WIP CrashReporter, misc refactoring

This commit is contained in:
Regalis
2015-09-19 15:14:47 +03:00
parent 16bf562837
commit f6966f06c3
86 changed files with 1616 additions and 631 deletions
+27 -27
View File
@@ -76,9 +76,9 @@ namespace Subsurface.Networking
outmsg.Write((byte)PacketTypes.Login);
outmsg.Write(password);
outmsg.Write(Game1.Version.ToString());
outmsg.Write(Game1.SelectedPackage.Name);
outmsg.Write(Game1.SelectedPackage.MD5hash.Hash);
outmsg.Write(GameMain.Version.ToString());
outmsg.Write(GameMain.SelectedPackage.Name);
outmsg.Write(GameMain.SelectedPackage.MD5hash.Hash);
outmsg.Write(name);
// Connect client, to ip previously requested from user
@@ -124,8 +124,8 @@ namespace Subsurface.Networking
private bool SelectMainMenu(GUIButton button, object obj)
{
Disconnect();
Game1.NetworkMember = null;
Game1.MainMenuScreen.Select();
GameMain.NetworkMember = null;
GameMain.MainMenuScreen.Select();
return true;
}
@@ -159,12 +159,12 @@ namespace Subsurface.Networking
if (packetType == (byte)PacketTypes.LoggedIn)
{
myID = inc.ReadInt32();
if (inc.ReadBoolean() && Screen.Selected != Game1.GameScreen)
if (inc.ReadBoolean() && Screen.Selected != GameMain.GameScreen)
{
new GUIMessageBox("Please wait", "A round is already running. You will have to wait for a new round to start.");
}
Game1.NetLobbyScreen.ClearPlayers();
GameMain.NetLobbyScreen.ClearPlayers();
//add the names of other connected clients to the lobby screen
int existingClients = inc.ReadInt32();
@@ -172,12 +172,12 @@ namespace Subsurface.Networking
{
Client otherClient = new Client(inc.ReadString(), inc.ReadInt32());
Game1.NetLobbyScreen.AddPlayer(otherClient);
GameMain.NetLobbyScreen.AddPlayer(otherClient);
otherClients.Add(otherClient);
}
//add the name of own client to the lobby screen
Game1.NetLobbyScreen.AddPlayer(new Client(name, myID));
GameMain.NetLobbyScreen.AddPlayer(new Client(name, myID));
CanStart = true;
}
@@ -186,7 +186,7 @@ namespace Subsurface.Networking
string msg = inc.ReadString();
DebugConsole.ThrowError(msg);
Game1.MainMenuScreen.Select();
GameMain.MainMenuScreen.Select();
}
break;
case NetIncomingMessageType.StatusChanged:
@@ -229,7 +229,7 @@ namespace Subsurface.Networking
}
else
{
if (Screen.Selected != Game1.GameScreen) Game1.NetLobbyScreen.Select();
if (Screen.Selected != GameMain.GameScreen) GameMain.NetLobbyScreen.Select();
connected = true;
}
@@ -265,7 +265,7 @@ namespace Subsurface.Networking
if (myCharacter.IsDead)
{
Character.Controlled = null;
Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
}
else if (gameStarted)
{
@@ -327,15 +327,15 @@ namespace Subsurface.Networking
string mapName = inc.ReadString();
string mapHash = inc.ReadString();
Game1.NetLobbyScreen.TrySelectMap(mapName, mapHash);
GameMain.NetLobbyScreen.TrySelectMap(mapName, mapHash);
double durationMinutes = inc.ReadDouble();
TimeSpan duration = new TimeSpan(0,(int)durationMinutes,0);
Rand.SetSyncedSeed(seed);
//int gameModeIndex = inc.ReadInt32();
Game1.GameSession = new GameSession(Submarine.Loaded, "", Game1.NetLobbyScreen.SelectedMode);
Game1.GameSession.StartShift(duration, levelSeed);
GameMain.GameSession = new GameSession(Submarine.Loaded, "", GameMain.NetLobbyScreen.SelectedMode);
GameMain.GameSession.StartShift(duration, levelSeed);
//myCharacter = ReadCharacterData(inc);
//Character.Controlled = myCharacter;
@@ -353,7 +353,7 @@ namespace Subsurface.Networking
gameStarted = true;
Game1.GameScreen.Select();
GameMain.GameScreen.Select();
AddChatMessage("Press TAB to chat", ChatMessageType.Server);
@@ -368,7 +368,7 @@ namespace Subsurface.Networking
Client otherClient = new Client(inc.ReadString(), inc.ReadInt32());
Game1.NetLobbyScreen.AddPlayer(otherClient);
GameMain.NetLobbyScreen.AddPlayer(otherClient);
otherClients.Add(otherClient);
AddChatMessage(otherClient.name + " has joined the server", ChatMessageType.Server);
@@ -378,7 +378,7 @@ namespace Subsurface.Networking
int leavingID = inc.ReadInt32();
AddChatMessage(inc.ReadString(), ChatMessageType.Server);
Game1.NetLobbyScreen.RemovePlayer(otherClients.Find(c => c.ID==leavingID));
GameMain.NetLobbyScreen.RemovePlayer(otherClients.Find(c => c.ID==leavingID));
break;
case (byte)PacketTypes.KickedOut:
@@ -386,7 +386,7 @@ namespace Subsurface.Networking
new GUIMessageBox("KICKED", msg);
Game1.MainMenuScreen.Select();
GameMain.MainMenuScreen.Select();
break;
case (byte)PacketTypes.Chatmessage:
@@ -400,7 +400,7 @@ namespace Subsurface.Networking
break;
case (byte)PacketTypes.UpdateNetLobby:
if (gameStarted) continue;
Game1.NetLobbyScreen.ReadData(inc);
GameMain.NetLobbyScreen.ReadData(inc);
break;
case (byte)PacketTypes.Traitor:
string targetName = inc.ReadString();
@@ -421,7 +421,7 @@ namespace Subsurface.Networking
var messageBox = new GUIMessageBox("The round has ended", endMessage);
Character.Controlled = null;
Game1.LightManager.LosEnabled = false;
GameMain.LightManager.LosEnabled = false;
float endPreviewLength = 10.0f;
@@ -437,7 +437,7 @@ namespace Subsurface.Networking
(float)Math.Cos(camAngle) * (Submarine.Borders.Width / 2.0f),
(float)Math.Sin(camAngle) * (Submarine.Borders.Height / 2.0f)));
Game1.GameScreen.Cam.TargetPos = offset * 0.8f;
GameMain.GameScreen.Cam.TargetPos = offset * 0.8f;
//Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
messageBox.Text = endMessage + "\nReturning to lobby in " + (int)secondsLeft + " s";
@@ -448,9 +448,9 @@ namespace Subsurface.Networking
Submarine.Unload();
Game1.NetLobbyScreen.Select();
GameMain.NetLobbyScreen.Select();
if (Game1.GameSession!=null) Game1.GameSession.EndShift("");
if (GameMain.GameSession!=null) GameMain.GameSession.EndShift("");
myCharacter = null;
@@ -462,10 +462,10 @@ namespace Subsurface.Networking
{
base.Draw(spriteBatch);
if (!Game1.DebugDraw) return;
if (!GameMain.DebugDraw) return;
int width = 200, height = 300;
int x = Game1.GraphicsWidth - width, y = (int)(Game1.GraphicsHeight * 0.3f);
int x = GameMain.GraphicsWidth - width, y = (int)(GameMain.GraphicsHeight * 0.3f);
GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black * 0.7f, true);
spriteBatch.DrawString(GUI.Font, "Network statistics:", new Vector2(x + 10, y + 10), Color.White);
@@ -497,7 +497,7 @@ namespace Subsurface.Networking
msg.Write(characterInfo.Gender == Gender.Male);
msg.Write(characterInfo.HeadSpriteId);
var jobPreferences = Game1.NetLobbyScreen.JobPreferences;
var jobPreferences = GameMain.NetLobbyScreen.JobPreferences;
int count = Math.Min(jobPreferences.Count, 3);
msg.Write(count);
for (int i = 0; i < count; i++ )
+32 -32
View File
@@ -36,7 +36,7 @@ namespace Subsurface.Networking
public GameServer(string name, int port, bool isPublic = false, string password = "", bool attemptUPnP = false, int maxPlayers = 10)
{
var endRoundButton = new GUIButton(new Rectangle(Game1.GraphicsWidth - 290, 20, 150, 25), "End round", Alignment.TopLeft, GUI.Style, inGameHUD);
var endRoundButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 290, 20, 150, 25), "End round", Alignment.TopLeft, GUI.Style, inGameHUD);
endRoundButton.OnClicked = EndButtonHit;
this.name = name;
@@ -116,7 +116,7 @@ namespace Subsurface.Networking
DebugConsole.NewMessage("Server started", Color.Green);
Game1.NetLobbyScreen.Select();
GameMain.NetLobbyScreen.Select();
started = true;
yield return CoroutineStatus.Success;
}
@@ -312,21 +312,21 @@ namespace Subsurface.Networking
break;
}
else if (version != Game1.Version.ToString())
else if (version != GameMain.Version.ToString())
{
inc.SenderConnection.Deny("Subsurface version " + Game1.Version + " required to connect to the server (Your version: " + version + ")");
inc.SenderConnection.Deny("Subsurface version " + GameMain.Version + " required to connect to the server (Your version: " + version + ")");
DebugConsole.NewMessage("Connection error - wrong game version", Color.Red);
break;
}
else if (packageName != Game1.SelectedPackage.Name)
else if (packageName != GameMain.SelectedPackage.Name)
{
inc.SenderConnection.Deny("Your content package ("+packageName+") doesn't match the server's version (" + Game1.SelectedPackage.Name + ")");
inc.SenderConnection.Deny("Your content package ("+packageName+") doesn't match the server's version (" + GameMain.SelectedPackage.Name + ")");
DebugConsole.NewMessage("Connection error - wrong content package name", Color.Red);
break;
}
else if (packageHash != Game1.SelectedPackage.MD5hash.Hash)
else if (packageHash != GameMain.SelectedPackage.MD5hash.Hash)
{
inc.SenderConnection.Deny("Your content package (MD5: " + packageHash + ") doesn't match the server's version (MD5: " + Game1.SelectedPackage.MD5hash.Hash + ")");
inc.SenderConnection.Deny("Your content package (MD5: " + packageHash + ") doesn't match the server's version (MD5: " + GameMain.SelectedPackage.MD5hash.Hash + ")");
DebugConsole.NewMessage("Connection error - wrong content package hash", Color.Red);
break;
}
@@ -365,10 +365,10 @@ namespace Subsurface.Networking
if (sender == null) break;
if (sender.version != Game1.Version.ToString())
if (sender.version != GameMain.Version.ToString())
{
DisconnectClient(sender, sender.name+" was unable to connect to the server (nonmatching game version)",
"Subsurface version " + Game1.Version + " required to connect to the server (Your version: " + sender.version + ")");
"Subsurface version " + GameMain.Version + " required to connect to the server (Your version: " + sender.version + ")");
}
else if (connectedClients.Find(x => x.name == sender.name && x != sender)!=null)
{
@@ -379,7 +379,7 @@ namespace Subsurface.Networking
{
//AssignJobs();
Game1.NetLobbyScreen.AddPlayer(sender);
GameMain.NetLobbyScreen.AddPlayer(sender);
// Notify the client that they have logged in
outmsg = server.CreateMessage();
@@ -538,11 +538,11 @@ namespace Subsurface.Networking
public bool StartGame(GUIButton button, object obj)
{
Submarine selectedMap = Game1.NetLobbyScreen.SelectedMap as Submarine;
Submarine selectedMap = GameMain.NetLobbyScreen.SelectedMap as Submarine;
if (selectedMap == null)
{
Game1.NetLobbyScreen.SubList.Flash();
GameMain.NetLobbyScreen.SubList.Flash();
return false;
}
@@ -552,8 +552,8 @@ namespace Subsurface.Networking
int seed = DateTime.Now.Millisecond;
Rand.SetSyncedSeed(seed);
Game1.GameSession = new GameSession(selectedMap, "", Game1.NetLobbyScreen.SelectedMode);
Game1.GameSession.StartShift(Game1.NetLobbyScreen.GameDuration, Game1.NetLobbyScreen.LevelSeed);
GameMain.GameSession = new GameSession(selectedMap, "", GameMain.NetLobbyScreen.SelectedMode);
GameMain.GameSession.StartShift(GameMain.NetLobbyScreen.GameDuration, GameMain.NetLobbyScreen.LevelSeed);
//EventManager.SelectEvent(Game1.netLobbyScreen.SelectedEvent);
List<CharacterInfo> characterInfos = new List<CharacterInfo>();
@@ -573,7 +573,7 @@ namespace Subsurface.Networking
if (characterInfo != null)
{
characterInfo.Job = new Job(Game1.NetLobbyScreen.JobPreferences[0]);
characterInfo.Job = new Job(GameMain.NetLobbyScreen.JobPreferences[0]);
characterInfos.Add(characterInfo);
}
@@ -604,12 +604,12 @@ namespace Subsurface.Networking
msg.Write(seed);
msg.Write(Game1.NetLobbyScreen.LevelSeed);
msg.Write(GameMain.NetLobbyScreen.LevelSeed);
msg.Write(Game1.NetLobbyScreen.SelectedMap.Name);
msg.Write(Game1.NetLobbyScreen.SelectedMap.MD5Hash.Hash);
msg.Write(GameMain.NetLobbyScreen.SelectedMap.Name);
msg.Write(GameMain.NetLobbyScreen.SelectedMap.MD5Hash.Hash);
msg.Write(Game1.NetLobbyScreen.GameDuration.TotalMinutes);
msg.Write(GameMain.NetLobbyScreen.GameDuration.TotalMinutes);
msg.Write((myCharacter == null) ? connectedClients.Count : connectedClients.Count+1);
foreach (Client client in connectedClients)
@@ -628,9 +628,9 @@ namespace Subsurface.Networking
gameStarted = true;
Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
Game1.GameScreen.Select();
GameMain.GameScreen.Select();
CreateCrewFrame(crew);
@@ -639,7 +639,7 @@ namespace Subsurface.Networking
private bool EndButtonHit(GUIButton button, object obj)
{
Game1.GameSession.gameMode.End("Server admin has ended the round");
GameMain.GameSession.gameMode.End("Server admin has ended the round");
return true;
}
@@ -651,8 +651,8 @@ namespace Subsurface.Networking
Character.Controlled = null;
Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
Game1.LightManager.LosEnabled = false;
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
GameMain.LightManager.LosEnabled = false;
gameStarted = false;
@@ -688,7 +688,7 @@ namespace Subsurface.Networking
(float)Math.Cos(camAngle) * (Submarine.Borders.Width / 2.0f),
(float)Math.Sin(camAngle) * (Submarine.Borders.Height / 2.0f)));
Game1.GameScreen.Cam.TargetPos = offset * 0.8f;
GameMain.GameScreen.Cam.TargetPos = offset * 0.8f;
//Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
messageBox.Text = endMessage + "\nReturning to lobby in " + (int)secondsLeft + " s";
@@ -698,7 +698,7 @@ namespace Subsurface.Networking
Submarine.Unload();
Game1.NetLobbyScreen.Select();
GameMain.NetLobbyScreen.Select();
yield return CoroutineStatus.Success;
@@ -731,7 +731,7 @@ namespace Subsurface.Networking
outmsg.Write(client.ID);
outmsg.Write(msg);
Game1.NetLobbyScreen.RemovePlayer(client);
GameMain.NetLobbyScreen.RemovePlayer(client);
if (server.Connections.Count > 0)
{
@@ -775,10 +775,10 @@ namespace Subsurface.Networking
{
base.Draw(spriteBatch);
if (!Game1.DebugDraw) return;
if (!GameMain.DebugDraw) return;
int width = 200, height = 300;
int x = Game1.GraphicsWidth - width, y = (int)(Game1.GraphicsHeight*0.3f);
int x = GameMain.GraphicsWidth - width, y = (int)(GameMain.GraphicsHeight*0.3f);
GUI.DrawRectangle(spriteBatch, new Rectangle(x,y,width,height), Color.Black*0.7f, true);
spriteBatch.DrawString(GUI.Font, "Network statistics:", new Vector2(x+10, y+10), Color.White);
@@ -809,7 +809,7 @@ namespace Subsurface.Networking
{
NetOutgoingMessage msg = server.CreateMessage();
msg.Write((byte)PacketTypes.UpdateNetLobby);
Game1.NetLobbyScreen.WriteData(msg);
GameMain.NetLobbyScreen.WriteData(msg);
if (server.Connections.Count > 0)
{
@@ -912,7 +912,7 @@ namespace Subsurface.Networking
if (characterInfo!=null)
{
assignedClientCount[JobPrefab.List.FindIndex(jp => jp == Game1.NetLobbyScreen.JobPreferences[0])]=1;
assignedClientCount[JobPrefab.List.FindIndex(jp => jp == GameMain.NetLobbyScreen.JobPreferences[0])]=1;
}
//if any of the players has chosen a job that is Always Allowed, give them that job
+1 -1
View File
@@ -12,7 +12,7 @@ namespace Subsurface.Networking
//UpdateEntity networkevents aren't sent to clients if they're further than this from the entity
public const float UpdateEntityDistance = 2500.0f;
public static string MasterServerUrl = Game1.Config.MasterServerUrl;
public static string MasterServerUrl = GameMain.Config.MasterServerUrl;
//if a ragdoll is further than this from the correct position, teleport it there
//(in sim units)
+2 -2
View File
@@ -59,11 +59,11 @@ namespace Subsurface.Networking
{
if (isClient)
{
if (Game1.Server != null && Game1.Server.Character == null) return;
if (GameMain.Server != null && GameMain.Server.Character == null) return;
}
else
{
if (Game1.Server == null) return;
if (GameMain.Server == null) return;
}
eventType = type;
@@ -93,8 +93,8 @@ namespace Subsurface.Networking
int width = 350, height = 100;
chatBox = new GUIListBox(new Rectangle(
Game1.GraphicsWidth - 20 - width,
Game1.GraphicsHeight - 40 - 25 - height,
GameMain.GraphicsWidth - 20 - width,
GameMain.GraphicsHeight - 40 - 25 - height,
width, height),
Color.White * 0.5f, GUI.Style, inGameHUD);
@@ -112,7 +112,7 @@ namespace Subsurface.Networking
{
int width = 500, height = 400;
crewFrame = new GUIFrame(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, Game1.GraphicsHeight / 2 - height / 2, width, height), GUI.Style);
crewFrame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), GUI.Style);
crewFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
GUIListBox crewList = new GUIListBox(new Rectangle(0, 0, 200, 300), Color.White * 0.7f, GUI.Style, crewFrame);
@@ -135,7 +135,7 @@ namespace Subsurface.Networking
null, frame);
textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);
new GUIImage(new Rectangle(-10, -10, 0, 0), character.AnimController.limbs[0].sprite, Alignment.Left, frame);
new GUIImage(new Rectangle(-10, -10, 0, 0), character.AnimController.Limbs[0].sprite, Alignment.Left, frame);
}
var closeButton = new GUIButton(new Rectangle(0,0, 80, 20), "Close", Alignment.BottomCenter, GUI.Style, crewFrame);
@@ -171,7 +171,7 @@ namespace Subsurface.Networking
{
if (string.IsNullOrWhiteSpace(message)) return false;
SendChatMessage(Game1.NetworkMember.Name + ": " + message);
SendChatMessage(GameMain.NetworkMember.Name + ": " + message);
textBox.Deselect();
@@ -180,7 +180,7 @@ namespace Subsurface.Networking
public void AddChatMessage(string message, ChatMessageType messageType)
{
Game1.NetLobbyScreen.NewChatMessage(message, messageColor[(int)messageType]);
GameMain.NetLobbyScreen.NewChatMessage(message, messageColor[(int)messageType]);
while (chatBox.CountChildren > 20)
{