diff --git a/src/js/storyJS.tw b/src/js/storyJS.tw index cc8212777d422dea86ed16eb8dd1c1e5fa287da4..5ca395259bebcad5a382d9d6aaa9ccd2f126bc8d 100644 --- a/src/js/storyJS.tw +++ b/src/js/storyJS.tw @@ -983,3 +983,16 @@ window.SoftenSexualFlaw = function SoftenSexualFlaw(slave) { } slave.sexualFlaw = "none"; }; + +window.genUUID = function() { + var d = new Date().getTime(); + if(Date.now){ + d = Date.now(); //high-precision timer + } + var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = (d + Math.random()*16)%16 | 0; + d = Math.floor(d/16); + return (c=='x' ? r : (r&0x3|0x8)).toString(16); + }); + return uuid; +}; diff --git a/src/js/wombJS.tw b/src/js/wombJS.tw index 499bc78d679e8293f5631f19ccb26e6459aca8c3..bf2d9813f433cb8e86cb38fb9f51b19cdd025e0d 100644 --- a/src/js/wombJS.tw +++ b/src/js/wombJS.tw @@ -87,6 +87,7 @@ window.WombImpregnate = function(actor, fCount, fatherID, age) { 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. + tf.ID = genUUID(); try { if (actor.womb.length == 0) { @@ -329,7 +330,14 @@ window.fetalSplit = function(actor, chance) { s.splitted = 1; //this is marker that this is already splitted fetus (to not split second time in loop), only source fetus needed it. nft.identical = 1; //this is marker that this fetus has at least one twin. s.identical = 1; //this is marker that this fetus has at least one twin. - actor.womb.push(nft); + + if (s.twinID == "" || s.twinID == undefined) + s.twinID = genUUID(); + + nft.twinID = s.twinID; + + actor.womb.push(nft); + } }); WombNormalizePreg(actor); @@ -573,6 +581,10 @@ window.BCReserveInit = function() ft.reserve = ""; if (typeof ft.motherID != 'number') //setting missing biological mother ID for fetus. ft.motherID = slave.ID; + + if (ft.ID == undefined) + ft.ID = genUUID(); + try { if (slave.reservedChildren > 0) WombSetGenericReserve(slave, "incubator", reservedChildren);