Ticket #4990: load_simstate+visual_replay.diff

File load_simstate+visual_replay.diff, 1.3 KB (added by elexis, 6 years ago)

Start a visual replay from commandline after loading a savestate from command line, (a21 patch that should still apply)

  • source/ps/Game.cpp

     
    3737#include "ps/LoaderThunks.h"
    3838#include "ps/Profile.h"
    3939#include "ps/Replay.h"
    4040#include "ps/Shapes.h"
    4141#include "ps/World.h"
     42#include "ps/GameSetup/CmdLineArgs.h"
    4243#include "ps/GameSetup/GameSetup.h"
    4344#include "renderer/Renderer.h"
    4445#include "renderer/TimeManager.h"
    4546#include "renderer/WaterManager.h"
    4647#include "scriptinterface/ScriptInterface.h"
     
    5253#include "tools/atlas/GameInterface/GameLoop.h"
    5354
    5455extern bool g_GameRestarted;
    5556extern GameLoopState* g_AtlasGameLoop;
    5657
     58extern CmdLineArgs g_args;
     59
    5760/**
    5861 * Globally accessible pointer to the CGame object.
    5962 **/
    6063CGame *g_Game=NULL;
    6164
    bool CGame::StartVisualReplay(const std:  
    189192    JSContext* cx = scriptInterface.GetContext();
    190193    JSAutoRequest rq(cx);
    191194
    192195    JS::RootedValue attribs(cx);
    193196    scriptInterface.ParseJSON(line, &attribs);
    194     StartGame(&attribs, "");
     197
     198    CStr savegame = "";
     199    if (g_args.Has("load"))
     200    {
     201        std::ifstream file (g_args.Get("load").c_str(), std::ifstream::in);
     202        std::stringstream buffer;
     203        buffer << file.rdbuf();
     204        savegame = buffer.str();
     205    }
     206
     207    StartGame(&attribs, savegame);
    195208
    196209    return true;
    197210}
    198211
    199212/**