diff --git a/ryzom/client/src/commands.cpp b/ryzom/client/src/commands.cpp index 117eecbe0..d06e975ca 100644 --- a/ryzom/client/src/commands.cpp +++ b/ryzom/client/src/commands.cpp @@ -4501,6 +4501,32 @@ NLMISC_COMMAND(debugInfoWindows, "log info windows sheetId", "") 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(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") { if (args.size() != 1) return false; diff --git a/ryzom/client/src/interface_v3/inventory_manager.cpp b/ryzom/client/src/interface_v3/inventory_manager.cpp index 8a9492afa..9fe203a0e 100644 --- a/ryzom/client/src/interface_v3/inventory_manager.cpp +++ b/ryzom/client/src/interface_v3/inventory_manager.cpp @@ -3148,13 +3148,7 @@ class CHandlerLockInvItem : public IActionHandler return; } - string lock = "1"; - if (item->getLockedByOwner()) - { - lock = "0"; - } - - uint32 slot = item->getIndexInDB(); + uint16 slot = (uint16)item->getIndexInDB(); uint32 inv = item->getInventoryIndex(); INVENTORIES::TInventory inventory = INVENTORIES::UNDEFINED; inventory = (INVENTORIES::TInventory)(inv); @@ -3162,7 +3156,22 @@ class CHandlerLockInvItem : public IActionHandler { 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" ); diff --git a/ryzom/common/data_common/msg.xml b/ryzom/common/data_common/msg.xml index 032cd5b07..93468fe64 100644 --- a/ryzom/common/data_common/msg.xml +++ b/ryzom/common/data_common/msg.xml @@ -167,8 +167,8 @@ - - + + 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 589c549e9..f91361156 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 @@ -49,7 +49,7 @@ NL_INSTANCE_COUNTER_IMPL(CGameItem); // singleton data CGameItemVector CGameItem::_Items; -uint32 CGameItem::_FirstFreeItem = 1; // Item 0 is invalid! +uint32 CGameItem::_FirstFreeItem; #if 0 uint32 CGameItem::_BugTestCounter; #endif @@ -1210,6 +1210,7 @@ CGameItemPtr CGameItem::getItemCopy() item->_LockedByOwner = false; item->_Movable = false; item->_UnMovable = false; + item->_AccessGrade = DefaultAccessGrade; // item->_StackSize = 1; // item->_CreatorId = CEntityId::Unknown; @@ -1240,7 +1241,7 @@ uint32 CGameItem::sendNameId(CCharacter * user) if (_PhraseLiteral) { 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); } else @@ -1307,6 +1308,8 @@ void CGameItem::clear() _Movable = false; _UnMovable = false; + _AccessGrade = DefaultAccessGrade; + _TypeSkillMods.clear(); _PhraseId = 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>=_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]; } @@ -1745,6 +1748,17 @@ CGameItem * CGameItem::getItem(uint idx) //----------------------------------------------- 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 // the following assert is very important as the rest of this algorithm depends on this condition being met nlassert(_FirstFreeItem <= _Items.size()); 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 403678901..61c29230f 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 @@ -1039,7 +1039,7 @@ inline CGameItemPtr::CGameItemPtr(const CGameItemPtr &other) : m_Idx(other.m_Idx } // ctor - initialise from a CGameItem* -inline CGameItemPtr::CGameItemPtr(const CGameItem *item) : m_Idx(static_cast(item)->VectorIdx) +inline CGameItemPtr::CGameItemPtr(const CGameItem *item) : m_Idx(item ? static_cast(item)->VectorIdx : 0) { incRef(); } 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 be0b97bce..05a51c18d 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 @@ -1364,10 +1364,10 @@ private: LPROP_VECT(CSheetId, _Enchantment, VECT_LOGIC(_Enchantment) if (_Enchantment[i]!=CSheetId::Unknown))\ PROP2(_CustomText, string, getCustomText(), setCustomText(val))\ LPROP2(_CustomName, string, if (false), string(), setPhraseIdInternal(val, true)) /* Ryzom Forge compatibility, replaced by _PhraseLiteral */ \ - PROP(bool, _Movable)\ - PROP(bool, _UnMovable)\ - PROP(bool, _LockedByOwner)\ - LPROP2(_AccessGrade, string, if (_AccessGrade != DefaultAccessGrade), CGuildGrade::toString(_AccessGrade), _AccessGrade = CGuildGrade::fromString(val))\ + LPROP(bool, _Movable, if (!_Movable))\ + LPROP(bool, _UnMovable, if (!_UnMovable))\ + LPROP(bool, _LockedByOwner, if (!_LockedByOwner))\ + LPROP2(_AccessGrade, string, if (_AccessGrade != DefaultAccessGrade), CGuildGrade::toString(_AccessGrade), _AccessGrade = CGuildGrade::fromString(val); if (_AccessGrade == CGuildGrade::Unknown) _AccessGrade = DefaultAccessGrade)\ //#pragma message( PERSISTENT_GENERATION_MESSAGE ) #include "game_share/persistent_data_template.h"