From 333b472dafccca915f6b8fbc0dace6220b13a808 Mon Sep 17 00:00:00 2001
From: Monsterovich <monsterovich@gmail.com>
Date: Tue, 12 Mar 2024 05:17:34 +0200
Subject: [PATCH] Get rid of fallbackGroup

---
 src/basedef.h     | 1 -
 src/cmddroid.cpp  | 7 ++-----
 src/structure.cpp | 7 +------
 3 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/src/basedef.h b/src/basedef.h
index b780c948022..85151f81e3d 100644
--- a/src/basedef.h
+++ b/src/basedef.h
@@ -96,7 +96,6 @@ struct BASE_OBJECT : public SIMPLE_OBJECT
 	SCREEN_DISP_DATA    sDisplay;                   ///< screen coordinate details
 	UBYTE               group = 0;                  ///< Which group selection is the droid currently in?
 	UBYTE               repairGroup = UBYTE_MAX;    ///< Group to be set when the unit has been repaired
-	UBYTE               fallbackGroup = UBYTE_MAX;  ///< Group to revert if the commander capacity is full
 	UBYTE               selected;                   ///< Whether the object is selected (might want this elsewhere)
 	UBYTE               visible[MAX_PLAYERS];       ///< Whether object is visible to specific player
 	UBYTE               seenThisTick[MAX_PLAYERS];  ///< Whether object has been seen this tick by the specific player.
diff --git a/src/cmddroid.cpp b/src/cmddroid.cpp
index f2873227449..282b9ffdfcd 100644
--- a/src/cmddroid.cpp
+++ b/src/cmddroid.cpp
@@ -91,8 +91,6 @@ bool cmdDroidAddDroid(DROID *psCommander, DROID *psDroid)
 
 	auto initialDroidGroup = psDroid->group;
 	auto initialRepairDroidGroup = psDroid->repairGroup;
-	// select a value depending on whether the commander was assigned manually or after construction in the factory
-	auto fallbackDroidGroup = initialDroidGroup != UBYTE_MAX ? initialDroidGroup : psDroid->fallbackGroup;
 
 	if (psCommander->psGroup == nullptr)
 	{
@@ -127,10 +125,9 @@ bool cmdDroidAddDroid(DROID *psCommander, DROID *psDroid)
 			lastMaxCmdLimitMsgTime = gameTime;
 		}
 
-		if (fallbackDroidGroup != UBYTE_MAX)
+		if (initialDroidGroup != UBYTE_MAX)
 		{
-			psDroid->group = fallbackDroidGroup;
-			psDroid->fallbackGroup = UBYTE_MAX;
+			psDroid->group = initialDroidGroup;
 			SelectGroupDroid(psDroid);
 		}
 		psDroid->repairGroup = initialRepairDroidGroup;
diff --git a/src/structure.cpp b/src/structure.cpp
index 21ee968f1a0..bac124d89c5 100644
--- a/src/structure.cpp
+++ b/src/structure.cpp
@@ -2478,19 +2478,14 @@ static bool structPlaceDroid(STRUCTURE *psStructure, DROID_TEMPLATE *psTempl, DR
 		psFact = &psStructure->pFunctionality->factory;
 		bool hasCommander = psFact->psCommander != nullptr && myResponsibility(psStructure->player);
 		// assign a group to the manufactured droid
-		// if a commander is assigned, ignore this behavior (except for builders)
 		if (psStructure->productToGroup != UBYTE_MAX)
 		{
+			psNewDroid->group = psStructure->productToGroup;
 			if (!hasCommander || isConstructionDroid(psNewDroid))
 			{
-				psNewDroid->group = psStructure->productToGroup;
 				intGroupsChanged(psNewDroid->group); // update groups UI
 				SelectGroupDroid(psNewDroid);
 			}
-			else
-			{
-				psNewDroid->fallbackGroup = psStructure->productToGroup;
-			}
 		}
 		setFactorySecondaryState(psNewDroid, psStructure);
 		const auto mapCoord = map_coord({x, y});