Browse Source

【优化】增加场景单位数量过多日志信息

# Conflicts:
#	Common/CommonAI/Zone/Instance/InstanceUnit.cs
meijun 3 years ago
parent
commit
1fd94826bb

+ 10 - 10
Common/CommonAI/Zone/EventTrigger/EventAdapter.cs

@@ -336,16 +336,16 @@ namespace CommonAI.Zone.EventTrigger
 			{
 			{
 				log.Warn("--调试场景: " + this.ZoneAPI.UUID + ", " + this.ZoneAPI.GetSceneID() + ", 执行动作:" + this.Name);
 				log.Warn("--调试场景: " + this.ZoneAPI.UUID + ", " + this.ZoneAPI.GetSceneID() + ", 执行动作:" + this.Name);
 			}
 			}
-			//else
-			//{
-			//	log.Info("--调试场景: " + this.ZoneAPI.UUID + ", " + this.ZoneAPI.GetSceneID() + ", 执行动作:" + this.Name);
-			//}
-
-			//if(this.Name.Equals("事件重置列表1") || this.Name.Equals("玉重置"))
-			//{
-			//	int i = 0;
-			//}
-			Stopwatch stopwatch = Stopwatch.StartNew();
+            else
+            {
+                log.Info("--调试场景: " + this.ZoneAPI.UUID + ", " + this.ZoneAPI.GetSceneID() + ", 执行动作:" + this.Name);
+            }
+
+            //if(this.Name.Equals("事件重置列表1") || this.Name.Equals("玉重置"))
+            //{
+            //	int i = 0;
+            //}
+            Stopwatch stopwatch = Stopwatch.StartNew();
 			try
 			try
 			{
 			{
 				if (mOnActionBegin != null)
 				if (mOnActionBegin != null)

+ 34 - 1
Common/CommonAI/Zone/Instance/InstanceZone.cs

@@ -810,13 +810,22 @@ namespace CommonAI.Zone.Instance
         /// <param name="add">输出事件</param>
         /// <param name="add">输出事件</param>
         /// <param name="summoner">召唤者</param>
         /// <param name="summoner">召唤者</param>
         /// <returns></returns>
         /// <returns></returns>
+        /// 
+
+        private long mAddUnitPrintTime = 0;
+
         public InstanceUnit AddUnit(UnitInfo info, string name, int force, int level, float x, float y, float direction, 
         public InstanceUnit AddUnit(UnitInfo info, string name, int force, int level, float x, float y, float direction, 
             out AddUnitEvent add, InstanceUnit summoner = null, String clientShowName = "", int gsFlag = 0, int alliesForce = 0, bool pointLv = false)
             out AddUnitEvent add, InstanceUnit summoner = null, String clientShowName = "", int gsFlag = 0, int alliesForce = 0, bool pointLv = false)
         {
         {
             add = null;
             add = null;
 			if (mObjects.UnitsCount >= mMaxUnitCount)
 			if (mObjects.UnitsCount >= mMaxUnitCount)
 			{
 			{
-				log.Warn(string.Format("--Zone AddUnit to max: {0}, UUID: {1}, ID: {2} 单位数量:{3}", this.GetSceneID(), this.UUID, info.TemplateID, mObjects.UnitsCount));
+                if(mAddUnitPrintTime < CommonLang.CUtils.localTimeMS)
+                {
+                    mAddUnitPrintTime = CommonLang.CUtils.localTimeMS + 3000;
+                    log.Warn(string.Format("--Zone AddUnit to max: {0}, UUID: {1}, ID: {2} 单位数量:{3}", this.GetSceneID(), this.UUID, info.TemplateID, GetZoneUnitInfo()));
+                }
+				
 				return null;
 				return null;
 			}
 			}
 
 
@@ -884,6 +893,30 @@ namespace CommonAI.Zone.Instance
             return null;
             return null;
         }
         }
 
 
+        /** 获取场景单位异常信息 */
+        private string GetZoneUnitInfo(int nMinNums = 50)
+        {
+            HashMap<int, int> mInfo = new HashMap<int, int>();
+            foreach (InstanceUnit obj in mObjects.Units)
+            {
+                mInfo.Put(obj.Info.ID, mInfo.Get(obj.Info.ID) + 1);
+            }
+
+            string finalStr = "";
+            foreach(int unitID in mInfo.Keys)
+            {
+                int count = mInfo.Get(unitID);
+                if (count < nMinNums)
+                {
+                    continue;
+                }
+                finalStr = finalStr + (unitID) + "-" + count + ", ";
+            }
+
+            return finalStr;
+        }
+
+
         public InstanceItem AddItem(ItemTemplate template, string name, float x, float y, float direction, int force, string disPlayName,
         public InstanceItem AddItem(ItemTemplate template, string name, float x, float y, float direction, int force, string disPlayName,
 			out AddItemEvent add, InstanceUnit creater,int from)
 			out AddItemEvent add, InstanceUnit creater,int from)
         {
         {