mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +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:
@@ -561,8 +561,7 @@ INT32 AddRottingCorpse( ROTTING_CORPSE_DEFINITION *pCorpseDef )
|
||||
}
|
||||
else
|
||||
{
|
||||
AniParams.sX = CenterX(pCorpse->def.sGridNo);
|
||||
AniParams.sY = CenterY(pCorpse->def.sGridNo);
|
||||
ConvertGridNoToCenterCellXY(pCorpse->def.sGridNo, &AniParams.sX, &AniParams.sY);
|
||||
}
|
||||
|
||||
AniParams.sZ = (INT16)pCorpse->def.sHeightAdjustment;
|
||||
@@ -1588,8 +1587,7 @@ void VaporizeCorpse( INT32 sGridNo, INT8 asLevel, UINT16 usStructureID )
|
||||
AniParams.sDelay = (INT16)( 80 );
|
||||
AniParams.sStartFrame = 0;
|
||||
AniParams.uiFlags = ANITILE_CACHEDTILE | ANITILE_FORWARD;
|
||||
AniParams.sX = CenterX( sBaseGridNo );
|
||||
AniParams.sY = CenterY( sBaseGridNo );
|
||||
ConvertGridNoToCenterCellXY(sBaseGridNo, &AniParams.sX, &AniParams.sY);
|
||||
AniParams.sZ = (INT16)pCorpse->def.sHeightAdjustment;
|
||||
|
||||
strcpy( AniParams.zCachedFile, "TILECACHE\\GEN_BLOW.STI" );
|
||||
@@ -2284,10 +2282,12 @@ BOOLEAN AddCorpseFromObject(OBJECTTYPE* pObj, INT32 sGridNo, INT8 bLevel )
|
||||
Corpse.ubBodyType = REGMALE;
|
||||
}
|
||||
|
||||
INT16 sX, sY;
|
||||
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);
|
||||
|
||||
Corpse.sGridNo = sGridNo;
|
||||
|
||||
Corpse.dXPos = CenterX(Corpse.sGridNo);
|
||||
Corpse.dYPos = CenterY(Corpse.sGridNo);
|
||||
Corpse.dXPos = sX;
|
||||
Corpse.dYPos = sY;
|
||||
|
||||
Corpse.sHeightAdjustment = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user