summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-23 22:17:33 +0000
committerrubidium <rubidium@openttd.org>2008-04-23 22:17:33 +0000
commit739cb53fff0efbdf68300776f2fe9b53b7cdf01e (patch)
tree4fcd044ab176903e6e76b5e9862463168a6e5f6a
parentdce1b331965c660a80996230503149b28221f34c (diff)
downloadopenttd-739cb53fff0efbdf68300776f2fe9b53b7cdf01e.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.cpp48
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;