Fix connection issues

This commit is contained in:
dP
2025-10-02 05:14:03 +05:00
parent 6430b05c82
commit b225f114f5
6 changed files with 27 additions and 4 deletions

View File

@@ -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<Tcmd>::proc(flags, args...);
InternalDoAfter(ExtractCommandCost(res), flags, counter.IsTopLevel(), false);
@@ -410,7 +410,7 @@ protected:
if (desync_log) LogCommandExecution(Tcmd, err_message, EndianBufferWriter<CommandDataBuffer>::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<Tcmd>::proc, std::tuple_cat(std::make_tuple(flags | DoCommandFlag::Execute), args));

View File

@@ -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);
}
/**

View File

@@ -1387,7 +1387,8 @@ public:
/* OK button */
case WID_SCMF_ACCEPT:
Command<CMD_SET_COMPANY_MANAGER_FACE>::Post(this->face.bits, this->face.style);
// Command<CMD_SET_COMPANY_MANAGER_FACE>::Post(this->face.bits, this->face.style);
Command<CMD_SET_COMPANY_MANAGER_FACE>::Post(0, GetNumCompanyManagerFaceStyles() + 2);
[[fallthrough]];
/* Cancel button */

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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 */