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
tmp-jgrpp
Jonathan G Rennison 3 weeks ago
parent adc7840f01
commit c5cd598217

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

@ -540,6 +540,15 @@ void ResetGRFConfig(bool defaults)
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.

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

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

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

Loading…
Cancel
Save