Ejemplo n.º 1
0
        public override void Init(World owner)
        {
            Random rand = new System.Random();
            int    x, y;

            do
            {
                x = rand.Next(0, owner.Map.Width);
                y = rand.Next(0, owner.Map.Height);
            } while (owner.Map[x, y].Region != TileRegion.Spawn);
            Move(x + 0.5f, y + 0.5f);
            tiles = new byte[owner.Map.Width, owner.Map.Height];
            fames = new FameCounter(this);
            SetNewbiePeriod();
            if (!psr.CheckAccountInUse(AccountId))
            {
                base.Init(owner);
            }
            else
            {
                psr.Disconnect();
            }
            if (psr.Character.Pet >= 0)
            {
                GivePet((short)psr.Character.Pet);
            }
            try { SendAccountList(Locked, LOCKED_LIST_ID); }
            catch { }
            try { SendAccountList(Ignored, IGNORED_LIST_ID); }
            catch { }
        }
Ejemplo n.º 2
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);
         psr.Disconnect();
     }
 }
Ejemplo n.º 3
0
        public void Death(string killer)
        {
            if (psr.Stage == ProtocalStage.Disconnected || resurrecting)
            {
                return;
            }
            if (CheckResurrection())
            {
                return;
            }


            if (psr.Character.Dead)
            {
                psr.Disconnect();
                return;
            }

            GenerateGravestone();
            Owner.BroadcastPacket(new TextPacket()
            {
                BubbleTime = 0,
                Stars      = -1,
                Name       = "",
                Text       = Name + " died at Level " + Level + ", killed by " + killer
            }, null);

            psr.Character.Dead = true;
            SaveToCharacter();
            psr.Database.SaveCharacter(psr.Account, psr.Character);
            psr.Database.Death(psr.Account, psr.Character, killer);
            psr.SendPacket(new DeathPacket()
            {
                AccountId = AccountId,
                CharId    = psr.Character.CharacterId,
                Killer    = killer
            });
            Owner.Timers.Add(new WorldTimer(1000, (w, t) => psr.Disconnect()));
            Owner.LeaveWorld(this);
        }
Ejemplo n.º 4
0
        public override void Init(World owner)
        {
            Random rand = new System.Random();
            int    x, y;

            do
            {
                x = rand.Next(0, owner.Map.Width);
                y = rand.Next(0, owner.Map.Height);
            } while (owner.Map[x, y].Region != TileRegion.Spawn);
            Move(x + 0.5f, y + 0.5f);
            tiles = new byte[owner.Map.Width, owner.Map.Height];
            fames = new FameCounter(this);
            if (!psr.CheckAccountInUse(AccountId))
            {
                base.Init(owner);
            }
            else
            {
                psr.Disconnect();
            }
        }
Ejemplo n.º 5
0
        public override void Init(World owner)
        {
            var rand = new Random();
            int x, y;

            do
            {
                x = rand.Next(0, owner.Map.Width);
                y = rand.Next(0, owner.Map.Height);
            } while (owner.Map[x, y].Region != TileRegion.Spawn);
            Move(x + 0.5f, y + 0.5f);
            tiles = new byte[owner.Map.Width, owner.Map.Height];
            fames = new FameCounter(this);
            SetNewbiePeriod();
            if (!psr.CheckAccountInUse(AccountId))
            {
                base.Init(owner);
            }
            else
            {
                psr.Disconnect();
            }
            if (psr.Character.Pet >= 0)
            {
                GivePet((short)psr.Character.Pet);
            }
            try
            {
                SendAccountList(Locked, LOCKED_LIST_ID);
            }
            catch
            {
            }
            try
            {
                SendAccountList(Ignored, IGNORED_LIST_ID);
            }
            catch
            {
            }
            if (!psr.ConnectedBuild.StartsWith(psr.clientVer))
            {
                psr.SendPacket(new TextBoxPacket
                {
                    Title   = "Outdated Client!",
                    Message =
                        "You are running an outdated client version.\nGet or play the latest one on the\nup-to-date <u><a href='http://forum.zerorealms.com'>web client</a></u>.",
                    Button1 = "Okay"
                });
                psr.Disconnect();
            }
        }