Use comparison operator for NewGRFCache instead of memcmp

This commit is contained in:
Jonathan G Rennison
2024-01-24 19:30:05 +00:00
parent c8f5585ba7
commit df9fc6d1cf
2 changed files with 3 additions and 1 deletions

View File

@@ -1830,7 +1830,7 @@ void CheckCaches(bool force_check, std::function<void(const char *)> log, CheckC
length = 0; length = 0;
for (const Vehicle *u = v; u != nullptr; u = u->Next()) { for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
FillNewGRFVehicleCache(u); FillNewGRFVehicleCache(u);
if (memcmp(&grf_cache[length], &u->grf_cache, sizeof(NewGRFCache)) != 0) { if (grf_cache[length] != u->grf_cache) {
CCLOGV("newgrf cache mismatch"); CCLOGV("newgrf cache mismatch");
} }
if (veh_cache[length].cached_max_speed != u->vcache.cached_max_speed || veh_cache[length].cached_cargo_age_period != u->vcache.cached_cargo_age_period || if (veh_cache[length].cached_max_speed != u->vcache.cached_max_speed || veh_cache[length].cached_cargo_age_period != u->vcache.cached_cargo_age_period ||

View File

@@ -87,6 +87,8 @@ struct NewGRFCache {
uint32_t company_information; ///< Cache for NewGRF var 43. uint32_t company_information; ///< Cache for NewGRF var 43.
uint32_t position_in_vehicle; ///< Cache for NewGRF var 4D. uint32_t position_in_vehicle; ///< Cache for NewGRF var 4D.
uint8_t cache_valid; ///< Bitset that indicates which cache values are valid. uint8_t cache_valid; ///< Bitset that indicates which cache values are valid.
bool operator==(const NewGRFCache&) const = default;
}; };
/** Meaning of the various bits of the visual effect. */ /** Meaning of the various bits of the visual effect. */