summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-03-26 22:55:27 +0000
committerDarkvater <darkvater@openttd.org>2006-03-26 22:55:27 +0000
commit2c27f45cdc31c0466d72eb8d1539448b93af0d5b (patch)
tree5375ce61c67417cfbafdc80258742b527d4675c3
parent2ba792d64447968bbd18c755a6e4d1720728c5ae (diff)
downloadopenttd-2c27f45cdc31c0466d72eb8d1539448b93af0d5b.tar.xz
(svn r4131) - CodeChange: Add proper semantics for StationID for such variables instead of using the general uint16-type. StationID was added for depots, waypoints and stations where necessary. We probably need to change GetDepot(), IsDepotIndex(), IsStationIndex(), GetWaypoint() and IsWaypointIndex() as well to use StationID.
-rw-r--r--depot.h2
-rw-r--r--economy.c4
-rw-r--r--openttd.h1
-rw-r--r--order.h2
-rw-r--r--station.h6
-rw-r--r--vehicle.h6
-rw-r--r--waypoint.h2
7 files changed, 11 insertions, 12 deletions
diff --git a/depot.h b/depot.h
index 3ab106881..365177cde 100644
--- a/depot.h
+++ b/depot.h
@@ -16,7 +16,7 @@
struct Depot {
TileIndex xy;
TownID town_index;
- uint16 index;
+ StationID index;
};
extern MemoryPool _depot_pool;
diff --git a/economy.c b/economy.c
index 86aebd70e..0bb008dbc 100644
--- a/economy.c
+++ b/economy.c
@@ -1230,7 +1230,7 @@ static bool CheckSubsidised(Station *from, Station *to, CargoID cargo_type)
return false;
}
-static int32 DeliverGoods(int num_pieces, CargoID cargo_type, uint16 source, uint16 dest, byte days_in_transit)
+static int32 DeliverGoods(int num_pieces, CargoID cargo_type, StationID source, StationID dest, byte days_in_transit)
{
bool subsidised;
Station *s_from, *s_to;
@@ -1340,7 +1340,7 @@ int LoadUnloadVehicle(Vehicle *v)
int unloading_time = 20;
Vehicle *u = v;
int result = 0;
- uint16 last_visited;
+ StationID last_visited;
Station *st;
int t;
uint count, cap;
diff --git a/openttd.h b/openttd.h
index 31f8c35df..f8fdfb2f9 100644
--- a/openttd.h
+++ b/openttd.h
@@ -61,6 +61,7 @@ typedef struct NewsItem NewsItem;
typedef struct Industry Industry;
typedef struct DrawPixelInfo DrawPixelInfo;
typedef uint16 VehicleID;
+typedef uint16 StationID;
typedef uint16 TownID;
typedef byte PlayerID;
typedef byte OrderID;
diff --git a/order.h b/order.h
index dd387161b..35f0a4c26 100644
--- a/order.h
+++ b/order.h
@@ -78,7 +78,7 @@ enum {
typedef struct Order {
uint8 type;
uint8 flags;
- uint16 station;
+ StationID station;
struct Order *next; ///< Pointer to next order. If NULL, end of list
diff --git a/station.h b/station.h
index 2407ed25d..f62990509 100644
--- a/station.h
+++ b/station.h
@@ -14,7 +14,7 @@ typedef struct GoodsEntry {
uint16 waiting_acceptance;
byte days_since_pickup;
byte rating;
- uint16 enroute_from;
+ StationID enroute_from;
byte enroute_time;
byte last_speed;
byte last_age;
@@ -32,8 +32,6 @@ enum {
ROAD_STOP_LIMIT = 16,
};
-typedef uint16 StationID;
-
typedef struct RoadStop {
TileIndex xy;
bool used;
@@ -150,7 +148,7 @@ static inline uint16 GetStationPoolSize(void)
return _station_pool.total_items;
}
-static inline bool IsStationIndex(uint index)
+static inline bool IsStationIndex(StationID index)
{
return index < GetStationPoolSize();
}
diff --git a/vehicle.h b/vehicle.h
index 63f6bbdf1..d63e6b5f5 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -97,7 +97,7 @@ typedef struct VehicleAir {
uint16 crashed_counter;
byte pos;
byte previous_pos;
- uint16 targetairport;
+ StationID targetairport;
byte state;
} VehicleAir;
@@ -176,11 +176,11 @@ struct Vehicle {
byte progress;
byte vehstatus; // Status
- uint16 last_station_visited;
+ StationID last_station_visited;
CargoID cargo_type; // type of cargo this vehicle is carrying
byte cargo_days; // how many days have the pieces been in transit
- uint16 cargo_source;// source of cargo
+ StationID cargo_source;// source of cargo
uint16 cargo_cap; // total capacity
uint16 cargo_count;// how many pieces are used
diff --git a/waypoint.h b/waypoint.h
index 4842d1a31..763694f8c 100644
--- a/waypoint.h
+++ b/waypoint.h
@@ -8,7 +8,7 @@
struct Waypoint {
TileIndex xy; ///< Tile of waypoint
- uint16 index; ///< Index of waypoint
+ StationID index; ///< Index of waypoint
TownID town_index; ///< Town associated with the waypoint
byte town_cn; ///< The Nth waypoint for this town (consecutive number)