From 550b78cf99ffd6abd3ae15e419cd9ff1f908b889 Mon Sep 17 00:00:00 2001
From: Arkerthan <arkerthan@gmail.com>
Date: Tue, 17 Sep 2019 16:53:46 +0200
Subject: [PATCH] make currentState local

---
 src/npc/descriptions/limbs.js | 51 +++++++++++------------------------
 1 file changed, 16 insertions(+), 35 deletions(-)

diff --git a/src/npc/descriptions/limbs.js b/src/npc/descriptions/limbs.js
index b40abd3c1c6..d2e6657084a 100644
--- a/src/npc/descriptions/limbs.js
+++ b/src/npc/descriptions/limbs.js
@@ -1,6 +1,5 @@
 App.Desc.limbChange = function() {
 	return {
-		currentState: currentState,
 		currentLimbs: currentLimbs,
 		amputate: amputate,
 		prosthetic: prosthetic,
@@ -9,38 +8,6 @@ App.Desc.limbChange = function() {
 		reaction: reaction
 	};
 
-	/**
-	 * Generates an array with the current limbs of a slave to be used in other limbChange functions.
-	 * @param {App.Entity.SlaveState} slave
-	 * @param {boolean} [PLimb]
-	 * @returns {[number]}
-	 */
-	function currentState(slave, PLimb = true) {
-		let a = [];
-		if (hasLeftArm(slave)) {
-			a[0] = getLeftArmID(slave);
-		} else {
-			// limb interfaces are stored as their negative value
-			a[0] = PLimb ? -slave.PLimb : 0;
-		}
-		if (hasRightArm(slave)) {
-			a[1] = getRightArmID(slave);
-		} else {
-			a[1] = PLimb ? -slave.PLimb : 0;
-		}
-		if (hasLeftLeg(slave)) {
-			a[2] = getLeftLegID(slave);
-		} else {
-			a[2] = PLimb ? -slave.PLimb : 0;
-		}
-		if (hasRightLeg(slave)) {
-			a[3] = getRightLegID(slave);
-		} else {
-			a[3] = PLimb ? -slave.PLimb : 0;
-		}
-		return a;
-	}
-
 	/**
 	 * Generates an object usable with the standard limb check functions.
 	 * @param {App.Entity.SlaveState} slave
@@ -147,7 +114,21 @@ App.Desc.limbChange = function() {
 		if (slave.PLimb < 1) {
 			return "//You must install a prosthetic interface before you can attach prosthetics.//";
 		}
-		const state = currentState(slave, false);
+		const state = currentState(slave);
+
+		/**
+		 * Generates an array with the current limbs of a slave.
+		 * @param {App.Entity.SlaveState} slave
+		 * @returns {[number]}
+		 */
+		function currentState(slave) {
+			let a = [];
+			a[0] = getLeftArmID(slave);
+			a[1] = getRightArmID(slave);
+			a[2] = getLeftLegID(slave);
+			a[3] = getRightLegID(slave);
+			return a;
+		}
 
 		function entry(pos, id) {
 			if (state[pos] === 1) {
@@ -183,7 +164,7 @@ App.Desc.limbChange = function() {
 			}
 		}
 
-		r = "<<set _newState = App.Desc.limbChange().currentState($activeSlave, false)>>" +
+		r = `<<set _newState = [${state}]>>` +
 			"<style> .selector{display: grid; grid-template-columns: 200px 100px 100px 100px 100px;}" +
 			".cyber {grid-column-start: 1; grid-column-end: 6;</style>" +
 			`<div class='selector'>${r}</div>${apply()}`;
-- 
GitLab