Check caches at desync level 1, every 500 ticks.
Also check aircraft cache.
This commit is contained in:
@@ -1236,7 +1236,9 @@ static void CheckCaches()
|
|||||||
{
|
{
|
||||||
/* Return here so it is easy to add checks that are run
|
/* Return here so it is easy to add checks that are run
|
||||||
* always to aid testing of caches. */
|
* always to aid testing of caches. */
|
||||||
if (_debug_desync_level <= 1) return;
|
if (_debug_desync_level < 1) return;
|
||||||
|
|
||||||
|
if (_debug_desync_level == 1 && CURRENT_SCALED_TICKS % 500 != 0) return;
|
||||||
|
|
||||||
/* Check the town caches. */
|
/* Check the town caches. */
|
||||||
SmallVector<TownCache, 4> old_town_caches;
|
SmallVector<TownCache, 4> old_town_caches;
|
||||||
@@ -1252,7 +1254,7 @@ static void CheckCaches()
|
|||||||
uint i = 0;
|
uint i = 0;
|
||||||
FOR_ALL_TOWNS(t) {
|
FOR_ALL_TOWNS(t) {
|
||||||
if (MemCmpT(old_town_caches.Get(i), &t->cache) != 0) {
|
if (MemCmpT(old_town_caches.Get(i), &t->cache) != 0) {
|
||||||
DEBUG(desync, 2, "town cache mismatch: town %i", (int)t->index);
|
DEBUG(desync, 0, "town cache mismatch: town %i", (int)t->index);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -1268,7 +1270,7 @@ static void CheckCaches()
|
|||||||
i = 0;
|
i = 0;
|
||||||
FOR_ALL_COMPANIES(c) {
|
FOR_ALL_COMPANIES(c) {
|
||||||
if (MemCmpT(old_infrastructure.Get(i), &c->infrastructure) != 0) {
|
if (MemCmpT(old_infrastructure.Get(i), &c->infrastructure) != 0) {
|
||||||
DEBUG(desync, 2, "infrastructure cache mismatch: company %i", (int)c->index);
|
DEBUG(desync, 0, "infrastructure cache mismatch: company %i", (int)c->index);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -1294,6 +1296,7 @@ static void CheckCaches()
|
|||||||
NewGRFCache *grf_cache = CallocT<NewGRFCache>(length);
|
NewGRFCache *grf_cache = CallocT<NewGRFCache>(length);
|
||||||
VehicleCache *veh_cache = CallocT<VehicleCache>(length);
|
VehicleCache *veh_cache = CallocT<VehicleCache>(length);
|
||||||
GroundVehicleCache *gro_cache = CallocT<GroundVehicleCache>(length);
|
GroundVehicleCache *gro_cache = CallocT<GroundVehicleCache>(length);
|
||||||
|
AircraftCache *air_cache = CallocT<AircraftCache>(length);
|
||||||
TrainCache *tra_cache = CallocT<TrainCache>(length);
|
TrainCache *tra_cache = CallocT<TrainCache>(length);
|
||||||
Vehicle **veh_old = CallocT<Vehicle *>(length);
|
Vehicle **veh_old = CallocT<Vehicle *>(length);
|
||||||
|
|
||||||
@@ -1314,6 +1317,11 @@ static void CheckCaches()
|
|||||||
veh_old[length] = CallocT<RoadVehicle>(1);
|
veh_old[length] = CallocT<RoadVehicle>(1);
|
||||||
MemCpyT((RoadVehicle *) veh_old[length], RoadVehicle::From(u));
|
MemCpyT((RoadVehicle *) veh_old[length], RoadVehicle::From(u));
|
||||||
break;
|
break;
|
||||||
|
case VEH_AIRCRAFT:
|
||||||
|
air_cache[length] = Aircraft::From(u)->acache;
|
||||||
|
veh_old[length] = CallocT<Aircraft>(1);
|
||||||
|
MemCpyT((Aircraft *) veh_old[length], Aircraft::From(u));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
veh_old[length] = CallocT<Vehicle>(1);
|
veh_old[length] = CallocT<Vehicle>(1);
|
||||||
MemCpyT(veh_old[length], u);
|
MemCpyT(veh_old[length], u);
|
||||||
@@ -1334,56 +1342,61 @@ static void CheckCaches()
|
|||||||
for (const Vehicle *u = v; u != NULL; u = u->Next()) {
|
for (const Vehicle *u = v; u != NULL; u = u->Next()) {
|
||||||
FillNewGRFVehicleCache(u);
|
FillNewGRFVehicleCache(u);
|
||||||
if (memcmp(&grf_cache[length], &u->grf_cache, sizeof(NewGRFCache)) != 0) {
|
if (memcmp(&grf_cache[length], &u->grf_cache, sizeof(NewGRFCache)) != 0) {
|
||||||
DEBUG(desync, 2, "newgrf cache mismatch: type %i, vehicle %i, company %i, unit number %i, wagon %i", (int)v->type, v->index, (int)v->owner, v->unitnumber, length);
|
DEBUG(desync, 0, "newgrf cache mismatch: type %i, vehicle %i, company %i, unit number %i, wagon %i", (int)v->type, v->index, (int)v->owner, v->unitnumber, length);
|
||||||
}
|
}
|
||||||
if (memcmp(&veh_cache[length], &u->vcache, sizeof(VehicleCache)) != 0) {
|
if (memcmp(&veh_cache[length], &u->vcache, sizeof(VehicleCache)) != 0) {
|
||||||
DEBUG(desync, 2, "vehicle cache mismatch: type %i, vehicle %i, company %i, unit number %i, wagon %i", (int)v->type, v->index, (int)v->owner, v->unitnumber, length);
|
DEBUG(desync, 0, "vehicle cache mismatch: type %i, vehicle %i, company %i, unit number %i, wagon %i", (int)v->type, v->index, (int)v->owner, v->unitnumber, length);
|
||||||
}
|
}
|
||||||
if (veh_old[length]->acceleration != u->acceleration) {
|
if (veh_old[length]->acceleration != u->acceleration) {
|
||||||
DEBUG(desync, 2, "acceleration mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
DEBUG(desync, 0, "acceleration mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
||||||
}
|
}
|
||||||
if (veh_old[length]->breakdown_chance != u->breakdown_chance) {
|
if (veh_old[length]->breakdown_chance != u->breakdown_chance) {
|
||||||
DEBUG(desync, 2, "breakdown_chance mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
DEBUG(desync, 0, "breakdown_chance mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
||||||
}
|
}
|
||||||
if (veh_old[length]->breakdown_ctr != u->breakdown_ctr) {
|
if (veh_old[length]->breakdown_ctr != u->breakdown_ctr) {
|
||||||
DEBUG(desync, 2, "breakdown_ctr mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
DEBUG(desync, 0, "breakdown_ctr mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
||||||
}
|
}
|
||||||
if (veh_old[length]->breakdown_delay != u->breakdown_delay) {
|
if (veh_old[length]->breakdown_delay != u->breakdown_delay) {
|
||||||
DEBUG(desync, 2, "breakdown_delay mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
DEBUG(desync, 0, "breakdown_delay mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
||||||
}
|
}
|
||||||
if (veh_old[length]->breakdowns_since_last_service != u->breakdowns_since_last_service) {
|
if (veh_old[length]->breakdowns_since_last_service != u->breakdowns_since_last_service) {
|
||||||
DEBUG(desync, 2, "breakdowns_since_last_service mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
DEBUG(desync, 0, "breakdowns_since_last_service mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
||||||
}
|
}
|
||||||
if (veh_old[length]->breakdown_severity != u->breakdown_severity) {
|
if (veh_old[length]->breakdown_severity != u->breakdown_severity) {
|
||||||
DEBUG(desync, 2, "breakdown_severity mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
DEBUG(desync, 0, "breakdown_severity mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
||||||
}
|
}
|
||||||
if (veh_old[length]->breakdown_type != u->breakdown_type) {
|
if (veh_old[length]->breakdown_type != u->breakdown_type) {
|
||||||
DEBUG(desync, 2, "breakdown_type mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
DEBUG(desync, 0, "breakdown_type mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
||||||
}
|
}
|
||||||
if (veh_old[length]->vehicle_flags != u->vehicle_flags) {
|
if (veh_old[length]->vehicle_flags != u->vehicle_flags) {
|
||||||
DEBUG(desync, 2, "vehicle_flags mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
DEBUG(desync, 0, "vehicle_flags mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
||||||
}
|
}
|
||||||
switch (u->type) {
|
switch (u->type) {
|
||||||
case VEH_TRAIN:
|
case VEH_TRAIN:
|
||||||
if (memcmp(&gro_cache[length], &Train::From(u)->gcache, sizeof(GroundVehicleCache)) != 0) {
|
if (memcmp(&gro_cache[length], &Train::From(u)->gcache, sizeof(GroundVehicleCache)) != 0) {
|
||||||
DEBUG(desync, 2, "train ground vehicle cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
DEBUG(desync, 0, "train ground vehicle cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
||||||
}
|
}
|
||||||
if (memcmp(&tra_cache[length], &Train::From(u)->tcache, sizeof(TrainCache)) != 0) {
|
if (memcmp(&tra_cache[length], &Train::From(u)->tcache, sizeof(TrainCache)) != 0) {
|
||||||
DEBUG(desync, 2, "train cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
DEBUG(desync, 0, "train cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
||||||
}
|
}
|
||||||
if (Train::From(veh_old[length])->railtype != Train::From(u)->railtype) {
|
if (Train::From(veh_old[length])->railtype != Train::From(u)->railtype) {
|
||||||
DEBUG(desync, 2, "railtype mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
DEBUG(desync, 0, "railtype mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
||||||
}
|
}
|
||||||
if (Train::From(veh_old[length])->compatible_railtypes != Train::From(u)->compatible_railtypes) {
|
if (Train::From(veh_old[length])->compatible_railtypes != Train::From(u)->compatible_railtypes) {
|
||||||
DEBUG(desync, 2, "compatible_railtypes mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
DEBUG(desync, 0, "compatible_railtypes mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
||||||
}
|
}
|
||||||
if (Train::From(veh_old[length])->flags != Train::From(u)->flags) {
|
if (Train::From(veh_old[length])->flags != Train::From(u)->flags) {
|
||||||
DEBUG(desync, 2, "flags mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
DEBUG(desync, 0, "flags mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case VEH_ROAD:
|
case VEH_ROAD:
|
||||||
if (memcmp(&gro_cache[length], &RoadVehicle::From(u)->gcache, sizeof(GroundVehicleCache)) != 0) {
|
if (memcmp(&gro_cache[length], &RoadVehicle::From(u)->gcache, sizeof(GroundVehicleCache)) != 0) {
|
||||||
DEBUG(desync, 2, "road vehicle ground vehicle cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
DEBUG(desync, 0, "road vehicle ground vehicle cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case VEH_AIRCRAFT:
|
||||||
|
if (memcmp(&air_cache[length], &Aircraft::From(u)->acache, sizeof(AircraftCache)) != 0) {
|
||||||
|
DEBUG(desync, 0, "Aircraft vehicle cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user