mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
Fixed two bugs:
1st) Weight Overflow, mostly when calculating Weight of Creature Spit Ammo. This has no Ammo, so the old code calculated accidentally -1.6f, resulting in 0xFFFF integer 2nd) GetAttachmentComboMerge() improved. Now a base item can be merged with _different_ 2nd items to result in _different_ merges. Before, a base item was only able to be merged to _one_ result. F.I. if we want to make a Dart gun from Dart pistol by adding (a buttstock and) wheter a steel tube /or/ a Gun Barrel Extender, the old code wouldn't work for the Gun Barel Extender, since it would never been tested, if there is a Gun Barrel. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1069 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+33
-10
@@ -2238,7 +2238,11 @@ UINT8 CalculateObjectWeight( OBJECTTYPE *pObject )
|
||||
// add in weight of ammo
|
||||
if (Item[ pObject->usItem ].usItemClass == IC_GUN && pObject->ubGunShotsLeft > 0)
|
||||
{
|
||||
if( gGameExternalOptions.fAmmoDynamicWeight == TRUE )
|
||||
if( 0==pObject->usGunAmmoItem ) /* Sergeant_Kolja: 2007-06-11, Fix for Creature Spit. This has no Ammo, so the old code calculated accidentally -1.6 resulting in 0xFFFF */
|
||||
{
|
||||
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, "'no ammo weight' FIX for Creatures\r\n" );
|
||||
}
|
||||
else if( gGameExternalOptions.fAmmoDynamicWeight == TRUE )
|
||||
{
|
||||
//Pulmu:
|
||||
//Temporary calculation for minWeight
|
||||
@@ -3122,31 +3126,50 @@ BOOLEAN AutoReload( SOLDIERTYPE * pSoldier )
|
||||
INT8 GetAttachmentComboMerge( OBJECTTYPE * pObj )
|
||||
{
|
||||
INT8 bIndex = 0;
|
||||
INT8 bAttachLoop, bAttachPos;
|
||||
INT8 bAttachLoop, bAttachPos = -1;
|
||||
|
||||
while( AttachmentComboMerge[ bIndex ].usItem != NOTHING )
|
||||
/* check the whole Array of possible Attachements, while there are still entries ... */
|
||||
while( AttachmentComboMerge[ bIndex ].usItem != NOTHING )
|
||||
{
|
||||
if ( pObj->usItem == AttachmentComboMerge[ bIndex ].usItem )
|
||||
/* if we found our current Object as "basic hand" item, then
|
||||
* we have found at least ONE entry of our item (may be there are more)
|
||||
*/
|
||||
if ( pObj->usItem == AttachmentComboMerge[ bIndex ].usItem )
|
||||
{
|
||||
// search for all the appropriate attachments
|
||||
/* every ComboMerge must have at least one attachments Field */
|
||||
for ( bAttachLoop = 0; bAttachLoop < 2; bAttachLoop++ )
|
||||
{
|
||||
if ( AttachmentComboMerge[ bIndex ].usAttachment[ bAttachLoop ] == NOTHING )
|
||||
/* if the none of both Fields contains anything, do not merge */
|
||||
if ( AttachmentComboMerge[ bIndex ].usAttachment[ bAttachLoop ] == NOTHING )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bAttachPos = FindAttachment( pObj, AttachmentComboMerge[ bIndex ].usAttachment[ bAttachLoop ] );
|
||||
/* 2007-05-27, Sgt_Kolja:
|
||||
* do not return, but break the inner loop moved away, otherwise
|
||||
* we can only have ONE attachmentCombo per basic item. F.I. if we want
|
||||
* to make a Dart gun from Dart pistol by adding (a buttstock and) wheter a
|
||||
* steel tube /or/ a Gun Barrel Extender, the old code wouldn't work for
|
||||
* the Gun Barel Extender, since it would never been tested.
|
||||
*/
|
||||
if ( bAttachPos == -1 )
|
||||
{
|
||||
// didn't find something required
|
||||
return( -1 );
|
||||
// didn't find something required
|
||||
//return( -1 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
// found everything required!
|
||||
return( bIndex );
|
||||
}
|
||||
// found everything required?
|
||||
/* 2007-05-27, Sgt_Kolja: Not-found-condition moved from above, otherwise we can only have ONE attachmentCombo per basic item */
|
||||
if ( bAttachPos != -1 )
|
||||
{
|
||||
return( bIndex );
|
||||
}
|
||||
} /* end-if-this-is-our-item */
|
||||
|
||||
/* try next Attachment Order */
|
||||
bIndex++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user