Merge branch 'jgrpp' into jgrpp-beta
# Conflicts: # src/settings.cpp # src/settings_gui.cpp # src/settings_internal.h # src/table/company_settings.ini # src/table/currency_settings.ini # src/table/gameopt_settings.ini # src/table/misc_settings.ini # src/table/settings.h.preamble # src/table/settings.ini # src/table/win32_settings.ini # src/table/window_settings.ini
This commit is contained in:
758
src/openttd.cpp
758
src/openttd.cpp
@@ -78,6 +78,9 @@
|
||||
#include "cargopacket.h"
|
||||
#include "core/checksum_func.hpp"
|
||||
#include "tbtr_template_vehicle_func.h"
|
||||
#include "debug_settings.h"
|
||||
#include "debug_desync.h"
|
||||
#include "event_logs.h"
|
||||
|
||||
#include "linkgraph/linkgraphschedule.h"
|
||||
#include "tracerestrict.h"
|
||||
@@ -112,11 +115,6 @@ bool _save_config = false;
|
||||
bool _request_newgrf_scan = false;
|
||||
NewGRFScanCallback *_request_newgrf_scan_callback = nullptr;
|
||||
|
||||
GameEventFlags _game_events_since_load;
|
||||
GameEventFlags _game_events_overall;
|
||||
|
||||
time_t _game_load_time;
|
||||
|
||||
SimpleChecksum64 _state_checksum;
|
||||
|
||||
/**
|
||||
@@ -251,6 +249,7 @@ static void ShowHelp()
|
||||
" -M music_set = Force the music set (see below)\n"
|
||||
" -c config_file = Use 'config_file' instead of 'openttd.cfg'\n"
|
||||
" -x = Never save configuration changes to disk\n"
|
||||
" -X = Don't use global folders to search for files\n"
|
||||
" -q savegame = Write some information about the savegame and exit\n"
|
||||
" -Z = Write detailed version information and exit\n"
|
||||
"\n",
|
||||
@@ -459,6 +458,7 @@ static void ShutdownGame()
|
||||
ClearVehicleTickCaches();
|
||||
InvalidateTemplateReplacementImages();
|
||||
ClearCommandLog();
|
||||
ClearSpecialEventsLog();
|
||||
ClearDesyncMsgLog();
|
||||
|
||||
_loaded_local_company = COMPANY_SPECTATOR;
|
||||
@@ -659,6 +659,7 @@ static const OptionData _options[] = {
|
||||
GETOPT_SHORT_VALUE('G'),
|
||||
GETOPT_SHORT_VALUE('c'),
|
||||
GETOPT_SHORT_NOVAL('x'),
|
||||
GETOPT_SHORT_NOVAL('X'),
|
||||
GETOPT_SHORT_VALUE('q'),
|
||||
GETOPT_SHORT_VALUE('K'),
|
||||
GETOPT_SHORT_NOVAL('h'),
|
||||
@@ -688,6 +689,7 @@ int openttd_main(int argc, char *argv[])
|
||||
std::unique_ptr<AfterNewGRFScan> scanner(new AfterNewGRFScan());
|
||||
bool dedicated = false;
|
||||
char *debuglog_conn = nullptr;
|
||||
bool only_local_path = false;
|
||||
|
||||
extern bool _dedicated_forks;
|
||||
_dedicated_forks = false;
|
||||
@@ -767,7 +769,7 @@ int openttd_main(int argc, char *argv[])
|
||||
break;
|
||||
case 'q':
|
||||
case 'K': {
|
||||
DeterminePaths(argv[0]);
|
||||
DeterminePaths(argv[0], only_local_path);
|
||||
if (StrEmpty(mgo.opt)) {
|
||||
ret = 1;
|
||||
return ret;
|
||||
@@ -808,6 +810,7 @@ int openttd_main(int argc, char *argv[])
|
||||
CrashLog::VersionInfoLog();
|
||||
return ret;
|
||||
}
|
||||
case 'X': only_local_path = true; break;
|
||||
case 'h':
|
||||
i = -2; // Force printing of help.
|
||||
break;
|
||||
@@ -821,7 +824,7 @@ int openttd_main(int argc, char *argv[])
|
||||
*
|
||||
* The next two functions are needed to list the graphics sets. We can't do them earlier
|
||||
* because then we cannot show it on the debug console as that hasn't been configured yet. */
|
||||
DeterminePaths(argv[0]);
|
||||
DeterminePaths(argv[0], only_local_path);
|
||||
TarScanner::DoScan(TarScanner::BASESET);
|
||||
BaseGraphics::FindSets();
|
||||
BaseSounds::FindSets();
|
||||
@@ -830,7 +833,7 @@ int openttd_main(int argc, char *argv[])
|
||||
return ret;
|
||||
}
|
||||
|
||||
DeterminePaths(argv[0]);
|
||||
DeterminePaths(argv[0], only_local_path);
|
||||
TarScanner::DoScan(TarScanner::BASESET);
|
||||
|
||||
if (dedicated) DEBUG(net, 3, "Starting dedicated server, version %s", _openttd_revision);
|
||||
@@ -1336,14 +1339,28 @@ void WriteVehicleInfo(char *&p, const char *last, const Vehicle *u, const Vehicl
|
||||
* the cached value and what the value would
|
||||
* 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) {
|
||||
int desync_level = _debug_desync_level;
|
||||
|
||||
if (unlikely(HasChickenBit(DCBF_DESYNC_CHECK_PERIODIC)) && desync_level < 1) {
|
||||
desync_level = 1;
|
||||
if (HasChickenBit(DCBF_DESYNC_CHECK_NO_GENERAL)) flags &= ~CHECK_CACHE_GENERAL;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
std::vector<std::string> saved_messages;
|
||||
if (flags & CHECK_CACHE_EMIT_LOG) {
|
||||
log = [&saved_messages](const char *str) {
|
||||
saved_messages.emplace_back(str);
|
||||
};
|
||||
}
|
||||
|
||||
char cclog_buffer[1024];
|
||||
@@ -1372,362 +1389,377 @@ void CheckCaches(bool force_check, std::function<void(const char *)> log)
|
||||
} \
|
||||
}
|
||||
|
||||
/* Check the town caches. */
|
||||
std::vector<TownCache> old_town_caches;
|
||||
std::vector<StationList> old_town_stations_nears;
|
||||
for (const Town *t : Town::Iterate()) {
|
||||
old_town_caches.push_back(t->cache);
|
||||
old_town_stations_nears.push_back(t->stations_near);
|
||||
}
|
||||
|
||||
std::vector<IndustryList> old_station_industries_nears;
|
||||
std::vector<BitmapTileArea> old_station_catchment_tiles;
|
||||
std::vector<uint> old_station_tiles;
|
||||
for (Station *st : Station::Iterate()) {
|
||||
old_station_industries_nears.push_back(st->industries_near);
|
||||
old_station_catchment_tiles.push_back(st->catchment_tiles);
|
||||
old_station_tiles.push_back(st->station_tiles);
|
||||
}
|
||||
|
||||
std::vector<StationList> old_industry_stations_nears;
|
||||
for (Industry *ind : Industry::Iterate()) {
|
||||
old_industry_stations_nears.push_back(ind->stations_near);
|
||||
}
|
||||
|
||||
extern void RebuildTownCaches(bool cargo_update_required, bool old_map_position);
|
||||
RebuildTownCaches(false, false);
|
||||
RebuildSubsidisedSourceAndDestinationCache();
|
||||
|
||||
Station::RecomputeCatchmentForAll();
|
||||
|
||||
uint i = 0;
|
||||
for (Town *t : Town::Iterate()) {
|
||||
if (MemCmpT(old_town_caches.data() + i, &t->cache) != 0) {
|
||||
CCLOG("town cache mismatch: town %i", (int)t->index);
|
||||
}
|
||||
if (old_town_stations_nears[i] != t->stations_near) {
|
||||
CCLOG("town stations_near mismatch: town %i, (old size: %u, new size: %u)", (int)t->index, (uint)old_town_stations_nears[i].size(), (uint)t->stations_near.size());
|
||||
}
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
for (Station *st : Station::Iterate()) {
|
||||
if (old_station_industries_nears[i] != st->industries_near) {
|
||||
CCLOG("station industries_near mismatch: st %i, (old size: %u, new size: %u)", (int)st->index, (uint)old_station_industries_nears[i].size(), (uint)st->industries_near.size());
|
||||
}
|
||||
if (!(old_station_catchment_tiles[i] == st->catchment_tiles)) {
|
||||
CCLOG("station catchment_tiles mismatch: st %i", (int)st->index);
|
||||
}
|
||||
if (!(old_station_tiles[i] == st->station_tiles)) {
|
||||
CCLOG("station station_tiles mismatch: st %i, (old: %u, new: %u)", (int)st->index, old_station_tiles[i], st->station_tiles);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
for (Industry *ind : Industry::Iterate()) {
|
||||
if (old_industry_stations_nears[i] != ind->stations_near) {
|
||||
CCLOG("industry stations_near mismatch: ind %i, (old size: %u, new size: %u)", (int)ind->index, (uint)old_industry_stations_nears[i].size(), (uint)ind->stations_near.size());
|
||||
}
|
||||
StationList stlist;
|
||||
if (ind->neutral_station != nullptr && !_settings_game.station.serve_neutral_industries) {
|
||||
stlist.insert(ind->neutral_station);
|
||||
if (ind->stations_near != stlist) {
|
||||
CCLOG("industry neutral station stations_near mismatch: ind %i, (recalc size: %u, neutral size: %u)", (int)ind->index, (uint)ind->stations_near.size(), (uint)stlist.size());
|
||||
}
|
||||
} else {
|
||||
ForAllStationsAroundTiles(ind->location, [ind, &stlist](Station *st, TileIndex tile) {
|
||||
if (!IsTileType(tile, MP_INDUSTRY) || GetIndustryIndex(tile) != ind->index) return false;
|
||||
stlist.insert(st);
|
||||
return true;
|
||||
});
|
||||
if (ind->stations_near != stlist) {
|
||||
CCLOG("industry FindStationsAroundTiles mismatch: ind %i, (recalc size: %u, find size: %u)", (int)ind->index, (uint)ind->stations_near.size(), (uint)stlist.size());
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
/* Check company infrastructure cache. */
|
||||
std::vector<CompanyInfrastructure> old_infrastructure;
|
||||
for (const Company *c : Company::Iterate()) old_infrastructure.push_back(c->infrastructure);
|
||||
|
||||
extern void AfterLoadCompanyStats();
|
||||
AfterLoadCompanyStats();
|
||||
|
||||
i = 0;
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
if (MemCmpT(old_infrastructure.data() + i, &c->infrastructure) != 0) {
|
||||
CCLOG("infrastructure cache mismatch: company %i", (int)c->index);
|
||||
char buffer[4096];
|
||||
old_infrastructure[i].Dump(buffer, lastof(buffer));
|
||||
CCLOG("Previous:");
|
||||
ProcessLineByLine(buffer, [&](const char *line) {
|
||||
CCLOG(" %s", line);
|
||||
});
|
||||
c->infrastructure.Dump(buffer, lastof(buffer));
|
||||
CCLOG("Recalculated:");
|
||||
ProcessLineByLine(buffer, [&](const char *line) {
|
||||
CCLOG(" %s", line);
|
||||
});
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
/* Strict checking of the road stop cache entries */
|
||||
for (const RoadStop *rs : RoadStop::Iterate()) {
|
||||
if (IsStandardRoadStopTile(rs->xy)) continue;
|
||||
|
||||
assert(rs->GetEntry(DIAGDIR_NE) != rs->GetEntry(DIAGDIR_NW));
|
||||
rs->GetEntry(DIAGDIR_NE)->CheckIntegrity(rs);
|
||||
rs->GetEntry(DIAGDIR_NW)->CheckIntegrity(rs);
|
||||
}
|
||||
|
||||
for (Vehicle *v : Vehicle::Iterate()) {
|
||||
extern bool ValidateVehicleTileHash(const Vehicle *v);
|
||||
if (!ValidateVehicleTileHash(v)) {
|
||||
CCLOG("vehicle tile hash mismatch: type %i, vehicle %i, company %i, unit number %i", (int)v->type, v->index, (int)v->owner, v->unitnumber);
|
||||
if (flags & CHECK_CACHE_GENERAL) {
|
||||
/* Check the town caches. */
|
||||
std::vector<TownCache> old_town_caches;
|
||||
std::vector<StationList> old_town_stations_nears;
|
||||
for (const Town *t : Town::Iterate()) {
|
||||
old_town_caches.push_back(t->cache);
|
||||
old_town_stations_nears.push_back(t->stations_near);
|
||||
}
|
||||
|
||||
extern void FillNewGRFVehicleCache(const Vehicle *v);
|
||||
if (v != v->First() || v->vehstatus & VS_CRASHED || !v->IsPrimaryVehicle()) continue;
|
||||
|
||||
uint length = 0;
|
||||
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
|
||||
if (u->IsGroundVehicle() && (HasBit(u->GetGroundVehicleFlags(), GVF_GOINGUP_BIT) || HasBit(u->GetGroundVehicleFlags(), GVF_GOINGDOWN_BIT)) && u->GetGroundVehicleCache()->cached_slope_resistance && HasBit(v->vcache.cached_veh_flags, VCF_GV_ZERO_SLOPE_RESIST)) {
|
||||
CCLOGV("VCF_GV_ZERO_SLOPE_RESIST set incorrectly (1)");
|
||||
}
|
||||
if (u->type == VEH_TRAIN && u->breakdown_ctr != 0 && !HasBit(Train::From(v)->flags, VRF_CONSIST_BREAKDOWN)) {
|
||||
CCLOGV("VRF_CONSIST_BREAKDOWN incorrectly not set");
|
||||
}
|
||||
if (u->type == VEH_TRAIN && ((Train::From(u)->track & TRACK_BIT_WORMHOLE && !(Train::From(u)->vehstatus & VS_HIDDEN)) || Train::From(u)->track == TRACK_BIT_DEPOT) && !HasBit(Train::From(v)->flags, VRF_CONSIST_SPEED_REDUCTION)) {
|
||||
CCLOGV("VRF_CONSIST_SPEED_REDUCTION incorrectly not set");
|
||||
}
|
||||
length++;
|
||||
std::vector<IndustryList> old_station_industries_nears;
|
||||
std::vector<BitmapTileArea> old_station_catchment_tiles;
|
||||
std::vector<uint> old_station_tiles;
|
||||
for (Station *st : Station::Iterate()) {
|
||||
old_station_industries_nears.push_back(st->industries_near);
|
||||
old_station_catchment_tiles.push_back(st->catchment_tiles);
|
||||
old_station_tiles.push_back(st->station_tiles);
|
||||
}
|
||||
|
||||
NewGRFCache *grf_cache = CallocT<NewGRFCache>(length);
|
||||
VehicleCache *veh_cache = CallocT<VehicleCache>(length);
|
||||
GroundVehicleCache *gro_cache = CallocT<GroundVehicleCache>(length);
|
||||
AircraftCache *air_cache = CallocT<AircraftCache>(length);
|
||||
TrainCache *tra_cache = CallocT<TrainCache>(length);
|
||||
Vehicle **veh_old = CallocT<Vehicle *>(length);
|
||||
|
||||
length = 0;
|
||||
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
|
||||
FillNewGRFVehicleCache(u);
|
||||
grf_cache[length] = u->grf_cache;
|
||||
veh_cache[length] = u->vcache;
|
||||
switch (u->type) {
|
||||
case VEH_TRAIN:
|
||||
gro_cache[length] = Train::From(u)->gcache;
|
||||
tra_cache[length] = Train::From(u)->tcache;
|
||||
veh_old[length] = CallocT<Train>(1);
|
||||
memcpy((void *) veh_old[length], (const void *) Train::From(u), sizeof(Train));
|
||||
break;
|
||||
case VEH_ROAD:
|
||||
gro_cache[length] = RoadVehicle::From(u)->gcache;
|
||||
veh_old[length] = CallocT<RoadVehicle>(1);
|
||||
memcpy((void *) veh_old[length], (const void *) RoadVehicle::From(u), sizeof(RoadVehicle));
|
||||
break;
|
||||
case VEH_AIRCRAFT:
|
||||
air_cache[length] = Aircraft::From(u)->acache;
|
||||
veh_old[length] = CallocT<Aircraft>(1);
|
||||
memcpy((void *) veh_old[length], (const void *) Aircraft::From(u), sizeof(Aircraft));
|
||||
break;
|
||||
default:
|
||||
veh_old[length] = CallocT<Vehicle>(1);
|
||||
memcpy((void *) veh_old[length], (const void *) u, sizeof(Vehicle));
|
||||
break;
|
||||
}
|
||||
length++;
|
||||
std::vector<StationList> old_industry_stations_nears;
|
||||
for (Industry *ind : Industry::Iterate()) {
|
||||
old_industry_stations_nears.push_back(ind->stations_near);
|
||||
}
|
||||
|
||||
switch (v->type) {
|
||||
case VEH_TRAIN: Train::From(v)->ConsistChanged(CCF_TRACK); break;
|
||||
case VEH_ROAD: RoadVehUpdateCache(RoadVehicle::From(v)); break;
|
||||
case VEH_AIRCRAFT: UpdateAircraftCache(Aircraft::From(v)); break;
|
||||
case VEH_SHIP: Ship::From(v)->UpdateCache(); break;
|
||||
default: break;
|
||||
extern void RebuildTownCaches(bool cargo_update_required, bool old_map_position);
|
||||
RebuildTownCaches(false, false);
|
||||
RebuildSubsidisedSourceAndDestinationCache();
|
||||
|
||||
Station::RecomputeCatchmentForAll();
|
||||
|
||||
uint i = 0;
|
||||
for (Town *t : Town::Iterate()) {
|
||||
if (MemCmpT(old_town_caches.data() + i, &t->cache) != 0) {
|
||||
CCLOG("town cache mismatch: town %i", (int)t->index);
|
||||
}
|
||||
if (old_town_stations_nears[i] != t->stations_near) {
|
||||
CCLOG("town stations_near mismatch: town %i, (old size: %u, new size: %u)", (int)t->index, (uint)old_town_stations_nears[i].size(), (uint)t->stations_near.size());
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
length = 0;
|
||||
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
|
||||
FillNewGRFVehicleCache(u);
|
||||
if (memcmp(&grf_cache[length], &u->grf_cache, sizeof(NewGRFCache)) != 0) {
|
||||
CCLOGV("newgrf cache mismatch");
|
||||
i = 0;
|
||||
for (Station *st : Station::Iterate()) {
|
||||
if (old_station_industries_nears[i] != st->industries_near) {
|
||||
CCLOG("station industries_near mismatch: st %i, (old size: %u, new size: %u)", (int)st->index, (uint)old_station_industries_nears[i].size(), (uint)st->industries_near.size());
|
||||
}
|
||||
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 ||
|
||||
veh_cache[length].cached_vis_effect != u->vcache.cached_vis_effect || HasBit(veh_cache[length].cached_veh_flags ^ u->vcache.cached_veh_flags, VCF_LAST_VISUAL_EFFECT)) {
|
||||
CCLOGV("vehicle cache mismatch: %c%c%c%c",
|
||||
veh_cache[length].cached_max_speed != u->vcache.cached_max_speed ? 'm' : '-',
|
||||
veh_cache[length].cached_cargo_age_period != u->vcache.cached_cargo_age_period ? 'c' : '-',
|
||||
veh_cache[length].cached_vis_effect != u->vcache.cached_vis_effect ? 'v' : '-',
|
||||
HasBit(veh_cache[length].cached_veh_flags ^ u->vcache.cached_veh_flags, VCF_LAST_VISUAL_EFFECT) ? 'l' : '-');
|
||||
if (!(old_station_catchment_tiles[i] == st->catchment_tiles)) {
|
||||
CCLOG("station catchment_tiles mismatch: st %i", (int)st->index);
|
||||
}
|
||||
if (u->IsGroundVehicle() && (HasBit(u->GetGroundVehicleFlags(), GVF_GOINGUP_BIT) || HasBit(u->GetGroundVehicleFlags(), GVF_GOINGDOWN_BIT)) && u->GetGroundVehicleCache()->cached_slope_resistance && HasBit(v->vcache.cached_veh_flags, VCF_GV_ZERO_SLOPE_RESIST)) {
|
||||
CCLOGV("VCF_GV_ZERO_SLOPE_RESIST set incorrectly (2)");
|
||||
if (!(old_station_tiles[i] == st->station_tiles)) {
|
||||
CCLOG("station station_tiles mismatch: st %i, (old: %u, new: %u)", (int)st->index, old_station_tiles[i], st->station_tiles);
|
||||
}
|
||||
if (veh_old[length]->acceleration != u->acceleration) {
|
||||
CCLOGV("acceleration mismatch");
|
||||
}
|
||||
if (veh_old[length]->breakdown_chance != u->breakdown_chance) {
|
||||
CCLOGV("breakdown_chance mismatch");
|
||||
}
|
||||
if (veh_old[length]->breakdown_ctr != u->breakdown_ctr) {
|
||||
CCLOGV("breakdown_ctr mismatch");
|
||||
}
|
||||
if (veh_old[length]->breakdown_delay != u->breakdown_delay) {
|
||||
CCLOGV("breakdown_delay mismatch");
|
||||
}
|
||||
if (veh_old[length]->breakdowns_since_last_service != u->breakdowns_since_last_service) {
|
||||
CCLOGV("breakdowns_since_last_service mismatch");
|
||||
}
|
||||
if (veh_old[length]->breakdown_severity != u->breakdown_severity) {
|
||||
CCLOGV("breakdown_severity mismatch");
|
||||
}
|
||||
if (veh_old[length]->breakdown_type != u->breakdown_type) {
|
||||
CCLOGV("breakdown_type mismatch");
|
||||
}
|
||||
if (veh_old[length]->vehicle_flags != u->vehicle_flags) {
|
||||
CCLOGV("vehicle_flags mismatch");
|
||||
}
|
||||
auto print_gv_cache_diff = [&](const char *vtype, const GroundVehicleCache &a, const GroundVehicleCache &b) {
|
||||
CCLOGV("%s ground vehicle cache mismatch: %c%c%c%c%c%c%c%c%c%c",
|
||||
vtype,
|
||||
a.cached_weight != b.cached_weight ? 'w' : '-',
|
||||
a.cached_slope_resistance != b.cached_slope_resistance ? 'r' : '-',
|
||||
a.cached_max_te != b.cached_max_te ? 't' : '-',
|
||||
a.cached_axle_resistance != b.cached_axle_resistance ? 'a' : '-',
|
||||
a.cached_max_track_speed != b.cached_max_track_speed ? 's' : '-',
|
||||
a.cached_power != b.cached_power ? 'p' : '-',
|
||||
a.cached_air_drag != b.cached_air_drag ? 'd' : '-',
|
||||
a.cached_total_length != b.cached_total_length ? 'l' : '-',
|
||||
a.first_engine != b.first_engine ? 'e' : '-',
|
||||
a.cached_veh_length != b.cached_veh_length ? 'L' : '-');
|
||||
};
|
||||
switch (u->type) {
|
||||
case VEH_TRAIN:
|
||||
if (memcmp(&gro_cache[length], &Train::From(u)->gcache, sizeof(GroundVehicleCache)) != 0) {
|
||||
print_gv_cache_diff("train", gro_cache[length], Train::From(u)->gcache);
|
||||
}
|
||||
if (memcmp(&tra_cache[length], &Train::From(u)->tcache, sizeof(TrainCache)) != 0) {
|
||||
CCLOGV("train cache mismatch: %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_tflags != Train::From(u)->tcache.cached_tflags ? 'f' : '-',
|
||||
tra_cache[length].cached_num_engines != Train::From(u)->tcache.cached_num_engines ? 'e' : '-',
|
||||
tra_cache[length].cached_centre_mass != Train::From(u)->tcache.cached_centre_mass ? 'm' : '-',
|
||||
tra_cache[length].cached_veh_weight != Train::From(u)->tcache.cached_veh_weight ? 'w' : '-',
|
||||
tra_cache[length].cached_uncapped_decel != Train::From(u)->tcache.cached_uncapped_decel ? 'D' : '-',
|
||||
tra_cache[length].cached_deceleration != Train::From(u)->tcache.cached_deceleration ? 'd' : '-',
|
||||
tra_cache[length].user_def_data != Train::From(u)->tcache.user_def_data ? 'u' : '-',
|
||||
tra_cache[length].cached_max_curve_speed != Train::From(u)->tcache.cached_max_curve_speed ? 'c' : '-');
|
||||
}
|
||||
if (Train::From(veh_old[length])->railtype != Train::From(u)->railtype) {
|
||||
CCLOGV("railtype mismatch");
|
||||
}
|
||||
if (Train::From(veh_old[length])->compatible_railtypes != Train::From(u)->compatible_railtypes) {
|
||||
CCLOGV("compatible_railtypes mismatch");
|
||||
}
|
||||
if (Train::From(veh_old[length])->flags != Train::From(u)->flags) {
|
||||
CCLOGV("train flags mismatch");
|
||||
}
|
||||
break;
|
||||
case VEH_ROAD:
|
||||
if (memcmp(&gro_cache[length], &RoadVehicle::From(u)->gcache, sizeof(GroundVehicleCache)) != 0) {
|
||||
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) {
|
||||
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' : '-');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
free(veh_old[length]);
|
||||
length++;
|
||||
i++;
|
||||
}
|
||||
|
||||
free(grf_cache);
|
||||
free(veh_cache);
|
||||
free(gro_cache);
|
||||
free(air_cache);
|
||||
free(tra_cache);
|
||||
free(veh_old);
|
||||
}
|
||||
|
||||
/* Check whether the caches are still valid */
|
||||
for (Vehicle *v : Vehicle::Iterate()) {
|
||||
byte buff[sizeof(VehicleCargoList)];
|
||||
memcpy(buff, &v->cargo, sizeof(VehicleCargoList));
|
||||
v->cargo.InvalidateCache();
|
||||
assert(memcmp(&v->cargo, buff, sizeof(VehicleCargoList)) == 0);
|
||||
}
|
||||
|
||||
for (Station *st : Station::Iterate()) {
|
||||
for (CargoID c = 0; c < NUM_CARGO; c++) {
|
||||
byte buff[sizeof(StationCargoList)];
|
||||
memcpy(buff, &st->goods[c].cargo, sizeof(StationCargoList));
|
||||
st->goods[c].cargo.InvalidateCache();
|
||||
assert(memcmp(&st->goods[c].cargo, buff, sizeof(StationCargoList)) == 0);
|
||||
}
|
||||
|
||||
/* Check docking tiles */
|
||||
TileArea ta;
|
||||
std::map<TileIndex, bool> docking_tiles;
|
||||
for (TileIndex tile : st->docking_station) {
|
||||
ta.Add(tile);
|
||||
docking_tiles[tile] = IsDockingTile(tile);
|
||||
}
|
||||
UpdateStationDockingTiles(st);
|
||||
if (ta.tile != st->docking_station.tile || ta.w != st->docking_station.w || ta.h != st->docking_station.h) {
|
||||
CCLOG("station docking mismatch: station %i, company %i, prev: (%X, %u, %u), recalc: (%X, %u, %u)",
|
||||
st->index, (int)st->owner, ta.tile, ta.w, ta.h, st->docking_station.tile, st->docking_station.w, st->docking_station.h);
|
||||
}
|
||||
for (TileIndex tile : ta) {
|
||||
if (docking_tiles[tile] != IsDockingTile(tile)) {
|
||||
CCLOG("docking tile mismatch: tile %i", (int)tile);
|
||||
i = 0;
|
||||
for (Industry *ind : Industry::Iterate()) {
|
||||
if (old_industry_stations_nears[i] != ind->stations_near) {
|
||||
CCLOG("industry stations_near mismatch: ind %i, (old size: %u, new size: %u)", (int)ind->index, (uint)old_industry_stations_nears[i].size(), (uint)ind->stations_near.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (OrderList *order_list : OrderList::Iterate()) {
|
||||
order_list->DebugCheckSanity();
|
||||
}
|
||||
|
||||
extern void ValidateVehicleTickCaches();
|
||||
ValidateVehicleTickCaches();
|
||||
|
||||
for (Vehicle *v : Vehicle::Iterate()) {
|
||||
if (v->Previous()) assert_msg(v->Previous()->Next() == v, "%u", v->index);
|
||||
if (v->Next()) assert_msg(v->Next()->Previous() == v, "%u", v->index);
|
||||
}
|
||||
for (const TemplateVehicle *tv : TemplateVehicle::Iterate()) {
|
||||
if (tv->Prev()) assert_msg(tv->Prev()->Next() == tv, "%u", tv->index);
|
||||
if (tv->Next()) assert_msg(tv->Next()->Prev() == tv, "%u", tv->index);
|
||||
}
|
||||
|
||||
if (!TraceRestrictSlot::ValidateVehicleIndex()) CCLOG("Trace restrict slot vehicle index validation failed");
|
||||
TraceRestrictSlot::ValidateSlotOccupants(log);
|
||||
|
||||
if (!CargoPacket::ValidateDeferredCargoPayments()) CCLOG("Cargo packets deferred payments validation failed");
|
||||
|
||||
if (_order_destination_refcount_map_valid) {
|
||||
btree::btree_map<uint32, uint32> saved_order_destination_refcount_map = std::move(_order_destination_refcount_map);
|
||||
for (auto iter = saved_order_destination_refcount_map.begin(); iter != saved_order_destination_refcount_map.end();) {
|
||||
if (iter->second == 0) {
|
||||
iter = saved_order_destination_refcount_map.erase(iter);
|
||||
StationList stlist;
|
||||
if (ind->neutral_station != nullptr && !_settings_game.station.serve_neutral_industries) {
|
||||
stlist.insert(ind->neutral_station);
|
||||
if (ind->stations_near != stlist) {
|
||||
CCLOG("industry neutral station stations_near mismatch: ind %i, (recalc size: %u, neutral size: %u)", (int)ind->index, (uint)ind->stations_near.size(), (uint)stlist.size());
|
||||
}
|
||||
} else {
|
||||
++iter;
|
||||
ForAllStationsAroundTiles(ind->location, [ind, &stlist](Station *st, TileIndex tile) {
|
||||
if (!IsTileType(tile, MP_INDUSTRY) || GetIndustryIndex(tile) != ind->index) return false;
|
||||
stlist.insert(st);
|
||||
return true;
|
||||
});
|
||||
if (ind->stations_near != stlist) {
|
||||
CCLOG("industry FindStationsAroundTiles mismatch: ind %i, (recalc size: %u, find size: %u)", (int)ind->index, (uint)ind->stations_near.size(), (uint)stlist.size());
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & CHECK_CACHE_INFRA_TOTALS) {
|
||||
/* Check company infrastructure cache. */
|
||||
std::vector<CompanyInfrastructure> old_infrastructure;
|
||||
for (const Company *c : Company::Iterate()) old_infrastructure.push_back(c->infrastructure);
|
||||
|
||||
extern void AfterLoadCompanyStats();
|
||||
AfterLoadCompanyStats();
|
||||
|
||||
uint i = 0;
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
if (MemCmpT(old_infrastructure.data() + i, &c->infrastructure) != 0) {
|
||||
CCLOG("infrastructure cache mismatch: company %i", (int)c->index);
|
||||
char buffer[4096];
|
||||
old_infrastructure[i].Dump(buffer, lastof(buffer));
|
||||
CCLOG("Previous:");
|
||||
ProcessLineByLine(buffer, [&](const char *line) {
|
||||
CCLOG(" %s", line);
|
||||
});
|
||||
c->infrastructure.Dump(buffer, lastof(buffer));
|
||||
CCLOG("Recalculated:");
|
||||
ProcessLineByLine(buffer, [&](const char *line) {
|
||||
CCLOG(" %s", line);
|
||||
});
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & CHECK_CACHE_GENERAL) {
|
||||
/* Strict checking of the road stop cache entries */
|
||||
for (const RoadStop *rs : RoadStop::Iterate()) {
|
||||
if (IsStandardRoadStopTile(rs->xy)) continue;
|
||||
|
||||
assert(rs->GetEntry(DIAGDIR_NE) != rs->GetEntry(DIAGDIR_NW));
|
||||
rs->GetEntry(DIAGDIR_NE)->CheckIntegrity(rs);
|
||||
rs->GetEntry(DIAGDIR_NW)->CheckIntegrity(rs);
|
||||
}
|
||||
|
||||
for (Vehicle *v : Vehicle::Iterate()) {
|
||||
extern bool ValidateVehicleTileHash(const Vehicle *v);
|
||||
if (!ValidateVehicleTileHash(v)) {
|
||||
CCLOG("vehicle tile hash mismatch: type %i, vehicle %i, company %i, unit number %i", (int)v->type, v->index, (int)v->owner, v->unitnumber);
|
||||
}
|
||||
|
||||
extern void FillNewGRFVehicleCache(const Vehicle *v);
|
||||
if (v != v->First() || v->vehstatus & VS_CRASHED || !v->IsPrimaryVehicle()) continue;
|
||||
|
||||
uint length = 0;
|
||||
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
|
||||
if (u->IsGroundVehicle() && (HasBit(u->GetGroundVehicleFlags(), GVF_GOINGUP_BIT) || HasBit(u->GetGroundVehicleFlags(), GVF_GOINGDOWN_BIT)) && u->GetGroundVehicleCache()->cached_slope_resistance && HasBit(v->vcache.cached_veh_flags, VCF_GV_ZERO_SLOPE_RESIST)) {
|
||||
CCLOGV("VCF_GV_ZERO_SLOPE_RESIST set incorrectly (1)");
|
||||
}
|
||||
if (u->type == VEH_TRAIN && u->breakdown_ctr != 0 && !HasBit(Train::From(v)->flags, VRF_CONSIST_BREAKDOWN)) {
|
||||
CCLOGV("VRF_CONSIST_BREAKDOWN incorrectly not set");
|
||||
}
|
||||
if (u->type == VEH_TRAIN && ((Train::From(u)->track & TRACK_BIT_WORMHOLE && !(Train::From(u)->vehstatus & VS_HIDDEN)) || Train::From(u)->track == TRACK_BIT_DEPOT) && !HasBit(Train::From(v)->flags, VRF_CONSIST_SPEED_REDUCTION)) {
|
||||
CCLOGV("VRF_CONSIST_SPEED_REDUCTION incorrectly not set");
|
||||
}
|
||||
length++;
|
||||
}
|
||||
|
||||
NewGRFCache *grf_cache = CallocT<NewGRFCache>(length);
|
||||
VehicleCache *veh_cache = CallocT<VehicleCache>(length);
|
||||
GroundVehicleCache *gro_cache = CallocT<GroundVehicleCache>(length);
|
||||
AircraftCache *air_cache = CallocT<AircraftCache>(length);
|
||||
TrainCache *tra_cache = CallocT<TrainCache>(length);
|
||||
Vehicle **veh_old = CallocT<Vehicle *>(length);
|
||||
|
||||
length = 0;
|
||||
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
|
||||
FillNewGRFVehicleCache(u);
|
||||
grf_cache[length] = u->grf_cache;
|
||||
veh_cache[length] = u->vcache;
|
||||
switch (u->type) {
|
||||
case VEH_TRAIN:
|
||||
gro_cache[length] = Train::From(u)->gcache;
|
||||
tra_cache[length] = Train::From(u)->tcache;
|
||||
veh_old[length] = CallocT<Train>(1);
|
||||
memcpy((void *) veh_old[length], (const void *) Train::From(u), sizeof(Train));
|
||||
break;
|
||||
case VEH_ROAD:
|
||||
gro_cache[length] = RoadVehicle::From(u)->gcache;
|
||||
veh_old[length] = CallocT<RoadVehicle>(1);
|
||||
memcpy((void *) veh_old[length], (const void *) RoadVehicle::From(u), sizeof(RoadVehicle));
|
||||
break;
|
||||
case VEH_AIRCRAFT:
|
||||
air_cache[length] = Aircraft::From(u)->acache;
|
||||
veh_old[length] = CallocT<Aircraft>(1);
|
||||
memcpy((void *) veh_old[length], (const void *) Aircraft::From(u), sizeof(Aircraft));
|
||||
break;
|
||||
default:
|
||||
veh_old[length] = CallocT<Vehicle>(1);
|
||||
memcpy((void *) veh_old[length], (const void *) u, sizeof(Vehicle));
|
||||
break;
|
||||
}
|
||||
length++;
|
||||
}
|
||||
|
||||
switch (v->type) {
|
||||
case VEH_TRAIN: Train::From(v)->ConsistChanged(CCF_TRACK); break;
|
||||
case VEH_ROAD: RoadVehUpdateCache(RoadVehicle::From(v)); break;
|
||||
case VEH_AIRCRAFT: UpdateAircraftCache(Aircraft::From(v)); break;
|
||||
case VEH_SHIP: Ship::From(v)->UpdateCache(); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
length = 0;
|
||||
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
|
||||
FillNewGRFVehicleCache(u);
|
||||
if (memcmp(&grf_cache[length], &u->grf_cache, sizeof(NewGRFCache)) != 0) {
|
||||
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 ||
|
||||
veh_cache[length].cached_vis_effect != u->vcache.cached_vis_effect || HasBit(veh_cache[length].cached_veh_flags ^ u->vcache.cached_veh_flags, VCF_LAST_VISUAL_EFFECT)) {
|
||||
CCLOGV("vehicle cache mismatch: %c%c%c%c",
|
||||
veh_cache[length].cached_max_speed != u->vcache.cached_max_speed ? 'm' : '-',
|
||||
veh_cache[length].cached_cargo_age_period != u->vcache.cached_cargo_age_period ? 'c' : '-',
|
||||
veh_cache[length].cached_vis_effect != u->vcache.cached_vis_effect ? 'v' : '-',
|
||||
HasBit(veh_cache[length].cached_veh_flags ^ u->vcache.cached_veh_flags, VCF_LAST_VISUAL_EFFECT) ? 'l' : '-');
|
||||
}
|
||||
if (u->IsGroundVehicle() && (HasBit(u->GetGroundVehicleFlags(), GVF_GOINGUP_BIT) || HasBit(u->GetGroundVehicleFlags(), GVF_GOINGDOWN_BIT)) && u->GetGroundVehicleCache()->cached_slope_resistance && HasBit(v->vcache.cached_veh_flags, VCF_GV_ZERO_SLOPE_RESIST)) {
|
||||
CCLOGV("VCF_GV_ZERO_SLOPE_RESIST set incorrectly (2)");
|
||||
}
|
||||
if (veh_old[length]->acceleration != u->acceleration) {
|
||||
CCLOGV("acceleration mismatch");
|
||||
}
|
||||
if (veh_old[length]->breakdown_chance != u->breakdown_chance) {
|
||||
CCLOGV("breakdown_chance mismatch");
|
||||
}
|
||||
if (veh_old[length]->breakdown_ctr != u->breakdown_ctr) {
|
||||
CCLOGV("breakdown_ctr mismatch");
|
||||
}
|
||||
if (veh_old[length]->breakdown_delay != u->breakdown_delay) {
|
||||
CCLOGV("breakdown_delay mismatch");
|
||||
}
|
||||
if (veh_old[length]->breakdowns_since_last_service != u->breakdowns_since_last_service) {
|
||||
CCLOGV("breakdowns_since_last_service mismatch");
|
||||
}
|
||||
if (veh_old[length]->breakdown_severity != u->breakdown_severity) {
|
||||
CCLOGV("breakdown_severity mismatch");
|
||||
}
|
||||
if (veh_old[length]->breakdown_type != u->breakdown_type) {
|
||||
CCLOGV("breakdown_type mismatch");
|
||||
}
|
||||
if (veh_old[length]->vehicle_flags != u->vehicle_flags) {
|
||||
CCLOGV("vehicle_flags mismatch");
|
||||
}
|
||||
auto print_gv_cache_diff = [&](const char *vtype, const GroundVehicleCache &a, const GroundVehicleCache &b) {
|
||||
CCLOGV("%s ground vehicle cache mismatch: %c%c%c%c%c%c%c%c%c%c",
|
||||
vtype,
|
||||
a.cached_weight != b.cached_weight ? 'w' : '-',
|
||||
a.cached_slope_resistance != b.cached_slope_resistance ? 'r' : '-',
|
||||
a.cached_max_te != b.cached_max_te ? 't' : '-',
|
||||
a.cached_axle_resistance != b.cached_axle_resistance ? 'a' : '-',
|
||||
a.cached_max_track_speed != b.cached_max_track_speed ? 's' : '-',
|
||||
a.cached_power != b.cached_power ? 'p' : '-',
|
||||
a.cached_air_drag != b.cached_air_drag ? 'd' : '-',
|
||||
a.cached_total_length != b.cached_total_length ? 'l' : '-',
|
||||
a.first_engine != b.first_engine ? 'e' : '-',
|
||||
a.cached_veh_length != b.cached_veh_length ? 'L' : '-');
|
||||
};
|
||||
switch (u->type) {
|
||||
case VEH_TRAIN:
|
||||
if (memcmp(&gro_cache[length], &Train::From(u)->gcache, sizeof(GroundVehicleCache)) != 0) {
|
||||
print_gv_cache_diff("train", gro_cache[length], Train::From(u)->gcache);
|
||||
}
|
||||
if (memcmp(&tra_cache[length], &Train::From(u)->tcache, sizeof(TrainCache)) != 0) {
|
||||
CCLOGV("train cache mismatch: %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_tflags != Train::From(u)->tcache.cached_tflags ? 'f' : '-',
|
||||
tra_cache[length].cached_num_engines != Train::From(u)->tcache.cached_num_engines ? 'e' : '-',
|
||||
tra_cache[length].cached_centre_mass != Train::From(u)->tcache.cached_centre_mass ? 'm' : '-',
|
||||
tra_cache[length].cached_veh_weight != Train::From(u)->tcache.cached_veh_weight ? 'w' : '-',
|
||||
tra_cache[length].cached_uncapped_decel != Train::From(u)->tcache.cached_uncapped_decel ? 'D' : '-',
|
||||
tra_cache[length].cached_deceleration != Train::From(u)->tcache.cached_deceleration ? 'd' : '-',
|
||||
tra_cache[length].user_def_data != Train::From(u)->tcache.user_def_data ? 'u' : '-',
|
||||
tra_cache[length].cached_max_curve_speed != Train::From(u)->tcache.cached_max_curve_speed ? 'c' : '-');
|
||||
}
|
||||
if (Train::From(veh_old[length])->railtype != Train::From(u)->railtype) {
|
||||
CCLOGV("railtype mismatch");
|
||||
}
|
||||
if (Train::From(veh_old[length])->compatible_railtypes != Train::From(u)->compatible_railtypes) {
|
||||
CCLOGV("compatible_railtypes mismatch");
|
||||
}
|
||||
if (Train::From(veh_old[length])->flags != Train::From(u)->flags) {
|
||||
CCLOGV("train flags mismatch");
|
||||
}
|
||||
break;
|
||||
case VEH_ROAD:
|
||||
if (memcmp(&gro_cache[length], &RoadVehicle::From(u)->gcache, sizeof(GroundVehicleCache)) != 0) {
|
||||
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) {
|
||||
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' : '-');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
free(veh_old[length]);
|
||||
length++;
|
||||
}
|
||||
|
||||
free(grf_cache);
|
||||
free(veh_cache);
|
||||
free(gro_cache);
|
||||
free(air_cache);
|
||||
free(tra_cache);
|
||||
free(veh_old);
|
||||
}
|
||||
|
||||
/* Check whether the caches are still valid */
|
||||
for (Vehicle *v : Vehicle::Iterate()) {
|
||||
byte buff[sizeof(VehicleCargoList)];
|
||||
memcpy(buff, &v->cargo, sizeof(VehicleCargoList));
|
||||
v->cargo.InvalidateCache();
|
||||
assert(memcmp(&v->cargo, buff, sizeof(VehicleCargoList)) == 0);
|
||||
}
|
||||
|
||||
for (Station *st : Station::Iterate()) {
|
||||
for (CargoID c = 0; c < NUM_CARGO; c++) {
|
||||
byte buff[sizeof(StationCargoList)];
|
||||
memcpy(buff, &st->goods[c].cargo, sizeof(StationCargoList));
|
||||
st->goods[c].cargo.InvalidateCache();
|
||||
assert(memcmp(&st->goods[c].cargo, buff, sizeof(StationCargoList)) == 0);
|
||||
}
|
||||
|
||||
/* Check docking tiles */
|
||||
TileArea ta;
|
||||
std::map<TileIndex, bool> docking_tiles;
|
||||
for (TileIndex tile : st->docking_station) {
|
||||
ta.Add(tile);
|
||||
docking_tiles[tile] = IsDockingTile(tile);
|
||||
}
|
||||
UpdateStationDockingTiles(st);
|
||||
if (ta.tile != st->docking_station.tile || ta.w != st->docking_station.w || ta.h != st->docking_station.h) {
|
||||
CCLOG("station docking mismatch: station %i, company %i, prev: (%X, %u, %u), recalc: (%X, %u, %u)",
|
||||
st->index, (int)st->owner, ta.tile, ta.w, ta.h, st->docking_station.tile, st->docking_station.w, st->docking_station.h);
|
||||
}
|
||||
for (TileIndex tile : ta) {
|
||||
if (docking_tiles[tile] != IsDockingTile(tile)) {
|
||||
CCLOG("docking tile mismatch: tile %i", (int)tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
IntialiseOrderDestinationRefcountMap();
|
||||
if (saved_order_destination_refcount_map != _order_destination_refcount_map) CCLOG("Order destination refcount map mismatch");
|
||||
} else {
|
||||
CCLOG("Order destination refcount map not valid");
|
||||
|
||||
for (OrderList *order_list : OrderList::Iterate()) {
|
||||
order_list->DebugCheckSanity();
|
||||
}
|
||||
|
||||
extern void ValidateVehicleTickCaches();
|
||||
ValidateVehicleTickCaches();
|
||||
|
||||
for (Vehicle *v : Vehicle::Iterate()) {
|
||||
if (v->Previous()) assert_msg(v->Previous()->Next() == v, "%u", v->index);
|
||||
if (v->Next()) assert_msg(v->Next()->Previous() == v, "%u", v->index);
|
||||
}
|
||||
for (const TemplateVehicle *tv : TemplateVehicle::Iterate()) {
|
||||
if (tv->Prev()) assert_msg(tv->Prev()->Next() == tv, "%u", tv->index);
|
||||
if (tv->Next()) assert_msg(tv->Next()->Prev() == tv, "%u", tv->index);
|
||||
}
|
||||
|
||||
if (!TraceRestrictSlot::ValidateVehicleIndex()) CCLOG("Trace restrict slot vehicle index validation failed");
|
||||
TraceRestrictSlot::ValidateSlotOccupants(log);
|
||||
|
||||
if (!CargoPacket::ValidateDeferredCargoPayments()) CCLOG("Cargo packets deferred payments validation failed");
|
||||
|
||||
if (_order_destination_refcount_map_valid) {
|
||||
btree::btree_map<uint32, uint32> saved_order_destination_refcount_map = std::move(_order_destination_refcount_map);
|
||||
for (auto iter = saved_order_destination_refcount_map.begin(); iter != saved_order_destination_refcount_map.end();) {
|
||||
if (iter->second == 0) {
|
||||
iter = saved_order_destination_refcount_map.erase(iter);
|
||||
} else {
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
IntialiseOrderDestinationRefcountMap();
|
||||
if (saved_order_destination_refcount_map != _order_destination_refcount_map) CCLOG("Order destination refcount map mismatch");
|
||||
} else {
|
||||
CCLOG("Order destination refcount map not valid");
|
||||
}
|
||||
}
|
||||
|
||||
if ((flags & CHECK_CACHE_EMIT_LOG) && !saved_messages.empty()) {
|
||||
InconsistencyExtraInfo info;
|
||||
info.check_caches_result = std::move(saved_messages);
|
||||
CrashLog::InconsistencyLog(info);
|
||||
for (std::string &str : info.check_caches_result) {
|
||||
LogDesyncMsg(std::move(str));
|
||||
}
|
||||
}
|
||||
|
||||
#undef CCLOGV
|
||||
@@ -1746,7 +1778,7 @@ void CheckCaches(bool force_check, std::function<void(const char *)> log)
|
||||
CommandCost CmdDesyncCheck(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
if (flags & DC_EXEC) {
|
||||
CheckCaches(true, nullptr);
|
||||
CheckCaches(true, nullptr, CHECK_CACHE_ALL | CHECK_CACHE_EMIT_LOG);
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
@@ -1803,7 +1835,7 @@ void StateGameLoop()
|
||||
SaveOrLoad(name, SLO_SAVE, DFT_GAME_FILE, AUTOSAVE_DIR, false);
|
||||
}
|
||||
|
||||
CheckCaches(false, nullptr);
|
||||
CheckCaches(false, nullptr, CHECK_CACHE_ALL | CHECK_CACHE_EMIT_LOG);
|
||||
|
||||
/* All these actions has to be done from OWNER_NONE
|
||||
* for multiplayer compatibility */
|
||||
@@ -1969,21 +2001,3 @@ void GameLoop()
|
||||
SoundDriver::GetInstance()->MainLoop();
|
||||
MusicLoop();
|
||||
}
|
||||
|
||||
char *DumpGameEventFlags(GameEventFlags events, char *b, const char *last)
|
||||
{
|
||||
if (b <= last) *b = 0;
|
||||
auto dump = [&](char c, GameEventFlags ev) {
|
||||
if (events & ev) b += seprintf(b, last, "%c", c);
|
||||
};
|
||||
dump('d', GEF_COMPANY_DELETE);
|
||||
dump('m', GEF_COMPANY_MERGE);
|
||||
dump('n', GEF_RELOAD_NEWGRF);
|
||||
dump('t', GEF_TBTR_REPLACEMENT);
|
||||
dump('D', GEF_DISASTER_VEH);
|
||||
dump('c', GEF_TRAIN_CRASH);
|
||||
dump('i', GEF_INDUSTRY_CREATE);
|
||||
dump('j', GEF_INDUSTRY_DELETE);
|
||||
dump('v', GEF_VIRT_TRAIN);
|
||||
return b;
|
||||
}
|
||||
|
Reference in New Issue
Block a user