diff --git a/Subsurface/Content/Characters/Moloch/moloch.xml b/Subsurface/Content/Characters/Moloch/moloch.xml
index 17f78f8f3..765e02224 100644
--- a/Subsurface/Content/Characters/Moloch/moloch.xml
+++ b/Subsurface/Content/Characters/Moloch/moloch.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/Subsurface/Content/Items/Diving/divinggear.xml b/Subsurface/Content/Items/Diving/divinggear.xml
index fda2d77d4..804ede07f 100644
--- a/Subsurface/Content/Items/Diving/divinggear.xml
+++ b/Subsurface/Content/Items/Diving/divinggear.xml
@@ -86,12 +86,10 @@
-
+
-
-
-
+
diff --git a/Subsurface/Content/Items/Weapons/weapons.xml b/Subsurface/Content/Items/Weapons/weapons.xml
index 97cf6e072..6a2794628 100644
--- a/Subsurface/Content/Items/Weapons/weapons.xml
+++ b/Subsurface/Content/Items/Weapons/weapons.xml
@@ -66,7 +66,7 @@
-
+
@@ -109,11 +109,11 @@
-
+
-
+
diff --git a/Subsurface/Source/Characters/AI/EnemyAIController.cs b/Subsurface/Source/Characters/AI/EnemyAIController.cs
index 0a14ac5bc..233f6e223 100644
--- a/Subsurface/Source/Characters/AI/EnemyAIController.cs
+++ b/Subsurface/Source/Characters/AI/EnemyAIController.cs
@@ -311,6 +311,8 @@ namespace Barotrauma
{
IDamageable damageTarget = null;
+ float dist = ConvertUnits.ToDisplayUnits(Vector2.Distance(limb.SimPosition, attackPosition));
+
switch (limb.attack.Type)
{
case AttackType.PinchCW:
@@ -328,7 +330,6 @@ namespace Barotrauma
break;
}
- float dist = ConvertUnits.ToDisplayUnits(Vector2.Distance(limb.SimPosition, attackPosition));
if (dist < limb.attack.Range * 0.5f)
{
attackTimer += deltaTime;
@@ -361,10 +362,16 @@ namespace Barotrauma
break;
}
- if (ConvertUnits.ToDisplayUnits(Vector2.Distance(limb.SimPosition, attackPosition)) < limb.attack.Range)
+
+ if (dist < limb.attack.Range)
{
attackTimer += deltaTime;
limb.body.ApplyForce(limb.Mass * limb.attack.Force * Vector2.Normalize(attackPosition - limb.SimPosition));
+
+ if (damageTarget is Character && dist c.Connection == message.SenderConnection);
if (sender != null)
{
- Networking.GameServer.Log("Pump settings adjusted by " + sender.name);
- Networking.GameServer.Log("Active: " + (IsActive ? "yes" : "no ") + " Pumping speed: " + (int)flowPercentage + " %");
+ Networking.GameServer.Log("Pump settings adjusted by " + sender.name, Color.Orange);
+ Networking.GameServer.Log("Active: " + (IsActive ? "yes" : "no ") + " Pumping speed: " + (int)flowPercentage + " %", Color.Orange);
}
}
}
diff --git a/Subsurface/Source/Items/Components/Machines/Reactor.cs b/Subsurface/Source/Items/Components/Machines/Reactor.cs
index 51f610e27..a0845745d 100644
--- a/Subsurface/Source/Items/Components/Machines/Reactor.cs
+++ b/Subsurface/Source/Items/Components/Machines/Reactor.cs
@@ -226,7 +226,7 @@ namespace Barotrauma.Items.Components
fissionRate = Math.Min(fissionRate, AvailableFuel);
float heat = 100 * fissionRate * (AvailableFuel/2000.0f);
- float heatDissipation = 50 * coolingRate + ExtraCooling;
+ float heatDissipation = 50 * coolingRate + Math.Max(ExtraCooling, 5.0f);
float deltaTemp = (((heat - heatDissipation) * 5) - temperature) / 10000.0f;
Temperature = temperature + deltaTemp;
@@ -362,7 +362,7 @@ namespace Barotrauma.Items.Components
{
if (item.Condition <= 0.0f) return;
- GameServer.Log("Reactor meltdown!");
+ GameServer.Log("Reactor meltdown!", Color.Red);
new RepairTask(item, 60.0f, "Reactor meltdown!");
item.Condition = 0.0f;
@@ -583,8 +583,8 @@ namespace Barotrauma.Items.Components
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
if (sender != null)
{
- Networking.GameServer.Log("Reactor settings adjusted by " + sender.name);
- Networking.GameServer.Log("Autotemp: " +(autoTemp ? "ON " : "OFF") + " Shutdown temp: "+shutDownTemp+" Cooling rate: "+coolingRate+" Fission rate: "+fissionRate);
+ Networking.GameServer.Log("Reactor settings adjusted by " + sender.name+": ", Color.Orange);
+ Networking.GameServer.Log("Autotemp: " +(autoTemp ? "ON " : "OFF") + " Shutdown temp: "+shutDownTemp+" Cooling rate: "+(int)coolingRate+" Fission rate: "+(int)fissionRate, Color.Orange);
}
}
diff --git a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs
index 5e0f15b23..b22bfa69c 100644
--- a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs
+++ b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs
@@ -146,7 +146,7 @@ namespace Barotrauma.Items.Components
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
if (sender != null)
{
- Networking.GameServer.Log(item.Name + " rewired by " + sender.name);
+ Networking.GameServer.Log(item.Name + " rewired by " + sender.name, Color.Orange);
}
}
@@ -172,7 +172,7 @@ namespace Barotrauma.Items.Components
wireComponent.Connect(c, false);
var otherConnection = c.Wires[i].OtherConnection(c);
- Networking.GameServer.Log(c.Name + " -> " + (otherConnection == null ? "none" : otherConnection.Name));
+ Networking.GameServer.Log(c.Name + " -> " + (otherConnection == null ? "none" : otherConnection.Name), Color.Orange);
}
c.UpdateRecipients();
}
diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs
index ebc309689..494816aa1 100644
--- a/Subsurface/Source/Items/Item.cs
+++ b/Subsurface/Source/Items/Item.cs
@@ -1125,7 +1125,7 @@ namespace Barotrauma
// new NetworkEvent(NetworkEventType.DropItem, ID, true);
- if (dropper != null) GameServer.Log(dropper.Name + " dropped " + Name);
+ if (dropper != null) GameServer.Log(dropper.Name + " dropped " + Name, Color.Orange);
foreach (ItemComponent ic in components) ic.Drop(dropper);
diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs
index 89982fd94..d4b9647db 100644
--- a/Subsurface/Source/Networking/GameServer.cs
+++ b/Subsurface/Source/Networking/GameServer.cs
@@ -33,18 +33,12 @@ namespace Barotrauma.Networking
private bool masterServerResponded;
private ServerLog log;
+ private GUIButton showLogButton;
public TraitorManager TraitorManager;
public GameServer(string name, int port, bool isPublic = false, string password = "", bool attemptUPnP = false, int maxPlayers = 10)
{
- var endRoundButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170, 20, 150, 25), "End round", Alignment.TopLeft, GUI.Style, inGameHUD);
- endRoundButton.OnClicked = EndButtonHit;
-
- banList = new BanList();
-
- log = new ServerLog(name);
-
this.name = name;
this.password = password;
@@ -74,6 +68,31 @@ namespace Barotrauma.Networking
NetIncomingMessageType.UnconnectedData);
config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
+
+ //----------------------------------------
+
+ var endRoundButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170, 20, 150, 20), "End round", Alignment.TopLeft, GUI.Style, inGameHUD);
+ endRoundButton.OnClicked = EndButtonHit;
+
+ log = new ServerLog(name);
+ showLogButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170 - 170, 20, 150, 20), "Server Log", Alignment.TopLeft, GUI.Style, inGameHUD);
+ showLogButton.OnClicked = (GUIButton button, object userData) =>
+ {
+ if (log.LogFrame == null)
+ {
+ log.CreateLogFrame();
+ }
+ else
+ {
+ log.LogFrame = null;
+ }
+ return true;
+ };
+
+ banList = new BanList();
+
+ //----------------------------------------
+
CoroutineManager.StartCoroutine(StartServer(isPublic));
}
@@ -82,14 +101,14 @@ namespace Barotrauma.Networking
{
try
{
- Log("Starting the server...");
+ Log("Starting the server...", Color.Cyan);
server = new NetServer(config);
netPeer = server;
server.Start();
}
catch (Exception e)
{
- Log("Error while starting the server ("+e.Message+")");
+ Log("Error while starting the server ("+e.Message+")", Color.Red);
DebugConsole.ThrowError("Couldn't start the server", e);
}
@@ -173,7 +192,7 @@ namespace Barotrauma.Networking
request.AddParameter("gamestarted", gameStarted ? 1 : 0);
request.AddParameter("playercount", PlayerCountToByte(ConnectedClients.Count, config.MaximumConnections));
- Log("Refreshing connection with master server...");
+ Log("Refreshing connection with master server...", Color.Cyan);
var sw = new Stopwatch();
sw.Start();
@@ -189,7 +208,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)");
+ Log("Couldn't connect to master server (request timed out)", Color.Red);
break;
//registeredToMaster = false;
@@ -210,24 +229,25 @@ namespace Barotrauma.Networking
if (response.ErrorException != null)
{
DebugConsole.NewMessage("Error while registering to master server (" + response.ErrorException + ")", Color.Red);
- Log("Error while registering to master server (" + response.ErrorException + ")");
+ Log("Error while registering to master server (" + response.ErrorException + ")", Color.Red);
return;
}
if (response.StatusCode != System.Net.HttpStatusCode.OK)
{
DebugConsole.NewMessage("Error while reporting to master server (" + response.StatusCode + ": " + response.StatusDescription + ")", Color.Red);
- Log("Error while reporting to master server (" + response.StatusCode + ": " + response.StatusDescription + ")");
+ Log("Error while reporting to master server (" + response.StatusCode + ": " + response.StatusDescription + ")", Color.Red);
return;
}
- Log("Master server responded");
+ Log("Master server responded", Color.Cyan);
}
public override void Update(float deltaTime)
{
if (ShowNetStats) netStats.Update(deltaTime);
if (settingsFrame != null) settingsFrame.Update(deltaTime);
+ if (log.LogFrame != null) log.LogFrame.Update(deltaTime);
if (!started) return;
@@ -248,11 +268,11 @@ namespace Barotrauma.Networking
{
if (AutoRestart && isCrewDead)
{
- Log("Ending round (entire crew dead)");
+ Log("Ending round (entire crew dead)", Color.Cyan);
}
else
{
- Log("Ending round (submarine reached the end of the level)");
+ Log("Ending round (submarine reached the end of the level)", Color.Cyan);
}
EndButtonHit(null, null);
@@ -499,7 +519,7 @@ namespace Barotrauma.Networking
if (Voting.AllowEndVoting && EndVoteMax > 0 &&
((float)EndVoteCount / (float)EndVoteMax) >= EndVoteRequiredRatio)
{
- Log("Ending round by votes ("+EndVoteCount+"/"+(EndVoteMax-EndVoteCount)+")");
+ Log("Ending round by votes ("+EndVoteCount+"/"+(EndVoteMax-EndVoteCount)+")", Color.Cyan);
EndButtonHit(null,null);
}
break;
@@ -791,10 +811,10 @@ namespace Barotrauma.Networking
GameMain.GameSession = new GameSession(selectedSub, "", selectedMode);
GameMain.GameSession.StartShift(GameMain.NetLobbyScreen.LevelSeed);
- GameServer.Log("Starting a new round...");
- GameServer.Log("Submarine: " + selectedSub.Name);
- GameServer.Log("Game mode: " + selectedMode.Name);
- GameServer.Log("Level seed: " + GameMain.NetLobbyScreen.LevelSeed);
+ 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);
yield return CoroutineStatus.Running;
@@ -1007,7 +1027,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);
+ Log(msg, messageColor[(int)ChatMessageType.Server]);
NetOutgoingMessage outmsg = server.CreateMessage();
outmsg.Write((byte)PacketTypes.KickedOut);
@@ -1115,7 +1135,7 @@ namespace Barotrauma.Networking
return;
}
- Log(traitor.Info.Name + " is the traitor and the target is " + target.Info.Name);
+ Log(traitor.Info.Name + " is the traitor and the target is " + target.Info.Name, Color.Cyan);
Client traitorClient = null;
foreach (Client c in ConnectedClients)
@@ -1138,7 +1158,14 @@ namespace Barotrauma.Networking
{
base.Draw(spriteBatch);
- if (settingsFrame != null) settingsFrame.Draw(spriteBatch);
+ if (settingsFrame != null)
+ {
+ settingsFrame.Draw(spriteBatch);
+ }
+ else if (log.LogFrame!=null)
+ {
+ log.LogFrame.Draw(spriteBatch);
+ }
if (!ShowNetStats) return;
@@ -1428,11 +1455,11 @@ namespace Barotrauma.Networking
return preferredClient;
}
- public static void Log(string line)
+ public static void Log(string line, Color? color)
{
- if (GameMain.Server == null || GameMain.Server.saveServerLogs) return;
+ if (GameMain.Server == null || !GameMain.Server.saveServerLogs) return;
- GameMain.Server.log.WriteLine(line);
+ GameMain.Server.log.WriteLine(line, color);
}
///
@@ -1478,7 +1505,7 @@ namespace Barotrauma.Networking
if (saveServerLogs)
{
- Log("Shutting down server...");
+ Log("Shutting down server...", Color.Cyan);
log.Save();
}
diff --git a/Subsurface/Source/Networking/GameServerSettings.cs b/Subsurface/Source/Networking/GameServerSettings.cs
index 4a1af6c77..e945fe803 100644
--- a/Subsurface/Source/Networking/GameServerSettings.cs
+++ b/Subsurface/Source/Networking/GameServerSettings.cs
@@ -167,8 +167,9 @@ namespace Barotrauma.Networking
saveLogsBox.OnSelected = (GUITickBox) =>
{
saveServerLogs = GUITickBox.Selected;
+ showLogButton.Visible = saveServerLogs;
return true;
- }; ;
+ };
var closeButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Close", Alignment.BottomRight, GUI.Style, innerFrame);
closeButton.OnClicked = ToggleSettingsFrame;
diff --git a/Subsurface/Source/Networking/NetworkMember.cs b/Subsurface/Source/Networking/NetworkMember.cs
index 1c6916fe7..cb1b2c633 100644
--- a/Subsurface/Source/Networking/NetworkMember.cs
+++ b/Subsurface/Source/Networking/NetworkMember.cs
@@ -59,7 +59,7 @@ namespace Barotrauma.Networking
protected GUIFrame inGameHUD;
protected GUIListBox chatBox;
protected GUITextBox chatMsgBox;
-
+
public int EndVoteCount, EndVoteMax;
//private GUITextBlock endVoteText;
@@ -186,7 +186,7 @@ namespace Barotrauma.Networking
{
GameMain.NetLobbyScreen.NewChatMessage(message, messageColor[(int)messageType]);
- GameServer.Log(message);
+ GameServer.Log(message, messageColor[(int)messageType]);
while (chatBox.CountChildren > 20)
{
diff --git a/Subsurface/Source/Networking/ServerLog.cs b/Subsurface/Source/Networking/ServerLog.cs
index 7d1c5cb7b..dc9a8881d 100644
--- a/Subsurface/Source/Networking/ServerLog.cs
+++ b/Subsurface/Source/Networking/ServerLog.cs
@@ -1,4 +1,5 @@
-using System;
+using Microsoft.Xna.Framework;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -14,20 +15,24 @@ namespace Barotrauma.Networking
private string serverName;
- private Queue lines;
+ public GUIFrame LogFrame;
+
+ private Queue lines;
public ServerLog(string serverName)
{
this.serverName = serverName;
- lines = new Queue();
+ lines = new Queue();
}
- public void WriteLine(string line)
+ public void WriteLine(string line, Color? color)
{
string logLine = "[" + DateTime.Now.ToLongTimeString() + "] " + line;
- lines.Enqueue(logLine);
+ lines.Enqueue(new ColoredText(logLine, color == null ? Color.White : (Color)color));
+
+ if (LogFrame != null) CreateLogFrame();
if (lines.Count>=LinesPerFile)
{
@@ -35,6 +40,36 @@ namespace Barotrauma.Networking
}
}
+ public void CreateLogFrame()
+ {
+ LogFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f);
+
+ GUIFrame innerFrame = new GUIFrame(new Rectangle(0,0,400, 400), null, Alignment.Center, GUI.Style, LogFrame);
+ innerFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
+
+ GUIListBox listBox = new GUIListBox(new Rectangle(0,0,0,355), GUI.Style, innerFrame);
+
+ var currLines = lines.ToList();
+
+ foreach (ColoredText line in currLines)
+ {
+ var textBlock = new GUITextBlock(new Rectangle(0, 0, 0, 0), line.Text, GUI.Style, Alignment.TopLeft, Alignment.TopLeft, listBox, true, GUI.SmallFont);
+ //textBlock.Rect = new Rectangle(textBlock.Rect.X, textBlock.Rect.Y, textBlock.Rect.Width, (line.Text.Count(c => c == '\n') + 1) * 15);
+
+ textBlock.TextColor = line.Color;
+ textBlock.CanBeFocused = false;
+ }
+
+ listBox.BarScroll = 1.0f;
+
+ GUIButton closeButton = new GUIButton(new Rectangle(0,0,100, 15), "Close", Alignment.BottomRight, GUI.Style, innerFrame);
+ closeButton.OnClicked = (GUIButton button, object userData) =>
+ {
+ LogFrame = null;
+ return true;
+ };
+ }
+
public void Save()
{
if (!Directory.Exists(SavePath))
@@ -55,10 +90,10 @@ namespace Barotrauma.Networking
fileName = fileName.Replace(":", "");
string filePath = Path.Combine(SavePath, fileName);
-
+
try
{
- File.WriteAllLines(filePath, lines);
+ File.WriteAllLines(filePath, lines.Select(l => l.Text));
}
catch (Exception e)
{
diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo
index 0bdc51fff..24f2594e4 100644
Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ