public void OnDisconnect() { try { CharacterTable.Update(this); if (this.myMap != null && this.Client != null && this.Client.GetState() == WorldState.STATE_IN_GAME) { this.DestroyFromMap(); } if (InventoryCache != null) { foreach (var item in InventoryCache.ItemsCache) { if (item.Value.SpeakingItem != null) { SpeakingTable.Add(item.Value.SpeakingItem); SpeakingTable.Cache.Remove(item.Value.SpeakingID); } InventoryItemTable.Items.Remove(item.Key); } } CharacterTable.DelCharacter(this); this.Client = null; } catch (Exception e) { Logger.Error(e); } }
private static void BuyRequest(WorldClient Client, string Packet) { Client.Send(new GameRideMessage("v")); MountPark MP = Client.Character.myMap.mountPark; if (MP == null) { Client.Send(new BasicNoOperationMessage()); return; } if (MP.get_owner() == -1) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 96)); return; } if (MP.get_price() == 0) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 97)); return; } if (!Client.Character.HasGuild()) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 135)); return; } if (Client.GetCharacter().getCharacterGuild().GradeType != GuildGradeEnum.GRADE_BOSS) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 98)); return; } byte enclosMax = (byte)Math.Floor((double)Client.Character.GetGuild().Level / 10); byte TotalEncloGuild = (byte)MountParkTable.CountByGuild(Client.Character.GetGuild().ID); if (TotalEncloGuild >= enclosMax) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 103)); return; } if (Client.Character.Kamas < MP.get_price()) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 82)); return; } Client.GetCharacter().InventoryCache.SubstractKamas(MP.get_price()); if (MP.get_owner() > 0) { var Owner = CharacterTable.GetCharacter(MP.get_owner()); if (Owner != null && Owner.Account.curPlayer != null) { Owner.Send(new ChatGameMessage("Un enclo a ete vendu a " + MP.get_price() + ".", "CC0000")); Owner.Account.Data.BankKamas += MP.get_price(); Owner.Account.Data.Save(); } else { AccountDataTable.Update(MP.get_price(), MP.get_owner()); } } MP.set_price(0); MP.set_owner(Client.Character.ID); MP.set_guild(Client.Character.GetGuild()); MountParkTable.Update(MP); CharacterTable.Update(Client.Character); Client.GetCharacter().myMap.SendToMap(new MapMountParkMessage(MP)); }
/// <summary> /// Sauvegarde les changements effectués. /// </summary> public static bool Save() { try { lock (mySyncSave) { long StartTime = Environment.TickCount; Logger.Info("World saving ..."); // Execution des requetes lock (mySaveQueue) while (mySaveQueue.Count != 0) { mySaveQueue.Dequeue()(); } lock (GuildTable.Cache) foreach (var Guild in GuildTable.Cache.Values) { Guild.SaveChanges(); GuildTable.Update(Guild); } lock (CharacterTable.myCharacterById) foreach (var Character in CharacterTable.myCharacterById.Values.Where(x => x.myInitialized)) { CharacterTable.Update(Character); } lock (SpeakingTable.Cache) foreach (var Speaking in SpeakingTable.Cache.Values) { SpeakingTable.Add(Speaking); } lock (AreaTable.Cache) foreach (var area in AreaTable.Cache.Values) { AreaTable.Update(area); } lock (AreaSubTable.Cache) foreach (var subarea in AreaSubTable.Cache.Values) { AreaSubTable.Save(subarea); } lock (BidHouseTable.Cache) { var BHI = new List <BidHouseItem>(); foreach (var BH in BidHouseTable.Cache.Values) { BHI.AddRange(BH.getAllEntry()); } BidHouseTable.Update(BHI); } Logger.Info("World saved in " + (Environment.TickCount - StartTime) + "ms"); return(true); } } catch (Exception ex) { Logger.Error("DatabaseEntities::Save() " + ex.ToString()); return(false); } }