[Server] Reset variables more elegantly in WorldFunctions

pull/199/head
David Cernat 8 years ago
parent b9d68c0ab2
commit e9c3abc2c3

@ -10,8 +10,12 @@
using namespace mwmp; using namespace mwmp;
BaseEvent scriptEvent; BaseEvent scriptEvent;
WorldObject tempWorldObject; WorldObject tempWorldObject;
const WorldObject emptyWorldObject = {};
ContainerItem tempContainerItem; ContainerItem tempContainerItem;
const ContainerItem emptyContainerItem = {};
std::regex exteriorCellPattern("^(-?\\d+), (-?\\d+)$"); std::regex exteriorCellPattern("^(-?\\d+), (-?\\d+)$");
@ -243,32 +247,16 @@ void WorldFunctions::SetContainerItemCharge(int charge) noexcept
void WorldFunctions::AddWorldObject() noexcept void WorldFunctions::AddWorldObject() noexcept
{ {
WorldObject worldObject; scriptEvent.objectChanges.objects.push_back(tempWorldObject);
worldObject.refId = tempWorldObject.refId;
worldObject.refNumIndex = tempWorldObject.refNumIndex;
worldObject.mpNum = tempWorldObject.mpNum;
worldObject.count = tempWorldObject.count;
worldObject.charge = tempWorldObject.charge;
worldObject.goldValue = tempWorldObject.goldValue;
worldObject.scale = tempWorldObject.scale;
worldObject.doorState = tempWorldObject.doorState;
worldObject.lockLevel = tempWorldObject.lockLevel;
worldObject.pos = tempWorldObject.pos;
worldObject.containerChanges.items = tempWorldObject.containerChanges.items;
scriptEvent.objectChanges.objects.push_back(worldObject);
tempWorldObject.containerChanges.items.clear(); tempWorldObject = emptyWorldObject;
} }
void WorldFunctions::AddContainerItem() noexcept void WorldFunctions::AddContainerItem() noexcept
{ {
ContainerItem containerItem; tempWorldObject.containerChanges.items.push_back(tempContainerItem);
containerItem.refId = tempContainerItem.refId;
containerItem.count = tempContainerItem.count;
containerItem.charge = tempContainerItem.charge;
tempWorldObject.containerChanges.items.push_back(containerItem); tempContainerItem = emptyContainerItem;
} }
void WorldFunctions::SendObjectDelete() noexcept void WorldFunctions::SendObjectDelete() noexcept

Loading…
Cancel
Save