diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index dc4405cab..3031ac5e1 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -171,9 +171,9 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) break; } - case ID_PLAYER_CELL_LOAD: + case ID_PLAYER_CELL_STATE: { - LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_CELL_LOAD from %s", + LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_CELL_STATE from %s", player->npc.mName.c_str()); Script::Call(player->getId()); diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 4e50c05fd..db382127f 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -1070,22 +1070,22 @@ void LocalPlayer::sendJournalIndex(const std::string& quest, int index) void LocalPlayer::sendCellLoad(ESM::Cell cellLoaded) { - cellLoadChanges.cells.clear(); + cellStateChanges.cells.clear(); - cellLoadChanges.cells.push_back(cellLoaded); + cellStateChanges.cells.push_back(cellLoaded); - cellLoadChanges.action = CellLoadChanges::LOAD; - Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_CELL_LOAD)->Send(this); + cellStateChanges.action = CellStateChanges::LOAD; + Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_CELL_STATE)->Send(this); } void LocalPlayer::sendCellUnload(ESM::Cell cellUnloaded) { - cellLoadChanges.cells.clear(); + cellStateChanges.cells.clear(); - cellLoadChanges.cells.push_back(cellUnloaded); + cellStateChanges.cells.push_back(cellUnloaded); - cellLoadChanges.action = CellLoadChanges::UNLOAD; - Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_CELL_LOAD)->Send(this); + cellStateChanges.action = CellStateChanges::UNLOAD; + Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_CELL_STATE)->Send(this); } void LocalPlayer::sendAttack(Attack::TYPE type) diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index ff33f7353..ba876315a 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -532,7 +532,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) } break; } - case ID_PLAYER_CELL_LOAD: + case ID_PLAYER_CELL_STATE: { break; } diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 48b6e8aa2..8a449a680 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -159,7 +159,7 @@ add_component_dir (openmw-mp Packets/Player/PacketGUIBoxes Packets/Player/PacketClass Packets/Player/PacketTime Packets/Player/PacketInventory Packets/Player/PacketSpellbook Packets/Player/PacketJournal Packets/Player/PacketActiveSkills Packets/Player/PacketPlayerCellChange - Packets/Player/PacketPlayerCellLoad + Packets/Player/PacketPlayerCellState Packets/World/PacketObjectDelete Packets/World/PacketObjectPlace Packets/World/PacketObjectLock Packets/World/PacketObjectUnlock Packets/World/PacketObjectScale Packets/World/PacketObjectMove diff --git a/components/openmw-mp/Base/BasePlayer.hpp b/components/openmw-mp/Base/BasePlayer.hpp index d5212af02..c00079e75 100644 --- a/components/openmw-mp/Base/BasePlayer.hpp +++ b/components/openmw-mp/Base/BasePlayer.hpp @@ -94,7 +94,7 @@ namespace mwmp int action; //0 - Clear and set in entirety, 1 - Add spell, 2 - Remove spell }; - struct CellLoadChanges + struct CellStateChanges { std::vector cells; unsigned int count; @@ -157,7 +157,7 @@ namespace mwmp InventoryChanges inventoryChanges; SpellbookChanges spellbookChanges; JournalChanges journalChanges; - CellLoadChanges cellLoadChanges; + CellStateChanges cellStateChanges; bool consoleAllowed; bool ignorePosPacket; ESM::ActiveSpells activeSpells; diff --git a/components/openmw-mp/Controllers/PlayerPacketController.cpp b/components/openmw-mp/Controllers/PlayerPacketController.cpp index 613bd7266..8c023bb09 100644 --- a/components/openmw-mp/Controllers/PlayerPacketController.cpp +++ b/components/openmw-mp/Controllers/PlayerPacketController.cpp @@ -5,7 +5,7 @@ #include "../Packets/Player/PacketClass.hpp" #include "../Packets/Player/PacketPosition.hpp" #include "../Packets/Player/PacketPlayerCellChange.hpp" -#include "../Packets/Player/PacketPlayerCellLoad.hpp" +#include "../Packets/Player/PacketPlayerCellState.hpp" #include "../Packets/Player/PacketBaseInfo.hpp" #include "../Packets/Player/PacketEquipment.hpp" #include "../Packets/Player/PacketAttack.hpp" @@ -44,7 +44,7 @@ mwmp::PlayerPacketController::PlayerPacketController(RakNet::RakPeerInterface *p { AddPacket(&packets, peer); AddPacket(&packets, peer); - AddPacket(&packets, peer); + AddPacket(&packets, peer); AddPacket(&packets, peer); AddPacket(&packets, peer); diff --git a/components/openmw-mp/NetworkMessages.hpp b/components/openmw-mp/NetworkMessages.hpp index 7134bdf3e..386362a44 100644 --- a/components/openmw-mp/NetworkMessages.hpp +++ b/components/openmw-mp/NetworkMessages.hpp @@ -37,7 +37,7 @@ enum GameMessages ID_GAME_ACTIVESKILLS, ID_PLAYER_CELL_CHANGE, - ID_PLAYER_CELL_LOAD, + ID_PLAYER_CELL_STATE, ID_OBJECT_PLACE, ID_OBJECT_DELETE, diff --git a/components/openmw-mp/Packets/Player/PacketPlayerCellLoad.cpp b/components/openmw-mp/Packets/Player/PacketPlayerCellLoad.cpp deleted file mode 100644 index abe3fc479..000000000 --- a/components/openmw-mp/Packets/Player/PacketPlayerCellLoad.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include "PacketPlayerCellLoad.hpp" - - -mwmp::PacketPlayerCellLoad::PacketPlayerCellLoad(RakNet::RakPeerInterface *peer) : PlayerPacket(peer) -{ - packetID = ID_PLAYER_CELL_LOAD; - priority = IMMEDIATE_PRIORITY; - reliability = RELIABLE_ORDERED; -} - -void mwmp::PacketPlayerCellLoad::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send) -{ - PlayerPacket::Packet(bs, player, send); - - RW(player->cellLoadChanges.action, send); - - if (!send) - player->cellLoadChanges.cells.clear(); - else - player->cellLoadChanges.count = (unsigned int)(player->cellLoadChanges.cells.size()); - - RW(player->cellLoadChanges.count, send); - - for (unsigned int i = 0; i < player->cellLoadChanges.count; i++) - { - ESM::Cell cellLoaded; - - if (send) - { - cellLoaded = player->cellLoadChanges.cells[i]; - } - - RW(cellLoaded.mData.mFlags, send); - RW(cellLoaded.mData.mX, send); - RW(cellLoaded.mData.mY, send); - RW(cellLoaded.mName, send); - - if (!send) - { - player->cellLoadChanges.cells.push_back(cellLoaded); - } - } -} diff --git a/components/openmw-mp/Packets/Player/PacketPlayerCellLoad.hpp b/components/openmw-mp/Packets/Player/PacketPlayerCellLoad.hpp deleted file mode 100644 index 6b60752da..000000000 --- a/components/openmw-mp/Packets/Player/PacketPlayerCellLoad.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef OPENMW_PACKETPLAYERCELLLOAD_HPP -#define OPENMW_PACKETPLAYERCELLLOAD_HPP - - -#include - -namespace mwmp -{ - class PacketPlayerCellLoad : public PlayerPacket - { - public: - PacketPlayerCellLoad(RakNet::RakPeerInterface *peer); - - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); - }; -} - - - -#endif //OPENMW_PACKETPLAYERCELLLOAD_HPP diff --git a/components/openmw-mp/Packets/Player/PacketPlayerCellState.cpp b/components/openmw-mp/Packets/Player/PacketPlayerCellState.cpp new file mode 100644 index 000000000..c910fa1b9 --- /dev/null +++ b/components/openmw-mp/Packets/Player/PacketPlayerCellState.cpp @@ -0,0 +1,44 @@ +#include +#include "PacketPlayerCellState.hpp" + + +mwmp::PacketPlayerCellState::PacketPlayerCellState(RakNet::RakPeerInterface *peer) : PlayerPacket(peer) +{ + packetID = ID_PLAYER_CELL_STATE; + priority = IMMEDIATE_PRIORITY; + reliability = RELIABLE_ORDERED; +} + +void mwmp::PacketPlayerCellState::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send) +{ + PlayerPacket::Packet(bs, player, send); + + RW(player->cellStateChanges.action, send); + + if (!send) + player->cellStateChanges.cells.clear(); + else + player->cellStateChanges.count = (unsigned int)(player->cellStateChanges.cells.size()); + + RW(player->cellStateChanges.count, send); + + for (unsigned int i = 0; i < player->cellStateChanges.count; i++) + { + ESM::Cell cell; + + if (send) + { + cell = player->cellStateChanges.cells[i]; + } + + RW(cell.mData.mFlags, send); + RW(cell.mData.mX, send); + RW(cell.mData.mY, send); + RW(cell.mName, send); + + if (!send) + { + player->cellStateChanges.cells.push_back(cell); + } + } +} diff --git a/components/openmw-mp/Packets/Player/PacketPlayerCellState.hpp b/components/openmw-mp/Packets/Player/PacketPlayerCellState.hpp new file mode 100644 index 000000000..e4c6f2984 --- /dev/null +++ b/components/openmw-mp/Packets/Player/PacketPlayerCellState.hpp @@ -0,0 +1,20 @@ +#ifndef OPENMW_PACKETPLAYERCELLSTATE_HPP +#define OPENMW_PACKETPLAYERCELLSTATE_HPP + + +#include + +namespace mwmp +{ + class PacketPlayerCellState : public PlayerPacket + { + public: + PacketPlayerCellState(RakNet::RakPeerInterface *peer); + + virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + }; +} + + + +#endif //OPENMW_PACKETPLAYERCELLSTATE_HPP