adonthell-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Adonthell-commits] CVS: adonthell/src dialog.cc,1.31,1.32 event.cc,1.17


From: Kai Sterker <address@hidden>
Subject: [Adonthell-commits] CVS: adonthell/src dialog.cc,1.31,1.32 event.cc,1.17,1.18 event.h,1.28,1.29 gamedata.cc,1.25,1.26 map_event.cc,1.2,1.3 mapcharacter.cc,1.46,1.47 mapcharacter.h,1.56,1.57 time_event.cc,1.3,1.4 time_event.h,1.5,1.6
Date: Tue, 20 Aug 2002 13:40:42 -0400

Update of /cvsroot/adonthell/adonthell/src
In directory subversions:/tmp/cvs-serv28106

Modified Files:
        dialog.cc event.cc event.h gamedata.cc map_event.cc 
        mapcharacter.cc mapcharacter.h time_event.cc time_event.h 
Log Message:
FIXED another memleak in dialog.cc
ADDED pause/resume methods to event system


Index: dialog.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/dialog.cc,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -r1.31 -r1.32
*** dialog.cc   18 Aug 2002 19:53:16 -0000      1.31
--- dialog.cc   20 Aug 2002 17:40:40 -0000      1.32
***************
*** 277,287 ****
          {
              begin = newstr.length () - strlen (start);
!             tmp = new char[newstr.length () - 4 + strlen 
(the_player->get_name().c_str ())];
!             strncpy (tmp, newstr.c_str (), begin);
!             tmp[begin] = 0;
!             strcat (tmp, the_player->get_name().c_str ());
!             strcat (tmp, start+5);
!             newstr = tmp;
! 
              continue;
          }
--- 277,285 ----
          {
              begin = newstr.length () - strlen (start);
!             string t (newstr, 0, begin);
!             t += the_player->get_name ();
!             t += (start+5);
!             
!             newstr = t;
              continue;
          }

Index: event.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/event.cc,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** event.cc    19 Aug 2002 19:57:28 -0000      1.17
--- event.cc    20 Aug 2002 17:40:40 -0000      1.18
***************
*** 13,17 ****
  */
  
- 
  /**
   * @file   event.cc
--- 13,16 ----
***************
*** 19,23 ****
   * 
   * @brief  Defines the base event class.
-  * 
   */
  
--- 18,21 ----
***************
*** 28,37 ****
  event::event ()
  {
!     Repeat = -1;
      Registered = false;
      Script = NULL;
      PyFunc = NULL;
      Args = NULL;
-     Action = ACTION_NOTHING;
      List = NULL;
  }
--- 26,36 ----
  event::event ()
  {
!     Action = ACTION_NOTHING;
      Registered = false;
+     Paused = false;
+     Repeat = -1;
      Script = NULL;
      PyFunc = NULL;
      Args = NULL;
      List = NULL;
  }
***************
*** 139,142 ****
--- 138,142 ----
      Type >> file;
      Repeat >> file;
+     Paused >> file;
      Action >> file;
      
***************
*** 175,178 ****
--- 175,179 ----
      // determine what event subclass to instanciate
      Repeat << file;
+     Paused << file;
      Action << file;
      

Index: event.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/event.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -r1.28 -r1.29
*** event.h     18 Aug 2002 19:53:16 -0000      1.28
--- event.h     20 Aug 2002 17:40:40 -0000      1.29
***************
*** 68,73 ****
   *
   * Events are used to notify when certain things happen during the game.
!  * They may either execute the "run" method of an exclusive python script
!  * or a simple python callback defined elsewhere.
   */ 
  class event
--- 68,73 ----
   *
   * Events are used to notify when certain things happen during the game.
!  * They may either execute the "run" method of an exclusive %python script
!  * or a simple %python callback defined elsewhere.
   */ 
  class event
***************
*** 208,211 ****
--- 208,235 ----
  
      /**
+      * @name Pausing / Resuming execution
+      */
+     //@{
+     
+     /**
+      * Disable the %event temporarily. As long as it in this state, the
+      * event will neither be executed, nor will its repeat-count change.
+      */
+     virtual void pause ()
+     {
+         Paused = true;
+     }
+     
+     /**
+      * Re-enable an %event that has been paused. 
+      */
+     virtual void resume ()
+     {
+         Paused = false;
+     }
+     
+     //@}
+ 
+     /**
       * @name Loading / Saving
       */
***************
*** 261,264 ****
--- 285,293 ----
       */
      bool Registered;
+     
+     /**
+      * Whether the %event temporarily disabled or not. 
+      */
+     bool Paused;
      
      /**

Index: gamedata.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gamedata.cc,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -r1.25 -r1.26
*** gamedata.cc 19 Aug 2002 19:57:28 -0000      1.25
--- gamedata.cc 20 Aug 2002 17:40:40 -0000      1.26
***************
*** 38,42 ****
  // File format versions of the various data files
  // *** Increase when changing file format! ***
! #define ENGINE_DAT_VER  4
  #define AUDIO_DAT_VER   2
  #define CHAR_DAT_VER    4
--- 38,42 ----
  // File format versions of the various data files
  // *** Increase when changing file format! ***
! #define ENGINE_DAT_VER  5
  #define AUDIO_DAT_VER   2
  #define CHAR_DAT_VER    4

Index: map_event.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/map_event.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** map_event.cc        18 Aug 2002 19:53:17 -0000      1.2
--- map_event.cc        20 Aug 2002 17:40:40 -0000      1.3
***************
*** 32,36 ****
  bool map_event::equals (const event* e)
  {
!     // we know that we've got an enter_event :)
      map_event *t = (map_event *) e;
  
--- 32,39 ----
  bool map_event::equals (const event* e)
  {
!     // if our event is paused, this will prevent it from getting executed
!     if (Paused) return false;
!     
!     // we know that we've got a map_event :)
      map_event *t = (map_event *) e;
  

Index: mapcharacter.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/mapcharacter.cc,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -r1.46 -r1.47
*** mapcharacter.cc     19 Aug 2002 19:57:28 -0000      1.46
--- mapcharacter.cc     20 Aug 2002 17:40:40 -0000      1.47
***************
*** 596,599 ****
--- 596,611 ----
  }
  
+ void mapcharacter::pause ()
+ {
+     for (vector<event*>::iterator i = Events.begin (); i != Events.end (); 
i++)
+         (*i)->pause ();
+ }
+ 
+ void mapcharacter::resume ()
+ {
+     for (vector<event*>::iterator i = Events.begin (); i != Events.end (); 
i++)
+         (*i)->resume ();
+ }
+ 
  bool mapcharacter::follow_path () 
  {
***************
*** 805,809 ****
  
      // if we have a goal, then go there!
!     if (get_id () != "Player" && !goal_reached ()) 
          follow_path ();
  
--- 817,821 ----
  
      // if we have a goal, then go there!
!     if (!goal_reached ()) 
          follow_path ();
  

Index: mapcharacter.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/mapcharacter.h,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -r1.56 -r1.57
*** mapcharacter.h      19 Aug 2002 19:57:28 -0000      1.56
--- mapcharacter.h      20 Aug 2002 17:40:40 -0000      1.57
***************
*** 658,661 ****
--- 658,674 ----
  
      /**
+      * Disable any events associated with this character. This will
+      * effectively stop all of its actions (at least if its schedule
+      * is event-driven as it should be.
+      */
+     void pause ();
+     
+     /**
+      * Re-enable the events associated with the character, thus
+      * 'awaking' it to life again. 
+      */
+     void resume ();
+ 
+     /**
       * Tell the character to do something. Will execute the given method
       * of the current schedule with the given arguments.

Index: time_event.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/time_event.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** time_event.cc       18 Aug 2002 19:53:17 -0000      1.3
--- time_event.cc       20 Aug 2002 17:40:40 -0000      1.4
***************
*** 28,31 ****
--- 28,32 ----
      Repeat = 1;
      Type = TIME_EVENT;
+     Absolute = absolute;
      Time = gamedate::parse_time (time);
      if (!absolute) Time += gamedate::time ();
***************
*** 73,76 ****
--- 74,95 ----
  }
  
+ // disable the event temporarily
+ void time_event::pause ()
+ {
+     event::pause ();
+     
+     // save time 'til relative event is raised
+     if (!Absolute) Time -= gamedate::time ();
+ }
+ 
+ // enable a previously paused event
+ void time_event::resume ()
+ {
+     event::resume ();
+     
+     // restore alarm time for relative event
+     if (!Absolute) Time += gamedate::time ();
+ }
+ 
  // Save time event to file
  void time_event::put_state (ogzstream& out) const
***************
*** 82,85 ****
--- 101,105 ----
      Time >> out;
      Interval >> out;
+     Absolute >> out;
  }
  
***************
*** 93,96 ****
--- 113,117 ----
      Time << in;
      Interval << in;
+     Absolute << in;
      
      return true;

Index: time_event.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/time_event.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** time_event.h        20 Aug 2002 09:25:20 -0000      1.5
--- time_event.h        20 Aug 2002 17:40:40 -0000      1.6
***************
*** 103,107 ****
      {
          time_event *e = (time_event *) evnt;
!         return Time <= e->time ();
      }
      
--- 103,107 ----
      {
          time_event *e = (time_event *) evnt;
!         return Time <= e->time () && !Paused;
      }
      
***************
*** 141,144 ****
--- 141,168 ----
  
      /**
+      * @name Pausing / Resuming execution
+      */
+     //@{
+     
+     /**
+      * Disable the %event temporarily. As long as it in this state, the
+      * event will neither be executed, nor will its repeat-count change.
+      *
+      * The alarm time of relative time events will be prolongued be the
+      * time the event was paused. Absolute events will only be deferred
+      * until they are resumed.
+      */
+     void pause ();
+     
+     /**
+      * Re-enable an %event that has been paused. 
+      *
+      * Absolute events that are past their alarm time are executed at once.
+      */
+     void resume ();
+     
+     //@}
+     
+     /**
       * Get the event's "alarm" time, i.e. the time when it needs to be
       * executed.
***************
*** 158,161 ****
--- 182,188 ----
      // time that lies between two occurances of the event
      u_int32 Interval;
+     
+     // whether the alarm time is relative or absolute
+     bool Absolute;
  #endif // SWIG
  };





reply via email to

[Prev in Thread] Current Thread [Next in Thread]