Merge branch 'master' into jgrpp
# Conflicts: # CMakeLists.txt # COMPILING.md # src/console.cpp # src/console_cmds.cpp # src/console_internal.h # src/rev.cpp.in
This commit is contained in:
@@ -324,7 +324,6 @@ CommandCost CmdCreateGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
Group *g = new Group(_current_company);
|
||||
g->replace_protection = false;
|
||||
g->vehicle_type = vt;
|
||||
g->parent = INVALID_GROUP;
|
||||
|
||||
@@ -332,10 +331,12 @@ CommandCost CmdCreateGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
const Company *c = Company::Get(_current_company);
|
||||
g->livery.colour1 = c->livery[LS_DEFAULT].colour1;
|
||||
g->livery.colour2 = c->livery[LS_DEFAULT].colour2;
|
||||
if (c->settings.renew_keep_length) SetBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL);
|
||||
} else {
|
||||
g->parent = pg->index;
|
||||
g->livery.colour1 = pg->livery.colour1;
|
||||
g->livery.colour2 = pg->livery.colour2;
|
||||
g->flags = pg->flags;
|
||||
}
|
||||
|
||||
_new_group_id = g->index;
|
||||
@@ -728,42 +729,50 @@ CommandCost CmdSetGroupLivery(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
|
||||
}
|
||||
|
||||
/**
|
||||
* Set replace protection for a group and its sub-groups.
|
||||
* Set group flag for a group and its sub-groups.
|
||||
* @param g initial group.
|
||||
* @param protect 1 to set or 0 to clear protection.
|
||||
* @param set 1 to set or 0 to clear protection.
|
||||
*/
|
||||
static void SetGroupReplaceProtection(Group *g, bool protect)
|
||||
static void SetGroupFlag(Group *g, GroupFlags flag, bool set, bool children)
|
||||
{
|
||||
g->replace_protection = protect;
|
||||
if (set) {
|
||||
SetBit(g->flags, flag);
|
||||
} else {
|
||||
ClrBit(g->flags, flag);
|
||||
}
|
||||
|
||||
if (!children) return;
|
||||
|
||||
for (Group *pg : Group::Iterate()) {
|
||||
if (pg->parent == g->index) SetGroupReplaceProtection(pg, protect);
|
||||
if (pg->parent == g->index) SetGroupFlag(pg, flag, set, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (Un)set global replace protection from a group
|
||||
* (Un)set group flag from a group
|
||||
* @param tile unused
|
||||
* @param flags type of operation
|
||||
* @param p1 index of group array
|
||||
* - p1 bit 0-15 : GroupID
|
||||
* - p1 bit 0-15 : GroupID
|
||||
* - p1 bit 16-18 : Flag to set, by value not bit.
|
||||
* @param p2
|
||||
* - p2 bit 0 : 1 to set or 0 to clear protection.
|
||||
* - p2 bit 1 : 1 to apply to sub-groups.
|
||||
* @param text unused
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSetGroupReplaceProtection(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
CommandCost CmdSetGroupFlag(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
Group *g = Group::GetIfValid(p1);
|
||||
Group *g = Group::GetIfValid(GB(p1, 0, 16));
|
||||
if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
|
||||
|
||||
/* GroupFlags are stored in as an 8 bit bitfield but passed here by value,
|
||||
* so 3 bits is sufficient to cover each possible value. */
|
||||
GroupFlags flag = (GroupFlags)GB(p1, 16, 3);
|
||||
if (flag >= GroupFlags::GF_END) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (HasBit(p2, 1)) {
|
||||
SetGroupReplaceProtection(g, HasBit(p2, 0));
|
||||
} else {
|
||||
g->replace_protection = HasBit(p2, 0);
|
||||
}
|
||||
SetGroupFlag(g, flag, 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);
|
||||
|
Reference in New Issue
Block a user