Remove use of memcmp in CheckCaches

This commit is contained in:
Jonathan G Rennison
2024-05-29 18:30:54 +01:00
parent 2b539a2d37
commit cb1e41fc88
8 changed files with 24 additions and 14 deletions

View File

@@ -1749,7 +1749,7 @@ void CheckCaches(bool force_check, std::function<void(const char *)> log, CheckC
if (old_town_caches[i].part_of_subsidy != t->cache.part_of_subsidy) {
CCLOG("town cache population mismatch: town %i, (old size: %u, new size: %u)", (int)t->index, old_town_caches[i].part_of_subsidy, t->cache.part_of_subsidy);
}
if (MemCmpT(old_town_caches[i].squared_town_zone_radius, t->cache.squared_town_zone_radius, lengthof(t->cache.squared_town_zone_radius)) != 0) {
if (old_town_caches[i].squared_town_zone_radius != t->cache.squared_town_zone_radius) {
CCLOG("town cache squared_town_zone_radius mismatch: town %i", (int)t->index);
}
if (old_town_caches[i].building_counts != t->cache.building_counts) {
@@ -1807,7 +1807,7 @@ void CheckCaches(bool force_check, std::function<void(const char *)> log, CheckC
uint i = 0;
for (const Company *c : Company::Iterate()) {
if (MemCmpT(old_infrastructure.data() + i, &c->infrastructure) != 0) {
if (old_infrastructure[i] != c->infrastructure) {
CCLOG("infrastructure cache mismatch: company %i", (int)c->index);
char buffer[4096];
old_infrastructure[i].Dump(buffer, lastof(buffer));
@@ -1963,10 +1963,10 @@ void CheckCaches(bool force_check, std::function<void(const char *)> log, CheckC
};
switch (u->type) {
case VEH_TRAIN:
if (memcmp(&gro_cache[length], &Train::From(u)->gcache, sizeof(GroundVehicleCache)) != 0) {
if (gro_cache[length] != Train::From(u)->gcache) {
print_gv_cache_diff("train", gro_cache[length], Train::From(u)->gcache);
}
if (memcmp(&tra_cache[length], &Train::From(u)->tcache, sizeof(TrainCache)) != 0) {
if (tra_cache[length] != Train::From(u)->tcache) {
CCLOGV("train cache mismatch: %c%c%c%c%c%c%c%c%c%c%c",
tra_cache[length].cached_override != Train::From(u)->tcache.cached_override ? 'o' : '-',
tra_cache[length].cached_curve_speed_mod != Train::From(u)->tcache.cached_curve_speed_mod ? 'C' : '-',
@@ -1991,12 +1991,12 @@ void CheckCaches(bool force_check, std::function<void(const char *)> log, CheckC
}
break;
case VEH_ROAD:
if (memcmp(&gro_cache[length], &RoadVehicle::From(u)->gcache, sizeof(GroundVehicleCache)) != 0) {
if (gro_cache[length] != RoadVehicle::From(u)->gcache) {
print_gv_cache_diff("road vehicle", gro_cache[length], Train::From(u)->gcache);
}
break;
case VEH_AIRCRAFT:
if (memcmp(&air_cache[length], &Aircraft::From(u)->acache, sizeof(AircraftCache)) != 0) {
if (air_cache[length] != Aircraft::From(u)->acache) {
CCLOGV("Aircraft vehicle cache mismatch: %c%c",
air_cache[length].cached_max_range != Aircraft::From(u)->acache.cached_max_range ? 'r' : '-',
air_cache[length].cached_max_range_sqr != Aircraft::From(u)->acache.cached_max_range_sqr ? 's' : '-');