diff options
author | tron <tron@openttd.org> | 2006-03-08 07:48:56 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-03-08 07:48:56 +0000 |
commit | ecabf8a5f0b39626efef5c720f302a3169c8cdab (patch) | |
tree | f7e5f43e03b4cc5ea6f80ee95a7e5827601efcbf /aircraft_cmd.c | |
parent | fbe939b31f8c7ea4e6e47d6d903625dd25c5e856 (diff) | |
download | openttd-ecabf8a5f0b39626efef5c720f302a3169c8cdab.tar.xz |
(svn r3784) Add a type and functions to handle direction changes
Diffstat (limited to 'aircraft_cmd.c')
-rw-r--r-- | aircraft_cmd.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c index f74d92ec2..ba1c9ee2b 100644 --- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -764,7 +764,7 @@ static bool AircraftController(Vehicle *v) Station *st; const AirportMovingData *amd; Vehicle *u; - byte z,dirdiff,newdir,maxz,curz; + byte z,newdir,maxz,curz; GetNewVehiclePosResult gp; uint dist; int x,y; @@ -853,20 +853,22 @@ static bool AircraftController(Vehicle *v) // At final pos? if (dist == 0) { + DirDiff dirdiff; + if (v->cur_speed > 12) v->cur_speed = 12; // Change direction smoothly to final direction. - dirdiff = amd->direction - v->direction; + dirdiff = DirDifference(amd->direction, v->direction); // if distance is 0, and plane points in right direction, no point in calling // UpdateAircraftSpeed(). So do it only afterwards - if (dirdiff == 0) { + if (dirdiff == DIRDIFF_SAME) { v->cur_speed = 0; return true; } if (!UpdateAircraftSpeed(v)) return false; - v->direction = (v->direction+((dirdiff&7)<5?1:-1)) & 7; + v->direction = ChangeDir(v->direction, dirdiff > DIRDIFF_REVERSE ? DIRDIFF_45LEFT : DIRDIFF_45RIGHT); v->cur_speed >>= 1; SetAircraftPosition(v, v->x_pos, v->y_pos, v->z_pos); |