From ff8223150aa28b1dfec8d1697d27d6aa96c18f93 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Sat, 12 Nov 2005 00:19:34 +0000 Subject: (svn r3167) - NewGRF: Start moving custom station code to separate files. Rewrite handling of station classes. Allow for more than 8 station tile layouts. Start of code to unload custom stations. --- station_cmd.c | 62 ----------------------------------------------------------- 1 file changed, 62 deletions(-) (limited to 'station_cmd.c') diff --git a/station_cmd.c b/station_cmd.c index f46bd19a6..b0c88412c 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -1199,60 +1199,6 @@ uint GetStationPlatforms(const Station *st, TileIndex tile) return len - 1; } - -/* TODO: Custom classes! */ -/* Indexed by class, just STAT_CLASS_DFLT and STAT_CLASS_WAYP supported. */ -static int _statspec_highest_id[2] = {-1, -1}; -static StationSpec _station_spec[2][256]; - -void SetCustomStation(byte local_stid, StationSpec *spec) -{ - StationClass sclass; - int stid = -1; - - assert(spec->sclass == STAT_CLASS_DFLT || spec->sclass == STAT_CLASS_WAYP); - sclass = spec->sclass - 1; - - if (spec->localidx != 0) { - /* Already allocated, try to resolve to global stid */ - int i; - - for (i = 0; i <= _statspec_highest_id[sclass]; i++) { - if (_station_spec[sclass][i].grfid == spec->grfid && - _station_spec[sclass][i].localidx == local_stid + 1) { - stid = i; - /* FIXME: Release original SpriteGroup to - * prevent leaks. But first we need to - * refcount the SpriteGroup. --pasky */ - break; - } - } - } - - if (stid == -1) { - /* Allocate new one. */ - if (_statspec_highest_id[sclass] >= 255) { - error("Too many custom stations allocated."); - return; - } - stid = ++_statspec_highest_id[sclass]; - spec->localidx = local_stid + 1; - } - - //debug("Registering station #%d of class %d", stid, sclass); - memcpy(&_station_spec[sclass][stid], spec, sizeof(*spec)); -} - -StationSpec *GetCustomStation(StationClass sclass, byte stid) -{ - assert(sclass == STAT_CLASS_DFLT || sclass == STAT_CLASS_WAYP); - sclass--; - //debug("Asking for station #%d of class %d", stid, sclass); - if (stid > _statspec_highest_id[sclass]) - return NULL; - return &_station_spec[sclass][stid]; -} - static const RealSpriteGroup *ResolveStationSpriteGroup(const SpriteGroup *spg, const Station *st) { switch (spg->type) { @@ -1351,14 +1297,6 @@ uint32 GetCustomStationRelocation(const StationSpec *spec, const Station *st, by return SPR_RAIL_PLATFORM_Y_FRONT; } -int GetCustomStationsCount(StationClass sclass) -{ - assert(sclass == STAT_CLASS_DFLT || sclass == STAT_CLASS_WAYP); - sclass--; - return _statspec_highest_id[sclass] + 1; -} - - static int32 RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags) { int w,h; -- cgit v1.2.3-54-g00ecf