1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 01:15:33 +00:00

Add a CellRef to WorldEvent

This commit is contained in:
David Cernat 2016-10-20 22:15:47 +03:00
parent b2845cd17c
commit ac666edebd
5 changed files with 23 additions and 1 deletions

View file

@ -368,6 +368,9 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet)
if (!player->isHandshaked() || player->LoadedState() != Player::POSTLOADED)
return;
WorldPacket *myPacket = worldController->GetPacket(packet->data[0]);
WorldEvent *event = new WorldEvent(player->guid);
switch (packet->data[0])
{
@ -375,6 +378,9 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet)
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_WORLD_OBJECT_REMOVAL from %s",
player->Npc()->mName.c_str());
myPacket->Read(event);
myPacket->Send(event, true);
break;
}

View file

@ -28,7 +28,7 @@ namespace MWWorld
*/
MWWorld::CellRef mRef;
/* Added by TES3MP to prevent dedicated players' references from automatically
/* Added by tes3mp to prevent dedicated players' references from automatically
* and unpredictably moving across exterior cell boundaries on clients
*/
bool canChangeCell;

View file

@ -1106,7 +1106,10 @@ namespace MWWorld
&& mWorldScene->getActiveCells().find(ptr.getCell()) != mWorldScene->getActiveCells().end()
&& ptr.getRefData().isEnabled())
{
// Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
event->CellRef()->mRefID = ptr.getCellRef().getRefId();
event->CellRef()->mRefNum = ptr.getCellRef().getRefNum();
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_WORLD_OBJECT_REMOVAL)->Send(event);
mWorldScene->removeObjectFromScene (ptr);

View file

@ -1,6 +1,7 @@
#ifndef OPENMW_WORLDEVENT_HPP
#define OPENMW_WORLDEVENT_HPP
#include <components/esm/cellref.hpp>
#include <RakNetTypes.h>
namespace mwmp
@ -19,7 +20,17 @@ namespace mwmp
}
virtual ESM::CellRef *CellRef()
{
return &ref;
}
RakNet::RakNetGUID guid;
protected:
ESM::CellRef ref;
};
}

View file

@ -11,4 +11,6 @@ PacketObjectRemoval::PacketObjectRemoval(RakNet::RakPeerInterface *peer) : World
void PacketObjectRemoval::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send)
{
WorldPacket::Packet(bs, event, send);
RW(*event->CellRef(), send);
}