From f203559ecbf79674a34192682384a44f5fc548bf Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 13 Nov 2020 10:37:28 +0800 Subject: [PATCH] Update client inventory when item name is changed --- nel/include/nel/misc/deep_ptr.h | 3 +++ ryzom/common/src/game_share/inventories.cpp | 2 ++ ryzom/common/src/game_share/inventories.h | 3 +++ .../game_item_manager/game_item.cpp | 13 +++++++++++-- .../game_item_manager/game_item.h | 3 ++- .../game_item_manager/game_item_manager.cpp | 2 +- .../game_item_manager/guild_inv.cpp | 4 ++-- .../player_manager/character.cpp | 4 ++-- .../character_inventory_manipulation.cpp | 4 +--- .../player_manager/persistent_player_data.cpp | 4 ++-- 10 files changed, 29 insertions(+), 13 deletions(-) diff --git a/nel/include/nel/misc/deep_ptr.h b/nel/include/nel/misc/deep_ptr.h index 087b1d84b..76493c6e4 100644 --- a/nel/include/nel/misc/deep_ptr.h +++ b/nel/include/nel/misc/deep_ptr.h @@ -46,6 +46,9 @@ public: NL_FORCE_INLINE bool operator==(const T *p) const { return (m == p) || (m && p && *m == *p); } NL_FORCE_INLINE bool operator!=(const T *p) const { return !(*this == p); } + NL_FORCE_INLINE bool operator==(const T &p) const { return (m == &p) || (m && *m == p); } + NL_FORCE_INLINE bool operator!=(const T &p) const { return !(*this == p); } + NL_FORCE_INLINE bool operator==(long int p) const { return (*this == (const T *)(ptrdiff_t)p); } //< == NULL NL_FORCE_INLINE bool operator!=(long int p) const { return (*this != (const T *)(ptrdiff_t)p); } //< != NULL diff --git a/ryzom/common/src/game_share/inventories.cpp b/ryzom/common/src/game_share/inventories.cpp index 446b9db38..e7de9ca27 100644 --- a/ryzom/common/src/game_share/inventories.cpp +++ b/ryzom/common/src/game_share/inventories.cpp @@ -125,3 +125,5 @@ namespace INVENTORIES { "SHEET", "QUALITY", "QUANTITY", "USER_COLOR", "BUFFS", "LOCKED", "ACCESS", "WEIGHT", "NAMEID", "ENCHANT", "RM_CLASS_TYPE", "RM_FABER_STAT_TYPE", "PREREQUISIT_VALID", "PRICE", "RESALE_FLAG", "WORNED" }; const uint CItemSlot::DataBitSize [NbItemPropId] = { 32, 10, 10, 3, 8, 10, 2, 16, 32, 10, 3, 5, 1, 32, 2, 1, }; + +} diff --git a/ryzom/common/src/game_share/inventories.h b/ryzom/common/src/game_share/inventories.h index ce86d215d..a31eb1af3 100644 --- a/ryzom/common/src/game_share/inventories.h +++ b/ryzom/common/src/game_share/inventories.h @@ -482,6 +482,9 @@ enum TItemChange itc_lock_state = 1<<6, itc_info_version = 1<<7, itc_worned = 1<<8, + itc_owner_locked = itc_lock_state, + itc_access_grade = itc_lock_state, + itc_name = itc_lock_state, }; typedef NLMISC::CEnumBitset TItemChangeFlags; diff --git a/ryzom/server/src/entities_game_service/game_item_manager/game_item.cpp b/ryzom/server/src/entities_game_service/game_item_manager/game_item.cpp index e0dc3cd6e..fe63153ca 100644 --- a/ryzom/server/src/entities_game_service/game_item_manager/game_item.cpp +++ b/ryzom/server/src/entities_game_service/game_item_manager/game_item.cpp @@ -1151,7 +1151,7 @@ void CGameItem::setLockedByOwner(bool value) if (value != _LockedByOwner) { _LockedByOwner = value; - callItemChanged(INVENTORIES::TItemChangeFlags(INVENTORIES::itc_lock_state)); + callItemChanged(INVENTORIES::TItemChangeFlags(INVENTORIES::itc_owner_locked)); } } @@ -1160,7 +1160,16 @@ void CGameItem::setAccessGrade(EGSPD::CGuildGrade::TGuildGrade value) if (value != _AccessGrade) { _AccessGrade = value; - callItemChanged(INVENTORIES::TItemChangeFlags(INVENTORIES::itc_lock_state)); + callItemChanged(INVENTORIES::TItemChangeFlags(INVENTORIES::itc_access_grade)); + } +} + +void CGameItem::setPhraseId(const std::string &str, bool literal = false) +{ + if (literal != _PhraseLiteral || _PhraseId != str) + { + setPhraseIdInternal(str, literal); + callItemChanged(INVENTORIES::TItemChangeFlags(INVENTORIES::itc_name)); } } diff --git a/ryzom/server/src/entities_game_service/game_item_manager/game_item.h b/ryzom/server/src/entities_game_service/game_item_manager/game_item.h index aefbb1257..403678901 100644 --- a/ryzom/server/src/entities_game_service/game_item_manager/game_item.h +++ b/ryzom/server/src/entities_game_service/game_item_manager/game_item.h @@ -489,7 +489,8 @@ public : /// accessors to the item phrase const std::string &getPhraseId() const { static const std::string empty; return _PhraseId ? *_PhraseId : empty; } bool isPhraseLiteral() const { return _PhraseLiteral; } - void setPhraseId(const std::string &str, bool literal = false) { if (!_PhraseId) _PhraseId = new std::string(); *_PhraseId = str; _PhraseLiteral = literal; } + void setPhraseIdInternal(const std::string &str, bool literal = false) { if (!_PhraseId) _PhraseId = new std::string(); *_PhraseId = str; _PhraseLiteral = literal; } + void setPhraseId(const std::string &str, bool literal = false); // return the enchantment value to be displayed in the client uint16 getClientEnchantValue() const; diff --git a/ryzom/server/src/entities_game_service/game_item_manager/game_item_manager.cpp b/ryzom/server/src/entities_game_service/game_item_manager/game_item_manager.cpp index 9f8b47fbd..1d9fad62e 100644 --- a/ryzom/server/src/entities_game_service/game_item_manager/game_item_manager.cpp +++ b/ryzom/server/src/entities_game_service/game_item_manager/game_item_manager.cpp @@ -466,7 +466,7 @@ CGameItemPtr CGameItemManager::createInGameItem( uint16 quality, uint32 quantity item = sellingItem->getItemCopy(); item->quality( quality ); if ( phraseId ) - item->setPhraseId(*phraseId); + item->setPhraseIdInternal(*phraseId); } else if (sheet == preorderSheetId) { diff --git a/ryzom/server/src/entities_game_service/game_item_manager/guild_inv.cpp b/ryzom/server/src/entities_game_service/game_item_manager/guild_inv.cpp index 369472864..4d131acb2 100644 --- a/ryzom/server/src/entities_game_service/game_item_manager/guild_inv.cpp +++ b/ryzom/server/src/entities_game_service/game_item_manager/guild_inv.cpp @@ -141,11 +141,11 @@ void CGuildInventoryView::updateClientSlot(uint32 slot) itemSlot.setItemProp( INVENTORIES::Locked, 0 ); itemSlot.setItemProp( INVENTORIES::Access, item->getAccessGrade() ); itemSlot.setItemProp( INVENTORIES::Weight, item->weight() / 10 ); - itemSlot.setItemProp( INVENTORIES::NameId, 0 ); // TODO: name of guild (item->sendNameId()) + itemSlot.setItemProp( INVENTORIES::NameId, 0 ); // TODO: send name to all guild members (item->sendNameId()) itemSlot.setItemProp( INVENTORIES::Enchant, item->getClientEnchantValue() ); itemSlot.setItemProp( INVENTORIES::ItemClass, item->getItemClass() ); itemSlot.setItemProp( INVENTORIES::ItemBestStat, item->getCraftParameters() == 0 ? RM_FABER_STAT_TYPE::Unknown : item->getCraftParameters()->getBestItemStat() ); - itemSlot.setItemProp( INVENTORIES::PrerequisitValid, 1 ); // TODO: per user prereq + itemSlot.setItemProp( INVENTORIES::PrerequisitValid, 1 ); // TODO: can we send prereq per user? itemSlot.setItemProp( INVENTORIES::Price, 0 ); itemSlot.setItemProp( INVENTORIES::ResaleFlag, 0 ); _GuildInvUpdater.setItemProps( INVENTORIES::CInventoryCategoryForGuild::GuildInvId, itemSlot ); diff --git a/ryzom/server/src/entities_game_service/player_manager/character.cpp b/ryzom/server/src/entities_game_service/player_manager/character.cpp index 13f6342f7..693291423 100644 --- a/ryzom/server/src/entities_game_service/player_manager/character.cpp +++ b/ryzom/server/src/entities_game_service/player_manager/character.cpp @@ -18765,7 +18765,7 @@ uint32 CPetAnimal::initLinkAnimalToTicket( CCharacter * c, uint8 index ) // Slot = ItemPtr->getLocSlot(); ItemPtr->setPetIndex(index); #ifdef RYZOM_FORGE_PET_NAME - ItemPtr->setPhraseId(CustomName, true); + ItemPtr->setPhraseIdInternal(CustomName, true); #endif Slot = ItemPtr->getInventorySlot(); return Slot; @@ -18781,7 +18781,7 @@ uint32 CPetAnimal::initLinkAnimalToTicket( CCharacter * c, uint8 index ) Slot = ItemPtr->getInventorySlot(); ItemPtr->setPetIndex(index); #ifdef RYZOM_FORGE_PET_NAME - ItemPtr->setPhraseId(CustomName, true); + ItemPtr->setPhraseIdInternal(CustomName, true); #endif return Slot; } diff --git a/ryzom/server/src/entities_game_service/player_manager/character_inventory_manipulation.cpp b/ryzom/server/src/entities_game_service/player_manager/character_inventory_manipulation.cpp index 90379a49f..002d09892 100644 --- a/ryzom/server/src/entities_game_service/player_manager/character_inventory_manipulation.cpp +++ b/ryzom/server/src/entities_game_service/player_manager/character_inventory_manipulation.cpp @@ -1637,7 +1637,7 @@ CGameItemPtr CCharacter::createItem(uint16 obtainedQuality, uint32 quantity, con item = sellingItem->getItemCopy(); item->quality(obtainedQuality); if (phraseId) - item->setPhraseId(*phraseId); + item->setPhraseIdInternal(*phraseId); } else if (obtainedItem == preorderSheetId) { @@ -2442,8 +2442,6 @@ void CCharacter::sendItemInfos( uint16 slotId ) infos.TypeSkillMods = item->getTypeSkillMods(); - infos.AccessGrade = item->getAccessGrade(); - infos.CustomText = item->getCustomText(); CMessage msgout( "IMPULSION_ID" ); diff --git a/ryzom/server/src/entities_game_service/player_manager/persistent_player_data.cpp b/ryzom/server/src/entities_game_service/player_manager/persistent_player_data.cpp index db29d0090..be0b97bce 100644 --- a/ryzom/server/src/entities_game_service/player_manager/persistent_player_data.cpp +++ b/ryzom/server/src/entities_game_service/player_manager/persistent_player_data.cpp @@ -1343,7 +1343,7 @@ private: PROP2(_HP, uint32, _HP, _HP=val)\ PROP2(_Recommended, uint32, _Recommended, _Recommended=val)\ PROP2(_CreatorId, CEntityId, _CreatorId, _CreatorId=val)\ - PROP2(_PhraseId, string, getPhraseId(), setPhraseId(val))\ + PROP2(_PhraseId, string, getPhraseId(), setPhraseIdInternal(val))\ LPROP2(_PhraseLiteral, bool, if (_PhraseLiteral), _PhraseLiteral, _PhraseLiteral=val)\ LSTRUCT2(_CraftParameters, if (_CraftParameters), _CraftParameters->store(pdr), _CraftParameters = new CItemCraftParameters; _CraftParameters->apply(pdr))\ LPROP2(_SlotImage, uint16, if (0), 0xffff, slotImage=val) /* Very old version compatibility */ \ @@ -1363,7 +1363,7 @@ private: STRUCT_VECT(_TypeSkillMods)\ LPROP_VECT(CSheetId, _Enchantment, VECT_LOGIC(_Enchantment) if (_Enchantment[i]!=CSheetId::Unknown))\ PROP2(_CustomText, string, getCustomText(), setCustomText(val))\ - LPROP2(_CustomName, string, if (false), string(), setPhraseId(val, true)) /* Ryzom Forge compatibility, replaced by _PhraseLiteral */ \ + LPROP2(_CustomName, string, if (false), string(), setPhraseIdInternal(val, true)) /* Ryzom Forge compatibility, replaced by _PhraseLiteral */ \ PROP(bool, _Movable)\ PROP(bool, _UnMovable)\ PROP(bool, _LockedByOwner)\