From 44874d2bb53069b5a646b02f1e5c767a0e9439ea Mon Sep 17 00:00:00 2001 From: kopareigns <kopareigns@gmail.com> Date: Sat, 21 Apr 2018 19:56:22 -0400 Subject: [PATCH] slaveIndices Conversion --- .../mod_EditSlaveCheatDatatypeCleanup.tw | 10 ++--- .../mod_EditSlaveCheatDatatypeCleanupNew.tw | 8 ++-- src/init/storyInit.tw | 20 +++------- src/npc/acquisition.tw | 38 +++++++++---------- src/npc/agent/agentCompany.tw | 4 +- src/npc/agent/agentRetrieve.tw | 4 +- src/npc/descriptions/fAnus.tw | 3 +- src/npc/descriptions/fBoobs.tw | 3 +- src/npc/descriptions/fButt.tw | 3 +- src/npc/descriptions/fFuckdollWidgets.tw | 12 ++---- src/npc/descriptions/fLips.tw | 4 +- src/npc/descriptions/fVagina.tw | 6 +-- src/npc/fRelation.tw | 12 +++--- src/npc/fRival.tw | 2 +- src/uncategorized/BackwardsCompatibility.tw | 3 ++ 15 files changed, 59 insertions(+), 73 deletions(-) diff --git a/src/cheats/mod_EditSlaveCheatDatatypeCleanup.tw b/src/cheats/mod_EditSlaveCheatDatatypeCleanup.tw index cbb3f25a670..98d3dd81d0f 100644 --- a/src/cheats/mod_EditSlaveCheatDatatypeCleanup.tw +++ b/src/cheats/mod_EditSlaveCheatDatatypeCleanup.tw @@ -70,9 +70,7 @@ You perform the dark rituals, pray to the dark gods and sold your soul for the p <br><br>This slave has been changed forever and you have lost a bit of your soul, YOU CHEATER! -<<for $i = 0; $i < $slaves.length; $i++>> - <<if $activeSlave.ID == $slaves[$i].ID>> - <<set $slaves[$i] = $activeSlave>> - <<break>> - <</if>> -<</for>> +<<set _escdc = $slaveIndices[$activeSlave.ID]>> +<<if def _escdc>> + <<set $slaves[_escdc] = $activeSlave>> +<</if>> diff --git a/src/cheats/mod_EditSlaveCheatDatatypeCleanupNew.tw b/src/cheats/mod_EditSlaveCheatDatatypeCleanupNew.tw index f2737b472a6..f47e5c935a6 100644 --- a/src/cheats/mod_EditSlaveCheatDatatypeCleanupNew.tw +++ b/src/cheats/mod_EditSlaveCheatDatatypeCleanupNew.tw @@ -446,7 +446,7 @@ <<set $tempSlave.prestige = 3>> <</if>> <<if $tempSlave.breedingMark == 1 && ["whore", "serve the public", "work a glory hole", "work in the dairy", "serve in the club", "be the DJ", "be the Madam", "live with your Head Girl", "be confined in the arcade", "work in the brothel", "be a subordinate slave"].includes($tempSlave.assignment)>> - <<print "Eugenics Breeding Marked slave detected in questionable use, defualting slave assignment to 'rest'">><br> + <<print "Eugenics Breeding Marked slave detected in questionable use, defaulting slave assignment to 'rest'">><br> <<assignJob $tempSlave "rest">> <</if>> <<SetBellySize $tempSlave>> @@ -458,5 +458,7 @@ You perform the dark rituals, pray to the dark gods and sold your soul for the p <<set $activeSlave = clone($tempSlave)>> <<unset $tempSlave>> -<<set _escn = $slaves.findIndex(function(s) { return $activeSlave.ID == s.ID; })>> -<<set $slaves[_escn] = clone($activeSlave)>> +<<set _escn = $slaveIndices[$activeSlave.ID]>> +<<if def _escn>> + <<set $slaves[_escn] = clone($activeSlave)>> +<</if>> diff --git a/src/init/storyInit.tw b/src/init/storyInit.tw index ab8357012d2..55ad5a8cd66 100644 --- a/src/init/storyInit.tw +++ b/src/init/storyInit.tw @@ -83,8 +83,8 @@ You should have received a copy of the GNU General Public License along with thi <</for>> <<if $slaves[_k].pregSource > 0>> <<set $slaves[_k].pregSource += 1200000>> - <<set _getFather = $slaves.findIndex(function(s) { return s.ID == $slaves[_k].pregSource; })>> - <<if _getFather == -1>> + <<set _getFather = $slaveIndices[$slaves[_k].pregSource]>> + <<if ndef _getFather>> <<set $slaves[_k].pregSource = 0>> <</if>> <</if>> @@ -106,28 +106,20 @@ You should have received a copy of the GNU General Public License along with thi <<for _i = 0; _i < _SL; _i++>> <<if $slaves[_i].relation != 0>> <<set _seed = 0, _rt = $slaves[_i].relationTarget, _ID = $slaves[_i].ID>> - <<for _j = 0; _j < _SL; _j++>> - <<if _rt == $slaves[_j].ID>> - <<if $slaves[_j].relationTarget == _ID>> + <<set _j = $slaveIndices[_rt]>> + <<if def _j && $slaves[_j].relationTarget == _ID>> <<set _seed = 1>> - <<break>> - <</if>> <</if>> - <</for>> <<if _seed == 0>> <<set $slaves[_i].relation = 0, $slaves[_i].relationTarget = 0>> <</if>> <</if>> <<if $slaves[_i].relationship > 0>> <<set _seed = 0, _rt = $slaves[_i].relationshipTarget, _ID = $slaves[_i].ID>> - <<for _j = 0; _j < _SL; _j++>> - <<if _rt == $slaves[_j].ID>> - <<if $slaves[_j].relationshipTarget == _ID>> + <<set _j = $slaveIndices[_rt]>> + <<if def _j && $slaves[_j].relationshipTarget == _ID>> <<set _seed = 1>> - <<break>> - <</if>> <</if>> - <</for>> <<if _seed == 0>> <<set $slaves[_i].relationship = 0, $slaves[_i].relationshipTarget = 0>> <</if>> diff --git a/src/npc/acquisition.tw b/src/npc/acquisition.tw index 9f572b966ae..fe50df7512a 100644 --- a/src/npc/acquisition.tw +++ b/src/npc/acquisition.tw @@ -61,13 +61,13 @@ <</if>> /*closes ng*/ <<if $familyTesting == 1>> <<set _pcMomFound = 0, _pcDadFound = 0>> + <<if def $slaveIndices[$PC.mother]>> + <<set _pcMomFound = 1>> + <</if>> + <<if def $slaveIndices[$PC.father]>> + <<set _pcDadFound = 1>> + <</if>> <<for _i = 0; _i < $slaves.length; _i++>> - <<if $PC.mother > 0 && $PC.mother == $slaves[_i].ID>> - <<set _pcMomFound = 1>> - <</if>> - <<if $PC.father > 0 && $PC.father == $slaves[_i].ID>> - <<set _pcDadFound = 1>> - <</if>> <<if $slaves[_i].mother == $PC.ID || $slaves[_i].father == $PC.ID>> <<set $PC.daughters += 1>> <</if>> @@ -97,14 +97,12 @@ <</if>> <<for _i = 0; _i < $slaves.length; _i++>> <<set _slaveMomFound = 0, _slaveDadFound = 0>> - <<for _j = 0; _j < $slaves.length; _j++>> - <<if $slaves[_i].mother > 0 && $slaves[_i].mother == $slaves[_j].ID>> - <<set _slaveMomFound = 1>> - <</if>> - <<if $slaves[_i].father > 0 && $slaves[_i].father == $slaves[_j].ID>> - <<set _slaveDadFound = 1>> - <</if>> - <</for>> + <<if def $slaveIndices[$slaves[_i].mother]>> + <<set _slaveMomFound = 1>> + <</if>> + <<if def $slaveIndices[$slaves[_i].father]>> + <<set _slaveDadFound = 1>> + <</if>> <<if _slaveMomFound == 0 && $slaves[_i].mother > 0>> <<set _lostMom = $slaves[_i].mother>> <<set $slaves[_i].mother = $missingParentID>> @@ -611,12 +609,12 @@ The previous owner seems to have left in something of a hurry. <<set _slavesContributing = 0>> <<for $i = 0; $i < $slaves.length; $i++>> <<if $slaves[$i].relation != 0>> - <<set $seed = $slaves.findIndex(function(s) { return $slaves[$i].relationTarget == s.ID && s.relationTarget == $slaves[$i].ID; })>> - <<if $seed == -1>> - <<set $slaves[$i].relation = 0>> - <<set $slaves[$i].relationTarget = 0>> - <<goto "Acquisition">> - <</if>> + <<set $seed = $slaveIndices[$slaves[$i].relationTarget]>> + <<if (def $seed && $slaves[$seed].relationTarget != $slaves[$i].ID) || (ndef $seed)>> + <<set $slaves[$i].relation = 0>> + <<set $slaves[$i].relationTarget = 0>> + <<goto "Acquisition">> + <</if>> <</if>> <<set $slaves[$i].oldDevotion = $slaves[$i].devotion>> <<set $slaves[$i].oldTrust = $slaves[$i].trust>> diff --git a/src/npc/agent/agentCompany.tw b/src/npc/agent/agentCompany.tw index 0013796d3e2..8dbdbb32649 100644 --- a/src/npc/agent/agentCompany.tw +++ b/src/npc/agent/agentCompany.tw @@ -10,8 +10,8 @@ <</if>> <<if $activeSlave.rivalry > 0>> - <<set _i = $slaves.findIndex(function(s) { return s.rivalryTarget == _ID; })>> - <<if _i != -1>> + <<set _i = $slaveIndices[$activeSlave.rivalryTarget]>> + <<if def _i>> <<set $slaves[_i].rivalry = 0, $slaves[_i].rivalryTarget = 0>> <<else>> @@.red;Error, activeSlave rival not found.@@ diff --git a/src/npc/agent/agentRetrieve.tw b/src/npc/agent/agentRetrieve.tw index 86ff349b873..831f39bae86 100644 --- a/src/npc/agent/agentRetrieve.tw +++ b/src/npc/agent/agentRetrieve.tw @@ -2,8 +2,8 @@ <<set _ID = $activeArcology.leaderID>> -<<set _i = $slaves.findIndex(function(s) { return s.ID == _ID; })>> -<<if _i != -1>> +<<set _i = $slaveIndices[_ID]>> +<<if def _i>> <<removeJob $slaves[_i] "be your agent">> <</if>> diff --git a/src/npc/descriptions/fAnus.tw b/src/npc/descriptions/fAnus.tw index 893db190557..2ac237bb196 100644 --- a/src/npc/descriptions/fAnus.tw +++ b/src/npc/descriptions/fAnus.tw @@ -215,7 +215,6 @@ Her anus is invitingly bleached, <</if>> <<if passage() != "Slave Interact">> - <<set _i = $slaves.findIndex(function(s) { return s.ID == $activeSlave.ID; })>> - <<set $slaves[_i] = $activeSlave>> + <<set $slaves[$slaveIndices[$activeSlave.ID]] = $activeSlave>> <</if>> <<set _Anus = "">> diff --git a/src/npc/descriptions/fBoobs.tw b/src/npc/descriptions/fBoobs.tw index 1b3bab671f5..71b18807d1d 100644 --- a/src/npc/descriptions/fBoobs.tw +++ b/src/npc/descriptions/fBoobs.tw @@ -213,6 +213,5 @@ tits. <</if>> <<if passage() !== "Slave Interact">> - <<set _i = $slaves.findIndex(function(s) { return s.ID == $activeSlave.ID; })>> - <<set $slaves[_i] = $activeSlave>> + <<set $slaves[$slaveIndices[$activeSlave.ID]] = $activeSlave>> <</if>> diff --git a/src/npc/descriptions/fButt.tw b/src/npc/descriptions/fButt.tw index aca637eecc0..9848691a17f 100644 --- a/src/npc/descriptions/fButt.tw +++ b/src/npc/descriptions/fButt.tw @@ -235,6 +235,5 @@ Her anus is invitingly bleached, <</if>> <<if passage() !== "Slave Interact">> - <<set _i = $slaves.findIndex(function(s) { return s.ID == $activeSlave.ID; })>> - <<set $slaves[_i] = $activeSlave>> + <<set $slaves[$slaveIndices[$activeSlave.ID]] = $activeSlave>> <</if>> diff --git a/src/npc/descriptions/fFuckdollWidgets.tw b/src/npc/descriptions/fFuckdollWidgets.tw index 512c3cd274e..e90b554b20b 100644 --- a/src/npc/descriptions/fFuckdollWidgets.tw +++ b/src/npc/descriptions/fFuckdollWidgets.tw @@ -32,8 +32,7 @@ You climax, <<if $PC.dick == 1>>blowing your load down its throat<<else>>giving <</if>> <<if passage() != "Slave Interact">> - <<set _i = $slaves.findIndex(function(s) { return s.ID == $activeSlave.ID; })>> - <<set $slaves[_i] = $activeSlave>> + <<set $slaves[$slaveIndices[$activeSlave.ID]] = $activeSlave>> <</if>> <</widget>> @@ -89,8 +88,7 @@ You climax<<if $PC.dick == 1>>, your cum shooting forward to splash against its <</if>> <<if passage() != "Slave Interact">> - <<set _i = $slaves.findIndex(function(s) { return s.ID == $activeSlave.ID; })>> - <<set $slaves[_i] = $activeSlave>> + <<set $slaves[$slaveIndices[$activeSlave.ID]] = $activeSlave>> <</if>> <</widget>> @@ -177,8 +175,7 @@ You repeat this ritual throughout the week, ensuring that it will be an @@.lime; <</if>> <<if passage() != "Slave Interact">> - <<set _i = $slaves.findIndex(function(s) { return s.ID == $activeSlave.ID; })>> - <<set $slaves[_i] = $activeSlave>> + <<set $slaves[$slaveIndices[$activeSlave.ID]] = $activeSlave>> <</if>> <</widget>> @@ -234,8 +231,7 @@ You climax<<if $PC.dick == 1>>, filling its rectum with your cum,<</if>> and ret <</if>> <<if passage() != "Slave Interact">> - <<set _i = $slaves.findIndex(function(s) { return s.ID == $activeSlave.ID; })>> - <<set $slaves[_i] = $activeSlave>> + <<set $slaves[$slaveIndices[$activeSlave.ID]] = $activeSlave>> <</if>> <</widget>> \ No newline at end of file diff --git a/src/npc/descriptions/fLips.tw b/src/npc/descriptions/fLips.tw index 5a8c5d1d63b..9319857d8fc 100644 --- a/src/npc/descriptions/fLips.tw +++ b/src/npc/descriptions/fLips.tw @@ -174,8 +174,8 @@ You tell $activeSlave.slaveName to <</if>> <<if passage() != "Slave Interact">> - <<set _fl = $slaves.findIndex(function(s) { return s.ID == $activeSlave.ID; })>> - <<if _fl != -1>> + <<set _fl = $slaveIndices[$activeSlave.ID]>> + <<if def _fl != -1>> <<set $slaves[_fl] = $activeSlave>> <</if>> <</if>> diff --git a/src/npc/descriptions/fVagina.tw b/src/npc/descriptions/fVagina.tw index af198931a3c..41ade45ebbc 100644 --- a/src/npc/descriptions/fVagina.tw +++ b/src/npc/descriptions/fVagina.tw @@ -547,8 +547,8 @@ You call her over so you can <</if>> <<if passage() != "Slave Interact">> - <<set _i = $slaves.findIndex(function(s) { return s.ID == $activeSlave.ID; })>> - <<if _i != -1>> - <<set $slaves[_i] = $activeSlave>> + <<set _fv = $slaveIndices[$activeSlave.ID]>> + <<if def _fv>> + <<set $slaves[_fv] = $activeSlave>> <</if>> <</if>> diff --git a/src/npc/fRelation.tw b/src/npc/fRelation.tw index 065a35c7f48..8a421443799 100644 --- a/src/npc/fRelation.tw +++ b/src/npc/fRelation.tw @@ -1,14 +1,14 @@ :: FRelation [nobr] <<if ($partner == "mother")>> - <<set $partner = $slaves.findIndex(function(s) { return s.ID == $activeSlave.mother; })>> + <<set $partner = $slaveIndices[$activeSlave.mother]>> <<set _activeSlaveRel = "daughter", _partnerRel = "mother">> <<elseif ($partner == "father")>> - <<set $partner = $slaves.findIndex(function(s) { return s.ID == $activeSlave.father; })>> + <<set $partner = $slaveIndices[$activeSlave.father]>> <<set _activeSlaveRel = "daughter", _partnerRel = "father">> <<elseif ($partner == "daughter")>> <<set $partner = randomAvailableDaughter($activeSlave)>> - <<set $partner = $slaves.findIndex(function(s) { return s.ID == $partner.ID; })>> + <<set $partner = $slaveIndices[$partner.ID]>> <<if $activeSlave.ID == $slaves[$partner].father>> <<set _activeSlaveRel = "father", _partnerRel = "daughter">> <<elseif $activeSlave.ID == $slaves[$partner].mother>> @@ -16,7 +16,7 @@ <</if>> <<elseif ($partner == "sister")>> <<set $partner = randomAvailableSister($activeSlave)>> - <<set $partner = $slaves.findIndex(function(s) { return s.ID == $partner.ID; })>> + <<set $partner = $slaveIndices[$partner.ID]>> <<switch areSisters($activeSlave, $slaves[$partner])>> <<case 3>> <<set _activeSlaveRel = "half-sister", _partnerRel = "half-sister">> @@ -26,10 +26,10 @@ <<set _activeSlaveRel = "twin", _partnerRel = "twin">> <</switch>> <<elseif ($partner == "relation")>> - <<set $partner = $slaves.findIndex(function(s) { return s.ID == $activeSlave.relationTarget; })>> + <<set $partner = $slaveIndices[$activeSlave.relationTarget]>> <<set _activeSlaveRel = $activeSlave.relation, _partnerRel = $slaves[$partner].relation>> <<else>> - <<set $partner = $slaves.findIndex(function(s) { return s.ID == $activeSlave.relationshipTarget; })>> + <<set $partner = $slaveIndices[$activeSlave.relationshipTarget]>> <<switch $activeSlave.relationship>> <<case 1>> <<set _activeSlaveRel = "friend", _partnerRel = "friend">> diff --git a/src/npc/fRival.tw b/src/npc/fRival.tw index 58ce9fe5af0..9df812e8b26 100644 --- a/src/npc/fRival.tw +++ b/src/npc/fRival.tw @@ -1,6 +1,6 @@ :: FRival [nobr] -<<set $partner = $slaves.findIndex(function(s) { return s.ID == $activeSlave.rivalryTarget; })>> +<<set $partner = $slaveIndices[$activeSlave.rivalryTarget]>> <<ClearSummaryCache $activeSlave>> <<ClearSummaryCache $slaves[$partner]>> diff --git a/src/uncategorized/BackwardsCompatibility.tw b/src/uncategorized/BackwardsCompatibility.tw index 7f21b6cfe3d..4789fdb3dcd 100644 --- a/src/uncategorized/BackwardsCompatibility.tw +++ b/src/uncategorized/BackwardsCompatibility.tw @@ -166,6 +166,9 @@ <<if def $piercingLocation>> <<unset $piercingLocation>> <</if>> +<<if def $target1 || def $target2 || def $target3>> + <<unset $target1, $target2, $target3>> +<</if>> /* pregmod stuff */ -- GitLab