From c7221b7f359ef1bb1b9541cf1837dce76740448c Mon Sep 17 00:00:00 2001
From: klorpa <30924131+klorpa@users.noreply.github.com>
Date: Tue, 11 Dec 2018 20:46:23 -0600
Subject: [PATCH] RevertOddness

---
 devNotes/twine JS.txt       | 167 ++----------------------------------
 src/js/slaveGenerationJS.tw |   1 +
 src/js/wombJS.tw            |  18 ++--
 3 files changed, 17 insertions(+), 169 deletions(-)

diff --git a/devNotes/twine JS.txt b/devNotes/twine JS.txt
index 8a2419f8b4f..e7b54e03212 100644
--- a/devNotes/twine JS.txt	
+++ b/devNotes/twine JS.txt	
@@ -10954,8 +10954,7 @@ window.generateChild = function(mother, ova, destination) {
 /*:: wombJS [script]*/
 
 /*
-This is womb processor/simulator script. It's take care about calculation of belly sizes based on individual fetus sizes,
-with full support of broodmothers implant random turning on and off possibility. Also this can be expanded to store more parents data in each individual fetus in future.
+This is womb processor/simulator script. It takes care about calculation of belly sizes based on individual fetus sizes, with full support of broodmothers implant random turning on and off possibility. Also this can be expanded to store more parents data in each individual fetus in future.
 Design limitations:
 - Mother can't gestate children with different speeds at same time. All speed changes apply to all fetuses.
 - Sizes of individual fetuses updated only on call of WombGetVolume - not every time as called WombProgress. This is for better overall code speed.
@@ -10998,12 +10997,12 @@ window.WombInit = function(actor) {
 		actor.readyOva = 0;
 	}
 
-    if ( actor.pregData == undefined)
-    {
-        actor.pregData = clone( setup.pregData.human );
-        //Setup should be through deep copy, so in future, if we like, these values can be changed individually. Gameplay expansion possibilities. But for dev time to simplify debugging:
-        //actor.pregData = setup.pregData.human;  // any changes in setup pregData template will be applied immediately to all. But can't be made separate changes.
-    }
+	if ( actor.pregData == undefined)
+	{
+		actor.pregData = clone( setup.pregData.human );
+		//Setup should be through deep copy, so in future, if we like, these values can be changed individually. Gameplay expansion possibilities. But for dev time to simplify debugging:
+		//actor.pregData = setup.pregData.human;  // any changes in setup pregData template will be applied immediately to all. But can't be made separate changes.
+	}
 
 	//backward compatibility setup. Fully accurate for normal pregnancy only.
 	if (actor.womb.length > 0 && actor.womb[0].genetics == undefined) {
@@ -11145,155 +11144,6 @@ window.WombBirthReady = function(actor, readyAge) {
 
 window.WombGetVolume = function(actor) { //most legacy code from pregJS.tw with minor adaptation.
 
-    if (actor.pregData.sizeType == 0)
-        return getVolByLen(actor);
-    else if (actor.pregData.sizeType == 1)
-        return getVolByWeight(actor);
-    else if (actor.pregData.sizeType == 2)
-        return getVolByRaw(actor);
-    else
-        return 0;
-
-    function getCurData(actor, age)
-    {
-        let i = 0;
-        let min, max, ageMin, ageMax, rateMin, rateMax, one, rateOne, rate, cage, csize;
-        let data = {};
-
-        while (actor.pregData.fetusWeek[i+1] < age && i < actor.pregData.fetusWeek.length-1)
-            i++;
-
-        min = actor.pregData.fetusSize[i];
-        max = actor.pregData.fetusSize[i+1];
-        ageMin = actor.pregData.fetusWeek[i];
-        ageMax = actor.pregData.fetusWeek[i+1];
-        rateMin = actor.pregData.fetusRate[i];
-        rateMax = actor.pregData.fetusRate[i+1];
-
-        cage = age - ageMin;
-
-        one = (max - min) / (ageMax - ageMin);
-        rateOne = (rateMax - rateMin) / (ageMax - ageMin);
-
-        rate = rateMin + (rateOne * cage);
-
-        csize = (min + (one * cage));
-        //console.log("min:"+min+"  max:"+max+"  ageMin:"+ageMin+"  ageMax:"+ageMax+"  one:"+one+"  rateOne:"+rateOne+"  cage:"+cage+"  rate:"+rate+"  csize:"+csize+"  final size:"+csize*rate);
-
-        data.size = csize;
-        data.rate = rate;
-
-        return data; //csize * rate;
-        //maybe not very effective code, but simple and easy to debug. May be optimized more in future.
-    }
-
-
-    function getVolByLen(actor){
-
-    try {
-
-            var phi = 1.618;
-            var targetData, targetLen;
-            var wombSize = 0;
-
-            actor.womb.forEach(ft => {
-
-                /* legacy block for debug only
-                let gestastionWeek = ft.age;
-                let oldLen;
-                let oldVol;
-                if (gestastionWeek <= 32) {
-                    oldLen = (0.00006396 * Math.pow(gestastionWeek, 4)) -
-                        (0.005501 * Math.pow(gestastionWeek, 3)) +
-                        (0.161 * Math.pow(gestastionWeek, 2)) -
-                        (0.76 * gestastionWeek) +
-                        0.208;
-                } else if (gestastionWeek <= 106) {
-                    oldLen = (-0.0000004675 * Math.pow(gestastionWeek, 4)) +
-                        (0.0001905 * Math.pow(gestastionWeek, 3)) -
-                        (0.029 * Math.pow(gestastionWeek, 2)) +
-                        (2.132 * gestastionWeek) -
-                        16.575;
-                } else {
-                    oldLen = (-0.00003266 * Math.pow(gestastionWeek,2)) +
-                        (0.076 * gestastionWeek) +
-                        43.843;
-                }
-                */
-
-                targetData = getCurData(actor, ft.age);
-                targetLen = targetData.size * targetData.rate;
-
-                ft.volume = ((4 / 3) * (Math.PI) * (phi / 2) * (Math.pow((targetLen / 2), 3)));
-                wombSize += ft.volume;
-
-                //oldVol = ((4 / 3) * (Math.PI) * (phi / 2) * (Math.pow((oldLen / 2), 3))); //for debug
-
-                //console.log("fetus.age:" + ft.age + "  oldLen:"+oldLen+"  targetLen:"+targetLen+"  ft.volume:"+ft.volume+ "  old volume:"+oldVol );
-                /*
-                    I found, that previous targetLen calculation not exactly accurate if compared to the actual medical data chart for fetal length. It's been rough aproximation based only on pregnancy week (giving smaller fetus size then it should in most cases). So I need all this debug code to compare data and verify calculations. After final tweaking I will remove or comment out legacy code. Please not touch this before it.
-                    Pregmodfan.
-                */
-            });
-        } catch(err){
-            WombInit(actor);
-            alert("WombGetVolume warning - " + actor.slaveName + " " + err);
-        }
-        if (wombSize < 0) //catch for strange cases, to avoid messing with outside code.
-            wombSize = 0;
-
-        return wombSize;
-
-    }
-
-
-    function getVolByWeight(actor)
-    {
-        var targetData;
-        var wombSize = 0;
-
-        actor.womb.forEach(ft => {
-
-            targetData = getCurData(actor, ft.age);
-
-            wombSize += targetData.size * targetData.rate;
-
-        });
-
-        if (wombSize < 0) //catch for strange cases, to avoid messing with outside code.
-            wombSize = 0;
-
-        return wombSize;
-    }
-
-
-    function getVolByRaw(actor)
-    {
-        var targetData;
-        var wombSize = 0;
-
-        actor.womb.forEach(ft => {
-
-            targetData = getCurData(actor, ft.age);
-
-            wombSize += targetData.size;
-
-        });
-
-        if (wombSize < 0) //catch for strange cases, to avoid messing with outside code.
-            wombSize = 0;
-
-        return wombSize;
-    }
-
-
-
-    function getVolByWeight(actor)
-    {
-        var targetData;
-        var wombSize = 0;
-
-        actor.womb.forEach(ft => {
 
 	if (actor.pregData.sizeType == 0)
 		return getVolByLen(actor);
@@ -11337,7 +11187,6 @@ window.WombGetVolume = function(actor) { //most legacy code from pregJS.tw with
 		//maybe not very effective code, but simple and easy to debug. May be optimized more in future.
 	}
 
-
 	function getVolByLen(actor){
 
 	try {
@@ -11381,7 +11230,7 @@ window.WombGetVolume = function(actor) { //most legacy code from pregJS.tw with
 
 				//console.log("fetus.age:" + ft.age + "  oldLen:"+oldLen+"  targetLen:"+targetLen+"  ft.volume:"+ft.volume+ "  old volume:"+oldVol );
 				/*
-					I found, that previous targetLen calculation not exactly accurate if compared to the actual medical data chart for fetal length. It's been rough aproximation based only on pregnancy week (giving smaller fetus size then it should in most cases). So I need all this debug code to compare data and verify calculations. After final tweaking I will remove or comment out legacy code. Please not touch this before it.
+					I found, that previous targetLen calculation not exactly accurate if compared to the actual medical data chart for fetal length. It's been rough approximation based only on pregnancy week (giving smaller fetus size then it should in most cases). So I need all this debug code to compare data and verify calculations. After final tweaking I will remove or comment out legacy code. Please not touch this before it.
 					Pregmodfan.
 				*/
 			});
diff --git a/src/js/slaveGenerationJS.tw b/src/js/slaveGenerationJS.tw
index 72a100761d6..b0e48712d15 100644
--- a/src/js/slaveGenerationJS.tw
+++ b/src/js/slaveGenerationJS.tw
@@ -5,6 +5,7 @@ window.nationalityToRace = function nationalityToRace(slave) {
 };
 
 window.raceToNationality = function raceToNationality(slave) {
+	/* consider this placeholder until raceNationalities gets fixed up */
 	const V = State.variables;
 	slave.nationality = hashChoice(V.nationalities);
 	/* Maximum of 100 attempts */
diff --git a/src/js/wombJS.tw b/src/js/wombJS.tw
index 1d9f86441ea..f71ad82d8ff 100644
--- a/src/js/wombJS.tw
+++ b/src/js/wombJS.tw
@@ -1,8 +1,7 @@
 :: wombJS [script]
 
 /*
-This is womb processor/simulator script. It's take care about calculation of belly sizes based on individual fetus sizes,
-with full support of broodmothers implant random turning on and off possibility. Also this can be expanded to store more parents data in each individual fetus in future.
+This is womb processor/simulator script. It takes care about calculation of belly sizes based on individual fetus sizes, with full support of broodmothers implant random turning on and off possibility. Also this can be expanded to store more parents data in each individual fetus in future.
 Design limitations:
 - Mother can't gestate children with different speeds at same time. All speed changes apply to all fetuses.
 - Sizes of individual fetuses updated only on call of WombGetVolume - not every time as called WombProgress. This is for better overall code speed.
@@ -45,12 +44,12 @@ window.WombInit = function(actor) {
 		actor.readyOva = 0;
 	}
 
-    if ( actor.pregData == undefined)
-    {
-        actor.pregData = clone( setup.pregData.human );
-        //Setup should be through deep copy, so in future, if we like, these values can be changed individually. Gameplay expansion possibilities. But for dev time to simplify debugging:
-        //actor.pregData = setup.pregData.human;  // any changes in setup pregData template will be applied immediately to all. But can't be made separate changes.
-    }
+	if ( actor.pregData == undefined)
+	{
+		actor.pregData = clone( setup.pregData.human );
+		//Setup should be through deep copy, so in future, if we like, these values can be changed individually. Gameplay expansion possibilities. But for dev time to simplify debugging:
+		//actor.pregData = setup.pregData.human;  // any changes in setup pregData template will be applied immediately to all. But can't be made separate changes.
+	}
 
 	//backward compatibility setup. Fully accurate for normal pregnancy only.
 	if (actor.womb.length > 0 && actor.womb[0].genetics == undefined) {
@@ -235,7 +234,6 @@ window.WombGetVolume = function(actor) { //most legacy code from pregJS.tw with
 		//maybe not very effective code, but simple and easy to debug. May be optimized more in future.
 	}
 
-
 	function getVolByLen(actor){
 
 	try {
@@ -279,7 +277,7 @@ window.WombGetVolume = function(actor) { //most legacy code from pregJS.tw with
 
 				//console.log("fetus.age:" + ft.age + "  oldLen:"+oldLen+"  targetLen:"+targetLen+"  ft.volume:"+ft.volume+ "  old volume:"+oldVol );
 				/*
-					I found, that previous targetLen calculation not exactly accurate if compared to the actual medical data chart for fetal length. It's been rough aproximation based only on pregnancy week (giving smaller fetus size then it should in most cases). So I need all this debug code to compare data and verify calculations. After final tweaking I will remove or comment out legacy code. Please not touch this before it.
+					I found, that previous targetLen calculation not exactly accurate if compared to the actual medical data chart for fetal length. It's been rough approximation based only on pregnancy week (giving smaller fetus size then it should in most cases). So I need all this debug code to compare data and verify calculations. After final tweaking I will remove or comment out legacy code. Please not touch this before it.
 					Pregmodfan.
 				*/
 			});
-- 
GitLab