diff --git a/BarotraumaClient/Source/Characters/Character.cs b/BarotraumaClient/Source/Characters/Character.cs index 51bb1e3c1..03e2756e4 100644 --- a/BarotraumaClient/Source/Characters/Character.cs +++ b/BarotraumaClient/Source/Characters/Character.cs @@ -47,6 +47,8 @@ namespace Barotrauma private void InitProjSpecific(XDocument doc) { + keys = new Key[Enum.GetNames(typeof(InputType)).Length]; + for (int i = 0; i < Enum.GetNames(typeof(InputType)).Length; i++) { keys[i] = new Key(GameMain.Config.KeyBind((InputType)i)); diff --git a/BarotraumaClient/Source/Characters/CharacterNetworking.cs b/BarotraumaClient/Source/Characters/CharacterNetworking.cs index 7c4ae474e..f2413ba47 100644 --- a/BarotraumaClient/Source/Characters/CharacterNetworking.cs +++ b/BarotraumaClient/Source/Characters/CharacterNetworking.cs @@ -186,6 +186,8 @@ namespace Barotrauma } public static Character ReadSpawnData(NetBuffer inc, bool spawn = true) { + DebugConsole.NewMessage("READING CHARACTER SPAWN DATA", Color.Cyan); + if (GameMain.Server != null) return null; bool noInfo = inc.ReadBoolean(); diff --git a/BarotraumaClient/Source/DebugConsole.cs b/BarotraumaClient/Source/DebugConsole.cs index 32cf07e5c..259dee661 100644 --- a/BarotraumaClient/Source/DebugConsole.cs +++ b/BarotraumaClient/Source/DebugConsole.cs @@ -146,6 +146,7 @@ namespace Barotrauma case "help": case "dumpids": case "admin": + case "entitylist": return true; default: return false; diff --git a/BarotraumaClient/Source/Networking/NetEntityEvent/ClientEntityEventManager.cs b/BarotraumaClient/Source/Networking/NetEntityEvent/ClientEntityEventManager.cs index 1153e0b1a..3f66e4cf2 100644 --- a/BarotraumaClient/Source/Networking/NetEntityEvent/ClientEntityEventManager.cs +++ b/BarotraumaClient/Source/Networking/NetEntityEvent/ClientEntityEventManager.cs @@ -190,7 +190,7 @@ namespace Barotrauma.Networking { if (GameSettings.VerboseLogging) { - DebugConsole.ThrowError("Failed to read event for entity \"" + entity.ToString() + "!", e); + DebugConsole.ThrowError("Failed to read event for entity \"" + entity.ToString() + "\"!", e); } msg.Position = msgPosition + msgLength * 8; } diff --git a/BarotraumaClient/Source/Networking/NetworkMember.cs b/BarotraumaClient/Source/Networking/NetworkMember.cs index df6c5da68..6ec1fede1 100644 --- a/BarotraumaClient/Source/Networking/NetworkMember.cs +++ b/BarotraumaClient/Source/Networking/NetworkMember.cs @@ -11,6 +11,22 @@ namespace Barotrauma.Networking { abstract partial class NetworkMember { + protected CharacterInfo characterInfo; + + protected Character myCharacter; + + public CharacterInfo CharacterInfo + { + get { return characterInfo; } + set { characterInfo = value; } + } + + public Character Character + { + get { return myCharacter; } + set { myCharacter = value; } + } + protected GUIFrame inGameHUD; protected GUIListBox chatBox; protected GUITextBox chatMsgBox; diff --git a/BarotraumaClient/Source/Program.cs b/BarotraumaClient/Source/Program.cs index 1cb5e0f3f..ca47685cb 100644 --- a/BarotraumaClient/Source/Program.cs +++ b/BarotraumaClient/Source/Program.cs @@ -164,7 +164,7 @@ namespace Barotrauma sw.WriteLine(sb.ToString()); - sw.Close(); + sw.Close(); CrashMessageBox( "A crash report (\"crashreport.txt\") was saved in the root folder of the game."+ " If you'd like to help fix this bug, please post the report on the Undertow Games forums."); diff --git a/BarotraumaServer/Source/Characters/Character.cs b/BarotraumaServer/Source/Characters/Character.cs index b4b52b0ee..aad3d127d 100644 --- a/BarotraumaServer/Source/Characters/Character.cs +++ b/BarotraumaServer/Source/Characters/Character.cs @@ -26,7 +26,7 @@ namespace Barotrauma private void InitProjSpecific(XDocument doc) { - //do nothing + keys = null; } private void UpdateControlled(float deltaTime) diff --git a/BarotraumaServer/Source/DebugConsole.cs b/BarotraumaServer/Source/DebugConsole.cs index 29575e84b..4bca6e98e 100644 --- a/BarotraumaServer/Source/DebugConsole.cs +++ b/BarotraumaServer/Source/DebugConsole.cs @@ -43,6 +43,20 @@ namespace Barotrauma if (Screen.Selected == GameMain.NetLobbyScreen) break; GameMain.Server.EndGame(); break; + case "entitydata": + Entity ent = Entity.FindEntityByID(Convert.ToUInt16(commands[1])); + if (ent != null) + { + NewMessage(ent.ToString(), Color.Lime); + } + break; + case "eventdata": + ServerEntityEvent ev = GameMain.Server.EntityEventManager.Events[Convert.ToUInt16(commands[1])]; + if (ev != null) + { + NewMessage(ev.StackTrace, Color.Lime); + } + break; default: return false; break; diff --git a/BarotraumaServer/Source/GameMain.cs b/BarotraumaServer/Source/GameMain.cs index 55d7ad710..edee7e842 100644 --- a/BarotraumaServer/Source/GameMain.cs +++ b/BarotraumaServer/Source/GameMain.cs @@ -103,7 +103,7 @@ namespace Barotrauma while (true) { DebugConsole.Update(); - NetLobbyScreen.Update((float)Timing.Step); + if (Screen.Selected != null) Screen.Selected.Update((float)Timing.Step); Server.Update((float)Timing.Step); CoroutineManager.Update((float)Timing.Step, (float)Timing.Step); diff --git a/BarotraumaServer/Source/Networking/NetworkMember.cs b/BarotraumaServer/Source/Networking/NetworkMember.cs index e778ce634..f4ea9e15e 100644 --- a/BarotraumaServer/Source/Networking/NetworkMember.cs +++ b/BarotraumaServer/Source/Networking/NetworkMember.cs @@ -11,6 +11,20 @@ namespace Barotrauma.Networking { abstract partial class NetworkMember { + protected const CharacterInfo characterInfo = null; + + protected const Character myCharacter = null; + + public CharacterInfo CharacterInfo + { + get { return null; } + } + + public Character Character + { + get { return null; } + } + private void InitProjSpecific() { //do nothing diff --git a/BarotraumaServer/Source/Program.cs b/BarotraumaServer/Source/Program.cs index 47007b4ee..3aaf2dd16 100644 --- a/BarotraumaServer/Source/Program.cs +++ b/BarotraumaServer/Source/Program.cs @@ -29,17 +29,19 @@ namespace Barotrauma static void Main() { GameMain game = null; + Thread inputThread = null; try { game = new GameMain(); - Thread inputThread = new Thread(new ThreadStart(game.ProcessInput)); + inputThread = new Thread(new ThreadStart(game.ProcessInput)); inputThread.Start(); game.Run(); } catch (Exception e) { CrashDump(game, "servercrashreport.txt", e); + //inputThread.Abort(); inputThread.Join(); } } @@ -84,6 +86,8 @@ namespace Barotrauma sb.AppendLine(" "+DebugConsole.Messages[i].Time+" - "+DebugConsole.Messages[i].Text); } + Console.ForegroundColor = ConsoleColor.Red; + Console.Write(sb.ToString()); sw.WriteLine(sb.ToString()); sw.Close(); diff --git a/BarotraumaServer/Source/Screens/NetLobbyScreen.cs b/BarotraumaServer/Source/Screens/NetLobbyScreen.cs index 386d62ec5..f2ee637a5 100644 --- a/BarotraumaServer/Source/Screens/NetLobbyScreen.cs +++ b/BarotraumaServer/Source/Screens/NetLobbyScreen.cs @@ -53,7 +53,7 @@ namespace Barotrauma } - private List subs = new List(); + private List subs; public List GetSubList() { return subs; diff --git a/BarotraumaServer/Source/Utils/XnaToConsoleColor.cs b/BarotraumaServer/Source/Utils/XnaToConsoleColor.cs index e6a11aa8e..7377bc216 100644 --- a/BarotraumaServer/Source/Utils/XnaToConsoleColor.cs +++ b/BarotraumaServer/Source/Utils/XnaToConsoleColor.cs @@ -27,6 +27,7 @@ namespace Barotrauma dictionary.Add(Color.Cyan, ConsoleColor.Cyan); dictionary.Add(Color.DarkBlue, ConsoleColor.DarkBlue); dictionary.Add(Color.Pink, ConsoleColor.Magenta); + dictionary.Add(Color.Magenta, ConsoleColor.Magenta); } ConsoleColor val = ConsoleColor.White; diff --git a/BarotraumaShared/Source/Characters/Character.cs b/BarotraumaShared/Source/Characters/Character.cs index 69b8db155..17a242749 100644 --- a/BarotraumaShared/Source/Characters/Character.cs +++ b/BarotraumaShared/Source/Characters/Character.cs @@ -505,8 +505,6 @@ namespace Barotrauma protected Character(string file, Vector2 position, CharacterInfo characterInfo = null, bool isRemotePlayer = false) : base(null) { - keys = new Key[Enum.GetNames(typeof(InputType)).Length]; - ConfigPath = file; selectedItems = new Item[2]; @@ -899,8 +897,8 @@ namespace Barotrauma } } - - if (IsRemotePlayer) + + if (IsRemotePlayer && keys!=null) { foreach (Key key in keys) { @@ -1726,9 +1724,9 @@ namespace Barotrauma { GameMain.GameSession.CrewManager.characters.Remove(this); } -#endif if (GameMain.Client != null && GameMain.Client.Character == this) GameMain.Client.Character = null; +#endif if (aiTarget != null) aiTarget.Remove(); diff --git a/BarotraumaShared/Source/Characters/CharacterNetworking.cs b/BarotraumaShared/Source/Characters/CharacterNetworking.cs index 814ae1eea..869187f80 100644 --- a/BarotraumaShared/Source/Characters/CharacterNetworking.cs +++ b/BarotraumaShared/Source/Characters/CharacterNetworking.cs @@ -401,7 +401,7 @@ namespace Barotrauma attack = dequeuedInput.HasFlag(InputNetFlags.Attack); } - else + else if (keys != null) { aiming = keys[(int)InputType.Aim].GetHeldQueue; use = keys[(int)InputType.Use].GetHeldQueue; diff --git a/BarotraumaShared/Source/DebugConsole.cs b/BarotraumaShared/Source/DebugConsole.cs index 11810ca22..50aac47be 100644 --- a/BarotraumaShared/Source/DebugConsole.cs +++ b/BarotraumaShared/Source/DebugConsole.cs @@ -29,7 +29,7 @@ namespace Barotrauma static partial class DebugConsole { - const int MaxMessages = 200; + const int MaxMessages = 20000; public static List Messages = new List(); @@ -55,6 +55,17 @@ namespace Barotrauma switch (commands[0].ToLowerInvariant()) { + case "entitylist": + System.IO.StreamWriter sw = new System.IO.StreamWriter("ENTLIST "+Rand.Int(20000).ToString()+".TXT"); + + List entList = Entity.GetEntityList(); + foreach (Entity ent in entList) + { + sw.WriteLine(ent.ID.ToString()+" "+ent.ToString()); + } + + sw.Close(); + break; case "help": NewMessage("menu: go to main menu", Color.Cyan); NewMessage("game: enter the \"game screen\"", Color.Cyan); @@ -501,6 +512,7 @@ namespace Barotrauma //TODO: REMOVE Console.ForegroundColor = XnaToConsoleColor.Convert(color); Console.WriteLine(msg); + Console.ForegroundColor = ConsoleColor.White; #endif if (Messages.Count > MaxMessages) diff --git a/BarotraumaShared/Source/Items/Item.cs b/BarotraumaShared/Source/Items/Item.cs index 22087a01c..7098437a9 100644 --- a/BarotraumaShared/Source/Items/Item.cs +++ b/BarotraumaShared/Source/Items/Item.cs @@ -293,11 +293,11 @@ namespace Barotrauma public override string ToString() { -#if CLIENT +/*#if CLIENT return (GameMain.DebugDraw) ? Name + "(ID: " + ID + ")" : Name; -#elif SERVER +#elif SERVER*/ return Name + "(ID: " + ID + ")"; -#endif +//#endif } public List AllPropertyObjects @@ -1304,6 +1304,7 @@ namespace Barotrauma public void ServerWrite(NetBuffer msg, Client c, object[] extraData = null) { + DebugConsole.NewMessage(ToString(), Color.Magenta); if (extraData == null || extraData.Length == 0 || !(extraData[0] is NetEntityEvent.Type)) { return; diff --git a/BarotraumaShared/Source/Map/Entity.cs b/BarotraumaShared/Source/Map/Entity.cs index 67696b105..935227e30 100644 --- a/BarotraumaShared/Source/Map/Entity.cs +++ b/BarotraumaShared/Source/Map/Entity.cs @@ -10,6 +10,10 @@ namespace Barotrauma class Entity { private static Dictionary dictionary = new Dictionary(); + public static List GetEntityList() + { + return dictionary.Values.ToList(); + } public static EntitySpawner Spawner; diff --git a/BarotraumaShared/Source/Networking/EntitySpawner.cs b/BarotraumaShared/Source/Networking/EntitySpawner.cs index ddb574d58..85f26837d 100644 --- a/BarotraumaShared/Source/Networking/EntitySpawner.cs +++ b/BarotraumaShared/Source/Networking/EntitySpawner.cs @@ -183,9 +183,10 @@ namespace Barotrauma else if (entities.Entity is Character) { message.Write((byte)SpawnableType.Character); + DebugConsole.NewMessage("WRITING CHARACTER DATA: " + (entities.Entity).ToString(),Color.Cyan); ((Character)entities.Entity).WriteSpawnData(message); } - } + } } } } diff --git a/BarotraumaShared/Source/Networking/GameServer.cs b/BarotraumaShared/Source/Networking/GameServer.cs index e2eb901dd..7a8986100 100644 --- a/BarotraumaShared/Source/Networking/GameServer.cs +++ b/BarotraumaShared/Source/Networking/GameServer.cs @@ -1185,6 +1185,7 @@ namespace Barotrauma.Networking #endif } +#if CLIENT if (characterInfo != null && hostTeam == teamID) { myCharacter = Character.Create(characterInfo, assignedWayPoints[assignedWayPoints.Length - 1].WorldPosition, false, false); @@ -1192,10 +1193,10 @@ namespace Barotrauma.Networking myCharacter.TeamID = (byte)teamID; Character.Controlled = myCharacter; -#if CLIENT + GameMain.GameSession.CrewManager.characters.Add(myCharacter); -#endif } +#endif } @@ -1247,7 +1248,7 @@ namespace Barotrauma.Networking GameMain.GameScreen.Cam.TargetPos = Vector2.Zero; GameMain.GameScreen.Select(); - AddChatMessage("Press TAB to chat. Use ''r;'' to talk through the radio.", ChatMessageType.Server); + AddChatMessage("Press TAB to chat. Use \"r;\" to talk through the radio.", ChatMessageType.Server); GameMain.NetLobbyScreen.StartButtonEnabled = true; @@ -1336,12 +1337,13 @@ namespace Barotrauma.Networking if (SaveServerLogs) log.Save(); Character.Controlled = null; - myCharacter = null; + GameMain.GameScreen.Cam.TargetPos = Vector2.Zero; #if CLIENT + myCharacter = null; GameMain.LightManager.LosEnabled = false; #endif - + entityEventManager.Clear(); foreach (Client c in connectedClients) { diff --git a/BarotraumaShared/Source/Networking/NetEntityEvent/NetEntityEvent.cs b/BarotraumaShared/Source/Networking/NetEntityEvent/NetEntityEvent.cs index be389fe73..4c34b7c37 100644 --- a/BarotraumaShared/Source/Networking/NetEntityEvent/NetEntityEvent.cs +++ b/BarotraumaShared/Source/Networking/NetEntityEvent/NetEntityEvent.cs @@ -64,6 +64,8 @@ namespace Barotrauma.Networking public bool Sent; + public string StackTrace; + private double createTime; public double CreateTime { @@ -76,6 +78,8 @@ namespace Barotrauma.Networking serializable = entity; createTime = Timing.TotalTime; + + StackTrace = Environment.StackTrace.ToString(); } public void Write(NetBuffer msg, Client recipient) diff --git a/BarotraumaShared/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs b/BarotraumaShared/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs index 695a247ab..08e771c43 100644 --- a/BarotraumaShared/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs +++ b/BarotraumaShared/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs @@ -137,7 +137,7 @@ namespace Barotrauma.Networking { if (GameSettings.VerboseLogging) { - DebugConsole.ThrowError("Failed to read event for entity \"" + bufferedEvent.TargetEntity.ToString() + "!", e); + DebugConsole.ThrowError("Failed to read event for entity \"" + bufferedEvent.TargetEntity.ToString() + "\"!", e); } } @@ -232,6 +232,7 @@ namespace Barotrauma.Networking msg.Write(client.UnreceivedEntityEventCount); msg.Write(client.FirstNewEventID); + //DebugConsole.NewMessage(eventsToSync[0].ID.ToString(), Microsoft.Xna.Framework.Color.Yellow); Write(msg, eventsToSync, client); } else diff --git a/BarotraumaShared/Source/Networking/NetworkMember.cs b/BarotraumaShared/Source/Networking/NetworkMember.cs index 8b65f9bf6..8548b3875 100644 --- a/BarotraumaShared/Source/Networking/NetworkMember.cs +++ b/BarotraumaShared/Source/Networking/NetworkMember.cs @@ -90,27 +90,12 @@ namespace Barotrauma.Networking protected bool gameStarted; - protected Character myCharacter; - protected CharacterInfo characterInfo; - public Dictionary monsterEnabled; protected RespawnManager respawnManager; public Voting Voting; - public Character Character - { - get { return myCharacter; } - set { myCharacter = value; } - } - - public CharacterInfo CharacterInfo - { - get { return characterInfo; } - set { characterInfo = value; } - } - public string Name { get { return name; } diff --git a/BarotraumaShared/Source/Networking/RespawnManager.cs b/BarotraumaShared/Source/Networking/RespawnManager.cs index 1f27f90b7..0e4e167ae 100644 --- a/BarotraumaShared/Source/Networking/RespawnManager.cs +++ b/BarotraumaShared/Source/Networking/RespawnManager.cs @@ -437,20 +437,24 @@ namespace Barotrauma.Networking var character = Character.Create(characterInfos[i], shuttleSpawnPoints[i].WorldPosition, !myCharacter, false); character.TeamID = 1; - + +#if CLIENT if (myCharacter) { server.Character = character; Character.Controlled = character; -#if CLIENT + GameMain.LightManager.LosEnabled = true; -#endif + } else { +#endif clients[i].Character = character; +#if CLIENT } - +#endif + Vector2 pos = cargoSp == null ? character.Position : cargoSp.Position; if (divingSuitPrefab != null && oxyPrefab != null) diff --git a/BarotraumaShared/Source/Utils/Rand.cs b/BarotraumaShared/Source/Utils/Rand.cs index 610b43e3f..d47c05318 100644 --- a/BarotraumaShared/Source/Utils/Rand.cs +++ b/BarotraumaShared/Source/Utils/Rand.cs @@ -26,7 +26,7 @@ namespace Barotrauma private static void Assert(RandSync sync) { //TODO: REMOVE AFTER FINDING ALL WRONG RNG USAGE -#if CLIENT +#if false string trace = Environment.StackTrace.ToString(); if (sync != RandSync.Server) return; if (trace.ToLower().Contains("barotraumaclient\\source")) DebugConsole.NewMessage("WARNING: Client code using RandSync.Server\n"+trace,Color.Yellow);