(99836db69) Fixed clients being unable to end campaign rounds at all if the sub isn't at the start/end outpost (regardless if they have the permission to end the round or not), added a verification prompt when trying to end the round when the sub isn't at either outpost.
This commit is contained in:
@@ -141,8 +141,23 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
OnClicked = (btn, userdata) =>
|
||||
{
|
||||
if (!permissions.HasFlag(ClientPermissions.ManageRound)) return false;
|
||||
RequestRoundEnd();
|
||||
if (!permissions.HasFlag(ClientPermissions.ManageRound)) { return false; }
|
||||
if (!Submarine.MainSub.AtStartPosition && !Submarine.MainSub.AtEndPosition)
|
||||
{
|
||||
var msgBox = new GUIMessageBox("", TextManager.Get("EndRoundSubNotAtLevelEnd"),
|
||||
new string[] { TextManager.Get("Yes"), TextManager.Get("No") });
|
||||
msgBox.Buttons[0].OnClicked = (_, __) =>
|
||||
{
|
||||
GameMain.Client.RequestRoundEnd();
|
||||
return true;
|
||||
};
|
||||
msgBox.Buttons[0].OnClicked += msgBox.Close;
|
||||
msgBox.Buttons[1].OnClicked += msgBox.Close;
|
||||
}
|
||||
else
|
||||
{
|
||||
RequestRoundEnd();
|
||||
}
|
||||
return true;
|
||||
},
|
||||
Visible = false
|
||||
@@ -1267,6 +1282,75 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadLobbyUpdate(NetIncomingMessage inc)
|
||||
{
|
||||
UInt16 listId = inc.ReadUInt16();
|
||||
List<TempClient> tempClients = new List<TempClient>();
|
||||
int clientCount = inc.ReadByte();
|
||||
for (int i = 0; i < clientCount; i++)
|
||||
{
|
||||
byte id = inc.ReadByte();
|
||||
string name = inc.ReadString();
|
||||
UInt16 characterID = inc.ReadUInt16();
|
||||
bool muted = inc.ReadBoolean();
|
||||
inc.ReadPadBits();
|
||||
|
||||
tempClients.Add(new TempClient
|
||||
{
|
||||
ID = id,
|
||||
Name = name,
|
||||
CharacterID = characterID,
|
||||
Muted = muted
|
||||
});
|
||||
}
|
||||
|
||||
if (NetIdUtils.IdMoreRecent(listId, LastClientListUpdateID))
|
||||
{
|
||||
bool updateClientListId = true;
|
||||
List<Client> currentClients = new List<Client>();
|
||||
foreach (TempClient tc in tempClients)
|
||||
{
|
||||
//see if the client already exists
|
||||
var existingClient = ConnectedClients.Find(c => c.ID == tc.ID && c.Name == tc.Name);
|
||||
if (existingClient == null) //if not, create it
|
||||
{
|
||||
existingClient = new Client(tc.Name, tc.ID)
|
||||
{
|
||||
Muted = tc.Muted
|
||||
};
|
||||
ConnectedClients.Add(existingClient);
|
||||
GameMain.NetLobbyScreen.AddPlayer(existingClient);
|
||||
}
|
||||
existingClient.Character = null;
|
||||
existingClient.Muted = tc.Muted;
|
||||
if (tc.CharacterID > 0)
|
||||
{
|
||||
existingClient.Character = Entity.FindEntityByID(tc.CharacterID) as Character;
|
||||
if (existingClient.Character == null)
|
||||
{
|
||||
updateClientListId = false;
|
||||
}
|
||||
}
|
||||
if (existingClient.ID == myID)
|
||||
{
|
||||
existingClient.SetPermissions(permissions, permittedConsoleCommands);
|
||||
}
|
||||
currentClients.Add(existingClient);
|
||||
}
|
||||
//remove clients that aren't present anymore
|
||||
for (int i = ConnectedClients.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (!currentClients.Contains(ConnectedClients[i]))
|
||||
{
|
||||
GameMain.NetLobbyScreen.RemovePlayer(ConnectedClients[i]);
|
||||
ConnectedClients[i].Dispose();
|
||||
ConnectedClients.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
if (updateClientListId) LastClientListUpdateID = listId;
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadLobbyUpdate(NetIncomingMessage inc)
|
||||
{
|
||||
ServerNetObject objHeader;
|
||||
|
||||
@@ -1039,7 +1039,7 @@ namespace Barotrauma.Networking
|
||||
if (command == ClientPermissions.ManageRound && inc.PeekBoolean() &&
|
||||
GameMain.GameSession?.GameMode is MultiPlayerCampaign mpCampaign)
|
||||
{
|
||||
if (!mpCampaign.AllowedToEndRound(sender.Character))
|
||||
if (!mpCampaign.AllowedToEndRound(sender.Character) && !sender.HasPermission(command))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user