#1497
GPS: a route set before a BeamMP join survives the codeswap
A BeamMP join whose server sends another copy of the mod runs codeswap.swap(). That unloads our extensions and forgets every beamngEarth/* module.
gps.lua keeps the destination and the waypoints in module locals. So a route set before the join, or in the seconds between the level loading and the swap, is gone after it.
The change
codeswap.lua:M.keepGps(), called at the start ofswap(), stores the running GPS's waypoints still ahead and its destination in a global (M.GPS), the wayM.GLOBALcarries the fingerprint.- It runs before the unload, which may clear the GPS.
- Without a destination, the global is cleared, so a route the player cleared stays cleared.
gps.lua: at load, it takes that global once and callsM.setRoutewith it (one point: just the destination). The route is planned again at the next update. Autodrive isn't carried over.- Older copies: a copy on either side without this simply doesn't carry or take the route. A copy that carries it into one that doesn't take it leaves a small table in a global, which the next swap clears.
Tests
test_codeswap.lua, a swap with a destination and a waypoint set:- the carry holds both, the destination last;
- the real
gps.lua, required again, has the destination and the waypoint, with autodrive off; - the global is gone afterwards.
test_codeswap.lua, a swap with no destination: nothing is carried and a stale carry is cleared, so the new GPS starts empty.tools/run_lua_tests.py: all 141 modules pass on LuaJIT 2.1 (test_codeswap30,test_gps224). The new checks fail without the change.