diff --git a/src/debug_settings.h b/src/debug_settings.h index a31b3833c4..cc031e2756 100644 --- a/src/debug_settings.h +++ b/src/debug_settings.h @@ -16,6 +16,7 @@ enum ChickenBitFlags { DCBF_VEH_TICK_CACHE = 0, DCBF_MP_NO_STATE_CSUM_CHECK = 1, + DCBF_DESYNC_CHECK_PERIODIC = 2, }; inline bool HasChickenBit(ChickenBitFlags flag) diff --git a/src/openttd.cpp b/src/openttd.cpp index 690e5efe43..c3ae283e5c 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -78,6 +78,7 @@ #include "cargopacket.h" #include "core/checksum_func.hpp" #include "tbtr_template_vehicle_func.h" +#include "debug_settings.h" #include "linkgraph/linkgraphschedule.h" #include "tracerestrict.h" @@ -1360,11 +1361,15 @@ void WriteVehicleInfo(char *&p, const char *last, const Vehicle *u, const Vehicl void CheckCaches(bool force_check, std::function log) { if (!force_check) { + int desync_level = _debug_desync_level; + + if (unlikely(HasChickenBit(DCBF_DESYNC_CHECK_PERIODIC)) && desync_level < 1) desync_level = 1; + /* Return here so it is easy to add checks that are run * always to aid testing of caches. */ - if (_debug_desync_level < 1) return; + if (desync_level < 1) return; - if (_debug_desync_level == 1 && _scaled_date_ticks % 500 != 0) return; + if (desync_level == 1 && _scaled_date_ticks % 500 != 0) return; } char cclog_buffer[1024];