[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Adonthell-commits] CVS: adonthell/src schedule_data.h,NONE,1.1.2.1 Make
From: |
Kai Sterker <address@hidden> |
Subject: |
[Adonthell-commits] CVS: adonthell/src schedule_data.h,NONE,1.1.2.1 Makefile.am,1.80.2.29,1.80.2.30 schedule.cc,1.1.2.3,1.1.2.4 schedule.h,1.1.2.2,1.1.2.3 |
Date: |
Sun, 16 Jun 2002 06:59:33 -0400 |
Update of /cvsroot/adonthell/adonthell/src
In directory subversions:/tmp/cvs-serv25798
Modified Files:
Tag: Branch_road_to_0-4
Makefile.am schedule.cc schedule.h
Added Files:
Tag: Branch_road_to_0-4
schedule_data.h
Log Message:
ADDED schedule queue to allow schedules to overrule the manager script
***** Error reading new file: [Errno 2] No such file or directory:
'schedule_data.h'
Index: Makefile.am
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Makefile.am,v
retrieving revision 1.80.2.29
retrieving revision 1.80.2.30
diff -C2 -r1.80.2.29 -r1.80.2.30
*** Makefile.am 14 Jun 2002 08:55:41 -0000 1.80.2.29
--- Makefile.am 16 Jun 2002 10:59:30 -0000 1.80.2.30
***************
*** 51,54 ****
--- 51,55 ----
quest.h \
schedule.h \
+ schedule_data.h \
storage.h \
str_hash.h \
Index: schedule.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/schedule.cc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -r1.1.2.3 -r1.1.2.4
*** schedule.cc 15 Jun 2002 20:23:24 -0000 1.1.2.3
--- schedule.cc 16 Jun 2002 10:59:30 -0000 1.1.2.4
***************
*** 29,32 ****
--- 29,33 ----
Active = false;
Running = false;
+ Queue = NULL;
Alarm = NULL;
}
***************
*** 40,43 ****
--- 41,47 ----
delete Alarm;
}
+
+ if (Queue)
+ delete Queue;
}
***************
*** 49,54 ****
// no schedule running --> assign a new one
! if (!Running) Manager.run ();
!
// finally run schedule
Schedule.run ();
--- 53,73 ----
// no schedule running --> assign a new one
! if (!Running)
! {
! // if no schedule queued, let the manager script decide
! if (!Queue)
! Manager.run ();
!
! // otherwise use the queued script
! else
! {
! set_schedule (Queue->file, Queue->args);
! set_alarm (Queue->time, Queue->absolute);
!
! delete Queue;
! Queue = NULL;
! }
! }
!
// finally run schedule
Schedule.run ();
***************
*** 73,76 ****
--- 92,103 ----
}
+ // queue a schedule
+ void schedule::queue_schedule (string file, PyObject *args)
+ {
+ if (Queue) delete Queue;
+
+ Queue = new schedule_data (file, args);
+ }
+
// assign a (new) manager script
void schedule::set_manager (string file, PyObject *args)
***************
*** 113,116 ****
--- 140,156 ----
}
+ // set alarm for a queued schedule
+ void schedule::queue_alarm (string time, bool absolute)
+ {
+ if (!Queue)
+ {
+ fprintf (stderr, "*** schedule::queue_alarm: queue a schedule
first!\n");
+ return;
+ }
+
+ Queue->time = time;
+ Queue->absolute = absolute;
+ }
+
// save state to disk
void schedule::put_state (ogzstream &file)
***************
*** 135,138 ****
--- 175,189 ----
Alarm->put_state (file);
}
+
+ // save queue, if set
+ if (!Queue)
+ {
+ false >> file;
+ }
+ else
+ {
+ true >> file;
+ Queue->put_state (file);
+ }
}
***************
*** 140,144 ****
bool schedule::get_state (igzstream &file)
{
! bool has_alarm;
Active << file;
--- 191,195 ----
bool schedule::get_state (igzstream &file)
{
! bool has_feature;
Active << file;
***************
*** 160,165 ****
// restore alarm
! has_alarm << file;
! if (has_alarm)
{
Alarm = new time_event;
--- 211,216 ----
// restore alarm
! has_feature << file;
! if (has_feature)
{
Alarm = new time_event;
***************
*** 169,172 ****
--- 220,231 ----
// don't forget to register the alarm!
event_handler::register_event (Alarm);
+ }
+
+ // restore queue
+ has_feature << file;
+ if (has_feature)
+ {
+ Queue = new schedule_data;
+ Queue->get_state (file);
}
Index: schedule.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/Attic/schedule.h,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -r1.1.2.2 -r1.1.2.3
*** schedule.h 14 Jun 2002 08:55:41 -0000 1.1.2.2
--- schedule.h 16 Jun 2002 10:59:30 -0000 1.1.2.3
***************
*** 25,28 ****
--- 25,29 ----
#include "py_object.h"
#include "time_event.h"
+ #include "schedule_data.h"
/**
***************
*** 61,74 ****
/**
! * Assign a (new) %schedule script. This script is responsible for
! * the character's current activity.
*
* @param file Filename of the script to load.
* @param args Addional arguments to pass to the script constructor.
*/
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.
--- 62,92 ----
/**
! * Assign a (new) %schedule script, which is responsible for the
! * character's current activity. This method should only be used
! * from the manager %schedule. From within a %schedule script, use
! * queue_schedule () instead.
*
* @param file Filename of the script to load.
* @param args Addional arguments to pass to the script constructor.
+ *
+ * @sa queue_schedule ()
*/
void set_schedule (string file, PyObject * args = NULL);
/**
! * Set %schedule to use once the current one stops. Overrides
! * the %schedule otherwise chosen by the manager script. This
! * method allows a %schedule to decide upon the character's
! * next activity.
! *
! * @param file Filename of the script to load.
! * @param args Addional arguments to pass to the script constructor.
! *
! * @sa set_schedule ()
! */
! void queue_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.
***************
*** 93,97 ****
* inactive, it will cause the %character to freeze.
*
! * @param a \c true if the schedule should be activated, \c false
otherwise.
*/
void set_active (bool a) { Active = a; }
--- 111,116 ----
* inactive, it will cause the %character to freeze.
*
! * @param a \c true if the %schedule should be activated, \c false
! * otherwise.
*/
void set_active (bool a) { Active = a; }
***************
*** 109,115 ****
* Sets whether the %schedule is running or not. Once
* it stops running, the manager script will be executed to
! * determine a new schedule.
*
! * @param a \c false if the schedule should be stopped, \c true otherwise.
*/
void set_running (bool r) { Running = r; }
--- 128,134 ----
* Sets whether the %schedule is running or not. Once
* it stops running, the manager script will be executed to
! * determine a new %schedule.
*
! * @param a \c false if the %schedule should be stopped, \c true
otherwise.
*/
void set_running (bool r) { Running = r; }
***************
*** 128,132 ****
* whether the active %schedule is finished or not. This function
* makes use of the %event system and is much more efficient than
! * querying the current time within the schedule itself. It
* therefore is the preferred method of letting schedules run a
* fixed amount of gametime.
--- 147,151 ----
* whether the active %schedule is finished or not. This function
* makes use of the %event system and is much more efficient than
! * querying the current time within the %schedule itself. It
* therefore is the preferred method of letting schedules run a
* fixed amount of gametime.
***************
*** 144,148 ****
*/
void set_alarm (string time, bool absolute = false);
!
/**
* Restore the state of the %schedule class from disk. Loads
--- 163,181 ----
*/
void set_alarm (string time, bool absolute = false);
!
! /**
! * Set an alarm for a script set with queue_schedule (). This
! * needs to happen after the call to %queue_schedule, but before
! * calling set_running (false). If a %schedule is already running,
! * use set_alarm () instead.
! *
! * @param time The amount of time the %schedule should be active.
! * @param absolute whether the given time is relative to the current
! * time or an absolute hour of the current (or next) day.
! *
! * @sa set_alarm ()
! */
! void queue_alarm (string time, bool absolute = false);
!
/**
* Restore the state of the %schedule class from disk. Loads
***************
*** 178,181 ****
--- 211,217 ----
// set the alarm to execute the manager script at a certain time
time_event *Alarm;
+
+ // schedule to set instead of running manager script
+ schedule_data *Queue;
#endif // SWIG
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Adonthell-commits] CVS: adonthell/src schedule_data.h,NONE,1.1.2.1 Makefile.am,1.80.2.29,1.80.2.30 schedule.cc,1.1.2.3,1.1.2.4 schedule.h,1.1.2.2,1.1.2.3,
Kai Sterker <address@hidden> <=
- Prev by Date:
[Adonthell-commits] CVS: adonthell/src event.cc,1.12.2.4,1.12.2.5 event.h,1.25.2.4,1.25.2.5 event_handler_base.h,1.1.2.1,1.1.2.2 gamedate.cc,1.1.2.5,1.1.2.6 py_base.i,1.1.2.4,1.1.2.5 py_callback.h,1.3,1.3.2.1 schedule.cc,1.1.2.2,1.1.2.3 time_event.cc,1.1.2.4,1.1.2.5 time_event.h,1.1.2.6,1.1.2.7
- Next by Date:
[Adonthell-commits] CVS: adonthell/src event.cc,1.12.2.5,1.12.2.6 event.h,1.25.2.5,1.25.2.6 gamedate.cc,1.1.2.6,1.1.2.7 schedule.cc,1.1.2.4,1.1.2.5 schedule.h,1.1.2.3,1.1.2.4 time_event.cc,1.1.2.5,1.1.2.6
- Previous by thread:
[Adonthell-commits] CVS: adonthell/src event.cc,1.12.2.4,1.12.2.5 event.h,1.25.2.4,1.25.2.5 event_handler_base.h,1.1.2.1,1.1.2.2 gamedate.cc,1.1.2.5,1.1.2.6 py_base.i,1.1.2.4,1.1.2.5 py_callback.h,1.3,1.3.2.1 schedule.cc,1.1.2.2,1.1.2.3 time_event.cc,1.1.2.4,1.1.2.5 time_event.h,1.1.2.6,1.1.2.7
- Next by thread:
[Adonthell-commits] CVS: adonthell/src event.cc,1.12.2.5,1.12.2.6 event.h,1.25.2.5,1.25.2.6 gamedate.cc,1.1.2.6,1.1.2.7 schedule.cc,1.1.2.4,1.1.2.5 schedule.h,1.1.2.3,1.1.2.4 time_event.cc,1.1.2.5,1.1.2.6
- Index(es):