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
{
ucstring customValue;
if (command_args.size() >= 6 && command_args[5] != "*")
{
customValue.fromUtf8(command_args[5]);
new_item->setCustomName(customValue);
new_item->setPhraseId(command_args[5], true);
}
if (command_args.size() >= 7 && command_args[6] != "*")
{
customValue.fromUtf8(command_args[6]);
new_item->setCustomText(customValue);
new_item->setPhraseId(command_args[6], true);
}
if (command_args.size() >= 8)

@ -790,7 +790,7 @@ void CGameItem::ctor( const CSheetId& sheetId, uint32 recommended, bool destroya
// SlotCount = slotCount;
_Recommended = recommended;
_TotalSaleCycle = 0;
_PetIndex = MAX_INVENTORY_ANIMAL;
_PetIndex = ~0;
_Form = CSheets::getForm( sheetId );
if (_Form)
@ -1214,11 +1214,22 @@ CGameItemPtr CGameItem::getItemCopy()
//-----------------------------------------------
uint32 CGameItem::sendNameId(CCharacter * user)
{
nlassert( _Form != 0 );
if( _Form->Family != ITEMFAMILY::SCROLL_R2 )
nlassert(_Form != 0);
if (_Form->Family != ITEMFAMILY::SCROLL_R2)
{
if (_PhraseId && !_PhraseId->empty())
return STRING_MANAGER::sendStringToClient(user->getEntityRowId(), *_PhraseId, TVectorParamCheck());
{
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());
}
}
}
else
{
@ -1248,17 +1259,14 @@ void CGameItem::clear()
_CraftParameters = NULL;
_StackSize = 1;
// _IsOnTheGround = false;
// _IsOnTheGround = false;
_LockCount = 0;
_CreatorId = NLMISC::CEntityId::Unknown;
// TimeOnTheGround = 0;
// SlotCount = 0;
_Destroyable = true;
_Dropable = true;
// _SlotImage = 0xFFFF;
// _SlotImage = 0xFFFF;
_LatencyEndDate = 0;
// _Parent = NULL;
_Inventory = NULL;
_InventorySlot = INVENTORIES::INVALID_INVENTORY_SLOT;
_Form = NULL;
@ -1284,6 +1292,7 @@ void CGameItem::clear()
_TypeSkillMods.clear();
_PhraseId = NULL;
_CustomText = NULL;
_PhraseLiteral = false;
}
void CGameItem::setStackSize(uint32 size)

@ -371,7 +371,7 @@ public :
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
uint32 sendNameId(CCharacter * user);
uint32 sendNameId(CCharacter *user);
/// Delete an item in the sub item list
// void deleteChildItem(uint index);
@ -484,7 +484,8 @@ public :
/// accessors to the item phrase
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
uint16 getClientEnchantValue() const;
@ -695,11 +696,6 @@ public :
uint8 getPetIndex() const { return _PetIndex; }
void setPetIndex(uint8 val) { _PetIndex = val; }
#ifdef RYZOM_FORGE_PET_NAME
ucstring getCustomName() const { return _CustomName; }
void setCustomName(ucstring val) { _CustomName = val; }
#endif
protected:
friend class CFaberPhrase;
// set Default Color (for craft only)
@ -711,15 +707,6 @@ protected:
/// set link information between item and reference inventory (used by CRefInventory)
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:
//--------------------------------------------------------------------
@ -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::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
void computeRequiredLevel();
@ -825,48 +804,25 @@ private:
// Recompute the Requirement from Old System (old values for old items)
void computeRequirementFromOldSystem();
public:
/// owner id (an item or the entity and the inventory id if root item (Parent=NULL))
// NLMISC::CEntityId Owner;
// union TLocation
// {
// uint32 Slot;
// struct CItemPos
// {
// 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;
protected:
/// 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:
/// Item unique id
INVENTORIES::TItemId _ItemId;
/// item id
// NLMISC::CEntityId _ItemId;
/// looter id of the character currently looting this item (for items on the ground only)
NLMISC::CEntityId _Looter;
/// sheet ref
NLMISC::CSheetId _SheetId;
/// Item stack size
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
uint32 _Recommended;
@ -889,7 +845,7 @@ private:
/// Vector of CSheetId used for craft this item
// std::vector< NLMISC::CSheetId > _RmUsedForCraft;
/// 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
const CStaticItem* _Form;
@ -900,10 +856,6 @@ private:
std::vector<CTypeSkillMod> _TypeSkillMods;
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
NLMISC::TGameCycle _LatencyEndDate;
@ -925,6 +877,9 @@ private:
bool _HasPrerequisit;
bool _UseNewSystemRequirement;
/// phrase id is a literal, not a phrase
bool _PhraseLiteral;
bool _LockedByOwner;
bool _UnMovable;
bool _Movable;

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

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

@ -672,6 +672,12 @@ static void prepareCharacterPositionForStore ( COfflineEntityState & state, cons
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\
FLAG0(CLEAR,clear())\
PROP2(TicketPetSheetId,CSheetId,TicketPetSheetId,\
@ -700,7 +706,7 @@ static void prepareCharacterPositionForStore ( COfflineEntityState & state, cons
LPROP(bool,IsMounted,if(IsMounted))\
PROP(bool,IsTpAllowed)\
PROP(TSatiety,Satiety)\
/*PROP2(CustomName, ucstring, CustomName, CustomName = val)*/\
PROP_PET_ANIMAL_CUSTOM_NAME()\
//#pragma message( PERSISTENT_GENERATION_MESSAGE )
#include "game_share/persistent_data_template.h"
@ -1329,24 +1335,18 @@ private:
}\
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\
FLAG0(CLEAR,clear())\
PROP2(_ItemId, uint64, _ItemId.getRawId(), _ItemId = INVENTORIES::TItemId(val))\
PROP2(_SheetId, CSheetId, _SheetId, _SheetId=val)\
/* PROP2(_LocSlot, uint32, _InventorySlot, _InventorySlot=val)*/\
PROP2(_LocSlot, uint32, _InventorySlot, applyArgs.InventorySlot=val)\
PROP2(_HP, uint32, _HP, _HP=val)\
PROP2(_Recommended, uint32, _Recommended, _Recommended=val)\
PROP2(_CreatorId, CEntityId, _CreatorId, _CreatorId=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))\
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(_Dropable, bool, if (!_Dropable), _Dropable, _Dropable=val)\
LPROP2(_Destroyable, bool, if (!_Destroyable), _Destroyable, _Destroyable=val)\
@ -1362,11 +1362,11 @@ private:
LPROP2(_RequiredCharacLevel, uint16, if (_RequiredCharacLevel!=0),_RequiredCharacLevel, _RequiredCharacLevel=val)\
STRUCT_VECT(_TypeSkillMods)\
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) */ \
PD_CUSTOM_NAME_PROP2()\
PROP2(_CustomText, string, getCustomText(), setCustomText(val))\
LPROP2(_CustomName, string, if (false), string(), setPhraseId(val, true)) /* Ryzom Forge compatibility, replaced by _PhraseLiteral */ \
PROP(bool, _Movable)\
PROP(bool, _UnMovable)\
PROP(bool, _LockedByOwner)\
PROP(bool, _LockedByOwner) /* Ryzom Forge compatibility */\
//#pragma message( PERSISTENT_GENERATION_MESSAGE )
#include "game_share/persistent_data_template.h"

Loading…
Cancel
Save