diff options
author | rubidium <rubidium@openttd.org> | 2008-04-23 22:17:33 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-04-23 22:17:33 +0000 |
commit | 29ce273067e4940486b5eda4522c6d1c6e5d58f1 (patch) | |
tree | 4fcd044ab176903e6e76b5e9862463168a6e5f6a | |
parent | 2b85217bfe7197684e22a0257cabe9b4a37cb7d6 (diff) | |
download | openttd-29ce273067e4940486b5eda4522c6d1c6e5d58f1.tar.xz |
(svn r12858) -Add: small piece of code that can help hunting desyncs. Has to be enabled by --enable-desync-debug=1 though.
-rw-r--r-- | src/openttd.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp index 6ef326ecd..2d32c04f6 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -968,6 +968,54 @@ void StateGameLoop() CallWindowTickEvent(); NewsLoop(); } else { +#ifdef DEBUG_DUMP_COMMANDS + Vehicle *v; + FOR_ALL_VEHICLES(v) { + if (v != v->First()) continue; + + switch (v->type) { + case VEH_ROAD: { + extern byte GetRoadVehLength(const Vehicle *v); + if (GetRoadVehLength(v) != v->u.road.cached_veh_length) { + printf("cache mismatch: vehicle %i, player %i, unit number %i wagon %i\n", v->index, (int)v->owner, v->unitnumberlength); + } + } break; + + case VEH_TRAIN: { + uint length = 0; + for (Vehicle *u = v; u != NULL; u = u->Next()) length++; + + VehicleRail *wagons = MallocT<VehicleRail>(length); + length = 0; + for (Vehicle *u = v; u != NULL; u = u->Next()) wagons[length++] = u->u.rail; + + TrainConsistChanged(v); + + length = 0; + for (Vehicle *u = v; u != NULL; u = u->Next()) { + if (memcmp(&wagons[length], &u->u.rail, sizeof(VehicleRail)) != 0) { + printf("cache mismatch: vehicle %i, player %i, unit number %i wagon %i\n", v->index, (int)v->owner, v->unitnumberlength); + } + length++; + } + + free(wagons); + } break; + + case VEH_AIRCRAFT: { + uint speed = v->u.air.cached_max_speed; + UpdateAircraftCache(v); + if (speed != v->u.air.cached_max_speed) { + printf("cache mismatch: vehicle %i, player %i, unit number %i wagon %i\n", v->index, (int)v->owner, v->unitnumberlength); + } + } break; + + default: + break; + } + } +#endif + /* All these actions has to be done from OWNER_NONE * for multiplayer compatibility */ PlayerID p = _current_player; |