[Server] Move packet.Read() to parent

0.6.1
Koncord 8 years ago
parent 4daf471874
commit 47924f5bb0

@ -32,6 +32,9 @@ bool PlayerProcessor::Process(RakNet::Packet &packet) noexcept
PlayerPacket *myPacket = Networking::get().getPlayerController()->GetPacket(packet.data[0]); PlayerPacket *myPacket = Networking::get().getPlayerController()->GetPacket(packet.data[0]);
myPacket->setPlayer(player); myPacket->setPlayer(player);
if(!processor.second->dontRead)
myPacket->Read();
processor.second->Do(*myPacket, *player); processor.second->Do(*myPacket, *player);
return true; return true;
} }

@ -41,7 +41,8 @@ bool WorldProcessor::Process(RakNet::Packet &packet) noexcept
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received %s from %s", processor.second->strPacketID.c_str(), LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received %s from %s", processor.second->strPacketID.c_str(),
player->npc.mName.c_str()); player->npc.mName.c_str());
myPacket->setEvent(&baseEvent); myPacket->setEvent(&baseEvent);
myPacket->Read(); if(!processor.second->dontRead)
myPacket->Read();
processor.second->Do(*myPacket, *player, baseEvent); processor.second->Do(*myPacket, *player, baseEvent);
return true; return true;
} }

@ -22,7 +22,6 @@ namespace mwmp
{ {
DEBUG_PRINTF(strPacketID.c_str()); DEBUG_PRINTF(strPacketID.c_str());
packet.Read();
Script::CallBackReturn<Script::CallbackIdentity("OnPlayerSendMessage")> result = true; Script::CallBackReturn<Script::CallbackIdentity("OnPlayerSendMessage")> result = true;
Script::Call<Script::CallbackIdentity("OnPlayerSendMessage")>(result, player.getId(), player.chatMessage.c_str()); Script::Call<Script::CallbackIdentity("OnPlayerSendMessage")>(result, player.getId(), player.chatMessage.c_str());

@ -22,8 +22,6 @@ namespace mwmp
{ {
DEBUG_PRINTF(strPacketID.c_str()); DEBUG_PRINTF(strPacketID.c_str());
packet.Read();
Script::Call<Script::CallbackIdentity("OnGUIAction")>(player.getId(), (int)player.guiMessageBox.id, Script::Call<Script::CallbackIdentity("OnGUIAction")>(player.getId(), (int)player.guiMessageBox.id,
player.guiMessageBox.data.c_str()); player.guiMessageBox.data.c_str());
} }

@ -22,9 +22,6 @@ namespace mwmp
{ {
if (!player.creatureStats.mDead) if (!player.creatureStats.mDead)
{ {
packet.Read();
//packet.Send(&player, true);
Script::Call<Script::CallbackIdentity("OnPlayerLevelChange")>(player.getId()); Script::Call<Script::CallbackIdentity("OnPlayerLevelChange")>(player.getId());
} }
} }

@ -26,8 +26,6 @@ namespace mwmp
if (!player.creatureStats.mDead) if (!player.creatureStats.mDead)
{ {
packet.Read();
Player *target = Players::getPlayer(player.attack.target); Player *target = Players::getPlayer(player.attack.target);
if (target == nullptr) if (target == nullptr)

@ -22,7 +22,6 @@ namespace mwmp
{ {
if (!player.creatureStats.mDead) if (!player.creatureStats.mDead)
{ {
packet.Read();
//myPacket->Send(player, true); //myPacket->Send(player, true);
player.sendToLoaded(&packet); player.sendToLoaded(&packet);

@ -28,8 +28,6 @@ namespace mwmp
if (!player.creatureStats.mDead) if (!player.creatureStats.mDead)
{ {
packet.Read();
LOG_APPEND(Log::LOG_INFO, "- Moved to %s", player.cell.getDescription().c_str()); LOG_APPEND(Log::LOG_INFO, "- Moved to %s", player.cell.getDescription().c_str());
player.forEachLoaded([this](Player *pl, Player *other) { player.forEachLoaded([this](Player *pl, Player *other) {

@ -27,8 +27,6 @@ namespace mwmp
{ {
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID, player.npc.mName.c_str()); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID, player.npc.mName.c_str());
packet.Read();
CellController::get()->update(&player); CellController::get()->update(&player);
Script::Call<Script::CallbackIdentity("OnPlayerCellState")>(player.getId()); Script::Call<Script::CallbackIdentity("OnPlayerCellState")>(player.getId());

@ -21,8 +21,6 @@ namespace mwmp
void Do(PlayerPacket &packet, Player &player) override void Do(PlayerPacket &packet, Player &player) override
{ {
DEBUG_PRINTF(strPacketID.c_str()); DEBUG_PRINTF(strPacketID.c_str());
packet.Read();
} }
}; };
} }

@ -22,8 +22,6 @@ namespace mwmp
{ {
DEBUG_PRINTF(strPacketID.c_str()); DEBUG_PRINTF(strPacketID.c_str());
packet.Read();
if (player.charGenStage.current == player.charGenStage.end && player.charGenStage.current != 0) if (player.charGenStage.current == player.charGenStage.end && player.charGenStage.current != 0)
Script::Call<Script::CallbackIdentity("OnPlayerEndCharGen")>(player.getId()); Script::Call<Script::CallbackIdentity("OnPlayerEndCharGen")>(player.getId());
} }

@ -17,6 +17,7 @@ namespace mwmp
ProcessorPlayerDeath() ProcessorPlayerDeath()
{ {
BPP_INIT(ID_PLAYER_DEATH) BPP_INIT(ID_PLAYER_DEATH)
dontRead = true;
} }
void Do(PlayerPacket &packet, Player &player) override void Do(PlayerPacket &packet, Player &player) override

@ -22,9 +22,6 @@ namespace mwmp
{ {
DEBUG_PRINTF(strPacketID.c_str()); DEBUG_PRINTF(strPacketID.c_str());
packet.Read();
//packet.Send(&player, true);
player.sendToLoaded(&packet); player.sendToLoaded(&packet);
} }
}; };

@ -22,8 +22,6 @@ namespace mwmp
{ {
DEBUG_PRINTF(strPacketID.c_str()); DEBUG_PRINTF(strPacketID.c_str());
packet.Read();
player.sendToLoaded(&packet); player.sendToLoaded(&packet);
} }
}; };

@ -22,9 +22,6 @@ namespace mwmp
{ {
DEBUG_PRINTF(strPacketID.c_str()); DEBUG_PRINTF(strPacketID.c_str());
packet.Read();
//myPacket->Send(player, true);
player.sendToLoaded(&packet); player.sendToLoaded(&packet);
Script::Call<Script::CallbackIdentity("OnPlayerEquipmentChange")>(player.getId()); Script::Call<Script::CallbackIdentity("OnPlayerEquipmentChange")>(player.getId());

@ -21,8 +21,6 @@ namespace mwmp
{ {
DEBUG_PRINTF(strPacketID.c_str()); DEBUG_PRINTF(strPacketID.c_str());
packet.Read();
Script::Call<Script::CallbackIdentity("OnPlayerInventoryChange")>(player.getId()); Script::Call<Script::CallbackIdentity("OnPlayerInventoryChange")>(player.getId());
} }
}; };

@ -22,8 +22,6 @@ namespace mwmp
{ {
DEBUG_PRINTF(strPacketID.c_str()); DEBUG_PRINTF(strPacketID.c_str());
packet.Read();
Script::Call<Script::CallbackIdentity("OnPlayerJournalChange")>(player.getId()); Script::Call<Script::CallbackIdentity("OnPlayerJournalChange")>(player.getId());
} }
}; };

@ -22,9 +22,6 @@ namespace mwmp
//DEBUG_PRINTF(strPacketID); //DEBUG_PRINTF(strPacketID);
if (!player.creatureStats.mDead) if (!player.creatureStats.mDead)
{ {
packet.Read();
//myPacket.Send(player, true); //send to other clients
player.sendToLoaded(&packet); player.sendToLoaded(&packet);
} }
} }

@ -16,6 +16,7 @@ namespace mwmp
ProcessorPlayerResurrect() ProcessorPlayerResurrect()
{ {
BPP_INIT(ID_PLAYER_RESURRECT) BPP_INIT(ID_PLAYER_RESURRECT)
dontRead = true;
} }
void Do(PlayerPacket &packet, Player &player) override void Do(PlayerPacket &packet, Player &player) override

@ -21,7 +21,6 @@ namespace mwmp
{ {
if (!player.creatureStats.mDead) if (!player.creatureStats.mDead)
{ {
packet.Read();
//myPacket->Send(player, true); //myPacket->Send(player, true);
player.sendToLoaded(&packet); player.sendToLoaded(&packet);

@ -21,8 +21,6 @@ namespace mwmp
{ {
DEBUG_PRINTF(strPacketID.c_str()); DEBUG_PRINTF(strPacketID.c_str());
packet.Read();
Script::Call<Script::CallbackIdentity("OnPlayerSpellbookChange")>(player.getId()); Script::Call<Script::CallbackIdentity("OnPlayerSpellbookChange")>(player.getId());
} }
}; };

Loading…
Cancel
Save