Each of the three cases where dispersal is calculated should be refactored into a separate function, so that the goto's can be removed.
Also, the log lines needs to fixed so that the current player is not removed from the count. For example, for rank dispersal:
String a = rankers[1] + "/" + rankers[2];
if (isSQDM) a = a + "/" + rankers[3] + "/" + rankers[4];
DebugWrite("^9(DEBUG) ToTeamByDispersal: analysis of ^b" + name + "^n dispersal of rank >= " + perMode.DisperseEvenlyByRank + ": " + a, 5);
Since this log line happens before rankers is used to select the target team, the log line would have to be moved after and the player added back to the team count they belong to before the string is constructed, something like:
int pTeam = ... get players's team ...;
rankers[pTeam] += 1;
Each of the three cases where dispersal is calculated should be refactored into a separate function, so that the goto's can be removed.
Also, the log lines needs to fixed so that the current player is not removed from the count. For example, for rank dispersal:
Since this log line happens before rankers is used to select the target team, the log line would have to be moved after and the player added back to the team count they belong to before the string is constructed, something like: