Pol  Revision:cb584c9
uoscrobj.h
Go to the documentation of this file.
1 
11 #ifndef UOSCROBJ_H
12 #define UOSCROBJ_H
13 
14 #include <stddef.h>
15 
16 #include "../bscript/bobject.h"
17 #include "../bscript/bstruct.h"
18 #include "../clib/compilerspecifics.h"
19 #include "../clib/passert.h"
20 #include "../clib/rawtypes.h"
21 #include "../clib/refptr.h"
22 #include "../clib/weakptr.h"
23 #include "eventid.h"
24 #include "gameclck.h"
25 #include "globals/state.h"
26 #include "mobile/charactr.h"
27 #include "multi/boat.h"
28 #include "network/client.h"
29 #include "uobjcnt.h"
30 
31 #ifndef ITEM_H
32 #include "item/item.h"
33 #endif
34 
35 
36 namespace Pol
37 {
38 namespace Bscript
39 {
40 class Executor;
41 } // namespace Bscript
42 namespace Core
43 {
44 class UContainer;
45 } // namespace Core
46 namespace Mobile
47 {
48 class NPC;
49 } // namespace Mobile
50 namespace Multi
51 {
52 class UMulti;
53 } // namespace Multi
54 } // namespace Pol
55 
56 namespace Pol
57 {
58 namespace Module
59 {
60 extern Bscript::BApplicObjType eitemrefobjimp_type;
61 extern Bscript::BApplicObjType echaracterrefobjimp_type;
62 extern Bscript::BApplicObjType echaracterequipobjimp_type;
63 extern Bscript::BApplicObjType euboatrefobjimp_type;
64 extern Bscript::BApplicObjType emultirefobjimp_type;
65 extern Bscript::BApplicObjType storage_area_type;
66 extern Bscript::BApplicObjType menu_type;
67 extern Bscript::BApplicObjType eclientrefobjimp_type;
68 
69 class ECharacterRefObjImp : public Bscript::BApplicObj<Core::CharacterRef>
70 {
72 
73 public:
75  : BApplicObj<Core::CharacterRef>( &echaracterrefobjimp_type, Core::CharacterRef( chr ) )
76  {
78  passert( obj_->ref_counted_count() > 1 );
79  }
81  virtual const char* typeOf() const POL_OVERRIDE;
82  virtual u8 typeOfInt() const POL_OVERRIDE;
83  virtual Bscript::BObjectImp* copy() const POL_OVERRIDE;
84  virtual Bscript::BObjectImp* call_method( const char* methodname,
86  virtual Bscript::BObjectImp* call_method_id( const int id, Bscript::Executor& ex,
87  bool forcebuiltin = false ) POL_OVERRIDE;
88  virtual Bscript::BObjectRef get_member( const char* membername ) POL_OVERRIDE;
89  virtual Bscript::BObjectRef get_member_id( const int id ) POL_OVERRIDE;
90  virtual Bscript::BObjectRef set_member( const char* membername, Bscript::BObjectImp* value,
91  bool copy ) POL_OVERRIDE;
92  virtual Bscript::BObjectRef set_member_id( const int id, Bscript::BObjectImp* value,
93  bool copy ) POL_OVERRIDE; // id test
94 
95  virtual bool isTrue() const POL_OVERRIDE;
96  virtual bool operator==( const Bscript::BObjectImp& objimp ) const POL_OVERRIDE;
97  virtual bool operator<( const Bscript::BObjectImp& objimp ) const POL_OVERRIDE;
98 
99  virtual bool offline_access_ok() const { return false; }
100 };
101 
103 {
104 public:
106  virtual const char* typeOf() const POL_OVERRIDE;
107  virtual u8 typeOfInt() const POL_OVERRIDE;
108  virtual Bscript::BObjectImp* copy() const POL_OVERRIDE;
109 
110  virtual bool isTrue() const POL_OVERRIDE;
111  virtual bool offline_access_ok() const POL_OVERRIDE { return true; }
112 };
113 
114 class ECharacterEquipObjImp : public Bscript::BApplicObj<Core::CharacterRef>
115 {
117 
118 public:
120  : BApplicObj<Core::CharacterRef>( &echaracterequipobjimp_type, Core::CharacterRef( chr ) )
121  {
122  }
123 
124  virtual Bscript::BObjectImp* copy() const POL_OVERRIDE;
125  virtual Bscript::BObjectRef OperSubscript( const Bscript::BObject& obj ) POL_OVERRIDE;
126 };
127 
128 
129 class EItemRefObjImp : public Bscript::BApplicObj<Core::ItemRef>
130 {
132 
133 public:
134  explicit EItemRefObjImp( Items::Item* item )
135  : BApplicObj<Core::ItemRef>( &eitemrefobjimp_type, Core::ItemRef( item ) )
136  {
137  }
138 
139  virtual const char* typeOf() const POL_OVERRIDE;
140  virtual u8 typeOfInt() const POL_OVERRIDE;
141  virtual Bscript::BObjectImp* copy() const POL_OVERRIDE;
142  virtual Bscript::BObjectImp* call_method( const char* methodname,
144  virtual Bscript::BObjectImp* call_method_id( const int id, Bscript::Executor& ex,
145  bool forcebuiltin = false ) POL_OVERRIDE;
146  virtual Bscript::BObjectRef get_member( const char* membername ) POL_OVERRIDE;
147  virtual Bscript::BObjectRef get_member_id( const int id ) POL_OVERRIDE; // id test
148  virtual Bscript::BObjectRef set_member( const char* membername, Bscript::BObjectImp* value,
149  bool copy ) POL_OVERRIDE;
150  virtual Bscript::BObjectRef set_member_id( const int id, Bscript::BObjectImp* value,
151  bool copy ) POL_OVERRIDE; // id test
152 
153  virtual bool isTrue() const POL_OVERRIDE;
154  virtual bool operator==( const Bscript::BObjectImp& objimp ) const POL_OVERRIDE;
155  virtual bool operator<( const Bscript::BObjectImp& objimp ) const POL_OVERRIDE;
156 };
157 
158 
159 class EUBoatRefObjImp : public Bscript::BApplicObj<ref_ptr<Multi::UBoat>>
160 {
162 
163 public:
164  explicit EUBoatRefObjImp( Multi::UBoat* boat )
165  : Bscript::BApplicObj<ref_ptr<Multi::UBoat>>( &euboatrefobjimp_type,
166  ref_ptr<Multi::UBoat>( boat ) )
167  {
168  }
169 
170  virtual const char* typeOf() const POL_OVERRIDE;
171  virtual u8 typeOfInt() const POL_OVERRIDE;
172  virtual Bscript::BObjectImp* copy() const POL_OVERRIDE;
173  virtual Bscript::BObjectImp* call_method( const char* methodname,
175  virtual Bscript::BObjectImp* call_method_id( const int id, Bscript::Executor& ex,
176  bool forcebuiltin = false ) POL_OVERRIDE;
177  virtual Bscript::BObjectRef get_member( const char* membername ) POL_OVERRIDE;
178  virtual Bscript::BObjectRef get_member_id( const int id ) POL_OVERRIDE; // id test
179  virtual Bscript::BObjectRef set_member( const char* membername, Bscript::BObjectImp* value,
180  bool copy ) POL_OVERRIDE;
181  virtual Bscript::BObjectRef set_member_id( const int id, Bscript::BObjectImp* value,
182  bool copy ) POL_OVERRIDE; // id test
183 
184  virtual bool isTrue() const POL_OVERRIDE;
185  virtual bool operator==( const Bscript::BObjectImp& objimp ) const POL_OVERRIDE;
186 };
187 
188 
189 class EMultiRefObjImp : public Bscript::BApplicObj<ref_ptr<Multi::UMulti>>
190 {
192 
193 public:
194  explicit EMultiRefObjImp( Multi::UMulti* multi )
195  : BApplicObj<ref_ptr<Multi::UMulti>>( &emultirefobjimp_type, ref_ptr<Multi::UMulti>( multi ) )
196  {
197  }
198 
199  virtual const char* typeOf() const POL_OVERRIDE;
200  virtual u8 typeOfInt() const POL_OVERRIDE;
201  virtual Bscript::BObjectImp* copy() const POL_OVERRIDE;
202  virtual Bscript::BObjectRef get_member( const char* membername ) POL_OVERRIDE;
203  virtual Bscript::BObjectRef get_member_id( const int id ) POL_OVERRIDE; // id test
204  virtual Bscript::BObjectRef set_member( const char* membername, Bscript::BObjectImp* value,
205  bool copy ) POL_OVERRIDE;
206  virtual Bscript::BObjectRef set_member_id( const int id, Bscript::BObjectImp* value,
207  bool copy ) POL_OVERRIDE; // test id
208  virtual bool isTrue() const POL_OVERRIDE;
209  virtual Bscript::BObjectImp* call_method( const char* methodname,
211  virtual Bscript::BObjectImp* call_method_id( const int id, Bscript::Executor& ex,
212  bool forcebuiltin = false ) POL_OVERRIDE;
213  virtual bool operator==( const Bscript::BObjectImp& objimp ) const POL_OVERRIDE;
214 };
215 
217 class EClientRefObjImp : public Bscript::BApplicObj<ClientPtrHolder>
218 {
220 
221 public:
222  explicit EClientRefObjImp( ClientPtrHolder client )
223  : Bscript::BApplicObj<ClientPtrHolder>( &eclientrefobjimp_type, client )
224  {
225  }
226  virtual ~EClientRefObjImp(){};
227 
228  virtual const char* typeOf() const POL_OVERRIDE;
229  virtual u8 typeOfInt() const POL_OVERRIDE;
230  virtual Bscript::BObjectImp* copy() const POL_OVERRIDE;
231  virtual Bscript::BObjectImp* call_method( const char* methodname,
233  virtual Bscript::BObjectImp* call_method_id( const int id, Bscript::Executor& ex,
234  bool forcebuiltin = false ) POL_OVERRIDE;
235  virtual Bscript::BObjectRef get_member( const char* membername ) POL_OVERRIDE;
236  virtual Bscript::BObjectRef get_member_id( const int id ) POL_OVERRIDE; // id test
237  virtual Bscript::BObjectRef set_member( const char* membername, Bscript::BObjectImp* value,
238  bool copy ) POL_OVERRIDE;
239  virtual Bscript::BObjectRef set_member_id( const int id, Bscript::BObjectImp* value,
240  bool copy ) POL_OVERRIDE; // id test
241 
242  virtual bool isTrue() const POL_OVERRIDE;
243  virtual bool operator==( const Bscript::BObjectImp& objimp ) const POL_OVERRIDE;
244 };
245 
246 // EMenuObjImp defined on UOEMOD.CPP
247 
248 
250 {
251 public:
252  SpeechEvent( Mobile::Character* speaker, const char* speech );
253  SpeechEvent( Mobile::Character* speaker, const char* speech, const char* texttype ); // DAVE
254 };
255 
257 {
258 public:
259  UnicodeSpeechEvent( Mobile::Character* speaker, const char* speech, const u16* wspeech,
260  const char lang[4], Bscript::ObjArray* speechtokens = nullptr );
261  UnicodeSpeechEvent( Mobile::Character* speaker, const char* speech, const char* texttype,
262  const u16* wspeech, const char lang[4],
263  Bscript::ObjArray* speechtokens = nullptr );
264 };
265 
267 {
268 public:
269  DamageEvent( Mobile::Character* source, unsigned short damage );
270 };
271 
272 
274 {
275 public:
277 };
278 
279 class EngageEvent : public SourcedEvent
280 {
281 public:
282  explicit EngageEvent( Mobile::Character* engaged )
283  : SourcedEvent( Core::EVID_ENGAGED, engaged ){};
284 };
285 
287 {
288 public:
289  explicit DisengageEvent( Mobile::Character* disengaged )
290  : SourcedEvent( Core::EVID_DISENGAGED, disengaged ){};
291 };
292 
294 {
295 public:
296  ItemGivenEvent( Mobile::Character* chr_givenby, Items::Item* item_given,
297  Mobile::NPC* chr_givento );
298  virtual ~ItemGivenEvent();
299 
300 private:
305 };
306 }
307 }
308 #endif // UOSCROBJ_H
unsigned char u8
Definition: rawtypes.h:25
ECharacterEquipObjImp(Mobile::Character *chr)
Definition: uoscrobj.h:119
unsigned int gameclock_t
Definition: gameclck.h:14
DisengageEvent(Mobile::Character *disengaged)
Definition: uoscrobj.h:289
BApplicObjType echaracterrefobjimp_type
Definition: uoscrobj.cpp:126
#define POL_OVERRIDE
bool operator<(T *ptr, const ref_ptr< T > &rptr)
Definition: refptr.h:323
BApplicObjType eitemrefobjimp_type
Definition: uoscrobj.cpp:125
virtual bool offline_access_ok() const
Definition: uoscrobj.h:99
Core::gameclock_t given_time_
Definition: uoscrobj.h:304
EUBoatRefObjImp(Multi::UBoat *boat)
Definition: uoscrobj.h:164
Bscript::BApplicObj< ClientPtrHolder > base
Definition: uoscrobj.h:219
bool operator==(T *ptr, const ref_ptr< T > &rptr)
Definition: refptr.h:311
EItemRefObjImp(Items::Item *item)
Definition: uoscrobj.h:134
BApplicObjType echaracterequipobjimp_type
Definition: uoscrobj.cpp:127
EngageEvent(Mobile::Character *engaged)
Definition: uoscrobj.h:282
BApplicObjType emultirefobjimp_type
Definition: uoscrobj.cpp:124
unsigned short u16
Definition: rawtypes.h:26
EOfflineCharacterRefObjImp(Mobile::Character *chr)
Definition: uoscrobj.h:105
BApplicObjType eclientrefobjimp_type
Definition: uoscrobj.cpp:130
Bscript::BApplicObj< Core::CharacterRef > base
Definition: uoscrobj.h:116
Core::CharacterRef given_by_
Definition: uoscrobj.h:303
Definition: refptr.h:65
BApplicObjType storage_area_type
Definition: uoscrobj.cpp:128
Bscript::BApplicObj< Core::CharacterRef > base
Definition: uoscrobj.h:71
ref_ptr< Mobile::Character > CharacterRef
Definition: reftypes.h:42
#define passert(exp)
Definition: passert.h:62
BApplicObjType euboatrefobjimp_type
Definition: uoscrobj.cpp:123
ECharacterRefObjImp(Mobile::Character *chr)
Definition: uoscrobj.h:74
StateManager stateManager
Definition: state.cpp:8
Bscript::BApplicObj< Core::ItemRef > base
Definition: uoscrobj.h:131
EMultiRefObjImp(Multi::UMulti *multi)
Definition: uoscrobj.h:194
ref_ptr< Items::Item > ItemRef
Definition: reftypes.h:43
virtual bool offline_access_ok() const POL_OVERRIDE
Definition: uoscrobj.h:111
Bscript::BApplicObj< ref_ptr< Multi::UMulti > > base
Definition: uoscrobj.h:191
BApplicObjType menu_type
Definition: uoscrobj.cpp:129
BApplicObj< ref_ptr< Multi::UBoat > > base
Definition: uoscrobj.h:161
weak_ptr< Network::Client > ClientPtrHolder
Definition: uoscrobj.h:216
Definition: berror.cpp:12
ref_ptr< Core::UContainer > cont_
Definition: uoscrobj.h:302
EClientRefObjImp(ClientPtrHolder client)
Definition: uoscrobj.h:222
UObjCount uobjcount
Definition: state.h:49