[General] Change type of Item::enchantmentCharge to float

sol2-server-rewrite
Koncord 7 years ago
parent cb86557aca
commit de0bb3cdab

@ -97,7 +97,7 @@ int Inventory::getChangesSize() const
return netActor->getNetCreature()->inventoryChanges.items.size();
}
void Inventory::equipItem(unsigned short slot, const std::string& refId, unsigned int count, int charge, double enchantmentCharge)
void Inventory::equipItem(unsigned short slot, const std::string& refId, unsigned int count, int charge, float enchantmentCharge)
{
netActor->getNetCreature()->equipmentItems[slot].refId = refId;
netActor->getNetCreature()->equipmentItems[slot].count = count;
@ -119,7 +119,7 @@ void Inventory::unequipItem( unsigned short slot)
}
void Inventory::addItem(const std::string &refId, unsigned int count, int charge, double enchantmentCharge)
void Inventory::addItem(const std::string &refId, unsigned int count, int charge, float enchantmentCharge)
{
if (inventoryChanged == mwmp::InventoryChanges::Type::Remove)
return;

@ -25,7 +25,7 @@ public:
//inventory
int getChangesSize() const;
void addItem(const std::string& refId, unsigned int count, int charge, double enchantmentCharge);
void addItem(const std::string& refId, unsigned int count, int charge, float enchantmentCharge);
void removeItem(const std::string& refId, unsigned short count);
/**
@ -37,7 +37,7 @@ public:
// equipment
void equipItem(unsigned short slot, const std::string& refId, unsigned int count, int charge, double enchantmentCharge);
void equipItem(unsigned short slot, const std::string& refId, unsigned int count, int charge, float enchantmentCharge);
void unequipItem(unsigned short slot);
bool hasItemEquipped(const std::string& refId) const;

@ -172,15 +172,18 @@ void DedicatedActor::setEquipment()
const string &packetRefId = equipmentItems[slot].refId;
int packetCharge = equipmentItems[slot].charge;
std::string storeRefId = "";
bool equal = false;
if (it != invStore.end())
{
storeRefId = it->getCellRef().getRefId();
std::string storeRefId = it->getCellRef().getRefId();
int count = invStore.count(storeRefId);
if (!Misc::StringUtils::ciEqual(storeRefId, packetRefId)) // if other item equiped
if (!Misc::StringUtils::ciEqual(storeRefId, packetRefId)) // if other item equipped
{
invStore.unequipSlot(slot, ptr);
ptr.getClass().getContainerStore(ptr).remove(storeRefId, count, ptr);
}
else
equal = true;
}

@ -170,11 +170,10 @@ void DedicatedPlayer::setEquipment()
MWWorld::ContainerStoreIterator it = invStore.getSlot(slot);
const string &dedicItem = equipmentItems[slot].refId;
std::string item = "";
bool equal = false;
if (it != invStore.end())
{
item = it->getCellRef().getRefId();
const std::string &item = it->getCellRef().getRefId();
if (!Misc::StringUtils::ciEqual(item, dedicItem)) // if other item equiped
{
MWWorld::ContainerStore &store = ptr.getClass().getContainerStore(ptr);

@ -455,11 +455,11 @@ void LocalPlayer::updateEquipment(bool forceUpdate)
item.refId = "";
item.count = 0;
item.charge = -1;
item.enchantmentCharge = -1;
item.enchantmentCharge = -1.0f;
}
}
if (equipmentIndexChanges.size() > 0)
if (!equipmentIndexChanges.empty())
{
getNetworking()->getPlayerPacket(ID_PLAYER_EQUIPMENT)->setPlayer(this);
getNetworking()->getPlayerPacket(ID_PLAYER_EQUIPMENT)->Send();

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

Loading…
Cancel
Save