diff options
Diffstat (limited to 'vehicle.c')
-rw-r--r-- | vehicle.c | 33 |
1 files changed, 31 insertions, 2 deletions
@@ -15,6 +15,8 @@ #include "engine.h" #include "sound.h" #include "debug.h" +#include "npf.h" +#include "vehicle_gui.h" #define INVALID_COORD (-0x8000) #define GEN_HASH(x,y) (((x & 0x1F80)>>7) + ((y & 0xFC0))) @@ -1707,6 +1709,35 @@ byte GetDirectionTowards(Vehicle *v, int x, int y) return (dir+((dirdiff&7)<5?1:-1)) & 7; } +byte GetVehicleTrackdir(const Vehicle* v) +{ + switch(v->type) + { + case VEH_Train: + if (v->u.rail.track == 0x80) + return 0xFF; /* Train in depot */ + else if (v->u.rail.track == 0x40) + /* train in tunnel, so just use his direction and assume a diagonal track */ + return _dir_to_diag_trackdir[(v->direction>>1)&3]; + else + return _track_direction_to_trackdir[FIND_FIRST_BIT(v->u.rail.track)][v->direction]; + case VEH_Ship: + if (v->u.ship.state == 0x80) + return 0xFF; /* Ship in depot */ + else + return _track_direction_to_trackdir[FIND_FIRST_BIT(v->u.ship.state)][v->direction]; + case VEH_Road: + if (v->u.road.state == 254) + return 0xFF; /* Road vehicle in depot */ + else + return _dir_to_diag_trackdir[(v->direction>>1)&3]; + case VEH_Aircraft: + case VEH_Special: + case VEH_Disaster: + default: + return 0xFF; + } +} /* Return value has bit 0x2 set, when the vehicle enters a station. Then, * result << 8 contains the id of the station entered. If the return value has * bit 0x8 set, the vehicle could not and did not enter the tile. Are there @@ -2076,5 +2107,3 @@ static void Load_VEHS(void) const ChunkHandler _veh_chunk_handlers[] = { { 'VEHS', Save_VEHS, Load_VEHS, CH_SPARSE_ARRAY | CH_LAST}, }; - - |