From f943fe8509114d899466c732eb9dc622182be7fc Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 15 May 2023 09:51:27 +0200 Subject: [PATCH] RecastMesh.cpp: Fix compiler warning 2 warnings: Operation 'lkup[arr[i] & 0xF] | 0x8000;' returns an int, but should return a unsigned short; added explicit cast. Operation 'arr[i] & 0xF' could read up to 64 bytes, while the stack buffer is only 16 bytes. Switched to operation: ''arr[i] & 0x3'. The static buffer has also been declare const now. --- .../recast/Recast/Source/RecastMesh.cpp | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/r5dev/thirdparty/recast/Recast/Source/RecastMesh.cpp b/r5dev/thirdparty/recast/Recast/Source/RecastMesh.cpp index 8f18e19a..d882cd8d 100644 --- a/r5dev/thirdparty/recast/Recast/Source/RecastMesh.cpp +++ b/r5dev/thirdparty/recast/Recast/Source/RecastMesh.cpp @@ -1630,22 +1630,25 @@ void shift_left(unsigned short* arr, int count) } arr[count - 1] = zval; } -void flip_neis_direction(rcPolyMesh& mesh,unsigned short* arr, int count) +void flip_neis_direction(unsigned short* arr, int count) { - //int lkup[4] = { 0,1,2,3 }; //NOOP - int lkup[4] = { 2,1,0,3 };// flip x only - //int lkup[4] = { 0,3,2,1 }; //flip y only - //int lkup[4] = { 2,3,0,1 }; //flip x and y - //int lkup[4] = { 3,0,1,2 }; //exchange x/y (90 deg) - //int lkup[4] = { 1,2,3,0 }; //-90 deg - //int lkup[4] = { 2,3,0,1 }; //180 deg + //const int lkup[4] = { 0,1,2,3 }; //NOOP + const int lkup[4] = { 2,1,0,3 };// flip x only + //const int lkup[4] = { 0,3,2,1 }; //flip y only + //const int lkup[4] = { 2,3,0,1 }; //flip x and y + //const int lkup[4] = { 3,0,1,2 }; //exchange x/y (90 deg) + //const int lkup[4] = { 1,2,3,0 }; //-90 deg + //const int lkup[4] = { 2,3,0,1 }; //180 deg - for(int i=0;i 0 cur.y ==h && next.x ==h -> 1 @@ -1693,7 +1696,7 @@ bool rcFlipPolyMesh(rcPolyMesh& mesh) } //*/ shift_left(poly_begin_neis, cur_count); //this is needed because the neis index edges not vertexes - flip_neis_direction(mesh,poly_begin_neis, cur_count); + flip_neis_direction(poly_begin_neis, cur_count); } return true; } \ No newline at end of file