From b76e00c66e680535025189ca731a6592a175c3b5 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Wed, 26 Sep 2018 02:40:21 +0300 Subject: [PATCH] [Server] Call OnPlayerCellChange script event near start of cell change This makes it possible to send custom records used by players for their equipment before the hardcoded exchange of equipment packets takes place. Additionally, remove the check for dead players because it has no real use and can potentially cause problems. --- .../player/ProcessorPlayerCellChange.hpp | 88 +++++++++---------- 1 file changed, 41 insertions(+), 47 deletions(-) diff --git a/apps/openmw-mp/processors/player/ProcessorPlayerCellChange.hpp b/apps/openmw-mp/processors/player/ProcessorPlayerCellChange.hpp index 459ebc248..6e607642f 100644 --- a/apps/openmw-mp/processors/player/ProcessorPlayerCellChange.hpp +++ b/apps/openmw-mp/processors/player/ProcessorPlayerCellChange.hpp @@ -25,67 +25,61 @@ namespace mwmp void Do(PlayerPacket &packet, Player &player) override { LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str()); + LOG_APPEND(Log::LOG_INFO, "- Moved to %s", player.cell.getDescription().c_str()); - if (!player.creatureStats.mDead) - { - LOG_APPEND(Log::LOG_INFO, "- Moved to %s", player.cell.getDescription().c_str()); + Script::Call(player.getId()); - player.exchangeFullInfo = true; + player.exchangeFullInfo = true; - player.forEachLoaded([this](Player *pl, Player *other) { + player.forEachLoaded([this](Player *pl, Player *other) { - LOG_APPEND(Log::LOG_INFO, "- Started information exchange with %s", other->npc.mName.c_str()); + LOG_APPEND(Log::LOG_INFO, "- Started information exchange with %s", other->npc.mName.c_str()); - other->exchangeFullInfo = true; + other->exchangeFullInfo = true; - 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); + 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); - 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); + 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); - 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); + 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); - 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); + 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); - other->exchangeFullInfo = false; + other->exchangeFullInfo = false; - LOG_APPEND(Log::LOG_INFO, "- Finished information exchange with %s", other->npc.mName.c_str()); - }); + LOG_APPEND(Log::LOG_INFO, "- Finished information exchange with %s", other->npc.mName.c_str()); + }); - playerController->GetPacket(ID_PLAYER_POSITION)->setPlayer(&player); - playerController->GetPacket(ID_PLAYER_POSITION)->Send(); - packet.setPlayer(&player); - packet.Send(true); //send to other clients + playerController->GetPacket(ID_PLAYER_POSITION)->setPlayer(&player); + playerController->GetPacket(ID_PLAYER_POSITION)->Send(); + packet.setPlayer(&player); + packet.Send(true); //send to other clients - Script::Call(player.getId()); + LOG_APPEND(Log::LOG_INFO, "- Finished processing ID_PLAYER_CELL_CHANGE", player.cell.getDescription().c_str()); - LOG_APPEND(Log::LOG_INFO, "- Finished processing ID_PLAYER_CELL_CHANGE", player.cell.getDescription().c_str()); - - player.exchangeFullInfo = false; - } - else - LOG_APPEND(Log::LOG_INFO, "- Ignored because %s is dead", player.npc.mName.c_str()); + player.exchangeFullInfo = false; } }; }