From 690211ad99ebec31b7bde72e56c10cc262118fb3 Mon Sep 17 00:00:00 2001 From: Koncord Date: Mon, 6 Mar 2017 17:44:08 +0800 Subject: [PATCH] [General] Extract BaseEvent & BasePlayer from packets to functions Move Send and Read functions to BasePacket --- apps/openmw-mp/Cell.cpp | 4 +- apps/openmw-mp/Networking.cpp | 240 ++++++++++++------ apps/openmw-mp/Player.cpp | 3 +- apps/openmw-mp/Script/Functions/Cells.cpp | 3 +- apps/openmw-mp/Script/Functions/CharClass.cpp | 3 +- apps/openmw-mp/Script/Functions/Chat.cpp | 6 +- apps/openmw-mp/Script/Functions/GUI.cpp | 15 +- apps/openmw-mp/Script/Functions/Items.cpp | 8 +- apps/openmw-mp/Script/Functions/Positions.cpp | 3 +- apps/openmw-mp/Script/Functions/Quests.cpp | 3 +- apps/openmw-mp/Script/Functions/Spells.cpp | 3 +- apps/openmw-mp/Script/Functions/Stats.cpp | 29 ++- apps/openmw-mp/Script/Functions/World.cpp | 30 ++- apps/openmw/mwgui/container.cpp | 9 +- apps/openmw/mwgui/hud.cpp | 3 +- apps/openmw/mwgui/inventorywindow.cpp | 3 +- apps/openmw/mwmechanics/security.cpp | 5 +- apps/openmw/mwmp/GUIChat.cpp | 3 +- apps/openmw/mwmp/GUIController.cpp | 6 +- apps/openmw/mwmp/GUIDialogList.cpp | 3 +- apps/openmw/mwmp/LocalPlayer.cpp | 70 +++-- apps/openmw/mwmp/Main.cpp | 6 +- apps/openmw/mwmp/Networking.cpp | 108 +++++--- apps/openmw/mwmp/WorldEvent.cpp | 3 +- apps/openmw/mwscript/animationextensions.cpp | 3 +- apps/openmw/mwscript/interpretercontext.cpp | 12 +- apps/openmw/mwscript/miscextensions.cpp | 12 +- apps/openmw/mwscript/soundextensions.cpp | 3 +- .../mwscript/transformationextensions.cpp | 6 +- apps/openmw/mwworld/actiontake.cpp | 3 +- apps/openmw/mwworld/worldimp.cpp | 6 +- components/openmw-mp/Packets/BasePacket.cpp | 31 ++- components/openmw-mp/Packets/BasePacket.hpp | 11 +- .../openmw-mp/Packets/PacketPreInit.cpp | 4 +- .../openmw-mp/Packets/PacketPreInit.hpp | 2 +- .../Packets/Player/PacketChatMessage.cpp | 4 +- .../Packets/Player/PacketChatMessage.hpp | 2 +- .../Packets/Player/PacketConsole.hpp | 4 +- .../Packets/Player/PacketGUIBoxes.cpp | 4 +- .../Packets/Player/PacketGUIBoxes.hpp | 2 +- .../Packets/Player/PacketHandshake.cpp | 4 +- .../Packets/Player/PacketHandshake.hpp | 2 +- .../Player/PacketPlayerActiveSkills.cpp | 4 +- .../Player/PacketPlayerActiveSkills.hpp | 2 +- .../Packets/Player/PacketPlayerAttack.cpp | 4 +- .../Packets/Player/PacketPlayerAttack.hpp | 2 +- .../Packets/Player/PacketPlayerAttribute.cpp | 4 +- .../Packets/Player/PacketPlayerAttribute.hpp | 2 +- .../Packets/Player/PacketPlayerBaseInfo.cpp | 4 +- .../Packets/Player/PacketPlayerBaseInfo.hpp | 2 +- .../Packets/Player/PacketPlayerCellChange.cpp | 4 +- .../Packets/Player/PacketPlayerCellChange.hpp | 2 +- .../Packets/Player/PacketPlayerCellState.cpp | 4 +- .../Packets/Player/PacketPlayerCellState.hpp | 2 +- .../Packets/Player/PacketPlayerCharGen.cpp | 4 +- .../Packets/Player/PacketPlayerCharGen.hpp | 2 +- .../Packets/Player/PacketPlayerClass.cpp | 4 +- .../Packets/Player/PacketPlayerClass.hpp | 2 +- .../Packets/Player/PacketPlayerDeath.hpp | 4 +- .../Packets/Player/PacketPlayerDrawState.cpp | 4 +- .../Packets/Player/PacketPlayerDrawState.hpp | 2 +- .../Player/PacketPlayerDynamicStats.cpp | 4 +- .../Player/PacketPlayerDynamicStats.hpp | 2 +- .../Packets/Player/PacketPlayerEquipment.cpp | 4 +- .../Packets/Player/PacketPlayerEquipment.hpp | 2 +- .../Packets/Player/PacketPlayerInventory.cpp | 4 +- .../Packets/Player/PacketPlayerInventory.hpp | 2 +- .../Packets/Player/PacketPlayerJournal.cpp | 4 +- .../Packets/Player/PacketPlayerJournal.hpp | 2 +- .../Packets/Player/PacketPlayerLevel.cpp | 4 +- .../Packets/Player/PacketPlayerLevel.hpp | 2 +- .../Packets/Player/PacketPlayerPosition.cpp | 4 +- .../Packets/Player/PacketPlayerPosition.hpp | 2 +- .../Packets/Player/PacketPlayerResurrect.hpp | 4 +- .../Packets/Player/PacketPlayerSkill.cpp | 4 +- .../Packets/Player/PacketPlayerSkill.hpp | 2 +- .../Packets/Player/PacketPlayerSpellbook.cpp | 4 +- .../Packets/Player/PacketPlayerSpellbook.hpp | 2 +- .../openmw-mp/Packets/Player/PacketTime.cpp | 4 +- .../openmw-mp/Packets/Player/PacketTime.hpp | 2 +- .../openmw-mp/Packets/Player/PlayerPacket.cpp | 24 +- .../openmw-mp/Packets/Player/PlayerPacket.hpp | 7 +- .../Packets/World/PacketContainer.cpp | 4 +- .../Packets/World/PacketContainer.hpp | 2 +- .../Packets/World/PacketDoorState.cpp | 4 +- .../Packets/World/PacketDoorState.hpp | 2 +- .../Packets/World/PacketMusicPlay.cpp | 4 +- .../Packets/World/PacketMusicPlay.hpp | 2 +- .../Packets/World/PacketObjectAnimPlay.cpp | 4 +- .../Packets/World/PacketObjectAnimPlay.hpp | 2 +- .../Packets/World/PacketObjectDelete.cpp | 4 +- .../Packets/World/PacketObjectDelete.hpp | 2 +- .../Packets/World/PacketObjectLock.cpp | 4 +- .../Packets/World/PacketObjectLock.hpp | 2 +- .../Packets/World/PacketObjectMove.cpp | 4 +- .../Packets/World/PacketObjectMove.hpp | 2 +- .../Packets/World/PacketObjectPlace.cpp | 4 +- .../Packets/World/PacketObjectPlace.hpp | 2 +- .../Packets/World/PacketObjectRotate.cpp | 4 +- .../Packets/World/PacketObjectRotate.hpp | 2 +- .../Packets/World/PacketObjectScale.cpp | 4 +- .../Packets/World/PacketObjectScale.hpp | 2 +- .../Packets/World/PacketObjectUnlock.cpp | 4 +- .../Packets/World/PacketObjectUnlock.hpp | 2 +- .../Packets/World/PacketScriptGlobalShort.cpp | 4 +- .../Packets/World/PacketScriptGlobalShort.hpp | 2 +- .../Packets/World/PacketScriptLocalFloat.cpp | 4 +- .../Packets/World/PacketScriptLocalFloat.hpp | 2 +- .../Packets/World/PacketScriptLocalShort.cpp | 4 +- .../Packets/World/PacketScriptLocalShort.hpp | 2 +- .../Packets/World/PacketScriptMemberShort.cpp | 4 +- .../Packets/World/PacketScriptMemberShort.hpp | 2 +- .../Packets/World/PacketVideoPlay.cpp | 4 +- .../Packets/World/PacketVideoPlay.hpp | 2 +- .../openmw-mp/Packets/World/WorldPacket.cpp | 25 +- .../openmw-mp/Packets/World/WorldPacket.hpp | 6 +- 116 files changed, 578 insertions(+), 380 deletions(-) diff --git a/apps/openmw-mp/Cell.cpp b/apps/openmw-mp/Cell.cpp index 1b02bd541..81427b306 100644 --- a/apps/openmw-mp/Cell.cpp +++ b/apps/openmw-mp/Cell.cpp @@ -67,7 +67,9 @@ void Cell::sendToLoaded(mwmp::WorldPacket *worldPacket, mwmp::BaseEvent *baseEve for (auto pl : plList) { if (pl->guid == baseEvent->guid) continue; - worldPacket->Send(baseEvent, pl->guid); + worldPacket->setEvent(baseEvent); + worldPacket->setGUID(pl->guid); + worldPacket->Send(); } } diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index b071d0eb1..0ca936815 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -76,8 +76,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) if (packet->data[0] == ID_HANDSHAKE) { - - myPacket->Read(player); + myPacket->setPlayer(player); + myPacket->Read(); if (player->isHandshaked()) { @@ -115,7 +115,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) if (!result) { - playerController->GetPacket(ID_USER_DISCONNECTED)->Send(Players::getPlayer(packet->guid), false); + playerController->GetPacket(ID_USER_DISCONNECTED)->setPlayer(Players::getPlayer(packet->guid)); + playerController->GetPacket(ID_USER_DISCONNECTED)->Send(false); Players::deletePlayer(packet->guid); return; } @@ -124,8 +125,9 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_BASEINFO about %s", player->npc.mName.c_str()); - myPacket->Read(player); - myPacket->Send(player, true); + myPacket->setPlayer(player); + myPacket->Read(); + myPacket->Send(true); } if (player->getLoadState() == Player::NOTLOADED) @@ -154,7 +156,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) if (!player->creatureStats.mDead) { - myPacket->Read(player); + myPacket->setPlayer(player); + myPacket->Read(); //myPacket->Send(player, true); //send to other clients player->sendToLoaded(myPacket); @@ -169,7 +172,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) if (!player->creatureStats.mDead) { - myPacket->Read(player); + myPacket->setPlayer(player); + myPacket->Read(); LOG_APPEND(Log::LOG_INFO, "- Moved to %s", player->cell.getDescription().c_str()); @@ -184,25 +188,40 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) { LOG_APPEND(Log::LOG_INFO, "- Started information exchange with %s", other->npc.mName.c_str()); - playerController->GetPacket(ID_PLAYER_DYNAMICSTATS)->Send(other, pl->guid); - playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(other, pl->guid); - playerController->GetPacket(ID_PLAYER_POS)->Send(other, pl->guid); - playerController->GetPacket(ID_PLAYER_SKILL)->Send(other, pl->guid); - playerController->GetPacket(ID_PLAYER_EQUIPMENT)->Send(other, pl->guid); - playerController->GetPacket(ID_PLAYER_DRAWSTATE)->Send(other, pl->guid); - - playerController->GetPacket(ID_PLAYER_DYNAMICSTATS)->Send(pl, other->guid); - playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(pl, other->guid); - playerController->GetPacket(ID_PLAYER_SKILL)->Send(pl, other->guid); - playerController->GetPacket(ID_PLAYER_EQUIPMENT)->Send(pl, other->guid); - playerController->GetPacket(ID_PLAYER_DRAWSTATE)->Send(pl, other->guid); + playerController->GetPacket(ID_PLAYER_DYNAMICSTATS)->setPlayer(other); + playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->setPlayer(other); + playerController->GetPacket(ID_PLAYER_POS)->setPlayer(other); + playerController->GetPacket(ID_PLAYER_SKILL)->setPlayer(other); + playerController->GetPacket(ID_PLAYER_EQUIPMENT)->setPlayer(other); + playerController->GetPacket(ID_PLAYER_DRAWSTATE)->setPlayer(other); + + playerController->GetPacket(ID_PLAYER_DYNAMICSTATS)->Send(pl->guid); + playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(pl->guid); + playerController->GetPacket(ID_PLAYER_POS)->Send(pl->guid); + playerController->GetPacket(ID_PLAYER_SKILL)->Send(pl->guid); + playerController->GetPacket(ID_PLAYER_EQUIPMENT)->Send(pl->guid); + playerController->GetPacket(ID_PLAYER_DRAWSTATE)->Send(pl->guid); + + playerController->GetPacket(ID_PLAYER_DYNAMICSTATS)->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_DRAWSTATE)->setPlayer(pl); + + playerController->GetPacket(ID_PLAYER_DYNAMICSTATS)->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_DRAWSTATE)->Send(other->guid); LOG_APPEND(Log::LOG_INFO, "- Finished information exchange with %s", other->npc.mName.c_str()); } }); - playerController->GetPacket(ID_PLAYER_POS)->Send(player); - myPacket->Send(player, true); //send to other clients + playerController->GetPacket(ID_PLAYER_POS)->setPlayer(player); + playerController->GetPacket(ID_PLAYER_POS)->Send(); + myPacket->setPlayer(player); + myPacket->Send(true); //send to other clients Script::Call(player->getId()); @@ -217,7 +236,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_CELL_STATE from %s", player->npc.mName.c_str()); - myPacket->Read(player); + myPacket->setPlayer(player); + myPacket->Read(); CellController::get()->update(player); @@ -230,7 +250,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) if (!player->creatureStats.mDead) { - myPacket->Read(player); + myPacket->setPlayer(player); + myPacket->Read(); //myPacket->Send(player, true); player->sendToLoaded(myPacket); @@ -245,7 +266,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) if (!player->creatureStats.mDead) { - myPacket->Read(player); + myPacket->setPlayer(player); + myPacket->Read(); //myPacket->Send(player, true); player->sendToLoaded(myPacket); @@ -259,7 +281,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) if (!player->creatureStats.mDead) { - myPacket->Read(player); + myPacket->setPlayer(player); + myPacket->Read(); //myPacket->Send(player, true); Script::Call(player->getId()); @@ -271,7 +294,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) { DEBUG_PRINTF("ID_PLAYER_EQUIPMENT\n"); - myPacket->Read(player); + myPacket->setPlayer(player); + myPacket->Read(); //myPacket->Send(player, true); player->sendToLoaded(myPacket); @@ -284,7 +308,9 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) case ID_PLAYER_INVENTORY: { DEBUG_PRINTF("ID_PLAYER_INVENTORY\n"); - myPacket->Read(player); + + myPacket->setPlayer(player); + myPacket->Read(); Script::Call(player->getId()); @@ -294,7 +320,9 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) case ID_PLAYER_SPELLBOOK: { DEBUG_PRINTF("ID_PLAYER_SPELLBOOK\n"); - myPacket->Read(player); + + myPacket->setPlayer(player); + myPacket->Read(); Script::Call(player->getId()); @@ -304,7 +332,9 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) case ID_PLAYER_JOURNAL: { DEBUG_PRINTF("ID_PLAYER_JOURNAL\n"); - myPacket->Read(player); + + myPacket->setPlayer(player); + myPacket->Read(); Script::Call(player->getId()); @@ -317,7 +347,9 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) if (!player->creatureStats.mDead) { - myPacket->Read(player); + + myPacket->setPlayer(player); + myPacket->Read(); Player *target = Players::getPlayer(player->attack.target); @@ -347,7 +379,9 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) case ID_PLAYER_DYNAMICSTATS: { DEBUG_PRINTF("ID_PLAYER_DYNAMICSTATS\n"); - myPacket->Read(player); + + myPacket->setPlayer(player); + myPacket->Read(); //myPacket->Send(player, true); player->sendToLoaded(myPacket); @@ -376,7 +410,9 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) player->resetLastAttacker(); player->creatureStats.mDead = true; - myPacket->Send(player, true); + + myPacket->setPlayer(player); + myPacket->Send(true); Script::Call(player->getId(), reason, killer->getId()); @@ -388,7 +424,9 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_RESURRECT from %s", player->npc.mName.c_str()); player->creatureStats.mDead = false; - myPacket->Send(player, true); + + myPacket->setPlayer(player); + myPacket->Send(true); Script::Call(player->getId()); @@ -398,7 +436,9 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) case ID_PLAYER_DRAWSTATE: { DEBUG_PRINTF("ID_PLAYER_DRAWSTATE\n"); - myPacket->Read(player); + + myPacket->setPlayer(player); + myPacket->Read(); //myPacket->Send(player, true); player->sendToLoaded(myPacket); @@ -409,7 +449,9 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) case ID_CHAT_MESSAGE: { DEBUG_PRINTF("ID_CHAT_MESSAGE\n"); - myPacket->Read(player); + + myPacket->setPlayer(player); + myPacket->Read(); Script::CallBackReturn result = true; Script::Call(result, player->getId(), player->chatMessage.c_str()); @@ -417,15 +459,19 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) { player->chatMessage = player->npc.mName + " (" + std::to_string(player->getId()) + "): " + player->chatMessage + "\n"; - myPacket->Send(player, false); - myPacket->Send(player, true); + + myPacket->setPlayer(player); + myPacket->Send(false); + myPacket->Send(true); } break; } case ID_PLAYER_CHARGEN: { DEBUG_PRINTF("ID_PLAYER_CHARGEN\n"); - myPacket->Read(player); + + myPacket->setPlayer(player); + myPacket->Read(); if (player->charGenStage.current == player->charGenStage.end && player->charGenStage.current != 0) Script::Call(player->getId()); @@ -435,7 +481,9 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) case ID_GUI_MESSAGEBOX: { DEBUG_PRINTF("ID_GUI_MESSAGEBOX\n"); - myPacket->Read(player); + + myPacket->setPlayer(player); + myPacket->Read(); Script::Call(player->getId(), (int)player->guiMessageBox.id, player->guiMessageBox.data.c_str()); @@ -445,7 +493,9 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) case ID_PLAYER_CHARCLASS: { DEBUG_PRINTF("ID_PLAYER_CHARCLASS\n"); - myPacket->Read(player); + + myPacket->setPlayer(player); + myPacket->Read(); break; } @@ -476,8 +526,9 @@ void Networking::processWorldPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_PLACE from %s", player->npc.mName.c_str()); - myPacket->Read(&baseEvent); - myPacket->Send(&baseEvent, true); + myPacket->setEvent(&baseEvent); + myPacket->Read(); + myPacket->Send(true); Script::Call(player->getId(), baseEvent.cell.getDescription().c_str()); @@ -488,8 +539,9 @@ void Networking::processWorldPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_DELETE from %s", player->npc.mName.c_str()); - myPacket->Read(&baseEvent); - myPacket->Send(&baseEvent, true); + myPacket->setEvent(&baseEvent); + myPacket->Read(); + myPacket->Send(true); Script::Call(player->getId(), baseEvent.cell.getDescription().c_str()); @@ -500,8 +552,9 @@ void Networking::processWorldPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_SCALE from %s", player->npc.mName.c_str()); - myPacket->Read(&baseEvent); - myPacket->Send(&baseEvent, true); + myPacket->setEvent(&baseEvent); + myPacket->Read(); + myPacket->Send(true); Script::Call(player->getId(), baseEvent.cell.getDescription().c_str()); @@ -512,8 +565,9 @@ void Networking::processWorldPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_LOCK from %s", player->npc.mName.c_str()); - myPacket->Read(&baseEvent); - myPacket->Send(&baseEvent, true); + myPacket->setEvent(&baseEvent); + myPacket->Read(); + myPacket->Send(true); Script::Call(player->getId(), baseEvent.cell.getDescription().c_str()); @@ -524,8 +578,9 @@ void Networking::processWorldPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_UNLOCK from %s", player->npc.mName.c_str()); - myPacket->Read(&baseEvent); - myPacket->Send(&baseEvent, true); + myPacket->setEvent(&baseEvent); + myPacket->Read(); + myPacket->Send(true); Script::Call(player->getId(), baseEvent.cell.getDescription().c_str()); @@ -536,8 +591,9 @@ void Networking::processWorldPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_MOVE from %s", player->npc.mName.c_str()); - myPacket->Read(&baseEvent); - myPacket->Send(&baseEvent, true); + myPacket->setEvent(&baseEvent); + myPacket->Read(); + myPacket->Send(true); break; } @@ -546,8 +602,9 @@ void Networking::processWorldPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_ROTATE from %s", player->npc.mName.c_str()); - myPacket->Read(&baseEvent); - myPacket->Send(&baseEvent, true); + myPacket->setEvent(&baseEvent); + myPacket->Read(); + myPacket->Send(true); break; } @@ -556,8 +613,9 @@ void Networking::processWorldPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_ANIM_PLAY from %s", player->npc.mName.c_str()); - myPacket->Read(&baseEvent); - myPacket->Send(&baseEvent, true); + myPacket->setEvent(&baseEvent); + myPacket->Read(); + myPacket->Send(true); break; } @@ -566,8 +624,9 @@ void Networking::processWorldPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_DOOR_STATE from %s", player->npc.mName.c_str()); - myPacket->Read(&baseEvent); - myPacket->Send(&baseEvent, true); + myPacket->setEvent(&baseEvent); + myPacket->Read(); + myPacket->Send(true); Script::Call(player->getId(), baseEvent.cell.getDescription().c_str()); @@ -578,7 +637,8 @@ void Networking::processWorldPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_CONTAINER from %s", player->npc.mName.c_str()); - myPacket->Read(&baseEvent); + myPacket->setEvent(&baseEvent); + myPacket->Read(); LOG_APPEND(Log::LOG_WARN, "- action: %i", baseEvent.action); @@ -588,7 +648,7 @@ void Networking::processWorldPacket(RakNet::Packet *packet) if (baseEvent.action == BaseEvent::SET && baseEvent.objectChanges.count > 1) CellController::get()->getCell(&baseEvent.cell)->sendToLoaded(myPacket, &baseEvent); else - myPacket->Send(&baseEvent, true); + myPacket->Send(true); Script::Call(player->getId(), baseEvent.cell.getDescription().c_str()); @@ -601,8 +661,9 @@ void Networking::processWorldPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_LOCAL_SHORT from %s", player->npc.mName.c_str()); - myPacket->Read(&baseEvent); - myPacket->Send(&baseEvent, true); + myPacket->setEvent(&baseEvent); + myPacket->Read(); + myPacket->Send(true); break; } @@ -611,8 +672,9 @@ void Networking::processWorldPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_LOCAL_FLOAT from %s", player->npc.mName.c_str()); - myPacket->Read(&baseEvent); - myPacket->Send(&baseEvent, true); + myPacket->setEvent(&baseEvent); + myPacket->Read(); + myPacket->Send(true); break; } @@ -621,8 +683,9 @@ void Networking::processWorldPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_MEMBER_SHORT from %s", player->npc.mName.c_str()); - myPacket->Read(&baseEvent); - myPacket->Send(&baseEvent, true); + myPacket->setEvent(&baseEvent); + myPacket->Read(); + myPacket->Send(true); break; } @@ -631,8 +694,9 @@ void Networking::processWorldPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_GLOBAL_SHORT from %s", player->npc.mName.c_str()); - myPacket->Read(&baseEvent); - myPacket->Send(&baseEvent, true); + myPacket->setEvent(&baseEvent); + myPacket->Read(); + myPacket->Send(true); break; } @@ -641,8 +705,9 @@ void Networking::processWorldPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_MUSIC_PLAY from %s", player->npc.mName.c_str()); - myPacket->Read(&baseEvent); - myPacket->Send(&baseEvent, true); + myPacket->setEvent(&baseEvent); + myPacket->Read(); + myPacket->Send(true); break; } @@ -651,8 +716,9 @@ void Networking::processWorldPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_VIDEO_PLAY from %s", player->npc.mName.c_str()); - myPacket->Read(&baseEvent); - myPacket->Send(&baseEvent, true); + myPacket->setEvent(&baseEvent); + myPacket->Read(); + myPacket->Send(true); break; } @@ -679,7 +745,9 @@ void Networking::update(RakNet::Packet *packet) playerController->GetPacket(ID_HANDSHAKE)->RequestData(packet->guid); Players::newPlayer(packet->guid); player = Players::getPlayer(packet->guid); - playerController->GetPacket(ID_USER_MYID)->Send(player, false); + + playerController->GetPacket(ID_USER_MYID)->setPlayer(player); + playerController->GetPacket(ID_USER_MYID)->Send(false); return; } else if (playerController->ContainsPacket(packet->data[0])) @@ -720,13 +788,21 @@ void Networking::newPlayer(RakNet::RakNetGUID guid) // If we are iterating over a player who has inputted their name, proceed else if (pl->second->getLoadState() == Player::POSTLOADED) { - playerController->GetPacket(ID_PLAYER_BASEINFO)->Send(pl->second, guid); - playerController->GetPacket(ID_PLAYER_DYNAMICSTATS)->Send(pl->second, guid); - playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(pl->second, guid); - playerController->GetPacket(ID_PLAYER_SKILL)->Send(pl->second, guid); - playerController->GetPacket(ID_PLAYER_POS)->Send(pl->second, guid); - playerController->GetPacket(ID_PLAYER_CELL_CHANGE)->Send(pl->second, guid); - playerController->GetPacket(ID_PLAYER_EQUIPMENT)->Send(pl->second, guid); + playerController->GetPacket(ID_PLAYER_BASEINFO)->setPlayer(pl->second); + playerController->GetPacket(ID_PLAYER_DYNAMICSTATS)->setPlayer(pl->second); + playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->setPlayer(pl->second); + playerController->GetPacket(ID_PLAYER_SKILL)->setPlayer(pl->second); + playerController->GetPacket(ID_PLAYER_POS)->setPlayer(pl->second); + playerController->GetPacket(ID_PLAYER_CELL_CHANGE)->setPlayer(pl->second); + playerController->GetPacket(ID_PLAYER_EQUIPMENT)->setPlayer(pl->second); + + playerController->GetPacket(ID_PLAYER_BASEINFO)->Send(guid); + playerController->GetPacket(ID_PLAYER_DYNAMICSTATS)->Send(guid); + playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(guid); + playerController->GetPacket(ID_PLAYER_SKILL)->Send(guid); + playerController->GetPacket(ID_PLAYER_POS)->Send(guid); + playerController->GetPacket(ID_PLAYER_CELL_CHANGE)->Send(guid); + playerController->GetPacket(ID_PLAYER_EQUIPMENT)->Send(guid); } } @@ -740,7 +816,9 @@ void Networking::disconnectPlayer(RakNet::RakNetGUID guid) if (!player) return; Script::Call(player->getId()); - playerController->GetPacket(ID_USER_DISCONNECTED)->Send(player, true); + + playerController->GetPacket(ID_USER_DISCONNECTED)->setPlayer(player); + playerController->GetPacket(ID_USER_DISCONNECTED)->Send(true); Players::deletePlayer(guid); } diff --git a/apps/openmw-mp/Player.cpp b/apps/openmw-mp/Player.cpp index a56d29b93..8b09eb8e4 100644 --- a/apps/openmw-mp/Player.cpp +++ b/apps/openmw-mp/Player.cpp @@ -158,7 +158,8 @@ void Player::sendToLoaded(mwmp::PlayerPacket *myPacket) for (auto pl : plList) { if (pl == this) continue; - myPacket->Send(this, pl->guid); + myPacket->setPlayer(this); + myPacket->Send(); } } diff --git a/apps/openmw-mp/Script/Functions/Cells.cpp b/apps/openmw-mp/Script/Functions/Cells.cpp index 23029be62..b138cdc09 100644 --- a/apps/openmw-mp/Script/Functions/Cells.cpp +++ b/apps/openmw-mp/Script/Functions/Cells.cpp @@ -110,5 +110,6 @@ void CellFunctions::SendCell(unsigned short pid) noexcept Player *player; GET_PLAYER(pid, player, ); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_CELL_CHANGE)->Send(player, false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_CELL_CHANGE)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_CELL_CHANGE)->Send(false); } diff --git a/apps/openmw-mp/Script/Functions/CharClass.cpp b/apps/openmw-mp/Script/Functions/CharClass.cpp index 85bd3d092..3bc355735 100644 --- a/apps/openmw-mp/Script/Functions/CharClass.cpp +++ b/apps/openmw-mp/Script/Functions/CharClass.cpp @@ -15,7 +15,8 @@ void CharClassFunctions::SendClass(unsigned short pid) noexcept Player *player; GET_PLAYER(pid, player,); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_CHARCLASS)->Send(player, false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_CHARCLASS)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_CHARCLASS)->Send(false); } void CharClassFunctions::SetDefaultClass(unsigned short pid, const char *id) noexcept diff --git a/apps/openmw-mp/Script/Functions/Chat.cpp b/apps/openmw-mp/Script/Functions/Chat.cpp index 950cb6434..3aed12060 100644 --- a/apps/openmw-mp/Script/Functions/Chat.cpp +++ b/apps/openmw-mp/Script/Functions/Chat.cpp @@ -15,9 +15,11 @@ void ScriptFunctions::SendMessage(unsigned short pid, const char *message, bool LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "System: %s", message); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_CHAT_MESSAGE)->Send(player, false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_CHAT_MESSAGE)->setPlayer(player); + + mwmp::Networking::get().getPlayerController()->GetPacket(ID_CHAT_MESSAGE)->Send(false); if (broadcast) - mwmp::Networking::get().getPlayerController()->GetPacket(ID_CHAT_MESSAGE)->Send(player, true); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_CHAT_MESSAGE)->Send(true); } void ScriptFunctions::CleanChat(unsigned short pid) diff --git a/apps/openmw-mp/Script/Functions/GUI.cpp b/apps/openmw-mp/Script/Functions/GUI.cpp index 0fe3908b2..3c8151d16 100644 --- a/apps/openmw-mp/Script/Functions/GUI.cpp +++ b/apps/openmw-mp/Script/Functions/GUI.cpp @@ -18,7 +18,8 @@ void GUIFunctions::_MessageBox(unsigned short pid, int id, const char *label) no player->guiMessageBox.label = label; player->guiMessageBox.type = Player::GUIMessageBox::MessageBox; - mwmp::Networking::get().getPlayerController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_GUI_MESSAGEBOX)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(false); } void GUIFunctions::CustomMessageBox(unsigned short pid, int id, const char *label, const char *buttons) noexcept @@ -31,7 +32,8 @@ void GUIFunctions::CustomMessageBox(unsigned short pid, int id, const char *labe player->guiMessageBox.buttons = buttons; player->guiMessageBox.type = Player::GUIMessageBox::CustomMessageBox; - mwmp::Networking::get().getPlayerController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_GUI_MESSAGEBOX)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(false); } void GUIFunctions::InputDialog(unsigned short pid, int id, const char *label) noexcept @@ -43,7 +45,8 @@ void GUIFunctions::InputDialog(unsigned short pid, int id, const char *label) no player->guiMessageBox.label = label; player->guiMessageBox.type = Player::GUIMessageBox::InputDialog; - mwmp::Networking::get().getPlayerController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_GUI_MESSAGEBOX)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(false); } void GUIFunctions::ListBox(unsigned short pid, int id, const char *label, const char *items) @@ -56,7 +59,8 @@ void GUIFunctions::ListBox(unsigned short pid, int id, const char *label, const player->guiMessageBox.data = items; player->guiMessageBox.type = Player::GUIMessageBox::ListBox; - mwmp::Networking::get().getPlayerController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_GUI_MESSAGEBOX)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(false); } void GUIFunctions::SetMapVisibility(unsigned short targetPID, unsigned short affectedPID, unsigned short state) noexcept @@ -76,5 +80,6 @@ void GUIFunctions::SetConsoleAllow(unsigned short pid, bool state) player->consoleAllowed = state; - mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_CONSOLE)->Send(player, false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_CONSOLE)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_CONSOLE)->Send(false); } diff --git a/apps/openmw-mp/Script/Functions/Items.cpp b/apps/openmw-mp/Script/Functions/Items.cpp index 82edb2c2c..f5f1c144c 100644 --- a/apps/openmw-mp/Script/Functions/Items.cpp +++ b/apps/openmw-mp/Script/Functions/Items.cpp @@ -145,8 +145,9 @@ void ItemFunctions::SendEquipment(unsigned short pid) noexcept Player *player; GET_PLAYER(pid, player, ); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_EQUIPMENT)->Send(player, false); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_EQUIPMENT)->Send(player, true); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_EQUIPMENT)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_EQUIPMENT)->Send(false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_EQUIPMENT)->Send(true); } void ItemFunctions::SendInventoryChanges(unsigned short pid) noexcept @@ -155,7 +156,8 @@ void ItemFunctions::SendInventoryChanges(unsigned short pid) noexcept GET_PLAYER(pid, player, ); std::swap(player->inventoryChanges, player->inventoryChangesBuffer); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_INVENTORY)->Send(player, false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_INVENTORY)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_INVENTORY)->Send(false); player->inventoryChanges = std::move(player->inventoryChangesBuffer); player->inventoryChangesBuffer.items.clear(); } diff --git a/apps/openmw-mp/Script/Functions/Positions.cpp b/apps/openmw-mp/Script/Functions/Positions.cpp index 7c25b52e3..cfe3dc8ba 100644 --- a/apps/openmw-mp/Script/Functions/Positions.cpp +++ b/apps/openmw-mp/Script/Functions/Positions.cpp @@ -109,5 +109,6 @@ void PositionFunctions::SendPos(unsigned short pid) noexcept Player *player; GET_PLAYER(pid, player, ); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_POS)->Send(player, false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_POS)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_POS)->Send(false); } diff --git a/apps/openmw-mp/Script/Functions/Quests.cpp b/apps/openmw-mp/Script/Functions/Quests.cpp index d3a527873..e5c873733 100644 --- a/apps/openmw-mp/Script/Functions/Quests.cpp +++ b/apps/openmw-mp/Script/Functions/Quests.cpp @@ -73,7 +73,8 @@ void QuestFunctions::SendJournalChanges(unsigned short pid) noexcept GET_PLAYER(pid, player, ); std::swap(player->journalChanges, player->journalChangesBuffer); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_JOURNAL)->Send(player, false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_JOURNAL)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_JOURNAL)->Send(false); player->journalChanges = std::move(player->journalChangesBuffer); player->journalChangesBuffer.journalItems.clear(); } diff --git a/apps/openmw-mp/Script/Functions/Spells.cpp b/apps/openmw-mp/Script/Functions/Spells.cpp index fa6c6f2e8..d474f7941 100644 --- a/apps/openmw-mp/Script/Functions/Spells.cpp +++ b/apps/openmw-mp/Script/Functions/Spells.cpp @@ -72,7 +72,8 @@ void SpellFunctions::SendSpellbookChanges(unsigned short pid) noexcept GET_PLAYER(pid, player, ); std::swap(player->spellbookChanges, player->spellbookChangesBuffer); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_SPELLBOOK)->Send(player, false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_SPELLBOOK)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_SPELLBOOK)->Send(false); player->spellbookChanges = std::move(player->spellbookChangesBuffer); player->spellbookChangesBuffer.spells.clear(); } diff --git a/apps/openmw-mp/Script/Functions/Stats.cpp b/apps/openmw-mp/Script/Functions/Stats.cpp index aae95b35c..dd6845335 100644 --- a/apps/openmw-mp/Script/Functions/Stats.cpp +++ b/apps/openmw-mp/Script/Functions/Stats.cpp @@ -451,7 +451,8 @@ void StatsFunctions::SetCharGenStage(unsigned short pid, int start, int end) noe player->charGenStage.current = start; player->charGenStage.end = end; - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_CHARGEN)->Send(player, false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_CHARGEN)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_CHARGEN)->Send(false); } void StatsFunctions::Resurrect(unsigned short pid) @@ -466,16 +467,19 @@ void StatsFunctions::SendBaseInfo(unsigned short pid) noexcept Player *player; GET_PLAYER(pid, player,); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_BASEINFO)->Send(player, false); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_BASEINFO)->Send(player, true); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_BASEINFO)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_BASEINFO)->Send(false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_BASEINFO)->Send(true); } void StatsFunctions::SendDynamicStats(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_DYNAMICSTATS)->Send(player, false); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_DYNAMICSTATS)->Send(player, true); + + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_DYNAMICSTATS)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_DYNAMICSTATS)->Send(false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_DYNAMICSTATS)->Send(true); } void StatsFunctions::SendAttributes(unsigned short pid) noexcept @@ -483,8 +487,9 @@ void StatsFunctions::SendAttributes(unsigned short pid) noexcept Player *player; GET_PLAYER(pid, player,); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(player, false); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(player, true); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_ATTRIBUTE)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(true); } void StatsFunctions::SendSkills(unsigned short pid) noexcept @@ -492,8 +497,9 @@ void StatsFunctions::SendSkills(unsigned short pid) noexcept Player *player; GET_PLAYER(pid, player,); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_SKILL)->Send(player, false); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_SKILL)->Send(player, true); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_SKILL)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_SKILL)->Send(false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_SKILL)->Send(true); } void StatsFunctions::SendLevel(unsigned short pid) noexcept @@ -501,6 +507,7 @@ void StatsFunctions::SendLevel(unsigned short pid) noexcept Player *player; GET_PLAYER(pid, player, ); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_LEVEL)->Send(player, false); - mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_LEVEL)->Send(player, true); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_LEVEL)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_LEVEL)->Send(false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_LEVEL)->Send(true); } diff --git a/apps/openmw-mp/Script/Functions/World.cpp b/apps/openmw-mp/Script/Functions/World.cpp index 82d79833b..8d7ffb266 100644 --- a/apps/openmw-mp/Script/Functions/World.cpp +++ b/apps/openmw-mp/Script/Functions/World.cpp @@ -262,37 +262,44 @@ void WorldFunctions::AddContainerItem() noexcept void WorldFunctions::SendObjectDelete() noexcept { - mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_DELETE)->Send(&scriptEvent, scriptEvent.guid); + mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_DELETE)->setEvent(&scriptEvent); + mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_DELETE)->Send(scriptEvent.guid); } void WorldFunctions::SendObjectPlace() noexcept { - mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_PLACE)->Send(&scriptEvent, scriptEvent.guid); + mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_PLACE)->setEvent(&scriptEvent); + mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_PLACE)->Send(scriptEvent.guid); } void WorldFunctions::SendObjectScale() noexcept { - mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_SCALE)->Send(&scriptEvent, scriptEvent.guid); + mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_SCALE)->setEvent(&scriptEvent); + mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_SCALE)->Send(scriptEvent.guid); } void WorldFunctions::SendObjectLock() noexcept { - mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_LOCK)->Send(&scriptEvent, scriptEvent.guid); + mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_LOCK)->setEvent(&scriptEvent); + mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_LOCK)->Send(scriptEvent.guid); } void WorldFunctions::SendObjectUnlock() noexcept { - mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_UNLOCK)->Send(&scriptEvent, scriptEvent.guid); + mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_UNLOCK)->setEvent(&scriptEvent); + mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_UNLOCK)->Send(scriptEvent.guid); } void WorldFunctions::SendDoorState() noexcept { - mwmp::Networking::get().getWorldController()->GetPacket(ID_DOOR_STATE)->Send(&scriptEvent, scriptEvent.guid); + mwmp::Networking::get().getWorldController()->GetPacket(ID_DOOR_STATE)->setEvent(&scriptEvent); + mwmp::Networking::get().getWorldController()->GetPacket(ID_DOOR_STATE)->Send(scriptEvent.guid); } void WorldFunctions::SendContainer() noexcept { - mwmp::Networking::get().getWorldController()->GetPacket(ID_CONTAINER)->Send(&scriptEvent, scriptEvent.guid); + mwmp::Networking::get().getWorldController()->GetPacket(ID_CONTAINER)->setEvent(&scriptEvent); + mwmp::Networking::get().getWorldController()->GetPacket(ID_CONTAINER)->Send(scriptEvent.guid); } void WorldFunctions::SetHour(unsigned short pid, double hour) noexcept @@ -304,7 +311,8 @@ void WorldFunctions::SetHour(unsigned short pid, double hour) noexcept player->month = -1; player->day = -1; - mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_TIME)->Send(player, false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_TIME)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_TIME)->Send(false); } void WorldFunctions::SetMonth(unsigned short pid, int month) noexcept @@ -316,7 +324,8 @@ void WorldFunctions::SetMonth(unsigned short pid, int month) noexcept player->month = month; player->day = -1; - mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_TIME)->Send(player, false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_TIME)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_TIME)->Send(false); } @@ -329,5 +338,6 @@ void WorldFunctions::SetDay(unsigned short pid, int day) noexcept player->month = -1; player->day = day; - mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_TIME)->Send(player, false); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_TIME)->setPlayer(player); + mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_TIME)->Send(false); } diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 0c4a136c3..e4af9c3b0 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -126,7 +126,8 @@ namespace MWGui worldObject.containerChanges.items.push_back(containerItem); worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send(); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s\n- item: %s, %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str(), @@ -187,7 +188,8 @@ namespace MWGui worldObject.containerChanges.items.push_back(containerItem); worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send(); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s\n- item: %s, %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str(), @@ -330,7 +332,8 @@ namespace MWGui worldObject.refNumIndex = mPtr.getCellRef().getRefNum().mIndex; worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send(); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s", worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str()); diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 013e6ac6f..eba905b6c 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -93,7 +93,8 @@ namespace MWGui worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_PLACE)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_PLACE)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_PLACE)->Send(); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_PLACE\n- cellRef: %s, %i\n- count: %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldObject.count); diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index cf3d0e2d7..5ea8fb434 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -652,7 +652,8 @@ namespace MWGui worldObject.refNumIndex = object.getCellRef().getRefNum().mIndex; worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(); mwmp::Main::get().getLocalPlayer()->sendInventory(); /* End of tes3mp addition diff --git a/apps/openmw/mwmechanics/security.cpp b/apps/openmw/mwmechanics/security.cpp index f8d2d26a3..aa42a2199 100644 --- a/apps/openmw/mwmechanics/security.cpp +++ b/apps/openmw/mwmechanics/security.cpp @@ -70,8 +70,9 @@ namespace MWMechanics worldObject.refId = lock.getCellRef().getRefId(); worldObject.refNumIndex = lock.getCellRef().getRefNum().mIndex; worldEvent->addObject(worldObject); - - mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->Send(worldEvent); + + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->Send(); /* End of tes3mp addition */ diff --git a/apps/openmw/mwmp/GUIChat.cpp b/apps/openmw/mwmp/GUIChat.cpp index a4d6be24e..39148f865 100644 --- a/apps/openmw/mwmp/GUIChat.cpp +++ b/apps/openmw/mwmp/GUIChat.cpp @@ -134,7 +134,8 @@ namespace mwmp localPlayer->chatMessage = str; - networking->getPlayerPacket(ID_CHAT_MESSAGE)->Send(localPlayer); + networking->getPlayerPacket(ID_CHAT_MESSAGE)->setPlayer(localPlayer); + networking->getPlayerPacket(ID_CHAT_MESSAGE)->Send(); } void GUIChat::clean() diff --git a/apps/openmw/mwmp/GUIController.cpp b/apps/openmw/mwmp/GUIController.cpp index fb96e2048..eb7066cd7 100644 --- a/apps/openmw/mwmp/GUIController.cpp +++ b/apps/openmw/mwmp/GUIController.cpp @@ -159,7 +159,8 @@ void mwmp::GUIController::onInputBoxDone(MWGui::WindowBase *parWindow) LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "GUIController::OnInputBoxDone: %s.",mInputBox->getTextInput().c_str()); Main::get().getLocalPlayer()->guiMessageBox.data = mInputBox->getTextInput(); - Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->Send(Main::get().getLocalPlayer()); + Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->setPlayer(Main::get().getLocalPlayer()); + Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->Send(); MWBase::Environment::get().getWindowManager()->removeDialog(mInputBox); mInputBox = 0; @@ -201,7 +202,8 @@ void mwmp::GUIController::update(float dt) LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Pressed: %d", pressedButton); calledMessageBox = false; Main::get().getLocalPlayer()->guiMessageBox.data = MyGUI::utility::toString(pressedButton); - Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->Send(Main::get().getLocalPlayer()); + Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->setPlayer(Main::get().getLocalPlayer()); + Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->Send(); } blockConsole(); diff --git a/apps/openmw/mwmp/GUIDialogList.cpp b/apps/openmw/mwmp/GUIDialogList.cpp index ea33c6d47..5c0111f4c 100644 --- a/apps/openmw/mwmp/GUIDialogList.cpp +++ b/apps/openmw/mwmp/GUIDialogList.cpp @@ -41,7 +41,8 @@ void GUIDialogList::mousePressed(MyGUI::Widget * /*widget*/) size_t id = mListBox->getIndexSelected(); Main::get().getLocalPlayer()->guiMessageBox.data = MyGUI::utility::toString(id); - Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->Send(Main::get().getLocalPlayer()); + Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->setPlayer(Main::get().getLocalPlayer()); + Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->Send(); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Selected id: %d", id); if(id == MyGUI::ITEM_NONE) diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 1d109b2f8..1b056f08d 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -108,7 +108,8 @@ bool LocalPlayer::charGenThread() windowManager->pushGuiMode(MWGui::GM_Review); break; } - getNetworking()->getPlayerPacket(ID_PLAYER_CHARGEN)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_CHARGEN)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_CHARGEN)->Send(); charGenStage.current++; return false; @@ -124,7 +125,8 @@ bool LocalPlayer::charGenThread() birthsign = world->getPlayer().getBirthSign(); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_PLAYER_BASEINFO to server with my CharGen info"); - getNetworking()->getPlayerPacket(ID_PLAYER_BASEINFO)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_BASEINFO)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_BASEINFO)->Send(); // Send stats packets if this is the 2nd round of CharGen that // only happens for new characters @@ -136,7 +138,8 @@ bool LocalPlayer::charGenThread() updateLevel(true); sendClass(); sendSpellbook(); - getNetworking()->getPlayerPacket(ID_PLAYER_CHARGEN)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_CHARGEN)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_CHARGEN)->Send(); } sendCellStates(); @@ -183,7 +186,8 @@ void LocalPlayer::updateDynamicStats(bool forceUpdate) timer = 0; - getNetworking()->getPlayerPacket(ID_PLAYER_DYNAMICSTATS)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_DYNAMICSTATS)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_DYNAMICSTATS)->Send(); } } } @@ -205,7 +209,8 @@ void LocalPlayer::updateAttributes(bool forceUpdate) if (attributesChanged || forceUpdate) { - getNetworking()->getPlayerPacket(ID_PLAYER_ATTRIBUTE)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_ATTRIBUTE)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_ATTRIBUTE)->Send(); } } @@ -244,7 +249,8 @@ void LocalPlayer::updateSkills(bool forceUpdate) if (skillsChanged || forceUpdate) { npcStats.mLevelProgress = ptrNpcStats.getLevelProgress(); - getNetworking()->getPlayerPacket(ID_PLAYER_SKILL)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_SKILL)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_SKILL)->Send(); } } @@ -256,7 +262,8 @@ void LocalPlayer::updateLevel(bool forceUpdate) if (ptrNpcStats.getLevel() != creatureStats.mLevel || forceUpdate) { creatureStats.mLevel = ptrNpcStats.getLevel(); - getNetworking()->getPlayerPacket(ID_PLAYER_LEVEL)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_LEVEL)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_LEVEL)->Send(); // Also update skills to refresh level progress and attribute bonuses // for next level up @@ -296,7 +303,8 @@ void LocalPlayer::updatePosition(bool forceUpdate) direction.pos[1] = move.mPosition[1]; direction.pos[2] = move.mPosition[2]; - getNetworking()->getPlayerPacket(ID_PLAYER_POS)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_POS)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_POS)->Send(); } else if (isJumping && world->isOnGround(player)) { @@ -308,7 +316,8 @@ void LocalPlayer::updatePosition(bool forceUpdate) { sentJumpEnd = true; position = ptrPos; - getNetworking()->getPlayerPacket(ID_PLAYER_POS)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_POS)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_POS)->Send(); } } @@ -354,7 +363,8 @@ void LocalPlayer::updateCell(bool forceUpdate) // cell change events in server scripts will have the wrong player position updatePosition(true); - getNetworking()->getPlayerPacket(ID_PLAYER_CELL_CHANGE)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_CELL_CHANGE)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_CELL_CHANGE)->Send(); // Also force an update to skills (to send all progress to skill increases) updateSkills(true); @@ -418,7 +428,8 @@ void LocalPlayer::updateEquipment(bool forceUpdate) if (equipChanged) { - getNetworking()->getPlayerPacket(ID_PLAYER_EQUIPMENT)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_EQUIPMENT)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_EQUIPMENT)->Send(); equipChanged = false; } } @@ -546,7 +557,8 @@ void LocalPlayer::updateDeadState(bool forceUpdate) creatureStats.mDead = true; LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_PLAYER_DEATH to server about myself"); - getNetworking()->getPlayerPacket(ID_PLAYER_DEATH)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_DEATH)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_DEATH)->Send(); isDead = true; } else if (ptrNpcStats->getHealth().getCurrent() > 0 && isDead) @@ -619,7 +631,8 @@ void LocalPlayer::updateDrawStateAndFlags(bool forceUpdate) if (isJumping) mwmp::Main::get().getLocalPlayer()->updatePosition(true); // fix position after jump; - getNetworking()->getPlayerPacket(ID_PLAYER_DRAWSTATE)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_DRAWSTATE)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_DRAWSTATE)->Send(); } } @@ -956,7 +969,8 @@ void LocalPlayer::sendClass() else charClass.mId = cls->mId; - getNetworking()->getPlayerPacket(ID_PLAYER_CHARCLASS)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_CHARCLASS)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_CHARCLASS)->Send(); } void LocalPlayer::sendInventory() @@ -981,7 +995,8 @@ void LocalPlayer::sendInventory() inventoryChanges.count = (unsigned int) inventoryChanges.items.size(); inventoryChanges.action = InventoryChanges::SET; - Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_INVENTORY)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_INVENTORY)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_INVENTORY)->Send(); } void LocalPlayer::sendSpellbook() @@ -1003,12 +1018,14 @@ void LocalPlayer::sendSpellbook() } spellbookChanges.action = SpellbookChanges::SET; - Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->Send(); } void LocalPlayer::sendCellStates() { - Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_CELL_STATE)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_CELL_STATE)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_CELL_STATE)->Send(); } @@ -1024,7 +1041,8 @@ void LocalPlayer::sendSpellAddition(std::string id) spellbookChanges.spells.push_back(spell); spellbookChanges.action = SpellbookChanges::ADD; - Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->Send(); } void LocalPlayer::sendSpellRemoval(std::string id) @@ -1039,7 +1057,8 @@ void LocalPlayer::sendSpellRemoval(std::string id) spellbookChanges.spells.push_back(spell); spellbookChanges.action = SpellbookChanges::REMOVE; - Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->Send(); } void LocalPlayer::sendSpellAddition(const ESM::Spell &spell) @@ -1069,7 +1088,8 @@ void LocalPlayer::sendJournalEntry(const std::string& quest, int index, const MW journalChanges.journalItems.push_back(journalItem); - Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_JOURNAL)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_JOURNAL)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_JOURNAL)->Send(); } void LocalPlayer::sendJournalIndex(const std::string& quest, int index) @@ -1083,7 +1103,8 @@ void LocalPlayer::sendJournalIndex(const std::string& quest, int index) journalChanges.journalItems.push_back(journalItem); - Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_JOURNAL)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_JOURNAL)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_JOURNAL)->Send(); } void LocalPlayer::sendAttack(Attack::TYPE type) @@ -1092,7 +1113,9 @@ void LocalPlayer::sendAttack(Attack::TYPE type) attack.type = type; attack.pressed = false; - getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->Send(this); + + getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->Send(); } void LocalPlayer::clearCellStates() @@ -1162,5 +1185,6 @@ void LocalPlayer::prepareAttack(Attack::TYPE type, bool state) attack.target = RakNet::RakNetGUID(); attack.attacker = guid; - getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->Send(this); + getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->Send(); } diff --git a/apps/openmw/mwmp/Main.cpp b/apps/openmw/mwmp/Main.cpp index 78da9830f..98b499acd 100644 --- a/apps/openmw/mwmp/Main.cpp +++ b/apps/openmw/mwmp/Main.cpp @@ -200,8 +200,10 @@ void Main::updateWorld(float dt) const init = false; LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_PLAYER_BASEINFO to server"); - mNetworking->getPlayerPacket(ID_PLAYER_BASEINFO)->Send(getLocalPlayer()); - mNetworking->getPlayerPacket(ID_LOADED)->Send(getLocalPlayer()); + mNetworking->getPlayerPacket(ID_PLAYER_BASEINFO)->setPlayer(getLocalPlayer()); + mNetworking->getPlayerPacket(ID_LOADED)->setPlayer(getLocalPlayer()); + mNetworking->getPlayerPacket(ID_PLAYER_BASEINFO)->Send(); + mNetworking->getPlayerPacket(ID_LOADED)->Send(); mLocalPlayer->updateDynamicStats(true); get().getGUIController()->setChatVisible(true); } diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index dfd9390a1..8447774d8 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -196,7 +196,9 @@ void Networking::preInit(std::vector &content, Files::Collections & PacketPreInit packetPreInit(peer); RakNet::BitStream bs; RakNet::RakNetGUID guid; - packetPreInit.Packet(&bs, guid, true, checksums); + packetPreInit.setGUID(guid); + packetPreInit.Packet(&bs, true, checksums); + bool done = false; PacketPreInit::PluginContainer checksumsResponse; @@ -248,7 +250,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) { case ID_HANDSHAKE: { - myPacket->Send(getLocalPlayer(), serverAddr); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Send(serverAddr); break; } case ID_PLAYER_BASEINFO: @@ -262,11 +265,14 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) if (packet->length == myPacket->headerSize()) { LOG_APPEND(Log::LOG_INFO, "- Requesting info"); - myPacket->Send(getLocalPlayer(), serverAddr); + + myPacket->setPlayer(getLocalPlayer()); + myPacket->Send(serverAddr); } else { - myPacket->Packet(&bsIn, getLocalPlayer(), false); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Packet(&bsIn, false); LOG_APPEND(Log::LOG_INFO, "- Updating LocalPlayer"); getLocalPlayer()->updateChar(); } @@ -281,7 +287,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) pl = Players::newPlayer(guid); } - myPacket->Packet(&bsIn, pl, false); + myPacket->setPlayer(pl); + myPacket->Packet(&bsIn, false); Players::createPlayer(guid); } break; @@ -293,7 +300,9 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) if (packet->length != myPacket->headerSize()) { LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "ID_PLAYER_POS changed by server"); - myPacket->Packet(&bsIn, getLocalPlayer(), false); + + myPacket->setPlayer(getLocalPlayer()); + myPacket->Packet(&bsIn, false); getLocalPlayer()->setPosition(); } else @@ -301,7 +310,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) } else if (pl != 0) { - myPacket->Packet(&bsIn, pl, false); + myPacket->setPlayer(pl); + myPacket->Packet(&bsIn, false); pl->updateMarker(); } break; @@ -331,13 +341,15 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) } else { - myPacket->Packet(&bsIn, getLocalPlayer(), false); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Packet(&bsIn, false); getLocalPlayer()->setEquipment(); } } else if (pl != 0) { - myPacket->Packet(&bsIn, pl, false); + myPacket->setPlayer(pl); + myPacket->Packet(&bsIn, false); pl->updateEquipment(); } break; @@ -352,7 +364,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) } else { - myPacket->Packet(&bsIn, getLocalPlayer(), false); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Packet(&bsIn, false); int inventoryAction = getLocalPlayer()->inventoryChanges.action; if (inventoryAction == InventoryChanges::ADD) @@ -381,7 +394,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) } else { - myPacket->Packet(&bsIn, getLocalPlayer(), false); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Packet(&bsIn, false); int spellbookAction = getLocalPlayer()->spellbookChanges.action; if (spellbookAction == SpellbookChanges::ADD) @@ -410,7 +424,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) } else { - myPacket->Packet(&bsIn, getLocalPlayer(), false); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Packet(&bsIn, false); getLocalPlayer()->addJournalItems(); } } @@ -420,7 +435,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) { if (pl != 0) { - myPacket->Packet(&bsIn, pl, false); + myPacket->setPlayer(pl); + myPacket->Packet(&bsIn, false); //cout << "Player: " << pl->Npc()->mName << " pressed: " << (pl->getAttack()->pressed == 1) << endl; if (pl->attack.pressed == 0) @@ -488,13 +504,15 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) } else { - myPacket->Packet(&bsIn, getLocalPlayer(), false); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Packet(&bsIn, false); getLocalPlayer()->setDynamicStats(); } } else if (pl != 0) { - myPacket->Packet(&bsIn, pl, false); + myPacket->setPlayer(pl); + myPacket->Packet(&bsIn, false); MWWorld::Ptr ptrPlayer = pl->getPtr(); MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer); @@ -520,7 +538,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) MWMechanics::DynamicStat health = player.getClass().getCreatureStats(player).getHealth(); health.setCurrent(0); player.getClass().getCreatureStats(player).setHealth(health); - myPacket->Send(getLocalPlayer(), serverAddr); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Send(serverAddr); } else if (pl != 0) { @@ -550,10 +569,12 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) // still have it readied but be unable to use it unless we clear it here player.getClass().getNpcStats(player).setDrawState(MWMechanics::DrawState_Nothing); - myPacket->Send(getLocalPlayer(), serverAddr); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Send(serverAddr); getLocalPlayer()->updateDynamicStats(true); - playerController.GetPacket(ID_PLAYER_DYNAMICSTATS)->Send(getLocalPlayer(), serverAddr); + playerController.GetPacket(ID_PLAYER_DYNAMICSTATS)->setPlayer(getLocalPlayer()); + playerController.GetPacket(ID_PLAYER_DYNAMICSTATS)->Send(serverAddr); } else if (pl != 0) { @@ -580,13 +601,15 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) getLocalPlayer()->updateCell(true); else { - myPacket->Packet(&bsIn, getLocalPlayer(), false); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Packet(&bsIn, false); getLocalPlayer()->setCell(); } } else if (pl != 0) { - myPacket->Packet(&bsIn, pl, false); + myPacket->setPlayer(pl); + myPacket->Packet(&bsIn, false); pl->updateCell(); } break; @@ -607,7 +630,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) getLocalPlayer()->updateDrawStateAndFlags(true); else if (pl != 0) { - myPacket->Packet(&bsIn, pl, false); + myPacket->setPlayer(pl); + myPacket->Packet(&bsIn, false); pl->updateDrawState(); } break; @@ -617,12 +641,14 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) std::string message; if (guid == myGuid) { - myPacket->Packet(&bsIn, getLocalPlayer(), false); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Packet(&bsIn, false); message = getLocalPlayer()->chatMessage; } else if (pl != 0) { - myPacket->Packet(&bsIn, pl, false); + myPacket->setPlayer(pl); + myPacket->Packet(&bsIn, false); message = pl->chatMessage; } Main::get().getGUIController()->printChatMessage(message); @@ -633,7 +659,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) { if (guid == myGuid) { - myPacket->Packet(&bsIn, getLocalPlayer(), false); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Packet(&bsIn, false); } break; } @@ -647,13 +674,15 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) } else { - myPacket->Packet(&bsIn, getLocalPlayer(), false); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Packet(&bsIn, false); getLocalPlayer()->setAttributes(); } } else if (pl != 0) { - myPacket->Packet(&bsIn, pl, false); + myPacket->setPlayer(pl); + myPacket->Packet(&bsIn, false); MWWorld::Ptr ptrPlayer = pl->getPtr(); MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer); @@ -677,13 +706,15 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) } else { - myPacket->Packet(&bsIn, getLocalPlayer(), false); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Packet(&bsIn, false); getLocalPlayer()->setSkills(); } } else if (pl != 0) { - myPacket->Packet(&bsIn, pl, false); + myPacket->setPlayer(pl); + myPacket->Packet(&bsIn, false); MWWorld::Ptr ptrPlayer = pl->getPtr(); MWMechanics::NpcStats *ptrNpcStats = &ptrPlayer.getClass().getNpcStats(ptrPlayer); @@ -707,13 +738,15 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) } else { - myPacket->Packet(&bsIn, getLocalPlayer(), false); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Packet(&bsIn, false); getLocalPlayer()->setLevel(); } } else if (pl != 0) { - myPacket->Packet(&bsIn, pl, false); + myPacket->setPlayer(pl); + myPacket->Packet(&bsIn, false); MWWorld::Ptr ptrPlayer = pl->getPtr(); MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer); @@ -726,7 +759,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) { if (guid == myGuid) { - myPacket->Packet(&bsIn, getLocalPlayer(), false); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Packet(&bsIn, false); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "ID_GUI_MESSAGEBOX, Type %d, MSG %s", getLocalPlayer()->guiMessageBox.type, getLocalPlayer()->guiMessageBox.label.c_str()); @@ -752,7 +786,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) getLocalPlayer()->sendClass(); else { - myPacket->Packet(&bsIn, getLocalPlayer(), false); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Packet(&bsIn, false); getLocalPlayer()->setClass(); } } @@ -762,7 +797,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) { if (guid == myGuid) { - myPacket->Packet(&bsIn, getLocalPlayer(), false); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Packet(&bsIn, false); MWBase::World *world = MWBase::Environment::get().getWorld(); if (getLocalPlayer()->hour != -1) world->setHour(getLocalPlayer()->hour); @@ -775,7 +811,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) } case ID_GAME_CONSOLE: { - myPacket->Packet(&bsIn, getLocalPlayer(), false); + myPacket->setPlayer(getLocalPlayer()); + myPacket->Packet(&bsIn, false); break; } default: @@ -796,7 +833,8 @@ void Networking::processWorldPacket(RakNet::Packet *packet) WorldPacket *myPacket = worldController.GetPacket(packet->data[0]); - myPacket->Packet(&bsIn, &worldEvent, false); + myPacket->setEvent(&worldEvent); + myPacket->Packet(&bsIn, false); switch (packet->data[0]) { diff --git a/apps/openmw/mwmp/WorldEvent.cpp b/apps/openmw/mwmp/WorldEvent.cpp index 2a32c73ac..df45453ca 100644 --- a/apps/openmw/mwmp/WorldEvent.cpp +++ b/apps/openmw/mwmp/WorldEvent.cpp @@ -74,7 +74,8 @@ void WorldEvent::sendContainers(MWWorld::CellStore* cellStore) worldEvent->addObject(worldObject); } - mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send(); } void WorldEvent::editContainers(MWWorld::CellStore* cellStore) diff --git a/apps/openmw/mwscript/animationextensions.cpp b/apps/openmw/mwscript/animationextensions.cpp index defa3e1eb..17c8de00f 100644 --- a/apps/openmw/mwscript/animationextensions.cpp +++ b/apps/openmw/mwscript/animationextensions.cpp @@ -81,7 +81,8 @@ namespace MWScript worldObject.animMode = mode; worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_ANIM_PLAY)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_ANIM_PLAY)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_ANIM_PLAY)->Send(); } /* End of tes3mp addition diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 25a2cda44..f17b2aefb 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -212,7 +212,8 @@ namespace MWScript worldObject.shortVal = value; worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_SHORT)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_SHORT)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_SHORT)->Send(); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_LOCAL_SHORT\n- cellRef: %s, %i\n- cell: %s\n- index: %i\n- shortVal: %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str(), @@ -257,7 +258,8 @@ namespace MWScript worldObject.floatVal = value; worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_FLOAT)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_FLOAT)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_FLOAT)->Send(); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_LOCAL_FLOAT\n- cellRef: %s, %i\n- cell: %s\n- index: %i\n- floatVal: %f", worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str(), @@ -324,7 +326,8 @@ namespace MWScript worldObject.shortVal = value; worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_GLOBAL_SHORT)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_GLOBAL_SHORT)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_GLOBAL_SHORT)->Send(); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_GLOBAL_SHORT\n- varName: %s\n- shortVal: %i", worldObject.varName.c_str(), worldObject.shortVal); @@ -669,7 +672,8 @@ namespace MWScript worldObject.shortVal = value; worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_MEMBER_SHORT)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_MEMBER_SHORT)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_MEMBER_SHORT)->Send(); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_MEMBER_SHORT\n- cellRef: %s\n- index: %i\n- shortVal: %i", worldObject.refId.c_str(), worldObject.index, worldObject.shortVal); diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index b49f2484d..f642182bc 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -102,7 +102,8 @@ namespace MWScript worldObject.allowSkipping = allowSkipping; worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_VIDEO_PLAY)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_VIDEO_PLAY)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_VIDEO_PLAY)->Send(); /* End of tes3mp addition */ @@ -220,7 +221,8 @@ namespace MWScript worldObject.lockLevel = lockLevel; worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_LOCK)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_LOCK)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_LOCK)->Send(); /* End of tes3mp addition */ @@ -265,7 +267,8 @@ namespace MWScript worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex; worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->Send(); /* End of tes3mp addition */ @@ -744,7 +747,8 @@ namespace MWScript worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex; worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(); /* End of tes3mp addition */ diff --git a/apps/openmw/mwscript/soundextensions.cpp b/apps/openmw/mwscript/soundextensions.cpp index b9c0eb1f9..cfda551b9 100644 --- a/apps/openmw/mwscript/soundextensions.cpp +++ b/apps/openmw/mwscript/soundextensions.cpp @@ -82,7 +82,8 @@ namespace MWScript worldObject.filename = sound; worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_MUSIC_PLAY)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_MUSIC_PLAY)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_MUSIC_PLAY)->Send(); /* End of tes3mp addition */ diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index 477657b8d..44f1a7d07 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -61,7 +61,8 @@ namespace MWScript worldObject.scale = scale; worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_SCALE)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_SCALE)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_SCALE)->Send(); /* End of tes3mp addition */ @@ -578,7 +579,8 @@ namespace MWScript worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_PLACE)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_PLACE)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_PLACE)->Send(); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_PLACE\n- cellRef: %s, %i\n- count: %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldObject.count); diff --git a/apps/openmw/mwworld/actiontake.cpp b/apps/openmw/mwworld/actiontake.cpp index dd559e44b..d00de6004 100644 --- a/apps/openmw/mwworld/actiontake.cpp +++ b/apps/openmw/mwworld/actiontake.cpp @@ -42,7 +42,8 @@ namespace MWWorld worldObject.refNumIndex = getTarget().getCellRef().getRefNum().mIndex; worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_DELETE about\n- cellRef: %s, %i\n- cell: %s", worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str()); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 990ab65ab..8820c0f28 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2332,7 +2332,8 @@ namespace MWWorld worldObject.doorState = state; worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_STATE)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_STATE)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_STATE)->Send(); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Door activation 1\n- cellRef: %s, %i\n- cell: %s\n- state: %s", worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str(), @@ -2361,7 +2362,8 @@ namespace MWWorld worldObject.doorState = state; worldEvent->addObject(worldObject); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_STATE)->Send(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_STATE)->setEvent(worldEvent); + mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_STATE)->Send(); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Door activation 2\n- cellRef: %s, %i\n- cell: %s\n- state: %s", worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str(), diff --git a/components/openmw-mp/Packets/BasePacket.cpp b/components/openmw-mp/Packets/BasePacket.cpp index 8699f3ef3..57fa5bfc5 100644 --- a/components/openmw-mp/Packets/BasePacket.cpp +++ b/components/openmw-mp/Packets/BasePacket.cpp @@ -18,7 +18,7 @@ BasePacket::~BasePacket() } -void BasePacket::Packet(RakNet::BitStream *bs, RakNet::RakNetGUID &guid, bool send) +void BasePacket::Packet(RakNet::BitStream *bs, bool send) { this->bs = bs; @@ -54,3 +54,32 @@ void BasePacket::RequestData(RakNet::RakNetGUID guid) bsSend->Write(guid); peer->Send(bsSend, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false); } + +void BasePacket::Send(RakNet::AddressOrGUID destination) +{ + bsSend->ResetWritePointer(); + Packet(bsSend, true); + peer->Send(bsSend, priority, reliability, 0, destination, false); +} + +void BasePacket::Send(bool toOther) +{ + bsSend->ResetWritePointer(); + Packet(bsSend, true); + peer->Send(bsSend, priority, reliability, 0, guid, toOther); +} + +void BasePacket::Read() +{ + Packet(bsRead, false); +} + +void BasePacket::setGUID(RakNet::RakNetGUID guid) +{ + this->guid = guid; +} + +RakNet::RakNetGUID BasePacket::getGUID() +{ + return guid; +} diff --git a/components/openmw-mp/Packets/BasePacket.hpp b/components/openmw-mp/Packets/BasePacket.hpp index 244a273ee..395d7094b 100644 --- a/components/openmw-mp/Packets/BasePacket.hpp +++ b/components/openmw-mp/Packets/BasePacket.hpp @@ -14,9 +14,15 @@ namespace mwmp public: BasePacket(RakNet::RakPeerInterface *peer); - ~BasePacket(); + virtual ~BasePacket(); - virtual void Packet(RakNet::BitStream *bs, RakNet::RakNetGUID &guid, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); + virtual void Send(bool toOtherPlayers = true); + virtual void Send(RakNet::AddressOrGUID destination); + virtual void Read(); + + void setGUID(RakNet::RakNetGUID guid); + RakNet::RakNetGUID getGUID(); void SetReadStream(RakNet::BitStream *bitStream); void SetSendStream(RakNet::BitStream *bitStream); @@ -88,6 +94,7 @@ namespace mwmp PacketPriority priority; RakNet::BitStream *bsRead, *bsSend, *bs; RakNet::RakPeerInterface *peer; + RakNet::RakNetGUID guid; }; } diff --git a/components/openmw-mp/Packets/PacketPreInit.cpp b/components/openmw-mp/Packets/PacketPreInit.cpp index 02048b4a2..fb6e59ca2 100644 --- a/components/openmw-mp/Packets/PacketPreInit.cpp +++ b/components/openmw-mp/Packets/PacketPreInit.cpp @@ -11,9 +11,9 @@ mwmp::PacketPreInit::PacketPreInit(RakNet::RakPeerInterface *peer) : BasePacket( packetID = ID_GAME_PREINIT; } -void mwmp::PacketPreInit::Packet(RakNet::BitStream *bs, RakNet::RakNetGUID &guid, bool send, PluginContainer &checksums) +void mwmp::PacketPreInit::Packet(RakNet::BitStream *bs, bool send, PluginContainer &checksums) { - BasePacket::Packet(bs, guid, send); + BasePacket::Packet(bs, send); unsigned int size = checksums.size(); RW(size, send); diff --git a/components/openmw-mp/Packets/PacketPreInit.hpp b/components/openmw-mp/Packets/PacketPreInit.hpp index 82185c4c8..61b359df5 100644 --- a/components/openmw-mp/Packets/PacketPreInit.hpp +++ b/components/openmw-mp/Packets/PacketPreInit.hpp @@ -19,7 +19,7 @@ namespace mwmp PacketPreInit(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, RakNet::RakNetGUID &guid, bool send, PluginContainer &checksums); + virtual void Packet(RakNet::BitStream *bs, bool send, PluginContainer &checksums); }; } diff --git a/components/openmw-mp/Packets/Player/PacketChatMessage.cpp b/components/openmw-mp/Packets/Player/PacketChatMessage.cpp index 0c1e7a6fe..b9e0a68fd 100644 --- a/components/openmw-mp/Packets/Player/PacketChatMessage.cpp +++ b/components/openmw-mp/Packets/Player/PacketChatMessage.cpp @@ -10,9 +10,9 @@ mwmp::PacketChatMessage::PacketChatMessage(RakNet::RakPeerInterface *peer) : Pla packetID = ID_CHAT_MESSAGE; } -void mwmp::PacketChatMessage::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send) +void mwmp::PacketChatMessage::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); RW(player->chatMessage, send); } diff --git a/components/openmw-mp/Packets/Player/PacketChatMessage.hpp b/components/openmw-mp/Packets/Player/PacketChatMessage.hpp index c15dc1083..937e59f03 100644 --- a/components/openmw-mp/Packets/Player/PacketChatMessage.hpp +++ b/components/openmw-mp/Packets/Player/PacketChatMessage.hpp @@ -14,7 +14,7 @@ namespace mwmp public: PacketChatMessage(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketConsole.hpp b/components/openmw-mp/Packets/Player/PacketConsole.hpp index 57828a42b..ea207412c 100644 --- a/components/openmw-mp/Packets/Player/PacketConsole.hpp +++ b/components/openmw-mp/Packets/Player/PacketConsole.hpp @@ -17,9 +17,9 @@ namespace mwmp { packetID = ID_GAME_CONSOLE; } - void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) + void Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); RW(player->consoleAllowed, send); } }; diff --git a/components/openmw-mp/Packets/Player/PacketGUIBoxes.cpp b/components/openmw-mp/Packets/Player/PacketGUIBoxes.cpp index 18c4764c7..2b63ce91f 100644 --- a/components/openmw-mp/Packets/Player/PacketGUIBoxes.cpp +++ b/components/openmw-mp/Packets/Player/PacketGUIBoxes.cpp @@ -12,9 +12,9 @@ PacketGUIBoxes::PacketGUIBoxes(RakNet::RakPeerInterface *peer) : PlayerPacket(pe packetID = ID_GUI_MESSAGEBOX; } -void PacketGUIBoxes::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) +void PacketGUIBoxes::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); RW(player->guiMessageBox.id, send); RW(player->guiMessageBox.type, send); diff --git a/components/openmw-mp/Packets/Player/PacketGUIBoxes.hpp b/components/openmw-mp/Packets/Player/PacketGUIBoxes.hpp index 8d71257f9..a96030b4d 100644 --- a/components/openmw-mp/Packets/Player/PacketGUIBoxes.hpp +++ b/components/openmw-mp/Packets/Player/PacketGUIBoxes.hpp @@ -15,7 +15,7 @@ namespace mwmp public: PacketGUIBoxes(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketHandshake.cpp b/components/openmw-mp/Packets/Player/PacketHandshake.cpp index 983a7f6c5..5078426a0 100644 --- a/components/openmw-mp/Packets/Player/PacketHandshake.cpp +++ b/components/openmw-mp/Packets/Player/PacketHandshake.cpp @@ -12,9 +12,9 @@ PacketHandshake::PacketHandshake(RakNet::RakPeerInterface *peer) : PlayerPacket( packetID = ID_HANDSHAKE; } -void PacketHandshake::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) +void PacketHandshake::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); RW(player->npc.mName, send); RW(player->passw, send); } diff --git a/components/openmw-mp/Packets/Player/PacketHandshake.hpp b/components/openmw-mp/Packets/Player/PacketHandshake.hpp index 539be878b..e6494c04f 100644 --- a/components/openmw-mp/Packets/Player/PacketHandshake.hpp +++ b/components/openmw-mp/Packets/Player/PacketHandshake.hpp @@ -14,7 +14,7 @@ namespace mwmp public: PacketHandshake(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerActiveSkills.cpp b/components/openmw-mp/Packets/Player/PacketPlayerActiveSkills.cpp index 0633534a0..c19a1e223 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerActiveSkills.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerActiveSkills.cpp @@ -12,9 +12,9 @@ PacketPlayerActiveSkills::PacketPlayerActiveSkills(RakNet::RakPeerInterface *pee packetID = ID_PLAYER_ACTIVESKILLS; } -void PacketPlayerActiveSkills::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send) +void PacketPlayerActiveSkills::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); unsigned long spells = 0; diff --git a/components/openmw-mp/Packets/Player/PacketPlayerActiveSkills.hpp b/components/openmw-mp/Packets/Player/PacketPlayerActiveSkills.hpp index 6b417633e..bc33bbe74 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerActiveSkills.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerActiveSkills.hpp @@ -14,7 +14,7 @@ namespace mwmp public: PacketPlayerActiveSkills(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerAttack.cpp b/components/openmw-mp/Packets/Player/PacketPlayerAttack.cpp index 5ee41d65c..3db761a20 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerAttack.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerAttack.cpp @@ -12,9 +12,9 @@ PacketPlayerAttack::PacketPlayerAttack(RakNet::RakPeerInterface *peer) : PlayerP packetID = ID_PLAYER_ATTACK; } -void PacketPlayerAttack::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send) +void PacketPlayerAttack::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); RW(player->attack.attacker, send); RW(player->attack.target, send); diff --git a/components/openmw-mp/Packets/Player/PacketPlayerAttack.hpp b/components/openmw-mp/Packets/Player/PacketPlayerAttack.hpp index 8c79bd875..2450a7f18 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerAttack.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerAttack.hpp @@ -15,7 +15,7 @@ namespace mwmp public: PacketPlayerAttack(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerAttribute.cpp b/components/openmw-mp/Packets/Player/PacketPlayerAttribute.cpp index 598298f56..1de941dc1 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerAttribute.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerAttribute.cpp @@ -12,9 +12,9 @@ PacketPlayerAttribute::PacketPlayerAttribute(RakNet::RakPeerInterface *peer) : P packetID = ID_PLAYER_ATTRIBUTE; } -void PacketPlayerAttribute::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) +void PacketPlayerAttribute::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); for (int i = 0; i < AttributeCount; ++i) RW(player->creatureStats.mAttributes[i], send); diff --git a/components/openmw-mp/Packets/Player/PacketPlayerAttribute.hpp b/components/openmw-mp/Packets/Player/PacketPlayerAttribute.hpp index e603320e6..5945a278b 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerAttribute.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerAttribute.hpp @@ -15,7 +15,7 @@ namespace mwmp const static int AttributeCount = 8; PacketPlayerAttribute(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerBaseInfo.cpp b/components/openmw-mp/Packets/Player/PacketPlayerBaseInfo.cpp index ee0e6d5f4..b2e80a0f8 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerBaseInfo.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerBaseInfo.cpp @@ -12,9 +12,9 @@ PacketPlayerBaseInfo::PacketPlayerBaseInfo(RakNet::RakPeerInterface *peer) : Pla packetID = ID_PLAYER_BASEINFO; } -void PacketPlayerBaseInfo::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) +void PacketPlayerBaseInfo::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); RW(player->npc.mName, send); RW(player->npc.mModel, send); diff --git a/components/openmw-mp/Packets/Player/PacketPlayerBaseInfo.hpp b/components/openmw-mp/Packets/Player/PacketPlayerBaseInfo.hpp index 765607490..c4f26829e 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerBaseInfo.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerBaseInfo.hpp @@ -14,7 +14,7 @@ namespace mwmp public: PacketPlayerBaseInfo(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerCellChange.cpp b/components/openmw-mp/Packets/Player/PacketPlayerCellChange.cpp index c0c5e7fb7..20d77fb86 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerCellChange.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerCellChange.cpp @@ -13,9 +13,9 @@ mwmp::PacketPlayerCellChange::PacketPlayerCellChange(RakNet::RakPeerInterface *p reliability = RELIABLE_ORDERED; } -void mwmp::PacketPlayerCellChange::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send) +void mwmp::PacketPlayerCellChange::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); RW(player->cell.mData.mFlags, send); RW(player->cell.mData.mX, send); diff --git a/components/openmw-mp/Packets/Player/PacketPlayerCellChange.hpp b/components/openmw-mp/Packets/Player/PacketPlayerCellChange.hpp index d0c6bda3b..e2800b55f 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerCellChange.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerCellChange.hpp @@ -15,7 +15,7 @@ namespace mwmp public: PacketPlayerCellChange(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerCellState.cpp b/components/openmw-mp/Packets/Player/PacketPlayerCellState.cpp index 523fb396a..30050121a 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerCellState.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerCellState.cpp @@ -9,9 +9,9 @@ mwmp::PacketPlayerCellState::PacketPlayerCellState(RakNet::RakPeerInterface *pee reliability = RELIABLE_ORDERED; } -void mwmp::PacketPlayerCellState::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send) +void mwmp::PacketPlayerCellState::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); if (!send) player->cellStateChanges.cellStates.clear(); diff --git a/components/openmw-mp/Packets/Player/PacketPlayerCellState.hpp b/components/openmw-mp/Packets/Player/PacketPlayerCellState.hpp index e4c6f2984..78d8b7b82 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerCellState.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerCellState.hpp @@ -11,7 +11,7 @@ namespace mwmp public: PacketPlayerCellState(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerCharGen.cpp b/components/openmw-mp/Packets/Player/PacketPlayerCharGen.cpp index ded6fac99..63bc61deb 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerCharGen.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerCharGen.cpp @@ -10,9 +10,9 @@ mwmp::PacketPlayerCharGen::PacketPlayerCharGen(RakNet::RakPeerInterface *peer) : packetID = ID_PLAYER_CHARGEN; } -void mwmp::PacketPlayerCharGen::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send) +void mwmp::PacketPlayerCharGen::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); RW(player->charGenStage, send); diff --git a/components/openmw-mp/Packets/Player/PacketPlayerCharGen.hpp b/components/openmw-mp/Packets/Player/PacketPlayerCharGen.hpp index 781f0b617..bf201fc8d 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerCharGen.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerCharGen.hpp @@ -15,7 +15,7 @@ namespace mwmp public: PacketPlayerCharGen(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerClass.cpp b/components/openmw-mp/Packets/Player/PacketPlayerClass.cpp index f0872ec05..7c63b9831 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerClass.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerClass.cpp @@ -10,9 +10,9 @@ mwmp::PacketPlayerClass::PacketPlayerClass(RakNet::RakPeerInterface *peer) : Pla packetID = ID_PLAYER_CHARCLASS; } -void mwmp::PacketPlayerClass::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send) +void mwmp::PacketPlayerClass::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); RW(player->charClass.mId, send); if (player->charClass.mId.empty()) // custom class diff --git a/components/openmw-mp/Packets/Player/PacketPlayerClass.hpp b/components/openmw-mp/Packets/Player/PacketPlayerClass.hpp index c3161e034..400f136ad 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerClass.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerClass.hpp @@ -15,7 +15,7 @@ namespace mwmp public: PacketPlayerClass(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerDeath.hpp b/components/openmw-mp/Packets/Player/PacketPlayerDeath.hpp index e6c481568..380287698 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerDeath.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerDeath.hpp @@ -18,9 +18,9 @@ namespace mwmp { packetID = ID_PLAYER_DEATH; } - void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) + void Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); RW(player->creatureStats.mDead, send); } }; diff --git a/components/openmw-mp/Packets/Player/PacketPlayerDrawState.cpp b/components/openmw-mp/Packets/Player/PacketPlayerDrawState.cpp index b8d2972a9..2d9ddb04f 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerDrawState.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerDrawState.cpp @@ -10,9 +10,9 @@ mwmp::PacketPlayerDrawState::PacketPlayerDrawState(RakNet::RakPeerInterface *pee packetID = ID_PLAYER_DRAWSTATE; } -void mwmp::PacketPlayerDrawState::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send) +void mwmp::PacketPlayerDrawState::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); RW(player->movementFlags, send); RW(player->drawState, send); diff --git a/components/openmw-mp/Packets/Player/PacketPlayerDrawState.hpp b/components/openmw-mp/Packets/Player/PacketPlayerDrawState.hpp index 50f51bbd5..e7180ad75 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerDrawState.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerDrawState.hpp @@ -15,7 +15,7 @@ namespace mwmp public: PacketPlayerDrawState(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerDynamicStats.cpp b/components/openmw-mp/Packets/Player/PacketPlayerDynamicStats.cpp index 4538897ae..d9f282961 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerDynamicStats.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerDynamicStats.cpp @@ -12,9 +12,9 @@ PacketPlayerDynamicStats::PacketPlayerDynamicStats(RakNet::RakPeerInterface *pee packetID = ID_PLAYER_DYNAMICSTATS; } -void PacketPlayerDynamicStats::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) +void PacketPlayerDynamicStats::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); RW(player->creatureStats.mDynamic[0], send); // health RW(player->creatureStats.mDynamic[1], send); // magic RW(player->creatureStats.mDynamic[2], send); // fatigue diff --git a/components/openmw-mp/Packets/Player/PacketPlayerDynamicStats.hpp b/components/openmw-mp/Packets/Player/PacketPlayerDynamicStats.hpp index dd511acab..9d608e6d8 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerDynamicStats.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerDynamicStats.hpp @@ -15,7 +15,7 @@ namespace mwmp public: PacketPlayerDynamicStats(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerEquipment.cpp b/components/openmw-mp/Packets/Player/PacketPlayerEquipment.cpp index fb28a9800..c1e695589 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerEquipment.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerEquipment.cpp @@ -12,9 +12,9 @@ PacketPlayerEquipment::PacketPlayerEquipment(RakNet::RakPeerInterface *peer) : P packetID = ID_PLAYER_EQUIPMENT; } -void PacketPlayerEquipment::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) +void PacketPlayerEquipment::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); for (int i = 0; i < 19; i++) { diff --git a/components/openmw-mp/Packets/Player/PacketPlayerEquipment.hpp b/components/openmw-mp/Packets/Player/PacketPlayerEquipment.hpp index 802b5851a..c204f8579 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerEquipment.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerEquipment.hpp @@ -14,7 +14,7 @@ namespace mwmp public: PacketPlayerEquipment(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerInventory.cpp b/components/openmw-mp/Packets/Player/PacketPlayerInventory.cpp index 65f153edc..8562c894f 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerInventory.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerInventory.cpp @@ -13,9 +13,9 @@ PacketPlayerInventory::PacketPlayerInventory(RakNet::RakPeerInterface *peer) : P packetID = ID_PLAYER_INVENTORY; } -void PacketPlayerInventory::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) +void PacketPlayerInventory::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); RW(player->inventoryChanges.action, send); diff --git a/components/openmw-mp/Packets/Player/PacketPlayerInventory.hpp b/components/openmw-mp/Packets/Player/PacketPlayerInventory.hpp index bc7375243..829a18e68 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerInventory.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerInventory.hpp @@ -14,7 +14,7 @@ namespace mwmp public: PacketPlayerInventory(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerJournal.cpp b/components/openmw-mp/Packets/Player/PacketPlayerJournal.cpp index 92394cfad..3df36d52e 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerJournal.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerJournal.cpp @@ -9,9 +9,9 @@ PacketPlayerJournal::PacketPlayerJournal(RakNet::RakPeerInterface *peer) : Playe packetID = ID_PLAYER_JOURNAL; } -void PacketPlayerJournal::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) +void PacketPlayerJournal::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); if (!send) player->journalChanges.journalItems.clear(); diff --git a/components/openmw-mp/Packets/Player/PacketPlayerJournal.hpp b/components/openmw-mp/Packets/Player/PacketPlayerJournal.hpp index d28014040..02f9402af 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerJournal.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerJournal.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketPlayerJournal(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerLevel.cpp b/components/openmw-mp/Packets/Player/PacketPlayerLevel.cpp index e847f3436..9e83d6398 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerLevel.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerLevel.cpp @@ -8,9 +8,9 @@ PacketPlayerLevel::PacketPlayerLevel(RakNet::RakPeerInterface *peer) : PlayerPac packetID = ID_PLAYER_LEVEL; } -void PacketPlayerLevel::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) +void PacketPlayerLevel::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); RW(player->creatureStats.mLevel, send); } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerLevel.hpp b/components/openmw-mp/Packets/Player/PacketPlayerLevel.hpp index 2dc6758eb..dac2aebec 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerLevel.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerLevel.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketPlayerLevel(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerPosition.cpp b/components/openmw-mp/Packets/Player/PacketPlayerPosition.cpp index 25f7290fa..344ffd3cb 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerPosition.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerPosition.cpp @@ -15,9 +15,9 @@ PacketPlayerPosition::PacketPlayerPosition(RakNet::RakPeerInterface *peer) : Pla //reliability = UNRELIABLE_SEQUENCED; } -void PacketPlayerPosition::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) +void PacketPlayerPosition::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); RW(player->position, send); RW(player->direction, send); diff --git a/components/openmw-mp/Packets/Player/PacketPlayerPosition.hpp b/components/openmw-mp/Packets/Player/PacketPlayerPosition.hpp index a69a4838e..dcbc56213 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerPosition.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerPosition.hpp @@ -14,7 +14,7 @@ namespace mwmp public: PacketPlayerPosition(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerResurrect.hpp b/components/openmw-mp/Packets/Player/PacketPlayerResurrect.hpp index c4f70123a..5080d4db4 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerResurrect.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerResurrect.hpp @@ -18,9 +18,9 @@ namespace mwmp { packetID = ID_PLAYER_RESURRECT; } - void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) + void Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); RW(player->creatureStats.mDead, send); } }; diff --git a/components/openmw-mp/Packets/Player/PacketPlayerSkill.cpp b/components/openmw-mp/Packets/Player/PacketPlayerSkill.cpp index aeaf81fb4..6ced9194e 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerSkill.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerSkill.cpp @@ -14,9 +14,9 @@ PacketPlayerSkill::PacketPlayerSkill(RakNet::RakPeerInterface *peer) : PlayerPac packetID = ID_PLAYER_SKILL; } -void PacketPlayerSkill::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) +void PacketPlayerSkill::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); for (int i = 0; i < SkillCount; ++i) RW(player->npcStats.mSkills[i], send); diff --git a/components/openmw-mp/Packets/Player/PacketPlayerSkill.hpp b/components/openmw-mp/Packets/Player/PacketPlayerSkill.hpp index 8debb7245..1d76015f2 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerSkill.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerSkill.hpp @@ -17,7 +17,7 @@ namespace mwmp const static int AttributeCount = 8; PacketPlayerSkill(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.cpp b/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.cpp index 5671542e9..b6c535b49 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.cpp @@ -9,9 +9,9 @@ PacketPlayerSpellbook::PacketPlayerSpellbook(RakNet::RakPeerInterface *peer) : P packetID = ID_PLAYER_SPELLBOOK; } -void PacketPlayerSpellbook::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) +void PacketPlayerSpellbook::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); RW(player->spellbookChanges.action, send); diff --git a/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.hpp b/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.hpp index 7365c88a6..eda00065c 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.hpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketPlayerSpellbook(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PacketTime.cpp b/components/openmw-mp/Packets/Player/PacketTime.cpp index 30abc871d..f21719faf 100644 --- a/components/openmw-mp/Packets/Player/PacketTime.cpp +++ b/components/openmw-mp/Packets/Player/PacketTime.cpp @@ -12,9 +12,9 @@ PacketTime::PacketTime(RakNet::RakPeerInterface *peer) : PlayerPacket(peer) packetID = ID_GAME_TIME; } -void PacketTime::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) +void PacketTime::Packet(RakNet::BitStream *bs, bool send) { - PlayerPacket::Packet(bs, player, send); + PlayerPacket::Packet(bs, send); RW(player->month, send); RW(player->day, send); diff --git a/components/openmw-mp/Packets/Player/PacketTime.hpp b/components/openmw-mp/Packets/Player/PacketTime.hpp index 69efa442b..31dd9327a 100644 --- a/components/openmw-mp/Packets/Player/PacketTime.hpp +++ b/components/openmw-mp/Packets/Player/PacketTime.hpp @@ -15,7 +15,7 @@ namespace mwmp public: PacketTime(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/Player/PlayerPacket.cpp b/components/openmw-mp/Packets/Player/PlayerPacket.cpp index 99bc15183..649e75426 100644 --- a/components/openmw-mp/Packets/Player/PlayerPacket.cpp +++ b/components/openmw-mp/Packets/Player/PlayerPacket.cpp @@ -5,12 +5,6 @@ using namespace mwmp; -void PlayerPacket::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) -{ - BasePacket::Packet(bs, player->guid, send); - this->player = player; -} - PlayerPacket::PlayerPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer) { packetID = 0; @@ -24,21 +18,13 @@ PlayerPacket::~PlayerPacket() } -void PlayerPacket::Send(BasePlayer *player, RakNet::AddressOrGUID destination) +void PlayerPacket::setPlayer(BasePlayer *player) { - bsSend->ResetWritePointer(); - Packet(bsSend, player, true); - peer->Send(bsSend, priority, reliability, 0, destination, false); -} - -void PlayerPacket::Send(BasePlayer *player, bool toOther) -{ - bsSend->ResetWritePointer(); - Packet(bsSend, player, true); - peer->Send(bsSend, priority, reliability, 0, player->guid, toOther); + this->player = player; + guid = player->guid; } -void PlayerPacket::Read(BasePlayer *player) +BasePlayer *PlayerPacket::getPlayer() { - Packet(bsRead, player, false); + return player; } diff --git a/components/openmw-mp/Packets/Player/PlayerPacket.hpp b/components/openmw-mp/Packets/Player/PlayerPacket.hpp index 8d573d74e..a1dcd402f 100644 --- a/components/openmw-mp/Packets/Player/PlayerPacket.hpp +++ b/components/openmw-mp/Packets/Player/PlayerPacket.hpp @@ -19,11 +19,8 @@ namespace mwmp ~PlayerPacket(); - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); - - virtual void Send(BasePlayer *player, bool toOtherPlayers = true); - virtual void Send(BasePlayer *player, RakNet::AddressOrGUID destination); - virtual void Read(BasePlayer *player); + void setPlayer(BasePlayer *player); + BasePlayer *getPlayer(); protected: BasePlayer *player; diff --git a/components/openmw-mp/Packets/World/PacketContainer.cpp b/components/openmw-mp/Packets/World/PacketContainer.cpp index 74a273a43..cf61c1fb9 100644 --- a/components/openmw-mp/Packets/World/PacketContainer.cpp +++ b/components/openmw-mp/Packets/World/PacketContainer.cpp @@ -8,9 +8,9 @@ PacketContainer::PacketContainer(RakNet::RakPeerInterface *peer) : WorldPacket(p packetID = ID_CONTAINER; } -void PacketContainer::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send) +void PacketContainer::Packet(RakNet::BitStream *bs, bool send) { - WorldPacket::Packet(bs, event, send); + WorldPacket::Packet(bs, send); RW(event->action, send); diff --git a/components/openmw-mp/Packets/World/PacketContainer.hpp b/components/openmw-mp/Packets/World/PacketContainer.hpp index c1fcb6d89..28a885283 100644 --- a/components/openmw-mp/Packets/World/PacketContainer.hpp +++ b/components/openmw-mp/Packets/World/PacketContainer.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketContainer(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BaseEvent *event, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/World/PacketDoorState.cpp b/components/openmw-mp/Packets/World/PacketDoorState.cpp index 0df9cdcad..dc307e8d4 100644 --- a/components/openmw-mp/Packets/World/PacketDoorState.cpp +++ b/components/openmw-mp/Packets/World/PacketDoorState.cpp @@ -8,9 +8,9 @@ PacketDoorState::PacketDoorState(RakNet::RakPeerInterface *peer) : WorldPacket(p packetID = ID_DOOR_STATE; } -void PacketDoorState::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send) +void PacketDoorState::Packet(RakNet::BitStream *bs, bool send) { - WorldPacket::Packet(bs, event, send); + WorldPacket::Packet(bs, send); if (!send) event->objectChanges.objects.clear(); diff --git a/components/openmw-mp/Packets/World/PacketDoorState.hpp b/components/openmw-mp/Packets/World/PacketDoorState.hpp index 130bbe1e3..7def1cbb2 100644 --- a/components/openmw-mp/Packets/World/PacketDoorState.hpp +++ b/components/openmw-mp/Packets/World/PacketDoorState.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketDoorState(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BaseEvent *event, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/World/PacketMusicPlay.cpp b/components/openmw-mp/Packets/World/PacketMusicPlay.cpp index ef9f45962..80ba03826 100644 --- a/components/openmw-mp/Packets/World/PacketMusicPlay.cpp +++ b/components/openmw-mp/Packets/World/PacketMusicPlay.cpp @@ -8,9 +8,9 @@ PacketMusicPlay::PacketMusicPlay(RakNet::RakPeerInterface *peer) : WorldPacket(p packetID = ID_MUSIC_PLAY; } -void PacketMusicPlay::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send) +void PacketMusicPlay::Packet(RakNet::BitStream *bs, bool send) { - WorldPacket::Packet(bs, event, send); + WorldPacket::Packet(bs, send); if (!send) event->objectChanges.objects.clear(); diff --git a/components/openmw-mp/Packets/World/PacketMusicPlay.hpp b/components/openmw-mp/Packets/World/PacketMusicPlay.hpp index 69cb9635a..8da124858 100644 --- a/components/openmw-mp/Packets/World/PacketMusicPlay.hpp +++ b/components/openmw-mp/Packets/World/PacketMusicPlay.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketMusicPlay(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BaseEvent *event, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/World/PacketObjectAnimPlay.cpp b/components/openmw-mp/Packets/World/PacketObjectAnimPlay.cpp index dfc1eca31..cbfda63a5 100644 --- a/components/openmw-mp/Packets/World/PacketObjectAnimPlay.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectAnimPlay.cpp @@ -8,9 +8,9 @@ PacketObjectAnimPlay::PacketObjectAnimPlay(RakNet::RakPeerInterface *peer) : Wor packetID = ID_OBJECT_ANIM_PLAY; } -void PacketObjectAnimPlay::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send) +void PacketObjectAnimPlay::Packet(RakNet::BitStream *bs, bool send) { - WorldPacket::Packet(bs, event, send); + WorldPacket::Packet(bs, send); if (!send) event->objectChanges.objects.clear(); diff --git a/components/openmw-mp/Packets/World/PacketObjectAnimPlay.hpp b/components/openmw-mp/Packets/World/PacketObjectAnimPlay.hpp index b22a87e79..ee886ab2d 100644 --- a/components/openmw-mp/Packets/World/PacketObjectAnimPlay.hpp +++ b/components/openmw-mp/Packets/World/PacketObjectAnimPlay.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketObjectAnimPlay(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BaseEvent *event, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/World/PacketObjectDelete.cpp b/components/openmw-mp/Packets/World/PacketObjectDelete.cpp index ea0810177..2d6cad146 100644 --- a/components/openmw-mp/Packets/World/PacketObjectDelete.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectDelete.cpp @@ -8,9 +8,9 @@ PacketObjectDelete::PacketObjectDelete(RakNet::RakPeerInterface *peer) : WorldPa packetID = ID_OBJECT_DELETE; } -void PacketObjectDelete::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send) +void PacketObjectDelete::Packet(RakNet::BitStream *bs, bool send) { - WorldPacket::Packet(bs, event, send); + WorldPacket::Packet(bs, send); if (!send) event->objectChanges.objects.clear(); diff --git a/components/openmw-mp/Packets/World/PacketObjectDelete.hpp b/components/openmw-mp/Packets/World/PacketObjectDelete.hpp index 3f125244b..cb77ef2e4 100644 --- a/components/openmw-mp/Packets/World/PacketObjectDelete.hpp +++ b/components/openmw-mp/Packets/World/PacketObjectDelete.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketObjectDelete(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BaseEvent *event, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/World/PacketObjectLock.cpp b/components/openmw-mp/Packets/World/PacketObjectLock.cpp index fc15ab531..96aaa114b 100644 --- a/components/openmw-mp/Packets/World/PacketObjectLock.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectLock.cpp @@ -8,9 +8,9 @@ PacketObjectLock::PacketObjectLock(RakNet::RakPeerInterface *peer) : WorldPacket packetID = ID_OBJECT_LOCK; } -void PacketObjectLock::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send) +void PacketObjectLock::Packet(RakNet::BitStream *bs, bool send) { - WorldPacket::Packet(bs, event, send); + WorldPacket::Packet(bs, send); if (!send) event->objectChanges.objects.clear(); diff --git a/components/openmw-mp/Packets/World/PacketObjectLock.hpp b/components/openmw-mp/Packets/World/PacketObjectLock.hpp index f65d27df1..19242d762 100644 --- a/components/openmw-mp/Packets/World/PacketObjectLock.hpp +++ b/components/openmw-mp/Packets/World/PacketObjectLock.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketObjectLock(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BaseEvent *event, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/World/PacketObjectMove.cpp b/components/openmw-mp/Packets/World/PacketObjectMove.cpp index 4d2e6d293..ac89cac1e 100644 --- a/components/openmw-mp/Packets/World/PacketObjectMove.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectMove.cpp @@ -8,9 +8,9 @@ PacketObjectMove::PacketObjectMove(RakNet::RakPeerInterface *peer) : WorldPacket packetID = ID_OBJECT_MOVE; } -void PacketObjectMove::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send) +void PacketObjectMove::Packet(RakNet::BitStream *bs, bool send) { - WorldPacket::Packet(bs, event, send); + WorldPacket::Packet(bs, send); if (!send) event->objectChanges.objects.clear(); diff --git a/components/openmw-mp/Packets/World/PacketObjectMove.hpp b/components/openmw-mp/Packets/World/PacketObjectMove.hpp index 9ebea8ff1..1d6fc814e 100644 --- a/components/openmw-mp/Packets/World/PacketObjectMove.hpp +++ b/components/openmw-mp/Packets/World/PacketObjectMove.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketObjectMove(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BaseEvent *event, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/World/PacketObjectPlace.cpp b/components/openmw-mp/Packets/World/PacketObjectPlace.cpp index feb13e245..fb12e6927 100644 --- a/components/openmw-mp/Packets/World/PacketObjectPlace.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectPlace.cpp @@ -8,9 +8,9 @@ PacketObjectPlace::PacketObjectPlace(RakNet::RakPeerInterface *peer) : WorldPack packetID = ID_OBJECT_PLACE; } -void PacketObjectPlace::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send) +void PacketObjectPlace::Packet(RakNet::BitStream *bs, bool send) { - WorldPacket::Packet(bs, event, send); + WorldPacket::Packet(bs, send); if (!send) event->objectChanges.objects.clear(); diff --git a/components/openmw-mp/Packets/World/PacketObjectPlace.hpp b/components/openmw-mp/Packets/World/PacketObjectPlace.hpp index fb0d9f740..f1b51e3dd 100644 --- a/components/openmw-mp/Packets/World/PacketObjectPlace.hpp +++ b/components/openmw-mp/Packets/World/PacketObjectPlace.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketObjectPlace(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BaseEvent *event, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/World/PacketObjectRotate.cpp b/components/openmw-mp/Packets/World/PacketObjectRotate.cpp index 49d20d16c..4086ac29e 100644 --- a/components/openmw-mp/Packets/World/PacketObjectRotate.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectRotate.cpp @@ -8,9 +8,9 @@ PacketObjectRotate::PacketObjectRotate(RakNet::RakPeerInterface *peer) : WorldPa packetID = ID_OBJECT_ROTATE; } -void PacketObjectRotate::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send) +void PacketObjectRotate::Packet(RakNet::BitStream *bs, bool send) { - WorldPacket::Packet(bs, event, send); + WorldPacket::Packet(bs, send); if (!send) event->objectChanges.objects.clear(); diff --git a/components/openmw-mp/Packets/World/PacketObjectRotate.hpp b/components/openmw-mp/Packets/World/PacketObjectRotate.hpp index 601f6039e..a42a396dd 100644 --- a/components/openmw-mp/Packets/World/PacketObjectRotate.hpp +++ b/components/openmw-mp/Packets/World/PacketObjectRotate.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketObjectRotate(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BaseEvent *event, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/World/PacketObjectScale.cpp b/components/openmw-mp/Packets/World/PacketObjectScale.cpp index 314a650f2..893df3206 100644 --- a/components/openmw-mp/Packets/World/PacketObjectScale.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectScale.cpp @@ -8,9 +8,9 @@ PacketObjectScale::PacketObjectScale(RakNet::RakPeerInterface *peer) : WorldPack packetID = ID_OBJECT_SCALE; } -void PacketObjectScale::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send) +void PacketObjectScale::Packet(RakNet::BitStream *bs, bool send) { - WorldPacket::Packet(bs, event, send); + WorldPacket::Packet(bs, send); if (!send) event->objectChanges.objects.clear(); diff --git a/components/openmw-mp/Packets/World/PacketObjectScale.hpp b/components/openmw-mp/Packets/World/PacketObjectScale.hpp index 5991ada9f..46a4ef68a 100644 --- a/components/openmw-mp/Packets/World/PacketObjectScale.hpp +++ b/components/openmw-mp/Packets/World/PacketObjectScale.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketObjectScale(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BaseEvent *event, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/World/PacketObjectUnlock.cpp b/components/openmw-mp/Packets/World/PacketObjectUnlock.cpp index ff9436e35..cf2d123ca 100644 --- a/components/openmw-mp/Packets/World/PacketObjectUnlock.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectUnlock.cpp @@ -8,9 +8,9 @@ PacketObjectUnlock::PacketObjectUnlock(RakNet::RakPeerInterface *peer) : WorldPa packetID = ID_OBJECT_UNLOCK; } -void PacketObjectUnlock::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send) +void PacketObjectUnlock::Packet(RakNet::BitStream *bs, bool send) { - WorldPacket::Packet(bs, event, send); + WorldPacket::Packet(bs, send); if (!send) event->objectChanges.objects.clear(); diff --git a/components/openmw-mp/Packets/World/PacketObjectUnlock.hpp b/components/openmw-mp/Packets/World/PacketObjectUnlock.hpp index 1b4d4a7e0..ceed94301 100644 --- a/components/openmw-mp/Packets/World/PacketObjectUnlock.hpp +++ b/components/openmw-mp/Packets/World/PacketObjectUnlock.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketObjectUnlock(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BaseEvent *event, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/World/PacketScriptGlobalShort.cpp b/components/openmw-mp/Packets/World/PacketScriptGlobalShort.cpp index 5e3fbe301..56f2a57e4 100644 --- a/components/openmw-mp/Packets/World/PacketScriptGlobalShort.cpp +++ b/components/openmw-mp/Packets/World/PacketScriptGlobalShort.cpp @@ -8,9 +8,9 @@ PacketScriptGlobalShort::PacketScriptGlobalShort(RakNet::RakPeerInterface *peer) packetID = ID_SCRIPT_GLOBAL_SHORT; } -void PacketScriptGlobalShort::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send) +void PacketScriptGlobalShort::Packet(RakNet::BitStream *bs, bool send) { - WorldPacket::Packet(bs, event, send); + WorldPacket::Packet(bs, send); if (!send) event->objectChanges.objects.clear(); diff --git a/components/openmw-mp/Packets/World/PacketScriptGlobalShort.hpp b/components/openmw-mp/Packets/World/PacketScriptGlobalShort.hpp index d0738c7cc..f4aa1d8bc 100644 --- a/components/openmw-mp/Packets/World/PacketScriptGlobalShort.hpp +++ b/components/openmw-mp/Packets/World/PacketScriptGlobalShort.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketScriptGlobalShort(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BaseEvent *event, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/World/PacketScriptLocalFloat.cpp b/components/openmw-mp/Packets/World/PacketScriptLocalFloat.cpp index d72191dbb..e7bd0b078 100644 --- a/components/openmw-mp/Packets/World/PacketScriptLocalFloat.cpp +++ b/components/openmw-mp/Packets/World/PacketScriptLocalFloat.cpp @@ -8,9 +8,9 @@ PacketScriptLocalFloat::PacketScriptLocalFloat(RakNet::RakPeerInterface *peer) : packetID = ID_SCRIPT_LOCAL_FLOAT; } -void PacketScriptLocalFloat::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send) +void PacketScriptLocalFloat::Packet(RakNet::BitStream *bs, bool send) { - WorldPacket::Packet(bs, event, send); + WorldPacket::Packet(bs, send); if (!send) event->objectChanges.objects.clear(); diff --git a/components/openmw-mp/Packets/World/PacketScriptLocalFloat.hpp b/components/openmw-mp/Packets/World/PacketScriptLocalFloat.hpp index 8599609a4..3404e7159 100644 --- a/components/openmw-mp/Packets/World/PacketScriptLocalFloat.hpp +++ b/components/openmw-mp/Packets/World/PacketScriptLocalFloat.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketScriptLocalFloat(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BaseEvent *event, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/World/PacketScriptLocalShort.cpp b/components/openmw-mp/Packets/World/PacketScriptLocalShort.cpp index 441a190b4..fc063b18f 100644 --- a/components/openmw-mp/Packets/World/PacketScriptLocalShort.cpp +++ b/components/openmw-mp/Packets/World/PacketScriptLocalShort.cpp @@ -8,9 +8,9 @@ PacketScriptLocalShort::PacketScriptLocalShort(RakNet::RakPeerInterface *peer) : packetID = ID_SCRIPT_LOCAL_SHORT; } -void PacketScriptLocalShort::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send) +void PacketScriptLocalShort::Packet(RakNet::BitStream *bs, bool send) { - WorldPacket::Packet(bs, event, send); + WorldPacket::Packet(bs, send); if (!send) event->objectChanges.objects.clear(); diff --git a/components/openmw-mp/Packets/World/PacketScriptLocalShort.hpp b/components/openmw-mp/Packets/World/PacketScriptLocalShort.hpp index cadb9b312..58c01ad3c 100644 --- a/components/openmw-mp/Packets/World/PacketScriptLocalShort.hpp +++ b/components/openmw-mp/Packets/World/PacketScriptLocalShort.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketScriptLocalShort(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BaseEvent *event, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/World/PacketScriptMemberShort.cpp b/components/openmw-mp/Packets/World/PacketScriptMemberShort.cpp index 0cefc843a..72803b271 100644 --- a/components/openmw-mp/Packets/World/PacketScriptMemberShort.cpp +++ b/components/openmw-mp/Packets/World/PacketScriptMemberShort.cpp @@ -8,9 +8,9 @@ PacketScriptMemberShort::PacketScriptMemberShort(RakNet::RakPeerInterface *peer) packetID = ID_SCRIPT_MEMBER_SHORT; } -void PacketScriptMemberShort::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send) +void PacketScriptMemberShort::Packet(RakNet::BitStream *bs, bool send) { - WorldPacket::Packet(bs, event, send); + WorldPacket::Packet(bs, send); if (!send) event->objectChanges.objects.clear(); diff --git a/components/openmw-mp/Packets/World/PacketScriptMemberShort.hpp b/components/openmw-mp/Packets/World/PacketScriptMemberShort.hpp index e95b0ddce..f554103ed 100644 --- a/components/openmw-mp/Packets/World/PacketScriptMemberShort.hpp +++ b/components/openmw-mp/Packets/World/PacketScriptMemberShort.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketScriptMemberShort(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BaseEvent *event, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/World/PacketVideoPlay.cpp b/components/openmw-mp/Packets/World/PacketVideoPlay.cpp index f2d9bf3d8..2b5e212ee 100644 --- a/components/openmw-mp/Packets/World/PacketVideoPlay.cpp +++ b/components/openmw-mp/Packets/World/PacketVideoPlay.cpp @@ -8,9 +8,9 @@ PacketVideoPlay::PacketVideoPlay(RakNet::RakPeerInterface *peer) : WorldPacket(p packetID = ID_VIDEO_PLAY; } -void PacketVideoPlay::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send) +void PacketVideoPlay::Packet(RakNet::BitStream *bs, bool send) { - WorldPacket::Packet(bs, event, send); + WorldPacket::Packet(bs, send); if (!send) event->objectChanges.objects.clear(); diff --git a/components/openmw-mp/Packets/World/PacketVideoPlay.hpp b/components/openmw-mp/Packets/World/PacketVideoPlay.hpp index bff4c6070..bed395e03 100644 --- a/components/openmw-mp/Packets/World/PacketVideoPlay.hpp +++ b/components/openmw-mp/Packets/World/PacketVideoPlay.hpp @@ -10,7 +10,7 @@ namespace mwmp public: PacketVideoPlay(RakNet::RakPeerInterface *peer); - virtual void Packet(RakNet::BitStream *bs, BaseEvent *event, bool send); + virtual void Packet(RakNet::BitStream *bs, bool send); }; } diff --git a/components/openmw-mp/Packets/World/WorldPacket.cpp b/components/openmw-mp/Packets/World/WorldPacket.cpp index 7a013f59c..25f316de8 100644 --- a/components/openmw-mp/Packets/World/WorldPacket.cpp +++ b/components/openmw-mp/Packets/World/WorldPacket.cpp @@ -5,12 +5,6 @@ using namespace mwmp; -void WorldPacket::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send) -{ - BasePacket::Packet(bs, event->guid, send); - this->event = event; -} - WorldPacket::WorldPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer) { packetID = 0; @@ -24,21 +18,8 @@ WorldPacket::~WorldPacket() } -void WorldPacket::Send(BaseEvent *event, RakNet::AddressOrGUID destination) +void WorldPacket::setEvent(BaseEvent *event) { - bsSend->ResetWritePointer(); - Packet(bsSend, event, true); - peer->Send(bsSend, priority, reliability, 0, destination, false); -} - -void WorldPacket::Send(BaseEvent *event, bool toOther) -{ - bsSend->ResetWritePointer(); - Packet(bsSend, event, true); - peer->Send(bsSend, priority, reliability, 0, event->guid, toOther); -} - -void WorldPacket::Read(BaseEvent *event) -{ - Packet(bsRead, event, false); + this->event = event; + guid = event->guid; } diff --git a/components/openmw-mp/Packets/World/WorldPacket.hpp b/components/openmw-mp/Packets/World/WorldPacket.hpp index 71b6a3e37..6e9be13b8 100644 --- a/components/openmw-mp/Packets/World/WorldPacket.hpp +++ b/components/openmw-mp/Packets/World/WorldPacket.hpp @@ -19,11 +19,7 @@ namespace mwmp ~WorldPacket(); - virtual void Packet(RakNet::BitStream *bs, BaseEvent *event, bool send); - - virtual void Send(BaseEvent *event, bool toOtherPlayers = true); - virtual void Send(BaseEvent *event, RakNet::AddressOrGUID destination); - virtual void Read(BaseEvent *event); + void setEvent(BaseEvent *event); protected: BaseEvent *event;