(svn r27090) -Codechange [FS#5976]: Simplify some hierarchical groups code. (Juanjo)
This commit is contained in:
@@ -404,11 +404,7 @@ CommandCost CmdAlterGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||||||
|
|
||||||
/* Ensure request parent isn't child of group.
|
/* Ensure request parent isn't child of group.
|
||||||
* This is the only place that infinite loops are prevented. */
|
* This is the only place that infinite loops are prevented. */
|
||||||
const Group *looptest = pg;
|
if (GroupIsInGroup(pg->index, g->index)) return CMD_ERROR;
|
||||||
while (looptest->parent != INVALID_GROUP) {
|
|
||||||
if (looptest->parent == g->index) return CMD_ERROR;
|
|
||||||
looptest = Group::Get(looptest->parent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
@@ -688,7 +684,7 @@ void UpdateTrainGroupID(Train *v)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of engines with EngineID id_e in the group with GroupID
|
* Get the number of engines with EngineID id_e in the group with GroupID
|
||||||
* id_g
|
* id_g and its sub-groups.
|
||||||
* @param company The company the group belongs to
|
* @param company The company the group belongs to
|
||||||
* @param id_g The GroupID of the group used
|
* @param id_g The GroupID of the group used
|
||||||
* @param id_e The EngineID of the engine to count
|
* @param id_e The EngineID of the engine to count
|
||||||
@@ -723,10 +719,7 @@ void RemoveAllGroupsForCompany(const CompanyID company)
|
|||||||
*/
|
*/
|
||||||
bool GroupIsInGroup(GroupID search, GroupID group)
|
bool GroupIsInGroup(GroupID search, GroupID group)
|
||||||
{
|
{
|
||||||
if (search == NEW_GROUP ||
|
if (!Group::IsValidID(search)) return search == group;
|
||||||
search == ALL_GROUP ||
|
|
||||||
search == DEFAULT_GROUP ||
|
|
||||||
search == INVALID_GROUP) return search == group;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (search == group) return true;
|
if (search == group) return true;
|
||||||
|
Reference in New Issue
Block a user