[Server] Reset variables more elegantly in WorldFunctions

0.6.1
David Cernat 8 years ago
parent b9d68c0ab2
commit e9c3abc2c3

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

Loading…
Cancel
Save