Browse Source

【优化】增加报错日志

meijun 3 years ago
parent
commit
4351080426
1 changed files with 51 additions and 44 deletions
  1. 51 44
      Common/CommonAI/Zone/Instance/InstanceUnit.cs

+ 51 - 44
Common/CommonAI/Zone/Instance/InstanceUnit.cs

@@ -85,18 +85,18 @@ namespace CommonAI.Zone.Instance
         //游戏服标记字段,怪物死亡的时候,回传给游戏服
         public int gameServerFlag = 0;
 
-		//回血
-		public int recoverHP = 0;
-        
+        //回血
+        public int recoverHP = 0;
+
         //随从最后一次瞬移时间
         public long petTeleportTime = 0;
-        
+
         //最后一次返回召回随从操作频繁时间
-        public  long lastTeleportTime = 0;
+        public long lastTeleportTime = 0;
 
-		//绑定攻击玩家
-		private string mBindAttackPlayerId;
-		//主人id
+        //绑定攻击玩家
+        private string mBindAttackPlayerId;
+        //主人id
         private long mRemoveSelfTime;
         private InstanceUnit mBindMaster;
         //检测散开间隔
@@ -842,61 +842,68 @@ namespace CommonAI.Zone.Instance
         /** 执行死亡处理逻辑 */
         private void doDeadProcess(InstanceUnit attacker, AttackSource source)
         {
-            if (this.mProcessDeadCallbackTime > CommonLang.CUtils.localTimeMS)
-            {
-                log.Warn("cb_unitDeadCallBack 跳过:" + this.mProcessDeadCallbackTime + ", " + this.Parent.GetSceneID() + ", ID:" + this.Info.ID + ", " + this.PlayerUUID);
-                return;
-            }
-
-            if (this.IsMonster && this.Virtual.GetMaType() >= 4 && this.Level > 80)
+            try
             {
-                log.Info("boss死亡:" + this.mProcessDeadCallbackTime + ", 单位id=" + this.Info.ID + ", 场景Id=" +
-                    this.Parent.GetSceneID() + ", " + this.mZone.UUID + ", " + (attacker == null ? "null" : attacker.PlayerUUID));
-
-                if(attacker.IsPlayerUnit)
+                if (this.mProcessDeadCallbackTime > CommonLang.CUtils.localTimeMS)
                 {
-                    JSGHackerModule.OnPlayerKillMonster(attacker, this);
+                    log.Warn("cb_unitDeadCallBack 跳过:" + this.mProcessDeadCallbackTime + ", " + this.Parent.GetSceneID() + ", ID:" + this.Info.ID + ", " + this.PlayerUUID);
+                    return;
                 }
-            }
 
-            mDeadTime = Parent.PassTimeMS;
-            onDead(attacker);
-            Parent.cb_unitDeadCallBack(this, attacker);
+                if (this.IsMonster && this.Virtual.GetMaType() >= 4 && this.Level > 80)
+                {
+                    log.Info("boss死亡:" + this.mProcessDeadCallbackTime + ", 单位id=" + this.Info.ID + ", 场景Id=" +
+                        this.Parent.GetSceneID() + ", " + this.mZone.UUID + ", " + (attacker == null ? "null" : attacker.PlayerUUID));
 
-            if (source == null)
-            {
-                queueEvent(new UnitDeadEvent(ID, attacker == null ? 0 : attacker.ID, false, mInfo.RebirthTimeMS));
-                changeState(new StateDead(this, attacker, true));
-            }
-            else
-            {
-                queueEvent(new UnitDeadEvent(ID, attacker.ID, source.OutIsCrush, mInfo.RebirthTimeMS));
+                    if (attacker.IsPlayerUnit)
+                    {
+                        JSGHackerModule.OnPlayerKillMonster(attacker, this);
+                    }
+                }
 
-                // 被击碎,秒杀 //
-                if (source.OutIsCrush)
+                mDeadTime = Parent.PassTimeMS;
+                onDead(attacker);
+                Parent.cb_unitDeadCallBack(this, attacker);
+
+                if (source == null)
                 {
-                    Parent.queueEvent(new AddEffectEvent(this.ID, X, Y, Direction, source.Attack.CrushEffect));
+                    queueEvent(new UnitDeadEvent(ID, attacker == null ? 0 : attacker.ID, false, mInfo.RebirthTimeMS));
                     changeState(new StateDead(this, attacker, true));
                 }
                 else
                 {
-                    if (!Moveable)
+                    queueEvent(new UnitDeadEvent(ID, attacker.ID, source.OutIsCrush, mInfo.RebirthTimeMS));
+
+                    // 被击碎,秒杀 //
+                    if (source.OutIsCrush)
                     {
-                        changeState(new StateDead(this, attacker));
+                        Parent.queueEvent(new AddEffectEvent(this.ID, X, Y, Direction, source.Attack.CrushEffect));
+                        changeState(new StateDead(this, attacker, true));
                     }
-                    else if (source.OutHasKnockDown || source.OutHasFly)
+                    else
                     {
-                        if (!changeState(new StateDamage(this, source, attacker)))
+                        if (!Moveable)
+                        {
+                            changeState(new StateDead(this, attacker));
+                        }
+                        else if (source.OutHasKnockDown || source.OutHasFly)
+                        {
+                            if (!changeState(new StateDamage(this, source, attacker)))
+                            {
+                                changeState(new StateDead(this, attacker));
+                            }
+                        }
+                        else
                         {
                             changeState(new StateDead(this, attacker));
                         }
                     }
-                    else
-                    {
-                        changeState(new StateDead(this, attacker));
-                    }
+                    doHitAttackEndEffect(attacker, source);
                 }
-                doHitAttackEndEffect(attacker, source);
+            }
+            catch (Exception e)
+            {
+                log.Warn("doDeadProcess catch:" + this.Info.ID + ", AttackId: " + (attacker == null ? -1 : attacker.Info.ID), e);
             }
         }