Add network messages for locking and renaming items

ryzomclassic-develop
kaetemi 4 years ago
parent f203559ecb
commit be11ae1fb6

@ -1907,8 +1907,8 @@ void getItemText (CDBCtrlSheet *item, string &itemText, const CItemSheet*pIS)
const CClientItemInfo &itemInfo = getInventory().getItemInfo(getInventory().getItemSlotId(item) );
if (!itemInfo.CustomText.empty())
{
strFindReplace(itemText, "%custom_text", "\n@{FFFF}" + itemInfo.CustomText.toUtf8() + "\n");
string itemMFC = CI18N::get("uiItemTextMessageFromCrafter");
strFindReplace(itemText, "%custom_text", "\n@{FFFF}" + itemInfo.CustomText + "\n");
const string &itemMFC = CI18N::get("uiItemTextMessageFromCrafter");
strFindReplace(itemText, "%mfc", itemMFC);
}
else

@ -130,7 +130,7 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived()
{
if ( pIS->Family == ITEMFAMILY::SCROLL)
{
editBoxLarge->setInputString(itemInfo.CustomText.toUtf8()); // TODO: UTF-8 (serial)
editBoxLarge->setInputString(itemInfo.CustomText); // TODO: UTF-8 (serial)
editLarge->setActive(true);
editBoxLarge->setActive(true);
@ -144,7 +144,7 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived()
string customText;
if (!itemInfo.CustomText.empty())
{
customText = itemInfo.CustomText.toUtf8(); // TODO: UTF-8 (serial)
customText = itemInfo.CustomText; // TODO: UTF-8 (serial)
strFindReplace(customText, "%mfc", string());
}
@ -244,7 +244,7 @@ void CInterfaceItemEdition::CItemEditionWindow::begin()
// If we already have item info
if ( pIS->Family == ITEMFAMILY::SCROLL)
{
editBoxLarge->setInputString(itemInfo.CustomText.toUtf8()); // TODO: UTF-8 (serial)
editBoxLarge->setInputString(itemInfo.CustomText); // TODO: UTF-8 (serial)
editLarge->setActive(true);
editBoxLarge->setActive(true);
@ -259,7 +259,7 @@ void CInterfaceItemEdition::CItemEditionWindow::begin()
string customText;
if (!itemInfo.CustomText.empty())
{
customText = itemInfo.CustomText.toUtf8();
customText = itemInfo.CustomText;
strFindReplace(customText, "%mfc", string());
}
@ -304,7 +304,7 @@ void CInterfaceItemEdition::CItemEditionWindow::begin()
display->setTextFormatTaged(localDesc);
else
{
string text = itemInfo.CustomText.toUtf8();
string text = itemInfo.CustomText;
string::size_type delimiter = text.find(' ');
if(text.size() > 3 && text[0]=='@' && text[1]=='W' && text[2]=='E' && text[3]=='B')
{
@ -407,19 +407,18 @@ void CInterfaceItemEdition::CItemEditionWindow::validate()
if (textValid)
{
CBitMemStream out;
const char *msgName = "EVENT:SET_ITEM_CUSTOM_TEXT";
const char *msgName = "ITEM:WRITE";
if (!GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
nlwarning ("don't know message name %s", msgName);
}
else
{
uint32 uiInventory = (uint32)pCSItem->getInventoryIndex();
out.serial(uiInventory);
uint32 uiSlot = (uint32)pCSItem->getIndexInDB();
out.serial(uiSlot);
ucstring ucText = ucstring::makeFromUtf8(text); // TODO: UTF-8 (serial)
out.serial(ucText);
INVENTORIES::TInventory inventory = (INVENTORIES::TInventory)pCSItem->getInventoryIndex();
out.serialShortEnum(inventory);
uint16 slot = (uint16)pCSItem->getIndexInDB();
out.serial(slot);
out.serial(text);
NetMngr.push(out);
//nlinfo("impulseCallBack : %s %s %d \"%s\" sent", msgName.c_str(), INVENTORIES::toString((INVENTORIES::TInventory)pCSItem->getInventoryIndex()).c_str(), pCSItem->getIndexInDB(), text.toUtf8().c_str());
}

@ -166,9 +166,9 @@
<leaf name="CLOSE_ROOM_INVENTORY" sendto="" description="EGS wants to close the user inventory" />
<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="LOCK" sendto="EGS" format="u16 u16 b" description="lock or unlock an item. inventory, slot, lock" />
<leav name="RENAME" sendot="EGS" format="u16 u16 b s" description="change an item name to a phrase or literal. inventory, slot, literal, name" />
<leav name="WRITE" sendot="EGS" format="u16 u16 s" description="wrrite a crafter's message. 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="WRITE" sendot="EGS" format="u8 u16 s" description="wrrite a crafter's message. inventory, slot, lock" />
</branch>
<branch name="TP">
<leaf name="RESPAWN" sendto="EGS" format="" description="teleport the player to his respawn point" />
@ -349,6 +349,7 @@
<leaf name="TAKE_MONEY" sendto="EGS" format="u64 u16" description="take money from guild warehouse" />
<leaf name="OPEN_INVENTORY" sendto="" format="" description="open the guild inventory" />
<leaf name="CLOSE_INVENTORY" sendto="" format="" description="close the guild inventory" />
<leaf name="ITEM_ACCESS" sendto="EGS" format="u16 u8" description="grant a guild access grade to an item in the guild inventory. slot, grade" />
</branch>
<branch name="OUTPOST">
<leaf name="GIVEUP_OUTPOST" sendto="EGS" format="u32" description="Give up an outpost (outpostSHEET)" />
@ -462,10 +463,12 @@
<leaf name="BARS" format="u8 s16 s16 s16 s16" description="server update the players Bars (fast message) $msgNumber $hp $sap $sta $focus" />
<leaf name="POPUP" format="u32 u32" description="server display an important info message on the client (u32 titleDynString u32 textDynString)" />
</branch>
<!--
<branch name="EVENT">
<leaf name="SET_ITEM_CUSTOM_TEXT" sendto="EGS" format="u32 u32 uc" description="set the cursom of the item in inventory $inventory in slot $slot to $text" />
<leaf name="DUMMY" description="stupid server....." />
</branch>
-->
<branch name="TOTEM">
<leaf name="BUILD" sendto="EGS" format="" description="client has built a totem" />
<leaf name="DUMMY" description="stupid server....." />

@ -60,6 +60,17 @@ inline ucstring capitalize(const ucstring & s)
return ucstring::makeFromUtf8(capitalize(s.toUtf8()));
}
inline std::string capitalizeFirst(const std::string &s)
{
if (s.empty())
return s;
std::string res;
res.reserve(4);
ptrdiff_t i = 0;
NLMISC::appendToUpper(res, s, i);
return res + s.substr(i);
}
//-------------------------------------------------------------------------------------------------
// HANDY MACROS - For forcing the pre-preprocessor to evaluate concatenation operations nicely

@ -351,6 +351,171 @@ void cbClientItemStopUseXpCat( CMessage& msgin, const std::string &serviceName,
character->stopUseItem( isRingCatalyser );
}
void cbClientItemLock(NLNET::CMessage &msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
{
CEntityId eid;
INVENTORIES::TInventory inventory;
uint16 slot;
bool lock;
msgin.serial(eid);
msgin.serialShortEnum(inventory);
msgin.serial(slot);
msgin.serial(lock);
CCharacter *character = PlayerManager.getChar(eid);
DROP_IF(!character, "Character not found", return);
DROP_IF(inventory == INVENTORIES::UNDEFINED, "Inventory is undefined", return);
CInventoryPtr invent = character->getInventory(inventory);
DROP_IF(slot >= invent->getSlotCount(), "Invalid slot specified", return);
CGameItemPtr item = invent->getItem(slot);
DROP_IF(item == NULL, "Item does not exist", return);
item->setLockedByOwner(lock);
}
void cbClientItemRename(NLNET::CMessage &msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
{
CEntityId eid;
INVENTORIES::TInventory inventory;
uint16 slot;
bool literal;
string text;
msgin.serial(eid);
msgin.serialShortEnum(inventory);
msgin.serial(slot);
msgin.serial(literal);
msgin.serial(text);
CCharacter *character = PlayerManager.getChar(eid);
DROP_IF(!character, "Character not found", return);
DROP_IF(inventory == INVENTORIES::UNDEFINED, "Inventory is undefined", return);
CInventoryPtr invent = character->getInventory(inventory);
DROP_IF(slot >= invent->getSlotCount(), "Invalid slot specified", return);
CGameItemPtr item = invent->getItem(slot);
DROP_IF(item == NULL, "Item does not exist", return);
if (!character->havePriv(":DEV:SGM:GM:EM:"))
{
// TODO: Some special rights to name items :)
const NLMISC::CEntityId &crafterEId = item->getCreator();
const NLMISC::CEntityId &userEId = character->getId();
DROP_IF(crafterEId != userEId, "Item name can only be set by the crafter", return);
}
/*
const CStaticItem *form = item->getStaticForm();
DROP_IF(!form, "Item does not have a static form", return);
ITEMFAMILY::EItemFamily family = form->Family;
DROP_IF(!ITEMFAMILY::isTextCustomizable(family), "Item text cannot be changed", return);
*/
if (literal)
{
text = capitalizeFirst(text); // Require first character to be capitalized
if (text.size() >= 255) // Limit literal text length
text = text.substr(0, 255);
}
item->setPhraseId(text, literal);
}
/// returns 0 on success, anything else is error:
/// -1: Invalid inventory
/// -2: Invalid slot
/// -3: Empty slot
sint32 cbClientItemWrite(CCharacter* character, INVENTORIES::TInventory inventory, uint32 slot, ucstring const& text)
{
if (inventory==INVENTORIES::UNDEFINED)
{
return -1;
}
CInventoryPtr invent = character->getInventory(inventory);
if (slot >= invent->getSlotCount())
{
return -2;
}
if (invent->getItem(slot) == NULL)
{
return -3;
}
CGameItemPtr item = invent->getItem(slot);
item->setCustomText(text.toUtf8());
// Following line was commented out by trap, reason unknown
character->incSlotVersion(inventory, slot); // this ensures re-fetch of info window, unusual case
return 0;
}
void cbClientItemWrite( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
{
CEntityId eid;
INVENTORIES::TInventory inventory;
uint16 slot;
string text;
msgin.serial(eid);
msgin.serialShortEnum(inventory);
msgin.serial(slot);
msgin.serial(text);
CCharacter* character = PlayerManager.getChar(eid);
if(!character) return;
if (!character->havePriv(":DEV:SGM:GM:EM:"))
{
// it should be the crafter of the item, check
if (inventory==INVENTORIES::UNDEFINED) return;
CInventoryPtr invent = character->getInventory(inventory);
if (slot >= invent->getSlotCount()) return;
if (invent->getItem(slot) == NULL) return;
CGameItemPtr item = invent->getItem(slot);
const NLMISC::CEntityId &crafterEId = item->getCreator();
const NLMISC::CEntityId &userEId = character->getId();
if(crafterEId != userEId)
{
string name = CEntityIdTranslator::getInstance()->getByEntity(userEId).toString();
nlwarning("HACK: %s %s tries to set custom text on an item he didn't crafted", userEId.toString().c_str(), name.c_str());
return;
}
// text must not be too big
if(text.size() > 256)
{
string name = CEntityIdTranslator::getInstance()->getByEntity(userEId).toString();
nlwarning("HACK: %s %s tries to set custom text of a size > 256 (%d)", userEId.toString().c_str(), name.c_str(), text.size());
return;
}
// the item must have the good family
const CStaticItem * form = item->getStaticForm();
if (!form) return;
ITEMFAMILY::EItemFamily family = form->Family;
if (!ITEMFAMILY::isTextCustomizable(family))
{
string name = CEntityIdTranslator::getInstance()->getByEntity(userEId).toString();
nlwarning("HACK: %s %s tries to set custom text on a item that is not text customizable (%s)", userEId.toString().c_str(), name.c_str(), ITEMFAMILY::toString(family).c_str());
return;
}
// prevent use of @WEB at begin
if (text.size() >= 4 && text[0]=='@' && text[1]=='W' && text[2]=='E' && text[3]=='B')
text = text.substr(4, text.size() - 4);
// force that the begin of the text for non admin is %mfc
if(!text.empty() && text.substr(0, 4) != string("%mfc"))
{
text = string("%mfc") + text;
}
}
cbClientItemWrite(character, inventory, slot, text);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -2647,6 +2812,7 @@ void cbClientGuildQuit( NLNET::CMessage& msgin, const std::string & serviceName,
void cbClientGuildPutMoney( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId );
/// money : guild to bag
void cbClientGuildTakeMoney( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId );
void cbClientGuildItemAccess( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId );
/// outpost callbacks (implemented in guild_client_callbacks.cpp)
void cbClientOutpostSetSquad(NLNET::CMessage & msgin, const std::string & serviceName, NLNET::TServiceId serviceId);
@ -3135,110 +3301,6 @@ void cbClientReturnToMainland( NLNET::CMessage& msgin, const std::string & servi
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
// CLIENT:EVENT
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
/// returns 0 on success, anything else is error:
/// -1: Invalid inventory
/// -2: Invalid slot
/// -3: Empty slot
sint32 clientEventSetItemCustomText(CCharacter* character, INVENTORIES::TInventory inventory, uint32 slot, ucstring const& text)
{
if (inventory==INVENTORIES::UNDEFINED)
{
return -1;
}
CInventoryPtr invent = character->getInventory(inventory);
if (slot >= invent->getSlotCount())
{
return -2;
}
if (invent->getItem(slot) == NULL)
{
return -3;
}
CGameItemPtr item = invent->getItem(slot);
item->setCustomText(text.toUtf8());
// Following line was commented out by trap, reason unknown
character->incSlotVersion(inventory, slot);
return 0;
}
void cbClientEventSetItemCustomText( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
{
CEntityId eid;
INVENTORIES::TInventory inventory;
uint32 uiInventory;
uint32 slot;
ucstring text;
msgin.serial(eid);
msgin.serial(uiInventory);
inventory = (INVENTORIES::TInventory)uiInventory;
msgin.serial(slot);
msgin.serial(text);
CCharacter* character = PlayerManager.getChar(eid);
if(!character) return;
if (!character->havePriv(":DEV:SGM:GM:EM:"))
{
// it should be the crafter of the item, check
if (inventory==INVENTORIES::UNDEFINED) return;
CInventoryPtr invent = character->getInventory(inventory);
if (slot >= invent->getSlotCount()) return;
if (invent->getItem(slot) == NULL) return;
CGameItemPtr item = invent->getItem(slot);
const NLMISC::CEntityId &crafterEId = item->getCreator();
const NLMISC::CEntityId &userEId = character->getId();
if(crafterEId != userEId)
{
string name = CEntityIdTranslator::getInstance()->getByEntity(userEId).toString();
nlwarning("HACK: %s %s tries to set custom text on an item he didn't crafted", userEId.toString().c_str(), name.c_str());
return;
}
// text must not be too big
if(text.size() > 256)
{
string name = CEntityIdTranslator::getInstance()->getByEntity(userEId).toString();
nlwarning("HACK: %s %s tries to set custom text of a size > 256 (%d)", userEId.toString().c_str(), name.c_str(), text.size());
return;
}
// the item must have the good family
const CStaticItem * form = item->getStaticForm();
if (!form) return;
ITEMFAMILY::EItemFamily family = form->Family;
if (!ITEMFAMILY::isTextCustomizable(family))
{
string name = CEntityIdTranslator::getInstance()->getByEntity(userEId).toString();
nlwarning("HACK: %s %s tries to set custom text on a item that is not text customizable (%s)", userEId.toString().c_str(), name.c_str(), ITEMFAMILY::toString(family).c_str());
return;
}
// prevent use of @WEB at begin
if (text.size() >= 4 && text[0]=='@' && text[1]=='W' && text[2]=='E' && text[3]=='B')
text = text.substr(4, text.size() - 4);
// force that the begin of the text for non admin is %mfc
if(!text.empty() && text.substr(0, 4) != ucstring("%mfc"))
{
text = ucstring("%mfc") + text;
}
}
clientEventSetItemCustomText(character, inventory, slot, text);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
// CLIENT:TOTEM
@ -3420,6 +3482,9 @@ TUnifiedCallbackItem CbClientArray[]=
{ "CLIENT:ITEM:ENCHANT", cbClientItemEnchant },
{ "CLIENT:ITEM:USE_ITEM", cbClientItemUseItem },
{ "CLIENT:ITEM:STOP_USE_XP_CAT", cbClientItemStopUseXpCat },
{ "CLIENT:ITEM:LOCK", cbClientItemLock },
{ "CLIENT:ITEM:RENAME", cbClientItemRename },
{ "CLIENT:ITEM:WRITE", cbClientItemWrite },
{ "CLIENT:ITEM_INFO:GET", cbClientItemInfos },
@ -3589,6 +3654,7 @@ TUnifiedCallbackItem CbClientArray[]=
//{ "CLIENT:GUILD:GUILD_TO_BAG", cbClientGuildToBag },
{ "CLIENT:GUILD:PUT_MONEY", cbClientGuildPutMoney },
{ "CLIENT:GUILD:TAKE_MONEY", cbClientGuildTakeMoney },
{ "CLIENT:GUILD:ITEM_ACCESS", cbClientGuildItemAccess },
// outpost related messages
{ "CLIENT:OUTPOST:SET_SQUAD", cbClientOutpostSetSquad },
@ -3641,7 +3707,7 @@ TUnifiedCallbackItem CbClientArray[]=
{ "CLIENT:MISSION:WAKE", cbClientMissionWake },
{ "CLIENT:MISSION:GROUP_WAKE", cbClientMissionGroupWake },
{ "CLIENT:EVENT:SET_ITEM_CUSTOM_TEXT", cbClientEventSetItemCustomText },
// { "CLIENT:EVENT:SET_ITEM_CUSTOM_TEXT", cbClientEventSetItemCustomText },
{ "CLIENT:TOTEM:BUILD", cbTotemBuild },

@ -1204,6 +1204,10 @@ void CBankAccessor_PLR::TEXCHANGE::TGIVE::TArray::init(ICDBStructNode *parent, u
nlassert(node != NULL);
_USER_COLOR = node;
node = parent->getNode( ICDBStructNode::CTextId("CHARAC_BUFFS"), false );
nlassert(node != NULL);
_CHARAC_BUFFS = node;
node = parent->getNode( ICDBStructNode::CTextId("WEIGHT"), false );
nlassert(node != NULL);
_WEIGHT = node;
@ -1287,6 +1291,10 @@ void CBankAccessor_PLR::TEXCHANGE::TRECEIVE::TArray::init(ICDBStructNode *parent
nlassert(node != NULL);
_USER_COLOR = node;
node = parent->getNode( ICDBStructNode::CTextId("CHARAC_BUFFS"), false );
nlassert(node != NULL);
_CHARAC_BUFFS = node;
node = parent->getNode( ICDBStructNode::CTextId("WEIGHT"), false );
nlassert(node != NULL);
_WEIGHT = node;
@ -1498,6 +1506,10 @@ void CBankAccessor_PLR::TINVENTORY::TTEMP::TArray::init(ICDBStructNode *parent,
nlassert(node != NULL);
_USER_COLOR = node;
node = parent->getNode( ICDBStructNode::CTextId("CHARAC_BUFFS"), false );
nlassert(node != NULL);
_CHARAC_BUFFS = node;
node = parent->getNode( ICDBStructNode::CTextId("WEIGHT"), false );
nlassert(node != NULL);
_WEIGHT = node;
@ -1592,6 +1604,10 @@ void CBankAccessor_PLR::TINVENTORY::TSHARE::TArray::init(ICDBStructNode *parent,
nlassert(node != NULL);
_USER_COLOR = node;
node = parent->getNode( ICDBStructNode::CTextId("CHARAC_BUFFS"), false );
nlassert(node != NULL);
_CHARAC_BUFFS = node;
node = parent->getNode( ICDBStructNode::CTextId("WEIGHT"), false );
nlassert(node != NULL);
_WEIGHT = node;
@ -2144,6 +2160,10 @@ void CBankAccessor_PLR::TTRADING::TArray::init(ICDBStructNode *parent, uint inde
nlassert(node != NULL);
_USER_COLOR = node;
node = parent->getNode( ICDBStructNode::CTextId("CHARAC_BUFFS"), false );
nlassert(node != NULL);
_CHARAC_BUFFS = node;
node = parent->getNode( ICDBStructNode::CTextId("WEIGHT"), false );
nlassert(node != NULL);
_WEIGHT = node;

@ -2785,6 +2785,7 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
ICDBStructNode *_QUALITY;
ICDBStructNode *_QUANTITY;
ICDBStructNode *_USER_COLOR;
ICDBStructNode *_CHARAC_BUFFS;
ICDBStructNode *_WEIGHT;
ICDBStructNode *_NAMEID;
ICDBStructNode *_ENCHANT;
@ -2894,6 +2895,26 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
return _USER_COLOR;
}
void setCHARAC_BUFFS(CCDBSynchronised &dbGroup, uint8 value, bool forceSending = false)
{
_setProp(dbGroup, _CHARAC_BUFFS, value, forceSending);
}
uint8 getCHARAC_BUFFS(const CCDBSynchronised &dbGroup)
{
uint8 value;
_getProp(dbGroup, _CHARAC_BUFFS, value);
return value;
}
ICDBStructNode *getCHARAC_BUFFSCDBNode()
{
return _CHARAC_BUFFS;
}
void setWEIGHT(CCDBSynchronised &dbGroup, uint16 value, bool forceSending = false)
{
@ -3105,6 +3126,7 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
ICDBStructNode *_QUALITY;
ICDBStructNode *_QUANTITY;
ICDBStructNode *_USER_COLOR;
ICDBStructNode *_CHARAC_BUFFS;
ICDBStructNode *_WEIGHT;
ICDBStructNode *_NAMEID;
ICDBStructNode *_ENCHANT;
@ -3214,6 +3236,26 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
return _USER_COLOR;
}
void setCHARAC_BUFFS(CCDBSynchronised &dbGroup, uint8 value, bool forceSending = false)
{
_setProp(dbGroup, _CHARAC_BUFFS, value, forceSending);
}
uint8 getCHARAC_BUFFS(const CCDBSynchronised &dbGroup)
{
uint8 value;
_getProp(dbGroup, _CHARAC_BUFFS, value);
return value;
}
ICDBStructNode *getCHARAC_BUFFSCDBNode()
{
return _CHARAC_BUFFS;
}
void setWEIGHT(CCDBSynchronised &dbGroup, uint16 value, bool forceSending = false)
{
@ -3758,6 +3800,7 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
ICDBStructNode *_QUALITY;
ICDBStructNode *_QUANTITY;
ICDBStructNode *_USER_COLOR;
ICDBStructNode *_CHARAC_BUFFS;
ICDBStructNode *_WEIGHT;
ICDBStructNode *_NAMEID;
ICDBStructNode *_ENCHANT;
@ -3867,6 +3910,26 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
return _USER_COLOR;
}
void setCHARAC_BUFFS(CCDBSynchronised &dbGroup, uint8 value, bool forceSending = false)
{
_setProp(dbGroup, _CHARAC_BUFFS, value, forceSending);
}
uint8 getCHARAC_BUFFS(const CCDBSynchronised &dbGroup)
{
uint8 value;
_getProp(dbGroup, _CHARAC_BUFFS, value);
return value;
}
ICDBStructNode *getCHARAC_BUFFSCDBNode()
{
return _CHARAC_BUFFS;
}
void setWEIGHT(CCDBSynchronised &dbGroup, uint16 value, bool forceSending = false)
{
@ -4120,6 +4183,7 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
ICDBStructNode *_QUALITY;
ICDBStructNode *_QUANTITY;
ICDBStructNode *_USER_COLOR;
ICDBStructNode *_CHARAC_BUFFS;
ICDBStructNode *_WEIGHT;
ICDBStructNode *_NAMEID;
ICDBStructNode *_ENCHANT;
@ -4231,6 +4295,26 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
return _USER_COLOR;
}
void setCHARAC_BUFFS(CCDBSynchronised &dbGroup, uint8 value, bool forceSending = false)
{
_setProp(dbGroup, _CHARAC_BUFFS, value, forceSending);
}
uint8 getCHARAC_BUFFS(const CCDBSynchronised &dbGroup)
{
uint8 value;
_getProp(dbGroup, _CHARAC_BUFFS, value);
return value;
}
ICDBStructNode *getCHARAC_BUFFSCDBNode()
{
return _CHARAC_BUFFS;
}
void setWEIGHT(CCDBSynchronised &dbGroup, uint16 value, bool forceSending = false)
{
@ -5763,6 +5847,7 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
ICDBStructNode *_QUALITY;
ICDBStructNode *_QUANTITY;
ICDBStructNode *_USER_COLOR;
ICDBStructNode *_CHARAC_BUFFS;
ICDBStructNode *_WEIGHT;
ICDBStructNode *_NAMEID;
ICDBStructNode *_ENCHANT;
@ -5883,6 +5968,26 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
return _USER_COLOR;
}
void setCHARAC_BUFFS(CCDBSynchronised &dbGroup, uint8 value, bool forceSending = false)
{
_setProp(dbGroup, _CHARAC_BUFFS, value, forceSending);
}
uint8 getCHARAC_BUFFS(const CCDBSynchronised &dbGroup)
{
uint8 value;
_getProp(dbGroup, _CHARAC_BUFFS, value);
return value;
}
ICDBStructNode *getCHARAC_BUFFSCDBNode()
{
return _CHARAC_BUFFS;
}
void setWEIGHT(CCDBSynchronised &dbGroup, uint16 value, bool forceSending = false)
{

@ -1089,7 +1089,7 @@ void CCharacterInvView::updateClientSlot(uint32 slot, const CGameItemPtr item)
itemSlot.setItemProp( INVENTORIES::UserColor, item->color() );
itemSlot.setItemProp( INVENTORIES::Buffs, item->buffFlags() );
itemSlot.setItemProp( INVENTORIES::Locked, item->getLockCount() );
itemSlot.setItemProp( INVENTORIES::Access, item->getAccessGrade() );
itemSlot.setItemProp( INVENTORIES::Access, 0 ); // don't care here
itemSlot.setItemProp( INVENTORIES::Weight, item->weight() / 10 );
itemSlot.setItemProp( INVENTORIES::NameId, item->sendNameId(getCharacter()) );
itemSlot.setItemProp( INVENTORIES::Enchant, item->getClientEnchantValue() );

@ -237,6 +237,33 @@ void cbClientGuildTakeMoney( NLNET::CMessage& msgin, const std::string & service
guild->takeMoney( character, money ,session );
}
void cbClientGuildItemAccess(NLNET::CMessage &msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
{
CEntityId eid;
// INVENTORIES::TInventory inventory;
uint16 slot;
EGSPD::CGuildGrade::TGuildGrade grade;
msgin.serial(eid);
// msgin.serialShortEnum(inventory);
msgin.serial(slot);
msgin.serialShortEnum(grade);
CCharacter *character = PlayerManager.getChar(eid);
DROP_IF(!character, "Character not found", return);
// DROP_IF(inventory == INVENTORIES::UNDEFINED, "Inventory is undefined", return);
CInventoryPtr invent = character->getInventory(INVENTORIES::guild);
DROP_IF(slot >= invent->getSlotCount(), "Invalid slot specified", return);
CGameItemPtr item = invent->getItem(slot);
DROP_IF(item == NULL, "Item does not exist", return);
CGuild *guild = CGuildManager::getInstance()->getGuildFromId(character->getGuildId());
bool hasAccess = guild->getMemberFromEId(eid)->getGrade() <= item->getAccessGrade();
DROP_IF(!hasAccess, "Character does not have the right grade to change access rights on this item", return);
item->setAccessGrade(grade);
}
#undef GET_CHAR
#undef GET_GUILD_MODULE

Loading…
Cancel
Save