Fixed round ending tickbox not being visible client-side if the client is not controlling character (despite servers now allowing votes from players who've spawned at least once during the round). Closes #500

This commit is contained in:
Joonas Rikkonen
2018-07-19 10:47:39 +03:00
parent 30a453191f
commit c901b75ff1
4 changed files with 34 additions and 17 deletions

View File

@@ -188,6 +188,7 @@ namespace Barotrauma
controlled = this;
IsRemotePlayer = false;
GameMain.Client.HasSpawned = true;
GameMain.Client.Character = this;
GameMain.LightManager.LosEnabled = true;
}
@@ -286,6 +287,7 @@ namespace Barotrauma
if (GameMain.Client.ID == ownerId)
{
GameMain.Client.HasSpawned = true;
GameMain.Client.Character = character;
Controlled = character;

View File

@@ -44,6 +44,9 @@ namespace Barotrauma.Networking
private FileReceiver fileReceiver;
//has the client been given a character to control this round
public bool HasSpawned;
public byte ID
{
get { return myID; }
@@ -480,7 +483,7 @@ namespace Barotrauma.Networking
if (gameStarted && Screen.Selected == GameMain.GameScreen)
{
endVoteTickBox.Visible = Voting.AllowEndVoting && myCharacter != null;
endVoteTickBox.Visible = Voting.AllowEndVoting && HasSpawned;
if (respawnManager != null)
{
@@ -666,6 +669,7 @@ namespace Barotrauma.Networking
private IEnumerable<object> StartGame(NetIncomingMessage inc)
{
if (Character != null) Character.Remove();
HasSpawned = false;
GameMain.LightManager.LightingEnabled = true;
@@ -1281,6 +1285,23 @@ namespace Barotrauma.Networking
{
base.Draw(spriteBatch);
if (Screen.Selected == GameMain.GameScreen && !GUI.DisableHUD)
{
if (EndVoteCount > 0)
{
if (!HasSpawned)
{
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth - 180.0f, 40),
"Votes to end the round (y/n): " + EndVoteCount + "/" + (EndVoteMax - EndVoteCount), Color.White, null, 0, GUI.SmallFont);
}
else
{
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth - 140.0f, 40),
"Votes (y/n): " + EndVoteCount + "/" + (EndVoteMax - EndVoteCount), Color.White, null, 0, GUI.SmallFont);
}
}
}
if (fileReceiver != null && fileReceiver.ActiveTransfers.Count > 0)
{
Vector2 pos = new Vector2(GameMain.NetLobbyScreen.InfoFrame.Rect.X, GameMain.GraphicsHeight - 35);
@@ -1564,14 +1585,13 @@ namespace Barotrauma.Networking
{
if (!gameStarted) return false;
if (!Voting.AllowEndVoting || myCharacter==null)
if (!Voting.AllowEndVoting || !HasSpawned)
{
tickBox.Visible = false;
return false;
}
Vote(VoteType.EndRound, tickBox.Selected);
return false;
}
}

View File

@@ -63,6 +63,15 @@ namespace Barotrauma.Networking
log.LogFrame.Draw(spriteBatch);
}
if (Screen.Selected == GameMain.GameScreen && !GUI.DisableHUD)
{
if (EndVoteCount > 0)
{
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth - 180.0f, 40),
"Votes to end the round (y/n): " + EndVoteCount + "/" + (EndVoteMax - EndVoteCount), Color.White, null, 0, GUI.SmallFont);
}
}
if (!ShowNetStats) return;
GUI.Font.DrawString(spriteBatch, "Unique Events: " + entityEventManager.UniqueEvents.Count, new Vector2(10, 50), Color.White);

View File

@@ -119,20 +119,6 @@ namespace Barotrauma.Networking
inGameHUD.Draw(spriteBatch);
if (EndVoteCount > 0)
{
if (GameMain.NetworkMember.myCharacter == null)
{
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth - 180.0f, 40),
"Votes to end the round (y/n): " + EndVoteCount + "/" + (EndVoteMax - EndVoteCount), Color.White, null, 0, GUI.SmallFont);
}
else
{
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth - 140.0f, 40),
"Votes (y/n): " + EndVoteCount + "/" + (EndVoteMax - EndVoteCount), Color.White, null, 0, GUI.SmallFont);
}
}
if (respawnManager != null)
{
string respawnInfo = "";