Planeshift

psitem.h

Go to the documentation of this file.
00001 /*
00002  * psitem.h
00003  *
00004  * Copyright (C) 2003 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 
00020 #ifndef __PSITEM_H__
00021 #define __PSITEM_H__
00022 //=============================================================================
00023 // Crystal Space Includes
00024 //=============================================================================
00025 #include <csutil/array.h>
00026 #include <csgeom/vector3.h>
00027 #include <csutil/weakreferenced.h>
00028 
00029 //=============================================================================
00030 // Project Includes
00031 //=============================================================================
00032 #include "util/psconst.h"
00033 #include "util/scriptvar.h"
00034 #include "util/gameevent.h"
00035 #include "util/slots.h"
00036 
00037 #include <idal.h>
00038 
00039 #include "util/poolallocator.h"
00040 
00041 #include "net/messages.h"
00042 
00043 //=============================================================================
00044 // Local Includes
00045 //=============================================================================
00046 #include "psskills.h"
00047 #include "psitemstats.h"
00048 #include "deleteobjcallback.h"
00049 #include "psactionlocationinfo.h"
00050 #include "lootrandomizer.h"
00051 
00052 
00053 class Client;
00054 class gemActor;
00055 
00060 // Note: The following 2 options require a clean rebuild when changed.
00061 
00063 #define SAVE_DEBUG 0
00064 
00066 #define SAVE_TRACER 0
00067 
00068 
00070 #define REMOVAL_INTERVAL_RANGE     300
00071 #define REMOVAL_INTERVAL_MINIMUM  2419200
00072 
00074 #define  ID_DONT_SAVE_ITEM 0xffffffff
00075 
00077 #define PSITEM_FLAG_CRAFTER_ID_IS_VALID 0x00000001
00078 
00079 #define PSITEM_FLAG_GUILD_ID_IS_VALID   0x00000002
00080 
00081 #define PSITEM_FLAG_UNIQUE_ITEM         0x00000004
00082 
00091 #define PSITEM_FLAG_USES_BASIC_ITEM     0x00000008
00092 
00093 #define PSITEM_FLAG_PURIFIED            0x00000010
00094 #define PSITEM_FLAG_PURIFYING           0x00000020
00095 
00097 #define PSITEM_FLAG_LOCKED              0x00000040
00098 
00100 #define PSITEM_FLAG_LOCKABLE            0x00000080
00101 
00103 #define PSITEM_FLAG_NOPICKUP            0x00000100
00104 
00106 #define PSITEM_FLAG_KEY                 0x00000200
00107 
00109 #define PSITEM_FLAG_TRANSIENT           0x00000400
00110 
00112 #define PSITEM_FLAG_UNPICKABLE          0x00000800
00113 
00115 #define PSITEM_FLAG_SECURITYLOCK        0x00001000
00116 
00118 #define PSITEM_FLAG_NPCOWNED            0x00002000
00119 
00121 #define PSITEM_FLAG_MASTERKEY           0x00004000
00122 
00124 #define PSITEM_FLAG_USE_CD              0x00008000
00125 
00127 #define PSITEM_FLAG_ACTIVE              0x00010000
00128 
00130 #define PSITEM_FLAG_UNSTACKABLE         0x00020000
00131 
00133 #define PSITEM_FLAG_STACKABLE           0x00040000
00134 
00136 #define PSITEM_FLAG_SETTINGITEM         0x00080000
00137 
00139 #define PSITEM_FLAG_NOPICKUPWEAK        0x00100000
00140 
00142 #define PSITEM_FLAG_IDENTIFIABLE        0x00200000
00143 
00144 #define KEY_SKELETON      ((unsigned int)-2)
00145 
00146 #define MAX_STACK_COUNT        65  // This is the most items a player can have in a stack
00147 
00148 typedef unsigned int PSITEM_FLAGS;
00149 
00151 #define PSITEM_MAX_MODIFIERS    10
00152 
00153 class ActiveSpell;
00154 class psItem;
00155 class psCharacter;
00156 class gemItem;
00157 class psSectorInfo;
00158 struct psItemCategory;
00159 class psScheduledItem;
00160 class psWorkGameEvent;
00161 
00171 class RandomizedOverlay
00172 {
00173 public:
00174     RandomizedOverlay(); 
00175     ~RandomizedOverlay(); 
00176     bool active; 
00177     csString name; 
00178     float weight; 
00179     float latency; 
00180     float damageStats[PSITEMSTATS_DAMAGETYPE_COUNT]; 
00181     ApplicativeScript* equip_script; 
00182     psMoney price; 
00183     csArray<ItemRequirement> reqs; 
00184     csString mesh; 
00185     csString icon; 
00186 };
00187 
00238 class psItem : public iScriptableVar, public iDeleteObjectCallback
00239 {
00240 public:
00241 
00247     psItem();
00248 
00251     virtual ~psItem();
00252 
00255     virtual const char* GetItemType()
00256     {
00257         return "Item";
00258     }
00259 
00260     gemItem* GetGemObject()
00261     {
00262         return gItem;
00263     }
00264     void SetGemObject(gemItem* object);
00265 
00266     psWorkGameEvent* GetTransformationEvent()
00267     {
00268         return transformationEvent;
00269     }
00270     void SetTransformationEvent(psWorkGameEvent* t)
00271     {
00272         transformationEvent = t;
00273     }
00274 
00276     virtual void DeleteObjectCallback(iDeleteNotificationObject* object);
00277 
00279     void UpdateView(Client* fromClient, EID eid, bool clear);
00280 
00281     bool SendItemDescription(Client* client);
00282 
00283     bool SendContainerContents(Client* client, int containerID = CONTAINER_INVENTORY_BULK);
00284 
00291     void ViewItem(Client* client, int containerID, INVENTORY_SLOT_NUMBER slotID);
00292 
00293     bool SendActionContents(Client* client, psActionLocation* action);
00294 
00295 private:
00296 
00297 
00302     void FillContainerMsg(Client* client, psViewContainerDescription &outgoing);
00303 
00304     void SendCraftTransInfo(Client* client);
00305 
00306     void GetComboInfoString(psCharacter* character, uint32 designID, csString &comboString);
00307 
00308     void GetTransInfoString(psCharacter* character, uint32 designID, csString &transString);
00309 
00310     bool SendBookText(Client* client, int containerID, int slotID);
00311 
00312     void SendSketchDefinition(Client* client);
00313 
00314     void SendMusicalSheet(Client* client);
00315 
00317     uint32 uid;
00318 
00320     bool item_in_use;
00321 
00323     psWorkGameEvent* transformationEvent;
00324 
00326     struct
00327     {
00328         psSectorInfo* loc_sectorinfo;
00329         float loc_x,loc_y,loc_z;
00330         float loc_xrot,loc_yrot,loc_zrot;
00331         InstanceID worldInstance;
00332     } location;
00333 
00335     float decay_resistance; // percent 3.2
00336 
00337 
00338     float item_quality;                     
00339     float crafted_quality;                  
00340 
00341 
00343     float item_quality_original;
00344 
00346     unsigned short stack_count;
00347 
00349     int charges;
00350 
00352     bool useNat;
00353 
00354 
00355 protected:
00362     PSITEM_FLAGS flags;
00363 private:
00367     PID crafter_id;
00374     unsigned int guild_id;
00375 
00376     /* Container Hierarchy Data
00377      *
00378      *  The following field allows objects-within-objects (containers) to be described.
00379      *
00380      */
00382     InstanceID parent_item_InstanceID;
00383 
00384 
00388     INVENTORY_SLOT_NUMBER loc_in_parent;
00389 
00390 
00396     psCharacter* owning_character;
00397 
00401     PID owningCharacterID;
00402     PID guardingCharacterID;
00403 
00408     psItemStats* base_stats;
00414     psItemStats* current_stats;
00420     psItemStats* modifiers[PSITEM_MAX_MODIFIERS];
00421 
00422     // Lock stuff
00423     unsigned int lockStrength;
00424     PSSKILL lockpickSkill;
00425 
00426     // A key can open multiple locks
00427     csArray<unsigned int> openableLocks;
00428 
00429     psScheduledItem* schedule;
00430 
00436     void Commit(bool children = false);
00437 
00444     void UpdateItemQuality(uint32 id, float qual);
00445 
00447     friend class psDelaySave;
00448 
00452     csString item_name;
00453 
00457     csString item_description;
00458 
00460     ActiveSpell* equipActiveSpell;
00461 
00463     psItemCreativeStats creativeStats;
00464 
00466     RandomizedOverlay* itemModifiers;
00467 
00469     csArray<uint32_t> modifierIds;
00470 
00471 public:
00476     virtual bool Load(iResultRow &row);
00477 
00482     void Save(bool children);
00483 
00485     void ForceSaveIfNew();
00486 
00491     void SetLoaded()
00492     {
00493         loaded = true;
00494     }
00495 
00498     bool CheckRequirements(psCharacter* character, csString &resp);
00499 
00504     uint32 GetUID()
00505     {
00506         return uid;
00507     }
00508 
00512     void SetUID(uint32 v);
00513 
00515     bool GetIsCrafterIDValid();
00517     void SetIsCrafterIDValid(bool v);
00518 
00520     bool GetIsGuildIDValid();
00522     void SetIsGuildIDValid(bool v);
00524 
00525     PID GetCrafterID() const
00526     {
00527         return crafter_id;
00528     }
00530     void SetCrafterID(PID v);
00531 
00533     unsigned int GetGuildID() const
00534     {
00535         return guild_id;
00536     }
00538     void SetGuildID(unsigned int v);
00539 
00541     float GetMaxItemQuality() const;
00543     void SetMaxItemQuality(float v);
00544 
00546     float GetItemQuality() const;
00548     void SetItemQuality(float v);
00550     const char* GetQualityString();
00551 
00553     PSITEM_FLAGS ParseItemFlags(csString flagstr);
00554 
00556     int GetRequiredRepairTool();
00558     bool GetRequiredRepairToolConsumed();
00559 
00561     int GetIdentifySkill();
00563     int GetIdentifyMinSkill();
00564 
00566     void SetDecayResistance(float v);
00568     void SetItemDecayRate(float v);
00570     float GetItemDecayRate()
00571     {
00572         return base_stats->GetDecayRate();
00573     }
00575     float AddDecay(float severityFactor);
00576 
00577     bool IsInUse()
00578     {
00579         return item_in_use;
00580     }
00581     void SetInUse(bool flag)
00582     {
00583         item_in_use = flag;
00584     }
00585 
00590     bool GetIsUnique() const;
00591 
00599     bool HasModifier(psItemStats* modifier);
00600 
00606     bool AddModifier(psItemStats* modifier);
00607 
00611     psItemStats* GetModifier(int index);
00612 
00614     virtual psItem* CreateNew()
00615     {
00616         return new psItem();
00617     }
00618 
00625     virtual psItem* Copy(unsigned short newstackcount);
00626 
00629     virtual void Copy(psItem* target);
00630 
00637     psItem* SplitStack(unsigned short newstackcount);
00638 
00639 
00642     void CombineStack(psItem* &stackme);
00643 
00644 
00648     int GetAttackAnimID(psCharacter* pschar);
00649 
00651     float GetDecay();
00653     void SetDecay(float v);
00654 
00656     unsigned short GetStackCount() const
00657     {
00658         return stack_count;
00659     }
00664     void SetStackCount(unsigned short v);
00665 
00666 
00672     psCharacter* GetOwningCharacter()
00673     {
00674         return owning_character;
00675     }
00679     PID GetOwningCharacterID() const
00680     {
00681         return owningCharacterID;
00682     }
00683 
00685     virtual void SetOwningCharacter(psCharacter* owner);
00686 
00689     PID  GetGuardingCharacterID() const
00690     {
00691         return guardingCharacterID;
00692     }
00693     void SetGuardingCharacterID(PID guardian)
00694     {
00695         guardingCharacterID = guardian;
00696     }
00697 
00699     uint32 GetContainerID() const
00700     {
00701         return parent_item_InstanceID;
00702     }
00703     void SetContainerID(uint32 parentId)
00704     {
00705         parent_item_InstanceID = parentId;
00706     }
00707 
00708 
00713     INVENTORY_SLOT_NUMBER GetLocInParent(bool adjustSlot=false);
00714 
00716     void SetLocInParent(INVENTORY_SLOT_NUMBER location);
00717 
00721     void SetUniqueStats(psItemStats* statptr);
00722 
00727     void SetBaseStats(psItemStats* statptr);
00728 
00732     psItemStats* GetBaseStats() const
00733     {
00734         return base_stats;
00735     }
00736 
00741     void SetCurrentStats(psItemStats* statptr);
00742 
00746     psItemStats* GetCurrentStats() const
00747     {
00748         return current_stats;
00749     }
00750 
00754     void RecalcCurrentStats();
00755 
00756     PSITEM_FLAGS GetFlags()
00757     {
00758         return flags;
00759     }
00760 
00761     void SetFlags(int f)
00762     {
00763         flags = f;
00764     }
00765 
00766     virtual int GetPurifyStatus() const
00767     {
00768         return 0;
00769     }
00770 
00771     // Interface to itemstats
00772 
00773     /*  The following functions mostly call into the current stats to return the requested values.
00774      *  In the future additional logic about value modification may be added to these functions.
00775      *  For this reason these functions should ALWAYS be used rather than calling GetCurrentStats()->Get*()
00776      *   unless you REALLY know what you're doing and REALLY mean to bypass the intended value of the item instance.
00777      */
00778 
00779     bool GetIsMeleeWeapon();
00780     bool GetIsBothHandsWeapon();
00781     bool GetIsRangeWeapon();
00782     bool GetIsAmmo();
00783     bool GetIsArmor();
00784     bool GetIsShield();
00785     bool GetIsContainer();
00786     bool GetIsAutoTransformContainer();
00787     bool GetIsTrap();
00788     bool GetIsConstructible();
00789     bool GetCanTransform();
00790     bool GetUsesAmmo();
00791     bool GetIsStackable() const;
00792     bool GetIsEquipStackable() const;
00793     PSITEMSTATS_CREATIVETYPE GetCreative();
00795     bool SetCreation(PSITEMSTATS_CREATIVETYPE, const csString &, csString);
00800     PID GetCreator(PSITEMSTATS_CREATORSTATUS &creatorStatus);
00802     void SetCreator(PID, PSITEMSTATS_CREATORSTATUS);
00803 
00809     bool IsThisTheCreator(PID pid);
00810     bool GetBuyPersonalise();
00811     const char* GetName() const;
00816     const char* GetDescription() const;
00817     void SetName(const char* newName);
00818     void SetDescription(const char* newDescription);
00819     const char* GetStandardName();
00820     const char* GetStandardDescription();
00821 
00830     void AddLootModifier(uint32_t id, int pos = -1);
00831 
00833     void UpdateModifiers();
00834 
00835     float GetRange() const
00836     {
00837         return current_stats->GetRange();
00838     }
00839     bool UsesAmmoType(uint32_t id) const
00840     {
00841         return current_stats->UsesAmmoType(id);
00842     }
00843 
00844     psWeaponType *GetWeaponType();
00845     PSSKILL GetWeaponSkill(PSITEMSTATS_WEAPONSKILL_INDEX index);
00846     float GetLatency();
00847     float GetDamage(PSITEMSTATS_DAMAGETYPE dmgtype);
00848     PSITEMSTATS_AMMOTYPE GetAmmoType();
00849 
00850     float GetPenetration();
00851     float GetUntargetedBlockValue();
00852     float GetTargetedBlockValue();
00853     float GetCounterBlockValue();
00854     PSITEMSTATS_ARMORTYPE GetArmorType();
00855     float GetDamageProtection(PSITEMSTATS_DAMAGETYPE dmgtype);
00856     float GetHardness();
00857     float GetWeaponAttributeBonus(PSITEMSTATS_STAT stat);
00858     PSITEMSTATS_STAT GetWeaponAttributeBonusType(int index);
00859     float GetWeaponAttributeBonusMax(int index);
00860 
00861     float GetWeight();
00862     float GetItemSize();
00864     float GetTotalStackSize()
00865     {
00866         return GetItemSize()*stack_count;
00867     }
00868 
00869     unsigned short GetContainerMaxSize();
00870 
00877     int GetContainerMaxSlots();
00878     PSITEMSTATS_SLOTLIST GetValidSlots();
00879     bool FitsInSlots(PSITEMSTATS_SLOTLIST slotmask);
00880     bool FitsInSlot(INVENTORY_SLOT_NUMBER slot);
00881 
00888     csString GetSlotRemovedMesh(int slot, csString meshName = "")
00889     {
00890         return GetBaseStats()->GetSlotRemovedMesh(slot, meshName);
00891     }
00892     float GetDecayResistance();
00893     psMoney GetPrice();
00894     psMoney GetSellPrice();    
00895     psItemCategory* GetCategory();
00896 
00897 
00898     float GetVisibleDistance();
00899 
00900     void GetLocationInWorld(InstanceID &instance,psSectorInfo** sectorinfo,float &loc_x,float &loc_y,float &loc_z,float &loc_yrot) const;
00901     void SetLocationInWorld(InstanceID instance,psSectorInfo* sectorinfo,float loc_x,float loc_y,float loc_z,float loc_yrot);
00902 
00907     void GetXZRotationInWorld(float &loc_xrot, float &loc_zrot);
00908 
00913     void SetXZRotationInWorld(float loc_xrot, float loc_zrot);
00914 
00920     void GetRotationInWorld(float &loc_xrot, float &loc_yrot, float &loc_zrot);
00921 
00927     void SetRotationInWorld(float loc_xrot, float loc_yrot, float loc_zrot);
00928 
00929     psSectorInfo* GetSector() const
00930     {
00931         return location.loc_sectorinfo;
00932     }
00933 
00938     const char* GetMeshName();
00939 
00944     const char* GetTextureName();
00945 
00951     const char* GetPartName();
00952 
00958     const char* GetPartMeshName();
00959 
00965     const char* GetImageName();
00966 
00967     csString GetQuantityName(); // returns the quantity and plural name in a string
00968     static csString GetQuantityName(const char* namePtr, int stack_count, PSITEMSTATS_CREATIVETYPE creativeType, bool giveDetail = false);
00969 
00970     // For future use, see notes for mesh_index variables, etc.
00971     /*
00972     unsigned int GetMeshIndex();
00973     unsigned int GetTextureIndex();
00974     unsigned int GetTexturePartIndex();
00975     unsigned int GetImageIndex();
00976     */
00977 
00978     void UpdateInventoryStatus(psCharacter* owner,uint32 parent_id, INVENTORY_SLOT_NUMBER slot);
00979 
00980     bool IsEquipped() const;
00981     // an item can be equipped, but not active. This happens when its equip requirements
00982     // fail to be met while the item is still equipped.
00983     //   IsActive = true means the progression script for this item is active
00984     //   IsActive = false means the progression script for this item is inactive
00985     bool IsActive() const;
00986     void SetActive(bool state);
00987 
00988     void RunEquipScript(gemActor* actor);
00989     void CancelEquipScript();
00990 
00995     const char* GetModifiersDescription();
00996 
01005     bool CheckStackableWith(const psItem* otheritem, bool precise, bool checkStackCount = true, bool checkWorld = true) const;
01006 
01007     const char* GetSound();
01008 
01010     double GetProperty(MathEnvironment* env, const char* ptr);
01011     double CalcFunction(MathEnvironment* env, const char* functionName, const double* params);
01012     const char* ToString()
01013     {
01014         return item_name.GetDataSafe();
01015     }
01016 
01017     bool GetIsLocked()
01018     {
01019         return ((flags & PSITEM_FLAG_LOCKED)? true : false);
01020     }
01021     void SetIsLocked(bool v);
01022 
01023     bool GetIsLockable()
01024     {
01025         return ((flags & PSITEM_FLAG_LOCKABLE)? true : false);
01026     }
01027     void SetIsLockable(bool v);
01028 
01029     bool GetIsSecurityLocked()
01030     {
01031         return ((flags & PSITEM_FLAG_SECURITYLOCK)? true : false);
01032     }
01033     void SetIsSecurityLocked(bool v);
01034 
01035     bool GetIsUnpickable()
01036     {
01037         return ((flags & PSITEM_FLAG_UNPICKABLE)? true : false);
01038     }
01039     void SetIsUnpickable(bool v);
01040 
01044     bool GetIsNoPickup()
01045     {
01046         return (GetIsNoPickupStrong() || GetIsNoPickupWeak());
01047     }
01048 
01052     bool GetIsNoPickupStrong()
01053     {
01054         return ((flags & PSITEM_FLAG_NOPICKUP)? true : false);
01055     }
01056 
01060     bool GetIsNoPickupWeak()
01061     {
01062         return ((flags & PSITEM_FLAG_NOPICKUPWEAK)? true : false);
01063     }
01064 
01065     bool GetIsCD() const
01066     {
01067         return ((flags & PSITEM_FLAG_USE_CD)? true : false);
01068     }
01069     void SetIsCD(bool v);
01070 
01071     bool GetIsNpcOwned() const
01072     {
01073         return (flags & PSITEM_FLAG_NPCOWNED) != 0;
01074     }
01075     void SetIsNpcOwned(bool v);
01076 
01077     bool GetIsKey() const
01078     {
01079         return ((flags & PSITEM_FLAG_KEY)? true : false);
01080     }
01081     void SetIsKey(bool v);
01082 
01083     bool GetIsMasterKey() const
01084     {
01085         return ((flags & PSITEM_FLAG_MASTERKEY)? true : false);
01086     }
01087     void SetIsMasterKey(bool v);
01088 
01089     bool IsTransient()
01090     {
01091         return ((flags & PSITEM_FLAG_TRANSIENT) ? true : false);
01092     }
01093     void SetIsTransient(bool v);
01094 
01098     void SetIsPickupable(bool v);
01099 
01103     void SetIsPickupableWeak(bool v);
01104 
01105     void SetIsItemStackable(bool v);
01106     void ResetItemStackable();
01107 
01108     bool GetIsSettingItem() const
01109     {
01110         return ((flags & PSITEM_FLAG_SETTINGITEM)? true : false);
01111     }
01112     void SetIsSettingItem(bool v);
01113 
01114     PSSKILL GetLockpickSkill()
01115     {
01116         return lockpickSkill;
01117     }
01118     void SetLockpickSkill(PSSKILL v);
01119 
01120     unsigned int GetLockStrength()
01121     {
01122         return lockStrength;
01123     }
01124     void SetLockStrength(unsigned int v);
01125 
01126     bool CompareOpenableLocks(const psItem* key) const;
01127     bool CanOpenLock(uint32 id, bool includeSkel) const;
01128     void AddOpenableLock(uint32 v);
01129     void RemoveOpenableLock(uint32 v);
01130     void ClearOpenableLocks();
01131     void CopyOpenableLock(psItem* origKey);
01132     void MakeSkeleton(bool b);
01133     bool GetIsSkeleton();
01134     csString GetOpenableLockNames();
01135 
01136     psScheduledItem* GetScheduledItem()
01137     {
01138         return schedule;
01139     }
01140     void SetScheduledItem(psScheduledItem* item)
01141     {
01142         schedule = item;
01143     }
01144     void ScheduleRespawn();
01145 
01147     float GetArmorVSWeaponResistance(psItemStats* armor);
01148 
01150     csString GetBookText()
01151     {
01152         return GetLiteratureText();
01153     }
01155     bool SetBookText(const csString &newText);
01157     bool SetSketch(const csString &newSketchData);
01159     bool SetMusicalSheet(const csString &newMusicalSheet);
01160 
01161     bool HasCharges() const;
01162     bool IsRechargeable() const;
01163     void SetCharges(int charges);
01164     int GetCharges() const;
01165     int GetMaxCharges() const;
01166 
01168     csString GetItemCommand()
01169     {
01170         return GetBaseStats()->GetItemCommand();
01171     }
01172 
01182     bool Destroy();
01183 
01188     void ScheduleRemoval();
01189 
01190     bool DeleteFromDatabase();
01191 
01192     /*  Objects of this class utilize a pool allocator.  The pool allocator can be found in poolallocator.h in the psutil library.
01193      *  The pool allocator allows us to avoid allocating memory from and releasing memory to the heap over and over for things that are
01194      *  constantly shifting in the number of allocations (such as items in the game).  It also reduces memory usage overhead slightly.
01195      *
01196      *  It should be possible to debug memory leaks from a specific pool easier as well since you can analyze allocations solely from that pool
01197      *  without getting flooded with allocations from everywhere else.
01198      */
01199 
01201     void* operator new(size_t);
01203     void operator delete(void*);
01204 
01208     bool GetIsWriteable();
01212     bool GetIsReadable();
01213 
01215     const csString &GetSketch(void)
01216     {
01217         return creativeStats.creativeType == PSITEMSTATS_CREATIVETYPE_NONE ? GetBaseStats()->GetSketch() : creativeStats.content;
01218     }
01220     const csString &GetMusicalSheet(void)
01221     {
01222         return creativeStats.creativeType == PSITEMSTATS_CREATIVETYPE_NONE ? GetBaseStats()->GetSketch() : creativeStats.content;
01223     }
01225     const csString &GetLiteratureText(void)
01226     {
01227         return creativeStats.creativeType == PSITEMSTATS_CREATIVETYPE_NONE ? GetBaseStats()->GetSketch() : creativeStats.content;
01228     }
01230     const csString &GetCreativeBackgroundImg()
01231     {
01232         return creativeStats.creativeType == PSITEMSTATS_CREATIVETYPE_NONE ? GetBaseStats()->GetCreativeBackgroundImg() : creativeStats.backgroundImg;
01233     }
01234 
01235     void PrepareCreativeItemInstance();
01236 
01238     float GetRarity();
01239 
01241     csString GetRarityName();
01242 
01244     bool GetIsIdentifiable()
01245     {
01246         return ((flags & PSITEM_FLAG_IDENTIFIABLE)? true : false);
01247     }
01249     void SetIsIdentifiable(bool v);
01250 
01251 
01252 private:
01254     static PoolAllocator<psItem> itempool;
01255 
01256     gemItem* gItem;
01257 
01258     bool pendingsave;
01259 
01260     float rarity;
01261 
01264     float CalculateItemRarity();
01265 
01266 protected:
01267     bool loaded;
01268 
01269 #if SAVE_TRACER
01270 private:
01271     csString last_save_queued_from;
01272 #endif
01273 
01274 };
01275 
01276 
01277 class psScheduledItem
01278 {
01279 public:
01280     psScheduledItem(int spawnID,uint32 itemID,csVector3 &position, psSectorInfo* sector,InstanceID instance, int interval,int maxrnd,
01281                     float range, int lock_str = 0, int lock_skill = -1, csString flags = "");
01282 
01283     psItem* CreateItem();
01284     uint32 GetItemID()
01285     {
01286         return itemID;
01287     }
01288 
01289     psSectorInfo* GetSector()
01290     {
01291         return sector;
01292     }
01293     csVector3 &GetPosition()
01294     {
01295         return pos;
01296     }
01297     int MakeInterval(); 
01298     int GetInterval()
01299     {
01300         return interval;
01301     }
01302     int GetMaxModifier()
01303     {
01304         return maxrnd;
01305     }
01306 
01308     int GetLockStrength()
01309     {
01310         return lock_str;
01311     }
01312 
01314     int GetLockSkill()
01315     {
01316         return lock_skill;
01317     }
01318 
01320     csString GetFlags()
01321     {
01322         return flags;
01323     }
01324 
01325     void UpdatePosition(csVector3 &positon, const char* sector);
01326     void ChangeIntervals(int newint, int newrand);
01327     void ChangeRange(float newRange);
01328     void ChangeAmount(int newAmount);
01329     void Remove(); 
01330 
01331     bool WantToDie()
01332     {
01333         return wantToDie;
01334     }
01335 
01336 private:
01337     bool wantToDie;
01338     int spawnID;           
01339     uint32 itemID;         
01340     csVector3 pos;         
01341     psSectorInfo* sector;  
01342     InstanceID worldInstance;     
01343     int interval;          
01344     int maxrnd;            
01345     float range;           
01346     int lock_str;          
01347     int lock_skill;        
01348     csString flags;        
01349 };
01350 
01353 #endif