Skip to content

Commit d1b4568

Browse files
committed
Fix crashing bug
The call to `GetSave` wasn't on the UI thread, so we couldn't get the `Global` object, and then the fallback loaded the autosave file, which isn't guaranteed to have the updated rules that specify the starting units.
1 parent adc076c commit d1b4568

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

C7/UIElements/NewGame/PlayerSetup.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,22 +202,22 @@ private SaveGame GetSave() {
202202
} catch (Exception e) {
203203
// Hardcoded fallback for the godot editor, which doesn't handle the
204204
// global.
205-
return SaveManager.LoadSave(@"./Text/c7-autosave-turn-0.json", "", (string unused) => { return unused; });
205+
return SaveManager.LoadSave(@"./Text/c7-static-map-save.json", "", (string unused) => { return unused; });
206206
}
207207
}
208208

209209
private void CreateGame() {
210210
loadingLabel.Visible = true;
211211
GlobalSingleton global = GetNode<GlobalSingleton>("/root/GlobalSingleton");
212+
SaveGame save = GetSave();
212213

213214
// World generation can take a bit of time if multiple attempts are
214215
// needed, so we don't want to tie up the UI thread.
215-
Thread thread = new(() => { DoWorldGenerationAndstartGame(global); });
216+
Thread thread = new(() => { DoWorldGenerationAndstartGame(save, global); });
216217
thread.Start();
217218
}
218219

219-
private void DoWorldGenerationAndstartGame(GlobalSingleton Global) {
220-
SaveGame save = GetSave();
220+
private void DoWorldGenerationAndstartGame(SaveGame save, GlobalSingleton Global) {
221221
log.Information("Starting map generation");
222222
save.Map = new SaveMap(MapGenerator.GenerateMap(Global.WorldCharacteristics));
223223
log.Information("Done with map generation");

0 commit comments

Comments
 (0)