- server doesn't send the STARTGAME message to all clients when someone joins mid-round
- team ID is included in character spawn messages even if no-one is controlling the character anymore - living characters are taken into account when assigning jobs for respawned characters (e.g. there can't be two captains alive at the same time)
This commit is contained in:
@@ -2461,13 +2461,11 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
msg.Write(true);
|
msg.Write(true);
|
||||||
msg.Write(ownerClient.ID);
|
msg.Write(ownerClient.ID);
|
||||||
msg.Write(TeamID);
|
|
||||||
}
|
}
|
||||||
else if (GameMain.Server.Character == this)
|
else if (GameMain.Server.Character == this)
|
||||||
{
|
{
|
||||||
msg.Write(true);
|
msg.Write(true);
|
||||||
msg.Write((byte)0);
|
msg.Write((byte)0);
|
||||||
msg.Write(TeamID);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2475,6 +2473,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
msg.Write(Info.Name);
|
msg.Write(Info.Name);
|
||||||
|
msg.Write(TeamID);
|
||||||
|
|
||||||
msg.Write(this is AICharacter);
|
msg.Write(this is AICharacter);
|
||||||
msg.Write(Info.Gender == Gender.Female);
|
msg.Write(Info.Gender == Gender.Female);
|
||||||
@@ -2508,9 +2507,10 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
bool hasOwner = inc.ReadBoolean();
|
bool hasOwner = inc.ReadBoolean();
|
||||||
int ownerId = hasOwner ? inc.ReadByte() : -1;
|
int ownerId = hasOwner ? inc.ReadByte() : -1;
|
||||||
byte teamID = hasOwner ? inc.ReadByte() : (byte)0;
|
|
||||||
|
|
||||||
string newName = inc.ReadString();
|
string newName = inc.ReadString();
|
||||||
|
byte teamID = inc.ReadByte();
|
||||||
|
|
||||||
bool hasAi = inc.ReadBoolean();
|
bool hasAi = inc.ReadBoolean();
|
||||||
bool isFemale = inc.ReadBoolean();
|
bool isFemale = inc.ReadBoolean();
|
||||||
|
|||||||
@@ -546,7 +546,7 @@ namespace Barotrauma.Networking
|
|||||||
//game already started -> send start message immediately
|
//game already started -> send start message immediately
|
||||||
if (gameStarted)
|
if (gameStarted)
|
||||||
{
|
{
|
||||||
SendStartMessage(roundStartSeed, Submarine.MainSub, GameMain.GameSession.gameMode.Preset, connectedClients);
|
SendStartMessage(roundStartSeed, Submarine.MainSub, GameMain.GameSession.gameMode.Preset, connectedClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1096,6 +1096,12 @@ namespace Barotrauma.Networking
|
|||||||
private void SendStartMessage(int seed, Submarine selectedSub, GameModePreset selectedMode, List<Client> clients)
|
private void SendStartMessage(int seed, Submarine selectedSub, GameModePreset selectedMode, List<Client> clients)
|
||||||
{
|
{
|
||||||
foreach (Client client in clients)
|
foreach (Client client in clients)
|
||||||
|
{
|
||||||
|
SendStartMessage(seed, selectedSub, selectedMode, client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SendStartMessage(int seed, Submarine selectedSub, GameModePreset selectedMode, Client client)
|
||||||
{
|
{
|
||||||
NetOutgoingMessage msg = server.CreateMessage();
|
NetOutgoingMessage msg = server.CreateMessage();
|
||||||
msg.Write((byte)ServerPacketHeader.STARTGAME);
|
msg.Write((byte)ServerPacketHeader.STARTGAME);
|
||||||
@@ -1137,8 +1143,6 @@ namespace Barotrauma.Networking
|
|||||||
server.SendMessage(msg, client.Connection, NetDeliveryMethod.ReliableUnordered);
|
server.SendMessage(msg, client.Connection, NetDeliveryMethod.ReliableUnordered);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void EndGame()
|
public void EndGame()
|
||||||
{
|
{
|
||||||
if (!gameStarted) return;
|
if (!gameStarted) return;
|
||||||
@@ -1468,6 +1472,7 @@ namespace Barotrauma.Networking
|
|||||||
if (type == ChatMessageType.Server)
|
if (type == ChatMessageType.Server)
|
||||||
{
|
{
|
||||||
senderName = null;
|
senderName = null;
|
||||||
|
senderCharacter = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var chatMsg = ChatMessage.Create(
|
var chatMsg = ChatMessage.Create(
|
||||||
@@ -1721,14 +1726,20 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
assignedClientCount[JobPrefab.List.FindIndex(jp => jp == GameMain.NetLobbyScreen.JobPreferences[0])] = 1;
|
assignedClientCount[JobPrefab.List.FindIndex(jp => jp == GameMain.NetLobbyScreen.JobPreferences[0])] = 1;
|
||||||
}
|
}
|
||||||
|
else if (myCharacter != null && !myCharacter.IsDead)
|
||||||
|
{
|
||||||
|
assignedClientCount[JobPrefab.List.IndexOf(myCharacter.Info.Job.Prefab)] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//count the clients who already have characters with an assigned job
|
||||||
foreach (Client c in connectedClients)
|
foreach (Client c in connectedClients)
|
||||||
{
|
{
|
||||||
if (unassigned.Contains(c)) continue;
|
if (unassigned.Contains(c)) continue;
|
||||||
if (c.Character == null || !c.Character.IsDead) continue;
|
if (c.Character != null && !c.Character.IsDead)
|
||||||
|
{
|
||||||
assignedClientCount[JobPrefab.List.IndexOf(c.Character.Info.Job.Prefab)]++;
|
assignedClientCount[JobPrefab.List.IndexOf(c.Character.Info.Job.Prefab)]++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//if any of the players has chosen a job that is Always Allowed, give them that job
|
//if any of the players has chosen a job that is Always Allowed, give them that job
|
||||||
for (int i = unassigned.Count - 1; i >= 0; i--)
|
for (int i = unassigned.Count - 1; i >= 0; i--)
|
||||||
|
|||||||
Reference in New Issue
Block a user