private void ServerResponded(gameserveritem_t server)
        {
            Debug.Log("AutoJoin: Server ping succeeded");
            Debug.Log("Starting dedicated client");
            SteamDSConfig.isDedicatedServer       = false;
            CoopPeerStarter.DedicatedHost         = false;
            SteamClientDSConfig.isDedicatedClient = true;
            string[] array = server.GetGameTags().Split(new char[]
            {
                ';'
            });
            string guid = (array == null || array.Length <= 0) ? string.Empty : array[0];

            SteamClientDSConfig.Guid          = guid;
            SteamClientDSConfig.Server        = server;
            SteamClientDSConfig.serverAddress = server.m_NetAdr.GetConnectionAddressString();
            if (!string.IsNullOrEmpty(this.invitedToPassword))
            {
                SteamClientDSConfig.password = SteamDSConfig.PasswordToHash(this.invitedToPassword);
            }
            else
            {
                SteamClientDSConfig.password = string.Empty;
            }
            SteamClientDSConfig.adminPassword = string.Empty;
            SteamClientDSConfig.EndPoint      = UdpEndPoint.Parse(SteamClientDSConfig.serverAddress);
        }
Beispiel #2
0
 public static string[] CreateServerCfg()
 {
     try
     {
         if (!Directory.Exists(SteamDSConfig.GetServerCfgDir()))
         {
             Directory.CreateDirectory(SteamDSConfig.GetServerCfgDir());
         }
     }
     catch (Exception exception)
     {
         Debug.LogException(exception);
     }
     try
     {
         if (File.Exists(SteamDSConfig.GetServerCfgPath()))
         {
             File.Delete(SteamDSConfig.GetServerCfgPath());
         }
     }
     catch (Exception exception2)
     {
         Debug.LogException(exception2);
     }
     try
     {
         File.WriteAllLines(SteamDSConfig.GetServerCfgPath(), SteamDSConfig.ServerDefaultData);
     }
     catch (Exception exception3)
     {
         Debug.LogException(exception3);
     }
     return(SteamDSConfig.ServerDefaultData);
 }
Beispiel #3
0
    private static void JoinServerRequest(GameServerChangeRequested_t param)
    {
        if (BoltNetwork.isRunning || SteamClientDSConfig.Server != null)
        {
            return;
        }
        AutoJoinAfterMPInvite autoJoinAfterMPInvite = UnityEngine.Object.FindObjectOfType <AutoJoinAfterMPInvite>();
        CoopSteamNGUI         exists = UnityEngine.Object.FindObjectOfType <CoopSteamNGUI>();

        SteamClientDSConfig.serverAddress = param.m_rgchServer;
        SteamClientDSConfig.password      = SteamDSConfig.PasswordToHash(param.m_rgchPassword);
        if (exists)
        {
            if (CoopLobby.IsInLobby)
            {
                return;
            }
            Debug.Log("todo ?");
        }
        else if (autoJoinAfterMPInvite)
        {
            autoJoinAfterMPInvite.invitedToPassword = param.m_rgchPassword;
            autoJoinAfterMPInvite.SetInvitedToServer(param.m_rgchServer);
        }
    }
Beispiel #4
0
	public static void LoadServerCfg()
	{
		if (!SteamDSConfig.ServerConfigLoaded)
		{
			SteamDSConfig.serverConfig = SteamDSConfig.GetServerCfg();
			SteamDSConfig.ServerConfigLoaded = true;
		}
	}
Beispiel #5
0
	private static string defaultString(string key, string defaultValue = "")
	{
		if (SteamDSConfig.UseServerConfigFile)
		{
			string serverData = SteamDSConfig.GetServerData(key);
			return (!(serverData != string.Empty)) ? defaultValue : serverData;
		}
		return defaultValue;
	}
Beispiel #6
0
 public override void OnEvent(ServerStatusInfo evnt)
 {
     if (!this.ValidateSender(evnt, SenderTypes.Any))
     {
         return;
     }
     Debug.Log("Receive server status code: " + evnt.Status);
     SteamDSConfig.ReceiveServerStatus(evnt.Status);
 }
Beispiel #7
0
    private string GetPasswordArg(string[] args, string name, string defaultValue)
    {
        string text = this.GetStringArg(args, name, defaultValue);

        if (!string.IsNullOrEmpty(text))
        {
            text = SteamDSConfig.PasswordToHash(text);
        }
        return(text);
    }
Beispiel #8
0
	private static bool defaultBool(string key, bool defaultValue)
	{
		if (SteamDSConfig.UseServerConfigFile)
		{
			string serverData = SteamDSConfig.GetServerData(key);
			if (serverData != string.Empty)
			{
				return serverData.ToLower() == "on" || serverData.ToLower() == "true";
			}
		}
		return defaultValue;
	}
Beispiel #9
0
	private static int defaultInt(string key, int defaultValue)
	{
		if (SteamDSConfig.UseServerConfigFile)
		{
			string serverData = SteamDSConfig.GetServerData(key);
			int result = defaultValue;
			if (serverData != string.Empty && int.TryParse(serverData, out result))
			{
				return result;
			}
		}
		return defaultValue;
	}
Beispiel #10
0
 private static ushort defaultShort(string key, ushort defaultValue)
 {
     if (SteamDSConfig.UseServerConfigFile)
     {
         string serverData = SteamDSConfig.GetServerData(key);
         ushort result     = defaultValue;
         if (serverData != string.Empty && ushort.TryParse(serverData, out result))
         {
             return(result);
         }
     }
     return(defaultValue);
 }
Beispiel #11
0
 public static string GetServerData(string key)
 {
     SteamDSConfig.LoadServerCfg();
     if (SteamDSConfig.serverConfig != null && SteamDSConfig.serverConfig.Count > 0)
     {
         string key2 = key.ToLower();
         if (SteamDSConfig.serverConfig.ContainsKey(key2))
         {
             return(SteamDSConfig.serverConfig[key2]);
         }
     }
     Debug.LogError("No ServerConfig key (" + key + ") found. Check your configuration file.");
     return(string.Empty);
 }
Beispiel #12
0
	public static string[] GetServerCfg()
	{
		try
		{
			if (File.Exists(SteamDSConfig.GetServerCfgPath()))
			{
				return File.ReadAllLines(SteamDSConfig.GetServerCfgPath());
			}
		}
		catch (Exception exception)
		{
			Debug.LogException(exception);
		}
		return SteamDSConfig.CreateServerCfg();
	}
Beispiel #13
0
    private IEnumerator AutoSave()
    {
        while (!Scene.FinishGameLoad)
        {
            yield return(null);
        }
        SteamDSConfig.SetServerStatus(1);
        yield return(new WaitForEndOfFrame());

        yield return(new WaitForEndOfFrame());

        SteamDSConfig.SaveGame();
        SteamDSConfig.SetServerStatus(0);
        Debug.Log("Game saved");
        yield break;
    }
Beispiel #14
0
	public static string GetServerData(string key)
	{
		SteamDSConfig.LoadServerCfg();
		if (SteamDSConfig.serverConfig.Length > 0)
		{
			foreach (string text in SteamDSConfig.serverConfig)
			{
				if (!text.Contains("
				{
					string text2 = text.Replace(key, string.Empty);
					return text2.Trim();
				}
			}
		}
		Debug.LogError("No ServerConfig key (" + key + ") found. Check your configuration file.");
		return string.Empty;
	}
    protected override void OnLoadingDone()
    {
        if (SteamDSConfig.isDedicatedServer)
        {
            SteamDSConfig.StartAutoSaveMode();
        }
        BoltEntity boltEntity = BoltNetwork.Instantiate(BoltPrefabs.CoopBuildMission);

        boltEntity.transform.position = new Vector3(0f, 100f, 0f);
        BoltEntity boltEntity2 = BoltNetwork.Instantiate(BoltPrefabs.CoopWeatherProxy);

        boltEntity2.GetState <IWeatherState>().TimeOfDay = -1f;
        boltEntity2.transform.position = new Vector3(0f, 200f, 0f);
        if (CoopPeerStarter.DedicatedHost)
        {
            Console.WriteLine("Dedicated Server Running");
            Console.WriteLine("Address: " + SteamDSConfig.EndPoint);
            Console.WriteLine("Max Players: " + SteamDSConfig.ServerPlayers);
            Console.WriteLine("Save Interval: " + SteamDSConfig.GameAutoSaveIntervalMinutes + " minutes");
        }
    }
Beispiel #16
0
 public static void LoadServerCfg()
 {
     if (!SteamDSConfig.ServerConfigLoaded)
     {
         string[] serverCfg = SteamDSConfig.GetServerCfg();
         SteamDSConfig.serverConfig = new Dictionary <string, string>();
         for (int i = 0; i < serverCfg.Length; i++)
         {
             string text = serverCfg[i].Trim();
             if (!text.StartsWith("//"))
             {
                 int num = text.IndexOf(' ');
                 if (num == -1)
                 {
                     SteamDSConfig.serverConfig.Add(text.ToLower(), string.Empty);
                     if (text.EndsWith("s"))
                     {
                         SteamDSConfig.serverConfig.Add(text, string.Empty);
                     }
                 }
                 else
                 {
                     string text2 = text.Substring(0, num).ToLower();
                     string text3 = text.Substring(num + 1, text.Length - (num + 1));
                     SteamDSConfig.serverConfig.Add(text2, text3.Trim());
                     if (text2.EndsWith("s"))
                     {
                         SteamDSConfig.serverConfig.Add(text2.TrimEnd(new char[]
                         {
                             's'
                         }), text3.Trim());
                     }
                 }
             }
         }
         SteamDSConfig.ServerConfigLoaded = true;
     }
 }
Beispiel #17
0
    public void OnClientContinueGameDS(gameserveritem_t server)
    {
        Debug.Log("Starting dedicated client");
        SteamDSConfig.isDedicatedServer       = false;
        CoopPeerStarter.DedicatedHost         = false;
        SteamClientDSConfig.isDedicatedClient = true;
        string[] array = server.GetGameTags().Split(new char[]
        {
            ';'
        });
        string guid = (array == null || array.Length <= 0) ? string.Empty : array[0];

        SteamClientDSConfig.Guid          = guid;
        SteamClientDSConfig.Server        = server;
        SteamClientDSConfig.serverAddress = server.m_NetAdr.GetConnectionAddressString();
        if (!string.IsNullOrEmpty(this._joinDsScreen._password.value))
        {
            SteamClientDSConfig.password       = SteamDSConfig.PasswordToHash(this._joinDsScreen._password.value);
            this._joinDsScreen._password.value = string.Empty;
        }
        else
        {
            SteamClientDSConfig.password = string.Empty;
        }
        if (!string.IsNullOrEmpty(this._joinDsScreen._adminPassword.value))
        {
            SteamClientDSConfig.adminPassword       = SteamDSConfig.PasswordToHash(this._joinDsScreen._adminPassword.value);
            this._joinDsScreen._adminPassword.value = string.Empty;
        }
        else
        {
            SteamClientDSConfig.adminPassword = string.Empty;
        }
        SteamClientDSConfig.EndPoint = UdpEndPoint.Parse(SteamClientDSConfig.serverAddress);
        GameSetup.SetInitType(InitTypes.Continue);
        UnityEngine.Object.Destroy(base.gameObject);
        SceneManager.LoadScene("SteamStartSceneDedicatedServer_Client");
    }
Beispiel #18
0
 /// <summary>
 /// Saves the server and any related information
 /// </summary>
 public void Save() => SteamDSConfig.SaveGame();
Beispiel #19
0
 /// <summary>
 /// Saves the server and any related information
 /// </summary>
 public void Save()
 {
     LevelSerializer.Checkpoint();
     SteamDSConfig.SaveGame();
 }
Beispiel #20
0
	private static int defaultInt(string key, int defaultValue, int minValue)
	{
		return Mathf.Max(SteamDSConfig.defaultInt(key, defaultValue), minValue);
	}
Beispiel #21
0
 private static int defaultInt(string key, int defaultValue, int minValue, int maxValue)
 {
     return(Mathf.Clamp(SteamDSConfig.defaultInt(key, defaultValue), minValue, maxValue));
 }
Beispiel #22
0
	public static void StartAutoSaveMode()
	{
		SteamDSConfig.SetServerStatus(0);
		GameObject gameObject = new GameObject("GameAutoSave");
		AutoSaveMode autoSaveMode = gameObject.AddComponent<AutoSaveMode>();
	}