1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-26 19:39:40 +00:00
openmw-tes3mp/apps/openmw-mp/processors/world/ProcessorContainer.hpp
David Cernat 3d5860d6f4 Merge pull request #396 from TES3MP/0.6.3 while resolving conflicts
Conflicts:
	apps/openmw-mp/Player.cpp
	apps/openmw-mp/Script/Functions/Settings.cpp
	apps/openmw-mp/Script/Functions/Settings.hpp
	apps/openmw-mp/Script/Functions/World.cpp
	apps/openmw-mp/Script/Functions/World.hpp
	apps/openmw/mwgui/container.cpp
	apps/openmw/mwmp/LocalActor.cpp
	apps/openmw/mwmp/LocalPlayer.cpp
	apps/openmw/mwmp/WorldEvent.cpp
	apps/openmw/mwmp/processors/world/ProcessorContainer.hpp
	components/openmw-mp/Base/BaseEvent.hpp
	components/openmw-mp/Log.cpp
	components/openmw-mp/Log.hpp
2018-03-30 09:32:43 +03:00

50 lines
1.8 KiB
C++

#ifndef OPENMW_PROCESSORCONTAINER_HPP
#define OPENMW_PROCESSORCONTAINER_HPP
#include <apps/openmw-mp/Object.hpp>
#include "../WorldProcessor.hpp"
namespace mwmp
{
class ProcessorContainer final: public WorldProcessor
{
public:
ProcessorContainer()
{
BPP_INIT(ID_CONTAINER)
}
void Do(WorldPacket &packet, const std::shared_ptr<Player> &player, BaseEvent &event) override
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player->npc.mName.c_str());
LOG_APPEND(Log::LOG_INFO, "- action: %i", (int) event.action);
// Until we have a timestamp-based system, send packets pertaining to more
// than one container (i.e. replies to server requests for container contents)
// only to players who have the container's cell loaded
if (event.action == BaseEvent::Action::Set && event.worldObjects.size() > 1)
{
Cell *serverCell = CellController::get().getCell(event.cell);
if (serverCell != nullptr)
serverCell->sendToLoaded(&packet, &event);
}
// Otherwise, don't have any hardcoded sync and expect Lua scripts to forward
// container packets to ensure their integrity based on what exists in the
// server data
auto objCtrl = Networking::get().getState().getObjectCtrl();
auto containers = objCtrl.copyContainers(event);
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_CONTAINER>(player, containers);
Networking::get().getState().getObjectCtrl().sendContainers(player, containers, event.cell);
LOG_APPEND(Log::LOG_INFO, "- Finished processing ID_CONTAINER");
}
};
}
#endif //OPENMW_PROCESSORCONTAINER_HPP