Clients can be given a permission to select the sub or the game mode
This commit is contained in:
@@ -620,12 +620,15 @@ namespace Barotrauma.Networking
|
||||
if (!newPermissions.HasFlag(permission) || permission == ClientPermissions.None) continue;
|
||||
System.Reflection.FieldInfo fi = typeof(ClientPermissions).GetField(permission.ToString());
|
||||
DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
||||
msg += " - " + attributes[0].Description+"\n";
|
||||
msg += " - " + attributes[0].Description + "\n";
|
||||
}
|
||||
}
|
||||
permissions = newPermissions;
|
||||
new GUIMessageBox("Permissions changed", msg).UserData = "permissions";
|
||||
|
||||
GameMain.NetLobbyScreen.SubList.Enabled = Voting.AllowSubVoting || HasPermission(ClientPermissions.SelectSub);
|
||||
GameMain.NetLobbyScreen.ModeList.Enabled = Voting.AllowModeVoting || HasPermission(ClientPermissions.SelectMode);
|
||||
|
||||
endRoundButton.Visible = HasPermission(ClientPermissions.EndRound);
|
||||
}
|
||||
|
||||
@@ -1326,6 +1329,51 @@ namespace Barotrauma.Networking
|
||||
client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tell the server to select a submarine (permission required)
|
||||
/// </summary>
|
||||
public void RequestSelectSub(int subIndex)
|
||||
{
|
||||
if (!HasPermission(ClientPermissions.SelectSub)) return;
|
||||
if (subIndex < 0 || subIndex >= GameMain.NetLobbyScreen.SubList.CountChildren)
|
||||
{
|
||||
DebugConsole.ThrowError("Submarine index out of bounds (" + subIndex + ")\n" + Environment.StackTrace);
|
||||
return;
|
||||
}
|
||||
|
||||
NetOutgoingMessage msg = client.CreateMessage();
|
||||
msg.Write((byte)ClientPacketHeader.SERVER_COMMAND);
|
||||
msg.Write((byte)ClientPermissions.SelectSub);
|
||||
msg.Write((UInt16)subIndex);
|
||||
msg.Write((byte)ServerNetObject.END_OF_MESSAGE);
|
||||
|
||||
client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tell the server to select a submarine (permission required)
|
||||
/// </summary>
|
||||
public void RequestSelectMode(int modeIndex)
|
||||
{
|
||||
if (!HasPermission(ClientPermissions.SelectMode)) return;
|
||||
if (modeIndex < 0 || modeIndex >= GameMain.NetLobbyScreen.ModeList.CountChildren)
|
||||
{
|
||||
DebugConsole.ThrowError("Gamemode index out of bounds (" + modeIndex + ")\n" + Environment.StackTrace);
|
||||
return;
|
||||
}
|
||||
|
||||
NetOutgoingMessage msg = client.CreateMessage();
|
||||
msg.Write((byte)ClientPacketHeader.SERVER_COMMAND);
|
||||
msg.Write((byte)ClientPermissions.SelectMode);
|
||||
msg.Write((UInt16)modeIndex);
|
||||
msg.Write((byte)ServerNetObject.END_OF_MESSAGE);
|
||||
|
||||
client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tell the server to end the round (permission required)
|
||||
/// </summary>
|
||||
public void RequestRoundEnd()
|
||||
{
|
||||
NetOutgoingMessage msg = client.CreateMessage();
|
||||
|
||||
Reference in New Issue
Block a user