Exemple #1
0
 internal void ProcessPacket(Packet pkt)
 {
     try
     {
         log.Logger.Log(typeof(Client), log4net.Core.Level.Verbose,
             string.Format("Handling packet '{0}'...", pkt.ID), null);
         if (pkt.ID == PacketID.Packet) return;
         IPacketHandler handler;
         if (!PacketHandlers.Handlers.TryGetValue(pkt.ID, out handler))
             log.WarnFormat("Unhandled packet '{0}'.", pkt.ID);
         else
             handler.Handle(this, (ClientPacket)pkt);
     }
     catch (Exception e)
     {
         log.Error(string.Format("Error when handling packet '{0}'...", pkt.ToString()), e);
         Disconnect();
     }
 }
Exemple #2
0
 internal void ProcessPacket(Packet pkt)
 {
     try
     {
         if (pkt.ID == PacketID.Hello)
             ProcessHelloPacket(pkt as HelloPacket);
         else if (pkt.ID == PacketID.Create)
             ProcessCreatePacket(pkt as CreatePacket);
         else if (pkt.ID == PacketID.Load)
             ProcessLoadPacket(pkt as LoadPacket);
         else if (pkt.ID == PacketID.Pong)
             entity.Pong(pkt as PongPacket);
         else if (pkt.ID == PacketID.Move)
             Manager.Logic.AddPendingAction(t => entity.Move(t, pkt as MovePacket));
         else if (pkt.ID == PacketID.PlayerShoot)
             Manager.Logic.AddPendingAction(t => entity.PlayerShoot(t, pkt as PlayerShootPacket));
         else if (pkt.ID == PacketID.EnemyHit)
             Manager.Logic.AddPendingAction(t => entity.EnemyHit(t, pkt as EnemyHitPacket));
         else if (pkt.ID == PacketID.OtherHit)
             Manager.Logic.AddPendingAction(t => entity.OtherHit(t, pkt as OtherHitPacket));
         else if (pkt.ID == PacketID.SquareHit)
             Manager.Logic.AddPendingAction(t => entity.SquareHit(t, pkt as SquareHitPacket));
         else if (pkt.ID == PacketID.PlayerHit)
             Manager.Logic.AddPendingAction(t => entity.PlayerHit(t, pkt as PlayerHitPacket));
         else if (pkt.ID == PacketID.ShootAck)   //TODO: this one is spammed when lots of bullet, special handle?
             Manager.Logic.AddPendingAction(t => entity.ShootAck(t, pkt as ShootAckPacket));
         else if (pkt.ID == PacketID.InvSwap)
             Manager.Logic.AddPendingAction(t => entity.InventorySwap(t, pkt as InvSwapPacket));
         else if (pkt.ID == PacketID.InvDrop)
             Manager.Logic.AddPendingAction(t => entity.InventoryDrop(t, pkt as InvDropPacket));
         else if (pkt.ID == PacketID.UseItem)
             Manager.Logic.AddPendingAction(t => entity.UseItem(t, pkt as UseItemPacket));
         else if (pkt.ID == PacketID.UsePortal)
             Manager.Logic.AddPendingAction(t => entity.UsePortal(t, pkt as UsePortalPacket));
         else if (pkt.ID == PacketID.PlayerText)
             Manager.Logic.AddPendingAction(t => entity.PlayerText(t, pkt as PlayerTextPacket));
         else if (pkt.ID == PacketID.ChooseName)
             ProcessChooseNamePacket(pkt as ChooseNamePacket);
         else if (pkt.ID == PacketID.Escape)
             ProcessEscapePacket(pkt as EscapePacket);
         else if (pkt.ID == PacketID.Teleport)
             Manager.Logic.AddPendingAction(t => entity.Teleport(t, pkt as TeleportPacket));
         else if (pkt.ID == PacketID.GotoAck)
             Manager.Logic.AddPendingAction(t => entity.GotoAck(t, pkt as GotoAckPacket));
         else if (pkt.ID == PacketID.EditAccountList)
             entity.EditAccountList(pkt as EditAccountListPacket);
         else if (pkt.ID == PacketID.Buy)
             entity.Buy(pkt as BuyPacket);
         else if (pkt.ID == PacketID.RequestTrade)
             Manager.Logic.AddPendingAction(t => entity.RequestTrade(t, pkt as RequestTradePacket));
         else if (pkt.ID == PacketID.ChangeTrade)
             Manager.Logic.AddPendingAction(t => entity.ChangeTrade(t, pkt as ChangeTradePacket));
         else if (pkt.ID == PacketID.AcceptTrade)
             Manager.Logic.AddPendingAction(t => entity.AcceptTrade(t, pkt as AcceptTradePacket));
         else if (pkt.ID == PacketID.CancelTrade)
             Manager.Logic.AddPendingAction(t => entity.CancelTrade(t, pkt as CancelTradePacket));
         else if (pkt.ID == PacketID.AOEAck)
             Manager.Logic.AddPendingAction(t => entity.AOEAck(t, pkt as AOEAckPacket));
         else if (pkt.ID == PacketID.GroundDamage)
             Manager.Logic.AddPendingAction(t => entity.GroundDamage(t, pkt as GroundDamagePacket));
         else if (pkt.ID == PacketID.CheckCredits)
             entity.CheckCredits(pkt as CheckCreditsPacket);
         else if (pkt.ID != PacketID.Packet)
         {
             Console.WriteLine("Unhandled packet: " + pkt.ToString());
         }
     }
     catch
     {
         Disconnect();
     }
 }
Exemple #3
0
 internal void ProcessPacket(Packet pkt)
 {
     try
     {
         if (pkt.ID == PacketID.Hello)
             ProcessHelloPacket(pkt as HelloPacket);
         else if (pkt.ID == PacketID.Create)
             ProcessCreatePacket(pkt as CreatePacket);
         else if (pkt.ID == PacketID.Load)
             ProcessLoadPacket(pkt as LoadPacket);
         else if (pkt.ID == PacketID.Pong)
             entity.Pong(pkt as PongPacket);
         else if (pkt.ID == PacketID.Move)
             RealmManager.Logic.AddPendingAction(t => entity.Move(t, pkt as MovePacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.PlayerShoot)
             RealmManager.Logic.AddPendingAction(t => entity.PlayerShoot(t, pkt as PlayerShootPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.EnemyHit)
             RealmManager.Logic.AddPendingAction(t => entity.EnemyHit(t, pkt as EnemyHitPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.OtherHit)
             RealmManager.Logic.AddPendingAction(t => entity.OtherHit(t, pkt as OtherHitPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.SquareHit)
             RealmManager.Logic.AddPendingAction(t => entity.SquareHit(t, pkt as SquareHitPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.PlayerHit)
             RealmManager.Logic.AddPendingAction(t => entity.PlayerHit(t, pkt as PlayerHitPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.ShootAck) //Spam
             RealmManager.Logic.AddPendingAction(t => entity.ShootAck(t, pkt as ShootAckPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.InvSwap)
             RealmManager.Logic.AddPendingAction(t => entity.InventorySwap(t, pkt as InvSwapPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.InvDrop)
             RealmManager.Logic.AddPendingAction(t => entity.InventoryDrop(t, pkt as InvDropPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.UseItem)
             RealmManager.Logic.AddPendingAction(t => entity.UseItem(t, pkt as UseItemPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.UsePortal)
             RealmManager.Logic.AddPendingAction(t => entity.UsePortal(t, pkt as UsePortalPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.PlayerText)
             RealmManager.Logic.AddPendingAction(t => entity.PlayerText(t, pkt as PlayerTextPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.ChooseName)
             ProcessChooseNamePacket(pkt as ChooseNamePacket);
         else if (pkt.ID == PacketID.Escape)
             ProcessEscapePacket(pkt as EscapePacket);
         else if (pkt.ID == PacketID.Teleport)
             RealmManager.Logic.AddPendingAction(t => entity.Teleport(t, pkt as TeleportPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.GotoAck)
             RealmManager.Logic.AddPendingAction(t => entity.GotoAck(t, pkt as GotoAckPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.EditAccountList)
             RealmManager.Logic.AddPendingAction(t => entity.EditAccountList(t, pkt as EditAccountListPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.Buy)
             RealmManager.Logic.AddPendingAction(t => entity.Buy(t, pkt as BuyPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.RequestTrade)
             RealmManager.Logic.AddPendingAction(t => entity.RequestTrade(t, pkt as RequestTradePacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.ChangeTrade)
             RealmManager.Logic.AddPendingAction(t => entity.ChangeTrade(t, pkt as ChangeTradePacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.AcceptTrade)
             RealmManager.Logic.AddPendingAction(t => entity.AcceptTrade(t, pkt as AcceptTradePacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.CancelTrade)
             RealmManager.Logic.AddPendingAction(t => entity.CancelTrade(t, pkt as CancelTradePacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.AOEAck)
             RealmManager.Logic.AddPendingAction(t => entity.AOEAck(t, pkt as AOEAckPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.GroundDamage)
             RealmManager.Logic.AddPendingAction(t => entity.GroundDamage(t, pkt as GroundDamagePacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.CheckCredits)
             RealmManager.Logic.AddPendingAction(t => entity.CheckCredits(t, pkt as CheckCreditsPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.GuildRemove)
             RealmManager.Logic.AddPendingAction(t => entity.GuildRemove(t, pkt as GuildRemovePacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.CreateGuild)
             RealmManager.Logic.AddPendingAction(t => entity.CreateGuild(t, pkt as CreateGuildPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.JoinGuild)
             RealmManager.Logic.AddPendingAction(t => entity.JoinGuild(t, pkt as JoinGuildPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.GuildInvite)
             RealmManager.Logic.AddPendingAction(t => entity.InviteToGuild(t, pkt as GuildInvitePacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.ChangeGuildRank)
             RealmManager.Logic.AddPendingAction(t => entity.ChangeGuildRank(t, pkt as ChangeGuildRankPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.Visibullet)
             RealmManager.Logic.AddPendingAction(t => entity.VisibulletHit(pkt as VisibulletPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.TextBoxButton)
             RealmManager.Logic.AddPendingAction(t => entity.TextBoxButton(pkt as TextBoxButtonPacket), PendingPriority.Networking);
         else if (pkt.ID == PacketID.UpdateAck)
             RealmManager.Logic.AddPendingAction(t => HandleUpdateAck(), PendingPriority.Networking);
         else
         {
             logger.Error("Unhandled packet: " + pkt.ToString());
         }
     }
     catch (Exception e)
     {
         logger.Fatal(e);
         Disconnect();
     }
 }