From 87809f222fc0228219261f056d19000fc2710726 Mon Sep 17 00:00:00 2001 From: Flugente Date: Sat, 14 Jan 2017 22:41:48 +0000 Subject: [PATCH] Gun selection at shopkeepers is pre-sorted by weapon type (by DepressivesBrot) git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8366 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/ArmsDealerInvInit.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Tactical/ArmsDealerInvInit.cpp b/Tactical/ArmsDealerInvInit.cpp index df066d3b4..3ee03a13d 100644 --- a/Tactical/ArmsDealerInvInit.cpp +++ b/Tactical/ArmsDealerInvInit.cpp @@ -1353,6 +1353,21 @@ int CompareItemsForSorting( UINT16 usItem1Index, UINT16 usItem2Index, UINT16 ubI return( 1 ); } + if ( Item[usItem1Index].usItemClass == IC_GUN && Item[usItem2Index].usItemClass == IC_GUN ) + { + UINT8 ubItem1WeaponType = Weapon[Item[usItem1Index].ubClassIndex].ubWeaponType; + UINT8 ubItem2WeaponType = Weapon[Item[usItem2Index].ubClassIndex].ubWeaponType; + + if ( ubItem1WeaponType < ubItem2WeaponType ) + { + return (-1); + } + else if ( ubItem1WeaponType > ubItem2WeaponType ) + { + return (1); + } + } + // the same category //if ( Item[ usItem1Index ].usItemClass == IC_AMMO && Item[ usItem2Index ].usItemClass == IC_AMMO ) //{ @@ -1467,7 +1482,7 @@ UINT8 GetDealerItemCategoryNumber( UINT16 usItemIndex ) if ( usItemIndex < gMAXITEMS_READ && IsWeapon( usItemIndex ) ) { - ubWeaponClass = 0;// Madd: commented out so we can sort guns by name instead ... Weapon[ usItemIndex ].ubWeaponClass; + ubWeaponClass = Weapon[usItemIndex].ubWeaponClass; } else {