2017-04-02 21:46:46 +00:00
|
|
|
#ifndef OPENMW_PROCESSORCONTAINER_HPP
|
|
|
|
#define OPENMW_PROCESSORCONTAINER_HPP
|
|
|
|
|
|
|
|
#include "apps/openmw-mp/WorldProcessor.hpp"
|
|
|
|
|
|
|
|
namespace mwmp
|
|
|
|
{
|
|
|
|
class ProcessorContainer : public WorldProcessor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ProcessorContainer()
|
|
|
|
{
|
2017-04-02 21:49:23 +00:00
|
|
|
BPP_INIT(ID_CONTAINER)
|
2017-04-02 21:46:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Do(WorldPacket &packet, Player &player, BaseEvent &event) override
|
|
|
|
{
|
2017-04-08 09:00:07 +00:00
|
|
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
|
2017-04-04 05:24:11 +00:00
|
|
|
LOG_APPEND(Log::LOG_INFO, "- action: %i", event.action);
|
2017-04-02 21:46:46 +00:00
|
|
|
|
|
|
|
// 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
|
2017-05-06 18:57:14 +00:00
|
|
|
if (event.action == BaseEvent::SET && event.worldObjectCount > 1)
|
2017-04-04 04:21:02 +00:00
|
|
|
{
|
|
|
|
Cell *serverCell = CellController::get()->getCell(&event.cell);
|
|
|
|
|
|
|
|
if (serverCell != nullptr)
|
|
|
|
serverCell->sendToLoaded(&packet, &event);
|
|
|
|
}
|
2017-04-02 21:46:46 +00:00
|
|
|
else
|
|
|
|
packet.Send(true);
|
|
|
|
|
|
|
|
Script::Call<Script::CallbackIdentity("OnContainer")>(player.getId(), event.cell.getDescription().c_str());
|
|
|
|
|
|
|
|
LOG_APPEND(Log::LOG_INFO, "- Finished processing ID_CONTAINER");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //OPENMW_PROCESSORCONTAINER_HPP
|