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
commit13692798e65b9627ebc5c6eabdcafdfa48660080 (patch)
tree8e0bc57b2b06b68cd87f0cd9d2168ec3eb7ed227 /src/autoreplace_cmd.cpp
parentc598d1b446ba8902d7070f7d7ba137fc8edf2e96 (diff)
downloadopenttd-13692798e65b9627ebc5c6eabdcafdfa48660080.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;
}
}