summaryrefslogtreecommitdiff
path: root/src/newgrf_config.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-07-31 09:33:39 +0000
committeryexo <yexo@openttd.org>2010-07-31 09:33:39 +0000
commitd3c1be9abd2507fc5e77e5310e97bc1f31c28e65 (patch)
treebec0ca8eec0327145cc2b575795d9f154ac24404 /src/newgrf_config.cpp
parent1ca16aa979fab1d7a60fb40def0374433362d265 (diff)
downloadopenttd-d3c1be9abd2507fc5e77e5310e97bc1f31c28e65.tar.xz
(svn r20249) -Codechange: change the newgrf name/description from a char* to a GRFText* to make translations possible
Diffstat (limited to 'src/newgrf_config.cpp')
-rw-r--r--src/newgrf_config.cpp21
1 files changed, 11 insertions, 10 deletions
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<uint8>(this->original_md5sum, config.original_md5sum, lengthof(this->original_md5sum));
MemCpyT<uint32>(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;
}
}