forked from mirror/openmw-tes3mp
This commit changes the style of tes3mp serverside scripting mods. Short list of changes: * Break compatibility with old server mods * OOP style lua API * Basic dependency checker, allowing the installation of multiple server mods without changing configs * Remove support for C++ plugins * Change outdated LuaBridge to [sol2](https://github.com/ThePhD/sol2); * Support GCC, Clang and MSVC compilers * New environment variables: "TES3MP_SERVER_DIR" and "TES3MP_SERVER_USERDIR"; * New entity "Command controller" for registering new chat commands; * New Event system * Simplified Timer API * All Lua mods now run in their own environments * Add global namespace - Data that can be used for communicating between mods * Player and Actor inherit base class NetActor
84 lines
4.2 KiB
C++
84 lines
4.2 KiB
C++
//
|
|
// Created by koncord on 01.04.17.
|
|
//
|
|
|
|
#ifndef OPENMW_PROCESSORPLAYERCELLCHANGE_HPP
|
|
#define OPENMW_PROCESSORPLAYERCELLCHANGE_HPP
|
|
|
|
#include "../PlayerProcessor.hpp"
|
|
#include "apps/openmw-mp/Networking.hpp"
|
|
#include <components/openmw-mp/Controllers/PlayerPacketController.hpp>
|
|
|
|
namespace mwmp
|
|
{
|
|
class ProcessorPlayerCellChange : public PlayerProcessor
|
|
{
|
|
PlayerPacketController *playerController;
|
|
public:
|
|
ProcessorPlayerCellChange()
|
|
{
|
|
BPP_INIT(ID_PLAYER_CELL_CHANGE)
|
|
playerController = Networking::get().getPlayerPacketController();
|
|
}
|
|
|
|
void Do(PlayerPacket &packet, std::shared_ptr<Player> player) override
|
|
{
|
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player->npc.mName.c_str());
|
|
|
|
if (!player->creatureStats.mDead)
|
|
{
|
|
LOG_APPEND(Log::LOG_INFO, "- Moved to %s", player->cell.getDescription().c_str());
|
|
|
|
player->forEachLoaded([this](Player *pl, Player *other) {
|
|
|
|
LOG_APPEND(Log::LOG_INFO, "- Started information exchange with %s", other->npc.mName.c_str());
|
|
|
|
playerController->GetPacket(ID_PLAYER_SHAPESHIFT)->setPlayer(other);
|
|
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)->Send(pl->guid);
|
|
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)->setPlayer(pl);
|
|
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)->Send(other->guid);
|
|
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);
|
|
|
|
LOG_APPEND(Log::LOG_INFO, "- Finished information exchange with %s", other->npc.mName.c_str());
|
|
});
|
|
|
|
playerController->GetPacket(ID_PLAYER_POSITION)->setPlayer(player.get());
|
|
playerController->GetPacket(ID_PLAYER_POSITION)->Send();
|
|
packet.setPlayer(player.get());
|
|
packet.Send(true); //send to other clients
|
|
|
|
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_PLAYER_CELLCHANGE>(player);
|
|
|
|
LOG_APPEND(Log::LOG_INFO, "- Finished processing ID_PLAYER_CELL_CHANGE", player->cell.getDescription().c_str());
|
|
}
|
|
else
|
|
LOG_APPEND(Log::LOG_INFO, "- Ignored because %s is dead", player->npc.mName.c_str());
|
|
}
|
|
};
|
|
}
|
|
|
|
#endif //OPENMW_PROCESSORPLAYERCELLCHANGE_HPP
|