From afbafdf8062c00fc473d23e29867509e1c6ce703 Mon Sep 17 00:00:00 2001 From: Koncord Date: Mon, 5 Mar 2018 15:15:39 +0800 Subject: [PATCH] [Server] Add PreReading virtual method add "const" qualifier to exteriorCellPattern --- apps/openmw-mp/Utils.cpp | 4 +++- apps/openmw-mp/processors/PlayerProcessor.cpp | 7 ++++++- apps/openmw-mp/processors/PlayerProcessor.hpp | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/openmw-mp/Utils.cpp b/apps/openmw-mp/Utils.cpp index 921e45599..5ce7addad 100644 --- a/apps/openmw-mp/Utils.cpp +++ b/apps/openmw-mp/Utils.cpp @@ -14,6 +14,7 @@ const vector Utils::split(const string &str, int delimiter) vector result; for (const auto &symb : str) + { if (symb != delimiter) buffer += symb; else if (!buffer.empty()) @@ -21,6 +22,7 @@ const vector Utils::split(const string &str, int delimiter) result.push_back(move(buffer)); buffer.clear(); } + } if (!buffer.empty()) result.push_back(move(buffer)); @@ -32,7 +34,7 @@ ESM::Cell Utils::getCellFromDescription(const std::string &cellDescription) ESM::Cell cell; cell.blank(); - static regex exteriorCellPattern("^(-?\\d+), (-?\\d+)$"); + static const regex exteriorCellPattern("^(-?\\d+), (-?\\d+)$"); smatch baseMatch; if (regex_match(cellDescription, baseMatch, exteriorCellPattern)) diff --git a/apps/openmw-mp/processors/PlayerProcessor.cpp b/apps/openmw-mp/processors/PlayerProcessor.cpp index e6753f073..a478dce97 100644 --- a/apps/openmw-mp/processors/PlayerProcessor.cpp +++ b/apps/openmw-mp/processors/PlayerProcessor.cpp @@ -20,10 +20,15 @@ bool PlayerProcessor::Process(RakNet::Packet &packet) noexcept PlayerPacket *myPacket = Networking::get().getPlayerPacketController()->GetPacket(packet.data[0]); myPacket->setPlayer(player.get()); - LOG_MESSAGE_SIMPLE(Log::LOG_TRACE, "Processing %s from %s", processor.second->strPacketID.c_str(), player->npc.mName.c_str()); + + LOG_MESSAGE_SIMPLE(Log::LOG_TRACE, "Processing %s from %s", processor.second->strPacketID.c_str(), + player->npc.mName.c_str()); if (!processor.second->avoidReading) + { + processor.second->PreReading(*myPacket, player); myPacket->Read(); + } processor.second->Do(*myPacket, player); return true; diff --git a/apps/openmw-mp/processors/PlayerProcessor.hpp b/apps/openmw-mp/processors/PlayerProcessor.hpp index e4e69779e..89e321f4b 100644 --- a/apps/openmw-mp/processors/PlayerProcessor.hpp +++ b/apps/openmw-mp/processors/PlayerProcessor.hpp @@ -18,6 +18,7 @@ namespace mwmp { public: + virtual void PreReading(PlayerPacket &packet, const std::shared_ptr &player){}; virtual void Do(PlayerPacket &packet, const std::shared_ptr &player) = 0; static bool Process(RakNet::Packet &packet) noexcept;