Skip to content

Commit

Permalink
(svn r18940) -Feature: make the crash position of aircraft a bit rand…
Browse files Browse the repository at this point in the history
…om by giving aircraft a chance to crash every tick they're breaking.

Slow aircraft will crash a bit less, fast aircraft might crash a bit more
  • Loading branch information
Yexo committed Jan 28, 2010
1 parent d437677 commit da3ff51
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/aircraft_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,9 @@ static byte AircraftGetEntryPoint(const Aircraft *v, const AirportFTAClass *apc)
return apc->entry_points[dir];
}


static void MaybeCrashAirplane(Aircraft *v);

/**
* Controls the movement of an aircraft. This function actually moves the vehicle
* on the map and takes care of minor things like sound playback.
Expand Down Expand Up @@ -967,6 +970,11 @@ static bool AircraftController(Aircraft *v)
return false;
}

if (amd->flag & AMED_BRAKE && v->cur_speed > SPEED_LIMIT_TAXI * _settings_game.vehicle.plane_speed) {
MaybeCrashAirplane(v);
if ((v->vehstatus & VS_CRASHED) != 0) return false;
}

uint speed_limit = SPEED_LIMIT_TAXI;
bool hard_limit = true;

Expand Down Expand Up @@ -1293,7 +1301,7 @@ static void MaybeCrashAirplane(Aircraft *v)
prob = 0x10000 / 20;
}

if (GB(Random(), 0, 16) > prob) return;
if (GB(Random(), 0, 22) > prob) return;

/* Crash the airplane. Remove all goods stored at the station. */
for (CargoID i = 0; i < NUM_CARGO; i++) {
Expand Down Expand Up @@ -1336,7 +1344,6 @@ static void AircraftLandAirplane(Aircraft *v)
if (!PlayVehicleSound(v, VSE_TOUCHDOWN)) {
SndPlayVehicleFx(SND_17_SKID_PLANE, v);
}
MaybeCrashAirplane(v);
}


Expand Down

0 comments on commit da3ff51

Please sign in to comment.