Эх сурвалжийг харах

修复掉使用线程池调度纤程导致寻路的错误,原因是PathfindingComponent.extents加了个ThreadStatic,导致有些线程并没有赋值

tanghai 2 жил өмнө
parent
commit
33bbca6cbd

+ 2 - 2
Unity/Assets/Scripts/Hotfix/Server/Demo/EntryEvent2_InitServer.cs

@@ -19,14 +19,14 @@ namespace ET.Server
                     
                     // 创建进程通信纤程
                     int fiberId = FiberManager.Instance.Create(ConstFiberId.NetInner, 0, SceneType.NetInner, SceneType.NetInner.ToString());
-                    ThreadScheduler.Instance.Add(fiberId);
+                    ThreadPoolScheduler.Instance.Add(fiberId);
                     
                     // 根据配置创建纤程
                     var processScenes = StartSceneConfigCategory.Instance.GetByProcess(root.Fiber().Process);
                     foreach (StartSceneConfig startConfig in processScenes)
                     {
                         fiberId = FiberManager.Instance.Create(startConfig.Id, startConfig.Zone, startConfig.Type, startConfig.Name);
-                        ThreadScheduler.Instance.Add(fiberId);
+                        ThreadPoolScheduler.Instance.Add(fiberId);
                     }
 
                     break;

+ 0 - 2
Unity/Assets/Scripts/Hotfix/Server/Demo/Map/Move/C2M_PathfindingResultHandler.cs

@@ -6,8 +6,6 @@ namespace ET.Server
 	{
 		protected override async ETTask Run(Unit unit, C2M_PathfindingResult message)
 		{
-			Log.Debug($"11111111111111111111111111: {message}");
-			
 			unit.FindPathMoveToAsync(message.Position).Coroutine();
 			await ETTask.CompletedTask;
 		}

+ 7 - 2
Unity/Assets/Scripts/Hotfix/Share/Module/Recast/PathfindingComponentSystem.cs

@@ -45,7 +45,12 @@ namespace ET
             self.EndPos[1] = target.y;
             self.EndPos[2] = target.z;
             //Log.Debug($"start find path: {self.GetParent<Unit>().Id}");
-            int n = Recast.RecastFind(self.navMesh, PathfindingComponent.extents, self.StartPos, self.EndPos, self.Result);
+            int n = Recast.RecastFind(self.navMesh, self.extents, self.StartPos, self.EndPos, self.Result);
+            if (n < 0)
+            {
+                throw new Exception($"find path error: {n}");
+            }
+            
             for (int i = 0; i < n; ++i)
             {
                 int index = i * 3;
@@ -150,7 +155,7 @@ namespace ET
             self.StartPos[1] = pos.y;
             self.StartPos[2] = pos.z;
 
-            int ret = Recast.RecastFindNearestPoint(self.navMesh, PathfindingComponent.extents, self.StartPos, self.EndPos);
+            int ret = Recast.RecastFindNearestPoint(self.navMesh, self.extents, self.StartPos, self.EndPos);
             if (ret == 0)
             {
                 throw new Exception($"RecastFindNearestPoint fail, 可能是位置配置有问题: sceneName:{self.Scene().Name} {pos} {self.Name} {self.GetParent<Unit>().Id} {self.GetParent<Unit>().Config.Id} {self.EndPos.ArrayToString()}");

+ 1 - 3
Unity/Assets/Scripts/Model/Share/Module/Recast/PathfindingComponent.cs

@@ -10,9 +10,7 @@ namespace ET
     {
         public const int FindRandomNavPosMaxRadius = 15000;  // 随机找寻路点的最大半径
         
-        [ThreadStatic]
-        [StaticField]
-        public static float[] extents = {15, 10, 15};
+        public float[] extents = {15, 10, 15};
         
         public string Name;