From c94c396283eca3b4a2745511e40c64360cefea01 Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Tue, 14 Apr 2020 13:48:06 -0700
Subject: [PATCH] Use setMissingParents(slave) more widely.

---
 .../updateSlaveObject.js                      |  6 +--
 src/uncategorized/REroyalblood.tw             | 42 ++++------------
 src/uncategorized/householdLiquidator.tw      | 10 +---
 .../reFSEgyptianRevivalistAcquisition.tw      |  5 +-
 src/uncategorized/recETS.tw                   | 50 ++++---------------
 5 files changed, 24 insertions(+), 89 deletions(-)

diff --git a/src/data/backwardsCompatibility/updateSlaveObject.js b/src/data/backwardsCompatibility/updateSlaveObject.js
index 68e893729cf..ab62ac61cda 100644
--- a/src/data/backwardsCompatibility/updateSlaveObject.js
+++ b/src/data/backwardsCompatibility/updateSlaveObject.js
@@ -985,10 +985,7 @@ App.Update.Slave = function(slave, genepool=false) {
 							slave.father = otherLink.father;
 						} else {
 							// don't know your parents, generate new IDs for them
-							slave.mother = V.missingParentID;
-							V.missingParentID--;
-							slave.father = V.missingParentID;
-							V.missingParentID--;
+							setMissingParents(slave);
 						}
 						V.relationLinks[slave.ID] = {mother: slave.mother, father: slave.father};
 						// your sister's parents are the same as your parents
@@ -1020,5 +1017,4 @@ App.Update.Slave = function(slave, genepool=false) {
 	delete slave.relation;
 	delete slave.relationTarget;
 	delete slave.recruiter;
-
 };
diff --git a/src/uncategorized/REroyalblood.tw b/src/uncategorized/REroyalblood.tw
index 9fb68d20d2b..d97b35e76ab 100644
--- a/src/uncategorized/REroyalblood.tw
+++ b/src/uncategorized/REroyalblood.tw
@@ -336,10 +336,7 @@ Time is short, but you are well placed to acquire some choice slaves. With an ad
 		<br><br>
 		/* princess */
 		<<set _princess.origin = "$He was a princess of a royal kingdom, till $his family was overthrown and $he was sold to you in exchange for aid.">>
-		<<set _princess.mother = $missingParentID>>
-		<<set $missingParentID-->>
-		<<set _princess.father = $missingParentID>>
-		<<set $missingParentID-->>
+		<<run setMissingParents(_princess)>>
 		<<run cashX(-60000, "slaveTransfer", _princess)>>
 		<<run repX(-6000, "event", _princess)>>
 		<<run newSlave(_princess)>> /* skip New Slave Intro */
@@ -366,10 +363,7 @@ Time is short, but you are well placed to acquire some choice slaves. With an ad
 		<<set $arcologies[0].prosperity -= 15>>
 		/* princess */
 		<<set _princess.origin = "$He was a princess of a royal kingdom, till $his family was overthrown and $he was acquired by "+$SF.Lower+".">>
-		<<set _princess.mother = $missingParentID>>
-		<<set $missingParentID-->>
-		<<set _princess.father = $missingParentID>>
-		<<set $missingParentID-->>
+		<<run setMissingParents(_princess)>>
 		<<run newSlave(_princess)>> /* skip New Slave Intro */
 		<<run repX(-10000, "event", _princess)>>
 		/* prince */
@@ -542,8 +536,7 @@ Time is short, but you are well placed to acquire some choice slaves. With an ad
 		/* princess */
 		<<set _princess.origin = "$He was a princess of a royal kingdom, till $his family was overthrown and $he was sold for credits.">>
 		<<set _princess.mother = _queen.ID>>
-		<<set _princess.father = $missingParentID>>
-		<<set $missingParentID-->>
+		<<run setMissingParents(_princess)>>
 		<<run cashX(-400000, "slaveTransfer", _princess)>>
 		<<run newSlave(_princess)>> /* skip New Slave Intro */
 		/*Queen*/
@@ -568,8 +561,7 @@ Time is short, but you are well placed to acquire some choice slaves. With an ad
 		/* princess */
 		<<set _princess.origin = "$He was a princess of a royal kingdom, till $his family was overthrown and $he was sold for credits.">>
 		<<set _princess.mother = _queen.ID>>
-		<<set _princess.father = $missingParentID>>
-		<<set $missingParentID-->>
+		<<run setMissingParents(_princess)>>
 		<<run newSlave(_princess)>> /* skip New Slave Intro */
 		<<run repX(-10000, "event", _princess)>>
 		/*Queen*/
@@ -628,10 +620,7 @@ Time is short, but you are well placed to acquire some choice slaves. With an ad
 		<</for>>
 		/*Queen*/
 		<<set _queen.origin = "$He was the Queen of a royal kingdom, till $his husband was overthrown and $he was sold for credits.">>
-		<<set _queen.mother = $missingParentID>>
-		<<set $missingParentID-->>
-		<<set _queen.father = $missingParentID>>
-		<<set $missingParentID-->>
+		<<run setMissingParents(_queen)>>
 		<<run newSlave(_queen)>> /* skip New Slave Intro */
 		<<run cashX(-200000, "slaveTransfer", _queen)>>
 	<</replace>>
@@ -686,10 +675,7 @@ Time is short, but you are well placed to acquire some choice slaves. With an ad
 		<</for>>
 		/*Queen*/
 		<<set _queen.origin = "$He was the Queen of a royal kingdom, till $his husband was overthrown and $he was acquired by "+$SF.Lower+".">>
-		<<set _queen.mother = $missingParentID>>
-		<<set $missingParentID-->>
-		<<set _queen.father = $missingParentID>>
-		<<set $missingParentID-->>
+		<<run setMissingParents(_queen)>>
 		<<run newSlave(_queen)>> /* skip New Slave Intro */
 		<<run repX(-4000, "event", _queen)>>
 	<</replace>>
@@ -744,8 +730,7 @@ Time is short, but you are well placed to acquire some choice slaves. With an ad
 			/* princess */
 			<<set _princess.origin = "$He was a princess of a royal kingdom, till $his family was overthrown and $he was sold for credits.">>
 			<<set _princess.mother = _queen.ID>>
-			<<set _princess.father = $missingParentID>>
-			<<set $missingParentID-->>
+			<<run setMissingParents(_princess)>>
 			<<run newSlave(_princess)>> /* skip New Slave Intro */
 			<<run cashX(-1100000, "slaveTransfer", _princess)>>
 			/* prince */
@@ -758,10 +743,7 @@ Time is short, but you are well placed to acquire some choice slaves. With an ad
 			<</if>>
 			/*Queen*/
 			<<set _queen.origin = "$He was the Queen of a royal kingdom, till $his husband was overthrown and $he was sold for credits.">>
-			<<set _queen.mother = $missingParentID>>
-			<<set $missingParentID-->>
-			<<set _queen.father = $missingParentID>>
-			<<set $missingParentID-->>
+			<<run setMissingParents(_queen)>>
 			<<run newSlave(_queen)>> /* skip New Slave Intro */
 			<<run cashX(-250000, "slaveTransfer", _queen)>>
 		<</replace>>
@@ -821,8 +803,7 @@ Time is short, but you are well placed to acquire some choice slaves. With an ad
 			/* princess */
 			<<set _princess.origin = "$He was a princess of a royal kingdom, till $his family was overthrown and $he was acquired by "+$SF.Lower+".">>
 			<<set _princess.mother = _queen.ID>>
-			<<set _princess.father = $missingParentID>>
-			<<set $missingParentID-->>
+			<<run setMissingParents(_princess)>>
 			<<run newSlave(_princess)>> /* skip New Slave Intro */
 			<<run repX((5*_repShares), "event", $activeSlave)>>
 			/* prince */
@@ -835,10 +816,7 @@ Time is short, but you are well placed to acquire some choice slaves. With an ad
 			<</if>>
 			/*Queen*/
 			<<set _queen.origin = "$He was the Queen of a royal kingdom, till $his husband was overthrown and $he was acquired by "+$SF.Lower+".">>
-			<<set _queen.mother = $missingParentID>>
-			<<set $missingParentID-->>
-			<<set _queen.father = $missingParentID>>
-			<<set $missingParentID-->>
+			<<run setMissingParents(_queen)>>
 			<<run newSlave(_queen)>> /* skip New Slave Intro */
 			<<run repX((4*_repShares), "event", $activeSlave)>>
 			<<run repX(0-$rep, "event")>> /*Round off any remaining rep due to the trunc on shares*/
diff --git a/src/uncategorized/householdLiquidator.tw b/src/uncategorized/householdLiquidator.tw
index 198d32c9d88..aed9638ba21 100644
--- a/src/uncategorized/householdLiquidator.tw
+++ b/src/uncategorized/householdLiquidator.tw
@@ -13,10 +13,7 @@
 <<set $activeSlave.oldDevotion = $activeSlave.devotion>>
 <<set $activeSlave.oldTrust = $activeSlave.trust>>
 <<run setHealth($activeSlave, jsRandom(-50, 20))>>
-<<set $activeSlave.mother = $missingParentID>>
-<<set $missingParentID-->>
-<<set $activeSlave.father = $missingParentID>>
-<<set $missingParentID-->>
+<<run setMissingParents($activeSlave)>>
 <<set $activeSlave.canRecruit = 0>>
 
 The household liquidator is offering a set of siblings for sale. As usual, you will only be permitted to inspect the older, but there is a guarantee that the younger will be similar.
@@ -71,10 +68,7 @@ The household liquidator is offering a mother and $his daughter for sale. As usu
 <<set $activeSlave.oldDevotion = $activeSlave.devotion>>
 <<set $activeSlave.oldTrust = $activeSlave.trust>>
 <<run setHealth($activeSlave, jsRandom(-50, 20))>>
-<<set $activeSlave.mother = $missingParentID>>
-<<set $missingParentID-->>
-<<set $activeSlave.father = $missingParentID>>
-<<set $missingParentID-->>
+<<run setMissingParents($activeSlave)>>
 <<set $activeSlave.canRecruit = 0>>
 
 The household liquidator is offering something special: identical twins. The markup is huge, but the merchandise isn't something you see every day.
diff --git a/src/uncategorized/reFSEgyptianRevivalistAcquisition.tw b/src/uncategorized/reFSEgyptianRevivalistAcquisition.tw
index d659db4f57b..5d2b3634a7f 100644
--- a/src/uncategorized/reFSEgyptianRevivalistAcquisition.tw
+++ b/src/uncategorized/reFSEgyptianRevivalistAcquisition.tw
@@ -14,11 +14,8 @@
 <<set $activeSlave.devotion = random(5,15)>>
 <<set $activeSlave.trust = random(-15,-5)>>
 <<run setHealth($activeSlave, jsRandom(-20, 0))>>
-<<set $activeSlave.mother = $missingParentID>>
-<<set $missingParentID-->>
-<<set $activeSlave.father = $missingParentID>>
+<<run setMissingParents($activeSlave)>>
 <<set $activeSlave.canRecruit = 0>>
-<<set $missingParentID-->>
 <<if ($activeSlave.dick > 0) && ($activeSlave.balls == 0)>><<set $activeSlave.balls = random(1,5)>><</if>>
 
 <<set _oppositeSex = $seeDicks > 0 && $seeDicks < 100 && (random(1, 4) <= 3)>>
diff --git a/src/uncategorized/recETS.tw b/src/uncategorized/recETS.tw
index a1134aef678..330e6af0055 100644
--- a/src/uncategorized/recETS.tw
+++ b/src/uncategorized/recETS.tw
@@ -227,10 +227,7 @@
 			<<run setHealth($activeSlave, jsRandom(20, 40), 0, 0, 0)>>
 			<<set $activeSlave.pubicHStyle = "in a strip">>
 			<<set $activeSlave.behavioralQuirk = "sinful">>
-			<<set $activeSlave.mother = $missingParentID>>
-			<<set $missingParentID-->>
-			<<set $activeSlave.father = $missingParentID>>
-			<<set $missingParentID-->>
+			<<run setMissingParents($activeSlave)>>
 			<<set $activeSlave.canRecruit = 0>>
 			<<set $activeSlave.relationship = 3>>
 			<<set $activeSlave.relationshipTarget = $activeSlave.ID + 1000>>
@@ -256,10 +253,7 @@
 			<<run setHealth($activeSlave, jsRandom(20, 40), 0, 0, 0)>>
 			<<set $activeSlave.pubicHStyle = "in a strip">>
 			<<set $activeSlave.behavioralQuirk = "sinful">>
-			<<set $activeSlave.mother = $missingParentID>>
-			<<set $missingParentID-->>
-			<<set $activeSlave.father = $missingParentID>>
-			<<set $missingParentID-->>
+			<<run setMissingParents($activeSlave)>>
 			<<set $activeSlave.canRecruit = 0>>
 			<<set $activeSlave.relationship = 3>>
 			<<set $activeSlave.relationshipTarget = $activeSlave.ID + 1000>>
@@ -283,10 +277,7 @@
 			<<set $activeSlave.attrXY = 80>>
 			<<set $activeSlave.pubicHStyle = "bushy">>
 			<<set $activeSlave.behavioralQuirk = "sinful">>
-			<<set $activeSlave.mother = $missingParentID>>
-			<<set $missingParentID-->>
-			<<set $activeSlave.father = $missingParentID>>
-			<<set $missingParentID-->>
+			<<run setMissingParents($activeSlave)>>
 			<<set $activeSlave.canRecruit = 0>>
 			<<set $activeSlave.relationship = 3>>
 			<<set $activeSlave.relationshipTarget = $activeSlave.ID + 1000>>
@@ -310,10 +301,7 @@
 			<<run setHealth($activeSlave, jsRandom(20, 40), 0, 0, 0)>>
 			<<set $activeSlave.pubicHStyle = "in a strip">>
 			<<set $activeSlave.behavioralQuirk = "sinful">>
-			<<set $activeSlave.mother = $missingParentID>>
-			<<set $missingParentID-->>
-			<<set $activeSlave.father = $missingParentID>>
-			<<set $missingParentID-->>
+			<<run setMissingParents($activeSlave)>>
 			<<set $activeSlave.canRecruit = 0>>
 			<<set $activeSlave.relationship = 3>>
 			<<set $activeSlave.relationshipTarget = $activeSlave.ID + 1000>>
@@ -336,10 +324,7 @@
 			<<set $activeSlave.attrXY = 80>>
 			<<set $activeSlave.pubicHStyle = "bushy">>
 			<<set $activeSlave.behavioralQuirk = "sinful">>
-			<<set $activeSlave.mother = $missingParentID>>
-			<<set $missingParentID-->>
-			<<set $activeSlave.father = $missingParentID>>
-			<<set $missingParentID-->>
+			<<run setMissingParents($activeSlave)>>
 			<<set $activeSlave.canRecruit = 0>>
 			<<set $activeSlave.relationship = 3>>
 			<<set $activeSlave.relationshipTarget = $activeSlave.ID + 1000>>
@@ -363,10 +348,7 @@
 			<<run setHealth($activeSlave, jsRandom(20, 40), 0, 0, 0)>>
 			<<set $activeSlave.pubicHStyle = "in a strip">>
 			<<set $activeSlave.behavioralQuirk = "sinful">>
-			<<set $activeSlave.mother = $missingParentID>>
-			<<set $missingParentID-->>
-			<<set $activeSlave.father = $missingParentID>>
-			<<set $missingParentID-->>
+			<<run setMissingParents($activeSlave)>>
 			<<set $activeSlave.canRecruit = 0>>
 			<<set $activeSlave.relationship = 3>>
 			<<set $activeSlave.relationshipTarget = $activeSlave.ID + 1000>>
@@ -471,10 +453,7 @@
 			<<set $activeSlave.hStyle = "in twin tails">>
 			<<set $activeSlave.pubicHStyle = "waxed">>
 			<<set $activeSlave.underArmHStyle = "waxed">>
-			<<set $activeSlave.mother = $missingParentID>>
-			<<set $missingParentID-->>
-			<<set $activeSlave.father = $missingParentID>>
-			<<set $missingParentID-->>
+			<<run setMissingParents($activeSlave)>>
 			<<set $activeSlave.canRecruit = 0>>
 			<<set $activeSlave.rivalry = 3>>
 			<<set $activeSlave.rivalryTarget = $activeSlave.ID + 1000>>
@@ -518,11 +497,8 @@
 			<<set $activeSlave.underArmHStyle = "waxed">>
 			<<set $activeSlave.sexualFlaw = "none">>
 			<<set $activeSlave.behavioralFlaw = "none">>
-			<<set $activeSlave.mother = $missingParentID>>
-			<<set $missingParentID-->>
-			<<set $activeSlave.father = $missingParentID>>
+			<<run setMissingParents($activeSlave)>>
 			<<set $activeSlave.canRecruit = 0>>
-			<<set $missingParentID-->>
 			<<set $activeSlave.relationship = 2>>
 			<<set $activeSlave.relationshipTarget = $activeSlave.ID + 1000>>
 			<<set _slaveCost = slaveCost($activeSlave)>>
@@ -569,11 +545,8 @@
 			<<set $activeSlave.pubicHStyle = "waxed">>
 			<<set $activeSlave.sexualQuirk = "none">>
 			<<set $activeSlave.behavioralQuirk = "none">>
-			<<set $activeSlave.mother = $missingParentID>>
-			<<set $missingParentID-->>
-			<<set $activeSlave.father = $missingParentID>>
+			<<run setMissingParents($activeSlave)>>
 			<<set $activeSlave.canRecruit = 0>>
-			<<set $missingParentID-->>
 			<<set $activeSlave.relationship = 2>>
 			<<set $activeSlave.relationshipTarget = $activeSlave.ID + 1000>>
 			<<set _slaveCost = slaveCost($activeSlave)>>
@@ -630,11 +603,8 @@
 			<<set $activeSlave.fetishStrength = 100>>
 			<<set $activeSlave.sexualQuirk = "perverted">>
 			<<set $activeSlave.behavioralQuirk = "none">>
-			<<set $activeSlave.mother = $missingParentID>>
-			<<set $missingParentID-->>
-			<<set $activeSlave.father = $missingParentID>>
+			<<run setMissingParents($activeSlave)>>
 			<<set $activeSlave.canRecruit = 0>>
-			<<set $missingParentID-->>
 			<<set $activeSlave.relationship = 4>>
 			<<set $activeSlave.relationshipTarget = $activeSlave.ID + 1000>>
 			<<set _slaveCost = slaveCost($activeSlave)>>
-- 
GitLab