Changeset - r21054:4d49b7f1aef2
[Not reviewed]
master
0 1 0
rubidium - 11 years ago 2013-11-28 19:37:24
rubidium@openttd.org
(svn r26134) -Fix [FS#5820]: aircraft crashing near the map's border due to a lack of airports could trigger an assertion in most builds
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/aircraft_cmd.cpp
Show inline comments
 
@@ -1011,49 +1011,49 @@ static bool AircraftController(Aircraft 
 
				z--;
 
			} else if (z < curz) {
 
				z++;
 
			}
 

	
 
		}
 

	
 
		SetAircraftPosition(v, gp.x, gp.y, z);
 
	} while (--count != 0);
 
	return false;
 
}
 

	
 
/**
 
 * Handle crashed aircraft \a v.
 
 * @param v Crashed aircraft.
 
 */
 
static bool HandleCrashedAircraft(Aircraft *v)
 
{
 
	v->crashed_counter += 3;
 

	
 
	Station *st = GetTargetAirportIfValid(v);
 

	
 
	/* make aircraft crash down to the ground */
 
	if (v->crashed_counter < 500 && st == NULL && ((v->crashed_counter % 3) == 0) ) {
 
		int z = GetSlopePixelZ(v->x_pos, v->y_pos);
 
		int z = GetSlopePixelZ(Clamp(v->x_pos, 0, MapMaxX() * TILE_SIZE), Clamp(v->y_pos, 0, MapMaxY() * TILE_SIZE));
 
		v->z_pos -= 1;
 
		if (v->z_pos == z) {
 
			v->crashed_counter = 500;
 
			v->z_pos++;
 
		}
 
	}
 

	
 
	if (v->crashed_counter < 650) {
 
		uint32 r;
 
		if (Chance16R(1, 32, r)) {
 
			static const DirDiff delta[] = {
 
				DIRDIFF_45LEFT, DIRDIFF_SAME, DIRDIFF_SAME, DIRDIFF_45RIGHT
 
			};
 

	
 
			v->direction = ChangeDir(v->direction, delta[GB(r, 16, 2)]);
 
			SetAircraftPosition(v, v->x_pos, v->y_pos, v->z_pos);
 
			r = Random();
 
			CreateEffectVehicleRel(v,
 
				GB(r, 0, 4) - 4,
 
				GB(r, 4, 4) - 4,
 
				GB(r, 8, 4),
 
				EV_EXPLOSION_SMALL);
 
		}
 
	} else if (v->crashed_counter >= 10000) {
0 comments (0 inline, 0 general)