mirror of
https://github.com/1dot13/source.git
synced 2026-08-19 14:20:30 +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:
@@ -1757,30 +1757,30 @@ void AddCorpsesToBloodcatLair( INT16 sSectorX, INT16 sSectorY )
|
||||
Corpse.usFlags = ROTTING_CORPSE_FIND_SWEETSPOT_FROM_GRIDNO;
|
||||
|
||||
// 1st gridno
|
||||
Corpse.sGridNo = 14319; //dnl!!!
|
||||
ConvertGridNoToXY( Corpse.sGridNo, &sXPos, &sYPos );
|
||||
Corpse.dXPos = (FLOAT)( CenterX( sXPos ) );
|
||||
Corpse.dYPos = (FLOAT)( CenterY( sYPos ) );
|
||||
Corpse.sGridNo = 14319; //dnl!!!
|
||||
ConvertGridNoToCenterCellXY(Corpse.sGridNo, &sXPos, &sYPos);
|
||||
Corpse.dXPos = (FLOAT)( sXPos );
|
||||
Corpse.dYPos = (FLOAT)( sYPos );
|
||||
|
||||
//Add the rotting corpse info to the sectors unloaded rotting corpse file
|
||||
AddRottingCorpseToUnloadedSectorsRottingCorpseFile( sSectorX, sSectorY, 0, &Corpse);
|
||||
|
||||
|
||||
// 2nd gridno
|
||||
Corpse.sGridNo = 9835; //dnl!!!
|
||||
ConvertGridNoToXY( Corpse.sGridNo, &sXPos, &sYPos );
|
||||
Corpse.dXPos = (FLOAT)( CenterX( sXPos ) );
|
||||
Corpse.dYPos = (FLOAT)( CenterY( sYPos ) );
|
||||
Corpse.sGridNo = 9835; //dnl!!!
|
||||
ConvertGridNoToCenterCellXY(Corpse.sGridNo, &sXPos, &sYPos);
|
||||
Corpse.dXPos = (FLOAT)(sXPos);
|
||||
Corpse.dYPos = (FLOAT)(sYPos);
|
||||
|
||||
//Add the rotting corpse info to the sectors unloaded rotting corpse file
|
||||
AddRottingCorpseToUnloadedSectorsRottingCorpseFile( sSectorX, sSectorY, 0, &Corpse);
|
||||
|
||||
|
||||
// 3rd gridno
|
||||
Corpse.sGridNo = 11262; //dnl!!!
|
||||
ConvertGridNoToXY( Corpse.sGridNo, &sXPos, &sYPos );
|
||||
Corpse.dXPos = (FLOAT)( CenterX( sXPos ) );
|
||||
Corpse.dYPos = (FLOAT)( CenterY( sYPos ) );
|
||||
Corpse.sGridNo = 11262; //dnl!!!
|
||||
ConvertGridNoToCenterCellXY(Corpse.sGridNo, &sXPos, &sYPos);
|
||||
Corpse.dXPos = (FLOAT)(sXPos);
|
||||
Corpse.dYPos = (FLOAT)(sYPos);
|
||||
|
||||
//Add the rotting corpse info to the sectors unloaded rotting corpse file
|
||||
AddRottingCorpseToUnloadedSectorsRottingCorpseFile( sSectorX, sSectorY, 0, &Corpse);
|
||||
|
||||
Reference in New Issue
Block a user