Molochs can damage characters, server log UI, stun weapons have a longer stun time, characters can't breathe when wearing a diving suit with no oxygen tank

This commit is contained in:
Regalis
2016-02-14 19:05:03 +02:00
parent bec6d95198
commit 94e34c0ed9
18 changed files with 136 additions and 68 deletions
@@ -11,7 +11,7 @@
<!-- head --> <!-- head -->
<limb id = "0" radius="230" height="500" type="Head" steerforce="1.0" flip="true" armorsector="0.0,180.0" armorvalue="100.0" impacttolerance="100"> <limb id = "0" radius="230" height="500" type="Head" steerforce="1.0" flip="true" armorsector="0.0,180.0" armorvalue="100.0" impacttolerance="100">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="0,0,628,1024" depth="0.02" origin ="0.4,0.5"/> <sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="0,0,628,1024" depth="0.02" origin ="0.4,0.5"/>
<attack type="Hit" range="700" duration="0.2" force="400" damagetype="blunt"/> <attack type="Hit" range="700" duration="0.2" damage="200" stun="5" force="400" damagetype="blunt"/>
</limb> </limb>
<limb id = "1" width="50" height="440" flip="true"> <limb id = "1" width="50" height="440" flip="true">
@@ -86,12 +86,10 @@
<sprite texture="DivingSuit.png" limb="LeftLeg" sourcerect="17,47,21,51" origin="0.5,0.55" depth="0.02" hidelimb="true"/> <sprite texture="DivingSuit.png" limb="LeftLeg" sourcerect="17,47,21,51" origin="0.5,0.55" depth="0.02" hidelimb="true"/>
<StatusEffect type="OnWearing" target="Character" ObstructVision="true" PressureProtection="100.0" SpeedMultiplier="0.6" LowPassMultiplier="0.2" setvalue="true" disabledeltatime="true"/> <StatusEffect type="OnWearing" target="Character" ObstructVision="true" PressureProtection="100.0" SpeedMultiplier="0.6" LowPassMultiplier="0.2" setvalue="true" disabledeltatime="true"/>
<StatusEffect type="OnWearing" target="Contained,Character" Oxygen="20.0" Condition="-0.5"> <StatusEffect type="OnWearing" target="Contained,Character" Oxygen="30.0" Condition="-0.5">
<RequiredItem type="Contained" name="Oxygen Tank"/> <RequiredItem type="Contained" name="Oxygen Tank"/>
</StatusEffect> </StatusEffect>
<StatusEffect type="OnWearing" target="Contained,Character" Oxygen="-30.0" Condition="-0.5"> <StatusEffect type="OnWearing" target="Character" Oxygen="-15.0"/>
<RequiredItem type="Contained" name="Welding Fuel Tank"/>
</StatusEffect>
</Wearable> </Wearable>
<ItemContainer capacity="1" hideitems="true"> <ItemContainer capacity="1" hideitems="true">
+3 -3
View File
@@ -66,7 +66,7 @@
<Throwable slots="Any,RightHand,LeftHand" holdpos="0,0" handle1="0,0" throwforce="4.0" aimpos="35,-10"> <Throwable slots="Any,RightHand,LeftHand" holdpos="0,0" handle1="0,0" throwforce="4.0" aimpos="35,-10">
<StatusEffect type="OnUse" target="This" Condition="-100.0" delay="3.0" sound="Content/Items/Weapons/stungrenade.ogg"> <StatusEffect type="OnUse" target="This" Condition="-100.0" delay="3.0" sound="Content/Items/Weapons/stungrenade.ogg">
<Explosion range="500" damage="5" stun="10" force="0.1"/> <Explosion range="500" damage="5" stun="25" force="0.1"/>
</StatusEffect> </StatusEffect>
</Throwable> </Throwable>
</Item> </Item>
@@ -109,11 +109,11 @@
<MeleeWeapon slots="Any,RightHand,LeftHand" <MeleeWeapon slots="Any,RightHand,LeftHand"
aimpos="50,0" handle1="-5,0" holdangle="10" reload="1.0"> aimpos="50,0" handle1="-5,0" holdangle="10" reload="1.0">
<Attack damage="2" stun="0.2" damagetype="Blunt" sound="Content/Items/Weapons/smack.ogg"/> <Attack damage="2" stun="0.2" damagetype="Blunt" sound="Content/Items/Weapons/smack.ogg"/>
<StatusEffect type="OnUse" target="Contained,Character" Condition="-25.0" stun="10.0" disabledeltatime="true" sound="Content/Items/Weapons/stunbaton.ogg"> <StatusEffect type="OnUse" target="Contained,Character" Condition="-25.0" stun="15.0" disabledeltatime="true" sound="Content/Items/Weapons/stunbaton.ogg">
<RequiredItem name="Battery Cell" type="Contained" msg="Loaded Battery Cell required"/> <RequiredItem name="Battery Cell" type="Contained" msg="Loaded Battery Cell required"/>
<Explosion range="100.0" force="0.1" shockwave="false" flames="false" camerashake="5.0"/> <Explosion range="100.0" force="0.1" shockwave="false" flames="false" camerashake="5.0"/>
</StatusEffect> </StatusEffect>
<StatusEffect type="OnUse" target="Contained,Character" Condition="-15.0" stun="15.0" disabledeltatime="true" sound="Content/Items/Weapons/stunbaton.ogg"> <StatusEffect type="OnUse" target="Contained,Character" Condition="-15.0" stun="30.0" disabledeltatime="true" sound="Content/Items/Weapons/stunbaton.ogg">
<RequiredItem name="Fulgurium Battery Cell" type="Contained" msg="Loaded Battery Cell required"/> <RequiredItem name="Fulgurium Battery Cell" type="Contained" msg="Loaded Battery Cell required"/>
<Explosion range="100.0" force="0.5" shockwave="false" flames="false" camerashake="5.0"/> <Explosion range="100.0" force="0.5" shockwave="false" flames="false" camerashake="5.0"/>
</StatusEffect> </StatusEffect>
@@ -311,6 +311,8 @@ namespace Barotrauma
{ {
IDamageable damageTarget = null; IDamageable damageTarget = null;
float dist = ConvertUnits.ToDisplayUnits(Vector2.Distance(limb.SimPosition, attackPosition));
switch (limb.attack.Type) switch (limb.attack.Type)
{ {
case AttackType.PinchCW: case AttackType.PinchCW:
@@ -328,7 +330,6 @@ namespace Barotrauma
break; break;
} }
float dist = ConvertUnits.ToDisplayUnits(Vector2.Distance(limb.SimPosition, attackPosition));
if (dist < limb.attack.Range * 0.5f) if (dist < limb.attack.Range * 0.5f)
{ {
attackTimer += deltaTime; attackTimer += deltaTime;
@@ -361,10 +362,16 @@ namespace Barotrauma
break; break;
} }
if (ConvertUnits.ToDisplayUnits(Vector2.Distance(limb.SimPosition, attackPosition)) < limb.attack.Range)
if (dist < limb.attack.Range)
{ {
attackTimer += deltaTime; attackTimer += deltaTime;
limb.body.ApplyForce(limb.Mass * limb.attack.Force * Vector2.Normalize(attackPosition - limb.SimPosition)); limb.body.ApplyForce(limb.Mass * limb.attack.Force * Vector2.Normalize(attackPosition - limb.SimPosition));
if (damageTarget is Character && dist<limb.attack.Range*0.5f)
{
limb.attack.DoDamage(Character, damageTarget, limb.WorldPosition, deltaTime, false);
}
} }
steeringManager.SteeringSeek(attackPosition + (limb.SimPosition-SimPosition), 5.0f); steeringManager.SteeringSeek(attackPosition + (limb.SimPosition-SimPosition), 5.0f);
+4 -4
View File
@@ -1096,7 +1096,7 @@ namespace Barotrauma
var attackingCharacter = attacker as Character; var attackingCharacter = attacker as Character;
if (attackingCharacter != null && attackingCharacter.AIController == null) if (attackingCharacter != null && attackingCharacter.AIController == null)
{ {
GameServer.Log(Name + " attacked by " + attackingCharacter.Name+". Damage: "+attackResult.Damage+" Bleeding damage: "+attackResult.Bleeding); GameServer.Log(Name + " attacked by " + attackingCharacter.Name+". Damage: "+attackResult.Damage+" Bleeding damage: "+attackResult.Bleeding, Color.Orange);
} }
return attackResult; return attackResult;
@@ -1259,7 +1259,7 @@ namespace Barotrauma
} }
} }
GameServer.Log(Name+" has died (cause of death: "+causeOfDeath+")"); GameServer.Log(Name+" has died (Cause of death: "+causeOfDeath+")", Color.Red);
if (OnDeath != null) OnDeath(this, causeOfDeath); if (OnDeath != null) OnDeath(this, causeOfDeath);
@@ -1464,11 +1464,11 @@ namespace Barotrauma
{ {
if (item == selectedConstruction) if (item == selectedConstruction)
{ {
GameServer.Log(Name + " deselected " + item.Name); GameServer.Log(Name + " deselected " + item.Name, Color.Orange);
} }
else else
{ {
GameServer.Log(Name + " selected " + item.Name); GameServer.Log(Name + " selected " + item.Name, Color.Orange);
} }
item.Pick(this, false, pickHit, actionHit); item.Pick(this, false, pickHit, actionHit);
} }
+1 -1
View File
@@ -176,7 +176,7 @@ namespace Barotrauma
string header = index < headers.Count ? headers[index] : ""; string header = index < headers.Count ? headers[index] : "";
string message = index < messages.Count ? messages[index] : ""; string message = index < messages.Count ? messages[index] : "";
Barotrauma.Networking.GameServer.Log("Mission info: " + header + " - " + message); Barotrauma.Networking.GameServer.Log("Mission info: " + header + " - " + message, Color.Cyan);
new GUIMessageBox(header, message); new GUIMessageBox(header, message);
} }
@@ -38,8 +38,8 @@ namespace Barotrauma
new GUIMessageBox(mission.Name, mission.Description, 400, 400); new GUIMessageBox(mission.Name, mission.Description, 400, 400);
Networking.GameServer.Log("Mission: " + mission.Name); Networking.GameServer.Log("Mission: " + mission.Name, Color.Cyan);
Networking.GameServer.Log(mission.Description); Networking.GameServer.Log(mission.Description, Color.Cyan);
//quest.Start(Level.Loaded); //quest.Start(Level.Loaded);
} }
@@ -109,7 +109,7 @@ namespace Barotrauma
{ {
if (Items[i] != null || limbSlots[i] != LimbSlot.Any) continue; if (Items[i] != null || limbSlots[i] != LimbSlot.Any) continue;
GameServer.Log(character.Name + " picked up " + item.Name); GameServer.Log(character.Name + " picked up " + item.Name, Color.Orange);
PutItem(item, i, createNetworkEvent); PutItem(item, i, createNetworkEvent);
item.Unequip(character); item.Unequip(character);
return true; return true;
@@ -144,7 +144,7 @@ namespace Barotrauma
if (placed) if (placed)
{ {
if (!alreadyInInventory) GameServer.Log(character.Name + " picked up " + item.Name); if (!alreadyInInventory) GameServer.Log(character.Name + " picked up " + item.Name, Color.Orange);
return true; return true;
} }
} }
@@ -164,7 +164,7 @@ namespace Barotrauma.Items.Components
item.body.Enabled = true; item.body.Enabled = true;
IsActive = true; IsActive = true;
if (!alreadySelected) Barotrauma.Networking.GameServer.Log(character.Name+" equipped "+item.Name); if (!alreadySelected) Barotrauma.Networking.GameServer.Log(character.Name+" equipped "+item.Name, Color.Orange);
} }
} }
@@ -174,7 +174,7 @@ namespace Barotrauma.Items.Components
picker.DeselectItem(item); picker.DeselectItem(item);
Barotrauma.Networking.GameServer.Log(character.Name + " unequipped " + item.Name); Barotrauma.Networking.GameServer.Log(character.Name + " unequipped " + item.Name, Color.Orange);
item.body.Enabled = false; item.body.Enabled = false;
IsActive = false; IsActive = false;
@@ -236,8 +236,8 @@ namespace Barotrauma.Items.Components
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection); var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
if (sender != null) if (sender != null)
{ {
Networking.GameServer.Log("Pump settings adjusted by " + sender.name); Networking.GameServer.Log("Pump settings adjusted by " + sender.name, Color.Orange);
Networking.GameServer.Log("Active: " + (IsActive ? "yes" : "no ") + " Pumping speed: " + (int)flowPercentage + " %"); Networking.GameServer.Log("Active: " + (IsActive ? "yes" : "no ") + " Pumping speed: " + (int)flowPercentage + " %", Color.Orange);
} }
} }
} }
@@ -226,7 +226,7 @@ namespace Barotrauma.Items.Components
fissionRate = Math.Min(fissionRate, AvailableFuel); fissionRate = Math.Min(fissionRate, AvailableFuel);
float heat = 100 * fissionRate * (AvailableFuel/2000.0f); 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; float deltaTemp = (((heat - heatDissipation) * 5) - temperature) / 10000.0f;
Temperature = temperature + deltaTemp; Temperature = temperature + deltaTemp;
@@ -362,7 +362,7 @@ namespace Barotrauma.Items.Components
{ {
if (item.Condition <= 0.0f) return; if (item.Condition <= 0.0f) return;
GameServer.Log("Reactor meltdown!"); GameServer.Log("Reactor meltdown!", Color.Red);
new RepairTask(item, 60.0f, "Reactor meltdown!"); new RepairTask(item, 60.0f, "Reactor meltdown!");
item.Condition = 0.0f; item.Condition = 0.0f;
@@ -583,8 +583,8 @@ namespace Barotrauma.Items.Components
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection); var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
if (sender != null) if (sender != null)
{ {
Networking.GameServer.Log("Reactor settings adjusted by " + sender.name); Networking.GameServer.Log("Reactor settings adjusted by " + sender.name+": ", Color.Orange);
Networking.GameServer.Log("Autotemp: " +(autoTemp ? "ON " : "OFF") + " Shutdown temp: "+shutDownTemp+" Cooling rate: "+coolingRate+" Fission rate: "+fissionRate); Networking.GameServer.Log("Autotemp: " +(autoTemp ? "ON " : "OFF") + " Shutdown temp: "+shutDownTemp+" Cooling rate: "+(int)coolingRate+" Fission rate: "+(int)fissionRate, Color.Orange);
} }
} }
@@ -146,7 +146,7 @@ namespace Barotrauma.Items.Components
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection); var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
if (sender != null) 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); wireComponent.Connect(c, false);
var otherConnection = c.Wires[i].OtherConnection(c); 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(); c.UpdateRecipients();
} }
+1 -1
View File
@@ -1125,7 +1125,7 @@ namespace Barotrauma
// new NetworkEvent(NetworkEventType.DropItem, ID, true); // 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); foreach (ItemComponent ic in components) ic.Drop(dropper);
+55 -28
View File
@@ -33,18 +33,12 @@ namespace Barotrauma.Networking
private bool masterServerResponded; private bool masterServerResponded;
private ServerLog log; private ServerLog log;
private GUIButton showLogButton;
public TraitorManager TraitorManager; public TraitorManager TraitorManager;
public GameServer(string name, int port, bool isPublic = false, string password = "", bool attemptUPnP = false, int maxPlayers = 10) 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.name = name;
this.password = password; this.password = password;
@@ -75,6 +69,31 @@ namespace Barotrauma.Networking
config.EnableMessageType(NetIncomingMessageType.ConnectionApproval); 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)); CoroutineManager.StartCoroutine(StartServer(isPublic));
} }
@@ -82,14 +101,14 @@ namespace Barotrauma.Networking
{ {
try try
{ {
Log("Starting the server..."); Log("Starting the server...", Color.Cyan);
server = new NetServer(config); server = new NetServer(config);
netPeer = server; netPeer = server;
server.Start(); server.Start();
} }
catch (Exception e) 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); DebugConsole.ThrowError("Couldn't start the server", e);
} }
@@ -173,7 +192,7 @@ namespace Barotrauma.Networking
request.AddParameter("gamestarted", gameStarted ? 1 : 0); request.AddParameter("gamestarted", gameStarted ? 1 : 0);
request.AddParameter("playercount", PlayerCountToByte(ConnectedClients.Count, config.MaximumConnections)); 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(); var sw = new Stopwatch();
sw.Start(); sw.Start();
@@ -189,7 +208,7 @@ namespace Barotrauma.Networking
restRequestHandle.Abort(); restRequestHandle.Abort();
DebugConsole.NewMessage("Couldn't connect to master server (request timed out)", Color.Red); 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; break;
//registeredToMaster = false; //registeredToMaster = false;
@@ -210,24 +229,25 @@ namespace Barotrauma.Networking
if (response.ErrorException != null) if (response.ErrorException != null)
{ {
DebugConsole.NewMessage("Error while registering to master server (" + response.ErrorException + ")", Color.Red); 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; return;
} }
if (response.StatusCode != System.Net.HttpStatusCode.OK) if (response.StatusCode != System.Net.HttpStatusCode.OK)
{ {
DebugConsole.NewMessage("Error while reporting to master server (" + response.StatusCode + ": " + response.StatusDescription + ")", Color.Red); 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; return;
} }
Log("Master server responded"); Log("Master server responded", Color.Cyan);
} }
public override void Update(float deltaTime) public override void Update(float deltaTime)
{ {
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 (!started) return; if (!started) return;
@@ -248,11 +268,11 @@ namespace Barotrauma.Networking
{ {
if (AutoRestart && isCrewDead) if (AutoRestart && isCrewDead)
{ {
Log("Ending round (entire crew dead)"); Log("Ending round (entire crew dead)", Color.Cyan);
} }
else 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); EndButtonHit(null, null);
@@ -499,7 +519,7 @@ namespace Barotrauma.Networking
if (Voting.AllowEndVoting && EndVoteMax > 0 && if (Voting.AllowEndVoting && EndVoteMax > 0 &&
((float)EndVoteCount / (float)EndVoteMax) >= EndVoteRequiredRatio) ((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); EndButtonHit(null,null);
} }
break; break;
@@ -791,10 +811,10 @@ namespace Barotrauma.Networking
GameMain.GameSession = new GameSession(selectedSub, "", selectedMode); GameMain.GameSession = new GameSession(selectedSub, "", selectedMode);
GameMain.GameSession.StartShift(GameMain.NetLobbyScreen.LevelSeed); GameMain.GameSession.StartShift(GameMain.NetLobbyScreen.LevelSeed);
GameServer.Log("Starting a new round..."); GameServer.Log("Starting a new round...", Color.Cyan);
GameServer.Log("Submarine: " + selectedSub.Name); GameServer.Log("Submarine: " + selectedSub.Name, Color.Cyan);
GameServer.Log("Game mode: " + selectedMode.Name); GameServer.Log("Game mode: " + selectedMode.Name, Color.Cyan);
GameServer.Log("Level seed: " + GameMain.NetLobbyScreen.LevelSeed); GameServer.Log("Level seed: " + GameMain.NetLobbyScreen.LevelSeed, Color.Cyan);
yield return CoroutineStatus.Running; 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(msg)) msg = client.name + " has left the server";
if (string.IsNullOrWhiteSpace(targetmsg)) targetmsg = "You have 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(); NetOutgoingMessage outmsg = server.CreateMessage();
outmsg.Write((byte)PacketTypes.KickedOut); outmsg.Write((byte)PacketTypes.KickedOut);
@@ -1115,7 +1135,7 @@ namespace Barotrauma.Networking
return; 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; Client traitorClient = null;
foreach (Client c in ConnectedClients) foreach (Client c in ConnectedClients)
@@ -1138,7 +1158,14 @@ namespace Barotrauma.Networking
{ {
base.Draw(spriteBatch); 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; if (!ShowNetStats) return;
@@ -1428,11 +1455,11 @@ namespace Barotrauma.Networking
return preferredClient; 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);
} }
/// <summary> /// <summary>
@@ -1478,7 +1505,7 @@ namespace Barotrauma.Networking
if (saveServerLogs) if (saveServerLogs)
{ {
Log("Shutting down server..."); Log("Shutting down server...", Color.Cyan);
log.Save(); log.Save();
} }
@@ -167,8 +167,9 @@ namespace Barotrauma.Networking
saveLogsBox.OnSelected = (GUITickBox) => saveLogsBox.OnSelected = (GUITickBox) =>
{ {
saveServerLogs = GUITickBox.Selected; saveServerLogs = GUITickBox.Selected;
showLogButton.Visible = saveServerLogs;
return true; return true;
}; ; };
var closeButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Close", Alignment.BottomRight, GUI.Style, innerFrame); var closeButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Close", Alignment.BottomRight, GUI.Style, innerFrame);
closeButton.OnClicked = ToggleSettingsFrame; closeButton.OnClicked = ToggleSettingsFrame;
@@ -186,7 +186,7 @@ namespace Barotrauma.Networking
{ {
GameMain.NetLobbyScreen.NewChatMessage(message, messageColor[(int)messageType]); GameMain.NetLobbyScreen.NewChatMessage(message, messageColor[(int)messageType]);
GameServer.Log(message); GameServer.Log(message, messageColor[(int)messageType]);
while (chatBox.CountChildren > 20) while (chatBox.CountChildren > 20)
{ {
+41 -6
View File
@@ -1,4 +1,5 @@
using System; using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -14,20 +15,24 @@ namespace Barotrauma.Networking
private string serverName; private string serverName;
private Queue<string> lines; public GUIFrame LogFrame;
private Queue<ColoredText> lines;
public ServerLog(string serverName) public ServerLog(string serverName)
{ {
this.serverName = serverName; this.serverName = serverName;
lines = new Queue<string>(); lines = new Queue<ColoredText>();
} }
public void WriteLine(string line) public void WriteLine(string line, Color? color)
{ {
string logLine = "[" + DateTime.Now.ToLongTimeString() + "] " + line; 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) 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() public void Save()
{ {
if (!Directory.Exists(SavePath)) if (!Directory.Exists(SavePath))
@@ -58,7 +93,7 @@ namespace Barotrauma.Networking
try try
{ {
File.WriteAllLines(filePath, lines); File.WriteAllLines(filePath, lines.Select(l => l.Text));
} }
catch (Exception e) catch (Exception e)
{ {
Binary file not shown.