mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 17:06:43 +00:00
[General] Rename item health into charge, for consistency with OpenMW
This commit is contained in:
parent
f03724be7b
commit
f314b13edf
7 changed files with 35 additions and 34 deletions
|
@ -24,14 +24,14 @@ 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 health) noexcept
|
void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *itemId, 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 = itemId;
|
||||||
player->equipedItems[slot].count = count;
|
player->equipedItems[slot].count = count;
|
||||||
player->equipedItems[slot].health = health;
|
player->equipedItems[slot].charge = charge;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcept
|
void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcept
|
||||||
|
@ -42,7 +42,7 @@ 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 health) noexcept
|
void ItemFunctions::AddItem(unsigned short pid, const char* itemId, unsigned int count, int charge) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, );
|
GET_PLAYER(pid, player, );
|
||||||
|
@ -50,7 +50,7 @@ void ItemFunctions::AddItem(unsigned short pid, const char* itemId, unsigned int
|
||||||
Item item;
|
Item item;
|
||||||
item.refId = itemId;
|
item.refId = itemId;
|
||||||
item.count = count;
|
item.count = count;
|
||||||
item.health = health;
|
item.charge = charge;
|
||||||
|
|
||||||
player->inventoryChangesBuffer.items.push_back(item);
|
player->inventoryChangesBuffer.items.push_back(item);
|
||||||
player->inventoryChangesBuffer.action = InventoryChanges::ADD;
|
player->inventoryChangesBuffer.action = InventoryChanges::ADD;
|
||||||
|
@ -105,12 +105,12 @@ int ItemFunctions::GetEquipmentItemCount(unsigned short pid, unsigned short slot
|
||||||
return player->equipedItems[slot].count;
|
return player->equipedItems[slot].count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ItemFunctions::GetEquipmentItemHealth(unsigned short pid, unsigned short slot) noexcept
|
int ItemFunctions::GetEquipmentItemCharge(unsigned short pid, unsigned short slot) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, 0);
|
GET_PLAYER(pid, player, 0);
|
||||||
|
|
||||||
return player->equipedItems[slot].health;
|
return player->equipedItems[slot].charge;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ItemFunctions::GetInventoryItemId(unsigned short pid, unsigned int i) noexcept
|
const char *ItemFunctions::GetInventoryItemId(unsigned short pid, unsigned int i) noexcept
|
||||||
|
@ -132,12 +132,12 @@ int ItemFunctions::GetInventoryItemCount(unsigned short pid, unsigned int i) noe
|
||||||
return player->inventoryChanges.items.at(i).count;
|
return player->inventoryChanges.items.at(i).count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ItemFunctions::GetInventoryItemHealth(unsigned short pid, unsigned int i) noexcept
|
int ItemFunctions::GetInventoryItemCharge(unsigned short pid, unsigned int i) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, 0);
|
GET_PLAYER(pid, player, 0);
|
||||||
|
|
||||||
return player->inventoryChanges.items.at(i).health;
|
return player->inventoryChanges.items.at(i).charge;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemFunctions::SendEquipment(unsigned short pid) noexcept
|
void ItemFunctions::SendEquipment(unsigned short pid) noexcept
|
||||||
|
|
|
@ -20,11 +20,11 @@
|
||||||
\
|
\
|
||||||
{"GetEquipmentItemId", ItemFunctions::GetEquipmentItemId},\
|
{"GetEquipmentItemId", ItemFunctions::GetEquipmentItemId},\
|
||||||
{"GetEquipmentItemCount", ItemFunctions::GetEquipmentItemCount},\
|
{"GetEquipmentItemCount", ItemFunctions::GetEquipmentItemCount},\
|
||||||
{"GetEquipmentItemHealth", ItemFunctions::GetEquipmentItemHealth},\
|
{"GetEquipmentItemCharge", ItemFunctions::GetEquipmentItemCharge},\
|
||||||
\
|
\
|
||||||
{"GetInventoryItemId", ItemFunctions::GetInventoryItemId},\
|
{"GetInventoryItemId", ItemFunctions::GetInventoryItemId},\
|
||||||
{"GetInventoryItemCount", ItemFunctions::GetInventoryItemCount},\
|
{"GetInventoryItemCount", ItemFunctions::GetInventoryItemCount},\
|
||||||
{"GetInventoryItemHealth", ItemFunctions::GetInventoryItemHealth},\
|
{"GetInventoryItemCharge", ItemFunctions::GetInventoryItemCharge},\
|
||||||
\
|
\
|
||||||
{"SendEquipment", ItemFunctions::SendEquipment},\
|
{"SendEquipment", ItemFunctions::SendEquipment},\
|
||||||
{"SendInventoryChanges", ItemFunctions::SendInventoryChanges}
|
{"SendInventoryChanges", ItemFunctions::SendInventoryChanges}
|
||||||
|
@ -36,10 +36,10 @@ 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 health) noexcept;
|
static void EquipItem(unsigned short pid, unsigned short slot, const char* itemId, 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 health) noexcept;
|
static void AddItem(unsigned short pid, const char* itemId, 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* itemId, unsigned short count) noexcept;
|
||||||
static void ClearInventory(unsigned short pid) noexcept;
|
static void ClearInventory(unsigned short pid) noexcept;
|
||||||
|
|
||||||
|
@ -47,11 +47,11 @@ public:
|
||||||
|
|
||||||
static const char *GetEquipmentItemId(unsigned short pid, unsigned short slot) noexcept;
|
static const char *GetEquipmentItemId(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 GetEquipmentItemHealth(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 *GetInventoryItemId(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 GetInventoryItemHealth(unsigned short pid, unsigned int i) noexcept;
|
static int GetInventoryItemCharge(unsigned short pid, unsigned int i) noexcept;
|
||||||
|
|
||||||
static void SendEquipment(unsigned short pid) noexcept;
|
static void SendEquipment(unsigned short pid) noexcept;
|
||||||
static void SendInventoryChanges(unsigned short pid) noexcept;
|
static void SendInventoryChanges(unsigned short pid) noexcept;
|
||||||
|
|
|
@ -400,7 +400,7 @@ void LocalPlayer::updateEquipment(bool forceUpdate)
|
||||||
equipChanged = true;
|
equipChanged = true;
|
||||||
|
|
||||||
equipedItems[slot].refId = it->getCellRef().getRefId();
|
equipedItems[slot].refId = it->getCellRef().getRefId();
|
||||||
equipedItems[slot].health = it->getCellRef().getCharge();
|
equipedItems[slot].charge = it->getCellRef().getCharge();
|
||||||
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
||||||
{
|
{
|
||||||
MWMechanics::WeaponType weaptype;
|
MWMechanics::WeaponType weaptype;
|
||||||
|
@ -416,7 +416,7 @@ void LocalPlayer::updateEquipment(bool forceUpdate)
|
||||||
equipChanged = true;
|
equipChanged = true;
|
||||||
equipedItems[slot].refId = "";
|
equipedItems[slot].refId = "";
|
||||||
equipedItems[slot].count = 0;
|
equipedItems[slot].count = 0;
|
||||||
equipedItems[slot].health = 0;
|
equipedItems[slot].charge = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ void LocalPlayer::updateInventory(bool forceUpdate)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
item.count = result->getRefData().getCount();
|
item.count = result->getRefData().getCount();
|
||||||
item.health = result->getCellRef().getCharge();
|
item.charge = result->getCellRef().getCharge();
|
||||||
|
|
||||||
if (item == (*iter))
|
if (item == (*iter))
|
||||||
break;
|
break;
|
||||||
|
@ -475,7 +475,7 @@ void LocalPlayer::updateInventory(bool forceUpdate)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
item.count = iter->getRefData().getCount();
|
item.count = iter->getRefData().getCount();
|
||||||
item.health = iter->getCellRef().getCharge();
|
item.charge = iter->getCellRef().getCharge();
|
||||||
|
|
||||||
vector<Item>::iterator result = inventoryChanges.items.begin();
|
vector<Item>::iterator result = inventoryChanges.items.begin();
|
||||||
|
|
||||||
|
@ -638,8 +638,8 @@ void LocalPlayer::addItems()
|
||||||
{
|
{
|
||||||
mwmp::Item item = inventoryChanges.items[i];
|
mwmp::Item item = inventoryChanges.items[i];
|
||||||
MWWorld::Ptr itemPtr = *ptrStore.add(item.refId, item.count, ptrPlayer);
|
MWWorld::Ptr itemPtr = *ptrStore.add(item.refId, item.count, ptrPlayer);
|
||||||
if (item.health != -1)
|
if (item.charge != -1)
|
||||||
itemPtr.getCellRef().setCharge(item.health);
|
itemPtr.getCellRef().setCharge(item.charge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -970,7 +970,7 @@ void LocalPlayer::sendInventory()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
item.count = iter->getRefData().getCount();
|
item.count = iter->getRefData().getCount();
|
||||||
item.health = iter->getCellRef().getCharge();
|
item.charge = iter->getCellRef().getCharge();
|
||||||
|
|
||||||
inventoryChanges.items.push_back(item);
|
inventoryChanges.items.push_back(item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,10 +39,11 @@ namespace mwmp
|
||||||
{
|
{
|
||||||
std::string refId;
|
std::string refId;
|
||||||
int count;
|
int count;
|
||||||
int health;
|
int charge;
|
||||||
|
|
||||||
inline bool operator==(const Item& rhs)
|
inline bool operator==(const Item& rhs)
|
||||||
{
|
{
|
||||||
return refId == rhs.refId && count == rhs.count && health == rhs.health;
|
return refId == rhs.refId && count == rhs.count && charge == rhs.charge;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,6 @@ void PacketPlayerEquipment::Packet(RakNet::BitStream *bs, BasePlayer *player, bo
|
||||||
{
|
{
|
||||||
RW(player->equipedItems[i].refId, send);
|
RW(player->equipedItems[i].refId, send);
|
||||||
RW(player->equipedItems[i].count, send);
|
RW(player->equipedItems[i].count, send);
|
||||||
RW(player->equipedItems[i].health, send);
|
RW(player->equipedItems[i].charge, send);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,15 +33,14 @@ void PacketPlayerInventory::Packet(RakNet::BitStream *bs, BasePlayer *player, bo
|
||||||
if (send)
|
if (send)
|
||||||
{
|
{
|
||||||
item = player->inventoryChanges.items[i];
|
item = player->inventoryChanges.items[i];
|
||||||
RW(item.refId, send);
|
|
||||||
RW(item.count, send);
|
|
||||||
RW(item.health, send);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
RW(item.refId, send);
|
||||||
|
RW(item.count, send);
|
||||||
|
RW(item.charge, send);
|
||||||
|
|
||||||
|
if (!send)
|
||||||
{
|
{
|
||||||
RW(item.refId, send);
|
|
||||||
RW(item.count, send);
|
|
||||||
RW(item.health, send);
|
|
||||||
player->inventoryChanges.items.push_back(item);
|
player->inventoryChanges.items.push_back(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,11 +29,12 @@ void PacketPlayerSpellbook::Packet(RakNet::BitStream *bs, BasePlayer *player, bo
|
||||||
if (send)
|
if (send)
|
||||||
{
|
{
|
||||||
spell = player->spellbookChanges.spells[i];
|
spell = player->spellbookChanges.spells[i];
|
||||||
RW(spell.mId, send);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
RW(spell.mId, send);
|
||||||
|
|
||||||
|
if (!send)
|
||||||
{
|
{
|
||||||
RW(spell.mId, send);
|
|
||||||
player->spellbookChanges.spells.push_back(spell);
|
player->spellbookChanges.spells.push_back(spell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue