diff --git a/Editor/EditorMercs.cpp b/Editor/EditorMercs.cpp
index 7a3658f6..27dc5f42 100644
--- a/Editor/EditorMercs.cpp
+++ b/Editor/EditorMercs.cpp
@@ -528,7 +528,7 @@ void AddMercToWorld( INT32 iMapIndex )
gTempBasicPlacement.bAttitude = gbDefaultAttitude;
gTempBasicPlacement.bRelativeAttributeLevel = gbDefaultRelativeAttributeLevel;
gTempBasicPlacement.bRelativeEquipmentLevel = gbDefaultRelativeEquipmentLevel;
- gTempBasicPlacement.bDirection = gbDefaultDirection;
+ gTempBasicPlacement.ubDirection = gbDefaultDirection;
//Generate detailed placement information given the temp placement information.
CreateDetailedPlacementGivenBasicPlacementInfo( &gTempDetailedPlacement, &gTempBasicPlacement );
@@ -645,7 +645,7 @@ void ResetAllMercPositions()
// EVENT_SetSoldierPosition( gpSelected->pSoldier, (FLOAT)(sCellX + 5), (FLOAT)(sCellY + 5) );
// if( gpSelected->pBasicPlacement->fOnRoof )
// SetSoldierHeight( gpSelected->pSoldier, 58.0 );
- // SetMercDirection( gpSelected->pBasicPlacement->bDirection );
+ // SetMercDirection( gpSelected->pBasicPlacement->ubDirection );
//}
curr = curr->next;
}
@@ -1451,7 +1451,7 @@ void SetMercDirection( INT8 bDirection )
ClickEditorButton( FIRST_MERCS_DIRECTION_BUTTON + bDirection );
gbDefaultDirection = bDirection;
- gpSelected->pBasicPlacement->bDirection = bDirection;
+ gpSelected->pBasicPlacement->ubDirection = bDirection;
// ATE: Changed these to call functions....
EVENT_SetSoldierDirection( gpSelected->pSoldier, bDirection );
@@ -1676,7 +1676,7 @@ void IndicateSelectedMerc( INT16 sID )
//assigns the soldier with the same orders/attitude.
SetMercOrders( gpSelected->pSoldier->bOrders );
SetMercAttitude( gpSelected->pSoldier->bAttitude );
- SetMercDirection( gpSelected->pSoldier->bDirection );
+ SetMercDirection( gpSelected->pSoldier->ubDirection );
if( gpSelected->pBasicPlacement->fPriorityExistance )
ClickEditorButton( MERCS_PRIORITYEXISTANCE_CHECKBOX );
else
diff --git a/GameSettings.cpp b/GameSettings.cpp
index 145a251b..4c49d441 100644
--- a/GameSettings.cpp
+++ b/GameSettings.cpp
@@ -708,6 +708,11 @@ void LoadGameExternalOptions()
}
+void FreeGameExternalOptions()
+{
+ MemFree( gGameExternalOptions.iaIMPSlots);
+}
+
BOOLEAN GetCDLocation( )
{
UINT32 uiStrngLength = 0;
diff --git a/GameSettings.h b/GameSettings.h
index 08189c76..8d73475f 100644
--- a/GameSettings.h
+++ b/GameSettings.h
@@ -438,6 +438,7 @@ BOOLEAN SaveGameSettings();
BOOLEAN LoadGameSettings();
// Snap: Read options from an INI file in the default of custom Data directory
void LoadGameExternalOptions();
+void FreeGameExternalOptions();
void InitGameOptions();
diff --git a/Laptop/files.cpp b/Laptop/files.cpp
index e1ddd6ed..8c113073 100644
--- a/Laptop/files.cpp
+++ b/Laptop/files.cpp
@@ -1292,6 +1292,7 @@ void ClearFileStringList( void )
{
pDeleteFileString = pFileString;
pFileString = pFileString -> Next;
+ MemFree( pDeleteFileString->pString);
MemFree( pDeleteFileString );
}
diff --git a/Standard Gaming Platform/FileCat.cpp b/Standard Gaming Platform/FileCat.cpp
index d18e72af..a977d597 100644
--- a/Standard Gaming Platform/FileCat.cpp
+++ b/Standard Gaming Platform/FileCat.cpp
@@ -75,6 +75,7 @@ void TFileCat::TraverseDir(std::string dir, int depth)
using std::string;
static string dot( ".");
static string dotdot( "..");
+ static string svn( ".svn");
if (!dir.empty()) dir += '\\';
@@ -84,7 +85,7 @@ void TFileCat::TraverseDir(std::string dir, int depth)
unsigned attrib;
while ( readDir.NextFile(fileName, attrib) ) {
- if (dot == fileName || dotdot == fileName) continue;
+ if (dot == fileName || dotdot == fileName || svn == fileName) continue;
string fullPath = dir + fileName;
diff --git a/Standard Gaming Platform/mousesystem.cpp b/Standard Gaming Platform/mousesystem.cpp
index 24fffb44..3e2ab714 100644
--- a/Standard Gaming Platform/mousesystem.cpp
+++ b/Standard Gaming Platform/mousesystem.cpp
@@ -622,7 +622,8 @@ void MSYS_UpdateMouseRegion(void)
#endif
}
- MSYS_CurrRegion->FastHelpTimer = gsFastHelpDelay;
+ if (MSYS_CurrRegion)
+ MSYS_CurrRegion->FastHelpTimer = gsFastHelpDelay;
// Force a callbacks to happen on previous region to indicate that
// the mouse has left the old region
diff --git a/Standard Gaming Platform/sgp.cpp b/Standard Gaming Platform/sgp.cpp
index 14bcf310..eabaa98d 100644
--- a/Standard Gaming Platform/sgp.cpp
+++ b/Standard Gaming Platform/sgp.cpp
@@ -133,7 +133,8 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
FreeConsole();
return 0L;
}
-
+ BOOL visible = IsWindowVisible(hWindow);
+
if(gfIgnoreMessages)
return(DefWindowProc(hWindow, Message, wParam, lParam));
@@ -159,11 +160,29 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
#ifdef JA2
case WM_MOVE:
// if( 1==iScreenMode )
-// {
+ {
GetClientRect(hWindow, &rcWindow);
ClientToScreen(hWindow, (LPPOINT)&rcWindow);
ClientToScreen(hWindow, (LPPOINT)&rcWindow+1);
-// }
+ int xPos = (int)(short) LOWORD(lParam);
+ int yPos = (int)(short) HIWORD(lParam);
+ BOOL needchange = FALSE;
+ if (xPos < 0)
+ {
+ xPos = 0;
+ needchange = TRUE;
+ }
+ if (yPos < 0)
+ {
+ yPos = 0;
+ needchange = TRUE;
+ }
+ if (needchange)
+ {
+ SetWindowPos( hWindow, NULL, xPos, yPos, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
+ }
+
+ }
break;
case WM_GETMINMAXINFO:
{
@@ -792,7 +811,10 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR p
//end rain
#ifdef _DEBUG
- _CrtSetDbgFlag( _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
+ // Use this one ONLY if you're having memory corruption issues that can be repeated in a short time
+ // Otherwise it will just run out of memory.
+ //_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF);
+ _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_EVERY_1024_DF);
#endif
ghInstance = hInstance;
diff --git a/Standard Gaming Platform/video.cpp b/Standard Gaming Platform/video.cpp
index a1479124..35bbd881 100644
--- a/Standard Gaming Platform/video.cpp
+++ b/Standard Gaming Platform/video.cpp
@@ -1083,6 +1083,12 @@ void ScrollJA2Background(UINT32 uiDirection, INT16 sScrollXIncrement, INT16 sScr
ReturnCode = IDirectDrawSurface2_SGPBltFast(pDest, sScrollXIncrement, gsVIEWPORT_WINDOW_START_Y, pSource, (LPRECT)&Region, DDBLTFAST_NOCOLORKEY);
if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING))
{
+ // Prevent the assertion failure lockup
+ if (ReturnCode == DDERR_INVALIDRECT)
+ {
+ break;
+ }
+
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
if (ReturnCode == DDERR_SURFACELOST)
@@ -1124,6 +1130,12 @@ void ScrollJA2Background(UINT32 uiDirection, INT16 sScrollXIncrement, INT16 sScr
ReturnCode = IDirectDrawSurface2_SGPBltFast(pDest, 0, gsVIEWPORT_WINDOW_START_Y, pSource, (LPRECT)&Region, DDBLTFAST_NOCOLORKEY);
if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING))
{
+ // Prevent the assertion failure lockup
+ if (ReturnCode == DDERR_INVALIDRECT)
+ {
+ break;
+ }
+
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
if (ReturnCode == DDERR_SURFACELOST)
@@ -1166,6 +1178,12 @@ void ScrollJA2Background(UINT32 uiDirection, INT16 sScrollXIncrement, INT16 sScr
ReturnCode = IDirectDrawSurface2_SGPBltFast(pDest, 0, gsVIEWPORT_WINDOW_START_Y + sScrollYIncrement, pSource, (LPRECT)&Region, DDBLTFAST_NOCOLORKEY);
if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING))
{
+ // Prevent the assertion failure lockup
+ if (ReturnCode == DDERR_INVALIDRECT)
+ {
+ break;
+ }
+
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
if (ReturnCode == DDERR_SURFACELOST)
@@ -1207,6 +1225,12 @@ void ScrollJA2Background(UINT32 uiDirection, INT16 sScrollXIncrement, INT16 sScr
ReturnCode = IDirectDrawSurface2_SGPBltFast(pDest, 0, gsVIEWPORT_WINDOW_START_Y, pSource, (LPRECT)&Region, DDBLTFAST_NOCOLORKEY);
if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING))
{
+ // Prevent the assertion failure lockup
+ if (ReturnCode == DDERR_INVALIDRECT)
+ {
+ break;
+ }
+
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
if (ReturnCode == DDERR_SURFACELOST)
@@ -1249,6 +1273,12 @@ void ScrollJA2Background(UINT32 uiDirection, INT16 sScrollXIncrement, INT16 sScr
ReturnCode = IDirectDrawSurface2_SGPBltFast(pDest, sScrollXIncrement, gsVIEWPORT_WINDOW_START_Y + sScrollYIncrement, pSource, (LPRECT)&Region, DDBLTFAST_NOCOLORKEY);
if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING))
{
+ // Prevent the assertion failure lockup
+ if (ReturnCode == DDERR_INVALIDRECT)
+ {
+ break;
+ }
+
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
if (ReturnCode == DDERR_SURFACELOST)
@@ -1294,6 +1324,12 @@ void ScrollJA2Background(UINT32 uiDirection, INT16 sScrollXIncrement, INT16 sScr
ReturnCode = IDirectDrawSurface2_SGPBltFast(pDest, 0, gsVIEWPORT_WINDOW_START_Y + sScrollYIncrement, pSource, (LPRECT)&Region, DDBLTFAST_NOCOLORKEY);
if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING))
{
+ // Prevent the assertion failure lockup
+ if (ReturnCode == DDERR_INVALIDRECT)
+ {
+ break;
+ }
+
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
if (ReturnCode == DDERR_SURFACELOST)
@@ -1338,6 +1374,12 @@ void ScrollJA2Background(UINT32 uiDirection, INT16 sScrollXIncrement, INT16 sScr
ReturnCode = IDirectDrawSurface2_SGPBltFast(pDest, sScrollXIncrement, gsVIEWPORT_WINDOW_START_Y, pSource, (LPRECT)&Region, DDBLTFAST_NOCOLORKEY);
if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING))
{
+ // Prevent the assertion failure lockup
+ if (ReturnCode == DDERR_INVALIDRECT)
+ {
+ break;
+ }
+
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
if (ReturnCode == DDERR_SURFACELOST)
@@ -1385,6 +1427,12 @@ void ScrollJA2Background(UINT32 uiDirection, INT16 sScrollXIncrement, INT16 sScr
ReturnCode = IDirectDrawSurface2_SGPBltFast(pDest, 0, gsVIEWPORT_WINDOW_START_Y, pSource, (LPRECT)&Region, DDBLTFAST_NOCOLORKEY);
if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING))
{
+ // Prevent the assertion failure lockup
+ if (ReturnCode == DDERR_INVALIDRECT)
+ {
+ break;
+ }
+
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
if (ReturnCode == DDERR_SURFACELOST)
@@ -1456,6 +1504,12 @@ void ScrollJA2Background(UINT32 uiDirection, INT16 sScrollXIncrement, INT16 sScr
ReturnCode = IDirectDrawSurface2_SGPBltFast(pDest, StripRegions[ cnt ].left, StripRegions[ cnt ].top, gpFrameBuffer, (LPRECT)&( StripRegions[ cnt ] ), DDBLTFAST_NOCOLORKEY);
if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING))
{
+ // Prevent the assertion failure lockup
+ if (ReturnCode == DDERR_INVALIDRECT)
+ {
+ break;
+ }
+
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
}
diff --git a/Strategic/AI Viewer.cpp b/Strategic/AI Viewer.cpp
index e1a2ea0a..f3f3d0e8 100644
--- a/Strategic/AI Viewer.cpp
+++ b/Strategic/AI Viewer.cpp
@@ -540,7 +540,7 @@ void RenderMovingGroupsAndMercs()
UINT8 ubNumTroops, ubNumAdmins, ubNumElites;
float ratio;
INT32 minX, maxX, minY, maxY;
- INT32 iSector = 0;
+ //INT32 iSector = 0;
UINT8 ubIconType;
UINT8 ubIconColor;
UINT8 ubFontColor;
@@ -577,7 +577,7 @@ void RenderMovingGroupsAndMercs()
if( pGroup->fPlayer )
{
- ubIconType = ( pGroup->uiTraverseTime ) ? ICON_TYPE_ASSAULT : ICON_TYPE_STOPPED;
+ ubIconType = (UINT8) (( pGroup->uiTraverseTime ) ? ICON_TYPE_ASSAULT : ICON_TYPE_STOPPED);
ubIconColor = ICON_COLOR_GREEN;
ubFontColor = FONT_YELLOW;
}
@@ -1447,16 +1447,16 @@ void ExtractAndUpdatePopulations()
//CIniReader iniReader("..\\Ja2_Options.ini");
//INT32 iMaxEnemyGroupSize = iniReader.ReadInteger("Options","MAX_STRATEGIC_TEAM_SIZE",20);
- gsAINumAdmins = min( GetNumericStrictValueFromField( 0 ), gGameExternalOptions.iMaxEnemyGroupSize );
+ gsAINumAdmins = (INT16) min( GetNumericStrictValueFromField( 0 ), gGameExternalOptions.iMaxEnemyGroupSize );
SetInputFieldStringWithNumericStrictValue( 0, gsAINumAdmins );
- gsAINumTroops = min( GetNumericStrictValueFromField( 1 ), gGameExternalOptions.iMaxEnemyGroupSize );
+ gsAINumTroops = (INT16) min( GetNumericStrictValueFromField( 1 ), gGameExternalOptions.iMaxEnemyGroupSize );
SetInputFieldStringWithNumericStrictValue( 1, gsAINumTroops );
- gsAINumElites = min( GetNumericStrictValueFromField( 2 ), gGameExternalOptions.iMaxEnemyGroupSize );
+ gsAINumElites = (INT16) min( GetNumericStrictValueFromField( 2 ), gGameExternalOptions.iMaxEnemyGroupSize );
SetInputFieldStringWithNumericStrictValue( 2, gsAINumElites );
- gsAINumCreatures = min( GetNumericStrictValueFromField( 3 ), gGameExternalOptions.iMaxEnemyGroupSize );
+ gsAINumCreatures = (INT16) min( GetNumericStrictValueFromField( 3 ), gGameExternalOptions.iMaxEnemyGroupSize );
SetInputFieldStringWithNumericStrictValue( 3, gsAINumCreatures );
}
@@ -1866,7 +1866,7 @@ void BlitGroupIcon( UINT8 ubIconType, UINT8 ubIconColor, UINT32 uiX, UINT32 uiY,
Assert( ubIconType < NUM_ICON_TYPES );
Assert( ubIconColor < NUM_ICON_COLORS );
- ubObjectIndex = ( ubIconType * NUM_ICON_COLORS ) + ubIconColor;
+ ubObjectIndex = (UINT8)( ubIconType * NUM_ICON_COLORS ) + ubIconColor;
BltVideoObject( FRAME_BUFFER, hVObject, ubObjectIndex, uiX, uiY, VO_BLT_SRCTRANSPARENCY, NULL );
}
diff --git a/Strategic/Assignments.cpp b/Strategic/Assignments.cpp
index 96d11453..f95fedc6 100644
--- a/Strategic/Assignments.cpp
+++ b/Strategic/Assignments.cpp
@@ -917,8 +917,8 @@ BOOLEAN CanCharacterRepairButDoesntHaveARepairkit( SOLDIERTYPE *pSoldier )
// check that character is alive, oklife, has repair skill, and equipment, etc.
BOOLEAN CanCharacterRepair( SOLDIERTYPE *pSoldier )
{
- INT8 bPocket = 0;
- BOOLEAN fToolKitFound = FALSE;
+ //INT8 bPocket = 0;
+ //BOOLEAN fToolKitFound = FALSE;
if ( !BasicCanCharacterAssignment( pSoldier, TRUE ) )
{
@@ -1565,8 +1565,8 @@ BOOLEAN CanCharacterPractise( SOLDIERTYPE *pSoldier )
BOOLEAN CanCharacterTrainTeammates( SOLDIERTYPE *pSoldier )
{
- INT32 cnt = 0;
- SOLDIERTYPE *pTeamSoldier = NULL;
+ //INT32 cnt = 0;
+ //SOLDIERTYPE *pTeamSoldier = NULL;
// can character train at all
if( CanCharacterPractise( pSoldier ) == FALSE )
@@ -1588,7 +1588,7 @@ BOOLEAN CanCharacterTrainTeammates( SOLDIERTYPE *pSoldier )
BOOLEAN CanCharacterBeTrainedByOther( SOLDIERTYPE *pSoldier )
{
- INT32 iCounter = 0;
+ //INT32 iCounter = 0;
// can character train at all
if( CanCharacterPractise( pSoldier ) == FALSE )
@@ -2047,8 +2047,8 @@ UINT8 FindNumberInSectorWithAssignment( INT16 sX, INT16 sY, INT8 bAssignment )
{
// run thought list of characters find number with this assignment
SOLDIERTYPE *pSoldier, *pTeamSoldier;
- INT32 cnt=0;
- INT32 iCounter=0;
+ INT32 cnt=0;
+ //INT32 iCounter=0;
INT8 bNumberOfPeople = 0;
// set psoldier as first in merc ptrs
@@ -2137,11 +2137,11 @@ UINT16 CalculateHealingPointsForDoctor(SOLDIERTYPE *pDoctor, UINT16 *pusMaxPts,
}
// calculate effective doctoring rate (adjusted for drugs, alcohol, etc.)
- usHealPts = ( EffectiveMedical( pDoctor ) * (( EffectiveDexterity( pDoctor ) + EffectiveWisdom( pDoctor ) ) / 2) * (100 + ( 5 * EffectiveExpLevel( pDoctor) ) ) ) / gGameExternalOptions.ubDoctoringRateDivisor;
+ usHealPts = (UINT16) (( EffectiveMedical( pDoctor ) * (( EffectiveDexterity( pDoctor ) + EffectiveWisdom( pDoctor ) ) / 2) * (100 + ( 5 * EffectiveExpLevel( pDoctor) ) ) ) / gGameExternalOptions.ubDoctoringRateDivisor);
// calculate normal doctoring rate - what it would be if his stats were "normal" (ignoring drugs, fatigue, equipment condition)
// and equipment was not a hindrance
- *pusMaxPts = ( pDoctor -> bMedical * (( pDoctor -> bDexterity + pDoctor -> bWisdom ) / 2 ) * (100 + ( 5 * pDoctor->bExpLevel) ) ) / gGameExternalOptions.ubDoctoringRateDivisor;
+ *pusMaxPts = (UINT16) (( pDoctor -> bMedical * (( pDoctor -> bDexterity + pDoctor -> bWisdom ) / 2 ) * (100 + ( 5 * pDoctor->bExpLevel) ) ) / gGameExternalOptions.ubDoctoringRateDivisor);
// adjust for fatigue
ReducePointsForFatigue( pDoctor, &usHealPts );
@@ -2196,11 +2196,11 @@ UINT8 CalculateRepairPointsForRepairman(SOLDIERTYPE *pSoldier, UINT16 *pusMaxPts
}
// calculate effective repair rate (adjusted for drugs, alcohol, etc.)
- usRepairPts = (EffectiveMechanical( pSoldier ) * EffectiveDexterity( pSoldier ) * (100 + ( 5 * EffectiveExpLevel( pSoldier) ) ) ) / ( gGameExternalOptions.ubRepairRateDivisor * gGameExternalOptions.ubAssignmentUnitsPerDay );
+ usRepairPts = (UINT16) ((EffectiveMechanical( pSoldier ) * EffectiveDexterity( pSoldier ) * (100 + ( 5 * EffectiveExpLevel( pSoldier) ) ) ) / ( gGameExternalOptions.ubRepairRateDivisor * gGameExternalOptions.ubAssignmentUnitsPerDay ));
// calculate normal repair rate - what it would be if his stats were "normal" (ignoring drugs, fatigue, equipment condition)
// and equipment was not a hindrance
- *pusMaxPts = ( pSoldier -> bMechanical * pSoldier -> bDexterity * (100 + ( 5 * pSoldier->bExpLevel) ) ) / ( gGameExternalOptions.ubRepairRateDivisor * gGameExternalOptions.ubAssignmentUnitsPerDay );
+ *pusMaxPts = (UINT16) (( pSoldier -> bMechanical * pSoldier -> bDexterity * (100 + ( 5 * pSoldier->bExpLevel) ) ) / ( gGameExternalOptions.ubRepairRateDivisor * gGameExternalOptions.ubAssignmentUnitsPerDay ));
// adjust for fatigue
@@ -2275,7 +2275,7 @@ void HandleDoctorsInSector( INT16 sX, INT16 sY, INT8 bZ )
{
SOLDIERTYPE *pSoldier, *pTeamSoldier;
INT32 cnt=0;
- INT32 iCounter=0;
+ //INT32 iCounter=0;
// set psoldier as first in merc ptrs
pSoldier = MercPtrs[0];
diff --git a/Strategic/Game Init.cpp b/Strategic/Game Init.cpp
index b826cb9a..e159d375 100644
--- a/Strategic/Game Init.cpp
+++ b/Strategic/Game Init.cpp
@@ -352,6 +352,7 @@ void ShutdownStrategicLayer()
TrashUndergroundSectorInfo();
DeleteCreatureDirectives();
KillStrategicAI();
+ ClearTacticalMessageQueue();
}
BOOLEAN InitNewGame( BOOLEAN fReset )
diff --git a/Strategic/Map Screen Interface Map.cpp b/Strategic/Map Screen Interface Map.cpp
index 6477edc8..94b203b1 100644
--- a/Strategic/Map Screen Interface Map.cpp
+++ b/Strategic/Map Screen Interface Map.cpp
@@ -2055,6 +2055,7 @@ void PlotPathForHelicopter( INT16 sX, INT16 sY )
void PlotATemporaryPathForHelicopter( INT16 sX, INT16 sY )
{
// clear old temp path
+ pTempHelicopterPath = MoveToBeginningOfPathList( pTempHelicopterPath);
pTempHelicopterPath = ClearStrategicPathList( pTempHelicopterPath, 0 );
// is cursor allowed here?..if not..don't build temp path
diff --git a/Strategic/Merc Contract.cpp b/Strategic/Merc Contract.cpp
index 20a16f4b..1f3f1830 100644
--- a/Strategic/Merc Contract.cpp
+++ b/Strategic/Merc Contract.cpp
@@ -1263,7 +1263,7 @@ BOOLEAN HandleFiredDeadMerc( SOLDIERTYPE *pSoldier )
SET_PALETTEREP_ID ( Corpse.SkinPal, pSoldier->SkinPal );
SET_PALETTEREP_ID ( Corpse.PantsPal, pSoldier->PantsPal );
- Corpse.bDirection = pSoldier->bDirection;
+ Corpse.bDirection = pSoldier->ubDirection;
// Set time of death
Corpse.uiTimeOfDeath = GetWorldTotalMin( );
diff --git a/Strategic/Queen Command.cpp b/Strategic/Queen Command.cpp
index 11404cd6..a32fcc6d 100644
--- a/Strategic/Queen Command.cpp
+++ b/Strategic/Queen Command.cpp
@@ -443,54 +443,58 @@ BOOLEAN PrepareEnemyForSectorBattle()
if( gbWorldSectorZ > 0 )
return PrepareEnemyForUndergroundBattle();
- // Reinforcement groups? Bring it on! That is, if this is an enemy invasion.
- if( gGameExternalOptions.gfAllowReinforcements &&
- !( (GetTownIdForSector( gWorldSectorX, gWorldSectorY ) == OMERTA )&&( gGameOptions.ubDifficultyLevel != DIF_LEVEL_INSANE ) ) &&
- gpBattleGroup && !gpBattleGroup->fPlayer )
+ // Add the invading group
+ if (gpBattleGroup && !gpBattleGroup->fPlayer )
{
- UINT16 pusMoveDir[4][3];
- UINT8 ubDirNumber = 0, ubIndex;
- GROUP *pGroup;
- SECTORINFO *pThisSector;
-
//The enemy has instigated the battle which means they are the ones entering the conflict.
//The player was actually in the sector first, and the enemy doesn't use reinforced placements
HandleArrivalOfReinforcements( gpBattleGroup );
- // They arrived in multiple groups, so here they come
- pThisSector = &SectorInfo[ SECTOR( gWorldSectorX, gWorldSectorY ) ];
-
- GenerateDirectionInfos( gWorldSectorX, gWorldSectorY, &ubDirNumber, pusMoveDir,
- ( GetTownIdForSector( gWorldSectorX, gWorldSectorY ) != BLANK_SECTOR ? TRUE : FALSE ), TRUE, IS_ONLY_IN_CITIES );
-
- for( ubIndex = 0; ubIndex < ubDirNumber; ubIndex++ )
+ // Reinforcement groups? Bring it on!
+ if( gGameExternalOptions.gfAllowReinforcements &&
+ !( (GetTownIdForSector( gWorldSectorX, gWorldSectorY ) == OMERTA )&&( gGameOptions.ubDifficultyLevel != DIF_LEVEL_INSANE ) ) )
{
- while ( NumMobileEnemiesInSector( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) && GetEnemyGroupInSector( SECTORX( pusMoveDir[ ubIndex][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) )
+ UINT16 pusMoveDir[4][3];
+ UINT8 ubDirNumber = 0, ubIndex;
+ GROUP *pGroup;
+ SECTORINFO *pThisSector;
+
+ // They arrived in multiple groups, so here they come
+ pThisSector = &SectorInfo[ SECTOR( gWorldSectorX, gWorldSectorY ) ];
+
+ GenerateDirectionInfos( gWorldSectorX, gWorldSectorY, &ubDirNumber, pusMoveDir,
+ ( GetTownIdForSector( gWorldSectorX, gWorldSectorY ) != BLANK_SECTOR ? TRUE : FALSE ), TRUE, IS_ONLY_IN_CITIES );
+
+ for( ubIndex = 0; ubIndex < ubDirNumber; ubIndex++ )
{
- pGroup = GetEnemyGroupInSector( SECTORX( pusMoveDir[ ubIndex][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) );
+ while ( NumMobileEnemiesInSector( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) && GetEnemyGroupInSector( SECTORX( pusMoveDir[ ubIndex][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) )
+ {
+ pGroup = GetEnemyGroupInSector( SECTORX( pusMoveDir[ ubIndex][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) );
- pGroup->ubPrevX = pGroup->ubSectorX;
- pGroup->ubPrevY = pGroup->ubSectorY;
+ pGroup->ubPrevX = pGroup->ubSectorX;
+ pGroup->ubPrevY = pGroup->ubSectorY;
- pGroup->ubSectorX = pGroup->ubNextX = (UINT8)gWorldSectorX;
- pGroup->ubSectorY = pGroup->ubNextY = (UINT8)gWorldSectorY;
+ pGroup->ubSectorX = pGroup->ubNextX = (UINT8)gWorldSectorX;
+ pGroup->ubSectorY = pGroup->ubNextY = (UINT8)gWorldSectorY;
+ }
}
- }
- //It is now possible that other enemy groups have also arrived. Add them in the same manner.
- pGroup = gpGroupList;
- while( pGroup )
- {
- if( pGroup != gpBattleGroup && !pGroup->fPlayer && !pGroup->fVehicle &&
- pGroup->ubSectorX == gpBattleGroup->ubSectorX &&
+ //It is now possible that other enemy groups have also arrived. Add them in the same manner.
+ pGroup = gpGroupList;
+ while( pGroup )
+ {
+ if( pGroup != gpBattleGroup && !pGroup->fPlayer && !pGroup->fVehicle &&
+ pGroup->ubSectorX == gpBattleGroup->ubSectorX &&
pGroup->ubSectorY == gpBattleGroup->ubSectorY &&
!pGroup->pEnemyGroup->ubAdminsInBattle &&
!pGroup->pEnemyGroup->ubTroopsInBattle &&
!pGroup->pEnemyGroup->ubElitesInBattle )
- {
- HandleArrivalOfReinforcements( pGroup );
+ {
+ HandleArrivalOfReinforcements( pGroup );
+ }
+ pGroup = pGroup->next;
}
- pGroup = pGroup->next;
+
}
ValidateEnemiesHaveWeapons();
@@ -670,24 +674,29 @@ BOOLEAN PrepareEnemyForSectorBattle()
pGroup = gpGroupList;
while( pGroup && sNumSlots )
{
- i = gTacticalStatus.Team[ ENEMY_TEAM ].bFirstID;
- pSoldier = &Menptr[ i ];
- if( !pGroup->fPlayer && !pGroup->fVehicle && pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && !gbWorldSectorZ )
+ if( !pGroup->fPlayer && !pGroup->fVehicle &&
+ pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && !gbWorldSectorZ )
{
- num = pGroup->ubGroupSize;
ubNumAdmins = pGroup->pEnemyGroup->ubAdminsInBattle;
ubNumTroops = pGroup->pEnemyGroup->ubTroopsInBattle;
ubNumElites = pGroup->pEnemyGroup->ubElitesInBattle;
- while( num && sNumSlots && i <= gTacticalStatus.Team[ ENEMY_TEAM ].bLastID )
+ num = ubNumAdmins + ubNumTroops + ubNumElites;
+
+ for (i= gTacticalStatus.Team[ ENEMY_TEAM ].bFirstID;
+ i<= gTacticalStatus.Team[ ENEMY_TEAM ].bLastID && num;
+ i++)
{
- while( !pSoldier->bActive || pSoldier->ubGroupID )
+ // At this point we should not have added more soldiers than are in slots
+ Assert( sNumSlots);
+
+ pSoldier = &Menptr[ i ];
+
+ // Skip inactive and already grouped soldiers
+ if (!pSoldier->bActive || pSoldier->ubGroupID)
{
- pSoldier = &Menptr[ ++i ];
- if( i > gTacticalStatus.Team[ ENEMY_TEAM ].bLastID )
- {
- AssertMsg( 0, "Failed to assign battle counters for enemies properly. Please send save. KM:0." );
- }
+ continue;
}
+
switch( pSoldier->ubSoldierClass )
{
case SOLDIER_CLASS_ADMINISTRATOR:
@@ -718,8 +727,9 @@ BOOLEAN PrepareEnemyForSectorBattle()
}
break;
}
- pSoldier = &Menptr[ ++i ];
}
+
+ Assert( ubNumElites + ubNumTroops + ubNumAdmins + num == 0);
}
pGroup = pGroup->next;
}
diff --git a/Strategic/Strategic Movement.cpp b/Strategic/Strategic Movement.cpp
index eb5983e4..62c15b47 100644
--- a/Strategic/Strategic Movement.cpp
+++ b/Strategic/Strategic Movement.cpp
@@ -1552,7 +1552,7 @@ void AddCorpsesToBloodcatLair( INT16 sSectorX, INT16 sSectorY )
SET_PALETTEREP_ID ( Corpse.PantsPal, "GREENPANTS" );
- Corpse.bDirection = (INT8)Random(8);
+ Corpse.ubDirection = (UINT8)Random(8);
// Set time of death
// Make sure they will be rotting!
diff --git a/Strategic/Strategic Pathing.cpp b/Strategic/Strategic Pathing.cpp
index 5b1b6656..7f999693 100644
--- a/Strategic/Strategic Pathing.cpp
+++ b/Strategic/Strategic Pathing.cpp
@@ -495,7 +495,9 @@ PathStPtr BuildAStrategicPath(PathStPtr pPath , INT16 iStartSectorNum, INT16 iEn
INT32 iOldDelta = 0;
iCurrentSectorNum=iStartSectorNum;
-
+ if(iEndSectorNum < MAP_WORLD_X-1)
+ return NULL;
+
if (pNode==NULL)
{
// start new path list
@@ -513,9 +515,6 @@ PathStPtr BuildAStrategicPath(PathStPtr pPath , INT16 iStartSectorNum, INT16 iEn
pHeadOfPathList = pNode;
}
- if(iEndSectorNum < MAP_WORLD_X-1)
- return NULL;
-
iPathLength=((INT32)FindStratPath(((INT16)iStartSectorNum),((INT16)iEndSectorNum), sMvtGroupNumber, fTacticalTraversal ));
while(iPathLength > iCount)
{
@@ -885,6 +884,7 @@ PathStPtr ClearStrategicPathList( PathStPtr pHeadOfPath, INT16 sMvtGroup )
// move to next node
pNode = pNode -> pNext;
+ pNode->pPrev = NULL;
// delete delete node
MemFree( pDeleteNode );
diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp
index 5478289f..c9ec3a13 100644
--- a/Strategic/mapscreen.cpp
+++ b/Strategic/mapscreen.cpp
@@ -7510,6 +7510,7 @@ void CheckToSeeIfMouseHasLeftMapRegionDuringPathPlotting( )
// clear the temp path
if( pTempCharacterPath )
{
+ pTempCharacterPath = MoveToBeginningOfPathList( pTempCharacterPath);
pTempCharacterPath = ClearStrategicPathList( pTempCharacterPath, 0 );
}
}
diff --git a/Tactical/Auto Bandage.cpp b/Tactical/Auto Bandage.cpp
index 2f2fc8d5..ffb7454c 100644
--- a/Tactical/Auto Bandage.cpp
+++ b/Tactical/Auto Bandage.cpp
@@ -456,7 +456,8 @@ void AutoBandage( BOOLEAN fStart )
cnt = gTacticalStatus.Team[ OUR_TEAM ].bFirstID;
for ( pSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; cnt++,pSoldier++)
{
- if ( pSoldier->bActive )
+ // 0verhaul: Make sure the merc is also in the sector before making him stand up!
+ if ( pSoldier->bActive && pSoldier->bInSector )
{
ActionDone( pSoldier );
if ( pSoldier->bSlotItemTakenFrom != NO_SLOT )
@@ -523,7 +524,12 @@ void AutoBandage( BOOLEAN fStart )
DoScreenIndependantMessageBox(pDoctorWarningString[ 1 ], MSG_BOX_FLAG_OK, NULL );
gfAutoBandageFailed = FALSE;
}
+
+ // Memory cleanup!
+ MemFree( sAutoBandageString);
+ sAutoBandageString = NULL;
}
+
guiAutoBandageSeconds = 0;
ResetAllMercSpeeds( );
diff --git a/Tactical/Boxing.cpp b/Tactical/Boxing.cpp
index 01528c31..336fcfca 100644
--- a/Tactical/Boxing.cpp
+++ b/Tactical/Boxing.cpp
@@ -133,7 +133,7 @@ void BoxingPlayerDisqualified( SOLDIERTYPE * pOffender, INT8 bReason )
{
if (bReason == BOXER_OUT_OF_RING || bReason == NON_BOXER_IN_RING)
{
- EVENT_StopMerc( pOffender, pOffender->sGridNo, pOffender->bDirection );
+ EVENT_StopMerc( pOffender, pOffender->sGridNo, pOffender->ubDirection );
}
SetBoxingState( DISQUALIFIED );
TriggerNPCRecord( DARREN, 21 );
diff --git a/Tactical/End Game.cpp b/Tactical/End Game.cpp
index 7844e1e1..ff72550c 100644
--- a/Tactical/End Game.cpp
+++ b/Tactical/End Game.cpp
@@ -437,7 +437,7 @@ void BeginHandleQueenBitchDeath( SOLDIERTYPE *pKillerSoldier, INT16 sGridNo, INT
{
// gTacticalStatus.ubAttackBusyCount++;
DebugAttackBusy( "Killing off a queen ally.\n");
- EVENT_SoldierGotHit( pTeamSoldier, 0, 10000, 0, pTeamSoldier->bDirection, 320, NOBODY , FIRE_WEAPON_NO_SPECIAL, pTeamSoldier->bAimShotLocation, 0, NOWHERE );
+ EVENT_SoldierGotHit( pTeamSoldier, 0, 10000, 0, pTeamSoldier->ubDirection, 320, NOBODY , FIRE_WEAPON_NO_SPECIAL, pTeamSoldier->bAimShotLocation, 0, NOWHERE );
}
}
}
diff --git a/Tactical/Enemy Soldier Save.cpp b/Tactical/Enemy Soldier Save.cpp
index 534ad043..94a52f10 100644
--- a/Tactical/Enemy Soldier Save.cpp
+++ b/Tactical/Enemy Soldier Save.cpp
@@ -289,7 +289,7 @@ BOOLEAN LoadEnemySoldiersFromTempFile()
*curr->pDetailedPlacement = tempDetailedPlacement;
curr->pBasicPlacement->fPriorityExistance = TRUE;
- curr->pBasicPlacement->bDirection = curr->pDetailedPlacement->bDirection;
+ curr->pBasicPlacement->ubDirection = curr->pDetailedPlacement->ubDirection;
curr->pBasicPlacement->bOrders = curr->pDetailedPlacement->bOrders;
curr->pBasicPlacement->bAttitude = curr->pDetailedPlacement->bAttitude;
curr->pBasicPlacement->bBodyType = curr->pDetailedPlacement->bBodyType;
@@ -332,7 +332,7 @@ BOOLEAN LoadEnemySoldiersFromTempFile()
curr->pDetailedPlacement->sSectorX * 7 -
curr->pDetailedPlacement->ubSoldierClass * 4 +
curr->pDetailedPlacement->bTeam * 7 +
- curr->pDetailedPlacement->bDirection * 5 +
+ curr->pDetailedPlacement->ubDirection * 5 +
curr->pDetailedPlacement->fOnRoof * 17 +
curr->pDetailedPlacement->sInsertionGridNo * 1 +
3;
@@ -519,7 +519,7 @@ BOOLEAN SaveEnemySoldiersToTempFile( INT16 sSectorX, INT16 sSectorY, INT8 bSecto
curr->pDetailedPlacement->bSectorZ = pSoldier->bSectorZ;
curr->pDetailedPlacement->ubSoldierClass = pSoldier->ubSoldierClass;
curr->pDetailedPlacement->bTeam = pSoldier->bTeam;
- curr->pDetailedPlacement->bDirection = pSoldier->bDirection;
+ curr->pDetailedPlacement->ubDirection = pSoldier->ubDirection;
//we don't want the player to think that all the enemies start in the exact position when we
//left the map, so randomize the start locations either current position or original position.
@@ -729,7 +729,7 @@ BOOLEAN SaveEnemySoldiersToTempFile( INT16 sSectorX, INT16 sSectorY, INT8 bSecto
curr->pDetailedPlacement->sSectorX * 7 -
curr->pDetailedPlacement->ubSoldierClass * 4 +
curr->pDetailedPlacement->bTeam * 7 +
- curr->pDetailedPlacement->bDirection * 5 +
+ curr->pDetailedPlacement->ubDirection * 5 +
curr->pDetailedPlacement->fOnRoof * 17 +
curr->pDetailedPlacement->sInsertionGridNo * 1 +
3;
@@ -1016,7 +1016,7 @@ BOOLEAN NewWayOfLoadingEnemySoldiersFromTempFile()
*curr->pDetailedPlacement = tempDetailedPlacement;
curr->pBasicPlacement->fPriorityExistance = TRUE;
- curr->pBasicPlacement->bDirection = curr->pDetailedPlacement->bDirection;
+ curr->pBasicPlacement->ubDirection = curr->pDetailedPlacement->ubDirection;
curr->pBasicPlacement->bOrders = curr->pDetailedPlacement->bOrders;
curr->pBasicPlacement->bAttitude = curr->pDetailedPlacement->bAttitude;
curr->pBasicPlacement->bBodyType = curr->pDetailedPlacement->bBodyType;
@@ -1059,7 +1059,7 @@ BOOLEAN NewWayOfLoadingEnemySoldiersFromTempFile()
curr->pDetailedPlacement->sSectorX * 7 -
curr->pDetailedPlacement->ubSoldierClass * 4 +
curr->pDetailedPlacement->bTeam * 7 +
- curr->pDetailedPlacement->bDirection * 5 +
+ curr->pDetailedPlacement->ubDirection * 5 +
curr->pDetailedPlacement->fOnRoof * 17 +
curr->pDetailedPlacement->sInsertionGridNo * 1 +
3;
@@ -1376,7 +1376,7 @@ BOOLEAN NewWayOfLoadingCiviliansFromTempFile()
*curr->pDetailedPlacement = tempDetailedPlacement;
curr->pBasicPlacement->fPriorityExistance = TRUE;
- curr->pBasicPlacement->bDirection = curr->pDetailedPlacement->bDirection;
+ curr->pBasicPlacement->ubDirection = curr->pDetailedPlacement->ubDirection;
curr->pBasicPlacement->bOrders = curr->pDetailedPlacement->bOrders;
curr->pBasicPlacement->bAttitude = curr->pDetailedPlacement->bAttitude;
curr->pBasicPlacement->bBodyType = curr->pDetailedPlacement->bBodyType;
@@ -1419,7 +1419,7 @@ BOOLEAN NewWayOfLoadingCiviliansFromTempFile()
curr->pDetailedPlacement->sSectorX * 7 -
curr->pDetailedPlacement->ubSoldierClass * 4 +
curr->pDetailedPlacement->bTeam * 7 +
- curr->pDetailedPlacement->bDirection * 5 +
+ curr->pDetailedPlacement->ubDirection * 5 +
curr->pDetailedPlacement->fOnRoof * 17 +
curr->pDetailedPlacement->sInsertionGridNo * 1 +
3;
@@ -1614,7 +1614,7 @@ BOOLEAN NewWayOfSavingEnemyAndCivliansToTempFile( INT16 sSectorX, INT16 sSectorY
curr->pDetailedPlacement->bSectorZ = pSoldier->bSectorZ;
curr->pDetailedPlacement->ubSoldierClass = pSoldier->ubSoldierClass;
curr->pDetailedPlacement->bTeam = pSoldier->bTeam;
- curr->pDetailedPlacement->bDirection = pSoldier->bDirection;
+ curr->pDetailedPlacement->ubDirection = pSoldier->ubDirection;
//we don't want the player to think that all the enemies start in the exact position when we
//left the map, so randomize the start locations either current position or original position.
@@ -1807,7 +1807,7 @@ BOOLEAN NewWayOfSavingEnemyAndCivliansToTempFile( INT16 sSectorX, INT16 sSectorY
curr->pDetailedPlacement->sSectorX * 7 -
curr->pDetailedPlacement->ubSoldierClass * 4 +
curr->pDetailedPlacement->bTeam * 7 +
- curr->pDetailedPlacement->bDirection * 5 +
+ curr->pDetailedPlacement->ubDirection * 5 +
curr->pDetailedPlacement->fOnRoof * 17 +
curr->pDetailedPlacement->sInsertionGridNo * 1 +
3;
@@ -2073,7 +2073,7 @@ BOOLEAN CountNumberOfElitesRegularsAdminsAndCreaturesFromEnemySoldiersTempFile(
*curr->pDetailedPlacement = tempDetailedPlacement;
curr->pBasicPlacement->fPriorityExistance = TRUE;
- curr->pBasicPlacement->bDirection = curr->pDetailedPlacement->bDirection;
+ curr->pBasicPlacement->ubDirection = curr->pDetailedPlacement->ubDirection;
curr->pBasicPlacement->bOrders = curr->pDetailedPlacement->bOrders;
curr->pBasicPlacement->bAttitude = curr->pDetailedPlacement->bAttitude;
curr->pBasicPlacement->bBodyType = curr->pDetailedPlacement->bBodyType;
@@ -2116,7 +2116,7 @@ BOOLEAN CountNumberOfElitesRegularsAdminsAndCreaturesFromEnemySoldiersTempFile(
curr->pDetailedPlacement->sSectorX * 7 -
curr->pDetailedPlacement->ubSoldierClass * 4 +
curr->pDetailedPlacement->bTeam * 7 +
- curr->pDetailedPlacement->bDirection * 5 +
+ curr->pDetailedPlacement->ubDirection * 5 +
curr->pDetailedPlacement->fOnRoof * 17 +
curr->pDetailedPlacement->sInsertionGridNo * 1 +
3;
diff --git a/Tactical/Handle Doors.cpp b/Tactical/Handle Doors.cpp
index afc1ee5f..d82b62f3 100644
--- a/Tactical/Handle Doors.cpp
+++ b/Tactical/Handle Doors.cpp
@@ -307,7 +307,7 @@ void InteractWithOpenableStruct( SOLDIERTYPE *pSoldier, STRUCTURE *pStructure, U
if ( pDoorStatus && (pDoorStatus->ubFlags & DOOR_BUSY) )
{
// Send this guy into stationary stance....
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
if ( pSoldier->bTeam == gbPlayerNum )
{
diff --git a/Tactical/Handle Items.cpp b/Tactical/Handle Items.cpp
index fdda0e0f..5eb13b00 100644
--- a/Tactical/Handle Items.cpp
+++ b/Tactical/Handle Items.cpp
@@ -2152,7 +2152,7 @@ OBJECTTYPE* InternalAddItemToPool( INT16 *psGridNo, OBJECTTYPE *pObject, INT8 bV
// IF SO, DONT'T ADD!
bTerrainID = GetTerrainType( *psGridNo );
- if ( bTerrainID == DEEP_WATER || bTerrainID == LOW_WATER || bTerrainID == MED_WATER )
+ if ( TERRAIN_IS_WATER( bTerrainID) )
{
// if ( Item[ pObject->usItem ].fFlags & ITEM_SINKS )
if ( Item[ pObject->usItem ].sinks )
diff --git a/Tactical/Handle UI Plan.cpp b/Tactical/Handle UI Plan.cpp
index 4c8e4a8a..24ac2c53 100644
--- a/Tactical/Handle UI Plan.cpp
+++ b/Tactical/Handle UI Plan.cpp
@@ -115,7 +115,7 @@ BOOLEAN AddUIPlan( UINT16 sGridNo, UINT8 ubPlanID )
bDirection = (INT8)gpUIPlannedSoldier->usPathingData[ gpUIPlannedSoldier->usPathDataSize - 1 ];
// Set direction
- pPlanSoldier->bDirection = bDirection;
+ pPlanSoldier->ubDirection = bDirection;
pPlanSoldier->bDesiredDirection = bDirection;
// Set walking animation
@@ -194,7 +194,7 @@ BOOLEAN AddUIPlan( UINT16 sGridNo, UINT8 ubPlanID )
bDirection = (INT8)gpUIPlannedSoldier->usPathingData[ gpUIPlannedSoldier->usPathDataSize - 1 ];
// Set direction
- pPlanSoldier->bDirection = bDirection;
+ pPlanSoldier->ubDirection = bDirection;
pPlanSoldier->bDesiredDirection = bDirection;
// Set walking animation
@@ -220,7 +220,7 @@ BOOLEAN AddUIPlan( UINT16 sGridNo, UINT8 ubPlanID )
bDirection = (INT8)GetDirectionFromGridNo( sGridNo, gpUIPlannedSoldier );
// Set direction
- gpUIPlannedSoldier->bDirection = bDirection;
+ gpUIPlannedSoldier->ubDirection = bDirection;
gpUIPlannedSoldier->bDesiredDirection = bDirection;
// Set to shooting animation
diff --git a/Tactical/Handle UI.cpp b/Tactical/Handle UI.cpp
index 184db366..d524ef3b 100644
--- a/Tactical/Handle UI.cpp
+++ b/Tactical/Handle UI.cpp
@@ -85,6 +85,7 @@
#include "qarray.h"
#include "environment.h"
#include "Map Information.h"
+#include "Soldier Control.h"
#endif
@@ -246,8 +247,6 @@ void SetUIbasedOnStance( SOLDIERTYPE *pSoldier, INT8 bNewStance );
INT8 DrawUIMovementPath( SOLDIERTYPE *pSoldier, UINT16 usMapPos, UINT32 uiFlags );
INT8 UIHandleInteractiveTilesAndItemsOnTerrain( SOLDIERTYPE *pSoldier, INT16 usMapPos, BOOLEAN fUseOKCursor, BOOLEAN fItemsOnlyIfOnIntTiles );
-extern void EVENT_InternalSetSoldierDesiredDirection( SOLDIERTYPE *pSoldier, UINT16 usNewDirection, BOOLEAN fInitalMove, UINT16 usAnimState );
-
extern BOOLEAN gfExitDebugScreen;
extern INT8 gCurDebugPage;
extern BOOLEAN gfGetNewPathThroughPeople;
@@ -1238,7 +1237,7 @@ UINT32 UIHandleTestHit( UI_EVENT *pUIEvent )
// gTacticalStatus.ubAttackBusyCount++;
DebugAttackBusy( "Testing a hit.\n" );
- EVENT_SoldierGotHit( pSoldier, 1, bDamage, 10, pSoldier->bDirection, 320, NOBODY , FIRE_WEAPON_NO_SPECIAL, pSoldier->bAimShotLocation, 0, NOWHERE );
+ EVENT_SoldierGotHit( pSoldier, 1, bDamage, 10, pSoldier->ubDirection, 320, NOBODY , FIRE_WEAPON_NO_SPECIAL, pSoldier->bAimShotLocation, 0, NOWHERE );
// callahan update end - put everything as it was
}
return( GAME_SCREEN );
@@ -2136,7 +2135,7 @@ UINT32 UIHandleMAdjustStanceMode( UI_EVENT *pUIEvent )
// IF we are on a basic level...(temp)
if ( pSoldier->bLevel == 0 )
{
- if ( FindHeigherLevel( pSoldier, pSoldier->sGridNo, pSoldier->bDirection, &bNewDirection ) )
+ if ( FindHeigherLevel( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &bNewDirection ) )
{
ubNearHeigherLevel = TRUE;
}
@@ -2145,7 +2144,7 @@ UINT32 UIHandleMAdjustStanceMode( UI_EVENT *pUIEvent )
// IF we are higher...
if ( pSoldier->bLevel > 0 )
{
- if ( FindLowerLevel( pSoldier, pSoldier->sGridNo, pSoldier->bDirection, &bNewDirection ) )
+ if ( FindLowerLevel( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &bNewDirection ) )
{
ubNearLowerLevel = TRUE;
}
@@ -3000,7 +2999,7 @@ void GetMercClimbDirection( UINT8 ubSoldierID, BOOLEAN *pfGoDown, BOOLEAN *pfGoU
if ( pSoldier->bLevel == 0 )
{
// See if we are not in a building!
- if ( FindHeigherLevel( pSoldier, pSoldier->sGridNo, pSoldier->bDirection, &bNewDirection ) )
+ if ( FindHeigherLevel( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &bNewDirection ) )
{
*pfGoUp = TRUE;
}
@@ -3009,7 +3008,7 @@ void GetMercClimbDirection( UINT8 ubSoldierID, BOOLEAN *pfGoDown, BOOLEAN *pfGoU
// IF we are higher...
if ( pSoldier->bLevel > 0 )
{
- if ( FindLowerLevel( pSoldier, pSoldier->sGridNo, pSoldier->bDirection, &bNewDirection ) )
+ if ( FindLowerLevel( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &bNewDirection ) )
{
*pfGoDown = TRUE;
}
@@ -4571,7 +4570,7 @@ UINT32 UIHandleLCOnTerrain( UI_EVENT *pUIEvent )
sFacingDir = GetDirectionFromXY( sXPos, sYPos, pSoldier );
// Set # of APs
- if ( sFacingDir != pSoldier->bDirection )
+ if ( sFacingDir != pSoldier->ubDirection )
{
gsCurrentActionPoints = GetAPsToLook( pSoldier );
gfUIHandleShowMoveGrid = FALSE;
@@ -4627,7 +4626,7 @@ BOOLEAN MakeSoldierTurn( SOLDIERTYPE *pSoldier, INT16 sXPos, INT16 sYPos )
// Get direction from mouse pos
sFacingDir = GetDirectionFromXY( sXPos, sYPos, pSoldier );
- if ( sFacingDir != pSoldier->bDirection )
+ if ( sFacingDir != pSoldier->ubDirection )
{
sAPCost = GetAPsToLook( pSoldier );
@@ -5341,7 +5340,7 @@ UINT32 UIHandleJumpOver( UI_EVENT *pUIEvent )
{
SOLDIERTYPE *pSoldier;
UINT16 usMapPos;
- INT8 bDirection;
+ UINT8 ubDirection;
// Here, first get map screen
if ( !GetSoldier( &pSoldier, gusSelectedSoldier ) )
@@ -5366,11 +5365,11 @@ UINT32 UIHandleJumpOver( UI_EVENT *pUIEvent )
pSoldier->ubPendingAction = NO_PENDING_ACTION;
// Get direction to goto....
- bDirection = (INT8)GetDirectionFromGridNo( usMapPos, pSoldier );
+ ubDirection = GetDirectionFromGridNo( usMapPos, pSoldier );
pSoldier->fDontChargeTurningAPs = TRUE;
- EVENT_InternalSetSoldierDesiredDirection( pSoldier, bDirection, FALSE, pSoldier->usAnimState );
+ EVENT_SetSoldierDesiredDirection( pSoldier, ubDirection);
pSoldier->fTurningUntilDone = TRUE;
// ATE: Reset flag to go back to prone...
//pSoldier->fTurningFromPronePosition = TURNING_FROM_PRONE_OFF;
diff --git a/Tactical/Interface Dialogue.cpp b/Tactical/Interface Dialogue.cpp
index c485f94d..26b800ff 100644
--- a/Tactical/Interface Dialogue.cpp
+++ b/Tactical/Interface Dialogue.cpp
@@ -1775,7 +1775,7 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum
// see if we are facing this person
ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(pSoldier2->sGridNo),CenterY(pSoldier2->sGridNo));
// if not already facing in that direction,
- if (pSoldier->bDirection != ubDesiredMercDir)
+ if (pSoldier->ubDirection != ubDesiredMercDir)
{
EVENT_SetSoldierDesiredDirection( pSoldier, ubDesiredMercDir );
}
@@ -1961,7 +1961,7 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum
pSoldier = FindSoldierByProfileID( ubTargetNPC, FALSE );
if (pSoldier && pSoldier->inv[HANDPOS].usItem != NOTHING)
{
- sGridNo = pSoldier->sGridNo + DirectionInc( pSoldier->bDirection );
+ sGridNo = pSoldier->sGridNo + DirectionInc( pSoldier->ubDirection );
SoldierReadyWeapon( pSoldier, (INT16) (sGridNo % WORLD_COLS), (INT16) (sGridNo / WORLD_COLS), FALSE );
}
break;
@@ -2226,7 +2226,7 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum
if (bItemIn != NO_SLOT && bItemIn != HANDPOS)
{
SwapObjs( &(pSoldier->inv[HANDPOS]), &(pSoldier->inv[bItemIn]) );
- sGridNo = pSoldier->sGridNo + DirectionInc( pSoldier->bDirection );
+ sGridNo = pSoldier->sGridNo + DirectionInc( pSoldier->ubDirection );
SoldierReadyWeapon( pSoldier, (INT16) (sGridNo % WORLD_COLS), (INT16) (sGridNo / WORLD_COLS), FALSE );
}
// fall through so that the person faces the nearest merc!
@@ -2240,7 +2240,7 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum
// see if we are facing this person
ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sGridNo),CenterY(sGridNo));
// if not already facing in that direction,
- if (pSoldier->bDirection != ubDesiredMercDir)
+ if (pSoldier->ubDirection != ubDesiredMercDir)
{
EVENT_SetSoldierDesiredDirection( pSoldier, ubDesiredMercDir );
}
@@ -2395,7 +2395,7 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum
if (pSoldier)
{
DeleteTalkingMenu();
- EVENT_SoldierGotHit( pSoldier, 1, 100, 10, pSoldier->bDirection, 320, NOBODY , FIRE_WEAPON_NO_SPECIAL, AIM_SHOT_TORSO, 0, NOWHERE );
+ EVENT_SoldierGotHit( pSoldier, 1, 100, 10, pSoldier->ubDirection, 320, NOBODY , FIRE_WEAPON_NO_SPECIAL, AIM_SHOT_TORSO, 0, NOWHERE );
}
break;
diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp
index 4a1fa6db..bbcc3616 100644
--- a/Tactical/Interface Items.cpp
+++ b/Tactical/Interface Items.cpp
@@ -4455,7 +4455,7 @@ BOOLEAN SoldierCanSeeCatchComing( SOLDIERTYPE *pSoldier, INT16 sSrcGridNo )
bTargetDirection = (INT8)GetDirectionToGridNoFromGridNo( pSoldier->sGridNo, sSrcGridNo );
// Look 3 directions Clockwise from what we are facing....
- bDirection = pSoldier->bDirection;
+ bDirection = pSoldier->ubDirection;
for ( cnt = 0; cnt < 3; cnt++ )
{
@@ -4468,7 +4468,7 @@ BOOLEAN SoldierCanSeeCatchComing( SOLDIERTYPE *pSoldier, INT16 sSrcGridNo )
}
// Look 3 directions CounterClockwise from what we are facing....
- bDirection = pSoldier->bDirection;
+ bDirection = pSoldier->ubDirection;
for ( cnt = 0; cnt < 3; cnt++ )
{
@@ -4826,7 +4826,7 @@ BOOLEAN HandleItemPointerClick( UINT16 usMapPos )
}
// Don't allow if our soldier is a # of things...
- if ( AM_AN_EPC( gpItemPointerSoldier ) || gpItemPointerSoldier->bLife < OKLIFE || gpItemPointerSoldier->bOverTerrainType == DEEP_WATER )
+ if ( AM_AN_EPC( gpItemPointerSoldier ) || gpItemPointerSoldier->bLife < OKLIFE || MercInDeepWater( gpItemPointerSoldier) )
{
return( FALSE );
}
@@ -5130,7 +5130,7 @@ BOOLEAN HandleItemPointerClick( UINT16 usMapPos )
ubFacingDirection = (UINT8)GetDirectionFromGridNo( gpItemPointerSoldier->sGridNo, pSoldier );
// Stop merc first....
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
// WANNE: Also turn merc if he is crouched and he passes an item
if ( !MercInWater( pSoldier ) )
diff --git a/Tactical/Interface Panels.cpp b/Tactical/Interface Panels.cpp
index d062e46e..0780c1e4 100644
--- a/Tactical/Interface Panels.cpp
+++ b/Tactical/Interface Panels.cpp
@@ -900,7 +900,7 @@ void UpdateSMPanel( )
}
}
- if ( FindFenceJumpDirection( gpSMCurrentMerc, gpSMCurrentMerc->sGridNo, gpSMCurrentMerc->bDirection, &bDirection ) )
+ if ( FindFenceJumpDirection( gpSMCurrentMerc, gpSMCurrentMerc->sGridNo, gpSMCurrentMerc->ubDirection, &bDirection ) )
{
EnableButton( iSMPanelButtons[ CLIMB_BUTTON ] );
}
@@ -3140,7 +3140,7 @@ void BtnClimbCallback(GUI_BUTTON *btn,INT32 reason)
BeginSoldierClimbUpRoof( gpSMCurrentMerc );
}
- if ( FindFenceJumpDirection( gpSMCurrentMerc, gpSMCurrentMerc->sGridNo, gpSMCurrentMerc->bDirection, &bDirection ) )
+ if ( FindFenceJumpDirection( gpSMCurrentMerc, gpSMCurrentMerc->sGridNo, gpSMCurrentMerc->ubDirection, &bDirection ) )
{
BeginSoldierClimbFence( gpSMCurrentMerc );
}
diff --git a/Tactical/Item Types.h b/Tactical/Item Types.h
index 86837226..08cb7f67 100644
--- a/Tactical/Item Types.h
+++ b/Tactical/Item Types.h
@@ -586,10 +586,10 @@ typedef enum
BIG_TEAR_GAS,
SMALL_CREATURE_GAS,
LARGE_CREATURE_GAS,
- VERY_SMALL_CREATURE_GAS,
+ VERY_SMALL_CREATURE_GAS=995, // Renumbered because the original 160 was lost
// armor
- FLAK_JACKET, //= FIRST_ARMOUR, ( We're out of space! )
+ FLAK_JACKET=161, //= FIRST_ARMOUR, ( We're out of space! )
FLAK_JACKET_18,
FLAK_JACKET_Y,
KEVLAR_VEST,
diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp
index 74f7daee..95331fe2 100644
--- a/Tactical/Items.cpp
+++ b/Tactical/Items.cpp
@@ -4844,6 +4844,7 @@ BOOLEAN CreateGun( UINT16 usItem, INT8 bStatus, OBJECTTYPE * pObj )
{
pObj->ItemData.Gun.ubGunShotsLeft = GetMagSize(pObj);
pObj->ItemData.Gun.ubGunAmmoType = AMMO_MONSTER;
+ pObj->ItemData.Gun.ubGunState |= GS_CARTRIDGE_IN_CHAMBER; // 0verhaul: Monsters don't have to reload!
}
else if ( EXPLOSIVE_GUN( usItem ) )
{
@@ -5701,7 +5702,7 @@ void WaterDamage( SOLDIERTYPE *pSoldier )
INT8 bLoop, bDamage, bDieSize;
UINT32 uiRoll;
- if ( pSoldier->bOverTerrainType == DEEP_WATER )
+ if ( MercInDeepWater( pSoldier) )
{
for ( bLoop = 0; bLoop < NUM_INV_SLOTS; bLoop++ )
{
@@ -5733,7 +5734,7 @@ void WaterDamage( SOLDIERTYPE *pSoldier )
{
// reduce camouflage by 2% per tile of deep water
// and 1% for medium water
- if ( pSoldier->bOverTerrainType == DEEP_WATER )
+ if ( MercInDeepWater( pSoldier) )
pSoldier->bCamo = __max( 0, pSoldier->bCamo - 2 );
else
pSoldier->bCamo = __max( 0, pSoldier->bCamo - 1 );
@@ -5746,7 +5747,7 @@ void WaterDamage( SOLDIERTYPE *pSoldier )
{
// reduce camouflage by 2% per tile of deep water
// and 1% for medium water
- if ( pSoldier->bOverTerrainType == DEEP_WATER )
+ if ( MercInDeepWater( pSoldier) )
pSoldier->urbanCamo = __max( 0, pSoldier->urbanCamo - 2 );
else
pSoldier->urbanCamo = __max( 0, pSoldier->urbanCamo - 1 );
@@ -5759,7 +5760,7 @@ void WaterDamage( SOLDIERTYPE *pSoldier )
{
// reduce camouflage by 2% per tile of deep water
// and 1% for medium water
- if ( pSoldier->bOverTerrainType == DEEP_WATER )
+ if ( MercInDeepWater( pSoldier) )
pSoldier->desertCamo = __max( 0, pSoldier->desertCamo - 2 );
else
pSoldier->desertCamo = __max( 0, pSoldier->desertCamo - 1 );
@@ -5772,7 +5773,7 @@ void WaterDamage( SOLDIERTYPE *pSoldier )
{
// reduce camouflage by 2% per tile of deep water
// and 1% for medium water
- if ( pSoldier->bOverTerrainType == DEEP_WATER )
+ if ( MercInDeepWater( pSoldier) )
pSoldier->snowCamo = __max( 0, pSoldier->snowCamo - 2 );
else
pSoldier->snowCamo = __max( 0, pSoldier->snowCamo - 1 );
@@ -5798,7 +5799,7 @@ void WaterDamage( SOLDIERTYPE *pSoldier )
if ( pSoldier->bTeam == gbPlayerNum && pSoldier->bMonsterSmell > 0 )
{
- if ( pSoldier->bOverTerrainType == DEEP_WATER )
+ if ( MercInDeepWater( pSoldier) )
{
bDieSize = 10;
}
@@ -6557,8 +6558,6 @@ INT16 GetVisionRangeBonus( SOLDIERTYPE * pSoldier )
UINT16 usItem;
INVTYPE *pItem;
- //ADB and AXP 28.03.2007: CtH bug fix: We also want to check on a firing weapon, "raised" alone is not enough ;)
- bool usingGunScope = WeaponReady(pSoldier);
for (int i = HELMETPOS; i < BIGPOCK1POS; i++)
{
// Okay, it's time for some optimization here too
@@ -6572,15 +6571,16 @@ INT16 GetVisionRangeBonus( SOLDIERTYPE * pSoldier )
continue;
}
- if (!IsWeapon(usItem) || (IsWeapon(usItem) && usingGunScope == true) )
+ if (!IsWeapon(usItem) || (IsWeapon(usItem) && WeaponReady(pSoldier) ) )
{
bns += BonusReduceMore( pItem->visionrangebonus, pObj->ItemData.Generic.bStatus[0] );
}
}
- // Snap: check only attachments on a raised weapon!
+ // Snap: check only attachments on a readied weapon!
+ // 0verhaul: Moved this bug fix into WeaponReady so that all CTH modifier functions may benefit from this fix
//AXP 28.03.2007: CtH bug fix: We also want to check on a firing weapon, "raised" alone is not enough ;)
- if ( usingGunScope == true )
+ if ( WeaponReady(pSoldier) )
{
pObj = &( pSoldier->inv[HANDPOS]);
@@ -6614,8 +6614,6 @@ INT16 GetNightVisionRangeBonus( SOLDIERTYPE * pSoldier, UINT8 bLightLevel )
UINT16 usItem;
INVTYPE *pItem;
- //ADB and AXP 28.03.2007: CtH bug fix: We also want to check on a firing weapon, "raised" alone is not enough ;)
- bool usingGunScope = WeaponReady(pSoldier);
for (int i = HELMETPOS; i < BIGPOCK1POS; i++)
{
// More optimization
@@ -6629,7 +6627,7 @@ INT16 GetNightVisionRangeBonus( SOLDIERTYPE * pSoldier, UINT8 bLightLevel )
continue;
}
- if (!IsWeapon(usItem) || (IsWeapon(usItem) && usingGunScope == true ) )
+ if (!IsWeapon(usItem) || (IsWeapon(usItem) && WeaponReady(pSoldier) ) )
{
bns += BonusReduceMore(
NightBonusScale( pItem->nightvisionrangebonus, bLightLevel ),
@@ -6638,7 +6636,7 @@ INT16 GetNightVisionRangeBonus( SOLDIERTYPE * pSoldier, UINT8 bLightLevel )
}
// Snap: check only attachments on a raised weapon!
- if ( usingGunScope == true )
+ if ( WeaponReady(pSoldier) )
{
pObj = &( pSoldier->inv[HANDPOS]);
@@ -6660,8 +6658,6 @@ INT16 GetCaveVisionRangeBonus( SOLDIERTYPE * pSoldier, UINT8 bLightLevel )
UINT16 usItem;
INVTYPE *pItem;
- //ADB and AXP 28.03.2007: CtH bug fix: We also want to check on a firing weapon, "raised" alone is not enough ;)
- bool usingGunScope = WeaponReady(pSoldier);
for (int i = 0; i < BIGPOCK1POS; i++)
{
// More optimization
@@ -6676,7 +6672,7 @@ INT16 GetCaveVisionRangeBonus( SOLDIERTYPE * pSoldier, UINT8 bLightLevel )
continue;
}
- if (!IsWeapon(usItem) || (IsWeapon(usItem) && usingGunScope == true ) )
+ if (!IsWeapon(usItem) || (IsWeapon(usItem) && WeaponReady(pSoldier) ) )
{
bns += BonusReduceMore(
NightBonusScale( pItem->cavevisionrangebonus, bLightLevel ),
@@ -6685,7 +6681,7 @@ INT16 GetCaveVisionRangeBonus( SOLDIERTYPE * pSoldier, UINT8 bLightLevel )
}
// Snap: check only attachments on a raised weapon!
- if ( usingGunScope == true )
+ if ( WeaponReady(pSoldier) )
{
pObj = &( pSoldier->inv[HANDPOS]);
@@ -6709,8 +6705,6 @@ INT16 GetDayVisionRangeBonus( SOLDIERTYPE * pSoldier, UINT8 bLightLevel )
// Snap: Scale the bonus with the light level
- //ADB and AXP 28.03.2007: CtH bug fix: We also want to check on a firing weapon, "raised" alone is not enough ;)
- bool usingGunScope = WeaponReady(pSoldier);
for (int i = 0; i < BIGPOCK1POS; i++)
{
// More optimization
@@ -6725,7 +6719,7 @@ INT16 GetDayVisionRangeBonus( SOLDIERTYPE * pSoldier, UINT8 bLightLevel )
continue;
}
- if (!IsWeapon(usItem) || (IsWeapon(usItem) && usingGunScope == true ) )
+ if (!IsWeapon(usItem) || (IsWeapon(usItem) && WeaponReady(pSoldier) ) )
{
bns += BonusReduceMore( idiv( pItem->dayvisionrangebonus
* (NORMAL_LIGHTLEVEL_NIGHT - bLightLevel), NORMAL_LIGHTLEVEL_NIGHT ),
@@ -6734,7 +6728,7 @@ INT16 GetDayVisionRangeBonus( SOLDIERTYPE * pSoldier, UINT8 bLightLevel )
}
// Snap: check only attachments on a raised weapon!
- if ( usingGunScope == true )
+ if ( WeaponReady(pSoldier) )
{
pObj = &( pSoldier->inv[HANDPOS]);
@@ -6758,8 +6752,6 @@ INT16 GetBrightLightVisionRangeBonus( SOLDIERTYPE * pSoldier, UINT8 bLightLevel
// Snap: Scale the bonus with the light level
- //ADB and AXP 28.03.2007: CtH bug fix: We also want to check on a firing weapon, "raised" alone is not enough ;)
- bool usingGunScope = WeaponReady(pSoldier);
for (int i = 0; i < BIGPOCK1POS; i++)
{
// More optimization
@@ -6774,7 +6766,7 @@ INT16 GetBrightLightVisionRangeBonus( SOLDIERTYPE * pSoldier, UINT8 bLightLevel
continue;
}
- if (!IsWeapon(usItem) || (IsWeapon(usItem) && usingGunScope == true ) )
+ if (!IsWeapon(usItem) || (IsWeapon(usItem) && WeaponReady(pSoldier) ) )
{
bns += BonusReduceMore( idiv( pItem->brightlightvisionrangebonus
* (NORMAL_LIGHTLEVEL_DAY - bLightLevel), NORMAL_LIGHTLEVEL_DAY ),
@@ -6783,7 +6775,7 @@ INT16 GetBrightLightVisionRangeBonus( SOLDIERTYPE * pSoldier, UINT8 bLightLevel
}
// Snap: check only attachments on a raised weapon!
- if ( usingGunScope == true )
+ if ( WeaponReady(pSoldier) )
{
pObj = &( pSoldier->inv[HANDPOS]);
@@ -6850,9 +6842,8 @@ UINT8 GetPercentTunnelVision( SOLDIERTYPE * pSoldier )
}
}
- bool usingGunScope = WeaponReady(pSoldier);
// Snap: check only attachments on a raised weapon!
- if ( usingGunScope == true )
+ if ( WeaponReady(pSoldier) )
{
OBJECTTYPE *pInv = &(pSoldier->inv[HANDPOS]);
usItem = pInv->usItem;
@@ -6877,7 +6868,6 @@ UINT8 GetPercentTunnelVision( SOLDIERTYPE * pSoldier )
BOOLEAN HasThermalOptics( SOLDIERTYPE * pSoldier )
{
- bool usingGunScope = WeaponReady(pSoldier);
for (int i = 0; i < BIGPOCK1POS; i++)
{
if ( (i == HANDPOS || i == SECONDHANDPOS) &&
@@ -6886,7 +6876,7 @@ BOOLEAN HasThermalOptics( SOLDIERTYPE * pSoldier )
continue;
}
- if (!IsWeapon(pSoldier->inv[i].usItem) || (IsWeapon(pSoldier->inv[i].usItem) && usingGunScope == true) )
+ if (!IsWeapon(pSoldier->inv[i].usItem) || (IsWeapon(pSoldier->inv[i].usItem) && WeaponReady(pSoldier) ) )
{
if (Item[pSoldier->inv[i].usItem].thermaloptics)
return TRUE;
@@ -6894,7 +6884,7 @@ BOOLEAN HasThermalOptics( SOLDIERTYPE * pSoldier )
}
// Snap: check only attachments on a raised weapon!
- if ( usingGunScope == true )
+ if ( WeaponReady(pSoldier) )
{
for (int i=0; i < MAX_ATTACHMENTS; i++)
{
diff --git a/Tactical/LOS.cpp b/Tactical/LOS.cpp
index 8d5fbe1f..bfe11802 100644
--- a/Tactical/LOS.cpp
+++ b/Tactical/LOS.cpp
@@ -1410,12 +1410,12 @@ BOOLEAN CalculateSoldierZPos( SOLDIERTYPE * pSoldier, UINT8 ubPosType, FLOAT * p
// Crow always as prone...
ubHeight = ANIM_PRONE;
}
- else if (pSoldier->bOverTerrainType == DEEP_WATER)
+ else if ( MercInDeepWater( pSoldier) )
{
// treat as prone
ubHeight = ANIM_PRONE;
}
- else if ( pSoldier->bOverTerrainType == LOW_WATER || pSoldier->bOverTerrainType == MED_WATER )
+ else if ( MercInShallowWater(pSoldier) )
{
// treat as crouched
ubHeight = ANIM_CROUCH;
@@ -2020,7 +2020,7 @@ BOOLEAN BulletHitMerc( BULLET * pBullet, STRUCTURE * pStructure, BOOLEAN fIntend
if ( (pTarget->ubBodyType >= ADULTFEMALEMONSTER) && (pTarget->ubBodyType <= YAM_MONSTER) )
{
ubAttackDirection = (UINT8) GetDirectionToGridNoFromGridNo( pBullet->pFirer->sGridNo, pTarget->sGridNo );
- if ( ubAttackDirection == pTarget->bDirection || ubAttackDirection == gOneCCDirection[ pTarget->bDirection ] || ubAttackDirection == gOneCDirection[ pTarget->bDirection ] )
+ if ( ubAttackDirection == pTarget->ubDirection || ubAttackDirection == gOneCCDirection[ pTarget->ubDirection ] || ubAttackDirection == gOneCDirection[ pTarget->ubDirection ] )
{
// may hit weak spot!
if (0) // check fact
@@ -2043,7 +2043,7 @@ BOOLEAN BulletHitMerc( BULLET * pBullet, STRUCTURE * pStructure, BOOLEAN fIntend
if (ubHitLocation == AIM_SHOT_RANDOM) // i.e. if not set yet
{
- if (pTarget->bOverTerrainType == DEEP_WATER)
+ if (MercInDeepWater( pTarget) )
{
// automatic head hit!
ubHitLocation = AIM_SHOT_HEAD;
@@ -2054,7 +2054,7 @@ BOOLEAN BulletHitMerc( BULLET * pBullet, STRUCTURE * pStructure, BOOLEAN fIntend
{
case ANIM_STAND:
// Fall through to crouch if in shallow or medium water
- if ( pTarget->bOverTerrainType != LOW_WATER && pTarget->bOverTerrainType != MED_WATER )
+ if ( !MercInShallowWater( pTarget) )
{
dZPosRelToMerc = FixedToFloat( pBullet->qCurrZ ) - CONVERT_PIXELS_TO_HEIGHTUNITS( gpWorldLevelData[pBullet->sGridNo].sHeight );
if ( dZPosRelToMerc > HEIGHT_UNITS )
@@ -2110,7 +2110,7 @@ BOOLEAN BulletHitMerc( BULLET * pBullet, STRUCTURE * pStructure, BOOLEAN fIntend
ubAttackDirection = (UINT8) GetDirectionToGridNoFromGridNo( pBullet->pFirer->sGridNo, pTarget->sGridNo );
ubOppositeDirection = gOppositeDirection[ ubAttackDirection ];
- if ( ! ( ubOppositeDirection == pTarget->bDirection || ubAttackDirection == gOneCCDirection[ pTarget->bDirection ] || ubAttackDirection == gOneCDirection[ pTarget->bDirection ] ) )
+ if ( ! ( ubOppositeDirection == pTarget->ubDirection || ubAttackDirection == gOneCCDirection[ pTarget->ubDirection ] || ubAttackDirection == gOneCDirection[ pTarget->ubDirection ] ) )
{
// lucky bastard was facing away!
}
@@ -4724,7 +4724,7 @@ INT32 CheckForCollision( FLOAT dX, FLOAT dY, FLOAT dZ, FLOAT dDeltaX, FLOAT dDel
if (iCurrAboveLevelZ < 0)
{
// ground is in the way!
- if ( pMapElement->ubTerrainID == DEEP_WATER || pMapElement->ubTerrainID == LOW_WATER || pMapElement->ubTerrainID == MED_WATER )
+ if ( TERRAIN_IS_WATER( pMapElement->ubTerrainID) )
{
return ( COLLISION_WATER );
}
@@ -4764,7 +4764,7 @@ INT32 CheckForCollision( FLOAT dX, FLOAT dY, FLOAT dZ, FLOAT dDeltaX, FLOAT dDel
if ( dZ < iLandHeight)
{
// ground is in the way!
- if ( pMapElement->ubTerrainID == DEEP_WATER || pMapElement->ubTerrainID == LOW_WATER || pMapElement->ubTerrainID == MED_WATER )
+ if ( TERRAIN_IS_WATER( pMapElement->ubTerrainID) )
{
return ( COLLISION_WATER );
}
diff --git a/Tactical/Merc Hiring.cpp b/Tactical/Merc Hiring.cpp
index dab6dfe2..8b959478 100644
--- a/Tactical/Merc Hiring.cpp
+++ b/Tactical/Merc Hiring.cpp
@@ -111,7 +111,8 @@ INT8 HireMerc( MERC_HIRE_STRUCT *pHireMerc)
}
// BUILD STRUCTURES
- memset( &MercCreateStruct, 0, sizeof( MercCreateStruct ) );
+ // MercCreateStruct has been C++'d
+ //memset( &MercCreateStruct, 0, sizeof( MercCreateStruct ) );
MercCreateStruct.ubProfile = ubCurrentSoldier;
MercCreateStruct.fPlayerMerc = TRUE;
MercCreateStruct.sSectorX = pHireMerc->sSectorX;
diff --git a/Tactical/Militia Control.cpp b/Tactical/Militia Control.cpp
index ab1b6e5b..19183f42 100644
--- a/Tactical/Militia Control.cpp
+++ b/Tactical/Militia Control.cpp
@@ -124,7 +124,7 @@ void ResetMilitia()
UINT8 ubNumGreen = 0;
UINT8 ubNumReg = 0;
UINT8 ubNumVet = 0;
- UINT32 cnt;
+ //UINT32 cnt;
// if ( gWorldSectorX !=0 && gWorldSectorY != 0 && NumEnemiesInSector( gWorldSectorX, gWorldSectorY ) )
// fBattleInProgress = TRUE;
@@ -1096,7 +1096,7 @@ BOOLEAN CheckIfRadioIsEquipped( void )
//sFacingDir = GetDirectionFromXY( sXPos, sYPos, pTMilitiaSoldier );
//SendSoldierSetDesiredDirectionEvent( pTMilitiaSoldier, sFacingDir );
//SendSoldierSetDesiredDirectionEvent( pTMilitiaSoldier, gOppositeDirection[ sFacingDir ] );
-//EVENT_StopMerc( pTMilitiaSoldier, pTMilitiaSoldier->sGridNo, pTMilitiaSoldier->bDirection );
+//EVENT_StopMerc( pTMilitiaSoldier, pTMilitiaSoldier->sGridNo, pTMilitiaSoldier->ubDirection );
//SendChangeSoldierStanceEvent( pTMilitiaSoldier, ANIM_PRONE );
//SendChangeSoldierStanceEvent( pTMilitiaSoldier, ANIM_CROUCH );
diff --git a/Tactical/Overhead.cpp b/Tactical/Overhead.cpp
index 3046216c..051ba50a 100644
--- a/Tactical/Overhead.cpp
+++ b/Tactical/Overhead.cpp
@@ -2023,13 +2023,13 @@ BOOLEAN HandleGotoNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving, BOOLE
{
if ( pSoldier2->bActive )
{
- EVENT_StopMerc( pSoldier2, pSoldier2->sGridNo, pSoldier2->bDirection );
+ EVENT_StopMerc( pSoldier2, pSoldier2->sGridNo, pSoldier2->ubDirection );
}
}
}
else
{
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
}
(*pfKeepMoving) = FALSE;
@@ -2049,7 +2049,7 @@ BOOLEAN HandleGotoNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving, BOOLE
if (sMineGridNo != NOWHERE)
{
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
(*pfKeepMoving) = FALSE;
if (pSoldier->bSide != 0)
@@ -2179,7 +2179,7 @@ BOOLEAN HandleGotoNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving, BOOLE
{
if ( pExplosive )
{
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
fDontContinue = TRUE;
DishOutGasDamage( pSoldier, pExplosive, TRUE, FALSE,
@@ -2215,7 +2215,7 @@ BOOLEAN HandleGotoNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving, BOOLE
}
if ( (pSoldier->bBlindedCounter > 0) && (pSoldier->usAnimState == RUNNING) && (Random( 5 ) == 0) &&
- OKFallDirection( pSoldier, (INT16) (pSoldier->sGridNo + DirectionInc( pSoldier->bDirection ) ), pSoldier->bLevel, pSoldier->bDirection, pSoldier->usAnimState ) )
+ OKFallDirection( pSoldier, (INT16) (pSoldier->sGridNo + DirectionInc( pSoldier->ubDirection ) ), pSoldier->bLevel, pSoldier->ubDirection, pSoldier->usAnimState ) )
{
// 20% chance of falling over!
DoMercBattleSound( pSoldier, BATTLE_SOUND_CURSE1 );
@@ -2228,7 +2228,7 @@ BOOLEAN HandleGotoNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving, BOOLE
return( FALSE );
}
else if ( ( GetDrunkLevel( pSoldier ) == DRUNK ) && (Random( 5 ) == 0) &&
- OKFallDirection( pSoldier, (INT16) (pSoldier->sGridNo + DirectionInc( pSoldier->bDirection ) ), pSoldier->bLevel, pSoldier->bDirection, pSoldier->usAnimState ) )
+ OKFallDirection( pSoldier, (INT16) (pSoldier->sGridNo + DirectionInc( pSoldier->ubDirection ) ), pSoldier->bLevel, pSoldier->ubDirection, pSoldier->usAnimState ) )
{
// 20% chance of falling over!
DoMercBattleSound( pSoldier, BATTLE_SOUND_CURSE1 );
@@ -2255,7 +2255,7 @@ BOOLEAN HandleGotoNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving, BOOLE
pSoldier->ubNumTilesMovesSinceLastForget = 0;
TacticalCharacterDialogue( pSoldier, QUOTE_PERSONALITY_TRAIT );
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
if (pSoldier->bActionPoints > 0)
{
pSoldier->bActionPoints -= (INT8) (Random( pSoldier->bActionPoints ) + 1);
@@ -2373,7 +2373,7 @@ void HandleMaryArrival( SOLDIERTYPE * pSoldier )
// Mary has arrived
SetFactTrue( FACT_MARY_OR_JOHN_ARRIVED );
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
TriggerNPCRecord( MARY, 13 );
}
@@ -2417,12 +2417,12 @@ void HandleJohnArrival( SOLDIERTYPE * pSoldier )
SetFactTrue( FACT_MARY_OR_JOHN_ARRIVED );
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
// if Mary is alive/dead
if ( pSoldier2 )
{
- EVENT_StopMerc( pSoldier2, pSoldier2->sGridNo, pSoldier2->bDirection );
+ EVENT_StopMerc( pSoldier2, pSoldier2->sGridNo, pSoldier2->ubDirection );
TriggerNPCRecord( JOHN, 13 );
}
else
@@ -2519,7 +2519,7 @@ BOOLEAN HandleAtNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving )
if (SetOffBombsInGridNo( pSoldier->ubID, pSoldier->sGridNo, FALSE, pSoldier->bLevel ) )
{
(*pfKeepMoving) = FALSE;
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
return( FALSE );
}
@@ -2615,13 +2615,13 @@ BOOLEAN HandleAtNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving )
{
if ( pSoldier2->bActive )
{
- EVENT_StopMerc( pSoldier2, pSoldier2->sGridNo, pSoldier2->bDirection );
+ EVENT_StopMerc( pSoldier2, pSoldier2->sGridNo, pSoldier2->ubDirection );
}
}
}
else
{
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
}
(*pfKeepMoving) = FALSE;
@@ -2641,7 +2641,7 @@ BOOLEAN HandleAtNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving )
if (sMineGridNo != NOWHERE)
{
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
(*pfKeepMoving) = FALSE;
gpWorldLevelData[ sMineGridNo ].uiFlags |= MAPELEMENT_ENEMY_MINE_PRESENT;
@@ -2668,7 +2668,7 @@ BOOLEAN HandleAtNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving )
if (PythSpacesAway( pSoldier->sGridNo, 8842 ) < 11)
{
// Skyrider has arrived!
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
SetFactTrue( FACT_SKYRIDER_CLOSE_TO_CHOPPER );
TriggerNPCRecord( SKYRIDER, 15 );
SetUpHelicopterForPlayer( 13, MAP_ROW_B );
@@ -2698,7 +2698,7 @@ BOOLEAN HandleAtNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving )
// if Joey walks near Martha then trigger Martha record 7
if ( CheckFact( FACT_JOEY_NEAR_MARTHA, 0 ) )
{
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
TriggerNPCRecord( JOEY, 9 );
}
}
@@ -4603,7 +4603,7 @@ INT16 FindAdjacentGridEx( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 *pubDirect
// Set default direction
if (pubDirection)
{
- *pubDirection = pSoldier->bDirection;
+ *pubDirection = pSoldier->ubDirection;
}
// CHECK IF WE WANT TO FORCE GRIDNO TO PERSON
@@ -4896,7 +4896,7 @@ INT16 FindNextToAdjacentGridEx( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 *pub
// CHECK IF IT'S THE SAME ONE AS WE'RE ON, IF SO, RETURN THAT!
if ( pSoldier->sGridNo == sGridNo )
{
- *pubDirection = pSoldier->bDirection;
+ *pubDirection = pSoldier->ubDirection;
return( sGridNo );
}
@@ -5023,7 +5023,7 @@ INT16 FindNextToAdjacentGridEx( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 *pub
{
(*pubDirection) = (UINT8)GetDirectionFromGridNo( sGridNo, pSoldier );
}
- //*pubDirection = pSoldier->bDirection;
+ //*pubDirection = pSoldier->ubDirection;
return( sSpot );
}
@@ -5417,7 +5417,7 @@ void CommonEnterCombatModeCode( )
pSoldier->usQuoteSaidFlags &= (~SOLDIER_QUOTE_SAID_MULTIPLE_CREATURES);
// Hault!
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
// END AI actions
CancelAIAction( pSoldier, TRUE );
@@ -7053,7 +7053,7 @@ void HandleSuppressionFire( UINT8 ubTargetedMerc, UINT8 ubCausedAttacker )
}
break;
default: // standing!
- if (pSoldier->bOverTerrainType == LOW_WATER || pSoldier->bOverTerrainType == DEEP_WATER)
+ if ( MercInWater( pSoldier ))
{
// can't change stance here!
break;
@@ -7900,7 +7900,7 @@ void CencelAllActionsForTimeCompression( void )
if ( pSoldier->bInSector )
{
// Hault!
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
// END AI actions
CancelAIAction( pSoldier, TRUE );
diff --git a/Tactical/PATHAI.cpp b/Tactical/PATHAI.cpp
index 303eec23..b258a076 100644
--- a/Tactical/PATHAI.cpp
+++ b/Tactical/PATHAI.cpp
@@ -2384,11 +2384,11 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo
{
if (fReverse)
{
- iLastDir = gOppositeDirection[s->bDirection];
+ iLastDir = gOppositeDirection[s->ubDirection];
}
else
{
- iLastDir = s->bDirection;
+ iLastDir = s->ubDirection;
}
// start prev-to-last dir at same as current (could cause a problem)
iPrevToLastDir = iLastDir;
@@ -2442,7 +2442,7 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo
{
if (trailTreeNdx < 2)
{
- iLastDir = s->bDirection;
+ iLastDir = s->ubDirection;
}
else if ( trailTree[pCurrPtr->sPathNdx].fFlags & STEP_BACKWARDS )
{
@@ -3866,7 +3866,7 @@ INT16 PlotPath( SOLDIERTYPE *pSold, INT16 sDestGridno, INT8 bCopyRoute, INT8 bPl
usMovementModeToUseForAPs = usMovementMode;
// ATE - MAKE MOVEMENT ALWAYS WALK IF IN WATER
- if ( gpWorldLevelData[ sTempGrid ].ubTerrainID == DEEP_WATER || gpWorldLevelData[ sTempGrid ].ubTerrainID == MED_WATER || gpWorldLevelData[ sTempGrid ].ubTerrainID == LOW_WATER )
+ if ( TERRAIN_IS_WATER( gpWorldLevelData[ sTempGrid ].ubTerrainID) )
{
usMovementModeToUseForAPs = WALKING;
}
diff --git a/Tactical/Points.cpp b/Tactical/Points.cpp
index 2ed13acc..6132c260 100644
--- a/Tactical/Points.cpp
+++ b/Tactical/Points.cpp
@@ -216,7 +216,7 @@ INT16 TerrainBreathPoints(SOLDIERTYPE * pSoldier, INT16 sGridno,INT8 bDir, UINT1
iPoints = iPoints * BreathPointAdjustmentForCarriedWeight( pSoldier ) / 100;
// ATE - MAKE MOVEMENT ALWAYS WALK IF IN WATER
- if ( gpWorldLevelData[ sGridno ].ubTerrainID == DEEP_WATER || gpWorldLevelData[ sGridno ].ubTerrainID == MED_WATER || gpWorldLevelData[ sGridno ].ubTerrainID == LOW_WATER )
+ if ( TERRAIN_IS_WATER( gpWorldLevelData[ sGridno ].ubTerrainID) )
{
usMovementMode = WALKING;
}
@@ -276,7 +276,7 @@ INT16 ActionPointCost( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bDir, UINT16 u
}
// ATE - MAKE MOVEMENT ALWAYS WALK IF IN WATER
- if ( gpWorldLevelData[ sGridNo ].ubTerrainID == DEEP_WATER || gpWorldLevelData[ sGridNo ].ubTerrainID == MED_WATER || gpWorldLevelData[ sGridNo ].ubTerrainID == LOW_WATER )
+ if ( TERRAIN_IS_WATER( gpWorldLevelData[ sGridNo ].ubTerrainID) )
{
usMovementMode = WALKING;
}
@@ -1257,7 +1257,7 @@ void GetAPChargeForShootOrStabWRTGunRaises( SOLDIERTYPE *pSoldier, INT16 sGridNo
ubDirection = (UINT8)GetDirectionFromGridNo( sGridNo, pSoldier );
// Is it the same as he's facing?
- if ( ubDirection != pSoldier->bDirection )
+ if ( ubDirection != pSoldier->ubDirection )
{
fAddingTurningCost = TRUE;
}
@@ -1465,7 +1465,7 @@ UINT8 MinAPsToPunch(SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAddTurningCost
ubDirection = (UINT8)GetDirectionFromGridNo( sGridNo, pSoldier );
// Is it the same as he's facing?
- if ( ubDirection != pSoldier->bDirection )
+ if ( ubDirection != pSoldier->ubDirection )
{
bAPCost += AP_LOOK_STANDING;
}
@@ -1520,7 +1520,7 @@ INT8 PtsToMoveDirection(SOLDIERTYPE *pSoldier, INT8 bDirection )
// ATE: Check if the new place is watter and we were tying to run....
bOverTerrainType = GetTerrainType( sGridno );
- if ( bOverTerrainType == MED_WATER || bOverTerrainType == DEEP_WATER || bOverTerrainType == LOW_WATER )
+ if ( TERRAIN_IS_WATER( bOverTerrainType) )
{
usMoveModeToUse = WALKING;
}
@@ -2222,7 +2222,7 @@ INT16 MinAPsToThrow( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAddTurningCos
ubDirection = (UINT8)GetDirectionFromGridNo( sGridNo, pSoldier );
// Is it the same as he's facing?
- if ( ubDirection != pSoldier->bDirection )
+ if ( ubDirection != pSoldier->ubDirection )
{
//Lalien: disabled it again
//AXP 25.03.2007: Reenabled look cost
diff --git a/Tactical/Rotting Corpses.cpp b/Tactical/Rotting Corpses.cpp
index 0ed76e5c..580bb76e 100644
--- a/Tactical/Rotting Corpses.cpp
+++ b/Tactical/Rotting Corpses.cpp
@@ -412,7 +412,7 @@ UINT16 GetCorpseStructIndex( ROTTING_CORPSE_DEFINITION *pCorpseDef, BOOLEAN fFor
case HUMMER_DEAD:
// OK , these have 2 directions....
- bDirection = gb2DirectionsFrom8[ pCorpseDef->bDirection ];
+ bDirection = gb2DirectionsFrom8[ pCorpseDef->ubDirection ];
if ( fForImage )
{
bDirection = gOneCDirection[ bDirection ];
@@ -427,7 +427,7 @@ UINT16 GetCorpseStructIndex( ROTTING_CORPSE_DEFINITION *pCorpseDef, BOOLEAN fFor
case FMERC_FALLF:
// OK , these have 4 directions....
- bDirection = gb4DirectionsFrom8[ pCorpseDef->bDirection ];
+ bDirection = gb4DirectionsFrom8[ pCorpseDef->ubDirection ];
// if ( fForImage )
// {
@@ -438,7 +438,7 @@ UINT16 GetCorpseStructIndex( ROTTING_CORPSE_DEFINITION *pCorpseDef, BOOLEAN fFor
default:
// Uses 8
- bDirection = pCorpseDef->bDirection;
+ bDirection = pCorpseDef->ubDirection;
if ( fForImage )
{
@@ -541,7 +541,7 @@ INT32 AddRottingCorpse( ROTTING_CORPSE_DEFINITION *pCorpseDef )
AniParams.sX = CenterX( pCorpse->def.sGridNo );
AniParams.sY = CenterY( pCorpse->def.sGridNo );
AniParams.sZ = (INT16)pCorpse->def.sHeightAdjustment;
- AniParams.uiUserData3 = pCorpse->def.bDirection;
+ AniParams.uiUserData3 = pCorpse->def.ubDirection;
if ( !gGameSettings.fOptions[ TOPTION_BLOOD_N_GORE ] )
@@ -847,7 +847,7 @@ BOOLEAN TurnSoldierIntoCorpse( SOLDIERTYPE *pSoldier, BOOLEAN fRemoveMerc, BOOLE
// Determine corpse type!
ubType = (UINT8)gubAnimSurfaceCorpseID[ pSoldier->ubBodyType][ pSoldier->usAnimState ];
- Corpse.bDirection = pSoldier->bDirection;
+ Corpse.ubDirection = pSoldier->ubDirection;
// If we are a vehicle.... only use 1 direction....
if ( pSoldier->uiStatusFlags & SOLDIER_VEHICLE )
@@ -856,17 +856,17 @@ BOOLEAN TurnSoldierIntoCorpse( SOLDIERTYPE *pSoldier, BOOLEAN fRemoveMerc, BOOLE
if ( pSoldier->ubBodyType != ICECREAMTRUCK && pSoldier->ubBodyType != HUMVEE )
{
- Corpse.bDirection = 7;
+ Corpse.ubDirection = 7;
}
else
{
- Corpse.bDirection = gb2DirectionsFrom8[ Corpse.bDirection ];
+ Corpse.ubDirection = gb2DirectionsFrom8[ Corpse.ubDirection ];
}
}
if ( ubType == QUEEN_MONSTER_DEAD || ubType == BURNT_DEAD || ubType == EXPLODE_DEAD )
{
- Corpse.bDirection = 7;
+ Corpse.ubDirection = 7;
}
@@ -1077,7 +1077,7 @@ void AddCrowToCorpse( ROTTING_CORPSE *pCorpse )
MercCreateStruct.sSectorY = gWorldSectorY;
MercCreateStruct.bSectorZ = gbWorldSectorZ;
MercCreateStruct.bBodyType = bBodyType;
- MercCreateStruct.bDirection = SOUTH;
+ MercCreateStruct.ubDirection = SOUTH;
MercCreateStruct.bTeam = CIV_TEAM;
MercCreateStruct.sInsertionGridNo = pCorpse->def.sGridNo;
RandomizeNewSoldierStats( &MercCreateStruct );
@@ -1693,7 +1693,7 @@ INT16 FindNearestAvailableGridNoForCorpse( ROTTING_CORPSE_DEFINITION *pDef, INT8
{
if ( fSetDirection )
{
- pDef->bDirection = ubBestDirection;
+ pDef->ubDirection = ubBestDirection;
}
return sLowestGridNo;
diff --git a/Tactical/Rotting Corpses.h b/Tactical/Rotting Corpses.h
index f5c1b5e9..7747325f 100644
--- a/Tactical/Rotting Corpses.h
+++ b/Tactical/Rotting Corpses.h
@@ -99,7 +99,7 @@ typedef struct
PaletteRepID VestPal;
PaletteRepID SkinPal;
- INT8 bDirection;
+ UINT8 ubDirection;
UINT32 uiTimeOfDeath;
UINT16 usFlags;
diff --git a/Tactical/Soldier Add.cpp b/Tactical/Soldier Add.cpp
index e55a0aa6..c37db569 100644
--- a/Tactical/Soldier Add.cpp
+++ b/Tactical/Soldier Add.cpp
@@ -296,7 +296,7 @@ UINT16 FindGridNoFromSweetSpotWithStructData( SOLDIERTYPE *pSoldier, UINT16 usAn
// If we are already at this gridno....
if ( pSoldier->sGridNo == sSweetGridNo && !( pSoldier->uiStatusFlags & SOLDIER_VEHICLE ) )
{
- *pubDirection = pSoldier->bDirection;
+ *pubDirection = pSoldier->ubDirection;
return( sSweetGridNo );
}
@@ -461,7 +461,7 @@ UINT16 FindGridNoFromSweetSpotWithStructDataUsingGivenDirectionFirst( SOLDIERTYP
// If we are already at this gridno....
if ( pSoldier->sGridNo == sSweetGridNo && !( pSoldier->uiStatusFlags & SOLDIER_VEHICLE ) )
{
- *pubDirection = pSoldier->bDirection;
+ *pubDirection = pSoldier->ubDirection;
return( sSweetGridNo );
}
@@ -1219,7 +1219,7 @@ BOOLEAN InternalAddSoldierToSector( UINT8 ubID, BOOLEAN fCalculateDirection, BOO
//Add
if(gTacticalStatus.uiFlags & LOADING_SAVED_GAME )
- AddSoldierToSectorGridNo( pSoldier, sGridNo, pSoldier->bDirection, fUseAnimation, usAnimState, usAnimCode );
+ AddSoldierToSectorGridNo( pSoldier, sGridNo, pSoldier->ubDirection, fUseAnimation, usAnimState, usAnimCode );
else
AddSoldierToSectorGridNo( pSoldier, sGridNo, ubDirection, fUseAnimation, usAnimState, usAnimCode );
@@ -1279,7 +1279,7 @@ void InternalSoldierInSectorSleep( SOLDIERTYPE *pSoldier, INT16 sGridNo, BOOLEAN
EVENT_SetSoldierDirection( pSoldier, ubNewDirection );
EVENT_SetSoldierDesiredDirection( pSoldier, ubNewDirection );
- //pSoldier->bDesiredDirection = pSoldier->bDirection;
+ //pSoldier->bDesiredDirection = pSoldier->ubDirection;
if ( AM_AN_EPC( pSoldier ) )
{
@@ -1320,7 +1320,7 @@ void SoldierInSectorIncompaciated( SOLDIERTYPE *pSoldier, INT16 sGridNo )
EVENT_SetSoldierDirection( pSoldier, ubNewDirection );
EVENT_SetSoldierDesiredDirection( pSoldier, ubNewDirection );
- //pSoldier->bDesiredDirection = pSoldier->bDirection;
+ //pSoldier->bDesiredDirection = pSoldier->ubDirection;
EVENT_InitNewSoldierAnim( pSoldier, STAND_FALLFORWARD_STOP, 1, TRUE );
}
@@ -1356,7 +1356,7 @@ void SoldierInSectorPatient( SOLDIERTYPE *pSoldier, INT16 sGridNo )
EVENT_SetSoldierDirection( pSoldier, ubNewDirection );
EVENT_SetSoldierDesiredDirection( pSoldier, ubNewDirection );
- //pSoldier->bDesiredDirection = pSoldier->bDirection;
+ //pSoldier->bDesiredDirection = pSoldier->ubDirection;
if ( !IS_MERC_BODY_TYPE( pSoldier ) )
{
@@ -1391,7 +1391,7 @@ void SoldierInSectorDoctor( SOLDIERTYPE *pSoldier, INT16 sGridNo )
EVENT_SetSoldierDirection( pSoldier, ubNewDirection );
EVENT_SetSoldierDesiredDirection( pSoldier, ubNewDirection );
- //pSoldier->bDesiredDirection = pSoldier->bDirection;
+ //pSoldier->bDesiredDirection = pSoldier->ubDirection;
if ( !IS_MERC_BODY_TYPE( pSoldier ) )
{
@@ -1426,7 +1426,7 @@ void SoldierInSectorRepair( SOLDIERTYPE *pSoldier, INT16 sGridNo )
EVENT_SetSoldierDirection( pSoldier, ubNewDirection );
EVENT_SetSoldierDesiredDirection( pSoldier, ubNewDirection );
- //pSoldier->bDesiredDirection = pSoldier->bDirection;
+ //pSoldier->bDesiredDirection = pSoldier->ubDirection;
if ( !IS_MERC_BODY_TYPE( pSoldier ) )
{
diff --git a/Tactical/Soldier Ani.cpp b/Tactical/Soldier Ani.cpp
index a044b2ad..2e086fd2 100644
--- a/Tactical/Soldier Ani.cpp
+++ b/Tactical/Soldier Ani.cpp
@@ -238,7 +238,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
case 406:
// Move merc up
- if ( pSoldier->bDirection == NORTH )
+ if ( pSoldier->ubDirection == NORTH )
{
SetSoldierHeight( pSoldier, (FLOAT)(pSoldier->sHeightAdjustment + 2 ) );
}
@@ -257,14 +257,14 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
{
INT16 sXPos, sYPos;
- //usNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (UINT16)DirectionInc( pSoldier->bDirection ) );
+ //usNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (UINT16)DirectionInc( pSoldier->ubDirection ) );
ConvertMapPosToWorldTileCenter( pSoldier->sTempNewGridNo, &sXPos, &sYPos );
EVENT_SetSoldierPosition( pSoldier, (FLOAT)sXPos, (FLOAT)sYPos );
}
// Move two CC directions
- EVENT_SetSoldierDirection( pSoldier, gTwoCCDirection[ pSoldier->bDirection ] );
+ EVENT_SetSoldierDirection( pSoldier, gTwoCCDirection[ pSoldier->ubDirection ] );
- EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->bDirection );
+ EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->ubDirection );
// Set desired anim height!
pSoldier->ubDesiredHeight = ANIM_CROUCH;
@@ -324,9 +324,9 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
// CODE: SPECIALMOVE CLIMB DOWN EVENT
// Move two C directions
- EVENT_SetSoldierDirection( pSoldier, gTwoCDirection[ pSoldier->bDirection ] );
+ EVENT_SetSoldierDirection( pSoldier, gTwoCDirection[ pSoldier->ubDirection ] );
- EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->bDirection );
+ EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->ubDirection );
// Adjust height
SetSoldierHeight( pSoldier, (FLOAT)gClimbDownRoofStartDist[ pSoldier->ubBodyType ] );
// Adjust position
@@ -479,14 +479,14 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
case 437:
// CHANGE DIRECTION AND GET-UP
- //sGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (UINT16)(-1 * DirectionInc( pSoldier->bDirection ) ) );
+ //sGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (UINT16)(-1 * DirectionInc( pSoldier->ubDirection ) ) );
//ConvertMapPosToWorldTileCenter( pSoldier->sGridNo, &sXPos, &sYPos );
//SetSoldierPosition( pSoldier, (FLOAT)sXPos, (FLOAT)sYPos );
// Reverse direction
- EVENT_SetSoldierDirection( pSoldier, gOppositeDirection[ pSoldier->bDirection ] );
- EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->bDirection );
+ EVENT_SetSoldierDirection( pSoldier, gOppositeDirection[ pSoldier->ubDirection ] );
+ EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->ubDirection );
ChangeSoldierState( pSoldier, GETUP_FROM_ROLLOVER, 0 , FALSE );
return( TRUE );
@@ -558,7 +558,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
UINT16 usNewGridNo;
INT16 sXPos, sYPos;
- usNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, DirectionInc( pSoldier->bDirection ) );
+ usNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, DirectionInc( pSoldier->ubDirection ) );
ConvertGridNoToCenterCellXY( usNewGridNo, &sXPos, &sYPos );
LightSpritePosition( pSoldier->iMuzFlash, (INT16)(sXPos/CELL_X_SIZE), (INT16)(sYPos/CELL_Y_SIZE));
@@ -583,7 +583,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
case 443:
// MOVE GUY FORWARD FOR FENCE HOP ANIMATION
- switch( pSoldier->bDirection )
+ switch( pSoldier->ubDirection )
{
case SOUTH:
case EAST:
@@ -606,9 +606,9 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
sY = CenterY( pSoldier->sForcastGridno );
EVENT_InternalSetSoldierPosition( pSoldier, (FLOAT) sX, (FLOAT) sY, FALSE, FALSE, FALSE );
- EVENT_SetSoldierDirection( pSoldier, gTwoCDirection[ pSoldier->bDirection ] );
+ EVENT_SetSoldierDirection( pSoldier, gTwoCDirection[ pSoldier->ubDirection ] );
pSoldier->sZLevelOverride = -1;
- EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->bDirection );
+ EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->ubDirection );
if ( gTacticalStatus.bBoxingState == BOXING_WAITING_FOR_PLAYER || gTacticalStatus.bBoxingState == PRE_BOXING || gTacticalStatus.bBoxingState == BOXING )
@@ -618,7 +618,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
if ( SetOffBombsInGridNo( pSoldier->ubID, pSoldier->sGridNo, FALSE, pSoldier->bLevel ))
{
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
return( TRUE );
}
@@ -652,7 +652,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
case 445:
// CODE: MOVE GUY FORWARD ONE TILE, BASED ON WHERE WE ARE FACING
- switch( pSoldier->bDirection )
+ switch( pSoldier->ubDirection )
{
case SOUTH:
case EAST:
@@ -684,14 +684,14 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
// TRY FORWARDS...
// FIRST GRIDNO
- sNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (UINT16)( DirectionInc( pSoldier->bDirection ) ) );
+ sNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (UINT16)( DirectionInc( pSoldier->ubDirection ) ) );
- if ( OKFallDirection( pSoldier, sNewGridNo, pSoldier->bLevel, pSoldier->bDirection, FALLFORWARD_HITDEATH_STOP ) )
+ if ( OKFallDirection( pSoldier, sNewGridNo, pSoldier->bLevel, pSoldier->ubDirection, FALLFORWARD_HITDEATH_STOP ) )
{
// SECOND GRIDNO
- // sNewGridNo = NewGridNo( (UINT16)sNewGridNo, (UINT16)( DirectionInc( pSoldier->bDirection ) ) );
+ // sNewGridNo = NewGridNo( (UINT16)sNewGridNo, (UINT16)( DirectionInc( pSoldier->ubDirection ) ) );
- // if ( OKFallDirection( pSoldier, sNewGridNo, pSoldier->bLevel, pSoldier->bDirection, FALLFORWARD_HITDEATH_STOP ) )
+ // if ( OKFallDirection( pSoldier, sNewGridNo, pSoldier->bLevel, pSoldier->ubDirection, FALLFORWARD_HITDEATH_STOP ) )
{
// ALL'S OK HERE...
pSoldier->fTryingToFall = FALSE;
@@ -704,17 +704,17 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
// ATE: Added Feb1 - can be either direction....
if ( pSoldier->fFallClockwise )
{
- EVENT_SetSoldierDirection( pSoldier, gOneCDirection[ pSoldier->bDirection ] );
+ EVENT_SetSoldierDirection( pSoldier, gOneCDirection[ pSoldier->ubDirection ] );
}
else
{
- EVENT_SetSoldierDirection( pSoldier, gOneCCDirection[ pSoldier->bDirection ] );
+ EVENT_SetSoldierDirection( pSoldier, gOneCCDirection[ pSoldier->ubDirection ] );
}
- EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->bDirection );
+ EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->ubDirection );
sLastAniFrame = gusAnimInst[ pSoldier->usAnimState ][ ( pSoldier->usAniCode - 2 ) ];
ConvertAniCodeToAniFrame( pSoldier, (INT16)( sLastAniFrame ) );
- if ( pSoldier->bDirection == pSoldier->bStartFallDir )
+ if ( pSoldier->ubDirection == pSoldier->bStartFallDir )
{
// GO FORWARD HERE...
pSoldier ->fTryingToFall = FALSE;
@@ -852,7 +852,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
if ( pSoldier->sSpreadLocations[ pSoldier->fDoSpread - 1 ] != 0 )
{
EVENT_SetSoldierDirection( pSoldier, (INT8)GetDirectionToGridNoFromGridNo( pSoldier->sGridNo, pSoldier->sSpreadLocations[ pSoldier->fDoSpread - 1 ] ) );
- EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->bDirection );
+ EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->ubDirection );
}
}
break;
@@ -869,8 +869,8 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
//CODE: BEGINHOPFENCE
// MOVE TWO FACGIN GRIDNOS
- sNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (UINT16)( DirectionInc( pSoldier->bDirection ) ) );
- sNewGridNo = NewGridNo( (UINT16)sNewGridNo, (UINT16)( DirectionInc( pSoldier->bDirection ) ) );
+ sNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (UINT16)( DirectionInc( pSoldier->ubDirection ) ) );
+ sNewGridNo = NewGridNo( (UINT16)sNewGridNo, (UINT16)( DirectionInc( pSoldier->ubDirection ) ) );
pSoldier->sForcastGridno = sNewGridNo;
break;
@@ -878,7 +878,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
case 451:
// CODE: MANAGE START z-buffer override
- switch( pSoldier->bDirection )
+ switch( pSoldier->ubDirection )
{
case NORTH:
case WEST:
@@ -891,7 +891,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
case 452:
// CODE: MANAGE END z-buffer override
- switch( pSoldier->bDirection )
+ switch( pSoldier->ubDirection )
{
case SOUTH:
case EAST:
@@ -919,7 +919,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
// CODE: HANDLE CLIMBING ROOF,
// Move merc up
- if ( pSoldier->bDirection == NORTH )
+ if ( pSoldier->ubDirection == NORTH )
{
SetSoldierHeight( pSoldier, (FLOAT)(pSoldier->dHeightAdjustment + gClimbUpRoofDist[ pSoldier->ubBodyType ] ) );
}
@@ -943,7 +943,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
// CODE: HANDLE CLIMBING ROOF,
// Move merc DOWN
- if ( pSoldier->bDirection == NORTH )
+ if ( pSoldier->ubDirection == NORTH )
{
SetSoldierHeight( pSoldier, (FLOAT)(pSoldier->dHeightAdjustment - gClimbUpRoofDist[ pSoldier->ubBodyType ] ) );
}
@@ -1040,7 +1040,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
INT16 sTempGridNo, sNewX, sNewY;
//Get Next GridNo;
- sTempGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (INT16)( DirectionInc(pSoldier->bDirection ) ) );
+ sTempGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (INT16)( DirectionInc(pSoldier->ubDirection ) ) );
// Get center XY
ConvertGridNoToCenterCellXY( sTempGridNo, &sNewX, &sNewY );
@@ -1049,8 +1049,8 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
EVENT_SetSoldierPosition( pSoldier, sNewX, sNewY );
// Move two CC directions
- EVENT_SetSoldierDirection( pSoldier, gTwoCCDirection[ pSoldier->bDirection ] );
- EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->bDirection );
+ EVENT_SetSoldierDirection( pSoldier, gTwoCCDirection[ pSoldier->ubDirection ] );
+ EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->ubDirection );
// Set desired anim height!
pSoldier->ubDesiredHeight = ANIM_CROUCH;
@@ -1112,7 +1112,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
///CODE: FOR HELIDROP, SET DIRECTION
EVENT_SetSoldierDirection( pSoldier, EAST );
- EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->bDirection );
+ EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->ubDirection );
gfIngagedInDrop = FALSE;
@@ -1267,7 +1267,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
{
if ( pSoldier->bLife >= OKLIFE )
{
- InternalSoldierReadyWeapon( pSoldier, pSoldier->bDirection, FALSE );
+ InternalSoldierReadyWeapon( pSoldier, pSoldier->ubDirection, FALSE );
}
return( TRUE );
}
@@ -1359,7 +1359,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
if ( pSoldier->bLife >= OKLIFE && pSoldier->bBreath > 0 && pSoldier->bLevel == 0 )
{
// Save old direction
- pSoldier->uiPendingActionData1 = pSoldier->bDirection;
+ pSoldier->uiPendingActionData1 = pSoldier->ubDirection;
// If we got a head shot...more chance of turning...
if ( pSoldier->ubHitLocation != AIM_SHOT_HEAD )
@@ -1369,21 +1369,21 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
// 30 % chance to change direction one way
if ( uiChance < 30 )
{
- bNewDirection = gOneCDirection[ pSoldier->bDirection ];
+ bNewDirection = gOneCDirection[ pSoldier->ubDirection ];
}
// 30 % chance to change direction the other way
else if ( uiChance >= 30 && uiChance < 60 )
{
- bNewDirection = gOneCCDirection[ pSoldier->bDirection ];
+ bNewDirection = gOneCCDirection[ pSoldier->ubDirection ];
}
// 30 % normal....
else
{
- bNewDirection = pSoldier->bDirection;
+ bNewDirection = pSoldier->ubDirection;
}
EVENT_SetSoldierDirection( pSoldier, bNewDirection );
- EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->bDirection );
+ EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->ubDirection );
}
else
@@ -1402,13 +1402,13 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
// Pick evenly between both
if ( Random( 50 ) < 25 )
{
- bNewDirection = gOneCDirection[ pSoldier->bDirection ];
+ bNewDirection = gOneCDirection[ pSoldier->ubDirection ];
bNewDirection = gOneCDirection[ bNewDirection ];
bNewDirection = gOneCDirection[ bNewDirection ];
}
else
{
- bNewDirection = gOneCCDirection[ pSoldier->bDirection ];
+ bNewDirection = gOneCCDirection[ pSoldier->ubDirection ];
bNewDirection = gOneCCDirection[ bNewDirection ];
bNewDirection = gOneCCDirection[ bNewDirection ];
}
@@ -1431,7 +1431,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
//{
/// if ( !( pSoldier->uiStatusFlags & SOLDIER_TURNINGFROMHIT ) )
// {
- /// pSoldier->bDirection = (INT8)pSoldier->uiPendingActionData1;
+ /// pSoldier->ubDirection = (INT8)pSoldier->uiPendingActionData1;
// pSoldier->bDesiredDirection = (INT8)pSoldier->uiPendingActionData1;
// }
//}
@@ -1715,7 +1715,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
if ( gAnimControl[ pTSoldier->usAnimState ].ubHeight == ANIM_STAND )
{
// OK, stop merc....
- EVENT_StopMerc( pTSoldier, pTSoldier->sGridNo, pTSoldier->bDirection );
+ EVENT_StopMerc( pTSoldier, pTSoldier->sGridNo, pTSoldier->ubDirection );
if ( pTSoldier->bTeam != gbPlayerNum )
{
@@ -2620,7 +2620,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
{
// Dish out damage!
- EVENT_SoldierGotHit( MercPtrs[ pSoldier->uiPendingActionData4 ], TAKE_DAMAGE_BLADE, (INT16) 25, (INT16) 25, gOppositeDirection[ pSoldier->bDirection ], 50, pSoldier->ubID, 0, ANIM_PRONE, 0, 0 );
+ EVENT_SoldierGotHit( MercPtrs[ pSoldier->uiPendingActionData4 ], TAKE_DAMAGE_BLADE, (INT16) 25, (INT16) 25, gOppositeDirection[ pSoldier->ubDirection ], 50, pSoldier->ubID, 0, ANIM_PRONE, 0, 0 );
}
break;
@@ -2671,7 +2671,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
InternalDropBlood( pSoldier->sGridNo, pSoldier->bLevel, 0, (UINT8)(MAXBLOODQUANTITY), 1 );
// Move forward one gridno....
- sNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (UINT16)( DirectionInc( gOppositeDirection[ pSoldier->bDirection ] ) ) );
+ sNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (UINT16)( DirectionInc( gOppositeDirection[ pSoldier->ubDirection ] ) ) );
InternalDropBlood( sNewGridNo, pSoldier->bLevel, 0, (UINT8)(MAXBLOODQUANTITY), 1 );
@@ -3503,7 +3503,7 @@ void CheckForAndHandleSoldierIncompacitated( SOLDIERTYPE *pSoldier )
// Randomly fall back or forward, if we are in the standing hit animation
if ( pSoldier->usAnimState == GENERIC_HIT_STAND || pSoldier->usAnimState == STANDING_BURST_HIT || pSoldier->usAnimState == RIFLE_STAND_HIT )
{
- INT8 bTestDirection = pSoldier->bDirection;
+ INT8 bTestDirection = pSoldier->ubDirection;
BOOLEAN fForceDirection = FALSE;
BOOLEAN fDoFallback = FALSE;
@@ -3561,7 +3561,7 @@ void CheckForAndHandleSoldierIncompacitated( SOLDIERTYPE *pSoldier )
EVENT_SetSoldierDesiredDirection( pSoldier, bTestDirection );
EVENT_SetSoldierDirection( pSoldier, bTestDirection );
}
- ChangeToFallbackAnimation( pSoldier, pSoldier->bDirection );
+ ChangeToFallbackAnimation( pSoldier, pSoldier->ubDirection );
return;
}
}
@@ -3749,7 +3749,7 @@ BOOLEAN CheckForImproperFireGunEnd( SOLDIERTYPE *pSoldier )
if ( Item[ pSoldier->inv[ SECONDHANDPOS ].usItem ].usItemClass != IC_GUN )
{
// OK, put gun down....
- InternalSoldierReadyWeapon( pSoldier, pSoldier->bDirection, TRUE );
+ InternalSoldierReadyWeapon( pSoldier, pSoldier->ubDirection, TRUE );
return( TRUE );
}
}
@@ -3846,7 +3846,7 @@ if ( pSoldier->bLife >= OKLIFE )
// Randomly fall back or forward, if we are in the standing hit animation
if ( pSoldier->usAnimState == GENERIC_HIT_STAND || pSoldier->usAnimState == RIFLE_STAND_HIT )
{
- INT8 bTestDirection = pSoldier->bDirection;
+ INT8 bTestDirection = pSoldier->ubDirection;
BOOLEAN fForceDirection = FALSE;
BOOLEAN fDoFallback = FALSE;
@@ -3882,20 +3882,22 @@ if ( pSoldier->bLife >= OKLIFE )
#endif
-BOOLEAN OKFallDirection( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bLevel, INT8 bTestDirection, UINT16 usAnimState )
+BOOLEAN OKFallDirection( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bLevel, UINT8 ubTestDirection, UINT16 usAnimState )
{
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"OKFallDirection");
STRUCTURE_FILE_REF * pStructureFileRef;
UINT16 usAnimSurface;
+ UINT8 bOverTerrainType;
// How are the movement costs?
- if ( gubWorldMovementCosts[ sGridNo ][ bTestDirection ][ bLevel ] > TRAVELCOST_SHORE )
+ if ( gubWorldMovementCosts[ sGridNo ][ ubTestDirection ][ bLevel ] > TRAVELCOST_SHORE )
{
return( FALSE );
}
+ bOverTerrainType = GetTerrainType( sGridNo);
//NOT ok if in water....
- if ( GetTerrainType( sGridNo ) == MED_WATER || GetTerrainType( sGridNo ) == DEEP_WATER || GetTerrainType( sGridNo ) == LOW_WATER )
+ if ( TERRAIN_IS_WATER( bOverTerrainType) )
{
return( FALSE );
}
@@ -3922,9 +3924,9 @@ BOOLEAN OKFallDirection( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bLevel, INT8
// work now. The function is passing in an adjacent gridno but we need to place the structure
// data in the tile BEFORE. So we take one step back in the direction opposite to bTestDirection
// and use that gridno
- sTestGridNo = NewGridNo( sGridNo, (UINT16)( DirectionInc( gOppositeDirection[ bTestDirection ] ) ) );
+ sTestGridNo = NewGridNo( sGridNo, DirectionInc( gOppositeDirection[ ubTestDirection ] ) );
- if ( ! OkayToAddStructureToWorld( sTestGridNo, bLevel, &(pStructureFileRef->pDBStructureRef[ gOneCDirection[ bTestDirection ] ]), usStructureID ) )
+ if ( ! OkayToAddStructureToWorld( sTestGridNo, bLevel, &(pStructureFileRef->pDBStructureRef[ gOneCDirection[ ubTestDirection ] ]), usStructureID ) )
{
// can't go in that dir!
return( FALSE );
@@ -4071,7 +4073,7 @@ void KickOutWheelchair( SOLDIERTYPE *pSoldier )
INT16 sNewGridNo;
// Move forward one gridno....
- sNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (UINT16)( DirectionInc( pSoldier->bDirection ) ) );
+ sNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (UINT16)( DirectionInc( pSoldier->ubDirection ) ) );
// ATE: Make sure that the gridno is unoccupied!
if ( !NewOKDestination( pSoldier, sNewGridNo, TRUE, pSoldier->bLevel ) )
@@ -4080,7 +4082,7 @@ void KickOutWheelchair( SOLDIERTYPE *pSoldier )
sNewGridNo = pSoldier->sGridNo;
}
- EVENT_StopMerc( pSoldier, sNewGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, sNewGridNo, pSoldier->ubDirection );
pSoldier->ubBodyType = REGMALE;
if ( pSoldier->ubProfile == SLAY && pSoldier->bTeam == CIV_TEAM && !pSoldier->bNeutral )
{
diff --git a/Tactical/Soldier Ani.h b/Tactical/Soldier Ani.h
index 477463cc..cfedb906 100644
--- a/Tactical/Soldier Ani.h
+++ b/Tactical/Soldier Ani.h
@@ -9,7 +9,7 @@ BOOLEAN CheckForAndHandleSoldierDyingNotFromHit( SOLDIERTYPE *pSoldier );
BOOLEAN HandleSoldierDeath( SOLDIERTYPE *pSoldier , BOOLEAN *pfMadeCorpse );
-BOOLEAN OKFallDirection( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bLevel, INT8 bTestDirection, UINT16 usAnimState );
+BOOLEAN OKFallDirection( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bLevel, UINT8 ubTestDirection, UINT16 usAnimState );
BOOLEAN HandleCheckForDeathCommonCode( SOLDIERTYPE *pSoldier );
diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp
index 02685996..77ca338b 100644
--- a/Tactical/Soldier Control.cpp
+++ b/Tactical/Soldier Control.cpp
@@ -839,7 +839,7 @@ UINT16 *CreateEnemyGreyGlow16BPPPalette( SGPPaletteEntry *pPalette, UINT32 rscal
void SoldierBleed( SOLDIERTYPE *pSoldier, BOOLEAN fBandagedBleed );
INT32 CheckBleeding( SOLDIERTYPE *pSoldier );
-void EVENT_InternalSetSoldierDesiredDirection( SOLDIERTYPE *pSoldier, UINT16 usNewDirection, BOOLEAN fInitalMove, UINT16 usAnimState );
+void EVENT_InternalSetSoldierDesiredDirection( SOLDIERTYPE *pSoldier, UINT8 ubNewDirection, BOOLEAN fInitalMove, UINT16 usAnimState );
#ifdef JA2BETAVERSION
extern void ValidatePlayersAreInOneGroupOnly();
@@ -961,7 +961,7 @@ void HandleCrowShadowNewGridNo( SOLDIERTYPE *pSoldier )
AniParams.sZ = 0;
strcpy( AniParams.zCachedFile, "TILECACHE\\FLY_SHDW.STI" );
- AniParams.uiUserData3 = pSoldier->bDirection;
+ AniParams.uiUserData3 = pSoldier->ubDirection;
pSoldier->pAniTile = CreateAnimationTile( &AniParams );
@@ -996,7 +996,7 @@ void HandleCrowShadowNewDirection( SOLDIERTYPE *pSoldier )
{
if ( pSoldier->pAniTile != NULL )
{
- pSoldier->pAniTile->uiUserData3 = pSoldier->bDirection;
+ pSoldier->pAniTile->uiUserData3 = pSoldier->ubDirection;
}
}
}
@@ -2181,7 +2181,7 @@ BOOLEAN EVENT_InitNewSoldierAnim( SOLDIERTYPE *pSoldier, UINT16 usNewState, UINT
if ( usNewState == WALKING || usNewState == RUNNING || usNewState == SWATTING )
{
// CHECK FOR SIDEWAYS!
- if ( pSoldier->bDirection == gPurpendicularDirection[ pSoldier->bDirection ][ pSoldier->usPathingData[ pSoldier->usPathIndex ] ] )
+ if ( pSoldier->ubDirection == gPurpendicularDirection[ pSoldier->ubDirection ][ pSoldier->usPathingData[ pSoldier->usPathIndex ] ] )
{
// We are perpendicular!
usNewState = SIDE_STEP;
@@ -2220,7 +2220,7 @@ BOOLEAN EVENT_InitNewSoldierAnim( SOLDIERTYPE *pSoldier, UINT16 usNewState, UINT
}
// If we are in water.....and trying to run, change to run
- if ( pSoldier->bOverTerrainType == LOW_WATER || pSoldier->bOverTerrainType == MED_WATER )
+ if ( MercInWater( pSoldier) )
{
// Check animation
// Change to walking
@@ -2638,14 +2638,14 @@ BOOLEAN EVENT_InitNewSoldierAnim( SOLDIERTYPE *pSoldier, UINT16 usNewState, UINT
DeductPoints( pSoldier, AP_JUMP_OVER, BP_JUMP_OVER );
- usNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, DirectionInc( pSoldier->bDirection ) );
- usNewGridNo = NewGridNo( (UINT16)usNewGridNo, DirectionInc( pSoldier->bDirection ) );
+ usNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, DirectionInc( pSoldier->ubDirection ) );
+ usNewGridNo = NewGridNo( (UINT16)usNewGridNo, DirectionInc( pSoldier->ubDirection ) );
pSoldier->usPathDataSize = 0;
pSoldier->usPathIndex = 0;
- pSoldier->usPathingData[ pSoldier->usPathDataSize ] = pSoldier->bDirection;
+ pSoldier->usPathingData[ pSoldier->usPathDataSize ] = pSoldier->ubDirection;
pSoldier->usPathDataSize++;
- pSoldier->usPathingData[ pSoldier->usPathDataSize ] = pSoldier->bDirection;
+ pSoldier->usPathingData[ pSoldier->usPathDataSize ] = pSoldier->ubDirection;
pSoldier->usPathDataSize++;
pSoldier->sFinalDestination = usNewGridNo;
// Set direction
@@ -3243,7 +3243,7 @@ void SetSoldierGridNo( SOLDIERTYPE *pSoldier, INT16 sNewGridNo, BOOLEAN fForceRe
// OK, If we were not in deep water but we are now, handle deep animations!
- if ( pSoldier->bOverTerrainType == DEEP_WATER && pSoldier->bOldOverTerrainType != DEEP_WATER )
+ if ( TERRAIN_IS_DEEP_WATER( pSoldier->bOverTerrainType) && !TERRAIN_IS_DEEP_WATER( pSoldier->bOldOverTerrainType) )
{
// Based on our current animation, change!
switch( pSoldier->usAnimState )
@@ -3263,13 +3263,13 @@ void SetSoldierGridNo( SOLDIERTYPE *pSoldier, INT16 sNewGridNo, BOOLEAN fForceRe
}
// Damage water if in deep water....
- if ( pSoldier->bOverTerrainType == MED_WATER || pSoldier->bOverTerrainType == DEEP_WATER )
+ if ( MercInHighWater( pSoldier) )
{
WaterDamage( pSoldier );
}
// OK, If we were in deep water but we are NOT now, handle mid animations!
- if ( pSoldier->bOverTerrainType != DEEP_WATER && pSoldier->bOldOverTerrainType == DEEP_WATER )
+ if ( !TERRAIN_IS_DEEP_WATER( pSoldier->bOverTerrainType) && TERRAIN_IS_DEEP_WATER( pSoldier->bOldOverTerrainType) )
{
// Make transition from low to deep
EVENT_InitNewSoldierAnim( pSoldier, DEEP_TO_LOW_WATER, 0 , FALSE );
@@ -3791,7 +3791,7 @@ void SelectFallAnimation( SOLDIERTYPE *pSoldier )
BOOLEAN SoldierReadyWeapon( SOLDIERTYPE *pSoldier )
{
- return( InternalSoldierReadyWeapon( pSoldier, (INT8)pSoldier->bDirection, FALSE ) );
+ return( InternalSoldierReadyWeapon( pSoldier, (INT8)pSoldier->ubDirection, FALSE ) );
}
BOOLEAN SoldierReadyWeapon( SOLDIERTYPE *pSoldier, INT16 sTargetXPos, INT16 sTargetYPos, BOOLEAN fEndReady )
@@ -3839,7 +3839,7 @@ BOOLEAN InternalSoldierReadyWeapon( SOLDIERTYPE *pSoldier, UINT8 sFacingDir, BOO
EVENT_InternalSetSoldierDesiredDirection( pSoldier, sFacingDir, FALSE, usAnimState );
// Check if facing dir is different from ours and change direction if so!
- //if ( sFacingDir != pSoldier->bDirection )
+ //if ( sFacingDir != pSoldier->ubDirection )
//{
// DeductPoints( pSoldier, AP_CHANGE_FACING, 0 );
//}//
@@ -3859,7 +3859,7 @@ UINT16 PickSoldierReadyAnimation( SOLDIERTYPE *pSoldier, BOOLEAN fEndReady )
return( INVALID_ANIMATION );
}
- if ( pSoldier->bOverTerrainType == DEEP_WATER )
+ if ( MercInDeepWater( pSoldier) )
{
return( INVALID_ANIMATION );
}
@@ -4490,12 +4490,12 @@ void EVENT_SoldierGotHit( SOLDIERTYPE *pSoldier, UINT16 usWeaponIndex, INT16 sDa
}
// If here, we are a merc, check if we are in water
- if ( pSoldier->bOverTerrainType == LOW_WATER )
+ if ( MercInShallowWater( pSoldier) )
{
EVENT_InitNewSoldierAnim( pSoldier, WATER_HIT, 0 , FALSE );
return;
}
- if ( pSoldier->bOverTerrainType == DEEP_WATER )
+ if ( MercInDeepWater( pSoldier) )
{
EVENT_InitNewSoldierAnim( pSoldier, DEEP_WATER_HIT, 0 , FALSE );
return;
@@ -4573,7 +4573,7 @@ void DoGenericHit( SOLDIERTYPE *pSoldier, UINT8 ubSpecial, INT16 bDirection )
{
//SetSoldierDesiredDirection( pSoldier, bDirection );
EVENT_SetSoldierDirection( pSoldier, (INT8)bDirection );
- EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->bDirection );
+ EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->ubDirection );
EVENT_InitNewSoldierAnim( pSoldier, STANDING_BURST_HIT, 0 , FALSE );
}
@@ -4623,14 +4623,14 @@ void SoldierGotHitGunFire( SOLDIERTYPE *pSoldier, UINT16 usWeaponIndex, INT16 sD
{
if (SpacesAway( pSoldier->sGridNo, Menptr[ubAttackerID].sGridNo ) <= MAX_DISTANCE_FOR_MESSY_DEATH || (SpacesAway( pSoldier->sGridNo, Menptr[ubAttackerID].sGridNo ) <= MAX_BARRETT_DISTANCE_FOR_MESSY_DEATH && usWeaponIndex == BARRETT ))
{
- usNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (INT8)( DirectionInc( pSoldier->bDirection ) ) );
+ usNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (INT8)( DirectionInc( pSoldier->ubDirection ) ) );
// CHECK OK DESTINATION!
- if ( OKFallDirection( pSoldier, usNewGridNo, pSoldier->bLevel, pSoldier->bDirection, JFK_HITDEATH ) )
+ if ( OKFallDirection( pSoldier, usNewGridNo, pSoldier->bLevel, pSoldier->ubDirection, JFK_HITDEATH ) )
{
- usNewGridNo = NewGridNo( (UINT16)usNewGridNo, (INT8)( DirectionInc( pSoldier->bDirection ) ) );
+ usNewGridNo = NewGridNo( (UINT16)usNewGridNo, (INT8)( DirectionInc( pSoldier->ubDirection ) ) );
- if ( OKFallDirection( pSoldier, usNewGridNo, pSoldier->bLevel, pSoldier->bDirection, pSoldier->usAnimState ) )
+ if ( OKFallDirection( pSoldier, usNewGridNo, pSoldier->bLevel, pSoldier->ubDirection, pSoldier->usAnimState ) )
{
fHeadHit = TRUE;
}
@@ -4646,9 +4646,9 @@ void SoldierGotHitGunFire( SOLDIERTYPE *pSoldier, UINT16 usWeaponIndex, INT16 sD
{
// possibly play torso explosion anim!
- if (pSoldier->bDirection == bDirection)
+ if (pSoldier->ubDirection == bDirection)
{
- usNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, DirectionInc( gOppositeDirection[ pSoldier->bDirection ] ) );
+ usNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, DirectionInc( gOppositeDirection[ pSoldier->ubDirection ] ) );
if ( OKFallDirection( pSoldier, usNewGridNo, pSoldier->bLevel, gOppositeDirection[ bDirection ], FLYBACK_HIT ) )
{
@@ -4824,7 +4824,7 @@ void SoldierGotHitExplosion( SOLDIERTYPE *pSoldier, UINT16 usWeaponIndex, INT16
if ( OKFallDirection( pSoldier, sNewGridNo, pSoldier->bLevel, gOppositeDirection[ bDirection ], FLYBACK_HIT ) )
{
EVENT_SetSoldierDirection( pSoldier, (INT8)bDirection );
- EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->bDirection );
+ EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->ubDirection );
ChangeToFallbackAnimation( pSoldier, (INT8)bDirection );
}
else
@@ -4855,7 +4855,7 @@ void SoldierGotHitExplosion( SOLDIERTYPE *pSoldier, UINT16 usWeaponIndex, INT16
}
EVENT_SetSoldierDirection( pSoldier, (INT8)bDirection );
- EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->bDirection );
+ EVENT_SetSoldierDesiredDirection( pSoldier, pSoldier->ubDirection );
// Check behind us!
sNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, DirectionInc( gOppositeDirection[ bDirection ] ) );
@@ -5067,7 +5067,7 @@ BOOLEAN EVENT_InternalGetNewSoldierPath( SOLDIERTYPE *pSoldier, UINT16 sDestGrid
usMoveAnimState = pSoldier->usUIMovementMode;
- if ( pSoldier->bOverTerrainType == DEEP_WATER )
+ if ( MercInDeepWater( pSoldier) )
{
usMoveAnimState = DEEP_WATER_SWIM;
}
@@ -5120,7 +5120,7 @@ BOOLEAN EVENT_InternalGetNewSoldierPath( SOLDIERTYPE *pSoldier, UINT16 sDestGrid
// If true, we're OK, if not, WAIT for a guy to pass!
// If we are in deep water, we can only swim!
- if ( pSoldier->bOverTerrainType == DEEP_WATER )
+ if ( MercInDeepWater( pSoldier) )
{
usMoveAnimState = DEEP_WATER_SWIM;
}
@@ -5168,7 +5168,7 @@ void StopSoldier( SOLDIERTYPE *pSoldier )
if ( !( gAnimControl[ pSoldier->usAnimState ].uiFlags & ANIM_STATIONARY ) )
{
//SoldierGotoStationaryStance( pSoldier );
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
}
// Set desination
@@ -5196,7 +5196,7 @@ void SoldierGotoStationaryStance( SOLDIERTYPE *pSoldier )
}
// Check if we are in deep water!
- if ( pSoldier->bOverTerrainType == DEEP_WATER )
+ if ( MercInDeepWater( pSoldier) )
{
// IN deep water, tred!
EVENT_InitNewSoldierAnim( pSoldier, DEEP_WATER_TRED, 0 , FALSE );
@@ -5258,6 +5258,12 @@ void ChangeSoldierStance( SOLDIERTYPE *pSoldier, UINT8 ubDesiredStance )
return;
}
+ if (!IsValidStance( pSoldier, ubDesiredStance))
+ {
+ AssertMsg( 0, "Attempted to set soldier to an invalid stance.");
+ return;
+ }
+
// Set UI Busy
SetUIBusy( pSoldier->ubID );
@@ -5285,22 +5291,22 @@ void ChangeSoldierStance( SOLDIERTYPE *pSoldier, UINT8 ubDesiredStance )
}
}
-void EVENT_InternalSetSoldierDestination( SOLDIERTYPE *pSoldier, UINT16 usNewDirection, BOOLEAN fFromMove, UINT16 usAnimState )
+void EVENT_InternalSetSoldierDestination( SOLDIERTYPE *pSoldier, UINT8 ubNewDirection, BOOLEAN fFromMove, UINT16 usAnimState )
{
- UINT16 usNewGridNo;
+ INT16 sNewGridNo;
INT16 sXPos, sYPos;
// Get dest gridno, convert to center coords
- usNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, DirectionInc( usNewDirection ) );
+ sNewGridNo = NewGridNo( pSoldier->sGridNo, DirectionInc( ubNewDirection ) );
- ConvertMapPosToWorldTileCenter( usNewGridNo, &sXPos, &sYPos );
+ ConvertMapPosToWorldTileCenter( sNewGridNo, &sXPos, &sYPos );
// Save new dest gridno, x, y
- pSoldier->sDestination = usNewGridNo;
+ pSoldier->sDestination = sNewGridNo;
pSoldier->sDestXPos = sXPos;
pSoldier->sDestYPos = sYPos;
- pSoldier->bMovementDirection = (INT8)usNewDirection;
+ pSoldier->bMovementDirection = (INT8)ubNewDirection;
// OK, ATE: If we are side_stepping, calculate a NEW desired direction....
@@ -5309,17 +5315,17 @@ void EVENT_InternalSetSoldierDestination( SOLDIERTYPE *pSoldier, UINT16 usNewDir
UINT8 ubPerpDirection;
// Get a new desired direction,
- ubPerpDirection = gPurpendicularDirection[ pSoldier->bDirection ][ usNewDirection ];
+ ubPerpDirection = gPurpendicularDirection[ pSoldier->ubDirection ][ ubNewDirection ];
// CHange actual and desired direction....
EVENT_SetSoldierDirection( pSoldier, ubPerpDirection );
- pSoldier->bDesiredDirection = pSoldier->bDirection;
+ pSoldier->bDesiredDirection = pSoldier->ubDirection;
}
else
{
if ( !( gAnimControl[ usAnimState ].uiFlags & ANIM_SPECIALMOVE ) )
{
- EVENT_InternalSetSoldierDesiredDirection( pSoldier, usNewDirection, fFromMove, usAnimState );
+ EVENT_InternalSetSoldierDesiredDirection( pSoldier, ubNewDirection, fFromMove, usAnimState );
}
}
}
@@ -5409,17 +5415,17 @@ INT8 MultiTiledTurnDirection( SOLDIERTYPE * pSoldier, INT8 bStartDirection, INT8
-void EVENT_InternalSetSoldierDesiredDirection( SOLDIERTYPE *pSoldier, UINT16 usNewDirection, BOOLEAN fInitalMove, UINT16 usAnimState )
+void EVENT_InternalSetSoldierDesiredDirection( SOLDIERTYPE *pSoldier, UINT8 ubNewDirection, BOOLEAN fInitalMove, UINT16 usAnimState )
{
//if ( usAnimState == WALK_BACKWARDS )
if ( pSoldier->bReverse && usAnimState != SIDE_STEP )
{
// OK, check if we are going to go in the exact opposite than our facing....
- usNewDirection = gOppositeDirection[ usNewDirection ];
+ ubNewDirection = gOppositeDirection[ ubNewDirection ];
}
- pSoldier->bDesiredDirection = (INT8)usNewDirection;
+ pSoldier->bDesiredDirection = (INT8)ubNewDirection;
// If we are prone, goto crouched first!
// ONly if we are stationary, and only if directions are differnet!
@@ -5434,7 +5440,7 @@ void EVENT_InternalSetSoldierDesiredDirection( SOLDIERTYPE *pSoldier, UINT16 usN
AdjustNoAPToFinishMove( pSoldier, FALSE );
}
- if ( pSoldier->bDesiredDirection != pSoldier->bDirection )
+ if ( pSoldier->bDesiredDirection != pSoldier->ubDirection )
{
if ( gAnimControl[ usAnimState ].uiFlags & ( ANIM_BREATH | ANIM_OK_CHARGE_AP_FOR_TURN | ANIM_FIREREADY ) && !fInitalMove && !pSoldier->fDontChargeTurningAPs )
{
@@ -5492,7 +5498,7 @@ void EVENT_InternalSetSoldierDesiredDirection( SOLDIERTYPE *pSoldier, UINT16 usN
// Set desired direction for the extended directions...
pSoldier->ubHiResDesiredDirection = ubExtDirection[ pSoldier->bDesiredDirection ];
- if ( pSoldier->bDesiredDirection != pSoldier->bDirection )
+ if ( pSoldier->bDesiredDirection != pSoldier->ubDirection )
{
if ( pSoldier->uiStatusFlags & ( SOLDIER_VEHICLE ) || CREATURE_OR_BLOODCAT( pSoldier ) )
{
@@ -5509,20 +5515,20 @@ void EVENT_InternalSetSoldierDesiredDirection( SOLDIERTYPE *pSoldier, UINT16 usN
{
if ( pSoldier->uiStatusFlags & SOLDIER_MULTITILE )
{
- pSoldier->bTurningIncrement = (INT8) MultiTiledTurnDirection( pSoldier, pSoldier->bDirection, pSoldier->bDesiredDirection );
+ pSoldier->bTurningIncrement = (INT8) MultiTiledTurnDirection( pSoldier, pSoldier->ubDirection, pSoldier->bDesiredDirection );
}
else
{
- pSoldier->bTurningIncrement = (INT8) QuickestDirection( pSoldier->bDirection, pSoldier->bDesiredDirection );
+ pSoldier->bTurningIncrement = (INT8) QuickestDirection( pSoldier->ubDirection, pSoldier->bDesiredDirection );
}
}
}
-void EVENT_SetSoldierDesiredDirection( SOLDIERTYPE *pSoldier, UINT16 usNewDirection )
+void EVENT_SetSoldierDesiredDirection( SOLDIERTYPE *pSoldier, UINT8 ubNewDirection )
{
- EVENT_InternalSetSoldierDesiredDirection( pSoldier, usNewDirection, FALSE, pSoldier->usAnimState );
+ EVENT_InternalSetSoldierDesiredDirection( pSoldier, ubNewDirection, FALSE, pSoldier->usAnimState );
}
@@ -5531,10 +5537,10 @@ void EVENT_SetSoldierDirection( SOLDIERTYPE *pSoldier, UINT16 usNewDirection )
// Remove old location data
HandleAnimationProfile( pSoldier, pSoldier->usAnimState, TRUE );
- pSoldier->bDirection = (INT8)usNewDirection;
+ pSoldier->ubDirection = (INT8)usNewDirection;
// Updated extended direction.....
- pSoldier->ubHiResDirection = ubExtDirection[ pSoldier->bDirection ];
+ pSoldier->ubHiResDirection = ubExtDirection[ pSoldier->ubDirection ];
// Add new stuff
HandleAnimationProfile( pSoldier, pSoldier->usAnimState, FALSE );
@@ -5809,7 +5815,7 @@ BOOLEAN ConvertAniCodeToAniFrame( SOLDIERTYPE *pSoldier, UINT16 usAniFrame )
CHECKF( usAnimSurface != INVALID_ANIMATION_SURFACE );
// COnvert world direction into sprite direction
- ubTempDir = gOneCDirection[ pSoldier->bDirection ];
+ ubTempDir = gOneCDirection[ pSoldier->ubDirection ];
//If we are only one frame, ignore what the script is telling us!
if ( gAnimSurfaceDatabase[ usAnimSurface ].ubFlags & ANIM_DATA_FLAG_NOFRAMES )
@@ -5834,22 +5840,22 @@ BOOLEAN ConvertAniCodeToAniFrame( SOLDIERTYPE *pSoldier, UINT16 usAniFrame )
// Check # of directions /surface, adjust if ness.
else if ( gAnimSurfaceDatabase[ usAnimSurface ].uiNumDirections == 3 )
{
- if ( pSoldier->bDirection == NORTHWEST )
+ if ( pSoldier->ubDirection == NORTHWEST )
{
ubTempDir = 1;
}
- if ( pSoldier->bDirection == WEST )
+ if ( pSoldier->ubDirection == WEST )
{
ubTempDir = 0;
}
- if ( pSoldier->bDirection == EAST )
+ if ( pSoldier->ubDirection == EAST )
{
ubTempDir = 2;
}
}
else if ( gAnimSurfaceDatabase[ usAnimSurface ].uiNumDirections == 2 )
{
- ubTempDir = gDirectionFrom8to2[ pSoldier->bDirection ];
+ ubTempDir = gDirectionFrom8to2[ pSoldier->ubDirection ];
}
pSoldier->usAniFrame = usAniFrame + (UINT16) ( ( gAnimSurfaceDatabase[ usAnimSurface ].uiNumFramesPerDir * ubTempDir ) );
@@ -5892,7 +5898,7 @@ void TurnSoldier( SOLDIERTYPE *pSoldier)
if ( pSoldier->bDesiredDirection > 7 || pSoldier->bDesiredDirection < 0)
{
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("TurnSoldier() Warinig: Invalid desired direction for non-vehicle unit") );
- pSoldier->bDesiredDirection = pSoldier->bDirection;
+ pSoldier->bDesiredDirection = pSoldier->ubDirection;
}
}
// Lesh: patch ended
@@ -5914,7 +5920,7 @@ void TurnSoldier( SOLDIERTYPE *pSoldier)
if ( pSoldier->fTurningToShoot )
{
- if ( pSoldier->bDirection == pSoldier->bDesiredDirection )
+ if ( pSoldier->ubDirection == pSoldier->bDesiredDirection )
{
if ( ( (gAnimControl[ pSoldier->usAnimState ].uiFlags & ANIM_FIREREADY ) && !pSoldier->fTurningFromPronePosition ) || pSoldier->ubBodyType == ROBOTNOWEAPON || pSoldier->ubBodyType == TANK_NW || pSoldier->ubBodyType == TANK_NE )
{
@@ -5946,7 +5952,7 @@ void TurnSoldier( SOLDIERTYPE *pSoldier)
if ( pSoldier->fTurningToFall )
{
- if ( pSoldier->bDirection == pSoldier->bDesiredDirection )
+ if ( pSoldier->ubDirection == pSoldier->bDesiredDirection )
{
SelectFallAnimation( pSoldier );
pSoldier->fTurningToFall = FALSE;
@@ -5955,7 +5961,7 @@ void TurnSoldier( SOLDIERTYPE *pSoldier)
if ( pSoldier->fTurningUntilDone && ( pSoldier->ubPendingStanceChange != NO_PENDING_STANCE ) )
{
- if ( pSoldier->bDirection == pSoldier->bDesiredDirection )
+ if ( pSoldier->ubDirection == pSoldier->bDesiredDirection )
{
SendChangeSoldierStanceEvent( pSoldier, pSoldier->ubPendingStanceChange );
pSoldier->ubPendingStanceChange = NO_PENDING_STANCE;
@@ -5965,7 +5971,7 @@ void TurnSoldier( SOLDIERTYPE *pSoldier)
if ( pSoldier->fTurningUntilDone && ( pSoldier->usPendingAnimation != NO_PENDING_ANIMATION ) )
{
- if ( pSoldier->bDirection == pSoldier->bDesiredDirection )
+ if ( pSoldier->ubDirection == pSoldier->bDesiredDirection )
{
UINT16 usPendingAnimation;
@@ -5978,7 +5984,7 @@ void TurnSoldier( SOLDIERTYPE *pSoldier)
}
// Don't do anything if we are at dest direction!
- if ( pSoldier->bDirection == pSoldier->bDesiredDirection )
+ if ( pSoldier->ubDirection == pSoldier->bDesiredDirection )
{
if ( pSoldier->ubBodyType == TANK_NW || pSoldier->ubBodyType == TANK_NE )
{
@@ -6124,8 +6130,8 @@ void TurnSoldier( SOLDIERTYPE *pSoldier)
else
{
// Get new direction
- //sDirection = pSoldier->bDirection + QuickestDirection( pSoldier->bDirection, pSoldier->bDesiredDirection );
- sDirection = pSoldier->bDirection + pSoldier->bTurningIncrement;
+ //sDirection = pSoldier->ubDirection + QuickestDirection( pSoldier->ubDirection, pSoldier->bDesiredDirection );
+ sDirection = pSoldier->ubDirection + pSoldier->bTurningIncrement;
if (sDirection > 7)
{
sDirection = 0;
@@ -6180,7 +6186,7 @@ void TurnSoldier( SOLDIERTYPE *pSoldier)
// If we are a creature, or multi-tiled, cancel AI action.....?
else if ( pSoldier->uiStatusFlags & SOLDIER_MULTITILE )
{
- pSoldier->bDesiredDirection = pSoldier->bDirection;
+ pSoldier->bDesiredDirection = pSoldier->ubDirection;
}
}
@@ -6972,7 +6978,7 @@ void MoveMercFacingDirection( SOLDIERTYPE *pSoldier, BOOLEAN fReverse, FLOAT dMo
FLOAT dAngle = (FLOAT)0;
// Determine which direction we are in
- switch( pSoldier->bDirection )
+ switch( pSoldier->ubDirection )
{
case NORTH:
dAngle = (FLOAT)( -1 * PI );
@@ -7024,7 +7030,7 @@ void BeginSoldierClimbUpRoof( SOLDIERTYPE *pSoldier )
UINT8 ubWhoIsThere;
- if ( FindHeigherLevel( pSoldier, pSoldier->sGridNo, pSoldier->bDirection, &bNewDirection ) && ( pSoldier->bLevel == 0 ) )
+ if ( FindHeigherLevel( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &bNewDirection ) && ( pSoldier->bLevel == 0 ) )
{
if ( EnoughPoints( pSoldier, GetAPsToClimbRoof( pSoldier, FALSE ), 0, TRUE ) )
{
@@ -7074,7 +7080,7 @@ void BeginSoldierClimbFence( SOLDIERTYPE *pSoldier )
}
else
{
- bDirection = pSoldier->bDirection;
+ bDirection = pSoldier->ubDirection;
}
if ( FindFenceJumpDirection( pSoldier, pSoldier->sGridNo, bDirection, &bDirection ) )
@@ -8215,7 +8221,7 @@ BOOLEAN CheckSoldierHitRoof( SOLDIERTYPE *pSoldier )
return( FALSE );
}
- if ( FindLowerLevel( pSoldier, pSoldier->sGridNo, pSoldier->bDirection, &bNewDirection ) && ( pSoldier->bLevel > 0 ) )
+ if ( FindLowerLevel( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &bNewDirection ) && ( pSoldier->bLevel > 0 ) )
{
// ONly if standing!
if ( gAnimControl[ pSoldier->usAnimState ].ubHeight == ANIM_STAND )
@@ -8237,11 +8243,11 @@ BOOLEAN CheckSoldierHitRoof( SOLDIERTYPE *pSoldier )
}
// Are wee near enough to fall forwards....
- if ( pSoldier->bDirection == gOneCDirection[ bNewDirection ] ||
- pSoldier->bDirection == gTwoCDirection[ bNewDirection ] ||
- pSoldier->bDirection == bNewDirection ||
- pSoldier->bDirection == gOneCCDirection[ bNewDirection ] ||
- pSoldier->bDirection == gTwoCCDirection[ bNewDirection ] )
+ if ( pSoldier->ubDirection == gOneCDirection[ bNewDirection ] ||
+ pSoldier->ubDirection == gTwoCDirection[ bNewDirection ] ||
+ pSoldier->ubDirection == bNewDirection ||
+ pSoldier->ubDirection == gOneCCDirection[ bNewDirection ] ||
+ pSoldier->ubDirection == gTwoCCDirection[ bNewDirection ] )
{
// Do backwards...
fDoForwards = FALSE;
@@ -8290,7 +8296,7 @@ void BeginSoldierClimbDownRoof( SOLDIERTYPE *pSoldier )
UINT8 ubWhoIsThere;
- if ( FindLowerLevel( pSoldier, pSoldier->sGridNo, pSoldier->bDirection, &bNewDirection ) && ( pSoldier->bLevel > 0 ) )
+ if ( FindLowerLevel( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &bNewDirection ) && ( pSoldier->bLevel > 0 ) )
{
if ( EnoughPoints( pSoldier, GetAPsToClimbRoof( pSoldier, TRUE ), 0, TRUE ) )
{
@@ -8334,7 +8340,7 @@ INT8 bNewDirection;
UINT8 ubWhoIsThere;
-if ( FindLowerLevel( pSoldier, pSoldier->sGridNo, pSoldier->bDirection, &bNewDirection ) && ( pSoldier->bLevel > 0 ) )
+if ( FindLowerLevel( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &bNewDirection ) && ( pSoldier->bLevel > 0 ) )
{
if ( EnoughPoints( pSoldier, GetAPsToClimbRoof( pSoldier, TRUE ), 0, TRUE ) )
{
@@ -8487,7 +8493,7 @@ void MoveMerc( SOLDIERTYPE *pSoldier, FLOAT dMovementChange, FLOAT dAngle, BOOLE
}
-INT16 GetDirectionFromGridNo( INT16 sGridNo, SOLDIERTYPE *pSoldier )
+UINT8 GetDirectionFromGridNo( INT16 sGridNo, SOLDIERTYPE *pSoldier )
{
INT16 sXPos, sYPos;
@@ -8508,7 +8514,7 @@ INT16 GetDirectionToGridNoFromGridNo( INT16 sGridNoDest, INT16 sGridNoSrc )
}
-INT16 GetDirectionFromXY( INT16 sXPos, INT16 sYPos, SOLDIERTYPE *pSoldier )
+UINT8 GetDirectionFromXY( INT16 sXPos, INT16 sYPos, SOLDIERTYPE *pSoldier )
{
INT16 sXPos2, sYPos2;
@@ -8812,7 +8818,7 @@ void AdjustForFastTurnAnimation( SOLDIERTYPE *pSoldier )
// ATE: Mod: Only fastturn for OUR guys!
if ( gAnimControl[ pSoldier->usAnimState ].uiFlags & ANIM_FASTTURN && pSoldier->bTeam == gbPlayerNum && !( pSoldier->uiStatusFlags & SOLDIER_TURNINGFROMHIT ) )
{
- if ( pSoldier->bDirection != pSoldier->bDesiredDirection )
+ if ( pSoldier->ubDirection != pSoldier->bDesiredDirection )
{
pSoldier->sAniDelay = FAST_TURN_ANIM_SPEED;
}
@@ -8989,7 +8995,7 @@ void ReleaseSoldiersAttacker( SOLDIERTYPE *pSoldier )
BOOLEAN MercInWater( SOLDIERTYPE *pSoldier )
{
// Our water texture , for now is of a given type
- if ( pSoldier->bOverTerrainType == LOW_WATER || pSoldier->bOverTerrainType == MED_WATER || pSoldier->bOverTerrainType == DEEP_WATER )
+ if ( TERRAIN_IS_WATER( pSoldier->bOverTerrainType))
{
return( TRUE );
}
@@ -8999,6 +9005,47 @@ BOOLEAN MercInWater( SOLDIERTYPE *pSoldier )
}
}
+BOOLEAN MercInShallowWater( SOLDIERTYPE *pSoldier )
+{
+ // Our water texture , for now is of a given type
+ if ( TERRAIN_IS_SHALLOW_WATER( pSoldier->bOverTerrainType))
+ {
+ return( TRUE );
+ }
+ else
+ {
+ return( FALSE );
+ }
+}
+
+
+BOOLEAN MercInDeepWater( SOLDIERTYPE *pSoldier )
+{
+ // Our water texture , for now is of a given type
+ if ( TERRAIN_IS_DEEP_WATER( pSoldier->bOverTerrainType))
+ {
+ return( TRUE );
+ }
+ else
+ {
+ return( FALSE );
+ }
+}
+
+BOOLEAN MercInHighWater( SOLDIERTYPE *pSoldier )
+{
+ // Our water texture , for now is of a given type
+ if ( TERRAIN_IS_HIGH_WATER( pSoldier->bOverTerrainType))
+ {
+ return( TRUE );
+ }
+ else
+ {
+ return( FALSE );
+ }
+}
+
+
void RevivePlayerTeam( )
{
@@ -9083,7 +9130,7 @@ void HandleAnimationProfile( SOLDIERTYPE *pSoldier, UINT16 usAnimState, BOOLEAN
pProfile = &(gpAnimProfiles[ bProfileID ] );
// Get direction
- pProfileDir = &( pProfile->Dirs[ pSoldier->bDirection ] );
+ pProfileDir = &( pProfile->Dirs[ pSoldier->ubDirection ] );
// Loop tiles and set accordingly into world
for( iTileCount = 0; iTileCount < pProfileDir->ubNumTiles; iTileCount++ )
@@ -9180,7 +9227,7 @@ BOOLEAN GetProfileFlagsFromGridno( SOLDIERTYPE *pSoldier, UINT16 usAnimState, UI
pProfile = &(gpAnimProfiles[ bProfileID ] );
// Get direction
- pProfileDir = &( pProfile->Dirs[ pSoldier->bDirection ] );
+ pProfileDir = &( pProfile->Dirs[ pSoldier->ubDirection ] );
// Loop tiles and set accordingly into world
for( iTileCount = 0; iTileCount < pProfileDir->ubNumTiles; iTileCount++ )
@@ -9214,7 +9261,7 @@ void EVENT_SoldierBeginGiveItem( SOLDIERTYPE *pSoldier )
{
// CHANGE DIRECTION AND GOTO ANIMATION NOW
pSoldier->bDesiredDirection = pSoldier->bPendingActionData3;
- pSoldier->bDirection = pSoldier->bPendingActionData3;
+ pSoldier->ubDirection = pSoldier->bPendingActionData3;
// begin animation
EVENT_InitNewSoldierAnim( pSoldier, GIVE_ITEM, 0 , FALSE );
@@ -9330,7 +9377,7 @@ void EVENT_SoldierBeginBladeAttack( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8
if ( !( pTSoldier->uiStatusFlags & ( SOLDIER_MONSTER | SOLDIER_ANIMAL | SOLDIER_VEHICLE ) ) )
{
// OK, stop merc....
- EVENT_StopMerc( pTSoldier, pTSoldier->sGridNo, pTSoldier->bDirection );
+ EVENT_StopMerc( pTSoldier, pTSoldier->sGridNo, pTSoldier->ubDirection );
if ( pTSoldier->bTeam != gbPlayerNum )
{
@@ -9487,7 +9534,7 @@ void EVENT_SoldierBeginPunchAttack( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8
if ( !( pTSoldier->uiStatusFlags & ( SOLDIER_MONSTER | SOLDIER_ANIMAL | SOLDIER_VEHICLE ) ) )
{
// OK, stop merc....
- EVENT_StopMerc( pTSoldier, pTSoldier->sGridNo, pTSoldier->bDirection );
+ EVENT_StopMerc( pTSoldier, pTSoldier->sGridNo, pTSoldier->ubDirection );
if ( pTSoldier->bTeam != gbPlayerNum )
{
@@ -10004,7 +10051,7 @@ void HaultSoldierFromSighting( SOLDIERTYPE *pSoldier, BOOLEAN fFromSightingEnemy
//EV_S_STOP_MERC SStopMerc;
//SStopMerc.sGridNo = pSoldier->sGridNo;
- //SStopMerc.bDirection = pSoldier->bDirection;
+ //SStopMerc.bDirection = pSoldier->ubDirection;
//SStopMerc.usSoldierID = pSoldier->ubID;
//AddGameEvent( S_STOP_MERC, 0, &SStopMerc );
@@ -10065,7 +10112,7 @@ void HaultSoldierFromSighting( SOLDIERTYPE *pSoldier, BOOLEAN fFromSightingEnemy
if ( !( gTacticalStatus.uiFlags & INCOMBAT ) )
{
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
}
else
{
@@ -10595,7 +10642,7 @@ BOOLEAN InternalIsValidStance( SOLDIERTYPE *pSoldier, INT8 bDirection, INT8 bNew
BOOLEAN IsValidStance( SOLDIERTYPE *pSoldier, INT8 bNewStance )
{
- return( InternalIsValidStance( pSoldier, pSoldier->bDirection, bNewStance ) );
+ return( InternalIsValidStance( pSoldier, pSoldier->ubDirection, bNewStance ) );
}
@@ -10915,11 +10962,11 @@ void SoldierCollapse( SOLDIERTYPE *pSoldier )
{
case ANIM_STAND:
- if ( pSoldier->bOverTerrainType == DEEP_WATER )
+ if ( MercInDeepWater( pSoldier) )
{
EVENT_InitNewSoldierAnim( pSoldier, DEEP_WATER_DIE, 0, FALSE );
}
- else if ( pSoldier->bOverTerrainType == LOW_WATER )
+ else if ( MercInShallowWater( pSoldier) )
{
EVENT_InitNewSoldierAnim( pSoldier, WATER_DIE, 0, FALSE );
}
@@ -11218,7 +11265,7 @@ void PickPickupAnimation( SOLDIERTYPE *pSoldier, INT32 iItemIndex, INT16 sGridNo
default:
- bDirection = pSoldier->bDirection;
+ bDirection = pSoldier->ubDirection;
break;
}
@@ -11486,13 +11533,33 @@ void ResetSoldierChangeStatTimer( SOLDIERTYPE *pSoldier )
}
-void ChangeToFlybackAnimation( SOLDIERTYPE *pSoldier, INT8 bDirection )
+void ChangeToFlybackAnimation( SOLDIERTYPE *pSoldier, UINT8 ubDirection )
{
- UINT16 usNewGridNo;
+ INT16 sNewGridNo;
+ UINT8 ubOppositeDir;
+ INT16 sDirectionInc;
+
+ ubOppositeDir = gOppositeDirection[ ubDirection ];
+ sDirectionInc = DirectionInc( ubOppositeDir);
// Get dest gridno, convert to center coords
- usNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, DirectionInc( gOppositeDirection[ bDirection ] ) );
- usNewGridNo = NewGridNo( (UINT16)usNewGridNo, DirectionInc( gOppositeDirection[ bDirection ] ) );
+ sNewGridNo = NewGridNo( pSoldier->sGridNo, sDirectionInc );
+ if ( gubWorldMovementCosts[ sNewGridNo ][ ubOppositeDir ][ pSoldier->bLevel ] >= TRAVELCOST_BLOCKED )
+ {
+ // No room to fly back. Pretend we hit the wall and fall forward instead
+ BeginTyingToFall( pSoldier );
+ ChangeSoldierState( pSoldier, FALLFORWARD_FROMHIT_STAND, 0, FALSE );
+ return;
+ }
+
+ sNewGridNo = NewGridNo( sNewGridNo, sDirectionInc );
+ if ( gubWorldMovementCosts[ sNewGridNo ][ ubOppositeDir ][ pSoldier->bLevel ] >= TRAVELCOST_BLOCKED )
+ {
+ // No room to fly back. Fall back instead
+ BeginTyingToFall( pSoldier );
+ ChangeSoldierState( pSoldier, FALLBACK_HIT_STAND, 0, FALSE );
+ }
+
// Remove any previous actions
pSoldier->ubPendingAction = NO_PENDING_ACTION;
@@ -11500,23 +11567,38 @@ void ChangeToFlybackAnimation( SOLDIERTYPE *pSoldier, INT8 bDirection )
// Set path....
pSoldier->usPathDataSize = 0;
pSoldier->usPathIndex = 0;
- pSoldier->usPathingData[ pSoldier->usPathDataSize ] = gOppositeDirection[ pSoldier->bDirection ];
+ pSoldier->usPathingData[ pSoldier->usPathDataSize ] = ubOppositeDir;
pSoldier->usPathDataSize++;
- pSoldier->usPathingData[ pSoldier->usPathDataSize ] = gOppositeDirection[ pSoldier->bDirection ];
+ pSoldier->usPathingData[ pSoldier->usPathDataSize ] = ubOppositeDir;
pSoldier->usPathDataSize++;
- pSoldier->sFinalDestination = usNewGridNo;
+ pSoldier->sFinalDestination = sNewGridNo;
EVENT_InternalSetSoldierDestination( pSoldier, pSoldier->usPathingData[ pSoldier->usPathIndex ], FALSE, FLYBACK_HIT );
// Get a new direction based on direction
EVENT_InitNewSoldierAnim( pSoldier, FLYBACK_HIT, 0 , FALSE );
}
-void ChangeToFallbackAnimation( SOLDIERTYPE *pSoldier, INT8 bDirection )
+void ChangeToFallbackAnimation( SOLDIERTYPE *pSoldier, UINT8 ubDirection )
{
- UINT16 usNewGridNo;
+ INT16 sNewGridNo;
+ UINT8 ubOppositeDir;
+ INT16 sDirection;
+
+ ubOppositeDir = gOppositeDirection[ ubDirection ];
+ sDirection = DirectionInc( ubOppositeDir);
// Get dest gridno, convert to center coords
- usNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, DirectionInc( gOppositeDirection[ bDirection ] ) );
+ sNewGridNo = NewGridNo( pSoldier->sGridNo, sDirection );
+ if ( gubWorldMovementCosts[ sNewGridNo ][ ubOppositeDir ][ pSoldier->bLevel ] >= TRAVELCOST_BLOCKED )
+ {
+ // No room to fly back. Pretend we hit the wall and fall forward instead
+ BeginTyingToFall( pSoldier );
+ ChangeSoldierState( pSoldier, FALLFORWARD_FROMHIT_STAND, 0, FALSE );
+ return;
+ }
+
+ // Get dest gridno, convert to center coords
+ //sNewGridNo = NewGridNo( sNewGridNo, sDirection );
//usNewGridNo = NewGridNo( (UINT16)usNewGridNo, (UINT16)(-1 * DirectionInc( bDirection ) ) );
// Remove any previous actions
@@ -11525,10 +11607,11 @@ void ChangeToFallbackAnimation( SOLDIERTYPE *pSoldier, INT8 bDirection )
// Set path....
pSoldier->usPathDataSize = 0;
pSoldier->usPathIndex = 0;
- pSoldier->usPathingData[ pSoldier->usPathDataSize ] = gOppositeDirection[ pSoldier->bDirection ];
+ pSoldier->usPathingData[ pSoldier->usPathDataSize ] = ubOppositeDir;
pSoldier->usPathDataSize++;
- pSoldier->sFinalDestination = usNewGridNo;
- EVENT_InternalSetSoldierDestination( pSoldier, pSoldier->usPathingData[ pSoldier->usPathIndex ], FALSE, FALLBACK_HIT_STAND );
+ pSoldier->sFinalDestination = sNewGridNo;
+ //pSoldier->sFinalDestination = pSoldier->sGridNo;
+ EVENT_InternalSetSoldierDestination( pSoldier, ubOppositeDir, FALSE, FALLBACK_HIT_STAND );
// Get a new direction based on direction
EVENT_InitNewSoldierAnim( pSoldier, FALLBACK_HIT_STAND, 0 , FALSE );
@@ -11664,7 +11747,7 @@ BOOLEAN PlayerSoldierStartTalking( SOLDIERTYPE *pSoldier, UINT8 ubTargetID, BOOL
SendSoldierSetDesiredDirectionEvent( pTSoldier, gOppositeDirection[ sFacingDir ] );
// Stop our guys...
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
}
pTMilitiaSoldier = pTSoldier; //lal
@@ -12051,12 +12134,12 @@ void InternalPlaySoldierFootstepSound( SOLDIERTYPE * pSoldier )
{
ubSoundBase = WALK_LEFT_ROAD;
}
- else if ( pSoldier->bOverTerrainType == LOW_WATER || pSoldier->bOverTerrainType == MED_WATER )
+ else if ( MercInShallowWater( pSoldier) )
{
ubSoundBase = WATER_WALK1_IN;
ubRandomMax = 2;
}
- else if ( pSoldier->bOverTerrainType == DEEP_WATER )
+ else if ( MercInDeepWater( pSoldier) )
{
ubSoundBase = SWIM_1;
ubRandomMax = 2;
@@ -12208,7 +12291,7 @@ void DebugValidateSoldierData( )
void BeginTyingToFall( SOLDIERTYPE *pSoldier )
{
- pSoldier->bStartFallDir = pSoldier->bDirection;
+ pSoldier->bStartFallDir = pSoldier->ubDirection;
pSoldier->fTryingToFall = TRUE;
// Randomize direction
diff --git a/Tactical/Soldier Control.h b/Tactical/Soldier Control.h
index ad621aa7..af612971 100644
--- a/Tactical/Soldier Control.h
+++ b/Tactical/Soldier Control.h
@@ -503,7 +503,7 @@ public:
FLOAT dOldYPos;
INT16 sInitialGridNo;
INT16 sGridNo;
- INT8 bDirection;
+ UINT8 ubDirection;
INT16 sHeightAdjustment;
INT16 sDesiredHeight;
INT16 sTempNewGridNo; // New grid no for advanced animations
@@ -1158,7 +1158,7 @@ void EVENT_GetNewSoldierPath( SOLDIERTYPE *pSoldier, UINT16 sDestGridNo, UINT16
BOOLEAN EVENT_InternalGetNewSoldierPath( SOLDIERTYPE *pSoldier, UINT16 sDestGridNo, UINT16 usMovementAnim, BOOLEAN fFromUI, BOOLEAN fForceRestart );
void EVENT_SetSoldierDirection( SOLDIERTYPE *pSoldier, UINT16 usNewDirection );
-void EVENT_SetSoldierDesiredDirection( SOLDIERTYPE *pSoldier, UINT16 usNewDirection );
+void EVENT_SetSoldierDesiredDirection( SOLDIERTYPE *pSoldier, UINT8 ubNewDirection );
void EVENT_FireSoldierWeapon( SOLDIERTYPE *pSoldier, INT16 sTargetGridNo );
void EVENT_SoldierGotHit( SOLDIERTYPE *pSoldier, UINT16 usWeaponIndex, INT16 ubDamage, INT16 sBreathLoss, UINT16 bDirection , UINT16 sRange, UINT8 ubAttackerID, UINT8 ubSpecial, UINT8 ubHitLocation, INT16 sSubsequent, INT16 sLocationGridNo );
void EVENT_SoldierBeginBladeAttack( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubDirection );
@@ -1204,8 +1204,8 @@ BOOLEAN DeletePaletteData( );
// UTILITY FUNCTUIONS
void MoveMerc( SOLDIERTYPE *pSoldier, FLOAT dMovementChange, FLOAT dAngle, BOOLEAN fCheckRange );
void MoveMercFacingDirection( SOLDIERTYPE *pSoldier, BOOLEAN fReverse, FLOAT dMovementDist );
-INT16 GetDirectionFromXY( INT16 sXPos, INT16 sYPos, SOLDIERTYPE *pSoldier );
-INT16 GetDirectionFromGridNo( INT16 sGridNo, SOLDIERTYPE *pSoldier );
+UINT8 GetDirectionFromXY( INT16 sXPos, INT16 sYPos, SOLDIERTYPE *pSoldier );
+UINT8 GetDirectionFromGridNo( INT16 sGridNo, SOLDIERTYPE *pSoldier );
UINT8 atan8( INT16 sXPos, INT16 sYPos, INT16 sXPos2, INT16 sYPos2 );
UINT8 atan8FromAngle( DOUBLE dAngle );
INT8 CalcActionPoints(SOLDIERTYPE *pSold );
@@ -1214,6 +1214,9 @@ INT16 GetDirectionToGridNoFromGridNo( INT16 sGridNoDest, INT16 sGridNoSrc );
// This function is now obsolete. Call ReduceAttackBusyCount instead.
// void ReleaseSoldiersAttacker( SOLDIERTYPE *pSoldier );
BOOLEAN MercInWater( SOLDIERTYPE *pSoldier );
+BOOLEAN MercInShallowWater( SOLDIERTYPE *pSoldier );
+BOOLEAN MercInDeepWater( SOLDIERTYPE *pSoldier );
+BOOLEAN MercInHighWater( SOLDIERTYPE *pSoldier );
UINT16 GetNewSoldierStateFromNewStance( SOLDIERTYPE *pSoldier, UINT8 ubDesiredStance );
UINT16 GetMoveStateBasedOnStance( SOLDIERTYPE *pSoldier, UINT8 ubStanceHeight );
void SoldierGotoStationaryStance( SOLDIERTYPE *pSoldier );
@@ -1270,10 +1273,10 @@ void PositionSoldierLight( SOLDIERTYPE *pSoldier );
void SetCheckSoldierLightFlag( SOLDIERTYPE *pSoldier );
-void EVENT_InternalSetSoldierDestination( SOLDIERTYPE *pSoldier, UINT16 usNewDirection, BOOLEAN fFromMove, UINT16 usAnimState );
+void EVENT_InternalSetSoldierDestination( SOLDIERTYPE *pSoldier, UINT8 ubNewDirection, BOOLEAN fFromMove, UINT16 usAnimState );
-void ChangeToFlybackAnimation( SOLDIERTYPE *pSoldier, INT8 bDirection );
-void ChangeToFallbackAnimation( SOLDIERTYPE *pSoldier, INT8 bDirection );
+void ChangeToFlybackAnimation( SOLDIERTYPE *pSoldier, UINT8 ubDirection );
+void ChangeToFallbackAnimation( SOLDIERTYPE *pSoldier, UINT8 ubDirection );
//reset soldier timers
void ResetSoldierChangeStatTimer( SOLDIERTYPE *pSoldier );
diff --git a/Tactical/Soldier Create.cpp b/Tactical/Soldier Create.cpp
index cea5f4d4..ba1de8bf 100644
--- a/Tactical/Soldier Create.cpp
+++ b/Tactical/Soldier Create.cpp
@@ -414,10 +414,10 @@ SOLDIERTYPE* TacticalCreateSoldier( SOLDIERCREATE_STRUCT *pCreateStruct, UINT8 *
Soldier.sSectorX = pCreateStruct->sSectorX;
Soldier.sSectorY = pCreateStruct->sSectorY;
Soldier.bSectorZ = pCreateStruct->bSectorZ;
- Soldier.ubInsertionDirection = pCreateStruct->bDirection;
- Soldier.bDesiredDirection = pCreateStruct->bDirection;
- Soldier.bDominantDir = pCreateStruct->bDirection;
- Soldier.bDirection = pCreateStruct->bDirection;
+ Soldier.ubInsertionDirection = pCreateStruct->ubDirection;
+ Soldier.bDesiredDirection = pCreateStruct->ubDirection;
+ Soldier.bDominantDir = pCreateStruct->ubDirection;
+ Soldier.ubDirection = pCreateStruct->ubDirection;
Soldier.sInsertionGridNo = pCreateStruct->sInsertionGridNo;
Soldier.bOldLife = Soldier.bLifeMax;
@@ -812,7 +812,7 @@ BOOLEAN TacticalCopySoldierFromProfile( SOLDIERTYPE *pSoldier, SOLDIERCREATE_STR
pSoldier->bOrders = pCreateStruct->bOrders;
pSoldier->bAttitude = pCreateStruct->bAttitude;
- pSoldier->bDirection = pCreateStruct->bDirection;
+ pSoldier->ubDirection = pCreateStruct->ubDirection;
pSoldier->bPatrolCnt = pCreateStruct->bPatrolCnt;
memcpy( pSoldier->usPatrolGrid, pCreateStruct->sPatrolGrid, sizeof( INT16 ) * MAXPATROLGRIDS );
@@ -1642,7 +1642,7 @@ void CreateDetailedPlacementGivenBasicPlacementInfo( SOLDIERCREATE_STRUCT *pp, B
//Pass over mandatory information specified from the basic placement
pp->bOrders = bp->bOrders;
pp->bAttitude = bp->bAttitude;
- pp->bDirection = bp->bDirection;
+ pp->ubDirection = bp->ubDirection;
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("CreateDetailedPlacementGivenBasicPlacementInfo: determine soldier's class"));
@@ -1861,7 +1861,7 @@ void CreateStaticDetailedPlacementGivenBasicPlacementInfo( SOLDIERCREATE_STRUCT
//Pass over mandatory information specified from the basic placement
spp->bOrders = bp->bOrders;
spp->bAttitude = bp->bAttitude;
- spp->bDirection = bp->bDirection;
+ spp->ubDirection = bp->ubDirection;
//Only creatures have mandatory body types specified.
if( spp->bTeam == CREATURE_TEAM )
@@ -1929,7 +1929,7 @@ void CreateDetailedPlacementGivenStaticDetailedPlacementAndBasicPlacementInfo(
// Copy over team
pp->bTeam = bp->bTeam;
- pp->bDirection = bp->bDirection;
+ pp->ubDirection = bp->ubDirection;
pp->sInsertionGridNo = bp->usStartingGridNo;
//ATE: Copy over sector coordinates from profile to create struct
@@ -1941,7 +1941,7 @@ void CreateDetailedPlacementGivenStaticDetailedPlacementAndBasicPlacementInfo(
pp->bOrders = bp->bOrders;
pp->bAttitude = bp->bAttitude;
- pp->bDirection = bp->bDirection;
+ pp->ubDirection = bp->ubDirection;
pp->bPatrolCnt = bp->bPatrolCnt;
memcpy( pp->sPatrolGrid, bp->sPatrolGrid, sizeof( INT16 ) * MAXPATROLGRIDS );
pp->fHasKeys = bp->fHasKeys;
@@ -2383,7 +2383,8 @@ SOLDIERTYPE* TacticalCreateMilitia( UINT8 ubMilitiaClass )
UINT8 ubID;
SOLDIERTYPE * pSoldier;
- if (gpBattleGroup->ubSectorZ == gbWorldSectorZ &&
+ if (gpBattleGroup &&
+ gpBattleGroup->ubSectorZ == gbWorldSectorZ &&
gpBattleGroup->ubSectorX == gWorldSectorX &&
gpBattleGroup->ubSectorY == gWorldSectorY &&
guiCurrentScreen == AUTORESOLVE_SCREEN && !gfPersistantPBI )
diff --git a/Tactical/Soldier Create.h b/Tactical/Soldier Create.h
index 4161c1d9..260938a1 100644
--- a/Tactical/Soldier Create.h
+++ b/Tactical/Soldier Create.h
@@ -43,7 +43,7 @@ typedef struct
INT8 bTeam; //The team this individual is part of.
INT8 bRelativeAttributeLevel;
INT8 bRelativeEquipmentLevel;
- INT8 bDirection; //1 of 8 values (always mandatory)
+ UINT8 ubDirection; //1 of 8 values (always mandatory)
INT8 bOrders;
INT8 bAttitude;
INT8 bBodyType; //up to 128 body types, -1 means random
@@ -101,7 +101,7 @@ public:
//Location information
INT16 sSectorX;
INT16 sSectorY;
- INT8 bDirection;
+ UINT8 ubDirection;
INT16 sInsertionGridNo;
// Can force a team, but needs flag set
diff --git a/Tactical/Soldier Init List.cpp b/Tactical/Soldier Init List.cpp
index f3ae808c..6a8645e2 100644
--- a/Tactical/Soldier Init List.cpp
+++ b/Tactical/Soldier Init List.cpp
@@ -2368,7 +2368,9 @@ void StripEnemyDetailedPlacementsIfSectorWasPlayerLiberated()
{
if( curr->pBasicPlacement->bTeam == ENEMY_TEAM )
{
- MemFree( curr->pDetailedPlacement );
+ // pDetailedPlacement has been C++'d
+ //MemFree( curr->pDetailedPlacement );
+ delete curr->pDetailedPlacement;
curr->pDetailedPlacement = NULL;
curr->pBasicPlacement->fDetailedPlacement = FALSE;
curr->pBasicPlacement->fPriorityExistance = FALSE;
diff --git a/Tactical/Soldier Profile.cpp b/Tactical/Soldier Profile.cpp
index 5b776770..fdb15adf 100644
--- a/Tactical/Soldier Profile.cpp
+++ b/Tactical/Soldier Profile.cpp
@@ -915,7 +915,7 @@ SOLDIERTYPE *ChangeSoldierTeam( SOLDIERTYPE *pSoldier, UINT8 ubTeam )
MercCreateStruct.sSectorY = pSoldier->sSectorY;
MercCreateStruct.bSectorZ = pSoldier->bSectorZ;
MercCreateStruct.sInsertionGridNo = pSoldier->sGridNo;
- MercCreateStruct.bDirection = pSoldier->bDirection;
+ MercCreateStruct.ubDirection = pSoldier->ubDirection;
if ( pSoldier->uiStatusFlags & SOLDIER_VEHICLE )
{
diff --git a/Tactical/Soldier Tile.cpp b/Tactical/Soldier Tile.cpp
index 2979f69c..6fbf6577 100644
--- a/Tactical/Soldier Tile.cpp
+++ b/Tactical/Soldier Tile.cpp
@@ -166,7 +166,7 @@ void SetFinalTile( SOLDIERTYPE *pSoldier, INT16 sGridNo, BOOLEAN fGivenUp )
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, TacticalStr[ NO_PATH_FOR_MERC ], pSoldier->name );
}
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
}
@@ -427,7 +427,7 @@ BOOLEAN HandleNextTile( SOLDIERTYPE *pSoldier, INT8 bDirection, INT16 sGridNo, I
OutputDebugInfoForTurnBasedNextTileWaiting( pSoldier );
}
#endif
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
// Restore...
pSoldier->sFinalDestination = sOldFinalDest;
@@ -449,7 +449,7 @@ BOOLEAN HandleNextTile( SOLDIERTYPE *pSoldier, INT8 bDirection, INT16 sGridNo, I
OutputDebugInfoForTurnBasedNextTileWaiting( pSoldier );
}
#endif
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
// Restore...
pSoldier->sFinalDestination = sOldFinalDest;
@@ -471,7 +471,7 @@ BOOLEAN HandleNextTile( SOLDIERTYPE *pSoldier, INT8 bDirection, INT16 sGridNo, I
bOverTerrainType = GetTerrainType( sGridNo );
// Check if we are going into water!
- if ( bOverTerrainType == LOW_WATER || bOverTerrainType == MED_WATER || bOverTerrainType == DEEP_WATER )
+ if ( TERRAIN_IS_WATER( bOverTerrainType) )
{
// Check if we are of prone or crawl height and change stance accordingly....
switch( gAnimControl[ pSoldier->usAnimState ].ubHeight )
diff --git a/Tactical/Spread Burst.cpp b/Tactical/Spread Burst.cpp
index 706129c2..a3193c7a 100644
--- a/Tactical/Spread Burst.cpp
+++ b/Tactical/Spread Burst.cpp
@@ -122,7 +122,7 @@ void AccumulateBurstLocation( INT16 sGridNo )
void PickBurstLocations( SOLDIERTYPE *pSoldier )
{
UINT8 ubShotsPerBurst = 0;
- FLOAT dAccululator = 0;
+ FLOAT dAccumulator = 0;
FLOAT dStep = 0;
INT32 cnt;
UINT8 ubLocationNum;
@@ -147,7 +147,7 @@ void PickBurstLocations( SOLDIERTYPE *pSoldier )
while(EnoughPoints( pSoldier, sAPCosts, 0, FALSE ) && pSoldier->inv[ pSoldier->ubAttackingHand ].ItemData.Gun.ubGunShotsLeft >= pSoldier->bDoAutofire && gbNumBurstLocations >= pSoldier->bDoAutofire);
pSoldier->bDoAutofire--;
- ubShotsPerBurst = __min(pSoldier->bDoAutofire,MAX_BURST_SPREAD_TARGETS);
+ ubShotsPerBurst = pSoldier->bDoAutofire;
}
else if ( gbNumBurstLocations > 0 )
ubShotsPerBurst = pSoldier->bDoAutofire / gbNumBurstLocations;
@@ -156,11 +156,13 @@ void PickBurstLocations( SOLDIERTYPE *pSoldier )
else
{
if ( pSoldier->bWeaponMode == WM_ATTACHED_GL_BURST )
- ubShotsPerBurst = __min(Weapon[GetAttachedGrenadeLauncher(&pSoldier->inv[HANDPOS])].ubShotsPerBurst,MAX_BURST_SPREAD_TARGETS);
+ ubShotsPerBurst = Weapon[GetAttachedGrenadeLauncher(&pSoldier->inv[HANDPOS])].ubShotsPerBurst;
else
- ubShotsPerBurst = __min(GetShotsPerBurst(&pSoldier->inv[ HANDPOS ]),MAX_BURST_SPREAD_TARGETS);
+ ubShotsPerBurst = GetShotsPerBurst(&pSoldier->inv[ HANDPOS ]);
}
+ ubShotsPerBurst = __min( ubShotsPerBurst, MAX_BURST_SPREAD_TARGETS);
+
// Use # gridnos accululated and # burst shots to determine accululator
dStep = gbNumBurstLocations / (FLOAT)ubShotsPerBurst;
@@ -168,13 +170,18 @@ void PickBurstLocations( SOLDIERTYPE *pSoldier )
for ( cnt = 0; cnt < ubShotsPerBurst; cnt++ )
{
// Get index into list
- ubLocationNum = (UINT8)( dAccululator );
+ ubLocationNum = (UINT8)( dAccumulator );
// Add to merc location
pSoldier->sSpreadLocations[ cnt ] = gsBurstLocations[ ubLocationNum ].sGridNo;
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("PickBurstLocations: loc#%d = %d", cnt, pSoldier->sSpreadLocations[ cnt ]));
// Acculuate index value
- dAccululator += dStep;
+ dAccumulator += dStep;
+ }
+
+ for (; cnt < MAX_BURST_SPREAD_TARGETS; cnt++)
+ {
+ pSoldier->sSpreadLocations[ cnt ] = 0;
}
// OK, they have been added
@@ -219,6 +226,10 @@ void AIPickBurstLocations( SOLDIERTYPE *pSoldier, INT8 bTargets, SOLDIERTYPE *pT
dAccululator += dStep;
}
+ for (; cnt < MAX_BURST_SPREAD_TARGETS; cnt++)
+ {
+ pSoldier->sSpreadLocations[ cnt ] = 0;
+ }
// OK, they have been added
}
diff --git a/Tactical/Tactical Save.cpp b/Tactical/Tactical Save.cpp
index 05d5efb2..65668016 100644
--- a/Tactical/Tactical Save.cpp
+++ b/Tactical/Tactical Save.cpp
@@ -2779,7 +2779,7 @@ BOOLEAN AddDeadSoldierToUnLoadedSector( INT16 sMapX, INT16 sMapY, UINT8 bMapZ, S
SET_PALETTEREP_ID ( Corpse.SkinPal, pSoldier->SkinPal );
SET_PALETTEREP_ID ( Corpse.PantsPal, pSoldier->PantsPal );
- Corpse.bDirection = pSoldier->bDirection;
+ Corpse.ubDirection = pSoldier->ubDirection;
// Set time of death
Corpse.uiTimeOfDeath = GetWorldTotalMin( );
diff --git a/Tactical/Turn Based Input.cpp b/Tactical/Turn Based Input.cpp
index 9beb290b..07ec3a50 100644
--- a/Tactical/Turn Based Input.cpp
+++ b/Tactical/Turn Based Input.cpp
@@ -2358,7 +2358,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent )
BeginSoldierClimbUpRoof( pjSoldier );
}
- if ( FindFenceJumpDirection( pjSoldier, pjSoldier->sGridNo, pjSoldier->bDirection, &bDirection ) )
+ if ( FindFenceJumpDirection( pjSoldier, pjSoldier->sGridNo, pjSoldier->ubDirection, &bDirection ) )
{
BeginSoldierClimbFence( pjSoldier );
}
@@ -4392,7 +4392,7 @@ void TeleportSelectedSoldier()
{
SetSoldierHeight( pSoldier, 0 );
TeleportSoldier( pSoldier, usMapPos, FALSE );
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
}
else
{
@@ -4402,7 +4402,7 @@ void TeleportSelectedSoldier()
SetSoldierHeight( pSoldier, 50.0 );
TeleportSoldier( pSoldier, usMapPos, TRUE );
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
}
}
}
@@ -4519,7 +4519,7 @@ void ObliterateSector()
// CreateAnimationTile( &AniParams );
//PlayJA2Sample( EXPLOSION_1, RATE_11025, MIDVOLUME, 1, MIDDLEPAN );
- EVENT_SoldierGotHit( pTSoldier, 0, 400, 0, pTSoldier->bDirection, 320, NOBODY , FIRE_WEAPON_NO_SPECIAL, pTSoldier->bAimShotLocation, 0, NOWHERE );
+ EVENT_SoldierGotHit( pTSoldier, 0, 400, 0, pTSoldier->ubDirection, 320, NOBODY , FIRE_WEAPON_NO_SPECIAL, pTSoldier->bAimShotLocation, 0, NOWHERE );
}
}
}
@@ -4544,7 +4544,7 @@ void JumpFence()
INT8 bDirection;
if ( GetSoldier( &pSoldier, gusSelectedSoldier ) )
{
- if ( FindFenceJumpDirection( pSoldier, pSoldier->sGridNo, pSoldier->bDirection, &bDirection ) )
+ if ( FindFenceJumpDirection( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &bDirection ) )
{
BeginSoldierClimbFence( pSoldier );
}
@@ -4568,7 +4568,7 @@ void CreateNextCivType()
MercCreateStruct.sSectorY = gWorldSectorY;
MercCreateStruct.bSectorZ = gbWorldSectorZ;
MercCreateStruct.bBodyType = bBodyType;
- MercCreateStruct.bDirection = SOUTH;
+ MercCreateStruct.ubDirection = SOUTH;
bBodyType++;
diff --git a/Tactical/UI Cursors.cpp b/Tactical/UI Cursors.cpp
index 86007da7..8743c30a 100644
--- a/Tactical/UI Cursors.cpp
+++ b/Tactical/UI Cursors.cpp
@@ -2347,7 +2347,7 @@ UINT8 GetActionModeCursor( SOLDIERTYPE *pSoldier )
}
// Now check our terrain to see if we cannot do the action now...
- if ( pSoldier->bOverTerrainType == DEEP_WATER )
+ if ( WaterTooDeepForAttacks( pSoldier->sGridNo) )
{
ubCursor = INVALIDCURS;
}
diff --git a/Tactical/Vehicles.cpp b/Tactical/Vehicles.cpp
index 4e94f685..50a16a4c 100644
--- a/Tactical/Vehicles.cpp
+++ b/Tactical/Vehicles.cpp
@@ -576,7 +576,7 @@ BOOLEAN AddSoldierToVehicle( SOLDIERTYPE *pSoldier, INT32 iId )
EVENT_SetSoldierPosition( pSoldier, pVehicleSoldier->dXPos, pVehicleSoldier->dYPos );
// Stop from any movement.....
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
// can't call SetCurrentSquad OR SelectSoldier in mapscreen, that will initialize interface panels!!!
if ( guiCurrentScreen == GAME_SCREEN )
diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp
index 311c184a..d5b28027 100644
--- a/Tactical/Weapons.cpp
+++ b/Tactical/Weapons.cpp
@@ -1314,28 +1314,36 @@ BOOLEAN FireWeapon( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo )
else
{
// ATE: PAtch up - bookkeeping for spreading done out of whak
- if ( pSoldier->fDoSpread && !pSoldier->bDoBurst )
+ if ( pSoldier->fDoSpread)
{
- pSoldier->fDoSpread = FALSE;
- }
-
- if ( pSoldier->fDoSpread >= MAX_BURST_SPREAD_TARGETS )
- {
- //If we have more than MAX_BURST_SPREAD_TARGETS bullets, loop over and start again from the first target location
- pSoldier->fDoSpread = 1;
+ if (pSoldier->bDoBurst )
+ {
+ pSoldier->fDoSpread = FALSE;
+ }
+ // 0verhaul: The original code seemed brain damaged: If the current spread target was 0 it would shoot at the
+ // non-spread target grid # instead. Also fDoSpread is used as a counter from 1 to MAX_BURST_SPREAD_TARGETS,
+ // but was actually reset before it got there. So the final spread target would never be shot at. Hopefully this
+ // will work better.
+ else if (pSoldier->fDoSpread > MAX_BURST_SPREAD_TARGETS ||
+ pSoldier->sSpreadLocations[ pSoldier->fDoSpread - 1 ] == 0)
+ {
+ if (pSoldier->fDoSpread == 1)
+ {
+ // If no spread locations are defined, don't spread
+ pSoldier->fDoSpread = 0;
+ }
+ else
+ {
+ // If we hit the end of the array, either by finding a 0 or by exceeding its size, reset
+ pSoldier->fDoSpread = 1;
+ }
+ }
}
if ( pSoldier->fDoSpread )
{
- if ( pSoldier->sSpreadLocations[ pSoldier->fDoSpread - 1 ] != 0 )
- {
- UseGun( pSoldier, pSoldier->sSpreadLocations[ pSoldier->fDoSpread - 1 ] );
- }
- else
- {
- UseGun( pSoldier, sTargetGridNo );
- }
+ UseGun( pSoldier, pSoldier->sSpreadLocations[ pSoldier->fDoSpread - 1 ] );
pSoldier->fDoSpread++;
}
else
@@ -1357,28 +1365,36 @@ BOOLEAN FireWeapon( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo )
UseGun( pSoldier, sTargetGridNo );
else
// ATE: PAtch up - bookkeeping for spreading done out of whak
- if ( pSoldier->fDoSpread && !pSoldier->bDoBurst )
+ if ( pSoldier->fDoSpread)
{
- pSoldier->fDoSpread = FALSE;
- }
+ if (!pSoldier->bDoBurst )
+ {
+ pSoldier->fDoSpread = FALSE;
+ }
- if ( pSoldier->fDoSpread >= MAX_BURST_SPREAD_TARGETS )
- {
- //If we have more than MAX_BURST_SPREAD_TARGETS bullets, loop over and start again from the first target location
- pSoldier->fDoSpread = 1;
+ // 0verhaul: The original code seemed brain damaged: If the current spread target was 0 it would shoot at the
+ // non-spread target grid # instead. Also fDoSpread is used as a counter from 1 to MAX_BURST_SPREAD_TARGETS,
+ // but was actually reset before it got there. So the final spread target would never be shot at. Hopefully this
+ // will work better.
+ else if ( pSoldier->fDoSpread > MAX_BURST_SPREAD_TARGETS ||
+ pSoldier->sSpreadLocations[ pSoldier->fDoSpread - 1 ] == 0)
+ {
+ if (pSoldier->fDoSpread == 1)
+ {
+ // If no spread locations are defined, don't spread
+ pSoldier->fDoSpread = 0;
+ }
+ else
+ {
+ // If we hit the end of the array, either by finding a 0 or by exceeding its size, reset
+ pSoldier->fDoSpread = 1;
+ }
+ }
}
-
if ( pSoldier->fDoSpread )
{
- if ( pSoldier->sSpreadLocations[ pSoldier->fDoSpread - 1 ] != 0 )
- {
- UseLauncher( pSoldier, pSoldier->sSpreadLocations[ pSoldier->fDoSpread - 1 ] );
- }
- else
- {
- UseLauncher( pSoldier, sTargetGridNo );
- }
+ UseLauncher( pSoldier, pSoldier->sSpreadLocations[ pSoldier->fDoSpread - 1 ] );
pSoldier->fDoSpread++;
}
else
@@ -1917,7 +1933,7 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo )
}
// Direction to center of explosion
- ubDirection = gOppositeDirection[ pSoldier->bDirection ];
+ ubDirection = gOppositeDirection[ pSoldier->ubDirection ];
sNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (UINT16)(1 * DirectionInc( ubDirection ) ) );
// Check if a person exists here and is not prone....
@@ -1932,7 +1948,7 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo )
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Incrementing Attack: Exaust from LAW", gTacticalStatus.ubAttackBusyCount ) );
DebugAttackBusy( "Incrementing Attack: Exaust from LAW\n" );
- EVENT_SoldierGotHit( MercPtrs[ ubMerc ], MINI_GRENADE, 10, 200, pSoldier->bDirection, 0, pSoldier->ubID, 0, ANIM_CROUCH, 0, sNewGridNo );
+ EVENT_SoldierGotHit( MercPtrs[ ubMerc ], MINI_GRENADE, 10, 200, pSoldier->ubDirection, 0, pSoldier->ubID, 0, ANIM_CROUCH, 0, sNewGridNo );
}
}
}
@@ -2602,7 +2618,7 @@ BOOLEAN UseThrown( SOLDIERTYPE *pSoldier, INT16 sTargetGridNo )
//AXP 25.03.2007: Cleaned up throwing AP costs. Now only turning + stance change AP
// costs are deducted. Final throw cost is deducted on creating the grenade object
- if ( (UINT8)GetDirectionFromGridNo( sTargetGridNo, pSoldier ) != pSoldier->bDirection )
+ if ( (UINT8)GetDirectionFromGridNo( sTargetGridNo, pSoldier ) != pSoldier->ubDirection )
sAPCost += (INT16)GetAPsToLook( pSoldier );
sAPCost += (INT16)GetAPsToChangeStance( pSoldier, ANIM_STAND );
@@ -2897,29 +2913,30 @@ BOOLEAN DoSpecialEffectAmmoMiss( UINT8 ubAttackerID, INT16 sGridNo, INT16 sXPos,
// gTacticalStatus.ubAttackBusyCount++;
// DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Incrementing Attack: Explosion gone off, COunt now %d", gTacticalStatus.ubAttackBusyCount ) );
- PlayJA2Sample( CREATURE_GAS_NOISE, RATE_11025, SoundVolume( HIGHVOLUME, sGridNo ), 1, SoundDir( sGridNo ) );
+ PlayJA2Sample( CREATURE_GAS_NOISE, RATE_11025, SoundVolume( HIGHVOLUME, sGridNo ), 1, SoundDir( sGridNo ) );
+ // 0verhaul: Not ready to simplify this to a single call yet. What we need in order to
+ // fix this correctly is to detach 'alien spit' as a special caliber and instead add 3 new calibers for actual "ammo":
+ // very small spit, small spit, and large spit. Then we need to add a special effect miss index to point to the
+ // appropriate smoke effect to disperse.
+ //NewSmokeEffect( sGridNo, usItem, 0, ubAttackerID);
-// WDS fix 07/25/2007
-// Don't have monsters cause explosions
- // NewSmokeEffect( sGridNo, usItem, 0, ubAttackerID );
+ // Do Spread effect.......
+ switch( usItem )
+ {
+ case CREATURE_YOUNG_MALE_SPIT:
+ case CREATURE_INFANT_SPIT:
- // // Do Spread effect.......
- // switch( usItem )
- // {
- // case CREATURE_YOUNG_MALE_SPIT:
- //case CREATURE_INFANT_SPIT:
+ NewSmokeEffect( sGridNo, VERY_SMALL_CREATURE_GAS, 0, ubAttackerID );
+ break;
+ case CREATURE_OLD_MALE_SPIT:
+ NewSmokeEffect( sGridNo, SMALL_CREATURE_GAS, 0, ubAttackerID );
+ break;
- // NewSmokeEffect( sGridNo, VERY_SMALL_CREATURE_GAS, 0, ubAttackerID );
- // break;
- // case CREATURE_OLD_MALE_SPIT:
- // NewSmokeEffect( sGridNo, SMALL_CREATURE_GAS, 0, ubAttackerID );
- // break;
-
- // case CREATURE_QUEEN_SPIT:
- // NewSmokeEffect( sGridNo, LARGE_CREATURE_GAS, 0, ubAttackerID );
- // break;
- // }
- }
+ case CREATURE_QUEEN_SPIT:
+ NewSmokeEffect( sGridNo, LARGE_CREATURE_GAS, 0, ubAttackerID );
+ break;
+ }
+ }
return( FALSE );
}
@@ -2980,7 +2997,7 @@ void WeaponHit( UINT16 usSoldierID, UINT16 usWeaponIndex, INT16 sDamage, INT16 s
DoSpecialEffectAmmoMiss( ubAttackerID, pTargetSoldier->sGridNo, sXPos, sYPos, sZPos, FALSE, FALSE, 0 );
// OK, SHOT HAS HIT, DO THINGS APPROPRIATELY
- // ATE: This is 'cause of that darn smoke effect that could potnetially kill
+ // ATE: This is 'cause of that darn smoke effect that could potentially kill
// the poor bastard .. so check
if ( !pTargetSoldier->fDoingExternalDeath )
{
@@ -2988,7 +3005,7 @@ void WeaponHit( UINT16 usSoldierID, UINT16 usWeaponIndex, INT16 sDamage, INT16 s
}
// else
// {
- // Buddy had died from additional dammage - free up attacker here...
+ // Buddy had died from additional damage - free up attacker here...
// ReduceAttackBusyCount( pTargetSoldier->ubAttackerID, FALSE );
// DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Special effect killed before bullet impact, attack count now %d", gTacticalStatus.ubAttackBusyCount) );
// OutputDebugString( "Special effect killed before bullet impact\n" );
@@ -3228,7 +3245,7 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT8 bWeaponStatus, UINT
usMissTileType = FIRSTMISS;
// Check if we are in water...
- if ( gpWorldLevelData[ sGridNo ].ubTerrainID == LOW_WATER || gpWorldLevelData[ sGridNo ].ubTerrainID == DEEP_WATER )
+ if ( TERRAIN_IS_WATER( gpWorldLevelData[ sGridNo ].ubTerrainID) )
{
usMissTileIndex = SECONDMISS1;
usMissTileType = SECONDMISS;
@@ -3688,7 +3705,7 @@ UINT32 CalcChanceToHitGun(SOLDIERTYPE *pSoldier, UINT16 sGridNo, UINT8 ubAimTime
{
iSightRange = SoldierTo3DLocationLineOfSightTest( pSoldier, sGridNo, pSoldier->bTargetLevel, pSoldier->bTargetCubeLevel, TRUE, NO_DISTANCE_LIMIT );
}
-
+
//restore old flag
gAnimControl[ pSoldier->usAnimState ].uiFlags = oldFlag;
@@ -4498,7 +4515,7 @@ INT32 BulletImpact( SOLDIERTYPE *pFirer, SOLDIERTYPE * pTarget, UINT8 ubHitLocat
break;
case AIM_SHOT_LEGS:
// is the damage enough to make us fall over?
- if ( pubSpecial && IS_MERC_BODY_TYPE( pTarget ) && gAnimControl[ pTarget->usAnimState ].ubEndHeight == ANIM_STAND && pTarget->bOverTerrainType != LOW_WATER && pTarget->bOverTerrainType != MED_WATER && pTarget->bOverTerrainType != DEEP_WATER )
+ if ( pubSpecial && IS_MERC_BODY_TYPE( pTarget ) && gAnimControl[ pTarget->usAnimState ].ubEndHeight == ANIM_STAND && !MercInWater( pTarget) )
{
if (iImpactForCrits > MIN_DAMAGE_FOR_AUTO_FALL_OVER )
{
@@ -5355,6 +5372,14 @@ INT32 CalcMaxTossRange( SOLDIERTYPE * pSoldier, UINT16 usItem, BOOLEAN fArmed )
// better max range due to expertise
iRange = iRange * (100 + gbSkillTraitBonus[THROWING] * NUM_SKILL_TRAITS( pSoldier, THROWING ) ) / 100;
}
+
+ // Adjust for thrower's stance
+ if (gAnimControl[ pSoldier->usAnimState ].ubEndHeight < ANIM_STAND)
+ {
+ // For now we just assume the thrower is crouched since we don't allow prone tossing at the moment
+ // So dock 30% from the distance
+ iRange = (iRange * 70) / 100;
+ }
}
if (iRange < 1)
@@ -5768,12 +5793,13 @@ BOOLEAN WeaponReady(SOLDIERTYPE * pSoldier)
if ( AM_A_ROBOT( pSoldier) )
return TRUE;
#endif
- if ( gAnimControl[ pSoldier->usAnimState ].uiFlags & ANIM_FIREREADY )
+ if ( (gAnimControl[ pSoldier->usAnimState ].uiFlags & ANIM_FIREREADY ) ||
+ (gAnimControl[ pSoldier->usAnimState ].uiFlags & ANIM_FIRE ) )
return TRUE;
else
return FALSE;
-
}
+
INT8 GetAPsToReload( OBJECTTYPE *pObj )
{
// DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("GetAPsToReload"));
diff --git a/Tactical/Weapons.h b/Tactical/Weapons.h
index 9874b7ea..4f97e44e 100644
--- a/Tactical/Weapons.h
+++ b/Tactical/Weapons.h
@@ -162,7 +162,7 @@ typedef struct
BOOLEAN antiTank;
BOOLEAN dart;
BOOLEAN knife;
- BOOLEAN monsterSpit;
+ UINT16 monsterSpit;
BOOLEAN ignoreArmour;
BOOLEAN acidic;
INT16 lockBustingPower;
diff --git a/Tactical/fov.cpp b/Tactical/fov.cpp
index 8b36ce18..531bdd3c 100644
--- a/Tactical/fov.cpp
+++ b/Tactical/fov.cpp
@@ -351,7 +351,7 @@ void RevealRoofsAndItems(SOLDIERTYPE *pSoldier, UINT32 itemsToo, BOOLEAN fShowLo
who = pSoldier->ubID;
- dir = pSoldier->bDirection;
+ dir = pSoldier->ubDirection;
//NumMessage("good old reveal",dir);
@@ -374,7 +374,7 @@ void RevealRoofsAndItems(SOLDIERTYPE *pSoldier, UINT32 itemsToo, BOOLEAN fShowLo
// create gridno increment for NOVIEW - in other words, no increment!
Inc[5] = 0;
- Dir[5] = pSoldier->bDirection;
+ Dir[5] = pSoldier->ubDirection;
if (dir % 2 == 1) /* even numbers use ViewPath2 */
Path2 = TRUE;
diff --git a/Tactical/opplist.cpp b/Tactical/opplist.cpp
index 88b6c565..00db003a 100644
--- a/Tactical/opplist.cpp
+++ b/Tactical/opplist.cpp
@@ -1151,7 +1151,7 @@ INT16 DistanceVisible( SOLDIERTYPE *pSoldier, INT8 bFacingDir, INT8 bSubjectDir,
bSubjectDir = (INT8) GetDirectionToGridNoFromGridNo( pSoldier->sGridNo, sSubjectGridNo );
}
if (bFacingDir == DIRECTION_IRRELEVANT) {
- bFacingDir = pSoldier->bDirection;
+ bFacingDir = pSoldier->ubDirection;
}
sDistVisible = gbLookDistance[bFacingDir][bSubjectDir];
@@ -1205,8 +1205,8 @@ INT16 DistanceVisible( SOLDIERTYPE *pSoldier, INT8 bFacingDir, INT8 bSubjectDir,
// valid map references then use the ambient light level instead.
if(0 > sSubjectGridNo || sSubjectGridNo > WORLD_MAX)
{
- DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("113/UC Warning! Tried to detect the light level when character %ls[%d] looks at a location outside of the valid map (gridno %d). Assigning default %d",
- pSoldier->name, pSoldier->ubID, pSoldier->sGridNo, ubAmbientLightLevel));
+ DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("113/UC Warning! Tried to detect the light level when character %ls[%d] looks at a location outside of the valid map (gridno %d). Assigning default %d",
+ pSoldier->name, pSoldier->ubID, pSoldier->sGridNo, ubAmbientLightLevel));
bLightLevel = ubAmbientLightLevel;
}
@@ -1232,7 +1232,7 @@ INT16 DistanceVisible( SOLDIERTYPE *pSoldier, INT8 bFacingDir, INT8 bSubjectDir,
sDistVisible += sDistVisible * GetTotalVisionRangeBonus(pSoldier, bLightLevel) / 100;
}
-
+
// give one step better vision for people with nightops
if (HAS_SKILL_TRAIT( pSoldier, NIGHTOPS ))
{
@@ -1254,7 +1254,7 @@ INT16 DistanceVisible( SOLDIERTYPE *pSoldier, INT8 bFacingDir, INT8 bSubjectDir,
if ( TANK(pSoldier) && sDistVisible > 0 && pSubject)
{
sDistVisible = __max( sDistVisible + 5, pSubject->GetMaxDistanceVisible(pSoldier->sGridNo, pSoldier->bLevel) );
- }
+ }
else {
sDistVisible = __max( sDistVisible + 5, pSoldier->GetMaxDistanceVisible() );
}
@@ -2111,7 +2111,7 @@ void ManSeesMan(SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, INT16 sOppGridno,
{
CancelAIAction( pSoldier, TRUE );
pSoldier->sAbsoluteFinalDestination = NOWHERE;
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
TriggerNPCRecord( ANGEL, 20 );
// trigger Angel to walk off afterwards
//TriggerNPCRecord( ANGEL, 24 );
@@ -3852,7 +3852,7 @@ void DebugSoldierPage2( )
SetFontShade(LARGEFONT1, FONT_SHADE_GREEN);
gprintf( 0, LINE_HEIGHT * ubLine, L"Direction:");
SetFontShade(LARGEFONT1, FONT_SHADE_NEUTRAL);
- gprintf( 150, LINE_HEIGHT * ubLine, L"%S", gzDirectionStr[ pSoldier->bDirection] );
+ gprintf( 150, LINE_HEIGHT * ubLine, L"%S", gzDirectionStr[ pSoldier->ubDirection] );
ubLine++;
SetFontShade(LARGEFONT1, FONT_SHADE_GREEN);
@@ -5688,14 +5688,14 @@ void HearNoise(SOLDIERTYPE *pSoldier, UINT8 ubNoiseMaker, UINT16 sGridNo, INT8 b
sNoiseX = CenterX(sGridNo);
sNoiseY = CenterY(sGridNo);
bDirection = atan8(pSoldier->sX,pSoldier->sY,sNoiseX,sNoiseY);
- if ( pSoldier->bDirection != bDirection && pSoldier->bDirection != gOneCDirection[ bDirection ] && pSoldier->bDirection != gOneCCDirection[ bDirection ] )
+ if ( pSoldier->ubDirection != bDirection && pSoldier->ubDirection != gOneCDirection[ bDirection ] && pSoldier->ubDirection != gOneCCDirection[ bDirection ] )
{
// temporarily turn off muzzle flash so DistanceVisible can be calculated without it
MercPtrs[ ubNoiseMaker ]->fMuzzleFlash = FALSE;
fMuzzleFlash = TRUE;
}
}
-
+
int sDistVisible = pSoldier->GetMaxDistanceVisible(sGridNo, bLevel, CALC_FROM_WANTED_DIR );
if ( fMuzzleFlash )
@@ -5703,14 +5703,14 @@ void HearNoise(SOLDIERTYPE *pSoldier, UINT8 ubNoiseMaker, UINT16 sGridNo, INT8 b
// turn flash on again
MercPtrs[ ubNoiseMaker ]->fMuzzleFlash = TRUE;
}
-
+
if (PythSpacesAway(pSoldier->sGridNo,sGridNo) <= sDistVisible )
{
// just use the XXadjustedXX center of the gridno
sNoiseX = CenterX(sGridNo);
sNoiseY = CenterY(sGridNo);
- if (pSoldier->bDirection != atan8(pSoldier->sX,pSoldier->sY,sNoiseX,sNoiseY))
+ if (pSoldier->ubDirection != atan8(pSoldier->sX,pSoldier->sY,sNoiseX,sNoiseY))
{
bHadToTurn = TRUE;
}
@@ -6530,27 +6530,27 @@ void NoticeUnseenAttacker( SOLDIERTYPE * pAttacker, SOLDIERTYPE * pDefender, INT
}
bOldOppList = pDefender->bOppList[ pAttacker->ubID ];
- // check LOS, considering we are now aware of the attacker
- // ignore muzzle flashes when must turning head
- if ( pAttacker->fMuzzleFlash )
- {
- bDirection = atan8( pDefender->sX,pDefender->sY, pAttacker->sX, pAttacker->sY );
- if ( pDefender->bDirection != bDirection && pDefender->bDirection != gOneCDirection[ bDirection ] && pDefender->bDirection != gOneCCDirection[ bDirection ] )
+ // check LOS, considering we are now aware of the attacker
+ // ignore muzzle flashes when must turning head
+ if ( pAttacker->fMuzzleFlash )
{
- // temporarily turn off muzzle flash so DistanceVisible can be calculated without it
- pAttacker->fMuzzleFlash = FALSE;
- fMuzzleFlash = TRUE;
+ bDirection = atan8( pDefender->sX,pDefender->sY, pAttacker->sX, pAttacker->sY );
+ if ( pDefender->ubDirection != bDirection && pDefender->ubDirection != gOneCDirection[ bDirection ] && pDefender->ubDirection != gOneCCDirection[ bDirection ] )
+ {
+ // temporarily turn off muzzle flash so DistanceVisible can be calculated without it
+ pAttacker->fMuzzleFlash = FALSE;
+ fMuzzleFlash = TRUE;
+ }
}
- }
if (SoldierToSoldierLineOfSightTest( pDefender, pAttacker, TRUE, CALC_FROM_WANTED_DIR ) != 0)
- {
- fSeesAttacker = TRUE;
- }
- if ( fMuzzleFlash )
- {
- pAttacker->fMuzzleFlash = TRUE;
- }
+ {
+ fSeesAttacker = TRUE;
+ }
+ if ( fMuzzleFlash )
+ {
+ pAttacker->fMuzzleFlash = TRUE;
+ }
if (fSeesAttacker)
{
@@ -7011,4 +7011,4 @@ BOOLEAN SoldierHasLimitedVision(SOLDIERTYPE * pSoldier)
return TRUE;
else
return FALSE;
-}
\ No newline at end of file
+}
diff --git a/TacticalAI/AIMain.cpp b/TacticalAI/AIMain.cpp
index ec12886b..5a161b74 100644
--- a/TacticalAI/AIMain.cpp
+++ b/TacticalAI/AIMain.cpp
@@ -1101,7 +1101,7 @@ void FreeUpNPCFromTurning(SOLDIERTYPE *pSoldier, INT8 bLook)
{
#ifdef TESTAI
DebugMsg( TOPIC_JA2AI, DBG_LEVEL_3,
- String("FREEUPNPCFROMTURNING: our action %d, desdir %d dir %d",pSoldier->bAction,pSoldier->bDesiredDirection,pSoldier->bDirection) );
+ String("FREEUPNPCFROMTURNING: our action %d, desdir %d dir %d",pSoldier->bAction,pSoldier->bDesiredDirection,pSoldier->ubDirection) );
#endif
@@ -1160,7 +1160,7 @@ void ActionDone(SOLDIERTYPE *pSoldier)
{
#ifdef TESTAI
DebugMsg( TOPIC_JA2AI, DBG_LEVEL_3,
- String("Cancelling actiondone: our action %d, desdir %d dir %d",pSoldier->bAction,pSoldier->bDesiredDirection,pSoldier->bDirection) );
+ String("Cancelling actiondone: our action %d, desdir %d dir %d",pSoldier->bAction,pSoldier->bDesiredDirection,pSoldier->ubDirection) );
#endif
}
@@ -1177,7 +1177,7 @@ void ActionDone(SOLDIERTYPE *pSoldier)
if ( !pSoldier->fNoAPToFinishMove )
{
- EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
+ EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
AdjustNoAPToFinishMove( pSoldier, FALSE );
}
@@ -1276,9 +1276,9 @@ void NPCDoesAct(SOLDIERTYPE *pSoldier)
// CJC Feb 18 99: make sure that soldier is not in the middle of a turn due to visual crap to make enemies
// face and point their guns at us
- if ( pSoldier->bDesiredDirection != pSoldier->bDirection )
+ if ( pSoldier->bDesiredDirection != pSoldier->ubDirection )
{
- pSoldier->bDesiredDirection = pSoldier->bDirection;
+ pSoldier->bDesiredDirection = pSoldier->ubDirection;
}
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"NPCDoesAct done");
@@ -1421,16 +1421,16 @@ NameMessage(pSoldier,"will now be freed up from turning...",2000);
// force him to face in the right direction (as long as it's legal)
if ((pSoldier->bDesiredDirection >= 1) && (pSoldier->bDesiredDirection <= 8))
-pSoldier->bDirection = pSoldier->bDesiredDirection;
+pSoldier->ubDirection = pSoldier->bDesiredDirection;
else
-pSoldier->bDesiredDirection = pSoldier->bDirection;
+pSoldier->bDesiredDirection = pSoldier->ubDirection;
// free up ONLY players from whom we haven't received an AI_ACTION_DONE yet
// we can all agree the action is DONE and we can continue...
// (otherwise they'll be calling FreeUp... twice and get REAL screwed up)
NetSend.msgType = NET_FREE_UP_TURN;
NetSend.ubID = pSoldier->ubID;
-NetSend.misc_UCHAR = pSoldier->bDirection;
+NetSend.misc_UCHAR = pSoldier->ubDirection;
NetSend.answer = pSoldier->bDesiredDirection;
for (cnt = 0; cnt < MAXPLAYERS; cnt++)
@@ -2416,7 +2416,7 @@ INT8 ExecuteAction(SOLDIERTYPE *pSoldier)
case AI_ACTION_PULL_TRIGGER: // activate an adjacent panic trigger
// turn to face trigger first
- if ( FindStructure( (INT16)(pSoldier->sGridNo + DirectionInc( NORTH )), STRUCTURE_SWITCH ) )
+ if ( FindStructure( pSoldier->sGridNo + DirectionInc( NORTH ), STRUCTURE_SWITCH ) )
{
SendSoldierSetDesiredDirectionEvent( pSoldier, NORTH );
}
@@ -2553,17 +2553,17 @@ INT8 ExecuteAction(SOLDIERTYPE *pSoldier)
case AI_ACTION_LOCK_DOOR:
{
STRUCTURE * pStructure;
- INT8 bDirection;
+ UINT8 ubDirection;
INT16 sDoorGridNo;
- bDirection = (INT8) GetDirectionFromGridNo( pSoldier->usActionData, pSoldier );
- if (bDirection == EAST || bDirection == SOUTH)
+ ubDirection = GetDirectionFromGridNo( (INT16)pSoldier->usActionData, pSoldier );
+ if (ubDirection == EAST || ubDirection == SOUTH)
{
sDoorGridNo = pSoldier->sGridNo;
}
else
{
- sDoorGridNo = pSoldier->sGridNo + DirectionInc( bDirection );
+ sDoorGridNo = pSoldier->sGridNo + DirectionInc( ubDirection );
}
pStructure = FindStructure( sDoorGridNo, STRUCTURE_ANYDOOR );
@@ -2582,14 +2582,14 @@ INT8 ExecuteAction(SOLDIERTYPE *pSoldier)
EndAIGuysTurn( pSoldier );
}
- StartInteractiveObject( sDoorGridNo, pStructure->usStructureID, pSoldier, bDirection );
- InteractWithInteractiveObject( pSoldier, pStructure, bDirection );
+ StartInteractiveObject( sDoorGridNo, pStructure->usStructureID, pSoldier, ubDirection );
+ InteractWithInteractiveObject( pSoldier, pStructure, ubDirection );
}
break;
case AI_ACTION_LOWER_GUN:
// for now, just do "action done"
- InternalSoldierReadyWeapon(pSoldier,pSoldier->bDirection,TRUE);
+ InternalSoldierReadyWeapon(pSoldier,pSoldier->ubDirection,TRUE);
HandleSight(pSoldier, SIGHT_LOOK );
ActionDone( pSoldier );
break;
diff --git a/TacticalAI/AIUtils.cpp b/TacticalAI/AIUtils.cpp
index bcf20399..7004f5f7 100644
--- a/TacticalAI/AIUtils.cpp
+++ b/TacticalAI/AIUtils.cpp
@@ -448,7 +448,7 @@ BOOLEAN IsActionAffordable(SOLDIERTYPE *pSoldier)
{
INT8 bMinPointsNeeded = 0;
INT8 bAPForStandUp = 0;
- INT8 bAPToLookAtWall = ( FindDirectionForClimbing( pSoldier->sGridNo ) == pSoldier->bDirection ) ? 0 : 1;
+ INT8 bAPToLookAtWall = ( FindDirectionForClimbing( pSoldier->sGridNo ) == pSoldier->ubDirection ) ? 0 : 1;
//NumMessage("AffordableAction - Guy#",pSoldier->ubID);
@@ -583,7 +583,7 @@ INT16 RandomFriendWithin(SOLDIERTYPE *pSoldier)
UINT32 uiLoop;
UINT16 usMaxDist;
UINT8 ubFriendCount, ubFriendIDs[MAXMERCS], ubFriendID;
- UINT16 usDirection;
+ UINT8 ubDirection;
UINT8 ubDirsLeft;
BOOLEAN fDirChecked[8];
BOOLEAN fRangeRestricted = FALSE, fFound = FALSE;
@@ -663,9 +663,9 @@ INT16 RandomFriendWithin(SOLDIERTYPE *pSoldier)
// should be close enough, try to find a legal ->sDestination within 1 tile
// clear dirChecked flag for all 8 directions
- for (usDirection = 0; usDirection < 8; usDirection++)
+ for (ubDirection = 0; ubDirection < 8; ubDirection++)
{
- fDirChecked[usDirection] = FALSE;
+ fDirChecked[ubDirection] = FALSE;
}
ubDirsLeft = 8;
@@ -677,14 +677,14 @@ INT16 RandomFriendWithin(SOLDIERTYPE *pSoldier)
// randomly select a direction which hasn't been 'checked' yet
do
{
- usDirection = (UINT16) Random(8);
+ ubDirection = (UINT8) Random(8);
}
- while (fDirChecked[usDirection]);
+ while (fDirChecked[ubDirection]);
- fDirChecked[usDirection] = TRUE;
+ fDirChecked[ubDirection] = TRUE;
// determine the gridno 1 tile away from current friend in this direction
- usDest = NewGridNo(Menptr[ubFriendID].sGridNo,DirectionInc((INT16)(usDirection + 1)));
+ usDest = NewGridNo(Menptr[ubFriendID].sGridNo,DirectionInc(ubDirection));
// if that's out of bounds, ignore it & check next direction
if (usDest == Menptr[ubFriendID].sGridNo)
@@ -2189,7 +2189,7 @@ INT32 CalcManThreatValue( SOLDIERTYPE *pEnemy, INT16 sMyGrid, UINT8 ubReduceForC
else
{
// ADD 5% if man's already facing me
- if (pEnemy->bDirection == atan8(CenterX(pEnemy->sGridNo),CenterY(pEnemy->sGridNo),CenterX(sMyGrid),CenterY(sMyGrid)))
+ if (pEnemy->ubDirection == atan8(CenterX(pEnemy->sGridNo),CenterY(pEnemy->sGridNo),CenterX(sMyGrid),CenterY(sMyGrid)))
{
iThreatValue += (iThreatValue / 20);
}
@@ -2441,13 +2441,13 @@ BOOLEAN ValidCreatureTurn( SOLDIERTYPE * pCreature, INT8 bNewDirection )
INT8 bLoop;
BOOLEAN fFound;
- bDirChange = (INT8) QuickestDirection( pCreature->bDirection, bNewDirection );
+ bDirChange = (INT8) QuickestDirection( pCreature->ubDirection, bNewDirection );
for( bLoop = 0; bLoop < 2; bLoop++ )
{
fFound = TRUE;
- bTempDir = pCreature->bDirection;
+ bTempDir = pCreature->ubDirection;
do
{
diff --git a/TacticalAI/Attacks.cpp b/TacticalAI/Attacks.cpp
index a0c6e1b2..1f86b176 100644
--- a/TacticalAI/Attacks.cpp
+++ b/TacticalAI/Attacks.cpp
@@ -399,7 +399,7 @@ void CalcBestShot(SOLDIERTYPE *pSoldier, ATTACKTYPE *pBestShot, BOOLEAN shootUns
BOOLEAN CloseEnoughForGrenadeToss( INT16 sGridNo, INT16 sGridNo2 )
{
INT16 sTempGridNo;
- INT8 bDirection;
+ UINT8 ubDirection;
INT16 sXPos, sYPos, sXPos2, sYPos2;
UINT8 ubMovementCost;
@@ -407,10 +407,10 @@ BOOLEAN CloseEnoughForGrenadeToss( INT16 sGridNo, INT16 sGridNo2 )
{
// checking the same space; if there is a closed door next to location in ANY direction then forget it
// (could be the player closed a door on us)
- for (bDirection = 0; bDirection < NUM_WORLD_DIRECTIONS; bDirection++)
+ for (ubDirection = 0; ubDirection < NUM_WORLD_DIRECTIONS; ubDirection++)
{
- sTempGridNo = NewGridNo( sGridNo, DirectionInc( bDirection ) );
- ubMovementCost = gubWorldMovementCosts[ sTempGridNo ][ bDirection ][ 0 ];
+ sTempGridNo = NewGridNo( sGridNo, DirectionInc( ubDirection ) );
+ ubMovementCost = gubWorldMovementCosts[ sTempGridNo ][ ubDirection ][ 0 ];
if ( IS_TRAVELCOST_DOOR( ubMovementCost ) )
{
ubMovementCost = DoorTravelCost( NULL, sTempGridNo, ubMovementCost, FALSE, NULL );
@@ -437,14 +437,14 @@ BOOLEAN CloseEnoughForGrenadeToss( INT16 sGridNo, INT16 sGridNo2 )
sYPos = CenterY( sGridNo );
sXPos2 = CenterX( sGridNo2 );
sYPos2 = CenterY( sGridNo2 );
- bDirection = atan8( sXPos, sYPos, sXPos2, sYPos2 );
+ ubDirection = atan8( sXPos, sYPos, sXPos2, sYPos2 );
// For each step of the loop, we are checking for door or obstacle movement costs. If we
// find we're blocked, then this is no good for grenade tossing!
do
{
- sTempGridNo = NewGridNo( sTempGridNo, DirectionInc( bDirection ) );
- ubMovementCost = gubWorldMovementCosts[ sTempGridNo ][ bDirection ][ 0 ];
+ sTempGridNo = NewGridNo( sTempGridNo, DirectionInc( ubDirection ) );
+ ubMovementCost = gubWorldMovementCosts[ sTempGridNo ][ ubDirection ][ 0 ];
if ( IS_TRAVELCOST_DOOR( ubMovementCost ) )
{
ubMovementCost = DoorTravelCost( NULL, sTempGridNo, ubMovementCost, FALSE, NULL );
@@ -1575,6 +1575,8 @@ INT32 EstimateShotDamage(SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, UINT8 ub
INT32 iTotalProt;
INT8 bPlatePos;
UINT8 ubAmmoType;
+ UINT16 usItem;
+ OBJECTTYPE *pObj;
/*
if ( pOpponent->uiStatusFlags & SOLDIER_VEHICLE )
@@ -1584,19 +1586,22 @@ INT32 EstimateShotDamage(SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, UINT8 ub
}
*/
- if ( Item[ pSoldier->inv[pSoldier->ubAttackingHand].usItem ].usItemClass & IC_THROWING_KNIFE )
+ pObj = &(pSoldier->inv[pSoldier->ubAttackingHand]);
+ usItem = pObj->usItem;
+
+ if ( Item[ usItem ].usItemClass & IC_THROWING_KNIFE )
{
ubAmmoType = AMMO_KNIFE;
}
else
{
- ubAmmoType = pSoldier->inv[pSoldier->ubAttackingHand].ItemData.Gun.ubGunAmmoType;
+ ubAmmoType = pObj->ItemData.Gun.ubGunAmmoType;
}
// calculate distance to target, obtain his gun's maximum range rating
iRange = GetRangeInCellCoordsFromGridNoDiff( pSoldier->sGridNo, pOpponent->sGridNo );
- iMaxRange = Weapon[pSoldier->inv[HANDPOS].usItem].usRange;
+ iMaxRange = Weapon[usItem].usRange;
// bullet loses speed and penetrating power, 50% loss per maximum range
iPowerLost = ((50 * iRange) / iMaxRange);
@@ -1604,7 +1609,7 @@ INT32 EstimateShotDamage(SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, UINT8 ub
// up to 50% extra impact for making particularly accurate successful shots
ubBonus = ubChanceToHit / 4; // /4 is really /2 and /2 again
- iDamage = ((GetDamage(&pSoldier->inv[HANDPOS])) * (100 - iPowerLost + ubBonus) / 100) ;
+ iDamage = ((GetDamage(pObj)) * (100 - iPowerLost + ubBonus) / 100) ;
//NumMessage("Pre-protection damage: ",damage);
@@ -1679,7 +1684,7 @@ INT32 EstimateShotDamage(SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, UINT8 ub
{
// cheat and emphasize shots
//iDamage = (iDamage * 15) / 10;
- switch( pSoldier->inv[pSoldier->ubAttackingHand].usItem )
+ switch( usItem )
{
// explosive damage is 100-200% that of the rated, so multiply by 3/2s here
case CREATURE_QUEEN_SPIT: //TODO: Madd - remove the hardcoding here
diff --git a/TacticalAI/CreatureDecideAction.cpp b/TacticalAI/CreatureDecideAction.cpp
index 0e9ffb51..b4ca2156 100644
--- a/TacticalAI/CreatureDecideAction.cpp
+++ b/TacticalAI/CreatureDecideAction.cpp
@@ -391,7 +391,7 @@ INT8 CreatureDecideActionGreen( SOLDIERTYPE * pSoldier )
// if man has a LEGAL dominant facing, and isn't facing it, he will turn
// back towards that facing 50% of the time here (normally just enemies)
if ((pSoldier->bDominantDir >= 0) && (pSoldier->bDominantDir <= 8) &&
- (pSoldier->bDirection != pSoldier->bDominantDir) && PreRandom(2))
+ (pSoldier->ubDirection != pSoldier->bDominantDir) && PreRandom(2))
{
pSoldier->usActionData = pSoldier->bDominantDir;
}
@@ -399,7 +399,7 @@ INT8 CreatureDecideActionGreen( SOLDIERTYPE * pSoldier )
{
pSoldier->usActionData = (UINT16)PreRandom(8);
}
- } while (pSoldier->usActionData == pSoldier->bDirection);
+ } while (pSoldier->usActionData == pSoldier->ubDirection);
#ifdef DEBUGDECISIONS
STR16 tempstr;
@@ -479,7 +479,7 @@ INT8 CreatureDecideActionYellow( SOLDIERTYPE * pSoldier )
// if soldier is not already facing in that direction,
// and the noise source is close enough that it could possibly be seen
- if ((GetAPsToLook( pSoldier ) <= pSoldier->bActionPoints) && (pSoldier->bDirection != ubNoiseDir) && PythSpacesAway(pSoldier->sGridNo,sNoiseGridNo) <= STRAIGHT)
+ if ((GetAPsToLook( pSoldier ) <= pSoldier->bActionPoints) && (pSoldier->ubDirection != ubNoiseDir) && PythSpacesAway(pSoldier->sGridNo,sNoiseGridNo) <= STRAIGHT)
{
// set base chance according to orders
if ((pSoldier->bOrders == STATIONARY) || (pSoldier->bOrders == ONGUARD))
@@ -850,7 +850,7 @@ INT8 CreatureDecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK)
// note, have to change this to use the level returned from ClosestKnownOpponent
sDistVisible = pSoldier->GetMaxDistanceVisible(sClosestOpponent, 0 );
- if ((pSoldier->bDirection != ubOpponentDir) && (PythSpacesAway(pSoldier->sGridNo,sClosestOpponent) <= sDistVisible))
+ if ((pSoldier->ubDirection != ubOpponentDir) && (PythSpacesAway(pSoldier->sGridNo,sClosestOpponent) <= sDistVisible))
{
// set base chance according to orders
if ((pSoldier->bOrders == STATIONARY) || (pSoldier->bOrders == ONGUARD))
@@ -1405,7 +1405,7 @@ INT8 CreatureDecideActionBlack( SOLDIERTYPE * pSoldier )
bDirection = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sClosestOpponent),CenterY(sClosestOpponent));
// if we're not facing towards him
- if (pSoldier->bDirection != bDirection && ValidCreatureTurn( pSoldier, bDirection ) )
+ if (pSoldier->ubDirection != bDirection && ValidCreatureTurn( pSoldier, bDirection ) )
{
pSoldier->usActionData = bDirection;
@@ -1699,7 +1699,7 @@ INT8 CrowDecideActionGreen( SOLDIERTYPE * pSoldier )
// Change facing
sFacingDir = GetDirectionFromGridNo( sCorpseGridNo, pSoldier );
- if ( sFacingDir != pSoldier->bDirection )
+ if ( sFacingDir != pSoldier->ubDirection )
{
pSoldier->usActionData = sFacingDir;
return(AI_ACTION_CHANGE_FACING);
diff --git a/TacticalAI/DecideAction.cpp b/TacticalAI/DecideAction.cpp
index c27492a1..6645c9f1 100644
--- a/TacticalAI/DecideAction.cpp
+++ b/TacticalAI/DecideAction.cpp
@@ -550,7 +550,7 @@ INT8 DecideActionBoxerEnteringRing(SOLDIERTYPE *pSoldier)
ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sDesiredMercLoc),CenterY(sDesiredMercLoc));
// if not already facing in that direction,
- if ( pSoldier->bDirection != ubDesiredMercDir && InternalIsValidStance( pSoldier, ubDesiredMercDir, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) )
+ if ( pSoldier->ubDirection != ubDesiredMercDir && InternalIsValidStance( pSoldier, ubDesiredMercDir, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) )
{
pSoldier->usActionData = ubDesiredMercDir;
@@ -610,7 +610,7 @@ INT8 DecideActionNamedNPC( SOLDIERTYPE * pSoldier )
ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sDesiredMercLoc),CenterY(sDesiredMercLoc));
// if not already facing in that direction,
- if (pSoldier->bDirection != ubDesiredMercDir && InternalIsValidStance( pSoldier, ubDesiredMercDir, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) )
+ if (pSoldier->ubDirection != ubDesiredMercDir && InternalIsValidStance( pSoldier, ubDesiredMercDir, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) )
{
pSoldier->usActionData = ubDesiredMercDir;
@@ -754,7 +754,7 @@ INT8 DecideActionGreen(SOLDIERTYPE *pSoldier)
ubRingDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(CENTER_OF_RING),CenterY(CENTER_OF_RING));
if ( gfTurnBasedAI || GetAPsToLook( pSoldier ) <= pSoldier->bActionPoints )
{
- if ( pSoldier->bDirection != ubRingDir )
+ if ( pSoldier->ubDirection != ubRingDir )
{
pSoldier->usActionData = ubRingDir;
return( AI_ACTION_CHANGE_FACING );
@@ -1220,7 +1220,7 @@ INT8 DecideActionGreen(SOLDIERTYPE *pSoldier)
// if man has a LEGAL dominant facing, and isn't facing it, he will turn
// back towards that facing 50% of the time here (normally just enemies)
if ((pSoldier->bDominantDir >= 0) && (pSoldier->bDominantDir <= 8) &&
- (pSoldier->bDirection != pSoldier->bDominantDir) && PreRandom(2) && pSoldier->bOrders != SNIPER )
+ (pSoldier->ubDirection != pSoldier->bDominantDir) && PreRandom(2) && pSoldier->bOrders != SNIPER )
{
pSoldier->usActionData = pSoldier->bDominantDir;
}
@@ -1234,7 +1234,7 @@ INT8 DecideActionGreen(SOLDIERTYPE *pSoldier)
if (sNoiseGridNo == NOWHERE ||
(ubNoiseDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sNoiseGridNo),CenterY(sNoiseGridNo))
- ) == pSoldier->bDirection )
+ ) == pSoldier->ubDirection )
{
pSoldier->usActionData = (UINT16)PreRandom(8);
@@ -1244,7 +1244,7 @@ INT8 DecideActionGreen(SOLDIERTYPE *pSoldier)
pSoldier->usActionData = ubNoiseDir;
}
}
- } while (pSoldier->usActionData == pSoldier->bDirection);
+ } while (pSoldier->usActionData == pSoldier->ubDirection);
#ifdef DEBUGDECISIONS
@@ -1355,7 +1355,7 @@ INT8 DecideActionYellow(SOLDIERTYPE *pSoldier)
// and the noise source is close enough that it could possibly be seen
if ( !gfTurnBasedAI || GetAPsToLook( pSoldier ) <= pSoldier->bActionPoints )
{
- if ((pSoldier->bDirection != ubNoiseDir) && PythSpacesAway(pSoldier->sGridNo,sNoiseGridNo) <= pSoldier->GetMaxDistanceVisible(sNoiseGridNo) )
+ if ((pSoldier->ubDirection != ubNoiseDir) && PythSpacesAway(pSoldier->sGridNo,sNoiseGridNo) <= pSoldier->GetMaxDistanceVisible(sNoiseGridNo) )
{
// set base chance according to orders
if ((pSoldier->bOrders == STATIONARY) || (pSoldier->bOrders == ONGUARD) )
@@ -2154,10 +2154,10 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK)
// if firing mortar make sure we have room
if ( Item[pSoldier->inv[ BestThrow.bWeaponIn ].usItem].mortar )
{
- ubOpponentDir = (UINT8)GetDirectionFromGridNo( BestThrow.sTarget, pSoldier );
+ ubOpponentDir = GetDirectionFromGridNo( BestThrow.sTarget, pSoldier );
// Get new gridno!
- sCheckGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (UINT16)DirectionInc( ubOpponentDir ) );
+ sCheckGridNo = NewGridNo( pSoldier->sGridNo, DirectionInc( ubOpponentDir ) );
if ( OKFallDirection( pSoldier, sCheckGridNo, pSoldier->bLevel, ubOpponentDir, pSoldier->usAnimState ) )
{
@@ -2181,10 +2181,10 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK)
BestThrow.ubPossible = FALSE;
// try behind us, see if there's room to move back
- sCheckGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (UINT16)DirectionInc( gOppositeDirection[ ubOpponentDir ] ) );
+ sCheckGridNo = NewGridNo( pSoldier->sGridNo, DirectionInc( gOppositeDirection[ ubOpponentDir ] ) );
if ( OKFallDirection( pSoldier, sCheckGridNo, pSoldier->bLevel, gOppositeDirection[ ubOpponentDir ], pSoldier->usAnimState ) )
{
- pSoldier->usActionData = sCheckGridNo;
+ pSoldier->usActionData = (UINT16) sCheckGridNo;
return( AI_ACTION_GET_CLOSER );
}
@@ -2909,7 +2909,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK)
// if soldier is not already facing in that direction,
// and the opponent is close enough that he could possibly be seen
- if ( pSoldier->bDirection != ubOpponentDir && InternalIsValidStance( pSoldier, ubOpponentDir, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) )
+ if ( pSoldier->ubDirection != ubOpponentDir && InternalIsValidStance( pSoldier, ubOpponentDir, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) )
{
// turn
pSoldier->usActionData = ubOpponentDir;
@@ -3162,7 +3162,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK)
// note, have to change this to use the level returned from ClosestKnownOpponent
sDistVisible = pSoldier->GetMaxDistanceVisible(sClosestOpponent, 0, CALC_FROM_ALL_DIRS );
- if ((pSoldier->bDirection != ubOpponentDir) && (PythSpacesAway(pSoldier->sGridNo,sClosestOpponent) <= sDistVisible))
+ if ((pSoldier->ubDirection != ubOpponentDir) && (PythSpacesAway(pSoldier->sGridNo,sClosestOpponent) <= sDistVisible))
{
// set base chance according to orders
if ((pSoldier->bOrders == STATIONARY) || (pSoldier->bOrders == ONGUARD))
@@ -3197,7 +3197,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK)
return(AI_ACTION_CHANGE_FACING);
}
}
- else if ( pSoldier->bDirection == ubOpponentDir && pSoldier->bOrders == SNIPER )
+ else if ( pSoldier->ubDirection == ubOpponentDir && pSoldier->bOrders == SNIPER )
{
if (!gfTurnBasedAI || GetAPsToReadyWeapon( pSoldier, READY_RIFLE_CROUCH ) <= pSoldier->bActionPoints)
{
@@ -3216,7 +3216,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK)
if ( sClosestDisturbance != NOWHERE )
{
ubOpponentDir = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( sClosestDisturbance ), CenterY( sClosestDisturbance ) );
- if ( pSoldier->bDirection == ubOpponentDir )
+ if ( pSoldier->ubDirection == ubOpponentDir )
{
ubOpponentDir = (UINT8) PreRandom( NUM_WORLD_DIRECTIONS );
}
@@ -3226,7 +3226,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK)
ubOpponentDir = (UINT8) PreRandom( NUM_WORLD_DIRECTIONS );
}
- if ( (pSoldier->bDirection != ubOpponentDir) )
+ if ( (pSoldier->ubDirection != ubOpponentDir) )
{
if ( (pSoldier->bActionPoints == pSoldier->bInitialActionPoints || (INT16)PreRandom(100) < 60) && InternalIsValidStance( pSoldier, ubOpponentDir, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) )
{
@@ -3365,7 +3365,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK)
if ( sClosestDisturbance != NOWHERE )
{
ubOpponentDir = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( sClosestDisturbance ), CenterY( sClosestDisturbance ) );
- if ( pSoldier->bDirection != ubOpponentDir )
+ if ( pSoldier->ubDirection != ubOpponentDir )
{
if ( !gfTurnBasedAI || GetAPsToLook( pSoldier ) <= pSoldier->bActionPoints )
{
@@ -4277,7 +4277,7 @@ INT8 DecideActionBlack(SOLDIERTYPE *pSoldier)
if (ubBestStance != 0)
{
// change stance first!
- if ( pSoldier->bDirection != bDirection && InternalIsValidStance( pSoldier, bDirection, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) )
+ if ( pSoldier->ubDirection != bDirection && InternalIsValidStance( pSoldier, bDirection, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) )
{
// we're not facing towards him, so turn first!
pSoldier->usActionData = bDirection;
@@ -4632,7 +4632,7 @@ INT8 DecideActionBlack(SOLDIERTYPE *pSoldier)
if ( pSoldier->usActionData != NOWHERE )
{
// truncate path to 1 step
- pSoldier->usActionData = pSoldier->sGridNo + DirectionInc( pSoldier->usPathingData[0] );
+ pSoldier->usActionData = pSoldier->sGridNo + DirectionInc( (UINT8) pSoldier->usPathingData[0] );
pSoldier->sFinalDestination = pSoldier->usActionData;
pSoldier->bNextAction = AI_ACTION_END_TURN;
return( AI_ACTION_GET_CLOSER );
@@ -4749,7 +4749,7 @@ INT8 DecideActionBlack(SOLDIERTYPE *pSoldier)
bDirection = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sClosestOpponent),CenterY(sClosestOpponent));
// if we're not facing towards him
- if (pSoldier->bDirection != bDirection)
+ if (pSoldier->ubDirection != bDirection)
{
if ( InternalIsValidStance( pSoldier, bDirection, (INT8) pSoldier->usActionData) )
{
@@ -4807,7 +4807,7 @@ INT8 DecideActionBlack(SOLDIERTYPE *pSoldier)
bDirection = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sClosestOpponent),CenterY(sClosestOpponent));
// if we're not facing towards him
- if ( pSoldier->bDirection != bDirection && InternalIsValidStance( pSoldier, bDirection, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) )
+ if ( pSoldier->ubDirection != bDirection && InternalIsValidStance( pSoldier, bDirection, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) )
{
pSoldier->usActionData = bDirection;
diff --git a/TacticalAI/Movement.cpp b/TacticalAI/Movement.cpp
index 84edbeb4..7d6cf80a 100644
--- a/TacticalAI/Movement.cpp
+++ b/TacticalAI/Movement.cpp
@@ -998,7 +998,7 @@ INT16 TrackScent( SOLDIERTYPE * pSoldier )
ubBestStrength = ubStrength;
bDir = atan8( (INT16) iXStart, (INT16) iYStart, (INT16) (iXStart + iXDiff), (INT16) (iYStart + iYDiff) );
// now convert it into a difference in degree between it and our current dir
- ubBestDirDiff = abs( pSoldier->bDirection - bDir );
+ ubBestDirDiff = abs( pSoldier->ubDirection - bDir );
if (ubBestDirDiff > 4 ) // dir 0 compared with dir 6, for instance
{
ubBestDirDiff = 8 - ubBestDirDiff;
@@ -1018,7 +1018,7 @@ INT16 TrackScent( SOLDIERTYPE * pSoldier )
// start by calculating direction to the new gridno
bDir = atan8( (INT16) iXStart, (INT16) iYStart, (INT16) (iXStart + iXDiff), (INT16) (iYStart + iYDiff) );
// now convert it into a difference in degree between it and our current dir
- ubDirDiff = abs( pSoldier->bDirection - bDir );
+ ubDirDiff = abs( pSoldier->ubDirection - bDir );
if (ubDirDiff > 4 ) // dir 0 compared with dir 6, for instance
{
ubDirDiff = 8 - ubDirDiff;
diff --git a/TileEngine/Buildings.cpp b/TileEngine/Buildings.cpp
index 6bcd6a2a..cc579748 100644
--- a/TileEngine/Buildings.cpp
+++ b/TileEngine/Buildings.cpp
@@ -44,7 +44,7 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
UINT32 uiLoop2;
INT16 sTempGridNo, sNextTempGridNo, sVeryTemporaryGridNo;
INT16 sStartGridNo, sCurrGridNo, sPrevGridNo = NOWHERE, sRightGridNo;
- INT8 bDirection, bTempDirection;
+ UINT8 ubDirection, ubTempDirection;
BOOLEAN fFoundDir, fFoundWall;
UINT32 uiChanceIn = ROOF_LOCATION_CHANCE; // chance of a location being considered
INT16 sWallGridNo;
@@ -77,13 +77,13 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
RoofReachableTest( sDesiredSpot, ubBuildingID );
// From sGridNo, search until we find a spot that isn't part of the building
- bDirection = NORTHWEST;
+ ubDirection = NORTHWEST;
sTempGridNo = sDesiredSpot;
// using diagonal directions to hopefully prevent picking a
// spot that
while( (gpWorldLevelData[ sTempGridNo ].uiFlags & MAPELEMENT_REACHABLE ) )
{
- sNextTempGridNo = NewGridNo( sTempGridNo, DirectionInc( bDirection ) );
+ sNextTempGridNo = NewGridNo( sTempGridNo, DirectionInc( ubDirection ) );
if ( sTempGridNo == sNextTempGridNo )
{
// hit edge of map!??!
@@ -103,12 +103,12 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
if ( gpWorldLevelData[ sVeryTemporaryGridNo ].uiFlags & MAPELEMENT_REACHABLE )
{
// go north first
- bDirection = NORTH;
+ ubDirection = NORTH;
}
else
{
// go that way (east)
- bDirection = EAST;
+ ubDirection = EAST;
}
gpWorldLevelData[ sStartGridNo ].ubExtFlags[0] |= MAPELEMENT_EXT_ROOFCODE_VISITED;
@@ -118,7 +118,7 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
{
// if point to (2 clockwise) is not part of building and is not visited,
// or is starting point, turn!
- sRightGridNo = NewGridNo( sCurrGridNo, DirectionInc( gTwoCDirection[ bDirection ] ) );
+ sRightGridNo = NewGridNo( sCurrGridNo, DirectionInc( gTwoCDirection[ ubDirection ] ) );
sTempGridNo = sRightGridNo;
if ( ( ( !(gpWorldLevelData[ sTempGridNo ].uiFlags & MAPELEMENT_REACHABLE) && !(gpWorldLevelData[ sTempGridNo ].ubExtFlags[0] & MAPELEMENT_EXT_ROOFCODE_VISITED) ) || (sTempGridNo == sStartGridNo) ) && (sCurrGridNo != sStartGridNo) )
{
@@ -128,47 +128,47 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
{
return( NULL );
}
- bDirection = gTwoCDirection[ bDirection ];
+ ubDirection = gTwoCDirection[ ubDirection ];
// try in that direction
continue;
}
iLoopCount = 0;
// if spot ahead is part of building, turn
- sTempGridNo = NewGridNo( sCurrGridNo, DirectionInc( bDirection ) );
+ sTempGridNo = NewGridNo( sCurrGridNo, DirectionInc( ubDirection ) );
if ( gpWorldLevelData[ sTempGridNo ].uiFlags & MAPELEMENT_REACHABLE )
{
// first search for a spot that is neither part of the building or visited
// we KNOW that the spot in the original direction is blocked, so only loop 3 times
- bTempDirection = gTwoCDirection[ bDirection ];
+ ubTempDirection = gTwoCDirection[ ubDirection ];
fFoundDir = FALSE;
for ( uiLoop = 0; uiLoop < 3; uiLoop++ )
{
- sTempGridNo = NewGridNo( sCurrGridNo, DirectionInc( bTempDirection ) );
+ sTempGridNo = NewGridNo( sCurrGridNo, DirectionInc( ubTempDirection ) );
if ( !(gpWorldLevelData[ sTempGridNo ].uiFlags & MAPELEMENT_REACHABLE) && !(gpWorldLevelData[ sTempGridNo ].ubExtFlags[0] & MAPELEMENT_EXT_ROOFCODE_VISITED) )
{
// this is the way to go!
fFoundDir = TRUE;
break;
}
- bTempDirection = gTwoCDirection[ bTempDirection ];
+ ubTempDirection = gTwoCDirection[ ubTempDirection ];
}
if (!fFoundDir)
{
// now search for a spot that is just not part of the building
- bTempDirection = gTwoCDirection[ bDirection ];
+ ubTempDirection = gTwoCDirection[ ubDirection ];
fFoundDir = FALSE;
for ( uiLoop = 0; uiLoop < 3; uiLoop++ )
{
- sTempGridNo = NewGridNo( sCurrGridNo, DirectionInc( bTempDirection ) );
+ sTempGridNo = NewGridNo( sCurrGridNo, DirectionInc( ubTempDirection ) );
if ( !(gpWorldLevelData[ sTempGridNo ].uiFlags & MAPELEMENT_REACHABLE) )
{
// this is the way to go!
fFoundDir = TRUE;
break;
}
- bTempDirection = gTwoCDirection[ bTempDirection ];
+ ubTempDirection = gTwoCDirection[ ubTempDirection ];
}
if (!fFoundDir)
{
@@ -176,7 +176,7 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
return( NULL );
}
}
- bDirection = bTempDirection;
+ ubDirection = ubTempDirection;
// try in that direction
continue;
}
@@ -184,7 +184,7 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
// move ahead
sPrevGridNo = sCurrGridNo;
sCurrGridNo = sTempGridNo;
- sRightGridNo = NewGridNo( sCurrGridNo, DirectionInc( gTwoCDirection[ bDirection ] ) );
+ sRightGridNo = NewGridNo( sCurrGridNo, DirectionInc( gTwoCDirection[ ubDirection ] ) );
#ifdef ROOF_DEBUG
if (gsCoverValue[sCurrGridNo] == 0x7F7F)
@@ -219,7 +219,7 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
// if south or west, the wall would be in the gridno two clockwise
fFoundWall = FALSE;
- switch( bDirection )
+ switch( ubDirection )
{
case NORTH:
sWallGridNo = sCurrGridNo;
@@ -230,11 +230,11 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
bDesiredOrientation = OUTSIDE_TOP_LEFT;
break;
case SOUTH:
- sWallGridNo = (INT16) ( sCurrGridNo + DirectionInc( gTwoCDirection[ bDirection ] ) );
+ sWallGridNo = (INT16) ( sCurrGridNo + DirectionInc( gTwoCDirection[ ubDirection ] ) );
bDesiredOrientation = OUTSIDE_TOP_RIGHT;
break;
case WEST:
- sWallGridNo = (INT16) ( sCurrGridNo + DirectionInc( gTwoCDirection[ bDirection ] ) );
+ sWallGridNo = (INT16) ( sCurrGridNo + DirectionInc( gTwoCDirection[ ubDirection ] ) );
bDesiredOrientation = OUTSIDE_TOP_LEFT;
break;
default:
diff --git a/TileEngine/Explosion Control.cpp b/TileEngine/Explosion Control.cpp
index bbee3744..e782c3b8 100644
--- a/TileEngine/Explosion Control.cpp
+++ b/TileEngine/Explosion Control.cpp
@@ -406,7 +406,7 @@ void GenerateExplosionFromExplosionPointer( EXPLOSIONTYPE *pExplosion )
AniParams.sStartFrame = pExplosion->sCurrentFrame;
AniParams.uiFlags = ANITILE_CACHEDTILE | ANITILE_FORWARD | ANITILE_EXPLOSION;
- if ( ubTerrainType == LOW_WATER || ubTerrainType == MED_WATER || ubTerrainType == DEEP_WATER )
+ if ( TERRAIN_IS_WATER(ubTerrainType) )
{
// Change type to water explosion...
ubTypeID = WATER_BLAST;
@@ -1209,7 +1209,6 @@ BOOLEAN ExplosiveDamageStructureAtGridNo( STRUCTURE * pCurrent, STRUCTURE **ppNe
STRUCTURE *gStruct;
-// Lesh: somewhere here once I got CTD when militia stepped on mine in cambria sam
void ExplosiveDamageGridNo( INT16 sGridNo, INT16 sWoundAmt, UINT32 uiDist, BOOLEAN *pfRecompileMovementCosts, BOOLEAN fOnlyWalls, INT8 bMultiStructSpecialFlag, BOOLEAN fSubSequentMultiTilesTransitionDamage, UINT8 ubOwner, INT8 bLevel )
{
STRUCTURE * pCurrent, *pNextCurrent, *pStructure;
@@ -1233,7 +1232,7 @@ void ExplosiveDamageGridNo( INT16 sGridNo, INT16 sWoundAmt, UINT32 uiDist, BOOLE
// (1) we might need to destroy the currently-examined structure
while (pCurrent != NULL)
{
- // ATE: These are for the chacks below for multi-structs....
+ // ATE: These are for the checks below for multi-structs....
pBaseStructure = FindBaseStructure( pCurrent );
if ( pBaseStructure )
@@ -1243,7 +1242,6 @@ void ExplosiveDamageGridNo( INT16 sGridNo, INT16 sWoundAmt, UINT32 uiDist, BOOLE
fMultiStructure = ( ( pBaseStructure->fFlags & STRUCTURE_MULTI ) != 0 );
ppTile = (DB_STRUCTURE_TILE **) MemAlloc( sizeof( DB_STRUCTURE_TILE* ) * ubNumberOfTiles );
- // Lesh: CTD was in next line once
memcpy( ppTile, pBaseStructure->pDBStructureRef->ppTile, sizeof( DB_STRUCTURE_TILE* ) * ubNumberOfTiles );
if ( bMultiStructSpecialFlag == -1 )
@@ -1271,7 +1269,7 @@ void ExplosiveDamageGridNo( INT16 sGridNo, INT16 sWoundAmt, UINT32 uiDist, BOOLE
{
fExplodeDamageReturn = ExplosiveDamageStructureAtGridNo( pCurrent, &pNextCurrent, sGridNo, sWoundAmt, uiDist, pfRecompileMovementCosts, fOnlyWalls, 0, ubOwner, bLevel );
- // Are we overwritting damage due to multi-tile...?
+ // Are we overwriting damage due to multi-tile...?
if ( fExplodeDamageReturn )
{
if ( fSubSequentMultiTilesTransitionDamage == 2)
@@ -1288,65 +1286,74 @@ void ExplosiveDamageGridNo( INT16 sGridNo, INT16 sWoundAmt, UINT32 uiDist, BOOLE
{
fToBreak = TRUE;
}
- }
+ //}
- // OK, for multi-structs...
- // AND we took damage...
- if ( fMultiStructure && !fOnlyWalls && fExplodeDamageReturn == 0 )
- {
- // ATE: Don't after first attack...
- if ( uiDist > 1 )
+ // 0verhaul: The following was combined with the previous code block. I don't think they intended to execute this
+ // part unless fExplodeDamageReturn was actually set. When it was being executed, tossing a grenade just behind the
+ // plane in Drassen, for instance, would cause an infinite recursion in this code. The reason is that the plane's
+ // armor is (amazingly enough) stronger than a grenade blast can even damage. This code here seems to rely on the
+ // structure in question being destroyed by the blast since it indiscriminently recurses on neighbors, creating a
+ // ping pong on two adjacent parts of the plane. Probably the reason this was not found before is that fExplodeDamageReturn
+ // was uninitialized before and usually was non-zero. Now it is initialized to false.
+
+ // OK, for multi-structs...
+ // AND we took damage...
+ if ( fMultiStructure && !fOnlyWalls && fExplodeDamageReturn == 0 )
{
- if ( pBaseStructure )
+ // ATE: Don't after first attack...
+ if ( uiDist > 1 )
{
- MemFree( ppTile );
- }
- return;
- }
-
- {
-
- for ( ubLoop = BASE_TILE; ubLoop < ubNumberOfTiles; ubLoop++)
- {
- sNewGridNo = sBaseGridNo + ppTile[ubLoop]->sPosRelToBase;
-
- // look in adjacent tiles
- for ( ubLoop2 = 0; ubLoop2 < NUM_WORLD_DIRECTIONS; ubLoop2++ )
+ if ( pBaseStructure )
{
- sNewGridNo2 = NewGridNo( sNewGridNo, DirectionInc( ubLoop2 ) );
- if ( sNewGridNo2 != sNewGridNo && sNewGridNo2 != sGridNo )
+ MemFree( ppTile );
+ }
+ return;
+ }
+
+ {
+
+ for ( ubLoop = BASE_TILE; ubLoop < ubNumberOfTiles; ubLoop++)
+ {
+ sNewGridNo = sBaseGridNo + ppTile[ubLoop]->sPosRelToBase;
+
+ // look in adjacent tiles
+ for ( ubLoop2 = 0; ubLoop2 < NUM_WORLD_DIRECTIONS; ubLoop2++ )
{
- pStructure = FindStructure( sNewGridNo2, STRUCTURE_MULTI );
- if ( pStructure )
+ sNewGridNo2 = NewGridNo( sNewGridNo, DirectionInc( ubLoop2 ) );
+ if ( sNewGridNo2 != sNewGridNo && sNewGridNo2 != sGridNo )
{
- fMultiStructSpecialFlag = ( ( pStructure->fFlags & STRUCTURE_SPECIAL ) != 0 );
-
- if ( ( bMultiStructSpecialFlag == fMultiStructSpecialFlag ) )
+ pStructure = FindStructure( sNewGridNo2, STRUCTURE_MULTI );
+ if ( pStructure )
{
- // If we just damaged it, use same damage value....
- if ( fMultiStructSpecialFlag )
- {
- ExplosiveDamageGridNo( sNewGridNo2, sWoundAmt, uiDist, pfRecompileMovementCosts, fOnlyWalls, bMultiStructSpecialFlag, 1, ubOwner, bLevel );
- }
- else
- {
- ExplosiveDamageGridNo( sNewGridNo2, sWoundAmt, uiDist, pfRecompileMovementCosts, fOnlyWalls, bMultiStructSpecialFlag, 2, ubOwner, bLevel );
- }
+ fMultiStructSpecialFlag = ( ( pStructure->fFlags & STRUCTURE_SPECIAL ) != 0 );
+ if ( ( bMultiStructSpecialFlag == fMultiStructSpecialFlag ) )
{
- InternalIgniteExplosion( ubOwner, CenterX( sNewGridNo2 ), CenterY( sNewGridNo2 ), 0, sNewGridNo2, RDX, FALSE, bLevel );
- }
+ // If we just damaged it, use same damage value....
+ if ( fMultiStructSpecialFlag )
+ {
+ ExplosiveDamageGridNo( sNewGridNo2, sWoundAmt, uiDist, pfRecompileMovementCosts, fOnlyWalls, bMultiStructSpecialFlag, 1, ubOwner, bLevel );
+ }
+ else
+ {
+ ExplosiveDamageGridNo( sNewGridNo2, sWoundAmt, uiDist, pfRecompileMovementCosts, fOnlyWalls, bMultiStructSpecialFlag, 2, ubOwner, bLevel );
+ }
- fToBreak = TRUE;
+ {
+ InternalIgniteExplosion( ubOwner, CenterX( sNewGridNo2 ), CenterY( sNewGridNo2 ), 0, sNewGridNo2, RDX, FALSE, bLevel );
+ }
+
+ fToBreak = TRUE;
+ }
}
}
}
}
}
- }
- if ( fToBreak )
- {
- break;
+ if ( fToBreak )
+ {
+ break;
+ }
}
}
@@ -2862,7 +2869,7 @@ void PerformItemAction( INT16 sGridNo, OBJECTTYPE * pObj )
{
// stop the merc...
- EVENT_StopMerc( MercPtrs[ ubID ], MercPtrs[ ubID ]->sGridNo, MercPtrs[ ubID ]->bDirection );
+ EVENT_StopMerc( MercPtrs[ ubID ], MercPtrs[ ubID ]->sGridNo, MercPtrs[ ubID ]->ubDirection );
switch( sGridNo )
{
@@ -3673,7 +3680,7 @@ UINT8 DetermineFlashbangEffect( SOLDIERTYPE *pSoldier, INT8 ubExplosionDir, BOOL
INT8 bNumTurns;
UINT16 usHeadItem1, usHeadItem2;
- bNumTurns = FindNumTurnsBetweenDirs(pSoldier->bDirection, ubExplosionDir);
+ bNumTurns = FindNumTurnsBetweenDirs(pSoldier->ubDirection, ubExplosionDir);
usHeadItem1 = pSoldier->inv[ HEAD1POS ].usItem;
usHeadItem2 = pSoldier->inv[ HEAD2POS ].usItem;
diff --git a/TileEngine/Isometric Utils.cpp b/TileEngine/Isometric Utils.cpp
index a30f038e..97faea3f 100644
--- a/TileEngine/Isometric Utils.cpp
+++ b/TileEngine/Isometric Utils.cpp
@@ -549,9 +549,9 @@ INT16 NewGridNo(INT16 sGridno, INT16 sDirInc)
}
-INT16 DirectionInc(INT16 sDirection)
+INT16 DirectionInc(UINT8 ubDirection)
{
- if ((sDirection < 0) || (sDirection > 7))
+ if ((ubDirection < 0) || (ubDirection > 7))
{
//#ifdef BETAVERSION
@@ -559,11 +559,11 @@ INT16 DirectionInc(INT16 sDirection)
//#endif
//direction = random(8); // replace garbage with random direction
- sDirection = 1;
+ ubDirection = 1;
}
- return(DirIncrementer[sDirection]);
+ return(DirIncrementer[ubDirection]);
}
BOOLEAN CellXYToScreenXY(INT16 sCellX, INT16 sCellY, INT16 *sScreenX, INT16 *sScreenY)
diff --git a/TileEngine/Isometric Utils.h b/TileEngine/Isometric Utils.h
index 9d64ec26..f5542e3a 100644
--- a/TileEngine/Isometric Utils.h
+++ b/TileEngine/Isometric Utils.h
@@ -42,7 +42,7 @@ void ConvertGridNoToCenterCellXY( INT16 sGridNo, INT16 *sXPos, INT16 *sYPos );
// GRID NO MANIPULATION FUNCTIONS
INT16 NewGridNo(INT16 sGridno, INT16 sDirInc);
-INT16 DirectionInc(INT16 sDirection);
+INT16 DirectionInc(UINT8 ubDirection);
INT32 OutOfBounds(INT16 sGridno, INT16 sProposedGridno);
diff --git a/TileEngine/Map Edgepoints.cpp b/TileEngine/Map Edgepoints.cpp
index a685d9db..e5e45b32 100644
--- a/TileEngine/Map Edgepoints.cpp
+++ b/TileEngine/Map Edgepoints.cpp
@@ -1166,7 +1166,7 @@ void ChooseMapEdgepoints( MAPEDGEPOINTINFO *pMapEdgepointInfo, UINT8 ubStrategic
psArray = psTempArray;
for (i = 0; i < usArraySize; i++)
{
- if (GetTerrainType(psArray[ i ]) == MED_WATER || GetTerrainType(psArray[ i ]) == DEEP_WATER)
+ if (TERRAIN_IS_HIGH_WATER( GetTerrainType(psArray[ i ]) ) )
{
if (i == usArraySize - 1)
{
diff --git a/TileEngine/SaveLoadMap.cpp b/TileEngine/SaveLoadMap.cpp
index 932ff743..66d5ef99 100644
--- a/TileEngine/SaveLoadMap.cpp
+++ b/TileEngine/SaveLoadMap.cpp
@@ -1145,6 +1145,7 @@ BOOLEAN ChangeStatusOfOpenableStructInUnloadedSector( UINT16 usSectorX, UINT16 u
if( uiNumBytesRead != uiFileSize )
{
FileClose( hFile );
+ MemFree( pTempArrayOfMaps);
return( FALSE );
}
@@ -1180,6 +1181,7 @@ BOOLEAN ChangeStatusOfOpenableStructInUnloadedSector( UINT16 usSectorX, UINT16 u
if( hFile == 0 )
{
//Error opening map modification file,
+ MemFree( pTempArrayOfMaps);
return( FALSE );
}
@@ -1188,11 +1190,14 @@ BOOLEAN ChangeStatusOfOpenableStructInUnloadedSector( UINT16 usSectorX, UINT16 u
if( uiNumBytesWritten != uiFileSize )
{
FileClose( hFile );
+ MemFree( pTempArrayOfMaps);
return( FALSE );
}
FileClose( hFile );
+ MemFree( pTempArrayOfMaps);
+
return( TRUE );
}
diff --git a/TileEngine/Smell.cpp b/TileEngine/Smell.cpp
index 6269da6c..1a3a76f0 100644
--- a/TileEngine/Smell.cpp
+++ b/TileEngine/Smell.cpp
@@ -359,14 +359,16 @@ void InternalDropBlood( INT16 sGridNo, INT8 bLevel, UINT8 ubType, UINT8 ubStreng
MAP_ELEMENT * pMapElement;
UINT8 ubOldStrength=0;
UINT8 ubNewStrength=0;
+ UINT8 bOverTerrainType;
/*
* Dropping some blood;
* We can check the type of blood by consulting the type in the smell byte
*/
+ bOverTerrainType = GetTerrainType( sGridNo);
// If we are in water...
- if ( GetTerrainType( sGridNo ) == DEEP_WATER || GetTerrainType( sGridNo ) == LOW_WATER || GetTerrainType( sGridNo ) == MED_WATER )
+ if ( TERRAIN_IS_WATER( bOverTerrainType) )
{
return;
}
diff --git a/TileEngine/Tactical Placement GUI.cpp b/TileEngine/Tactical Placement GUI.cpp
index 20eadc1d..58add8d6 100644
--- a/TileEngine/Tactical Placement GUI.cpp
+++ b/TileEngine/Tactical Placement GUI.cpp
@@ -831,6 +831,8 @@ void KillTacticalPlacementGUI()
ScreenMsg( FONT_RED, MSG_ERROR, L"Substituted different entry side due to invalid entry points or map edgepoints. KM, LC : 1" );
}
#endif
+
+ MemFree( gMercPlacement);
}
void ChooseRandomEdgepoints()
@@ -1178,7 +1180,7 @@ void PutDownMercPiece( INT32 iPlacement )
ConvertGridNoToCellXY( sGridNo, &sCellX, &sCellY );
EVENT_SetSoldierPosition( pSoldier, (FLOAT)sCellX, (FLOAT)sCellY );
EVENT_SetSoldierDirection( pSoldier, ubDirection );
- pSoldier->ubInsertionDirection = pSoldier->bDirection;
+ pSoldier->ubInsertionDirection = pSoldier->ubDirection;
gMercPlacement[ iPlacement ].fPlaced = TRUE;
gMercPlacement[ iPlacement ].pSoldier->bInSector = TRUE;
}
diff --git a/TileEngine/physics.cpp b/TileEngine/physics.cpp
index 32458e32..9489ac69 100644
--- a/TileEngine/physics.cpp
+++ b/TileEngine/physics.cpp
@@ -2297,7 +2297,7 @@ void CheckForObjectHittingMerc( REAL_OBJECT *pObject, UINT16 usStructureID )
sDamage = 1;
sBreath = 0;
- EVENT_SoldierGotHit( pSoldier, NOTHING, sDamage, sBreath, pSoldier->bDirection, 0, pObject->ubOwner, FIRE_WEAPON_TOSSED_OBJECT_SPECIAL, 0, 0, NOWHERE );
+ EVENT_SoldierGotHit( pSoldier, NOTHING, sDamage, sBreath, pSoldier->ubDirection, 0, pObject->ubOwner, FIRE_WEAPON_TOSSED_OBJECT_SPECIAL, 0, 0, NOWHERE );
pObject->ubLastTargetTakenDamage = (UINT8)( usStructureID );
}
diff --git a/TileEngine/renderworld.cpp b/TileEngine/renderworld.cpp
index e1847a60..e46c57d4 100644
--- a/TileEngine/renderworld.cpp
+++ b/TileEngine/renderworld.cpp
@@ -1602,7 +1602,7 @@ void RenderTiles(UINT32 uiFlags, INT32 iStartPointX_M, INT32 iStartPointY_M, INT
}
else
{
- sMultiTransShadowZBlitterIndex = gOneCDirection[ pSoldier->bDirection ];
+ sMultiTransShadowZBlitterIndex = gOneCDirection[ pSoldier->ubDirection ];
}
}
else
diff --git a/TileEngine/tiledef.h b/TileEngine/tiledef.h
index 68a542e9..3103f733 100644
--- a/TileEngine/tiledef.h
+++ b/TileEngine/tiledef.h
@@ -108,20 +108,20 @@ typedef struct
UINT8 bZOffsetY;
// This union contains different data based on tile type
- union
- {
+// union
+// {
// Land and overlay type
- struct
- {
+// struct
+// {
INT16 sOffsetHeight;
UINT16 usWallOrientation;
UINT8 ubFullTile;
// For animated tiles
TILE_ANIMATION_DATA *pAnimData;
- };
+// };
- };
+// };
// Reserved for added room and 32-byte boundaries
BYTE bReserved[ 3 ];
@@ -139,6 +139,10 @@ typedef struct
} land_undo_struct;
+#define TERRAIN_IS_WATER(x) ((x) == LOW_WATER || (x) == MED_WATER || (x) == DEEP_WATER)
+#define TERRAIN_IS_SHALLOW_WATER(x) ((x) == LOW_WATER || (x) == MED_WATER)
+#define TERRAIN_IS_HIGH_WATER(x) ((x) == MED_WATER || (x) == DEEP_WATER)
+#define TERRAIN_IS_DEEP_WATER(x) ((x) == DEEP_WATER)
// Globals used
extern TILE_ELEMENT gTileDatabase[ NUMBEROFTILES ];
diff --git a/TileEngine/worlddef.cpp b/TileEngine/worlddef.cpp
index 92b8d7c0..4eea227b 100644
--- a/TileEngine/worlddef.cpp
+++ b/TileEngine/worlddef.cpp
@@ -3295,6 +3295,9 @@ void TrashWorld( void )
}
}
+ // Reset attack busy since a militia might have been in the middle of radioing
+ gTacticalStatus.ubAttackBusyCount = 0;
+
RemoveCorpses( );
// Remove all ani tiles...
diff --git a/TileEngine/worldman.cpp b/TileEngine/worldman.cpp
index 10d79a73..5c56d150 100644
--- a/TileEngine/worldman.cpp
+++ b/TileEngine/worldman.cpp
@@ -2208,18 +2208,18 @@ BOOLEAN AddMercStructureInfoFromAnimSurface( INT16 sGridNo, SOLDIERTYPE *pSoldie
}
else
{
- fReturn = AddStructureToWorld( sGridNo, pSoldier->bLevel, &( pStructureFileRef->pDBStructureRef[ gOneCDirection[ pSoldier->bDirection ] ] ), pSoldier->pLevelNode );
+ fReturn = AddStructureToWorld( sGridNo, pSoldier->bLevel, &( pStructureFileRef->pDBStructureRef[ gOneCDirection[ pSoldier->ubDirection ] ] ), pSoldier->pLevelNode );
}
/*
if ( fReturn == FALSE )
{
// try to add default
- ScreenMsg( MSG_FONT_YELLOW, MSG_DEBUG, L"FAILED: add struct info for merc: %d, at %d direction %d, trying default instead", pSoldier->ubID, sGridNo, pSoldier->bDirection );
+ ScreenMsg( MSG_FONT_YELLOW, MSG_DEBUG, L"FAILED: add struct info for merc: %d, at %d direction %d, trying default instead", pSoldier->ubID, sGridNo, pSoldier->ubDirection );
pStructureFileRef = GetDefaultStructureRef( pSoldier->ubID );
if ( pStructureFileRef )
{
- fReturn = AddStructureToWorld( sGridNo, pSoldier->bLevel, &( pStructureFileRef->pDBStructureRef[ gOneCDirection[ pSoldier->bDirection ] ] ), pSoldier->pLevelNode );
+ fReturn = AddStructureToWorld( sGridNo, pSoldier->bLevel, &( pStructureFileRef->pDBStructureRef[ gOneCDirection[ pSoldier->ubDirection ] ] ), pSoldier->pLevelNode );
}
}
*/
@@ -2228,9 +2228,9 @@ BOOLEAN AddMercStructureInfoFromAnimSurface( INT16 sGridNo, SOLDIERTYPE *pSoldie
{
// Debug msg
- ScreenMsg( MSG_FONT_RED, MSG_DEBUG, L"FAILED: add struct info for merc %d (%s), at %d direction %d", pSoldier->ubID, pSoldier->name, sGridNo, pSoldier->bDirection );
+ ScreenMsg( MSG_FONT_RED, MSG_DEBUG, L"FAILED: add struct info for merc %d (%s), at %d direction %d", pSoldier->ubID, pSoldier->name, sGridNo, pSoldier->ubDirection );
- if ( pStructureFileRef->pDBStructureRef[ gOneCDirection[ pSoldier->bDirection ] ].pDBStructure->ubNumberOfTiles > 1 )
+ if ( pStructureFileRef->pDBStructureRef[ gOneCDirection[ pSoldier->ubDirection ] ].pDBStructure->ubNumberOfTiles > 1 )
{
// If we have more than one tile
pSoldier->uiStatusFlags |= SOLDIER_MULTITILE_Z;
@@ -3441,7 +3441,7 @@ BOOLEAN Water( INT16 sGridNo )
}
pMapElement = &(gpWorldLevelData[sGridNo]);
- if ( pMapElement->ubTerrainID == LOW_WATER || pMapElement->ubTerrainID == MED_WATER || pMapElement->ubTerrainID == DEEP_WATER )
+ if ( TERRAIN_IS_WATER( pMapElement->ubTerrainID) )
{
// check for a bridge! otherwise...
return( TRUE );
@@ -3457,7 +3457,7 @@ BOOLEAN DeepWater( INT16 sGridNo )
MAP_ELEMENT * pMapElement;
pMapElement = &(gpWorldLevelData[sGridNo]);
- if (pMapElement->ubTerrainID == DEEP_WATER)
+ if (TERRAIN_IS_DEEP_WATER( pMapElement->ubTerrainID) )
{
// check for a bridge! otherwise...
return( TRUE );
diff --git a/gameloop.cpp b/gameloop.cpp
index 43796aee..13865f21 100644
--- a/gameloop.cpp
+++ b/gameloop.cpp
@@ -169,6 +169,8 @@ void ShutdownGame(void)
InitTacticalSave( FALSE );
ShutdownLua( );
+
+ FreeGameExternalOptions();
}
diff --git a/gamescreen.cpp b/gamescreen.cpp
index 623c90a1..20feea77 100644
--- a/gamescreen.cpp
+++ b/gamescreen.cpp
@@ -848,6 +848,7 @@ UINT32 MainGameScreenHandle(void)
if ( gfScrollPending )
{
+ DeleteVideoOverlaysArea( );
AllocateVideoOverlaysArea( );
SaveVideoOverlaysArea( FRAME_BUFFER );
ExecuteVideoOverlays( );
diff --git a/ja2_2005Express.vcproj b/ja2_2005Express.vcproj
index 5dd7fe3b..3f2949ec 100644
--- a/ja2_2005Express.vcproj
+++ b/ja2_2005Express.vcproj
@@ -345,6 +345,10 @@
RelativePath=".\ja2.h"
>
+
+
diff --git a/lua/lua.cpp b/lua/lua.cpp
index 13411d0a..81425328 100644
--- a/lua/lua.cpp
+++ b/lua/lua.cpp
@@ -256,6 +256,31 @@ int LuaSetSoldierGrid( lua_State *L )
return 0;
}
+int LuaGetSoldierAPs( lua_State *L )
+{
+ SOLDIERTYPE **ppSoldier = (SOLDIERTYPE**) lua_touserdata( L, 1 );
+ SOLDIERTYPE *pSoldier = *ppSoldier;
+ if (!pSoldier)
+ {
+ lua_pushnil( L );
+ }
+ else
+ {
+ lua_pushinteger( L, pSoldier->bActionPoints);
+ }
+ return 1;
+}
+
+int LuaSetSoldierAPs( lua_State *L )
+{
+ SOLDIERTYPE **ppSoldier = (SOLDIERTYPE**) lua_touserdata( L, 1 );
+ SOLDIERTYPE *pSoldier = *ppSoldier;
+ int newaps = luaL_checkinteger( L, 3);
+ luaL_argcheck( L, newaps > 0 && newaps < 256, 2, "The grid number must be on screen!" );
+ pSoldier->bActionPoints = (INT8) newaps;
+ return 0;
+}
+
int LuaSoldierWalkTo( lua_State *L )
{
SOLDIERTYPE **ppSoldier = (SOLDIERTYPE**) luaL_checkudata( L, 1, SOLDIER_CLASS );
@@ -282,12 +307,23 @@ int LuaSoldierRunTo( lua_State *L )
return 0;
}
+int LuaSoldierChangeStance( lua_State *L )
+{
+ SOLDIERTYPE **ppSoldier = (SOLDIERTYPE**) luaL_checkudata( L, 1, SOLDIER_CLASS );
+ SOLDIERTYPE *pSoldier = *ppSoldier;
+ int newstance = luaL_checkinteger( L, 2);
+ ChangeSoldierStance( pSoldier, (UINT8) newstance);
+ return 0;
+}
+
LuaAttrib Soldier[] = {
{ "name", LuaGetSoldierName, },
{ "fullname", LuaGetSoldierFullName, },
{ "grid", LuaGetSoldierGrid, LuaSetSoldierGrid },
+ { "APs", LuaGetSoldierAPs, LuaSetSoldierAPs },
{ "walkto", NULL, NULL, LuaSoldierWalkTo },
{ "runto", NULL, NULL, LuaSoldierRunTo },
+ { "changestance", NULL, NULL, LuaSoldierChangeStance },
{ NULL, },
};
diff --git a/lua/lwstring.cpp b/lua/lwstring.cpp
index 81b4c539..3b92a463 100644
--- a/lua/lwstring.cpp
+++ b/lua/lwstring.cpp
@@ -13,7 +13,7 @@ void luaWS_newlstr (lua_State *L, const CHAR16 *str, size_t l)
int size = sizewstring( l);
ts = (TWString*) lua_newuserdata( L, size );
ts->len = l;
- memcpy( ts->data, str, size);
+ memcpy( ts->data, str, l*sizeof(CHAR16)+sizeof(CHAR16));
// Make this data a wstring
luaL_getmetatable(L, "wstring");