[General] Add enchantmentCharge to worldObjects and items

pull/363/head
David Cernat 7 years ago
parent fef6bddc68
commit 993081ba1e

@ -163,6 +163,11 @@ int ActorFunctions::GetActorEquipmentItemCharge(unsigned int i, unsigned short s
return readActorList->baseActors.at(i).equipedItems[slot].charge; return readActorList->baseActors.at(i).equipedItems[slot].charge;
} }
int ActorFunctions::GetActorEquipmentItemEnchantmentCharge(unsigned int i, unsigned short slot) noexcept
{
return readActorList->baseActors.at(i).equipedItems[slot].enchantmentCharge;
}
bool ActorFunctions::DoesActorHavePosition(unsigned int i) noexcept bool ActorFunctions::DoesActorHavePosition(unsigned int i) noexcept
{ {
return readActorList->baseActors.at(i).hasPositionData; return readActorList->baseActors.at(i).hasPositionData;
@ -262,16 +267,17 @@ void ActorFunctions::SetActorFatigueModified(double value) noexcept
tempActor.creatureStats.mDynamic[2].mMod = value; tempActor.creatureStats.mDynamic[2].mMod = value;
} }
void ActorFunctions::EquipActorItem(unsigned short slot, const char *refId, unsigned int count, int charge) noexcept void ActorFunctions::EquipActorItem(unsigned short slot, const char *refId, unsigned int count, int charge, int enchantmentCharge) noexcept
{ {
tempActor.equipedItems[slot].refId = refId; tempActor.equipedItems[slot].refId = refId;
tempActor.equipedItems[slot].count = count; tempActor.equipedItems[slot].count = count;
tempActor.equipedItems[slot].charge = charge; tempActor.equipedItems[slot].charge = charge;
tempActor.equipedItems[slot].enchantmentCharge = enchantmentCharge;
} }
void ActorFunctions::UnequipActorItem(unsigned short slot) noexcept void ActorFunctions::UnequipActorItem(unsigned short slot) noexcept
{ {
ActorFunctions::EquipActorItem(slot, "", 0, -1); ActorFunctions::EquipActorItem(slot, "", 0, -1, -1);
} }
void ActorFunctions::AddActor() noexcept void ActorFunctions::AddActor() noexcept

@ -34,6 +34,7 @@
{"GetActorEquipmentItemRefId", ActorFunctions::GetActorEquipmentItemRefId},\ {"GetActorEquipmentItemRefId", ActorFunctions::GetActorEquipmentItemRefId},\
{"GetActorEquipmentItemCount", ActorFunctions::GetActorEquipmentItemCount},\ {"GetActorEquipmentItemCount", ActorFunctions::GetActorEquipmentItemCount},\
{"GetActorEquipmentItemCharge", ActorFunctions::GetActorEquipmentItemCharge},\ {"GetActorEquipmentItemCharge", ActorFunctions::GetActorEquipmentItemCharge},\
{"GetActorEquipmentItemEnchantmentCharge", ActorFunctions::GetActorEquipmentItemEnchantmentCharge},\
\ \
{"DoesActorHavePosition", ActorFunctions::DoesActorHavePosition},\ {"DoesActorHavePosition", ActorFunctions::DoesActorHavePosition},\
{"DoesActorHaveStatsDynamic", ActorFunctions::DoesActorHaveStatsDynamic},\ {"DoesActorHaveStatsDynamic", ActorFunctions::DoesActorHaveStatsDynamic},\
@ -299,6 +300,16 @@ public:
*/ */
static int GetActorEquipmentItemCharge(unsigned int i, unsigned short slot) noexcept; static int GetActorEquipmentItemCharge(unsigned int i, unsigned short slot) noexcept;
/**
* \brief Get the enchantment charge of the item in a certain slot of the equipment of the actor at a
* certain index in the read actor list.
*
* \param i The index of the actor.
* \param slot The slot of the equipment item.
* \return The enchantment charge.
*/
static int GetActorEquipmentItemEnchantmentCharge(unsigned int i, unsigned short slot) noexcept;
/** /**
* \brief Check whether there is any positional data for the actor at a certain index in * \brief Check whether there is any positional data for the actor at a certain index in
* the read actor list. * the read actor list.
@ -478,9 +489,10 @@ public:
* \param refId The refId of the item. * \param refId The refId of the item.
* \param count The count of the item. * \param count The count of the item.
* \param charge The charge of the item. * \param charge The charge of the item.
* \param enchantmentCharge The enchantment charge of the item.
* \return void * \return void
*/ */
static void EquipActorItem(unsigned short slot, const char* refId, unsigned int count, int charge) noexcept; static void EquipActorItem(unsigned short slot, const char* refId, unsigned int count, int charge, int enchantmentCharge = -1) noexcept;
/** /**
* \brief Unequip the item in a certain slot of the equipment of the temporary actor stored * \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; return player->inventoryChanges.count;
} }
void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *refId, unsigned int count, int charge) noexcept void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *refId, unsigned int count, int charge, int enchantmentCharge) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);
@ -43,6 +43,7 @@ void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const cha
player->equipedItems[slot].refId = refId; 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;
player->equipedItems[slot].enchantmentCharge = enchantmentCharge;
} }
void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcept void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcept
@ -50,10 +51,10 @@ void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcep
Player *player; Player *player;
GET_PLAYER(pid, player, ); GET_PLAYER(pid, player, );
ItemFunctions::EquipItem(pid, slot, "", 0, -1); ItemFunctions::EquipItem(pid, slot, "", 0, -1, -1);
} }
void ItemFunctions::AddItem(unsigned short pid, const char* refId, unsigned int count, int charge) noexcept void ItemFunctions::AddItem(unsigned short pid, const char* refId, unsigned int count, int charge, int enchantmentCharge) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, ); GET_PLAYER(pid, player, );
@ -62,6 +63,7 @@ void ItemFunctions::AddItem(unsigned short pid, const char* refId, unsigned int
item.refId = refId; item.refId = refId;
item.count = count; item.count = count;
item.charge = charge; item.charge = charge;
item.enchantmentCharge = enchantmentCharge;
player->inventoryChanges.items.push_back(item); player->inventoryChanges.items.push_back(item);
player->inventoryChanges.action = InventoryChanges::ADD; player->inventoryChanges.action = InventoryChanges::ADD;
@ -115,6 +117,14 @@ int ItemFunctions::GetEquipmentItemCharge(unsigned short pid, unsigned short slo
return player->equipedItems[slot].charge; return player->equipedItems[slot].charge;
} }
int ItemFunctions::GetEquipmentItemEnchantmentCharge(unsigned short pid, unsigned short slot) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
return player->equipedItems[slot].enchantmentCharge;
}
const char *ItemFunctions::GetInventoryItemRefId(unsigned short pid, unsigned int i) noexcept const char *ItemFunctions::GetInventoryItemRefId(unsigned short pid, unsigned int i) noexcept
{ {
Player *player; Player *player;
@ -142,6 +152,14 @@ int ItemFunctions::GetInventoryItemCharge(unsigned short pid, unsigned int i) no
return player->inventoryChanges.items.at(i).charge; return player->inventoryChanges.items.at(i).charge;
} }
int ItemFunctions::GetInventoryItemEnchantmentCharge(unsigned short pid, unsigned int i) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
return player->inventoryChanges.items.at(i).enchantmentCharge;
}
void ItemFunctions::SendEquipment(unsigned short pid) noexcept void ItemFunctions::SendEquipment(unsigned short pid) noexcept
{ {
Player *player; Player *player;

@ -22,10 +22,12 @@
{"GetEquipmentItemRefId", ItemFunctions::GetEquipmentItemRefId},\ {"GetEquipmentItemRefId", ItemFunctions::GetEquipmentItemRefId},\
{"GetEquipmentItemCount", ItemFunctions::GetEquipmentItemCount},\ {"GetEquipmentItemCount", ItemFunctions::GetEquipmentItemCount},\
{"GetEquipmentItemCharge", ItemFunctions::GetEquipmentItemCharge},\ {"GetEquipmentItemCharge", ItemFunctions::GetEquipmentItemCharge},\
{"GetEquipmentItemEnchantmentCharge", ItemFunctions::GetEquipmentItemEnchantmentCharge},\
\ \
{"GetInventoryItemRefId", ItemFunctions::GetInventoryItemRefId},\ {"GetInventoryItemRefId", ItemFunctions::GetInventoryItemRefId},\
{"GetInventoryItemCount", ItemFunctions::GetInventoryItemCount},\ {"GetInventoryItemCount", ItemFunctions::GetInventoryItemCount},\
{"GetInventoryItemCharge", ItemFunctions::GetInventoryItemCharge},\ {"GetInventoryItemCharge", ItemFunctions::GetInventoryItemCharge},\
{"GetInventoryItemEnchantmentCharge", ItemFunctions::GetInventoryItemEnchantmentCharge},\
\ \
{"SendEquipment", ItemFunctions::SendEquipment},\ {"SendEquipment", ItemFunctions::SendEquipment},\
{"SendInventoryChanges", ItemFunctions::SendInventoryChanges} {"SendInventoryChanges", ItemFunctions::SendInventoryChanges}
@ -39,10 +41,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* refId, unsigned int count, int charge) noexcept; static void EquipItem(unsigned short pid, unsigned short slot, const char* refId, unsigned int count, int charge, int enchantmentCharge = -1) 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* refId, unsigned int count, int charge) noexcept; static void AddItem(unsigned short pid, const char* refId, unsigned int count, int charge, int enchantmentCharge = -1) noexcept;
static void RemoveItem(unsigned short pid, const char* refId, unsigned short count) noexcept; static void RemoveItem(unsigned short pid, const char* refId, unsigned short count) noexcept;
static bool HasItemEquipped(unsigned short pid, const char* refId); static bool HasItemEquipped(unsigned short pid, const char* refId);
@ -50,10 +52,12 @@ public:
static const char *GetEquipmentItemRefId(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 int GetEquipmentItemEnchantmentCharge(unsigned short pid, unsigned short slot) noexcept;
static const char *GetInventoryItemRefId(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;
static int GetInventoryItemEnchantmentCharge(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, bool toOthers = false) noexcept; static void SendInventoryChanges(unsigned short pid, bool toOthers = false) noexcept;

@ -69,6 +69,11 @@ int WorldFunctions::GetObjectCharge(unsigned int i) noexcept
return readEvent->worldObjects.at(i).charge; return readEvent->worldObjects.at(i).charge;
} }
int WorldFunctions::GetObjectEnchantmentCharge(unsigned int i) noexcept
{
return readEvent->worldObjects.at(i).enchantmentCharge;
}
int WorldFunctions::GetObjectGoldValue(unsigned int i) noexcept int WorldFunctions::GetObjectGoldValue(unsigned int i) noexcept
{ {
return readEvent->worldObjects.at(i).goldValue; return readEvent->worldObjects.at(i).goldValue;
@ -147,6 +152,12 @@ int WorldFunctions::GetContainerItemCharge(unsigned int objectIndex, unsigned in
.containerItems.at(itemIndex).charge; .containerItems.at(itemIndex).charge;
} }
int WorldFunctions::GetContainerItemEnchantmentCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept
{
return readEvent->worldObjects.at(objectIndex)
.containerItems.at(itemIndex).enchantmentCharge;
}
int WorldFunctions::GetContainerItemActionCount(unsigned int objectIndex, unsigned int itemIndex) noexcept int WorldFunctions::GetContainerItemActionCount(unsigned int objectIndex, unsigned int itemIndex) noexcept
{ {
return readEvent->worldObjects.at(objectIndex) return readEvent->worldObjects.at(objectIndex)
@ -193,6 +204,11 @@ void WorldFunctions::SetObjectCharge(int charge) noexcept
tempWorldObject.charge = charge; tempWorldObject.charge = charge;
} }
void WorldFunctions::SetObjectEnchantmentCharge(int enchantmentCharge) noexcept
{
tempWorldObject.enchantmentCharge = enchantmentCharge;
}
void WorldFunctions::SetObjectGoldValue(int goldValue) noexcept void WorldFunctions::SetObjectGoldValue(int goldValue) noexcept
{ {
tempWorldObject.goldValue = goldValue; tempWorldObject.goldValue = goldValue;
@ -266,6 +282,11 @@ void WorldFunctions::SetContainerItemCharge(int charge) noexcept
tempContainerItem.charge = charge; tempContainerItem.charge = charge;
} }
void WorldFunctions::SetContainerItemEnchantmentCharge(int enchantmentCharge) noexcept
{
tempContainerItem.enchantmentCharge = enchantmentCharge;
}
void WorldFunctions::AddWorldObject() noexcept void WorldFunctions::AddWorldObject() noexcept
{ {
writeEvent.worldObjects.push_back(tempWorldObject); writeEvent.worldObjects.push_back(tempWorldObject);

@ -13,6 +13,7 @@
{"GetObjectMpNum", WorldFunctions::GetObjectMpNum},\ {"GetObjectMpNum", WorldFunctions::GetObjectMpNum},\
{"GetObjectCount", WorldFunctions::GetObjectCount},\ {"GetObjectCount", WorldFunctions::GetObjectCount},\
{"GetObjectCharge", WorldFunctions::GetObjectCharge},\ {"GetObjectCharge", WorldFunctions::GetObjectCharge},\
{"GetObjectEnchantmentCharge", WorldFunctions::GetObjectEnchantmentCharge},\
{"GetObjectGoldValue", WorldFunctions::GetObjectGoldValue},\ {"GetObjectGoldValue", WorldFunctions::GetObjectGoldValue},\
{"GetObjectScale", WorldFunctions::GetObjectScale},\ {"GetObjectScale", WorldFunctions::GetObjectScale},\
{"GetObjectState", WorldFunctions::GetObjectState},\ {"GetObjectState", WorldFunctions::GetObjectState},\
@ -29,6 +30,7 @@
{"GetContainerItemRefId", WorldFunctions::GetContainerItemRefId},\ {"GetContainerItemRefId", WorldFunctions::GetContainerItemRefId},\
{"GetContainerItemCount", WorldFunctions::GetContainerItemCount},\ {"GetContainerItemCount", WorldFunctions::GetContainerItemCount},\
{"GetContainerItemCharge", WorldFunctions::GetContainerItemCharge},\ {"GetContainerItemCharge", WorldFunctions::GetContainerItemCharge},\
{"GetContainerItemEnchantmentCharge", WorldFunctions::GetContainerItemEnchantmentCharge},\
{"GetContainerItemActionCount", WorldFunctions::GetContainerItemActionCount},\ {"GetContainerItemActionCount", WorldFunctions::GetContainerItemActionCount},\
\ \
{"SetEventCell", WorldFunctions::SetEventCell},\ {"SetEventCell", WorldFunctions::SetEventCell},\
@ -40,6 +42,7 @@
{"SetObjectMpNum", WorldFunctions::SetObjectMpNum},\ {"SetObjectMpNum", WorldFunctions::SetObjectMpNum},\
{"SetObjectCount", WorldFunctions::SetObjectCount},\ {"SetObjectCount", WorldFunctions::SetObjectCount},\
{"SetObjectCharge", WorldFunctions::SetObjectCharge},\ {"SetObjectCharge", WorldFunctions::SetObjectCharge},\
{"SetObjectEnchantmentCharge", WorldFunctions::SetObjectEnchantmentCharge},\
{"SetObjectGoldValue", WorldFunctions::SetObjectGoldValue},\ {"SetObjectGoldValue", WorldFunctions::SetObjectGoldValue},\
{"SetObjectScale", WorldFunctions::SetObjectScale},\ {"SetObjectScale", WorldFunctions::SetObjectScale},\
{"SetObjectState", WorldFunctions::SetObjectState},\ {"SetObjectState", WorldFunctions::SetObjectState},\
@ -54,6 +57,7 @@
{"SetContainerItemRefId", WorldFunctions::SetContainerItemRefId},\ {"SetContainerItemRefId", WorldFunctions::SetContainerItemRefId},\
{"SetContainerItemCount", WorldFunctions::SetContainerItemCount},\ {"SetContainerItemCount", WorldFunctions::SetContainerItemCount},\
{"SetContainerItemCharge", WorldFunctions::SetContainerItemCharge},\ {"SetContainerItemCharge", WorldFunctions::SetContainerItemCharge},\
{"SetContainerItemEnchantmentCharge", WorldFunctions::SetContainerItemEnchantmentCharge},\
\ \
{"AddWorldObject", WorldFunctions::AddWorldObject},\ {"AddWorldObject", WorldFunctions::AddWorldObject},\
{"AddContainerItem", WorldFunctions::AddContainerItem},\ {"AddContainerItem", WorldFunctions::AddContainerItem},\
@ -148,6 +152,14 @@ public:
*/ */
static int GetObjectCharge(unsigned int i) noexcept; static int GetObjectCharge(unsigned int i) noexcept;
/**
* \brief Get the enchantment charge of the object at a certain index in the read event's object changes.
*
* \param i The index of the object.
* \return The enchantment charge.
*/
static int GetObjectEnchantmentCharge(unsigned int i) noexcept;
/** /**
* \brief Get the gold value of the object at a certain index in the read event's object * \brief Get the gold value of the object at a certain index in the read event's object
* changes. * changes.
@ -287,6 +299,16 @@ public:
*/ */
static int GetContainerItemCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept; static int GetContainerItemCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept;
/**
* \brief Get the enchantment charge of the container item at a certain itemIndex in the container changes
* of the object at a certain objectIndex in the read event's object changes.
*
* \param objectIndex The index of the object.
* \param itemIndex The index of the container item.
* \return The enchantment charge.
*/
static int GetContainerItemEnchantmentCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept;
/** /**
* \brief Get the action count of the container item at a certain itemIndex in the container * \brief Get the action count of the container item at a certain itemIndex in the container
* changes of the object at a certain objectIndex in the read event's object changes. * changes of the object at a certain objectIndex in the read event's object changes.
@ -384,6 +406,16 @@ public:
*/ */
static void SetObjectCharge(int charge) noexcept; static void SetObjectCharge(int charge) noexcept;
/**
* \brief Set the enchantment charge of the temporary world object stored on the server.
*
* Object durabilities are set through this value.
*
* \param charge The enchantment charge.
* \return void
*/
static void SetObjectEnchantmentCharge(int enchantmentCharge) noexcept;
/** /**
* \brief Set the gold value of the temporary world object stored on the server. * \brief Set the gold value of the temporary world object stored on the server.
* *
@ -504,6 +536,14 @@ public:
*/ */
static void SetContainerItemCharge(int charge) noexcept; static void SetContainerItemCharge(int charge) noexcept;
/**
* \brief Set the enchantment charge of the temporary container item stored on the server.
*
* \param charge The enchantment charge.
* \return void
*/
static void SetContainerItemEnchantmentCharge(int enchantmentCharge) noexcept;
/** /**
* \brief Add a copy of the server's temporary world object to the server's temporary event. * \brief Add a copy of the server's temporary world object to the server's temporary event.
* *

@ -450,6 +450,8 @@ void LocalPlayer::updateEquipment(bool forceUpdate)
item.refId = it->getCellRef().getRefId(); item.refId = it->getCellRef().getRefId();
item.charge = it->getCellRef().getCharge(); item.charge = it->getCellRef().getCharge();
item.enchantmentCharge = it->getCellRef().getEnchantmentCharge();
if (slot == MWWorld::InventoryStore::Slot_CarriedRight) if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
{ {
MWMechanics::WeaponType weaptype; MWMechanics::WeaponType weaptype;
@ -467,7 +469,8 @@ void LocalPlayer::updateEquipment(bool forceUpdate)
equipmentChanged = true; equipmentChanged = true;
item.refId = ""; item.refId = "";
item.count = 0; item.count = 0;
item.charge = 0; item.charge = -1;
item.enchantmentCharge = -1;
} }
} }
@ -496,6 +499,7 @@ void LocalPlayer::updateInventory(bool forceUpdate)
return true; return true;
item.count = iter.getRefData().getCount(); item.count = iter.getRefData().getCount();
item.charge = iter.getCellRef().getCharge(); item.charge = iter.getCellRef().getCharge();
item.enchantmentCharge = iter.getCellRef().getEnchantmentCharge();
return false; return false;
}; };
@ -671,6 +675,9 @@ void LocalPlayer::addItems()
MWWorld::Ptr itemPtr = *ptrStore.add(item.refId, item.count, ptrPlayer); MWWorld::Ptr itemPtr = *ptrStore.add(item.refId, item.count, ptrPlayer);
if (item.charge != -1) if (item.charge != -1)
itemPtr.getCellRef().setCharge(item.charge); itemPtr.getCellRef().setCharge(item.charge);
if (item.enchantmentCharge != -1)
itemPtr.getCellRef().setEnchantmentCharge(item.enchantmentCharge);
} }
catch (std::exception&) catch (std::exception&)
{ {
@ -1188,6 +1195,7 @@ void LocalPlayer::sendInventory()
item.count = iter.getRefData().getCount(); item.count = iter.getRefData().getCount();
item.charge = iter.getCellRef().getCharge(); item.charge = iter.getCellRef().getCharge();
item.enchantmentCharge = iter.getCellRef().getEnchantmentCharge();
inventoryChanges.items.push_back(item); inventoryChanges.items.push_back(item);
} }

@ -95,6 +95,9 @@ void WorldEvent::editContainers(MWWorld::CellStore* cellStore)
if (containerItem.charge > -1) if (containerItem.charge > -1)
newPtr.getCellRef().setCharge(containerItem.charge); newPtr.getCellRef().setCharge(containerItem.charge);
if (containerItem.enchantmentCharge > -1)
newPtr.getCellRef().setEnchantmentCharge(containerItem.enchantmentCharge);
containerStore.add(newPtr, containerItem.count, ownerPtr, true); containerStore.add(newPtr, containerItem.count, ownerPtr, true);
} }
else if (action == BaseEvent::REMOVE) else if (action == BaseEvent::REMOVE)
@ -105,8 +108,9 @@ void WorldEvent::editContainers(MWWorld::CellStore* cellStore)
{ {
if (Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), containerItem.refId)) if (Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), containerItem.refId))
{ {
if (ptr.getCellRef().getCharge() == containerItem.charge && if (ptr.getRefData().getCount() == containerItem.count &&
ptr.getRefData().getCount() == containerItem.count) ptr.getCellRef().getCharge() == containerItem.charge &&
ptr.getCellRef().getEnchantmentCharge() == containerItem.enchantmentCharge)
{ {
// Is this an actor's container? If so, unequip this item if it was equipped // Is this an actor's container? If so, unequip this item if it was equipped
if (ptrFound.getClass().isActor()) if (ptrFound.getClass().isActor())
@ -153,8 +157,8 @@ void WorldEvent::placeObjects(MWWorld::CellStore* cellStore)
{ {
for (const auto &worldObject : worldObjects) for (const auto &worldObject : worldObjects)
{ {
LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i, charge: %i, count: %i", worldObject.refId.c_str(), LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i, count: %i, charge: %i, enchantmentCharge: %i", worldObject.refId.c_str(),
worldObject.refNumIndex, worldObject.mpNum, worldObject.charge, worldObject.count); worldObject.refNumIndex, worldObject.mpNum, worldObject.count, worldObject.charge, worldObject.enchantmentCharge);
MWWorld::Ptr ptrFound = cellStore->searchExact(0, worldObject.mpNum); MWWorld::Ptr ptrFound = cellStore->searchExact(0, worldObject.mpNum);
@ -164,11 +168,14 @@ void WorldEvent::placeObjects(MWWorld::CellStore* cellStore)
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), worldObject.refId, 1); MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), worldObject.refId, 1);
MWWorld::Ptr newPtr = ref.getPtr(); MWWorld::Ptr newPtr = ref.getPtr();
if (worldObject.count > 1)
newPtr.getRefData().setCount(worldObject.count);
if (worldObject.charge > -1) if (worldObject.charge > -1)
newPtr.getCellRef().setCharge(worldObject.charge); newPtr.getCellRef().setCharge(worldObject.charge);
if (worldObject.count > 1) if (worldObject.enchantmentCharge > -1)
newPtr.getRefData().setCount(worldObject.count); newPtr.getCellRef().setEnchantmentCharge(worldObject.enchantmentCharge);
newPtr.getCellRef().setGoldValue(worldObject.goldValue); newPtr.getCellRef().setGoldValue(worldObject.goldValue);
newPtr = MWBase::Environment::get().getWorld()->placeObject(newPtr, cellStore, worldObject.position); newPtr = MWBase::Environment::get().getWorld()->placeObject(newPtr, cellStore, worldObject.position);
@ -580,6 +587,7 @@ void WorldEvent::addObjectPlace(const MWWorld::Ptr& ptr)
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex; worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
worldObject.mpNum = 0; worldObject.mpNum = 0;
worldObject.charge = ptr.getCellRef().getCharge(); worldObject.charge = ptr.getCellRef().getCharge();
worldObject.enchantmentCharge = ptr.getCellRef().getEnchantmentCharge();
// Make sure we send the RefData position instead of the CellRef one, because that's what // Make sure we send the RefData position instead of the CellRef one, because that's what
// we actually see on this client // we actually see on this client
@ -944,6 +952,7 @@ void WorldEvent::sendContainers(MWWorld::CellStore* cellStore)
containerItem.refId = itemPtr.getCellRef().getRefId(); containerItem.refId = itemPtr.getCellRef().getRefId();
containerItem.count = itemPtr.getRefData().getCount(); containerItem.count = itemPtr.getRefData().getCount();
containerItem.charge = itemPtr.getCellRef().getCharge(); containerItem.charge = itemPtr.getCellRef().getCharge();
containerItem.enchantmentCharge = itemPtr.getCellRef().getEnchantmentCharge();
worldObject.containerItems.push_back(containerItem); worldObject.containerItems.push_back(containerItem);
} }

@ -12,12 +12,13 @@ namespace mwmp
std::string refId; std::string refId;
int count; int count;
int charge; int charge;
int enchantmentCharge;
int actionCount; int actionCount;
inline bool operator==(const ContainerItem& rhs) inline bool operator==(const ContainerItem& rhs)
{ {
return refId == rhs.refId && count == rhs.count && charge == rhs.charge; return refId == rhs.refId && count == rhs.count && charge == rhs.charge && enchantmentCharge == rhs.enchantmentCharge;
} }
}; };
@ -28,6 +29,7 @@ namespace mwmp
int mpNum; int mpNum;
int count; int count;
int charge; int charge;
int enchantmentCharge;
int goldValue; int goldValue;
ESM::Position position; ESM::Position position;

@ -12,10 +12,11 @@ namespace mwmp
std::string refId; std::string refId;
int count; int count;
int charge; int charge;
int enchantmentCharge;
inline bool operator==(const Item& rhs) inline bool operator==(const Item& rhs)
{ {
return refId == rhs.refId && count == rhs.count && charge == rhs.charge; return refId == rhs.refId && count == rhs.count && charge == rhs.charge && enchantmentCharge == rhs.enchantmentCharge;
} }
}; };

@ -16,5 +16,6 @@ void PacketActorEquipment::Actor(BaseActor &actor, bool send)
RW(actor.equipedItems[j].refId, send); RW(actor.equipedItems[j].refId, send);
RW(actor.equipedItems[j].count, send); RW(actor.equipedItems[j].count, send);
RW(actor.equipedItems[j].charge, send); RW(actor.equipedItems[j].charge, send);
RW(actor.equipedItems[j].enchantmentCharge, send);
} }
} }

@ -36,6 +36,7 @@ void PacketPlayerInventory::Packet(RakNet::BitStream *bs, bool send)
RW(item.refId, send, 1); RW(item.refId, send, 1);
RW(item.count, send); RW(item.count, send);
RW(item.charge, send); RW(item.charge, send);
RW(item.enchantmentCharge, send);
if (!send) if (!send)
player->inventoryChanges.items.push_back(item); player->inventoryChanges.items.push_back(item);

@ -48,6 +48,7 @@ void PacketContainer::Packet(RakNet::BitStream *bs, bool send)
RW(containerItem.refId, send); RW(containerItem.refId, send);
RW(containerItem.count, send); RW(containerItem.count, send);
RW(containerItem.charge, send); RW(containerItem.charge, send);
RW(containerItem.enchantmentCharge, send);
RW(containerItem.actionCount, send); RW(containerItem.actionCount, send);
if (!send) if (!send)

@ -14,6 +14,7 @@ void PacketObjectPlace::Object(WorldObject &worldObject, bool send)
WorldPacket::Object(worldObject, send); WorldPacket::Object(worldObject, send);
RW(worldObject.count, send); RW(worldObject.count, send);
RW(worldObject.charge, send); RW(worldObject.charge, send);
RW(worldObject.enchantmentCharge, send);
RW(worldObject.goldValue, send); RW(worldObject.goldValue, send);
RW(worldObject.position, send); RW(worldObject.position, send);
} }

Loading…
Cancel
Save