Dedicated server actually works to some extent

Clients can connect and use chat, the sub list isn't synced properly and there's no way to start a game yet
This commit is contained in:
juanjp600
2017-06-19 15:12:19 -03:00
parent 16bc68d768
commit fbe7dfc6fb
10 changed files with 84 additions and 12 deletions

View File

@@ -360,7 +360,7 @@ namespace Barotrauma
}
GUI.Update((float)Timing.Step);
}
}
CoroutineManager.Update((float)Timing.Step, paused ? 0.0f : (float)Timing.Step);

View File

@@ -25,7 +25,6 @@ namespace Barotrauma.Networking
var endRoundButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170, 20, 150, 20), "End round", Alignment.TopLeft, "", inGameHUD);
endRoundButton.OnClicked = (btn, userdata) => { EndGame(); return true; };
log = new ServerLog(name);
showLogButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170 - 170, 20, 150, 20), "Server Log", Alignment.TopLeft, "", inGameHUD);
showLogButton.OnClicked = (GUIButton button, object userData) =>
{
@@ -45,14 +44,6 @@ namespace Barotrauma.Networking
settingsButton.OnClicked = ToggleSettingsFrame;
settingsButton.UserData = "settingsButton";
entityEventManager = new ServerEntityEventManager(this);
whitelist = new WhiteList();
banList = new BanList();
LoadSettings();
LoadClientPermissions();
//----------------------------------------
}

View File

@@ -6,6 +6,7 @@ using FarseerPhysics.Dynamics;
using Barotrauma.Networking;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using System.Threading;
namespace Barotrauma
{
@@ -68,7 +69,46 @@ namespace Barotrauma
public void Run()
{
//TODO: implement
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();
MapEntityPrefab.Init();
LevelGenerationParams.LoadPresets();
JobPrefab.LoadAll(SelectedPackage.GetFilesOfType(ContentType.Jobs));
StructurePrefab.LoadAll(SelectedPackage.GetFilesOfType(ContentType.Structure));
ItemPrefab.LoadAll(SelectedPackage.GetFilesOfType(ContentType.Item));
GameModePreset.Init();
LocationType.Init();
Submarine.RefreshSavedSubs();
NetLobbyScreen = new NetLobbyScreen();
Server = new GameServer("Dedicated Server Test", 14242, true, "asd", false, 10);
while (true)
{
NetLobbyScreen.Update((float)Timing.Step);
Server.Update((float)Timing.Step);
CoroutineManager.Update((float)Timing.Step, (float)Timing.Step);
Thread.Sleep((int)(Timing.Step * 1000.0));
}
}
public void ProcessInput()
{
while (true)
{
string input = Console.ReadLine();
DebugConsole.ExecuteCommand(input, this);
}
}
public CoroutineHandle ShowLoading(IEnumerable<object> loader, bool waitKeyHit = true)

View File

@@ -4,6 +4,7 @@ using System;
using System.IO;
using System.Reflection;
using System.Text;
using System.Threading;
#if WINDOWS
using System.Management;
@@ -31,6 +32,9 @@ namespace Barotrauma
try
{
game = new GameMain();
Thread inputThread = new Thread(new ThreadStart(game.ProcessInput));
inputThread.Start();
game.Run();
}
catch (Exception e)

View File

@@ -33,6 +33,18 @@ namespace Barotrauma
}
}
public override void Select()
{
List<Submarine> subsToShow = Submarine.SavedSubmarines.Where(s => !s.HasTag(SubmarineTag.HideInMenus)).ToList();
SelectedSub = subsToShow[0];
SelectedShuttle = subsToShow[0]; //TODO: don't use the same sub as a shuttle by default
DebugConsole.NewMessage("Selected sub: " + SelectedSub.Name, Color.White);
DebugConsole.NewMessage("Selected shuttle: " + SelectedShuttle.Name, Color.White);
}
private List<Submarine> subs = new List<Submarine>();
public List<Submarine> GetSubList()
{

View File

@@ -710,6 +710,9 @@
<Content Include="$(MSBuildThisFileDirectory)README.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)serverconfig.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)Content\blurshader.xnb">

View File

@@ -497,6 +497,10 @@ namespace Barotrauma
if (String.IsNullOrEmpty((msg))) return;
Messages.Add(new ColoredText(msg, color));
#if SERVER
//TODO: REMOVE
Console.WriteLine(msg);
#endif
if (Messages.Count > MaxMessages)
{

View File

@@ -119,7 +119,17 @@ namespace Barotrauma.Networking
config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
log = new ServerLog(name);
InitProjSpecific();
entityEventManager = new ServerEntityEventManager(this);
whitelist = new WhiteList();
banList = new BanList();
LoadSettings();
LoadClientPermissions();
CoroutineManager.StartCoroutine(StartServer(isPublic));
}
@@ -341,7 +351,7 @@ namespace Barotrauma.Networking
#endif
if (!started) return;
base.Update(deltaTime);
foreach (UnauthenticatedClient unauthClient in unauthenticatedClients)

View File

@@ -80,6 +80,10 @@ namespace Barotrauma.Networking
{
//string logLine = "[" + DateTime.Now.ToLongTimeString() + "] " + line;
#if SERVER
DebugConsole.NewMessage(line, Color.White); //TODO: REMOVE
#endif
var newText = new LogMessage(line, messageType);
lines.Enqueue(newText);

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<config masterserverurl="http://www.undertowgames.com/baromaster" autocheckupdates="true" verboselogging="true">
<contentpackage path="Data/ContentPackages/Vanilla 0.3.xml" />
</config>