Pol  Revision:cb584c9
osmod.h
Go to the documentation of this file.
1 
8 #ifndef BSCRIPT_OSEMOD_H
9 #define BSCRIPT_OSEMOD_H
10 
11 #ifndef BSCRIPT_EXECMODL_H
12 #include "../../bscript/execmodl.h"
13 #endif
14 
15 #include <ctime>
16 #include <map>
17 #include <queue>
18 
19 #include "../globals/script_internals.h"
20 #include "../polclock.h"
21 #include "../uoexhelp.h"
22 
23 namespace Pol
24 {
25 namespace Bscript
26 {
27 class BObject;
28 class BObjectImp;
29 class Executor;
30 template <class T>
31 class TmplExecutorModule;
32 } // namespace Bscript
33 namespace Mobile
34 {
35 class Character;
36 } // namespace Mobile
37 } // namespace Pol
38 
39 namespace Pol
40 {
41 namespace Core
42 {
43 class UOExecutor;
44 
45 void run_ready( void );
46 void check_blocked( polclock_t* pclocksleft );
47 void deschedule_executor( UOExecutor* ex );
49 }
50 namespace Module
51 {
52 class OSExecutorModule : public Bscript::TmplExecutorModule<OSExecutorModule>
53 {
54 public:
55  bool signal_event( Bscript::BObjectImp* eventimp );
56  void suspend();
57  void revive();
58 
59  explicit OSExecutorModule( Bscript::Executor& exec );
61 
62  bool critical;
63  unsigned char priority;
65 
66  void SleepFor( int secs );
67  void SleepForMs( int msecs );
68 
69  unsigned int pid() const;
70  bool blocked() const;
71 
72  bool in_debugger_holdlist() const;
73  void revive_debugged();
74  Bscript::BObjectImp* clear_event_queue(); // DAVE
75 protected:
76  bool getCharacterParam( unsigned param, Mobile::Character*& chrptr );
77 
79 
81  Bscript::BObjectImp* getpid();
82  Bscript::BObjectImp* getprocess();
83  Bscript::BObjectImp* sleep();
84  Bscript::BObjectImp* sleepms();
85  Bscript::BObjectImp* wait_for_event();
86  Bscript::BObjectImp* events_waiting();
87  Bscript::BObjectImp* set_critical();
88  Bscript::BObjectImp* is_critical();
89 
91  Bscript::BObjectImp* start_skill_script();
93  Bscript::BObjectImp* run_script();
94  Bscript::BObjectImp* mf_parameter();
95  Bscript::BObjectImp* mf_set_debug();
96  Bscript::BObjectImp* mf_Log();
97  Bscript::BObjectImp* mf_system_rpm();
98  Bscript::BObjectImp* mf_set_priority();
99  Bscript::BObjectImp* mf_unload_scripts();
100  Bscript::BObjectImp* mf_set_script_option();
101  Bscript::BObjectImp* mf_set_event_queue_size(); // DAVE 11/24
102  Bscript::BObjectImp* mf_OpenURL();
103  Bscript::BObjectImp* mf_OpenConnection();
104  Bscript::BObjectImp* mf_debugger();
105  Bscript::BObjectImp* mf_HTTPRequest();
106 
107  Bscript::BObjectImp* mf_clear_event_queue(); // DAVE
108 
109  Bscript::BObjectImp* mf_performance_diff();
110 
111  bool blocked_;
112  Core::polclock_t sleep_until_clock_; // 0 if wait forever
113 
114  enum
115  {
119  DEBUGGER_LIST
120  } in_hold_list_;
122 
123  unsigned int pid_;
124 
126  {
129  WAIT_UNKNOWN
130  } wait_type;
131 
132  enum
133  {
134  MAX_EVENTQUEUE_SIZE = 20
135  };
136  unsigned short max_eventqueue_size; // DAVE 11/24
137  std::queue<Bscript::BObjectImp*> events_;
138 
139 
140  friend class NPCExecutorModule;
141  friend void step_scripts( void );
142  // friend void Core::run_ready( void );
143  friend class Core::ScriptScheduler; // TODO: REMOVE THIS AS SOON AS POSSIBLE!!!
144  friend void Core::check_blocked( Core::polclock_t* pclocksleft );
145  friend void new_check_blocked( void );
146  friend void Core::deschedule_executor( Core::UOExecutor* ex );
148 
149 
150  void event_occurred( Bscript::BObject event );
151 };
152 
153 inline bool OSExecutorModule::getCharacterParam( unsigned param, Mobile::Character*& chrptr )
154 {
155  return Core::getCharacterParam( exec, param, chrptr );
156 }
157 
158 inline bool OSExecutorModule::blocked() const
159 {
160  return blocked_;
161 }
162 }
163 }
164 
165 #endif
unsigned short max_eventqueue_size
Definition: osmod.h:136
void deschedule_executor(UOExecutor *ex)
u64 pid
Definition: osmod.cpp:945
bool getCharacterParam(Bscript::Executor &exec, unsigned param, Mobile::Character *&chrptr)
Definition: uoexhelp.cpp:140
HoldList::iterator TimeoutHandle
bool getCharacterParam(unsigned param, Mobile::Character *&chrptr)
Definition: osmod.h:153
Core::TimeoutHandle hold_itr_
Definition: osmod.h:121
polclock_t calc_script_clocksleft(polclock_t now)
Definition: scrsched.cpp:111
std::queue< Bscript::BObjectImp * > events_
Definition: osmod.h:137
int polclock_t
Definition: polclock.h:26
Core::polclock_t sleep_until_clock_
Definition: osmod.h:112
void check_blocked(polclock_t *pclocksleft)
Definition: scrsched.cpp:71
void run_ready(void)
Definition: scrsched.cpp:65
unsigned char priority
Definition: osmod.h:63
BObjectImp * create_debug_context()
Definition: poldbg.cpp:267
void step_scripts(polclock_t *clocksleft, bool *pactivity)
Definition: scrsched.cpp:133
bool run_script_to_completion(const char *filename, Bscript::BObjectImp *parameter)
Definition: scrsched.cpp:333
void start_script(const char *filename, Bscript::BObjectImp *param0, Bscript::BObjectImp *param1)
Definition: scrsched.cpp:150
Definition: berror.cpp:12
bool blocked() const
Definition: osmod.h:158