Skip to content

An OpenMW mod that lets you play the whole Elder Scrolls III: Morrowind as a top-down isometric game — with full online co-op or MMO modes.

C++

Isowind 8f53fa4: Server log: no warnings for a player's basic info or cells loaded at the login (both expected)

Isowindf0a978a3d313
diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp
index 9c31587..881b648 100644
--- a/apps/openmw-mp/Networking.cpp
+++ b/apps/openmw-mp/Networking.cpp
@@ -188,7 +188,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
}
- if (!PlayerProcessor::Process(*packet))
+ // (BaseInfo was handled above)
+ if (packet->data[0] != ID_PLAYER_BASEINFO && !PlayerProcessor::Process(*packet))
LOG_MESSAGE_SIMPLE(TimedLog::LOG_WARN, "Unhandled PlayerPacket with identifier %i has arrived", packet->data[0]);
}
diff --git a/apps/openmw/mwmp/MechanicsHelper.cpp b/apps/openmw/mwmp/MechanicsHelper.cpp
index 56ff4e4..ff12a37 100644
--- a/apps/openmw/mwmp/MechanicsHelper.cpp
+++ b/apps/openmw/mwmp/MechanicsHelper.cpp
@@ -120,7 +120,6 @@ bool MechanicsHelper::respawnActor(const MWWorld::Ptr& ptr)
ptr.getCellRef().setCount(1);
MWBase::Environment::get().getWindowManager()->onDeleteCustomData(ptr);
ptr.getRefData().setCustomData(nullptr);
- ptr.getRefData().enable();
const ESM::Position& start = ptr.getCellRef().getPosition();
MWWorld::Ptr moved = world->moveObject(ptr, ptr.getCell()->getOriginCell(ptr), start.asVec3());
diff --git a/isowind/server/CoreScripts/scripts/cell/base.lua b/isowind/server/CoreScripts/scripts/cell/base.lua
index de25445..814c93d 100644
--- a/isowind/server/CoreScripts/scripts/cell/base.lua
+++ b/isowind/server/CoreScripts/scripts/cell/base.lua
@@ -677,6 +677,9 @@ function BaseCell:SaveContainers(pid)
tableHelper.insertValueIfMissing(self.data.packets.container, uniqueIndex)
local inventory = self.data.objectData[uniqueIndex].inventory
+ -- Isowind: whether the server knows what this holds; if not (its contents never came), what a player
+ -- takes from it is taken as it is instead of refused
+ local isInventoryKnown = inventory ~= nil
-- If this object's inventory is nil, or if the action is SET,
-- change the inventory to an empty table
@@ -734,7 +737,10 @@ function BaseCell:SaveContainers(pid)
end
end
else
- if action == enumerations.container.REMOVE then
+ if action == enumerations.container.REMOVE and not isInventoryKnown then
+ tes3mp.LogAppend(enumerations.log.INFO, "- Removing count of " .. actionCount .. " of " ..
+ itemRefId .. " from a container whose contents the server doesn't know")
+ elseif action == enumerations.container.REMOVE then
tes3mp.LogAppend(enumerations.log.WARN, "- Attempt to remove count of " .. actionCount ..
" from non-existent item " .. itemRefId)
tes3mp.SetContainerItemActionCountByIndex(objectIndex, itemIndex, 0)
@@ -757,7 +763,10 @@ function BaseCell:SaveContainers(pid)
end
tableHelper.cleanNils(inventory)
- self.data.objectData[uniqueIndex].inventory = inventory
+ -- (Taking from a container whose contents are unknown leaves them unknown)
+ if isInventoryKnown or action ~= enumerations.container.REMOVE then
+ self.data.objectData[uniqueIndex].inventory = inventory
+ end
end
-- Is this a player replying to our request for container contents?
diff --git a/isowind/server/CoreScripts/scripts/custom/isowindHost.lua b/isowind/server/CoreScripts/scripts/custom/isowindHost.lua
index 7be17a3..4a382fd 100644
--- a/isowind/server/CoreScripts/scripts/custom/isowindHost.lua
+++ b/isowind/server/CoreScripts/scripts/custom/isowindHost.lua
@@ -75,3 +75,43 @@ customEventHooks.registerHandler("OnServerInit", function(eventStatus)
WorldInstance:UpdateFrametimeMultiplier()
WorldInstance:QuicksaveToDrive()
end)
+
+-- A dead actor can't be looted until the game in charge of its cell has said what it carries (the server asks when it
+-- dies). If that answer never comes, its body would stay locked ("currently unusable"), so it unlocks after 5 seconds
+-- anyway, and the server asks a player there again.
+local lockedCorpses = {}
+local unlockTimer = nil
+
+customEventHooks.registerHandler("OnActorDeath", function(eventStatus, pid, cellDescription, actors)
+ for uniqueIndex in pairs(actors) do
+ table.insert(lockedCorpses, { cell = cellDescription, uniqueIndex = uniqueIndex, time = os.time() + 5 })
+ end
+end)
+
+function IsowindUnlockCorpses()
+ local now = os.time()
+ local waiting = {}
+ for _, corpse in ipairs(lockedCorpses) do
+ if corpse.time > now then
+ table.insert(waiting, corpse)
+ else
+ local cell = LoadedCells[corpse.cell]
+ if cell ~= nil and tableHelper.containsValue(cell.unusableContainerUniqueIndexes, corpse.uniqueIndex) then
+ tableHelper.removeValue(cell.unusableContainerUniqueIndexes, corpse.uniqueIndex)
+ tes3mp.LogMessage(enumerations.log.WARN, "[Isowind] No contents came for the body of " ..
+ corpse.uniqueIndex .. " in " .. corpse.cell .. "; unlocked it and asked again")
+ local visitor = cell.visitors[1]
+ if visitor ~= nil and Players[visitor] ~= nil and Players[visitor]:IsLoggedIn() then
+ cell:RequestContainers(visitor, { corpse.uniqueIndex })
+ end
+ end
+ end
+ end
+ lockedCorpses = waiting
+ tes3mp.RestartTimer(unlockTimer, time.seconds(2))
+end
+
+customEventHooks.registerHandler("OnServerPostInit", function(eventStatus)
+ unlockTimer = tes3mp.CreateTimer("IsowindUnlockCorpses", time.seconds(2))
+ tes3mp.StartTimer(unlockTimer)
+end)
diff --git a/isowind/server/CoreScripts/scripts/custom/isowindMmo.lua b/isowind/server/CoreScripts/scripts/custom/isowindMmo.lua
index b983b38..61c73d6 100644
--- a/isowind/server/CoreScripts/scripts/custom/isowindMmo.lua
+++ b/isowind/server/CoreScripts/scripts/custom/isowindMmo.lua
@@ -485,8 +485,10 @@ local function respawnInCell(cellDescription, uniqueIndexes)
for _, uniqueIndex in ipairs(uniqueIndexes) do
local objectData = cell.data.objectData[uniqueIndex]
local moved = objectData ~= nil and (objectData.cellChangeTo ~= nil or objectData.cellChangeFrom ~= nil)
+ -- One a script disabled (a quest removing someone) stays gone
+ local disabled = objectData ~= nil and objectData.state == false
local _, mpNum = splitIndex(uniqueIndex)
- if not moved then
+ if not moved and not disabled then
if cell.data.isowindLoot ~= nil then
cell.data.isowindLoot[uniqueIndex] = nil
end
diff --git a/isowind/server/CoreScripts/scripts/eventHandler.lua b/isowind/server/CoreScripts/scripts/eventHandler.lua
index fa1998b..82d7d9f 100644
--- a/isowind/server/CoreScripts/scripts/eventHandler.lua
+++ b/isowind/server/CoreScripts/scripts/eventHandler.lua
@@ -205,73 +205,51 @@ eventHandler.InitializeDefaultHandlers = function()
tes3mp.SendWorldKillCount(pid, true)
else
-
- if Players[pid].data.kills == nil then
- Players[pid].data.kills = {}
- end
+ -- Isowind: each player's own kill counts - the killer's, their allies' and those of the players who hit
+ -- it in the last 10 minutes - each sent only to them
for uniqueIndex, actor in pairs(actors) do
-
- if Players[pid].data.kills[actor.refId] == nil then
- Players[pid].data.kills[actor.refId] = 0
+
+ local recipients = { pid }
+ local names = {}
+
+ for _, alliedName in ipairs(Players[pid].data.alliedPlayers or {}) do
+ table.insert(names, alliedName)
end
- Players[pid].data.kills[actor.refId] = Players[pid].data.kills[actor.refId] + 1
- Players[pid]:QuicksaveToDrive()
-
- if sendKills[uniqueIndex] == nil then
- sendKills[uniqueIndex] = {timestamp = os.time(), playersName = {}}
+ if sendKills[uniqueIndex] ~= nil and os.time() - sendKills[uniqueIndex].timestamp < 600 then
+ for _, hitterName in ipairs(sendKills[uniqueIndex].playersName) do
+ table.insert(names, hitterName)
+ end
end
- tableHelper.insertValueIfMissing(sendKills[uniqueIndex].playersName, string.lower(Players[pid].accountName))
-
- tes3mp.AddKill(actor.refId, Players[pid].data.kills[actor.refId])
-
- for _, alliedName in ipairs(Players[pid].data.alliedPlayers) do
+ sendKills[uniqueIndex] = nil
- if logicHandler.GetPlayerByName(alliedName) then
-
- local alliedPid = logicHandler.GetPlayerByName(alliedName).pid
-
- if Players[alliedPid] ~= nil and Players[alliedPid]:IsLoggedIn() then
-
- if Players[alliedPid].data.kills == nil then
- Players[alliedPid].data.kills = {}
- end
-
- if Players[alliedPid].data.kills[actor.refId] == nil then
- Players[alliedPid].data.kills[actor.refId] = 0
- end
-
- Players[alliedPid].data.kills[actor.refId] = Players[alliedPid].data.kills[actor.refId] + 1
- Players[alliedPid]:QuicksaveToDrive()
- tableHelper.insertValueIfMissing(sendKills[uniqueIndex].playersName, string.lower(Players[alliedPid].accountName))
-
- end
-
+ for _, name in ipairs(names) do
+ local player = logicHandler.GetPlayerByName(name)
+
+ if player ~= nil and player:IsLoggedIn() then
+ tableHelper.insertValueIfMissing(recipients, player.pid)
end
-
end
- table.insert(cell.unusableContainerUniqueIndexes, uniqueIndex)
-
- end
-
- for targetIndex, actor in pairs(actors) do
-
- for _, targetName in ipairs(sendKills[targetIndex].playersName) do
-
- local targetPid = logicHandler.GetPlayerByName(targetName).pid
-
- if Players[targetPid] ~= nil and Players[targetPid]:IsLoggedIn() then
- tes3mp.SendWorldKillCount(targetPid, false)
+ for _, recipientPid in ipairs(recipients) do
+ local recipient = Players[recipientPid]
+
+ if recipient.data.kills == nil then
+ recipient.data.kills = {}
end
-
+
+ recipient.data.kills[actor.refId] = (recipient.data.kills[actor.refId] or 0) + 1
+ recipient:QuicksaveToDrive()
+
+ tes3mp.ClearKillChanges()
+ tes3mp.AddKill(actor.refId, recipient.data.kills[actor.refId])
+ tes3mp.SendWorldKillCount(recipientPid, false)
end
-
- sendKills[targetIndex] = nil
-
+
+ table.insert(cell.unusableContainerUniqueIndexes, uniqueIndex)
end
-
+
end
cell:RequestContainers(pid, tableHelper.getArrayFromIndexes(actors))
@@ -1216,6 +1194,10 @@ eventHandler.OnCellLoad = function(pid, cellDescription)
logicHandler.LoadCellForPlayer(pid, cellDescription)
end
customEventHooks.triggerHandlers("OnCellLoad", eventStatus, {pid, cellDescription})
+ elseif Players[pid] ~= nil then
+ -- Isowind: a game still at the login reports the cells around where it waits; nothing to do
+ tes3mp.LogMessage(enumerations.log.VERBOSE, "- " .. pid .. " loaded cell " .. cellDescription ..
+ " before logging in")
else
tes3mp.LogMessage(enumerations.log.WARN, "Undefined behavior: invalid player " .. pid ..
" loaded cell " .. cellDescription)
diff --git a/isowind/server/tests/mmotest.lua b/isowind/server/tests/mmotest.lua
new file mode 100644
index 0000000..f40dcbc
--- /dev/null
+++ b/isowind/server/tests/mmotest.lua
@@ -0,0 +1,242 @@
+-- How to run: copy this into a copy of the server folder as CoreScripts/scripts/custom/mmotest.lua, add
+-- require("custom/mmotest") at the end of customScripts.lua, put mode = mmo under [Isowind] in tes3mp-server.cfg and
+-- start tes3mp-server for a few seconds; the log shows "[mmotest] PASS/FAIL ..." and "done, N failed".
+-- Tests of isowindMmo.lua inside a real server: fake players and packets, real cells and world data.
+local log = function(text) tes3mp.LogMessage(enumerations.log.INFO, "[mmotest] " .. text) end
+local failures = 0
+local function check(name, condition)
+ if condition then log("PASS " .. name) else log("FAIL " .. name); failures = failures + 1 end
+end
+
+-- Every Set/Add/Send/Clear/Copy call is recorded instead of done; Get* answer from the packet being "received"
+local sent = {}
+local current = {}
+local incoming = nil
+local function record(name)
+ return function(...)
+ local args = { ... }
+ if name == "ClearObjectList" then current = { objects = {}, object = { items = {} }, item = {} }
+ elseif name == "SetObjectRefNum" then current.object.refNum = args[1]
+ elseif name == "SetObjectMpNum" then current.object.mpNum = args[1]
+ elseif name == "SetObjectRefId" then current.object.refId = args[1]
+ elseif name == "SetContainerItemRefId" then current.item.refId = args[1]
+ elseif name == "SetContainerItemCount" then current.item.count = args[1]
+ elseif name == "SetContainerItemActionCount" then current.item.actionCount = args[1]
+ elseif name == "AddContainerItem" then table.insert(current.object.items, current.item); current.item = {}
+ elseif name == "AddObject" then table.insert(current.objects, current.object); current.object = { items = {} }
+ elseif name == "SetObjectListAction" then current.action = args[1]
+ elseif name == "SetObjectListConsoleCommand" then current.command = args[1]
+ elseif name == "SetContainerItemActionCountByIndex" then
+ table.insert(sent, { name = name, args = args })
+ elseif name:find("^Send") then
+ table.insert(sent, { name = name, args = args, action = current.action, command = current.command,
+ objects = current.objects })
+ end
+ end
+end
+local function installMocks()
+for name, fn in pairs(tes3mp) do
+ if type(name) == "string" and (name:find("^Set") or name:find("^Add") or name:find("^Send") or
+ name:find("^Clear") or name == "CopyReceivedObjectListToStore") then
+ tes3mp[name] = record(name)
+ end
+end
+current = { objects = {}, object = { items = {} }, item = {} }
+end
+
+local function receive(packet)
+ incoming = packet
+end
+tes3mp.ReadReceivedObjectList = function() end
+tes3mp.GetObjectListAction = function() return incoming.action end
+tes3mp.GetObjectListContainerSubAction = function() return incoming.subAction or 0 end
+tes3mp.GetObjectListOrigin = function() return incoming.origin or enumerations.packetOrigin.CLIENT_GAMEPLAY end
+tes3mp.GetObjectListSize = function() return #incoming.objects end
+tes3mp.GetObjectRefNum = function(i) return incoming.objects[i + 1].refNum end
+tes3mp.GetObjectMpNum = function(i) return incoming.objects[i + 1].mpNum end
+tes3mp.GetObjectRefId = function(i) return incoming.objects[i + 1].refId end
+tes3mp.GetContainerChangesSize = function(i) return #incoming.objects[i + 1].items end
+local function item(i, j) return incoming.objects[i + 1].items[j + 1] end
+tes3mp.GetContainerItemRefId = function(i, j) return item(i, j).refId end
+tes3mp.GetContainerItemCount = function(i, j) return item(i, j).count end
+tes3mp.GetContainerItemActionCount = function(i, j) return item(i, j).actionCount or 0 end
+tes3mp.GetContainerItemCharge = function() return -1 end
+tes3mp.GetContainerItemEnchantmentCharge = function() return -1 end
+tes3mp.GetContainerItemSoul = function() return "" end
+
+local function lastSent(name)
+ for i = #sent, 1, -1 do if sent[i].name == name then return sent[i] end end
+end
+
+local function validate(event, args)
+ return customEventHooks.triggerValidators(event, args)
+end
+
+local function runTests()
+ installMocks()
+ local CELL = "-3, 6"
+ local pid = 0
+ Players[pid] = { pid = pid, accountName = "Alpha", name = "Alpha", consoleCommandsQueued = {}, summons = {},
+ data = { location = { cell = CELL }, alliedPlayers = {} }, IsLoggedIn = function() return true end,
+ QuicksaveToDrive = function() end, Message = function() end }
+ logicHandler.LoadCell(CELL)
+ local cell = LoadedCells[CELL]
+ cell.visitors = { pid }
+ local ADD, REMOVE = enumerations.container.ADD, enumerations.container.REMOVE
+
+ -- Taking from a chest is this player's own, and only they get it back
+ receive({ action = REMOVE, objects = { { refNum = 1234, mpNum = 0, refId = "contain_chest",
+ items = { { refId = "gold_001", count = 50, actionCount = 20 } } } } })
+ local status = validate("OnContainer", { pid, CELL, {} })
+ check("container change skips the shared save", status.validDefaultHandler == false)
+ local echo = lastSent("SendContainer")
+ check("container change sent back to the taker only", echo ~= nil and echo.args[1] == false and echo.args[2] == false)
+ local mine = cell.data.isowindLoot["1234-0"].players.alpha
+ local key = next(mine)
+ check("loot recorded as -20 gold", key ~= nil and mine[key].count == -20)
+ check("chest not marked to refill", WorldInstance.data.isowindRegrow == nil or
+ WorldInstance.data.isowindRegrow[CELL] == nil)
+
+ -- Loading the cell gives the player their own state on top of the shared one
+ sent = {}
+ customEventHooks.triggerHandlers("OnCellLoad", customEventHooks.makeEventStatus(true, true), { pid, CELL })
+ local replay = lastSent("SendContainer")
+ check("cell load replays the loot as a REMOVE of 20",
+ replay ~= nil and replay.action == REMOVE and replay.objects[1].items[1].actionCount == 20 and
+ replay.objects[1].refId == "contain_chest")
+
+ -- Putting it back cancels it
+ receive({ action = ADD, objects = { { refNum = 1234, mpNum = 0, refId = "contain_chest",
+ items = { { refId = "gold_001", count = 20 } } } } })
+ validate("OnContainer", { pid, CELL, {} })
+ check("putting it back clears the record", cell.data.isowindLoot["1234-0"].players.alpha == nil)
+
+ -- Replies to the server's requests stay shared
+ receive({ action = enumerations.container.SET, subAction = enumerations.containerSub.REPLY_TO_REQUEST,
+ objects = { { refNum = 1234, mpNum = 0, refId = "contain_chest", items = {} } } })
+ status = validate("OnContainer", { pid, CELL, {} })
+ check("request reply goes to the default handler", status.validDefaultHandler ~= false)
+
+ -- Picking up a loose item from the game's files
+ sent = {}
+ receive({ objects = {} })
+ status = validate("OnObjectDelete", { pid, CELL, { ["5678-0"] = { refId = "misc_com_bottle_01",
+ uniqueIndex = "5678-0" } }, {} })
+ check("pickup skips the shared save", status.validDefaultHandler == false)
+ check("pickup recorded for the player", cell.data.isowindTaken["5678-0"].alpha == true)
+ local delete = lastSent("SendObjectDelete")
+ check("pickup sent to the player only", delete ~= nil and delete.args[1] == false)
+ check("pickup not saved as shared", not tableHelper.containsValue(cell.data.packets.delete or {}, "5678-0"))
+
+ -- A dead mudcrab comes back after 1.5 minutes, once no one is near
+ cell.data.objectData["999-0"] = { refId = "mudcrab", stats = { healthBase = 35 } }
+ customEventHooks.triggerHandlers("OnActorDeath", customEventHooks.makeEventStatus(true, true),
+ { pid, CELL, { ["999-0"] = { refId = "mudcrab", killer = {} } } })
+ local due = WorldInstance.data.isowindRespawns[CELL]["999-0"]
+ check("mudcrab due in about 90 seconds", due ~= nil and math.abs(due - os.time() - 90) <= 2)
+
+ cell.data.objectData["998-0"] = { refId = "dagoth gares", stats = { healthBase = 300 } }
+ cell.data.objectData["997-0"] = { refId = "ordinator", stats = { healthBase = 250 } }
+ customEventHooks.triggerHandlers("OnActorDeath", customEventHooks.makeEventStatus(true, true),
+ { pid, CELL, { ["998-0"] = { refId = "dagoth gares", killer = {} },
+ ["997-0"] = { refId = "ordinator", killer = {} } } })
+ check("Dagoth is a boss (60 minutes)",
+ math.abs(WorldInstance.data.isowindRespawns[CELL]["998-0"] - os.time() - 3600) <= 2)
+ check("250 health is elite (15 minutes)",
+ math.abs(WorldInstance.data.isowindRespawns[CELL]["997-0"] - os.time() - 900) <= 2)
+
+ -- MMO kill counts are each player's own
+ check("killer's own kill count is 1", Players[pid].data.kills ~= nil and Players[pid].data.kills.mudcrab == 1)
+ local killCount = lastSent("SendWorldKillCount")
+ check("kill count sent to the killer only", killCount ~= nil and killCount.args[1] == pid and
+ killCount.args[2] == false)
+
+ -- A body whose contents never come unlocks after 5 seconds
+ check("body locked right after death", tableHelper.containsValue(cell.unusableContainerUniqueIndexes, "999-0"))
+ local realTime = os.time
+ os.time = function() return realTime() + 10 end
+ IsowindUnlockCorpses()
+ os.time = realTime
+ check("body unlocked after 5 seconds", not tableHelper.containsValue(cell.unusableContainerUniqueIndexes, "999-0"))
+
+ -- Taking from a container whose contents the server doesn't know (as co-op does it) goes through
+ sent = {}
+ receive({ action = REMOVE, objects = { { refNum = 777, mpNum = 0, refId = "contain_barrel",
+ items = { { refId = "ingred_bread_01", count = 3, actionCount = 2 } } } } })
+ cell:SaveContainers(pid)
+ check("take from unknown contents not refused", lastSent("SetContainerItemActionCountByIndex") == nil)
+ check("unknown contents stay unknown", cell.data.objectData["777-0"].inventory == nil)
+ cell.data.objectData["777-0"].inventory = {}
+ receive({ action = REMOVE, objects = { { refNum = 777, mpNum = 0, refId = "contain_barrel",
+ items = { { refId = "ingred_bread_01", count = 3, actionCount = 2 } } } } })
+ cell:SaveContainers(pid)
+ local refused = lastSent("SetContainerItemActionCountByIndex")
+ check("take of something known not to be there still refused", refused ~= nil and refused.args[3] == 0)
+
+ -- One a quest script disabled after it died
+ cell.data.objectData["996-0"] = { refId = "quest_npc", state = false, stats = { healthBase = 40 } }
+ customEventHooks.triggerHandlers("OnActorDeath", customEventHooks.makeEventStatus(true, true),
+ { pid, CELL, { ["996-0"] = { refId = "quest_npc", killer = {} } } })
+ WorldInstance.data.isowindRespawns[CELL]["996-0"] = os.time() - 1
+
+ -- Not while the player is there
+ WorldInstance.data.isowindRespawns[CELL]["999-0"] = os.time() - 1
+ sent = {}
+ IsowindMmoRespawnTimer()
+ check("no respawn with the player in the cell", lastSent("SendConsoleCommand") == nil)
+
+ -- The player walks off, next to the cell: still not
+ Players[pid].data.location.cell = "-2, 6"
+ cell.visitors = {}
+ IsowindMmoRespawnTimer()
+ check("no respawn with the player next door", lastSent("SendConsoleCommand") == nil)
+
+ -- Far away: it respawns
+ Players[pid].data.location.cell = "10, 10"
+ logicHandler.UnloadCell(CELL)
+ IsowindMmoRespawnTimer()
+ local respawn = lastSent("SendConsoleCommand")
+ check("respawn sent to everyone", respawn ~= nil and respawn.command == "isowind respawn" and
+ respawn.args[1] == true)
+ check("respawn names the mudcrab", respawn ~= nil and respawn.objects[1] ~= nil and
+ respawn.objects[1].refNum == "999" or (respawn ~= nil and respawn.objects[1] ~= nil and
+ tostring(respawn.objects[1].refNum) == "999"))
+ logicHandler.LoadCell(CELL)
+ cell = LoadedCells[CELL]
+ check("mudcrab's death forgotten", cell.data.objectData["999-0"] == nil)
+ check("disabled one not brought back", cell.data.objectData["996-0"] ~= nil and
+ cell.data.objectData["996-0"].state == false)
+ check("boss still waiting", WorldInstance.data.isowindRespawns[CELL]["998-0"] ~= nil)
+
+ -- Plants grow back for the harvester
+ Players[pid].data.location.cell = CELL
+ receive({ action = REMOVE, objects = { { refNum = 4321, mpNum = 0, refId = "flora_kreshweed_01",
+ items = { { refId = "ingred_kresh_fiber_01", count = 1, actionCount = 1 } } } } })
+ validate("OnContainer", { pid, CELL, {} })
+ local regrow = WorldInstance.data.isowindRegrow[CELL]["4321-0"].alpha
+ check("plant regrowth due in 10 minutes", regrow ~= nil and math.abs(regrow - os.time() - 600) <= 2)
+ WorldInstance.data.isowindRegrow[CELL]["4321-0"].alpha = os.time() - 1
+ Players[pid].data.location.cell = "10, 10"
+ cell.visitors = {}
+ logicHandler.UnloadCell(CELL)
+ IsowindMmoRespawnTimer()
+ logicHandler.LoadCell(CELL)
+ cell = LoadedCells[CELL]
+ check("harvest forgotten after regrowth", cell.data.isowindLoot["4321-0"].players.alpha == nil)
+ sent = {}
+ Players[pid].data.location.cell = CELL
+ customEventHooks.triggerHandlers("OnCellLoad", customEventHooks.makeEventStatus(true, true), { pid, CELL })
+ local grown = nil
+ for _, packet in ipairs(sent) do
+ if packet.name == "SendContainer" and packet.action == ADD then grown = packet end
+ end
+ check("plant given back to the player's game as an ADD of 1", grown ~= nil and
+ grown.objects[1].items[1].count == 1 and grown.objects[1].items[1].refId == "ingred_kresh_fiber_01")
+
+ log("done, " .. failures .. " failed")
+end
+
+customEventHooks.registerHandler("OnServerPostInit", function()
+ local ok, err = pcall(runTests)
+ if not ok then log("ERROR " .. tostring(err)) end
+end)