diff options
author | rubidium <rubidium@openttd.org> | 2010-04-11 09:54:44 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-04-11 09:54:44 +0000 |
commit | 9b7d71699d2ae0016e721d425b12ad516bd88101 (patch) | |
tree | d8d7592c55ceb973b18731a85fd6d81444fdb4c0 | |
parent | ba5f5c1ce16e7a2c185522daa74c295fbc3e80ec (diff) | |
download | openttd-9b7d71699d2ae0016e721d425b12ad516bd88101.tar.xz |
(svn r19601) -Fix: make the desync replay parse the "whole" string instead of everything up to the first space; make it log the sync state too
-rw-r--r-- | src/command.cpp | 2 | ||||
-rw-r--r-- | src/network/network.cpp | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/command.cpp b/src/command.cpp index 6abb738df..50764793e 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; %02x; %02x; %06x; %08x; %08x; %08x; %s", _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/network/network.cpp b/src/network/network.cpp index 176261768..0367d6633 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -1077,6 +1077,9 @@ void NetworkGameLoop() if (!NetworkReceive()) return; if (_network_server) { + /* Log the sync state to check for in-syncedness of replays. */ + if (_date_fract == 0) DEBUG(desync, 1, "sync: %08x; %02x; %08x; %08x", _date, _date_fract, _random.state[0], _random.state[1]); + #ifdef DEBUG_DUMP_COMMANDS /* Loading of the debug commands from -ddesync>=1 */ static FILE *f = FioFOpenFile("commands.log", "rb", SAVE_DIR); @@ -1092,7 +1095,7 @@ void NetworkGameLoop() if (cp != NULL && _date == next_date && _date_fract == next_date_fract) { _current_company = cp->company; bool ret = DoCommandP(cp->tile, cp->p1, cp->p2, cp->cmd, NULL, cp->text); - DEBUG(net, 0, "injecting: %08x; %02x; %02x; %06x; %08x; %08x; %08x; %s -> %i", _date, _date_fract, (int)_current_company, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text, (int)ret); + DEBUG(net, 0, "injecting: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" -> %i", _date, _date_fract, (int)_current_company, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text, (int)ret); assert(ret); free(cp); cp = NULL; @@ -1112,9 +1115,9 @@ void NetworkGameLoop() } if (strncmp(p, "cmd: ", 5) == 0) { - cp = MallocT<CommandPacket>(1); + cp = CallocT<CommandPacket>(1); int company; - int ret = sscanf(p + 5, "%x; %x; %x; %x; %x; %x; %x; %s", &next_date, &next_date_fract, &company, &cp->tile, &cp->p1, &cp->p2, &cp->cmd, cp->text); + int ret = sscanf(p + 5, "%x; %x; %x; %x; %x; %x; %x; \"%[^\"]\"", &next_date, &next_date_fract, &company, &cp->tile, &cp->p1, &cp->p2, &cp->cmd, cp->text); /* There are 8 pieces of data to read, however the last is a * string that might or might not exist. Ignore it if that * string misses because in 99% of the time it's not used. */ |