mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-02 09:40:35 +00:00
(svn r5690) Factor common code to reduce code duplication
This commit is contained in:
parent
31e0bae89a
commit
2ee4ebfa39
@ -678,42 +678,37 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const StationSpec* GetStationSpec(TileIndex t)
|
||||||
|
{
|
||||||
|
const Station* st;
|
||||||
|
uint specindex;
|
||||||
|
|
||||||
|
if (!IsCustomStationSpecIndex(t)) return NULL;
|
||||||
|
|
||||||
|
st = GetStationByTile(t);
|
||||||
|
specindex = GetCustomStationSpecIndex(t);
|
||||||
|
return specindex < st->num_specs ? st->speclist[specindex].spec : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Check if a rail station tile is traversable.
|
/* Check if a rail station tile is traversable.
|
||||||
* XXX This could be cached (during build) in the map array to save on all the dereferencing */
|
* XXX This could be cached (during build) in the map array to save on all the dereferencing */
|
||||||
bool IsStationTileBlocked(TileIndex tile)
|
bool IsStationTileBlocked(TileIndex tile)
|
||||||
{
|
{
|
||||||
const Station *st;
|
const StationSpec* statspec = GetStationSpec(tile);
|
||||||
const StationSpec *statspec;
|
|
||||||
uint specindex;
|
|
||||||
|
|
||||||
if (!IsCustomStationSpecIndex(tile)) return false;
|
return statspec != NULL && HASBIT(statspec->blocked, GetStationGfx(tile));
|
||||||
|
|
||||||
st = GetStationByTile(tile);
|
|
||||||
specindex = GetCustomStationSpecIndex(tile);
|
|
||||||
if (specindex >= st->num_specs) return false;
|
|
||||||
|
|
||||||
statspec = st->speclist[specindex].spec;
|
|
||||||
if (statspec == NULL) return false;
|
|
||||||
|
|
||||||
return HASBIT(statspec->blocked, GetStationGfx(tile));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if a rail station tile is electrifiable.
|
/* Check if a rail station tile is electrifiable.
|
||||||
* XXX This could be cached (during build) in the map array to save on all the dereferencing */
|
* XXX This could be cached (during build) in the map array to save on all the dereferencing */
|
||||||
bool IsStationTileElectrifiable(TileIndex tile)
|
bool IsStationTileElectrifiable(TileIndex tile)
|
||||||
{
|
{
|
||||||
const Station *st;
|
const StationSpec* statspec = GetStationSpec(tile);
|
||||||
const StationSpec *statspec;
|
|
||||||
uint specindex;
|
|
||||||
|
|
||||||
if (!IsCustomStationSpecIndex(tile)) return true;
|
return
|
||||||
|
statspec == NULL ||
|
||||||
st = GetStationByTile(tile);
|
HASBIT(statspec->pylons, GetStationGfx(tile)) ||
|
||||||
specindex = GetCustomStationSpecIndex(tile);
|
!HASBIT(statspec->wires, GetStationGfx(tile));
|
||||||
if (specindex >= st->num_specs) return true;
|
|
||||||
|
|
||||||
statspec = st->speclist[specindex].spec;
|
|
||||||
if (statspec == NULL) return true;
|
|
||||||
|
|
||||||
return HASBIT(statspec->pylons, GetStationGfx(tile)) || !HASBIT(statspec->wires, GetStationGfx(tile));
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user