From 142e41e1ca04a77239e9f14647eb2caa2d82873c Mon Sep 17 00:00:00 2001 From: Nikita Edel Date: Wed, 11 Mar 2026 04:08:40 +0100 Subject: [PATCH] fix sort function --- .../Platform/Common/Consoles_App.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Minecraft.Client/Platform/Common/Consoles_App.cpp b/Minecraft.Client/Platform/Common/Consoles_App.cpp index c226ca016..a89d59f90 100644 --- a/Minecraft.Client/Platform/Common/Consoles_App.cpp +++ b/Minecraft.Client/Platform/Common/Consoles_App.cpp @@ -5861,7 +5861,21 @@ Random *CMinecraftApp::TipRandom = new Random(); int CMinecraftApp::TipsSortFunction(const void* a, const void* b) { - return ((TIPSTRUCT*)a)->iSortValue - ((TIPSTRUCT*)b)->iSortValue; + // 4jcraft, scince the sortvalues can be negative, i changed it + // to a three way comparison, + // scince subtracting of signed integers can cause overflow. + + int s1 = ((TIPSTRUCT*)a)->iSortValue; + int s2 = ((TIPSTRUCT*)b)->iSortValue; + + if(s1 > s2) { + return 1; + + } else if (s1 == s2) { + return 0; + } + + return -1; } void CMinecraftApp::InitialiseTips()