- Fix: compiler warning

- If possible, use the intended macrso to determine sector coordinates

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8018 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2016-01-10 18:06:55 +00:00
parent f09d7818f0
commit 3af6748b03
6 changed files with 38 additions and 41 deletions
+10 -10
View File
@@ -162,8 +162,8 @@ CREATURE_DIRECTIVE* NewDirective( UINT8 ubSectorID, UINT8 ubSectorZ, UINT8 ubCre
UINT8 ubSectorX, ubSectorY;
curr = (CREATURE_DIRECTIVE*)MemAlloc( sizeof( CREATURE_DIRECTIVE ) );
Assert( curr );
ubSectorX = (UINT8)((ubSectorID % 16) + 1);
ubSectorY = (UINT8)((ubSectorID / 16) + 1);
ubSectorX = SECTORX( ubSectorID);
ubSectorY = SECTORY( ubSectorID );
curr->pLevel = FindUnderGroundSector( ubSectorX, ubSectorY, ubSectorZ );
if( !curr->pLevel )
{
@@ -780,8 +780,8 @@ void ChooseTownSectorToAttack( UINT8 ubSectorID, BOOLEAN fOverrideTest )
INT8 bTownId, bTownSize;
UINT8 ubAttackSectorID;
ubSectorX = (UINT8)((ubSectorID % 16) + 1);
ubSectorY = (UINT8)((ubSectorID / 16) + 1);
ubSectorX = SECTORX( ubSectorID );
ubSectorY = SECTORY( ubSectorID );
/* // externalize to xml data
if( !fOverrideTest )
@@ -943,8 +943,8 @@ void ChooseTownSectorToAttack( UINT8 ubSectorID, BOOLEAN fOverrideTest )
else
ubAttackSectorID = ubSectorID;
ubAttackSectorX = (UINT8)((ubAttackSectorID % 16) + 1);
ubAttackSectorY = (UINT8)((ubAttackSectorID / 16) + 1);
ubAttackSectorX = SECTORX( ubAttackSectorID );
ubAttackSectorY = SECTORY( ubAttackSectorID );
// determine the attack sector insertion code
if( ubAttackSectorID == ubSectorID )
@@ -1063,8 +1063,8 @@ void CreatureAttackTown( UINT8 ubSectorID, BOOLEAN fOverrideTest )
gubCreatureBattleCode = CREATURE_BATTLE_CODE_NONE;
ubSectorX = (UINT8)((ubSectorID % 16) + 1);
ubSectorY = (UINT8)((ubSectorID / 16) + 1);
ubSectorX = SECTORX( ubSectorID );
ubSectorY = SECTORY( ubSectorID );
if( !fOverrideTest )
{
@@ -1087,8 +1087,8 @@ void CreatureAttackTown( UINT8 ubSectorID, BOOLEAN fOverrideTest )
//Choose one of the town sectors to attack. Sectors closer to
//the mine entrance have a greater chance of being chosen.
ChooseTownSectorToAttack( ubSectorID, FALSE );
ubSectorX = (UINT8)((gubSectorIDOfCreatureAttack % 16) + 1);
ubSectorY = (UINT8)((gubSectorIDOfCreatureAttack / 16) + 1);
ubSectorX = (UINT8)SECTORX( gubSectorIDOfCreatureAttack );
ubSectorY = (UINT8)SECTORY( gubSectorIDOfCreatureAttack );
}
else
{
+15 -17
View File
@@ -1263,8 +1263,7 @@ INT32 ShowVehicles(INT16 sMapX, INT16 sMapY, INT32 iCount)
void ShowEnemiesInSector( INT16 sSectorX, INT16 sSectorY, INT16 sNumberOfEnemies, UINT16 usNumTanks, UINT8 ubIconPosition )
{
HVOBJECT hIconHandle;
UINT8 i, ubEnemy, ub10xEnemy;
INT16 sEnemyLessTank;
INT16 sEnemy, s10xEnemy, sEnemyLessTank;
// get the video object
GetVideoObject(&hIconHandle, guiCHARICONS);
@@ -1274,19 +1273,19 @@ void ShowEnemiesInSector( INT16 sSectorX, INT16 sSectorY, INT16 sNumberOfEnemies
// no 10x icon for easy enemy quantity gauge in low resolution
if (iResolution >= _640x480 && iResolution < _800x600)
{
ub10xEnemy = 0;
ubEnemy = sNumberOfEnemies;
s10xEnemy = 0;
sEnemy = sNumberOfEnemies;
}
else
{
ub10xEnemy = sNumberOfEnemies / 10;
ubEnemy = sNumberOfEnemies % 10;
s10xEnemy = sNumberOfEnemies / 10;
sEnemy = sNumberOfEnemies % 10;
}
// Flugente: if we display tanks, we need to know that for several rows
INT16 secondtankrowstart = -1;
for( i = 0; i < sNumberOfEnemies; ++i )
for( INT16 i = 0; i < sNumberOfEnemies; ++i )
{
// Flugente: the tank icon has is 4 icons wide and 2 rows high, thus this odd code bit
// if we want to display a tank and have not yet done so, pick the first position that still has enough space to the right
@@ -1302,18 +1301,18 @@ void ShowEnemiesInSector( INT16 sSectorX, INT16 sSectorY, INT16 sNumberOfEnemies
// for now display only one tank icon
usNumTanks = 0;
ubIconPosition += 4;
ubEnemy = max( 0, ubEnemy - 1);
sEnemy = max( 0, sEnemy - 1 );
}
else if ( ub10xEnemy > 0 )
else if ( s10xEnemy > 0 )
{
DrawMapBoxIcon( hIconHandle, SMALL_RED_10X_BOX, sSectorX, sSectorY, ubIconPosition );
--ub10xEnemy;
--s10xEnemy;
++ubIconPosition;
}
else if ( ubEnemy > 0 )
else if ( sEnemy > 0 )
{
DrawMapBoxIcon( hIconHandle, SMALL_RED_BOX, sSectorX, sSectorY, ubIconPosition );
--ubEnemy;
--sEnemy;
++ubIconPosition;
}
}
@@ -4258,7 +4257,6 @@ void DisplayPositionOfEnemyHelicopter()
UINT16 minX, minY, maxX, maxY;
HVOBJECT hHandle;
INT32 iNumberOfPeopleInHelicopter = 0;
CHAR16 sString[4];
INT32 MAP_MVT_ICON_FONT = TINYFONT1;
@@ -5452,26 +5450,26 @@ void MilitiaButtonCallback(GUI_BUTTON *btn,INT32 reason)
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
{
btn->uiFlags|=(BUTTON_CLICKED_ON);
btn->uiFlags|=(BUTTON_CLICKED_ON);
}
else if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
{
if(btn->uiFlags & BUTTON_CLICKED_ON)
{
btn->uiFlags&=~(BUTTON_CLICKED_ON);
DropAPersonInASector( ( UINT8 )( iValue ), ( INT16 )( ( sGlobalMapSector % 16 ) + 1 ), ( INT16 )( ( sGlobalMapSector / 16 ) + 1 ) );
DropAPersonInASector( (UINT8)(iValue), (INT16)(SECTORX( sGlobalMapSector )), (INT16)(SECTORY( sGlobalMapSector )) );
}
}
else if(reason & MSYS_CALLBACK_REASON_RBUTTON_DWN )
{
btn->uiFlags|=(BUTTON_CLICKED_ON);
btn->uiFlags|=(BUTTON_CLICKED_ON);
}
else if(reason & MSYS_CALLBACK_REASON_RBUTTON_UP )
{
if(btn->uiFlags & BUTTON_CLICKED_ON)
{
btn->uiFlags&=~(BUTTON_CLICKED_ON);
PickUpATownPersonFromSector( ( UINT8 )( iValue ), ( INT16 )( ( sGlobalMapSector % 16 ) + 1 ), ( INT16 )( ( sGlobalMapSector / 16 ) + 1 ) );
PickUpATownPersonFromSector( (UINT8)(iValue), (INT16)(SECTORX( sGlobalMapSector )), (INT16)(SECTORY( sGlobalMapSector )) );
}
}
}
+8 -8
View File
@@ -1961,8 +1961,8 @@ BOOLEAN HandleMilitiaNoticedByPatrolGroup( UINT8 ubSectorID, GROUP *pEnemyGroup
{
//For now, automatically attack.
UINT16 usOffensePoints, usDefencePoints;
UINT8 ubSectorX = (UINT8)(ubSectorID % 16) + 1;
UINT8 ubSectorY = (UINT8)(ubSectorID / 16) + 1;
UINT8 ubSectorX = SECTORX( ubSectorID );
UINT8 ubSectorY = SECTORY( ubSectorID );
usOffensePoints = pEnemyGroup->pEnemyGroup->ubNumAdmins * 2 +
pEnemyGroup->pEnemyGroup->ubNumTroops * 4 +
pEnemyGroup->pEnemyGroup->ubNumElites * 6 +
@@ -2056,8 +2056,8 @@ BOOLEAN AttemptToNoticeAdjacentGroupSucceeds()
BOOLEAN HandleEmptySectorNoticedByPatrolGroup( GROUP *pGroup, UINT8 ubEmptySectorID )
{
UINT8 ubGarrisonID;
UINT8 ubSectorX = (UINT8)(ubEmptySectorID % 16) + 1;
UINT8 ubSectorY = (UINT8)(ubEmptySectorID / 16) + 1;
UINT8 ubSectorX = SECTORX( ubEmptySectorID );
UINT8 ubSectorY = SECTORY( ubEmptySectorID );
Ensure_RepairedGarrisonGroup( &gGarrisonGroup, &giGarrisonArraySize ); /* added NULL fix, 2007-03-03, Sgt. Kolja */
@@ -3162,8 +3162,8 @@ BOOLEAN SendReinforcementsForGarrison( INT32 iDstGarrisonID, UINT16 usDefencePoi
goto QUEEN_POOL;
}
ubSrcSectorX = (gGarrisonGroup[ iSrcGarrisonID ].ubSectorID % 16) + 1;
ubSrcSectorY = (gGarrisonGroup[ iSrcGarrisonID ].ubSectorID / 16) + 1;
ubSrcSectorX = SECTORX( gGarrisonGroup[iSrcGarrisonID].ubSectorID );
ubSrcSectorY = SECTORY( gGarrisonGroup[iSrcGarrisonID].ubSectorID );
if( ubSrcSectorX != gWorldSectorX || ubSrcSectorY != gWorldSectorY || gbWorldSectorZ > 0 )
{
//The reinforcements aren't coming from the currently loaded sector!
@@ -3266,8 +3266,8 @@ BOOLEAN SendReinforcementsForPatrol( INT32 iPatrolID, GROUP **pOptionalGroup )
if( iReinforcementsRequested <= 0)
return FALSE;
ubDstSectorX = (gPatrolGroup[ iPatrolID ].ubSectorID[1] % 16) + 1;
ubDstSectorY = (gPatrolGroup[ iPatrolID ].ubSectorID[1] / 16) + 1;
ubDstSectorX = SECTORX( gPatrolGroup[iPatrolID].ubSectorID[1] );
ubDstSectorY = SECTORY( gPatrolGroup[iPatrolID].ubSectorID[1] );
if( pOptionalGroup && *pOptionalGroup )
{
+3 -4
View File
@@ -241,8 +241,8 @@ BOOLEAN AddPlayerToGroup( UINT8 ubGroupID, SOLDIERTYPE *pSoldier )
{
pGroup->pPlayerList = pPlayer;
pGroup->ubGroupSize = 1;
pGroup->ubPrevX = (UINT8)((pSoldier->ubPrevSectorID % 16) + 1);
pGroup->ubPrevY = (UINT8)((pSoldier->ubPrevSectorID / 16) + 1);
pGroup->ubPrevX = SECTORX( pSoldier->ubPrevSectorID );
pGroup->ubPrevY = SECTORY( pSoldier->ubPrevSectorID );
pGroup->ubSectorX = (UINT8)pSoldier->sSectorX;
pGroup->ubSectorY = (UINT8)pSoldier->sSectorY;
pGroup->ubSectorZ = (UINT8)pSoldier->bSectorZ;
@@ -2796,7 +2796,6 @@ void InitiateGroupMovementToNextSector( GROUP *pGroup )
//Calc time to get to next waypoint...
if ( !pGroup->ubSectorZ )
{
BOOLEAN fCalcRegularTime = TRUE;
if ( pGroup->usGroupTeam == ENEMY_TEAM )
{
//Determine if the enemy group is "sleeping". If so, then simply delay their arrival time by the amount of time
@@ -2813,7 +2812,7 @@ void InitiateGroupMovementToNextSector( GROUP *pGroup )
}
else if ( pGroup->usGroupTeam == MILITIA_TEAM )
{
// As the player orders militia to move, a chance-based system is ill-advised - the player would simply cancel and reassign the order, leading to bypassing the mechanci in a tedious way
// As the player orders militia to move, a chance-based system is ill-advised - the player would simply cancel and reassign the order, leading to bypassing the mechanic in a tedious way
// so instead, we always add a penalty, but it will be lower
// however, do not give such a penalty for movement inside a town - the player might just want to redistribute his troops, and this would be tedious
if ( GetWorldHour( ) >= 21 || GetWorldHour( ) <= 4 )
+1 -1
View File
@@ -2005,7 +2005,7 @@ UINT32 PlayerStrength( void )
pSoldier = MercPtrs[ ubLoop ];
if ( pSoldier->bActive )
{
if ( pSoldier->bInSector || ( pSoldier->flags.fBetweenSectors && ((pSoldier->ubPrevSectorID % 16) + 1) == gWorldSectorX && ((pSoldier->ubPrevSectorID / 16) + 1) == gWorldSectorY && ( pSoldier->bSectorZ == gbWorldSectorZ ) ) )
if ( pSoldier->bInSector || (pSoldier->flags.fBetweenSectors && SECTORX( pSoldier->ubPrevSectorID ) == gWorldSectorX && SECTORY( pSoldier->ubPrevSectorID ) == gWorldSectorY && (pSoldier->bSectorZ == gbWorldSectorZ)) )
{
// count this person's strength (condition), calculated as life reduced up to half according to maxbreath
uiStrength = pSoldier->stats.bLife * ( pSoldier->bBreathMax + 100 ) / 200;
+1 -1
View File
@@ -780,7 +780,7 @@ void HandleMoraleEvent( SOLDIERTYPE *pSoldier, INT8 bMoraleEvent, INT16 sMapX, I
// CJC: adding to SOLDIER_IN_SECTOR check special stuff because the old sector values might
// be appropriate (because in transit going out of that sector!)
if ( SOLDIER_IN_SECTOR( pTeamSoldier, sMapX, sMapY, bMapZ ) || ( pTeamSoldier->flags.fBetweenSectors && ((pTeamSoldier->ubPrevSectorID % 16) + 1) == sMapX && ((pTeamSoldier->ubPrevSectorID / 16) + 1) == sMapY && ( pTeamSoldier->bSectorZ == bMapZ ) ) )
if ( SOLDIER_IN_SECTOR( pTeamSoldier, sMapX, sMapY, bMapZ ) || (pTeamSoldier->flags.fBetweenSectors && SECTORX( pTeamSoldier->ubPrevSectorID ) == sMapX && SECTORY( pTeamSoldier->ubPrevSectorID ) == sMapY && (pTeamSoldier->bSectorZ == bMapZ)) )
{
if ( gGameOptions.fNewTraitSystem )
{