Codechange: Pass GRFConfig by reference where feasible. (#13388)
In places where a GRFConfig is passed by pointer and not checked for nullptr, use a reference instead.
This commit is contained in:
@@ -180,20 +180,20 @@ const NetworkServerGameInfo &GetCurrentNetworkServerGameInfo()
|
||||
* @param config The GRF to handle.
|
||||
* @param name The name of the NewGRF, empty when unknown.
|
||||
*/
|
||||
static void HandleIncomingNetworkGameInfoGRFConfig(GRFConfig *config, std::string_view name)
|
||||
static void HandleIncomingNetworkGameInfoGRFConfig(GRFConfig &config, std::string_view name)
|
||||
{
|
||||
/* Find the matching GRF file */
|
||||
const GRFConfig *f = FindGRFConfig(config->ident.grfid, FGCM_EXACT, &config->ident.md5sum);
|
||||
const GRFConfig *f = FindGRFConfig(config.ident.grfid, FGCM_EXACT, &config.ident.md5sum);
|
||||
if (f == nullptr) {
|
||||
AddGRFTextToList(config->name, name.empty() ? GetString(STR_CONFIG_ERROR_INVALID_GRF_UNKNOWN) : name);
|
||||
config->status = GCS_NOT_FOUND;
|
||||
AddGRFTextToList(config.name, name.empty() ? GetString(STR_CONFIG_ERROR_INVALID_GRF_UNKNOWN) : name);
|
||||
config.status = GCS_NOT_FOUND;
|
||||
} else {
|
||||
config->filename = f->filename;
|
||||
config->name = f->name;
|
||||
config->info = f->info;
|
||||
config->url = f->url;
|
||||
config.filename = f->filename;
|
||||
config.name = f->name;
|
||||
config.info = f->info;
|
||||
config.url = f->url;
|
||||
}
|
||||
SetBit(config->flags, GCF_COPY);
|
||||
SetBit(config.flags, GCF_COPY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,7 +337,7 @@ void DeserializeNetworkGameInfo(Packet &p, NetworkGameInfo &info, const GameInfo
|
||||
|
||||
GRFConfig *c = new GRFConfig();
|
||||
c->ident = grf.ident;
|
||||
HandleIncomingNetworkGameInfoGRFConfig(c, grf.name);
|
||||
HandleIncomingNetworkGameInfoGRFConfig(*c, grf.name);
|
||||
|
||||
/* Append GRFConfig to the list */
|
||||
*dst = c;
|
||||
|
||||
Reference in New Issue
Block a user