From d8c342ae6b28b6a70dd5e25aca4409cab7a84b8d Mon Sep 17 00:00:00 2001
From: kopareigns <kopareigns@gmail.com>
Date: Thu, 13 Dec 2018 22:13:30 -0500
Subject: [PATCH] Incrementing releaseID and surrogacy fix

---
 devNotes/twine JS.txt                       | 39 +++++----------------
 src/js/wombJS.tw                            | 39 +++++----------------
 src/uncategorized/BackwardsCompatibility.tw |  8 ++---
 3 files changed, 22 insertions(+), 64 deletions(-)

diff --git a/devNotes/twine JS.txt b/devNotes/twine JS.txt
index 23cb9c1fca7..122b1f1083b 100644
--- a/devNotes/twine JS.txt	
+++ b/devNotes/twine JS.txt	
@@ -11034,19 +11034,24 @@ window.WombInit = function(actor) {
 	}
 };
 
-window.WombImpregnate = function(actor, fCount, fatherID, age) {
+window.WombImpregnate = function(actor, fCount, fatherID, age, surrogate) {
 	var i;
 	var tf;
 	for (i=0; i<fCount; i++) {
 		tf = {}; //new Object
 		tf.age = age; //initial age
-		tf.motherID = actor.ID; //Initial biological mother ID setup.
 		tf.fatherID = fatherID; //We can store who is father too.
 		tf.volume = 1; //Initial, to create property. Updated with actual data after WombGetVolume call.
 		tf.reserve = ""; //Initial, to create property. Used later to mark if this child is to be kept.
 		tf.identical = 0; //Initial, to create property. Updated with actual data during fetalSplit call.
 		tf.splitted = 0; //marker for already splitted fetus.
-		tf.genetics = generateGenetics(actor, fatherID, i+1); //Stored genetic information.
+		if (surrogate) {
+			tf.motherID = surrogate.ID; //Initial biological mother ID setup.
+			tf.genetics = generateGenetics(surrogate, fatherID, i+1); //Stored genetic information.
+		} else {
+			tf.motherID = actor.ID; //Initial biological mother ID setup.
+			tf.genetics = generateGenetics(actor, fatherID, i+1); //Stored genetic information.
+		}
 		tf.ID = generateNewID();
 
 		try {
@@ -11066,33 +11071,7 @@ window.WombImpregnate = function(actor, fCount, fatherID, age) {
 };
 
 window.WombSurrogate = function(actor, fCount, mother, fatherID, age) {
-	var i;
-	var tf;
-	for (i=0; i<fCount; i++) {
-		tf = {}; //new Object
-		tf.age = age; //initial age
-		tf.motherID = mother.ID; //Initial biological mother ID setup.
-		tf.fatherID = fatherID; //We can store who is father too.
-		tf.volume = 1; //Initial, to create property. Updated with actual data after WombGetVolume call.
-		tf.reserve = ""; //Initial, to create property. Used later to mark if this child is to be kept.
-		tf.identical = 0; //Initial, to create property. Updated with actual data during fetalSplit call.
-		tf.splitted = 0; //marker for already splitted fetus.
-		tf.genetics = generateGenetics(mother, fatherID, i+1); //Stored genetic information.
-
-		try {
-			if (actor.womb.length == 0) {
-				actor.pregWeek = age;
-				actor.preg = age;
-			}
-			actor.womb.push(tf);
-		} catch(err){
-			WombInit(actor);
-			actor.womb.push(tf);
-			alert("WombImpregnate warning - " + actor.slaveName+" "+err);
-		}
-
-	}
-	MissingParentIDCorrection(actor);
+	WombImpregnate(actor, fCount, fatherID, age, mother);
 };
 
 window.WombProgress = function(actor, ageToAdd) {
diff --git a/src/js/wombJS.tw b/src/js/wombJS.tw
index 8f89c315942..108bcdb2b31 100644
--- a/src/js/wombJS.tw
+++ b/src/js/wombJS.tw
@@ -80,19 +80,24 @@ window.WombInit = function(actor) {
 	}
 };
 
-window.WombImpregnate = function(actor, fCount, fatherID, age) {
+window.WombImpregnate = function(actor, fCount, fatherID, age, surrogate) {
 	var i;
 	var tf;
 	for (i=0; i<fCount; i++) {
 		tf = {}; //new Object
 		tf.age = age; //initial age
-		tf.motherID = actor.ID; //Initial biological mother ID setup.
 		tf.fatherID = fatherID; //We can store who is father too.
 		tf.volume = 1; //Initial, to create property. Updated with actual data after WombGetVolume call.
 		tf.reserve = ""; //Initial, to create property. Used later to mark if this child is to be kept.
 		tf.identical = 0; //Initial, to create property. Updated with actual data during fetalSplit call.
 		tf.splitted = 0; //marker for already splitted fetus.
-		tf.genetics = generateGenetics(actor, fatherID, i+1); //Stored genetic information.
+		if (surrogate) {
+			tf.motherID = surrogate.ID; //Initial biological mother ID setup.
+			tf.genetics = generateGenetics(surrogate, fatherID, i+1); //Stored genetic information.
+		} else {
+			tf.motherID = actor.ID; //Initial biological mother ID setup.
+			tf.genetics = generateGenetics(actor, fatherID, i+1); //Stored genetic information.
+		}
 		tf.ID = generateNewID();
 
 		try {
@@ -112,33 +117,7 @@ window.WombImpregnate = function(actor, fCount, fatherID, age) {
 };
 
 window.WombSurrogate = function(actor, fCount, mother, fatherID, age) {
-	var i;
-	var tf;
-	for (i=0; i<fCount; i++) {
-		tf = {}; //new Object
-		tf.age = age; //initial age
-		tf.motherID = mother.ID; //Initial biological mother ID setup.
-		tf.fatherID = fatherID; //We can store who is father too.
-		tf.volume = 1; //Initial, to create property. Updated with actual data after WombGetVolume call.
-		tf.reserve = ""; //Initial, to create property. Used later to mark if this child is to be kept.
-		tf.identical = 0; //Initial, to create property. Updated with actual data during fetalSplit call.
-		tf.splitted = 0; //marker for already splitted fetus.
-		tf.genetics = generateGenetics(mother, fatherID, i+1); //Stored genetic information.
-
-		try {
-			if (actor.womb.length == 0) {
-				actor.pregWeek = age;
-				actor.preg = age;
-			}
-			actor.womb.push(tf);
-		} catch(err){
-			WombInit(actor);
-			actor.womb.push(tf);
-			alert("WombImpregnate warning - " + actor.slaveName+" "+err);
-		}
-
-	}
-	MissingParentIDCorrection(actor);
+	WombImpregnate(actor, fCount, fatherID, age, mother);
 };
 
 window.WombProgress = function(actor, ageToAdd) {
diff --git a/src/uncategorized/BackwardsCompatibility.tw b/src/uncategorized/BackwardsCompatibility.tw
index 69a147fd5a7..9d50eb673d1 100644
--- a/src/uncategorized/BackwardsCompatibility.tw
+++ b/src/uncategorized/BackwardsCompatibility.tw
@@ -3730,10 +3730,6 @@ Done!
 	<</if>>
 <</for>>
 
-<<if $releaseID < 1032>>
-	<<set $releaseID = 1032>>
-<</if>>
-
 <<if ndef $postSexCleanUp>>
 	<<set $postSexCleanUp = 1>>
 <</if>>
@@ -3754,5 +3750,9 @@ Done!
 	<<set $abbreviateHormoneBalance = 2>>
 <</if>>
 
+<<if $releaseID < 1036>>
+	<<set $releaseID = 1036>>
+<</if>>
+
 /* reset NaNArray afterward BC is run */
 <<set $NaNArray = findNaN()>>
-- 
GitLab