Phrase literal flag for item name, replaces separate string, kaetemi/ryzomclassic#194

ryzomclassic-develop
kaetemi 4 years ago
parent 9eb7481c06
commit bc3a602ebc

@ -4924,18 +4924,14 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", "<user id> <web_app_url
if (new_item != NULL) // When the item is stacked, it's deleted by addItemToInventory. Need be checked again to prevent crash of egs if (new_item != NULL) // When the item is stacked, it's deleted by addItemToInventory. Need be checked again to prevent crash of egs
{ {
ucstring customValue;
if (command_args.size() >= 6 && command_args[5] != "*") if (command_args.size() >= 6 && command_args[5] != "*")
{ {
customValue.fromUtf8(command_args[5]); new_item->setPhraseId(command_args[5], true);
new_item->setCustomName(customValue);
} }
if (command_args.size() >= 7 && command_args[6] != "*") if (command_args.size() >= 7 && command_args[6] != "*")
{ {
customValue.fromUtf8(command_args[6]); new_item->setPhraseId(command_args[6], true);
new_item->setCustomText(customValue);
} }
if (command_args.size() >= 8) if (command_args.size() >= 8)

@ -790,7 +790,7 @@ void CGameItem::ctor( const CSheetId& sheetId, uint32 recommended, bool destroya
// SlotCount = slotCount; // SlotCount = slotCount;
_Recommended = recommended; _Recommended = recommended;
_TotalSaleCycle = 0; _TotalSaleCycle = 0;
_PetIndex = MAX_INVENTORY_ANIMAL; _PetIndex = ~0;
_Form = CSheets::getForm( sheetId ); _Form = CSheets::getForm( sheetId );
if (_Form) if (_Form)
@ -1214,12 +1214,23 @@ CGameItemPtr CGameItem::getItemCopy()
//----------------------------------------------- //-----------------------------------------------
uint32 CGameItem::sendNameId(CCharacter * user) uint32 CGameItem::sendNameId(CCharacter * user)
{ {
nlassert( _Form != 0 ); nlassert(_Form != 0);
if( _Form->Family != ITEMFAMILY::SCROLL_R2 ) if (_Form->Family != ITEMFAMILY::SCROLL_R2)
{ {
if (_PhraseId && !_PhraseId->empty()) if (_PhraseId && !_PhraseId->empty())
{
if (_PhraseLiteral)
{
SM_STATIC_PARAMS_1(params, STRING_MANAGER::literal);
params[0].Literal = *_PhraseId;
return STRING_MANAGER::sendStringToClient(user->getEntityRowId(), "LITERAL", params);
}
else
{
return STRING_MANAGER::sendStringToClient(user->getEntityRowId(), *_PhraseId, TVectorParamCheck()); return STRING_MANAGER::sendStringToClient(user->getEntityRowId(), *_PhraseId, TVectorParamCheck());
} }
}
}
else else
{ {
// sessionId() don't works with edition session // sessionId() don't works with edition session
@ -1248,17 +1259,14 @@ void CGameItem::clear()
_CraftParameters = NULL; _CraftParameters = NULL;
_StackSize = 1; _StackSize = 1;
// _IsOnTheGround = false; // _IsOnTheGround = false;
_LockCount = 0; _LockCount = 0;
_CreatorId = NLMISC::CEntityId::Unknown; _CreatorId = NLMISC::CEntityId::Unknown;
// TimeOnTheGround = 0;
// SlotCount = 0;
_Destroyable = true; _Destroyable = true;
_Dropable = true; _Dropable = true;
// _SlotImage = 0xFFFF; // _SlotImage = 0xFFFF;
_LatencyEndDate = 0; _LatencyEndDate = 0;
// _Parent = NULL;
_Inventory = NULL; _Inventory = NULL;
_InventorySlot = INVENTORIES::INVALID_INVENTORY_SLOT; _InventorySlot = INVENTORIES::INVALID_INVENTORY_SLOT;
_Form = NULL; _Form = NULL;
@ -1284,6 +1292,7 @@ void CGameItem::clear()
_TypeSkillMods.clear(); _TypeSkillMods.clear();
_PhraseId = NULL; _PhraseId = NULL;
_CustomText = NULL; _CustomText = NULL;
_PhraseLiteral = false;
} }
void CGameItem::setStackSize(uint32 size) void CGameItem::setStackSize(uint32 size)

@ -371,7 +371,7 @@ public :
void clear(); void clear();
/// send the item name Id to the specified player, and return the associated text id. Return 0 if the item has no text id /// send the item name Id to the specified player, and return the associated text id. Return 0 if the item has no text id
uint32 sendNameId(CCharacter * user); uint32 sendNameId(CCharacter *user);
/// Delete an item in the sub item list /// Delete an item in the sub item list
// void deleteChildItem(uint index); // void deleteChildItem(uint index);
@ -484,7 +484,8 @@ public :
/// accessors to the item phrase /// accessors to the item phrase
const std::string &getPhraseId() const { static const std::string empty; return _PhraseId ? *_PhraseId : empty; } const std::string &getPhraseId() const { static const std::string empty; return _PhraseId ? *_PhraseId : empty; }
void setPhraseId(const std::string &str) { if (!_PhraseId) _PhraseId = new std::string(); *_PhraseId = str; } bool isPhraseLiteral() const { return _PhraseLiteral; }
void setPhraseId(const std::string &str, bool literal = false) { if (!_PhraseId) _PhraseId = new std::string(); *_PhraseId = str; _PhraseLiteral = literal; }
// return the enchantment value to be displayed in the client // return the enchantment value to be displayed in the client
uint16 getClientEnchantValue() const; uint16 getClientEnchantValue() const;
@ -695,11 +696,6 @@ public :
uint8 getPetIndex() const { return _PetIndex; } uint8 getPetIndex() const { return _PetIndex; }
void setPetIndex(uint8 val) { _PetIndex = val; } void setPetIndex(uint8 val) { _PetIndex = val; }
#ifdef RYZOM_FORGE_PET_NAME
ucstring getCustomName() const { return _CustomName; }
void setCustomName(ucstring val) { _CustomName = val; }
#endif
protected: protected:
friend class CFaberPhrase; friend class CFaberPhrase;
// set Default Color (for craft only) // set Default Color (for craft only)
@ -711,15 +707,6 @@ protected:
/// set link information between item and reference inventory (used by CRefInventory) /// set link information between item and reference inventory (used by CRefInventory)
void setRefInventory(const CInventoryPtr &inv, uint32 slot); void setRefInventory(const CInventoryPtr &inv, uint32 slot);
/// The inventory that contains this item (NULL if none)
CInventoryPtr _Inventory;
/// The inventory that reference this item (NULL if none)
CInventoryPtr _RefInventory;
/// The slot inside the inventory
uint32 _InventorySlot;
/// The slot inside the reference inventory
uint32 _RefInventorySlot;
private: private:
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -805,14 +792,6 @@ private:
// void ctor( const NLMISC::CEntityId& id, const NLMISC::CSheetId& sheetId, uint32 recommended, sint16 slotCount, bool destroyable , bool dropable); // void ctor( const NLMISC::CEntityId& id, const NLMISC::CSheetId& sheetId, uint32 recommended, sint16 slotCount, bool destroyable , bool dropable);
void ctor( const NLMISC::CSheetId& sheetId, uint32 recommended, bool destroyable , bool dropable); void ctor( const NLMISC::CSheetId& sheetId, uint32 recommended, bool destroyable , bool dropable);
/**
* pseudo Destructor
*/
//void dtor();
/// Copy all the item info and parameters from model into this
// void copyItem(const CGameItemPtr &model);
// Compute required level (skills and charac) for wearing item // Compute required level (skills and charac) for wearing item
void computeRequiredLevel(); void computeRequiredLevel();
@ -825,48 +804,25 @@ private:
// Recompute the Requirement from Old System (old values for old items) // Recompute the Requirement from Old System (old values for old items)
void computeRequirementFromOldSystem(); void computeRequirementFromOldSystem();
public: protected:
/// owner id (an item or the entity and the inventory id if root item (Parent=NULL)) /// The inventory that contains this item (NULL if none)
// NLMISC::CEntityId Owner; CInventoryPtr _Inventory;
/// The inventory that reference this item (NULL if none)
// union TLocation CInventoryPtr _RefInventory;
// { /// The slot inside the inventory
// uint32 Slot; uint32 _InventorySlot;
// struct CItemPos /// The slot inside the reference inventory
// { uint32 _RefInventorySlot;
// sint32 X;
// sint32 Y;
// sint32 Z;
// };
// CItemPos Pos;
// };
// /// time elapsed since the item is on the ground
// NLMISC::TGameCycle TimeOnTheGround;
/// max slot count
// sint16 SlotCount;
/// location
// TLocation Loc;
private: private:
/// Item unique id /// Item unique id
INVENTORIES::TItemId _ItemId; INVENTORIES::TItemId _ItemId;
/// item id
// NLMISC::CEntityId _ItemId;
/// looter id of the character currently looting this item (for items on the ground only) /// looter id of the character currently looting this item (for items on the ground only)
NLMISC::CEntityId _Looter; NLMISC::CEntityId _Looter;
/// sheet ref /// sheet ref
NLMISC::CSheetId _SheetId; NLMISC::CSheetId _SheetId;
/// Item stack size /// Item stack size
uint32 _StackSize; uint32 _StackSize;
/// carrion sheet ref
// uint32 _CarrionSheetId;
/// children
// std::vector<CGameItemPtr> _Children;
/// pointer on the parent item (NULL if no parent)
// CGameItemPtr _Parent;
// CInventoryPtr _Inventory;
/// Recommended skill for use /// Recommended skill for use
uint32 _Recommended; uint32 _Recommended;
@ -889,7 +845,7 @@ private:
/// Vector of CSheetId used for craft this item /// Vector of CSheetId used for craft this item
// std::vector< NLMISC::CSheetId > _RmUsedForCraft; // std::vector< NLMISC::CSheetId > _RmUsedForCraft;
/// vector of sheetId of CStaticBrick define spell of enchanted item /// vector of sheetId of CStaticBrick define spell of enchanted item
std::vector< NLMISC::CSheetId > _Enchantment; std::vector<NLMISC::CSheetId> _Enchantment;
/// pointer on the associated static form /// pointer on the associated static form
const CStaticItem* _Form; const CStaticItem* _Form;
@ -900,10 +856,6 @@ private:
std::vector<CTypeSkillMod> _TypeSkillMods; std::vector<CTypeSkillMod> _TypeSkillMods;
NLMISC::CDeepPtr<std::string> _CustomText; NLMISC::CDeepPtr<std::string> _CustomText;
#ifdef RYZOM_FORGE_PET_NAME
// FIXME: Reuse _PhraseId string and add a m_Literal flag
ucstring _CustomName;
#endif
/// tick when the proc will be available again /// tick when the proc will be available again
NLMISC::TGameCycle _LatencyEndDate; NLMISC::TGameCycle _LatencyEndDate;
@ -925,6 +877,9 @@ private:
bool _HasPrerequisit; bool _HasPrerequisit;
bool _UseNewSystemRequirement; bool _UseNewSystemRequirement;
/// phrase id is a literal, not a phrase
bool _PhraseLiteral;
bool _LockedByOwner; bool _LockedByOwner;
bool _UnMovable; bool _UnMovable;
bool _Movable; bool _Movable;

@ -18765,7 +18765,7 @@ uint32 CPetAnimal::initLinkAnimalToTicket( CCharacter * c, uint8 index )
// Slot = ItemPtr->getLocSlot(); // Slot = ItemPtr->getLocSlot();
ItemPtr->setPetIndex(index); ItemPtr->setPetIndex(index);
#ifdef RYZOM_FORGE_PET_NAME #ifdef RYZOM_FORGE_PET_NAME
ItemPtr->setCustomName(CustomName); ItemPtr->setPhraseId(CustomName, true);
#endif #endif
Slot = ItemPtr->getInventorySlot(); Slot = ItemPtr->getInventorySlot();
return Slot; return Slot;
@ -18781,7 +18781,7 @@ uint32 CPetAnimal::initLinkAnimalToTicket( CCharacter * c, uint8 index )
Slot = ItemPtr->getInventorySlot(); Slot = ItemPtr->getInventorySlot();
ItemPtr->setPetIndex(index); ItemPtr->setPetIndex(index);
#ifdef RYZOM_FORGE_PET_NAME #ifdef RYZOM_FORGE_PET_NAME
ItemPtr->setCustomName(CustomName); ItemPtr->setPhraseId(CustomName, true);
#endif #endif
return Slot; return Slot;
} }

@ -299,7 +299,7 @@ struct CPetAnimal
bool IsTpAllowed; bool IsTpAllowed;
bool spawnFlag; bool spawnFlag;
#ifdef RYZOM_FORGE_PET_NAME #ifdef RYZOM_FORGE_PET_NAME
ucstring CustomName; std::string CustomName;
#endif #endif
// ctor // ctor
@ -315,7 +315,7 @@ struct CPetAnimal
uint32 getAnimalMaxBulk(); uint32 getAnimalMaxBulk();
#ifdef RYZOM_FORGE_PET_NAME #ifdef RYZOM_FORGE_PET_NAME
void setCustomName(const ucstring& customName) { CustomName = customName; } void setCustomName(const std::string &customName) { CustomName = customName; }
#endif #endif
}; };

@ -672,6 +672,12 @@ static void prepareCharacterPositionForStore ( COfflineEntityState & state, cons
stableAlias = stablePlace->getAlias();\ stableAlias = stablePlace->getAlias();\
}\ }\
#ifdef RYZOM_FORGE
#define PROP_PET_ANIMAL_CUSTOM_NAME() PROP2(CustomName, string, CustomName, CustomName = val)
#else
#define PROP_PET_ANIMAL_CUSTOM_NAME()
#endif
#define PERSISTENT_DATA\ #define PERSISTENT_DATA\
FLAG0(CLEAR,clear())\ FLAG0(CLEAR,clear())\
PROP2(TicketPetSheetId,CSheetId,TicketPetSheetId,\ PROP2(TicketPetSheetId,CSheetId,TicketPetSheetId,\
@ -700,7 +706,7 @@ static void prepareCharacterPositionForStore ( COfflineEntityState & state, cons
LPROP(bool,IsMounted,if(IsMounted))\ LPROP(bool,IsMounted,if(IsMounted))\
PROP(bool,IsTpAllowed)\ PROP(bool,IsTpAllowed)\
PROP(TSatiety,Satiety)\ PROP(TSatiety,Satiety)\
/*PROP2(CustomName, ucstring, CustomName, CustomName = val)*/\ PROP_PET_ANIMAL_CUSTOM_NAME()\
//#pragma message( PERSISTENT_GENERATION_MESSAGE ) //#pragma message( PERSISTENT_GENERATION_MESSAGE )
#include "game_share/persistent_data_template.h" #include "game_share/persistent_data_template.h"
@ -1329,24 +1335,18 @@ private:
}\ }\
postApply((INVENTORIES::TInventory) RefInventoryId, applyArgs.Owner);\ postApply((INVENTORIES::TInventory) RefInventoryId, applyArgs.Owner);\
#ifdef RYZOM_FORGE_PET_NAME
#define PD_CUSTOM_NAME_PROP2() PROP2(_CustomName, ucstring, _CustomName, _CustomName=val)
#else
#define PD_CUSTOM_NAME_PROP2()
#endif
#define PERSISTENT_DATA\ #define PERSISTENT_DATA\
FLAG0(CLEAR,clear())\ FLAG0(CLEAR,clear())\
PROP2(_ItemId, uint64, _ItemId.getRawId(), _ItemId = INVENTORIES::TItemId(val))\ PROP2(_ItemId, uint64, _ItemId.getRawId(), _ItemId = INVENTORIES::TItemId(val))\
PROP2(_SheetId, CSheetId, _SheetId, _SheetId=val)\ PROP2(_SheetId, CSheetId, _SheetId, _SheetId=val)\
/* PROP2(_LocSlot, uint32, _InventorySlot, _InventorySlot=val)*/\
PROP2(_LocSlot, uint32, _InventorySlot, applyArgs.InventorySlot=val)\ PROP2(_LocSlot, uint32, _InventorySlot, applyArgs.InventorySlot=val)\
PROP2(_HP, uint32, _HP, _HP=val)\ PROP2(_HP, uint32, _HP, _HP=val)\
PROP2(_Recommended, uint32, _Recommended, _Recommended=val)\ PROP2(_Recommended, uint32, _Recommended, _Recommended=val)\
PROP2(_CreatorId, CEntityId, _CreatorId, _CreatorId=val)\ PROP2(_CreatorId, CEntityId, _CreatorId, _CreatorId=val)\
PROP2(_PhraseId, string, getPhraseId(), setPhraseId(val))\ PROP2(_PhraseId, string, getPhraseId(), setPhraseId(val))\
LPROP2(_PhraseLiteral, bool, if (_PhraseLiteral), _PhraseLiteral, _PhraseLiteral=val)\
LSTRUCT2(_CraftParameters, if (_CraftParameters != NULL), _CraftParameters->store(pdr), _CraftParameters = new CItemCraftParameters; _CraftParameters->apply(pdr))\ LSTRUCT2(_CraftParameters, if (_CraftParameters != NULL), _CraftParameters->store(pdr), _CraftParameters = new CItemCraftParameters; _CraftParameters->apply(pdr))\
LPROP2(_SlotImage, uint16, if (0), 0xffff, slotImage=val)\ LPROP2(_SlotImage, uint16, if (0), 0xffff, slotImage=val) /* Very old version compatibility */ \
LPROP2(_SapLoad, uint32, if (_SapLoad!=0), _SapLoad, _SapLoad=val)\ LPROP2(_SapLoad, uint32, if (_SapLoad!=0), _SapLoad, _SapLoad=val)\
LPROP2(_Dropable, bool, if (!_Dropable), _Dropable, _Dropable=val)\ LPROP2(_Dropable, bool, if (!_Dropable), _Dropable, _Dropable=val)\
LPROP2(_Destroyable, bool, if (!_Destroyable), _Destroyable, _Destroyable=val)\ LPROP2(_Destroyable, bool, if (!_Destroyable), _Destroyable, _Destroyable=val)\
@ -1362,11 +1362,11 @@ private:
LPROP2(_RequiredCharacLevel, uint16, if (_RequiredCharacLevel!=0),_RequiredCharacLevel, _RequiredCharacLevel=val)\ LPROP2(_RequiredCharacLevel, uint16, if (_RequiredCharacLevel!=0),_RequiredCharacLevel, _RequiredCharacLevel=val)\
STRUCT_VECT(_TypeSkillMods)\ STRUCT_VECT(_TypeSkillMods)\
LPROP_VECT(CSheetId, _Enchantment, VECT_LOGIC(_Enchantment) if (_Enchantment[i]!=CSheetId::Unknown))\ LPROP_VECT(CSheetId, _Enchantment, VECT_LOGIC(_Enchantment) if (_Enchantment[i]!=CSheetId::Unknown))\
PROP2(_CustomText, ucstring, ucstring::makeFromUtf8(getCustomText()), setCustomText(val.toUtf8())) /* TODO: UTF-8 (file serial) */ \ PROP2(_CustomText, string, getCustomText(), setCustomText(val))\
PD_CUSTOM_NAME_PROP2()\ LPROP2(_CustomName, string, if (false), string(), setPhraseId(val, true)) /* Ryzom Forge compatibility, replaced by _PhraseLiteral */ \
PROP(bool, _Movable)\ PROP(bool, _Movable)\
PROP(bool, _UnMovable)\ PROP(bool, _UnMovable)\
PROP(bool, _LockedByOwner)\ PROP(bool, _LockedByOwner) /* Ryzom Forge compatibility */\
//#pragma message( PERSISTENT_GENERATION_MESSAGE ) //#pragma message( PERSISTENT_GENERATION_MESSAGE )
#include "game_share/persistent_data_template.h" #include "game_share/persistent_data_template.h"

Loading…
Cancel
Save