[Server] Add PreReading virtual method

add "const" qualifier to exteriorCellPattern
sol2-server-rewrite
Koncord 7 years ago
parent d0eef7c98e
commit afbafdf806

@ -14,6 +14,7 @@ const vector<string> Utils::split(const string &str, int delimiter)
vector<string> result; vector<string> result;
for (const auto &symb : str) for (const auto &symb : str)
{
if (symb != delimiter) if (symb != delimiter)
buffer += symb; buffer += symb;
else if (!buffer.empty()) else if (!buffer.empty())
@ -21,6 +22,7 @@ const vector<string> Utils::split(const string &str, int delimiter)
result.push_back(move(buffer)); result.push_back(move(buffer));
buffer.clear(); buffer.clear();
} }
}
if (!buffer.empty()) if (!buffer.empty())
result.push_back(move(buffer)); result.push_back(move(buffer));
@ -32,7 +34,7 @@ ESM::Cell Utils::getCellFromDescription(const std::string &cellDescription)
ESM::Cell cell; ESM::Cell cell;
cell.blank(); cell.blank();
static regex exteriorCellPattern("^(-?\\d+), (-?\\d+)$"); static const regex exteriorCellPattern("^(-?\\d+), (-?\\d+)$");
smatch baseMatch; smatch baseMatch;
if (regex_match(cellDescription, baseMatch, exteriorCellPattern)) if (regex_match(cellDescription, baseMatch, exteriorCellPattern))

@ -20,10 +20,15 @@ bool PlayerProcessor::Process(RakNet::Packet &packet) noexcept
PlayerPacket *myPacket = Networking::get().getPlayerPacketController()->GetPacket(packet.data[0]); PlayerPacket *myPacket = Networking::get().getPlayerPacketController()->GetPacket(packet.data[0]);
myPacket->setPlayer(player.get()); 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) if (!processor.second->avoidReading)
{
processor.second->PreReading(*myPacket, player);
myPacket->Read(); myPacket->Read();
}
processor.second->Do(*myPacket, player); processor.second->Do(*myPacket, player);
return true; return true;

@ -18,6 +18,7 @@ namespace mwmp
{ {
public: public:
virtual void PreReading(PlayerPacket &packet, const std::shared_ptr<Player> &player){};
virtual void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) = 0; virtual void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) = 0;
static bool Process(RakNet::Packet &packet) noexcept; static bool Process(RakNet::Packet &packet) noexcept;

Loading…
Cancel
Save