Esempio n. 1
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);
                }
            }
        }
Esempio n. 2
0
 public static void SendPing(WorldClient client)
 {
     using (var packet = new Packet(SH2Type.Ping))
     {
         client.SendPacket(packet);
     }
 }
Esempio n. 3
0
 public void AddClient(WorldClient client)
 {
     lock (clients)
     {
         clients.Add(client);
     }
 }
Esempio n. 4
0
        public static void LeaveParty(WorldClient client, Packet packet)
        {
            Party party;
            party = Program.Entity.Parties.First(c => c.CharNo == client.Character.Character.ID);

            foreach (Party PartyListFromDB in Program.Entity.Parties.Where(c => c.PartyNo == party.PartyNo).OrderBy(c => c.MasterNo))
            {
                Character character;
                character = Program.Entity.Characters.First(c => c.ID == PartyListFromDB.CharNo);
                WorldClient Partyclient = ClientManager.Instance.GetClientByCharname(character.Name);
                using (var ppacket = new Packet(SH14Type.LeaveParty))
                {
                    ppacket.WriteString(client.Character.Character.Name, 16);
                    ppacket.WriteUShort(1281);
                    Partyclient.SendPacket(ppacket);
                }
            }

            if(Program.Entity.Parties.Where(c => c.PartyNo == party.PartyNo).Count() == 2){
                Party OtherClientParty;
                OtherClientParty = Program.Entity.Parties.First(c => c.CharNo != client.Character.Character.ID);
                Program.Entity.DeleteObject(OtherClientParty);
            }

            Program.Entity.DeleteObject(party);
            Program.Entity.SaveChanges();
        }
Esempio n. 5
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);
            }
        }
Esempio n. 6
0
 public static void MasterRemove(WorldClient client, Packet packet)
 {
     string removename;
     if(!packet.TryReadString(out removename,16))
         return;
     MasterManager.Instance.RemoveMasterMember(client.Character, removename);
 }
Esempio n. 7
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;
 }
Esempio n. 8
0
 public static void ChangeDropMode(WorldClient client, Packet packet)
 {
     byte dropState;
     if (packet.TryReadByte(out dropState)) {
         client.Character.Group.ChangeDropType(client.Character, dropState);
     }
 }
Esempio n. 9
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);
            }
        }
Esempio n. 10
0
        public static void sendPartyMessage(WorldClient client, Packet packet)
        {
            string mess;
            byte len;
            if (!packet.TryReadByte(out len) || !packet.TryReadString(out mess, len))
            {
                Log.WriteLine(LogLevel.Error, "PartyChat :: Can not parse party chat from {0}", client.Character.Character.Name);
                return;
            }

            if(Program.Entity.Parties.Where(c => c.CharNo == client.Character.Character.ID).Count() == 1)
            {
                Party getPartyInfo = Program.Entity.Parties.First(c => c.CharNo == client.Character.Character.ID);
                foreach (Party party in Program.Entity.Parties.Where(c => c.PartyNo == getPartyInfo.PartyNo))
                {
                    Character character = Program.Entity.Characters.First(c => c.ID == party.CharNo);
                    WorldClient wclient = ClientManager.Instance.GetClientByCharname(character.Name);
                    using (var ppacket = new Packet(SH8Type.PartyChat))
                    {
                        ppacket.WriteString(client.Character.Character.Name, 16);
                        ppacket.WriteByte(len);
                        ppacket.WriteString(mess, len);
                        wclient.SendPacket(ppacket);
                    }
                }
            }
            else
            {
                using (var ppacket = new Packet(SH8Type.PartyChatErr))
                {
                    ppacket.WriteUShort(1985);
                    client.SendPacket(ppacket);
                }
            }
        }
Esempio n. 11
0
 public void AddClientByName(WorldClient client)
 {
     if (client.Character != null && !clientsByName.ContainsKey(client.CharacterName))
     {
         clientsByName.TryAdd(client.CharacterName, client);
     }
     else Log.WriteLine(LogLevel.Warn, "Trying to register client by name without having Character object.");
 }
Esempio n. 12
0
 public static void SendUnknown(WorldClient client)
 {
     using (var packet = new Packet(SH31Type.LoadUnkown))
     {
         packet.WriteInt(0xbd1); //lolwut?!  charid or sumtin'
         client.SendPacket(packet);
     }
 }
Esempio n. 13
0
 public static void PartyDecline(WorldClient client, Packet packet)
 {
     string inviteChar;
     if (packet.TryReadString(out inviteChar, 0x10))
     {
         GroupManager.Instance.DeclineInvite(client, inviteChar);
     }
 }
Esempio n. 14
0
 public static void sendUnk14(WorldClient client)
 {
     using (var packet = new Packet(SH2Type.Unk14))
     {
         packet.WriteHexAsBytes("07 2C 2A");
         client.SendPacket(packet);
     }
 }
Esempio n. 15
0
 public static void SendConnectError(WorldClient client, ConnectErrors error)
 {
     using (var packet = new Packet(SH4Type.ConnectError))
     {
         packet.WriteUShort((ushort)error);
         client.SendPacket(packet);
     }
 }
Esempio n. 16
0
 public static void SendError(WorldClient client, ServerError error)
 {
     using (Packet pack = new Packet(SH3Type.Error))
     {
         pack.WriteShort((byte)error);
         client.SendPacket(pack);
     }
 }
Esempio n. 17
0
 public static void AcceptParty(WorldClient client, Packet packet)
 {
     string inviteChar;
     if (packet.TryReadString(out inviteChar, 16))
     {
         GroupManager.Instance.AcceptInvite(client, inviteChar);
     }
 }
Esempio n. 18
0
 public static void SendGuildNameResult(WorldClient client, int pID, string pName)
 {
     using (var packet = new Packet(SH29Type.GuildNameResult))
     {
         packet.WriteInt(pID);
         packet.WriteString(pName, 16);
         client.SendPacket(packet);
     }
 }
Esempio n. 19
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);
     }
 }
Esempio n. 20
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);
     }
 }
Esempio n. 21
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);
 }
Esempio n. 22
0
 public static void SendBackToWorldSelect(WorldClient client)
 {
     using(Packet packet = new Packet(SH3Type.BackToWorldSelect))
     {
         packet.WriteUShort(7768);
         packet.WriteString(client.AccountKey);
         client.SendPacket(packet);
     }
 }
Esempio n. 23
0
 public static void SendConnectError(WorldClient client, ConnectErrors error)
 {
     Log.WriteLine(LogLevel.Error, error.ToString());
     using (var packet = new Packet(SH4Type.ConnectError))
     {
         packet.WriteUShort((ushort)error);
         client.SendPacket(packet);
     }
 }
Esempio n. 24
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;
 }
Esempio n. 25
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;
        }
Esempio n. 26
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);
                }
            }
        }
Esempio n. 27
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);
             }
        }
Esempio n. 28
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);
     }
 }
Esempio n. 29
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);
 }
Esempio n. 30
0
 public WorldCharacter(Character ch,WorldClient client)
 {
     Character = ch;
     this.Client = client;
     ID = Character.ID;
     Equips = new Dictionary<byte, ushort>();
     Inventory.LoadBasic(this);
     LoadEqupippet();
       ;
 }