Пример #1
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);
            }
        }
Пример #2
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);
                    }
                }
            }
        }
Пример #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);
                }
            }
        }
Пример #4
0
        public static void HandleTransfer(WorldConnector lc, InterPacket packet)
        {
            byte v;
            if (!packet.TryReadByte(out v))
            {
                return;
            }

            if (v == 0)
            {
                byte admin;
                int accountid;
                string username, hash, hostip;
                if (!packet.TryReadInt(out accountid) || !packet.TryReadString(out username) || !packet.TryReadString(out hash) || !packet.TryReadByte(out admin) || !packet.TryReadString(out hostip))
                {
                    return;
                }
                ClientTransfer ct = new ClientTransfer(accountid, username, admin, hostip, hash);
                ClientManager.Instance.AddTransfer(ct);
            }
            else if (v == 1)
            {
                byte admin;
                int accountid;
                string username, charname, hostip;
                ushort randid;
                if (!packet.TryReadInt(out accountid) || !packet.TryReadString(out username) || !packet.TryReadString(out charname) ||
                    !packet.TryReadUShort(out randid) || !packet.TryReadByte(out admin) || !packet.TryReadString(out hostip))
                {
                    return;
                }
                ClientTransfer ct = new ClientTransfer(accountid, username, charname, randid, admin, hostip);
                ClientManager.Instance.AddTransfer(ct);
            }
        }
Пример #5
0
 public static void TryAssiging(WorldConnector lc)
 {
     using (var p = new InterPacket(InterHeader.ASSIGN))
     {
         p.WriteStringLen(Settings.Instance.IP);
         lc.SendPacket(p);
     }
 }
Пример #6
0
 public static bool Load(string ip, int port)
 {
     try
     {
         Instance = new WorldConnector(ip, port);
         return true;
     }
     catch { return false; }
 }
Пример #7
0
 public static bool Load(string ip, int port)
 {
     try
     {
         Instance = new WorldConnector(ip, port);
         return(true);
     }
     catch { return(false); }
 }
Пример #8
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);
 }
Пример #9
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);
            }
        }
Пример #10
0
        public static void HandleZoneList(WorldConnector lc, InterPacket packet)
        {
            int amount;

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

            for (int 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 (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);
            }
        }
Пример #11
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);
            }
        }
Пример #12
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);
        }
Пример #13
0
        public static void HandleAssigned(WorldConnector lc, InterPacket packet)
        {
            string entity, name;
            byte   id;
            ushort port;
            int    mapidcout;

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

            Program.serviceInfo = new ZoneData
            {
                EntityString = entity,
                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));;
            }

            Console.Title = "Zepheus.Zone[" + id + "]";
            Log.WriteLine(LogLevel.Info, "Successfully linked with worldserver. [Zone: {0} | Port: {1}]", id, port);
            ZoneAcceptor.Load();
        }
Пример #14
0
        public static void HandleAssigned(WorldConnector lc, InterPacket packet)
        {
            string entity, name;
            byte id;
            ushort port;
            int mapidcout;
            if (!packet.TryReadString(out entity) || !packet.TryReadByte(out id) || !packet.TryReadString(out name) ||
                !packet.TryReadUShort(out port) || !packet.TryReadInt(out mapidcout))
            {
                return;
            }

            Program.serviceInfo = new ZoneData
            {
                EntityString = entity,
                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)); ;
            }

            Console.Title = "Zepheus.Zone[" + id + "]";
            Log.WriteLine(LogLevel.Info, "Successfully linked with worldserver. [Zone: {0} | Port: {1}]", id, port);
            ZoneAcceptor.Load();
        }
Пример #15
0
        public static void HandleTransfer(WorldConnector lc, InterPacket packet)
        {
            byte v;

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

            if (v == 0)
            {
                byte   admin;
                int    accountid;
                string username, hash, hostip;
                if (!packet.TryReadInt(out accountid) || !packet.TryReadString(out username) || !packet.TryReadString(out hash) || !packet.TryReadByte(out admin) || !packet.TryReadString(out hostip))
                {
                    return;
                }
                ClientTransfer ct = new ClientTransfer(accountid, username, admin, hostip, hash);
                ClientManager.Instance.AddTransfer(ct);
            }
            else if (v == 1)
            {
                byte   admin;
                int    accountid;
                string username, charname, hostip;
                ushort randid;
                if (!packet.TryReadInt(out accountid) || !packet.TryReadString(out username) || !packet.TryReadString(out charname) ||
                    !packet.TryReadUShort(out randid) || !packet.TryReadByte(out admin) || !packet.TryReadString(out hostip))
                {
                    return;
                }
                ClientTransfer ct = new ClientTransfer(accountid, username, charname, randid, admin, hostip);
                ClientManager.Instance.AddTransfer(ct);
            }
        }
Пример #16
0
        public static void On_InterClient_GuildCreated(WorldConnector pConnector, InterPacket pPacket)
        {
            int guildID, characterID;
            if (!pPacket.TryReadInt(out guildID)
                || !pPacket.TryReadInt(out characterID))
            {
                return;
            }

            Guild guild;
            if (GetGuildByID(guildID, out guild))
            {
                //check if character is on local zone, if so assign guild to him
                ZoneCharacter character;
                if (CharacterManager.GetLoggedInCharacter(characterID, out character))
                {
                    character.Guild = guild;
                    character.GuildAcademy = guild.Academy;

                    GuildMember member;
                    if (guild.GetMember(characterID, out member))
                    {
                        member.Character = character;
                        character.GuildMember = member;
                    }
                }
            }
        }
Пример #17
0
 public static void NewPartyCreated(WorldConnector lc, InterPacket packet)
 {
     long id;
     if (!packet.TryReadLong(out id))
     {
         throw new InvalidPacketException();
     }
     GroupManager.Instance.NewGroupCreated(id);
 }
Пример #18
0
 public static void NewGroupCreated(WorldConnector pConnector, InterPacket pPacket)
 {
     long groupId = -1;
     if (!pPacket.TryReadLong(out groupId))
     {
         throw new InvalidPacketException();
     }
     GroupManager.Instance.NewGroupCreated(groupId);
 }
Пример #19
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);
        }
Пример #20
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);
     }
 }
Пример #21
0
        public static void On_InterClient_GuildMemberAdd(WorldConnector pConnector, InterPacket pPacket)
        {
            int guildID, characterID;
            byte rank;
            ushort corp;
            if (!pPacket.TryReadInt(out guildID)
                || !pPacket.TryReadInt(out characterID)
                || !pPacket.TryReadByte(out rank)
                || !pPacket.TryReadUShort(out corp))
            {
                return;
            }

            Guild guild;
            if (GetGuildByID(guildID, out guild))
            {
                lock (guild.ThreadLocker)
                {
                    //create member
                    var member = new GuildMember(guild, characterID, (GuildRank)rank, corp)
                    {
                        IsOnline = true,
                    };

                    guild.Members.Add(member);

                    //check if member is on this zone, if so assign guild to him
                    ZoneCharacter character;
                    if (CharacterManager.GetLoggedInCharacter(characterID, out character))
                    {
                        character.Guild = guild;
                        character.GuildAcademy = guild.Academy;
                        character.GuildMember = member;

                        member.Character = character;

                        SetGuildBuff(character);
                    }
                }
            }
        }
Пример #22
0
        public static void On_InterClient_GuildMessageUpdate(WorldConnector pConnector, InterPacket pPacket)
        {
            int guildID, characterID;
            DateTime createTime;
            ushort length;
            string message;
            if (!pPacket.TryReadInt(out guildID)
                || !pPacket.TryReadInt(out characterID)
                || !pPacket.TryReadDateTime(out createTime)
                || !pPacket.TryReadUShort(out length)
                || !pPacket.TryReadString(out message, length))
            {
                return;
            }

            Guild guild;
            if (GetGuildByID(guildID, out guild))
            {
                //update guild
                guild.Message = message;
                guild.MessageCreateTime = createTime;
                guild.MessageCreaterID = characterID;
            }
        }
Пример #23
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);
 }
Пример #24
0
        public static void On_InterClient_GuildMemberLogin(WorldConnector pConnector, InterPacket pPacket)
        {
            int guildID, characterID;
            if (!pPacket.TryReadInt(out guildID)
                || !pPacket.TryReadInt(out characterID))
            {
                return;
            }

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

                    ZoneCharacter character;
                    if (CharacterManager.GetLoggedInCharacter(characterID, out character))
                    {
                        character.Guild = guild;
                        character.GuildAcademy = guild.Academy;
                        character.GuildMember = member;
                        member.Character = character;
                    }
                }
            }
        }
Пример #25
0
        public static void On_InterClient_GuildMemberLogout(WorldConnector pConnector, InterPacket pPacket)
        {
            int guildID, characterID;
            if (!pPacket.TryReadInt(out guildID)
                || !pPacket.TryReadInt(out characterID))
            {

                return;
            }

            Guild guild;
            if (GetGuildByID(guildID, out guild))
            {
                GuildMember member;
                if (guild.GetMember(characterID, out member))
                {
                    member.Character = null;
                    member.IsOnline = false;
                }
            }
        }
Пример #26
0
        public static void On_InterClient_GuildMemberRankUpdate(WorldConnector pConnector, InterPacket pPacket)
        {
            int guildID, characterID;
            byte newRank;
            if (!pPacket.TryReadInt(out guildID)
                || !pPacket.TryReadInt(out characterID)
                || !pPacket.TryReadByte(out newRank))
            {
                return;
            }

            Guild guild;
            if (GetGuildByID(guildID, out guild))
            {
                lock (guild.ThreadLocker)
                {
                    GuildMember member;
                    if (guild.GetMember(characterID, out member))
                    {
                        member.Rank = (GuildRank)newRank;
                    }
                }
            }
        }
Пример #27
0
        public static void On_InterClient_GuildMemberRemove(WorldConnector pConnector, InterPacket pPacket)
        {
            int guildID, characterID;
            if (!pPacket.TryReadInt(out guildID)
                || !pPacket.TryReadInt(out characterID))
            {
                return;
            }

            Guild guild;
            if (GetGuildByID(guildID, out guild))
            {
                lock (guild.ThreadLocker)
                {
                    GuildMember member;
                    if (guild.GetMember(characterID, out member))
                    {
                        //remove member and clean up
                        guild.Members.Remove(member);

                        member.Dispose();

                        //check if member is on this zone
                        ZoneCharacter character;
                        if (CharacterManager.GetLoggedInCharacter(characterID, out character))
                        {
                            character.Guild = null;
                            character.GuildAcademy = null;
                            character.GuildMember = null;

                            RemoveGuildBuff(character);
                        }
                    }
                }
            }
        }
Пример #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);
        }
Пример #29
0
 public static void TryAssiging(WorldConnector lc)
 {
     using (var p = new InterPacket(InterHeader.Assign))
     {
         p.WriteStringLen(Settings.Instance.IP);
         lc.SendPacket(p);
     }
 }
Пример #30
0
 public static void GroupBrokeUp(WorldConnector lc, InterPacket packet)
 {
     long groupId;
     if(!packet.TryReadLong(out groupId))
         return;
     GroupManager.Instance.GroupBrokeUp(groupId);
 }
Пример #31
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);
 }
Пример #32
0
        public static void On_WorldClient_AcademyMemberOffline(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 = false;

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

                        member.Character = null;
                    }
                }
            }
        }