1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-03 08:06:43 +00:00
openmw-tes3mp/apps/openmw-mp/processors/WorldstateProcessor.cpp
David Cernat 3f7e163c92 Merge pull request #439 from TES3MP/0.6.3 while resolving conflicts
Conflicts:
	apps/openmw-mp/CMakeLists.txt
	apps/openmw-mp/Script/Functions/GUI.cpp
	apps/openmw-mp/Script/Functions/GUI.hpp
	apps/openmw-mp/Script/Functions/Worldstate.cpp
	apps/openmw-mp/Script/Functions/Worldstate.hpp
	apps/openmw-mp/processors/worldstate/ProcessorRecordDynamic.hpp
	apps/openmw/mwmp/processors/worldstate/ProcessorRecordDynamic.hpp
	components/CMakeLists.txt
	components/openmw-mp/Packets/Player/PacketGUIBoxes.cpp
2018-05-25 06:34:07 +03:00

40 lines
1.2 KiB
C++

#include "WorldstateProcessor.hpp"
#include "Networking.hpp"
using namespace mwmp;
template<class T>
typename BasePacketProcessor<T>::processors_t BasePacketProcessor<T>::processors;
void WorldstateProcessor::Do(WorldstatePacket &packet, const std::shared_ptr<Player> &player, BaseWorldstate &worldstate)
{
packet.Send(true);
}
bool WorldstateProcessor::Process(RakNet::Packet &packet, BaseWorldstate &worldstate) noexcept
{
worldstate.guid = packet.guid;
for (auto &processor : processors)
{
if (processor.first == packet.data[0])
{
auto player = Players::getPlayerByGUID(packet.guid);
WorldstatePacket *myPacket = Networking::get().getWorldstatePacketController()->GetPacket(packet.data[0]);
myPacket->setWorldstate(&worldstate);
worldstate.isValid = true;
if (!processor.second->avoidReading)
myPacket->Read();
if (worldstate.isValid)
processor.second->Do(*myPacket, player, worldstate);
else
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Received %s that failed integrity check and was ignored!", processor.second->strPacketID.c_str());
return true;
}
}
return false;
}