Changeset - r23318:36431520b7ca
[Not reviewed]
master
0 2 0
PeterN - 6 years ago 2019-02-15 18:43:33
peter@fuzzle.org
Change: Use selected group as parent when creating a new group. (#7224)
2 files changed with 17 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/group_cmd.cpp
Show inline comments
 
@@ -311,7 +311,7 @@ Group::~Group()
 
 * @param tile unused
 
 * @param flags type of operation
 
 * @param p1   vehicle type
 
 * @param p2   unused
 
 * @param p2   parent groupid
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
@@ -322,15 +322,27 @@ CommandCost CmdCreateGroup(TileIndex til
 

	
 
	if (!Group::CanAllocateItem()) return CMD_ERROR;
 

	
 
	const Group *pg = Group::GetIfValid(GB(p2, 0, 16));
 
	if (pg != NULL) {
 
		if (pg->owner != _current_company) return CMD_ERROR;
 
		if (pg->vehicle_type != vt) return CMD_ERROR;
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		Group *g = new Group(_current_company);
 
		g->replace_protection = false;
 
		g->vehicle_type = vt;
 
		g->parent = INVALID_GROUP;
 

	
 
		const Company *c = Company::Get(_current_company);
 
		g->livery.colour1 = c->livery[LS_DEFAULT].colour1;
 
		g->livery.colour2 = c->livery[LS_DEFAULT].colour2;
 
		if (pg == NULL) {
 
			const Company *c = Company::Get(_current_company);
 
			g->livery.colour1 = c->livery[LS_DEFAULT].colour1;
 
			g->livery.colour2 = c->livery[LS_DEFAULT].colour2;
 
		} else {
 
			g->parent = pg->index;
 
			g->livery.colour1 = pg->livery.colour1;
 
			g->livery.colour2 = pg->livery.colour2;
 
		}
 

	
 
		_new_group_id = g->index;
 

	
src/group_gui.cpp
Show inline comments
 
@@ -687,7 +687,7 @@ public:
 
			}
 

	
 
			case WID_GL_CREATE_GROUP: { // Create a new group
 
				DoCommandP(0, this->vli.vtype, 0, CMD_CREATE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_CREATE), CcCreateGroup);
 
				DoCommandP(0, this->vli.vtype, this->vli.index, CMD_CREATE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_CREATE), CcCreateGroup);
 
				break;
 
			}
 

	
0 comments (0 inline, 0 general)