Skip to content

Commit

Permalink
teams: fix wrong targetTeam for second connection when same team conn…
Browse files Browse the repository at this point in the history
…ects twice
  • Loading branch information
SdePutter committed Apr 7, 2022
1 parent e2d0d8c commit 66024ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
16 changes: 14 additions & 2 deletions mslrb2015/Team.pde
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,29 @@ class Team {
unicastIP = teamselect.getString("UnicastAddr");
multicastIP = teamselect.getString("MulticastAddr");

String teamID = isLeft ? "A" : "B";

// support same team connecting twice: newest team gets adapted ids
if(teamA.team == teamB.team)
{
team += " " + teamID;
longName += " " + teamID;
}
if(teamA.multicastIP == teamB.multicastIP)
{
multicastIP += ":1";
}

if(connectedClient != null)
BaseStationServer.disconnect(connectedClient);
BaseStationServer.disconnect(connectedClient);

connectedClient = connectingClient;
send_event_v2(COMM_WELCOME,COMM_WELCOME, this ,-1);
connectingClient = null;

if(this.logFile == null || this.logFileOut == null)
{
this.logFile = new File(mainApplet.dataPath("tmp/" + Log.getTimedName() + "." + (isLeft?"A":"B") + ".msl"));
this.logFile = new File(mainApplet.dataPath("tmp/" + Log.getTimedName() + "." + (teamID) + ".msl"));
try{
this.logFileOut = new PrintWriter(new BufferedWriter(new FileWriter(logFile, true)));
}catch(IOException e){ }
Expand Down
12 changes: 0 additions & 12 deletions mslrb2015/mslrb2015.pde
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,6 @@ void draw() {
bTeamBcmds[i].update();
}

//Special case: what if the same team connects twice to RefBox
if(teamA.team == teamB.team)
{
teamA.team = teamA.team +" A";
teamA.longName = teamA.longName+" A";
teamA.multicastIP += ":1";
}
if(teamA.multicastIP == teamB.multicastIP)
{
teamA.multicastIP += ":1";
}

teamA.updateUI();
teamB.updateUI();

Expand Down

0 comments on commit 66024ab

Please sign in to comment.