Merge branch 'master' into jgrpp
# Conflicts: # .github/workflows/ci-build.yml # .github/workflows/release-linux.yml # src/aircraft_cmd.cpp # src/airport_gui.cpp # src/articulated_vehicles.cpp # src/build_vehicle_gui.cpp # src/company_gui.cpp # src/genworld_gui.cpp # src/gfx_layout.cpp # src/misc_gui.cpp # src/newgrf.cpp # src/newgrf_config.h # src/newgrf_engine.cpp # src/news_gui.cpp # src/order_gui.cpp # src/roadveh_cmd.cpp # src/saveload/saveload.h # src/saveload/vehicle_sl.cpp # src/ship_cmd.cpp # src/statusbar_gui.cpp # src/table/settings/network_private_settings.ini # src/table/settings/network_settings.ini # src/toolbar_gui.cpp # src/train_cmd.cpp # src/vehicle_gui.cpp
This commit is contained in:
@@ -40,13 +40,11 @@
|
||||
|
||||
/**
|
||||
* Create a new GRFConfig.
|
||||
* @param filename Set the filename of this GRFConfig to filename. The argument
|
||||
* is copied so the original string isn't needed after the constructor.
|
||||
* @param filename Set the filename of this GRFConfig to filename.
|
||||
*/
|
||||
GRFConfig::GRFConfig(const char *filename) :
|
||||
num_valid_params(lengthof(param))
|
||||
GRFConfig::GRFConfig(const std::string &filename) :
|
||||
filename(filename), num_valid_params(lengthof(param))
|
||||
{
|
||||
if (filename != nullptr) this->filename = stredup(filename);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,6 +54,7 @@ GRFConfig::GRFConfig(const char *filename) :
|
||||
GRFConfig::GRFConfig(const GRFConfig &config) :
|
||||
ZeroedMemoryAllocator(),
|
||||
ident(config.ident),
|
||||
filename(config.filename),
|
||||
name(config.name),
|
||||
info(config.info),
|
||||
url(config.url),
|
||||
@@ -71,8 +70,7 @@ GRFConfig::GRFConfig(const GRFConfig &config) :
|
||||
{
|
||||
MemCpyT<uint8>(this->original_md5sum, config.original_md5sum, lengthof(this->original_md5sum));
|
||||
MemCpyT<uint32>(this->param, config.param, lengthof(this->param));
|
||||
if (config.filename != nullptr) this->filename = stredup(config.filename);
|
||||
if (config.error != nullptr) this->error = new GRFError(*config.error);
|
||||
if (config.error != nullptr) this->error = std::make_unique<GRFError>(*config.error);
|
||||
for (uint i = 0; i < config.param_info.size(); i++) {
|
||||
if (config.param_info[i] == nullptr) {
|
||||
this->param_info.push_back(nullptr);
|
||||
@@ -85,12 +83,6 @@ GRFConfig::GRFConfig(const GRFConfig &config) :
|
||||
/** Cleanup a GRFConfig object. */
|
||||
GRFConfig::~GRFConfig()
|
||||
{
|
||||
/* GCF_COPY as in NOT stredupped/alloced the filename */
|
||||
if (!HasBit(this->flags, GCF_COPY)) {
|
||||
free(this->filename);
|
||||
delete this->error;
|
||||
}
|
||||
|
||||
for (uint i = 0; i < this->param_info.size(); i++) delete this->param_info[i];
|
||||
}
|
||||
|
||||
@@ -113,7 +105,7 @@ void GRFConfig::CopyParams(const GRFConfig &src)
|
||||
const char *GRFConfig::GetName() const
|
||||
{
|
||||
const char *name = GetGRFStringFromGRFText(this->name);
|
||||
return StrEmpty(name) ? this->filename : name;
|
||||
return StrEmpty(name) ? this->filename.c_str() : name;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -641,8 +633,7 @@ compatible_grf:
|
||||
* When the GCF_COPY flag is set, it is certain that the filename is
|
||||
* already a local one, so there is no need to replace it. */
|
||||
if (!HasBit(c->flags, GCF_COPY)) {
|
||||
free(c->filename);
|
||||
c->filename = stredup(f->filename);
|
||||
c->filename = f->filename;
|
||||
memcpy(c->ident.md5sum, f->ident.md5sum, sizeof(c->ident.md5sum));
|
||||
c->name = f->name;
|
||||
c->info = f->name;
|
||||
@@ -750,7 +741,7 @@ bool GRFFileScanner::AddFile(const std::string &filename, size_t basepath_length
|
||||
|
||||
const char *name = nullptr;
|
||||
if (c->name != nullptr) name = GetGRFStringFromGRFText(c->name);
|
||||
if (name == nullptr) name = c->filename;
|
||||
if (name == nullptr) name = c->filename.c_str();
|
||||
UpdateNewGRFScanStatus(this->num_scanned, name);
|
||||
VideoDriver::GetInstance()->GameLoopPause();
|
||||
|
||||
@@ -903,5 +894,5 @@ char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last)
|
||||
*/
|
||||
const char *GRFConfig::GetTextfile(TextfileType type) const
|
||||
{
|
||||
return ::GetTextfile(type, NEWGRF_DIR, this->filename);
|
||||
return ::GetTextfile(type, NEWGRF_DIR, this->filename.c_str());
|
||||
}
|
||||
|
Reference in New Issue
Block a user