fix: catch more edge cases
This commit is contained in:
parent
5eedbf2f1e
commit
b9a7a1c479
4 changed files with 28 additions and 25 deletions
|
|
@ -8,10 +8,17 @@ public class GBSUClient : MonoBehaviour
|
||||||
{
|
{
|
||||||
public static void JoinServer(string serverip, int serverport)
|
public static void JoinServer(string serverip, int serverport)
|
||||||
{
|
{
|
||||||
LobbyManager.Instance.LobbyStates.IP = serverip;
|
if (!Helper.hosting)
|
||||||
LobbyManager.Instance.LobbyStates.Port = serverport;
|
{
|
||||||
LobbyManager.Instance.LobbyStates.CurrentState = LobbyState.State.Ready | LobbyState.State.InGame;
|
LobbyManager.Instance.LobbyStates.IP = serverip;
|
||||||
LobbyManager.Instance.LocalBeasts.SetupNetMemberContext(true);
|
LobbyManager.Instance.LobbyStates.Port = serverport;
|
||||||
MonoSingleton<Global>.Instance.UNetManager.LaunchClient(serverip, serverport);
|
LobbyManager.Instance.LobbyStates.CurrentState = LobbyState.State.Ready | LobbyState.State.InGame;
|
||||||
|
LobbyManager.Instance.LocalBeasts.SetupNetMemberContext(true);
|
||||||
|
MonoSingleton<Global>.Instance.UNetManager.LaunchClient(serverip, serverport);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GBSUGui.PushError("You are currently hosting a game! Please stop your server before attempting to join.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -93,14 +93,7 @@ Make sure to download a file from the examples given and rename it to config.jso
|
||||||
{
|
{
|
||||||
if (LobbyManager.Instance.LobbyStates.SelfState == LobbyState.Game.Online)
|
if (LobbyManager.Instance.LobbyStates.SelfState == LobbyState.Game.Online)
|
||||||
{
|
{
|
||||||
if (!Helper.hosting)
|
GBSUClient.JoinServer(Helper.serverip, Helper.serverport);
|
||||||
{
|
|
||||||
GBSUClient.JoinServer(Helper.serverip, Helper.serverport);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PushError("You are currently hosting a match! Please restart the game before attempting to join.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -108,10 +101,6 @@ Make sure to download a file from the examples given and rename it to config.jso
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
PushError("Couldn't find the -ip CLI argument. Please refer to the documentation.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GUI.Button(new Rect(20f, 295f, 170f, 30f), "Cap FPS to 60"))
|
if (GUI.Button(new Rect(20f, 295f, 170f, 30f), "Cap FPS to 60"))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -35,15 +35,18 @@ public class GBSUServer : MonoBehaviour
|
||||||
|
|
||||||
public static void StartServer()
|
public static void StartServer()
|
||||||
{
|
{
|
||||||
Helper.hosting = true;
|
if (!Helper.hosting)
|
||||||
AudioListener.volume = 0; // mute game audio
|
{
|
||||||
|
Helper.hosting = true;
|
||||||
|
AudioListener.volume = 0; // mute game audio
|
||||||
|
|
||||||
Plugin.AddServerComp(); // add custom GBSU server component
|
Plugin.AddServerComp(); // add custom GBSU server component
|
||||||
|
|
||||||
RotationConfig gameConfig = GBConfigLoader.LoadRotationConfig(null); // the argument doesn't matter as we do stuff in the method
|
RotationConfig gameConfig = GBConfigLoader.LoadRotationConfig(null); // the argument doesn't matter as we do stuff in the method
|
||||||
ServerConfig serverConfig = NetConfigLoader.LoadServerConfig(); // load default server config, because it can be overridden by args like -ip and -port
|
ServerConfig serverConfig = NetConfigLoader.LoadServerConfig(); // load default server config, because it can be overridden by args like -ip and -port
|
||||||
MonoSingleton<Global>.Instance.UNetManager.LaunchServer(serverConfig); // launch the server with the server config
|
MonoSingleton<Global>.Instance.UNetManager.LaunchServer(serverConfig); // launch the server with the server config
|
||||||
MonoSingleton<Global>.Instance.UNetManager.GetComponent<GameManagerNew>().ChangeRotationConfig(gameConfig, 0); // set server's rotationconfig
|
MonoSingleton<Global>.Instance.UNetManager.GetComponent<GameManagerNew>().ChangeRotationConfig(gameConfig, 0); // set server's rotationconfig
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void StopServer()
|
public static void StopServer()
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,10 @@ public class Plugin : BaseUnityPlugin
|
||||||
{
|
{
|
||||||
Helper.serverip = CommandLineParser.Instance.GetValueForKey("-ip", false);
|
Helper.serverip = CommandLineParser.Instance.GetValueForKey("-ip", false);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GBSUGui.PushError("Couldn't find the -ip CLI argument. Please refer to the documentation.");
|
||||||
|
}
|
||||||
if (CommandLineParser.Instance.KeyExists("-port"))
|
if (CommandLineParser.Instance.KeyExists("-port"))
|
||||||
{
|
{
|
||||||
int.TryParse(CommandLineParser.Instance.GetValueForKey("-port", false), out Helper.serverport);
|
int.TryParse(CommandLineParser.Instance.GetValueForKey("-port", false), out Helper.serverport);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue