Clients can be given access to server logs. Closes #366
This commit is contained in:
@@ -32,18 +32,26 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
if (NetIdUtils.IdMoreRecent(ID, LastID))
|
if (NetIdUtils.IdMoreRecent(ID, LastID))
|
||||||
{
|
{
|
||||||
if (type == ChatMessageType.MessageBox)
|
switch (type)
|
||||||
{
|
{
|
||||||
new GUIMessageBox("", txt);
|
case ChatMessageType.MessageBox:
|
||||||
}
|
new GUIMessageBox("", txt);
|
||||||
else if (type == ChatMessageType.Console)
|
break;
|
||||||
{
|
case ChatMessageType.Console:
|
||||||
DebugConsole.NewMessage(txt, MessageColor[(int)ChatMessageType.Console]);
|
DebugConsole.NewMessage(txt, MessageColor[(int)ChatMessageType.Console]);
|
||||||
}
|
break;
|
||||||
else
|
case ChatMessageType.ServerLog:
|
||||||
{
|
if (!Enum.TryParse(senderName, out ServerLog.MessageType messageType))
|
||||||
GameMain.Client.AddChatMessage(txt, type, senderName, senderCharacter);
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GameMain.Client.ServerLog?.WriteLine(txt, messageType);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
GameMain.Client.AddChatMessage(txt, type, senderName, senderCharacter);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LastID = ID;
|
LastID = ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,6 +113,8 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
otherClients = new List<Client>();
|
otherClients = new List<Client>();
|
||||||
|
|
||||||
|
ServerLog = new ServerLog("");
|
||||||
|
|
||||||
ChatMessage.LastID = 0;
|
ChatMessage.LastID = 0;
|
||||||
GameMain.NetLobbyScreen = new NetLobbyScreen();
|
GameMain.NetLobbyScreen = new NetLobbyScreen();
|
||||||
}
|
}
|
||||||
@@ -470,6 +472,9 @@ namespace Barotrauma.Networking
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (PlayerInput.GetKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.P)) return;
|
if (PlayerInput.GetKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.P)) return;
|
||||||
#endif
|
#endif
|
||||||
|
#if CLIENT
|
||||||
|
if (ServerLog.LogFrame != null) ServerLog.LogFrame.Update(deltaTime);
|
||||||
|
#endif
|
||||||
|
|
||||||
base.Update(deltaTime);
|
base.Update(deltaTime);
|
||||||
|
|
||||||
@@ -673,6 +678,8 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
GameMain.NetLobbyScreen.SubList.Enabled = Voting.AllowSubVoting || HasPermission(ClientPermissions.SelectSub);
|
GameMain.NetLobbyScreen.SubList.Enabled = Voting.AllowSubVoting || HasPermission(ClientPermissions.SelectSub);
|
||||||
GameMain.NetLobbyScreen.ModeList.Enabled = Voting.AllowModeVoting || HasPermission(ClientPermissions.SelectMode);
|
GameMain.NetLobbyScreen.ModeList.Enabled = Voting.AllowModeVoting || HasPermission(ClientPermissions.SelectMode);
|
||||||
|
GameMain.NetLobbyScreen.InfoFrame.FindChild("showlog").Visible = HasPermission(ClientPermissions.ServerLog);
|
||||||
|
showLogButton.Visible = HasPermission(ClientPermissions.ServerLog);
|
||||||
|
|
||||||
endRoundButton.Visible = HasPermission(ClientPermissions.EndRound);
|
endRoundButton.Visible = HasPermission(ClientPermissions.EndRound);
|
||||||
}
|
}
|
||||||
@@ -929,6 +936,8 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
GameMain.NetLobbyScreen.LastUpdateID = updateID;
|
GameMain.NetLobbyScreen.LastUpdateID = updateID;
|
||||||
|
|
||||||
|
ServerLog.ServerName = serverName;
|
||||||
|
|
||||||
GameMain.NetLobbyScreen.ServerName = serverName;
|
GameMain.NetLobbyScreen.ServerName = serverName;
|
||||||
GameMain.NetLobbyScreen.ServerMessage.Text = serverText;
|
GameMain.NetLobbyScreen.ServerMessage.Text = serverText;
|
||||||
|
|
||||||
@@ -1398,6 +1407,12 @@ namespace Barotrauma.Networking
|
|||||||
public override void Disconnect()
|
public override void Disconnect()
|
||||||
{
|
{
|
||||||
client.Shutdown("");
|
client.Shutdown("");
|
||||||
|
|
||||||
|
if (HasPermission(ClientPermissions.ServerLog))
|
||||||
|
{
|
||||||
|
ServerLog?.Save();
|
||||||
|
}
|
||||||
|
|
||||||
GameMain.NetworkMember = null;
|
GameMain.NetworkMember = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,45 +9,22 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
private NetStats netStats;
|
private NetStats netStats;
|
||||||
|
|
||||||
private GUIButton showLogButton;
|
|
||||||
|
|
||||||
private GUIScrollBar clientListScrollBar;
|
private GUIScrollBar clientListScrollBar;
|
||||||
|
|
||||||
void InitProjSpecific()
|
void InitProjSpecific()
|
||||||
{
|
{
|
||||||
//----------------------------------------
|
|
||||||
|
|
||||||
var endRoundButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170, 20, 150, 20), "End round", Alignment.TopLeft, "", inGameHUD);
|
var endRoundButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170, 20, 150, 20), "End round", Alignment.TopLeft, "", inGameHUD);
|
||||||
endRoundButton.OnClicked = (btn, userdata) => { EndGame(); return true; };
|
endRoundButton.OnClicked = (btn, userdata) => { EndGame(); return true; };
|
||||||
|
|
||||||
showLogButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170 - 170, 20, 150, 20), "Server Log", Alignment.TopLeft, "", inGameHUD);
|
|
||||||
showLogButton.OnClicked = (GUIButton button, object userData) =>
|
|
||||||
{
|
|
||||||
if (log.LogFrame == null)
|
|
||||||
{
|
|
||||||
log.CreateLogFrame();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log.LogFrame = null;
|
|
||||||
GUIComponent.KeyboardDispatcher.Subscriber = null;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
GUIButton settingsButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170 - 170 - 170, 20, 150, 20), "Settings", Alignment.TopLeft, "", inGameHUD);
|
GUIButton settingsButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170 - 170 - 170, 20, 150, 20), "Settings", Alignment.TopLeft, "", inGameHUD);
|
||||||
settingsButton.OnClicked = ToggleSettingsFrame;
|
settingsButton.OnClicked = ToggleSettingsFrame;
|
||||||
settingsButton.UserData = "settingsButton";
|
settingsButton.UserData = "settingsButton";
|
||||||
|
|
||||||
//----------------------------------------
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AddToGUIUpdateList()
|
public override void AddToGUIUpdateList()
|
||||||
{
|
{
|
||||||
if (started) base.AddToGUIUpdateList();
|
base.AddToGUIUpdateList();
|
||||||
|
|
||||||
if (settingsFrame != null) settingsFrame.AddToGUIUpdateList();
|
if (settingsFrame != null) settingsFrame.AddToGUIUpdateList();
|
||||||
if (log.LogFrame != null) log.LogFrame.AddToGUIUpdateList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
|
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
|
||||||
@@ -58,9 +35,9 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
settingsFrame.Draw(spriteBatch);
|
settingsFrame.Draw(spriteBatch);
|
||||||
}
|
}
|
||||||
else if (log.LogFrame != null)
|
else if (ServerLog.LogFrame != null)
|
||||||
{
|
{
|
||||||
log.LogFrame.Draw(spriteBatch);
|
ServerLog.LogFrame.Draw(spriteBatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Screen.Selected == GameMain.GameScreen && !GUI.DisableHUD)
|
if (Screen.Selected == GameMain.GameScreen && !GUI.DisableHUD)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace Barotrauma.Networking
|
|||||||
protected GUIFrame inGameHUD;
|
protected GUIFrame inGameHUD;
|
||||||
protected GUIListBox chatBox;
|
protected GUIListBox chatBox;
|
||||||
protected GUITextBox chatMsgBox;
|
protected GUITextBox chatMsgBox;
|
||||||
|
protected GUIButton showLogButton;
|
||||||
|
|
||||||
public GUIFrame InGameHUD
|
public GUIFrame InGameHUD
|
||||||
{
|
{
|
||||||
@@ -35,6 +36,23 @@ namespace Barotrauma.Networking
|
|||||||
inGameHUD = new GUIFrame(new Rectangle(0, 0, 0, 0), null, null);
|
inGameHUD = new GUIFrame(new Rectangle(0, 0, 0, 0), null, null);
|
||||||
inGameHUD.CanBeFocused = false;
|
inGameHUD.CanBeFocused = false;
|
||||||
|
|
||||||
|
showLogButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170 - 170, 20, 150, 20), "Server Log", Alignment.TopLeft, "", inGameHUD)
|
||||||
|
{
|
||||||
|
OnClicked = (GUIButton button, object userData) =>
|
||||||
|
{
|
||||||
|
if (ServerLog.LogFrame == null)
|
||||||
|
{
|
||||||
|
ServerLog.CreateLogFrame();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ServerLog.LogFrame = null;
|
||||||
|
GUIComponent.KeyboardDispatcher.Subscriber = null;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
int width = (int)MathHelper.Clamp(GameMain.GraphicsWidth * 0.35f, 350, 500);
|
int width = (int)MathHelper.Clamp(GameMain.GraphicsWidth * 0.35f, 350, 500);
|
||||||
int height = (int)MathHelper.Clamp(GameMain.GraphicsHeight * 0.15f, 100, 200);
|
int height = (int)MathHelper.Clamp(GameMain.GraphicsHeight * 0.15f, 100, 200);
|
||||||
chatBox = new GUIListBox(new Rectangle(
|
chatBox = new GUIListBox(new Rectangle(
|
||||||
@@ -109,39 +127,44 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
inGameHUD.AddToGUIUpdateList();
|
inGameHUD.AddToGUIUpdateList();
|
||||||
}
|
}
|
||||||
|
if (ServerLog.LogFrame != null) ServerLog.LogFrame.AddToGUIUpdateList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
|
public virtual void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
if (!gameStarted || Screen.Selected != GameMain.GameScreen || GUI.DisableHUD) return;
|
if (GUI.DisableHUD) return;
|
||||||
|
|
||||||
GameMain.GameSession.CrewManager.Draw(spriteBatch);
|
if (gameStarted && Screen.Selected == GameMain.GameScreen)
|
||||||
|
|
||||||
inGameHUD.Draw(spriteBatch);
|
|
||||||
|
|
||||||
if (respawnManager != null)
|
|
||||||
{
|
{
|
||||||
string respawnInfo = "";
|
GameMain.GameSession.CrewManager.Draw(spriteBatch);
|
||||||
|
|
||||||
if (respawnManager.CurrentState == RespawnManager.State.Waiting &&
|
inGameHUD.Draw(spriteBatch);
|
||||||
respawnManager.CountdownStarted)
|
|
||||||
{
|
|
||||||
respawnInfo = respawnManager.UsingShuttle ? "Respawn Shuttle dispatching in " : "Respawning players in ";
|
|
||||||
respawnInfo = respawnManager.RespawnTimer <= 0.0f ? "" : respawnInfo + ToolBox.SecondsToReadableTime(respawnManager.RespawnTimer);
|
|
||||||
}
|
|
||||||
else if (respawnManager.CurrentState == RespawnManager.State.Transporting)
|
|
||||||
{
|
|
||||||
respawnInfo = respawnManager.TransportTimer <= 0.0f ? "" : "Shuttle leaving in " + ToolBox.SecondsToReadableTime(respawnManager.TransportTimer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(respawnInfo))
|
if (respawnManager != null)
|
||||||
{
|
{
|
||||||
GUI.DrawString(spriteBatch,
|
string respawnInfo = "";
|
||||||
new Vector2(120.0f, 10),
|
|
||||||
respawnInfo, Color.White, null, 0, GUI.SmallFont);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (respawnManager.CurrentState == RespawnManager.State.Waiting &&
|
||||||
|
respawnManager.CountdownStarted)
|
||||||
|
{
|
||||||
|
respawnInfo = respawnManager.UsingShuttle ? "Respawn Shuttle dispatching in " : "Respawning players in ";
|
||||||
|
respawnInfo = respawnManager.RespawnTimer <= 0.0f ? "" : respawnInfo + ToolBox.SecondsToReadableTime(respawnManager.RespawnTimer);
|
||||||
|
}
|
||||||
|
else if (respawnManager.CurrentState == RespawnManager.State.Transporting)
|
||||||
|
{
|
||||||
|
respawnInfo = respawnManager.TransportTimer <= 0.0f ? "" : "Shuttle leaving in " + ToolBox.SecondsToReadableTime(respawnManager.TransportTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(respawnInfo))
|
||||||
|
{
|
||||||
|
GUI.DrawString(spriteBatch,
|
||||||
|
new Vector2(120.0f, 10),
|
||||||
|
respawnInfo, Color.White, null, 0, GUI.SmallFont);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ServerLog.LogFrame?.Draw(spriteBatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool SelectCrewCharacter(Character character, GUIComponent characterFrame)
|
public virtual bool SelectCrewCharacter(Character character, GUIComponent characterFrame)
|
||||||
|
|||||||
@@ -379,13 +379,13 @@ namespace Barotrauma
|
|||||||
showLogButton.UserData = "showlog";
|
showLogButton.UserData = "showlog";
|
||||||
showLogButton.OnClicked = (GUIButton button, object userData) =>
|
showLogButton.OnClicked = (GUIButton button, object userData) =>
|
||||||
{
|
{
|
||||||
if (GameMain.Server.ServerLog.LogFrame == null)
|
if (GameMain.NetworkMember.ServerLog.LogFrame == null)
|
||||||
{
|
{
|
||||||
GameMain.Server.ServerLog.CreateLogFrame();
|
GameMain.NetworkMember.ServerLog.CreateLogFrame();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameMain.Server.ServerLog.LogFrame = null;
|
GameMain.NetworkMember.ServerLog.LogFrame = null;
|
||||||
GUIComponent.KeyboardDispatcher.Subscriber = null;
|
GUIComponent.KeyboardDispatcher.Subscriber = null;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -435,7 +435,9 @@ namespace Barotrauma
|
|||||||
infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "settingsButton"));
|
infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "settingsButton"));
|
||||||
infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "spectateButton"));
|
infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "spectateButton"));
|
||||||
|
|
||||||
InfoFrame.FindChild("showlog").Visible = GameMain.Server != null;
|
InfoFrame.FindChild("showlog").Visible =
|
||||||
|
GameMain.Server != null ||
|
||||||
|
(GameMain.Client != null && GameMain.Client.HasPermission(ClientPermissions.ServerLog));
|
||||||
|
|
||||||
if (campaignViewButton == null)
|
if (campaignViewButton == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
<Preset
|
<Preset
|
||||||
name="Moderator"
|
name="Moderator"
|
||||||
description="Allowed to manage round settings and kick players."
|
description="Allowed to manage round settings, kick players and access server logs."
|
||||||
permissions="EndRound,Kick,SelectSub,SelectMode,ManageCampaign,ConsoleCommands">
|
permissions="EndRound,Kick,SelectSub,SelectMode,ManageCampaign,ConsoleCommands,ServerLog">
|
||||||
<Command name="clientlist"/>
|
<Command name="clientlist"/>
|
||||||
<Command name="autorestart"/>
|
<Command name="autorestart"/>
|
||||||
<Command name="autorestartinterval"/>
|
<Command name="autorestartinterval"/>
|
||||||
@@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
<Preset
|
<Preset
|
||||||
name="Admin"
|
name="Admin"
|
||||||
description="Allowed to ban and kick players, manage round settings and use nearly all console commands."
|
description="Allowed to ban and kick players, manage round settings, access server logs and use nearly all console commands."
|
||||||
permissions="EndRound,Kick,Ban,SelectSub,SelectMode,ManageCampaign,ConsoleCommands">
|
permissions="EndRound,Kick,Ban,SelectSub,SelectMode,ManageCampaign,ConsoleCommands,ServerLog">
|
||||||
<Command name="clientlist"/>
|
<Command name="clientlist"/>
|
||||||
<Command name="autorestart"/>
|
<Command name="autorestart"/>
|
||||||
<Command name="autorestartinterval"/>
|
<Command name="autorestartinterval"/>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
enum ChatMessageType
|
enum ChatMessageType
|
||||||
{
|
{
|
||||||
Default, Error, Dead, Server, Radio, Private, Console, MessageBox
|
Default, Error, Dead, Server, Radio, Private, Console, MessageBox, ServerLog
|
||||||
}
|
}
|
||||||
|
|
||||||
partial class ChatMessage
|
partial class ChatMessage
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ namespace Barotrauma.Networking
|
|||||||
[Description("Manage campaign")]
|
[Description("Manage campaign")]
|
||||||
ManageCampaign = 32,
|
ManageCampaign = 32,
|
||||||
[Description("Console commands")]
|
[Description("Console commands")]
|
||||||
ConsoleCommands = 64
|
ConsoleCommands = 64,
|
||||||
|
[Description("Access server log")]
|
||||||
|
ServerLog = 128
|
||||||
}
|
}
|
||||||
|
|
||||||
class PermissionPreset
|
class PermissionPreset
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ namespace Barotrauma.Networking
|
|||||||
private bool masterServerResponded;
|
private bool masterServerResponded;
|
||||||
private IRestResponse masterServerResponse;
|
private IRestResponse masterServerResponse;
|
||||||
|
|
||||||
private ServerLog log;
|
|
||||||
|
|
||||||
private bool initiatedStartGame;
|
private bool initiatedStartGame;
|
||||||
private CoroutineHandle startGameCoroutine;
|
private CoroutineHandle startGameCoroutine;
|
||||||
|
|
||||||
@@ -58,11 +56,6 @@ namespace Barotrauma.Networking
|
|||||||
get { return entityEventManager; }
|
get { return entityEventManager; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerLog ServerLog
|
|
||||||
{
|
|
||||||
get { return log; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public TimeSpan UpdateInterval
|
public TimeSpan UpdateInterval
|
||||||
{
|
{
|
||||||
get { return updateInterval; }
|
get { return updateInterval; }
|
||||||
@@ -115,7 +108,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
|
config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
|
||||||
|
|
||||||
log = new ServerLog(name);
|
ServerLog = new ServerLog(name);
|
||||||
|
|
||||||
InitProjSpecific();
|
InitProjSpecific();
|
||||||
|
|
||||||
@@ -342,7 +335,7 @@ namespace Barotrauma.Networking
|
|||||||
#if CLIENT
|
#if CLIENT
|
||||||
if (ShowNetStats) netStats.Update(deltaTime);
|
if (ShowNetStats) netStats.Update(deltaTime);
|
||||||
if (settingsFrame != null) settingsFrame.Update(deltaTime);
|
if (settingsFrame != null) settingsFrame.Update(deltaTime);
|
||||||
if (log.LogFrame != null) log.LogFrame.Update(deltaTime);
|
if (ServerLog.LogFrame != null) ServerLog.LogFrame.Update(deltaTime);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!started) return;
|
if (!started) return;
|
||||||
@@ -1503,7 +1496,7 @@ namespace Barotrauma.Networking
|
|||||||
GameMain.NetLobbyScreen.LastUpdateID++;
|
GameMain.NetLobbyScreen.LastUpdateID++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SaveServerLogs) log.Save();
|
if (SaveServerLogs) ServerLog.Save();
|
||||||
|
|
||||||
Character.Controlled = null;
|
Character.Controlled = null;
|
||||||
|
|
||||||
@@ -2260,7 +2253,15 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
if (GameMain.Server == null || !GameMain.Server.SaveServerLogs) return;
|
if (GameMain.Server == null || !GameMain.Server.SaveServerLogs) return;
|
||||||
|
|
||||||
GameMain.Server.log.WriteLine(line, messageType);
|
GameMain.Server.ServerLog.WriteLine(line, messageType);
|
||||||
|
|
||||||
|
foreach (Client client in GameMain.Server.ConnectedClients)
|
||||||
|
{
|
||||||
|
if (!client.HasPermission(ClientPermissions.ServerLog)) continue;
|
||||||
|
//use sendername as the message type
|
||||||
|
GameMain.Server.SendChatMessage(
|
||||||
|
ChatMessage.Create(messageType.ToString(), line, ChatMessageType.ServerLog, null), client);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Disconnect()
|
public override void Disconnect()
|
||||||
@@ -2281,7 +2282,7 @@ namespace Barotrauma.Networking
|
|||||||
if (SaveServerLogs)
|
if (SaveServerLogs)
|
||||||
{
|
{
|
||||||
Log("Shutting down the server...", ServerLog.MessageType.ServerMessage);
|
Log("Shutting down the server...", ServerLog.MessageType.ServerMessage);
|
||||||
log.Save();
|
ServerLog.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
GameAnalyticsManager.AddDesignEvent("GameServer:ShutDown");
|
GameAnalyticsManager.AddDesignEvent("GameServer:ShutDown");
|
||||||
|
|||||||
@@ -151,11 +151,11 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return log.LinesPerFile;
|
return ServerLog.LinesPerFile;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
log.LinesPerFile = value;
|
ServerLog.LinesPerFile = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -122,6 +122,12 @@ namespace Barotrauma.Networking
|
|||||||
get { return respawnManager; }
|
get { return respawnManager; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ServerLog ServerLog
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
protected set;
|
||||||
|
}
|
||||||
|
|
||||||
public NetworkMember()
|
public NetworkMember()
|
||||||
{
|
{
|
||||||
InitProjSpecific();
|
InitProjSpecific();
|
||||||
|
|||||||
@@ -60,8 +60,6 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
public const string SavePath = "ServerLogs";
|
public const string SavePath = "ServerLogs";
|
||||||
|
|
||||||
private string serverName;
|
|
||||||
|
|
||||||
private readonly Queue<LogMessage> lines;
|
private readonly Queue<LogMessage> lines;
|
||||||
|
|
||||||
private int unsavedLineCount;
|
private int unsavedLineCount;
|
||||||
@@ -75,10 +73,11 @@ namespace Barotrauma.Networking
|
|||||||
set { linesPerFile = Math.Max(value, 10); }
|
set { linesPerFile = Math.Max(value, 10); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string ServerName;
|
||||||
|
|
||||||
public ServerLog(string serverName)
|
public ServerLog(string serverName)
|
||||||
{
|
{
|
||||||
this.serverName = serverName;
|
ServerName = serverName;
|
||||||
|
|
||||||
lines = new Queue<LogMessage>();
|
lines = new Queue<LogMessage>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +138,7 @@ namespace Barotrauma.Networking
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string fileName = serverName + "_" + DateTime.Now.ToString("yyyy-MM-dd_HH:mm") + ".txt";
|
string fileName = ServerName + "_" + DateTime.Now.ToString("yyyy-MM-dd_HH:mm") + ".txt";
|
||||||
|
|
||||||
var invalidChars = Path.GetInvalidFileNameChars();
|
var invalidChars = Path.GetInvalidFileNameChars();
|
||||||
foreach (char invalidChar in invalidChars)
|
foreach (char invalidChar in invalidChars)
|
||||||
@@ -156,6 +155,7 @@ namespace Barotrauma.Networking
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Saving the server log to " + filePath + " failed", e);
|
DebugConsole.ThrowError("Saving the server log to " + filePath + " failed", e);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user