From d3c1be9abd2507fc5e77e5310e97bc1f31c28e65 Mon Sep 17 00:00:00 2001 From: yexo Date: Sat, 31 Jul 2010 09:33:39 +0000 Subject: (svn r20249) -Codechange: change the newgrf name/description from a char* to a GRFText* to make translations possible --- src/newgrf_config.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/newgrf_config.cpp') diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index 20d3301b7..74c526b93 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -16,6 +16,7 @@ #include "gamelog.h" #include "network/network_func.h" #include "gfx_func.h" +#include "newgrf_text.h" #include "fileio_func.h" #include "fios.h" @@ -45,21 +46,21 @@ GRFConfig::GRFConfig(const GRFConfig &config) : MemCpyT(this->original_md5sum, config.original_md5sum, lengthof(this->original_md5sum)); MemCpyT(this->param, config.param, lengthof(this->param)); if (config.filename != NULL) this->filename = strdup(config.filename); - if (config.name != NULL) this->name = strdup(config.name); - if (config.info != NULL) this->info = strdup(config.info); + this->name = DuplicateGRFText(config.name); + this->info = DuplicateGRFText(config.info); if (config.error != NULL) this->error = new GRFError(*config.error); } /** Cleanup a GRFConfig object. */ GRFConfig::~GRFConfig() { - /* GCF_COPY as in NOT strdupped/alloced the filename, name and info */ + /* GCF_COPY as in NOT strdupped/alloced the filename and info */ if (!HasBit(this->flags, GCF_COPY)) { free(this->filename); - free(this->name); - free(this->info); + CleanUpGRFText(this->info); delete this->error; } + CleanUpGRFText(this->name); } /** @@ -69,8 +70,8 @@ GRFConfig::~GRFConfig() */ const char *GRFConfig::GetName() const { - if (StrEmpty(this->name)) return this->filename; - return this->name; + const char *name = GetGRFStringFromGRFText(this->name); + return StrEmpty(name) ? this->filename : name; } /** @@ -79,7 +80,7 @@ const char *GRFConfig::GetName() const */ const char *GRFConfig::GetDescription() const { - return this->info; + return GetGRFStringFromGRFText(this->info); } GRFConfig *_all_grfs; @@ -349,8 +350,8 @@ compatible_grf: free(c->filename); c->filename = strdup(f->filename); memcpy(c->ident.md5sum, f->ident.md5sum, sizeof(c->ident.md5sum)); - if (c->name == NULL && f->name != NULL) c->name = strdup(f->name); - if (c->info == NULL && f->info != NULL) c->info = strdup(f->info); + if (c->name == NULL) c->name = DuplicateGRFText(f->name); + if (c->info == NULL) c->info = DuplicateGRFText(f->info); c->error = NULL; } } -- cgit v1.2.3-54-g00ecf