[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Adonthell-commits] CVS: adonthell/src main.cc,1.51,1.52 mapcharacter.cc
From: |
Kai Sterker <address@hidden> |
Subject: |
[Adonthell-commits] CVS: adonthell/src main.cc,1.51,1.52 mapcharacter.cc,1.41,1.42 mapcharacter.h,1.52,1.53 py_object.cc,1.12,1.13 py_object.h,1.7,1.8 |
Date: |
Sat, 10 Aug 2002 18:02:03 -0400 |
Update of /cvsroot/adonthell/adonthell/src
In directory subversions:/tmp/cvs-serv24712
Modified Files:
main.cc mapcharacter.cc mapcharacter.h py_object.cc
py_object.h
Log Message:
MOVED path-following to C++ side
ADDED callback to notify of reaching end of path
FIXED crash on exit
Index: main.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/main.cc,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -r1.51 -r1.52
*** main.cc 10 Aug 2002 12:18:21 -0000 1.51
--- main.cc 10 Aug 2002 22:02:01 -0000 1.52
***************
*** 185,191 ****
gamedata::cleanup ();
- // cleanup event system
- event_handler::cleanup ();
-
// cleanup data
delete data::engine;
--- 185,188 ----
***************
*** 193,196 ****
--- 190,196 ----
delete data::the_player;
+ // cleanup event system
+ event_handler::cleanup ();
+
// shutdown python
// Cleanup the global namespace of python interpreter
Index: mapcharacter.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/mapcharacter.cc,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -r1.41 -r1.42
*** mapcharacter.cc 9 Aug 2002 20:01:26 -0000 1.41
--- mapcharacter.cc 10 Aug 2002 22:02:01 -0000 1.42
***************
*** 44,50 ****
schedule_activated = true;
action_activated = true;
schedule_args = NULL;
! action_args = NULL;
}
--- 44,53 ----
schedule_activated = true;
action_activated = true;
+ goal_reached_ = true;
schedule_args = NULL;
! action_args = NULL;
!
! callback = NULL;
}
***************
*** 77,81 ****
action_args = NULL;
schedule_file_ = "";
! action_file_ = "";
}
--- 80,86 ----
action_args = NULL;
schedule_file_ = "";
! action_file_ = "";
!
! if (callback) delete callback;
}
***************
*** 528,535 ****
--- 533,547 ----
mypath.dir = dir;
pathindex = 0;
+ goal_reached_ = false;
return mypath.calculate ();
}
+ void mapcharacter::set_callback (PyObject *cb, PyObject *args)
+ {
+ if (callback) delete callback;
+ callback = new py_callback (cb, args);
+ }
+
bool mapcharacter::follow_path ()
{
***************
*** 593,596 ****
--- 605,612 ----
}
+ // goal reached -> notify script (as the script might immediately
+ // set the next goal, we gotta set goal_reached_ before that)
+ goal_reached_ = true;
+ if (callback) callback->callback_func0 ();
return true;
}
***************
*** 600,604 ****
bool mapcharacter::goal_reached ()
{
! return (pathindex >= mypath.nbr_moves () && currentmove () < WALK_NORTH);
}
--- 616,621 ----
bool mapcharacter::goal_reached ()
{
! return goal_reached_;
! // return (pathindex >= mypath.nbr_moves () && currentmove () <
WALK_NORTH);
}
***************
*** 716,720 ****
{
update_move ();
! if (is_schedule_activated ()) schedule.run ();
if (previous_move != NO_MOVE && previous_move != current_move)
--- 733,739 ----
{
update_move ();
!
! if (is_schedule_activated () && schedule.has_attribute ("run"))
! schedule.run ();
if (previous_move != NO_MOVE && previous_move != current_move)
***************
*** 730,734 ****
saying = NULL;
}
!
return true;
}
--- 749,757 ----
saying = NULL;
}
!
! // if we have a goal, then go there!
! if (get_id () != "Player" && !goal_reached ())
! follow_path ();
!
return true;
}
Index: mapcharacter.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/mapcharacter.h,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -r1.52 -r1.53
*** mapcharacter.h 21 Feb 2002 20:28:13 -0000 1.52
--- mapcharacter.h 10 Aug 2002 22:02:01 -0000 1.53
***************
*** 39,42 ****
--- 39,43 ----
#include "mapsquare_walkable.h"
#include "py_object.h"
+ #include "py_callback.h"
#include "path.h"
#include "text_bubble.h"
***************
*** 591,594 ****
--- 592,596 ----
bool set_goal (u_int16 x, u_int16 y, u_int16 dir = NO_MOVE);
+ void set_callback (PyObject *callback, PyObject *args = NULL);
bool follow_path ();
bool goal_reached ();
***************
*** 836,839 ****
--- 838,842 ----
bool schedule_activated;
bool action_activated;
+ bool goal_reached_;
PyObject * schedule_args;
***************
*** 842,845 ****
--- 845,850 ----
string schedule_file_;
string action_file_;
+
+ py_callback *callback;
#ifndef SWIG
Index: py_object.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/py_object.cc,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** py_object.cc 28 Jun 2002 12:15:21 -0000 1.12
--- py_object.cc 10 Aug 2002 22:02:01 -0000 1.13
***************
*** 119,124 ****
PyObject *py_object::get_attribute (const string &name)
{
! if (!instance) return NULL;
! return PyObject_GetAttrString (instance, (char *) name.c_str ());
}
--- 119,134 ----
PyObject *py_object::get_attribute (const string &name)
{
! if (instance)
! return PyObject_GetAttrString (instance, (char *) name.c_str ());
! else
! return NULL;
! }
! // check for a certain attribute
! bool py_object::has_attribute (const std::string & name)
! {
! if (instance)
! return PyObject_HasAttrString (instance, (char *) name.c_str ());
! else
! return false;
}
Index: py_object.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/py_object.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** py_object.h 12 Apr 2002 15:35:40 -0000 1.7
--- py_object.h 10 Aug 2002 22:02:01 -0000 1.8
***************
*** 149,152 ****
--- 149,161 ----
PyObject* get_attribute (const string & name);
+ /**
+ * Tests whether the object contains a certain attribute (i.e. method
+ * or variable).
+ *
+ * @param name Name of the attribute to test for
+ * @return <b>true</b> if the attribute exists, <b>false</b> otherwise.
+ */
+ bool has_attribute (const std::string & name);
+
private:
/**
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Adonthell-commits] CVS: adonthell/src main.cc,1.51,1.52 mapcharacter.cc,1.41,1.42 mapcharacter.h,1.52,1.53 py_object.cc,1.12,1.13 py_object.h,1.7,1.8,
Kai Sterker <address@hidden> <=
- Prev by Date:
[Adonthell-commits] CVS: adonthell/doc/devel/figures map_obj_shape.eps,NONE,1.1.2.1 map_obj_shape.png,NONE,1.1.2.1 map_obj_shape.sk,NONE,1.1.2.1 map_obj_shape_extra.eps,NONE,1.1.2.1 map_obj_shape_extra.png,NONE,1.1.2.1 map_obj_shape_extra.sk,NONE,1.1.2.1 map_obj_sloap.eps,NONE,1.1.2.1 map_obj_sloap.png,NONE,1.1.2.1 map_obj_sloap.sk,NONE,1.1.2.1 vectors1.eps,NONE,1.1.2.1 vectors1.png,NONE,1.1.2.1 vectors1.sk,NONE,1.1.2.1 vectors2.eps,NONE,1.1.2.1 vectors2.png,NONE,1.1.2.1 vectors2.sk,NONE,1.1.2.1
- Next by Date:
[Adonthell-commits] CVS: wastesedge/scripts/schedules/mapcharacters alek.py,1.3,1.4 bjarn.py,1.4,1.5 erek.py,1.5,1.6 fellnir.py,1.4,1.5 frostbloom.py,1.4,1.5 janesta.py,1.3,1.4 jelom.py,1.3,1.4 lucia.py,1.5,1.6 oliver.py,1.5,1.6 orloth.py,1.4,1.5 sarin.py,1.3,1.4 silverhair.py,1.3,1.4 talan.py,1.3,1.4 tristan.py,1.4,1.5
- Previous by thread:
[Adonthell-commits] CVS: adonthell/doc/devel/figures map_obj_shape.eps,NONE,1.1.2.1 map_obj_shape.png,NONE,1.1.2.1 map_obj_shape.sk,NONE,1.1.2.1 map_obj_shape_extra.eps,NONE,1.1.2.1 map_obj_shape_extra.png,NONE,1.1.2.1 map_obj_shape_extra.sk,NONE,1.1.2.1 map_obj_sloap.eps,NONE,1.1.2.1 map_obj_sloap.png,NONE,1.1.2.1 map_obj_sloap.sk,NONE,1.1.2.1 vectors1.eps,NONE,1.1.2.1 vectors1.png,NONE,1.1.2.1 vectors1.sk,NONE,1.1.2.1 vectors2.eps,NONE,1.1.2.1 vectors2.png,NONE,1.1.2.1 vectors2.sk,NONE,1.1.2.1
- Next by thread:
[Adonthell-commits] CVS: wastesedge/scripts/schedules/mapcharacters alek.py,1.3,1.4 bjarn.py,1.4,1.5 erek.py,1.5,1.6 fellnir.py,1.4,1.5 frostbloom.py,1.4,1.5 janesta.py,1.3,1.4 jelom.py,1.3,1.4 lucia.py,1.5,1.6 oliver.py,1.5,1.6 orloth.py,1.4,1.5 sarin.py,1.3,1.4 silverhair.py,1.3,1.4 talan.py,1.3,1.4 tristan.py,1.4,1.5
- Index(es):