mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
Fix problem with items with default attachments not comparing to base items correctly
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1109 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -109,7 +109,7 @@ void ArmsDealerGetsFreshStock( UINT8 ubArmsDealer, UINT16 usItemIndex, UINT8 ub
|
|||||||
BOOLEAN ItemContainsLiquid( UINT16 usItemIndex );
|
BOOLEAN ItemContainsLiquid( UINT16 usItemIndex );
|
||||||
UINT8 DetermineDealerItemCondition( UINT8 ubArmsDealer, UINT16 usItemIndex );
|
UINT8 DetermineDealerItemCondition( UINT8 ubArmsDealer, UINT16 usItemIndex );
|
||||||
|
|
||||||
BOOLEAN IsItemInfoSpecial( SPECIAL_ITEM_INFO *pSpclItemInfo );
|
BOOLEAN IsItemInfoSpecial( SPECIAL_ITEM_INFO *pSpclItemInfo, UINT16 usItemIndex );
|
||||||
|
|
||||||
BOOLEAN DoesItemAppearInDealerInventoryList( UINT8 ubArmsDealer, UINT16 usItemIndex, BOOLEAN fPurchaseFromPlayer );
|
BOOLEAN DoesItemAppearInDealerInventoryList( UINT8 ubArmsDealer, UINT16 usItemIndex, BOOLEAN fPurchaseFromPlayer );
|
||||||
|
|
||||||
@@ -1034,7 +1034,7 @@ INT16 GetSpecialItemFromArmsDealerInventory( UINT8 ubArmsDealer, UINT16 usItemIn
|
|||||||
UINT8 ubElement;
|
UINT8 ubElement;
|
||||||
|
|
||||||
// this function won't find perfect items!
|
// this function won't find perfect items!
|
||||||
Assert( IsItemInfoSpecial( pSpclItemInfo ) );
|
Assert( IsItemInfoSpecial( pSpclItemInfo, usItemIndex ) );
|
||||||
|
|
||||||
for( ubElement = 0; ubElement < gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].ubElementsAlloced; ubElement++ )
|
for( ubElement = 0; ubElement < gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].ubElementsAlloced; ubElement++ )
|
||||||
{
|
{
|
||||||
@@ -1674,9 +1674,8 @@ void AddItemToArmsDealerInventory( UINT8 ubArmsDealer, UINT16 usItemIndex, SPECI
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// decide whether this item is "special" or not
|
// decide whether this item is "special" or not
|
||||||
if ( IsItemInfoSpecial( pSpclItemInfo ) )
|
if ( IsItemInfoSpecial( pSpclItemInfo, usItemIndex ) )
|
||||||
{
|
{
|
||||||
// Anything that's used/damaged or imprinted is store as a special item in the SpecialItem array,
|
// Anything that's used/damaged or imprinted is store as a special item in the SpecialItem array,
|
||||||
// exactly one item per element. We (re)allocate memory dynamically as necessary to hold the additional items.
|
// exactly one item per element. We (re)allocate memory dynamically as necessary to hold the additional items.
|
||||||
@@ -1684,7 +1683,7 @@ void AddItemToArmsDealerInventory( UINT8 ubArmsDealer, UINT16 usItemIndex, SPECI
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
// search for an already allocated, empty element in the special item array
|
// search for an already allocated, empty element in the special item array
|
||||||
fFoundOne = FALSE;
|
fFoundOne = FALSE;
|
||||||
for ( ubElement = 0; ubElement < gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].ubElementsAlloced; ubElement++ )
|
for ( ubElement = 0; ubElement < gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].ubElementsAlloced; ubElement++ )
|
||||||
{
|
{
|
||||||
if ( !( gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].SpecialItem[ ubElement ].fActive ) )
|
if ( !( gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].SpecialItem[ ubElement ].fActive ) )
|
||||||
@@ -1744,7 +1743,7 @@ void AddSpecialItemToArmsDealerInventoryAtElement( UINT8 ubArmsDealer, UINT16 us
|
|||||||
Assert( gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].ubTotalItems < 255 );
|
Assert( gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].ubTotalItems < 255 );
|
||||||
Assert( ubElement < gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].ubElementsAlloced );
|
Assert( ubElement < gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].ubElementsAlloced );
|
||||||
Assert( gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].SpecialItem[ ubElement ].fActive == FALSE );
|
Assert( gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].SpecialItem[ ubElement ].fActive == FALSE );
|
||||||
Assert( IsItemInfoSpecial( pSpclItemInfo ) );
|
Assert( IsItemInfoSpecial( pSpclItemInfo , usItemIndex) );
|
||||||
|
|
||||||
|
|
||||||
//Store the special values in that element, and make it active
|
//Store the special values in that element, and make it active
|
||||||
@@ -1757,6 +1756,30 @@ void AddSpecialItemToArmsDealerInventoryAtElement( UINT8 ubArmsDealer, UINT16 us
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// WDS bug fix (07/24/2007) - Items with default attachments have to be handled specially
|
||||||
|
|
||||||
|
BOOLEAN SpecialItemInfoIsIdentical (SPECIAL_ITEM_INFO& baseItem, SPECIAL_ITEM_INFO& actualItem, UINT16 usItemIndex)
|
||||||
|
{
|
||||||
|
BOOLEAN firstAttachmentIsDefault =
|
||||||
|
((actualItem.usAttachment[ 0 ] == Item [ usItemIndex ].defaultattachment) &&
|
||||||
|
(actualItem.bAttachmentStatus[0] == 100));
|
||||||
|
for (int idx=0; idx < MAX_ATTACHMENTS; ++idx) {
|
||||||
|
if ((idx != 0) || (!firstAttachmentIsDefault)) {
|
||||||
|
if (baseItem.usAttachment[idx] != actualItem.usAttachment[idx])
|
||||||
|
return FALSE;
|
||||||
|
if (baseItem.bAttachmentStatus[idx] != actualItem.bAttachmentStatus[idx])
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (baseItem.bItemCondition != actualItem.bItemCondition)
|
||||||
|
return FALSE;
|
||||||
|
if (baseItem.ubImprintID != actualItem.ubImprintID)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// removes ubHowMany items of usItemIndex with the matching Info from dealer ubArmsDealer
|
// removes ubHowMany items of usItemIndex with the matching Info from dealer ubArmsDealer
|
||||||
void RemoveItemFromArmsDealerInventory( UINT8 ubArmsDealer, UINT16 usItemIndex, SPECIAL_ITEM_INFO *pSpclItemInfo, UINT8 ubHowMany )
|
void RemoveItemFromArmsDealerInventory( UINT8 ubArmsDealer, UINT16 usItemIndex, SPECIAL_ITEM_INFO *pSpclItemInfo, UINT8 ubHowMany )
|
||||||
@@ -1764,7 +1787,6 @@ void RemoveItemFromArmsDealerInventory( UINT8 ubArmsDealer, UINT16 usItemIndex,
|
|||||||
DEALER_SPECIAL_ITEM *pSpecialItem;
|
DEALER_SPECIAL_ITEM *pSpecialItem;
|
||||||
UINT8 ubElement;
|
UINT8 ubElement;
|
||||||
|
|
||||||
|
|
||||||
Assert( ubHowMany <= gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].ubTotalItems );
|
Assert( ubHowMany <= gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].ubTotalItems );
|
||||||
|
|
||||||
if ( ubHowMany == 0)
|
if ( ubHowMany == 0)
|
||||||
@@ -1774,7 +1796,7 @@ void RemoveItemFromArmsDealerInventory( UINT8 ubArmsDealer, UINT16 usItemIndex,
|
|||||||
|
|
||||||
|
|
||||||
// decide whether this item is "special" or not
|
// decide whether this item is "special" or not
|
||||||
if ( IsItemInfoSpecial( pSpclItemInfo ) )
|
if ( IsItemInfoSpecial( pSpclItemInfo, usItemIndex ) )
|
||||||
{
|
{
|
||||||
// look through the elements, trying to find special items matching the specifications
|
// look through the elements, trying to find special items matching the specifications
|
||||||
for ( ubElement = 0; ubElement < gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].ubElementsAlloced; ubElement++ )
|
for ( ubElement = 0; ubElement < gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].ubElementsAlloced; ubElement++ )
|
||||||
@@ -1785,7 +1807,8 @@ void RemoveItemFromArmsDealerInventory( UINT8 ubArmsDealer, UINT16 usItemIndex,
|
|||||||
if ( pSpecialItem->fActive )
|
if ( pSpecialItem->fActive )
|
||||||
{
|
{
|
||||||
// and its contents are exactly what we're looking for
|
// and its contents are exactly what we're looking for
|
||||||
if( memcmp( &(gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].SpecialItem[ ubElement ].Info), pSpclItemInfo, sizeof( SPECIAL_ITEM_INFO ) ) == 0 )
|
// if( memcmp( &(gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].SpecialItem[ ubElement ].Info), pSpclItemInfo, sizeof( SPECIAL_ITEM_INFO ) ) == 0 )
|
||||||
|
if( SpecialItemInfoIsIdentical( gArmsDealersInventory[ ubArmsDealer ][ usItemIndex ].SpecialItem[ ubElement ].Info, *pSpclItemInfo, usItemIndex))
|
||||||
{
|
{
|
||||||
// Got one! Remove it
|
// Got one! Remove it
|
||||||
RemoveSpecialItemFromArmsDealerInventoryAtElement( ubArmsDealer, usItemIndex, ubElement );
|
RemoveSpecialItemFromArmsDealerInventoryAtElement( ubArmsDealer, usItemIndex, ubElement );
|
||||||
@@ -2023,7 +2046,6 @@ void MakeObjectOutOfDealerItems( UINT16 usItemIndex, SPECIAL_ITEM_INFO *pSpclIte
|
|||||||
INT8 bItemCondition;
|
INT8 bItemCondition;
|
||||||
UINT8 ubCnt;
|
UINT8 ubCnt;
|
||||||
|
|
||||||
|
|
||||||
bItemCondition = pSpclItemInfo->bItemCondition;
|
bItemCondition = pSpclItemInfo->bItemCondition;
|
||||||
|
|
||||||
//if the item condition is below 0, the item is in for repairs, so flip the sign
|
//if the item condition is below 0, the item is in for repairs, so flip the sign
|
||||||
@@ -2445,11 +2467,10 @@ void SetSpecialItemInfoFromObject( SPECIAL_ITEM_INFO *pSpclItemInfo, OBJECTTYPE
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOLEAN IsItemInfoSpecial( SPECIAL_ITEM_INFO *pSpclItemInfo )
|
BOOLEAN IsItemInfoSpecial( SPECIAL_ITEM_INFO *pSpclItemInfo, UINT16 usItemIndex )
|
||||||
{
|
{
|
||||||
UINT8 ubCnt;
|
UINT8 ubCnt;
|
||||||
|
|
||||||
|
|
||||||
// being damaged / in repairs makes an item special
|
// being damaged / in repairs makes an item special
|
||||||
if ( pSpclItemInfo->bItemCondition != 100 )
|
if ( pSpclItemInfo->bItemCondition != 100 )
|
||||||
{
|
{
|
||||||
@@ -2463,11 +2484,18 @@ BOOLEAN IsItemInfoSpecial( SPECIAL_ITEM_INFO *pSpclItemInfo )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// having an attachment makes an item special
|
// having an attachment makes an item special
|
||||||
|
// ...unless it is a default attachment (WDS fix 07/24/2007)
|
||||||
|
BOOLEAN firstAttachmentIsDefault =
|
||||||
|
((pSpclItemInfo->usAttachment[ 0 ] == Item [ usItemIndex ].defaultattachment) &&
|
||||||
|
(pSpclItemInfo->bAttachmentStatus[0] == 100));
|
||||||
|
|
||||||
for ( ubCnt = 0; ubCnt < MAX_ATTACHMENTS; ubCnt++ )
|
for ( ubCnt = 0; ubCnt < MAX_ATTACHMENTS; ubCnt++ )
|
||||||
{
|
{
|
||||||
if ( pSpclItemInfo->usAttachment[ ubCnt ] != NONE )
|
if ((ubCnt != 0) || (!firstAttachmentIsDefault)) {
|
||||||
{
|
if ( (pSpclItemInfo->usAttachment[ ubCnt ] != NONE) )
|
||||||
return(TRUE);
|
{
|
||||||
|
return(TRUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user