beyond-all-reason / spring-launcher

Launcher for SpringRTS games
MIT License
2 stars 7 forks source link

Allow savegames to be started with old engines #7

Closed Beherith closed 1 year ago

Beherith commented 2 years ago

Due to us lingering very long on one engine, with a large player influx since then, it might be wise to implement the loadsavegame wrapper function to run for alternate engines. Here are some notes regarding this:

Each save game has an associated lua file with metadata, which contains the engine version used :

return {
    description = "20220907_102607",
    engineVersion = "105.1.1-1158-g27934d7 BAR105",
    gameName = "Beyond All Reason",
    gameVersion = "test-20718-cbf3397",
    gameframe = 31594,
    map = "Comet Catcher Remake 1.8",
    playerName = "[teh]Beherith",
    totalGameframe = 31594,
    date = {
        day = 7,
        hour = 10,
        isdst = true,
        min = 26,
        month = 9,
        sec = 7,
        wday = 4,
        yday = 250,
        year = 2022,
    },
}

However, the way save games are loaded, they can only load on the most recent engine, due to being loaded via: WG.Chobby.localLobby:StartGameFromString(script)

Replays on the other hand, support being launched from older engines, as they are launched via the wrapper: https://github.com/beyond-all-reason/spring-launcher/blob/master/src/exts/start_new_spring_handler.js

local engine = string.gsub(string.gsub(startEngineVersion, " maintenance", ""), " develop", "")
local engine = string.gsub(startEngineVersion, "BAR105", "bar") -- because this is the path we use
local params = {
    StartDemoName = string.sub(startReplayFile, 7), -- TRUNCATE 'DEMOS/' FROM THE PATH!
    Engine = engine,
    SpringSettings = WG.SettingsWindow.GetSettingsString(),
}
WG.WrapperLoopback.StartNewSpring(params)

This wrapper is implemented by the launcher, and works fine usually, except it does not work for savegames, as the launcher hard codes the demos/ folder.

https://github.com/beyond-all-reason/spring-launcher/blob/master/src/exts/start_new_spring_handler.js

Proposed solution: I'm going to remove the hard-coded 'demos' from this, to allow loading of save games on old engines too.

p2004a commented 1 year ago

Closing as done per https://discord.com/channels/549281623154229250/927489991096033301/1095937144738033747