diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index 58fa6faeb..c7f64f6d2 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -1720,7 +1720,7 @@ namespace Barotrauma var attackingCharacter = attacker as Character; if (attackingCharacter != null && attackingCharacter.AIController == null) { - GameServer.Log(Name + " attacked by " + attackingCharacter.Name+". Damage: "+attackResult.Damage+" Bleeding damage: "+attackResult.Bleeding, Color.Orange); + GameServer.Log(Name + " attacked by " + attackingCharacter.Name+". Damage: "+attackResult.Damage+" Bleeding damage: "+attackResult.Bleeding, ServerLog.MessageType.Attack); } return attackResult; @@ -1857,7 +1857,7 @@ namespace Barotrauma AnimController.Frozen = false; - GameServer.Log(Name+" has died (Cause of death: "+causeOfDeath+")", Color.Red); + GameServer.Log(Name+" has died (Cause of death: "+causeOfDeath+")", ServerLog.MessageType.Attack); if (OnDeath != null) OnDeath(this, causeOfDeath); diff --git a/Subsurface/Source/Events/Missions/Mission.cs b/Subsurface/Source/Events/Missions/Mission.cs index c6088203a..6810e91f5 100644 --- a/Subsurface/Source/Events/Missions/Mission.cs +++ b/Subsurface/Source/Events/Missions/Mission.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using Barotrauma.Networking; +using Microsoft.Xna.Framework; using System; using System.Collections.Generic; using System.Linq; @@ -243,7 +244,7 @@ namespace Barotrauma string header = index < headers.Count ? headers[index] : ""; string message = index < messages.Count ? messages[index] : ""; - Barotrauma.Networking.GameServer.Log("Mission info: " + header + " - " + message, Color.Cyan); + GameServer.Log("Mission info: " + header + " - " + message, ServerLog.MessageType.Error); new GUIMessageBox(header, message); } diff --git a/Subsurface/Source/GameSession/GameModes/MissionMode.cs b/Subsurface/Source/GameSession/GameModes/MissionMode.cs index 24bf6e751..55a48f513 100644 --- a/Subsurface/Source/GameSession/GameModes/MissionMode.cs +++ b/Subsurface/Source/GameSession/GameModes/MissionMode.cs @@ -30,9 +30,8 @@ namespace Barotrauma var missionMsg = new GUIMessageBox(mission.Name, mission.Description, 400, 400); missionMsg.UserData = "missionstartmessage"; - Networking.GameServer.Log("Mission: " + mission.Name, Color.Cyan); - Networking.GameServer.Log(mission.Description, Color.Cyan); - + Networking.GameServer.Log("Mission: " + mission.Name, Networking.ServerLog.MessageType.Error); + Networking.GameServer.Log(mission.Description, Networking.ServerLog.MessageType.Error); } } } diff --git a/Subsurface/Source/Items/Components/DockingPort.cs b/Subsurface/Source/Items/Components/DockingPort.cs index bdfbb8441..57b2519d5 100644 --- a/Subsurface/Source/Items/Components/DockingPort.cs +++ b/Subsurface/Source/Items/Components/DockingPort.cs @@ -752,12 +752,12 @@ namespace Barotrauma.Items.Components if (docked) { if (item.Submarine != null && dockingTarget?.item?.Submarine != null) - GameServer.Log(sender.Name + " docked "+item.Submarine.Name+" to "+dockingTarget.item.Submarine, Color.White); + GameServer.Log(sender.Name + " docked " + item.Submarine.Name + " to " + dockingTarget.item.Submarine, ServerLog.MessageType.ItemInteraction); } else { if (item.Submarine != null && prevDockingTarget?.item?.Submarine != null) - GameServer.Log(sender.Name + " undocked " + item.Submarine.Name + " from " + prevDockingTarget.item.Submarine, Color.White); + GameServer.Log(sender.Name + " undocked " + item.Submarine.Name + " from " + prevDockingTarget.item.Submarine, ServerLog.MessageType.ItemInteraction); } } } diff --git a/Subsurface/Source/Items/Components/Door.cs b/Subsurface/Source/Items/Components/Door.cs index debb8aaed..db75742b3 100644 --- a/Subsurface/Source/Items/Components/Door.cs +++ b/Subsurface/Source/Items/Components/Door.cs @@ -501,7 +501,7 @@ namespace Barotrauma.Items.Components if (sender != null && wasOpen != isOpen) { - GameServer.Log(sender.Name + (isOpen ? " opened " : " closed ") + item.Name, Color.White); + GameServer.Log(sender.Name + (isOpen ? " opened " : " closed ") + item.Name, ServerLog.MessageType.ItemInteraction); } } diff --git a/Subsurface/Source/Items/Components/Holdable/Holdable.cs b/Subsurface/Source/Items/Components/Holdable/Holdable.cs index 2a0e02dc8..d692fad36 100644 --- a/Subsurface/Source/Items/Components/Holdable/Holdable.cs +++ b/Subsurface/Source/Items/Components/Holdable/Holdable.cs @@ -167,7 +167,7 @@ namespace Barotrauma.Items.Components item.body.Enabled = true; IsActive = true; - if (!alreadySelected) Barotrauma.Networking.GameServer.Log(character.Name+" equipped "+item.Name, Color.Orange); + if (!alreadySelected) Networking.GameServer.Log(character.Name + " equipped " + item.Name, Networking.ServerLog.MessageType.ItemInteraction); } } @@ -177,7 +177,7 @@ namespace Barotrauma.Items.Components picker.DeselectItem(item); - Barotrauma.Networking.GameServer.Log(character.Name + " unequipped " + item.Name, Color.Orange); + Networking.GameServer.Log(character.Name + " unequipped " + item.Name, Networking.ServerLog.MessageType.ItemInteraction); item.body.Enabled = false; IsActive = false; diff --git a/Subsurface/Source/Items/Components/Holdable/MeleeWeapon.cs b/Subsurface/Source/Items/Components/Holdable/MeleeWeapon.cs index 26ddbe6a4..b8c6acdb1 100644 --- a/Subsurface/Source/Items/Components/Holdable/MeleeWeapon.cs +++ b/Subsurface/Source/Items/Components/Holdable/MeleeWeapon.cs @@ -250,7 +250,7 @@ namespace Barotrauma.Items.Components logStr += "(" + string.Join(", ", item.ContainedItems.Select(i => i?.Name)) + ")"; } logStr += " on " + target + "."; - Networking.GameServer.Log(logStr, Color.Orange); + Networking.GameServer.Log(logStr, Networking.ServerLog.MessageType.Attack); } ApplyStatusEffects(ActionType.OnUse, 1.0f, limb.character); diff --git a/Subsurface/Source/Items/Components/Machines/Pump.cs b/Subsurface/Source/Items/Components/Machines/Pump.cs index 1e1a860a4..12c824990 100644 --- a/Subsurface/Source/Items/Components/Machines/Pump.cs +++ b/Subsurface/Source/Items/Components/Machines/Pump.cs @@ -77,7 +77,7 @@ namespace Barotrauma.Items.Components if (GameMain.Server != null) { item.CreateServerEvent(this); - GameServer.Log(Character.Controlled + (IsActive ? " turned on " : " turned off ") + item.Name, Color.Orange); + GameServer.Log(Character.Controlled + (IsActive ? " turned on " : " turned off ") + item.Name, ServerLog.MessageType.ItemInteraction); } else if (GameMain.Client != null) { @@ -96,7 +96,7 @@ namespace Barotrauma.Items.Components if (GameMain.Server != null) { item.CreateServerEvent(this); - GameServer.Log(Character.Controlled + " set the pumping speed of " + item.Name + " to " + (int)(flowPercentage) + " %", Color.Orange); + GameServer.Log(Character.Controlled + " set the pumping speed of " + item.Name + " to " + (int)(flowPercentage) + " %", ServerLog.MessageType.ItemInteraction); } else if (GameMain.Client != null) { @@ -115,7 +115,7 @@ namespace Barotrauma.Items.Components if (GameMain.Server != null) { item.CreateServerEvent(this); - GameServer.Log(Character.Controlled + " set the pumping speed of " + item.Name + " to " + (int)(flowPercentage) + " %", Color.Orange); + GameServer.Log(Character.Controlled + " set the pumping speed of " + item.Name + " to " + (int)(flowPercentage) + " %", ServerLog.MessageType.ItemInteraction); } else if (GameMain.Client != null) { @@ -249,11 +249,11 @@ namespace Barotrauma.Items.Components { if (newFlowPercentage != FlowPercentage) { - GameServer.Log(c.Character + " set the pumping speed of " + item.Name + " to " + (int)(newFlowPercentage) + " %", Color.Orange); + GameServer.Log(c.Character + " set the pumping speed of " + item.Name + " to " + (int)(newFlowPercentage) + " %", ServerLog.MessageType.ItemInteraction); } if (newIsActive != IsActive) { - GameServer.Log(c.Character + (newIsActive ? " turned on " : " turned off ") + item.Name, Color.Orange); + GameServer.Log(c.Character + (newIsActive ? " turned on " : " turned off ") + item.Name, ServerLog.MessageType.ItemInteraction); } FlowPercentage = newFlowPercentage; diff --git a/Subsurface/Source/Items/Components/Machines/Reactor.cs b/Subsurface/Source/Items/Components/Machines/Reactor.cs index 218d6d3ec..8018300a1 100644 --- a/Subsurface/Source/Items/Components/Machines/Reactor.cs +++ b/Subsurface/Source/Items/Components/Machines/Reactor.cs @@ -262,8 +262,8 @@ namespace Barotrauma.Items.Components ", Fission rate: " + (int)fissionRate + ", Cooling rate: " + (int)coolingRate + ", Cooling rate: " + coolingRate + - ", Shutdown temp: " + shutDownTemp, - Color.Orange); + ", Shutdown temp: " + shutDownTemp, + ServerLog.MessageType.ItemInteraction); nextServerLogWriteTime = null; lastServerLogWriteTime = (float)Timing.TotalTime; @@ -414,7 +414,7 @@ namespace Barotrauma.Items.Components { if (item.Condition <= 0.0f) return; - GameServer.Log("Reactor meltdown!", Color.Red); + GameServer.Log("Reactor meltdown!", ServerLog.MessageType.ItemInteraction); new RepairTask(item, 60.0f, "Reactor meltdown!"); item.Condition = 0.0f; diff --git a/Subsurface/Source/Items/Components/Power/PowerContainer.cs b/Subsurface/Source/Items/Components/Power/PowerContainer.cs index e46c13450..fb617d08c 100644 --- a/Subsurface/Source/Items/Components/Power/PowerContainer.cs +++ b/Subsurface/Source/Items/Components/Power/PowerContainer.cs @@ -102,7 +102,7 @@ namespace Barotrauma.Items.Components if (GameMain.Server != null) { item.CreateServerEvent(this); - GameServer.Log(Character.Controlled + " set the recharge speed of " + item.Name + " to " + (int)((rechargeSpeed / maxRechargeSpeed) * 100.0f) + " %", Color.Orange); + GameServer.Log(Character.Controlled + " set the recharge speed of " + item.Name + " to " + (int)((rechargeSpeed / maxRechargeSpeed) * 100.0f) + " %", ServerLog.MessageType.ItemInteraction); } else if (GameMain.Client != null) { @@ -121,7 +121,7 @@ namespace Barotrauma.Items.Components if (GameMain.Server != null) { item.CreateServerEvent(this); - GameServer.Log(Character.Controlled + " set the recharge speed of " + item.Name + " to " + (int)((rechargeSpeed / maxRechargeSpeed) * 100.0f) + " %", Color.Orange); + GameServer.Log(Character.Controlled + " set the recharge speed of " + item.Name + " to " + (int)((rechargeSpeed / maxRechargeSpeed) * 100.0f) + " %", ServerLog.MessageType.ItemInteraction); } else if (GameMain.Client != null) { @@ -289,7 +289,7 @@ namespace Barotrauma.Items.Components if (item.CanClientAccess(c)) { RechargeSpeed = newRechargeSpeed; - GameServer.Log(c.Character + " set the recharge speed of "+item.Name+" to "+ (int)((rechargeSpeed / maxRechargeSpeed) * 100.0f) + " %", Color.Orange); + GameServer.Log(c.Character + " set the recharge speed of "+item.Name+" to "+ (int)((rechargeSpeed / maxRechargeSpeed) * 100.0f) + " %", ServerLog.MessageType.ItemInteraction); } item.CreateServerEvent(this); diff --git a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs index 0e2b2c4ef..6451c3c4a 100644 --- a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs +++ b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs @@ -215,7 +215,7 @@ namespace Barotrauma.Items.Components } } - Networking.GameServer.Log(item.Name + " rewired by " + c.Character.Name, Color.Orange); + Networking.GameServer.Log(item.Name + " rewired by " + c.Character.Name, ServerLog.MessageType.ItemInteraction); //update the connections for (int i = 0; i < Connections.Count; i++) @@ -233,7 +233,7 @@ namespace Barotrauma.Items.Components Networking.GameServer.Log( item.Name + " (" + Connections[i].Name + ") -> " + - (otherConnection == null ? "none" : otherConnection.Item.Name + " (" + (otherConnection.Name) + ")"), Color.Orange); + (otherConnection == null ? "none" : otherConnection.Item.Name + " (" + (otherConnection.Name) + ")"), ServerLog.MessageType.ItemInteraction); } } diff --git a/Subsurface/Source/Items/Components/Turret.cs b/Subsurface/Source/Items/Components/Turret.cs index 1ea35063c..76374cde2 100644 --- a/Subsurface/Source/Items/Components/Turret.cs +++ b/Subsurface/Source/Items/Components/Turret.cs @@ -194,7 +194,7 @@ namespace Barotrauma.Items.Components if (character != null) { - GameServer.Log(character.Name + " launched " + item.Name, Color.Orange); + GameServer.Log(character.Name + " launched " + item.Name, ServerLog.MessageType.ItemInteraction); } return true; diff --git a/Subsurface/Source/Items/Inventory.cs b/Subsurface/Source/Items/Inventory.cs index ada0a842e..f48846032 100644 --- a/Subsurface/Source/Items/Inventory.cs +++ b/Subsurface/Source/Items/Inventory.cs @@ -590,11 +590,11 @@ namespace Barotrauma { if (Owner == c.Character) { - GameServer.Log(c.Character + " picked up " + item.Name, Color.Orange); + GameServer.Log(c.Character + " picked up " + item.Name, ServerLog.MessageType.ItemInteraction); } else { - GameServer.Log(c.Character + " placed " + item.Name + " in " + Owner, Color.Orange); + GameServer.Log(c.Character + " placed " + item.Name + " in " + Owner, ServerLog.MessageType.ItemInteraction); } } } @@ -605,11 +605,11 @@ namespace Barotrauma { if (Owner == c.Character) { - GameServer.Log(c.Character + " dropped " + item.Name, Color.Orange); + GameServer.Log(c.Character + " dropped " + item.Name, ServerLog.MessageType.ItemInteraction); } else { - GameServer.Log(c.Character + " removed " + item.Name + " from " + Owner, Color.Orange); + GameServer.Log(c.Character + " removed " + item.Name + " from " + Owner, ServerLog.MessageType.ItemInteraction); } } } diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index 225795baf..5b90e9ecd 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -1875,7 +1875,7 @@ namespace Barotrauma ApplyStatusEffects(ActionType.OnUse, (float)Timing.Step, c.Character); - GameServer.Log(c.Character.Name +" used item "+Name, Color.White); + GameServer.Log(c.Character.Name + " used item " + Name, ServerLog.MessageType.ItemInteraction); GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.ApplyStatusEffect, c.Character.ID }); diff --git a/Subsurface/Source/Networking/BanList.cs b/Subsurface/Source/Networking/BanList.cs index 2bf250e52..778f6e463 100644 --- a/Subsurface/Source/Networking/BanList.cs +++ b/Subsurface/Source/Networking/BanList.cs @@ -125,7 +125,7 @@ namespace Barotrauma.Networking if (banned == null) return false; DebugConsole.Log("Removing ban from " + banned.Name); - GameServer.Log("Removing ban from " + banned.Name, null); + GameServer.Log("Removing ban from " + banned.Name, ServerLog.MessageType.ServerMessage); bannedPlayers.Remove(banned); @@ -189,7 +189,7 @@ namespace Barotrauma.Networking public void Save() { - GameServer.Log("Saving banlist", null); + GameServer.Log("Saving banlist", ServerLog.MessageType.ServerMessage); List lines = new List(); diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index 7173c2238..3906d29c4 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -164,7 +164,7 @@ namespace Barotrauma.Networking bool error = false; try { - Log("Starting the server...", Color.Cyan); + Log("Starting the server...", ServerLog.MessageType.ServerMessage); server = new NetServer(config); netPeer = server; @@ -176,7 +176,7 @@ namespace Barotrauma.Networking } catch (Exception e) { - Log("Error while starting the server (" + e.Message + ")", Color.Red); + Log("Error while starting the server (" + e.Message + ")", ServerLog.MessageType.Error); System.Net.Sockets.SocketException socketException = e as System.Net.Sockets.SocketException; @@ -233,7 +233,7 @@ namespace Barotrauma.Networking updateInterval = new TimeSpan(0, 0, 0, 0, 150); - Log("Server started", Color.Cyan); + Log("Server started", ServerLog.MessageType.ServerMessage); GameMain.NetLobbyScreen.Select(); started = true; @@ -266,7 +266,7 @@ namespace Barotrauma.Networking { restRequestHandle.Abort(); DebugConsole.NewMessage("Couldn't register to master server (request timed out)", Color.Red); - Log("Couldn't register to master server (request timed out)", Color.Red); + Log("Couldn't register to master server (request timed out)", ServerLog.MessageType.Error); yield return CoroutineStatus.Success; } @@ -304,7 +304,7 @@ namespace Barotrauma.Networking request.AddParameter("currplayers", connectedClients.Count); request.AddParameter("maxplayers", MaxPlayers); - Log("Refreshing connection with master server...", Color.Cyan); + Log("Refreshing connection with master server...", ServerLog.MessageType.ServerMessage); var sw = new Stopwatch(); sw.Start(); @@ -320,7 +320,7 @@ namespace Barotrauma.Networking { restRequestHandle.Abort(); DebugConsole.NewMessage("Couldn't connect to master server (request timed out)", Color.Red); - Log("Couldn't connect to master server (request timed out)", Color.Red); + Log("Couldn't connect to master server (request timed out)", ServerLog.MessageType.Error); yield return CoroutineStatus.Success; } @@ -329,22 +329,22 @@ namespace Barotrauma.Networking if (masterServerResponse.Content == "Error: server not found") { - Log("Not registered to master server, re-registering...", Color.Red); + Log("Not registered to master server, re-registering...", ServerLog.MessageType.Error); CoroutineManager.StartCoroutine(RegisterToMasterServer()); } else if (masterServerResponse.ErrorException != null) { DebugConsole.NewMessage("Error while registering to master server (" + masterServerResponse.ErrorException + ")", Color.Red); - Log("Error while registering to master server (" + masterServerResponse.ErrorException + ")", Color.Red); + Log("Error while registering to master server (" + masterServerResponse.ErrorException + ")", ServerLog.MessageType.Error); } else if (masterServerResponse.StatusCode != System.Net.HttpStatusCode.OK) { DebugConsole.NewMessage("Error while reporting to master server (" + masterServerResponse.StatusCode + ": " + masterServerResponse.StatusDescription + ")", Color.Red); - Log("Error while reporting to master server (" + masterServerResponse.StatusCode + ": " + masterServerResponse.StatusDescription + ")", Color.Red); + Log("Error while reporting to master server (" + masterServerResponse.StatusCode + ": " + masterServerResponse.StatusDescription + ")", ServerLog.MessageType.Error); } else { - Log("Master server responded", Color.Cyan); + Log("Master server responded", ServerLog.MessageType.ServerMessage); } System.Diagnostics.Debug.WriteLine("took "+sw.ElapsedMilliseconds+" ms"); @@ -406,11 +406,11 @@ namespace Barotrauma.Networking { if (AutoRestart && isCrewDead) { - Log("Ending round (entire crew dead)", Color.Cyan); + Log("Ending round (entire crew dead)", ServerLog.MessageType.ServerMessage); } else { - Log("Ending round (submarine reached the end of the level)", Color.Cyan); + Log("Ending round (submarine reached the end of the level)", ServerLog.MessageType.ServerMessage); } EndGame(); @@ -777,7 +777,7 @@ namespace Barotrauma.Networking if (!c.HasPermission(command)) { - Log("Client \""+c.name+"\" sent a server command \""+command+"\". Permission denied.", Color.Red); + Log("Client \""+c.name+"\" sent a server command \""+command+"\". Permission denied.", ServerLog.MessageType.ServerMessage); return; } @@ -788,7 +788,7 @@ namespace Barotrauma.Networking var kickedClient = connectedClients.Find(cl => cl != c && cl.name == kickedName); if (kickedClient != null) { - Log("Client \"" + c.name + "\" kicked \"" + kickedClient.name + "\".", Color.Red); + Log("Client \"" + c.name + "\" kicked \"" + kickedClient.name + "\".", ServerLog.MessageType.ServerMessage); KickClient(kickedClient, false, false); } break; @@ -797,14 +797,14 @@ namespace Barotrauma.Networking var bannedClient = connectedClients.Find(cl => cl != c && cl.name == bannedName); if (bannedClient != null) { - Log("Client \"" + c.name + "\" banned \"" + bannedClient.name + "\".", Color.Red); + Log("Client \"" + c.name + "\" banned \"" + bannedClient.name + "\".", ServerLog.MessageType.ServerMessage); KickClient(bannedClient, true, false); } break; case ClientPermissions.EndRound: if (gameStarted) { - Log("Client \"" + c.name + "\" ended the round.", Color.Cyan); + Log("Client \"" + c.name + "\" ended the round.", ServerLog.MessageType.ServerMessage); EndGame(); } break; @@ -1088,10 +1088,10 @@ namespace Barotrauma.Networking GameMain.GameSession.StartShift(GameMain.NetLobbyScreen.LevelSeed, teamCount > 1); - GameServer.Log("Starting a new round...", Color.Cyan); - GameServer.Log("Submarine: " + selectedSub.Name, Color.Cyan); - GameServer.Log("Game mode: " + selectedMode.Name, Color.Cyan); - GameServer.Log("Level seed: " + GameMain.NetLobbyScreen.LevelSeed, Color.Cyan); + GameServer.Log("Starting a new round...", ServerLog.MessageType.ServerMessage); + GameServer.Log("Submarine: " + selectedSub.Name, ServerLog.MessageType.ServerMessage); + GameServer.Log("Game mode: " + selectedMode.Name, ServerLog.MessageType.ServerMessage); + GameServer.Log("Level seed: " + GameMain.NetLobbyScreen.LevelSeed, ServerLog.MessageType.ServerMessage); bool missionAllowRespawn = !(GameMain.GameSession.gameMode is MissionMode) || @@ -1166,7 +1166,7 @@ namespace Barotrauma.Networking if (TraitorManager.TraitorCharacter!=null && TraitorManager.TargetCharacter != null) { - Log(TraitorManager.TraitorCharacter.Name + " is the traitor and the target is " + TraitorManager.TargetCharacter.Name, Color.Cyan); + Log(TraitorManager.TraitorCharacter.Name + " is the traitor and the target is " + TraitorManager.TargetCharacter.Name, ServerLog.MessageType.ServerMessage); } } @@ -1409,7 +1409,7 @@ namespace Barotrauma.Networking if (string.IsNullOrWhiteSpace(msg)) msg = client.name + " has left the server"; if (string.IsNullOrWhiteSpace(targetmsg)) targetmsg = "You have left the server"; - Log(msg, ChatMessage.MessageColor[(int)ChatMessageType.Server]); + Log(msg, ServerLog.MessageType.ServerMessage); client.Connection.Disconnect(targetmsg); @@ -1818,7 +1818,7 @@ namespace Barotrauma.Networking if (Voting.AllowEndVoting && EndVoteMax > 0 && ((float)EndVoteCount / (float)EndVoteMax) >= EndVoteRequiredRatio) { - Log("Ending round by votes (" + EndVoteCount + "/" + (EndVoteMax - EndVoteCount) + ")", Color.Cyan); + Log("Ending round by votes (" + EndVoteCount + "/" + (EndVoteMax - EndVoteCount) + ")", ServerLog.MessageType.ServerMessage); EndGame(); } } @@ -2005,11 +2005,11 @@ namespace Barotrauma.Networking return preferredClient; } - public static void Log(string line, Color? color) + public static void Log(string line, ServerLog.MessageType messageType) { if (GameMain.Server == null || !GameMain.Server.SaveServerLogs) return; - GameMain.Server.log.WriteLine(line, color); + GameMain.Server.log.WriteLine(line, messageType); } public override void Disconnect() @@ -2029,7 +2029,7 @@ namespace Barotrauma.Networking if (SaveServerLogs) { - Log("Shutting down server...", Color.Cyan); + Log("Shutting down the server...", ServerLog.MessageType.ServerMessage); log.Save(); } diff --git a/Subsurface/Source/Networking/GameServerLogin.cs b/Subsurface/Source/Networking/GameServerLogin.cs index c4912892c..eca8a0ed7 100644 --- a/Subsurface/Source/Networking/GameServerLogin.cs +++ b/Subsurface/Source/Networking/GameServerLogin.cs @@ -127,45 +127,45 @@ namespace Barotrauma.Networking { DisconnectUnauthClient(inc, unauthClient, "You need a name."); - Log(inc.SenderConnection.RemoteEndPoint.Address.ToString() + " couldn't join the server (no name given)", Color.Red); + Log(inc.SenderConnection.RemoteEndPoint.Address.ToString() + " couldn't join the server (no name given)", ServerLog.MessageType.Error); return; } if (clVersion != GameMain.Version.ToString()) { DisconnectUnauthClient(inc, unauthClient, "Version " + GameMain.Version + " required to connect to the server (Your version: " + clVersion + ")"); - Log(clName + " couldn't join the server (wrong game version)", Color.Red); + Log(clName + " couldn't join the server (wrong game version)", ServerLog.MessageType.Error); return; } if (clPackageName != GameMain.SelectedPackage.Name) { DisconnectUnauthClient(inc, unauthClient, "Your content package (" + clPackageName + ") doesn't match the server's version (" + GameMain.SelectedPackage.Name + ")"); - Log(clName + " couldn't join the server (wrong content package name)", Color.Red); + Log(clName + " couldn't join the server (wrong content package name)", ServerLog.MessageType.Error); return; } if (clPackageHash != GameMain.SelectedPackage.MD5hash.Hash) { DisconnectUnauthClient(inc, unauthClient, "Your content package (MD5: " + clPackageHash + ") doesn't match the server's version (MD5: " + GameMain.SelectedPackage.MD5hash.Hash + ")"); - Log(clName + " couldn't join the server (wrong content package hash)", Color.Red); + Log(clName + " couldn't join the server (wrong content package hash)", ServerLog.MessageType.Error); return; } if (!whitelist.IsWhiteListed(clName, inc.SenderConnection.RemoteEndPoint.Address.ToString())) { DisconnectUnauthClient(inc, unauthClient, "You're not in this server's whitelist."); - Log(clName + " (" + inc.SenderConnection.RemoteEndPoint.Address.ToString() + ") couldn't join the server (not in whitelist)", Color.Red); + Log(clName + " (" + inc.SenderConnection.RemoteEndPoint.Address.ToString() + ") couldn't join the server (not in whitelist)", ServerLog.MessageType.Error); return; } if (!Client.IsValidName(clName)) { DisconnectUnauthClient(inc, unauthClient, "Your name contains illegal symbols."); - Log(clName + " (" + inc.SenderConnection.RemoteEndPoint.Address.ToString() + ") couldn't join the server (invalid name)", Color.Red); + Log(clName + " (" + inc.SenderConnection.RemoteEndPoint.Address.ToString() + ") couldn't join the server (invalid name)", ServerLog.MessageType.Error); return; } if (clName.ToLower() == Name.ToLower()) { DisconnectUnauthClient(inc, unauthClient, "That name is taken."); - Log(clName + " (" + inc.SenderConnection.RemoteEndPoint.Address.ToString() + ") couldn't join the server (name taken by the server)", Color.Red); + Log(clName + " (" + inc.SenderConnection.RemoteEndPoint.Address.ToString() + ") couldn't join the server (name taken by the server)", ServerLog.MessageType.Error); return; } Client nameTaken = ConnectedClients.Find(c => c.name.ToLower() == clName.ToLower()); @@ -185,7 +185,7 @@ namespace Barotrauma.Networking { //can't authorize this client DisconnectUnauthClient(inc, unauthClient, "That name is taken."); - Log(clName + " (" + inc.SenderConnection.RemoteEndPoint.Address.ToString() + ") couldn't join the server (name already taken)", Color.Red); + Log(clName + " (" + inc.SenderConnection.RemoteEndPoint.Address.ToString() + ") couldn't join the server (name already taken)", ServerLog.MessageType.Error); return; } } diff --git a/Subsurface/Source/Networking/GameServerSettings.cs b/Subsurface/Source/Networking/GameServerSettings.cs index aa2897fe7..b2ae0e810 100644 --- a/Subsurface/Source/Networking/GameServerSettings.cs +++ b/Subsurface/Source/Networking/GameServerSettings.cs @@ -741,7 +741,7 @@ namespace Barotrauma.Networking public void SaveClientPermissions() { - GameServer.Log("Saving client permissions", null); + GameServer.Log("Saving client permissions", ServerLog.MessageType.ServerMessage); List lines = new List(); diff --git a/Subsurface/Source/Networking/NetworkMember.cs b/Subsurface/Source/Networking/NetworkMember.cs index 0505eda01..f7ce98a20 100644 --- a/Subsurface/Source/Networking/NetworkMember.cs +++ b/Subsurface/Source/Networking/NetworkMember.cs @@ -227,7 +227,7 @@ namespace Barotrauma.Networking public void AddChatMessage(ChatMessage message) { - GameServer.Log(message.TextWithSender, message.Color); + GameServer.Log(message.TextWithSender, ServerLog.MessageType.Chat); string displayedText = message.Text; diff --git a/Subsurface/Source/Networking/ServerLog.cs b/Subsurface/Source/Networking/ServerLog.cs index f37e1c8a6..8b91da750 100644 --- a/Subsurface/Source/Networking/ServerLog.cs +++ b/Subsurface/Source/Networking/ServerLog.cs @@ -8,6 +8,36 @@ namespace Barotrauma.Networking { class ServerLog { + private struct LogMessage + { + public readonly string Text; + public readonly MessageType Type; + + public LogMessage(string text, MessageType type) + { + Text = "[" + DateTime.Now.ToString() + "] " + text; + Type = type; + } + } + + public enum MessageType + { + Chat, + ItemInteraction, + Attack, + ServerMessage, + Error + } + + private Color[] MessageColor = new Color[] + { + Color.LightBlue, + new Color(238, 208, 0), + new Color(204, 74, 78), + new Color(157, 225, 160), + Color.Red + }; + private int linesPerFile = 800; public const string SavePath = "ServerLogs"; @@ -18,7 +48,7 @@ namespace Barotrauma.Networking private GUIListBox listBox; - private readonly Queue lines; + private readonly Queue lines; private int unsavedLineCount; @@ -32,14 +62,14 @@ namespace Barotrauma.Networking { this.serverName = serverName; - lines = new Queue(); + lines = new Queue(); } - public void WriteLine(string line, Color? color) + public void WriteLine(string line, MessageType messageType) { - string logLine = "[" + DateTime.Now.ToLongTimeString() + "] " + line; + //string logLine = "[" + DateTime.Now.ToLongTimeString() + "] " + line; - var newText = new ColoredText(logLine, color == null ? Color.White : (Color)color); + var newText = new LogMessage(line, messageType); lines.Enqueue(newText); @@ -62,7 +92,7 @@ namespace Barotrauma.Networking { listBox.RemoveChild(listBox.children[0]); lines.Dequeue(); - } + } } public void CreateLogFrame() @@ -83,11 +113,11 @@ namespace Barotrauma.Networking clearButton.OnClicked = ClearFilter; clearButton.UserData = searchBox; - listBox = new GUIListBox(new Rectangle(0, 30, 0, 320), "", innerFrame); + listBox = new GUIListBox(new Rectangle(0, 30, 0, 340), "", innerFrame); var currLines = lines.ToList(); - foreach (ColoredText line in currLines) + foreach (LogMessage line in currLines) { AddLine(line); } @@ -104,16 +134,14 @@ namespace Barotrauma.Networking }; } - private void AddLine(ColoredText line) + private void AddLine(LogMessage line) { float prevSize = listBox.BarSize; var textBlock = new GUITextBlock(new Rectangle(0, 0, 0, 0), line.Text, "", Alignment.TopLeft, Alignment.TopLeft, listBox, true, GUI.SmallFont); textBlock.Rect = new Rectangle(textBlock.Rect.X, textBlock.Rect.Y, textBlock.Rect.Width, Math.Max(13, textBlock.Rect.Height)); - - //listBox.AddChild(textBlock); - - textBlock.TextColor = line.Color; + + textBlock.TextColor = MessageColor[(int)line.Type]; textBlock.CanBeFocused = false; if ((prevSize == 1.0f && listBox.BarScroll == 0.0f) || (prevSize < 1.0f && listBox.BarScroll == 1.0f)) listBox.BarScroll = 1.0f; diff --git a/Subsurface/Source/Networking/WhiteList.cs b/Subsurface/Source/Networking/WhiteList.cs index a55097d7e..e3a22253d 100644 --- a/Subsurface/Source/Networking/WhiteList.cs +++ b/Subsurface/Source/Networking/WhiteList.cs @@ -86,7 +86,7 @@ namespace Barotrauma.Networking public void Save() { - GameServer.Log("Saving whitelist", null); + GameServer.Log("Saving whitelist", ServerLog.MessageType.ServerMessage); List lines = new List(); @@ -193,7 +193,7 @@ namespace Barotrauma.Networking if (wlp == null) return false; DebugConsole.Log("Removing " + wlp.Name + " from whitelist"); - GameServer.Log("Removing " + wlp.Name + " from whitelist", null); + GameServer.Log("Removing " + wlp.Name + " from whitelist", ServerLog.MessageType.ServerMessage); whitelistedPlayers.Remove(wlp); Save();