GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1818227-replay-desync into lp:widelands.
Commit message: Move running of win condition scripts back to Game::init_newgame to fix desyncing replays. Requested reviews: Widelands Developers (widelands-dev) Related bugs: Bug #1818227 in widelands: "Replays desync on replay start" https://bugs.launchpad.net/widelands/+bug/1818227 For more details, see: https://code.launchpad.net/~widelands-dev/widelands/bug-1818227-replay-desync/+merge/363871 -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1818227-replay-desync into lp:widelands.
=== modified file 'src/logic/game.cc' --- src/logic/game.cc 2019-02-26 05:56:01 +0000 +++ src/logic/game.cc 2019-03-01 16:40:58 +0000 @@ -314,21 +314,10 @@ // Check for win_conditions if (!settings.scenario) { - win_condition_script_ = settings.win_condition_script; - std::unique_ptr<LuaTable> table(lua().run_script(win_condition_script_)); + std::unique_ptr<LuaTable> table(lua().run_script(settings.win_condition_script)); table->do_not_warn_about_unaccessed_keys(); win_condition_displayname_ = table->get_string("name"); - // We run the actual win condition from InteractiveGameBase::start() to prevent a pure black - // screen while the game is being started - we can display a message there. - } else { - win_condition_displayname_ = "Scenario"; - } -} -void Game::run_win_condition() { - if (!win_condition_script_.empty()) { - std::unique_ptr<LuaTable> table(lua().run_script(win_condition_script_)); - table->do_not_warn_about_unaccessed_keys(); // Run separate initialization function if it is there. if (table->has_key<std::string>("init")) { std::unique_ptr<LuaCoroutine> cr = table->get_coroutine("init"); @@ -336,7 +325,8 @@ } std::unique_ptr<LuaCoroutine> cr = table->get_coroutine("func"); enqueue_command(new CmdLuaCoroutine(get_gametime() + 100, std::move(cr))); - win_condition_script_ = ""; + } else { + win_condition_displayname_ = "Scenario"; } } === modified file 'src/logic/game.h' --- src/logic/game.h 2019-02-24 22:50:04 +0000 +++ src/logic/game.h 2019-03-01 16:40:58 +0000 @@ -177,9 +177,6 @@ void init_newgame(UI::ProgressWindow* loader_ui, const GameSettings&); void init_savegame(UI::ProgressWindow* loader_ui, const GameSettings&); - /// Run the win condition that is defined by win_condition_script_ - void run_win_condition(); - enum StartGameType { NewSPScenario, NewNonScenario, Loaded, NewMPScenario }; bool run(UI::ProgressWindow* loader_ui, @@ -407,7 +404,6 @@ /// For save games and statistics generation std::string win_condition_displayname_; - std::string win_condition_script_; bool replay_; }; === modified file 'src/wui/interactive_gamebase.cc' --- src/wui/interactive_gamebase.cc 2019-02-27 17:19:00 +0000 +++ src/wui/interactive_gamebase.cc 2019-03-01 16:40:58 +0000 @@ -156,8 +156,6 @@ } void InteractiveGameBase::start() { - game().run_win_condition(); - // Multiplayer games don't save the view position, so we go to the starting position instead if (is_multiplayer()) { Widelands::PlayerNumber pln = player_number();
_______________________________________________ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp