From fe2dd1bad47e4aef2b45a094f687d0f8fdb2ed26 Mon Sep 17 00:00:00 2001 From: Koncord Date: Tue, 29 Aug 2017 03:34:36 +0800 Subject: [PATCH] [Server] Use correct cells in "send" functions Remove unused return type from ON_PLAYER_SENDMESSAGE --- apps/openmw-mp/Actors.cpp | 28 ++++++++++--------- apps/openmw-mp/Actors.hpp | 8 +++--- apps/openmw-mp/Object.cpp | 18 ++++++------ apps/openmw-mp/Object.hpp | 4 +-- .../actor/ProcessorActorCellChange.hpp | 2 +- .../actor/ProcessorActorEquipment.hpp | 2 +- .../processors/actor/ProcessorActorList.hpp | 2 +- .../processors/actor/ProcessorActorTest.hpp | 2 +- .../processors/player/ProcessorChatMsg.hpp | 2 +- .../processors/world/ProcessorContainer.hpp | 2 +- .../processors/world/ProcessorDoorState.hpp | 2 +- .../world/ProcessorObjectDelete.hpp | 2 +- .../processors/world/ProcessorObjectLock.hpp | 2 +- .../processors/world/ProcessorObjectPlace.hpp | 2 +- .../processors/world/ProcessorObjectScale.hpp | 2 +- .../processors/world/ProcessorObjectSpawn.hpp | 2 +- .../processors/world/ProcessorObjectState.hpp | 2 +- .../processors/world/ProcessorObjectTrap.hpp | 2 +- 18 files changed, 45 insertions(+), 41 deletions(-) diff --git a/apps/openmw-mp/Actors.cpp b/apps/openmw-mp/Actors.cpp index ad09edf23..aa26634d4 100644 --- a/apps/openmw-mp/Actors.cpp +++ b/apps/openmw-mp/Actors.cpp @@ -91,21 +91,21 @@ void ActorController::Init(LuaState &lua) }); playersTable.set_function("sendActors", [&lua](shared_ptr player, vector> actors, - bool sendToAll) { - lua.getActorCtrl().sendActors(player, actors, sendToAll); + const std::string &cellDescription, bool sendToAll) { + lua.getActorCtrl().sendActors(player, actors, Utils::getCellFromDescription(cellDescription), sendToAll); }); playersTable.set_function("sendList", [&lua](shared_ptr player, vector> actors, - bool sendToAll) { - lua.getActorCtrl().sendList(player, actors, sendToAll); + const std::string &cellDescription, bool sendToAll) { + lua.getActorCtrl().sendList(player, actors, Utils::getCellFromDescription(cellDescription), sendToAll); }); - playersTable.set_function("requestList", [&lua](shared_ptr player){ - lua.getActorCtrl().requestList(player); + playersTable.set_function("requestList", [&lua](shared_ptr player, const std::string &cellDescription){ + lua.getActorCtrl().requestList(player, Utils::getCellFromDescription(cellDescription)); }); - playersTable.set_function("getActors", [&lua](shared_ptr player){ - lua.getActorCtrl().getActors(player); + playersTable.set_function("getActors", [&lua](shared_ptr player, const std::string &cellDescription){ + lua.getActorCtrl().getActors(player, Utils::getCellFromDescription(cellDescription)); }); } @@ -127,9 +127,10 @@ std::shared_ptr ActorController::createActor() return shared_ptr(actor); } -void ActorController::sendActors(std::shared_ptr player, std::vector> actors, bool sendToAll) +void ActorController::sendActors(std::shared_ptr player, std::vector> actors, + const ESM::Cell &cell, bool sendToAll) { - actorList.cell = player->cell; + actorList.cell = cell; actorList.guid = player->guid; bool positionChanged = false; @@ -231,7 +232,8 @@ void ActorController::sendActors(std::shared_ptr player, std::vector player, std::vector> actors, bool sendToAll) +void ActorController::sendList(std::shared_ptr player, std::vector> actors, + const ESM::Cell &cell, bool sendToAll) { actorList.cell = player->cell; actorList.guid = player->guid; @@ -242,7 +244,7 @@ void ActorController::sendList(std::shared_ptr player, std::vectorSend(actorList.guid); } -void ActorController::requestList(std::shared_ptr player) +void ActorController::requestList(std::shared_ptr player, const ESM::Cell &cell) { actorList.cell = player->cell; actorList.guid = player->guid; @@ -253,7 +255,7 @@ void ActorController::requestList(std::shared_ptr player) packet->Send(actorList.guid); } -std::vector> ActorController::getActors(std::shared_ptr player) +std::vector> ActorController::getActors(std::shared_ptr player, const ESM::Cell &cell) { Cell *serverCell = CellController::get()->getCell(&player->cell); diff --git a/apps/openmw-mp/Actors.hpp b/apps/openmw-mp/Actors.hpp index 7df6db56e..c4dc1d89b 100644 --- a/apps/openmw-mp/Actors.hpp +++ b/apps/openmw-mp/Actors.hpp @@ -41,12 +41,12 @@ public: ~ActorController(); std::shared_ptr createActor(); - void sendActors(std::shared_ptr player, std::vector> actors, bool sendToAll = false); - void sendList(std::shared_ptr player, std::vector> actors, bool sendToAll = false); + void sendActors(std::shared_ptr player, std::vector> actors, const ESM::Cell &cell, bool sendToAll = false); + void sendList(std::shared_ptr player, std::vector> actors, const ESM::Cell &cell, bool sendToAll = false); - void requestList(std::shared_ptr player); + void requestList(std::shared_ptr player, const ESM::Cell &cell); - std::vector> getActors(std::shared_ptr player); + std::vector> getActors(std::shared_ptr player, const ESM::Cell &cell); private: mwmp::BaseActorList actorList; diff --git a/apps/openmw-mp/Object.cpp b/apps/openmw-mp/Object.cpp index 137854349..8b4f7b9d8 100644 --- a/apps/openmw-mp/Object.cpp +++ b/apps/openmw-mp/Object.cpp @@ -257,12 +257,14 @@ void ObjectController::Init(LuaState &lua) { sol::table objectCtrl = lua.getState()->create_table("ObjectCtrl"); - objectCtrl.set_function("sendObjects", [&lua](shared_ptr player, shared_ptr>> objects) { - return lua.getObjectCtrl().sendObjects(player, objects); + objectCtrl.set_function("sendObjects", [&lua](shared_ptr player, shared_ptr>> objects, + const std::string &cellDescription) { + return lua.getObjectCtrl().sendObjects(player, objects, Utils::getCellFromDescription(cellDescription)); }); - objectCtrl.set_function("sendContainers", [&lua](shared_ptr player, shared_ptr>> objects) { - return lua.getObjectCtrl().sendContainers(player, objects); + objectCtrl.set_function("sendContainers", [&lua](shared_ptr player, shared_ptr>> objects, + const std::string &cellDescription) { + return lua.getObjectCtrl().sendContainers(player, objects, Utils::getCellFromDescription(cellDescription)); }); objectCtrl.set_function("requestContainers", [&lua](shared_ptr player) { @@ -300,7 +302,7 @@ shared_ptr>> ObjectController::copyContainers(mwmp: return containers; } -void ObjectController::sendObjects(shared_ptr player, shared_ptr>> objects) +void ObjectController::sendObjects(shared_ptr player, shared_ptr>> objects, const ESM::Cell &cell) { enum Type { @@ -321,7 +323,7 @@ void ObjectController::sendObjects(shared_ptr player, shared_ptrguid; - e.cell = player->cell; + e.cell = cell; } @@ -433,11 +435,11 @@ void ObjectController::sendObjects(shared_ptr player, shared_ptr player, shared_ptr>> objects) +void ObjectController::sendContainers(shared_ptr player, shared_ptr>> objects, const ESM::Cell &cell) { mwmp::BaseEvent event; - event.cell = player->cell; + event.cell = cell; event.action = mwmp::BaseEvent::SET; event.guid = player->guid; diff --git a/apps/openmw-mp/Object.hpp b/apps/openmw-mp/Object.hpp index 0aabc1468..f482a795f 100644 --- a/apps/openmw-mp/Object.hpp +++ b/apps/openmw-mp/Object.hpp @@ -112,8 +112,8 @@ public: std::shared_ptr>> copyObjects(mwmp::BaseEvent &event); std::shared_ptr>> copyContainers(mwmp::BaseEvent &event); - void sendObjects(std::shared_ptr player, std::shared_ptr>> objects); - void sendContainers(std::shared_ptr player, std::shared_ptr>> objects); + void sendObjects(std::shared_ptr player, std::shared_ptr>> objects, const ESM::Cell &cell); + void sendContainers(std::shared_ptr player, std::shared_ptr>> objects, const ESM::Cell &cell); void requestContainers(std::shared_ptr player); }; \ No newline at end of file diff --git a/apps/openmw-mp/processors/actor/ProcessorActorCellChange.hpp b/apps/openmw-mp/processors/actor/ProcessorActorCellChange.hpp index a8895316a..5accfa1c1 100644 --- a/apps/openmw-mp/processors/actor/ProcessorActorCellChange.hpp +++ b/apps/openmw-mp/processors/actor/ProcessorActorCellChange.hpp @@ -32,7 +32,7 @@ namespace mwmp Networking::get().getState().getEventCtrl().Call(player, actors); - Networking::get().getState().getActorCtrl().sendActors(player, actors, true); + Networking::get().getState().getActorCtrl().sendActors(player, actors, actorList.cell, true); // Send this to everyone packet.Send(true); diff --git a/apps/openmw-mp/processors/actor/ProcessorActorEquipment.hpp b/apps/openmw-mp/processors/actor/ProcessorActorEquipment.hpp index c0773bac3..a947dddc0 100644 --- a/apps/openmw-mp/processors/actor/ProcessorActorEquipment.hpp +++ b/apps/openmw-mp/processors/actor/ProcessorActorEquipment.hpp @@ -27,7 +27,7 @@ namespace mwmp Networking::get().getState().getEventCtrl().Call(player, actors); - Networking::get().getState().getActorCtrl().sendActors(player, actors, true); + Networking::get().getState().getActorCtrl().sendActors(player, actors, actorList.cell, true); } }; } diff --git a/apps/openmw-mp/processors/actor/ProcessorActorList.hpp b/apps/openmw-mp/processors/actor/ProcessorActorList.hpp index 8ce8ce63f..058a19773 100644 --- a/apps/openmw-mp/processors/actor/ProcessorActorList.hpp +++ b/apps/openmw-mp/processors/actor/ProcessorActorList.hpp @@ -28,7 +28,7 @@ namespace mwmp Networking::get().getState().getEventCtrl().Call(player, actors); - Networking::get().getState().getActorCtrl().sendActors(player, actors, true); + Networking::get().getState().getActorCtrl().sendActors(player, actors, actorList.cell, true); } }; } diff --git a/apps/openmw-mp/processors/actor/ProcessorActorTest.hpp b/apps/openmw-mp/processors/actor/ProcessorActorTest.hpp index a053d6553..4c0f2d782 100644 --- a/apps/openmw-mp/processors/actor/ProcessorActorTest.hpp +++ b/apps/openmw-mp/processors/actor/ProcessorActorTest.hpp @@ -26,7 +26,7 @@ namespace mwmp Networking::get().getState().getEventCtrl().Call(player, actors); - Networking::get().getState().getActorCtrl().sendActors(player, actors, true); + Networking::get().getState().getActorCtrl().sendActors(player, actors, actorList.cell, true); } }; } diff --git a/apps/openmw-mp/processors/player/ProcessorChatMsg.hpp b/apps/openmw-mp/processors/player/ProcessorChatMsg.hpp index 2fc3406da..29d938f54 100644 --- a/apps/openmw-mp/processors/player/ProcessorChatMsg.hpp +++ b/apps/openmw-mp/processors/player/ProcessorChatMsg.hpp @@ -30,7 +30,7 @@ namespace mwmp player->message("#FF0000Command not found.\n"); // inform player that command not found break; case CommandController::ExecResult::NOT_CMD: // cmd length < 2 or message is not cmd - lua.getEventCtrl().Call(player, player->chatMessage); + lua.getEventCtrl().Call(player, player->chatMessage); break; case CommandController::ExecResult::SUCCESS: // returned true from function break; diff --git a/apps/openmw-mp/processors/world/ProcessorContainer.hpp b/apps/openmw-mp/processors/world/ProcessorContainer.hpp index ca649c930..819491083 100644 --- a/apps/openmw-mp/processors/world/ProcessorContainer.hpp +++ b/apps/openmw-mp/processors/world/ProcessorContainer.hpp @@ -38,7 +38,7 @@ namespace mwmp Networking::get().getState().getEventCtrl().Call(player, containers); - Networking::get().getState().getObjectCtrl().sendContainers(player, containers); + Networking::get().getState().getObjectCtrl().sendContainers(player, containers, event.cell); LOG_APPEND(Log::LOG_INFO, "- Finished processing ID_CONTAINER"); } diff --git a/apps/openmw-mp/processors/world/ProcessorDoorState.hpp b/apps/openmw-mp/processors/world/ProcessorDoorState.hpp index cd89d599d..2cd205c9d 100644 --- a/apps/openmw-mp/processors/world/ProcessorDoorState.hpp +++ b/apps/openmw-mp/processors/world/ProcessorDoorState.hpp @@ -22,7 +22,7 @@ namespace mwmp Networking::get().getState().getEventCtrl().Call(player, objects); - objCtrl.sendObjects(player, objects); + objCtrl.sendObjects(player, objects, event.cell); } }; } diff --git a/apps/openmw-mp/processors/world/ProcessorObjectDelete.hpp b/apps/openmw-mp/processors/world/ProcessorObjectDelete.hpp index 7e0911a43..b7c9224ba 100644 --- a/apps/openmw-mp/processors/world/ProcessorObjectDelete.hpp +++ b/apps/openmw-mp/processors/world/ProcessorObjectDelete.hpp @@ -24,7 +24,7 @@ namespace mwmp Networking::get().getState().getEventCtrl().Call(player, objects); - objCtrl.sendObjects(player, objects); + objCtrl.sendObjects(player, objects, event.cell); } }; } diff --git a/apps/openmw-mp/processors/world/ProcessorObjectLock.hpp b/apps/openmw-mp/processors/world/ProcessorObjectLock.hpp index dbd69b948..a5ed3db6d 100644 --- a/apps/openmw-mp/processors/world/ProcessorObjectLock.hpp +++ b/apps/openmw-mp/processors/world/ProcessorObjectLock.hpp @@ -24,7 +24,7 @@ namespace mwmp Networking::get().getState().getEventCtrl().Call(player, objects); - objCtrl.sendObjects(player, objects); + objCtrl.sendObjects(player, objects, event.cell); } }; } diff --git a/apps/openmw-mp/processors/world/ProcessorObjectPlace.hpp b/apps/openmw-mp/processors/world/ProcessorObjectPlace.hpp index e64a6b6fa..c70e9d110 100644 --- a/apps/openmw-mp/processors/world/ProcessorObjectPlace.hpp +++ b/apps/openmw-mp/processors/world/ProcessorObjectPlace.hpp @@ -33,7 +33,7 @@ namespace mwmp Networking::get().getState().getEventCtrl().Call(player, objects); - objCtrl.sendObjects(player, objects); + objCtrl.sendObjects(player, objects, event.cell); } }; } diff --git a/apps/openmw-mp/processors/world/ProcessorObjectScale.hpp b/apps/openmw-mp/processors/world/ProcessorObjectScale.hpp index 918be0dde..63d3148e2 100644 --- a/apps/openmw-mp/processors/world/ProcessorObjectScale.hpp +++ b/apps/openmw-mp/processors/world/ProcessorObjectScale.hpp @@ -24,7 +24,7 @@ namespace mwmp Networking::get().getState().getEventCtrl().Call(player, objects); - objCtrl.sendObjects(player, objects); + objCtrl.sendObjects(player, objects, event.cell); } }; } diff --git a/apps/openmw-mp/processors/world/ProcessorObjectSpawn.hpp b/apps/openmw-mp/processors/world/ProcessorObjectSpawn.hpp index be76fc1df..65647a873 100644 --- a/apps/openmw-mp/processors/world/ProcessorObjectSpawn.hpp +++ b/apps/openmw-mp/processors/world/ProcessorObjectSpawn.hpp @@ -33,7 +33,7 @@ namespace mwmp Networking::get().getState().getEventCtrl().Call(player, objects); - objCtrl.sendObjects(player, objects); + objCtrl.sendObjects(player, objects, event.cell); } }; } diff --git a/apps/openmw-mp/processors/world/ProcessorObjectState.hpp b/apps/openmw-mp/processors/world/ProcessorObjectState.hpp index 66825e11b..6ef369867 100644 --- a/apps/openmw-mp/processors/world/ProcessorObjectState.hpp +++ b/apps/openmw-mp/processors/world/ProcessorObjectState.hpp @@ -24,7 +24,7 @@ namespace mwmp Networking::get().getState().getEventCtrl().Call(player, objects); - objCtrl.sendObjects(player, objects); + objCtrl.sendObjects(player, objects, event.cell); } }; } diff --git a/apps/openmw-mp/processors/world/ProcessorObjectTrap.hpp b/apps/openmw-mp/processors/world/ProcessorObjectTrap.hpp index f12a65a00..fe410db9b 100644 --- a/apps/openmw-mp/processors/world/ProcessorObjectTrap.hpp +++ b/apps/openmw-mp/processors/world/ProcessorObjectTrap.hpp @@ -24,7 +24,7 @@ namespace mwmp Networking::get().getState().getEventCtrl().Call(player, objects); - objCtrl.sendObjects(player, objects); + objCtrl.sendObjects(player, objects, event.cell); } }; }