Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions Multiplayer/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,10 +815,8 @@ void recievePATH(RPCParameters *rpcParameters)
SendGetNewSoldierPathEvent( pSoldier, SNetPath->sDestGridNo, SNetPath->ubNewState );

INT16 sCellX, sCellY;

sCellX = CenterX( SNetPath->sAtGridNo );
sCellY = CenterY( SNetPath->sAtGridNo );

ConvertGridNoToCenterCellXY(SNetPath->sAtGridNo, &sCellX, &sCellY);

if (( gAnimControl[ pSoldier->usAnimState ].uiFlags & ( ANIM_MOVING | ANIM_SPECIALMOVE ) ) && !(pSoldier->flags.fNoAPToFinishMove ) )
{
}
Expand Down Expand Up @@ -4251,8 +4249,7 @@ void UpdateSoldierFromNetwork (RPCParameters *rpcParameters)
pSoldier->stats.bLife=SUpdateNetworkSoldier->bLife;

INT16 sCellX, sCellY;
sCellX = CenterX( SUpdateNetworkSoldier->sAtGridNo );
sCellY = CenterY( SUpdateNetworkSoldier->sAtGridNo );
ConvertGridNoToCenterCellXY(SUpdateNetworkSoldier->sAtGridNo, &sCellX, &sCellY);

if( pSoldier->sGridNo != SUpdateNetworkSoldier->sAtGridNo)
{
Expand Down Expand Up @@ -5281,4 +5278,4 @@ void ChatCallback( UINT8 ubResult )
void OpenChatMsgBox( void )
{
DoChatBox((guiCurrentScreen == GAME_SCREEN? true : false),gzMPChatboxText[1],guiCurrentScreen,ChatCallback,NULL);
}
}
24 changes: 12 additions & 12 deletions Strategic/Strategic Movement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Strategic/strategicmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4773,8 +4773,8 @@ void DoneFadeOutAdjacentSector( )
curr->pSoldier->ubWaitActionToDo = 1;
// OK, here we have been given a position, a gridno has been given to use as well....
sOldGridNo = curr->pSoldier->sGridNo;
sWorldX = CenterX( sGridNo );
sWorldY = CenterY( sGridNo );
ConvertGridNoToCenterCellXY(sGridNo, &sWorldX, &sWorldY);

curr->pSoldier->EVENT_SetSoldierPosition( sWorldX, sWorldY );
if ( sGridNo != sOldGridNo )
{
Expand Down
22 changes: 9 additions & 13 deletions Tactical/Air Raid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,8 @@ INT32 PickRandomLocationAtMinSpacesAway( INT32 sGridNo, INT16 sMinValue, INT16 s

DebugMsg(TOPIC_JA2,DBG_LEVEL_3,"PickRandomLocationAtMinSpacesAway");

sX = CenterX( sGridNo );
sY = CenterY( sGridNo );

ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);

while(TileIsOutOfBounds(sNewGridNo))
{
sNewX = sX + sMinValue + (INT16)Random( sRandomVar );
Expand Down Expand Up @@ -596,8 +595,7 @@ void BeginBombing( )
sGridNo = PickRandomLocationAtMinSpacesAway( gsDiveTargetLocation , 300, 200 );

// Save X, y:
gsDiveX = CenterX( sGridNo );
gsDiveY = CenterY( sGridNo );
ConvertGridNoToCenterCellXY(sGridNo, &gsDiveX, &gsDiveY);

RESETTIMECOUNTER( giTimerAirRaidUpdate, RAID_DELAY );

Expand Down Expand Up @@ -657,8 +655,7 @@ void BeginDive( )
sGridNo = PickRandomLocationAtMinSpacesAway( gsDiveTargetLocation, 300, 200 );

// Save X, y:
gsDiveX = CenterX( sGridNo );
gsDiveY = CenterY( sGridNo );
ConvertGridNoToCenterCellXY(sGridNo, &gsDiveX, &gsDiveY);

RESETTIMECOUNTER( giTimerAirRaidUpdate, RAID_DELAY );
giNumTurnsSinceDiveStarted = 0;
Expand Down Expand Up @@ -760,8 +757,7 @@ void DoDive( )

DebugMsg(TOPIC_JA2,DBG_LEVEL_3,"DoDive: move towards target");
// Move Towards target....
sTargetX = CenterX( gsDiveTargetLocation );
sTargetY = CenterY( gsDiveTargetLocation );
ConvertGridNoToCenterCellXY(gsDiveTargetLocation, &sTargetX, &sTargetY);

// Determine deltas
dDeltaX = (FLOAT)( sTargetX - gsDiveX );
Expand Down Expand Up @@ -886,7 +882,7 @@ void DoBombing( )
INT16 sRange;
INT32 sGridNo, sOldGridNo, sBombGridNo;

INT16 sTargetX, sTargetY;
INT16 sTargetX, sTargetY, sBombX, sBombY;
UINT16 usItem;
INT16 sStrafeX, sStrafeY;
FLOAT dDeltaX, dDeltaY, dAngle, dDeltaXPos, dDeltaYPos;
Expand Down Expand Up @@ -933,8 +929,7 @@ void DoBombing( )
RESETTIMECOUNTER( giTimerAirRaidUpdate, RAID_DELAY );

// Move Towards target....
sTargetX = CenterX( gsDiveTargetLocation );
sTargetY = CenterY( gsDiveTargetLocation );
ConvertGridNoToCenterCellXY(gsDiveTargetLocation, &sTargetX, &sTargetY);

// Determine deltas
dDeltaX = (FLOAT)( sTargetX - gsDiveX );
Expand Down Expand Up @@ -1002,7 +997,8 @@ void DoBombing( )
}

// Drop bombs...
InternalIgniteExplosion( NOBODY, CenterX( sBombGridNo ), CenterY( sBombGridNo ), 0, sBombGridNo, usItem, fLocate , (UINT8)IsRoofPresentAtGridNo( sBombGridNo ) );
ConvertGridNoToCenterCellXY(sBombGridNo, &sBombX, &sBombY);
InternalIgniteExplosion( NOBODY, sBombX, sBombY, 0, sBombGridNo, usItem, fLocate , (UINT8)IsRoofPresentAtGridNo( sBombGridNo ) );

}

Expand Down
5 changes: 2 additions & 3 deletions Tactical/Handle Items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2187,7 +2187,7 @@ void HandleSoldierThrowItem( SOLDIERTYPE *pSoldier, INT32 sGridNo )
pSoldier->usPendingAnimation = LOB_ITEM;
}
// Draw item depending on distance from buddy
else if ( GetRangeFromGridNoDiff( sGridNo, pSoldier->sGridNo ) < MIN_LOB_RANGE )
else if (PythSpacesAway( sGridNo, pSoldier->sGridNo ) < MIN_LOB_RANGE )
{
//ddd maybe need to add check for throwing item class - grenade
if( (pSoldier->pThrowParams->ubActionCode == THROW_ARM_ITEM) &&
Expand Down Expand Up @@ -5919,8 +5919,7 @@ void SetOffBoobyTrap( ITEM_POOL * pItemPool )
if ( pItemPool )
{
INT16 sX, sY;
sX = CenterX( pItemPool->sGridNo );
sY = CenterY( pItemPool->sGridNo );
ConvertGridNoToCenterCellXY(pItemPool->sGridNo, &sX, &sY);
IgniteExplosion( NOBODY, sX, sY, (INT16) (gpWorldLevelData[pItemPool->sGridNo].sHeight + pItemPool->bRenderZHeightAboveLevel), pItemPool->sGridNo, MINI_GRENADE, 0 );
RemoveItemFromPool( pItemPool->sGridNo, pItemPool->iItemIndex, pItemPool->ubLevel );
}
Expand Down
4 changes: 2 additions & 2 deletions Tactical/Handle UI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5619,7 +5619,7 @@ UINT32 UIHandleTOnTerrain( UI_EVENT *pUIEvent )
sTargetGridNo = MercPtrs[ ubTargID ]->sGridNo;
}

uiRange = GetRangeFromGridNoDiff( pSoldier->sGridNo, sTargetGridNo );
uiRange = PythSpacesAway( pSoldier->sGridNo, sTargetGridNo );


if ( uiRange <= NPC_TALK_RADIUS )
Expand Down Expand Up @@ -6610,7 +6610,7 @@ BOOLEAN HandleTalkInit( )
}

// Check distance
uiRange = GetRangeFromGridNoDiff( pSoldier->sGridNo, usMapPos );
uiRange = PythSpacesAway( pSoldier->sGridNo, usMapPos );

// Double check path
if ( GetCivType( pTSoldier ) != CIV_TYPE_NA )
Expand Down
14 changes: 10 additions & 4 deletions Tactical/Interface Dialogue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1827,7 +1827,7 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum
EXITGRID ExitGrid;
INT32 iRandom = 0;
UINT8 ubMineIndex;

INT16 sX, sY, sX2, sY2;

pSoldier2 = NULL;
//ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Handling %s, action %d at %ld", gMercProfiles[ ubTargetNPC ].zNickname, usActionCode, GetJA2Clock() );
Expand All @@ -1840,7 +1840,9 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum
if (pSoldier && pSoldier2)
{
// see if we are facing this person
ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(pSoldier2->sGridNo),CenterY(pSoldier2->sGridNo));
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
ConvertGridNoToCenterCellXY(pSoldier2->sGridNo, &sX2, &sY2);
ubDesiredMercDir = atan8(sX, sY, sX2, sY2);
// if not already facing in that direction,
if (pSoldier->ubDirection != ubDesiredMercDir)
{
Expand Down Expand Up @@ -2317,7 +2319,9 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum
if (!TileIsOutOfBounds(sGridNo))
{
// see if we are facing this person
ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sGridNo),CenterY(sGridNo));
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
ConvertGridNoToCenterCellXY(sGridNo, &sX2, &sY2);
ubDesiredMercDir = atan8(sX, sY, sX2, sY2);
// if not already facing in that direction,
if (pSoldier->ubDirection != ubDesiredMercDir)
{
Expand Down Expand Up @@ -5632,7 +5636,9 @@ void HandleRaulBlowingHimselfUp()

//blow himself up with, hmmm, lets say TNT. :)
usItem = HAND_GRENADE;
IgniteExplosion( RAUL_UB, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, usItem, pSoldier->pathing.bLevel );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
IgniteExplosion( RAUL_UB, sX, sY, 0, pSoldier->sGridNo, usItem, pSoldier->pathing.bLevel );

SetJa25GeneralFlag( JA_GF__RAUL_BLOW_HIMSELF_UP );
}
Expand Down
2 changes: 1 addition & 1 deletion Tactical/Interface Items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9570,7 +9570,7 @@ BOOLEAN HandleItemPointerClick( INT32 usMapPos )
BOOLEAN ItemCursorInLobRange( INT32 usMapPos )
{
// Draw item depending on distance from buddy
if ( GetRangeFromGridNoDiff( usMapPos, gpItemPointerSoldier->sGridNo ) > MIN_LOB_RANGE )
if (PythSpacesAway( usMapPos, gpItemPointerSoldier->sGridNo ) > MIN_LOB_RANGE )
{
return( FALSE );
}
Expand Down
14 changes: 8 additions & 6 deletions Tactical/Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -6647,4 +6649,4 @@ INT16 GetBackgroundValue( UINT8 usProfile, UINT16 aNr )
}

return 0;
}
}
11 changes: 8 additions & 3 deletions Tactical/Items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9262,13 +9262,16 @@ void CheckEquipmentForDamage( SOLDIERTYPE *pSoldier, INT32 iDamage )
if (fBlowsUp)
{
// blow it up!
INT16 sX, sY;
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);

if ( gTacticalStatus.ubAttackBusyCount )
{
IgniteExplosion( pSoldier->ubAttackerID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, pSoldier->inv[ bSlot ].usItem, pSoldier->pathing.bLevel, pSoldier->ubDirection, &pSoldier->inv[ bSlot ] );
IgniteExplosion( pSoldier->ubAttackerID, sX, sY, 0, pSoldier->sGridNo, pSoldier->inv[ bSlot ].usItem, pSoldier->pathing.bLevel, pSoldier->ubDirection, &pSoldier->inv[ bSlot ] );
}
else
{
IgniteExplosion( pSoldier->ubID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, pSoldier->inv[ bSlot ].usItem, pSoldier->pathing.bLevel, pSoldier->ubDirection, &pSoldier->inv[ bSlot ] );
IgniteExplosion( pSoldier->ubID, sX, sY, 0, pSoldier->sGridNo, pSoldier->inv[ bSlot ].usItem, pSoldier->pathing.bLevel, pSoldier->ubDirection, &pSoldier->inv[ bSlot ] );
}

//ADB when something in a stack blows up the whole stack goes, so no need to worry about number of items
Expand Down Expand Up @@ -9333,7 +9336,9 @@ BOOLEAN DamageItemOnGround( OBJECTTYPE * pObject, INT32 sGridNo, INT8 bLevel, IN
if ( fBlowsUp )
{
// OK, Ignite this explosion!
IgniteExplosion( ubOwner, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, pObject->usItem, bLevel, DIRECTION_IRRELEVANT, pObject );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);
IgniteExplosion( ubOwner, sX, sY, 0, sGridNo, pObject->usItem, bLevel, DIRECTION_IRRELEVANT, pObject );

// SANDRO - merc records
if ( (pObject->fFlags & OBJECT_ARMED_BOMB) && ((*pObject)[0]->data.misc.ubBombOwner > 1) )
Expand Down
7 changes: 4 additions & 3 deletions Tactical/Keys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,9 @@ void HandleDoorTrap( SOLDIERTYPE * pSoldier, DOOR * pDoor )
{
case EXPLOSION:
// cause damage as a regular hand grenade
IgniteExplosion( NOBODY, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 25, pSoldier->sGridNo, HAND_GRENADE, 0 );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
IgniteExplosion( NOBODY, sX, sY, 25, pSoldier->sGridNo, HAND_GRENADE, 0 );
break;

case SIREN:
Expand Down Expand Up @@ -760,8 +762,7 @@ BOOLEAN AttemptToBlowUpLock(SOLDIERTYPE * pSoldier, DOOR * pDoor)
sGridNo = pDoor->sGridNo;

// Get sX, sy;
sX = CenterX(sGridNo);
sY = CenterY(sGridNo);
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);

// Get Z position, based on orientation....
sZ = 20;
Expand Down
Loading