summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2008-01-16 01:27:24 +0000
committerbjarni <bjarni@openttd.org>2008-01-16 01:27:24 +0000
commit48c2669185f467dcfccafa704890431278efb052 (patch)
tree6c5a5243498379b394b19b373c516e012b67aab8
parent61e40b1aa5f1b7137d0fc56d42c8221d9146e40a (diff)
downloadopenttd-48c2669185f467dcfccafa704890431278efb052.tar.xz
(svn r11872) -Fix (r9874): EngineHasReplacementForPlayer() didn't look in ALL_GROUP
-rw-r--r--src/engine.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index 94574b492..90fd63f77 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -507,6 +507,10 @@ void RemoveAllEngineReplacement(EngineRenewList *erl)
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group)
{
const EngineRenew *er = GetEngineReplacement(erl, engine, group);
+ if (er == NULL && (group == DEFAULT_GROUP || (IsValidGroupID(group) && !GetGroup(group)->replace_protection))) {
+ /* We didn't find anything useful in the vehicle's own group so we will try ALL_GROUP */
+ er = GetEngineReplacement(erl, engine, ALL_GROUP);
+ }
return er == NULL ? INVALID_ENGINE : er->to;
}