Add a chicken bit setting to enable periodic CheckCaches

This commit is contained in:
Jonathan G Rennison 2021-10-03 01:58:54 +01:00
parent 96ea775b24
commit d4d54c9b90
2 changed files with 8 additions and 2 deletions

View File

@ -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)

View File

@ -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<void(const char *)> 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];