mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r3786) More work for DirDiff
This commit is contained in:
parent
8b447de24c
commit
03536a32a1
|
@ -947,9 +947,6 @@ static bool AircraftController(Vehicle *v)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const int8 _crashed_aircraft_moddir[4] = {
|
|
||||||
-1,0,0,1
|
|
||||||
};
|
|
||||||
|
|
||||||
static void HandleCrashedAircraft(Vehicle *v)
|
static void HandleCrashedAircraft(Vehicle *v)
|
||||||
{
|
{
|
||||||
|
@ -973,7 +970,11 @@ static void HandleCrashedAircraft(Vehicle *v)
|
||||||
|
|
||||||
if (v->u.air.crashed_counter < 650) {
|
if (v->u.air.crashed_counter < 650) {
|
||||||
if (CHANCE16R(1,32,r)) {
|
if (CHANCE16R(1,32,r)) {
|
||||||
v->direction = (v->direction + _crashed_aircraft_moddir[GB(r, 16, 2)]) & 7;
|
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);
|
SetAircraftPosition(v, v->x_pos, v->y_pos, v->z_pos);
|
||||||
r = Random();
|
r = Random();
|
||||||
CreateEffectVehicleRel(v,
|
CreateEffectVehicleRel(v,
|
||||||
|
|
|
@ -665,7 +665,7 @@ static void DisasterTick_5_and_6(Vehicle *v)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
v->direction = (v->direction + (GB(Random(), 0, 1) ? 2 : -2)) & 7;
|
v->direction = ChangeDir(v->direction, GB(Random(), 0, 1) ? DIRDIFF_90RIGHT : DIRDIFF_90LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -494,9 +494,13 @@ static byte SetRoadVehPosition(Vehicle *v, int x, int y)
|
||||||
|
|
||||||
static void RoadVehSetRandomDirection(Vehicle *v)
|
static void RoadVehSetRandomDirection(Vehicle *v)
|
||||||
{
|
{
|
||||||
static const int8 _turn_prob[4] = { -1, 0, 0, 1 };
|
static const DirDiff delta[] = {
|
||||||
|
DIRDIFF_45LEFT, DIRDIFF_SAME, DIRDIFF_SAME, DIRDIFF_45RIGHT
|
||||||
|
};
|
||||||
|
|
||||||
uint32 r = Random();
|
uint32 r = Random();
|
||||||
v->direction = (v->direction + _turn_prob[r & 3]) & 7;
|
|
||||||
|
v->direction = ChangeDir(v->direction, delta[r & 3]);
|
||||||
BeginVehicleMove(v);
|
BeginVehicleMove(v);
|
||||||
UpdateRoadVehDeltaXY(v);
|
UpdateRoadVehDeltaXY(v);
|
||||||
v->cur_image = GetRoadVehImage(v, v->direction);
|
v->cur_image = GetRoadVehImage(v, v->direction);
|
||||||
|
|
|
@ -3015,12 +3015,15 @@ static void DeleteLastWagon(Vehicle *v)
|
||||||
|
|
||||||
static void ChangeTrainDirRandomly(Vehicle *v)
|
static void ChangeTrainDirRandomly(Vehicle *v)
|
||||||
{
|
{
|
||||||
static const int8 _random_dir_change[4] = { -1, 0, 0, 1 };
|
static const DirDiff delta[] = {
|
||||||
|
DIRDIFF_45LEFT, DIRDIFF_SAME, DIRDIFF_SAME, DIRDIFF_45RIGHT
|
||||||
|
};
|
||||||
|
|
||||||
do {
|
do {
|
||||||
//I need to buffer the train direction
|
//I need to buffer the train direction
|
||||||
if (!(v->u.rail.track & 0x40))
|
if (!(v->u.rail.track & 0x40)) {
|
||||||
v->direction = (v->direction + _random_dir_change[GB(Random(), 0, 2)]) & 7;
|
v->direction = ChangeDir(v->direction, delta[GB(Random(), 0, 2)]);
|
||||||
|
}
|
||||||
if (!(v->vehstatus & VS_HIDDEN)) {
|
if (!(v->vehstatus & VS_HIDDEN)) {
|
||||||
BeginVehicleMove(v);
|
BeginVehicleMove(v);
|
||||||
UpdateTrainDeltaXY(v, v->direction);
|
UpdateTrainDeltaXY(v, v->direction);
|
||||||
|
|
Loading…
Reference in New Issue