Example #1
0
 public static void MasterRemove(WorldClient client, Packet packet)
 {
     string removename;
     if(!packet.TryReadString(out removename,16))
         return;
     MasterManager.Instance.RemoveMasterMember(client.Character, removename);
 }
Example #2
0
 public static void SendPing(WorldClient client)
 {
     using (var packet = new Packet(SH2Type.Ping))
     {
         client.SendPacket(packet);
     }
 }
Example #3
0
        public static void SendClientTime(WorldClient client, DateTime time)
        {
            using (var packet = new Packet(SH2Type.UpdateClientTime))
            {
                //pPacket.WriteUInt((59 << 25) | (23 << 19) | (31 << 13) | (12 << 8) | (254));
            // *                    Minutes   | Hours      | Days       | Months    | Years
                packet.WriteInt(3);
                packet.WriteInt(time.Minute);//minutes
                packet.WriteInt(time.Hour);//hourses
                packet.WriteInt(time.Day);
                packet.WriteInt(time.Month-1);
                packet.WriteInt((time.Year - 1900));
                packet.WriteInt((int)time.DayOfWeek);//wekday?
                packet.WriteInt(105);
                packet.WriteInt(2);

                packet.WriteByte(1); //GMT 0-130 positive 130 -254 negative
              //  packet.WriteLong(2012);
               // packet.WriteInt(4);//unk
                //packet.WriteInt(1);//unk
                //packet.WriteInt(3);//unk
                //packet.WriteInt(46);
              //  packet.Fill(3, 0);//unk
               // packet.WriteByte(2);
                client.SendPacket(packet);
            }
        }
Example #4
0
        public static void GetAcademyGoldRewardList(WorldClient client, Packet packet)
        {
            using (var pack = new Packet(SH38Type.SendAcademyGoldRewardList))
            {
                pack.WriteHexAsBytes("80 18");//responsecode
                pack.WriteByte(1);//stat count
                pack.WriteHexAsBytes("0A 0A CA 9A 3B 00 00 00 00");//unk

                pack.WriteByte(10);//levelbreich
                pack.WriteLong(1000);
                pack.WriteByte(15);//level bereich
                pack.WriteLong(1000);
                pack.WriteByte(26);//level bereich
                pack.WriteLong(1000);
                pack.WriteByte(31);//level bereich
                pack.WriteLong(1000);
                pack.WriteByte(36);//levelbereich
                pack.WriteLong(1000);
                pack.WriteByte(41);//level bereich
                pack.WriteLong(9000);
                pack.WriteByte(46);//level bereich
                pack.WriteLong(1000);
                pack.WriteByte(51);//level bereich
                pack.WriteLong(1000);
                pack.WriteByte(56);//level bereich
                pack.WriteLong(1000);
                client.SendPacket(pack);
            }
        }
Example #5
0
 public GroupRequest(WorldClient pFrom, Group pGroup, string pInvited)
 {
     this.CrationTimeStamp = DateTime.Now;
     this.InvitedClient = ClientManager.Instance.GetClientByCharname(pInvited);
     this.InviterClient = pFrom;
     this.Group = pGroup;
 }
Example #6
0
 public static void ChangeDropMode(WorldClient client, Packet packet)
 {
     byte dropState;
     if (packet.TryReadByte(out dropState)) {
         client.Character.Group.ChangeDropType(client.Character, dropState);
     }
 }
Example #7
0
        public static void CharacterSelectHandler(WorldClient client, Packet packet)
        {
            byte slot;
            if (!packet.TryReadByte(out slot) || slot > 10 || !client.Characters.ContainsKey(slot))
            {
                Log.WriteLine(LogLevel.Warn, "{0} selected an invalid character.", client.Username);
                return;
            }

            WorldCharacter character;
            if (client.Characters.TryGetValue(slot, out character))
            {
                //generate transfer

                ZoneConnection zone = Program.GetZoneByMap(character.Character.PositionInfo.Map);
                if (zone != null)
                {
                    client.Characters.Clear(); //we clear the other ones from memory
                    client.Character = character; //only keep the one selecte
                    //Database.Storage.Characters.AddChars(character.Character);
                    zone.SendTransferClientFromZone(client.AccountID, client.Username, client.Character.Character.Name,client.Character.ID, client.RandomID, client.Admin, client.Host);
                    ClientManager.Instance.AddClientByName(client); //so we can look them up fast using charname later.
                    SendZoneServerIP(client, zone);
                }
                else
                {
                    Log.WriteLine(LogLevel.Warn, "Character tried to join unloaded map: {0}", character.Character.PositionInfo.Map);
                    SendConnectError(client, ConnectErrors.MapUnderMaintenance);
                }
            }
        }
Example #8
0
 public static void AcceptParty(WorldClient client, Packet packet)
 {
     string inviteChar;
     if (packet.TryReadString(out inviteChar, 16))
     {
         GroupManager.Instance.AcceptInvite(client, inviteChar);
     }
 }
Example #9
0
 public static void SendUnknown(WorldClient client)
 {
     using (var packet = new Packet(SH31Type.LoadUnkown))
     {
         packet.WriteInt(0xbd1); //lolwut?!  charid or sumtin'
         client.SendPacket(packet);
     }
 }
Example #10
0
 public static void SendError(WorldClient client, ServerError error)
 {
     using (Packet pack = new Packet(SH3Type.Error))
     {
         pack.WriteShort((byte)error);
         client.SendPacket(pack);
     }
 }
Example #11
0
 public static void SendConnectError(WorldClient client, ConnectErrors error)
 {
     using (var packet = new Packet(SH4Type.ConnectError))
     {
         packet.WriteUShort((ushort)error);
         client.SendPacket(packet);
     }
 }
Example #12
0
 public static void PartyDecline(WorldClient client, Packet packet)
 {
     string inviteChar;
     if (packet.TryReadString(out inviteChar, 0x10))
     {
         GroupManager.Instance.DeclineInvite(client, inviteChar);
     }
 }
Example #13
0
 public GroupMember(WorldClient client, GroupRole role)
 {
     this.Client = client;
     this.Character = client.Character;
     this.CharId = client.Character.ID;
     this.Role = role;
     this.Name = client.Character.Character.Name;
     this.IsOnline = true;
 }
Example #14
0
 public static void SendZoneServerIP(WorldClient client, ZoneConnection info)
 {
     using (var packet = new Packet(SH4Type.ServerIP))
     {
         packet.WriteString(info.IP, 16);
         packet.WriteUShort(info.Port);
         client.SendPacket(packet);
     }
 }
Example #15
0
 public static void UnknownRequest(WorldClient client, Packet packet)
 {
     if (client.Character == null)
     {
         Log.WriteLine(LogLevel.Warn, "Getting unknown block request from unauthorized host: {0}.", client.Host);
         return;
     }
     SendUnknown(client);
 }
Example #16
0
        public MasterRequest(string target,WorldClient pClient)
        {
            this.InvitedClient = ClientManager.Instance.GetClientByCharname(target);
            if (this.InvitedClient == null)
                return;

            this.InviterClient = pClient;
            this.CrationTimeStamp = DateTime.Now;
        }
Example #17
0
 public static void BackToWorldSelect(WorldClient client, Packet packet)
 {
     using (Packet pack = new Packet(SH3Type.BackToWorldListFromChar))
     {
         pack.WriteHexAsBytes("58 1E");//responsecode
         pack.Fill(32, 0);
         client.SendPacket(pack);
     }
 }
Example #18
0
 public static void SendAcademyResponse(WorldClient pClient,string GuildName, GuildAcademyResponse Response)
 {
     using (var packet = new Packet(SH38Type.AcademyResponse))
     {
         packet.WriteString(GuildName, 16);
         packet.WriteUShort((ushort)Response);
         pClient.SendPacket(packet);
     }
 }
Example #19
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);
             }
        }
Example #20
0
        public static void FriendInvite(WorldClient pClient, Packet pPacket)
        {
            string sender, receiver;
            if (!pPacket.TryReadString(out sender, 16) ||
                !pPacket.TryReadString(out receiver, 16))
            {
                Log.WriteLine(LogLevel.Warn, "Error reading friend invite.");
                return;
            }

            WorldCharacter inviter = pClient.Character;
            WorldClient invitee = ClientManager.Instance.GetClientByCharname(receiver);
            if (invitee == null)
            {
                //character not found
                using (var pack = new Packet(SH21Type.FriendInviteResponse))
                {
                    pack.WriteString(sender, 16);
                    pack.WriteString(receiver, 16);
                    pack.WriteUShort(0x0946);	// Cannot find ${Target}

                    pClient.SendPacket(pack);
                }
            }
            else if (receiver == sender)
            {
                using (var pack = new Packet(SH21Type.FriendInviteResponse))
                {
                    pack.WriteString(sender, 16);
                    pack.WriteString(receiver, 16);
                    pack.WriteUShort(0x0942);	// You cannot add yourself to your Buddy List.

                    pClient.SendPacket(pack);
                }
            }
            else if (inviter.Friends.Find(f => f.Name == receiver) != null)
            {
                using (var pack = new Packet(SH21Type.FriendInviteResponse))
                {
                    pack.WriteString(sender, 16);
                    pack.WriteString(receiver, 16);
                    pack.WriteUShort(0x0945);	// {Target} is already registered in the friends list.
                    pClient.SendPacket(pack);
                }
            }
            else
            {
                using (var pack = new Packet(SH21Type.FriendInviteRequest))
                {
                    pack.WriteString(receiver, 16);
                    pack.WriteString(sender, 16);

                    invitee.SendPacket(pack);
                }
            }
        }
Example #21
0
 public static void clearBlock(WorldClient client, Packet packet)
 {
     using (var pp = new Packet(SH42Type.ClearBlockList))
     {
         pp.WriteUShort(7200);//unk
         client.SendPacket(packet);
     }
     Program.DatabaseManager.GetClient().ExecuteQuery("DELETE FROM BlockUser WHERE CharID = '" + client.Character.ID + "'");
     client.Character.BlocketUser.Clear();
 }
Example #22
0
 public void AddMasterRequest(WorldClient pClient,string target)
 {
     MasterRequest Request = new MasterRequest(target,pClient);
       MasterRequestResponse response = new MasterRequestResponse(Request);
     if(response.responseAnswer)
     {
      response.SendMasterRequest();
      pMasterRequests.Add(Request);
     }
 }
Example #23
0
 public static void MasterRequest(WorldClient client, Packet packet)
 {
     string playername = string.Empty;
     string target = string.Empty;
     if (!packet.TryReadString(out playername, 16))
         return;
     if (!packet.TryReadString(out target, 16))
         return;
     MasterManager.Instance.AddMasterRequest(client, target);
 }
Example #24
0
 public WorldCharacter(Character ch,WorldClient client)
 {
     Character = ch;
     this.Client = client;
     ID = Character.ID;
     Equips = new Dictionary<byte, ushort>();
     Inventory.LoadBasic(this);
     LoadEqupippet();
       ;
 }
Example #25
0
        public static void ChangePartyMaster(WorldClient client, Packet packet)
        {
            string mastername;
            if (packet.TryReadString(out mastername, 16))
            {
                if(client.Character.Group.Master.Name != client.Character.Character.Name)
                    return;

                GroupManager.Instance.ChangeMaster(client, mastername);
            }
        }
Example #26
0
        public static void KickPartyMember(WorldClient client, Packet packet)
        {
            string removeName;
            if (packet.TryReadString(out removeName, 16))
            {
                if(!client.Character.Group.HasMember(removeName))
                    return;

                GroupManager.Instance.KickMember(client, removeName);
            }
        }
Example #27
0
 public static void Handunk1(WorldClient character, Packet packet)
 {
     using (var to = new Packet(SH2Type.Unk1))
     {
         DateTime now = DateTime.Now;
         to.WriteByte(Convert.ToByte(now.Hour));
         to.WriteByte(Convert.ToByte(now.Minute));
         to.WriteByte(Convert.ToByte(now.Second));
         character.SendPacket(to);
     }
 }
Example #28
0
        public static void SaveClientSettingsRequest(WorldClient client, Packet packet)
        {
            byte[] data;
            if (!packet.TryReadBytes(392, out data))
            {
                Log.WriteLine(LogLevel.Warn, "Unable to read 392 bytes from stream for save");
                return;
            }

            // Save it.
            client.Character.SetClientSettingsData(data);
        }
Example #29
0
        public static void SaveQuickBarStateRequest(WorldClient client, Packet packet)
        {
            byte[] data;
            if (!packet.TryReadBytes(24, out data))
            {
                Log.WriteLine(LogLevel.Warn, "Unable to read 24 bytes from stream for save");
                return;
            }

            // Save it.
            client.Character.SetQuickBarStateData(data);
        }
Example #30
0
        public static void CreateCharHandler(WorldClient client, Packet packet)
        {
            string name;
            byte slot, jobGender, hair, color, style;
            if (!packet.TryReadByte(out slot) || !packet.TryReadString(out name, 20) ||
                !packet.TryReadByte(out jobGender) || !packet.TryReadByte(out hair) ||
                !packet.TryReadByte(out color) || !packet.TryReadByte(out style))
            {
                Log.WriteLine(LogLevel.Warn, "Error reading create char for {0}", client.Username);
                return;
            }

            if (DatabaseChecks.IsCharNameUsed(name))
            {
                SendCharCreationError(client, CreateCharError.NameTaken);
                return;
            }
            else if (DataProvider.Instance.IsBadName(name))
            {
                SendCharCreationError(client, CreateCharError.NameInUse);
                return;
            }

            byte isMaleByte = (byte)((jobGender >> 7) & 0x01);
            byte classIDByte = (byte)((jobGender >> 2) & 0x1F);
            Job job = (Job)classIDByte;
            switch (job)
            {
                case Job.Archer:
                case Job.Cleric:
                case Job.Fighter:
                case Job.Mage:
                case Job.Trickster:
                   //create character here
                    try
                    {
                        WorldCharacter wchar = client.CreateCharacter(name, slot, hair, color, style, job, Convert.ToBoolean(isMaleByte));
                        SendCharOKResponse(client, wchar);
                    }
                    catch (Exception ex)
                    {
                        Log.WriteLine(LogLevel.Exception, "Error creating character for {0}: {1}", client.Username, ex.InnerException.ToString());
                        SendCharCreationError(client, CreateCharError.FailedToCreate);
                        return;
                    }
                    break;
                default:
                    SendCharCreationError(client, CreateCharError.WrongClass);
                    Log.WriteLine(LogLevel.Warn, "Invalid job ID at char creation from {0}", client.Username);
                    break;
            }
        }