private void Reassign(String name, int fromTeam, int toTeam, int diff)
{
if (toTeam == 0) toTeam = fromTeam;
// This is not a known player yet, so not PlayerModel to use
// Just do a raw move as quickly as possible, no messages, just logging
String doing = (EnableLoggingOnlyMode) ? "^9(SIMULATING) ^b^4REASSIGNING^0^n new player ^b" : "^b^4REASSIGNING^0^n new player ^b";
String because = (diff > 0) ? ", because difference is " + diff : String.Empty;
if (!fWhileScrambling) {
DebugWrite(doing + name + "^n from " + GetTeamName(fromTeam) + " team to " + GetTeamName(toTeam) + " team" + because, 4);
} else {
DebugWrite(doing + name + "^n to " + GetTeamName(toTeam) + " team" + because, 4);
}
int toSquad = ToSquad(name, toTeam);
if (!EnableLoggingOnlyMode) {
if (fromTeam != toTeam) fReassigned.Add(name);
ServerCommand("admin.movePlayer", name, toTeam.ToString(), toSquad.ToString(), "false");
if (fWhileScrambling) {
lock (fExtrasLock) {
if (!fExtraNames.Contains(name)) fExtraNames.Add(name);
fDebugScramblerSuspects[name] = "New player ^b{0}^n joined " + GetTeamName(toTeam) + "/" + GetSquadName(toSquad);
}
// Can't use reassigning logic if player is already in the right team
if (fromTeam == toTeam) {
IncrementTotal(); // no matching stat, reflects non-reassigment joins
AddNewPlayer(name, toTeam);
UpdateTeams();
DebugWrite("^4New player^0: ^b" + name + "^n, assigned to " + GetTeamName(toTeam) + " team during scrambling", 4);
}
}
ScheduleListPlayers(1);
} else {
// Simulate reassignment
fReassigned.Add(name);
ScheduleListPlayers(1);
OnPlayerTeamChange(name, toTeam, toSquad);
}
}