mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r10001) -Codechange: Add support for removing dynamically allocated newgrf data
This commit is contained in:
parent
294a154bf7
commit
78151810d7
@ -22,6 +22,11 @@ enum {
|
||||
INVALID_INDUSTRYTILE = NUM_INDUSTRYTILES, ///< one above amount is considered invalid
|
||||
};
|
||||
|
||||
enum {
|
||||
CLEAN_RANDOMSOUNDS, ///< Free the dynamically allocated sounds table
|
||||
CLEAN_TILELSAYOUT, ///< Free the dynamically allocated tile layout structure
|
||||
};
|
||||
|
||||
enum IndustryLifeType {
|
||||
INDUSTRYLIFE_NOT_CLOSABLE, ///< Industry can never close
|
||||
INDUSTRYLIFE_PRODUCTION, ///< Industry can close and change of production
|
||||
@ -135,6 +140,7 @@ struct IndustrySpec {
|
||||
const uint8 *random_sounds; ///< array of random sounds.
|
||||
/* Newgrf data */
|
||||
uint16 callback_flags; ///< Flags telling which grf callback is set
|
||||
uint8 cleanup_flag; ///< flags indicating which data should be freed upon cleaning up
|
||||
bool enabled; ///< entity still avaible (by default true).newgrf can disable it, though
|
||||
struct GRFFileProps grf_prop; ///< properties related the the grf file
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -1135,7 +1135,7 @@ static const uint8 _plastic_mine_sounds[] = { SND_33_PLASTIC_MINE };
|
||||
c1, c2, c3, proc, p1, r1, p2, r2, m, a1, im1, a2, im2, a3, im3, pr, clim, bev, in, intx, s1, s2, s3) \
|
||||
{tbl, lengthof(tbl), d, {c1, c2, c3}, proc, {p1, p2}, {r1, r2}, m, \
|
||||
{a1, a2, a3}, {{im1, 0}, {im2, 0}, {im3, 0}}, pr, clim, bev, col, in, intx, s1, s2, s3, {ai1, ai2, ai3, ai4}, {ag1, ag2, ag3, ag4}, \
|
||||
sndc, snd, 0, true, {0, 0, NULL, NULL, INVALID_INDUSTRYTYPE}}
|
||||
sndc, snd, 0, 0, true, {0, 0, NULL, NULL, INVALID_INDUSTRYTYPE}}
|
||||
/* Format:
|
||||
tile table count and sounds table
|
||||
cost multiplier appear chances(4ingame, 4random) map colour
|
||||
|
Loading…
Reference in New Issue
Block a user