From 30dd938b4ea34774f30bf0697962bade5ed9a75a Mon Sep 17 00:00:00 2001
From: Blank_Alt <12406-Blank_Alt@users.noreply.gitgud.io>
Date: Wed, 9 Sep 2020 01:08:15 -0700
Subject: [PATCH] SecExp-Fixes-QOL 1/2

---
 src/002-config/fc-version.js                  |   4 +-
 src/Mods/SecExp/attackOptions.tw              |   8 +-
 src/Mods/SecExp/buildings/secBarracks.tw      |  36 +++-
 .../SecExp/buildings/weaponsManufacturing.tw  |  27 ++-
 src/Mods/SecExp/js/Unit.js                    | 196 ++++++------------
 src/Mods/SecExp/js/secExp.js                  |   7 +-
 src/Mods/SecExp/js/secExpBC.js                |   7 +-
 src/Mods/SecExp/potentialToDo.txt             |   4 +-
 src/Mods/SecExp/securityReport.tw             |   8 +-
 src/Mods/SpecialForce/Firebase.tw             |   6 -
 src/gui/quicklinks.js                         |   2 +-
 11 files changed, 136 insertions(+), 169 deletions(-)

diff --git a/src/002-config/fc-version.js b/src/002-config/fc-version.js
index 42122a71276..b608daf8d56 100644
--- a/src/002-config/fc-version.js
+++ b/src/002-config/fc-version.js
@@ -2,5 +2,5 @@ App.Version = {
 	base: "0.10.7.1", // The vanilla version the mod is based off of, this should never be changed.
 	pmod: "3.7.1",
 	commitHash: null,
-	release: 1096
-};
+	release: 1097
+};
\ No newline at end of file
diff --git a/src/Mods/SecExp/attackOptions.tw b/src/Mods/SecExp/attackOptions.tw
index f8620b33d0e..a00ba603a4d 100644
--- a/src/Mods/SecExp/attackOptions.tw
+++ b/src/Mods/SecExp/attackOptions.tw
@@ -410,7 +410,7 @@ approximately <strong><<print _estimatedMen>> men</strong> are coming, they seem
 <<run App.UI.tabBar.handlePreSelectedTab($tabChoice.Options)>>
 
 <<if App.SecExp.battle.deployableUnits() === 0>> <strong>Unit roster full.</strong> <</if>>
-<br> <<includeDOM App.SecExp.deployUnitMenu($secBots)>>
+<br> <<includeDOM App.SecExp.deployUnitMenu($secBots, "bots")>>
 <<if $militiaUnits.length > 0>>
 	<button class="tab-links" onclick="App.UI.tabBar.openTab(event, 'militia')" id="tab militia">Militia: ($militiaUnits.length)</button>
 <</if>>
@@ -424,21 +424,21 @@ approximately <strong><<print _estimatedMen>> men</strong> are coming, they seem
 <div id="militia" class="tab-content">
 	<div class="content">
 		<<for _i = 0; _i < _mL; _i++>>
-			<<includeDOM App.SecExp.deployUnitMenu($militiaUnits[_i], _i)>>
+			<<includeDOM App.SecExp.deployUnitMenu($militiaUnits[_i], "militia", _i)>>
 		<</for>>
 	</div>
 </div>
 <div id="slaves" class="tab-content">
 	<div class="content">
 		<<for _i = 0; _i < _sL; _i++>>
-			<<includeDOM App.SecExp.deployUnitMenu($slaveUnits[_i], _i)>>
+			<<includeDOM App.SecExp.deployUnitMenu($slaveUnits[_i], "slaves", _i)>>
 		<</for>>
 	</div>
 </div>
 <div id="mercs" class="tab-content">
 	<div class="content">
 		<<for _i = 0; _i < _meL; _i++>>
-			<<includeDOM App.SecExp.deployUnitMenu($mercUnits[_i], _i)>>
+			<<includeDOM App.SecExp.deployUnitMenu($mercUnits[_i], "mercs", _i)>>
 		<</for>>
 	</div>
 </div>
\ No newline at end of file
diff --git a/src/Mods/SecExp/buildings/secBarracks.tw b/src/Mods/SecExp/buildings/secBarracks.tw
index a561c8ddbf4..391bb50d16c 100644
--- a/src/Mods/SecExp/buildings/secBarracks.tw
+++ b/src/Mods/SecExp/buildings/secBarracks.tw
@@ -51,7 +51,24 @@ While this a sore sight for many citizens of $arcologies[0].name, the barracks s
 	<</link>>
 	<br>//Costs <<print cashFormat((5000 * ($SecExp.buildings.barracks.size + 1))*$upgradeMultiplierArcology)>> and will increase the maximum number of units by 2.//
 <<else>>
-	You've expanded the barracks to their maximum.
+	<<if $SF.Toggle && $SF.Active >= 1>> 
+		<<set _reasons = [], _cost = Math.ceil((750000*(1.15+(App.SF.upgrades.total()/1000))*(1.15+($SF.Squad.Firebase/10)))*App.SF.env())>>
+		<br> <<= App.SF.Caps()>> might be able to provide assistance.
+		<<if $SF.Squad.Firebase > 5 && $SecExp.edicts.SFSupportLevel >= 4 && App.SecExp.battle.maxUnits() === 18 && App.SecExp.battle.deploySpeed() <= 10>>
+			<br><<= App.SF.Caps()>> [[will provide the security force their own section in the Firebase.|secBarracks][$sectionInFirebase = 1, cashX(-_cost, "specialForcesCap")]]
+			@@.red;<<print cashFormat(_cost)>>@@
+		<</if>>
+		<<if $SF.Squad.Firebase < 5>>
+			<<set _reasons.push('Firebase would likely require additional expansion(s)')>>
+		<</if>>
+		<<if $SecExp.edicts.SFSupportLevel < 4>>
+			<<set _reasons.push('support contract needs more clauses')>>
+		<</if>>
+		<<set _reasons.join(',')>>
+		<<if _reasons.length > 0>><br>The Colonel says that the; _reasons.<</if>>
+	<<else>>
+		You've expanded the barracks to their maximum. 
+	<</if>>
 <</if>>
 <br>
 <<if $SecExp.buildings.barracks.luxury == 0>>
@@ -173,8 +190,8 @@ Your current maximum number of units is <<print App.SecExp.battle.maxUnits()>> (
 				<</link>>
 				Utilize the technological developments made by $SF.Lower to further improve the control matrix of the security drones.
 				<br>//Costs <<print cashFormat(5000 + 10 * _secBotsUpgradeCost * $secBots.equip)>> and will increase the max by 10//
-			<<elseif $SF.Toggle && $SF.Active >= 1 && $SecExp.edicts.SFSupportLevel < 1>>
-				There's little left to improve in the matrix. However support from $SF.Lower might give some more room from improvement.
+			<<elseif $SF.Toggle && $SF.Active >= 1 && $SecExp.edicts.SFSupportLevel === 0>>
+				There's little left to improve in the matrix. However support from $SF.Lower might give some more room from improvement, if an assistance contract is signed.
 			<<else>>
 				There's little left to improve in the matrix. Your control systems are at top capacity and won't be able to handle a bigger drone unit.
 			<</if>>
@@ -203,11 +220,12 @@ Your current maximum number of units is <<print App.SecExp.battle.maxUnits()>> (
 <div id="Slaves" class="tab-content">
 	<div class="content">
 		You are free to organize your menial slaves into fighting units. Currently you have <<print num($menials)>> slaves available, while <<print num(App.SecExp.Manpower.employedSlave)>> are already employed as soldiers. During all your battles you lost a total of <<print num($slavesTotalCasualties)>>.
-		<<if $menials > 0 && App.SecExp.battle.activeUnits() < App.SecExp.battle.maxUnits()>> <br>
+		<br>Default unit name: <<textbox "$SecExp.defaultNames.slaves" $SecExp.defaultNames.slaves "secBarracks">> |
+		<<if $menials > 0 && App.SecExp.battle.activeUnits() < App.SecExp.battle.maxUnits()>>
 			<<link "Form a new unit" "secBarracks">>
 				<<set $slaveUnits.push(App.SecExp.generateUnit("slaves"))>>
-			<</link>>
-		<</if>> |
+			<</link>> |
+		<</if>>
 		<<includeDOM App.SecExp.bulkUpgradeUnit($slaveUnits)>>
 		
 		<<set _popCap = menialPopCap()>>
@@ -293,7 +311,8 @@ Your current maximum number of units is <<print App.SecExp.battle.maxUnits()>> (
 			With the adoption of a militarized society, your available manpower has swelled to be approximately 15% of the arcology's citizens population.
 		<</if>>
 		Your current total manpower is <<print num(App.SecExp.Manpower.totalMilitia)>>, of which <<print num(App.SecExp.Manpower.employedMilitia)>> is in active duty. You lost in total <<print num($militiaTotalCasualties)>> citizens, leaving you with <<print num($militiaFreeManpower)>> available citizens.
-		<<if $militiaFreeManpower > 0 && App.SecExp.battle.activeUnits() < App.SecExp.battle.maxUnits()>> <br>
+		<br>Default unit name: <<textbox "$SecExp.defaultNames.milita" $SecExp.defaultNames.milita "secBarracks">> |
+		<<if $militiaFreeManpower > 0 && App.SecExp.battle.activeUnits() < App.SecExp.battle.maxUnits()>>
 			<<link "Form a new unit" "secBarracks">>
 				<<set $militiaUnits.push(App.SecExp.generateUnit("militia"))>>
 			<</link>> |
@@ -355,7 +374,8 @@ Your current maximum number of units is <<print App.SecExp.battle.maxUnits()>> (
 	<div class="content">
 		With the installation of a mercenary company in the arcology, many other are attracted to your free city, hoping to land a contract with you.
 		You are able to organize them in units to use in the defense of the arcology. Excluding the defense force you set up, there are <<print num(App.SecExp.Manpower.totalMerc)>> mercenaries in your arcology, of which <<print num(App.SecExp.Manpower.employedMerc)>> actively employed and <<print num($mercFreeManpower)>> not yet under contract. In total <<print num($mercTotalCasualties)>> mercenaries have died defending your arcology.
-		<<if $mercFreeManpower > 0 && App.SecExp.battle.activeUnits() < App.SecExp.battle.maxUnits()>> <br>
+		<br>Default unit name: <<textbox "$SecExp.defaultNames.mercs" $SecExp.defaultNames.mercs "secBarracks">> |
+		<<if $mercFreeManpower > 0 && App.SecExp.battle.activeUnits() < App.SecExp.battle.maxUnits()>>
 			<<link "Form a new unit" "secBarracks">>
 				<<set $mercUnits.push(App.SecExp.generateUnit("mercs"))>>
 			<</link>> |
diff --git a/src/Mods/SecExp/buildings/weaponsManufacturing.tw b/src/Mods/SecExp/buildings/weaponsManufacturing.tw
index 5fb27aa14e3..540ef735116 100644
--- a/src/Mods/SecExp/buildings/weaponsManufacturing.tw
+++ b/src/Mods/SecExp/buildings/weaponsManufacturing.tw
@@ -155,11 +155,11 @@ You own <<print num($menials)>> free menial slaves. This manufacturing complex c
 	<<run delete $SecExp.buildings.weapManu.upgrades.queue>>
 <<else>>
 	<<set $SecExp.buildings.weapManu.upgrades.queue = $SecExp.buildings.weapManu.upgrades.queue || []>>
-
-	<br>Security Drones:
+	
 	<<if $SecExp.buildings.weapManu.lab < 3>>
-		Upgrade the research facility further to unlock more upgrades for the security drones.
+		<br>Upgrade the research facility further to unlock additional upgrades.
 	<</if>>
+	<br>Security Drones:
 	<<if App.SecExp.weapManuUpgrade.fully().bots>>
 		You have fully upgraded the security drones.
 	<<else>>
@@ -177,12 +177,23 @@ You own <<print num($menials)>> free menial slaves. This manufacturing complex c
 	<<if $SF.Toggle && $SF.Active >= 1 && (App.SecExp.getAppliedUpgrades('human').attack >= 4 || App.SecExp.getAppliedUpgrades('human').hp >= 4 || App.SecExp.getAppliedUpgrades('human').morale >= 40 || App.SecExp.getAppliedUpgrades('human').defense >= 4)>>
 		You have fully upgraded your human troops.
 	<<elseif App.SecExp.getAppliedUpgrades('human').attack >= 2 || App.SecExp.getAppliedUpgrades('human').hp >= 2 || App.SecExp.getAppliedUpgrades('human').morale >= 20 || App.SecExp.getAppliedUpgrades('human').defense >= 2>>
-		You have fully upgraded your human troops.
-		<<if $SF.Toggle && $SF.Active >= 1 && ($SecExp.edicts.SFSupportLevel >= 2 && $SF.Squad.Firebase >= 7 || $SecExp.edicts.SFSupportLevel >= 4 && $SF.Squad.Drugs >= 8 || $SecExp.edicts.SFSupportLevel >= 5)>>
-			With support from $SF.Lower, however, we may be able to further upgrade our troops.
+		<<if $SF.Toggle && $SF.Active >= 1>>
+			<<set _reasons = []>>
+			<<if $SF.Squad.Drugs < 8>>
+				<<set _reasons.push('drug lab needs more advanced equipement')>>
+			<</if>>
+			<<if $SecExp.edicts.SFSupportLevel < 2 || $SecExp.edicts.SFSupportLevel < 4 || $SecExp.edicts.SFSupportLevel < 5>>
+				<<set _reasons.push('support contract needs more clauses')>>
+			<</if>>
+			<<if $SF.Squad.Firebase < 7>>
+				<<set _reasons.push('Firebase would likely require additional expansion(s)')>>
+			<</if>>
+			<<set _reasons.join(',')>>
+			With support from $SF.Lower, we may be able to further upgrade our troops.
+			<<if _reasons.length > 0>><br>The Colonel says that the; _reasons.<</if>>
+		<<else>>
+			You have fully upgraded your human troops.
 		<</if>>
-	<<elseif $SecExp.buildings.weapManu.lab < 3>>
-		Upgrade the research facility further to unlock more upgrades for human troops.
 	<</if>>
 	<div> <<includeDOM App.SecExp.weapManuUpgrade.purchase(0)>> </div>
 	<div> <<includeDOM App.SecExp.weapManuUpgrade.purchase(1)>> </div>
diff --git a/src/Mods/SecExp/js/Unit.js b/src/Mods/SecExp/js/Unit.js
index f03ee4f779b..53dd19d9d25 100644
--- a/src/Mods/SecExp/js/Unit.js
+++ b/src/Mods/SecExp/js/Unit.js
@@ -2,125 +2,59 @@
  * @param {object} [unit] the unit to be checked.
  */
 App.SecExp.bulkUpgradeUnit = function(unit) {	
-	// unit.length === 'undefined' ? object : array  
-	const unitCount = typeof unit.length === 'undefined' ? 1 : unit.length;
-	console.log('unitCount', unitCount);
+	unit = Array.isArray(unit) ? unit : [unit];
+	// console.log(unit); return;
 	let el = document.createElement("a");
-	console.log('cost', getCost());
-	if (getCost() > 0) {
-		el.append(App.UI.DOM.link(`Bulk upgrade for ${cashFormat(getCost())}`, () => {
-			applyUpgrades();
-			cashX(-getCost(), "securityExpansion");
-		},
-		[], passage()
-		));
+	
+	function upgradeUnit(x) {
+		Object.assign(x, {
+			maxTroops: 50, equip: 3, commissars: 2,
+			cyber: 1, medics: 1, SF: 1
+		});
 	}
-	return el;
-
-	function getCost() {
+	
+	function getCost(x) {
 		let cost = 0;
 		const equipUpgradeCost = 250;
-		if (unitCount === 1) {
-			if (unit.maxTroops < 50) {
-				cost += 5000 + (((50 - unit.maxTroops) /10) * equipUpgradeCost * (unit.equip + unit.commissars + unit.cyber + unit.SF));
-			}
-			if (unit.equip < 3) {
-				cost += (equipUpgradeCost * unit.maxTroops + 1000) * (3 - unit.equip);
-			}
-			if (unit.commissars < 2) {
-				cost += (equipUpgradeCost * unit.maxTroops + 1000) * (2 - unit.commissars);
-			}
-			if (V.prostheticsUpgrade >= 2 || V.researchLab.advCombatPLimb === 1) {
-				if (unit.cyber === 0) {
-					cost += equipUpgradeCost * unit.maxTroops + 2000;
-				}
-			}
-			if (unit.medics === 0) {
-				cost += equipUpgradeCost * unit.maxTroops + 1000;
-			}
-			if (V.SF.Toggle && V.SF.Active >= 1 && unit.SF === 0) {
-				cost += equipUpgradeCost * unit.maxTroops + 5000;
-			}
-		} else {
-			for (let i = 0; i < unitCount; i++) {
-				if (unit[i].maxTroops < 50) {
-					cost += 5000 + (((50 - unit[i].maxTroops) /10) * equipUpgradeCost * (unit[i].equip + unit[i].commissars + unit[i].cyber + unit[i].SF));
-				}
-				if (unit[i].equip < 3) {
-					cost += (equipUpgradeCost * unit[i].maxTroops + 1000) * (3 - unit[i].equip);
-				}
-				if (unit[i].commissars < 2) {
-					cost += (equipUpgradeCost * unit[i].maxTroops + 1000) * (2 - unit[i].commissars);
-				}
-				if (V.prostheticsUpgrade >= 2 || V.researchLab.advCombatPLimb === 1) {
-					if (unit[i].cyber === 0) {
-						cost += equipUpgradeCost * unit[i].maxTroops + 2000;
-					}
-				}
-				if (unit[i].medics === 0) {
-					cost += equipUpgradeCost * unit[i].maxTroops + 1000;
-				}
-				if (V.SF.Toggle && V.SF.Active >= 1 && unit[i].SF === 0) {
-					cost += equipUpgradeCost * unit[i].maxTroops + 5000;
-				}
-			}
+		if (x.maxTroops < 50) {
+			cost += 5000 + (((50 - x.maxTroops) /10) * equipUpgradeCost * (x.equip + x.commissars + x.cyber + x.SF));
+		}
+		if (x.equip < 3) {
+			cost += (equipUpgradeCost * x.maxTroops + 1000) * (3 - x.equip);
+		}
+		if (x.commissars < 2) {
+			cost += (equipUpgradeCost * x.maxTroops + 1000) * (2 - x.commissars);
+		}
+		if ((V.prostheticsUpgrade >= 2 || V.researchLab.advCombatPLimb === 1) && x.cyber === 0) {
+			cost += equipUpgradeCost * x.maxTroops + 2000;
+		}
+		if (x.medics === 0) {
+			cost += equipUpgradeCost * x.maxTroops + 1000;
+		}
+		if (V.SF.Toggle && V.SF.Active >= 1 && x.SF === 0) {
+			cost += equipUpgradeCost * x.maxTroops + 5000;
 		}
 		return Math.ceil(cost *= 1.1);
 	}
 
-	function applyUpgrades() {
-		if (unitCount === 1) {
-			if (unit.maxTroops < 50) {
-				unit.maxTroops = 50;
-			}
-			if (unit.equip < 3) {
-				unit.equip = 3;
-			}
-			if (unit.commissars < 2) {
-				unit.commissars = 2;
-			}
-			if (V.prostheticsUpgrade >= 2 || V.researchLab.advCombatPLimb === 1) {
-				if (unit.cyber === 0) {
-					unit.cyber++;
-				}
-			}
-			if (unit.medics === 0) {
-				unit.medics++;
-			}
-			if (V.SF.Toggle && V.SF.Active >= 1 && unit.SF === 0) {
-				unit.SF++;
-			}
-		} else {
-			for (let i = 0; i < unitCount; i++) {
-				if (unit[i].maxTroops < 50) {
-					unit[i].maxTroops = 50;
-				}
-				if (unit[i].equip < 3) {
-					unit[i].equip = 3;
-				}
-				if (unit[i].commissars < 2) {
-					unit[i].commissars = 2;
-				}
-				if (V.prostheticsUpgrade >= 2 || V.researchLab.advCombatPLimb === 1) {
-					if (unit[i].cyber === 0) {
-						unit[i].cyber++;
-					}
-				}
-				if (unit[i].medics === 0) {
-					unit[i].medics++;
-				}
-				if (V.SF.Toggle && V.SF.Active >= 1 && unit[i].SF === 0) {
-					unit[i].SF++;
-				}
-			}	
+	if (unit.length > 0) {
+		const price = unit.map(getCost).reduce((acc, cur) => acc + cur);
+		if (price > 0) {
+			el.append(App.UI.DOM.link(`Bulk upgrade for ${cashFormat(price)}`, () => {
+				unit.map(upgradeUnit).reduce((acc, cur) => acc + cur);
+				cashX(-price, "securityExpansion");
+			},
+			[], passage()
+			));
 		}
 	}
-}
+	return el;
+};
 
 /** Reports changes to the supplied unit's loyalty.
  * @param {object} [input] the unit type to be checked.
  */
-App.SecExp.humanUnitLoyaltyChanges = function(input) {
+App.SecExp.humanUnitLoyaltyChanges = function(input, type) {
 	let loyaltyChange = 0, el = document.createElement("div");
 
 	el.append(`${input.platoonName}: `);
@@ -133,42 +67,42 @@ App.SecExp.humanUnitLoyaltyChanges = function(input) {
 		loyaltyChange += 2 * input.commissars;
 	}
 	if (V.SecExp.edicts.defense.soldierWages === 2) {
-		if (input.platoonName.contains('slave')) {
+		if (type === 'slave') {
 			el.append("The slaves greatly appreciate the generous wage given to them for their service as soldiers. Occasions to earn money for a slave are scarce after all.");
-		} else if (input.platoonName.contains('citizens')) {
+		} else if (type === 'citizens') {
 			el.append("The soldiers greatly appreciate the generous wage given to them for their service. They are proud to defend their homes while making a small fortune out of it.");
-		} else if (input.platoonName.contains('mercenary')) {
+		} else if (type === 'mercenary') {
 			el.append("The mercenaries greatly appreciate the generous wage given to them for their service. After all coin is the fastest way to reach their hearts.");
 		}
 		loyaltyChange += random(5, 10);
 	} else if (V.SecExp.edicts.defense.soldierWages === 1) {
-		if (input.platoonName.contains('slave')) {
+		if (type === 'slave') {
 			el.append("The slaves appreciate the wage given to them for their service as soldiers, despite it being just adequate. Occasions to earn money for a slave are scarce after all.");
-		} else if (input.platoonName.contains('citizens')) {
+		} else if (type === 'citizens') {
 			el.append("The soldiers appreciate the wage given to them for their service, despite it being just adequate. They are proud to defend their homes, though at the cost of possible financial gains.");
-		} else if (input.platoonName.contains('mercenary')) {
+		} else if (type === 'mercenary') {
 			el.append("The mercenaries do not appreciate the barely adequate wage given to them for their service. Still their professionalism keeps them determined to finish their contract.");
 		}
 		loyaltyChange += random(-5, 5);
 	} else {
-		if (input.platoonName.contains('slave')) {
+		if (type === 'slave') {
 			el.append("The slaves do not appreciate the low wage given to them for their service as soldiers, but occasions to earn money for a slave are scarce, so they're not too affected by it.");
-		} else if (input.platoonName.contains('citizens')) {
+		} else if (type === 'citizens') {
 			el.append("The soldiers do not appreciate the low wage given to them for their service. Their sense of duty keeps them proud of their role as defenders of the arcology, but many do feel its financial weight.");
-		} else if (input.platoonName.contains('mercenary')) {
+		} else if (type === 'mercenary') {
 			el.append("The mercenaries do not appreciate the low wage given to them for their service. Their skill would be better served by a better contract and this world does not lack demand for guns for hire.");
 		}
 		loyaltyChange -= random(5, 10);
 	}
-	if (input.platoonName.contains('slave') && V.SecExp.edicts.defense.privilege.slaveSoldier) {
+	if (type === 'slave' && V.SecExp.edicts.defense.privilege.slaveSoldier) {
 		el.append("Allowing them to hold material possessions earns you their devotion and loyalty.");
 		loyaltyChange += random(1, 2);
 	}
-	if (input.platoonName.contains('citizens') && V.SecExp.edicts.defense.privilege.militiaSoldier) {
+	if (type === 'citizens' && V.SecExp.edicts.defense.privilege.militiaSoldier) {
 		el.append("Allowing them to avoid rent payment for their military service earns you their happiness and loyalty.");
 		loyaltyChange += random(1, 2);
 	}
-	if (input.platoonName.contains('mercenary') && V.SecExp.edicts.defense.privilege.mercSoldier) {
+	if (type === 'mercenary' && V.SecExp.edicts.defense.privilege.mercSoldier) {
 		el.append("Allowing them to keep part of the loot gained from your enemies earns you their trust and loyalty.");
 		loyaltyChange += random(1, 2);
 	}
@@ -222,15 +156,15 @@ App.SecExp.generateUnit = function(type) {
 		});
 
 		if (type === "slaves") {
-			newUnit.platoonName = ordinalSuffix(++V.createdSlavesUnits) + " slave platoon";
+			newUnit.platoonName = `${ordinalSuffix(++V.createdSlavesUnits)} ` + V.SecExp.defaultNames[type];
 			newUnit.troops = Math.min(newUnit.maxTroops, V.menials);
 			V.menials -= newUnit.troops;
 		} else if (type === "militia") {
-			newUnit.platoonName = ordinalSuffix(++V.createdMilitiaUnits) + " citizens' platoon";
+			newUnit.platoonName = `${ordinalSuffix(++V.createdMilitiaUnits)} ` + V.SecExp.defaultNames[type];
 			newUnit.troops = Math.min(newUnit.maxTroops, V.militiaFreeManpower);
 			V.militiaFreeManpower -= newUnit.troops;
 		} else if (type === "mercs") {
-			newUnit.platoonName = ordinalSuffix(++V.createdMercUnits) + " mercenary platoon";
+			newUnit.platoonName = `${ordinalSuffix(++V.createdMercUnits)} ` + V.SecExp.defaultNames[type];
 			newUnit.troops = Math.min(newUnit.maxTroops, V.mercFreeManpower);
 			V.mercFreeManpower -= newUnit.troops;
 		}
@@ -242,17 +176,17 @@ App.SecExp.generateUnit = function(type) {
  * @param {object} [input] the unit to be checked.
  * @param {number} [count=0]
  */
-App.SecExp.deployUnitMenu = function(input, count = 0) {
+App.SecExp.deployUnitMenu = function(input, type, count = 0) {
 	let el = document.createElement("div"), options = document.createElement("div");
 
 	if (input.active === 1 && input.troops > 0) {
-		if (!jsDef(input.platoonName)) {
+		if (type === "bots") {
 			$(el).append(App.SecExp.getUnit("Bots").describe());
-		} else if (input.platoonName.contains('slave')) {
+		} else if (type === "slaves") {
 			$(el).append(App.SecExp.getUnit("Slaves", count).describe());
-		} else if (input.platoonName.contains('citizens')) {
+		} else if (type === "militia") {
 			$(el).append(App.SecExp.getUnit("Militia", count).describe());
-		} else if (input.platoonName.contains('mercenary')) {
+		} else if (type === "mercs") {
 			$(el).append(App.SecExp.getUnit("Mercs", count).describe());
 		}
 		options = document.createElement("div");
@@ -1000,7 +934,7 @@ App.SecExp.describeUnit = (function() {
 
 		if (unitType !== "Bots") {
 			r += `<br><strong>${input.platoonName}</strong>${!brief ? ``:`. `} `;
-			if (!brief) {
+			if (brief === 0) {
 				if (input.battlesFought > 1) {
 					r += `has participated in ${input.battlesFought} battles and is ready to face the enemy once more at your command. `;
 				} else if (input.battlesFought === 1) {
@@ -1021,14 +955,14 @@ App.SecExp.describeUnit = (function() {
 				r += `Battles fought: ${input.battlesFought}. `;
 			}
 		} else {
-			if (!brief) {
+			if (brief === 0) {
 				r += `<br>The drone unit is made up of ${input.troops} drones. All of which are assembled in an ordered formation in front of you, absolutely silent and ready to receive their orders.`;
 			} else {
 				r += `<br>Drone squad.`;
 			}
 		}
 
-		if (!brief) {
+		if (brief === 0) {
 			if (input.troops < input.maxTroops) {
 				r += `The unit is not at its full strength of ${input.maxTroops} operatives. `;
 			}
@@ -1036,7 +970,7 @@ App.SecExp.describeUnit = (function() {
 			r += `Unit size: ${input.troops}/${input.maxTroops}.`;
 		}
 
-		if (!brief) {
+		if (brief === 0) {
 			if (unitType !== "Bots") {
 				if (input.equip === 0) {
 					r += `They are issued with simple, yet effective equipment: firearms, a few explosives and standard uniforms, nothing more. `;
@@ -1072,7 +1006,7 @@ App.SecExp.describeUnit = (function() {
 		}
 
 		if (unitType !== "Bots") {
-			if (!brief) {
+			if (brief === 0) {
 				if (input.training <= 33) {
 					r += `They lack the experience to be considered professionals, but `;
 					if (unitType === "Militia") {
@@ -1142,7 +1076,7 @@ App.SecExp.describeUnit = (function() {
 				if (jsDef(input.medics) && input.medics > 0) {
 					r += `Medical squad attached. `;
 				}
-				if (V.SF.Toggle && V.SF.Active >= 1 && jsDef(input.SF) || input.SF > 0) {
+				if (V.SF.Toggle && V.SF.Active >= 1 && jsDef(input.SF) && input.SF > 0) {
 					r += `${App.SF.Caps()} "advisors" attached. `;
 				}
 			}
diff --git a/src/Mods/SecExp/js/secExp.js b/src/Mods/SecExp/js/secExp.js
index bef65353ff6..2756eec8496 100644
--- a/src/Mods/SecExp/js/secExp.js
+++ b/src/Mods/SecExp/js/secExp.js
@@ -144,7 +144,12 @@ App.SecExp.generalInit = function(){
 				pharaonTradition: 0,
 			}
 		},
-		smilingMan: { progress : 0 }
+		smilingMan: { progress : 0 },
+		defaultNames: {
+			slaves: "slave platoon",
+			milita: "citizens' platoon",
+			mercs: "mercenary platoon"
+		}
 	});
 
 	App.SecExp.initTrade();
diff --git a/src/Mods/SecExp/js/secExpBC.js b/src/Mods/SecExp/js/secExpBC.js
index 4c3740d976f..4cf9326b5b6 100644
--- a/src/Mods/SecExp/js/secExpBC.js
+++ b/src/Mods/SecExp/js/secExpBC.js
@@ -74,10 +74,15 @@ App.SecExp.generalBC = function() {
 		V.SecExp.edicts.defense.privilege.militiaSoldier = V.SecExp.edicts.defense.privilege.militiaSoldier || V.militiaSoldier || 0;
 		V.SecExp.edicts.defense.privilege.slaveSoldier = V.SecExp.edicts.defense.privilege.slaveSoldier || V.slaveSoldier || 0;
 		V.SecExp.edicts.defense.privilege.mercSoldier = V.SecExp.edicts.defense.privilege.mercSoldier || V.mercSoldier || 0;
+		
+		V.SecExp.defaultNames = V.SecExp.defaultNames || {};
+		V.SecExp.defaultNames.slaves = V.SecExp.defaultNames.slaves || "slave platoon";
+		V.SecExp.defaultNames.milita = V.SecExp.defaultNames.milita || "citizens' platoon";
+		V.SecExp.defaultNames.mercs = V.SecExp.defaultNames.mercs || "mercenary platoon";
 
 		// V.SecExp.units = V.SecExp.units || {};
 		Object.assign(V.secBots, {
-			active: V.secBots.active || V.arcologyUpgrade.drones > 0 ? 1 : 0,
+			active: Math.max(0, V.secBots.active) || V.arcologyUpgrade.drones > 0 ? 1 : 0,
 			ID: -1,
 			isDeployed: V.secBots.isDeployed || 0,
 			troops: Math.max(V.secBots.troops || 0, V.arcologyUpgrade.drones > 0 ? 30 : 0),
diff --git a/src/Mods/SecExp/potentialToDo.txt b/src/Mods/SecExp/potentialToDo.txt
index 56d49ff21c6..af235af81ba 100644
--- a/src/Mods/SecExp/potentialToDo.txt
+++ b/src/Mods/SecExp/potentialToDo.txt
@@ -29,7 +29,6 @@ Hexall90's last merged commit: 52dde0b3
 - Suggestion - Arcology Conquest - https://gitgud.io/pregmodfan/fc-pregmod/issues/760
 - Does forcing every citizen to be in military raise appeal of slaves that know how to fight?
 - And if I am a master tactician, maybe I could get an estimate how effective the various tacticts could be?
-- make https://gitgud.io/pregmodfan/fc-pregmod/issues/1431 and https://gitgud.io/pregmodfan/fc-pregmod/issues/1436 more visible
 - Ability to create more drone squads.
 - Increase base maximum units to 18, 20 with SF.
 - Suggestion - Gradual Battle Frequency - https://gitgud.io/pregmodfan/fc-pregmod/issues/1245#note_82504
@@ -40,5 +39,4 @@ Hexall90's last merged commit: 52dde0b3
 - It would be a start if the tactics talking about the size difference of the armies actually took the size difference into account.
 - How about to start off with option to send one or two of your combat trained slaves to assist the merc's when they are on a raid with the possibility of receiving battle wounds.
 - If there are choices, they should be along the lines of "higher risk, higher reward" (defeating the enemy with fewer casualties and damage if it goes right, but suffering higher casualties and damage if it goes wrong), or things like accepting more/less military casualties for better/worse protection of economic assets (costing money/damaging economy) and civilians (costing reputation/damaging population).
-- The ability to send units to the general to increase relationship as an alternative to sending slaves.
-- Unrelated minor suggestion: Could we perhaps set default unit names somewhere? Just a small thing so I don't have to change each new unit to (slave/citizen/mercenary) Legion in my Roman society whenever I make new ones.
+- The ability to send units to the general to increase relationship as an alternative to sending slaves.
\ No newline at end of file
diff --git a/src/Mods/SecExp/securityReport.tw b/src/Mods/SecExp/securityReport.tw
index fffe0b1b262..979f0409318 100644
--- a/src/Mods/SecExp/securityReport.tw
+++ b/src/Mods/SecExp/securityReport.tw
@@ -473,13 +473,13 @@ Due to the deterioration of the old world countries, organized crime focuses mor
 		/* loyalty and training */
 		<<set _sL = $slaveUnits.length, _mL = $militiaUnits.length, _meL = $mercUnits.length>>
 		<<for _i = 0; _i < _sL; _i++>>
-			<<includeDOM App.SecExp.humanUnitLoyaltyChanges($slaveUnits[_i])>>
+			<<includeDOM App.SecExp.humanUnitLoyaltyChanges($slaveUnits[_i], 'slave')>>
 		<</for>>
 		<<for _i = 0; _i < _mL; _i++>>
-			<<includeDOM App.SecExp.humanUnitLoyaltyChanges($militiaUnits[_i])>>
+			<<includeDOM App.SecExp.humanUnitLoyaltyChanges($militiaUnits[_i], 'citizens')>>
 		<</for>>
 		<<for _i = 0; _i < _meL; _i++>>
-			<<includeDOM App.SecExp.humanUnitLoyaltyChanges($mercUnits[_i])>>
+			<<includeDOM App.SecExp.humanUnitLoyaltyChanges($mercUnits[_i], 'mercenary')>>
 		<</for>>
 	<</if>>
 <</if>>
@@ -506,7 +506,7 @@ Due to the deterioration of the old world countries, organized crime focuses mor
 
 <<if $SecExp.buildings.weapManu>>
 	<<if App.SecExp.weapManuUpgrade.fully().bots && App.SecExp.weapManuUpgrade.fully().human>> <<run delete $SecExp.buildings.weapManu.upgrades.queue>> <</if>>
-	<<if jsDef($SecExp.buildings.weapManu.upgrades.queue) && $SecExp.buildings.weapManu.upgrades.queue[0].time > 0>>
+	<<if jsDef($SecExp.buildings.weapManu.upgrades.queue) && $SecExp.buildings.weapManu.upgrades.queue.length > 0 && $SecExp.buildings.weapManu.upgrades.queue[0].time > 0>>
 		<<set _current = App.SecExp.weapManuUpgrade.current(), $SecExp.buildings.weapManu.upgrades.queue[0].time-->>
 		<br>In the research lab, _current.dec
 		<<switch _current.dec>>
diff --git a/src/Mods/SpecialForce/Firebase.tw b/src/Mods/SpecialForce/Firebase.tw
index 3cf2bc20843..101ca83b87e 100644
--- a/src/Mods/SpecialForce/Firebase.tw
+++ b/src/Mods/SpecialForce/Firebase.tw
@@ -98,12 +98,6 @@
 				<<if $SF.UC.Assign < 1>>''Zero''<<elseif $SF.UC.Assign < 2>>A ''small'' section<<else>>A ''large'' section<</if>> 
 				of the special force is assigned to undercover work, which will primarily advance your cultural goals while also slightly boosting your reputation. [[Re-allocate the units|Firebase][$SF.UC.Lock = 0]]
 			<</if>>
-
-			<<if $SF.Squad.Firebase > 5 && $secExpEnabled > 0 && $SecExp.edicts.SFSupportLevel >= 4 && App.SecExp.battle.maxUnits() === 18 && App.SecExp.battle.deploySpeed() <= 10>>
-				<br><br>[[Provide the security force with their own section.|Firebase][$sectionInFirebase = 1, cashX(forceNeg(Math.ceil((750000*(1.15+(_size/1000))*(1.15+($SF.Squad.Firebase/10)))*_Env)), "specialForcesCap")]]
-				@@.red;<<print cashFormat(Math.ceil((750000*(1.15+(_size/1000))*(1.15+($SF.Squad.Firebase/10)))*_Env))>>@@
-			<</if>>
-
 			<<= App.SF.Interactions()>>
 			<<include "WC">>
 		</div>
diff --git a/src/gui/quicklinks.js b/src/gui/quicklinks.js
index 46f9ac907b0..5e8aa11d778 100644
--- a/src/gui/quicklinks.js
+++ b/src/gui/quicklinks.js
@@ -107,7 +107,7 @@ App.UI.quickMenu = (function() {
 		Pit: () => !V.pit,
 		propagandaHub: () => V.secExpEnabled === 0 || !V.SecExp.buildings.propHub,
 		"Prosthetic Lab": () => V.researchLab.level === 0,
-		riotControlCenter: () => V.secExpEnabled === 0 || V.SecExp.buildings.riotCenter,
+		riotControlCenter: () => V.secExpEnabled === 0 || !V.SecExp.buildings.riotCenter,
 		Schoolroom: () => !V.schoolroom,
 		secBarracks: () => V.secExpEnabled === 0 || !V.SecExp.buildings.barracks,
 		securityHQ: () => V.secExpEnabled === 0 || !V.SecExp.buildings.secHub,
-- 
GitLab