Test item renames

ryzomclassic-develop
kaetemi 4 years ago
parent 8d4c0d0ef1
commit 46541a700c

@ -4501,6 +4501,32 @@ NLMISC_COMMAND(debugInfoWindows, "log info windows sheetId", "")
return true; return true;
} }
NLMISC_COMMAND(renameItem, "rename an item", "inventory slot literal name")
{
if (args.size() != 4)
return false;
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream("ITEM:RENAME", out))
{
INVENTORIES::TInventory inventory = INVENTORIES::toInventory(args[0]);
out.serialShortEnum(inventory);
uint16 slot;
if (!fromString(args[1], slot))
return false;
out.serial(slot);
bool literal = toBool(args[2]);
out.serial(literal);
out.serial(const_cast<std::string &>(args[3]));
NetMngr.push(out);
}
else
nlwarning("mainLoop : unknown message name : '%s'", "ITEM:RENAME");
return true;
}
NLMISC_COMMAND(getSkillValue, "get a skill value by its name", "skill_name") NLMISC_COMMAND(getSkillValue, "get a skill value by its name", "skill_name")
{ {
if (args.size() != 1) return false; if (args.size() != 1) return false;

@ -3148,13 +3148,7 @@ class CHandlerLockInvItem : public IActionHandler
return; return;
} }
string lock = "1"; uint16 slot = (uint16)item->getIndexInDB();
if (item->getLockedByOwner())
{
lock = "0";
}
uint32 slot = item->getIndexInDB();
uint32 inv = item->getInventoryIndex(); uint32 inv = item->getInventoryIndex();
INVENTORIES::TInventory inventory = INVENTORIES::UNDEFINED; INVENTORIES::TInventory inventory = INVENTORIES::UNDEFINED;
inventory = (INVENTORIES::TInventory)(inv); inventory = (INVENTORIES::TInventory)(inv);
@ -3162,7 +3156,22 @@ class CHandlerLockInvItem : public IActionHandler
{ {
return; return;
} }
NLMISC::ICommand::execute("a lockItem " + INVENTORIES::toString(inventory) + " " + toString(slot) + " " + lock, g_log);
bool lock = !item->getLockedByOwner();
if (lock) item->setItemResaleFlag(BOTCHATTYPE::ResaleKOLockedByOwner);
// else wait for proper state
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream("ITEM:LOCK", out))
{
out.serialShortEnum(inventory);
out.serial(slot);
out.serial(lock);
NetMngr.push(out);
}
else
nlwarning("mainLoop : unknown message name : '%s'", "ITEM:RENAME");
} }
}; };
REGISTER_ACTION_HANDLER( CHandlerLockInvItem, "lock_inv_item" ); REGISTER_ACTION_HANDLER( CHandlerLockInvItem, "lock_inv_item" );

@ -167,8 +167,8 @@
<leaf name="USE_ITEM" sendto="EGS" format="u16" description="client wants to use teleport in the specified bag slot or consume an item to trigger its effect" /> <leaf name="USE_ITEM" sendto="EGS" format="u16" description="client wants to use teleport in the specified bag slot or consume an item to trigger its effect" />
<leaf name="STOP_USE_XP_CAT" sendto="EGS" format="b" description="client wants to stop using xp catalyser" /> <leaf name="STOP_USE_XP_CAT" sendto="EGS" format="b" description="client wants to stop using xp catalyser" />
<leaf name="LOCK" sendto="EGS" format="u8 u16 b" description="lock or unlock an item. inventory, slot, lock" /> <leaf name="LOCK" sendto="EGS" format="u8 u16 b" description="lock or unlock an item. inventory, slot, lock" />
<leaf name="RENAME" sendot="EGS" format="u8 u16 b s" description="change an item name to a phrase or literal. inventory, slot, literal, name" /> <leaf name="RENAME" sendto="EGS" format="u8 u16 b s" description="change an item name to a phrase or literal. inventory, slot, literal, name" />
<leaf name="WRITE" sendot="EGS" format="u8 u16 s" description="wrrite a crafter's message. inventory, slot, text" /> <leaf name="WRITE" sendto="EGS" format="u8 u16 s" description="wrrite a crafter's message. inventory, slot, text" />
</branch> </branch>
<branch name="TP"> <branch name="TP">
<leaf name="RESPAWN" sendto="EGS" format="" description="teleport the player to his respawn point" /> <leaf name="RESPAWN" sendto="EGS" format="" description="teleport the player to his respawn point" />

@ -49,7 +49,7 @@ NL_INSTANCE_COUNTER_IMPL(CGameItem);
// singleton data // singleton data
CGameItemVector CGameItem::_Items; CGameItemVector CGameItem::_Items;
uint32 CGameItem::_FirstFreeItem = 1; // Item 0 is invalid! uint32 CGameItem::_FirstFreeItem;
#if 0 #if 0
uint32 CGameItem::_BugTestCounter; uint32 CGameItem::_BugTestCounter;
#endif #endif
@ -1210,6 +1210,7 @@ CGameItemPtr CGameItem::getItemCopy()
item->_LockedByOwner = false; item->_LockedByOwner = false;
item->_Movable = false; item->_Movable = false;
item->_UnMovable = false; item->_UnMovable = false;
item->_AccessGrade = DefaultAccessGrade;
// item->_StackSize = 1; // item->_StackSize = 1;
// item->_CreatorId = CEntityId::Unknown; // item->_CreatorId = CEntityId::Unknown;
@ -1240,7 +1241,7 @@ uint32 CGameItem::sendNameId(CCharacter * user)
if (_PhraseLiteral) if (_PhraseLiteral)
{ {
SM_STATIC_PARAMS_1(params, STRING_MANAGER::literal); SM_STATIC_PARAMS_1(params, STRING_MANAGER::literal);
params[0].Literal = *_PhraseId; params[0].Literal = ucstring::makeFromUtf8(*_PhraseId); // FIXME: UTF-8 (serial)
return STRING_MANAGER::sendStringToClient(user->getEntityRowId(), "LITERAL", params); return STRING_MANAGER::sendStringToClient(user->getEntityRowId(), "LITERAL", params);
} }
else else
@ -1307,6 +1308,8 @@ void CGameItem::clear()
_Movable = false; _Movable = false;
_UnMovable = false; _UnMovable = false;
_AccessGrade = DefaultAccessGrade;
_TypeSkillMods.clear(); _TypeSkillMods.clear();
_PhraseId = NULL; _PhraseId = NULL;
_CustomText = NULL; _CustomText = NULL;
@ -1735,7 +1738,7 @@ CGameItem * CGameItem::getItem(uint idx)
{ {
BOMB_IF( !idx, "Attempt to access a null item pointer", return &_Items[0] ); BOMB_IF( !idx, "Attempt to access a null item pointer", return &_Items[0] );
BOMB_IF( idx>=_Items.size(), "Attempt to access an item beyond end of item vector", return &_Items[0] ); BOMB_IF( idx>=_Items.size(), "Attempt to access an item beyond end of item vector", return &_Items[0] );
BOMB_IF( _Items[idx].AllocatorNext>=0, NLMISC::toString("Attempt to access an item that is not allocated or has been freed (idx: %d)",idx), return &_Items[0] ); BOMB_IF( _Items[idx].AllocatorNext > 0, NLMISC::toString("Attempt to access an item that is not allocated or has been freed (idx: %d)",idx), return &_Items[0] );
return &_Items[idx]; return &_Items[idx];
} }
@ -1745,6 +1748,17 @@ CGameItem * CGameItem::getItem(uint idx)
//----------------------------------------------- //-----------------------------------------------
CGameItem *CGameItem::newItem() CGameItem *CGameItem::newItem()
{ {
if (!_FirstFreeItem)
{
// item 0 is the null item
nlassert(!_Items.size());
_Items.extend();
CGameItemEntry &nullItem = _Items[0];
nlassert(nullItem.AllocatorNext == 1);
_FirstFreeItem = 1;
nullItem.AllocatorNext = 0;
}
// NOTE // NOTE
// the following assert is very important as the rest of this algorithm depends on this condition being met // the following assert is very important as the rest of this algorithm depends on this condition being met
nlassert(_FirstFreeItem <= _Items.size()); nlassert(_FirstFreeItem <= _Items.size());

@ -1039,7 +1039,7 @@ inline CGameItemPtr::CGameItemPtr(const CGameItemPtr &other) : m_Idx(other.m_Idx
} }
// ctor - initialise from a CGameItem* // ctor - initialise from a CGameItem*
inline CGameItemPtr::CGameItemPtr(const CGameItem *item) : m_Idx(static_cast<const CGameItemEntry *>(item)->VectorIdx) inline CGameItemPtr::CGameItemPtr(const CGameItem *item) : m_Idx(item ? static_cast<const CGameItemEntry *>(item)->VectorIdx : 0)
{ {
incRef(); incRef();
} }

@ -1364,10 +1364,10 @@ private:
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, string, getCustomText(), setCustomText(val))\ PROP2(_CustomText, string, getCustomText(), setCustomText(val))\
LPROP2(_CustomName, string, if (false), string(), setPhraseIdInternal(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)\ LPROP(bool, _Movable, if (!_Movable))\
PROP(bool, _UnMovable)\ LPROP(bool, _UnMovable, if (!_UnMovable))\
PROP(bool, _LockedByOwner)\ LPROP(bool, _LockedByOwner, if (!_LockedByOwner))\
LPROP2(_AccessGrade, string, if (_AccessGrade != DefaultAccessGrade), CGuildGrade::toString(_AccessGrade), _AccessGrade = CGuildGrade::fromString(val))\ LPROP2(_AccessGrade, string, if (_AccessGrade != DefaultAccessGrade), CGuildGrade::toString(_AccessGrade), _AccessGrade = CGuildGrade::fromString(val); if (_AccessGrade == CGuildGrade::Unknown) _AccessGrade = DefaultAccessGrade)\
//#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