[Client] Reuse 1 BaseEvent over and over instead of creating new ones

pull/168/head
David Cernat 8 years ago
parent b158e89f77
commit ed2176c984

@ -102,9 +102,9 @@ namespace MWGui
return; return;
// Added by tes3mp // Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
event->cell = *mPtr.getCell()->getCell(); worldEvent->cell = *mPtr.getCell()->getCell();
event->action = mwmp::BaseEvent::REMOVE; worldEvent->action = mwmp::BaseEvent::REMOVE;
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.refId = mPtr.getCellRef().getRefId(); worldObject.refId = mPtr.getCellRef().getRefId();
@ -119,20 +119,17 @@ namespace MWGui
containerItem.actionCount = count; containerItem.actionCount = count;
worldObject.containerChanges.items.push_back(containerItem); worldObject.containerChanges.items.push_back(containerItem);
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send(worldEvent);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s\n- item: %s, %i", LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s\n- item: %s, %i",
worldObject.refId.c_str(), worldObject.refId.c_str(),
worldObject.refNumIndex, worldObject.refNumIndex,
event->cell.getDescription().c_str(), worldEvent->cell.getDescription().c_str(),
containerItem.refId.c_str(), containerItem.refId.c_str(),
containerItem.count); containerItem.count);
delete event;
event = NULL;
mDragAndDrop->startDrag(mSelectedItem, mSortModel, mModel, mItemView, count); mDragAndDrop->startDrag(mSelectedItem, mSortModel, mModel, mItemView, count);
} }
@ -160,9 +157,9 @@ namespace MWGui
} }
// Added by tes3mp // Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
event->cell = *mPtr.getCell()->getCell(); worldEvent->cell = *mPtr.getCell()->getCell();
event->action = mwmp::BaseEvent::ADD; worldEvent->action = mwmp::BaseEvent::ADD;
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.refId = mPtr.getCellRef().getRefId(); worldObject.refId = mPtr.getCellRef().getRefId();
@ -179,20 +176,17 @@ namespace MWGui
containerItem.charge = itemPtr.getCellRef().getCharge(); containerItem.charge = itemPtr.getCellRef().getCharge();
worldObject.containerChanges.items.push_back(containerItem); worldObject.containerChanges.items.push_back(containerItem);
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send(worldEvent);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s\n- item: %s, %i", LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s\n- item: %s, %i",
worldObject.refId.c_str(), worldObject.refId.c_str(),
worldObject.refNumIndex, worldObject.refNumIndex,
event->cell.getDescription().c_str(), worldEvent->cell.getDescription().c_str(),
containerItem.refId.c_str(), containerItem.refId.c_str(),
containerItem.count); containerItem.count);
delete event;
event = NULL;
mDragAndDrop->drop(mModel, mItemView); mDragAndDrop->drop(mModel, mItemView);
} }
@ -313,24 +307,21 @@ namespace MWGui
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container);
// Added by tes3mp // Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
event->cell = *mPtr.getCell()->getCell(); worldEvent->cell = *mPtr.getCell()->getCell();
event->action = mwmp::BaseEvent::SET; worldEvent->action = mwmp::BaseEvent::SET;
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.refId = mPtr.getCellRef().getRefId(); worldObject.refId = mPtr.getCellRef().getRefId();
worldObject.refNumIndex = mPtr.getCellRef().getRefNum().mIndex; worldObject.refNumIndex = mPtr.getCellRef().getRefNum().mIndex;
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send(worldEvent);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s", LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s",
worldObject.refId.c_str(), worldObject.refId.c_str(),
worldObject.refNumIndex, worldObject.refNumIndex,
event->cell.getDescription().c_str()); worldEvent->cell.getDescription().c_str());
delete event;
event = NULL;
} }
} }

@ -67,8 +67,8 @@ namespace MWGui
dropped.getCellRef().setRefNumIndex(cellStore->getLastRefNumIndex()); dropped.getCellRef().setRefNumIndex(cellStore->getLastRefNumIndex());
// Added by tes3mp // Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
event->cell = *dropped.getCell()->getCell(); worldEvent->cell = *dropped.getCell()->getCell();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.refId = dropped.getCellRef().getRefId(); worldObject.refId = dropped.getCellRef().getRefId();
@ -86,18 +86,15 @@ namespace MWGui
// Get the real count of gold in a stack // Get the real count of gold in a stack
worldObject.goldValue = dropped.getCellRef().getGoldValue(); worldObject.goldValue = dropped.getCellRef().getGoldValue();
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_PLACE)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_PLACE)->Send(worldEvent);
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_PLACE\n- cellRef: %s, %i\n- count: %i", LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_PLACE\n- cellRef: %s, %i\n- count: %i",
worldObject.refId.c_str(), worldObject.refId.c_str(),
worldObject.refNumIndex, worldObject.refNumIndex,
worldObject.count); worldObject.count);
delete event;
event = nullptr;
return dropped; return dropped;
} }

@ -636,17 +636,15 @@ namespace MWGui
MWWorld::Ptr newObject = *player.getClass().getContainerStore (player).add (object, object.getRefData().getCount(), player); MWWorld::Ptr newObject = *player.getClass().getContainerStore (player).add (object, object.getRefData().getCount(), player);
// Added by tes3mp // Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
event->cell = *object.getCell()->getCell(); worldEvent->cell = *object.getCell()->getCell();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.refId = object.getCellRef().getRefId(); worldObject.refId = object.getCellRef().getRefId();
worldObject.refNumIndex = object.getCellRef().getRefNum().mIndex; worldObject.refNumIndex = object.getCellRef().getRefNum().mIndex;
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(worldEvent);
delete event;
event = nullptr;
// LocalPlayer's inventory has changed, so send a packet with it // LocalPlayer's inventory has changed, so send a packet with it
mwmp::Main::get().getLocalPlayer()->sendInventory(); mwmp::Main::get().getLocalPlayer()->sendInventory();

@ -59,17 +59,15 @@ namespace MWMechanics
if (Misc::Rng::roll0to99() <= x) if (Misc::Rng::roll0to99() <= x)
{ {
// Added by tes3mp // Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
event->cell = *lock.getCell()->getCell(); worldEvent->cell = *lock.getCell()->getCell();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.refId = lock.getCellRef().getRefId(); worldObject.refId = lock.getCellRef().getRefId();
worldObject.refNumIndex = lock.getCellRef().getRefNum().mIndex; worldObject.refNumIndex = lock.getCellRef().getRefNum().mIndex;
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->Send(worldEvent);
delete event;
event = NULL;
lock.getClass().unlock(lock); lock.getClass().unlock(lock);
resultMessage = "#{sLockSuccess}"; resultMessage = "#{sLockSuccess}";

@ -733,188 +733,187 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
pl = Players::getPlayer(guid); pl = Players::getPlayer(guid);
WorldPacket *myPacket = worldController.GetPacket(packet->data[0]); WorldPacket *myPacket = worldController.GetPacket(packet->data[0]);
WorldEvent *event = new WorldEvent(guid);
myPacket->Packet(&bsIn, event, false); myPacket->Packet(&bsIn, &worldEvent, false);
switch (packet->data[0]) switch (packet->data[0])
{ {
case ID_CONTAINER: case ID_CONTAINER:
{ {
MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(event->cell); MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(worldEvent.cell);
if (!ptrCellStore) return; if (!ptrCellStore) return;
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received ID_CONTAINER about %s", LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received ID_CONTAINER about %s",
event->cell.getDescription().c_str()); worldEvent.cell.getDescription().c_str());
LOG_APPEND(Log::LOG_VERBOSE, "- action: %i", event->action); LOG_APPEND(Log::LOG_VERBOSE, "- action: %i", worldEvent.action);
// If we've received a request for information, comply with it // If we've received a request for information, comply with it
if (event->action == mwmp::BaseEvent::REQUEST) if (worldEvent.action == mwmp::BaseEvent::REQUEST)
event->sendContainers(ptrCellStore); worldEvent.sendContainers(ptrCellStore);
// Otherwise, edit containers based on the information received // Otherwise, edit containers based on the information received
else else
event->editContainers(ptrCellStore); worldEvent.editContainers(ptrCellStore);
break; break;
} }
case ID_OBJECT_PLACE: case ID_OBJECT_PLACE:
{ {
MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(event->cell); MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(worldEvent.cell);
if (!ptrCellStore) return; if (!ptrCellStore) return;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_PLACE about %s", LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_PLACE about %s",
event->cell.getDescription().c_str()); worldEvent.cell.getDescription().c_str());
event->placeObjects(ptrCellStore); worldEvent.placeObjects(ptrCellStore);
break; break;
} }
case ID_OBJECT_DELETE: case ID_OBJECT_DELETE:
{ {
MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(event->cell); MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(worldEvent.cell);
if (!ptrCellStore) return; if (!ptrCellStore) return;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_DELETE about %s", LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_DELETE about %s",
event->cell.getDescription().c_str()); worldEvent.cell.getDescription().c_str());
event->deleteObjects(ptrCellStore); worldEvent.deleteObjects(ptrCellStore);
break; break;
} }
case ID_OBJECT_LOCK: case ID_OBJECT_LOCK:
{ {
MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(event->cell); MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(worldEvent.cell);
if (!ptrCellStore) return; if (!ptrCellStore) return;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_LOCK about %s", LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_LOCK about %s",
event->cell.getDescription().c_str()); worldEvent.cell.getDescription().c_str());
event->lockObjects(ptrCellStore); worldEvent.lockObjects(ptrCellStore);
break; break;
} }
case ID_OBJECT_UNLOCK: case ID_OBJECT_UNLOCK:
{ {
MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(event->cell); MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(worldEvent.cell);
if (!ptrCellStore) return; if (!ptrCellStore) return;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_UNLOCK about %s", LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_UNLOCK about %s",
event->cell.getDescription().c_str()); worldEvent.cell.getDescription().c_str());
event->unlockObjects(ptrCellStore); worldEvent.unlockObjects(ptrCellStore);
break; break;
} }
case ID_OBJECT_SCALE: case ID_OBJECT_SCALE:
{ {
MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(event->cell); MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(worldEvent.cell);
if (!ptrCellStore) return; if (!ptrCellStore) return;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_SCALE about %s", LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_SCALE about %s",
event->cell.getDescription().c_str()); worldEvent.cell.getDescription().c_str());
event->scaleObjects(ptrCellStore); worldEvent.scaleObjects(ptrCellStore);
break; break;
} }
case ID_OBJECT_MOVE: case ID_OBJECT_MOVE:
{ {
MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(event->cell); MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(worldEvent.cell);
if (!ptrCellStore) return; if (!ptrCellStore) return;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_MOVE about %s", LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_MOVE about %s",
event->cell.getDescription().c_str()); worldEvent.cell.getDescription().c_str());
event->moveObjects(ptrCellStore); worldEvent.moveObjects(ptrCellStore);
break; break;
} }
case ID_OBJECT_ROTATE: case ID_OBJECT_ROTATE:
{ {
MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(event->cell); MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(worldEvent.cell);
if (!ptrCellStore) return; if (!ptrCellStore) return;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_ROTATE about %s", LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_ROTATE about %s",
event->cell.getDescription().c_str()); worldEvent.cell.getDescription().c_str());
event->rotateObjects(ptrCellStore); worldEvent.rotateObjects(ptrCellStore);
break; break;
} }
case ID_OBJECT_ANIM_PLAY: case ID_OBJECT_ANIM_PLAY:
{ {
MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(event->cell); MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(worldEvent.cell);
if (!ptrCellStore) return; if (!ptrCellStore) return;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_ANIM_PLAY about %s", LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_ANIM_PLAY about %s",
event->cell.getDescription().c_str()); worldEvent.cell.getDescription().c_str());
event->animateObjects(ptrCellStore); worldEvent.animateObjects(ptrCellStore);
break; break;
} }
case ID_DOOR_STATE: case ID_DOOR_STATE:
{ {
MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(event->cell); MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(worldEvent.cell);
if (!ptrCellStore) return; if (!ptrCellStore) return;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_DOOR_STATE about %s", LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_DOOR_STATE about %s",
event->cell.getDescription().c_str()); worldEvent.cell.getDescription().c_str());
event->activateDoors(ptrCellStore); worldEvent.activateDoors(ptrCellStore);
break; break;
} }
case ID_SCRIPT_LOCAL_SHORT: case ID_SCRIPT_LOCAL_SHORT:
{ {
MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(event->cell); MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(worldEvent.cell);
if (!ptrCellStore) return; if (!ptrCellStore) return;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_LOCAL_SHORT about %s", LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_LOCAL_SHORT about %s",
event->cell.getDescription().c_str()); worldEvent.cell.getDescription().c_str());
event->setLocalShorts(ptrCellStore); worldEvent.setLocalShorts(ptrCellStore);
break; break;
} }
case ID_SCRIPT_LOCAL_FLOAT: case ID_SCRIPT_LOCAL_FLOAT:
{ {
MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(event->cell); MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(worldEvent.cell);
if (!ptrCellStore) return; if (!ptrCellStore) return;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_LOCAL_FLOAT about %s", LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_LOCAL_FLOAT about %s",
event->cell.getDescription().c_str()); worldEvent.cell.getDescription().c_str());
event->setLocalFloats(ptrCellStore); worldEvent.setLocalFloats(ptrCellStore);
break; break;
} }
case ID_SCRIPT_MEMBER_SHORT: case ID_SCRIPT_MEMBER_SHORT:
{ {
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_MEMBER_SHORT"); LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_MEMBER_SHORT");
event->setMemberShorts(); worldEvent.setMemberShorts();
break; break;
} }
case ID_SCRIPT_GLOBAL_SHORT: case ID_SCRIPT_GLOBAL_SHORT:
{ {
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_GLOBAL_SHORT"); LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_GLOBAL_SHORT");
event->setGlobalShorts(); worldEvent.setGlobalShorts();
break; break;
} }
case ID_MUSIC_PLAY: case ID_MUSIC_PLAY:
{ {
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_MUSIC_PLAY"); LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_MUSIC_PLAY");
event->playMusic(); worldEvent.playMusic();
break; break;
} }
case ID_VIDEO_PLAY: case ID_VIDEO_PLAY:
{ {
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_VIDEO_PLAY"); LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_VIDEO_PLAY");
event->playVideo(); worldEvent.playVideo();
break; break;
} }
@ -954,9 +953,12 @@ LocalPlayer *Networking::getLocalPlayer()
return mwmp::Main::get().getLocalPlayer(); return mwmp::Main::get().getLocalPlayer();
} }
WorldEvent *Networking::createWorldEvent() WorldEvent *Networking::resetWorldEvent()
{ {
return new WorldEvent(getLocalPlayer()->guid); worldEvent.cell.blank();
worldEvent.objectChanges.objects.clear();
worldEvent.guid = getLocalPlayer()->guid;
return &worldEvent;
} }
bool Networking::isDedicatedPlayer(const MWWorld::Ptr &ptr) bool Networking::isDedicatedPlayer(const MWWorld::Ptr &ptr)

@ -40,7 +40,7 @@ namespace mwmp
bool isConnected(); bool isConnected();
WorldEvent *createWorldEvent(); WorldEvent *resetWorldEvent();
private: private:
bool connected; bool connected;
@ -50,6 +50,7 @@ namespace mwmp
PlayerPacketController playerController; PlayerPacketController playerController;
WorldPacketController worldController; WorldPacketController worldController;
WorldEvent worldEvent;
void processPlayerPacket(RakNet::Packet *packet); void processPlayerPacket(RakNet::Packet *packet);
void processWorldPacket(RakNet::Packet *packet); void processWorldPacket(RakNet::Packet *packet);

@ -20,9 +20,9 @@
using namespace mwmp; using namespace mwmp;
using namespace std; using namespace std;
WorldEvent::WorldEvent(RakNet::RakNetGUID guid) WorldEvent::WorldEvent()
{ {
this->guid = guid;
} }
WorldEvent::~WorldEvent() WorldEvent::~WorldEvent()
@ -42,9 +42,9 @@ void WorldEvent::addObject(WorldObject worldObject)
void WorldEvent::sendContainers(MWWorld::CellStore* cellStore) void WorldEvent::sendContainers(MWWorld::CellStore* cellStore)
{ {
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
event->cell = *cellStore->getCell(); worldEvent->cell = *cellStore->getCell();
event->action = BaseEvent::SET; worldEvent->action = BaseEvent::SET;
MWWorld::CellRefList<ESM::Container> *containerList = cellStore->getContainers(); MWWorld::CellRefList<ESM::Container> *containerList = cellStore->getContainers();
@ -71,10 +71,10 @@ void WorldEvent::sendContainers(MWWorld::CellStore* cellStore)
worldObject.containerChanges.items.push_back(containerItem); worldObject.containerChanges.items.push_back(containerItem);
} }
event->addObject(worldObject); worldEvent->addObject(worldObject);
} }
mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send(worldEvent);
} }
void WorldEvent::editContainers(MWWorld::CellStore* cellStore) void WorldEvent::editContainers(MWWorld::CellStore* cellStore)

@ -12,7 +12,7 @@ namespace mwmp
{ {
public: public:
WorldEvent(RakNet::RakNetGUID guid); WorldEvent();
virtual ~WorldEvent(); virtual ~WorldEvent();
void addObject(WorldObject worldObject); void addObject(WorldObject worldObject);

@ -66,19 +66,17 @@ namespace MWScript
// Added by tes3mp to check and set whether packets should be sent about this script // Added by tes3mp to check and set whether packets should be sent about this script
if (mwmp::Main::isValidPacketScript(ptr.getClass().getScript(ptr))) if (mwmp::Main::isValidPacketScript(ptr.getClass().getScript(ptr)))
{ {
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
event->cell = *ptr.getCell()->getCell(); worldEvent->cell = *ptr.getCell()->getCell();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.refId = ptr.getCellRef().getRefId(); worldObject.refId = ptr.getCellRef().getRefId();
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex; worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
worldObject.animGroup = group; worldObject.animGroup = group;
worldObject.animMode = mode; worldObject.animMode = mode;
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_ANIM_PLAY)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_ANIM_PLAY)->Send(worldEvent);
delete event;
event = NULL;
} }
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup (ptr, group, mode, std::numeric_limits<int>::max(), true); MWBase::Environment::get().getMechanicsManager()->playAnimationGroup (ptr, group, mode, std::numeric_limits<int>::max(), true);

@ -189,27 +189,24 @@ namespace MWScript
// Added by tes3mp // Added by tes3mp
if (sendPackets) if (sendPackets)
{ {
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
event->cell = *mReference.getCell()->getCell(); worldEvent->cell = *mReference.getCell()->getCell();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.refId = mReference.getCellRef().getRefId(); worldObject.refId = mReference.getCellRef().getRefId();
worldObject.refNumIndex = mReference.getCellRef().getRefNum().mIndex; worldObject.refNumIndex = mReference.getCellRef().getRefNum().mIndex;
worldObject.index = index; worldObject.index = index;
worldObject.shortVal = value; worldObject.shortVal = value;
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_SHORT)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_SHORT)->Send(worldEvent);
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_LOCAL_SHORT\n- cellRef: %s, %i\n- cell: %s\n- index: %i\n- shortVal: %i", LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_LOCAL_SHORT\n- cellRef: %s, %i\n- cell: %s\n- index: %i\n- shortVal: %i",
worldObject.refId.c_str(), worldObject.refId.c_str(),
worldObject.refNumIndex, worldObject.refNumIndex,
event->cell.getDescription().c_str(), worldEvent->cell.getDescription().c_str(),
worldObject.index, worldObject.index,
worldObject.shortVal); worldObject.shortVal);
delete event;
event = NULL;
} }
} }
@ -233,27 +230,24 @@ namespace MWScript
// Only send a packet if this float has no decimals (to avoid spam) // Only send a packet if this float has no decimals (to avoid spam)
if (sendPackets && value == (int) value) if (sendPackets && value == (int) value)
{ {
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
event->cell = *mReference.getCell()->getCell(); worldEvent->cell = *mReference.getCell()->getCell();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.refId = mReference.getCellRef().getRefId(); worldObject.refId = mReference.getCellRef().getRefId();
worldObject.refNumIndex = mReference.getCellRef().getRefNum().mIndex; worldObject.refNumIndex = mReference.getCellRef().getRefNum().mIndex;
worldObject.index = index; worldObject.index = index;
worldObject.floatVal = value; worldObject.floatVal = value;
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_FLOAT)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_FLOAT)->Send(worldEvent);
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_LOCAL_FLOAT\n- cellRef: %s, %i\n- cell: %s\n- index: %i\n- floatVal: %f", LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_LOCAL_FLOAT\n- cellRef: %s, %i\n- cell: %s\n- index: %i\n- floatVal: %f",
worldObject.refId.c_str(), worldObject.refId.c_str(),
worldObject.refNumIndex, worldObject.refNumIndex,
event->cell.getDescription().c_str(), worldEvent->cell.getDescription().c_str(),
worldObject.index, worldObject.index,
worldObject.floatVal); worldObject.floatVal);
delete event;
event = NULL;
} }
} }
@ -301,21 +295,18 @@ namespace MWScript
// Added by tes3mp // Added by tes3mp
if (sendPackets) if (sendPackets)
{ {
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.varName = name; worldObject.varName = name;
worldObject.shortVal = value; worldObject.shortVal = value;
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_GLOBAL_SHORT)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_GLOBAL_SHORT)->Send(worldEvent);
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_GLOBAL_SHORT\n- varName: %s\n- shortVal: %i", LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_GLOBAL_SHORT\n- varName: %s\n- shortVal: %i",
worldObject.varName.c_str(), worldObject.varName.c_str(),
worldObject.shortVal); worldObject.shortVal);
delete event;
event = NULL;
} }
MWBase::Environment::get().getWorld()->setGlobalInt (name, value); MWBase::Environment::get().getWorld()->setGlobalInt (name, value);
@ -641,23 +632,20 @@ namespace MWScript
// Added by tes3mp // Added by tes3mp
if (sendPackets && !global) if (sendPackets && !global)
{ {
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.refId = id; worldObject.refId = id;
worldObject.index = index; worldObject.index = index;
worldObject.shortVal = value; worldObject.shortVal = value;
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_MEMBER_SHORT)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_MEMBER_SHORT)->Send(worldEvent);
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_MEMBER_SHORT\n- cellRef: %s\n- index: %i\n- shortVal: %i", LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_MEMBER_SHORT\n- cellRef: %s\n- index: %i\n- shortVal: %i",
worldObject.refId.c_str(), worldObject.refId.c_str(),
worldObject.index, worldObject.index,
worldObject.shortVal); worldObject.shortVal);
delete event;
event = NULL;
} }
} }

@ -90,16 +90,14 @@ namespace MWScript
runtime.pop(); runtime.pop();
// Added by tes3mp // Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.filename = name; worldObject.filename = name;
worldObject.allowSkipping = allowSkipping; worldObject.allowSkipping = allowSkipping;
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_VIDEO_PLAY)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_VIDEO_PLAY)->Send(worldEvent);
delete event;
event = NULL;
MWBase::Environment::get().getWindowManager()->playVideo (name, allowSkipping); MWBase::Environment::get().getWindowManager()->playVideo (name, allowSkipping);
} }
@ -200,18 +198,16 @@ namespace MWScript
} }
// Added by tes3mp // Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
event->cell = *ptr.getCell()->getCell(); worldEvent->cell = *ptr.getCell()->getCell();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.refId = ptr.getCellRef().getRefId(); worldObject.refId = ptr.getCellRef().getRefId();
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex; worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
worldObject.lockLevel = lockLevel; worldObject.lockLevel = lockLevel;
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_LOCK)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_LOCK)->Send(worldEvent);
delete event;
event = NULL;
ptr.getClass().lock (ptr, lockLevel); ptr.getClass().lock (ptr, lockLevel);
@ -240,17 +236,15 @@ namespace MWScript
MWWorld::Ptr ptr = R()(runtime); MWWorld::Ptr ptr = R()(runtime);
// Added by tes3mp // Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
event->cell = *ptr.getCell()->getCell(); worldEvent->cell = *ptr.getCell()->getCell();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.refId = ptr.getCellRef().getRefId(); worldObject.refId = ptr.getCellRef().getRefId();
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex; worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->Send(worldEvent);
delete event;
event = NULL;
ptr.getClass().unlock (ptr); ptr.getClass().unlock (ptr);
} }
@ -713,17 +707,15 @@ namespace MWScript
if (parameter == 1) if (parameter == 1)
{ {
// Added by tes3mp // Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
event->cell = *ptr.getCell()->getCell(); worldEvent->cell = *ptr.getCell()->getCell();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.refId = ptr.getCellRef().getRefId(); worldObject.refId = ptr.getCellRef().getRefId();
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex; worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(worldEvent);
delete event;
event = NULL;
MWBase::Environment::get().getWorld()->deleteObject(ptr); MWBase::Environment::get().getWorld()->deleteObject(ptr);
} }

@ -71,15 +71,13 @@ namespace MWScript
runtime.pop(); runtime.pop();
// Added by tes3mp // Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.filename = sound; worldObject.filename = sound;
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_MUSIC_PLAY)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_MUSIC_PLAY)->Send(worldEvent);
delete event;
event = NULL;
MWBase::Environment::get().getSoundManager()->streamMusic (sound); MWBase::Environment::get().getSoundManager()->streamMusic (sound);
} }

@ -47,18 +47,16 @@ namespace MWScript
runtime.pop(); runtime.pop();
// Added by tes3mp // Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
event->cell = *ptr.getCell()->getCell(); worldEvent->cell = *ptr.getCell()->getCell();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.refId = ptr.getCellRef().getRefId(); worldObject.refId = ptr.getCellRef().getRefId();
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex; worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
worldObject.scale = scale; worldObject.scale = scale;
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_SCALE)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_SCALE)->Send(worldEvent);
delete event;
event = NULL;
MWBase::Environment::get().getWorld()->scaleObject(ptr,scale); MWBase::Environment::get().getWorld()->scaleObject(ptr,scale);
} }
@ -552,8 +550,8 @@ namespace MWScript
ptr.getCellRef().setRefNumIndex(cellStore->getLastRefNumIndex()); ptr.getCellRef().setRefNumIndex(cellStore->getLastRefNumIndex());
// Added by tes3mp // Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
event->cell = *ptr.getCell()->getCell(); worldEvent->cell = *ptr.getCell()->getCell();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.refId = ptr.getCellRef().getRefId(); worldObject.refId = ptr.getCellRef().getRefId();
@ -565,17 +563,14 @@ namespace MWScript
// we actually see on this client // we actually see on this client
worldObject.pos = ptr.getRefData().getPosition(); worldObject.pos = ptr.getRefData().getPosition();
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_PLACE)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_PLACE)->Send(worldEvent);
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_PLACE\n- cellRef: %s, %i\n- count: %i", LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_PLACE\n- cellRef: %s, %i\n- count: %i",
worldObject.refId.c_str(), worldObject.refId.c_str(),
worldObject.refNumIndex, worldObject.refNumIndex,
worldObject.count); worldObject.count);
delete event;
event = NULL;
} }
} }
}; };

@ -26,23 +26,20 @@ namespace MWWorld
MWWorld::Ptr newitem = *actor.getClass().getContainerStore (actor).add (getTarget(), getTarget().getRefData().getCount(), actor); MWWorld::Ptr newitem = *actor.getClass().getContainerStore (actor).add (getTarget(), getTarget().getRefData().getCount(), actor);
// Added by tes3mp // Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
event->cell = *getTarget().getCell()->getCell(); worldEvent->cell = *getTarget().getCell()->getCell();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.refId = getTarget().getCellRef().getRefId(); worldObject.refId = getTarget().getCellRef().getRefId();
worldObject.refNumIndex = getTarget().getCellRef().getRefNum().mIndex; worldObject.refNumIndex = getTarget().getCellRef().getRefNum().mIndex;
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(worldEvent);
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_DELETE about\n- cellRef: %s, %i\n- cell: %s", LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_DELETE about\n- cellRef: %s, %i\n- cell: %s",
worldObject.refId.c_str(), worldObject.refId.c_str(),
worldObject.refNumIndex, worldObject.refNumIndex,
event->cell.getDescription().c_str()); worldEvent->cell.getDescription().c_str());
delete event;
event = NULL;
// LocalPlayer's inventory has changed, so send a packet with it // LocalPlayer's inventory has changed, so send a packet with it
mwmp::Main::get().getLocalPlayer()->sendInventory(); mwmp::Main::get().getLocalPlayer()->sendInventory();

@ -2316,26 +2316,23 @@ namespace MWWorld
} }
// Added by tes3mp // Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
event->cell = *door.getCell()->getCell(); worldEvent->cell = *door.getCell()->getCell();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.refId = door.getCellRef().getRefId(); worldObject.refId = door.getCellRef().getRefId();
worldObject.refNumIndex = door.getCellRef().getRefNum().mIndex; worldObject.refNumIndex = door.getCellRef().getRefNum().mIndex;
worldObject.doorState = state; worldObject.doorState = state;
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_STATE)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_STATE)->Send(worldEvent);
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Door activation 1\n- cellRef: %s, %i\n- cell: %s\n- state: %s", LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Door activation 1\n- cellRef: %s, %i\n- cell: %s\n- state: %s",
worldObject.refId.c_str(), worldObject.refId.c_str(),
worldObject.refNumIndex, worldObject.refNumIndex,
event->cell.getDescription().c_str(), worldEvent->cell.getDescription().c_str(),
worldObject.doorState ? "true" : "false"); worldObject.doorState ? "true" : "false");
delete event;
event = NULL;
door.getClass().setDoorState(door, state); door.getClass().setDoorState(door, state);
mDoorStates[door] = state; mDoorStates[door] = state;
} }
@ -2343,26 +2340,23 @@ namespace MWWorld
void World::activateDoor(const Ptr &door, int state) void World::activateDoor(const Ptr &door, int state)
{ {
// Added by tes3mp // Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
event->cell = *door.getCell()->getCell(); worldEvent->cell = *door.getCell()->getCell();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
worldObject.refId = door.getCellRef().getRefId(); worldObject.refId = door.getCellRef().getRefId();
worldObject.refNumIndex = door.getCellRef().getRefNum().mIndex; worldObject.refNumIndex = door.getCellRef().getRefNum().mIndex;
worldObject.doorState = state; worldObject.doorState = state;
event->addObject(worldObject); worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_STATE)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_STATE)->Send(worldEvent);
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Door activation 2\n- cellRef: %s, %i\n- cell: %s\n- state: %s", LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Door activation 2\n- cellRef: %s, %i\n- cell: %s\n- state: %s",
worldObject.refId.c_str(), worldObject.refId.c_str(),
worldObject.refNumIndex, worldObject.refNumIndex,
event->cell.getDescription().c_str(), worldEvent->cell.getDescription().c_str(),
worldObject.doorState ? "true" : "false"); worldObject.doorState ? "true" : "false");
delete event;
event = NULL;
door.getClass().setDoorState(door, state); door.getClass().setDoorState(door, state);
mDoorStates[door] = state; mDoorStates[door] = state;
if (state == 0) if (state == 0)

Loading…
Cancel
Save