From 27140ada3219bfc12bf8b05f21d48c02cabd3f41 Mon Sep 17 00:00:00 2001
From: x <okp57855@psoxs.com>
Date: Sun, 26 Aug 2018 19:27:34 +1200
Subject: [PATCH] Tweaking VI

---
 src/SecExp/SecExpBackwardCompatibility.tw |   9 ++
 src/SecExp/riotControlCenter.tw           |  12 +-
 src/SecExp/secBarracks.tw                 |  16 +--
 src/SecExp/secInit.tw                     |   3 +
 src/SecExp/securityHQ.tw                  | 134 +++++++++++-----------
 5 files changed, 90 insertions(+), 84 deletions(-)

diff --git a/src/SecExp/SecExpBackwardCompatibility.tw b/src/SecExp/SecExpBackwardCompatibility.tw
index dbd4f433a89..ca83f5fcb47 100644
--- a/src/SecExp/SecExpBackwardCompatibility.tw
+++ b/src/SecExp/SecExpBackwardCompatibility.tw
@@ -986,6 +986,15 @@
 <<if ndef $secUpgrades.coldstorage>>
 	<<set $secUpgrades.coldstorage = 0>>
 <</if>>
+<<if ndef $SFGear>>
+	<<set $SFGear = 0>>
+<</if>>
+<<if ndef $SavedLeader>>
+	<<set $SavedLeader = $leadingTroops>>
+<</if>>
+<<if ndef $SavedSFI>>
+	<<set SavedSFI = $SFIntervention>>
+<</if>>
 
 /* recalculation widgets */
 <<fixBrokenUnits>>
diff --git a/src/SecExp/riotControlCenter.tw b/src/SecExp/riotControlCenter.tw
index e91625af63f..43d7f51035f 100644
--- a/src/SecExp/riotControlCenter.tw
+++ b/src/SecExp/riotControlCenter.tw
@@ -207,9 +207,11 @@ The riot control center opens its guarded doors to you. The great chamber inside
 	You have installed additional protection layers and redundant systems in the assistant CPU core.
 <</if>>
 
-<<if $SF.Toggle && $SF.Active >= 1 && $SFSupportLevel >= 4 && !$SFGear && $SFUnit.Armoury >= 8>> <<= Count()>>
-	<br><br> <<link "Give the riot unit access to the combat armour suits of $SF.Lower.""riotControlCenter">> <<set $SFGear = 1,$riotUpkeep += 15000,$cash -= Math.ceil(500000*_Env*(1.15+($SFUnit.Armoury/10)))>> <</link>>
-	<br>//Costs <<print cashFormat(Math.ceil(500000*_Env*(1.15+($SFUnit.Armoury/10))))>>
-<<else>>
-	<br><br>//You have given the riot unit access to the combat armour suits of $SF.Lower.//
+<<if $SF.Toggle && $SF.Active >= 1>>
+	<<if $SFSupportLevel >= 4 && !$SFGear && $SFUnit.Armoury >= 8>> <<= Count()>>
+		<br><br> <<link "Give the riot unit access to the combat armour suits of $SF.Lower.""riotControlCenter">> <<set $SFGear = 1,$riotUpkeep += 15000,$cash -= Math.ceil(500000*_Env*(1.15+($SFUnit.Armoury/10)))>> <</link>>
+		<br>//Costs <<print cashFormat(Math.ceil(500000*_Env*(1.15+($SFUnit.Armoury/10))))>>
+	<<else>>
+		<br><br>//You have given the riot unit access to the combat armour suits of $SF.Lower.//
+	<</if>>
 <</if>>
\ No newline at end of file
diff --git a/src/SecExp/secBarracks.tw b/src/SecExp/secBarracks.tw
index 85f3aafc8b5..5bfe8cd772d 100644
--- a/src/SecExp/secBarracks.tw
+++ b/src/SecExp/secBarracks.tw
@@ -138,8 +138,7 @@ Your current maximum number of units is <<print $maxUnits>> (<<print commaNum($s
 <</if>>
 <br>
 <<replenishAllUnits>>
-<br>
-<br>
+<<if $secBots.active === 1>> <br><br>
 __Security Drones__
 /* drones */
 <<if $secBots.active == 1>>
@@ -156,19 +155,10 @@ __Security Drones__
 			<<set $secBots.troops = $secBots.maxTroops>>
 		<</link>>
 	<</if>>
-<<else>>
-	You have lost too many security drones to be able to field them again.
-	<<link "Reform the unit" "secBarracks">>
-		<<set $cash -= $secBots.maxTroops * $secBotsCost>>
-		<<set $secBots.troops = $secBots.maxTroops>>
-		<<set $secBots.active = 1>>
-	<</link>>
+<</if>>
 <</if>>
 
-<br>
-<br>
-
-__Slaves__
+<br><br>__Slaves__
 <br>/* slaves */
 You are free to organize your menial slaves into fighting units. Currently you have <<print commaNum($helots)>> slaves available, while <<print commaNum($slavesEmployedManpower)>> are already employed as soldiers. During all your battles you lost a total of <<print commaNum($slavesTotalCasualties)>>.
 <<silently>><<= MenialPopCap()>><</silently>>
diff --git a/src/SecExp/secInit.tw b/src/SecExp/secInit.tw
index 97535043e2b..84654fea324 100644
--- a/src/SecExp/secInit.tw
+++ b/src/SecExp/secInit.tw
@@ -342,6 +342,9 @@
 /* SFanon additons */
 <<set $SFSupportLevel = 0>>
 <<set $SFSupportUpkeep = 0>>
+<<set $SFGear = 0>>
+<<set $SavedLeader = "none">>
+<<set $SavedSFI = 0>>
 
 /* helper widgets */
 <<calcInitialTrade>>
\ No newline at end of file
diff --git a/src/SecExp/securityHQ.tw b/src/SecExp/securityHQ.tw
index dc0fa111a99..891363eee56 100644
--- a/src/SecExp/securityHQ.tw
+++ b/src/SecExp/securityHQ.tw
@@ -96,78 +96,80 @@ You have <span id="secHel"> <<print commaNum($secHelots)>> </span> slaves workin
 			<</if>>
 		<</link>>
 	<</if>>
-<</if>>
 
-<br>Transfer out
-<<if $secHelots >= 5>>
-	<<link "5">>
-		<<set $helots += 5>>
-		<<set $secHelots -= 5>>
-		<<replace "#secHel">><<print $secHelots>><</replace>>
-		<<replace "#hel">><<print $helots>><</replace>>
-		<<if $secHelots < 5>>
-			<<goto "securityHQ">>
-		<</if>>
-		<<if $secHelots < $reqHelots>>
-			<<goto "securityHQ">>
-		<</if>>
-	<</link>>
-<</if>>
-<<if $secHelots >= 10>>
-	|<<link "10">>
-		<<set $helots += 10>>
-		<<set $secHelots -= 10>>
-		<<replace "#secHel">><<print $secHelots>><</replace>>
-		<<replace "#hel">><<print $helots>><</replace>>
-		<<if $secHelots < 10>>
-			<<goto "securityHQ">>
-		<</if>>
-		<<if $secHelots < $reqHelots>>
-			<<goto "securityHQ">>
-		<</if>>
-	<</link>>
-<</if>>
-<<if $secHelots >= 100>>
-	|<<link "100">>
-		<<set $helots += 100>>
-		<<set $secHelots -= 100>>
-		<<replace "#secHel">><<print $secHelots>><</replace>>
-		<<replace "#hel">><<print $helots>><</replace>>
-		<<if $secHelots < 100>>
-			<<goto "securityHQ">>
+	<<if $secHelots > 0>>
+		<br>Transfer out
+		<<if $secHelots >= 5>>
+			<<link "5">>
+				<<set $helots += 5>>
+				<<set $secHelots -= 5>>
+				<<replace "#secHel">><<print $secHelots>><</replace>>
+				<<replace "#hel">><<print $helots>><</replace>>
+				<<if $secHelots < 5>>
+					<<goto "securityHQ">>
+				<</if>>
+				<<if $secHelots < $reqHelots>>
+					<<goto "securityHQ">>
+				<</if>>
+			<</link>>
 		<</if>>
-		<<if $secHelots < $reqHelots>>
-			<<goto "securityHQ">>
-		<</if>>
-	<</link>>
-<</if>>
-<<if $secHelots >= 500>>
-	|<<link "500">>
-		<<set $helots += 500>>
-		<<set $secHelots -= 500>>
-		<<replace "#secHel">><<print $secHelots>><</replace>>
-		<<replace "#hel">><<print $helots>><</replace>>
-		<<if $secHelots < 500>>
-			<<goto "securityHQ">>
+		<<if $secHelots >= 10>>
+			|<<link "10">>
+				<<set $helots += 10>>
+				<<set $secHelots -= 10>>
+				<<replace "#secHel">><<print $secHelots>><</replace>>
+				<<replace "#hel">><<print $helots>><</replace>>
+				<<if $secHelots < 10>>
+					<<goto "securityHQ">>
+				<</if>>
+				<<if $secHelots < $reqHelots>>
+					<<goto "securityHQ">>
+				<</if>>
+			<</link>>
 		<</if>>
-		<<if $secHelots < $reqHelots>>
-			<<goto "securityHQ">>
+		<<if $secHelots >= 100>>
+			|<<link "100">>
+				<<set $helots += 100>>
+				<<set $secHelots -= 100>>
+				<<replace "#secHel">><<print $secHelots>><</replace>>
+				<<replace "#hel">><<print $helots>><</replace>>
+				<<if $secHelots < 100>>
+					<<goto "securityHQ">>
+				<</if>>
+				<<if $secHelots < $reqHelots>>
+					<<goto "securityHQ">>
+				<</if>>
+			<</link>>
 		<</if>>
-	<</link>>
-<</if>>
-<<if $secHelots >= 1000>>
-	|<<link "1000">>
-		<<set $helots += 1000>>
-		<<set $secHelots -= 1000>>
-		<<replace "#secHel">><<print $secHelots>><</replace>>
-		<<replace "#hel">><<print $helots>><</replace>>
-		<<if $secHelots < 1000>>
-			<<goto "securityHQ">>
+		<<if $secHelots >= 500>>
+			|<<link "500">>
+				<<set $helots += 500>>
+				<<set $secHelots -= 500>>
+				<<replace "#secHel">><<print $secHelots>><</replace>>
+				<<replace "#hel">><<print $helots>><</replace>>
+				<<if $secHelots < 500>>
+					<<goto "securityHQ">>
+				<</if>>
+				<<if $secHelots < $reqHelots>>
+					<<goto "securityHQ">>
+				<</if>>
+			<</link>>
 		<</if>>
-		<<if $secHelots < $reqHelots>>
-			<<goto "securityHQ">>
+		<<if $secHelots >= 1000>>
+			|<<link "1000">>
+				<<set $helots += 1000>>
+				<<set $secHelots -= 1000>>
+				<<replace "#secHel">><<print $secHelots>><</replace>>
+				<<replace "#hel">><<print $helots>><</replace>>
+				<<if $secHelots < 1000>>
+					<<goto "securityHQ">>
+				<</if>>
+				<<if $secHelots < $reqHelots>>
+					<<goto "securityHQ">>
+				<</if>>
+			<</link>>
 		<</if>>
-	<</link>>
+	<</if>>
 <</if>>
 
 <<if $secHelots != $reqHelots>>
-- 
GitLab