コード例 #1
0
        public static void HandleClientTransferZone(ZoneConnection zc, InterPacket packet)
        {
            byte   admin, zoneid;
            int    accountid, CharID;
            string username, charname, hostip;
            ushort randid, mapid;

            if (!packet.TryReadByte(out zoneid) || !packet.TryReadInt(out accountid) ||
                !packet.TryReadUShort(out mapid) || !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;
            }

            if (Program.Zones.ContainsKey(zoneid))
            {
                ZoneConnection z;
                if (Program.Zones.TryGetValue(zoneid, out z))
                {
                    z.SendTransferClientFromZone(accountid, username, charname, CharID, randid, admin, hostip);
                }
            }
            else
            {
                Log.WriteLine(LogLevel.Warn, "Uh oh, Zone {0} tried to transfer {1} to zone {1} D:", zc.ID, charname,
                              zoneid);
            }
        }
コード例 #2
0
        public static void ChangeZoneBeginn(ZoneConnection zc, InterPacket packet)
        {
            ushort mapid,randomid,port;
            string charname,ip;
            int x,y;
            if(!packet.TryReadUShort(out mapid))
                return;
            if(!packet.TryReadInt(out x))
                return;
            if(!packet.TryReadInt(out y))
                return;
            if(!packet.TryReadString(out charname,16))
                return;
            if(!packet.TryReadString(out ip,16))
                return;
            if(!packet.TryReadUShort(out port))
                return;
            if(!packet.TryReadUShort(out randomid))
                return;

            WorldClient client = ClientManager.Instance.GetClientByCharname(charname);
            if(client == null)
                return;
            int oldmap = client.Character.Character.PositionInfo.Map;
            client.Character.Character.PositionInfo.Map = mapid;
            client.Character.Character.PositionInfo.XPos = x;
            client.Character.Character.PositionInfo.YPos = y;
            Managers.CharacterManager.InvokeChangeMapEvent(client.Character);
            client.Character.ChangeFrendMap(DataProvider.GetMapname(mapid));//setup later to event
        }
コード例 #3
0
        public static void SendZoneList(ZoneConnection zc)
        {
            using (var packet = new InterPacket(InterHeader.Zonelist))
            {
                packet.Write(Program.Zones.Values.Count);
                foreach (var z in Program.Zones.Values)
                {
                    packet.Write(z.ID);
                    packet.Write(z.IP);
                    packet.Write(z.Port);
                    packet.WriteInt(z.Maps.Count);
                    foreach (var m in z.Maps)
                    {
                        packet.WriteUShort(m.ID);
                        packet.WriteStringLen(m.ShortName);
                        packet.WriteStringLen(m.FullName);
                        packet.WriteInt(m.RegenX);
                        packet.WriteInt(m.RegenY);
                        packet.WriteByte(m.Kingdom);
                        packet.WriteUShort(m.ViewRange);
                    }
                }

                zc.SendPacket(packet);
            }
        }
コード例 #4
0
        public static void ReciveCoper(ZoneConnection zc, InterPacket packet)
        {
            string charname;
            long   coper;
            bool   typ;

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

            if (!packet.TryReadLong(out coper))
            {
                return;
            }
            if (!packet.TryReadBool(out typ))
            {
                return;
            }

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

            if (typ)
            {
                pClient.Character.Character.ReviveCoper += coper;
            }
            else
            {
                pClient.Character.RecviveCoperMaster += coper;
                pClient.Character.UpdateRecviveCoper();
            }
        }
コード例 #5
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);
     }
 }
コード例 #6
0
 public static void SendAddReward(ZoneConnection ZC, ushort itemID, byte count, string CharName)
 {
     using (var packet = new InterPacket(InterHeader.SendAddRewardItem))
     {
         packet.WriteUShort(itemID);
         packet.WriteByte(count);
         packet.WriteString(CharName, 16);
         ZC.SendPacket(packet);
     }
 }
コード例 #7
0
        public static void SendGetCharacterBroaucast(WorldCharacter pChar, FiestaLib.Networking.Packet pPacket)
        {
            ZoneConnection conn = Program.GetZoneByMap(pChar.Character.PositionInfo.Map);

            using (var packet = new InterPacket(InterHeader.GetBroadcastList))
            {
                packet.WriteString(pChar.Character.Name, 16);
                packet.WriteInt(pPacket.ToNormalArray().Length);
                packet.WriteBytes(pPacket.ToNormalArray());
                conn.SendPacket(packet);
            }
        }
コード例 #8
0
        public static void DisconnectFromzoneserver(ZoneConnection zc, InterPacket packet)
        {
            string charname;
            if (packet.TryReadString(out charname,16))
            {
              WorldClient client =  ClientManager.Instance.GetClientByCharname(charname);
              if (client == null)
                  return;

              client.Character.Loggeout(client);
              ClientManager.Instance.RemoveClient(client);
            }
        }
コード例 #9
0
        public static void SendChangeMap(WorldCharacter pChar, int OldMap)
        {
            Managers.CharacterManager.InvokeChangeMapEvent(pChar);
            ZoneConnection conn = Program.GetZoneByMap(OldMap);

            using (var packet = new InterPacket(InterHeader.GetBroadcastList))
            {
                packet.WriteString(pChar.Character.Name, 16);
                packet.WriteInt(pChar.Character.PositionInfo.XPos);
                packet.WriteInt(pChar.Character.PositionInfo.YPos);
                conn.SendPacket(packet);
            }
        }
コード例 #10
0
        public static void UpdateMoneyInWorld(ZoneConnection lc, InterPacket packet)
        {
            string charname = string.Empty;
            long   NewMoney = 0;

            if (!packet.TryReadString(out charname, 16) || !packet.TryReadLong(out NewMoney))
            {
                return;
            }
            WorldCharacter Pchar = ClientManager.Instance.GetClientByCharname(charname).Character;

            Pchar.Character.Money = NewMoney;
        }
コード例 #11
0
        public static void ChangeZoneBeginn(ZoneConnection zc, InterPacket packet)
        {
            ushort mapid, randomid, port;
            string charname, ip;
            int    x, y;

            if (!packet.TryReadUShort(out mapid))
            {
                return;
            }
            if (!packet.TryReadInt(out x))
            {
                return;
            }
            if (!packet.TryReadInt(out y))
            {
                return;
            }
            if (!packet.TryReadString(out charname, 16))
            {
                return;
            }
            if (!packet.TryReadString(out ip, 16))
            {
                return;
            }
            if (!packet.TryReadUShort(out port))
            {
                return;
            }
            if (!packet.TryReadUShort(out randomid))
            {
                return;
            }

            var client = ClientManager.Instance.GetClientByCharname(charname);

            if (client == null)
            {
                return;
            }
            int oldmap = client.Character.Character.PositionInfo.Map;

            client.Character.Character.PositionInfo.Map  = mapid;
            client.Character.Character.PositionInfo.XPos = x;
            client.Character.Character.PositionInfo.YPos = y;
            CharacterManager.InvokeChangeMapEvent(client.Character);
            client.Character.ChangeFrendMap(DataProvider.GetMapname(mapid)); //setup later to event
        }
コード例 #12
0
        public static void FunctionGetCharacterOnline(ZoneConnection pConnection, InterPacket pPacket)
        {
            long id;
            string charName;

            if(!pPacket.TryReadLong(out id) ||!pPacket.TryReadString(out charName, 16))
                throw new InvalidPacketException();

            bool isOnline = ClientManager.Instance.IsOnline(charName);
            using (InterPacket packet = new InterPacket(InterHeader.FunctionAnswer))
            {
                packet.WriteLong(id);
                packet.WriteBool(isOnline);
                pConnection.SendPacket(packet);
            }
        }
コード例 #13
0
        public static void HandleAssigning(ZoneConnection lc, InterPacket packet)
        {
            string ip;

            if (!packet.TryReadString(out ip))
            {
                return;
            }

            lc.IP = ip;

            // make idlist
            SendZoneStarted(lc.ID, lc.IP, lc.Port, lc.Maps);
            SendZoneList(lc);
            Log.WriteLine(LogLevel.Info, "Zone {0} listens @ {1}:{2}", lc.ID, lc.IP, lc.Port);
        }
コード例 #14
0
        public static void DisconnectFromzoneserver(ZoneConnection zc, InterPacket packet)
        {
            string charname;

            if (packet.TryReadString(out charname, 16))
            {
                var client = ClientManager.Instance.GetClientByCharname(charname);
                if (client == null)
                {
                    return;
                }

                client.Character.Loggeout(client);
                ClientManager.Instance.RemoveClient(client);
            }
        }
コード例 #15
0
 public static void BanAccount(ZoneConnection zc, InterPacket packet)
 {
     string playername;
       if (packet.TryReadString(out playername, 16))
       {
           WorldClient bannclient = ClientManager.Instance.GetClientByCharname(playername);
           if (bannclient != null)
           {
               using (var p = new InterPacket(InterHeader.BanAccount))
               {
                   p.WriteInt(bannclient.AccountID);
                   LoginConnector.Instance.SendPacket(p);
               }
               bannclient.Disconnect();
           }
       }
 }
コード例 #16
0
        public static void BanAccount(ZoneConnection zc, InterPacket packet)
        {
            string playername;

            if (packet.TryReadString(out playername, 16))
            {
                WorldClient bannclient = ClientManager.Instance.GetClientByCharname(playername);
                if (bannclient != null)
                {
                    using (var p = new InterPacket(InterHeader.BanAccount))
                    {
                        p.WriteInt(bannclient.AccountID);
                        LoginConnector.Instance.SendPacket(p);
                    }
                    bannclient.Disconnect();
                }
            }
        }
コード例 #17
0
        public static void UpdateLevel(ZoneConnection pConnection, InterPacket pPacket)
        {
            byte   level;
            string Charname;

            if (!pPacket.TryReadByte(out level) || !pPacket.TryReadString(out Charname, 16))
            {
                return;
            }
            var pClient = ClientManager.Instance.GetClientByCharname(Charname);

            if (pClient == null)
            {
                return;
            }
            pClient.Character.Character.CharLevel = level;
            CharacterManager.invokeLevelUp(pClient.Character);
        }
コード例 #18
0
        public static void FunctionGetCharacterOnline(ZoneConnection pConnection, InterPacket pPacket)
        {
            long   id;
            string charName;

            if (!pPacket.TryReadLong(out id) || !pPacket.TryReadString(out charName, 16))
            {
                throw new InvalidPacketException();
            }

            var isOnline = ClientManager.Instance.IsOnline(charName);

            using (var packet = new InterPacket(InterHeader.FunctionAnswer))
            {
                packet.WriteLong(id);
                packet.WriteBool(isOnline);
                pConnection.SendPacket(packet);
            }
        }
コード例 #19
0
        public static void HandleWorldMessage(ZoneConnection zc, InterPacket packet)
        {
            string msg;
            bool   wut;
            byte   type;

            if (!packet.TryReadString(out msg) || !packet.TryReadByte(out type) || !packet.TryReadBool(out wut))
            {
                return;
            }

            if (wut)
            {
                string to;
                if (!packet.TryReadString(out to))
                {
                    return;
                }

                WorldClient client;
                if ((client = ClientManager.Instance.GetClientByCharname(to)) == null)
                {
                    Log.WriteLine(LogLevel.Warn,
                                  "Tried to send a WorldMessage to a character that is unknown. Charname: {0}", to);
                }
                else
                {
                    using (var p = Handler25.CreateWorldMessage((WorldMessageTypes)type, msg))
                    {
                        client.SendPacket(p);
                    }
                }
            }
            else
            {
                using (var p = Handler25.CreateWorldMessage((WorldMessageTypes)type, msg))
                {
                    ClientManager.Instance.SendPacketToAll(p);
                }
            }
        }
コード例 #20
0
        public static void GetList(ZoneConnection pConnection, InterPacket pPacket)
        {
            int count, packetlenght;

            byte[] SendPacket;

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

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

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

            for (var i = 0; i < count; i++)
            {
                string charname;
                if (!pPacket.TryReadString(out charname, 16))
                {
                    return;
                }
                var client = ClientManager.Instance.GetClientByCharname(charname);
                if (client != null)
                {
                    using (var packet = new Packet())
                    {
                        packet.WriteBytes(SendPacket);
                        client.SendPacket(packet);
                        Log.WriteLine(LogLevel.Debug, "Send borcast to {0}", charname);
                    }
                }
            }
        }
コード例 #21
0
        public static void HandleAssigning(ZoneConnection lc, InterPacket packet)
        {
            string ip;
            if (!packet.TryReadString(out ip))
            {
                return;
            }

            lc.IP = ip;

            // make idlist
            InterHandler.SendZoneStarted(lc.ID, lc.IP, lc.Port, lc.Maps);
            InterHandler.SendZoneList(lc);
            Log.WriteLine(LogLevel.Info, "Zone {0} listens @ {1}:{2}", lc.ID, lc.IP, lc.Port);
        }
コード例 #22
0
        public static void HandleClientTransferZone(ZoneConnection zc, InterPacket packet)
        {
            byte admin, zoneid;
            int accountid,CharID;
            string username, charname, hostip;
            ushort randid, mapid;
            if (!packet.TryReadByte(out zoneid) || !packet.TryReadInt(out accountid) || !packet.TryReadUShort(out mapid) || !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;
            }
            if (Program.Zones.ContainsKey(zoneid))
            {
                ZoneConnection z;
                if (Program.Zones.TryGetValue(zoneid, out z))
                {
                    z.SendTransferClientFromZone(accountid, username, charname,CharID, randid, admin, hostip);

                }
            }
            else
            {
                Log.WriteLine(LogLevel.Warn, "Uh oh, Zone {0} tried to transfer {1} to zone {1} D:", zc.ID, charname, zoneid);
            }
        }
コード例 #23
0
 public static void UpdateLevel(ZoneConnection pConnection, InterPacket pPacket)
 {
     byte level;
     string Charname;
     if (!pPacket.TryReadByte(out level) || !pPacket.TryReadString(out Charname, 16))
         return;
     WorldClient pClient = ClientManager.Instance.GetClientByCharname(Charname);
     if(pClient == null)
         return;
     pClient.Character.Character.CharLevel = level;
     Managers.CharacterManager.invokeLevelUp(pClient.Character);
 }
コード例 #24
0
 public static void UpdateMoneyInWorld(ZoneConnection lc, InterPacket packet)
 {
     string charname = string.Empty;
      long NewMoney = 0;
      if(!packet.TryReadString(out charname,16) || !packet.TryReadLong(out NewMoney))
      {
          return;
      }
     WorldCharacter Pchar = ClientManager.Instance.GetClientByCharname(charname).Character;
     Pchar.Character.Money = NewMoney;
 }
コード例 #25
0
 private void WorldAcceptor_OnIncommingConnection(Socket session)
 {
     // So something with it X:
     Log.WriteLine(LogLevel.Info, "Incoming connection from {0}", session.RemoteEndPoint);
     var wc = new ZoneConnection(session);
 }
コード例 #26
0
        public static void GetList(ZoneConnection pConnection, InterPacket pPacket)
        {
            int count, packetlenght;
            byte[] SendPacket;

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

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

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

            for (int i = 0; i < count; i++)
            {
                string charname;
                if(!pPacket.TryReadString(out charname,16))
                return;
               WorldClient client=  ClientManager.Instance.GetClientByCharname(charname);
                if(client !=null)
                using (var packet = new FiestaLib.Networking.Packet())
                {
                    packet.WriteBytes(SendPacket);
                    client.SendPacket(packet);
                    Log.WriteLine(LogLevel.Debug, "Send borcast to {0}", charname);
                }
            }
        }
コード例 #27
0
 public static void SendZoneList(ZoneConnection zc)
 {
     using (var packet = new InterPacket(InterHeader.Zonelist))
     {
         packet.Write(Program.Zones.Values.Count);
         foreach (var z in Program.Zones.Values)
         {
             packet.Write(z.ID);
             packet.Write(z.IP);
             packet.Write(z.Port);
             packet.WriteInt(z.Maps.Count);
             foreach (var m in z.Maps)
             {
                 packet.WriteUShort(m.ID);
                 packet.WriteStringLen(m.ShortName);
                 packet.WriteStringLen(m.FullName);
                 packet.WriteInt(m.RegenX);
                 packet.WriteInt(m.RegenY);
                 packet.WriteByte(m.Kingdom);
                 packet.WriteUShort(m.ViewRange);
             }
         }
         zc.SendPacket(packet);
     }
 }
コード例 #28
0
        public static void ReciveCoper(ZoneConnection zc, InterPacket packet)
        {
            string charname;
            long coper;
            bool typ;
            if (!packet.TryReadString(out charname, 16))
                return;

            if (!packet.TryReadLong(out coper))
                return;
            if (!packet.TryReadBool(out typ))
                return;

            WorldClient pClient = ClientManager.Instance.GetClientByCharname(charname);
            if (typ)
            {
              pClient.Character.Character.ReviveCoper += coper;

            }
            else
            {

                pClient.Character.RecviveCoperMaster += coper;
                pClient.Character.UpdateRecviveCoper();
            }
        }
コード例 #29
0
 public static void SendAddReward(ZoneConnection ZC, ushort itemID, byte count,string CharName)
 {
     using (var packet = new InterPacket(InterHeader.SendAddRewardItem))
     {
         packet.WriteUShort(itemID);
         packet.WriteByte(count);
         packet.WriteString(CharName, 16);
         ZC.SendPacket(packet);
     }
 }
コード例 #30
0
 private void WorldAcceptor_OnIncommingConnection(Socket session)
 {
     // So something with it X:
     Log.WriteLine(LogLevel.Info, "Incoming connection from {0}", session.RemoteEndPoint);
     ZoneConnection wc = new ZoneConnection(session);
 }
コード例 #31
0
 public static void HandleWorldMessage(ZoneConnection zc, InterPacket packet)
 {
     string msg;
     bool wut;
     byte type;
     if (!packet.TryReadString(out msg) || !packet.TryReadByte(out type) || !packet.TryReadBool(out wut))
     {
         return;
     }
     if (wut)
     {
         string to;
         if (!packet.TryReadString(out to))
         {
             return;
         }
         WorldClient client;
         if ((client = ClientManager.Instance.GetClientByCharname(to)) == null)
         {
             Log.WriteLine(LogLevel.Warn, "Tried to send a WorldMessage to a character that is unknown. Charname: {0}", to);
         }
         else
         {
             using (var p = Handler25.CreateWorldMessage((WorldMessageTypes)type, msg))
             {
                 client.SendPacket(p);
             }
         }
     }
     else
     {
         using (var p = Handler25.CreateWorldMessage((WorldMessageTypes)type, msg))
         {
             ClientManager.Instance.SendPacketToAll(p);
         }
     }
 }