forked from mirror/openmw-tes3mp
[Client] Clean up getting and resetting of WorldEvent
This commit is contained in:
parent
d7a760490e
commit
9759764699
15 changed files with 59 additions and 38 deletions
|
@ -107,7 +107,8 @@ namespace MWGui
|
|||
Send an ID_CONTAINER packet every time an item starts being dragged
|
||||
from a container
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->reset();
|
||||
worldEvent->cell = *mPtr.getCell()->getCell();
|
||||
worldEvent->action = mwmp::BaseEvent::REMOVE;
|
||||
|
||||
|
@ -168,7 +169,8 @@ namespace MWGui
|
|||
|
||||
Send an ID_CONTAINER packet every time an item is dropped in a container
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->reset();
|
||||
worldEvent->cell = *mPtr.getCell()->getCell();
|
||||
worldEvent->action = mwmp::BaseEvent::ADD;
|
||||
|
||||
|
@ -325,7 +327,8 @@ namespace MWGui
|
|||
Send an ID_CONTAINER packet every time the Take All button is used on
|
||||
a container
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->reset();
|
||||
worldEvent->cell = *mPtr.getCell()->getCell();
|
||||
worldEvent->action = mwmp::BaseEvent::SET;
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace MWGui
|
|||
Send an ID_OBJECT_PLACE packet every time an object is dropped into the world from
|
||||
the inventory screen
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->sendObjectPlace(dropped);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
|
|
@ -644,7 +644,7 @@ namespace MWGui
|
|||
Send an ID_PLAYER_INVENTORY packet as well because of the item thus gained
|
||||
by the player
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->sendObjectDelete(object);
|
||||
mwmp::Main::get().getLocalPlayer()->sendInventory();
|
||||
/*
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace MWMechanics
|
|||
|
||||
Send an ID_OBJECT_UNLOCK packet every time an object is unlocked
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->sendObjectUnlock(lock);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
|
|
@ -1067,11 +1067,8 @@ LocalPlayer *Networking::getLocalPlayer()
|
|||
return mwmp::Main::get().getLocalPlayer();
|
||||
}
|
||||
|
||||
WorldEvent *Networking::resetWorldEvent()
|
||||
WorldEvent *Networking::getWorldEvent()
|
||||
{
|
||||
worldEvent.cell.blank();
|
||||
worldEvent.objectChanges.objects.clear();
|
||||
worldEvent.guid = getLocalPlayer()->guid;
|
||||
return &worldEvent;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@ namespace mwmp
|
|||
|
||||
bool isConnected();
|
||||
|
||||
WorldEvent *resetWorldEvent();
|
||||
WorldEvent *getWorldEvent();
|
||||
LocalPlayer *getLocalPlayer();
|
||||
|
||||
private:
|
||||
bool connected;
|
||||
|
@ -55,7 +56,6 @@ namespace mwmp
|
|||
void processPlayerPacket(RakNet::Packet *packet);
|
||||
void processWorldPacket(RakNet::Packet *packet);
|
||||
void receiveMessage(RakNet::Packet *packet);
|
||||
LocalPlayer *getLocalPlayer();
|
||||
|
||||
void preInit(std::vector<std::string> &content, Files::Collections &collections);
|
||||
};
|
||||
|
|
|
@ -35,6 +35,13 @@ Networking *WorldEvent::getNetworking()
|
|||
return mwmp::Main::get().getNetworking();
|
||||
}
|
||||
|
||||
void WorldEvent::reset()
|
||||
{
|
||||
cell.blank();
|
||||
objectChanges.objects.clear();
|
||||
guid = mwmp::Main::get().getNetworking()->getLocalPlayer()->guid;
|
||||
}
|
||||
|
||||
void WorldEvent::addObject(WorldObject worldObject)
|
||||
{
|
||||
objectChanges.objects.push_back(worldObject);
|
||||
|
@ -42,9 +49,9 @@ void WorldEvent::addObject(WorldObject worldObject)
|
|||
|
||||
void WorldEvent::sendActors(MWWorld::CellStore* cellStore)
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *cellStore->getCell();
|
||||
worldEvent->action = BaseEvent::SET;
|
||||
reset();
|
||||
cell = *cellStore->getCell();
|
||||
action = BaseEvent::SET;
|
||||
|
||||
MWWorld::CellRefList<ESM::NPC> *npcList = cellStore->getNpcs();
|
||||
|
||||
|
@ -58,7 +65,7 @@ void WorldEvent::sendActors(MWWorld::CellStore* cellStore)
|
|||
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
|
||||
worldObject.mpNum = ptr.getCellRef().getMpNum();
|
||||
|
||||
worldEvent->addObject(worldObject);
|
||||
addObject(worldObject);
|
||||
}
|
||||
|
||||
MWWorld::CellRefList<ESM::Creature> *creatureList = cellStore->getCreatures();
|
||||
|
@ -73,18 +80,18 @@ void WorldEvent::sendActors(MWWorld::CellStore* cellStore)
|
|||
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
|
||||
worldObject.mpNum = ptr.getCellRef().getMpNum();
|
||||
|
||||
worldEvent->addObject(worldObject);
|
||||
addObject(worldObject);
|
||||
}
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_ACTOR_LIST)->setEvent(worldEvent);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_ACTOR_LIST)->setEvent(this);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_ACTOR_LIST)->Send();
|
||||
}
|
||||
|
||||
void WorldEvent::sendContainers(MWWorld::CellStore* cellStore)
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *cellStore->getCell();
|
||||
worldEvent->action = BaseEvent::SET;
|
||||
reset();
|
||||
cell = *cellStore->getCell();
|
||||
action = BaseEvent::SET;
|
||||
|
||||
MWWorld::CellRefList<ESM::Container> *containerList = cellStore->getContainers();
|
||||
|
||||
|
@ -112,16 +119,17 @@ void WorldEvent::sendContainers(MWWorld::CellStore* cellStore)
|
|||
worldObject.containerChanges.items.push_back(containerItem);
|
||||
}
|
||||
|
||||
worldEvent->addObject(worldObject);
|
||||
addObject(worldObject);
|
||||
}
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->setEvent(worldEvent);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->setEvent(this);
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send();
|
||||
}
|
||||
|
||||
|
||||
void WorldEvent::sendObjectPlace(MWWorld::Ptr ptr)
|
||||
{
|
||||
reset();
|
||||
cell = *ptr.getCell()->getCell();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
|
@ -152,6 +160,7 @@ void WorldEvent::sendObjectPlace(MWWorld::Ptr ptr)
|
|||
|
||||
void WorldEvent::sendObjectDelete(MWWorld::Ptr ptr)
|
||||
{
|
||||
reset();
|
||||
cell = *ptr.getCell()->getCell();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
|
@ -166,6 +175,7 @@ void WorldEvent::sendObjectDelete(MWWorld::Ptr ptr)
|
|||
|
||||
void WorldEvent::sendObjectLock(MWWorld::Ptr ptr, int lockLevel)
|
||||
{
|
||||
reset();
|
||||
cell = *ptr.getCell()->getCell();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
|
@ -181,6 +191,7 @@ void WorldEvent::sendObjectLock(MWWorld::Ptr ptr, int lockLevel)
|
|||
|
||||
void WorldEvent::sendObjectUnlock(MWWorld::Ptr ptr)
|
||||
{
|
||||
reset();
|
||||
cell = *ptr.getCell()->getCell();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
|
@ -195,6 +206,7 @@ void WorldEvent::sendObjectUnlock(MWWorld::Ptr ptr)
|
|||
|
||||
void WorldEvent::sendObjectScale(MWWorld::Ptr ptr, int scale)
|
||||
{
|
||||
reset();
|
||||
cell = *ptr.getCell()->getCell();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
|
@ -210,6 +222,7 @@ void WorldEvent::sendObjectScale(MWWorld::Ptr ptr, int scale)
|
|||
|
||||
void WorldEvent::sendObjectAnimPlay(MWWorld::Ptr ptr, std::string group, int mode)
|
||||
{
|
||||
reset();
|
||||
cell = *ptr.getCell()->getCell();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
|
@ -226,6 +239,7 @@ void WorldEvent::sendObjectAnimPlay(MWWorld::Ptr ptr, std::string group, int mod
|
|||
|
||||
void WorldEvent::sendDoorState(MWWorld::Ptr ptr, int state)
|
||||
{
|
||||
reset();
|
||||
cell = *ptr.getCell()->getCell();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
|
@ -245,6 +259,7 @@ void WorldEvent::sendDoorState(MWWorld::Ptr ptr, int state)
|
|||
|
||||
void WorldEvent::sendMusicPlay(std::string filename)
|
||||
{
|
||||
reset();
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.filename = filename;
|
||||
addObject(worldObject);
|
||||
|
@ -255,6 +270,7 @@ void WorldEvent::sendMusicPlay(std::string filename)
|
|||
|
||||
void WorldEvent::sendVideoPlay(std::string filename, bool allowSkipping)
|
||||
{
|
||||
reset();
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.filename = filename;
|
||||
worldObject.allowSkipping = allowSkipping;
|
||||
|
@ -266,6 +282,7 @@ void WorldEvent::sendVideoPlay(std::string filename, bool allowSkipping)
|
|||
|
||||
void WorldEvent::sendScriptLocalShort(MWWorld::Ptr ptr, int index, int shortVal)
|
||||
{
|
||||
reset();
|
||||
cell = *ptr.getCell()->getCell();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
|
@ -286,6 +303,7 @@ void WorldEvent::sendScriptLocalShort(MWWorld::Ptr ptr, int index, int shortVal)
|
|||
|
||||
void WorldEvent::sendScriptLocalFloat(MWWorld::Ptr ptr, int index, float floatVal)
|
||||
{
|
||||
reset();
|
||||
cell = *ptr.getCell()->getCell();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
|
@ -306,6 +324,7 @@ void WorldEvent::sendScriptLocalFloat(MWWorld::Ptr ptr, int index, float floatVa
|
|||
|
||||
void WorldEvent::sendScriptMemberShort(std::string refId, int index, int shortVal)
|
||||
{
|
||||
reset();
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.refId = refId;
|
||||
worldObject.index = index;
|
||||
|
@ -321,6 +340,7 @@ void WorldEvent::sendScriptMemberShort(std::string refId, int index, int shortVa
|
|||
|
||||
void WorldEvent::sendScriptGlobalShort(std::string varName, int shortVal)
|
||||
{
|
||||
reset();
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.varName = varName;
|
||||
worldObject.shortVal = shortVal;
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace mwmp
|
|||
WorldEvent();
|
||||
virtual ~WorldEvent();
|
||||
|
||||
void reset();
|
||||
void addObject(WorldObject worldObject);
|
||||
|
||||
void sendActors(MWWorld::CellStore* cellStore);
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace MWScript
|
|||
*/
|
||||
if (mwmp::Main::isValidPacketScript(ptr.getClass().getScript(ptr)))
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->sendObjectAnimPlay(ptr, group, mode);
|
||||
}
|
||||
/*
|
||||
|
|
|
@ -202,7 +202,7 @@ namespace MWScript
|
|||
*/
|
||||
if (sendPackets)
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->sendScriptLocalShort(mReference, index, value);
|
||||
}
|
||||
/*
|
||||
|
@ -234,7 +234,7 @@ namespace MWScript
|
|||
*/
|
||||
if (sendPackets && value == (int) value)
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->sendScriptLocalFloat(mReference, index, value);
|
||||
}
|
||||
/*
|
||||
|
@ -291,7 +291,7 @@ namespace MWScript
|
|||
*/
|
||||
if (sendPackets)
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->sendScriptGlobalShort(name, value);
|
||||
}
|
||||
/*
|
||||
|
@ -626,7 +626,7 @@ namespace MWScript
|
|||
*/
|
||||
if (sendPackets && !global)
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->sendScriptMemberShort(id, index, value);
|
||||
}
|
||||
/*
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace MWScript
|
|||
Send an ID_VIDEO_PLAY packet every time a video is played
|
||||
through a script
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->sendVideoPlay(name, allowSkipping);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
@ -205,7 +205,7 @@ namespace MWScript
|
|||
Send an ID_OBJECT_LOCK packet every time an object is locked
|
||||
through a script
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->sendObjectLock(ptr, lockLevel);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
@ -243,7 +243,7 @@ namespace MWScript
|
|||
Send an ID_OBJECT_UNLOCK packet every time an object is unlocked
|
||||
through a script
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->sendObjectUnlock(ptr);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
@ -715,7 +715,7 @@ namespace MWScript
|
|||
Send an ID_OBJECT_DELETE packet every time an object is deleted
|
||||
through a script
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->sendObjectDelete(ptr);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace MWScript
|
|||
Send an ID_MUSIC_PLAY packet every time new music is streamed through
|
||||
a script
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->sendMusicPlay(sound);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace MWScript
|
|||
Send an ID_OBJECT_SCALE every time an object's scale is changed
|
||||
through a script
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->sendObjectScale(ptr, scale);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
@ -547,7 +547,7 @@ namespace MWScript
|
|||
Send an ID_OBJECT_PLACE packet every time an object is placed in the world
|
||||
through a script
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->sendObjectPlace(ptr);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace MWWorld
|
|||
Send an ID_PLAYER_INVENTORY packet as well because of the item thus gained
|
||||
by the player
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->sendObjectDelete(getTarget());
|
||||
mwmp::Main::get().getLocalPlayer()->sendInventory();
|
||||
/*
|
||||
|
|
|
@ -2324,7 +2324,7 @@ namespace MWWorld
|
|||
|
||||
Send an ID_DOOR_STATE packet every time a door is activated
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->sendDoorState(door, state);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
@ -2341,7 +2341,7 @@ namespace MWWorld
|
|||
|
||||
Send an ID_DOOR_STATE packet every time a door is activated
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->sendDoorState(door, state);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
|
Loading…
Reference in a new issue