diff options
author | frosch <frosch@openttd.org> | 2010-05-03 19:55:03 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-05-03 19:55:03 +0000 |
commit | fc646a16a4326be420523e15f664c1bcd1b30a93 (patch) | |
tree | b3743f11060b5cbb8e0081194c5290c78dd397bc /src | |
parent | 809dd8a54c3252ad5d9d35b07a6c236b80f59c90 (diff) | |
download | openttd-fc646a16a4326be420523e15f664c1bcd1b30a93.tar.xz |
(svn r19755) -Fix: Blocked roadvehicles should first check whether they are still blocked before accelerating again, instead of continuous starting/stopping.
Diffstat (limited to 'src')
-rw-r--r-- | src/roadveh_cmd.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index cdf300248..7c234cc14 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -1598,13 +1598,18 @@ static bool RoadVehController(RoadVehicle *v) int j = RoadVehAccelerate(v); int adv_spd = (v->direction & 1) ? 192 : 256; + bool blocked = false; while (j >= adv_spd) { j -= adv_spd; RoadVehicle *u = v; for (RoadVehicle *prev = NULL; u != NULL; prev = u, u = u->Next()) { - if (!IndividualRoadVehicleController(u, prev)) break; + if (!IndividualRoadVehicleController(u, prev)) { + blocked = true; + break; + } } + if (blocked) break; /* 192 spd used for going straight, 256 for going diagonally. */ adv_spd = (v->direction & 1) ? 192 : 256; @@ -1619,7 +1624,10 @@ static bool RoadVehController(RoadVehicle *v) u->UpdateViewport(false, false); } - if (v->progress == 0) v->progress = j; + /* If movement is blocked, set 'progress' to its maximum, so the roadvehicle does + * not accelerate again before it can actually move. I.e. make sure it tries to advance again + * on next tick to discover whether it is still blocked. */ + if (v->progress == 0) v->progress = blocked ? adv_spd - 1 : j; return true; } |