diff --git a/src/data/newGamePlus.js b/src/data/newGamePlus.js index f5a569ea612662e0a39f428dcde935087e67530a..506bf21159e86316b6769813f73eba7bc5dcd4d9 100644 --- a/src/data/newGamePlus.js +++ b/src/data/newGamePlus.js @@ -69,15 +69,32 @@ App.Data.NewGamePlus = (function() { const ngUpdateMissingTable = function(missingTable) { const newTable = {}; + let needed = []; (V.slaves || []) .forEach(s => ([s.pregSource + NGPOffset, s.mother + NGPOffset, s.father + NGPOffset] .filter(i => (i in missingTable)) .forEach(i => { - newTable[i - NGPOffset] = missingTable[i]; - newTable[i - NGPOffset].ID -= NGPOffset; + if (needed.index(i) === -1) + needed.push(i); }))); + while (needed.length > 0) { + let s = needed.shift(); + newTable[i - NGPOffset] = s; + s.ID -= NGPOffset; + if (s.mother in missingTable) { + s.mother -= NGPOffset; + if (!(s.mother in newTable) && needed.indexOf(s.mother + NGPOffset) === -1) + needed.push(s.mother + NGPOffset); + } + if (s.father in missingTable) { + s.father -= NGPOffset; + if (!(s.father in newTable) && needed.indexOf(s.father + NGPOffset) === -1) + needed.push(s.father + NGPOffset); + } + } + return newTable; };