Skip to content

Commit

Permalink
Actually send and store the equipment slot
Browse files Browse the repository at this point in the history
I was wrong to assume that we do not need it. The accountserver needs to
send the info the the client in order to display the equipment on the
character selection page.
  • Loading branch information
Erik Schilling committed Sep 30, 2013
1 parent 2a3af0a commit 0eac9c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
11 changes: 3 additions & 8 deletions src/account-server/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,19 +510,15 @@ CharacterData *Storage::getCharacterBySQL(Account *owner)
unsigned short slot = toUint(itemInfo(k, 2));
item.itemId = toUint(itemInfo(k, 3));
item.amount = toUint(itemInfo(k, 4));
item.equipmentSlot = toUint(itemInfo(k, 5));
inventoryData[slot] = item;

if (toUint(itemInfo(k, 5)) != 0)
if (item.equipmentSlot != 0)
{
// The game server will set the right slot anyway,
// but this speeds up checking if the item is equipped
item.equipmentSlot = 1;
equipmentData.insert(slot);
}
else
{
item.equipmentSlot = 0;
}
}
}
poss.setInventory(inventoryData);
Expand Down Expand Up @@ -850,10 +846,9 @@ bool Storage::updateCharacter(CharacterData *character)
unsigned short slot = itemIt->first;
unsigned itemId = itemIt->second.itemId;
unsigned amount = itemIt->second.amount;
bool equipped = itemIt->second.equipmentSlot != 0;
assert(itemId);
sql << base << slot << ", " << itemId << ", " << amount << ", "
<< (equipped ? 1 : 0) << ");";
<< itemIt->second.equipmentSlot << ");";
mDb->execSql(sql.str());
}

Expand Down
10 changes: 3 additions & 7 deletions src/game-server/charactercomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,19 +278,15 @@ void CharacterComponent::serialize(Entity &entity, MessageOut &msg)

// inventory - must be last because size isn't transmitted
const Possessions &poss = getPossessions();
const EquipData &equipData = poss.getEquipment();

const InventoryData &inventoryData = poss.getInventory();
for (InventoryData::const_iterator itemIt = inventoryData.begin(),
itemIt_end = inventoryData.end(); itemIt != itemIt_end; ++itemIt)
{
msg.writeInt16(itemIt->first); // slot id
msg.writeInt16(itemIt->second.itemId); // item id
msg.writeInt16(itemIt->second.amount); // amount
if (equipData.find(itemIt->first) != equipData.end())
msg.writeInt8(1); // equipped
else
msg.writeInt8(0); // not equipped
msg.writeInt16(itemIt->second.itemId);
msg.writeInt16(itemIt->second.amount);
msg.writeInt8(itemIt->second.equipmentSlot);
}
}

Expand Down

0 comments on commit 0eac9c5

Please sign in to comment.