From: DaveG <da...@us...> - 2005-12-21 23:40:58
|
Update of /cvsroot/planeshift/planeshift/src/server/bulkobjects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9895/src/server/bulkobjects Modified Files: psitem.cpp psitem.h Log Message: Code and comment cleanups, simplifications/optimizations, and general futzing... Index: psitem.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/psitem.cpp,v retrieving revision 1.137 retrieving revision 1.138 diff -C2 -d -r1.137 -r1.138 *** psitem.cpp 20 Dec 2005 04:50:26 -0000 1.137 --- psitem.cpp 21 Dec 2005 23:40:46 -0000 1.138 *************** *** 725,739 **** } - - uint64 psItem::GetUID() - { - return uid; - } - - const char *psItem::GetUIDStr() - { - return uid_str; - } - void psItem::SetUID(uint64 v) { --- 725,728 ---- *************** *** 742,750 **** } - unsigned short psItem::GetStackCount() - { - return stack_count; - } - void psItem::SetStackCount(unsigned short v) { --- 731,734 ---- *************** *** 755,764 **** } - - unsigned int psItem::GetCrafterID() - { - return crafter_id; - } - void psItem::SetCrafterID(unsigned int v) { --- 739,742 ---- *************** *** 768,776 **** } - unsigned int psItem::GetGuildID() - { - return guild_id; - } - void psItem::SetGuildID(unsigned int v) { --- 746,749 ---- *************** *** 791,799 **** } - float psItem::GetItemDecay() - { - return item_decay; - } - void psItem::SetItemDecay(float v) { --- 764,767 ---- *************** *** 1250,1263 **** - float psItem::GetSumWeight() - { - return sum_weight; - } - - float psItem::GetSumSize() - { - return (float) GetSize()*stack_count; - } - float psItem::AdjustSumWeight(float delta) { --- 1218,1221 ---- *************** *** 1355,1363 **** } - psItemStats *psItem::GetBaseStats() - { - return base_stats; - } - void psItem::SetCurrentStats(psItemStats *statptr) { --- 1313,1316 ---- *************** *** 1366,1374 **** } - psItemStats *psItem::GetCurrentStats() - { - return current_stats; - } - void psItem::RecalcCurrentStats() { --- 1319,1322 ---- *************** *** 1458,1464 **** - - - bool psItem::CheckStackableWith(psItem *otheritem) { --- 1406,1409 ---- *************** *** 1508,1516 **** } - psItem *psItem::CreateNew() - { - return new psItem(); - } - psItem *psItem::Copy(unsigned short newstackcount) { --- 1453,1456 ---- *************** *** 1854,1858 **** - // Removed until future implementation to avoid confusion /* --- 1794,1797 ---- *************** *** 2046,2054 **** } - bool psItem::GetIsLocked() - { - return (flags & PSITEM_FLAG_LOCKED); - } - void psItem::SetIsLocked(bool v) { --- 1985,1988 ---- *************** *** 2061,2069 **** } - bool psItem::GetIsLockable() - { - return (flags & PSITEM_FLAG_LOCKABLE); - } - void psItem::SetIsLockable(bool v) { --- 1995,1998 ---- *************** *** 2076,2084 **** } - bool psItem::GetIsKey() - { - return (flags & PSITEM_FLAG_KEY); - } - void psItem::SetIsKey(bool v) { --- 2005,2008 ---- *************** *** 2091,2114 **** } - PSSKILL psItem::GetLockpickSkill() - { - return lockpickSkill; - } - - void psItem::SetLockpickSkill(PSSKILL v) - { - lockpickSkill = v; - } - - unsigned int psItem::GetLockStrength() - { - return lockStrength; - } - - void psItem::SetLockStrength(unsigned int v) - { - lockStrength = v; - } - bool psItem::CanOpenLock(unsigned int id) { --- 2015,2018 ---- *************** *** 2349,2367 **** } - csTicks psSheduledItem::GetLastSpawn() - { - return lastSpawn; - } - - psSectorInfo* psSheduledItem::GetSector() - { - return sector; - } - - csVector3& psSheduledItem::GetPosition() - { - return pos; - } - int psSheduledItem::MakeInterval() { --- 2253,2256 ---- Index: psitem.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/psitem.h,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** psitem.h 1 Dec 2005 22:09:34 -0000 1.82 --- psitem.h 21 Dec 2005 23:40:46 -0000 1.83 *************** *** 204,208 **** /** Return a string identifying this object as an Item */ ! virtual const char * GetItemType(){ return "Item"; } gemItem* GetGemObject() { return gItem; } --- 204,208 ---- /** Return a string identifying this object as an Item */ ! virtual const char * GetItemType() { return "Item"; } gemItem* GetGemObject() { return gItem; } *************** *** 361,367 **** * Items are initially created with a UID of 0. Save() generates a unique item id. */ ! uint64 GetUID(); ///Returns the unique item id in string form ! const char *GetUIDStr(); /** Sets the Unique ID of this item. DO NOT CALL THIS. * This should ONLY be called internally or from psCharacterLoader. --- 361,367 ---- * Items are initially created with a UID of 0. Save() generates a unique item id. */ ! uint64 GetUID() { return uid; } ///Returns the unique item id in string form ! const char *GetUIDStr() { return uid_str; } /** Sets the Unique ID of this item. DO NOT CALL THIS. * This should ONLY be called internally or from psCharacterLoader. *************** *** 369,377 **** void SetUID(uint64 v); - /// Returns true if the crafter character ID is valid bool GetIsCrafterIDValid(); /// Set wether the crafter ID is valid. SetCrafterID() sets this to true for you. void SetIsCrafterIDValid(bool v); /// Returns true if the certifying guild ID is valid bool GetIsGuildIDValid(); --- 369,377 ---- void SetUID(uint64 v); /// Returns true if the crafter character ID is valid bool GetIsCrafterIDValid(); /// Set wether the crafter ID is valid. SetCrafterID() sets this to true for you. void SetIsCrafterIDValid(bool v); + /// Returns true if the certifying guild ID is valid bool GetIsGuildIDValid(); *************** *** 379,389 **** void SetIsGuildIDValid(bool v); /// Returns the UID for the crafter of this item. Be sure to check GetIsCrafterIDValid()! ! unsigned int GetCrafterID(); /// Sets the UID for the cracter of this item. Generally used immediately after completing the crafting work. void SetCrafterID(unsigned int v); /// Returns the UID for the guild who has certified this item. Be sure to check GetIsGuildIDValid()! ! unsigned int GetGuildID(); /// Sets the UID for the guild certifying this item. void SetGuildID(unsigned int v); /// Gets the quality of the item. float GetItemQuality(); --- 379,392 ---- void SetIsGuildIDValid(bool v); /// Returns the UID for the crafter of this item. Be sure to check GetIsCrafterIDValid()! ! ! unsigned int GetCrafterID() { return crafter_id; } /// Sets the UID for the cracter of this item. Generally used immediately after completing the crafting work. void SetCrafterID(unsigned int v); + /// Returns the UID for the guild who has certified this item. Be sure to check GetIsGuildIDValid()! ! unsigned int GetGuildID() { return guild_id; } /// Sets the UID for the guild certifying this item. void SetGuildID(unsigned int v); + /// Gets the quality of the item. float GetItemQuality(); *************** *** 393,401 **** /// Set the item decay factor void SetItemDecay(float v); - /// Get the item decay factor ! float GetItemDecay(); ! ! /** Returns true if this item is based off of unique statistics. --- 396,401 ---- /// Set the item decay factor void SetItemDecay(float v); /// Get the item decay factor ! float GetItemDecay() { return item_decay; } /** Returns true if this item is based off of unique statistics. *************** *** 427,431 **** /** Creates a new blank instance of it's class (i.e. psItem or its subclass) */ ! virtual psItem *CreateNew(); /** Duplicates an item instance. --- 427,431 ---- /** Creates a new blank instance of it's class (i.e. psItem or its subclass) */ ! virtual psItem *CreateNew() { return new psItem(); } /** Duplicates an item instance. *************** *** 456,460 **** * * WARNING: caller must regard the 'stackme' pointer as invalid and must not access it any more - * */ psItem * CombineStack(psItem * stackme); --- 456,459 ---- *************** *** 470,475 **** /// Sets the decay value of the item. See the decay member for a description of what this is. void SetDecay(float v); /// Returns the stack count. Be sure to call GetIsStackable() first! ! unsigned short GetStackCount(); /** Sets the stack count. Be sure to call GetIsStackable() first! * Don't call this to try and combine or split stacks! That logic is done in CombineStack() --- 469,475 ---- /// Sets the decay value of the item. See the decay member for a description of what this is. void SetDecay(float v); + /// Returns the stack count. Be sure to call GetIsStackable() first! ! unsigned short GetStackCount() { return stack_count; } /** Sets the stack count. Be sure to call GetIsStackable() first! * Don't call this to try and combine or split stacks! That logic is done in CombineStack() *************** *** 507,516 **** * The UID isn't really useful outside of the database and maybe sending to clients as an ID. */ ! uint64 GetParentID() { if (container_parent!=NULL) return container_parent->GetUID(); return 0; } /** Returns the location of this item in it's parent item or in the players equipment, bulk or bank as appropriate. * */ ! unsigned int GetLocInParent() { return loc_in_parent; } /** DO NOT USE! DO NOT USE! DO NOT USE! --- 507,516 ---- * The UID isn't really useful outside of the database and maybe sending to clients as an ID. */ ! uint64 GetParentID() { if (container_parent!=NULL) return container_parent->GetUID(); return 0; } /** Returns the location of this item in it's parent item or in the players equipment, bulk or bank as appropriate. * */ ! unsigned int GetLocInParent() { return loc_in_parent; } /** DO NOT USE! DO NOT USE! DO NOT USE! *************** *** 519,532 **** * Look at TakeOutOfContainer() and AddItemToContainer() to do what you want to do. */ ! void SetLocInParent(unsigned int location); ! /// Returns the item in the specific slot of this container. Returns NULL if this is not a container or if there is no item in the requested slot. psItem *GetItemInSlot(unsigned int slot); /** Takes this item out of any container it's in. * This function adjusts the two way linkage, the owning player, and properties such as sum_weight of the parents. ! * Returns false if this item is not in a container. */ bool TakeOutOfContainer(); /** Put an item into this container item in any spot where it will fit, or any container within this container where it will fit. * This function adjusts the two way linkage, the owning player, and properties such as sum_weight of the parents. --- 519,535 ---- * Look at TakeOutOfContainer() and AddItemToContainer() to do what you want to do. */ ! void SetLocInParent(unsigned int location); ! /** Returns the item in the specific slot of this container. ! * Returns NULL if this is not a container or if there is no item in the requested slot. ! */ psItem *GetItemInSlot(unsigned int slot); /** Takes this item out of any container it's in. * This function adjusts the two way linkage, the owning player, and properties such as sum_weight of the parents. ! * Returns false if this item is not in a container. */ bool TakeOutOfContainer(); + /** Put an item into this container item in any spot where it will fit, or any container within this container where it will fit. * This function adjusts the two way linkage, the owning player, and properties such as sum_weight of the parents. *************** *** 546,549 **** --- 549,553 ---- */ bool AddItemToContainer(psItem *addme,unsigned int slot); + /** Swaps, moves, removes, and puts based on count in a container. * For drag and drop mostly. Different from and take and add in that you can split counts. *************** *** 552,557 **** bool MoveItemsInContainer(unsigned int fromSlot, unsigned int toSlot, int count); psItem *RemoveItemsInContainer(unsigned int fromSlot, int count); ! ! PS_CONTAINER_ERROR PutItemsInContainer(unsigned int toSlot, psItem *item, psCharacter* owner); --- 556,560 ---- bool MoveItemsInContainer(unsigned int fromSlot, unsigned int toSlot, int count); psItem *RemoveItemsInContainer(unsigned int fromSlot, int count); ! PS_CONTAINER_ERROR PutItemsInContainer(unsigned int toSlot, psItem *item, psCharacter* owner); *************** *** 561,565 **** /// Returns the sum weight of this item and all contained items ! float GetSumWeight(); /** DO NOT USE! HELPER FUNCTION! --- 564,568 ---- /// Returns the sum weight of this item and all contained items ! float GetSumWeight() { return sum_weight; } /** DO NOT USE! HELPER FUNCTION! *************** *** 594,598 **** * Do not use for retrieval of values for calculations (such as damage). */ ! psItemStats *GetBaseStats(); /** Sets the current item stats. DO NOT USE! --- 597,601 ---- * Do not use for retrieval of values for calculations (such as damage). */ ! psItemStats *GetBaseStats() { return base_stats; } /** Sets the current item stats. DO NOT USE! *************** *** 606,610 **** * */ ! psItemStats *GetCurrentStats(); /** In some cases some modifiers or effects may be difficult to reverse (for example percent bonuses applied and removed in different orders). --- 609,613 ---- * */ ! psItemStats *GetCurrentStats() { return current_stats; } /** In some cases some modifiers or effects may be difficult to reverse (for example percent bonuses applied and removed in different orders). *************** *** 624,628 **** */ - /** Returns a unique ID that can be assigned to an item instance being created. * --- 627,630 ---- *************** *** 633,637 **** */ static uint64 GetNextItemUID(); - /** Returns a unique ID that can be assigned to a new Unique ItemStats entry being created. * --- 635,638 ---- *************** *** 662,665 **** --- 663,667 ---- const char *GetName(); const char *GetDescription(); + PSITEMSTATS_WEAPONTYPE GetWeaponType(); PSSKILL GetWeaponSkill(PSITEMSTATS_WEAPONSKILL_INDEX index); *************** *** 679,686 **** PSITEMSTATS_STAT GetWeaponAttributeBonusType(PSITEMSTATS_STAT_BONUS_INDEX index); float GetWeaponAttributeBonusMax(PSITEMSTATS_STAT_BONUS_INDEX index); float GetWeight(); unsigned short GetSize(); ! /** Gets the total size of the items in the stack. */ ! float GetSumSize(); unsigned short GetContainerMaxSize(); --- 681,689 ---- PSITEMSTATS_STAT GetWeaponAttributeBonusType(PSITEMSTATS_STAT_BONUS_INDEX index); float GetWeaponAttributeBonusMax(PSITEMSTATS_STAT_BONUS_INDEX index); + float GetWeight(); unsigned short GetSize(); ! /// Gets the total size of the items in the stack. ! float GetSumSize() { return (float)GetSize()*stack_count; } unsigned short GetContainerMaxSize(); *************** *** 689,698 **** float GetDecayResistance(); psMoney& GetPrice(); ! psMoney GetSellPrice(); // Merchants want a percentage psItemCategory* GetCategory(); float GetVisibleDistance(); - void GetLocationInWorld(psSectorInfo **sectorinfo,float &loc_x,float &loc_y,float &loc_z,float &loc_yrot); void SetLocationInWorld(psSectorInfo *sectorinfo,float loc_x,float loc_y,float loc_z,float loc_yrot); --- 692,700 ---- float GetDecayResistance(); psMoney& GetPrice(); ! psMoney GetSellPrice(); ///< Merchants want a percentage psItemCategory* GetCategory(); float GetVisibleDistance(); void GetLocationInWorld(psSectorInfo **sectorinfo,float &loc_x,float &loc_y,float &loc_z,float &loc_yrot); void SetLocationInWorld(psSectorInfo *sectorinfo,float loc_x,float loc_y,float loc_z,float loc_yrot); *************** *** 721,731 **** double GetProperty(const char *ptr); ! bool GetIsLocked(); void SetIsLocked(bool v); ! bool GetIsLockable(); void SetIsLockable(bool v); ! bool GetIsKey(); void SetIsKey(bool v); --- 723,733 ---- double GetProperty(const char *ptr); ! bool GetIsLocked() { return (flags & PSITEM_FLAG_LOCKED); } void SetIsLocked(bool v); ! bool GetIsLockable() { return (flags & PSITEM_FLAG_LOCKABLE); } void SetIsLockable(bool v); ! bool GetIsKey() { return (flags & PSITEM_FLAG_KEY); } void SetIsKey(bool v); *************** *** 734,742 **** void SetIsPickupable(bool v); ! PSSKILL GetLockpickSkill(); ! void SetLockpickSkill(PSSKILL v); ! unsigned int GetLockStrength(); ! void SetLockStrength(unsigned int v); bool CanOpenLock(unsigned int id); --- 736,744 ---- void SetIsPickupable(bool v); ! PSSKILL GetLockpickSkill() { return lockpickSkill; } ! void SetLockpickSkill(PSSKILL v) { lockpickSkill = v; } ! unsigned int GetLockStrength() { return lockStrength; } ! void SetLockStrength(unsigned int v) { lockStrength = v; } bool CanOpenLock(unsigned int id); *************** *** 747,760 **** bool GetIsSkeleton(); ! psSheduledItem* GetSheduledItem() { return shedule;} void SetSheduledItem(psSheduledItem* item) { shedule = item; } void SheduleRespawn(); ! void ItemAboutToMove(); // This is called before item is moved to another place ! // Checks if the 'item' parameter is direct or indirect parent of our item bool IsIndirectParent(psItem * item); ! // Gets the reduction of this weapon against the armor given float GetArmorVSWeaponResistance(psItemStats* armor); --- 749,762 ---- bool GetIsSkeleton(); ! psSheduledItem* GetSheduledItem() { return shedule; } void SetSheduledItem(psSheduledItem* item) { shedule = item; } void SheduleRespawn(); ! void ItemAboutToMove(); ///< This is called before item is moved to another place ! /// Checks if the 'item' parameter is direct or indirect parent of our item bool IsIndirectParent(psItem * item); ! /// Gets the reduction of this weapon against the armor given float GetArmorVSWeaponResistance(psItemStats* armor); *************** *** 812,816 **** gemItem* gItem; ! bool savingDisabled; //are saving requests (Save() calls) ignored ? }; --- 814,818 ---- gemItem* gItem; ! bool savingDisabled; ///< Are saving requests (Save() calls) ignored ? }; *************** *** 823,847 **** int GetItemID() { return itemID;} ! psSectorInfo* GetSector(); ! csVector3& GetPosition(); ! int MakeInterval(); // This will return a randomized interval int GetInterval() { return interval; } int GetMaxModifier() { return maxrnd; } ! csTicks GetLastSpawn(); void UpdatePosition(csVector3& positon, const char *sector); void ChangeIntervals(int newint, int newrand); ! void Remove(); // Deletes from the DB and everything - bool WantToDie(){return wantToDie;} private: bool wantToDie; ! int spawnID; // database id ! int itemID; // Item ! csVector3 pos; // Position ! psSectorInfo* sector; // Sector ! int interval; // Interval ! int maxrnd; // Maximum random interval modifier ! csTicks lastSpawn; // When we last spawned it, good for something perhaps? :) }; --- 825,850 ---- int GetItemID() { return itemID;} ! psSectorInfo* GetSector() { return sector; } ! csVector3& GetPosition() { return pos; } ! int MakeInterval(); ///< This will return a randomized interval int GetInterval() { return interval; } int GetMaxModifier() { return maxrnd; } ! csTicks GetLastSpawn() { return lastSpawn; } void UpdatePosition(csVector3& positon, const char *sector); void ChangeIntervals(int newint, int newrand); ! void Remove(); ///< Deletes from the DB and everything ! ! bool WantToDie() { return wantToDie; } private: bool wantToDie; ! int spawnID; ///< database id ! int itemID; ///< Item ! csVector3 pos; ///< Position ! psSectorInfo* sector; ///< Sector ! int interval; ///< Interval ! int maxrnd; ///< Maximum random interval modifier ! csTicks lastSpawn; ///< When we last spawned it, good for something perhaps? :) }; *************** *** 854,861 **** public: ~psItemSet(); ! /** Adds a psitem to this set. The parentid must be specified since this function is used at load time. ! * ! * ! */ void Add(psItem *item,uint64 parentid); bool ResolveAllParents(); --- 857,862 ---- public: ~psItemSet(); ! ! /// Adds a psitem to this set. The parentid must be specified since this function is used at load time. void Add(psItem *item,uint64 parentid); bool ResolveAllParents(); |