summaryrefslogtreecommitdiff
path: root/src/newgrf.cpp
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2007-05-31 15:40:36 +0000
committerbelugas <belugas@openttd.org>2007-05-31 15:40:36 +0000
commit78151810d7cade6d6599d3c8a70b73ef8104a4d4 (patch)
tree082f8e8242493f956b635dfb21392821d27de0e2 /src/newgrf.cpp
parent294a154bf7a4892fb16979bb4304fa2ecdb91c51 (diff)
downloadopenttd-78151810d7cade6d6599d3c8a70b73ef8104a4d4.tar.xz
(svn r10001) -Codechange: Add support for removing dynamically allocated newgrf data
Diffstat (limited to 'src/newgrf.cpp')
-rw-r--r--src/newgrf.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index cc44682d0..8d50fef12 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -4326,6 +4326,24 @@ static void ResetCustomIndustries()
IndustrySpec *ind = file->industryspec[i];
if (ind != NULL) {
+ /* We need to remove the sounds array */
+ if (HASBIT(ind->cleanup_flag, CLEAN_RANDOMSOUNDS)) {
+ free((void*)ind->random_sounds);
+ }
+
+ /* We need to remove the tiles layouts */
+ if (HASBIT(ind->cleanup_flag, CLEAN_TILELSAYOUT) && ind->table != NULL) {
+ for (int j = 0; j < ind->num_table; j++) {
+ /* remove the individual layouts */
+ if (ind->table[j] != NULL) {
+ free((IndustryTileTable*)ind->table[j]);
+ }
+ }
+ /* remove the layouts pointers */
+ free((IndustryTileTable**)ind->table);
+ ind->table = NULL;
+ }
+
free(ind);
ind = NULL;
}