summaryrefslogtreecommitdiff
path: root/src/group_cmd.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2019-03-29 23:24:40 +0000
committerMichael Lutz <michi@icosahedron.de>2021-04-22 22:57:00 +0200
commit27a956ba6204e400e82fe10056bf730f286b23fe (patch)
tree7009ae20df0ecf558696f420e0ee6124774a5ba6 /src/group_cmd.cpp
parent37222c3fa2f558df5f7ef420ad583ba403ceda62 (diff)
downloadopenttd-27a956ba6204e400e82fe10056bf730f286b23fe.tar.xz
Codechange: Replace Group::replace_protection with Group::flags
Diffstat (limited to 'src/group_cmd.cpp')
-rw-r--r--src/group_cmd.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp
index bf25dae86..219470c20 100644
--- a/src/group_cmd.cpp
+++ b/src/group_cmd.cpp
@@ -315,7 +315,7 @@ CommandCost CmdCreateGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (flags & DC_EXEC) {
Group *g = new Group(_current_company);
- g->replace_protection = false;
+ ClrBit(g->flags, GroupFlags::GF_REPLACE_PROTECTION);
g->vehicle_type = vt;
g->parent = INVALID_GROUP;
@@ -668,12 +668,18 @@ CommandCost CmdSetGroupLivery(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
* @param g initial group.
* @param protect 1 to set or 0 to clear protection.
*/
-static void SetGroupReplaceProtection(Group *g, bool protect)
+static void SetGroupReplaceProtection(Group *g, bool protect, bool children)
{
- g->replace_protection = protect;
+ if (protect) {
+ SetBit(g->flags, GroupFlags::GF_REPLACE_PROTECTION);
+ } else {
+ ClrBit(g->flags, GroupFlags::GF_REPLACE_PROTECTION);
+ }
+
+ if (!children) return;
for (Group *pg : Group::Iterate()) {
- if (pg->parent == g->index) SetGroupReplaceProtection(pg, protect);
+ if (pg->parent == g->index) SetGroupReplaceProtection(pg, protect, true);
}
}
@@ -695,11 +701,7 @@ CommandCost CmdSetGroupReplaceProtection(TileIndex tile, DoCommandFlag flags, ui
if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
if (flags & DC_EXEC) {
- if (HasBit(p2, 1)) {
- SetGroupReplaceProtection(g, HasBit(p2, 0));
- } else {
- g->replace_protection = HasBit(p2, 0);
- }
+ SetGroupReplaceProtection(g, HasBit(p2, 0), HasBit(p2, 1));
SetWindowDirty(GetWindowClassForVehicleType(g->vehicle_type), VehicleListIdentifier(VL_GROUP_LIST, g->vehicle_type, _current_company).Pack());
InvalidateWindowData(WC_REPLACE_VEHICLE, g->vehicle_type);