Team ID assignment fixes:
- Clients are assigned to team 1 in sandbox mode (because the host is also in team 1). - Respawning characters are always assigned to team 1 (otherwise mid-round joining clients would end up in team 0 because the team assignment is done when the round starts)
This commit is contained in:
@@ -90,7 +90,7 @@ namespace Barotrauma
|
|||||||
return teamNames[teamID];
|
return teamNames[teamID];
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool AssignTeamIDs(List<Client> clients, out int hostTeam)
|
public override bool AssignTeamIDs(List<Client> clients, out byte hostTeam)
|
||||||
{
|
{
|
||||||
List<Client> randList = new List<Client>(clients);
|
List<Client> randList = new List<Client>(clients);
|
||||||
for (int i = 0; i < randList.Count; i++)
|
for (int i = 0; i < randList.Count; i++)
|
||||||
@@ -115,7 +115,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
if (halfPlayers * 2 == randList.Count)
|
if (halfPlayers * 2 == randList.Count)
|
||||||
{
|
{
|
||||||
hostTeam = Rand.Range(1, 2);
|
hostTeam = (byte)Rand.Range(1, 2);
|
||||||
}
|
}
|
||||||
else if (halfPlayers * 2 < randList.Count)
|
else if (halfPlayers * 2 < randList.Count)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public virtual void Update(float deltaTime) { }
|
public virtual void Update(float deltaTime) { }
|
||||||
|
|
||||||
public virtual bool AssignTeamIDs(List<Networking.Client> clients, out int hostTeam)
|
public virtual bool AssignTeamIDs(List<Networking.Client> clients, out byte hostTeam)
|
||||||
{
|
{
|
||||||
clients.ForEach(c => c.TeamID = 1);
|
clients.ForEach(c => c.TeamID = 1);
|
||||||
hostTeam = 1;
|
hostTeam = 1;
|
||||||
|
|||||||
@@ -914,7 +914,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
if (outmsg.LengthBytes > config.MaximumTransmissionUnit)
|
if (outmsg.LengthBytes > config.MaximumTransmissionUnit)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Maximum packet size exceeded (" + outmsg.LengthBytes + " > " + config.MaximumTransmissionUnit);
|
DebugConsole.ThrowError("Maximum packet size exceeded (" + outmsg.LengthBytes + " > " + config.MaximumTransmissionUnit + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
server.SendMessage(outmsg, c.Connection, NetDeliveryMethod.Unreliable);
|
server.SendMessage(outmsg, c.Connection, NetDeliveryMethod.Unreliable);
|
||||||
@@ -989,7 +989,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
if (outmsg.LengthBytes > config.MaximumTransmissionUnit)
|
if (outmsg.LengthBytes > config.MaximumTransmissionUnit)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Maximum packet size exceeded (" + outmsg.LengthBytes + " > " + config.MaximumTransmissionUnit);
|
DebugConsole.ThrowError("Maximum packet size exceeded (" + outmsg.LengthBytes + " > " + config.MaximumTransmissionUnit + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
server.SendMessage(outmsg, c.Connection, NetDeliveryMethod.Unreliable);
|
server.SendMessage(outmsg, c.Connection, NetDeliveryMethod.Unreliable);
|
||||||
@@ -1103,15 +1103,19 @@ namespace Barotrauma.Networking
|
|||||||
Rand.SetSyncedSeed(roundStartSeed);
|
Rand.SetSyncedSeed(roundStartSeed);
|
||||||
|
|
||||||
int teamCount = 1;
|
int teamCount = 1;
|
||||||
int hostTeam = 1;
|
byte hostTeam = 1;
|
||||||
|
|
||||||
GameMain.GameSession = new GameSession(selectedSub, "", selectedMode, Mission.MissionTypes[GameMain.NetLobbyScreen.MissionTypeIndex]);
|
GameMain.GameSession = new GameSession(selectedSub, "", selectedMode, Mission.MissionTypes[GameMain.NetLobbyScreen.MissionTypeIndex]);
|
||||||
|
|
||||||
if (GameMain.GameSession.gameMode.Mission != null &&
|
if (GameMain.GameSession.gameMode.Mission != null &&
|
||||||
GameMain.GameSession.gameMode.Mission.AssignTeamIDs(connectedClients,out hostTeam))
|
GameMain.GameSession.gameMode.Mission.AssignTeamIDs(connectedClients, out hostTeam))
|
||||||
{
|
{
|
||||||
teamCount = 2;
|
teamCount = 2;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
connectedClients.ForEach(c => c.TeamID = hostTeam);
|
||||||
|
}
|
||||||
|
|
||||||
GameMain.GameSession.StartShift(GameMain.NetLobbyScreen.LevelSeed, teamCount > 1);
|
GameMain.GameSession.StartShift(GameMain.NetLobbyScreen.LevelSeed, teamCount > 1);
|
||||||
|
|
||||||
|
|||||||
@@ -392,10 +392,14 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
var server = networkMember as GameServer;
|
var server = networkMember as GameServer;
|
||||||
if (server == null) return;
|
if (server == null) return;
|
||||||
|
|
||||||
|
|
||||||
var clients = GetClientsToRespawn();
|
var clients = GetClientsToRespawn();
|
||||||
foreach (Client c in clients)
|
foreach (Client c in clients)
|
||||||
{
|
{
|
||||||
|
//all characters are in Team 1 in game modes/missions with only one team.
|
||||||
|
//if at some point we add a game mode with multiple teams where respawning is possible, this needs to be reworked
|
||||||
|
c.TeamID = 1;
|
||||||
if (c.characterInfo == null) c.characterInfo = new CharacterInfo(Character.HumanConfigFile, c.name);
|
if (c.characterInfo == null) c.characterInfo = new CharacterInfo(Character.HumanConfigFile, c.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user