From 2a8d0ab928f0d827e0a9f9773a8411eec1b75112 Mon Sep 17 00:00:00 2001
From: Peace-Maker <peace-maker@wcfan.de>
Date: Tue, 17 Dec 2024 13:52:43 +0100
Subject: [PATCH] Fix compilation with SourcePawn 1.12

Cannot pass an array of enum structs to `SortCustom2D` anymore.
---
 .gitignore                     |  2 ++
 compile.sh                     | 10 ++++------
 scripting/smrpg/smrpg_stats.sp |  7 ++++++-
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/.gitignore b/.gitignore
index 818c559..cc0bbfa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
 *.smx
+build/
+package/
diff --git a/compile.sh b/compile.sh
index 8a2f395..0ebcb75 100755
--- a/compile.sh
+++ b/compile.sh
@@ -44,8 +44,6 @@ fi
 
 # setup the auto version file to have the git revision in the version convar.
 # get the correct revision count
-# https://github.com/travis-ci/travis-ci/issues/3412
-git fetch --unshallow
 GITREVCOUNT=$(git rev-list --count HEAD)
 
 echo -e "#if defined _smrpg_version_included\n#endinput\n#endif\n#define _smrpg_version_included\n\n" > build/addons/sourcemod/scripting/include/smrpg/smrpg_autoversion.inc
@@ -74,16 +72,16 @@ do
 	if [ "$f" != "smrpg_chattags.sp" ]; then
 		echo -e "\nCompiling $f..."
 		smxfile="`echo $f | sed -e 's/\.sp$/\.smx/'`"
-		./spcomp $f -o$PACKAGEDIR/plugins/$smxfile -E
+		./spcomp $f -o$PACKAGEDIR/plugins/$smxfile
 	fi
 done
 
 # compile both versions of chattags for both chat processors..
 echo -e "\nCompiling smrpg_chattags.sp for Chat Processor..."
-./spcomp smrpg_chattags.sp -o$PACKAGEDIR/plugins/smrpg_chattags_cp.smx -E
+./spcomp smrpg_chattags.sp -o$PACKAGEDIR/plugins/smrpg_chattags_cp.smx
 
 echo -e "\nCompiling smrpg_chattags.sp for Simple Chat Processor..."
-./spcomp smrpg_chattags.sp -o$PACKAGEDIR/plugins/smrpg_chattags_scp.smx -E USE_SIMPLE_PROCESSOR=
+./spcomp smrpg_chattags.sp -o$PACKAGEDIR/plugins/smrpg_chattags_scp.smx USE_SIMPLE_PROCESSOR=
 
 # compile all upgrades
 for f in upgrades/*.sp
@@ -92,7 +90,7 @@ do
 	if [ "$f" != "upgrades/smrpg_upgrade_example.sp" ]; then
 		echo -e "\nCompiling upgrade $f..."
 		smxfile="`echo $f | sed -e 's/\.sp$/\.smx/'`"
-		./spcomp $f -o$PACKAGEDIR/plugins/$smxfile -E
+		./spcomp $f -o$PACKAGEDIR/plugins/$smxfile
 	fi
 done
 
diff --git a/scripting/smrpg/smrpg_stats.sp b/scripting/smrpg/smrpg_stats.sp
index 17981e4..3a67b3c 100644
--- a/scripting/smrpg/smrpg_stats.sp
+++ b/scripting/smrpg/smrpg_stats.sp
@@ -1115,7 +1115,12 @@ public void SQL_GetNext10(Database db, DBResultSet results, const char[] error,
 		nextCache[i].credits = GetClientCredits(iLocalPlayer);
 	}
 	
-	SortCustom2D(nextCache, iCount, Sort2D_NextPlayers);
+	int nextCacheWorkaround[sizeof(nextCache)][sizeof(nextCache[])];
+	for (int i = 0; i < iCount; i++)
+		Array_Copy(nextCache[i], nextCacheWorkaround[i], sizeof(nextCache[]));
+	SortCustom2D(nextCacheWorkaround, iCount, Sort2D_NextPlayers);
+	for (int i = 0; i < iCount; i++)
+		Array_Copy(nextCacheWorkaround[i], nextCache[i], sizeof(nextCache[]));
 	
 	// Save the next rank as reference if the list is reordered with current data below
 	int iLastRank = nextCache[0].rank;