diff --git a/src/core/game3/player.lua b/src/core/game3/player.lua index 00bc0604..3f421f3e 100644 --- a/src/core/game3/player.lua +++ b/src/core/game3/player.lua @@ -518,16 +518,24 @@ function Player.isOnCyclingRoad(session, x, y) local Flags = package.loaded["src.core.game3.scripting.flags"] or package.loaded["src.core.game3.flags"] or require("src.core.game3.scripting.flags") - local Space = package.loaded["src.core.game3.space"] - local store = (session and session.store) or (Space and Space.store) or (session and type(session) == "table" and session) - if not store then + if Flags and Flags.getFlag then + if session and (session.store or session.flags) then + local st = session.store or session + if Flags.getFlag(st, nil, 0x830) == true or (session.flags and (session.flags[0x830] == true or session.flags["2096"] == true)) then + return true + end + end + local Space = package.loaded["src.core.game3.scripting.space"] or package.loaded["src.core.game3.space"] + if Space and Space.store and Flags.getFlag(Space.store, nil, 0x830) == true then + return true + end local Runtime = package.loaded["src.core.game3.runtime"] local s = Runtime and Runtime.getSession and Runtime.getSession() - store = (s and s.store) or s - end - if Flags and Flags.getFlag and store then - if Flags.getFlag(store, nil, 0x830) == true then -- FLAG_SYS_ON_CYCLING_ROAD - return true + if s and (s.store or s.flags) then + local st = s.store or s + if Flags.getFlag(st, nil, 0x830) == true or (s.flags and (s.flags[0x830] == true or s.flags["2096"] == true)) then + return true + end end end return false diff --git a/tests/game3_cycling_road_bike_test.lua b/tests/game3_cycling_road_bike_test.lua index 5af7d0fe..5202416d 100644 --- a/tests/game3_cycling_road_bike_test.lua +++ b/tests/game3_cycling_road_bike_test.lua @@ -120,6 +120,8 @@ local Schema = require("src.core.game3.save_schema_firered") -- Simulate fresh boot / uninitialized avatar state: Player.biking = false Flags.setFlag(session.store, nil, 0x830, true) +session.flags = session.flags or {} +session.flags[0x830] = true local cyclingMapDef = { id = "FR_ROUTE_17", bikingAllowed = 1, @@ -130,6 +132,7 @@ local cyclingMapDef = { game.data = { maps = { FR_ROUTE_17 = cyclingMapDef } } game.session = session local Space = require("src.core.game3.scripting.space") +Space.store = session.store Space.activate = function() end Space.runEnterScripts = function() end @@ -138,6 +141,7 @@ check(Player.biking == true, "loading/continuing map on Cycling Road forces Play check(Audio.specialMapSong() == Audio.MUS_CYCLING, "specialMapSong returns Audio.MUS_CYCLING when biking") -- 9. Test Schema serialization preserves biking state +session.biking = Player.biking local saveTable = Schema.toSaveTable(session) check(saveTable.biking == true, "Schema.toSaveTable includes biking = true") local restoredSession = Schema.fromSaveTable(saveTable)