From b62969d3cf0a51b7a68c08cb627d17c5e8ed8128 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 30 Apr 2017 03:32:04 +0300 Subject: [PATCH] [Server] Add OnCellUnload script callback --- apps/openmw-mp/ActorProcessor.cpp | 1 + apps/openmw-mp/CellController.cpp | 3 +++ apps/openmw-mp/Script/ScriptFunctions.hpp | 1 + apps/openmw-mp/WorldProcessor.cpp | 1 + 4 files changed, 6 insertions(+) diff --git a/apps/openmw-mp/ActorProcessor.cpp b/apps/openmw-mp/ActorProcessor.cpp index 93fb3e1f4..d1efa013b 100644 --- a/apps/openmw-mp/ActorProcessor.cpp +++ b/apps/openmw-mp/ActorProcessor.cpp @@ -27,6 +27,7 @@ bool ActorProcessor::Process(RakNet::Packet &packet, BaseActorList &actorList) n actorList.cell.blank(); actorList.baseActors.clear(); actorList.guid = packet.guid; + for (auto &processor : processors) { if (processor.first == packet.data[0]) diff --git a/apps/openmw-mp/CellController.cpp b/apps/openmw-mp/CellController.cpp index 8df799157..6b9aead47 100644 --- a/apps/openmw-mp/CellController.cpp +++ b/apps/openmw-mp/CellController.cpp @@ -3,6 +3,7 @@ #include #include "Cell.hpp" #include "Player.hpp" +#include "Script/Script.hpp" using namespace std; @@ -111,6 +112,8 @@ void CellController::removeCell(Cell *cell) if (cell == nullptr) return; + Script::Call(cell->getDescription().c_str()); + for (auto it = cells.begin(); it != cells.end();) { if (*it != nullptr && *it == cell) diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index 01b51d7c9..9651e1c44 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -124,6 +124,7 @@ public: {"OnPlayerInventoryChange", Function()}, {"OnPlayerSpellbookChange", Function()}, {"OnPlayerJournalChange", Function()}, + {"OnCellUnload", Function()}, {"OnActorList", Function()}, {"OnActorCellChange", Function()}, {"OnActorStatsDynamic", Function()}, diff --git a/apps/openmw-mp/WorldProcessor.cpp b/apps/openmw-mp/WorldProcessor.cpp index 94ab2a073..c1cc60e77 100644 --- a/apps/openmw-mp/WorldProcessor.cpp +++ b/apps/openmw-mp/WorldProcessor.cpp @@ -31,6 +31,7 @@ bool WorldProcessor::Process(RakNet::Packet &packet, BaseEvent &event) noexcept event.cell.blank(); event.objectChanges.objects.clear(); event.guid = packet.guid; + for (auto &processor : processors) { if (processor.first == packet.data[0])