diff options
author | tron <tron@openttd.org> | 2006-07-29 17:39:58 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-07-29 17:39:58 +0000 |
commit | 801bf631b0d95c30032fe59640b932c867b4b4d3 (patch) | |
tree | d36be930a050f4fac340789740d505fd5b916581 | |
parent | fef9818d3cee1c2d15a25d1b5fa83c5c26bfde16 (diff) | |
download | openttd-801bf631b0d95c30032fe59640b932c867b4b4d3.tar.xz |
(svn r5632) Replace a boolean variable in DeallocateSpecFromStation() by a return
Also set the return type to void, because the caller doesn't care about it
-rw-r--r-- | newgrf_station.c | 43 | ||||
-rw-r--r-- | newgrf_station.h | 2 |
2 files changed, 19 insertions, 26 deletions
diff --git a/newgrf_station.c b/newgrf_station.c index b04a1fff0..0ffe8989e 100644 --- a/newgrf_station.c +++ b/newgrf_station.c @@ -582,42 +582,35 @@ int AllocateSpecToStation(const StationSpec *statspec, Station *st, bool exec) * @param specindex Index of the custom station within the Station's spec list. * @return Indicates whether the StationSpec was deallocated. */ -bool DeallocateSpecFromStation(Station *st, byte specindex) +void DeallocateSpecFromStation(Station* st, byte specindex) { - bool freeable = true; - /* specindex of 0 (default) is never freeable */ - if (specindex == 0) return false; + if (specindex == 0) return; /* Check all tiles over the station to check if the specindex is still in use */ BEGIN_TILE_LOOP(tile, st->trainst_w, st->trainst_h, st->train_tile) { if (IsTileType(tile, MP_STATION) && GetStationIndex(tile) == st->index && IsRailwayStation(tile) && GetCustomStationSpecIndex(tile) == specindex) { - freeable = false; - break; + return; } } END_TILE_LOOP(tile, st->trainst_w, st->trainst_h, st->train_tile) - if (freeable) { - /* This specindex is no longer in use, so deallocate it */ - st->speclist[specindex].spec = NULL; - st->speclist[specindex].grfid = 0; - st->speclist[specindex].localidx = 0; - - /* If this was the highest spec index, reallocate */ - if (specindex == st->num_specs - 1) { - for (; st->speclist[st->num_specs - 1].grfid == 0 && st->num_specs > 1; st->num_specs--); - - if (st->num_specs > 1) { - st->speclist = realloc(st->speclist, st->num_specs * sizeof(*st->speclist)); - } else { - free(st->speclist); - st->num_specs = 0; - st->speclist = NULL; - } + /* This specindex is no longer in use, so deallocate it */ + st->speclist[specindex].spec = NULL; + st->speclist[specindex].grfid = 0; + st->speclist[specindex].localidx = 0; + + /* If this was the highest spec index, reallocate */ + if (specindex == st->num_specs - 1) { + for (; st->speclist[st->num_specs - 1].grfid == 0 && st->num_specs > 1; st->num_specs--); + + if (st->num_specs > 1) { + st->speclist = realloc(st->speclist, st->num_specs * sizeof(*st->speclist)); + } else { + free(st->speclist); + st->num_specs = 0; + st->speclist = NULL; } } - - return freeable; } /** Draw representation of a station tile for GUI purposes. diff --git a/newgrf_station.h b/newgrf_station.h index 98dc1b75e..b1f135e54 100644 --- a/newgrf_station.h +++ b/newgrf_station.h @@ -120,7 +120,7 @@ bool IsStationTileElectrifiable(TileIndex tile); int AllocateSpecToStation(const StationSpec *statspec, Station *st, bool exec); /* Deallocate a StationSpec from a Station. Called when removing a single station tile. */ -bool DeallocateSpecFromStation(Station *st, byte specindex); +void DeallocateSpecFromStation(Station* st, byte specindex); /* Draw representation of a station tile for GUI purposes. */ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station); |