diff options
author | yexo <yexo@openttd.org> | 2010-02-28 20:28:08 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2010-02-28 20:28:08 +0000 |
commit | 404df87b1f2e0c6ae8d71dd0ea83b55294f53af3 (patch) | |
tree | 868c12ba0cf41427a4c00eff31601f6e45398be4 /src/newgrf_config.cpp | |
parent | 333249ce501085405afabac8eb61a2c3ed599c0f (diff) | |
download | openttd-404df87b1f2e0c6ae8d71dd0ea83b55294f53af3.tar.xz |
(svn r19295) -Codechange: introduce wrapper functions for GRFConfig::name/info
Diffstat (limited to 'src/newgrf_config.cpp')
-rw-r--r-- | src/newgrf_config.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index a942279c8..16cb8b8ac 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -36,6 +36,26 @@ GRFConfig::~GRFConfig() } } +/** + * Get the name of this grf. In case the name isn't known + * the filename is returned. + * @return The name of filename of this grf. + */ +const char *GRFConfig::GetName() const +{ + if (this->name == NULL) return this->filename; + return this->name; +} + +/** + * Get the grf info. + * @return A string with a description of this grf. + */ +const char *GRFConfig::GetDescription() const +{ + return this->info; +} + GRFConfig *_all_grfs; GRFConfig *_grfconfig; GRFConfig *_grfconfig_newgame; @@ -337,7 +357,7 @@ bool GRFFileScanner::AddFile(const char *filename, size_t basepath_length) /* Because there can be multiple grfs with the same name, make sure we checked all grfs with the same name, * before inserting the entry. So insert a new grf at the end of all grfs with the same name, instead of * just after the first with the same name. Avoids doubles in the list. */ - if (strcasecmp(c->name, d->name) <= 0) { + if (strcasecmp(c->GetName(), d->GetName()) <= 0) { stop = true; } else if (stop) { break; @@ -372,8 +392,7 @@ static int CDECL GRFSorter(GRFConfig * const *p1, GRFConfig * const *p2) const GRFConfig *c1 = *p1; const GRFConfig *c2 = *p2; - return strcasecmp(c1->name != NULL ? c1->name : c1->filename, - c2->name != NULL ? c2->name : c2->filename); + return strcasecmp(c1->GetName(), c2->GetName()); } /* Scan for all NewGRFs */ |