mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +02:00
Reduce code duplication (#233)
* Use ConvertGridNoToCenterCellXY instead of CenterX & CenterY * Add direction utility function We have a lot of places in the code that calculate direction based on center cell coordinates, but lack a utility function for it similar to other direction methods. * Use utility function for calculating direction * Use ConvertGridNoToCenterCellXY * Use utility function for direction * Use ConvertGridNoToCenterCellXY instead of CenterX & CenterY * Use ConvertGridNoToCenterCellXY instead of CenterX & CenterY * Remove CenterX & CenterY functions Use ConvertGridNoToCenterCellXY instead * Remove CenterX & CenterY calls from UB configuration * Address review feedback * Remove duplicate function ConvertGridNoToCenterCellXY and ConvertMapPosToWorldTileCenter do the exact same thing * Use PythSpacesAway instead of GetRangeFromGridNoDiff Both functions calculate the same thing * Remove GetRangeFromGridNoDiff * Remove calls to abs() The values end up being squared anyways making these unnecessary
This commit is contained in:
@@ -2478,14 +2478,16 @@ BOOLEAN DrawCTHIndicator()
|
||||
|
||||
//////////////////////////////////
|
||||
// Calculate Aperture
|
||||
|
||||
INT16 sX, sY;
|
||||
// Calculate the center point of the shooter, in world coordinates.
|
||||
FLOAT dStartX = (FLOAT) CenterX( gCTHDisplay.iShooterGridNo );
|
||||
FLOAT dStartY = (FLOAT) CenterY( gCTHDisplay.iShooterGridNo );
|
||||
ConvertGridNoToCenterCellXY(gCTHDisplay.iShooterGridNo, &sX, &sY);
|
||||
FLOAT dStartX = (FLOAT) sX;
|
||||
FLOAT dStartY = (FLOAT) sY;
|
||||
|
||||
// Calculate the center point of the target, in world coordinates.
|
||||
FLOAT dEndX = (FLOAT) CenterX( gCTHDisplay.iTargetGridNo );
|
||||
FLOAT dEndY = (FLOAT) CenterY( gCTHDisplay.iTargetGridNo );
|
||||
ConvertGridNoToCenterCellXY(gCTHDisplay.iTargetGridNo, &sX, &sY);
|
||||
FLOAT dEndX = (FLOAT) sX;
|
||||
FLOAT dEndY = (FLOAT) sY;
|
||||
|
||||
// Calculate a delta: the difference between the shooter and target.
|
||||
FLOAT dDeltaX = dEndX - dStartX;
|
||||
@@ -6647,4 +6649,4 @@ INT16 GetBackgroundValue( UINT8 usProfile, UINT16 aNr )
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user