Add flags field to CheckCaches for which checks to run
Add header file for CheckCaches
This commit is contained in:
@@ -118,6 +118,7 @@ add_files(
|
|||||||
date_type.h
|
date_type.h
|
||||||
debug.cpp
|
debug.cpp
|
||||||
debug.h
|
debug.h
|
||||||
|
debug_desync.h
|
||||||
debug_settings.h
|
debug_settings.h
|
||||||
dedicated.cpp
|
dedicated.cpp
|
||||||
departures.cpp
|
departures.cpp
|
||||||
|
@@ -37,6 +37,7 @@
|
|||||||
#include "zoning.h"
|
#include "zoning.h"
|
||||||
#include "tbtr_template_vehicle_func.h"
|
#include "tbtr_template_vehicle_func.h"
|
||||||
#include "widgets/statusbar_widget.h"
|
#include "widgets/statusbar_widget.h"
|
||||||
|
#include "debug_desync.h"
|
||||||
|
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
|
|
||||||
@@ -937,7 +938,6 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||||||
InvalidateWindowData(WC_CLIENT_LIST, 0);
|
InvalidateWindowData(WC_CLIENT_LIST, 0);
|
||||||
InvalidateWindowClassesData(WC_DEPARTURES_BOARD, 0);
|
InvalidateWindowClassesData(WC_DEPARTURES_BOARD, 0);
|
||||||
|
|
||||||
extern void CheckCaches(bool force_check, std::function<void(const char *)> log);
|
|
||||||
CheckCaches(true, nullptr);
|
CheckCaches(true, nullptr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -53,6 +53,7 @@
|
|||||||
#include "linkgraph/linkgraphjob.h"
|
#include "linkgraph/linkgraphjob.h"
|
||||||
#include "base_media_base.h"
|
#include "base_media_base.h"
|
||||||
#include "debug_settings.h"
|
#include "debug_settings.h"
|
||||||
|
#include "debug_desync.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
@@ -2687,7 +2688,6 @@ DEF_CONSOLE_CMD(ConCheckCaches)
|
|||||||
if (broadcast) {
|
if (broadcast) {
|
||||||
DoCommandP(0, 0, 0, CMD_DESYNC_CHECK);
|
DoCommandP(0, 0, 0, CMD_DESYNC_CHECK);
|
||||||
} else {
|
} else {
|
||||||
extern void CheckCaches(bool force_check, std::function<void(const char *)> log);
|
|
||||||
CheckCaches(true, nullptr);
|
CheckCaches(true, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include "scope_info.h"
|
#include "scope_info.h"
|
||||||
#include "command_func.h"
|
#include "command_func.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
#include "debug_desync.h"
|
||||||
|
|
||||||
#include "ai/ai_info.hpp"
|
#include "ai/ai_info.hpp"
|
||||||
#include "game/game.hpp"
|
#include "game/game.hpp"
|
||||||
@@ -522,7 +523,6 @@ char *CrashLog::FillDesyncCrashLog(char *buffer, const char *last, const DesyncE
|
|||||||
buffer = DumpDesyncMsgLog(buffer, last);
|
buffer = DumpDesyncMsgLog(buffer, last);
|
||||||
|
|
||||||
bool have_cache_log = false;
|
bool have_cache_log = false;
|
||||||
extern void CheckCaches(bool force_check, std::function<void(const char *)> log);
|
|
||||||
CheckCaches(true, [&](const char *str) {
|
CheckCaches(true, [&](const char *str) {
|
||||||
if (!have_cache_log) buffer += seprintf(buffer, last, "CheckCaches:\n");
|
if (!have_cache_log) buffer += seprintf(buffer, last, "CheckCaches:\n");
|
||||||
buffer += seprintf(buffer, last, " %s\n", str);
|
buffer += seprintf(buffer, last, " %s\n", str);
|
||||||
|
25
src/debug_desync.h
Normal file
25
src/debug_desync.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of OpenTTD.
|
||||||
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||||
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file debug_desync.h Desync debugging. */
|
||||||
|
|
||||||
|
#ifndef DEBUG_DESYNC_H
|
||||||
|
#define DEBUG_DESYNC_H
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
enum CheckCachesFlags : uint32 {
|
||||||
|
CHECK_CACHE_NONE = 0,
|
||||||
|
CHECK_CACHE_GENERAL = 1 << 0,
|
||||||
|
CHECK_CACHE_INFRA_TOTALS = 1 << 1,
|
||||||
|
CHECK_CACHE_ALL = UINT32_MAX,
|
||||||
|
};
|
||||||
|
DECLARE_ENUM_AS_BIT_SET(CheckCachesFlags)
|
||||||
|
|
||||||
|
extern void CheckCaches(bool force_check, std::function<void(const char *)> log = nullptr, CheckCachesFlags flags = CHECK_CACHE_ALL);
|
||||||
|
|
||||||
|
#endif /* DEBUG_DESYNC_H */
|
@@ -54,6 +54,7 @@
|
|||||||
#include "tbtr_template_vehicle_func.h"
|
#include "tbtr_template_vehicle_func.h"
|
||||||
#include "scope_info.h"
|
#include "scope_info.h"
|
||||||
#include "pathfinder/yapf/yapf_cache.h"
|
#include "pathfinder/yapf/yapf_cache.h"
|
||||||
|
#include "debug_desync.h"
|
||||||
|
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
#include "table/pricebase.h"
|
#include "table/pricebase.h"
|
||||||
@@ -2287,7 +2288,6 @@ static void DoAcquireCompany(Company *c)
|
|||||||
|
|
||||||
delete c;
|
delete c;
|
||||||
|
|
||||||
extern void CheckCaches(bool force_check, std::function<void(const char *)> log);
|
|
||||||
CheckCaches(true, nullptr);
|
CheckCaches(true, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -79,6 +79,7 @@
|
|||||||
#include "core/checksum_func.hpp"
|
#include "core/checksum_func.hpp"
|
||||||
#include "tbtr_template_vehicle_func.h"
|
#include "tbtr_template_vehicle_func.h"
|
||||||
#include "debug_settings.h"
|
#include "debug_settings.h"
|
||||||
|
#include "debug_desync.h"
|
||||||
|
|
||||||
#include "linkgraph/linkgraphschedule.h"
|
#include "linkgraph/linkgraphschedule.h"
|
||||||
#include "tracerestrict.h"
|
#include "tracerestrict.h"
|
||||||
@@ -1358,7 +1359,7 @@ void WriteVehicleInfo(char *&p, const char *last, const Vehicle *u, const Vehicl
|
|||||||
* the cached value and what the value would
|
* the cached value and what the value would
|
||||||
* be when calculated from the 'base' data.
|
* be when calculated from the 'base' data.
|
||||||
*/
|
*/
|
||||||
void CheckCaches(bool force_check, std::function<void(const char *)> log)
|
void CheckCaches(bool force_check, std::function<void(const char *)> log, CheckCachesFlags flags)
|
||||||
{
|
{
|
||||||
if (!force_check) {
|
if (!force_check) {
|
||||||
int desync_level = _debug_desync_level;
|
int desync_level = _debug_desync_level;
|
||||||
@@ -1398,6 +1399,7 @@ void CheckCaches(bool force_check, std::function<void(const char *)> log)
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags & CHECK_CACHE_GENERAL) {
|
||||||
/* Check the town caches. */
|
/* Check the town caches. */
|
||||||
std::vector<TownCache> old_town_caches;
|
std::vector<TownCache> old_town_caches;
|
||||||
std::vector<StationList> old_town_stations_nears;
|
std::vector<StationList> old_town_stations_nears;
|
||||||
@@ -1472,7 +1474,9 @@ void CheckCaches(bool force_check, std::function<void(const char *)> log)
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & CHECK_CACHE_INFRA_TOTALS) {
|
||||||
/* Check company infrastructure cache. */
|
/* Check company infrastructure cache. */
|
||||||
std::vector<CompanyInfrastructure> old_infrastructure;
|
std::vector<CompanyInfrastructure> old_infrastructure;
|
||||||
for (const Company *c : Company::Iterate()) old_infrastructure.push_back(c->infrastructure);
|
for (const Company *c : Company::Iterate()) old_infrastructure.push_back(c->infrastructure);
|
||||||
@@ -1480,7 +1484,7 @@ void CheckCaches(bool force_check, std::function<void(const char *)> log)
|
|||||||
extern void AfterLoadCompanyStats();
|
extern void AfterLoadCompanyStats();
|
||||||
AfterLoadCompanyStats();
|
AfterLoadCompanyStats();
|
||||||
|
|
||||||
i = 0;
|
uint i = 0;
|
||||||
for (const Company *c : Company::Iterate()) {
|
for (const Company *c : Company::Iterate()) {
|
||||||
if (MemCmpT(old_infrastructure.data() + i, &c->infrastructure) != 0) {
|
if (MemCmpT(old_infrastructure.data() + i, &c->infrastructure) != 0) {
|
||||||
CCLOG("infrastructure cache mismatch: company %i", (int)c->index);
|
CCLOG("infrastructure cache mismatch: company %i", (int)c->index);
|
||||||
@@ -1498,7 +1502,9 @@ void CheckCaches(bool force_check, std::function<void(const char *)> log)
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & CHECK_CACHE_GENERAL) {
|
||||||
/* Strict checking of the road stop cache entries */
|
/* Strict checking of the road stop cache entries */
|
||||||
for (const RoadStop *rs : RoadStop::Iterate()) {
|
for (const RoadStop *rs : RoadStop::Iterate()) {
|
||||||
if (IsStandardRoadStopTile(rs->xy)) continue;
|
if (IsStandardRoadStopTile(rs->xy)) continue;
|
||||||
@@ -1755,6 +1761,7 @@ void CheckCaches(bool force_check, std::function<void(const char *)> log)
|
|||||||
} else {
|
} else {
|
||||||
CCLOG("Order destination refcount map not valid");
|
CCLOG("Order destination refcount map not valid");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#undef CCLOGV
|
#undef CCLOGV
|
||||||
#undef CCLOG
|
#undef CCLOG
|
||||||
|
Reference in New Issue
Block a user