Ejemplo n.º 1
0
        public static void On_WorldClient_AcademyMemberLeft(WorldConnector pConnector, InterPacket pPacket)
        {
            int guildID, characterID;
            if (!pPacket.TryReadInt(out guildID)
                || !pPacket.TryReadInt(out characterID))
            {
                return;
            }

            Guild guild;
            if (GuildManager.GetGuildByID(guildID, out guild))
            {
                GuildAcademyMember member;
                if (guild.Academy.GetMember(characterID, out member))
                {
                    guild.Academy.Members.Remove(member);
                    member.Dispose();

                    ZoneCharacter character;
                    if (CharacterManager.GetLoggedInCharacter(characterID, out character))
                    {
                        character.Guild = null;
                        character.GuildAcademy = null;
                        character.GuildAcademyMember = null;

                        GuildManager.RemoveGuildBuff(character);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void AddRewardItem(WorldConnector pConnector, InterPacket pPacket)
        {
            byte   count;
            ushort ItemID;
            string Charname;

            if (!pPacket.TryReadUShort(out ItemID))
            {
                return;
            }

            if (!pPacket.TryReadByte(out count))
            {
                return;
            }

            if (!pPacket.TryReadString(out Charname, 16))
            {
                return;
            }

            ZoneClient pClient = ClientManager.Instance.GetClientByName(Charname);

            if (pClient == null)
            {
                return;
            }

            pClient.Character.GiveMasterRewardItem(ItemID, count);
        }
Ejemplo n.º 3
0
        public static void On_WorldClient_AcademyMemberJoined(WorldConnector pConnector, InterPacket pPacket)
        {
            int guildID, characterID;
            DateTime registerDate;
            if (!pPacket.TryReadInt(out guildID)
                || !pPacket.TryReadInt(out characterID)
                || !pPacket.TryReadDateTime(out registerDate))
            {
                return;
            }

            Guild guild;
            if (GuildManager.GetGuildByID(guildID, out guild))
            {
                var member = new GuildAcademyMember(guild.Academy, characterID, GuildAcademyRank.Member, registerDate)
                {
                    IsOnline = true,
                };
                guild.Academy.Members.Add(member);

                ZoneCharacter character;
                if (CharacterManager.GetLoggedInCharacter(characterID, out character))
                {
                    member.Character = character;

                    character.Guild = guild;
                    character.GuildAcademy = guild.Academy;
                    character.GuildAcademyMember = member;

                    GuildManager.SetGuildBuff(character);
                }
            }
        }
Ejemplo n.º 4
0
        public static void Broadcast(WorldConnector pConnector, InterPacket pPacket)
        {
            int packetlenght;
            byte[] packet;
            string charname;
            if (!pPacket.TryReadString(out charname, 16))
                return;

            if (!pPacket.TryReadInt(out packetlenght))
                return;

            if (!pPacket.TryReadBytes(packetlenght, out packet))
                return;

            ZoneClient pClient = ClientManager.Instance.GetClientByCharName(charname);
            if (pClient == null)
                return;
            using (var ipacket = new InterPacket(InterHeader.SendBroiadCastList))
            {
                List<ZoneCharacter> Sender = pClient.Character.Map.GetCharactersBySectors(pClient.Character.MapSector.SurroundingSectors);
                if (Sender.Count == 0)
                    return;
                ipacket.WriteInt(packetlenght);
                ipacket.WriteBytes(packet);
                ipacket.WriteInt(Sender.Count);
                foreach (var character in Sender)
                {
                    ipacket.WriteString(character.Name,16);
                }
                pConnector.SendPacket(ipacket);
            }
        }
Ejemplo n.º 5
0
 public static void TryAssiging(WorldConnector lc)
 {
     using (var p = new InterPacket(InterHeader.Assign))
     {
         p.WriteStringLen(Settings.Instance.IP);
         lc.SendPacket(p);
     }
 }
Ejemplo n.º 6
0
 public static bool Load(string ip, int port)
 {
     try
     {
         Instance = new WorldConnector(ip, port);
         return true;
     }
     catch { return false; }
 }
Ejemplo n.º 7
0
 public static bool Load(string ip, int port)
 {
     try
     {
         Instance = new WorldConnector(ip, port);
         return(true);
     }
     catch { return(false); }
 }
Ejemplo n.º 8
0
        public static void GroupBrokeUp(WorldConnector lc, InterPacket packet)
        {
            long groupId;

            if (!packet.TryReadLong(out groupId))
            {
                return;
            }
            GroupManager.Instance.GroupBrokeUp(groupId);
        }
Ejemplo n.º 9
0
        public static void NewPartyCreated(WorldConnector lc, InterPacket packet)
        {
            long id;

            if (!packet.TryReadLong(out id))
            {
                throw new InvalidPacketException();
            }
            GroupManager.Instance.NewGroupCreated(id);
        }
Ejemplo n.º 10
0
        public static void NewGroupCreated(WorldConnector pConnector, InterPacket pPacket)
        {
            long groupId = -1;

            if (!pPacket.TryReadLong(out groupId))
            {
                throw new InvalidPacketException();
            }
            GroupManager.Instance.NewGroupCreated(groupId);
        }
Ejemplo n.º 11
0
 public static void AddPartyMember(WorldConnector lc, InterPacket packet)
 {
     long groupId = 0;
     string charName = "";
     if (!packet.TryReadLong(out groupId) &&
         !packet.TryReadString(out charName, 16))
     {
         throw new InvalidPacketException();
     }
     GroupManager.Instance.AddMemberToGroup(groupId, charName);
 }
Ejemplo n.º 12
0
        public static void FunctionAnswer(WorldConnector pConnector, InterPacket pPacket)
        {
            long id;

            if (!pPacket.TryReadLong(out id))
            {
                throw new InvalidPacketException();
            }
            object result = InterFunctionCallbackProvider.Instance.GetReadFunc(id)(pPacket);

            InterFunctionCallbackProvider.Instance.OnResult(id, result);
        }
Ejemplo n.º 13
0
        public static void AddPartyMember(WorldConnector lc, InterPacket packet)
        {
            long   groupId  = 0;
            string charName = "";

            if (!packet.TryReadLong(out groupId) &&
                !packet.TryReadString(out charName, 16))
            {
                throw new InvalidPacketException();
            }
            GroupManager.Instance.AddMemberToGroup(groupId, charName);
        }
Ejemplo n.º 14
0
        public static void HandleZoneList(WorldConnector lc, InterPacket packet)
        {
            int amount;

            if (!packet.TryReadInt(out amount))
            {
                return;
            }

            for (var i = 0; i < amount; i++)
            {
                byte   id;
                string ip;
                ushort port;
                int    mapcount;
                if (!packet.TryReadByte(out id) || !packet.TryReadString(out ip) || !packet.TryReadUShort(out port) ||
                    !packet.TryReadInt(out mapcount))
                {
                    return;
                }

                var maps = new List <MapInfo>();
                for (var j = 0; j < mapcount; j++)
                {
                    ushort mapid, viewrange;
                    string shortname, fullname;
                    int    regenx, regeny;
                    byte   kingdom;
                    if (!packet.TryReadUShort(out mapid) || !packet.TryReadString(out shortname) ||
                        !packet.TryReadString(out fullname) || !packet.TryReadInt(out regenx) ||
                        !packet.TryReadInt(out regeny) || !packet.TryReadByte(out kingdom) ||
                        !packet.TryReadUShort(out viewrange))
                    {
                        break;
                    }

                    maps.Add(new MapInfo(mapid, shortname, fullname, regenx, regeny, kingdom, viewrange));
                }

                ZoneData zd;
                if (!Program.Zones.TryGetValue(id, out zd))
                {
                    zd = new ZoneData();
                }

                zd.ID             = id;
                zd.IP             = ip;
                zd.Port           = port;
                zd.MapsToLoad     = maps;
                Program.Zones[id] = zd;
                Log.WriteLine(LogLevel.Info, "Added zone {0} to zonelist. {1}:{2}", zd.ID, zd.IP, zd.Port);
            }
        }
Ejemplo n.º 15
0
        public static void HandleZoneClosed(WorldConnector lc, InterPacket packet)
        {
            byte id;

            if (!packet.TryReadByte(out id))
            {
                return;
            }
            ZoneData zd;

            if (Program.Zones.TryRemove(id, out zd))
            {
                Log.WriteLine(LogLevel.Info, "Removed zone {0} from zones (disconnected)", id);
            }
        }
Ejemplo n.º 16
0
        public static void Broadcast(WorldConnector pConnector, InterPacket pPacket)
        {
            int packetlenght;

            byte[] packet;
            string charname;

            if (!pPacket.TryReadString(out charname, 16))
            {
                return;
            }

            if (!pPacket.TryReadInt(out packetlenght))
            {
                return;
            }

            if (!pPacket.TryReadBytes(packetlenght, out packet))
            {
                return;
            }

            var pClient = ClientManager.Instance.GetClientByCharName(charname);

            if (pClient == null)
            {
                return;
            }
            using (var ipacket = new InterPacket(InterHeader.SendBroiadCastList))
            {
                var Sender =
                    pClient.Character.Map.GetCharactersBySectors(pClient.Character.MapSector.SurroundingSectors);
                if (Sender.Count == 0)
                {
                    return;
                }
                ipacket.WriteInt(packetlenght);
                ipacket.WriteBytes(packet);
                ipacket.WriteInt(Sender.Count);
                foreach (var character in Sender)
                {
                    ipacket.WriteString(character.Name, 16);
                }

                pConnector.SendPacket(ipacket);
            }
        }
Ejemplo n.º 17
0
        public static void ChangeMoney(WorldConnector pConnector, InterPacket pPacket)
        {
            int  CharID;
            long NewMoney;

            if (!pPacket.TryReadInt(out CharID))
            {
                return;
            }
            if (!pPacket.TryReadLong(out NewMoney))
            {
                return;
            }
            var pClient = ClientManager.Instance.GetClientByCharID(CharID);

            pClient?.Character.ChangeMoney(NewMoney);
        }
Ejemplo n.º 18
0
        public static void RemovePartyMember(WorldConnector lc, InterPacket packet)
        {
            string name = "";

            if (!packet.TryReadString(out name, 16))
            {
                throw new InvalidPacketException();
            }

            if (!ClientManager.Instance.HasClient(name))
            {
                return;
            }
            var client = ClientManager.Instance.GetClientByCharName(name);
            var group  = GroupManager.Instance.GetGroupForCharacter(client.Character.ID);

            group.RemoveMember(name);
        }
Ejemplo n.º 19
0
        public static void HandleTransfer(WorldConnector lc, InterPacket packet)
        {
            byte v;

            if (!packet.TryReadByte(out v))
            {
                return;
            }

            if (v == 0)
            {
                byte   admin;
                int    accountid, CharID;
                string username, hash, hostip;
                if (!packet.TryReadInt(out accountid) || !packet.TryReadString(out username) ||
                    !packet.TryReadInt(out CharID) || !packet.TryReadString(out hash) ||
                    !packet.TryReadByte(out admin) || !packet.TryReadString(out hostip))
                {
                    return;
                }

                var ct = new ClientTransfer(accountid, username, CharID, admin, hostip, hash);
                ClientManager.Instance.AddTransfer(ct);
            }
            else if (v == 1)
            {
                byte   admin;
                int    accountid, CharID;
                string username, charname, hostip;
                ushort randid;
                if (!packet.TryReadInt(out accountid) || !packet.TryReadString(out username) ||
                    !packet.TryReadString(out charname) || !packet.TryReadInt(out CharID) ||
                    !packet.TryReadUShort(out randid) || !packet.TryReadByte(out admin) ||
                    !packet.TryReadString(out hostip))
                {
                    return;
                }

                var ct = new ClientTransfer(accountid, username, charname, CharID, randid, admin, hostip);
                ClientManager.Instance.AddTransfer(ct);
            }
        }
Ejemplo n.º 20
0
        public static void On_WorldClient_AcademyBuffUpdate(WorldConnector pConnector, InterPacket pPacket)
        {
            int guildID;
            DateTime updateTime;
            double keepTime;
            if (!pPacket.TryReadInt(out guildID)
                || !pPacket.TryReadDateTime(out updateTime)
                || !pPacket.TryReadDouble(out keepTime))
            {
                //Client.Dispose();
                return;
            }

            Guild guild;
            if (GuildManager.GetGuildByID(guildID, out guild))
            {
                guild.Academy.GuildBuffUpdateTime = updateTime;
                guild.Academy.GuildBuffKeepTime = TimeSpan.FromSeconds(keepTime);
            }
        }
Ejemplo n.º 21
0
        public static void AddRewardItem(WorldConnector pConnector, InterPacket pPacket)
        {
            byte count;
            ushort ItemID;
            string Charname;
            if (!pPacket.TryReadUShort(out ItemID))
                return;

            if (!pPacket.TryReadByte(out count))
                return;

            if(!pPacket.TryReadString(out Charname,16))
                return;

             ZoneClient pClient =  ClientManager.Instance.GetClientByName(Charname);
            if(pClient == null)
                return;

            pClient.Character.GiveMasterRewardItem(ItemID, count);
        }
Ejemplo n.º 22
0
        public static void HandleAssigned(WorldConnector lc, InterPacket packet)
        {
            string name;
            byte   id;
            ushort port;
            int    mapidcout;

            if (!packet.TryReadByte(out id) || !packet.TryReadString(out name) ||
                !packet.TryReadUShort(out port) || !packet.TryReadInt(out mapidcout))
            {
                return;
            }

            Program.ServiceInfo = new ZoneData
            {
                ID         = id,
                Port       = port,
                MapsToLoad = new List <MapInfo>()
            };

            for (var i = 0; i < mapidcout; i++)
            {
                ushort mapid, viewrange;
                string shortname, fullname;
                int    regenx, regeny;
                byte   kingdom;
                if (!packet.TryReadUShort(out mapid) || !packet.TryReadString(out shortname) ||
                    !packet.TryReadString(out fullname) || !packet.TryReadInt(out regenx) ||
                    !packet.TryReadInt(out regeny) || !packet.TryReadByte(out kingdom) ||
                    !packet.TryReadUShort(out viewrange))
                {
                    break;
                }

                Program.ServiceInfo.MapsToLoad.Add(new MapInfo(mapid, shortname, fullname, regenx, regeny, kingdom,
                                                               viewrange));
            }

            Log.WriteLine(LogLevel.Info, "Successfully linked with worldserver. [Zone: {0} | Port: {1}]", id, port);
            ZoneAcceptor.Load();
        }
Ejemplo n.º 23
0
        public static void HandleAssigned(WorldConnector lc, InterPacket packet)
        {
            string name;
            byte id;
            ushort port;
            int mapidcout;
            if (!packet.TryReadByte(out id) || !packet.TryReadString(out name) ||
                !packet.TryReadUShort(out port) || !packet.TryReadInt(out mapidcout))
            {
                return;
            }

            Program.ServiceInfo = new ZoneData
            {

                ID = id,
                Port = port,
                MapsToLoad = new List<FiestaLib.Data.MapInfo>()
            };

            for (int i = 0; i < mapidcout; i++)
            {
                ushort mapid, viewrange;
                string shortname, fullname;
                int regenx, regeny;
                byte kingdom;
                if (!packet.TryReadUShort(out mapid) || !packet.TryReadString(out shortname) || !packet.TryReadString(out fullname) || !packet.TryReadInt(out regenx) || !packet.TryReadInt(out regeny) || !packet.TryReadByte(out kingdom) || !packet.TryReadUShort(out viewrange))
                {
                    break;
                }
                Program.ServiceInfo.MapsToLoad.Add(new MapInfo(mapid, shortname, fullname, regenx, regeny, kingdom, viewrange));
            }

            Log.WriteLine(LogLevel.Info, "Successfully linked with worldserver. [Zone: {0} | Port: {1}]", id, port);
            ZoneAcceptor.Load();
        }
Ejemplo n.º 24
0
        public static void HandleZoneOpened(WorldConnector lc, InterPacket packet)
        {
            byte id;
            string ip;
            ushort port;
            int mapcount;
            if (!packet.TryReadByte(out id) || !packet.TryReadString(out ip) || !packet.TryReadUShort(out port) || !packet.TryReadInt(out mapcount))
            {
                return;
            }

            List<MapInfo> maps = new List<MapInfo>();
            for (int j = 0; j < mapcount; j++)
            {
                ushort mapid, viewrange;
                string shortname, fullname;
                int regenx, regeny;
                byte kingdom;
                if (!packet.TryReadUShort(out mapid) || !packet.TryReadString(out shortname) || !packet.TryReadString(out fullname) || !packet.TryReadInt(out regenx) || !packet.TryReadInt(out regeny) || !packet.TryReadByte(out kingdom) || !packet.TryReadUShort(out viewrange))
                {
                    break;
                }
                maps.Add(new MapInfo(mapid, shortname, fullname, regenx, regeny, kingdom, viewrange));
            }

            ZoneData zd;
            if (!Program.Zones.TryGetValue(id, out zd))
            {
                zd = new ZoneData();
            }
            zd.ID = id;
            zd.IP = ip;
            zd.Port = port;
            zd.MapsToLoad = maps;
            Program.Zones[id] = zd;
            Log.WriteLine(LogLevel.Info, "Added zone {0} to zonelist. {1}:{2}", zd.ID, zd.IP, zd.Port);
        }
Ejemplo n.º 25
0
 public static void HandleZoneClosed(WorldConnector lc, InterPacket packet)
 {
     byte id;
     if (!packet.TryReadByte(out id))
     {
         return;
     }
     ZoneData zd;
     if (Program.Zones.TryRemove(id, out zd))
     {
         Log.WriteLine(LogLevel.Info, "Removed zone {0} from zones (disconnected)", id);
     }
 }
Ejemplo n.º 26
0
 public static void NewGroupCreated(WorldConnector pConnector, InterPacket pPacket)
 {
     long groupId = -1;
     if (!pPacket.TryReadLong(out groupId))
     {
         throw new InvalidPacketException();
     }
     GroupManager.Instance.NewGroupCreated(groupId);
 }
Ejemplo n.º 27
0
 public static void NewPartyCreated(WorldConnector lc, InterPacket packet)
 {
     long id;
     if (!packet.TryReadLong(out id))
     {
         throw new InvalidPacketException();
     }
     GroupManager.Instance.NewGroupCreated(id);
 }
Ejemplo n.º 28
0
        public static void RemovePartyMember(WorldConnector lc, InterPacket packet)
        {
            string name = "";
            if (!packet.TryReadString(out name, 16))
            {
                throw new InvalidPacketException();
            }

            if (!ClientManager.Instance.HasClient(name))
                return;
            var client = ClientManager.Instance.GetClientByCharName(name);
            var group = GroupManager.Instance.GetGroupForCharacter(client.Character.ID);
            group.RemoveMember(name);
        }
Ejemplo n.º 29
0
 public static void TryAssiging(WorldConnector lc)
 {
     using (var p = new InterPacket(InterHeader.Assign))
     {
         p.WriteStringLen(Settings.Instance.IP);
         lc.SendPacket(p);
     }
 }
Ejemplo n.º 30
0
 public static void FunctionAnswer(WorldConnector pConnector, InterPacket pPacket)
 {
     long id;
     if(!pPacket.TryReadLong(out id))
         throw new InvalidPacketException();
     object result = InterFunctionCallbackProvider.Instance.GetReadFunc(id)(pPacket);
     InterFunctionCallbackProvider.Instance.OnResult(id, result);
 }
Ejemplo n.º 31
0
 public static void GroupBrokeUp(WorldConnector lc, InterPacket packet)
 {
     long groupId;
     if(!packet.TryReadLong(out groupId))
         return;
     GroupManager.Instance.GroupBrokeUp(groupId);
 }
Ejemplo n.º 32
0
        public static void HandleTransfer(WorldConnector lc, InterPacket packet)
        {
            byte v;
            if (!packet.TryReadByte(out v))
            {
                return;
            }

            if (v == 0)
            {
                byte admin;
                int accountid, CharID;
                string username, hash, hostip;
                if (!packet.TryReadInt(out accountid) || !packet.TryReadString(out username) || !packet.TryReadInt(out CharID)|| !packet.TryReadString(out hash) || !packet.TryReadByte(out admin) || !packet.TryReadString(out hostip))
                {
                    return;
                }
                ClientTransfer ct = new ClientTransfer(accountid, username,CharID, admin, hostip, hash);
                ClientManager.Instance.AddTransfer(ct);
            }
            else if (v == 1)
            {
                byte admin;
                int accountid,CharID;
                string username, charname, hostip;
                ushort randid;
                if (!packet.TryReadInt(out accountid) || !packet.TryReadString(out username) || !packet.TryReadString(out charname) || !packet.TryReadInt(out CharID) ||
                    !packet.TryReadUShort(out randid) || !packet.TryReadByte(out admin) || !packet.TryReadString(out hostip))
                {
                    return;
                }
                ClientTransfer ct = new ClientTransfer(accountid, username, charname,CharID, randid, admin, hostip);
                ClientManager.Instance.AddTransfer(ct);
            }
        }
Ejemplo n.º 33
0
 public static void ChangeMoney(WorldConnector pConnector, InterPacket pPacket)
 {
     int CharID;
     long NewMoney;
     if (!pPacket.TryReadInt(out CharID))
         return;
     if (!pPacket.TryReadLong(out NewMoney))
         return;
     ZoneClient pClient = ClientManager.Instance.GetClientByCharID(CharID);
     if (pClient == null)
         return;
     pClient.Character.ChangeMoney(NewMoney);
 }
Ejemplo n.º 34
0
        public static void On_WorldClient_AcademyMemberOnline(WorldConnector pConnector, InterPacket pPacket)
        {
            int guildID, characterID;
            if (!pPacket.TryReadInt(out guildID)
                || !pPacket.TryReadInt(out characterID))
            {
                return;
            }

            Guild guild;
            if (GuildManager.GetGuildByID(guildID, out guild))
            {
                GuildAcademyMember member;
                if (guild.Academy.GetMember(characterID, out member))
                {
                    member.IsOnline = true;

                    ZoneCharacter character;
                    if (CharacterManager.GetLoggedInCharacter(characterID, out character))
                    {
                        character.Guild = guild;
                        character.GuildAcademy = guild.Academy;
                        character.GuildAcademyMember = member;

                        member.Character = character;
                    }
                }
            }
        }