[General] Use doubles instead of ints for enchantmentCharge

Additionally, include enchantmentCharges for items  in PlayerEquipment packets.
0.6.2
David Cernat 7 years ago
parent f746958afa
commit 9935f56d46

@ -163,7 +163,7 @@ int ActorFunctions::GetActorEquipmentItemCharge(unsigned int i, unsigned short s
return readActorList->baseActors.at(i).equipedItems[slot].charge;
}
int ActorFunctions::GetActorEquipmentItemEnchantmentCharge(unsigned int i, unsigned short slot) noexcept
double ActorFunctions::GetActorEquipmentItemEnchantmentCharge(unsigned int i, unsigned short slot) noexcept
{
return readActorList->baseActors.at(i).equipedItems[slot].enchantmentCharge;
}
@ -267,7 +267,7 @@ void ActorFunctions::SetActorFatigueModified(double value) noexcept
tempActor.creatureStats.mDynamic[2].mMod = value;
}
void ActorFunctions::EquipActorItem(unsigned short slot, const char *refId, unsigned int count, int charge, int enchantmentCharge) noexcept
void ActorFunctions::EquipActorItem(unsigned short slot, const char *refId, unsigned int count, int charge, double enchantmentCharge) noexcept
{
tempActor.equipedItems[slot].refId = refId;
tempActor.equipedItems[slot].count = count;

@ -308,7 +308,7 @@ public:
* \param slot The slot of the equipment item.
* \return The enchantment charge.
*/
static int GetActorEquipmentItemEnchantmentCharge(unsigned int i, unsigned short slot) noexcept;
static double GetActorEquipmentItemEnchantmentCharge(unsigned int i, unsigned short slot) noexcept;
/**
* \brief Check whether there is any positional data for the actor at a certain index in
@ -492,7 +492,7 @@ public:
* \param enchantmentCharge The enchantment charge of the item.
* \return void
*/
static void EquipActorItem(unsigned short slot, const char* refId, unsigned int count, int charge, int enchantmentCharge = -1) noexcept;
static void EquipActorItem(unsigned short slot, const char* refId, unsigned int count, int charge, double enchantmentCharge = -1) noexcept;
/**
* \brief Unequip the item in a certain slot of the equipment of the temporary actor stored

@ -35,7 +35,7 @@ unsigned int ItemFunctions::GetInventoryChangesSize(unsigned short pid) noexcept
return player->inventoryChanges.count;
}
void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *refId, unsigned int count, int charge, int enchantmentCharge) noexcept
void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *refId, unsigned int count, int charge, double enchantmentCharge) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -54,7 +54,7 @@ void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcep
ItemFunctions::EquipItem(pid, slot, "", 0, -1, -1);
}
void ItemFunctions::AddItem(unsigned short pid, const char* refId, unsigned int count, int charge, int enchantmentCharge) noexcept
void ItemFunctions::AddItem(unsigned short pid, const char* refId, unsigned int count, int charge, double enchantmentCharge) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -117,7 +117,7 @@ int ItemFunctions::GetEquipmentItemCharge(unsigned short pid, unsigned short slo
return player->equipedItems[slot].charge;
}
int ItemFunctions::GetEquipmentItemEnchantmentCharge(unsigned short pid, unsigned short slot) noexcept
double ItemFunctions::GetEquipmentItemEnchantmentCharge(unsigned short pid, unsigned short slot) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -152,7 +152,7 @@ int ItemFunctions::GetInventoryItemCharge(unsigned short pid, unsigned int i) no
return player->inventoryChanges.items.at(i).charge;
}
int ItemFunctions::GetInventoryItemEnchantmentCharge(unsigned short pid, unsigned int i) noexcept
double ItemFunctions::GetInventoryItemEnchantmentCharge(unsigned short pid, unsigned int i) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);

@ -41,10 +41,10 @@ public:
static int GetEquipmentSize() noexcept;
static unsigned int GetInventoryChangesSize(unsigned short pid) noexcept;
static void EquipItem(unsigned short pid, unsigned short slot, const char* refId, unsigned int count, int charge, int enchantmentCharge = -1) noexcept;
static void EquipItem(unsigned short pid, unsigned short slot, const char* refId, unsigned int count, int charge, double enchantmentCharge = -1) noexcept;
static void UnequipItem(unsigned short pid, unsigned short slot) noexcept;
static void AddItem(unsigned short pid, const char* refId, unsigned int count, int charge, int enchantmentCharge = -1) noexcept;
static void AddItem(unsigned short pid, const char* refId, unsigned int count, int charge, double enchantmentCharge = -1) noexcept;
static void RemoveItem(unsigned short pid, const char* refId, unsigned short count) noexcept;
static bool HasItemEquipped(unsigned short pid, const char* refId);
@ -52,12 +52,12 @@ public:
static const char *GetEquipmentItemRefId(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 GetEquipmentItemEnchantmentCharge(unsigned short pid, unsigned short slot) noexcept;
static double GetEquipmentItemEnchantmentCharge(unsigned short pid, unsigned short slot) noexcept;
static const char *GetInventoryItemRefId(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 GetInventoryItemEnchantmentCharge(unsigned short pid, unsigned int i) noexcept;
static double GetInventoryItemEnchantmentCharge(unsigned short pid, unsigned int i) noexcept;
static void SendEquipment(unsigned short pid) noexcept;
static void SendInventoryChanges(unsigned short pid, bool toOthers = false) noexcept;

@ -69,7 +69,7 @@ int WorldFunctions::GetObjectCharge(unsigned int i) noexcept
return readEvent->worldObjects.at(i).charge;
}
int WorldFunctions::GetObjectEnchantmentCharge(unsigned int i) noexcept
double WorldFunctions::GetObjectEnchantmentCharge(unsigned int i) noexcept
{
return readEvent->worldObjects.at(i).enchantmentCharge;
}
@ -152,7 +152,7 @@ int WorldFunctions::GetContainerItemCharge(unsigned int objectIndex, unsigned in
.containerItems.at(itemIndex).charge;
}
int WorldFunctions::GetContainerItemEnchantmentCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept
double WorldFunctions::GetContainerItemEnchantmentCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept
{
return readEvent->worldObjects.at(objectIndex)
.containerItems.at(itemIndex).enchantmentCharge;
@ -204,7 +204,7 @@ void WorldFunctions::SetObjectCharge(int charge) noexcept
tempWorldObject.charge = charge;
}
void WorldFunctions::SetObjectEnchantmentCharge(int enchantmentCharge) noexcept
void WorldFunctions::SetObjectEnchantmentCharge(double enchantmentCharge) noexcept
{
tempWorldObject.enchantmentCharge = enchantmentCharge;
}
@ -282,7 +282,7 @@ void WorldFunctions::SetContainerItemCharge(int charge) noexcept
tempContainerItem.charge = charge;
}
void WorldFunctions::SetContainerItemEnchantmentCharge(int enchantmentCharge) noexcept
void WorldFunctions::SetContainerItemEnchantmentCharge(double enchantmentCharge) noexcept
{
tempContainerItem.enchantmentCharge = enchantmentCharge;
}

@ -158,7 +158,7 @@ public:
* \param i The index of the object.
* \return The enchantment charge.
*/
static int GetObjectEnchantmentCharge(unsigned int i) noexcept;
static double GetObjectEnchantmentCharge(unsigned int i) noexcept;
/**
* \brief Get the gold value of the object at a certain index in the read event's object
@ -307,7 +307,7 @@ public:
* \param itemIndex The index of the container item.
* \return The enchantment charge.
*/
static int GetContainerItemEnchantmentCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept;
static double GetContainerItemEnchantmentCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept;
/**
* \brief Get the action count of the container item at a certain itemIndex in the container
@ -414,7 +414,7 @@ public:
* \param charge The enchantment charge.
* \return void
*/
static void SetObjectEnchantmentCharge(int enchantmentCharge) noexcept;
static void SetObjectEnchantmentCharge(double enchantmentCharge) noexcept;
/**
* \brief Set the gold value of the temporary world object stored on the server.
@ -542,7 +542,7 @@ public:
* \param charge The enchantment charge.
* \return void
*/
static void SetContainerItemEnchantmentCharge(int enchantmentCharge) noexcept;
static void SetContainerItemEnchantmentCharge(double enchantmentCharge) noexcept;
/**
* \brief Add a copy of the server's temporary world object to the server's temporary event.

@ -12,7 +12,7 @@ namespace mwmp
std::string refId;
int count;
int charge;
int enchantmentCharge;
double enchantmentCharge;
int actionCount;
@ -29,7 +29,7 @@ namespace mwmp
int mpNum;
int count;
int charge;
int enchantmentCharge;
double enchantmentCharge;
int goldValue;
ESM::Position position;

@ -12,7 +12,7 @@ namespace mwmp
std::string refId;
int count;
int charge;
int enchantmentCharge;
double enchantmentCharge;
inline bool operator==(const Item& rhs)
{

@ -5,6 +5,7 @@
#include "PacketPlayerEquipment.hpp"
#include <components/openmw-mp/NetworkMessages.hpp>
using namespace mwmp;
PacketPlayerEquipment::PacketPlayerEquipment(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
@ -21,5 +22,6 @@ void PacketPlayerEquipment::Packet(RakNet::BitStream *bs, bool send)
RW(player->equipedItems[i].refId, send, 1);
RW(player->equipedItems[i].count, send);
RW(player->equipedItems[i].charge, send);
RW(player->equipedItems[i].enchantmentCharge, send);
}
}

Loading…
Cancel
Save