# HG changeset patch # User tron # Date 1142185324 0 # Node ID 4317b5b295c48fb689d504c105cca726516edc6a # Parent a9d0cdff7b841a23843598b3e997e3b9f3374bf2 (svn r3832) Replace some magic numbers by (Diag)Direction enums diff -r a9d0cdff7b84 -r 4317b5b295c4 aircraft_cmd.c --- a/aircraft_cmd.c Sun Mar 12 16:13:16 2006 +0000 +++ b/aircraft_cmd.c Sun Mar 12 17:42:04 2006 +0000 @@ -110,7 +110,7 @@ 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 -r a9d0cdff7b84 -r 4317b5b295c4 roadveh_cmd.c --- a/roadveh_cmd.c Sun Mar 12 16:13:16 2006 +0000 +++ b/roadveh_cmd.c Sun Mar 12 17:42:04 2006 +0000 @@ -82,7 +82,7 @@ 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 @@ 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 -r a9d0cdff7b84 -r 4317b5b295c4 ship_cmd.c --- a/ship_cmd.c Sun Mar 12 16:13:16 2006 +0000 +++ b/ship_cmd.c Sun Mar 12 17:42:04 2006 +0000 @@ -33,7 +33,7 @@ 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 -r a9d0cdff7b84 -r 4317b5b295c4 train_cmd.c --- a/train_cmd.c Sun Mar 12 16:13:16 2006 +0000 +++ b/train_cmd.c Sun Mar 12 17:42:04 2006 +0000 @@ -400,7 +400,7 @@ 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 @@ 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) {