mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +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:
@@ -776,7 +776,7 @@ BOOLEAN EnterShopKeeperInterface()
|
||||
else
|
||||
pShopkeeper = FindSoldierByProfileID( armsDealerInfo[gbSelectedArmsDealerID].ubShopKeeperID, FALSE );
|
||||
|
||||
if ( GetRangeFromGridNoDiff( pSoldier->sGridNo, pShopkeeper->sGridNo ) > NPC_TALK_RADIUS )
|
||||
if (PythSpacesAway( pSoldier->sGridNo, pShopkeeper->sGridNo ) > NPC_TALK_RADIUS )
|
||||
{
|
||||
//so now we know we are too far away to trade, so instead of just quitting,
|
||||
//either post a message or run to the guy like HandleTalkInit does
|
||||
@@ -6668,7 +6668,7 @@ BOOLEAN CanMercInteractWithSelectedShopkeeper( SOLDIERTYPE *pSoldier )
|
||||
if ( SoldierTo3DLocationLineOfSightTest( pSoldier, sDestGridNo, bDestLevel, 3, TRUE, CALC_FROM_ALL_DIRS ) )
|
||||
{
|
||||
// Get range to shopkeeper
|
||||
uiRange = GetRangeFromGridNoDiff( pSoldier->sGridNo, sDestGridNo );
|
||||
uiRange = PythSpacesAway( pSoldier->sGridNo, sDestGridNo );
|
||||
|
||||
// and is close enough to talk to the shopkeeper (use this define INSTEAD of PASSING_ITEM_DISTANCE_OKLIFE!)
|
||||
if ( uiRange <= NPC_TALK_RADIUS )
|
||||
|
||||
Reference in New Issue
Block a user