diff options
author | peter1138 <peter1138@openttd.org> | 2006-05-03 21:07:44 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2006-05-03 21:07:44 +0000 |
commit | 76df9c8302bf59bd106888630a2a8fa854904ae0 (patch) | |
tree | 209a122e5401e152b32eae2a369554bc13c4d020 | |
parent | 435985624643d5e5461eb38a1f4c9fbac3d49a71 (diff) | |
download | openttd-76df9c8302bf59bd106888630a2a8fa854904ae0.tar.xz |
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
-rw-r--r-- | newgrf.c | 16 | ||||
-rw-r--r-- | newgrf_station.h | 1 |
2 files changed, 16 insertions, 1 deletions
@@ -805,6 +805,8 @@ static bool StationChangeInfo(uint stid, int numinfo, int prop, byte **bufp, int statspec->tiles = grf_load_extended(&buf); statspec->renderdata = calloc(statspec->tiles, sizeof(*statspec->renderdata)); + statspec->copied_renderdata = false; + for (t = 0; t < statspec->tiles; t++) { DrawTileSprites *dts = &statspec->renderdata[t]; uint seq_count = 0; @@ -850,6 +852,7 @@ static bool StationChangeInfo(uint stid, int numinfo, int prop, byte **bufp, int statspec->tiles = srcstatspec->tiles; statspec->renderdata = srcstatspec->renderdata; + statspec->copied_renderdata = true; } break; @@ -2475,14 +2478,25 @@ static void InitializeGRFSpecial(void) static void ResetCustomStations(void) { + StationSpec *statspec; GRFFile *file; uint i; + uint t; for (file = _first_grffile; file != NULL; file = file->next) { for (i = 0; i < file->num_stations; i++) { if (file->stations[i].grfid != file->grfid) continue; + statspec = &file->stations[i]; + + /* Release renderdata, if it wasn't copied from another custom station spec */ + if (!statspec->copied_renderdata) { + for (t = 0; t < statspec->tiles; t++) { + free((void*)statspec->renderdata[t].seq); + } + free(statspec->renderdata); + } - // TODO: Release renderdata, platforms and layouts + // TODO: Release platforms and layouts } /* Free and reset the station data */ diff --git a/newgrf_station.h b/newgrf_station.h index 7ebe78852..073cfe35d 100644 --- a/newgrf_station.h +++ b/newgrf_station.h @@ -44,6 +44,7 @@ typedef struct StationSpec { */ uint tiles; DrawTileSprites *renderdata; ///< Array of tile layouts. + bool copied_renderdata; /** Cargo threshold for choosing between little and lots of cargo * @note little/lots are equivalent to the moving/loading states for vehicles |