changeset 14978:b71fc766c682 draft

(svn r19589) -Change: add some more useful information to the desync log and unify the formatting
author rubidium <rubidium@openttd.org>
date Thu, 08 Apr 2010 21:14:49 +0000 (2010-04-08)
parents 31f99d3d2d39
children 0eaabafbd6ce
files src/command.cpp src/debug.cpp src/genworld.cpp src/network/network.cpp src/network/network_server.cpp src/openttd.cpp src/saveload/saveload.cpp
diffstat 7 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -632,7 +632,7 @@
 		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 */
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -93,7 +93,7 @@
 		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);
 	}
 }
--- a/src/genworld.cpp
+++ b/src/genworld.cpp
@@ -176,7 +176,7 @@
 		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) {
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -249,7 +249,7 @@
 	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 @@
 			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;
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -716,6 +716,7 @@
 	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 @@
 
 	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);
 	}
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -1117,7 +1117,7 @@
 				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 @@
 				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 @@
 				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;
 
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -1884,7 +1884,7 @@
 		/* 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 @@
 			}
 		} 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);