mirror of
https://github.com/1dot13/source.git
synced 2026-08-12 14:10:23 +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:
+11
-10
@@ -1878,8 +1878,10 @@ BOOLEAN LoadRottingCorpsesFromTempCorpseFile( INT16 sMapX, INT16 sMapY, INT8 bMa
|
||||
def.sGridNo = gMapInformation.sWestGridNo;
|
||||
}
|
||||
//Recalculate the dx,dy info
|
||||
def.dXPos = CenterX( def.sGridNo );
|
||||
def.dYPos = CenterY( def.sGridNo );
|
||||
INT16 sX, sY;
|
||||
ConvertGridNoToCenterCellXY(def.sGridNo, &sX, &sY);
|
||||
def.dXPos = sX;
|
||||
def.dYPos = sY;
|
||||
// If not from loading a save....
|
||||
if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) )
|
||||
{
|
||||
@@ -2737,15 +2739,14 @@ BOOLEAN AddDeadSoldierToUnLoadedSector( INT16 sMapX, INT16 sMapY, UINT8 bMapZ, S
|
||||
memset( &Corpse, 0, sizeof( ROTTING_CORPSE_DEFINITION ) );
|
||||
|
||||
// Setup some values!
|
||||
Corpse.ubBodyType = pSoldier->ubBodyType;
|
||||
Corpse.sGridNo = sGridNo;
|
||||
ConvertGridNoToCenterCellXY(sGridNo, &sXPos, &sYPos);
|
||||
|
||||
ConvertGridNoToXY( sGridNo, &sXPos, &sYPos );
|
||||
|
||||
Corpse.dXPos = (FLOAT)( CenterX( sXPos ) );
|
||||
Corpse.dYPos = (FLOAT)( CenterY( sYPos ) );
|
||||
Corpse.sHeightAdjustment = pSoldier->sHeightAdjustment;
|
||||
Corpse.bVisible = TRUE;
|
||||
Corpse.ubBodyType = pSoldier->ubBodyType;
|
||||
Corpse.sGridNo = sGridNo;
|
||||
Corpse.dXPos = (FLOAT)( sXPos );
|
||||
Corpse.dYPos = (FLOAT)( sYPos );
|
||||
Corpse.sHeightAdjustment = pSoldier->sHeightAdjustment;
|
||||
Corpse.bVisible = TRUE;
|
||||
|
||||
SET_PALETTEREP_ID ( Corpse.HeadPal, pSoldier->HeadPal );
|
||||
SET_PALETTEREP_ID ( Corpse.VestPal, pSoldier->VestPal );
|
||||
|
||||
Reference in New Issue
Block a user