diff --git a/src/command_func.h b/src/command_func.h index d195b3a0ee..1494b618b2 100644 --- a/src/command_func.h +++ b/src/command_func.h @@ -169,7 +169,7 @@ public: /* Execute the command here. All cost-relevant functions set the expenses type * themselves to the cost object at some point. */ InternalDoBefore(counter.IsTopLevel(), false); - // Debug(misc, 0, "DO {}/{} {} {}({}) seed={} company={}", _date, _date_fract, _frame_counter, GetCommandName(Tcmd), Tcmd, _random.state[0] & 0xFF, (int)_current_company); + // Debug(misc, 0, "DO {}/{} {} {}({}) seed={} company={}", TimerGameCalendar::date, TimerGameCalendar::date_fract, _frame_counter, GetCommandName(Tcmd), Tcmd, _random.state[0] & 0xFF, _current_company); Tret res = CommandTraits::proc(flags, args...); InternalDoAfter(ExtractCommandCost(res), flags, counter.IsTopLevel(), false); @@ -410,7 +410,7 @@ protected: if (desync_log) LogCommandExecution(Tcmd, err_message, EndianBufferWriter::FromValue(args), false); - // Debug(misc, 0, "EXEC {}/{} {} {}({}) seed={} company={} tile={}", _date, _date_fract, _frame_counter, GetCommandName(Tcmd), Tcmd, _random.state[0] & 0xFF, (int)_current_company, tile); + Debug(misc, 0, "EXEC {}/{} {} {}({}) seed={} company={} tile={}", TimerGameCalendar::date, TimerGameCalendar::date_fract, _frame_counter, GetCommandName(Tcmd), Tcmd, _random.state[0] & 0xFF, _current_company, tile); /* Actually try and execute the command. */ Tret res2 = std::apply(CommandTraits::proc, std::tuple_cat(std::make_tuple(flags | DoCommandFlag::Execute), args)); diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index deb80fc3e1..e0707fbd7e 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -1463,6 +1463,7 @@ void SetCompanyManagerFaceStyle(CompanyManagerFace &cmf, uint style) cmf.style = style; cmf.style_label = spec->label; + Debug(misc, 0, "Set face style {} {}", cmf.style, cmf.style_label); } /** diff --git a/src/company_gui.cpp b/src/company_gui.cpp index d1a8386328..78361ab5b2 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -1387,7 +1387,8 @@ public: /* OK button */ case WID_SCMF_ACCEPT: - Command::Post(this->face.bits, this->face.style); + // Command::Post(this->face.bits, this->face.style); + Command::Post(0, GetNumCompanyManagerFaceStyles() + 2); [[fallthrough]]; /* Cancel button */ diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index 2842b494a7..1c639e75ce 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -849,6 +849,8 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(Packet /* If the savegame has successfully loaded, ALL windows have been removed, * only toolbar/statusbar and gamefield are visible */ + Debug(misc, 0, "Loaded save date {} / {}, frame {}, state {}", TimerGameCalendar::date, TimerGameCalendar::date_fract, _frame_counter, _random.state[0]); + /* Say we received the map and loaded it correctly! */ SendMapOk(); diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 910450b589..ed4f72da66 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -604,6 +604,7 @@ static void StartScripts() bool AfterLoadGame() { SetSignalHandlers(); + Debug(net, 0, "State before AfterLoad {}", _random.state[0]); extern TileIndex _cur_tileloop_tile; // From landscape.cpp. /* The LFSR used in RunTileLoop iteration cannot have a zeroed state, make it non-zeroed. */ @@ -762,6 +763,7 @@ bool AfterLoadGame() ResetSignalHandlers(); return false; } + Debug(net, 0, "AfterLoad state A {}", _random.state[0]); switch (gcf_res) { case GLC_COMPATIBLE: ShowErrorMessage(GetEncodedString(STR_NEWGRF_COMPATIBLE_LOAD_WARNING), {}, WL_CRITICAL); break; @@ -866,6 +868,8 @@ bool AfterLoadGame() /* Old orders are no longer needed. */ ClearOldOrders(); + Debug(net, 0, "AfterLoad state B {}", _random.state[0]); + /* make sure there is a town in the game */ if (_game_mode == GM_NORMAL && Town::GetNumItems() == 0) { SetSaveLoadError(STR_ERROR_NO_TOWN_IN_SCENARIO); @@ -1261,6 +1265,7 @@ bool AfterLoadGame() } } } + Debug(net, 0, "AfterLoad state C {}", _random.state[0]); if (IsSavegameVersionBefore(SLV_42)) { for (auto t : Map::Iterate()) { @@ -1669,6 +1674,8 @@ bool AfterLoadGame() } } + Debug(net, 0, "AfterLoad state D {}", _random.state[0]); + if (IsSavegameVersionBefore(SLV_49)) { /* Perform conversion of very old face bits. */ for (Company *c : Company::Iterate()) { @@ -1685,13 +1692,17 @@ bool AfterLoadGame() auto style = FindCompanyManagerFaceLabel(c->face.style_label); if (style.has_value()) { SetCompanyManagerFaceStyle(c->face, *style); + Debug(misc, 0, "SET style = {}", c->face.style_label); } else { /* Style no longer exists, pick an entirely new face. */ RandomiseCompanyManagerFace(c->face, _random); + Debug(misc, 0, "DANGER RANDOM CALL for style = {}", c->face.style_label); } } } + Debug(net, 0, "AfterLoad state D3 {}", _random.state[0]); + if (IsSavegameVersionBefore(SLV_52)) { for (auto t : Map::Iterate()) { if (IsTileType(t, MP_OBJECT) && t.m5() == OBJECT_STATUE) { @@ -2528,6 +2539,7 @@ bool AfterLoadGame() } } } + Debug(net, 0, "AfterLoad state E {}", _random.state[0]); /* Oilrig was moved from id 15 to 9. */ if (IsSavegameVersionBefore(SLV_139)) { @@ -3064,6 +3076,7 @@ bool AfterLoadGame() } /* Beyond this point, tile types which can be accessed by vehicles must be in a valid state. */ + Debug(net, 0, "AfterLoad state EE {}", _random.state[0]); /* Update all vehicles: Phase 2 */ AfterLoadVehiclesPhase2(true); @@ -3361,6 +3374,7 @@ bool AfterLoadGame() if (IsLevelCrossingTile(tile)) UpdateLevelCrossing(tile, false); } } + Debug(net, 0, "AfterLoad state F {}", _random.state[0]); /* Compute station catchment areas. This is needed here in case UpdateStationAcceptance is called below. */ Station::RecomputeCatchmentForAll(); @@ -3397,7 +3411,6 @@ bool AfterLoadGame() if (s->acceleration == 0) s->acceleration = ShipVehInfo(s->engine_type)->acceleration; } } - if (IsSavegameVersionBefore(SLV_MAX_LOAN_FOR_COMPANY)) { for (Company *c : Company::Iterate()) { c->max_loan = COMPANY_MAX_LOAN_DEFAULT; @@ -3476,6 +3489,8 @@ bool AfterLoadGame() } } + Debug(net, 0, "State after AfterLoad {}", _random.state[0]); + return true; } diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index c5821d8f61..171bd10b91 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -2309,6 +2309,10 @@ static void SlLoadChunks() if (ch == nullptr) SlErrorCorrupt("Unknown chunk type"); SlLoadChunk(*ch); } + Debug(misc, 0, + "SlLoadChunks date {} / {}, state {}, version {}-{}", + TimerGameCalendar::date, TimerGameCalendar::date_fract, + _random.state[0], _sl_version, _sl_minor_version); } /** Load all chunks for savegame checking */