mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-25 16:46:17 +00:00
Don't add multiples identical items to a group
Solves the issue where 2 hand weapon were not properly equipped --HG-- branch : fix_item_group_08072017
This commit is contained in:
parent
59ce9437c8
commit
bc17b5eb1a
1 changed files with 24 additions and 2 deletions
|
@ -73,6 +73,21 @@ bool CItemGroup::contains(CDBCtrlSheet *other, SLOT_EQUIPMENT::TSlotEquipment &s
|
|||
|
||||
void CItemGroup::addItem(sint32 createTime, sint32 serial, SLOT_EQUIPMENT::TSlotEquipment slot)
|
||||
{
|
||||
//Don't add an item if it already exists, this could cause issue
|
||||
// It's happening either if we are creating a group with a 2 hands items (and the item is found both in handR and handL)
|
||||
// Or if an user incorrectly edit his group file
|
||||
for(int i=0; i<Items.size(); i++)
|
||||
{
|
||||
if( Items[i].createTime == createTime && Items[i].serial == serial)
|
||||
{
|
||||
nldebug("Not adding duplicate item, createTime: %d, serial: %d", createTime, serial);
|
||||
//In this case, we are adding the duplicate item for a 2 hands item
|
||||
//If it's saved as a left hand item, save it as a right hand item instead (so we have only 1 correct item)
|
||||
if(Items[i].slot == SLOT_EQUIPMENT::TSlotEquipment::HANDL && slot == SLOT_EQUIPMENT::TSlotEquipment::HANDR)
|
||||
Items[i].slot = SLOT_EQUIPMENT::TSlotEquipment::HANDR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Items.push_back(CItem(createTime, serial, slot));
|
||||
}
|
||||
|
||||
|
@ -158,9 +173,16 @@ void CItemGroup::readFrom(xmlNodePtr node)
|
|||
ptrName = (char*) xmlGetProp(curNode, (xmlChar*)"maxPrice");
|
||||
if (ptrName) NLMISC::fromString((const char*)ptrName, item.maxPrice);
|
||||
item.usePrice = (item.minPrice != 0 || item.maxPrice != std::numeric_limits<uint32>::max());
|
||||
|
||||
if(item.createTime != 0)
|
||||
{
|
||||
addItem(item.createTime, item.serial, item.slot);
|
||||
}
|
||||
// Old load : keep for compatibility / migration reasons
|
||||
else
|
||||
{
|
||||
Items.push_back(item);
|
||||
}
|
||||
}
|
||||
if (strcmp((char*)curNode->name, "remove") == 0)
|
||||
{
|
||||
std::string slot;
|
||||
|
|
Loading…
Reference in a new issue