Example #1
0
        public override void Open(string bindip, ushort port, bool lan)
        {
            if (bindip == "*")
            {
                bindip = "0.0.0.0";
            }
            if (IsHosting)
            {
                return;
            }
            var         ip   = SteamworksCommon.GetUInt32FromIp(bindip);
            EServerMode mode = EServerMode.eServerModeAuthenticationAndSecure;

            //if(lan) mode = EServerMode.eServerModeNoAuthentication;
            if (!GameServer.Init(ip, (ushort)(port + 2), port, (ushort)(port + 1), mode,
                                 GameInfo.VERSION))
            {
                throw new ServerInitializationFailedException("Couldn't start server (Steamworks API initialization failed)");
            }

            SteamGameServer.SetDedicatedServer(!lan);
            SteamGameServer.SetGameDescription(GameInfo.NAME);
            SteamGameServer.SetProduct(GameInfo.NAME);
            SteamGameServer.SetModDir(GameInfo.NAME);
            SteamGameServer.SetServerName(Description);
            SteamGameServer.LogOnAnonymous();
            SteamGameServer.SetPasswordProtected(false); //Todo
            SteamGameServer.EnableHeartbeats(true);

            Application.targetFrameRate = 60;
            IsHosting = true;
        }
    //-----------------------------------------------------------------------------
    // Purpose: Called once we are connected to Steam to tell it about our details
    //-----------------------------------------------------------------------------
    void SendUpdatedServerDetailsToSteam()
    {
        //
        // Set state variables, relevant to any master server updates or client pings
        //

        // These server state variables may be changed at any time.  Note that there is no lnoger a mechanism
        // to send the player count.  The player count is maintained by steam and you should use the player
        // creation/authentication functions to maintain your player count.
        SteamGameServer.SetMaxPlayerCount(m_nMaxPlayers);
        SteamGameServer.SetPasswordProtected(false);
        SteamGameServer.SetServerName(m_strServerName);
        SteamGameServer.SetBotPlayerCount(0);         // optional, defaults to zero
        SteamGameServer.SetMapName(m_strMapName);

#if USE_GS_AUTH_API
        // Update all the players names/scores

        /* @TODO: Riley: Disabled
         * for (uint32 i = 0; i < MAX_PLAYERS_PER_SERVER; ++i) {
         *      if (m_rgClientData[i].m_bActive && m_rgpShips[i]) {
         *              SteamGameServer.BUpdateUserData(m_rgClientData[i].m_SteamIDUser, m_rgpShips[i]->GetPlayerName(), m_rguPlayerScores[i]);
         *      }
         * }*/
#endif

        // game type is a special string you can use for your game to differentiate different game play types occurring on the same maps
        // When users search for this parameter they do a sub-string search of this string
        // (i.e if you report "abc" and a client requests "ab" they return your server)
        //SteamGameServer.SetGameType( "dm" );

        // update any rule values we publish
        //SteamGameServer.SetKeyValue( "rule1_setting", "value" );
        //SteamGameServer.SetKeyValue( "rule2_setting", "value2" );
    }
 private void SendUpdatedServerDetailsToSteam()
 {
     SteamGameServer.SetMaxPlayerCount(SteamDSConfig.ServerPlayers);
     SteamGameServer.SetPasswordProtected(false);
     SteamGameServer.SetServerName(SteamDSConfig.ServerName);
     SteamGameServer.SetBotPlayerCount(0);
     SteamGameServer.SetMapName(SteamDSConfig.MapName);
 }
Example #4
0
 private void SendUpdatedServerDetailsToSteam()
 {
     SteamGameServer.SetMaxPlayerCount(SteamDSConfig.ServerPlayers);
     SteamGameServer.SetPasswordProtected(!string.IsNullOrEmpty(SteamDSConfig.ServerPassword));
     SteamGameServer.SetServerName(SteamDSConfig.ServerName);
     SteamGameServer.SetMapName(SteamDSConfig.MapName);
     SteamGameServer.SetGameTags(SteamDSConfig.ServerGUID + ";__E3C26D06F07B6AB14EC25F4823E9A30D6B4ED0450527C1E768739D96C9F061AE");
     SteamGameServer.ForceHeartbeat();
 }
Example #5
0
 private void OnSteamServersConnected(SteamServersConnected_t LogonSuccess)
 {
     _connectedToSteam = true;
     SteamGameServer.SetMaxPlayerCount(4);
     SteamGameServer.SetPasswordProtected(false);
     SteamGameServer.SetServerName("Snakes");
     SteamGameServer.SetBotPlayerCount(0);
     SteamGameServer.SetMapName("inGame");
 }
Example #6
0
 private void SendUpdatedServerDetailsToSteam()
 {
     SteamGameServer.SetMaxPlayerCount(SteamDSConfig.ServerPlayers);
     SteamGameServer.SetPasswordProtected(!string.IsNullOrEmpty(SteamDSConfig.ServerPassword));
     SteamGameServer.SetServerName(SteamDSConfig.ServerName);
     SteamGameServer.SetMapName(SteamDSConfig.MapName);
     SteamGameServer.SetGameTags(SteamDSConfig.ServerGUID + ";__F486E3E06B8E13E0388571BE0FDC8A35182D8BE83E9256BA53BC5FBBDBCF23BC");
     SteamGameServer.ForceHeartbeat();
 }
Example #7
0
        private void ServerConnectedCallback(SteamServersConnected_t callback)
        {
            Debug.Log("[Steamworks.NET] GameServer connected successfully");

            SteamGameServer.SetServerName(ServerConfig.ServerName);
            SteamGameServer.SetPasswordProtected(!string.IsNullOrEmpty(ServerConfig.Password));
            SteamGameServer.SetMaxPlayerCount(ServerConfig.TeamNum * ServerConfig.NumPerTeam);
            SteamGameServer.SetMapName(ServerConfig.MapName);
            SteamGameServer.SetDedicatedServer(true);
            SetAdditionalGameInfo();
            SteamGameServer.EnableHeartbeats(true);
        }
Example #8
0
    void SendUpdatedServerSteam()
    {
        SteamGameServer.SetMaxPlayerCount(4);
        SteamGameServer.SetPasswordProtected(false);
        SteamGameServer.SetServerName("Snakes");
        SteamGameServer.SetBotPlayerCount(0);
        SteamGameServer.SetMapName("inGame");
#if USE_GS_AUTH_API
        for (uint i = 0; i < 4; ++i)
        {
        }
#endif
    }
Example #9
0
        public static void SetModded()
        {
            try {
                using (TimeWarning.New("UpdateServerInformation", 0.1f)) {
                    SteamGameServer.SetServerName(ConVar.Server.hostname);
                    SteamGameServer.SetMaxPlayerCount(ConVar.Server.maxplayers);
                    SteamGameServer.SetPasswordProtected(false);
                    SteamGameServer.SetMapName(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name);
                    string pchGameTags = string.Format("mp{0},cp{1},v{2}{3}{4}", new object[] {
                        ConVar.Server.maxplayers,
                        BasePlayer.activePlayerList.Count,
                        Rust.Protocol.network,
                        ConVar.Server.pve ? ",pve" : string.Empty,
                        pluton.enabled ? ",modded,pluton" : string.Empty
                    });

                    SteamGameServer.SetGameTags(pchGameTags);
                    string[] array = ConVar.Server.description.SplitToChunks(100).ToArray <string>();
                    for (int i = 0; i < 16; i++)
                    {
                        if (i < array.Length)
                        {
                            SteamGameServer.SetKeyValue(string.Format("description_{0:00}", i), array[i]);
                        }
                        else
                        {
                            SteamGameServer.SetKeyValue(string.Format("description_{0:00}", i), String.Empty);
                        }
                    }
                    SteamGameServer.SetKeyValue("country", SteamGameServerUtils.GetIPCountry());
                    SteamGameServer.SetKeyValue("world.seed", global::World.Seed.ToString());
                    SteamGameServer.SetKeyValue("world.size", global::World.Size.ToString());
                    SteamGameServer.SetKeyValue("official", ConVar.Server.official.ToString());
                    SteamGameServer.SetKeyValue("pve", ConVar.Server.pve.ToString());
                    SteamGameServer.SetKeyValue("headerimage", ConVar.Server.headerimage);
                    SteamGameServer.SetKeyValue("url", ConVar.Server.url);
                    SteamGameServer.SetKeyValue("uptime", ((int)Time.realtimeSinceStartup).ToString());
                    SteamGameServer.SetKeyValue("mem_ws", Performance.usedMemoryWorkingSetMB.ToString());
                    SteamGameServer.SetKeyValue("mem_pv", Performance.usedMemoryPrivateMB.ToString());
                    SteamGameServer.SetKeyValue("gc_mb", Performance.memoryAllocations.ToString());
                    SteamGameServer.SetKeyValue("gc_cl", Performance.memoryCollections.ToString());
                    SteamGameServer.SetKeyValue("fps", Performance.frameRate.ToString());
                    SteamGameServer.SetKeyValue("fps_avg", Performance.frameRateAverage.ToString("0.00"));
                    SteamGameServer.SetKeyValue("ent_cnt", BaseNetworkable.serverEntities.Count.ToString());
                    SteamGameServer.SetKeyValue("build", BuildInformation.VersionStampDays.ToString());
                }
            } catch (Exception ex) {
                Logger.LogError("[Hooks] Error while setting the server modded.");
                Logger.LogException(ex);
            }
        }
 public static bool RegisterServer_modded(string name, bool password, string version, bool publicServer, string worldName,
                                          ZSteamMatchmaking __instance)
 {
     __instance.UnregisterServer();
     SteamGameServer.SetServerName(config.ServerName);
     SteamGameServer.SetMapName(config.SteamMapName);
     SteamGameServer.SetPasswordProtected(password);
     SteamGameServer.SetGameTags(version);
     SteamGameServer.EnableHeartbeats(publicServer);
     SteamGameServer.SetMaxPlayerCount(config.Size);
     SteamGameServer.SetGameDescription("Valheim");
     AccessTools.Field(typeof(ZSteamMatchmaking), "m_registerServerName").SetValue(__instance, config.ServerName);
     AccessTools.Field(typeof(ZSteamMatchmaking), "m_registerPassword").SetValue(__instance, password);
     AccessTools.Field(typeof(ZSteamMatchmaking), "m_registerVerson").SetValue(__instance, version);
     print("Registering lobby (modded)");
     return(false);
 }
Example #11
0
 public override void SetPasswordProtected(bool passwordProtected)
 {
     SteamGameServer.SetPasswordProtected(passwordProtected);
 }