summaryrefslogtreecommitdiff
path: root/src/autoreplace_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-07-14 23:10:27 +0000
committerrubidium <rubidium@openttd.org>2007-07-14 23:10:27 +0000
commit7aec26887cfc0f40c54a147d566b737cdbbf9451 (patch)
tree8e0bc57b2b06b68cd87f0cd9d2168ec3eb7ed227 /src/autoreplace_cmd.cpp
parent197245eefe096da8008ce8d4772ab51fd2fb5cf4 (diff)
downloadopenttd-7aec26887cfc0f40c54a147d566b737cdbbf9451.tar.xz
(svn r10567) -Add [FS#915]: a "group" with ungrouped vehicles. Patch by Matthias Wolf.
Diffstat (limited to 'src/autoreplace_cmd.cpp')
-rw-r--r--src/autoreplace_cmd.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index ede105d9f..0b9552d62 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -138,11 +138,11 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
* If not, chek if an global auto replacement is defined */
new_engine_type = (IsValidGroupID(old_v->group_id) && GetGroup(old_v->group_id)->replace_protection) ?
INVALID_ENGINE :
- EngineReplacementForPlayer(p, old_v->engine_type, DEFAULT_GROUP);
+ EngineReplacementForPlayer(p, old_v->engine_type, ALL_GROUP);
/* If we don't set new_egnine_type previously, we try to check if an autoreplacement was defined
* for the group and the engine_type of the vehicle */
- if (new_engine_type == INVALID_ENGINE && !IsDefaultGroupID(old_v->group_id)) {
+ if (new_engine_type == INVALID_ENGINE && !IsAllGroupID(old_v->group_id)) {
new_engine_type = EngineReplacementForPlayer(p, old_v->engine_type, old_v->group_id);
}
@@ -346,10 +346,15 @@ CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs)
if (IsValidGroupID(w->group_id)) {
if (!EngineHasReplacementForPlayer(p, w->engine_type, w->group_id) && (
GetGroup(w->group_id)->replace_protection ||
- !EngineHasReplacementForPlayer(p, w->engine_type, DEFAULT_GROUP))) {
+ !EngineHasReplacementForPlayer(p, w->engine_type, ALL_GROUP))) {
continue;
}
- } else if (!EngineHasReplacementForPlayer(p, w->engine_type, DEFAULT_GROUP)) {
+ } else if (IsDefaultGroupID(w->group_id)) {
+ if (!EngineHasReplacementForPlayer(p, w->engine_type, DEFAULT_GROUP) &&
+ !EngineHasReplacementForPlayer(p, w->engine_type, ALL_GROUP)) {
+ continue;
+ }
+ } else if (!EngineHasReplacementForPlayer(p, w->engine_type, ALL_GROUP)) {
continue;
}
}