void ProcessHelloPacket(HelloPacket pkt) { /*if (!skt.RemoteEndPoint.ToString().StartsWith("127.0.0.1")) { SendPacket(new TextPacket() { BubbleTime = 0, Stars = -1, Name = "*Error*", Text = "You should not be here!" }); Disconnect(); return; }*/ db = new Database(); if ((account = db.Verify(pkt.GUID, pkt.Password)) == null) { account = Database.Register(pkt.GUID, pkt.Password, true); if (account == null) { SendFailure("Invalid account."); Disconnect(); return; } } if (!Manager.TryConnect(this)) { account = null; SendFailure("Failed to connect."); Disconnect(); } else { World world = Manager.GetWorld(pkt.GameId); if (world == null) { SendFailure("Invalid world."); Disconnect(); } else { if (world.Id == -6) //Test World (world as realm.worlds.Test).LoadJson(pkt.MapInfo); else if (world.IsLimbo) world = world.GetInstance(this); var seed = (uint)((long)Environment.TickCount * pkt.GUID.GetHashCode()) % uint.MaxValue; Random = new wRandom(seed); targetWorld = world.Id; SendPacket(new MapInfoPacket() { Width = world.Map.Width, Height = world.Map.Height, Name = world.Name, Seed = seed, Background = world.Background, AllowTeleport = world.AllowTeleport, ShowDisplays = world.ShowDisplays, ClientXML = world.ClientXML, ExtraXML = world.ExtraXML }); stage = ProtocalStage.Handshaked; } } }
private void ProcessHelloPacket(HelloPacket pkt) { if (isGuest) Disconnect(); db = new Database(); if ((account = db.Verify(pkt.GUID, pkt.Password)) == null) { logger.Info("Account not verified."); account = Database.CreateGuestAccount(pkt.GUID); if (account == null) { logger.Info("Account is null!"); SendPacket(new svrPackets.FailurePacket() { Message = "Invalid account." }); Disconnect(); return; } } logger.Info("Client trying to connect!"); ConnectedBuild = pkt.BuildVersion; if (!RealmManager.TryConnect(this)) { if (CheckAccountInUse(account.AccountId) != false) { logger.Info("Account in use: " + account.AccountId + " " + account.Name); account = null; SendPacket(new svrPackets.FailurePacket() { Message = "Account in use! Retrying..." }); Disconnect(); return; } account = null; SendPacket(new svrPackets.FailurePacket() { Message = "Failed to connect." }); Disconnect(); logger.Info("Failed to connect."); return; } else { logger.Warn("Client loading world"); World world = RealmManager.GetWorld(pkt.GameId); if (world == null) { SendPacket(new svrPackets.FailurePacket() { Message = "Invalid world." }); Disconnect(); logger.Error("Invalid world"); } logger.Error("Client joined world " + world.Id.ToString()); if (world.Id == -6) //Test World (world as realm.worlds.Test).LoadJson(pkt.MapInfo); else if (world.IsLimbo) world = world.GetInstance(this); var seed = (uint)((long)Environment.TickCount * pkt.GUID.GetHashCode()) % uint.MaxValue; Random = new wRandom(seed); targetWorld = world.Id; SendPacket(new MapInfoPacket() { Width = world.Map.Width, Height = world.Map.Height, Name = world.Name, Seed = seed, Background = world.Background, AllowTeleport = world.AllowTeleport, ShowDisplays = world.ShowDisplays, ClientXML = world.ClientXML, ExtraXML = world.ExtraXML }); stage = ProtocalStage.Handshaked; } }