From d8baa1342c4ddce823724b758c5b3e4547e84e90 Mon Sep 17 00:00:00 2001 From: rubidium Date: Thu, 8 Apr 2010 21:14:49 +0000 Subject: [PATCH] (svn r19589) -Change: add some more useful information to the desync log and unify the formatting --- src/command.cpp | 2 +- src/debug.cpp | 2 +- src/genworld.cpp | 2 +- src/network/network.cpp | 4 ++-- src/network/network_server.cpp | 3 +++ src/openttd.cpp | 6 +++--- src/saveload/saveload.cpp | 4 ++-- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/command.cpp b/src/command.cpp index aad1bba761..6abb738df1 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -632,7 +632,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, return_dcpi(CommandCost(), false); } #endif /* ENABLE_NETWORK */ - DEBUG(desync, 1, "cmd: %08x; %08x; %1x; %06x; %08x; %08x; %04x; %s\n", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text); + DEBUG(desync, 1, "cmd: %08x; %02x; %02x; %06x; %08x; %08x; %08x; %s", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text); /* Actually try and execute the command. If no cost-type is given * use the construction one */ diff --git a/src/debug.cpp b/src/debug.cpp index 391730f5ed..8ef91bed0a 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -93,7 +93,7 @@ static void debug_print(const char *dbg, const char *buf) static FILE *f = FioFOpenFile("commands-out.log", "wb", AUTOSAVE_DIR); if (f == NULL) return; - fprintf(f, "%s%s", GetLogPrefix(), buf); + fprintf(f, "%s%s\n", GetLogPrefix(), buf); fflush(f); } } diff --git a/src/genworld.cpp b/src/genworld.cpp index 973bf89ffd..3b0f2260d9 100644 --- a/src/genworld.cpp +++ b/src/genworld.cpp @@ -176,7 +176,7 @@ static void _GenerateWorld(void *) ShowNewGRFError(); if (_network_dedicated) DEBUG(net, 0, "Map generated, starting game"); - DEBUG(desync, 1, "new_map: %i\n", _settings_game.game_creation.generation_seed); + DEBUG(desync, 1, "new_map: %08x", _settings_game.game_creation.generation_seed); if (_settings_client.gui.pause_on_newgame && _game_mode == GM_NORMAL) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE); if (_debug_desync_level > 0) { diff --git a/src/network/network.cpp b/src/network/network.cpp index b591e0ecd3..73548d2b1a 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -249,7 +249,7 @@ void NetworkTextMessage(NetworkAction action, ConsoleColour colour, bool self_se SetDParam(2, data); GetString(message, strid, lastof(message)); - DEBUG(desync, 1, "msg: %d; %d; %s\n", _date, _date_fract, message); + DEBUG(desync, 1, "msg: %08x; %02x; %s", _date, _date_fract, message); IConsolePrintF(colour, "%s", message); NetworkAddChatMessage((TextColour)colour, duration, "%s", message); } @@ -1024,7 +1024,7 @@ static bool NetworkDoClientLoop() if (_sync_seed_1 != _random.state[0]) { #endif NetworkError(STR_NETWORK_ERROR_DESYNC); - DEBUG(desync, 1, "sync_err: %d; %d\n", _date, _date_fract); + DEBUG(desync, 1, "sync_err: %08x; %02x", _date, _date_fract); DEBUG(net, 0, "Sync error detected!"); NetworkClientError(NETWORK_RECV_STATUS_DESYNC, NetworkClientSocket::Get(0)); return false; diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 94c2911f25..127ac1b90c 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -716,6 +716,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN) strecpy(ci->client_name, name, lastof(ci->client_name)); ci->client_playas = playas; ci->client_lang = client_lang; + DEBUG(desync, 1, "client: %08x; %02x; %02x; %04x", _date, _date_fract, (int)ci->client_playas, ci->index); /* Make sure companies to which people try to join are not autocleaned */ if (Company::IsValidID(playas)) _network_company_states[playas].months_empty = 0; @@ -1396,6 +1397,8 @@ void NetworkUpdateClientInfo(ClientID client_id) if (ci == NULL) return; + DEBUG(desync, 1, "client: %08x; %02x; %02x; %04x", _date, _date_fract, (int)ci->client_playas, client_id); + FOR_ALL_CLIENT_SOCKETS(cs) { SEND_COMMAND(PACKET_SERVER_CLIENT_INFO)(cs, ci); } diff --git a/src/openttd.cpp b/src/openttd.cpp index e5e05a0488..77677dd33a 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1117,7 +1117,7 @@ static void CheckCaches() RoadVehUpdateCache(rv); if (memcmp(&cache, &rv->rcache, sizeof(RoadVehicleCache)) != 0) { - DEBUG(desync, 2, "cache mismatch: vehicle %i, company %i, unit number %i\n", v->index, (int)v->owner, v->unitnumber); + DEBUG(desync, 2, "cache mismatch: vehicle %i, company %i, unit number %i", v->index, (int)v->owner, v->unitnumber); } } break; @@ -1135,7 +1135,7 @@ static void CheckCaches() length = 0; for (Train *u = t; u != NULL; u = u->Next()) { if (memcmp(&wagons[length], &u->tcache, sizeof(TrainCache)) != 0) { - DEBUG(desync, 2, "cache mismatch: vehicle %i, company %i, unit number %i, wagon %i\n", v->index, (int)v->owner, v->unitnumber, length); + DEBUG(desync, 2, "cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length); } length++; } @@ -1151,7 +1151,7 @@ static void CheckCaches() UpdateAircraftCache(a); if (memcmp(&cache, &a->acache, sizeof(AircraftCache)) != 0) { - DEBUG(desync, 2, "cache mismatch: vehicle %i, company %i, unit number %i\n", v->index, (int)v->owner, v->unitnumber); + DEBUG(desync, 2, "cache mismatch: vehicle %i, company %i, unit number %i", v->index, (int)v->owner, v->unitnumber); } } break; diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 8dc12eea2f..48c490f6f6 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -1884,7 +1884,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode, Subdirectory sb, boo /* General tactic is to first save the game to memory, then use an available writer * to write it to file, either in threaded mode if possible, or single-threaded */ if (mode == SL_SAVE) { // SAVE game - DEBUG(desync, 1, "save: %s\n", filename); + DEBUG(desync, 1, "save: %s", filename); _sl.write_bytes = WriteMem; _sl.excpt_uninit = UnInitMem; @@ -1908,7 +1908,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode, Subdirectory sb, boo } } else { // LOAD game assert(mode == SL_LOAD); - DEBUG(desync, 1, "load: %s\n", filename); + DEBUG(desync, 1, "load: %s", filename); /* Can't fseek to 0 as in tar files that is not correct */ long pos = ftell(_sl.fh);