summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-06-13 19:05:42 +0000
committertruelight <truelight@openttd.org>2007-06-13 19:05:42 +0000
commit79817428b12a895c0b16a4e6ada13fe3307ae17b (patch)
tree5d6feec5a89d4e271e7d1a317a3df1df6591183d /src
parent4b51ea375b21c31e959a8da08dbcbe281901b564 (diff)
downloadopenttd-79817428b12a895c0b16a4e6ada13fe3307ae17b.tar.xz
(svn r10149) -Fix r10143: MSVC warnings... (tnx boekabart and glx)
Diffstat (limited to 'src')
-rw-r--r--src/spritecache.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/spritecache.cpp b/src/spritecache.cpp
index 3e9faef4a..d85af6b70 100644
--- a/src/spritecache.cpp
+++ b/src/spritecache.cpp
@@ -252,13 +252,16 @@ bool LoadNextSprite(int load_index, byte file_index)
sc->lru = 0;
sc->id = load_index;
- char *grf_name = strrchr(FioGetFilename(), PATHSEPCHAR);
- if (grf_name == NULL) grf_name = (char *)FioGetFilename();
- /* Copy the string, make it lowercase, strip .grf */
- grf_name = strdup(grf_name);
- char *t = strrchr(grf_name, '.');
- if (t != NULL) *t = '\0';
+ const char *fio_grf_name = FioGetFilename();
+ const char *t = strrchr(fio_grf_name, PATHSEPCHAR);
+ char *grf_name;
+ if (t == NULL) grf_name = strdup(fio_grf_name);
+ else grf_name = strdup(t);
+ /* Make the string lowercase and strip extension */
+ char *t2 = strrchr(grf_name, '.');
+ if (t2 != NULL) *t2 = '\0';
strtolower(grf_name);
+
free((char *)sc->grf_name);
sc->grf_name = grf_name;