fix: sometimes, wrong clothes were taken off

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5568 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2012-09-16 15:13:05 +00:00
parent 3e30b296cf
commit 665917e043
+17 -3
View File
@@ -14652,6 +14652,11 @@ BOOLEAN GetFirstClothesItemWithSpecificData( UINT16* pusItem, PaletteRepID aPalV
if ( !GetPaletteRepIndexFromID(aPalPants, &filler) )
pantsok = TRUE;
// getting the best item isn't straightforward. As combo clothes can be found first, we will search for each item whose clothestype matches, and retreive the loest item that has
// the lowest clothestype
UINT32 bestclothestype = 999999;
UINT16 bestitem = 0;
register UINT16 i;
for (i = 1; i < MAXITEMS; ++i)
{
@@ -14682,12 +14687,21 @@ BOOLEAN GetFirstClothesItemWithSpecificData( UINT16* pusItem, PaletteRepID aPalV
}
if ( tmpvestok && tmppantsok )
{
*pusItem = i;
return( TRUE );
{
if ( Item[i].clothestype < bestclothestype )
{
bestclothestype = Item[i].clothestype;
bestitem = i;
}
}
}
}
if ( bestitem > 0 )
{
*pusItem = bestitem;
return( TRUE );
}
return( FALSE );
}