StackOverflowException: The requested operation caused a stack overflow.
今天打包版本測試轟炸超人發現這個問題
StackOverflowException: The requested operation caused a stack overflow. at (wrapper managed-to-native) System.String.FastAllocateString(int) at System.String.CreateStringFromEncoding (System.Byte* bytes, System.Int32 byteLength, System.Text.Encoding encoding) [0x00013] in <c9d3ffd4b98649ee9989e1908eaca019>:0 at System.Text.Encoding.GetString (System.Byte* bytes, System.Int32 byteCount) [0x00033] in <c9d3ffd4b98649ee9989e1908eaca019>:0 at System.Text.Encoding.GetString (System.ReadOnlySpan
1[T] bytes) [0x00013] in
at System.String.Ctor (System.SByte value, System.Int32 startIndex, System.Int32 length, System.Text.Encoding enc) [0x0006d] in
at System.String.CreateString (System.SByte
at (wrapper managed-to-managed) System.String..ctor(sbyte,int,int,System.Text.Encoding)
at UnityEngine.StackTraceUtility.ExtractStackTrace () [0x0002c] in
at (wrapper managed-to-native) UnityEngine.DebugLogHandler.Internal_Log(UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)
at UnityEngine.DebugLogHandler.LogFormat (UnityEngine.LogType logType, UnityEngine.Object context, System.String format, System.Object[] args) [0x0000b] in
at UnityEngine.Logger.Log (UnityEngine.LogType logType, System.Object message) [0x00027] in
at UnityEngine.Debug.Log (System.Object message) [0x00006] in
at ETModel.Log.Debug (System.String msg) [0x00000] in G:\OlgCase\bbm\source\Unity_Web\Assets\Model\Base\Log.cs:14
at ILRuntime.Runtime.Generated.ETModel_Log_Binding.Debug_8 (ILRuntime.Runtime.Intepreter.ILIntepreter __intp, ILRuntime.Runtime.Stack.StackObject
at (wrapper delegate-invoke) 1<object>_CLRMethod_bool(ILRuntime.Runtime.Intepreter.ILIntepreter,ILRuntime.Runtime.Stack.StackObject*,System.Collections.Generic.List
1
`
很明顯是出現了無限循環, 但不確定問題在哪, 測試了發現是 AIPlayer 造成的, 並且問題在尋路上
不知道為什麼這邊的計算公式如果設定 depth > 200 , 就會造成 depth = 39 就卡死
private void reCalcNonPath(int[,] matrixData, ref List<int[]> path, int bombCnt, int depth, int chunkH, int chunkW)
{
if (path.Count <= 0){
return;
}
int[] last = path[path.Count - 1];
//
if (depth > 30){
return;
}
改掉了就好了