コード例 #1
0
ファイル: CharacterModel.cs プロジェクト: 745c5412/tera-emu
 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);
     }
 }
コード例 #2
0
ファイル: DatabaseCache.cs プロジェクト: 745c5412/tera-emu
        /// <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);
            }
        }