Added some convenient console commands
This commit is contained in:
@@ -31,6 +31,30 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
switch (commands[0].ToLower())
|
switch (commands[0].ToLower())
|
||||||
{
|
{
|
||||||
|
case "restart":
|
||||||
|
case "reset":
|
||||||
|
DebugConsole.NewMessage("*****************", Color.Lime);
|
||||||
|
DebugConsole.NewMessage("RESTARTING SERVER", Color.Lime);
|
||||||
|
DebugConsole.NewMessage("*****************", Color.Lime);
|
||||||
|
GameMain.Instance.CloseServer();
|
||||||
|
GameMain.Instance.StartServer();
|
||||||
|
break;
|
||||||
|
case "exit":
|
||||||
|
case "close":
|
||||||
|
case "quit":
|
||||||
|
GameMain.ShouldRun = false;
|
||||||
|
break;
|
||||||
|
case "say":
|
||||||
|
case "msg":
|
||||||
|
string text = "";
|
||||||
|
for (int i=1;i<commands.Count();i++)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(text)) text += " ";
|
||||||
|
text += commands[i];
|
||||||
|
}
|
||||||
|
if (commands[0].ToLower() == "say") text = "HOST: " + text;
|
||||||
|
GameMain.Server.SendChatMessage(text, ChatMessageType.Server);
|
||||||
|
break;
|
||||||
case "startgame":
|
case "startgame":
|
||||||
case "startround":
|
case "startround":
|
||||||
case "start":
|
case "start":
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ namespace Barotrauma
|
|||||||
public static readonly Screen EditCharacterScreen = UnimplementedScreen.Instance;
|
public static readonly Screen EditCharacterScreen = UnimplementedScreen.Instance;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
public static bool ShouldRun = true;
|
||||||
|
|
||||||
public static ContentPackage SelectedPackage
|
public static ContentPackage SelectedPackage
|
||||||
{
|
{
|
||||||
@@ -75,13 +76,8 @@ namespace Barotrauma
|
|||||||
GameScreen = new GameScreen();
|
GameScreen = new GameScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Init()
|
||||||
{
|
{
|
||||||
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Character));
|
|
||||||
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Item));
|
|
||||||
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Items.Components.ItemComponent));
|
|
||||||
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Hull));
|
|
||||||
|
|
||||||
Mission.Init();
|
Mission.Init();
|
||||||
MapEntityPrefab.Init();
|
MapEntityPrefab.Init();
|
||||||
LevelGenerationParams.LoadPresets();
|
LevelGenerationParams.LoadPresets();
|
||||||
@@ -96,14 +92,36 @@ namespace Barotrauma
|
|||||||
LocationType.Init();
|
LocationType.Init();
|
||||||
|
|
||||||
Submarine.RefreshSavedSubs();
|
Submarine.RefreshSavedSubs();
|
||||||
|
|
||||||
NetLobbyScreen = new NetLobbyScreen();
|
|
||||||
|
|
||||||
|
Screen.SelectNull();
|
||||||
|
|
||||||
|
NetLobbyScreen = new NetLobbyScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StartServer()
|
||||||
|
{
|
||||||
Server = new GameServer("Dedicated Server Test", 14242, false, "asd", false, 10);
|
Server = new GameServer("Dedicated Server Test", 14242, false, "asd", false, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CloseServer()
|
||||||
|
{
|
||||||
|
Server.Disconnect();
|
||||||
|
Server = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Run()
|
||||||
|
{
|
||||||
|
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Character));
|
||||||
|
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Item));
|
||||||
|
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Items.Components.ItemComponent));
|
||||||
|
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Hull));
|
||||||
|
|
||||||
|
Init();
|
||||||
|
StartServer();
|
||||||
|
|
||||||
DateTime prevTime = DateTime.Now;
|
DateTime prevTime = DateTime.Now;
|
||||||
|
|
||||||
while (true)
|
while (ShouldRun)
|
||||||
{
|
{
|
||||||
prevTime = DateTime.Now;
|
prevTime = DateTime.Now;
|
||||||
|
|
||||||
@@ -115,6 +133,9 @@ namespace Barotrauma
|
|||||||
int frameTime = DateTime.Now.Subtract(prevTime).Milliseconds;
|
int frameTime = DateTime.Now.Subtract(prevTime).Milliseconds;
|
||||||
Thread.Sleep(Math.Max((int)(Timing.Step * 1000.0) - frameTime,0));
|
Thread.Sleep(Math.Max((int)(Timing.Step * 1000.0) - frameTime,0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CloseServer();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessInput()
|
public void ProcessInput()
|
||||||
|
|||||||
@@ -30,18 +30,19 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
GameMain game = null;
|
GameMain game = null;
|
||||||
Thread inputThread = null;
|
Thread inputThread = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
game = new GameMain();
|
game = new GameMain();
|
||||||
|
|
||||||
inputThread = new Thread(new ThreadStart(game.ProcessInput));
|
inputThread = new Thread(new ThreadStart(game.ProcessInput));
|
||||||
inputThread.Start();
|
inputThread.Start();
|
||||||
game.Run();
|
game.Run();
|
||||||
|
inputThread.Abort(); inputThread.Join();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
CrashDump(game, "servercrashreport.txt", e);
|
CrashDump(game, "servercrashreport.txt", e);
|
||||||
//inputThread.Abort(); inputThread.Join();
|
inputThread.Abort(); inputThread.Join();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,16 +91,14 @@ namespace Barotrauma
|
|||||||
|
|
||||||
switch (commands[0].ToLowerInvariant())
|
switch (commands[0].ToLowerInvariant())
|
||||||
{
|
{
|
||||||
case "entitylist":
|
case "clientlist":
|
||||||
System.IO.StreamWriter sw = new System.IO.StreamWriter("ENTLIST "+Rand.Int(20000).ToString()+".TXT");
|
if (GameMain.Server == null) break;
|
||||||
|
DebugConsole.NewMessage("***************", Color.Cyan);
|
||||||
List<Entity> entList = Entity.GetEntityList();
|
foreach (Client c in GameMain.Server.ConnectedClients)
|
||||||
foreach (Entity ent in entList)
|
|
||||||
{
|
{
|
||||||
sw.WriteLine(ent.ID.ToString()+" "+ent.ToString());
|
DebugConsole.NewMessage("- " + c.ID.ToString() + ": " + c.name + ", " + c.Connection.RemoteEndPoint.Address.ToString(),Color.Cyan);
|
||||||
}
|
}
|
||||||
|
DebugConsole.NewMessage("***************", Color.Cyan);
|
||||||
sw.Close();
|
|
||||||
break;
|
break;
|
||||||
case "help":
|
case "help":
|
||||||
NewMessage("menu: go to main menu", Color.Cyan);
|
NewMessage("menu: go to main menu", Color.Cyan);
|
||||||
@@ -308,6 +306,23 @@ namespace Barotrauma
|
|||||||
if (GameMain.NetworkMember == null || commands.Length < 2) break;
|
if (GameMain.NetworkMember == null || commands.Length < 2) break;
|
||||||
GameMain.NetworkMember.KickPlayer(string.Join(" ", commands.Skip(1)), false);
|
GameMain.NetworkMember.KickPlayer(string.Join(" ", commands.Skip(1)), false);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "kickid":
|
||||||
|
if (GameMain.Server == null || commands.Length < 2) break;
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
int.TryParse(commands[1], out id);
|
||||||
|
GameMain.Server.KickPlayer(id, false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "banid":
|
||||||
|
if (GameMain.Server == null || commands.Length < 2) break;
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
int.TryParse(commands[1], out id);
|
||||||
|
GameMain.Server.KickPlayer(id, true);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "ban":
|
case "ban":
|
||||||
if (GameMain.NetworkMember == null || commands.Length < 2) break;
|
if (GameMain.NetworkMember == null || commands.Length < 2) break;
|
||||||
|
|||||||
@@ -1249,7 +1249,7 @@ namespace Barotrauma.Networking
|
|||||||
GameMain.GameScreen.Select();
|
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;
|
GameMain.NetLobbyScreen.StartButtonEnabled = true;
|
||||||
|
|
||||||
gameStarted = true;
|
gameStarted = true;
|
||||||
@@ -1411,6 +1411,13 @@ namespace Barotrauma.Networking
|
|||||||
KickClient(client, ban, range);
|
KickClient(client, ban, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void KickPlayer(int id,bool ban,bool range=false)
|
||||||
|
{
|
||||||
|
Client client = connectedClients.Find(c => c.ID == id);
|
||||||
|
|
||||||
|
KickClient(client, ban, range);
|
||||||
|
}
|
||||||
|
|
||||||
public void KickClient(NetConnection conn, bool ban = false, bool range = false)
|
public void KickClient(NetConnection conn, bool ban = false, bool range = false)
|
||||||
{
|
{
|
||||||
Client client = connectedClients.Find(c => c.Connection == conn);
|
Client client = connectedClients.Find(c => c.Connection == conn);
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ namespace Barotrauma
|
|||||||
get { return selected; }
|
get { return selected; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SelectNull()
|
||||||
|
{
|
||||||
|
selected = null;
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void Deselect()
|
public virtual void Deselect()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user