summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-11 18:09:33 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-11 18:09:33 +0300
commit17dcb835103ac05012c5a7eafa8c7702cef53390 (patch)
tree422c28adfba13f2161fcfc36943a3903e531490b /src/net
parent84d53b7bb98bb44696ed1bc2c3f132e51394ac00 (diff)
downloadmanaverse-17dcb835103ac05012c5a7eafa8c7702cef53390.tar.gz
manaverse-17dcb835103ac05012c5a7eafa8c7702cef53390.tar.bz2
manaverse-17dcb835103ac05012c5a7eafa8c7702cef53390.tar.xz
manaverse-17dcb835103ac05012c5a7eafa8c7702cef53390.zip
Add some fixes after automatic checks.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/inventoryhandler.cpp60
1 files changed, 23 insertions, 37 deletions
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index 9e751f27c..1f589356e 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -160,14 +160,8 @@ int InventoryHandler::getSlot(int eAthenaSlot)
void InventoryHandler::processPlayerInventory(Net::MessageIn &msg,
bool playerInvintory)
{
- int index, amount, itemId, arrow;
- int cards[4], itemType;
- unsigned char identified;
- Inventory *inventory = nullptr;
-
- if (player_node)
- inventory = PlayerInfo::getInventory();
-
+ Inventory *const inventory = player_node
+ ? PlayerInfo::getInventory() : nullptr;
if (playerInvintory)
{
if (PlayerInfo::getEquipment())
@@ -190,17 +184,17 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg,
for (int loop = 0; loop < number; loop++)
{
- index = msg.readInt16();
- itemId = msg.readInt16();
- itemType = msg.readInt8();
- identified = msg.readInt8();
- amount = msg.readInt16();
- arrow = msg.readInt16();
+ int cards[4];
+ const int index = msg.readInt16() - (playerInvintory
+ ? INVENTORY_OFFSET : STORAGE_OFFSET);
+ const int itemId = msg.readInt16();
+ const int itemType = msg.readInt8();
+ unsigned char identified = msg.readInt8();
+ const int amount = msg.readInt16();
+ const int arrow = msg.readInt16();
for (int i = 0; i < 4; i++)
cards[i] = msg.readInt16();
- index -= (playerInvintory ? INVENTORY_OFFSET : STORAGE_OFFSET);
-
if (mDebugInventory)
{
logger->log("Index: %d, ID: %d, Type: %d, Identified: %d, "
@@ -233,24 +227,21 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg,
void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg)
{
- int index, amount, itemId, refine;
- int cards[4], itemType;
- unsigned char identified;
-
msg.readInt16(); // length
const int number = (msg.getLength() - 4) / 20;
for (int loop = 0; loop < number; loop++)
{
- index = msg.readInt16() - STORAGE_OFFSET;
- itemId = msg.readInt16();
- itemType = msg.readInt8();
- identified = msg.readInt8();
- amount = 1;
+ int cards[4];
+ const int index = msg.readInt16() - STORAGE_OFFSET;
+ const int itemId = msg.readInt16();
+ const int itemType = msg.readInt8();
+ unsigned char identified = msg.readInt8();
+ const int amount = 1;
msg.readInt16(); // Equip Point?
msg.readInt16(); // Another Equip Point?
msg.readInt8(); // Attribute (broken)
- refine = msg.readInt8();
+ const int refine = msg.readInt8();
for (int i = 0; i < 4; i++)
cards[i] = msg.readInt16();
@@ -507,10 +498,6 @@ void InventoryHandler::processPlayerStorageClose(Net::MessageIn &msg A_UNUSED)
void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
{
- int index, itemId, equipType, refine;
- int number;
- unsigned char identified;
-
Inventory *inventory = nullptr;
if (player_node)
inventory = PlayerInfo::getInventory();
@@ -522,22 +509,21 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
mEquips.clear();
PlayerInfo::getEquipment()->setBackend(&mEquips);
}
- number = (msg.getLength() - 4) / 20;
+ const int number = (msg.getLength() - 4) / 20;
for (int loop = 0; loop < number; loop++)
{
- index = msg.readInt16() - INVENTORY_OFFSET;
- itemId = msg.readInt16();
+ const int index = msg.readInt16() - INVENTORY_OFFSET;
+ const int itemId = msg.readInt16();
const int itemType = msg.readInt8(); // type
- identified = msg.readInt8(); // identify flag
+ unsigned char identified = msg.readInt8(); // identify flag
msg.readInt16(); // equip type
- equipType = msg.readInt16();
+ const int equipType = msg.readInt16();
msg.readInt8(); // attribute
- refine = msg.readInt8();
+ const int refine = msg.readInt8();
msg.skip(8); // card
-
if (mDebugInventory)
{
logger->log("Index: %d, ID: %d, Type: %d, Identified: %d",