From 66f7cbc3cbf7b779f57a29418c46dfe0d68c3bd2 Mon Sep 17 00:00:00 2001 From: Pregmodder <pregmodder@gmail.com> Date: Sat, 17 Nov 2018 15:26:13 -0500 Subject: [PATCH] fixes undefined issue in pre-enslavement conception --- src/js/generateGenetics.tw | 21 ++++++++++++++++----- src/js/wombJS.tw | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/js/generateGenetics.tw b/src/js/generateGenetics.tw index 8af37cb282f..5c3c5997a6b 100644 --- a/src/js/generateGenetics.tw +++ b/src/js/generateGenetics.tw @@ -13,8 +13,19 @@ window.generateGenetics = (function() { function generateGenetics(actor1, actor2, x) { V = State.variables; genes = {gender: "XX", name: "blank", surname: 0, mother: 0, motherName: "none", father: 0, fatherName: "none", nationality: "Stateless", race: "white", intelligence: 0, face: 0, eyeColor: "brown", hColor: "black", skin: "white", markings: "none", behavioralFlaw: "none", sexualFlaw: "none", pubicHSyle: "bushy", underArmHStyle: "bushy", geneticQuirks: 0}; - mother = (actor1 > 0) ? V.genePool.findIndex(function(s) { return s.ID == actor1; }) : V.PC; - activeMother = (actor1 > 0) ? V.slaves[V.slaveIndices[actor1]] : V.PC; + if (actor1.ID > 0) { + mother = V.genePool.findIndex(function(s) { return s.ID == actor1.ID; }); + if (mother === undefined) { + mother = actor1; + } + activeMother = V.slaves[V.slaveIndices[actor1]]; + if (activeMother === undefined) { + activeMother = actor1; + } + } else { + activeMother = V.PC; + mother = V.PC; + } father = (actor2 > 0) ? V.genePool.findIndex(function(s) { return s.ID == actor2; }) : (actor2 == -1) ? V.PC : 0; @@ -24,7 +35,7 @@ window.generateGenetics = (function() { genes.gender = setGender(father); genes.name = setName(x); - genes.mother = setMotherID(actor1); + genes.mother = setMotherID(actor1.ID); genes.motherName = setMotherName(activeMother); genes.father = setFatherID(actor2); genes.fatherName = setFatherName(father, activeFather); @@ -72,8 +83,8 @@ window.generateGenetics = (function() { } // motherID - function setMotherID(actor1) { - return actor1; + function setMotherID(actor1ID) { + return actor1ID; } // motherName diff --git a/src/js/wombJS.tw b/src/js/wombJS.tw index c218dbe6526..eaf9ff792de 100644 --- a/src/js/wombJS.tw +++ b/src/js/wombJS.tw @@ -85,7 +85,7 @@ window.WombImpregnate = function(actor, fCount, fatherID, age) { 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.genetics = generateGenetics(actor.ID, fatherID, i+1); //Stored genetic information. + tf.genetics = generateGenetics(actor, fatherID, i+1); //Stored genetic information. try { if (actor.womb.length == 0) { -- GitLab