TryReadBool() публичный Метод

public TryReadBool ( bool &pValue ) : bool
pValue bool
Результат bool
Пример #1
0
        public static void ChangeFromGuildAcademyToResponse(WorldClient client, Packet packet)
        {
            string GuildName;
              string RequestName;
              bool answer;
              if (!packet.TryReadString(out GuildName, 16) || !packet.TryReadString(out RequestName, 16)|| (!packet.TryReadBool(out answer) || !client.Character.IsInGuildAcademy))
                  return;
             if (answer)
            {
                GuildAcademyMember pMember = client.Character.GuildAcademy.Members.Find(m => m.Character.Character.Name == RequestName);
                if (pMember == null)
                    return;
                pMember.Character.IsInGuildAcademy = false;
                pMember.Academy.RemoveMember(pMember);
               pMember.Character.GuildAcademy.Guild.AddMember(pMember.Character, GuildRank.Member, Program.DatabaseManager.GetClient().GetConnection(), true, true);

                pMember.Character.Guild = pMember.Character.GuildAcademy.Guild;
                pMember.Character.IsInGuild = true;
             using (var pack = new Packet(SH38Type.SendJoinGuildFromAcademy))
             {
                 //this packet remove character from academy List and added to GuildList
                 pack.WriteString(RequestName, 16);
                 pack.WriteString(client.Character.Character.Name, 16);
                 pack.WriteByte(6);//rank
                 pack.WriteInt(0);//unk
                 pack.WriteUShort(0);//korp
                 pack.Fill(64, 0x00);//unk
                 pack.WriteByte(true ? (byte)0x95 : (byte)0x00);// (this.isOnline ? (byte)0x95 : (byte)0x00);
                 pack.Fill(3, 0x00);//unk
                 pack.WriteByte(pMember.Character.Character.Job);
                 pack.WriteByte(pMember.Character.Character.CharLevel);
                 pack.Fill(13, 0x00);//unk
                 client.Character.GuildAcademy.Guild.Broadcast(pack);
                 client.Character.GuildAcademy.Broadcast(pack);
                 }
             }
             using (var p2 = new Packet(SH4Type.CharacterGuildinfo))
             {
                 client.Character.Guild.WriteGuildInfo(packet);
                 client.SendPacket(p2);
             }
             using (var pack = new Packet(SH29Type.GuildMemberJoined))
             {
                 pack.WriteString(client.Character.Character.Name, 16);
                 client.Character.GuildAcademy.Guild.Broadcast(pack);
                 client.Character.GuildAcademy.Broadcast(pack);

             }
             using (var pack = new Packet(SH29Type.ChangeResponse))
             {
                 pack.WriteUShort(3137);//unk
                 pack.WriteByte(3);
                 pack.Fill(2, 0x00);//unk
                 client.SendPacket(pack);
             }
        }
Пример #2
0
        public static void FriendInviteResponse(WorldClient pClient, Packet pPacket)
        {
            string target, sender;
            bool response;
            if (!pPacket.TryReadString(out target, 16) ||
                !pPacket.TryReadString(out sender, 16) ||
                !pPacket.TryReadBool(out response))
            {
                Log.WriteLine(LogLevel.Warn, "Could not reat friend invite response.");
                return;
            }
            WorldClient sendchar = ClientManager.Instance.GetClientByCharname(sender);
            if (sendchar == null)
            {
                Log.WriteLine(LogLevel.Warn, "Invalid friend reject received.");
                return;
            }
            if (response)
            {
                Friend sendfriend = sendchar.Character.AddFriend(pClient.Character);
                if (sendfriend != null)
                {
                    using (var packet = new Packet(SH21Type.FriendInviteResponse))
                    {
                        packet.WriteString(sender, 16);
                        packet.WriteString(target, 16);
                        packet.WriteByte(0);
                        sendchar.SendPacket(packet);
                    }

                    using (var packet = new Packet(SH21Type.FriendExtraInformation))
                    {
                        sendfriend.WritePacket(packet);
                        sendchar.SendPacket(packet);
                    }
                }
            }
            else
            {
                using (var packet = new Packet(SH21Type.FriendInviteReject))
                {
                    packet.WriteString(target, 16);
                    sendchar.SendPacket(packet);
                }
            }
        }
Пример #3
0
        public static void BackToCharSelect(WorldClient pClient, Packet pPacket)
        {
            bool go; // dunno
            if (!pPacket.TryReadBool(out go))
            {
                Log.WriteLine(LogLevel.Warn, "Couldn't read back to char select packet");
                return;
            }
            if (!pClient.Authenticated)
            {
                Log.WriteLine(LogLevel.Warn, "Player tried using the back to char select packet while not able to");
                return;
            }

            if (go)
            {
                SendCharacterList(pClient);
            }
        }
Пример #4
0
        public static void On_GameClient_GuildInviteResponse(WorldClient Client, Packet pPacket)
        {
            string guildName;
            bool joinGuild;
            if (!pPacket.TryReadString(out guildName, 16)
                || !pPacket.TryReadBool(out joinGuild))
            {
                return;
            }

            //get guild
            Guild guild;
            if (GetGuildByName(guildName, out guild))
            {
                guild.AddMember(Client.Character, GuildRank.Member, null, true, true);
            }
        }
Пример #5
0
        public static void On_GameClient_CreateGuild(WorldClient Client, Packet Packet)
        {
            string name, password;
            bool allowGuildWar;
            if (!Packet.TryReadString(out name, 16)
                || !Packet.TryReadString(out password, 8)
                || !Packet.ReadSkip(4) // unk ?
                || !Packet.TryReadBool(out allowGuildWar))
            {
                return;
            }

            GuildCreateResponse response;

            if (Client.Character.Character.CharLevel < 20)
            {
                response = GuildCreateResponse.LevelTooLow;
            }
            else if (Client.Character.Character.Money < Guild.Price)
            {
                response = GuildCreateResponse.MoneyTooLow;
            }
            else
            {
                //encrypt guild pw
               var pwData = Encoding.UTF8.GetBytes(password);
            //                InterCrypto.Encrypt(ref pwData, 0, pwData.Length);

                Guild guild;

                //try to create guild
                lock (ThreadLocker)
                {
                    int result;
                    int guildID;
                    var createTime = Program.CurrentTime;

                    using (var con = Program.DatabaseManager.GetClient().GetConnection())
                    {
                        //insert guild in db
                        using (var cmd = con.CreateCommand())
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.CommandText = "Guild_Create";

                            cmd.Parameters.Add(new MySqlParameter("@pName", name));
                            cmd.Parameters.Add(new MySqlParameter("@pPassword", pwData));
                            cmd.Parameters.Add(new MySqlParameter("@pAllowGuildWar", allowGuildWar));
                            cmd.Parameters.Add(new MySqlParameter("@pCreaterID", Client.Character.ID));
                            cmd.Parameters.Add(new MySqlParameter("@pCreateTime", createTime));

                            var idParam = cmd.Parameters.Add(new MySqlParameter("@pID", SqlDbType.Int)
                                {
                                    Direction = ParameterDirection.Output
                                });
                            result = Convert.ToInt32(cmd.ExecuteScalar());
                            guildID = (int)idParam.Value;
                        }

                        switch (result)
                        {
                            case -1:
                                //guild name already exists (ToDo: get response code)

                                SendGuildCreateResponse(Client, name, password, allowGuildWar, GuildCreateResponse.AlredyExist);
                                return;

                            case -2: //database error @ insert guild (ToDo: get response code)
                                SendGuildCreateResponse(Client, name, password, allowGuildWar, GuildCreateResponse.Failed);
                                return;
                            case -3: //database error @ insert guild academy (ToDo: get response code)
                                SendGuildCreateResponse(Client, name, password, allowGuildWar, GuildCreateResponse.Failed);
                                return;

                            case 0:

                                //create guild
                                guild = new Guild(con, guildID, name, pwData, allowGuildWar, Client.Character, createTime);
                            //insert guild master (character will get updated)
                                guild.AddMember(Client.Character, GuildRank.Master, con, false, false);
                                //add to loaded guilds
                                LoadedGuilds.Add(guild);

                                break;

                            default:
                                return;
                        }
                    }
                }

                Client.Character.
                //revoke money
               Client.Character.ChangeMoney(Client.Character.Character.Money - Guild.Price);

                //let character broadcast guild name packet
                using (var packet = new Packet(SH29Type.GuildNameResult))
                {
                    packet.WriteInt(guild.ID);
                    packet.WriteString(guild.Name, 16);

                    BroadcastManager.Instance.BroadcastInRange(Client.Character, packet, true);
                }

                //let zone know that a guild has been loaded
                using (var packet = new InterPacket(InterHeader.ZONE_GuildCreated))
                {
                    packet.WriteInt(guild.ID);
                    packet.WriteInt(Client.Character.ID);

                    ZoneManager.Instance.Broadcast(packet);
                }

                //set response to success
                response = GuildCreateResponse.Success;
            }

            SendGuildCreateResponse(Client, name, password, allowGuildWar, response);
        }