[General] Remove owner var from ContainerItem because it is always empty

coverity_scan^2
David Cernat 8 years ago
parent fd4827b3a7
commit 4f2b88df8a

@ -138,12 +138,6 @@ int WorldFunctions::GetContainerItemGoldValue(unsigned int objectIndex, unsigned
.containerChanges.items.at(itemIndex).goldValue; .containerChanges.items.at(itemIndex).goldValue;
} }
const char *WorldFunctions::GetContainerItemOwner(unsigned int objectIndex, unsigned int itemIndex) noexcept
{
return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects.at(objectIndex)
.containerChanges.items.at(itemIndex).owner.c_str();
}
void WorldFunctions::SetBaseEventCell(const char* cellDescription) noexcept void WorldFunctions::SetBaseEventCell(const char* cellDescription) noexcept
{ {
std::string description = cellDescription; std::string description = cellDescription;

@ -27,7 +27,6 @@
{"GetContainerItemCount", WorldFunctions::GetContainerItemCount},\ {"GetContainerItemCount", WorldFunctions::GetContainerItemCount},\
{"GetContainerItemCharge", WorldFunctions::GetContainerItemCharge},\ {"GetContainerItemCharge", WorldFunctions::GetContainerItemCharge},\
{"GetContainerItemGoldValue", WorldFunctions::GetContainerItemGoldValue},\ {"GetContainerItemGoldValue", WorldFunctions::GetContainerItemGoldValue},\
{"GetContainerItemOwner", WorldFunctions::GetContainerItemOwner},\
\ \
{"SetBaseEventCell", WorldFunctions::SetBaseEventCell},\ {"SetBaseEventCell", WorldFunctions::SetBaseEventCell},\
{"SetBaseEventAction", WorldFunctions::SetBaseEventAction},\ {"SetBaseEventAction", WorldFunctions::SetBaseEventAction},\
@ -91,7 +90,6 @@ public:
static int GetContainerItemCount(unsigned int objectIndex, unsigned int itemIndex) noexcept; static int GetContainerItemCount(unsigned int objectIndex, unsigned int itemIndex) noexcept;
static int GetContainerItemCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept; static int GetContainerItemCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept;
static int GetContainerItemGoldValue(unsigned int objectIndex, unsigned int itemIndex) noexcept; static int GetContainerItemGoldValue(unsigned int objectIndex, unsigned int itemIndex) noexcept;
static const char *GetContainerItemOwner(unsigned int objectIndex, unsigned int itemIndex) noexcept;
static void SetBaseEventCell(const char* cellDescription) noexcept; static void SetBaseEventCell(const char* cellDescription) noexcept;
static void SetBaseEventAction(int action) noexcept; static void SetBaseEventAction(int action) noexcept;

@ -117,7 +117,6 @@ namespace MWGui
containerItem.count = itemPtr.getRefData().getCount(); containerItem.count = itemPtr.getRefData().getCount();
containerItem.charge = itemPtr.getCellRef().getCharge(); containerItem.charge = itemPtr.getCellRef().getCharge();
containerItem.goldValue = itemPtr.getCellRef().getGoldValue(); containerItem.goldValue = itemPtr.getCellRef().getGoldValue();
containerItem.owner = itemPtr.getCellRef().getOwner();
containerItem.actionCount = count; containerItem.actionCount = count;
worldObject.containerChanges.items.push_back(containerItem); worldObject.containerChanges.items.push_back(containerItem);
@ -180,7 +179,6 @@ namespace MWGui
containerItem.charge = itemPtr.getCellRef().getCharge(); containerItem.charge = itemPtr.getCellRef().getCharge();
containerItem.goldValue = itemPtr.getCellRef().getGoldValue(); containerItem.goldValue = itemPtr.getCellRef().getGoldValue();
containerItem.owner = itemPtr.getCellRef().getOwner();
worldObject.containerChanges.items.push_back(containerItem); worldObject.containerChanges.items.push_back(containerItem);
event->addObject(worldObject); event->addObject(worldObject);

@ -68,7 +68,6 @@ void WorldEvent::sendContainers(MWWorld::CellStore* cellStore)
containerItem.count = itemPtr.getRefData().getCount(); containerItem.count = itemPtr.getRefData().getCount();
containerItem.charge = itemPtr.getCellRef().getCharge(); containerItem.charge = itemPtr.getCellRef().getCharge();
containerItem.goldValue = itemPtr.getCellRef().getGoldValue(); containerItem.goldValue = itemPtr.getCellRef().getGoldValue();
containerItem.owner = itemPtr.getCellRef().getOwner();
worldObject.containerChanges.items.push_back(containerItem); worldObject.containerChanges.items.push_back(containerItem);
} }
@ -109,10 +108,7 @@ void WorldEvent::editContainers(MWWorld::CellStore* cellStore)
for (unsigned int i = 0; i < worldObject.containerChanges.count; i++) for (unsigned int i = 0; i < worldObject.containerChanges.count; i++)
{ {
ContainerItem containerItem = worldObject.containerChanges.items.at(i); ContainerItem containerItem = worldObject.containerChanges.items.at(i);
MWWorld::Ptr ownerPtr = MWBase::Environment::get().getWorld()->searchPtr(containerItem.owner, false); MWWorld::Ptr ownerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
if (ownerPtr.isEmpty())
ownerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
if (action == BaseEvent::ADD || action == BaseEvent::SET) if (action == BaseEvent::ADD || action == BaseEvent::SET)
{ {
@ -140,8 +136,7 @@ void WorldEvent::editContainers(MWWorld::CellStore* cellStore)
{ {
if (iter->getCellRef().getCharge() == containerItem.charge && if (iter->getCellRef().getCharge() == containerItem.charge &&
iter->getCellRef().getGoldValue() == containerItem.goldValue && iter->getCellRef().getGoldValue() == containerItem.goldValue &&
iter->getRefData().getCount() == containerItem.count && iter->getRefData().getCount() == containerItem.count)
iter->getCellRef().getOwner() == containerItem.owner)
{ {
containerStore.remove(*iter, containerItem.actionCount, ownerPtr); containerStore.remove(*iter, containerItem.actionCount, ownerPtr);
} }

@ -14,7 +14,6 @@ namespace mwmp
int charge; int charge;
int goldValue; int goldValue;
std::string owner;
int actionCount; int actionCount;
inline bool operator==(const ContainerItem& rhs) inline bool operator==(const ContainerItem& rhs)

@ -61,7 +61,6 @@ void PacketContainer::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send)
RW(containerItem.count, send); RW(containerItem.count, send);
RW(containerItem.charge, send); RW(containerItem.charge, send);
RW(containerItem.goldValue, send); RW(containerItem.goldValue, send);
RW(containerItem.owner, send);
RW(containerItem.actionCount, send); RW(containerItem.actionCount, send);
if (!send) if (!send)

Loading…
Cancel
Save