1
0
Fork 0

(svn r2055) -CodeChange: Begun introducting StationID

release/0.4.5
celestar 2005-03-25 10:40:58 +00:00
parent 75bc6cd7e7
commit 6e142d523e
3 changed files with 19 additions and 16 deletions

View File

@ -28,13 +28,15 @@ enum {
ROAD_STOP_LIMIT = 8, ROAD_STOP_LIMIT = 8,
}; };
typedef uint16 StationID;
typedef struct RoadStop { typedef struct RoadStop {
TileIndex xy; TileIndex xy;
bool used; bool used;
byte status; byte status;
uint32 index; uint32 index;
uint16 slot[NUM_SLOTS]; uint16 slot[NUM_SLOTS];
uint16 station; //XXX should be StationIndex StationID station;
uint8 type; uint8 type;
struct RoadStop *next; struct RoadStop *next;
struct RoadStop *prev; struct RoadStop *prev;
@ -72,7 +74,7 @@ struct Station {
//uint16 airport_flags; //uint16 airport_flags;
uint32 airport_flags; uint32 airport_flags;
uint16 index; StationID index;
VehicleID last_vehicle; VehicleID last_vehicle;
GoodsEntry goods[NUM_CARGO]; GoodsEntry goods[NUM_CARGO];
@ -131,7 +133,7 @@ extern MemoryPool _station_pool;
/** /**
* Get the pointer to the station with index 'index' * Get the pointer to the station with index 'index'
*/ */
static inline Station *GetStation(uint index) static inline Station *GetStation(StationID index)
{ {
return (Station*)GetItemFromPool(&_station_pool, index); return (Station*)GetItemFromPool(&_station_pool, index);
} }

View File

@ -79,7 +79,7 @@ static void MarkStationDirty(Station *st)
} }
} }
static void InitializeRoadStop(RoadStop *road_stop, RoadStop *previous, TileIndex tile, uint index) static void InitializeRoadStop(RoadStop *road_stop, RoadStop *previous, TileIndex tile, StationID index)
{ {
road_stop->xy = tile; road_stop->xy = tile;
road_stop->used = true; road_stop->used = true;
@ -224,7 +224,7 @@ TileIndex GetStationTileForVehicle(const Vehicle *v, const Station *st)
static bool CheckStationSpreadOut(Station *st, uint tile, int w, int h) static bool CheckStationSpreadOut(Station *st, uint tile, int w, int h)
{ {
uint16 station_index = st->index; StationID station_index = st->index;
uint i; uint i;
uint x1 = TileX(tile); uint x1 = TileX(tile);
uint y1 = TileY(tile); uint y1 = TileY(tile);
@ -258,7 +258,7 @@ static Station *AllocateStation(void)
FOR_ALL_STATIONS(st) { FOR_ALL_STATIONS(st) {
if (st->xy == 0) { if (st->xy == 0) {
uint index = st->index; StationID index = st->index;
memset(st, 0, sizeof(Station)); memset(st, 0, sizeof(Station));
st->index = index; st->index = index;
@ -1020,7 +1020,7 @@ int32 CmdBuildRailroadStation(int x_org, int y_org, uint32 flags, uint32 p1, uin
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
int tile_delta; int tile_delta;
byte *layout_ptr; byte *layout_ptr;
uint station_index = st->index; StationID station_index = st->index;
StationSpec *statspec; StationSpec *statspec;
// Now really clear the land below the station // Now really clear the land below the station
@ -2316,7 +2316,7 @@ static const byte _enter_station_speedtable[12] = {
static uint32 VehicleEnter_Station(Vehicle *v, uint tile, int x, int y) static uint32 VehicleEnter_Station(Vehicle *v, uint tile, int x, int y)
{ {
uint16 station_id; //XXX should be stationindex StationID station_id;
byte dir; byte dir;
uint16 spd; uint16 spd;
@ -2390,7 +2390,7 @@ static uint32 VehicleEnter_Station(Vehicle *v, uint tile, int x, int y)
static void DeleteStation(Station *st) static void DeleteStation(Station *st)
{ {
Order order; Order order;
int index; StationID index;
st->xy = 0; st->xy = 0;
DeleteName(st->string_id); DeleteName(st->string_id);
@ -2473,7 +2473,8 @@ static byte _rating_boost[3] = { 0, 31, 63};
static void UpdateStationRating(Station *st) static void UpdateStationRating(Station *st)
{ {
GoodsEntry *ge; GoodsEntry *ge;
int rating, index; int rating;
StationID index;
int waiting; int waiting;
bool waiting_changed = false; bool waiting_changed = false;
@ -2671,8 +2672,8 @@ int32 CmdRenameStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
uint MoveGoodsToStation(uint tile, int w, int h, int type, uint amount) uint MoveGoodsToStation(uint tile, int w, int h, int type, uint amount)
{ {
Station *around_ptr[8]; Station *around_ptr[8];
uint16 around[8]; StationID around[8];
uint16 st_index; StationID st_index;
int i; int i;
Station *st; Station *st;
uint moved; uint moved;

View File

@ -1521,7 +1521,7 @@ static bool CheckTrainStayInDepot(Vehicle *v)
/* Check for station tiles */ /* Check for station tiles */
typedef struct TrainTrackFollowerData { typedef struct TrainTrackFollowerData {
TileIndex dest_coords; TileIndex dest_coords;
int station_index; // station index we're heading for StationID station_index; // station index we're heading for
uint best_bird_dist; uint best_bird_dist;
uint best_track_dist; uint best_track_dist;
byte best_track; byte best_track;
@ -1550,7 +1550,7 @@ static bool TrainTrackFollower(uint tile, TrainTrackFollowerData *ttfd, int trac
return false; return false;
// did we reach the final station? // did we reach the final station?
if ((ttfd->station_index == -1 && tile == ttfd->dest_coords) || if ((ttfd->station_index == INVALID_STATION && tile == ttfd->dest_coords) ||
(IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_map5[tile], 0, 8) && _map2[tile] == ttfd->station_index)) { (IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_map5[tile], 0, 8) && _map2[tile] == ttfd->station_index)) {
/* We do not check for dest_coords if we have a station_index, /* We do not check for dest_coords if we have a station_index,
* because in that case the dest_coords are just an * because in that case the dest_coords are just an
@ -1585,7 +1585,7 @@ static void FillWithStationData(TrainTrackFollowerData *fd, Vehicle *v)
if (v->current_order.type == OT_GOTO_STATION) if (v->current_order.type == OT_GOTO_STATION)
fd->station_index = v->current_order.station; fd->station_index = v->current_order.station;
else else
fd->station_index = -1; fd->station_index = INVALID_STATION;
} }
@ -2018,7 +2018,7 @@ static int UpdateTrainSpeed(Vehicle *v)
return (spd >> 8); return (spd >> 8);
} }
static void TrainEnterStation(Vehicle *v, int station) static void TrainEnterStation(Vehicle *v, StationID station)
{ {
Station *st; Station *st;
uint32 flags; uint32 flags;