summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-12 17:42:04 +0000
committertron <tron@openttd.org>2006-03-12 17:42:04 +0000
commitb05a98fdfa3db1171064aa59c401dcad1798b7ae (patch)
tree92107719a9ce6eb371c4b48b27ef13761bc42120
parent12d252d9bd7ffee83c4be5162cd506bda1070020 (diff)
downloadopenttd-b05a98fdfa3db1171064aa59c401dcad1798b7ae.tar.xz
(svn r3832) Replace some magic numbers by (Diag)Direction enums
-rw-r--r--aircraft_cmd.c2
-rw-r--r--roadveh_cmd.c8
-rw-r--r--ship_cmd.c2
-rw-r--r--train_cmd.c16
4 files changed, 14 insertions, 14 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 42000164b..8d07cb0dc 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -110,7 +110,7 @@ void DrawAircraftEngine(int x, int y, EngineID engine, uint32 image_ormod)
int sprite = (6 + _aircraft_sprite[spritenum]);
if (is_custom_sprite(spritenum)) {
- sprite = GetCustomVehicleIcon(engine, 6);
+ sprite = GetCustomVehicleIcon(engine, DIR_W);
if (!sprite)
spritenum = orig_aircraft_vehicle_info[engine - AIRCRAFT_ENGINES_INDEX].image_index;
}
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index 9bd462072..676ea0d9b 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -82,7 +82,7 @@ void DrawRoadVehEngine(int x, int y, EngineID engine, uint32 image_ormod)
int spritenum = RoadVehInfo(engine)->image_index;
if (is_custom_sprite(spritenum)) {
- int sprite = GetCustomVehicleIcon(engine, 6);
+ int sprite = GetCustomVehicleIcon(engine, DIR_W);
if (sprite != 0) {
DrawSprite(sprite | image_ormod, x, y);
@@ -286,9 +286,9 @@ typedef struct RoadFindDepotData {
byte owner;
} RoadFindDepotData;
-static const byte _road_pf_directions[16] = {
- 0, 1, 0, 1, 2, 1, 255, 255,
- 2, 3, 3, 2, 3, 0, 255, 255,
+static const DiagDirection _road_pf_directions[] = {
+ DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_SE, 255, 255,
+ DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NW, DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NE, 255, 255
};
static bool EnumRoadSignalFindDepot(TileIndex tile, void* data, int track, uint length, byte* state)
diff --git a/ship_cmd.c b/ship_cmd.c
index 607dc152c..f75b8eef8 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -33,7 +33,7 @@ void DrawShipEngine(int x, int y, EngineID engine, uint32 image_ormod)
int spritenum = ShipVehInfo(engine)->image_index;
if (is_custom_sprite(spritenum)) {
- int sprite = GetCustomVehicleIcon(engine, 6);
+ int sprite = GetCustomVehicleIcon(engine, DIR_W);
if (sprite != 0) {
DrawSprite(sprite | image_ormod, x, y);
diff --git a/train_cmd.c b/train_cmd.c
index c174937d8..b14a9e0ff 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -400,7 +400,7 @@ void DrawTrainEngine(int x, int y, EngineID engine, uint32 image_ormod)
uint32 image = 0;
if (is_custom_sprite(img)) {
- image = GetCustomVehicleIcon(engine, 6);
+ image = GetCustomVehicleIcon(engine, DIR_W);
if (image == 0) {
img = orig_rail_vehicle_info[engine].image_index;
} else {
@@ -3153,13 +3153,13 @@ static bool TrainCheckIfLineEnds(Vehicle *v)
y = v->y_pos & 0xF;
switch (v->direction) {
- case 0: x = ~x + ~y + 24; break;
- case 7: x = y; /* FALLTHROUGH */
- case 1: x = ~x + 16; break;
- case 2: x = ~x + y + 8; break;
- case 3: x = y; break;
- case 4: x = x + y - 8; break;
- case 6: x = ~y + x + 8; break;
+ case DIR_N : x = ~x + ~y + 24; break;
+ case DIR_NW: x = y; /* FALLTHROUGH */
+ case DIR_NE: x = ~x + 16; break;
+ case DIR_E : x = ~x + y + 8; break;
+ case DIR_SE: x = y; break;
+ case DIR_S : x = x + y - 8; break;
+ case DIR_W : x = ~y + x + 8; break;
}
if (GB(ts, 0, 16) != 0) {