Skip to content
Snippets Groups Projects
Commit 4e533dc7 authored by Pregmodder's avatar Pregmodder
Browse files

Merge branch 'slavesInLine' into 'pregmod-master'

slavesInLine Improvement

See merge request !1827
parents ec9b89d5 39244e52
No related branches found
No related tags found
2 merge requests!2047RA rework,!1827slavesInLine Improvement
......@@ -139,6 +139,9 @@
<<if def $eventSlaves>>
<<unset $eventSlaves>>
<</if>>
<<if def $place>>
<<unset $place>>
<</if>>
/* pregmod stuff */
......
......@@ -2,15 +2,11 @@
<<silently>>
<<set $i = $slaves.findIndex(function(s) { return s.ID == $activeSlave.ID; })>>
<<set $i = $slaveIndices[$activeSlave.ID]>>
<<ClearSummaryCache $activeSlave>>
<<set $slaves[$i] = $activeSlave>> /* save changes before switching */
<<if $place == $slavesInLine.length-1>>
<<set $activeSlave = $slavesInLine[0]>>
<<else>>
<<set $activeSlave = $slavesInLine[$place+1]>>
<</if>>
<<set $activeSlave = $slaves[$slavesInLine[1]]>>
<<goto "Slave Interact">>
......
......@@ -3,21 +3,52 @@
<<silently>>
<<set $slavesInLine = []>>
<<set _activeSlaveIndex = $slaveIndices[$activeSlave.ID]>>
<<set _SL = $slaves.length>>
<<if ($activeSlave.assignmentVisible == 1)>>
<<for $i = 0; $i < $slaves.length; $i++>>
<<if ($slaves[$i].assignmentVisible == 1)>>
<<set $slavesInLine.push($slaves[$i])>>
<</if>>
<<for _pil = _activeSlaveIndex - 1; _pil != _activeSlaveIndex; _pil-->> /* loops backwards through the $slaves array */
<<if _pil < 0>>
<<set _pil = _SL - 1>>
<</if>>
<<if $slaves[_pil].assignmentVisible == 1>>
<<set $slavesInLine.push(_pil)>> /* index of the previous slave in line */
<<break>>
<</if>>
<</for>>
<<for _pil = _activeSlaveIndex + 1; _pil != _activeSlaveIndex; _pil++>> /* this loops forwards through the $slaves array */
<<if _pil == _SL>>
<<set _pil = 0>>
<</if>>
<<if $slaves[_pil].assignmentVisible == 1>>
<<set $slavesInLine.push(_pil)>> /* index of the next slave in line */
<<break>>
<</if>>
<</for>>
<<else>>
<<for $i = 0; $i < $slaves.length; $i++>>
<<if ($slaves[$i].assignment == $activeSlave.assignment)>>
<<set $slavesInLine.push($slaves[$i])>>
<</if>>
<<for _pil = _activeSlaveIndex - 1; _pil != _activeSlaveIndex; _pil-->> /* loops backwards through the $slaves array */
<<if _pil < 0>>
<<set _pil = _SL - 1>>
<</if>>
<<if ($slaves[_pil].assignment == $activeSlave.assignment)>>
<<set $slavesInLine.push(_pil)>> /* index of the previous slave in line */
<<break>>
<</if>>
<</for>>
<<for _pil = _activeSlaveIndex + 1; _pil != _activeSlaveIndex; _pil++>> /* this loops forwards through the $slaves array */
<<if _pil == _SL>>
<<set _pil = 0>>
<</if>>
<<if ($slaves[_pil].assignment == $activeSlave.assignment)>>
<<set $slavesInLine.push(_pil)>> /* index of the next slave in line */
<<break>>
<</if>>
<</for>>
<</if>>
<<set $place = $slavesInLine.findIndex(function(s) { return s.ID == $activeSlave.ID; })>>
<<if $slavesInLine.length == 0>> /* if there are no other slaves available, set previous/next slave to self */
<<set $slavesInLine[0] = _activeSlaveIndex>>
<<set $slavesInLine[1] = _activeSlaveIndex>>
<</if>>
<</silently>>
......@@ -2,15 +2,11 @@
<<silently>>
<<set $i = $slaves.findIndex(function(s) { return s.ID == $activeSlave.ID; })>>
<<set $i = $slaveIndices[$activeSlave.ID]>>
<<ClearSummaryCache $activeSlave>>
<<set $slaves[$i] = $activeSlave>> /* save changes before switching */
<<if $place == 0>>
<<set $activeSlave = $slavesInLine[$slavesInLine.length-1]>>
<<else>>
<<set $activeSlave = $slavesInLine[$place-1]>>
<</if>>
<<set $activeSlave = $slaves[$slavesInLine[0]]>>
<<goto "Slave Interact">>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment