From 2ebdc43bbe19514029ab080e1e80e6d80285a37b Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 7 Mar 2025 22:24:39 +0100 Subject: [PATCH] Add test for load while teleporting To reproduce #8311. Load game while landracer is scheduled to teleport from different cell. --- .../integration_tests/test_lua_api/global.lua | 18 ++++++++++++++++++ .../integration_tests/test_lua_api/menu.lua | 17 +++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/scripts/data/integration_tests/test_lua_api/global.lua b/scripts/data/integration_tests/test_lua_api/global.lua index cc8240554a..225660b858 100644 --- a/scripts/data/integration_tests/test_lua_api/global.lua +++ b/scripts/data/integration_tests/test_lua_api/global.lua @@ -326,6 +326,24 @@ testing.registerGlobalTest('player weapon attack', function() testing.runLocalTest(player, 'player weapon attack') end) +testing.registerGlobalTest('load while teleporting - init player', function() + local player = world.players[1] + player:teleport('Museum of Wonders', util.vector3(0, -1500, 111), util.transform.rotateZ(math.rad(180))) +end) + +testing.registerGlobalTest('load while teleporting - teleport', function() + local player = world.players[1] + local landracer = world.createObject('landracer') + landracer:teleport(player.cell, player.position + util.vector3(0, 500, 0)) + coroutine.yield() + + local door = world.getObjectByFormId(core.getFormId('the_hub.omwaddon', 26)) + door:activateBy(player) + coroutine.yield() + + landracer:teleport(player.cell, player.position) +end) + return { engineHandlers = { onUpdate = testing.updateGlobal, diff --git a/scripts/data/integration_tests/test_lua_api/menu.lua b/scripts/data/integration_tests/test_lua_api/menu.lua index 8316761765..8c6895a5d8 100644 --- a/scripts/data/integration_tests/test_lua_api/menu.lua +++ b/scripts/data/integration_tests/test_lua_api/menu.lua @@ -35,6 +35,23 @@ testing.registerMenuTest('save and load', function() testing.expectThat(menu.getAllSaves(), matchers.equalTo({})) end) +testing.registerMenuTest('load while teleporting', function() + menu.newGame() + coroutine.yield() + + testing.runGlobalTest('load while teleporting - init player') + + menu.saveGame('load while teleporting') + coroutine.yield() + + testing.runGlobalTest('load while teleporting - teleport') + + menu.loadGame(' - 1', 'load_while_teleporting.omwsave') + coroutine.yield() + + menu.deleteGame(' - 1', 'load_while_teleporting.omwsave') +end) + local function registerGlobalTest(name, description) testing.registerMenuTest(description or name, function() menu.newGame()