Ejemplo n.º 1
0
        public GameRoom_UpdatePvP(Client User, XmlDocument Packet)
            : base(User, Packet)
        {
            GameRoom room = User.Player.RoomPlayer.Room;

            try
            {
                if (room.Mission.Map.FirstChild.Attributes["uid"].InnerText != this.Query.Attributes["mission_key"].InnerText)
                {
                    XmlDocument xmlDocument = Core.GameResources.Maps.Find((Predicate <XmlDocument>)(Attribute => Attribute.FirstChild.Attributes["uid"].InnerText == this.Query.Attributes["mission_key"].InnerText));
                    if (xmlDocument.FirstChild.Attributes["release_mission"].InnerText == "0")
                    {
                        StanzaException stanzaException = new StanzaException(User, Packet, 1);
                    }
                    else
                    {
                        room.Mission.Map = xmlDocument;
                        ++room.Mission.Revision;
                    }
                }
            }
            catch
            {
                this.ErrorId = 1;
                this.Process();
                return;
            }
            if (this.Query.Attributes["private"] != null)
            {
                room.Core.Private = this.Query.Attributes["private"].InnerText == "1";
            }
            if (this.Query.Attributes["round_limit"] != null && (this.Query.Attributes["round_limit"].InnerText == "6" || this.Query.Attributes["round_limit"].InnerText == "11" || this.Query.Attributes["round_limit"].InnerText == "16"))
            {
                room.CustomParams.RoundLimit = Convert.ToByte(this.Query.Attributes["round_limit"].InnerText);
            }
            if (this.Query.Attributes["friendly_fire"] != null)
            {
                room.CustomParams.FriendlyFire = this.Query.Attributes["friendly_fire"].InnerText == "1";
            }
            if (this.Query.Attributes["enemy_outlines"] != null)
            {
                room.CustomParams.EmenyOutlines = this.Query.Attributes["enemy_outlines"].InnerText == "1";
            }
            if (this.Query.Attributes["auto_team_balance"] != null)
            {
                room.CustomParams.AutoTeamBalance = this.Query.Attributes["auto_team_balance"].InnerText == "1";
            }
            if (this.Query.Attributes["dead_can_chat"] != null)
            {
                room.CustomParams.DeadCanChat = this.Query.Attributes["dead_can_chat"].InnerText == "1";
            }
            if (this.Query.Attributes["join_in_the_process"] != null)
            {
                room.CustomParams.JoinInProcess = this.Query.Attributes["join_in_the_process"].InnerText == "1";
            }
            if (this.Query.Attributes["max_players"] != null)
            {
                room.CustomParams.MaxPlayers = byte.Parse(this.Query.Attributes["max_players"].InnerText);
            }
            if (this.Query.Attributes["inventory_slot"] != null)
            {
                room.CustomParams.InventorySlot = int.Parse(this.Query.Attributes["inventory_slot"].InnerText);
            }
            if (this.Query.Attributes["locked_spectator_camera"] != null)
            {
                room.CustomParams.LockedSpectatorCamera = this.Query.Attributes["locked_spectator_camera"].InnerText == "1";
            }
            if (this.Query.Attributes["overtime_mode"] != null)
            {
                room.CustomParams.OvertimeMode = this.Query.Attributes["overtime_mode"].InnerText == "1";
            }
            if (this.Query["class_rifleman"] != null)
            {
                room.CustomParams.SoldierEnabled = this.Query["class_rifleman"].Attributes["enabled"].InnerText == "1";
            }
            if (this.Query["class_medic"] != null)
            {
                room.CustomParams.MedicEnabled = this.Query["class_medic"].Attributes["enabled"].InnerText == "1";
            }
            if (this.Query["class_engineer"] != null)
            {
                room.CustomParams.EngineerEnabled = this.Query["class_engineer"].Attributes["enabled"].InnerText == "1";
            }
            if (this.Query["class_sniper"] != null)
            {
                room.CustomParams.SniperEnabled = this.Query["class_sniper"].Attributes["enabled"].InnerText == "1";
            }
            ++room.CustomParams.Revision;
            if (!room.CustomParams.SoldierEnabled || !room.CustomParams.EngineerEnabled || (!room.CustomParams.SniperEnabled || !room.CustomParams.MedicEnabled))
            {
                foreach (Client client in room.Players.Users.ToArray())
                {
                    bool flag = false;
                    if (client.Player.CurrentClass == (byte)0 && !room.CustomParams.SoldierEnabled)
                    {
                        flag = true;
                    }
                    if (client.Player.CurrentClass == (byte)4 && !room.CustomParams.EngineerEnabled)
                    {
                        flag = true;
                    }
                    if (client.Player.CurrentClass == (byte)3 && !room.CustomParams.MedicEnabled)
                    {
                        flag = true;
                    }
                    if (client.Player.CurrentClass == (byte)2 && !room.CustomParams.SniperEnabled)
                    {
                        flag = true;
                    }
                    if (flag)
                    {
                        if (room.CustomParams.SoldierEnabled)
                        {
                            client.Player.CurrentClass = (byte)0;
                        }
                        if (room.CustomParams.EngineerEnabled)
                        {
                            client.Player.CurrentClass = (byte)4;
                        }
                        if (room.CustomParams.MedicEnabled)
                        {
                            client.Player.CurrentClass = (byte)3;
                        }
                        if (room.CustomParams.SniperEnabled)
                        {
                            client.Player.CurrentClass = (byte)2;
                        }
                    }
                }
            }
            if (room.CustomParams.AutoTeamBalance && room.Players.Users.Count != 1)
            {
                room.AutoBalanceProcess();
            }
            else
            {
                room.Sync(User);
            }
            this.Process();
        }
Ejemplo n.º 2
0
        public GameRoom_Join(Client User, XmlDocument Packet)
            : base(User, Packet)
        {
            try
            {
                if (User.Player.RoomPlayer.Room != null)
                {
                    GameRoom_Leave gameRoomLeave = new GameRoom_Leave(User, (XmlDocument)null);
                }
                this.Room = User.Channel.GameRoomList.Find((Predicate <GameRoom>)(Attribute => Attribute.Core.RoomId == long.Parse(this.Query.Attributes["room_id"].InnerText)));
                if (this.Room == null)
                {
                    StanzaException stanzaException1 = new StanzaException(User, this.Packet, 10);
                }
                else if (this.Room.Core.Private)
                {
                    StanzaException stanzaException2 = new StanzaException(User, this.Packet, 10);
                }
                else if (!this.Room.CustomParams.JoinInProcess && !User.Player.RoomPlayer.isInvited)
                {
                    StanzaException stanzaException3 = new StanzaException(User, this.Packet, 10);
                }
                else if (this.Room.KickedUsers.Contains(User.Player.UserID))
                {
                    StanzaException stanzaException4 = new StanzaException(User, this.Packet, 2);
                }
                else if (this.Room.Players.Users.Count >= (int)this.Room.CustomParams.MaxPlayers)
                {
                    StanzaException stanzaException5 = new StanzaException(User, this.Packet, 4);
                }
                else if (User.Player.Clan == null && this.Room.Core.RoomType == (byte)4)
                {
                    StanzaException stanzaException6 = new StanzaException(User, this.Packet, 13);
                }
                else if (this.Room.ClanWar.ClanFirst != "" && this.Room.ClanWar.ClanFirst != User.Player.Clan.Name && (this.Room.ClanWar.ClanSecond != "" && this.Room.ClanWar.ClanSecond != User.Player.Clan.Name))
                {
                    StanzaException stanzaException7 = new StanzaException(User, this.Packet, 14);
                }
                else
                {
                    int num1 = (int)(byte)this.Room.Players.Users.Count <Client>((Func <Client, bool>)(Attribute => Attribute.Player.RoomPlayer.TeamId == Teams.WARFACE));
                    int num2 = (int)(byte)this.Room.Players.Users.Count <Client>((Func <Client, bool>)(Attribute => Attribute.Player.RoomPlayer.TeamId == Teams.BLACKWOOD));
                    User.Player.RoomPlayer.TeamId = num1 <= num2 ? Teams.WARFACE : Teams.BLACKWOOD;
                    User.Player.RoomPlayer.Room   = this.Room;
                    this.Room.Players.Users.Add(User);
                    if (!this.Room.CustomParams.SoldierEnabled || !this.Room.CustomParams.EngineerEnabled || (!this.Room.CustomParams.SniperEnabled || !this.Room.CustomParams.MedicEnabled))
                    {
                        foreach (Client client in this.Room.Players.Users.ToArray())
                        {
                            bool flag = false;
                            if (client.Player.CurrentClass == (byte)0 && !this.Room.CustomParams.SoldierEnabled)
                            {
                                flag = true;
                            }
                            if (client.Player.CurrentClass == (byte)4 && !this.Room.CustomParams.EngineerEnabled)
                            {
                                flag = true;
                            }
                            if (client.Player.CurrentClass == (byte)3 && !this.Room.CustomParams.MedicEnabled)
                            {
                                flag = true;
                            }
                            if (client.Player.CurrentClass == (byte)2 && !this.Room.CustomParams.SniperEnabled)
                            {
                                flag = true;
                            }
                            if (flag)
                            {
                                if (this.Room.CustomParams.SoldierEnabled)
                                {
                                    client.Player.CurrentClass = (byte)0;
                                }
                                if (this.Room.CustomParams.EngineerEnabled)
                                {
                                    client.Player.CurrentClass = (byte)4;
                                }
                                if (this.Room.CustomParams.MedicEnabled)
                                {
                                    client.Player.CurrentClass = (byte)3;
                                }
                                if (this.Room.CustomParams.SniperEnabled)
                                {
                                    client.Player.CurrentClass = (byte)2;
                                }
                            }
                        }
                    }

                    this.Process();
                    if (this.Room.Core.RoomType == (byte)4)
                    {
                        this.Room.ClanBalanceProcess();
                    }
                    else if (this.Room.CustomParams.AutoTeamBalance)
                    {
                        this.Room.AutoBalanceProcess();
                    }
                    else
                    {
                        this.Room.Sync(User);
                    }
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 3
0
 public GameRoom_Open(Client User, XmlDocument Packet)
     : base(User, Packet)
 {
     if (User.Channel.ChannelType == "pve")
     {
         this.Query.Attributes["max_players"].InnerText = "5";
     }
     else
     {
         if (byte.Parse(this.Query.Attributes["max_players"].InnerText) > (byte)16)
         {
             this.Code = 3;
         }
         if (byte.Parse(this.Query.Attributes["max_players"].InnerText) < (byte)4)
         {
             this.Code = 3;
         }
         if ((int)byte.Parse(this.Query.Attributes["max_players"].InnerText) % 2 != 0)
         {
             this.Code = 3;
         }
     }
     if (this.Code != 0)
     {
         this.Process();
     }
     else
     {
         string Uid = this.Query.Attributes["mission"].InnerText;
         if (User.Player.RoomPlayer.Room != null)
         {
             GameRoom_Leave gameRoomLeave = new GameRoom_Leave(User, (XmlDocument)null);
         }
         GameRoom gameRoom = new GameRoom()
         {
             Core =
             {
                 RoomId = GameRoom.Seed
             }
         };
         ++GameRoom.Seed;
         gameRoom.RoomMaster.UserId = User.Player.UserID;
         if (User.Channel.ChannelType != "pve")
         {
             XmlDocument xmlDocument = Core.GameResources.Maps.Find((Predicate <XmlDocument>)(Attribute => Attribute.FirstChild.Attributes["uid"].InnerText == Uid));
             if (xmlDocument.FirstChild.Attributes["release_mission"].InnerText == "0")
             {
                 StanzaException stanzaException = new StanzaException(User, Packet, 1);
             }
             else
             {
                 gameRoom.Mission.Map = xmlDocument;
             }
         }
         if (User.Channel.ChannelType == "pve")
         {
             XmlDocument xmlDocument = Core.GameResources.Maps.Find((XmlDocument Attribute) => Attribute.FirstChild.Attributes["uid"].InnerText == Uid);
             if (xmlDocument.FirstChild.Attributes["release_mission"].InnerText == "0")
             {
                 new StanzaException(User, Packet, 1);
             }
             else
             {
                 gameRoom.Mission.Map = xmlDocument;
             }
         }
         gameRoom.Core.Name     = this.Query.Attributes["room_name"].InnerText;
         gameRoom.Core.RoomType = User.Channel.ChannelType == "pve" ? (byte)1 : (byte)2;
         if (this.Query.Attributes["group_id"] != null)
         {
             User.Player.RoomPlayer.GroupId = this.Query.Attributes["group_id"].InnerText;
         }
         if (this.Query.Attributes["private"] != null)
         {
             gameRoom.Core.Private = this.Query.Attributes["private"].InnerText == "1";
         }
         if (this.Query.Attributes["round_limit"] != null && (this.Query.Attributes["round_limit"].InnerText == "6" || this.Query.Attributes["round_limit"].InnerText == "11" || this.Query.Attributes["round_limit"].InnerText == "16"))
         {
             gameRoom.CustomParams.RoundLimit = Convert.ToByte(this.Query.Attributes["round_limit"].InnerText);
         }
         if (this.Query.Attributes["room_type"] != null)
         {
             gameRoom.Core.RoomType = byte.Parse(this.Query.Attributes["room_type"].InnerText);
             if (gameRoom.Core.RoomType == (byte)4 && User.Player.Clan == null)
             {
                 StanzaException stanzaException = new StanzaException(User, Packet, 1);
             }
         }
         if (this.Query.Attributes["friendly_fire"] != null)
         {
             gameRoom.CustomParams.FriendlyFire = this.Query.Attributes["friendly_fire"].InnerText == "1";
         }
         if (this.Query.Attributes["enemy_outlines"] != null)
         {
             gameRoom.CustomParams.EmenyOutlines = this.Query.Attributes["enemy_outlines"].InnerText == "1";
         }
         if (this.Query.Attributes["auto_team_balance"] != null)
         {
             gameRoom.CustomParams.AutoTeamBalance = this.Query.Attributes["auto_team_balance"].InnerText == "1";
         }
         if (this.Query.Attributes["dead_can_chat"] != null)
         {
             gameRoom.CustomParams.DeadCanChat = this.Query.Attributes["dead_can_chat"].InnerText == "1";
         }
         if (this.Query.Attributes["join_in_the_process"] != null)
         {
             gameRoom.CustomParams.JoinInProcess = this.Query.Attributes["join_in_the_process"].InnerText == "1";
         }
         if (this.Query.Attributes["max_players"] != null)
         {
             gameRoom.CustomParams.MaxPlayers = User.Channel.ChannelType == "pve" ? (byte)5 : byte.Parse(this.Query.Attributes["max_players"].InnerText);
         }
         if (this.Query.Attributes["inventory_slot"] != null)
         {
             gameRoom.CustomParams.InventorySlot = int.Parse(this.Query.Attributes["inventory_slot"].InnerText);
         }
         if (this.Query.Attributes["locked_spectator_camera"] != null)
         {
             gameRoom.CustomParams.LockedSpectatorCamera = this.Query.Attributes["locked_spectator_camera"].InnerText == "1";
         }
         if (this.Query.Attributes["overtime_mode"] != null)
         {
             gameRoom.CustomParams.OvertimeMode = this.Query.Attributes["overtime_mode"].InnerText == "1";
         }
         if (this.Query.Attributes["class_rifleman"] != null)
         {
             gameRoom.CustomParams.SoldierEnabled = this.Query["class_rifleman"].Attributes["enabled"].InnerText == "1";
         }
         if (this.Query.Attributes["class_medic"] != null)
         {
             gameRoom.CustomParams.MedicEnabled = this.Query["class_medic"].Attributes["enabled"].InnerText == "1";
         }
         if (this.Query.Attributes["class_engineer"] != null)
         {
             gameRoom.CustomParams.EngineerEnabled = this.Query["class_engineer"].Attributes["enabled"].InnerText == "1";
         }
         if (this.Query.Attributes["class_sniper"] != null)
         {
             gameRoom.CustomParams.SniperEnabled = this.Query["class_sniper"].Attributes["enabled"].InnerText == "1";
         }
         User.Player.RoomPlayer.Room   = gameRoom;
         User.Player.RoomPlayer.TeamId = Teams.WARFACE;
         User.Channel.GameRoomList.Add(gameRoom);
         gameRoom.Players.Users.Add(User);
         if (gameRoom.Core.RoomType == (byte)4)
         {
             gameRoom.ClanWar.ClanFirst = User.Player.Clan.Name;
         }
         Program.WriteLine($"Игрок {User.Player.Nickname} создал комнату. Карта: {gameRoom.Mission.Map}, ID: {gameRoom.Core.RoomId}", ConsoleColor.Yellow);
         this.Process();
     }
 }