public FieldWar(int id) { Id = id; MapId = FieldWarMetadataStorage.MapId(id); List <Player> onlinePlayers = GameServer.PlayerManager.GetAllPlayers().Where(x => !MapMetadataStorage.MapIsInstancedOnly(x.MapId)).ToList(); DateTimeOffset now = DateTimeOffset.UtcNow; EntryClosureTime = now.AddSeconds(-now.Second).AddMinutes(5); foreach (Player player in onlinePlayers) { player.Session.Send(FieldWarPacket.LegionPopup(id, EntryClosureTime.ToUnixTimeSeconds())); } }
public override void Handle(GameSession session, PacketReader packet) { packet.ReadInt(); // ? // Liftable: 00 00 00 00 00 // SendBreakable // Self Player player = session.Player; Account account = player.Account; session.EnterField(player); session.Send(StatPacket.SetStats(player.FieldPlayer)); session.Send(StatPointPacket.WriteTotalStatPoints(player)); session.Send(StatPointPacket.WriteTotalStatPoints(player)); // This packet is sent twice on GMS, not sure why session.Send(StatPointPacket.WriteStatPointDistribution(player)); session.Send(SkillPointPacket.ExtraSkillPoints(player)); if (player.ActivePet is not null) { player.ActivePet.SetMetadataValues(); Pet pet = session.FieldManager.RequestPet(player.ActivePet, player.FieldPlayer); if (pet is not null) { player.FieldPlayer.ActivePet = pet; session.Send(ResponsePetPacket.LoadPetSettings(pet)); session.Send(NoticePacket.Notice(SystemNotice.PetSummonOn, NoticeType.Chat | NoticeType.FastText)); } } if (account.IsVip()) { session.Send(BuffPacket.SendBuff(0, new(100000014, player.FieldPlayer.ObjectId, player.FieldPlayer.ObjectId, 1, (int)account.VIPExpiration, 1))); session.Send(PremiumClubPacket.ActivatePremium(player.FieldPlayer, account.VIPExpiration)); } session.Send(EmotePacket.LoadEmotes(player)); session.Send(MacroPacket.LoadControls(player.Macros)); session.Send(ChatStickerPacket.LoadChatSticker(player)); session.Send(ResponseCubePacket.DecorationScore(account.Home)); session.Send(ResponseCubePacket.LoadHome(player.FieldPlayer.ObjectId, player.Account.Home)); session.Send(ResponseCubePacket.ReturnMap(player.ReturnMapId)); session.Send(LapenshardPacket.Load(player.Inventory.LapenshardStorage)); IEnumerable <Cube> cubes = session.FieldManager.State.Cubes.Values .Where(x => x.Value.PlotNumber == 1 && x.Value.Item.HousingCategory is ItemHousingCategory.Farming or ItemHousingCategory.Ranching) .Select(x => x.Value); foreach (Cube cube in cubes) { session.Send(FunctionCubePacket.UpdateFunctionCube(cube.CoordF.ToByte(), 2, 1)); } if (player.Party is not null) { session.Send(PartyPacket.UpdatePlayer(player)); } GlobalEvent globalEvent = GameServer.GlobalEventManager.GetCurrentEvent(); if (globalEvent is not null && !MapMetadataStorage.MapIsInstancedOnly(player.MapId)) { session.Send(GlobalPortalPacket.Notice(globalEvent)); } FieldWar fieldWar = GameServer.FieldWarManager.CurrentFieldWar; if (fieldWar is not null && !MapMetadataStorage.MapIsInstancedOnly(player.MapId) && fieldWar.MapId != player.MapId) { session.Send(FieldWarPacket.LegionPopup(fieldWar.Id, fieldWar.EntryClosureTime.ToUnixTimeSeconds())); } session.Send(KeyTablePacket.SendHotbars(player.GameOptions)); TrophyManager.OnMapEntered(player, player.MapId); QuestManager.OnMapEnter(player, player.MapId); player.InitializeEffects(); }
protected override void EndSession(bool logoutNotice) { if (Player is null || FieldManager is null) { return; } FieldManager.RemovePlayer(Player); GameServer.PlayerManager.RemovePlayer(Player); Player.OnlineCTS.Cancel(); Player.OnlineTimeThread = null; CoordF safeCoord = Player.SafeBlock; safeCoord.Z += Block.BLOCK_SIZE; Player.SavedCoord = safeCoord; // if session is not changing channels or servers, send the logout message if (logoutNotice) { Player.Session = null; GameServer.BuddyManager.SetFriendSessions(Player); Player.Party?.CheckOfflineParty(Player); Player.Guild?.BroadcastPacketGuild(GuildPacket.MemberLoggedOff(Player)); Player.UpdateBuddies(); foreach (Club club in Player.Clubs) { club?.BroadcastPacketClub(ClubPacket.LogoutNotice(Player, club)); } foreach (GroupChat groupChat in Player.GroupChats) { groupChat?.BroadcastPacketGroupChat(GroupChatPacket.LogoutNotice(groupChat, Player)); groupChat?.CheckOfflineGroupChat(); } Player.IsMigrating = false; if (MapMetadataStorage.MapIsInstancedOnly(Player.MapId) && !MapMetadataStorage.MapIsTutorial(Player.MapId)) { Player.SavedCoord = Player.ReturnCoord; Player.MapId = Player.ReturnMapId; } AuthData authData = Player.Account.AuthData; authData.OnlineCharacterId = 0; DatabaseManager.AuthData.UpdateOnlineCharacterId(authData); } List <GameEventUserValue> userTimeValues = Player.EventUserValues.Where(x => x.EventType == GameEventUserValueType.AttendanceAccumulatedTime).ToList(); foreach (GameEventUserValue userValue in userTimeValues) { if (!long.TryParse(userValue.EventValue, out long timeAccumulated)) { timeAccumulated = 0; } timeAccumulated += TimeInfo.Now() - Player.LastLogTime; userValue.EventValue = timeAccumulated.ToString(); DatabaseManager.GameEventUserValue.Update(userValue); } Player.LastLogTime = TimeInfo.Now(); Player.Account.LastLogTime = TimeInfo.Now(); if (Player.GuildMember is not null) { Player.GuildMember.LastLogTimestamp = TimeInfo.Now(); } DatabaseManager.Characters.Update(Player); }