Пример #1
0
 private static void NetworkManager_NewClientConnected(Lidgren.Network.NetConnection con)
 {
     if (torrentManager.torrentList.Count == 0)
     {
         return;
     }
     Logman.Log("Sending torrent database to new client.");
     networkManager.SendTorrentListUpdate(torrentManager.torrentList.ToArray(), con);
 }
        void Static_ServerDisconnected(Lidgren.Network.NetConnection connection)
        {
            MySteam.RefreshSessionTicket();

            if (m_waitDialog != null)
            {
                m_waitDialog.CloseScreen();
                m_waitDialog = null;
            }
            MyMultiplayerPeers.Static.ServerDisconnected -= m_serverDisconnectedHandler;
            //ShowNetworkError();
        }
        private static void TryToConnect(object insertIPScreen)
        {
            InsertIPAddressNetworkGameScreen insIPScreen = (InsertIPAddressNetworkGameScreen)insertIPScreen;

            Lidgren.Network.NetConfiguration config = new Lidgren.Network.NetConfiguration("chessPlayConnection");
            config.MaxConnections = 1;
            config.TimeoutDelay   = 15;
            Lidgren.Network.NetPeer peer = new Lidgren.Network.NetPeer(config);
            try
            {
                Lidgren.Network.NetConnection connection = peer.Connect(insIPScreen.ipToUse, Utilities.PortNumber);
                while (connection.Status == Lidgren.Network.NetConnectionStatus.Connecting)
                {
                    ;
                }
                if (connection.Status == Lidgren.Network.NetConnectionStatus.Disconnected)
                {
                    throw new Lidgren.Network.NetException("error");
                }

                Lidgren.Network.NetConnection  conn;
                Lidgren.Network.NetMessageType type;
                String side
                    = Utilities.GetMessageFromConnection(peer, out type, out conn);

                //if (side == SideType.White.ToString())
                //{
                //    insIPScreen.Game.OptionsCurrent.BlackPlayer = GameOptions.PlayerOption.RemoteHuman;
                //    insIPScreen.Game.OptionsCurrent.WhitePlayer = GameOptions.PlayerOption.LocalHuman;
                //}
                //else
                //{
                //    insIPScreen.Game.OptionsCurrent.BlackPlayer = GameOptions.PlayerOption.LocalHuman;
                //    insIPScreen.Game.OptionsCurrent.WhitePlayer = GameOptions.PlayerOption.RemoteHuman;
                //}

                //LoadingScreen.Load(insIPScreen.ScreenManager, true, insIPScreen.controllingPlayer,
                //    new GamePlayNetworkScreen(peer));
                insIPScreen.ExitScreen();
            }
            catch (Lidgren.Network.NetException e)
            {
                insIPScreen.ShowMessageBox("Unable to connect to " + insIPScreen.ipToUse);
            }
        }
Пример #4
0
        public IEnumerable <object> CheckVPNBan(Client newclient, string clname)
        {
            Lidgren.Network.NetConnection address = newclient.Connection;
            Boolean IsVPNBanned = false;

            try
            {
                IsVPNBanned = CheckIP(address);
            }
            catch
            {
            }

            if (IsVPNBanned && GameMain.NilMod.VPNBanKicksPlayer)
            {
                if (GameMain.NilMod.EnablePlayerLogSystem)
                {
                    NilMod.NilModPlayerLog.LogPlayer(address.RemoteEndPoint.Address.ToString(), "VPNBLACKLISTED: " + clname);
                }
                GameMain.Server.KickVPNClient(address, "The IP: " + address.RemoteEndPoint.Address.ToString() + " has been VPN Blacklisted.", clname);
            }
            else
            {
                if (GameMain.NilMod.EnablePlayerLogSystem)
                {
                    GameMain.Server.SendChatMessage(NilMod.NilModPlayerLog.ListPrevious(address.RemoteEndPoint.Address.ToString(), clname, false, false, true), Barotrauma.Networking.ChatMessageType.Server, null);
                    if (IsVPNBanned)
                    {
                        NilMod.NilModPlayerLog.LogPlayer(address.RemoteEndPoint.Address.ToString(), clname);
                        DebugConsole.NewMessage("VPN USER: "******" - Player not blocked.", Microsoft.Xna.Framework.Color.White);
                        Barotrauma.Networking.GameServer.Log("VPN USER: "******" - Player not blocked.", Barotrauma.Networking.ServerLog.MessageType.Connection);
                        GameServer.LogToClientconsole("VPN USER: "******" - Player not blocked.");
                    }
                    else
                    {
                        DebugConsole.NewMessage(NilMod.NilModPlayerLog.ListPrevious(address.RemoteEndPoint.Address.ToString(), clname, true, true, true), Microsoft.Xna.Framework.Color.White);
                        Barotrauma.Networking.GameServer.Log(NilMod.NilModPlayerLog.ListPrevious(address.RemoteEndPoint.Address.ToString(), clname, true, true, true), Barotrauma.Networking.ServerLog.MessageType.Connection);
                        NilMod.NilModPlayerLog.LogPlayer(address.RemoteEndPoint.Address.ToString(), clname);
                        GameServer.LogToClientconsole(NilMod.NilModPlayerLog.ListPrevious(address.RemoteEndPoint.Address.ToString(), clname, true, true, true));
                    }
                }
                else
                {
                    DisconnectedCharacter ReconnectedClient = null;
                    KickedClient          kickedclient      = null;

                    if (GameMain.NilMod.DisconnectedCharacters.Count > 0)
                    {
                        ReconnectedClient = GameMain.NilMod.DisconnectedCharacters.Find(dc => dc.IPAddress == address.RemoteEndPoint.Address.ToString() && dc.clientname == clname);
                    }
                    if (GameMain.NilMod.KickedClients.Count > 0)
                    {
                        kickedclient = GameMain.NilMod.KickedClients.Find(dc => dc.IPAddress == address.RemoteEndPoint.Address.ToString() && dc.clientname == clname);
                    }

                    if (kickedclient != null)
                    {
                        if (!newclient.HideJoin)
                        {
                            GameMain.Server.SendChatMessage("Recently Kicked Player " + clname + " (" + kickedclient.clientname + ") has rejoined the server.", Barotrauma.Networking.ChatMessageType.Server, null);
                        }
                        DebugConsole.NewMessage("Recently Kicked Player " + clname + " (" + kickedclient.clientname + ") (" + address.RemoteEndPoint.Address.ToString() + ") has rejoined the server.", Microsoft.Xna.Framework.Color.White);
                        Barotrauma.Networking.GameServer.Log("Recently Kicked Player " + clname + " (" + kickedclient.clientname + ") (" + address.RemoteEndPoint.Address.ToString() + ") has rejoined the server.", Barotrauma.Networking.ServerLog.MessageType.Connection);
                        GameServer.LogToClientconsole("Recently Kicked Player " + clname + " (" + kickedclient.clientname + ") (" + address.RemoteEndPoint.Address.ToString() + ") has rejoined the server.");

                        if (GameMain.NilMod.ClearKickStateNameOnRejoin)
                        {
                            GameMain.NilMod.KickedClients.Remove(kickedclient);
                        }
                        else
                        {
                            kickedclient.ExpireTimer += GameMain.NilMod.KickStateNameTimerIncreaseOnRejoin;
                            if (kickedclient.ExpireTimer > GameMain.NilMod.KickMaxStateNameTimer)
                            {
                                kickedclient.ExpireTimer = GameMain.NilMod.KickMaxStateNameTimer;
                            }
                        }
                    }
                    else if (ReconnectedClient == null)
                    {
                        if (!newclient.HideJoin)
                        {
                            GameMain.Server.SendChatMessage(clname + " has joined the server.", Barotrauma.Networking.ChatMessageType.Server, null);
                        }
                        DebugConsole.NewMessage(clname + " (" + address.RemoteEndPoint.Address.ToString() + ") has joined the server.", Microsoft.Xna.Framework.Color.White);
                        Barotrauma.Networking.GameServer.Log(clname + " (" + address.RemoteEndPoint.Address.ToString() + ") has joined the server.", Barotrauma.Networking.ServerLog.MessageType.Connection);
                        GameServer.LogToClientconsole(clname + " (" + address.RemoteEndPoint.Address.ToString() + ") has joined the server.");
                    }
                    else
                    {
                        if (!newclient.HideJoin)
                        {
                            GameMain.Server.SendChatMessage(clname + " has reconnected to the server.", Barotrauma.Networking.ChatMessageType.Server, null);
                        }
                        DebugConsole.NewMessage(clname + " (" + address.RemoteEndPoint.Address.ToString() + ") has reconnected to the server.", Microsoft.Xna.Framework.Color.White);
                        Barotrauma.Networking.GameServer.Log(clname + " (" + address.RemoteEndPoint.Address.ToString() + ") has reconnected to the server.", Barotrauma.Networking.ServerLog.MessageType.Connection);
                        GameServer.LogToClientconsole(clname + " (" + address.RemoteEndPoint.Address.ToString() + ") has reconnected to the server.");
                    }
                }
            }

            yield return(Barotrauma.CoroutineStatus.Success);
        }
Пример #5
0
        public Boolean CheckIP(Lidgren.Network.NetConnection address)
        {
            System.Net.IPAddress IpToCheck = IPAddress.Parse(address.RemoteEndPoint.Address.ToString());

            Byte[] IPBytes = IpToCheck.GetAddressBytes();
            try
            {
                if (Banlist.Count > 0)
                {
                    for (int i = 0; i < Banlist.Count; i++)
                    {
                        //Could be inside range
                        if (Banlist[i].LowRange[0] <= IPBytes[0] && Banlist[i].HighRange[0] >= IPBytes[0])
                        {
                            //Its inside of the range, thus this is a banned IP.
                            if (Banlist[i].LowRange[0] < IPBytes[0] && Banlist[i].HighRange[0] > IPBytes[0])
                            {
                                return(true);
                            }
                        }
                        else
                        {
                            //Is outside range
                            continue;
                        }

                        //Could be inside range
                        if (Banlist[i].LowRange[1] <= IPBytes[1] && Banlist[i].HighRange[1] >= IPBytes[1])
                        {
                            //Its inside of the range, thus this is a banned IP.
                            if (Banlist[i].LowRange[1] < IPBytes[1] && Banlist[i].HighRange[1] > IPBytes[1])
                            {
                                return(true);
                            }
                        }
                        else
                        {
                            //Is outside range
                            continue;
                        }

                        //Could be inside range
                        if (Banlist[i].LowRange[2] <= IPBytes[2] && Banlist[i].HighRange[2] >= IPBytes[2])
                        {
                            //Its inside of the range, thus this is a banned IP.
                            if (Banlist[i].LowRange[2] < IPBytes[2] && Banlist[i].HighRange[2] > IPBytes[2])
                            {
                                return(true);
                            }
                        }
                        else
                        {
                            //Is outside range
                            continue;
                        }

                        //Could be inside range - if true Its inside of the range, thus this is a banned IP.
                        if (Banlist[i].LowRange[3] <= IPBytes[3] && Banlist[i].HighRange[3] >= IPBytes[3])
                        {
                            return(true);
                        }
                        else
                        {
                            //Is outside range
                            continue;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                DebugConsole.NewMessage("Error occured in VPN Banlist: " + e.Message.ToString(), Microsoft.Xna.Framework.Color.Red);
                return(false);
            }
            return(false);
        }
Пример #6
0
        public static string Apply(object[] parameters)
        {
            // flag1 = id des states qui se trouve dans la table summon
            // flag2 = idForSummon

            Actor spellCaster = parameters[0] as Actor;
            List <Effects.ZoneEffect.ZoneEffectTemplate> affectedPlayers = parameters[1] as List <Effects.ZoneEffect.ZoneEffectTemplate>;
            int spellID = (int)parameters[2];

            Actor.effects effect   = parameters[3] as Actor.effects;
            bool          cd       = Convert.ToBoolean(parameters[4]);
            Point         spellPos = parameters[5] as Point;

            Actor.SpellsInformations infos_sorts    = spellCaster.sorts.Find(f => f.SpellId == spellID);
            mysql.spells             spell_Template = (DataBase.DataTables.spells as List <mysql.spells>).Find(f => f.spellID == spellID && f.level == infos_sorts.Level);
            Battle _battle = Battle.Battles.Find(f => f.IdBattle == spellCaster.idBattle);

            Lidgren.Network.NetConnection nim = MainClass.netServer.Connections.Find(f => (f.Tag as Actor).Pseudo == spellCaster.Pseudo);

            // check si le joueur a assez de point d'invocation, pour cela, on dois calculer combiens d'invoc il a déja invoqué
            int sumOfInvoc = _battle.AllPlayersByOrder.FindAll(f => f.Pseudo.IndexOf(spellCaster.Pseudo + "$") != -1).Count;

            if (spellCaster.summons <= sumOfInvoc)
            {
                // pas assez de point d'invocation
                CommonCode.SendMessage("cmd•spellNotEnoughInvoc", nim, true);
                Console.WriteLine("<--cmd•spellNotEnoughInvoc to " + spellCaster.Pseudo);
                return("");
            }

            int isAllowedSpellArea = Fight.spellsChecker.isAllowedSpellArea(spell_Template.pe, spellCaster.map_position, spellCaster, _battle, spellPos, 0, false, true);

            if (isAllowedSpellArea == 0)
            {
                // spell autorisé
            }
            else if (isAllowedSpellArea == 1)
            {
                // spell non autorisé, case obstacle
                CommonCode.SendMessage("cmd•spellTileNotAllowed", nim, true);
                Console.WriteLine("<--cmd•spellTileNotAllowed to " + spellCaster.Pseudo);
                return("");
            }
            else if (isAllowedSpellArea == 2)
            {
                // spell non autorisé, pas de porté
                CommonCode.SendMessage("cmd•spellPointNotEnoughPe", nim, true);
                return("");
            }
            else if (isAllowedSpellArea == -1)
            {
                // impossible de determiner la direction, normalement ca deverai le deviner
                return("");
            }

            // creation d'un clone
            mysql.summon _summon = (DataBase.DataTables.summon as List <mysql.summon>).Find(f => f.template_id == Convert.ToInt32(effect.flag1));
            Actor        __clone_jutsu_naruto = Summon.StatsDispatcher.Apply(spellCaster, _summon, spell_Template, effect);

            // creation d'un id aleatoire pour l'invocation
            string rndStr = "";

            // check si le nom de l'invoc est déja dans la liste des joueurs pour eviter un doublons
            while (true)
            {
                rndStr = CommonCode.ReturnRandomId();
                if (!_battle.AllPlayersByOrder.Exists(f => f.Pseudo == __clone_jutsu_naruto.Pseudo + "$" + rndStr))
                {
                    break;
                }
            }

            __clone_jutsu_naruto.Pseudo       = __clone_jutsu_naruto.Pseudo + "$" + rndStr; // separateur entre le nom et le id de l'invocation
            __clone_jutsu_naruto.map_position = spellPos;


            // insert dans la liste
            int index = _battle.AllPlayersByOrder.FindIndex(f => f.Pseudo == spellCaster.Pseudo);

            _battle.AllPlayersByOrder.Insert(index + 1, __clone_jutsu_naruto);

            string buffer = "";

            // conversion des rawdata sort en base64
            string encryptedSpellsRaw = Cryptography.Algo.Encoding.Base64Encode(_summon.sorts);

            //rawData = "typeRox:addInvoc|name:x|cd:x|totalPdv:x";
            string piRaw = __clone_jutsu_naruto.Pseudo + ":" + __clone_jutsu_naruto.classeName + ":" + __clone_jutsu_naruto.spirit + ":" + __clone_jutsu_naruto.spiritLvl.ToString() + ":" + __clone_jutsu_naruto.Pvp.ToString() + ":" + __clone_jutsu_naruto.hiddenVillage + ":" + __clone_jutsu_naruto.maskColorString + ":" + __clone_jutsu_naruto.directionLook.ToString() + ":" + __clone_jutsu_naruto.level.ToString() + ":" + __clone_jutsu_naruto.map + ":" + __clone_jutsu_naruto.officialRang.ToString() + ":" + __clone_jutsu_naruto.currentHealth.ToString() + ":" + __clone_jutsu_naruto.maxHealth.ToString() + ":" + __clone_jutsu_naruto.doton.ToString() + ":" + __clone_jutsu_naruto.katon.ToString() + ":" + __clone_jutsu_naruto.futon.ToString() + ":" + __clone_jutsu_naruto.raiton.ToString() + ":" + __clone_jutsu_naruto.suiton.ToString() + ":" + /*MainClass.chakralvl2*/ 0 + ":" + /*MainClass.chakralvl3*/ 0 + ":" + /*MainClass.chakralvl4*/ 0 + ":" + /*MainClass.chakralvl5*/ 0 + ":" + /*MainClass.chakralvl6*/ 0 + ":" + /*pi.usingDoton.ToString()*/ 0 + ":" + /*pi.usingKaton.ToString()*/ 0 + ":" + /*pi.usingFuton.ToString()*/ 0 + ":" + /*pi.usingRaiton.ToString()*/ 0 + ":" + /*pi.usingSuiton.ToString()*/ 0 + ":" + /*pi.dotonEquiped.ToString()*/ 0 + ":" + /*pi.katonEquiped.ToString()*/ 0 + ":" + /*pi.futonEquiped.ToString()*/ 0 + ":" + /*pi.raitonEquiped.ToString()*/ 0 + ":" + /*pi.suitonEquiped.ToString()*/ 0 + ":" + __clone_jutsu_naruto.originalPc.ToString() + ":" + __clone_jutsu_naruto.originalPm.ToString() + ":" + __clone_jutsu_naruto.pe.ToString() + ":" + __clone_jutsu_naruto.cd.ToString() + ":" + __clone_jutsu_naruto.summons.ToString() + ":" + __clone_jutsu_naruto.initiative.ToString() + ":" + __clone_jutsu_naruto.resiDotonPercent.ToString() + ":" + __clone_jutsu_naruto.resiKatonPercent.ToString() + ":" + __clone_jutsu_naruto.resiFutonPercent.ToString() + ":" + __clone_jutsu_naruto.resiRaitonPercent.ToString() + ":" + __clone_jutsu_naruto.resiSuitonPercent.ToString() + ":" + __clone_jutsu_naruto.dodgePC.ToString() + ":" + __clone_jutsu_naruto.dodgePM.ToString() + ":" + __clone_jutsu_naruto.dodgePE.ToString() + ":" + __clone_jutsu_naruto.dodgeCD.ToString() + ":" + __clone_jutsu_naruto.removePC.ToString() + ":" + __clone_jutsu_naruto.removePM.ToString() + ":" + __clone_jutsu_naruto.removePE.ToString() + ":" + __clone_jutsu_naruto.removeCD.ToString() + ":" + __clone_jutsu_naruto.escape.ToString() + ":" + __clone_jutsu_naruto.blocage.ToString() + ":" + encryptedSpellsRaw + ":" + __clone_jutsu_naruto.resiDotonFix + ":" + __clone_jutsu_naruto.resiKatonFix + ":" + __clone_jutsu_naruto.resiFutonFix + ":" + __clone_jutsu_naruto.resiRaitonFix + ":" + __clone_jutsu_naruto.resiSuitonFix + ":" + __clone_jutsu_naruto.resiFix + ":" + __clone_jutsu_naruto.domDotonFix + ":" + __clone_jutsu_naruto.domKatonFix + ":" + __clone_jutsu_naruto.domFutonFix + ":" + __clone_jutsu_naruto.domRaitonFix + ":" + __clone_jutsu_naruto.domSuitonFix + ":" + __clone_jutsu_naruto.domFix + ":" + __clone_jutsu_naruto.power + ":" + __clone_jutsu_naruto.equipedPower;

            buffer = "typeRox:addInvoc|" + piRaw + "|cd:" + cd;

            return(buffer);
        }