summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/newgrf_config.cpp5
-rw-r--r--src/settings.cpp4
2 files changed, 6 insertions, 3 deletions
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index 60563ba35..74c4ba525 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -64,6 +64,10 @@ bool FillGRFDetails(GRFConfig *config, bool is_static)
return false;
}
+ if (config->filename == NULL) {
+ config->filename = strdup(strrchr(config->full_path, PATHSEPCHAR) + 1);
+ }
+
/* Find and load the Action 8 information */
/* 62 is the last file slot before sample.cat.
* Should perhaps be some "don't care" value */
@@ -305,7 +309,6 @@ static uint ScanPath(const char *path)
GRFConfig *c = CallocT<GRFConfig>(1);
c->full_path = strdup(filename);
- c->filename = strdup(strrchr(filename, PATHSEPCHAR) + 1);
bool added = true;
if (FillGRFDetails(c, false)) {
diff --git a/src/settings.cpp b/src/settings.cpp
index b8ae00572..08255a957 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1576,7 +1576,7 @@ static GRFConfig *GRFLoadConfig(IniFile *ini, const char *grpname, bool is_stati
for (item = group->item; item != NULL; item = item->next) {
GRFConfig *c = CallocT<GRFConfig>(1);
- c->filename = strdup(item->name);
+ c->full_path = strdup(item->name);
/* Parse parameters */
if (*item->value != '\0') {
@@ -1653,7 +1653,7 @@ static void GRFSaveConfig(IniFile *ini, const char *grpname, const GRFConfig *li
char params[512];
GRFBuildParamList(params, c, lastof(params));
- *item = ini_item_alloc(group, c->filename, strlen(c->filename));
+ *item = ini_item_alloc(group, c->full_path, strlen(c->full_path));
(*item)->value = (char*)pool_strdup(&ini->pool, params, strlen(params));
item = &(*item)->next;
}