2017-05-29 01:43:52 +00:00
|
|
|
#ifndef OPENMW_PROCESSOROBJECTSPAWN_HPP
|
|
|
|
#define OPENMW_PROCESSOROBJECTSPAWN_HPP
|
|
|
|
|
2017-07-03 17:13:10 +00:00
|
|
|
#include "../WorldProcessor.hpp"
|
2017-05-29 01:43:52 +00:00
|
|
|
#include <apps/openmw-mp/Networking.hpp>
|
|
|
|
|
|
|
|
namespace mwmp
|
|
|
|
{
|
|
|
|
class ProcessorObjectSpawn : public WorldProcessor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ProcessorObjectSpawn()
|
|
|
|
{
|
|
|
|
BPP_INIT(ID_OBJECT_SPAWN)
|
|
|
|
}
|
|
|
|
|
2017-08-27 16:15:56 +00:00
|
|
|
void Do(WorldPacket &packet, std::shared_ptr<Player> player, BaseEvent &event) override
|
2017-05-29 01:43:52 +00:00
|
|
|
{
|
2017-08-27 16:15:56 +00:00
|
|
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player->npc.mName.c_str());
|
2017-05-29 01:43:52 +00:00
|
|
|
|
|
|
|
for (unsigned int i = 0; i < event.worldObjectCount; i++)
|
|
|
|
{
|
|
|
|
event.worldObjects.at(i).mpNum = mwmp::Networking::getPtr()->incrementMpNum();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send this packet back to the original sender with the mpNum generation from above,
|
|
|
|
// then send it to the other players
|
|
|
|
packet.Send(false);
|
|
|
|
packet.Send(true);
|
|
|
|
|
2017-08-27 16:15:56 +00:00
|
|
|
auto objCtrl = Networking::get().getState().getObjectCtrl();
|
|
|
|
auto objects = objCtrl.copyObjects(event);
|
|
|
|
|
|
|
|
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_OBJECT_SCALE>(player, objects);
|
|
|
|
|
2017-08-28 19:34:36 +00:00
|
|
|
objCtrl.sendObjects(player, objects, event.cell);
|
2017-05-29 01:43:52 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //OPENMW_PROCESSOROBJECTSPAWN_HPP
|