[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;
// Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
event->cell = *mPtr.getCell()->getCell();
event->action = mwmp::BaseEvent::REMOVE;
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
worldEvent->cell = *mPtr.getCell()->getCell();
worldEvent->action = mwmp::BaseEvent::REMOVE;
mwmp::WorldObject worldObject;
worldObject.refId = mPtr.getCellRef().getRefId();
@ -119,20 +119,17 @@ namespace MWGui
containerItem.actionCount = count;
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",
worldObject.refId.c_str(),
worldObject.refNumIndex,
event->cell.getDescription().c_str(),
worldEvent->cell.getDescription().c_str(),
containerItem.refId.c_str(),
containerItem.count);
delete event;
event = NULL;
mDragAndDrop->startDrag(mSelectedItem, mSortModel, mModel, mItemView, count);
}
@ -160,9 +157,9 @@ namespace MWGui
}
// Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
event->cell = *mPtr.getCell()->getCell();
event->action = mwmp::BaseEvent::ADD;
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
worldEvent->cell = *mPtr.getCell()->getCell();
worldEvent->action = mwmp::BaseEvent::ADD;
mwmp::WorldObject worldObject;
worldObject.refId = mPtr.getCellRef().getRefId();
@ -179,20 +176,17 @@ namespace MWGui
containerItem.charge = itemPtr.getCellRef().getCharge();
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",
worldObject.refId.c_str(),
worldObject.refNumIndex,
event->cell.getDescription().c_str(),
worldEvent->cell.getDescription().c_str(),
containerItem.refId.c_str(),
containerItem.count);
delete event;
event = NULL;
mDragAndDrop->drop(mModel, mItemView);
}
@ -313,24 +307,21 @@ namespace MWGui
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container);
// Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
event->cell = *mPtr.getCell()->getCell();
event->action = mwmp::BaseEvent::SET;
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
worldEvent->cell = *mPtr.getCell()->getCell();
worldEvent->action = mwmp::BaseEvent::SET;
mwmp::WorldObject worldObject;
worldObject.refId = mPtr.getCellRef().getRefId();
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",
worldObject.refId.c_str(),
worldObject.refNumIndex,
event->cell.getDescription().c_str());
delete event;
event = NULL;
worldEvent->cell.getDescription().c_str());
}
}

@ -67,8 +67,8 @@ namespace MWGui
dropped.getCellRef().setRefNumIndex(cellStore->getLastRefNumIndex());
// Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
event->cell = *dropped.getCell()->getCell();
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
worldEvent->cell = *dropped.getCell()->getCell();
mwmp::WorldObject worldObject;
worldObject.refId = dropped.getCellRef().getRefId();
@ -86,18 +86,15 @@ namespace MWGui
// Get the real count of gold in a stack
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",
worldObject.refId.c_str(),
worldObject.refNumIndex,
worldObject.count);
delete event;
event = nullptr;
return dropped;
}

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

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

@ -733,188 +733,187 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
pl = Players::getPlayer(guid);
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])
{
case ID_CONTAINER:
{
MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(event->cell);
MWWorld::CellStore *ptrCellStore = Main::get().getWorldController()->getCell(worldEvent.cell);
if (!ptrCellStore) return;
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received ID_CONTAINER about %s",
event->cell.getDescription().c_str());
LOG_APPEND(Log::LOG_VERBOSE, "- action: %i", event->action);
worldEvent.cell.getDescription().c_str());
LOG_APPEND(Log::LOG_VERBOSE, "- action: %i", worldEvent.action);
// If we've received a request for information, comply with it
if (event->action == mwmp::BaseEvent::REQUEST)
event->sendContainers(ptrCellStore);
if (worldEvent.action == mwmp::BaseEvent::REQUEST)
worldEvent.sendContainers(ptrCellStore);
// Otherwise, edit containers based on the information received
else
event->editContainers(ptrCellStore);
worldEvent.editContainers(ptrCellStore);
break;
}
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;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_PLACE about %s",
event->cell.getDescription().c_str());
event->placeObjects(ptrCellStore);
worldEvent.cell.getDescription().c_str());
worldEvent.placeObjects(ptrCellStore);
break;
}
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;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_DELETE about %s",
event->cell.getDescription().c_str());
event->deleteObjects(ptrCellStore);
worldEvent.cell.getDescription().c_str());
worldEvent.deleteObjects(ptrCellStore);
break;
}
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;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_LOCK about %s",
event->cell.getDescription().c_str());
event->lockObjects(ptrCellStore);
worldEvent.cell.getDescription().c_str());
worldEvent.lockObjects(ptrCellStore);
break;
}
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;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_UNLOCK about %s",
event->cell.getDescription().c_str());
event->unlockObjects(ptrCellStore);
worldEvent.cell.getDescription().c_str());
worldEvent.unlockObjects(ptrCellStore);
break;
}
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;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_SCALE about %s",
event->cell.getDescription().c_str());
event->scaleObjects(ptrCellStore);
worldEvent.cell.getDescription().c_str());
worldEvent.scaleObjects(ptrCellStore);
break;
}
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;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_MOVE about %s",
event->cell.getDescription().c_str());
event->moveObjects(ptrCellStore);
worldEvent.cell.getDescription().c_str());
worldEvent.moveObjects(ptrCellStore);
break;
}
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;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_ROTATE about %s",
event->cell.getDescription().c_str());
event->rotateObjects(ptrCellStore);
worldEvent.cell.getDescription().c_str());
worldEvent.rotateObjects(ptrCellStore);
break;
}
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;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_ANIM_PLAY about %s",
event->cell.getDescription().c_str());
event->animateObjects(ptrCellStore);
worldEvent.cell.getDescription().c_str());
worldEvent.animateObjects(ptrCellStore);
break;
}
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;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_DOOR_STATE about %s",
event->cell.getDescription().c_str());
event->activateDoors(ptrCellStore);
worldEvent.cell.getDescription().c_str());
worldEvent.activateDoors(ptrCellStore);
break;
}
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;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_LOCAL_SHORT about %s",
event->cell.getDescription().c_str());
event->setLocalShorts(ptrCellStore);
worldEvent.cell.getDescription().c_str());
worldEvent.setLocalShorts(ptrCellStore);
break;
}
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;
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_LOCAL_FLOAT about %s",
event->cell.getDescription().c_str());
event->setLocalFloats(ptrCellStore);
worldEvent.cell.getDescription().c_str());
worldEvent.setLocalFloats(ptrCellStore);
break;
}
case ID_SCRIPT_MEMBER_SHORT:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_MEMBER_SHORT");
event->setMemberShorts();
worldEvent.setMemberShorts();
break;
}
case ID_SCRIPT_GLOBAL_SHORT:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_GLOBAL_SHORT");
event->setGlobalShorts();
worldEvent.setGlobalShorts();
break;
}
case ID_MUSIC_PLAY:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_MUSIC_PLAY");
event->playMusic();
worldEvent.playMusic();
break;
}
case ID_VIDEO_PLAY:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_VIDEO_PLAY");
event->playVideo();
worldEvent.playVideo();
break;
}
@ -954,9 +953,12 @@ LocalPlayer *Networking::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)

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

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

@ -12,7 +12,7 @@ namespace mwmp
{
public:
WorldEvent(RakNet::RakNetGUID guid);
WorldEvent();
virtual ~WorldEvent();
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
if (mwmp::Main::isValidPacketScript(ptr.getClass().getScript(ptr)))
{
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
event->cell = *ptr.getCell()->getCell();
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
worldEvent->cell = *ptr.getCell()->getCell();
mwmp::WorldObject worldObject;
worldObject.refId = ptr.getCellRef().getRefId();
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
worldObject.animGroup = group;
worldObject.animMode = mode;
event->addObject(worldObject);
worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_ANIM_PLAY)->Send(event);
delete event;
event = NULL;
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_ANIM_PLAY)->Send(worldEvent);
}
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup (ptr, group, mode, std::numeric_limits<int>::max(), true);

@ -189,27 +189,24 @@ namespace MWScript
// Added by tes3mp
if (sendPackets)
{
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
event->cell = *mReference.getCell()->getCell();
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
worldEvent->cell = *mReference.getCell()->getCell();
mwmp::WorldObject worldObject;
worldObject.refId = mReference.getCellRef().getRefId();
worldObject.refNumIndex = mReference.getCellRef().getRefNum().mIndex;
worldObject.index = index;
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",
worldObject.refId.c_str(),
worldObject.refNumIndex,
event->cell.getDescription().c_str(),
worldEvent->cell.getDescription().c_str(),
worldObject.index,
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)
if (sendPackets && value == (int) value)
{
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
event->cell = *mReference.getCell()->getCell();
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
worldEvent->cell = *mReference.getCell()->getCell();
mwmp::WorldObject worldObject;
worldObject.refId = mReference.getCellRef().getRefId();
worldObject.refNumIndex = mReference.getCellRef().getRefNum().mIndex;
worldObject.index = index;
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",
worldObject.refId.c_str(),
worldObject.refNumIndex,
event->cell.getDescription().c_str(),
worldEvent->cell.getDescription().c_str(),
worldObject.index,
worldObject.floatVal);
delete event;
event = NULL;
}
}
@ -301,21 +295,18 @@ namespace MWScript
// Added by tes3mp
if (sendPackets)
{
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
mwmp::WorldObject worldObject;
worldObject.varName = name;
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",
worldObject.varName.c_str(),
worldObject.shortVal);
delete event;
event = NULL;
}
MWBase::Environment::get().getWorld()->setGlobalInt (name, value);
@ -641,23 +632,20 @@ namespace MWScript
// Added by tes3mp
if (sendPackets && !global)
{
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
mwmp::WorldObject worldObject;
worldObject.refId = id;
worldObject.index = index;
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",
worldObject.refId.c_str(),
worldObject.index,
worldObject.shortVal);
delete event;
event = NULL;
}
}

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

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

@ -47,18 +47,16 @@ namespace MWScript
runtime.pop();
// Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
event->cell = *ptr.getCell()->getCell();
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
worldEvent->cell = *ptr.getCell()->getCell();
mwmp::WorldObject worldObject;
worldObject.refId = ptr.getCellRef().getRefId();
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
worldObject.scale = scale;
event->addObject(worldObject);
worldEvent->addObject(worldObject);
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_SCALE)->Send(event);
delete event;
event = NULL;
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_SCALE)->Send(worldEvent);
MWBase::Environment::get().getWorld()->scaleObject(ptr,scale);
}
@ -552,8 +550,8 @@ namespace MWScript
ptr.getCellRef().setRefNumIndex(cellStore->getLastRefNumIndex());
// Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
event->cell = *ptr.getCell()->getCell();
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
worldEvent->cell = *ptr.getCell()->getCell();
mwmp::WorldObject worldObject;
worldObject.refId = ptr.getCellRef().getRefId();
@ -565,17 +563,14 @@ namespace MWScript
// we actually see on this client
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",
worldObject.refId.c_str(),
worldObject.refNumIndex,
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);
// Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
event->cell = *getTarget().getCell()->getCell();
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
worldEvent->cell = *getTarget().getCell()->getCell();
mwmp::WorldObject worldObject;
worldObject.refId = getTarget().getCellRef().getRefId();
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",
worldObject.refId.c_str(),
worldObject.refNumIndex,
event->cell.getDescription().c_str());
delete event;
event = NULL;
worldEvent->cell.getDescription().c_str());
// LocalPlayer's inventory has changed, so send a packet with it
mwmp::Main::get().getLocalPlayer()->sendInventory();

@ -2316,26 +2316,23 @@ namespace MWWorld
}
// Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
event->cell = *door.getCell()->getCell();
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
worldEvent->cell = *door.getCell()->getCell();
mwmp::WorldObject worldObject;
worldObject.refId = door.getCellRef().getRefId();
worldObject.refNumIndex = door.getCellRef().getRefNum().mIndex;
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",
worldObject.refId.c_str(),
worldObject.refNumIndex,
event->cell.getDescription().c_str(),
worldEvent->cell.getDescription().c_str(),
worldObject.doorState ? "true" : "false");
delete event;
event = NULL;
door.getClass().setDoorState(door, state);
mDoorStates[door] = state;
}
@ -2343,26 +2340,23 @@ namespace MWWorld
void World::activateDoor(const Ptr &door, int state)
{
// Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
event->cell = *door.getCell()->getCell();
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
worldEvent->cell = *door.getCell()->getCell();
mwmp::WorldObject worldObject;
worldObject.refId = door.getCellRef().getRefId();
worldObject.refNumIndex = door.getCellRef().getRefNum().mIndex;
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",
worldObject.refId.c_str(),
worldObject.refNumIndex,
event->cell.getDescription().c_str(),
worldEvent->cell.getDescription().c_str(),
worldObject.doorState ? "true" : "false");
delete event;
event = NULL;
door.getClass().setDoorState(door, state);
mDoorStates[door] = state;
if (state == 0)

Loading…
Cancel
Save