summaryrefslogtreecommitdiff
path: root/newgrf.c
diff options
context:
space:
mode:
authorpasky <pasky@openttd.org>2004-11-22 22:51:19 +0000
committerpasky <pasky@openttd.org>2004-11-22 22:51:19 +0000
commitf012e15c953f7d6a24f9d063123b41739060782f (patch)
treec7e672b662e7899b3172877cf215f60e884c7208 /newgrf.c
parentb2e973056ad8e1926a87d52e534c71a7c3dd6420 (diff)
downloadopenttd-f012e15c953f7d6a24f9d063123b41739060782f.tar.xz
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
Diffstat (limited to 'newgrf.c')
-rw-r--r--newgrf.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/newgrf.c b/newgrf.c
index 3ce32bae7..52ca90575 100644
--- a/newgrf.c
+++ b/newgrf.c
@@ -1989,6 +1989,14 @@ void InitNewGRFFile(const char *filename, int sprite_offset)
{
struct GRFFile *newfile;
+ newfile = GetFileByFilename(filename);
+ if (newfile) {
+ /* We already loaded it once. */
+ newfile->sprite_offset = sprite_offset;
+ _cur_grffile = newfile;
+ return;
+ }
+
newfile = calloc(1, sizeof(struct GRFFile));
if (newfile == NULL)