[Server] In Item script functions, rename itemId into refId for clarity

coverity_scan^2
David Cernat 8 years ago
parent 6144ca95d8
commit b651c4deb4

@ -24,12 +24,12 @@ unsigned int ItemFunctions::GetInventoryChangesSize(unsigned short pid) noexcept
return player->inventoryChanges.count; return player->inventoryChanges.count;
} }
void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *itemId, unsigned int count, int charge) noexcept void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *refId, unsigned int count, int charge) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);
player->equipedItems[slot].refId = itemId; player->equipedItems[slot].refId = refId;
player->equipedItems[slot].count = count; player->equipedItems[slot].count = count;
player->equipedItems[slot].charge = charge; player->equipedItems[slot].charge = charge;
} }
@ -42,13 +42,13 @@ void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcep
ItemFunctions::EquipItem(pid, slot, "", 0, -1); ItemFunctions::EquipItem(pid, slot, "", 0, -1);
} }
void ItemFunctions::AddItem(unsigned short pid, const char* itemId, unsigned int count, int charge) noexcept void ItemFunctions::AddItem(unsigned short pid, const char* refId, unsigned int count, int charge) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, ); GET_PLAYER(pid, player, );
Item item; Item item;
item.refId = itemId; item.refId = refId;
item.count = count; item.count = count;
item.charge = charge; item.charge = charge;
@ -56,13 +56,13 @@ void ItemFunctions::AddItem(unsigned short pid, const char* itemId, unsigned int
player->inventoryChangesBuffer.action = InventoryChanges::ADD; player->inventoryChangesBuffer.action = InventoryChanges::ADD;
} }
void ItemFunctions::RemoveItem(unsigned short pid, const char* itemId, unsigned short count) noexcept void ItemFunctions::RemoveItem(unsigned short pid, const char* refId, unsigned short count) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, ); GET_PLAYER(pid, player, );
Item item; Item item;
item.refId = itemId; item.refId = refId;
item.count = count; item.count = count;
player->inventoryChangesBuffer.items.push_back(item); player->inventoryChangesBuffer.items.push_back(item);
@ -78,18 +78,18 @@ void ItemFunctions::ClearInventory(unsigned short pid) noexcept
player->inventoryChangesBuffer.action = InventoryChanges::SET; player->inventoryChangesBuffer.action = InventoryChanges::SET;
} }
bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* itemId) bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* refId)
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, false); GET_PLAYER(pid, player, false);
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; slot++) for (int slot = 0; slot < MWWorld::InventoryStore::Slots; slot++)
if (Misc::StringUtils::ciEqual(player->equipedItems[slot].refId, itemId)) if (Misc::StringUtils::ciEqual(player->equipedItems[slot].refId, refId))
return true; return true;
return false; return false;
} }
const char *ItemFunctions::GetEquipmentItemId(unsigned short pid, unsigned short slot) noexcept const char *ItemFunctions::GetEquipmentItemRefId(unsigned short pid, unsigned short slot) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, 0); GET_PLAYER(pid, player, 0);
@ -113,7 +113,7 @@ int ItemFunctions::GetEquipmentItemCharge(unsigned short pid, unsigned short slo
return player->equipedItems[slot].charge; return player->equipedItems[slot].charge;
} }
const char *ItemFunctions::GetInventoryItemId(unsigned short pid, unsigned int i) noexcept const char *ItemFunctions::GetInventoryItemRefId(unsigned short pid, unsigned int i) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, ""); GET_PLAYER(pid, player, "");

@ -18,11 +18,11 @@
\ \
{"HasItemEquipped", ItemFunctions::HasItemEquipped},\ {"HasItemEquipped", ItemFunctions::HasItemEquipped},\
\ \
{"GetEquipmentItemId", ItemFunctions::GetEquipmentItemId},\ {"GetEquipmentItemRefId", ItemFunctions::GetEquipmentItemRefId},\
{"GetEquipmentItemCount", ItemFunctions::GetEquipmentItemCount},\ {"GetEquipmentItemCount", ItemFunctions::GetEquipmentItemCount},\
{"GetEquipmentItemCharge", ItemFunctions::GetEquipmentItemCharge},\ {"GetEquipmentItemCharge", ItemFunctions::GetEquipmentItemCharge},\
\ \
{"GetInventoryItemId", ItemFunctions::GetInventoryItemId},\ {"GetInventoryItemRefId", ItemFunctions::GetInventoryItemRefId},\
{"GetInventoryItemCount", ItemFunctions::GetInventoryItemCount},\ {"GetInventoryItemCount", ItemFunctions::GetInventoryItemCount},\
{"GetInventoryItemCharge", ItemFunctions::GetInventoryItemCharge},\ {"GetInventoryItemCharge", ItemFunctions::GetInventoryItemCharge},\
\ \
@ -36,20 +36,20 @@ public:
static int GetEquipmentSize() noexcept; static int GetEquipmentSize() noexcept;
static unsigned int GetInventoryChangesSize(unsigned short pid) noexcept; static unsigned int GetInventoryChangesSize(unsigned short pid) noexcept;
static void EquipItem(unsigned short pid, unsigned short slot, const char* itemId, unsigned int count, int charge) noexcept; static void EquipItem(unsigned short pid, unsigned short slot, const char* refId, unsigned int count, int charge) noexcept;
static void UnequipItem(unsigned short pid, unsigned short slot) noexcept; static void UnequipItem(unsigned short pid, unsigned short slot) noexcept;
static void AddItem(unsigned short pid, const char* itemId, unsigned int count, int charge) noexcept; static void AddItem(unsigned short pid, const char* refId, unsigned int count, int charge) noexcept;
static void RemoveItem(unsigned short pid, const char* itemId, unsigned short count) noexcept; static void RemoveItem(unsigned short pid, const char* refId, unsigned short count) noexcept;
static void ClearInventory(unsigned short pid) noexcept; static void ClearInventory(unsigned short pid) noexcept;
static bool HasItemEquipped(unsigned short pid, const char* itemId); static bool HasItemEquipped(unsigned short pid, const char* refId);
static const char *GetEquipmentItemId(unsigned short pid, unsigned short slot) noexcept; static const char *GetEquipmentItemRefId(unsigned short pid, unsigned short slot) noexcept;
static int GetEquipmentItemCount(unsigned short pid, unsigned short slot) noexcept; static int GetEquipmentItemCount(unsigned short pid, unsigned short slot) noexcept;
static int GetEquipmentItemCharge(unsigned short pid, unsigned short slot) noexcept; static int GetEquipmentItemCharge(unsigned short pid, unsigned short slot) noexcept;
static const char *GetInventoryItemId(unsigned short pid, unsigned int i) noexcept; static const char *GetInventoryItemRefId(unsigned short pid, unsigned int i) noexcept;
static int GetInventoryItemCount(unsigned short pid, unsigned int i) noexcept; static int GetInventoryItemCount(unsigned short pid, unsigned int i) noexcept;
static int GetInventoryItemCharge(unsigned short pid, unsigned int i) noexcept; static int GetInventoryItemCharge(unsigned short pid, unsigned int i) noexcept;

Loading…
Cancel
Save