From 6767337886bce1b5be32802d1dd13e1486c3b408 Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Wed, 11 Mar 2020 22:54:25 -0400
Subject: [PATCH] fix splice

---
 src/js/heroCreator.js                     | 11 +++++++----
 src/npc/databases/customSlavesDatabase.tw |  4 ++--
 src/uncategorized/completeCatalog.tw      |  3 ++-
 src/uncategorized/newSlaveIntro.tw        |  3 ++-
 4 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/js/heroCreator.js b/src/js/heroCreator.js
index ccea1381c11..9283d8d6603 100644
--- a/src/js/heroCreator.js
+++ b/src/js/heroCreator.js
@@ -18,22 +18,24 @@ App.Utils.buildHeroArray = function() {
 		);
 	}
 	if (V.heroSlaves) {
+		console.log("array length: ", array.length);
 		array = array.concat(V.heroSlaves);
 		console.log("found and integrated custom slaves: ", V.heroSlaves);
+		console.log("array length: ", array.length);
 	}
 	for (let hero = 0; hero < array.length; hero++) {
 		if (V.seePreg !== 1 && [900089, 900102].includes(array[hero].ID)) {
-			array.splice(hero);
+			array.splice(hero, 1);
 			hero--;
 			continue;
 		}
 		if (V.familyTesting !== 1 && [900110, 900111].includes(array[hero].ID)) {
-			array.splice(hero);
+			array.splice(hero, 1);
 			hero--;
 			continue;
 		}
 		if (V.heroSlavesPuchased.includes(array[hero].ID)) {
-			array.splice(hero);
+			array.splice(hero, 1);
 			hero--;
 			continue;
 		}
@@ -72,7 +74,6 @@ App.Utils.getHeroSlave = function(heroSlave) {
 	if (!heroSlave.hasOwnProperty("birthWeek")) {
 		heroSlave.birthWeek = random(0, 51);
 	}
-	heroSlave.ID = generateSlaveID();
 	// Nationalities, races, surnames random fill
 	if (!heroSlave.nationality) {
 		// Check for a pre-set race and if the nationality fits, else regenerate
@@ -108,6 +109,8 @@ App.Utils.getHeroSlave = function(heroSlave) {
 	// WombInit(heroSlave);
 	const newSlave = BaseSlave();
 	deepAssign(newSlave, heroSlave);
+	V.heroSlaveID = heroSlave.ID;
+	newSlave.ID = generateSlaveID();
 	newSlave.albinismOverride = albinismOverride;
 	repairLimbs(newSlave);
 	generatePuberty(newSlave);
diff --git a/src/npc/databases/customSlavesDatabase.tw b/src/npc/databases/customSlavesDatabase.tw
index 01340a55ef3..0356b639fde 100644
--- a/src/npc/databases/customSlavesDatabase.tw
+++ b/src/npc/databases/customSlavesDatabase.tw
@@ -1,11 +1,11 @@
 :: custom Slaves Database [nobr]
 
 <<set $heroSlaves = []>>
-/*
+
 <<set _i = 1000000>>
 <<set _HS = App.Entity.SlaveState.makeSkeleton()>>
 <<set _HS.slaveName = "McChesterton", _HS.birthName = "Testy", _HS.origin = "$He is obsessed with testing new customizations of $his body.", _HS.ID = _i++, _HS.birthWeek = random(0,51), _HS.actualAge = 24, _HS.physicalAge = 24, _HS.visualAge = 24, _HS.ovaryAge = 24, setHealth(_HS, 20), _HS.devotion = 100, _HS.weight = 25, _HS.origHColor = "chestnut", _HS.pubicHColor = "chestnut", _HS.hLength = 30, _HS.hStyle = "shoulder-length and in a bun", _HS.boobs = 700, _HS.butt = 3, _HS.vagina = 1, _HS.vaginaLube = 1, _HS.anus = 1, _HS.ovaries = 1, _HS.skill.vaginal = 15, _HS.skill.oral = 15, _HS.skill.anal = 15, _HS.skill.entertainment = 1, _HS.clothes = "a nice maid outfit", _HS.intelligence = 20, _HS.intelligenceImplant = 30, _HS.attrXY = 40, _HS.fetish = "submissive", _HS.career = "a maid", _HS.eyewear = "corrective glasses">>
 <<run eyeSurgery(_HS, "both", "blur")>>
 <<set $heroSlaves.push(_HS)>>
 
-To add custom slaves, try to use the format of the above example. Add new slaves below this line. */
\ No newline at end of file
+/*To add custom slaves, try to use the format of the above example. Add new slaves below this line. */
\ No newline at end of file
diff --git a/src/uncategorized/completeCatalog.tw b/src/uncategorized/completeCatalog.tw
index 002861592cd..eec6f5db3d7 100644
--- a/src/uncategorized/completeCatalog.tw
+++ b/src/uncategorized/completeCatalog.tw
@@ -7,11 +7,12 @@
 <br><br>
 <<include "custom Slaves Database">>
 <<set _heroSlaves = App.Utils.buildHeroArray()>>
+<<run console.log("total array ", _heroSlaves)>>
 <<unset $heroSlaves>>
 
 <<for $i = 0; $i < _heroSlaves.length; $i++>>
 	<<if $i > 0>> | <</if>>
-	<<if _heroSlaves[$i].ID == $activeSlave.ID>>
+	<<if _heroSlaves[$i].slaveName == $activeSlave.slaveName>>
 		<span class="note">_heroSlaves[$i].slaveName</span>
 	<<else>>
 		<<print "[[_heroSlaves[$i].slaveName|Complete Catalog][$activeSlave = App.Utils.getHeroSlave(_heroSlaves[" + $i + "])]]">>
diff --git a/src/uncategorized/newSlaveIntro.tw b/src/uncategorized/newSlaveIntro.tw
index 205f49b4288..4a4c6cdee00 100644
--- a/src/uncategorized/newSlaveIntro.tw
+++ b/src/uncategorized/newSlaveIntro.tw
@@ -89,7 +89,8 @@
 <</if>>
 
 <<if $specialSlave == 1>>
-	<<run $heroSlavesPuchased.push($activeSlave.ID)>>
+	<<run $heroSlavesPuchased.push($heroSlaveID)>>
+	<<unset $heroSlaveID>>
 	<<set $specialSlave = 0>>
 <</if>>
 
-- 
GitLab