Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

/home/groups/n/no/noxwizard/cvs/src/object.h

Go to the documentation of this file.
00001   /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
00002     || NoX-Wizard UO Server Emulator (NXW) [http://noxwizard.sourceforge.net]  ||
00003     ||                                                                         ||
00004     || This software is free software released under GPL2 license.             ||
00005     || You can find detailed license information in nox-wizard.cpp file.       ||
00006     ||                                                                         ||
00007     || For any question post to NoX-Wizard forums.                             ||
00008     -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
00009 
00016 #ifndef __OBJECT_H
00017 #define __OBJECT_H
00018 
00019 #include <stdarg.h>
00020 #include "constants.h"
00021 #include "typedefs.h"
00022 #include "amx/amxcback.h"
00023 #include "tmpeff.h"
00024 #include "basics.h"
00025 
00026 #define ISVALIDPO(po) ( ( po!=NULL && ( sizeof(*po) == sizeof(cObject) || sizeof(*po) == sizeof(cChar) || sizeof(*po) == sizeof(cItem) ) ) ? (po->getSerial32() > 0) : false )
00027 #define VALIDATEPO(po) if (!ISVALIDPO(po)) { LogWarning("a non-valid P_OBJECT pointer was used in %s:%d", basename(__FILE__), __LINE__); return; }
00028 #define VALIDATEPOR(po, r) if (!ISVALIDPO(po)) { LogWarning("a non-valid P_OBJECT pointer was used in %s:%d", basename(__FILE__), __LINE__); return r; }
00029 
00030 class cScpIterator;
00031 
00032 typedef map< UI32, AmxEvent* > AmxEventMap;
00033 
00034 typedef slist< tempfx::cTempfx > TempfxVector;
00035 
00037 inline bool operator ==(Location a, Location b)
00038 { return ((a.x==b.x) && (a.y==b.y) && (a.z==b.z)); }
00039 
00041 inline bool operator !=(Location a, Location b)
00042 { return ((a.x!=b.x) || (a.y!=b.y) || (a.z!=b.z)); }
00043 
00049 class cObject
00050 {
00051 protected:
00052         enum{OBJECT, ITEM, CHAR, } objtype;
00054 
00057 public:
00058         inline bool             operator> (const cObject& obj) const
00059         { return(getSerial32() >  obj.getSerial32()); }
00060 
00061         inline bool             operator< (const cObject& obj) const
00062         { return(getSerial32() <  obj.getSerial32()); }
00063 
00064         inline bool             operator>=(const cObject& obj) const
00065         { return(getSerial32() >= obj.getSerial32()); }
00066 
00067         inline bool             operator<=(const cObject& obj) const
00068         { return(getSerial32() <= obj.getSerial32()); }
00069 
00070         inline bool             operator==(const cObject& obj) const
00071         { return(getSerial32() == obj.getSerial32()); }
00072 
00073         inline bool             operator!=(const cObject& obj) const
00074         { return(getSerial32() != obj.getSerial32()); }
00076 
00077 public:
00078         static std::string      getRandomScriptValue( std::string section, std::string& sectionId );
00079 private:
00080         static cScpIterator*    getScriptIterator( std::string section, std::string& sectionId );
00081 
00082 public:
00083         cObject();
00084         virtual ~cObject();
00086 
00090 private:
00091         Serial                  serial;                 
00092         Serial                  multi_serial;           
00093         Serial                  OwnerSerial;            
00094         Serial          spawnserial;
00095         Serial          spawnregion;
00096 
00097 public:
00099         inline const Serial     getSerial() const
00100         { return serial; }
00101 
00103         inline const SI32       getSerial32() const
00104         { return serial.serial32; }
00105 
00106         void                    setSerial32(SI32 newserial);
00107         const void              setSerialByte(UI32 nByte, BYTE value);
00108 
00110         inline const Serial     getMultiSerial() const
00111         { return multi_serial; }
00112 
00114         inline const SI32       getMultiSerial32() const
00115         { return multi_serial.serial32; }
00116 
00118         inline void             setMultiSerial32Only(SI32 newserial)
00119         { multi_serial.serial32= newserial; }
00120 
00121         const void              setMultiSerialByte(UI32 nByte, BYTE value);
00122 
00124         inline const SI32       getSpawnSerial() const
00125         { return spawnserial.serial32; }
00127         inline void             setSpawnSerial(SI32 newserial)
00128         { spawnserial.serial32= newserial; }
00130         inline const SI32       getSpawnRegion() const
00131         { return spawnregion.serial32; }
00133         inline void             setSpawnRegion(SI32 newserial)
00134         { spawnregion.serial32= newserial; }
00135 
00137         inline const Serial     getOwnerSerial() const
00138         { return OwnerSerial; }
00139 
00141         inline const SI32       getOwnerSerial32() const
00142         { return OwnerSerial.serial32; }
00143 
00144         inline void             setOwnerSerial32Only(SI32 newserial)
00145         { OwnerSerial.serial32 = newserial; }
00146 
00147         void                    setOwnerSerial32(SI32 newserial, bool force=false );
00148         const void              setOwnerSerialByte(UI32 nByte, BYTE value);
00149 
00150         inline void             setSameOwnerAs(const cObject* obj)
00151         { setOwnerSerial32Only(obj->getOwnerSerial32()); }
00153 
00155 
00159 private:
00160         Location                old_position;           
00161         Location                position;               
00162 
00163 public:
00165         inline const Location   getPosition() const
00166         { return position; }
00167 
00168         SI32                    getPosition(const char *what) const;
00169         void                    setPosition(const char *what, SI32 value);
00170         void                    setPosition(Location where);
00171 
00173         inline void             setPosition(UI32 x, UI32 y, SI08 z)
00174         { setPosition( Loc( x, y, z ) ); }
00175 
00176         inline const Location   getOldPosition() const
00177         { return old_position; }
00178 
00179         SI32                    getOldPosition(const char *what) const;
00180         void                    setOldPosition(const char *what, SI32 value);
00181 
00182         inline void             setOldPosition(const Location where)
00183         { old_position = where; }
00184 
00185         inline void             setOldPosition(SI32 x, SI32 y, signed char z, signed char dispz)
00186         { setOldPosition( Loc(x, y, z, dispz) ); }
00188 
00190 
00193 protected:
00194         string                  secondary_name;
00199         string                  current_name;   
00200 
00201 public:
00203         inline const string     getRealName() const
00204         { return secondary_name; }
00205 
00207         inline const char*              getRealNameC() const
00208         { return secondary_name.c_str(); }
00209 
00211         inline void             setRealName(string s)
00212         { secondary_name = s; }
00213 
00215         inline void             setRealName(const char *str)
00216         { secondary_name = string(str); }
00217 
00219         inline const string     getCurrentName() const
00220         { return current_name;  }
00221 
00223         inline const char*      getCurrentNameC() const
00224         { return current_name.c_str(); }
00225 
00227         inline void             setCurrentName(string s)
00228         { current_name = s; }
00229 
00231         inline void             setCurrentName(const char *str)
00232         { current_name = string(str); }
00233 
00234         void                    setCurrentName(char *format, ...);
00235 
00237         inline void             setSecondaryName( string s )
00238         { secondary_name = s; }
00239 
00241         inline const char*      getSecondaryNameC() const
00242         { return secondary_name.c_str(); }
00243 
00245         inline const string     getSecondaryName() const
00246         { return secondary_name; }
00247 
00248         void                    setSecondaryName(const char *format, ...);
00250 
00252 
00255 private:
00256         UI32                    ScriptID;
00257         TempfxVector            *tempfx;
00258 
00259 public:
00260         LOGICAL                 addTempfx(tempfx::cTempfx *fx);
00261         LOGICAL                 addTempfx( cObject& src, SI32 num, SI08 more1 = 0, SI08 more2 = 0, SI08 more3 = 0, SI08 more4 = 0,SI32 dur = 0, SI32 amxcback = INVALID );
00262         void                    delTempfx( SI32 num, LOGICAL executeExpireCode = true, SERIAL funcidx = INVALID );
00263         void                    checkTempfx();
00264         void                    tempfxOn();
00265         void                    tempfxOff();
00266         LOGICAL                 hasTempfx();
00267         tempfx::cTempfx*        getTempfx( SI32 num, SERIAL funcidx = INVALID );
00268         TempfxVector    *getTempfxVec( );
00270 
00272         inline const UI32       getScriptID() const
00273         { return ScriptID; }
00274 
00276         inline void             setScriptID(UI32 sid)
00277         { ScriptID = sid; }
00278 
00279         UI32    disabled;       
00280         std::string*    disabledmsg; 
00281 
00282 private:
00283         SI08 gender; // -1 neutral, 1 man, 2 woman, ...
00285 
00290         SI32                    race;                           
00291 
00292 public:
00293         inline const SI08 getGender() const
00294         { return gender; }
00295         inline void             setGender(SI08 newGender)
00296         { gender = newGender; }
00297         inline const SI32 getRace() const
00298         { return race; }
00299         inline void             setRace(SI32 newRace)
00300         { race = newRace; }
00301 
00302 public:
00303         virtual void            Delete();
00304 
00305 private:
00306         UI16 id_old;
00307         UI16 id;
00308         COLOR color;
00309         COLOR color_old;
00310 public:
00311         inline void setId( UI16 newId )
00312         { id = newId; }
00313 
00314         inline const UI16 getId() const
00315         { return id; }
00316 
00317         inline void setOldId( UI16 oldId )
00318         { id_old = oldId; }
00319 
00320         inline const UI16 getOldId() const
00321         { return id_old; }
00322 
00323         inline void setColor( COLOR newColor )
00324         { color = newColor; }
00325 
00326         inline const COLOR getColor() const
00327         { return color; }
00328 
00329         inline void setOldColor( COLOR oldColor )
00330         { color_old = oldColor; }
00331 
00332         inline const COLOR getOldColor() const
00333         { return this->color_old; }
00334 
00335 } PACK_NEEDED;
00336 
00340 class cSpawner : public cObject
00341 {
00342 };
00343 
00344 class cItemSpawner : public cSpawner
00345 {
00346 };
00347 
00348 class cNpcSpawner : public cSpawner
00349 {
00350 };
00351 
00352 #endif  // __OBJECT_H
00353 
SourceForge.net Logo