Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Tactical/DisplayCover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1823,8 +1823,8 @@ void CalculateWeapondata()
pObjUsed = pObjPlatform;
}

gunrange = GunRange( pObjUsed, pSoldier ) / 10;
laserrange = GetBestLaserRange( pObjPlatform ) / 10;
gunrange = GunRange( pObjUsed, pSoldier ) / CELL_X_SIZE;
laserrange = GetBestLaserRange( pObjPlatform ) / CELL_X_SIZE;

if ( Item[pObjUsed->usItem].usItemClass & IC_LAUNCHER )
{
Expand Down
68 changes: 38 additions & 30 deletions Tactical/Interface Enhanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1621,8 +1621,8 @@ void InternalInitEDBTooltipRegion( OBJECTTYPE * gpItemDescObject, UINT32 guiCurr

/////////////////// PROJECTION FACTOR / NCTH BEST LASER RANGE
// with the reworked NCTH code and the laser performance factor we will display BestLaserRange instead of ProjectionFactor but we still need the mouse region
if (UsingNewCTHSystem() && ( GetProjectionFactor( gpItemDescObject ) > 1.0 || GetBestLaserRange( gpItemDescObject ) > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) ) )
if (UsingNewCTHSystem() && ( GetProjectionFactor( gpItemDescObject ) > 1.0 || (GetBestLaserRange(gpItemDescObject) / CELL_X_SIZE > 0
Copy link
Copy Markdown
Contributor

@NorthFury NorthFury May 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding / CELL_X_SIZE doesn't change the evaluation of the condition unless CELL_X_SIZE can be negative. I see CELL_X_SIZE is a constant defined as 10.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It changes condition for cases when GetBestLaserRange(gpItemDescObject) returns [0..9]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. The division is evaluated to an integer. Thank you for the clarification.

&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0)) ) )
Copy link
Copy Markdown
Contributor

@NorthFury NorthFury May 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this also be checking if it's higher than zero?

gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE > 0

Copy link
Copy Markdown
Contributor Author

@sun-alf sun-alf May 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. But this was out of the scope of issue I resolved.

{
ubRegionOffset = 6;
MSYS_EnableRegion( &gUDBFasthelpRegions[ iFirstDataRegion + ubRegionOffset ] );
Expand All @@ -1637,7 +1637,7 @@ void InternalInitEDBTooltipRegion( OBJECTTYPE * gpItemDescObject, UINT32 guiCurr
}

/////////////////// OCTH BEST LASER RANGE
if (!UsingNewCTHSystem() && (Item[gpItemDescObject->usItem].bestlaserrange > 0 || GetAverageBestLaserRange( gpItemDescObject ) > 0 ) )
if ( UsingNewCTHSystem() == false && (GetAverageBestLaserRange(gpItemDescObject) / CELL_X_SIZE) > 0 )
{
ubRegionOffset = 7;
MSYS_EnableRegion( &gUDBFasthelpRegions[ iFirstDataRegion + ubRegionOffset ] );
Expand Down Expand Up @@ -2874,10 +2874,10 @@ void InternalInitEDBTooltipRegion( OBJECTTYPE * gpItemDescObject, UINT32 guiCurr
///////////////////// ACCURACY MODIFIER
if (GetAccuracyModifier( gpItemDescObject ) != 0 )
{
if (cnt >= sFirstLine && cnt < sLastLine)
{
if( UsingNewCTHSystem() == true )
if (UsingNewCTHSystem() == true)
{
if (cnt >= sFirstLine && cnt < sLastLine)
{
if (Item[ gpItemDescObject->usItem ].usItemClass & (IC_WEAPON|IC_PUNCH))
{
swprintf( pStr, L"%s%s", szUDBAdvStatsTooltipText[ 0 ], szUDBAdvStatsExplanationsTooltipTextForWeapons[ 0 ]);
Expand Down Expand Up @@ -3255,9 +3255,9 @@ void InternalInitEDBTooltipRegion( OBJECTTYPE * gpItemDescObject, UINT32 guiCurr

///////////////////// PROJECTION FACTOR / BEST LASER RANGE
// with the reworked NCTH code and the laser performance factor we will display BestLaserRange instead of ProjectionFactor
if ( ( UsingNewCTHSystem() && GetBestLaserRange( gpItemDescObject ) > 0
if ( ( UsingNewCTHSystem() && (GetBestLaserRange(gpItemDescObject) / CELL_X_SIZE) > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) )
|| ( !UsingNewCTHSystem() && GetBestLaserRange( gpItemDescObject ) > 0 ) )
|| ( !UsingNewCTHSystem() && (GetBestLaserRange(gpItemDescObject) / CELL_X_SIZE) > 0 ) )
{
if (cnt >= sFirstLine && cnt < sLastLine)
{
Expand Down Expand Up @@ -4434,10 +4434,12 @@ void DrawWeaponStats( OBJECTTYPE * gpItemDescObject )

//////////////////// PROJECTION FACTOR / NCTH BEST LASER RANGE
// with the reworked NCTH code and the laser performance factor we will display BestLaserRange instead of ProjectionFactor but we use the same icon
if ( (UsingNewCTHSystem() && ( GetProjectionFactor( gpItemDescObject ) > 1.0 || ( GetBestLaserRange( gpItemDescObject ) > 0
INT16 itemLaserRangeTiles = GetBestLaserRange(gpItemDescObject) / CELL_X_SIZE;
INT16 comparedLaserRangeTiles = fComparisonMode ? GetBestLaserRange(gpComparedItemDescObject) / CELL_X_SIZE : 0;
if ( (UsingNewCTHSystem() && ( GetProjectionFactor( gpItemDescObject ) > 1.0 || ( itemLaserRangeTiles > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) ) ) ) ||
( fComparisonMode && UsingNewCTHSystem() && ( (GetProjectionFactor( gpItemDescObject ) > 1.0 || GetProjectionFactor( gpComparedItemDescObject ) > 1.0) ||
( GetBestLaserRange( gpComparedItemDescObject ) > 0
( comparedLaserRangeTiles > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) ) ) ) )
{
ubNumLine = 6;
Expand All @@ -4455,8 +4457,8 @@ void DrawWeaponStats( OBJECTTYPE * gpItemDescObject )
}

//////////////////// OCTH BEST LASER RANGE
if ( !UsingNewCTHSystem() && ( GetBestLaserRange( gpItemDescObject ) ||
( fComparisonMode && GetBestLaserRange( gpComparedItemDescObject ) ) ) )
if ( UsingNewCTHSystem() == false &&
(itemLaserRangeTiles != 0 || (fComparisonMode && comparedLaserRangeTiles != 0)) )
{
ubNumLine = 7;
BltVideoObjectFromIndex( guiSAVEBUFFER, guiItemInfoWeaponIcon, 14, gItemDescGenRegions[ubNumLine][0].sLeft+sOffsetX, gItemDescGenRegions[ubNumLine][0].sTop+sOffsetY, VO_BLT_SRCTRANSPARENCY, NULL );
Expand Down Expand Up @@ -5347,11 +5349,13 @@ void DrawAdvancedStats( OBJECTTYPE * gpItemDescObject )

///////////////////// PROJECTION FACTOR / BEST LASER RANGE
// with the reworked NCTH code and the laser performance factor we will display BestLaserRange instead of ProjectionFactor but we use the same icon
if ( ( UsingNewCTHSystem() && ( GetProjectionFactor( gpItemDescObject ) > 1.0 || ( GetBestLaserRange( gpItemDescObject ) > 0
INT16 itemLaserRangeTiles = GetBestLaserRange(gpItemDescObject) / CELL_X_SIZE;
INT16 comparedLaserRangeTiles = fComparisonMode ? GetBestLaserRange(gpComparedItemDescObject) / CELL_X_SIZE : 0;
if ( ( UsingNewCTHSystem() && ( GetProjectionFactor( gpItemDescObject ) > 1.0 || ( itemLaserRangeTiles > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) ) ) ||
( fComparisonMode && ( GetProjectionFactor( gpComparedItemDescObject ) > 1.0 || ( GetBestLaserRange( gpComparedItemDescObject ) > 0
( fComparisonMode && ( GetProjectionFactor( gpComparedItemDescObject ) > 1.0 || ( comparedLaserRangeTiles > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) ) ) ) ) ||
( !UsingNewCTHSystem() && ( GetBestLaserRange( gpItemDescObject ) > 0 || ( fComparisonMode && GetBestLaserRange( gpComparedItemDescObject ) > 0 ) ) ) )
( !UsingNewCTHSystem() && ( itemLaserRangeTiles > 0 || ( fComparisonMode && comparedLaserRangeTiles > 0 ) ) ) )
{
if (cnt >= sFirstLine && cnt < sLastLine)
{
Expand Down Expand Up @@ -7532,9 +7536,11 @@ void DrawWeaponValues( OBJECTTYPE * gpItemDescObject )

///////////////// (LASER) PROJECTION FACTOR
// with the reworked NCTH code and the laser performance factor we will display BestLaserRange instead of ProjectionFactor
INT16 itemLaserRangeTiles = GetBestLaserRange(gpItemDescObject) / CELL_X_SIZE;
INT16 comparedLaserRangeTiles = fComparisonMode ? GetBestLaserRange(gpComparedItemDescObject) / CELL_X_SIZE : 0;
if (UsingNewCTHSystem() == true &&
( (Item[gpItemDescObject->usItem].projectionfactor > 1.0 || GetProjectionFactor( gpItemDescObject ) > 1.0) ||
( GetBestLaserRange( gpItemDescObject ) > 0
( itemLaserRangeTiles > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) ) ) )
{
// Set line to draw into
Expand All @@ -7545,13 +7551,13 @@ void DrawWeaponValues( OBJECTTYPE * gpItemDescObject )
FLOAT iFinalProjectionValue = 0;
BOOLEAN bNewCode = FALSE;

if ( GetBestLaserRange( gpItemDescObject ) > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) )
if ( itemLaserRangeTiles > 0 &&
(gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) )
{
// Get base laser range
iProjectionValue = __max(0, Item[ gpItemDescObject->usItem ].bestlaserrange * gItemSettings.fBestLaserRangeModifier / CELL_X_SIZE);
// Get best laser range
iProjectionModifier = ((FLOAT)GetBestLaserRange( gpItemDescObject ) / CELL_X_SIZE);
iProjectionModifier = (FLOAT)itemLaserRangeTiles;
// Get final laser range
iFinalProjectionValue = __max( iProjectionValue, iProjectionModifier );
bNewCode = TRUE;
Expand Down Expand Up @@ -7609,7 +7615,7 @@ void DrawWeaponValues( OBJECTTYPE * gpItemDescObject )
// Get base laser range
iComparedProjectionValue = __max(0, Item[ gpComparedItemDescObject->usItem ].bestlaserrange * gItemSettings.fBestLaserRangeModifier / CELL_X_SIZE);
// Get best laser range
iComparedProjectionModifier = ((FLOAT)GetBestLaserRange( gpComparedItemDescObject ) / CELL_X_SIZE);
iComparedProjectionModifier = (FLOAT)comparedLaserRangeTiles;
// Get final laser range
iComparedFinalProjectionValue = __max( iComparedProjectionValue, iComparedProjectionModifier );
}
Expand All @@ -7632,7 +7638,7 @@ void DrawWeaponValues( OBJECTTYPE * gpItemDescObject )
}
else if( fComparisonMode && UsingNewCTHSystem() == true &&
( (Item[gpComparedItemDescObject->usItem].projectionfactor > 1.0 || GetProjectionFactor( gpComparedItemDescObject ) > 1.0) ||
( GetBestLaserRange( gpItemDescObject ) > 0
( itemLaserRangeTiles > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) ) ) )
{
ubNumLine = 6;
Expand All @@ -7642,13 +7648,13 @@ void DrawWeaponValues( OBJECTTYPE * gpItemDescObject )
FLOAT iFinalProjectionValue = 0;
BOOLEAN bNewCode = FALSE;

if ( GetBestLaserRange( gpComparedItemDescObject ) > 0
if ( comparedLaserRangeTiles > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) )
{
// Get base laser range
iProjectionValue = __max(0, Item[ gpComparedItemDescObject->usItem ].bestlaserrange * gItemSettings.fBestLaserRangeModifier / CELL_X_SIZE);
// Get best laser range
iProjectionModifier = ((FLOAT)GetBestLaserRange( gpComparedItemDescObject ) / CELL_X_SIZE);
iProjectionModifier = (FLOAT)comparedLaserRangeTiles;
// Get final laser range
iFinalProjectionValue = __max( iProjectionValue, iProjectionModifier );
bNewCode = TRUE;
Expand Down Expand Up @@ -7752,7 +7758,7 @@ void DrawWeaponValues( OBJECTTYPE * gpItemDescObject )
}

///////////////// OCTH BEST LASER RANGE
if ( !UsingNewCTHSystem() && GetBestLaserRange( gpItemDescObject ) > 0 )
if ( !UsingNewCTHSystem() && itemLaserRangeTiles > 0 )
{
// Set line to draw into
ubNumLine = 7;
Expand Down Expand Up @@ -7789,7 +7795,7 @@ void DrawWeaponValues( OBJECTTYPE * gpItemDescObject )
DrawPropertyValueInColour( iComparedFinalBestLaserRangeValue - iFinalBestLaserRangeValue, ubNumLine, 3, fComparisonMode, FALSE, TRUE );
}
}
else if( !UsingNewCTHSystem() && ( fComparisonMode && GetBestLaserRange( gpComparedItemDescObject ) > 0 ) )
else if( !UsingNewCTHSystem() && ( fComparisonMode && comparedLaserRangeTiles > 0 ) )
{
// Set line to draw into
ubNumLine = 7;
Expand Down Expand Up @@ -11366,14 +11372,16 @@ void DrawAdvancedValues( OBJECTTYPE *gpItemDescObject )
cnt++;
}

BOOLEAN bNewCode = FALSE;
///////////////////// PROJECTION FACTOR / BEST LASER RANGE
// with the reworked NCTH code and the laser performance factor we will display BestLaserRange instead of ProjectionFactor
if ( ( UsingNewCTHSystem() && ( GetBestLaserRange( gpItemDescObject ) > 0 || ( fComparisonMode && GetBestLaserRange( gpComparedItemDescObject ) > 0
BOOLEAN bNewCode = FALSE;
INT16 itemLaserRangeTiles = GetBestLaserRange(gpItemDescObject) / CELL_X_SIZE;
INT16 comparedLaserRangeTiles = fComparisonMode ? GetBestLaserRange(gpComparedItemDescObject) / CELL_X_SIZE : 0;
if ( ( UsingNewCTHSystem() && (itemLaserRangeTiles > 0 || ( fComparisonMode && comparedLaserRangeTiles > 0
&& (gGameCTHConstants.LASER_PERFORMANCE_BONUS_HIP + gGameCTHConstants.LASER_PERFORMANCE_BONUS_IRON + gGameCTHConstants.LASER_PERFORMANCE_BONUS_SCOPE != 0) ) ) )
|| ( !UsingNewCTHSystem() && ( GetBestLaserRange( gpItemDescObject ) > 0 || ( fComparisonMode && GetBestLaserRange( gpComparedItemDescObject ) > 0 ) ) ) )
|| ( !UsingNewCTHSystem() && (itemLaserRangeTiles > 0 || ( fComparisonMode && comparedLaserRangeTiles > 0 ) ) ) )
{
iFloatModifier[0] = ((FLOAT)GetBestLaserRange( gpItemDescObject ) / CELL_X_SIZE);
iFloatModifier[0] = (FLOAT)itemLaserRangeTiles;
bNewCode = TRUE;
}
else
Expand All @@ -11384,7 +11392,7 @@ void DrawAdvancedValues( OBJECTTYPE *gpItemDescObject )
if( fComparisonMode )
{
if ( bNewCode )
iComparedFloatModifier[0] = ((FLOAT)GetBestLaserRange( gpComparedItemDescObject ) / CELL_X_SIZE);
iComparedFloatModifier[0] = (FLOAT)comparedLaserRangeTiles;
else
iComparedFloatModifier[0] = GetProjectionFactor( gpComparedItemDescObject );
iComparedFloatModifier[1] = iComparedFloatModifier[0];
Expand Down
23 changes: 9 additions & 14 deletions Tactical/Items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14078,29 +14078,29 @@ INT16 GetFlatToHitBonus( OBJECTTYPE * pObj )
// HEADROCK: Function to get average of all "best laser range" attributes from weapon and attachments
INT16 GetAverageBestLaserRange( OBJECTTYPE * pObj )
{
INT16 bonus=0;
FLOAT bonus = 0.0;
INT16 numModifiers=0;

if (Item[pObj->usItem].bestlaserrange > 0)
{
numModifiers++;
bonus += Item[pObj->usItem].bestlaserrange;
bonus += (FLOAT) Item[pObj->usItem].bestlaserrange;
}
for (attachmentList::iterator iter = (*pObj)[0]->attachments.begin(); iter != (*pObj)[0]->attachments.end(); ++iter)
{
if (Item[iter->usItem].bestlaserrange > 0 && iter->exists())
{
numModifiers++;
bonus += Item[iter->usItem].bestlaserrange;
bonus += (FLOAT) Item[iter->usItem].bestlaserrange;
}
}

if (numModifiers>0)
if (numModifiers > 1)
{
bonus = bonus / numModifiers;
}

return( bonus * gItemSettings.fBestLaserRangeModifier );
return (INT16)(bonus * gItemSettings.fBestLaserRangeModifier);
}

// get the best laser range from the weapon and attachments
Expand All @@ -14120,7 +14120,7 @@ INT16 GetBestLaserRange( OBJECTTYPE * pObj )
}
}

return( range * gItemSettings.fBestLaserRangeModifier );
return (INT16) ((FLOAT)range * gItemSettings.fBestLaserRangeModifier);
}

// HEADROCK: This function determines the bipod bonii of the gun or its attachments
Expand Down Expand Up @@ -15642,14 +15642,9 @@ BOOLEAN GetItemFromRandomItem( UINT16 usRandomItem, UINT16* pusNewItem )
// as it is also possible to reference to other random items, we also have to check for them

// clear the random item arrays and reset the counters
for ( int i = 0; i < RANDOM_ITEM_MAX_NUMBER; ++i)
randomitemarray[i] = 0;

for ( int i = 0; i < RANDOM_TABOO_MAX; ++i)
{
randomitemtabooarray[i] = 0;
randomitemclasstabooarray[i] = 0;
}
memset(randomitemarray, 0, sizeof(randomitemarray));
memset(randomitemtabooarray, 0, sizeof(randomitemtabooarray));
memset(randomitemclasstabooarray, 0, sizeof(randomitemclasstabooarray));

itemcnt = 0;
rdtaboocnt = 0;
Expand Down