adonthell-commits
[Top][All Lists]
Advanced

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

[Adonthell-commits] CVS: adonthell/src Makefile.am,1.80.2.28,1.80.2.29 c


From: Kai Sterker <address@hidden>
Subject: [Adonthell-commits] CVS: adonthell/src Makefile.am,1.80.2.28,1.80.2.29 character.cc,1.9,1.9.2.1 character.h,1.24,1.24.2.1 event.cc,1.12.2.3,1.12.2.4 event.h,1.25.2.3,1.25.2.4 event_handler.cc,1.1.2.4,1.1.2.5 gamedata.cc,1.17,1.17.2.1 gamedata.h,1.11,1.11.2.1 gamedate.cc,1.1.2.4,1.1.2.5 gamedate.h,1.1.2.3,1.1.2.4 py_base.i,1.1.2.3,1.1.2.4 py_object.cc,1.10.2.2,1.10.2.3 py_object.h,1.6.2.2,1.6.2.3 schedtest.cc,1.1.2.1,1.1.2.2 schedule.cc,1.1.2.1,1.1.2.2 schedule.h,1.1.2.1,1.1.2.2 time_event.cc,1.1.2.3,1.1.2.4 time_event.h,1.1.2.5,1.1.2.6 time_event_handler.cc,1.1.2.3,1.1.2.4
Date: Fri, 14 Jun 2002 04:55:45 -0400

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

Modified Files:
      Tag: Branch_road_to_0-4
        Makefile.am character.cc character.h event.cc event.h 
        event_handler.cc gamedata.cc gamedata.h gamedate.cc gamedate.h 
        py_base.i py_object.cc py_object.h schedtest.cc schedule.cc 
        schedule.h time_event.cc time_event.h time_event_handler.cc 
Log Message:
FIXED various bugs in the schedule system


Index: Makefile.am
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Makefile.am,v
retrieving revision 1.80.2.28
retrieving revision 1.80.2.29
diff -C2 -r1.80.2.28 -r1.80.2.29
*** Makefile.am 10 Jun 2002 13:15:04 -0000      1.80.2.28
--- Makefile.am 14 Jun 2002 08:55:41 -0000      1.80.2.29
***************
*** 21,24 ****
--- 21,25 ----
  libbase_a_SOURCES = \
          character_base.cc \
+         character.cc \
          event.cc \
          event_handler.cc \
***************
*** 26,29 ****
--- 27,31 ----
          fileops.cc \
          game.cc \
+         gamedata.cc \
          gamedate.cc \
          gametime.cc \
***************
*** 36,39 ****
--- 38,42 ----
          yarg.cc \
          callback.h \
+         character.h \
          character_base.h \
          event.h \
***************
*** 43,46 ****
--- 46,50 ----
          fileops.h \
          game.h \
+         gamedata.h \
          gamedate.h \
          gametime.h \

Index: character.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/character.cc,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -C2 -r1.9 -r1.9.2.1
*** character.cc        2 Nov 2001 13:19:34 -0000       1.9
--- character.cc        14 Jun 2002 08:55:41 -0000      1.9.2.1
***************
*** 28,32 ****
  character * data::the_player = NULL;
  
! character::character() : mapcharacter ()
  {
  }
--- 28,32 ----
  character * data::the_player = NULL;
  
! character::character()
  {
  }

Index: character.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/character.h,v
retrieving revision 1.24
retrieving revision 1.24.2.1
diff -C2 -r1.24 -r1.24.2.1
*** character.h 2 Nov 2001 13:19:34 -0000       1.24
--- character.h 14 Jun 2002 08:55:41 -0000      1.24.2.1
***************
*** 28,32 ****
  
  #include "storage.h"
! #include "mapcharacter.h"
  
  /**
--- 28,33 ----
  
  #include "storage.h"
! #include "character_base.h"
! #include "schedule.h"
  
  /**
***************
*** 34,38 ****
   * 
   */ 
! class character : public mapcharacter
  {
  public:
--- 35,39 ----
   * 
   */ 
! class character : public character_base
  {
  public:
***************
*** 48,51 ****
--- 49,58 ----
       */ 
      ~character();
+ 
+     void set_schedule (schedule *s) { Schedule = s; }
+     schedule *get_schedule ()       { return Schedule; }
+ 
+ private:
+     schedule *Schedule;
  };
  

Index: event.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/event.cc,v
retrieving revision 1.12.2.3
retrieving revision 1.12.2.4
diff -C2 -r1.12.2.3 -r1.12.2.4
*** event.cc    8 Jun 2002 21:15:35 -0000       1.12.2.3
--- event.cc    14 Jun 2002 08:55:41 -0000      1.12.2.4
***************
*** 24,27 ****
--- 24,35 ----
  #include "event.h"
  
+ // constructor
+ event::event ()
+ {
+     Repeat = -1;
+     Shared = false;
+     Args = NULL;
+ }
+ 
  // destructor
  event::~event ()

Index: event.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/event.h,v
retrieving revision 1.25.2.3
retrieving revision 1.25.2.4
diff -C2 -r1.25.2.3 -r1.25.2.4
*** event.h     10 Jun 2002 13:15:04 -0000      1.25.2.3
--- event.h     14 Jun 2002 08:55:41 -0000      1.25.2.4
***************
*** 52,55 ****
--- 52,60 ----
  {
  public:
+     /**
+      * Constructor
+      */
+     event ();
+ 
      /** 
       * Destructor.
***************
*** 84,88 ****
          return Repeat;
      }
!     
      /**
       * @name Event Handling
--- 89,105 ----
          return Repeat;
      }
! 
!     /**
!      * Set whether this event should be repeated. A number greater than 0
!      * will repeat the event that many times, a number less than 0 will
!      * repeat the event forever. A number equal to 0 won't repeat the event.
!      *
!      *  @param count How often the event should be repeated.
!      */
!     void set_repeat (s_int32 count)
!     {
!         Repeat = count;
!     }
! 
      /**
       * @name Event Handling

Index: event_handler.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/event_handler.cc,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -r1.1.2.4 -r1.1.2.5
*** event_handler.cc    10 Jun 2002 13:15:04 -0000      1.1.2.4
--- event_handler.cc    14 Jun 2002 08:55:41 -0000      1.1.2.5
***************
*** 47,51 ****
  }
  
! // Register a event with it's script
  void event_handler::cleanup ()
  {
--- 47,51 ----
  }
  
! // Clear the registered handlers
  void event_handler::cleanup ()
  {

Index: gamedata.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gamedata.cc,v
retrieving revision 1.17
retrieving revision 1.17.2.1
diff -C2 -r1.17 -r1.17.2.1
*** gamedata.cc 26 Jan 2002 21:52:07 -0000      1.17
--- gamedata.cc 14 Jun 2002 08:55:41 -0000      1.17.2.1
***************
*** 30,34 ****
  #include <sys/stat.h>
  
! #include "audio.h"
  #include "gamedata.h"
  #include "python_class.h"
--- 30,34 ----
  #include <sys/stat.h>
  
! // #include "audio.h"
  #include "gamedata.h"
  #include "python_class.h"
***************
*** 177,180 ****
--- 177,181 ----
  bool gamedata::load_mapengine (u_int32 pos) 
  {
+ /*
      igzstream in;
      
***************
*** 202,206 ****
      
      in.close (); 
! 
      return true; 
  }
--- 203,207 ----
      
      in.close (); 
! */
      return true; 
  }
***************
*** 208,211 ****
--- 209,213 ----
  bool gamedata::load_audio (u_int32 pos)
  {
+ /*
      igzstream in;
      string filepath;
***************
*** 232,236 ****
      
      in.close (); 
! 
      return true; 
  }
--- 234,238 ----
      
      in.close (); 
! */
      return true; 
  }
***************
*** 362,366 ****
      vnbr >> file; 
      file.close ();
!     
      // Save mapengine state
      filepath = gdata->directory(); 
--- 364,368 ----
      vnbr >> file; 
      file.close ();
! /*
      // Save mapengine state
      filepath = gdata->directory(); 
***************
*** 406,410 ****
      gdata->put (file);
      file.close ();
!     
      // only now it is safe to add the new record to the array
      if (pos >= saves.size ()) saves.push_back (gdata);
--- 408,412 ----
      gdata->put (file);
      file.close ();
! */
      // only now it is safe to add the new record to the array
      if (pos >= saves.size ()) saves.push_back (gdata);
***************
*** 514,518 ****
  {
      // stop the music
!     audio::fade_out_background (500);
      
      // delete all characters
--- 516,520 ----
  {
      // stop the music
!     // audio::fade_out_background (500);
      
      // delete all characters
***************
*** 520,524 ****
      for (itc = data::characters.begin (); itc != data::characters.end (); 
itc++) 
      {
!         itc->second->remove_from_map (); 
          delete itc->second;
      }
--- 522,526 ----
      for (itc = data::characters.begin (); itc != data::characters.end (); 
itc++) 
      {
!         // itc->second->remove_from_map ();
          delete itc->second;
      }

Index: gamedata.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gamedata.h,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -C2 -r1.11 -r1.11.2.1
*** gamedata.h  31 Dec 2001 16:55:46 -0000      1.11
--- gamedata.h  14 Jun 2002 08:55:41 -0000      1.11.2.1
***************
*** 34,38 ****
  #include "quest.h"
  #include "character.h"
! #include "adonthell.h"
  
  /**
--- 34,38 ----
  #include "quest.h"
  #include "character.h"
! // #include "adonthell.h"
  
  /**
***************
*** 340,348 ****
       * @return Pointer to the global game engine.
       */
      static adonthell* engine ()
      {
          return data::engine;
      }
! 
  private:
  #ifndef SWIG
--- 340,349 ----
       * @return Pointer to the global game engine.
       */
+ /*
      static adonthell* engine ()
      {
          return data::engine;
      }
! */
  private:
  #ifndef SWIG

Index: gamedate.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/gamedate.cc,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -r1.1.2.4 -r1.1.2.5
*** gamedate.cc 10 Jun 2002 13:15:04 -0000      1.1.2.4
--- gamedate.cc 14 Jun 2002 08:55:41 -0000      1.1.2.5
***************
*** 91,92 ****
--- 91,150 ----
      return Time % 60; 
  }
+ 
+ // convert the time string to gametime minutes
+ u_int32 gamedate::parse_time (const string & time)
+ {
+     u_int32 minutes = 0, number = 0;
+     char num[2] = "0";
+ 
+     for (u_int32 i = 0; i < time.length (); i++)
+     {
+         // got a number
+         if (isdigit (time[i]))
+         {
+             num[0] = time[i];
+             number = 10 * number + atoi (num);
+         }
+         // got a letter
+         else
+         {
+             switch (time[i])
+             {
+                 // weeks
+                 case 'w':
+                 {
+                     minutes += number * DAYS_PER_WEEK * HOURS_PER_DAY * 60;
+                     break;
+                 }
+                 // days
+                 case 'd':
+                 {
+                     minutes += number * HOURS_PER_DAY * 60;
+                     break;
+                 }
+                 // hours
+                 case 'h':
+                 {
+                     minutes += number * 60;
+                     break;
+                 }
+                 // minutes
+                 case 'm':
+                 {
+                     minutes += number;
+                     break;
+                 }
+                 // error
+                 default:
+                 {
+                     fprintf (stderr, "*** time_event::parse_date: Unknown 
time specifier '%c'\n", time[i]);
+                     break;
+                 }
+             }
+ 
+             number = 0;
+         }
+     }
+ 
+     return minutes;
+ }

Index: gamedate.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/gamedate.h,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -r1.1.2.3 -r1.1.2.4
*** gamedate.h  10 Jun 2002 13:15:04 -0000      1.1.2.3
--- gamedate.h  14 Jun 2002 08:55:41 -0000      1.1.2.4
***************
*** 80,84 ****
       */
      static u_int16 minute ();
!     
      /**
       * Load the state of the %gamedate class from disk
--- 80,95 ----
       */
      static u_int16 minute ();
! 
!     /**
!      * convert the time string to gametime minutes. The time string
!      * has the format "<number>X", where X may be (w)eek, (d)ay,
!      * (h)our or (m)inute. Several such pairs can be concatenated.
!      * Valid examples are "1w1d1h", "30m1h" but also "1h1h".
!      *
!      * @param time The time format string.
!      * @return The time represented by the string in minutes.
!      */
!     static u_int32 parse_time (const string & time);
! 
      /**
       * Load the state of the %gamedate class from disk

Index: py_base.i
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/py_base.i,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -r1.1.2.3 -r1.1.2.4
*** py_base.i   10 Jun 2002 13:15:04 -0000      1.1.2.3
--- py_base.i   14 Jun 2002 08:55:41 -0000      1.1.2.4
***************
*** 7,13 ****
--- 7,17 ----
  #include "event.h"
  #include "fileops.h"
+ #include "gamedata.h"
  #include "gamedate.h"
  #include "gametime.h"
  #include "schedule.h"
+ #include "storage.h"
+ #include "character_base.h"
+ #include "character.h"
  
  %}
***************
*** 18,22 ****
--- 22,30 ----
  %include "game.h"
  %include "fileops.h"
+ %include "gamedata.h"
  %include "gametime.h"
  %include "gamedate.h"
  %include "schedule.h"
+ %include "storage.h"
+ %include "character_base.h"
+ %include "character.h"

Index: py_object.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/py_object.cc,v
retrieving revision 1.10.2.2
retrieving revision 1.10.2.3
diff -C2 -r1.10.2.2 -r1.10.2.3
*** py_object.cc        10 Jun 2002 13:15:04 -0000      1.10.2.2
--- py_object.cc        14 Jun 2002 08:55:41 -0000      1.10.2.3
***************
*** 139,142 ****
--- 139,151 ----
  }
  
+ // check for a certain attribute
+ bool py_object::has_attribute (const string & name)
+ {
+     if (Instance)
+         return PyObject_HasAttrString (Instance, (char *) name.c_str ());
+     else
+         return false;
+ }
+ 
  // Save internal state of the script to disk
  void py_object::put_state (ogzstream &file)

Index: py_object.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/py_object.h,v
retrieving revision 1.6.2.2
retrieving revision 1.6.2.3
diff -C2 -r1.6.2.2 -r1.6.2.3
*** py_object.h 8 Jun 2002 21:15:35 -0000       1.6.2.2
--- py_object.h 14 Jun 2002 08:55:41 -0000      1.6.2.3
***************
*** 156,159 ****
--- 156,168 ----
  
      /**
+      * 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 string & name);
+ 
+     /**
       * Saves the state of the associated script, so that it can be
       * completely restored later on. Writes the file- and class name

Index: schedtest.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/schedtest.cc,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** schedtest.cc        10 Jun 2002 13:15:04 -0000      1.1.2.1
--- schedtest.cc        14 Jun 2002 08:55:41 -0000      1.1.2.2
***************
*** 4,7 ****
--- 4,8 ----
  #include "event_handler.h"
  #include "input_manager.h"
+ #include "character.h"
  #include "gametime.h"
  #include "gamedate.h"
***************
*** 16,19 ****
--- 17,21 ----
  // our global test scbedule
  schedule myschedule;
+ character myself;
  
  // tell the program to quit
***************
*** 86,92 ****
      // a clock telling every hour
      time_event clock ("1h");
!     clock.repeat ("1h");
      clock.set_script ("clock");
      event_handler::register_event (&clock);
  
      // mainloop
--- 88,104 ----
      // a clock telling every hour
      time_event clock ("1h");
!     clock.set_repeat ("1h");
      clock.set_script ("clock");
      event_handler::register_event (&clock);
+ 
+     // create a character for the schedule
+     myself.set_name ("Kai Sterker");
+     myself.set_schedule (&myschedule);
+     data::characters[myself.get_id ().c_str ()] = &myself;
+ 
+     // all we need to do is setting the manager script;
+     PyObject *args = Py_BuildValue ("(s)", myself.get_id ().c_str ());
+     myschedule.set_manager ("student", args);
+     myschedule.set_active (true);
  
      // mainloop

Index: schedule.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/schedule.cc,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** schedule.cc 8 Jun 2002 21:15:35 -0000       1.1.2.1
--- schedule.cc 14 Jun 2002 08:55:41 -0000      1.1.2.2
***************
*** 21,24 ****
--- 21,25 ----
   
  #include "schedule.h"
+ #include "gamedate.h"
  #include "event_handler.h"
  
***************
*** 49,53 ****
      // no schedule running --> assign a new one
      if (!Running) Manager.run ();
!     
      // finally run schedule
      Schedule.run ();
--- 50,54 ----
      // no schedule running --> assign a new one
      if (!Running) Manager.run ();
! 
      // finally run schedule
      Schedule.run ();
***************
*** 82,86 ****
  
  // set the alarm
! void schedule::set_alarm (string time)
  {
      // get rid of the current alarm
--- 83,87 ----
  
  // set the alarm
! void schedule::set_alarm (string time, bool absolute)
  {
      // get rid of the current alarm
***************
*** 91,96 ****
      }
  
!     // create and register the new alarm    
!     Alarm = new time_event (time);
      Alarm->set_shared_script (Manager);
      event_handler::register_event (Alarm);
--- 92,113 ----
      }
  
!     // absolute hour of the day
!     if (absolute)
!     {
!         char day[16];
! 
!         // if that hour has already passed today, assume the
!         // same hour tomorrow
!         if (gamedate::parse_time (time) > (u_int32) gamedate::hour () * 60)
!             sprintf (day, "%id", gamedate::day ());
!         else
!             sprintf (day, "%id", gamedate::day () + 1);
! 
!         time += day;
!     }
! 
!     // create and register the new alarm
!     Alarm = new time_event (time, absolute);
!     Alarm->event::set_repeat (0);
      Alarm->set_shared_script (Manager);
      event_handler::register_event (Alarm);

Index: schedule.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/schedule.h,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** schedule.h  8 Jun 2002 21:15:35 -0000       1.1.2.1
--- schedule.h  14 Jun 2002 08:55:41 -0000      1.1.2.2
***************
*** 68,72 ****
       */
      void set_schedule (string file, PyObject * args = NULL);
!     
      /** 
       * Returns whether the %schedule is active or not. As long as the
--- 68,82 ----
       */
      void set_schedule (string file, PyObject * args = NULL);
! 
!     /**
!      * Call this to explicitly clear the attached schedule. This will
!      * also run the destructor (__del__ method) of the script, if it
!      * exists.
!      */
!     void clear_schedule ()
!     {
!         Schedule.clear ();
!     }
! 
      /** 
       * Returns whether the %schedule is active or not. As long as the
***************
*** 127,133 ****
       *
       * @param time The amount of time the %schedule should be active,
!      *      in the format used by time_event::time_event (). 
       */
!     void set_alarm (string time);
                  
      /**
--- 137,147 ----
       *
       * @param time The amount of time the %schedule should be active,
!      *      in the format used by time_event::time_event ().
!      * @param absolute If <b>true</b>, the current day will be added
!      *      to the time. For example, set_alarm ("14h", true) means
!      *      "today at 14:00", whereas set_alarm ("14h", false) means
!      *      "14 hours from now on".
       */
!     void set_alarm (string time, bool absolute = false);
                  
      /**

Index: time_event.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/time_event.cc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -r1.1.2.3 -r1.1.2.4
*** time_event.cc       8 Jun 2002 21:15:35 -0000       1.1.2.3
--- time_event.cc       14 Jun 2002 08:55:41 -0000      1.1.2.4
***************
*** 29,40 ****
      Repeat = 0;
      Type = TIME_EVENT;
!     Time = parse_time (time);
      if (!absolute) Time += gamedate::time ();
  }
  
  // specify the interval between two occurances of the event
! void time_event::repeat (const string & interval, s_int32 count)
  {
!     Interval = parse_time (interval);
      Repeat = count;
  }
--- 29,40 ----
      Repeat = 0;
      Type = TIME_EVENT;
!     Time = gamedate::parse_time (time);
      if (!absolute) Time += gamedate::time ();
  }
  
  // specify the interval between two occurances of the event
! void time_event::set_repeat (const string & interval, s_int32 count)
  {
!     Interval = gamedate::parse_time (interval);
      Repeat = count;
  }
***************
*** 47,52 ****
      Script.run ();
      
-     if (Repeat > 0) Repeat--;
-      
      // when the script needs be repeated, do so.
      if (Repeat != 0) Time += Interval;
--- 47,50 ----
***************
*** 75,135 ****
      
      return true;
- }
- 
- // convert the time string to gametime minutes
- u_int32 time_event::parse_time (const string & time)
- {
-     u_int32 minutes = 0, number = 0;
-     char num[2] = "0";
-     
-     for (u_int32 i = 0; i < time.length (); i++)
-     {
-         // got a number
-         if (isdigit (time[i]))
-         {
-             num[0] = time[i];
-             number = 10 * number + atoi (num);
-         }
-         // got a letter
-         else
-         {
-             switch (time[i])
-             {
-                 // weeks
-                 case 'w':
-                 {
-                     minutes += number * DAYS_PER_WEEK * HOURS_PER_DAY * 60;
-                     break;
-                 }
-                 // days
-                 case 'd':
-                 {
-                     minutes += number * HOURS_PER_DAY * 60;
-                     break;
-                 }
-                 // hours
-                 case 'h':
-                 {
-                     minutes += number * 60;
-                     break;
-                 }
-                 // minutes
-                 case 'm':
-                 {
-                     minutes += number;
-                     break;
-                 }
-                 // error
-                 default:
-                 {
-                     fprintf (stderr, "*** time_event::parse_date: Unknown 
time specifier '%c'\n", time[i]);
-                     break;
-                 }
-             }
- 
-             number = 0;
-         }
-     }
- 
-     return minutes;
  }
--- 73,75 ----

Index: time_event.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/time_event.h,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -r1.1.2.5 -r1.1.2.6
*** time_event.h        10 Jun 2002 13:15:04 -0000      1.1.2.5
--- time_event.h        14 Jun 2002 08:55:41 -0000      1.1.2.6
***************
*** 56,62 ****
  #ifndef SWIG
      /**
!      * Standart constructor.
       */
!     time_event ()
      {
          Type = TIME_EVENT;
--- 56,62 ----
  #ifndef SWIG
      /**
!      * Standard constructor.
       */
!     time_event () : event ()
      {
          Type = TIME_EVENT;
***************
*** 83,87 ****
       *      Specify -1 to repeat it an unlimited number of times.
       */
!     void repeat (const string & interval, s_int32 count = -1);
      //@}
      
--- 83,87 ----
       *      Specify -1 to repeat it an unlimited number of times.
       */
!     void set_repeat (const string & interval, s_int32 count = -1);
      //@}
      
***************
*** 134,138 ****
  
      //@}
!     
      /**
       * Get the event's "alarm" time, i.e. the time when it needs to be
--- 134,138 ----
  
      //@}
! 
      /**
       * Get the event's "alarm" time, i.e. the time when it needs to be
***************
*** 145,154 ****
          return Time;
      }
!     
  private:
  #ifndef SWIG
-     // convert the time string to gametime minutes
-     u_int32 parse_time (const string & time);
- 
      // the time when the event shall be triggered
      u_int32 Time;
--- 145,151 ----
          return Time;
      }
! 
  private:
  #ifndef SWIG
      // the time when the event shall be triggered
      u_int32 Time;

Index: time_event_handler.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/time_event_handler.cc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -r1.1.2.3 -r1.1.2.4
*** time_event_handler.cc       10 Jun 2002 13:15:04 -0000      1.1.2.3
--- time_event_handler.cc       14 Jun 2002 08:55:41 -0000      1.1.2.4
***************
*** 21,47 ****
  
  #include <algorithm>
  #include "time_event.h"
  #include "time_event_handler.h"
  
- // function returning a new time event
- 
  // See whether a matching event is registered and execute the
  // according script(s) 
  void time_event_handler::raise_event (const event& e)
  {
!     // no time event registered
!     if (Events.empty ()) return;
!     
      // As long as matching events are in the list
!     while (Events.front ()->equals (e))
      {
!         event *evt = Events.front ();
!         evt->execute (e);
!         
!         // remove event
          Events.erase (Events.begin ());
!         
          // re-register event if it needs be repeated
!         if (evt->repeat ()) register_event (evt);
      }
      
--- 21,51 ----
  
  #include <algorithm>
+ #include "gamedate.h"
  #include "time_event.h"
  #include "time_event_handler.h"
  
  // See whether a matching event is registered and execute the
  // according script(s) 
  void time_event_handler::raise_event (const event& e)
  {
!     s_int32 repeat;
!     event *evt;
! 
      // As long as matching events are in the list
!     while (!Events.empty () && Events.front ()->equals (e))
      {
!         evt = Events.front ();
! 
!         // Note: we need to get the value of 'repeat' here, as
!         // executing the event might destroy it
!         repeat = evt->repeat ();
! 
!         // remove event before executing (see above)
          Events.erase (Events.begin ());
! 
!         evt->execute (e);
! 
          // re-register event if it needs be repeated
!         if (repeat) register_event (evt);
      }
      
***************
*** 64,67 ****
--- 68,78 ----
  void time_event_handler::register_event (event *e)
  {
+     // make sure the event is recent enough
+     if (((time_event *) e)->time () < gamedate::time ())
+     {
+         fprintf (stderr, "*** time_event_handler::register_event: event older 
than current time!\n");
+         return;
+     }
+ 
      vector<event*>::iterator i = Events.begin ();
  
***************
*** 73,77 ****
          i++;
      }
!     
      Events.insert (i, e);
  }
--- 84,88 ----
          i++;
      }
! 
      Events.insert (i, e);
  }




reply via email to

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