summaryrefslogtreecommitdiff
path: root/src/openttd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2012-04-25 21:06:31 +0000
committerrubidium <rubidium@openttd.org>2012-04-25 21:06:31 +0000
commitb926277caf0ab423dd4b6cdfa38bce3eb8a58d2c (patch)
tree7ddd714e183d8103efdc3abde574c84914639b2c /src/openttd.cpp
parent41e5c839e08bfc811b1e8d7272996567776b788f (diff)
downloadopenttd-b926277caf0ab423dd4b6cdfa38bce3eb8a58d2c.tar.xz
(svn r24180) -Codechange/feature-ish: add cache checker for the town's cache
Diffstat (limited to 'src/openttd.cpp')
-rw-r--r--src/openttd.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 9ef5b5a28..c11dfcf9a 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -59,6 +59,7 @@
#include "misc/getoptdata.h"
#include "game/game.hpp"
#include "game/game_config.hpp"
+#include "town.h"
@@ -1134,6 +1135,24 @@ static void CheckCaches()
* always to aid testing of caches. */
if (_debug_desync_level <= 1) return;
+ /* Check the town caches. */
+ SmallVector<TownCache, 4> old_town_caches;
+ Town *t;
+ FOR_ALL_TOWNS(t) {
+ MemCpyT(old_town_caches.Append(), &t->cache);
+ }
+
+ extern void RebuildTownCaches();
+ RebuildTownCaches();
+
+ uint i = 0;
+ FOR_ALL_TOWNS(t) {
+ if (MemCmpT(old_town_caches.Get(i), &t->cache) != 0) {
+ DEBUG(desync, 2, "town cache mismatch: town %i", (int)t->index);
+ }
+ i++;
+ }
+
/* Check company infrastructure cache. */
SmallVector<CompanyInfrastructure, 4> old_infrastructure;
Company *c;
@@ -1142,7 +1161,7 @@ static void CheckCaches()
extern void AfterLoadCompanyStats();
AfterLoadCompanyStats();
- uint i = 0;
+ i = 0;
FOR_ALL_COMPANIES(c) {
if (MemCmpT(old_infrastructure.Get(i), &c->infrastructure) != 0) {
DEBUG(desync, 2, "infrastructure cache mismatch: company %i", (int)c->index);