From d512d10f189fe69b9c2c3539ffc459f51b4569b0 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 13 Nov 2020 10:22:21 +0800 Subject: [PATCH] Add guild access grade bits to inventory summary --- ryzom/common/data_common/database.xml | 34 ++++++++++++------- ryzom/common/data_common/msg.xml | 3 ++ ryzom/common/src/game_share/bot_chat_types.h | 2 +- ryzom/common/src/game_share/characteristics.h | 3 ++ ryzom/common/src/game_share/inventories.cpp | 5 ++- ryzom/common/src/game_share/inventories.h | 31 ++++++++--------- ryzom/common/src/game_share/item_family.h | 3 ++ ryzom/common/src/game_share/item_infos.cpp | 4 +-- ryzom/common/src/game_share/item_infos.h | 10 +++--- ryzom/common/src/game_share/item_origin.h | 3 ++ ryzom/common/src/game_share/item_type.h | 3 ++ ryzom/common/src/game_share/skills.h | 3 ++ .../game_item_manager/game_item.cpp | 9 +++++ .../game_item_manager/game_item.h | 21 +++++++++--- .../game_item_manager/guild_inv.cpp | 7 ++-- .../game_item_manager/player_inventory.cpp | 11 ++++-- .../character_inventory_manipulation.cpp | 6 ++-- .../player_manager/persistent_player_data.cpp | 7 ++-- 18 files changed, 111 insertions(+), 54 deletions(-) diff --git a/ryzom/common/data_common/database.xml b/ryzom/common/data_common/database.xml index ce8eab025..07dafdff1 100644 --- a/ryzom/common/data_common/database.xml +++ b/ryzom/common/data_common/database.xml @@ -216,7 +216,8 @@ - + + @@ -241,13 +242,14 @@ - + + @@ -261,13 +263,14 @@ - + + @@ -293,13 +296,14 @@ - + + @@ -314,13 +318,14 @@ - + + @@ -345,13 +350,14 @@ - + + @@ -371,13 +377,14 @@ - + + @@ -407,14 +414,15 @@ - + - + + @@ -538,13 +546,14 @@ - + + @@ -713,14 +722,15 @@ - + - + + diff --git a/ryzom/common/data_common/msg.xml b/ryzom/common/data_common/msg.xml index af8650f69..4fd5657fb 100644 --- a/ryzom/common/data_common/msg.xml +++ b/ryzom/common/data_common/msg.xml @@ -166,6 +166,9 @@ + + + diff --git a/ryzom/common/src/game_share/bot_chat_types.h b/ryzom/common/src/game_share/bot_chat_types.h index 8e976049f..073ea1dd4 100644 --- a/ryzom/common/src/game_share/bot_chat_types.h +++ b/ryzom/common/src/game_share/bot_chat_types.h @@ -82,7 +82,7 @@ namespace BOTCHATTYPE ResaleKOBroken, // this item can't be sold because its Resold time has expired ResaleKONoTimeLeft, - // this item can't be sold because the owner has locked it (temporary hack to get around modifying database.xml) + // this item can't be sold because the owner has locked it ResaleKOLockedByOwner, NumBotChatResaleFlag diff --git a/ryzom/common/src/game_share/characteristics.h b/ryzom/common/src/game_share/characteristics.h index e2714fdf2..f984a3287 100644 --- a/ryzom/common/src/game_share/characteristics.h +++ b/ryzom/common/src/game_share/characteristics.h @@ -26,6 +26,9 @@ namespace CHARACTERISTICS { enum TCharacteristics +#ifdef NL_CPP14 + : uint8 +#endif { constitution = 0, //HP max metabolism, //Hp Regen diff --git a/ryzom/common/src/game_share/inventories.cpp b/ryzom/common/src/game_share/inventories.cpp index 71971bd81..2ac41313d 100644 --- a/ryzom/common/src/game_share/inventories.cpp +++ b/ryzom/common/src/game_share/inventories.cpp @@ -122,7 +122,6 @@ namespace INVENTORIES const char *InfoVersionStr = "INFO_VERSION"; const char *CItemSlot::ItemPropStr [NbItemPropId] = - { "SHEET", "QUALITY", "QUANTITY", "USER_COLOR", "CREATE_TIME", "SERIAL", "LOCKED", "WEIGHT", "NAMEID", "ENCHANT", "RM_CLASS_TYPE", "RM_FABER_STAT_TYPE", "PRICE", "RESALE_FLAG", "PREREQUISIT_VALID", "WORNED" }; + { "SHEET", "QUALITY", "QUANTITY", "USER_COLOR", "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, 32, 32, 10, 16, 32, 10, 3, 5, 32, 2, 1, 1 }; -} + { 32, 10, 10, 3, 10, 2, 16, 32, 10, 3, 5, 1, 32, 2, 1, }; \ No newline at end of file diff --git a/ryzom/common/src/game_share/inventories.h b/ryzom/common/src/game_share/inventories.h index 5558451e2..6c7d0673d 100644 --- a/ryzom/common/src/game_share/inventories.h +++ b/ryzom/common/src/game_share/inventories.h @@ -263,22 +263,21 @@ namespace INVENTORIES enum TItemPropId { Sheet, - Quality, - Quantity, - UserColor, - CreateTime, - Serial, - Locked, - Weight, - NameId, - Enchant, - ItemClass, - ItemBestStat, - Price, - ResaleFlag, - PrerequisitValid, - Worned, - NbItemPropId + Quality, + Quantity, + UserColor, + Locked, + Access, + Weight, + NameId, + Enchant, + ItemClass, + ItemBestStat, + PrerequisitValid, + Price, + ResaleFlag, + Worned, + NbItemPropId }; const uint NbBitsForItemPropId = 4; // TODO: replace this constant by an inline function using NbItemPropId diff --git a/ryzom/common/src/game_share/item_family.h b/ryzom/common/src/game_share/item_family.h index 68c3110b0..3237ad7c8 100644 --- a/ryzom/common/src/game_share/item_family.h +++ b/ryzom/common/src/game_share/item_family.h @@ -25,6 +25,9 @@ namespace ITEMFAMILY { // Mode enum EItemFamily +#ifdef NL_CPP14 + : uint8 +#endif { UNDEFINED = 0, SERVICE, diff --git a/ryzom/common/src/game_share/item_infos.cpp b/ryzom/common/src/game_share/item_infos.cpp index 02af62f45..f675aac39 100644 --- a/ryzom/common/src/game_share/item_infos.cpp +++ b/ryzom/common/src/game_share/item_infos.cpp @@ -73,7 +73,7 @@ CItemInfos::CItemInfos() LacustreMagicResistance = 0; JungleMagicResistance = 0; PrimaryRootMagicResistance = 0; - PetNumber = 0; // 1 based! + } void CItemInfos::serial(NLMISC::IStream & s) @@ -128,9 +128,9 @@ void CItemInfos::serial(NLMISC::IStream & s) s.serial(CastingSpeedFactor[i]); s.serial(MagicPowerFactor[i]); } + s.serial( CustomText ); s.serial( R2ItemDescription ); s.serial( R2ItemComment ); - s.serial( PetNumber ); } diff --git a/ryzom/common/src/game_share/item_infos.h b/ryzom/common/src/game_share/item_infos.h index 1a0746f3b..94d54c3bd 100644 --- a/ryzom/common/src/game_share/item_infos.h +++ b/ryzom/common/src/game_share/item_infos.h @@ -27,7 +27,7 @@ #include "characteristics.h" #include "sphrase_com.h" #include "type_skill_mod.h" - +#include "guild_grade.h" ///\structure defining the protection of an item struct SProtection @@ -136,10 +136,10 @@ public: CSPhraseCom Enchantment; float WearEquipmentMalus; // Malus for wearing this equipment (malus is used when execute an magic, forage action, craft action...), malus is only applicable for weapon and armor pieces - ucstring CustomText; // TODO: UTF-8 (serial) - ucstring R2ItemDescription; // TODO: UTF-8 (serial) - ucstring R2ItemComment; // TODO: UTF-8 (serial) - uint8 PetNumber; // 1 based pet index + std::string CustomText; + std::string R2ItemDescription; + std::string R2ItemComment; + //@} }; diff --git a/ryzom/common/src/game_share/item_origin.h b/ryzom/common/src/game_share/item_origin.h index 28e3e81ac..a0deea496 100644 --- a/ryzom/common/src/game_share/item_origin.h +++ b/ryzom/common/src/game_share/item_origin.h @@ -26,6 +26,9 @@ namespace ITEM_ORIGIN { enum EItemOrigin +#ifdef NL_CPP14 + : uint8 +#endif { COMMON = 0, FYROS, diff --git a/ryzom/common/src/game_share/item_type.h b/ryzom/common/src/game_share/item_type.h index d5dbb2ac9..105e8f0eb 100644 --- a/ryzom/common/src/game_share/item_type.h +++ b/ryzom/common/src/game_share/item_type.h @@ -26,6 +26,9 @@ namespace ITEM_TYPE // Mode // nb : sell filter uses two 64b database values to build a bitfield, so the item type limit is 128 for now enum TItemType +#ifdef NL_CPP14 + : uint8 +#endif { DAGGER, SWORD, diff --git a/ryzom/common/src/game_share/skills.h b/ryzom/common/src/game_share/skills.h index 937158b6a..090fe18b0 100644 --- a/ryzom/common/src/game_share/skills.h +++ b/ryzom/common/src/game_share/skills.h @@ -27,6 +27,9 @@ namespace SKILLS { enum ESkills +#ifdef NL_CPP14 + : uint8 +#endif { SC = 0, SCA, 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 349846ca6..ff4abc76e 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 @@ -1155,6 +1155,15 @@ void CGameItem::setLockedByOwner(bool value) } } +void CGameItem::setAccessGrade(EGSPD::CGuildGrade::TGuildGrade value) +{ + if (value != _AccessGrade) + { + _AccessGrade = value; + callItemChanged(INVENTORIES::TItemChangeFlags(INVENTORIES::itc_lock_state)); + } +} + //----------------------------------------------- // getCopy : //----------------------------------------------- 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 1f7254be5..dab160a0a 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 @@ -34,6 +34,7 @@ #include "game_share/type_skill_mod.h" #include "game_share/resistance_type.h" #include "game_share/skills.h" +#include "game_share/guild_grade.h" #include "egs_log_filter.h" #include "player_inventory.h" @@ -442,7 +443,7 @@ public : // get maximum piercing protection uint32 maxPiercingProtection() const; // get color - uint8 color() const { return _CraftParameters == 0 ? 1 : _CraftParameters->Color; } + uint8 color() const { return _CraftParameters == 0 ? DefaultColor : _CraftParameters->Color; } // get one of the three possible protection, legal protection number are 1,2 or 3 void magicProtection(uint32 protectionNumber, PROTECTION_TYPE::TProtectionType& protectionType, uint32& protectionValue) const; @@ -659,6 +660,8 @@ public : inline bool getLockedByOwner() const { return _LockedByOwner; } void setLockedByOwner(bool value); + inline EGSPD::CGuildGrade::TGuildGrade getAccessGrade() const { return _AccessGrade; } + void setAccessGrade(EGSPD::CGuildGrade::TGuildGrade value); inline bool getMovable() const { return _Movable; } inline void setMovable(bool value) { _Movable = value; } @@ -699,7 +702,7 @@ public : protected: friend class CFaberPhrase; // set Default Color (for craft only) - void setDefaultColor() { if( _CraftParameters ) _CraftParameters->Color = 1; } + void setDefaultColor() { if( _CraftParameters ) _CraftParameters->Color = DefaultColor; } /// set link information between item and container inventory (used by CInventoryBase) void setInventory(const CInventoryPtr &inv, uint32 slot); @@ -866,13 +869,15 @@ private: uint32 _LockCount; // required skill - SKILLS::ESkills _RequiredSkill; - SKILLS::ESkills _RequiredSkill2; - CHARACTERISTICS::TCharacteristics _RequiredCharac; uint16 _RequiredSkillLevel; uint16 _RequiredSkillLevel2; /// min required stat level and required stat uint16 _RequiredCharacLevel; + // required skill + SKILLS::ESkills _RequiredSkill; + SKILLS::ESkills _RequiredSkill2; + /// min required stat level and required stat + CHARACTERISTICS::TCharacteristics _RequiredCharac; /// whether the item has any skill requirements bool _HasPrerequisit; bool _UseNewSystemRequirement; @@ -881,6 +886,8 @@ private: bool _PhraseLiteral; bool _LockedByOwner; + EGSPD::CGuildGrade::TGuildGrade _AccessGrade; + bool _UnMovable; bool _Movable; uint8 _PetIndex; @@ -892,6 +899,10 @@ private: // true if the item is on the ground // bool _IsOnTheGround; +public: + static const EGSPD::CGuildGrade::TGuildGrade DefaultAccessGrade = EGSPD::CGuildGrade::HighOfficer; + static const uint8 DefaultColor = 1; + }; /** 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 1a353c46b..9f9378b03 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 @@ -138,14 +138,15 @@ void CGuildInventoryView::updateClientSlot(uint32 slot) itemSlot.setItemProp( INVENTORIES::Quantity, item->getStackSize() ); itemSlot.setItemProp( INVENTORIES::UserColor, item->color() ); 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::Enchant, item->getClientEnchantValue() ); - itemSlot.setItemProp( INVENTORIES::Price, 0 ); - itemSlot.setItemProp( INVENTORIES::ResaleFlag, 0 ); 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 ); + itemSlot.setItemProp( INVENTORIES::PrerequisitValid, 1 ); // TODO: per user prereq + 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/game_item_manager/player_inventory.cpp b/ryzom/server/src/entities_game_service/game_item_manager/player_inventory.cpp index ea832b494..7cdf2e095 100644 --- a/ryzom/server/src/entities_game_service/game_item_manager/player_inventory.cpp +++ b/ryzom/server/src/entities_game_service/game_item_manager/player_inventory.cpp @@ -1071,6 +1071,14 @@ void CCharacterInvView::updateClientSlot(uint32 slot, const CGameItemPtr item) { resaleFlag = BOTCHATTYPE::ResaleKOLockedByOwner; } + else if (item->durability() == item->maxDurability()) + { + resaleFlag = BOTCHATTYPE::ResaleOk; + } + else + { + resaleFlag = BOTCHATTYPE::ResaleKOBroken; + } const INVENTORIES::TItemId &itemId = item->getItemId(); @@ -1079,9 +1087,8 @@ void CCharacterInvView::updateClientSlot(uint32 slot, const CGameItemPtr item) itemSlot.setItemProp( INVENTORIES::Quality, item->quality() ); itemSlot.setItemProp( INVENTORIES::Quantity, item->getStackSize() ); itemSlot.setItemProp( INVENTORIES::UserColor, item->color() ); - itemSlot.setItemProp( INVENTORIES::CreateTime, itemId.getCreateTime() ); - itemSlot.setItemProp( INVENTORIES::Serial, itemId.getSerialNumber() ); itemSlot.setItemProp( INVENTORIES::Locked, item->getLockCount() ); + itemSlot.setItemProp( INVENTORIES::Access, item->getAccessGrade() ); itemSlot.setItemProp( INVENTORIES::Weight, item->weight() / 10 ); itemSlot.setItemProp( INVENTORIES::NameId, item->sendNameId(getCharacter()) ); itemSlot.setItemProp( INVENTORIES::Enchant, item->getClientEnchantValue() ); 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 0f93f1eed..90379a49f 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 @@ -2385,8 +2385,8 @@ void CCharacter::sendItemInfos( uint16 slotId ) const R2::TMissionItem * itemDesc = CR2MissionItem::getInstance().getR2ItemDefinition( currentSessionId(), item->getSheetId() ); if( itemDesc != 0 ) { - infos.R2ItemDescription = itemDesc->Description; - infos.R2ItemComment = itemDesc->Comment; + infos.R2ItemDescription = itemDesc->Description.toUtf8(); + infos.R2ItemComment = itemDesc->Comment.toUtf8(); } } } @@ -2442,6 +2442,8 @@ 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 a6dbdfe7f..db29d0090 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 @@ -1366,8 +1366,9 @@ private: LPROP2(_CustomName, string, if (false), string(), setPhraseId(val, true)) /* Ryzom Forge compatibility, replaced by _PhraseLiteral */ \ PROP(bool, _Movable)\ PROP(bool, _UnMovable)\ - PROP(bool, _LockedByOwner) /* Ryzom Forge compatibility */\ - + PROP(bool, _LockedByOwner)\ + LPROP2(_AccessGrade, string, if (_AccessGrade != DefaultAccessGrade), CGuildGrade::toString(_AccessGrade), _AccessGrade = CGuildGrade::fromString(val))\ + //#pragma message( PERSISTENT_GENERATION_MESSAGE ) #include "game_share/persistent_data_template.h" @@ -1402,7 +1403,7 @@ private: LPROP(float,MaxSlashingProtection,if (MaxSlashingProtection!=0.0f))\ LPROP(float,MaxBluntProtection,if (MaxBluntProtection!=0.0f))\ LPROP(float,MaxPiercingProtection,if (MaxPiercingProtection!=0.0f))\ - LPROP(uint8,Color,if (Color!=1))\ + LPROP(uint8,Color,if (Color!=CGameItem::DefaultColor))\ LPROP(sint32,HpBuff,if (HpBuff!=0))\ LPROP(sint32,SapBuff,if (SapBuff!=0))\ LPROP(sint32,StaBuff,if (StaBuff!=0))\