Debug: Log number of GRFs at level sl=2 when loading a game

Add helper to get the number of non-static GRFs in a GRF config
pull/679/merge
Jonathan G Rennison 1 month ago
parent adc7840f01
commit c5cd598217

@ -499,15 +499,8 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendNewGRFCheck()
return this->SendNeedGamePassword(); return this->SendNeedGamePassword();
} }
const GRFConfig *c; p->Send_uint32(GetGRFConfigListNonStaticCount(_grfconfig));
uint grf_count = 0; for (const GRFConfig *c = _grfconfig; c != nullptr; c = c->next) {
for (c = _grfconfig; c != nullptr; c = c->next) {
if (!HasBit(c->flags, GCF_STATIC)) grf_count++;
}
p->Send_uint32(grf_count);
for (c = _grfconfig; c != nullptr; c = c->next) {
if (!HasBit(c->flags, GCF_STATIC)) SerializeGRFIdentifier(*p, c->ident); if (!HasBit(c->flags, GCF_STATIC)) SerializeGRFIdentifier(*p, c->ident);
} }

@ -540,6 +540,15 @@ void ResetGRFConfig(bool defaults)
AppendStaticGRFConfigs(&_grfconfig); AppendStaticGRFConfigs(&_grfconfig);
} }
/** Get the count of non-static GRFs in a GRF config list */
uint GetGRFConfigListNonStaticCount(const GRFConfig *config)
{
uint grf_count = 0;
for (const GRFConfig *c = config; c != nullptr; c = c->next) {
if (!HasBit(c->flags, GCF_STATIC)) grf_count++;
}
return grf_count;
}
/** /**
* Check if all GRFs in the GRF config from a savegame can be loaded. * Check if all GRFs in the GRF config from a savegame can be loaded.

@ -233,6 +233,7 @@ void AppendStaticGRFConfigs(GRFConfig **dst);
void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el); void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el);
void ClearGRFConfigList(GRFConfig **config); void ClearGRFConfigList(GRFConfig **config);
void ResetGRFConfig(bool defaults); void ResetGRFConfig(bool defaults);
uint GetGRFConfigListNonStaticCount(const GRFConfig *config);
GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig); GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig);
bool FillGRFDetails(GRFConfig *config, bool is_static, Subdirectory subdir = NEWGRF_DIR); bool FillGRFDetails(GRFConfig *config, bool is_static, Subdirectory subdir = NEWGRF_DIR);
std::string GRFBuildParamList(const GRFConfig *c); std::string GRFBuildParamList(const GRFConfig *c);

@ -15,6 +15,7 @@
#include "newgrf_sl.h" #include "newgrf_sl.h"
#include "../fios.h" #include "../fios.h"
#include "../load_check.h" #include "../load_check.h"
#include "../debug.h"
#include "../safeguards.h" #include "../safeguards.h"
@ -98,6 +99,8 @@ struct NGRFChunkHandler : ChunkHandler {
if (IsSavegameVersionBefore(SLV_101)) c->SetSuitablePalette(); if (IsSavegameVersionBefore(SLV_101)) c->SetSuitablePalette();
AppendToGRFConfigList(&grfconfig, c); AppendToGRFConfigList(&grfconfig, c);
} }
DEBUG(sl, 2, "Loaded %u NewGRFs", GetGRFConfigListNonStaticCount(grfconfig));
} }
void Load() const override void Load() const override

@ -11,6 +11,7 @@
#include "../fios.h" #include "../fios.h"
#include "../load_check.h" #include "../load_check.h"
#include "../string_func.h" #include "../string_func.h"
#include "../debug.h"
#include "saveload.h" #include "saveload.h"
#include "newgrf_sl.h" #include "newgrf_sl.h"
@ -118,6 +119,7 @@ static void Load_NGRF_common(GRFConfig *&grfconfig)
if (IsSavegameVersionBefore(SLV_101)) c->SetSuitablePalette(); if (IsSavegameVersionBefore(SLV_101)) c->SetSuitablePalette();
AppendToGRFConfigList(&grfconfig, c); AppendToGRFConfigList(&grfconfig, c);
} }
DEBUG(sl, 2, "Loaded %u NewGRFs", GetGRFConfigListNonStaticCount(grfconfig));
} }
static void Load_NGRF() static void Load_NGRF()

Loading…
Cancel
Save