2017-03-31 18:36:24 +00:00
|
|
|
#ifndef OPENMW_PROCESSORPLAYERCELLCHANGE_HPP
|
|
|
|
#define OPENMW_PROCESSORPLAYERCELLCHANGE_HPP
|
|
|
|
|
2017-07-03 17:13:10 +00:00
|
|
|
#include "../PlayerProcessor.hpp"
|
2017-04-02 21:45:41 +00:00
|
|
|
#include "apps/openmw-mp/Networking.hpp"
|
|
|
|
#include "apps/openmw-mp/Script/Script.hpp"
|
2017-03-31 18:36:24 +00:00
|
|
|
#include <components/openmw-mp/Controllers/PlayerPacketController.hpp>
|
|
|
|
|
|
|
|
namespace mwmp
|
|
|
|
{
|
|
|
|
class ProcessorPlayerCellChange : public PlayerProcessor
|
|
|
|
{
|
|
|
|
PlayerPacketController *playerController;
|
|
|
|
public:
|
|
|
|
ProcessorPlayerCellChange()
|
|
|
|
{
|
|
|
|
BPP_INIT(ID_PLAYER_CELL_CHANGE)
|
2017-04-09 05:51:28 +00:00
|
|
|
playerController = Networking::get().getPlayerPacketController();
|
2017-03-31 18:36:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Do(PlayerPacket &packet, Player &player) override
|
|
|
|
{
|
2019-08-19 18:39:33 +00:00
|
|
|
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
|
|
|
|
LOG_APPEND(TimedLog::LOG_INFO, "- Moved to %s", player.cell.getDescription().c_str());
|
2017-03-31 18:36:24 +00:00
|
|
|
|
2018-09-25 23:40:21 +00:00
|
|
|
Script::Call<Script::CallbackIdentity("OnPlayerCellChange")>(player.getId());
|
2017-03-31 18:36:24 +00:00
|
|
|
|
2018-09-25 23:40:21 +00:00
|
|
|
player.exchangeFullInfo = true;
|
2018-04-26 18:56:14 +00:00
|
|
|
|
2018-09-25 23:40:21 +00:00
|
|
|
player.forEachLoaded([this](Player *pl, Player *other) {
|
2017-03-31 18:36:24 +00:00
|
|
|
|
2019-08-19 18:39:33 +00:00
|
|
|
LOG_APPEND(TimedLog::LOG_INFO, "- Started information exchange with %s", other->npc.mName.c_str());
|
2017-05-09 11:30:25 +00:00
|
|
|
|
2018-09-25 23:40:21 +00:00
|
|
|
other->exchangeFullInfo = true;
|
2018-04-26 18:56:14 +00:00
|
|
|
|
2018-09-25 23:40:21 +00:00
|
|
|
playerController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(other);
|
|
|
|
playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->setPlayer(other);
|
|
|
|
playerController->GetPacket(ID_PLAYER_POSITION)->setPlayer(other);
|
|
|
|
playerController->GetPacket(ID_PLAYER_SKILL)->setPlayer(other);
|
|
|
|
playerController->GetPacket(ID_PLAYER_EQUIPMENT)->setPlayer(other);
|
|
|
|
playerController->GetPacket(ID_PLAYER_ANIM_FLAGS)->setPlayer(other);
|
|
|
|
playerController->GetPacket(ID_PLAYER_SHAPESHIFT)->setPlayer(other);
|
2017-05-09 11:30:25 +00:00
|
|
|
|
2018-09-25 23:40:21 +00:00
|
|
|
playerController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->Send(pl->guid);
|
|
|
|
playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(pl->guid);
|
|
|
|
playerController->GetPacket(ID_PLAYER_POSITION)->Send(pl->guid);
|
|
|
|
playerController->GetPacket(ID_PLAYER_SKILL)->Send(pl->guid);
|
|
|
|
playerController->GetPacket(ID_PLAYER_EQUIPMENT)->Send(pl->guid);
|
|
|
|
playerController->GetPacket(ID_PLAYER_ANIM_FLAGS)->Send(pl->guid);
|
|
|
|
playerController->GetPacket(ID_PLAYER_SHAPESHIFT)->Send(pl->guid);
|
2017-05-09 11:30:25 +00:00
|
|
|
|
2018-09-25 23:40:21 +00:00
|
|
|
playerController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(pl);
|
|
|
|
playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->setPlayer(pl);
|
|
|
|
playerController->GetPacket(ID_PLAYER_SKILL)->setPlayer(pl);
|
|
|
|
playerController->GetPacket(ID_PLAYER_EQUIPMENT)->setPlayer(pl);
|
|
|
|
playerController->GetPacket(ID_PLAYER_ANIM_FLAGS)->setPlayer(pl);
|
|
|
|
playerController->GetPacket(ID_PLAYER_SHAPESHIFT)->setPlayer(pl);
|
2017-05-09 11:30:25 +00:00
|
|
|
|
2018-09-25 23:40:21 +00:00
|
|
|
playerController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->Send(other->guid);
|
|
|
|
playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(other->guid);
|
|
|
|
playerController->GetPacket(ID_PLAYER_SKILL)->Send(other->guid);
|
|
|
|
playerController->GetPacket(ID_PLAYER_EQUIPMENT)->Send(other->guid);
|
|
|
|
playerController->GetPacket(ID_PLAYER_ANIM_FLAGS)->Send(other->guid);
|
|
|
|
playerController->GetPacket(ID_PLAYER_SHAPESHIFT)->Send(other->guid);
|
2017-05-09 11:30:25 +00:00
|
|
|
|
2018-09-25 23:40:21 +00:00
|
|
|
other->exchangeFullInfo = false;
|
2018-04-26 18:56:14 +00:00
|
|
|
|
2019-08-19 18:39:33 +00:00
|
|
|
LOG_APPEND(TimedLog::LOG_INFO, "- Finished information exchange with %s", other->npc.mName.c_str());
|
2018-09-25 23:40:21 +00:00
|
|
|
});
|
2017-03-31 18:36:24 +00:00
|
|
|
|
2018-09-25 23:40:21 +00:00
|
|
|
playerController->GetPacket(ID_PLAYER_POSITION)->setPlayer(&player);
|
|
|
|
playerController->GetPacket(ID_PLAYER_POSITION)->Send();
|
|
|
|
packet.setPlayer(&player);
|
|
|
|
packet.Send(true); //send to other clients
|
2017-03-31 18:36:24 +00:00
|
|
|
|
2019-08-19 18:39:33 +00:00
|
|
|
LOG_APPEND(TimedLog::LOG_INFO, "- Finished processing ID_PLAYER_CELL_CHANGE", player.cell.getDescription().c_str());
|
2017-03-31 18:36:24 +00:00
|
|
|
|
2018-09-25 23:40:21 +00:00
|
|
|
player.exchangeFullInfo = false;
|
2017-03-31 18:36:24 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //OPENMW_PROCESSORPLAYERCELLCHANGE_HPP
|