Voting UI fixes:
- The vote count texts are removed when voting is disabled. - Server sends vote status to joining clients (-> clients see the number of votes immediately, not after someone votes something). - Server refreshes vote count texts when a client disconnects.
This commit is contained in:
@@ -19,11 +19,12 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (GameMain.Server != null)
|
if (GameMain.Server != null)
|
||||||
{
|
{
|
||||||
UpdateVoteTexts(GameMain.Server.ConnectedClients, VoteType.Sub);
|
UpdateVoteTexts(value ? GameMain.Server.ConnectedClients : null, VoteType.Sub);
|
||||||
GameMain.Server.UpdateVoteStatus();
|
GameMain.Server.UpdateVoteStatus();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
UpdateVoteTexts(null, VoteType.Sub);
|
||||||
GameMain.NetLobbyScreen.SubList.Deselect();
|
GameMain.NetLobbyScreen.SubList.Deselect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,11 +40,12 @@ namespace Barotrauma
|
|||||||
GameMain.NetLobbyScreen.InfoFrame.FindChild("modevotes", true).Visible = value;
|
GameMain.NetLobbyScreen.InfoFrame.FindChild("modevotes", true).Visible = value;
|
||||||
if (GameMain.Server != null)
|
if (GameMain.Server != null)
|
||||||
{
|
{
|
||||||
UpdateVoteTexts(GameMain.Server.ConnectedClients, VoteType.Mode);
|
UpdateVoteTexts(value ? GameMain.Server.ConnectedClients : null, VoteType.Mode);
|
||||||
GameMain.Server.UpdateVoteStatus();
|
GameMain.Server.UpdateVoteStatus();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
UpdateVoteTexts(null, VoteType.Mode);
|
||||||
GameMain.NetLobbyScreen.ModeList.Deselect();
|
GameMain.NetLobbyScreen.ModeList.Deselect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,10 +62,13 @@ namespace Barotrauma
|
|||||||
if (voteText != null) comp.RemoveChild(voteText);
|
if (voteText != null) comp.RemoveChild(voteText);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Pair<object, int>> voteList = GetVoteList(voteType, clients);
|
if (clients != null)
|
||||||
foreach (Pair<object, int> votable in voteList)
|
|
||||||
{
|
{
|
||||||
SetVoteText(listBox, votable.First, votable.Second);
|
List<Pair<object, int>> voteList = GetVoteList(voteType, clients);
|
||||||
|
foreach (Pair<object, int> votable in voteList)
|
||||||
|
{
|
||||||
|
SetVoteText(listBox, votable.First, votable.Second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,10 +132,7 @@ namespace Barotrauma
|
|||||||
AllowSubVoting = inc.ReadBoolean();
|
AllowSubVoting = inc.ReadBoolean();
|
||||||
if (allowSubVoting)
|
if (allowSubVoting)
|
||||||
{
|
{
|
||||||
foreach (Submarine sub in Submarine.SavedSubmarines)
|
UpdateVoteTexts(null, VoteType.Sub);
|
||||||
{
|
|
||||||
SetVoteText(GameMain.NetLobbyScreen.SubList, sub, 0);
|
|
||||||
}
|
|
||||||
int votableCount = inc.ReadByte();
|
int votableCount = inc.ReadByte();
|
||||||
for (int i = 0; i < votableCount; i++)
|
for (int i = 0; i < votableCount; i++)
|
||||||
{
|
{
|
||||||
@@ -143,6 +145,7 @@ namespace Barotrauma
|
|||||||
AllowModeVoting = inc.ReadBoolean();
|
AllowModeVoting = inc.ReadBoolean();
|
||||||
if (allowModeVoting)
|
if (allowModeVoting)
|
||||||
{
|
{
|
||||||
|
UpdateVoteTexts(null, VoteType.Mode);
|
||||||
int votableCount = inc.ReadByte();
|
int votableCount = inc.ReadByte();
|
||||||
for (int i = 0; i < votableCount; i++)
|
for (int i = 0; i < votableCount; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1001,6 +1001,8 @@ namespace Barotrauma.Networking
|
|||||||
//and assume the message was received, so we don't have to keep resending
|
//and assume the message was received, so we don't have to keep resending
|
||||||
//these large initial messages until the client acknowledges receiving them
|
//these large initial messages until the client acknowledges receiving them
|
||||||
c.lastRecvGeneralUpdate++;
|
c.lastRecvGeneralUpdate++;
|
||||||
|
|
||||||
|
SendVoteStatus(new List<Client>() { c });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1559,11 +1561,13 @@ namespace Barotrauma.Networking
|
|||||||
Log(msg, ServerLog.MessageType.ServerMessage);
|
Log(msg, ServerLog.MessageType.ServerMessage);
|
||||||
|
|
||||||
client.Connection.Disconnect(targetmsg);
|
client.Connection.Disconnect(targetmsg);
|
||||||
|
connectedClients.Remove(client);
|
||||||
|
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
GameMain.NetLobbyScreen.RemovePlayer(client.name);
|
GameMain.NetLobbyScreen.RemovePlayer(client.name);
|
||||||
|
Voting.UpdateVoteTexts(connectedClients, VoteType.Sub);
|
||||||
|
Voting.UpdateVoteTexts(connectedClients, VoteType.Mode);
|
||||||
#endif
|
#endif
|
||||||
connectedClients.Remove(client);
|
|
||||||
|
|
||||||
UpdateVoteStatus();
|
UpdateVoteStatus();
|
||||||
|
|
||||||
@@ -1852,13 +1856,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
GameMain.NetLobbyScreen.LastUpdateID++;
|
GameMain.NetLobbyScreen.LastUpdateID++;
|
||||||
|
|
||||||
NetOutgoingMessage msg = server.CreateMessage();
|
SendVoteStatus(connectedClients);
|
||||||
msg.Write((byte)ServerPacketHeader.UPDATE_LOBBY);
|
|
||||||
msg.Write((byte)ServerNetObject.VOTE);
|
|
||||||
Voting.ServerWrite(msg);
|
|
||||||
msg.Write((byte)ServerNetObject.END_OF_MESSAGE);
|
|
||||||
|
|
||||||
server.SendMessage(msg, connectedClients.Select(c => c.Connection).ToList(), NetDeliveryMethod.ReliableUnordered, 0);
|
|
||||||
|
|
||||||
if (Voting.AllowEndVoting && EndVoteMax > 0 &&
|
if (Voting.AllowEndVoting && EndVoteMax > 0 &&
|
||||||
((float)EndVoteCount / (float)EndVoteMax) >= EndVoteRequiredRatio)
|
((float)EndVoteCount / (float)EndVoteMax) >= EndVoteRequiredRatio)
|
||||||
@@ -1868,6 +1866,17 @@ namespace Barotrauma.Networking
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SendVoteStatus(List<Client> recipients)
|
||||||
|
{
|
||||||
|
NetOutgoingMessage msg = server.CreateMessage();
|
||||||
|
msg.Write((byte)ServerPacketHeader.UPDATE_LOBBY);
|
||||||
|
msg.Write((byte)ServerNetObject.VOTE);
|
||||||
|
Voting.ServerWrite(msg);
|
||||||
|
msg.Write((byte)ServerNetObject.END_OF_MESSAGE);
|
||||||
|
|
||||||
|
server.SendMessage(msg, recipients.Select(c => c.Connection).ToList(), NetDeliveryMethod.ReliableUnordered, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateClientPermissions(Client client)
|
public void UpdateClientPermissions(Client client)
|
||||||
{
|
{
|
||||||
clientPermissions.RemoveAll(cp => cp.IP == client.Connection.RemoteEndPoint.Address.ToString());
|
clientPermissions.RemoveAll(cp => cp.IP == client.Connection.RemoteEndPoint.Address.ToString());
|
||||||
|
|||||||
Reference in New Issue
Block a user