summaryrefslogtreecommitdiff
path: root/train_cmd.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-08 08:16:31 +0000
committertron <tron@openttd.org>2006-03-08 08:16:31 +0000
commit03536a32a189918713ec808bf270d4ad853a7a38 (patch)
treed22cc6ddd9856b7d1f71491480efca03c24ec3c9 /train_cmd.c
parent8b447de24c0f65dabb9fc9ea710f6f567303f40f (diff)
downloadopenttd-03536a32a189918713ec808bf270d4ad853a7a38.tar.xz
(svn r3786) More work for DirDiff
Diffstat (limited to 'train_cmd.c')
-rw-r--r--train_cmd.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/train_cmd.c b/train_cmd.c
index 960af695a..88e8881d2 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -3015,12 +3015,15 @@ static void DeleteLastWagon(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 {
//I need to buffer the train direction
- if (!(v->u.rail.track & 0x40))
- v->direction = (v->direction + _random_dir_change[GB(Random(), 0, 2)]) & 7;
+ if (!(v->u.rail.track & 0x40)) {
+ v->direction = ChangeDir(v->direction, delta[GB(Random(), 0, 2)]);
+ }
if (!(v->vehstatus & VS_HIDDEN)) {
BeginVehicleMove(v);
UpdateTrainDeltaXY(v, v->direction);