示例#1
0
        // Token: 0x06001FFC RID: 8188 RVA: 0x000966C4 File Offset: 0x000948C4
        private static int GetRealLobbyPlayerCount(LobbyList.Lobby lobby)
        {
            string data = lobby.GetData("player_count");
            int    result;

            if (data != null && TextSerialization.TryParseInvariant(data, out result))
            {
                return(result);
            }
            return(SteamLobbyFinder.steamClient.Lobby.MaxMembers);
        }
示例#2
0
 // Token: 0x06001FFB RID: 8187 RVA: 0x000966B0 File Offset: 0x000948B0
 private static bool CanJoinLobby(int currentLobbySize, LobbyList.Lobby lobby)
 {
     return(currentLobbySize + SteamLobbyFinder.GetRealLobbyPlayerCount(lobby) < lobby.MemberLimit);
 }
示例#3
0
        private bool SteamLobbyFinder_CanJoinLobby(On.RoR2.Networking.SteamLobbyFinder.orig_CanJoinLobby orig, int currentLobbySize, LobbyList.Lobby lobby)
        {
            var dataList = lobby.GetAllData();
            var configs  = file.ConfigDefinitions;

#if DEBUG
            Debug.LogError(lobby.Name);
            foreach (var data in dataList)
            {
                Debug.LogWarning(data.Key + "   :   " + data.Value);
            }
#endif

            configP2Pplugin(dataList, configs);

            foreach (var assetmod in Modeffects.BothSideMod.HostClientMod)
            {
                if (lobby.GetData("has: " + assetmod) != "1")
                {
                    return(false);
                }

                if (lobby.GetData("wants: " + assetmod) != "1")
                {
                    return(false);
                }
            }

            foreach (var config in configs)
            {
                if (config.Section == "joining")
                {
                    var data  = lobby.GetData("has: " + config.Key);
                    var value = file.Wrap <string>(config).Value;
                    if (value == "1")
                    {
                        if (data != "1")
                        {
#if DEBUG
                            Debug.LogError("no cuz host not have: " + config.Key);
#endif
                            return(false);
                        }
                    }
                    else if (value == "-1")
                    {
                        if (data == "1")
                        {
#if DEBUG
                            Debug.LogError("no cuz host have: " + config.Key);
#endif
                            return(false);
                        }
                    }
                }
            }

            foreach (var data in dataList)
            {
                if (data.Key.Contains("wants: "))
                {
                    string toBeSearched = "wants: ";
                    string GUID         = data.Key.Substring(data.Key.IndexOf(toBeSearched) + toBeSearched.Length);
                    bool   hasmod       = BepInEx.Bootstrap.Chainloader.Plugins.Any(p => MetadataHelper.GetMetadata(p).GUID == GUID);
                    if (data.Value == "1")
                    {
                        if (!hasmod)
                        {
#if DEBUG
                            Debug.LogError("no cuz host want: " + GUID);
#endif
                            return(false);
                        }
                    }
                    else if (data.Value == "-1")
                    {
                        if (hasmod)
                        {
#if DEBUG
                            Debug.LogError("no cuz host not want: " + GUID);
#endif
                            return(false);
                        }
                    }
                }
            }

            string playercount = dataList["player_count"];
            int    result      = int.MinValue;
            if (playercount != null)
            {
                TextSerialization.TryParseInvariant(playercount, out result);
                if (result != int.MinValue)
                {
                    if (result + currentLobbySize <= lobby.MemberLimit)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }