From 6ec2c5da7d55cedf3326ac4a86807f12eb992f06 Mon Sep 17 00:00:00 2001 From: Overhaul Date: Mon, 13 Aug 2007 03:39:54 +0000 Subject: [PATCH] Initialized many variables Fix for enemy invasions and reinforcements git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1192 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Console/Console.cpp | 58 +- Console/Console_2005Express.vcproj | 3 +- Console/FileStream.cpp | 2 +- Editor/Editor Callbacks.cpp | 1 + Editor/EditorBuildings.cpp | 2 +- Editor/EditorItems.cpp | 2 +- Editor/EditorMercs.cpp | 13 +- Editor/Editor_2005Express.vcproj | 3 +- Editor/Item Statistics.cpp | 6 +- Editor/LoadScreen.cpp | 32 +- Editor/edit_sys.cpp | 4 +- Editor/editscreen.cpp | 6 +- Editor/newsmooth.cpp | 17 +- Editor/popupmenu.cpp | 3 + Editor/selectwin.cpp | 29 +- Laptop/IMP MainPage.cpp | 5 + Laptop/Laptop_2005Express.vcproj | 3 +- Laptop/finances.cpp | 4 +- Standard Gaming Platform/Button System.cpp | 2 +- Standard Gaming Platform/DbMan.cpp | 2 +- Standard Gaming Platform/DirectDraw Calls.cpp | 4 +- Standard Gaming Platform/MemMan.cpp | 2 +- .../SGP_2005Express.vcproj | 3 +- Standard Gaming Platform/sgp.cpp | 2 + Standard Gaming Platform/vsurface.cpp | 774 ++++---- Strategic/AI Viewer.cpp | 2 +- Strategic/Assignments.cpp | 4 +- Strategic/Creature Spreading.cpp | 2 +- Strategic/Hourly Update.cpp | 2 +- Strategic/Map Screen Helicopter.cpp | 768 ++++---- Strategic/Map Screen Interface Map.cpp | 3 + Strategic/Meanwhile.cpp | 1 + Strategic/PreBattle Interface.cpp | 2 +- Strategic/Queen Command.cpp | 6 + Strategic/Reinforcement.cpp | 229 +-- Strategic/Strategic Turns.cpp | 3 + Strategic/Strategic_2005Express.vcproj | 3 +- Strategic/strategicmap.cpp | 2 +- Tactical/Dialogue Control.cpp | 2 +- Tactical/Enemy Soldier Save.cpp | 2 +- Tactical/Handle Doors.cpp | 2 +- Tactical/Handle Items.cpp | 267 +-- Tactical/Handle Items.h | 2 +- Tactical/Interface Dialogue.cpp | 2 +- Tactical/Interface Items.cpp | 45 +- Tactical/Interface Panels.cpp | 2 +- Tactical/Interface.cpp | 44 +- Tactical/LOS.cpp | 2 + Tactical/Militia Control.cpp | 2 +- Tactical/Overhead.cpp | 5 +- Tactical/PATHAI.cpp | 1718 ++++++++--------- Tactical/Points.cpp | 980 +++++----- Tactical/Soldier Init List.cpp | 8 +- Tactical/Soldier Tile.cpp | 2 +- Tactical/Spread Burst.cpp | 2 +- Tactical/Tactical_2005Express.vcproj | 3 +- Tactical/Weapons.cpp | 2 +- Tactical/bullets.cpp | 2 + Tactical/opplist.cpp | 2 +- TacticalAI/AIUtils.cpp | 2 +- TacticalAI/Attacks.cpp | 4 +- TacticalAI/CreatureDecideAction.cpp | 2 +- TacticalAI/DecideAction.cpp | 31 +- TacticalAI/FindLocations.cpp | 2 +- TacticalAI/Medical.cpp | 4 +- TacticalAI/NPC.cpp | 7 +- TacticalAI/TacticalAI_2005Express.vcproj | 3 +- TileEngine/Explosion Control.cpp | 6 +- TileEngine/TileEngine_2005Express.vcproj | 3 +- TileEngine/physics.cpp | 8 +- TileEngine/renderworld.cpp | 6 +- TileEngine/structure.cpp | 2 +- Utils/STIConvert.cpp | 2 +- Utils/Utils_2005Express.vcproj | 3 +- Utils/WordWrap.cpp | 2 +- ja2_2005Express.vcproj | 3 +- lua/lua.cpp | 2 + lua/lua_2005Express.vcproj | 3 +- lua/lwstring.cpp | 5 +- 79 files changed, 2621 insertions(+), 2584 deletions(-) diff --git a/Console/Console.cpp b/Console/Console.cpp index 49aa27e7..d07c4bc4 100644 --- a/Console/Console.cpp +++ b/Console/Console.cpp @@ -645,13 +645,13 @@ void Console::OnVScroll(WPARAM wParam) { return; } - if (nDelta = max(-nCurrentPos, min(nDelta, (int)(m_dwBufferRows-m_dwRows) - nCurrentPos))) { + if ((nDelta = max(-nCurrentPos, min(nDelta, (int)(m_dwBufferRows-m_dwRows) - nCurrentPos))) != 0) { nCurrentPos += nDelta; SMALL_RECT sr; - sr.Top = nCurrentPos; - sr.Bottom = nDelta; + sr.Top = (short) nCurrentPos; +// sr.Bottom = nDelta; sr.Left = sr.Right = 0; m_csbiConsole.srWindow = sr; // ::SetConsoleWindowInfo(m_hStdOutFresh, FALSE, &sr); @@ -825,6 +825,7 @@ void Console::OnMButtonDown(UINT uiFlags, POINTS points) { void Console::OnMouseMove(UINT uiFlags, POINTS points) { +#if 0 RECT windowRect; int deltaX, deltaY; POINT point; @@ -905,6 +906,7 @@ void Console::OnMouseMove(UINT uiFlags, POINTS points) { } } } +#endif } ///////////////////////////////////////////////////////////////////////////// @@ -2697,11 +2699,12 @@ void Console::SetWindowSizeAndPosition() { break; } - HWND hwndZ; + HWND hwndZ = 0; switch (m_dwCurrentZOrder) { case Z_ORDER_REGULAR : hwndZ = HWND_NOTOPMOST; break; case Z_ORDER_ONTOP : hwndZ = HWND_TOPMOST; break; case Z_ORDER_ONBOTTOM : hwndZ = HWND_BOTTOM; break; + default : return; } ::SetWindowPos( @@ -2769,7 +2772,7 @@ BOOL Console::SetTrayIcon(DWORD dwMessage) { if (strToolTip.length() > 63) { strToolTip.resize(59); strToolTip += _T(" ..."); - DWORD dw = strToolTip.length(); +// DWORD dw = strToolTip.length(); } _tcscpy(tnd.szTip, strToolTip.c_str()); @@ -2804,7 +2807,7 @@ void Console::EditConfigFile() { // no params, just use the config file strParams = m_strConfigFile; } else { - int nPos = strParams.find(_T("%f")); + tstring::size_type nPos = strParams.find(_T("%f")); if (nPos == tstring::npos) { // no '%f' in editor params, concatenate config file name @@ -3190,8 +3193,8 @@ void Console::InitConsoleWndSize(DWORD dwColumns) { SMALL_RECT srConsoleRect; srConsoleRect.Top = srConsoleRect.Left =0; - srConsoleRect.Right = dwColumns - 1; - srConsoleRect.Bottom= m_dwRows - 1; +// srConsoleRect.Right = dwColumns - 1; +// srConsoleRect.Bottom= m_dwRows - 1; #if 0 CONSOLE_SCREEN_BUFFER_INFO csbi; @@ -3230,8 +3233,8 @@ void Console::ResizeConsoleWindow() { SMALL_RECT srConsoleRect; srConsoleRect.Top = srConsoleRect.Left =0; - srConsoleRect.Right = m_dwColumns - 1; - srConsoleRect.Bottom= m_dwRows - 1; +// srConsoleRect.Right = m_dwColumns - 1; +// srConsoleRect.Bottom= m_dwRows - 1; #if 0 // order of setting window size and screen buffer size depends on current and desired dimensions @@ -3311,9 +3314,9 @@ void Console::RepaintWindow() { COLORREF crBkColor = RGB(0, 0, 0); COLORREF crTxtColor = RGB(0, 0, 0); - int nNewBkMode = TRANSPARENT; - COLORREF crNewBkColor = RGB(0, 0, 0); - COLORREF crNewTxtColor = RGB(0, 0, 0); +// int nNewBkMode = TRANSPARENT; +// COLORREF crNewBkColor = RGB(0, 0, 0); +// COLORREF crNewTxtColor = RGB(0, 0, 0); bool bTextOut = false; @@ -3635,7 +3638,7 @@ inline void Console::GetCursorRect(RECT& rectCursor) { auto_ptr pszLine(new wchar_t[m_csbiCursor.dwCursorPosition.X + 2]); ::ZeroMemory(pszLine.get(), (m_csbiCursor.dwCursorPosition.X + 2)*sizeof(wchar_t)); - for (DWORD i = 0; i <= m_csbiCursor.dwCursorPosition.X; ++i) pszLine.get()[i] = m_pScreenBuffer[m_csbiCursor.dwCursorPosition.Y * m_dwColumns + i].Char.UnicodeChar; + for (short i = 0; i <= m_csbiCursor.dwCursorPosition.X; ++i) pszLine.get()[i] = m_pScreenBuffer[m_csbiCursor.dwCursorPosition.Y * m_dwColumns + i].Char.UnicodeChar; rectLine.left = rectLine.right = 0; rectLine.top = rectLine.bottom = m_csbiCursor.dwCursorPosition.Y * m_nCharHeight; @@ -3676,7 +3679,7 @@ inline void Console::DrawCursorBackground(RECT& rectCursor) { GetCursorRect(rectCursor); if (m_csbiCursor.dwCursorPosition.Y < m_csbiConsole.srWindow.Top || - m_csbiCursor.dwCursorPosition.Y >= m_csbiConsole.srWindow.Top + m_dwRows) { + m_csbiCursor.dwCursorPosition.Y >= m_csbiConsole.srWindow.Top + (SHORT) m_dwRows) { return; } @@ -3810,11 +3813,12 @@ void Console::ToggleWindowOnTop() { m_dwCurrentZOrder = m_dwOriginalZOrder; } - HWND hwndZ; + HWND hwndZ = 0; switch (m_dwCurrentZOrder) { case Z_ORDER_REGULAR : hwndZ = HWND_NOTOPMOST; break; case Z_ORDER_ONTOP : hwndZ = HWND_TOPMOST; break; case Z_ORDER_ONBOTTOM : hwndZ = HWND_BOTTOM; break; + default : return; } ::SetWindowPos( @@ -4098,7 +4102,7 @@ void Console::ShowReadmeFile() { // no params, just use the readme file strParams = m_strReadmeFile; } else { - int nPos = strParams.find(_T("%f")); + tstring::size_type nPos = strParams.find(_T("%f")); if (nPos == tstring::npos) { // no '%f' in editor params, concatenate readme file name @@ -4148,7 +4152,7 @@ void Console::SendTextToConsole(const wchar_t *pszText) { RECT rectInval; int cursorX; int cursorY; - int attr = m_nTextColor + (m_nTextBgColor << 4); + WORD attr = (WORD)(m_nTextColor + (m_nTextBgColor << 4)); cursorX = m_csbiCursor.dwCursorPosition.X * m_nCharWidth + m_nInsideBorder; cursorY = m_csbiCursor.dwCursorPosition.Y * m_nCharHeight + m_nInsideBorder; @@ -4183,7 +4187,7 @@ void Console::SendTextToConsole(const wchar_t *pszText) { OnVScroll( SB_LINEUP); } m_csbiCursor.dwCursorPosition.Y--; - m_csbiCursor.dwCursorPosition.X = m_dwColumns - 1; + m_csbiCursor.dwCursorPosition.X = (SHORT)m_dwColumns - 1; cursorX = m_nCharWidth * m_csbiCursor.dwCursorPosition.X; idx--; } @@ -4196,17 +4200,17 @@ void Console::SendTextToConsole(const wchar_t *pszText) { m_csbiCursor.dwCursorPosition.X++; } - if (m_csbiCursor.dwCursorPosition.X >= m_dwColumns || *pszText == '\r' || *pszText == '\n' ) { + if (m_csbiCursor.dwCursorPosition.X >= (SHORT) m_dwColumns || *pszText == '\r' || *pszText == '\n' ) { m_csbiCursor.dwCursorPosition.X = 0; cursorX = m_nInsideBorder; if (*pszText != '\r') { m_csbiCursor.dwCursorPosition.Y++; - if (m_csbiCursor.dwCursorPosition.Y >= m_dwBufferRows) { + if (m_csbiCursor.dwCursorPosition.Y >= (SHORT)m_dwBufferRows) { m_csbiCursor.dwCursorPosition.Y--; idx = m_csbiCursor.dwCursorPosition.X + m_csbiCursor.dwCursorPosition.Y * m_dwColumns; ::CopyMemory( m_pScreenBufferNew, m_pScreenBufferNew + m_dwColumns, idx * sizeof( CHAR_INFO)); ::ZeroMemory( m_pScreenBufferNew + idx, m_dwColumns * sizeof( CHAR_INFO)); - } else if (m_csbiCursor.dwCursorPosition.Y == m_csbiConsole.srWindow.Top + m_dwRows) { + } else if (m_csbiCursor.dwCursorPosition.Y == m_csbiConsole.srWindow.Top + (SHORT)m_dwRows) { OnVScroll( SB_LINEDOWN); } else { cursorY += m_nCharHeight; @@ -4429,7 +4433,7 @@ LRESULT CALLBACK Console::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM #endif case WM_CHAR: - myself->OnChar( wParam); + myself->OnChar( (WORD) wParam); break; case WM_KEYDOWN: @@ -4511,12 +4515,12 @@ DWORD WINAPI Console::MonitorThreadStatic(LPVOID lpParam) { DWORD Console::MonitorThread() { // HANDLE arrHandles[] = {m_hConsoleProcess, m_hQuitEvent, m_hStdOut}; - HANDLE arrHandles[] = { m_hStdOut}; +// HANDLE arrHandles[] = { m_hStdOut}; - while (1) { + for (;;) { // Infinite loop +#if 0 DWORD dwWait = ::WaitForMultipleObjects(1, arrHandles, FALSE, INFINITE); -#if 0 if (dwWait == WAIT_OBJECT_0) { ::PostMessage(m_hWnd, WM_CLOSE, 0, 0); break; @@ -4532,7 +4536,7 @@ DWORD Console::MonitorThread() { // } } - return 0; +// return 0; } ///////////////////////////////////////////////////////////////////////////// diff --git a/Console/Console_2005Express.vcproj b/Console/Console_2005Express.vcproj index 60967431..c3c7a558 100644 --- a/Console/Console_2005Express.vcproj +++ b/Console/Console_2005Express.vcproj @@ -61,9 +61,10 @@ AssemblerListingLocation=".\Debug/" ObjectFile=".\Debug/" ProgramDataBaseFileName=".\Debug/" - WarningLevel="3" + WarningLevel="4" SuppressStartupBanner="true" DebugInformationFormat="4" + DisableSpecificWarnings="4100" /> uiFlags & BUTTON_CLICKED_ON ) ) @@ -1528,6 +1529,7 @@ void ReEvaluateAttachmentStatii() case 3: usAttachment = BIPOD; break; case 4: usAttachment = DUCKBILL; break; case 5: usAttachment = UNDER_GLAUNCHER; break; + default: Assert(0); continue; } if( ValidItemAttachment( gpItem, usAttachment, TRUE ) ) EnableButton( guiAttachmentButton[ i ] ); diff --git a/Editor/LoadScreen.cpp b/Editor/LoadScreen.cpp index 2850eab8..ff0f274d 100644 --- a/Editor/LoadScreen.cpp +++ b/Editor/LoadScreen.cpp @@ -1067,31 +1067,13 @@ BOOLEAN ExtractFilenameFromFields() BOOLEAN ValidCoordinate() { - if( gzFilename[0] >= 'A' && gzFilename[0] <= 'P' || - gzFilename[0] >= 'a' && gzFilename[0] <='p' ) - { - UINT16 usTotal; - if( gzFilename[1] == '1' && gzFilename[2] >= '0' && gzFilename[2] <= '6' ) - { - usTotal = ( gzFilename[1] - 0x30 ) * 10 + ( gzFilename[2] - 0x30 ); - } - else if( gzFilename[1] >= '1' && gzFilename[1] <= '9') - { - if( gzFilename[2] < '0' || gzFilename[2] > '9' ) - { - usTotal = ( gzFilename[1] - 0x30 ); - } - else - { - return FALSE; - } - } - if( usTotal >= 1 && usTotal <= 16 ) - { - return TRUE; - } - } - return FALSE; + CHAR16 sectorY = 0; + UINT16 sectorX = 0; + swscanf( gzFilename, L"%c%2hd", §orY, §orX); + + sectorY = towupper( sectorY); + return ( sectorY >= 'A' && sectorY <= 'P' && + sectorX >= 1 && sectorX <= 16); } BOOLEAN ValidFilename() diff --git a/Editor/edit_sys.cpp b/Editor/edit_sys.cpp index 0903fe5c..049b6573 100644 --- a/Editor/edit_sys.cpp +++ b/Editor/edit_sys.cpp @@ -541,7 +541,7 @@ void PasteStructure2( UINT32 iMapIndex ) // void PasteStructureCommon( UINT32 iMapIndex ) { - BOOLEAN fDoPaste = FALSE; +// BOOLEAN fDoPaste = FALSE; UINT32 fHeadType; UINT16 usUseIndex; UINT16 usUseObjIndex; @@ -1181,13 +1181,13 @@ void RaiseWorldLand( ) if (pTileElement->fType==FIRSTCLIFF) { fSomethingRaised = TRUE; + usIndex=pStruct->usIndex; // DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("Cliff found at count=%d",cnt)); if( pTileElement->ubNumberOfTiles > 1 ) { // DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("Cliff has %d children", pTileElement->ubNumberOfTiles)); for (ubLoop = 0; ubLoop < pTileElement->ubNumberOfTiles; ubLoop++) { - usIndex=pStruct->usIndex; // need means to turn land raising on and off based on the tile ID and the offset in the // tile database when reading into the mapsystem // turning off of land raising can only be done diff --git a/Editor/editscreen.cpp b/Editor/editscreen.cpp index 07919697..00b6a79c 100644 --- a/Editor/editscreen.cpp +++ b/Editor/editscreen.cpp @@ -2809,9 +2809,9 @@ BOOLEAN RemoveLight( INT16 iMapX, INT16 iMapY ) SOLDIERTYPE *pSoldier; BOOLEAN fSoldierLight; BOOLEAN fRemovedLight; - INT32 iMapIndex; - UINT32 uiLastLightType; - UINT8 *pLastLightName; + INT32 iMapIndex = 0; + UINT32 uiLastLightType = 0; + UINT8 *pLastLightName = NULL; fRemovedLight = FALSE; diff --git a/Editor/newsmooth.cpp b/Editor/newsmooth.cpp index 1369b3a4..d0a1bf65 100644 --- a/Editor/newsmooth.cpp +++ b/Editor/newsmooth.cpp @@ -217,6 +217,9 @@ UINT16 GetCaveTileIndexFromPerimeterValue( UINT8 ubTotal ) case 0xff: usIndex = 60 + (UINT16)Random( 6 ); break; + default: + AssertMsg(0, "Invalid total given"); + return 0xffff; } GetTileIndexFromTypeSubIndex( usType, usIndex, &usTileIndex ); return usTileIndex; @@ -447,6 +450,7 @@ void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType ) switch( ubWallPiece ) { case EXTERIOR_TOP: + ubWallClass = EXTERIOR_L; iMapIndex -= WORLD_COLS; //exterior bottom left corner generated if ( !gfBasement && GetVerticalWall( iMapIndex - 1) && !GetVerticalWall( iMapIndex + WORLD_COLS - 1) ) @@ -464,7 +468,6 @@ void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType ) GetTileIndexFromTypeSubIndex( usWallType, sIndex, &usTileIndex ); ReplaceStructIndex( iMapIndex, pStruct->usIndex, usTileIndex ); } - ubWallClass = EXTERIOR_L; if( !gfBasement ) { //All exterior_l walls have shadows. @@ -483,8 +486,8 @@ void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType ) } break; case EXTERIOR_LEFT: - iMapIndex--; ubWallClass = EXTERIOR_R; + iMapIndex--; if( GetHorizontalWall( iMapIndex ) ) { //Special case where placing the new wall will generate a corner. This piece //becomes an exterior bottomend, but nothing else is effected. @@ -510,8 +513,8 @@ void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType ) } break; case INTERIOR_TOP: - iMapIndex -= WORLD_COLS; ubWallClass = INTERIOR_L; + iMapIndex -= WORLD_COLS; //check for a lower left corner. if( pStruct = GetVerticalWall( iMapIndex + WORLD_COLS - 1 ) ) { //Replace the piece with an extended piece. @@ -554,8 +557,8 @@ void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType ) } break; case INTERIOR_LEFT: - iMapIndex--; ubWallClass = INTERIOR_R; + iMapIndex--; if( GetHorizontalWall( iMapIndex ) ) { ubWallClass = INTERIOR_BOTTOMEND; @@ -595,6 +598,10 @@ void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType ) AddExclusiveShadow( iMapIndex, usTileIndex ); } break; + default: + AssertMsg( 0, "Invalid wall piece"); + return; + } sIndex = PickAWallPiece( ubWallClass ); GetTileIndexFromTypeSubIndex( usWallType, sIndex, &usTileIndex ); @@ -980,6 +987,8 @@ void AddBuildingSectionToWorld( SGPRect *pSelectRegion ) //change the floor for say a kitchen which might have a different floor type. usWallType = GetRandomIndexByRange( FIRSTWALL, LASTWALL ); usFloorType = GetRandomIndexByRange( FIRSTFLOOR, LASTFLOOR ); + usRoofType = 0xffff; + if( usWallType == 0xffff && usFloorType != 0xffff ) { //allow user to place floors for( y = top; y <= bottom; y++ ) for( x = left; x <= right; x++ ) diff --git a/Editor/popupmenu.cpp b/Editor/popupmenu.cpp index 30cad810..daa13718 100644 --- a/Editor/popupmenu.cpp +++ b/Editor/popupmenu.cpp @@ -125,6 +125,9 @@ void InitPopupMenu( INT32 iButtonID, UINT8 ubPopupMenuID, UINT8 ubDirection ) usX = button->Area.RegionBottomRightX; usY = button->Area.RegionBottomRightY; break; + default: + AssertMsg(0, "Invalid direction given"); + return; } //Decipher the popupMenuID diff --git a/Editor/selectwin.cpp b/Editor/selectwin.cpp index 39d4399c..2e86598b 100644 --- a/Editor/selectwin.cpp +++ b/Editor/selectwin.cpp @@ -346,6 +346,10 @@ void CreateJA2SelectionWindow( INT16 sWhat ) pSelList = SelRoom; pNumSelList = &iNumRoomsSelected; break; + default: + // If none of these, don't create anything! + AssertMsg( 0, "Unknown window creation type"); + return; } BuildDisplayWindow( pDSpec, usNSpecs, &pDispList, &SelWinStartPoint, &SelWinEndPoint, @@ -1086,21 +1090,19 @@ void DisplaySelectionWindowGraphicalInformation() // void AddToSelectionList( DisplayList *pNode ) { - INT32 iIndex, iUseIndex; - BOOLEAN fDone; + INT32 iIndex, iUseIndex = -1; - fDone = FALSE; - for (iIndex = 0; iIndex < (*pNumSelList) && !fDone; iIndex++ ) + for (iIndex = 0; iIndex < (*pNumSelList); iIndex++ ) { if ( pNode->uiObjIndx == pSelList[ iIndex ].uiObject && pNode->uiIndex == pSelList[ iIndex ].usIndex ) { - fDone = TRUE; iUseIndex = iIndex; + break; } } - - if ( fDone ) + + if ( iUseIndex >= 0 ) { // Was already in the list, so bump up the count pSelList[ iUseIndex ].sCount++; @@ -1158,26 +1160,25 @@ BOOLEAN ClearSelectionList( void ) // BOOLEAN RemoveFromSelectionList( DisplayList *pNode ) { - INT32 iIndex, iUseIndex; - BOOLEAN fDone, fRemoved; + INT32 iIndex, iUseIndex = -1; + BOOLEAN fRemoved; // Abort if no entries in list (pretend we removed a node) if ( (*pNumSelList) <= 0 ) return( TRUE ); fRemoved = FALSE; - fDone = FALSE; - for (iIndex = 0; iIndex < (*pNumSelList) && !fDone; iIndex++ ) + for (iIndex = 0; iIndex < (*pNumSelList); iIndex++ ) { if ( pNode->uiObjIndx == pSelList[ iIndex ].uiObject && pNode->uiIndex == pSelList[ iIndex ].usIndex ) { - fDone = TRUE; iUseIndex = iIndex; + break; } } - if ( fDone ) + if ( iUseIndex >= 0 ) { // Was already in the list, so bump up the count pSelList[ iUseIndex ].sCount--; @@ -1613,7 +1614,7 @@ BOOLEAN DisplayWindowFunc( DisplayList *pNode, INT16 iTopCutOff, INT16 iBottomCu fReturnVal = FALSE; if (DisplayWindowFunc(pNode->pNext, iTopCutOff, iBottomCutOff, pUpperLeft, fFlags)) { - iCurrY = pUpperLeft->iY + pNode->iY - iTopCutOff; + iCurrY = (INT16) pUpperLeft->iY + pNode->iY - iTopCutOff; if ( iCurrY > iBottomCutOff ) return(TRUE); diff --git a/Laptop/IMP MainPage.cpp b/Laptop/IMP MainPage.cpp index 5247f260..1be324ac 100644 --- a/Laptop/IMP MainPage.cpp +++ b/Laptop/IMP MainPage.cpp @@ -1079,6 +1079,11 @@ INT32 GetFreeIMPSlot(INT32 iIMPId, INT32 iDefaultIMPId) iStart = GetFirstMaleSlot(); iEnd = GetLastMaleSlot(); } + else + { + AssertMsg( 0, "Merc neither male nor female"); + return -1; + } // Find a free imp slot for (i = iStart; i <= iEnd; ++i) diff --git a/Laptop/Laptop_2005Express.vcproj b/Laptop/Laptop_2005Express.vcproj index 6b69e3f4..aa17655a 100644 --- a/Laptop/Laptop_2005Express.vcproj +++ b/Laptop/Laptop_2005Express.vcproj @@ -46,8 +46,9 @@ RuntimeLibrary="1" RuntimeTypeInfo="false" UsePrecompiledHeader="0" - WarningLevel="3" + WarningLevel="4" DebugInformationFormat="4" + DisableSpecificWarnings="4100" /> iIconID >= 0) diff --git a/Standard Gaming Platform/DbMan.cpp b/Standard Gaming Platform/DbMan.cpp index 64f9a4f7..5b9ff1be 100644 --- a/Standard Gaming Platform/DbMan.cpp +++ b/Standard Gaming Platform/DbMan.cpp @@ -469,7 +469,7 @@ void DbClose( HDBINDEX hFile ) HDBFILE DbFileOpen( STR strFilename ) { HDBFILE hFile; - HFILEINDEX hFileIndex; + HFILEINDEX hFileIndex = 0xffff; HDBINDEX hDBIndex; UINT16 i; diff --git a/Standard Gaming Platform/DirectDraw Calls.cpp b/Standard Gaming Platform/DirectDraw Calls.cpp index 2634d2a1..97eebc4f 100644 --- a/Standard Gaming Platform/DirectDraw Calls.cpp +++ b/Standard Gaming Platform/DirectDraw Calls.cpp @@ -451,8 +451,8 @@ HRESULT BltFastDDSurfaceUsingSoftware( LPDIRECTDRAWSURFACE2 pDestSurface, INT32 HRESULT BltDDSurfaceUsingSoftware( LPDIRECTDRAWSURFACE2 pDestSurface, LPRECT pDestRect, LPDIRECTDRAWSURFACE2 pSrcSurface, LPRECT pSrcRect, UINT32 uiFlags, LPDDBLTFX pDDBltFx ) { DDSURFACEDESC SurfaceDescription; - UINT32 uiDestPitchBYTES, uiSrcPitchBYTES; - UINT8 *pDestBuf, *pSrcBuf; + UINT32 uiDestPitchBYTES, uiSrcPitchBYTES = 0; + UINT8 *pDestBuf, *pSrcBuf = NULL; HRESULT ReturnCode; DDCOLORKEY ColorKey; UINT16 us16BPPColorKey; diff --git a/Standard Gaming Platform/MemMan.cpp b/Standard Gaming Platform/MemMan.cpp index 4db39fbc..9ffd8888 100644 --- a/Standard Gaming Platform/MemMan.cpp +++ b/Standard Gaming Platform/MemMan.cpp @@ -306,7 +306,7 @@ void MemFreeReal( PTR ptr, const STR8 pcFile, INT32 iLine ) PTR MemReallocReal( PTR ptr, UINT32 uiSize, const STR8 pcFile, INT32 iLine ) { PTR ptrNew; - UINT32 uiOldSize; + UINT32 uiOldSize = 0; if ( !fMemManagerInit ) diff --git a/Standard Gaming Platform/SGP_2005Express.vcproj b/Standard Gaming Platform/SGP_2005Express.vcproj index 30598791..f7038fda 100644 --- a/Standard Gaming Platform/SGP_2005Express.vcproj +++ b/Standard Gaming Platform/SGP_2005Express.vcproj @@ -46,8 +46,9 @@ RuntimeLibrary="1" RuntimeTypeInfo="false" UsePrecompiledHeader="0" - WarningLevel="3" + WarningLevel="4" DebugInformationFormat="4" + DisableSpecificWarnings="4100" /> - #include - #include "debug.h" - #if defined( JA2 ) || defined( UTIL ) - #include "video.h" - #else - #include "video2.h" - #endif - #include "himage.h" - #include "vsurface.h" - #include "vsurface_private.h" - #include "video_private.h" - #include "wcheck.h" - #include "vobject_blitters.h" +#include "DirectDraw Calls.h" +#include +#include +#include "debug.h" +#if defined( JA2 ) || defined( UTIL ) +#include "video.h" +#else +#include "video2.h" +#endif +#include "himage.h" +#include "vsurface.h" +#include "vsurface_private.h" +#include "video_private.h" +#include "wcheck.h" +#include "vobject_blitters.h" #endif extern void SetClippingRect(SGPRect *clip); @@ -71,12 +71,12 @@ typedef struct VSURFACE_NODE { HVSURFACE hVSurface; UINT32 uiIndex; - struct VSURFACE_NODE *next, *prev; + struct VSURFACE_NODE *next, *prev; - #ifdef SGP_VIDEO_DEBUGGING - STR8 pName; - STR8 pCode; - #endif +#ifdef SGP_VIDEO_DEBUGGING + STR8 pName; + STR8 pCode; +#endif }VSURFACE_NODE; @@ -140,7 +140,7 @@ BOOLEAN InitializeVideoSurfaceManager( ) // Create primary and backbuffer from globals if ( !SetPrimaryVideoSurfaces( ) ) { - DbgMessage(TOPIC_VIDEOSURFACE, DBG_LEVEL_1, String( "Could not create primary surfaces" ) ); + DbgMessage(TOPIC_VIDEOSURFACE, DBG_LEVEL_1, String( "Could not create primary surfaces" ) ); return FALSE; } @@ -151,7 +151,7 @@ BOOLEAN ShutdownVideoSurfaceManager( ) { VSURFACE_NODE *curr; - DbgMessage(TOPIC_VIDEOSURFACE, DBG_LEVEL_0, "Shutting down the Video Surface manager"); + DbgMessage(TOPIC_VIDEOSURFACE, DBG_LEVEL_0, "Shutting down the Video Surface manager"); // Delete primary viedeo surfaces DeletePrimaryVideoSurfaces( ); @@ -161,12 +161,12 @@ BOOLEAN ShutdownVideoSurfaceManager( ) curr = gpVSurfaceHead; gpVSurfaceHead = gpVSurfaceHead->next; DeleteVideoSurface( curr->hVSurface ); - #ifdef SGP_VIDEO_DEBUGGING - if( curr->pName ) - MemFree( curr->pName ); - if( curr->pCode ) - MemFree( curr->pCode ); - #endif +#ifdef SGP_VIDEO_DEBUGGING + if( curr->pName ) + MemFree( curr->pName ); + if( curr->pCode ) + MemFree( curr->pCode ); +#endif MemFree( curr ); } gpVSurfaceHead = NULL; @@ -183,9 +183,9 @@ BOOLEAN RestoreVideoSurfaces( ) { VSURFACE_NODE *curr; - // + // // Loop through Video Surfaces and Restore - // + // curr = gpVSurfaceTail; while( curr ) { @@ -236,10 +236,10 @@ BOOLEAN AddStandardVideoSurface( VSURFACE_DESC *pVSurfaceDesc, UINT32 *puiIndex gpVSurfaceHead->prev = gpVSurfaceHead->next = NULL; gpVSurfaceTail = gpVSurfaceHead; } - #ifdef SGP_VIDEO_DEBUGGING - gpVSurfaceTail->pName = NULL; - gpVSurfaceTail->pCode = NULL; - #endif +#ifdef SGP_VIDEO_DEBUGGING + gpVSurfaceTail->pName = NULL; + gpVSurfaceTail->pCode = NULL; +#endif //Set the hVSurface into the node. gpVSurfaceTail->hVSurface = hVSurface; gpVSurfaceTail->uiIndex = guiVSurfaceIndex+=2; @@ -257,34 +257,34 @@ BYTE *LockVideoSurface( UINT32 uiVSurface, UINT32 *puiPitch ) { VSURFACE_NODE *curr; - // - // Check if given backbuffer or primary buffer - // + // + // Check if given backbuffer or primary buffer + // #ifdef JA2 - if ( uiVSurface == PRIMARY_SURFACE ) - { - return (BYTE *)LockPrimarySurface( puiPitch ); - } + if ( uiVSurface == PRIMARY_SURFACE ) + { + return (BYTE *)LockPrimarySurface( puiPitch ); + } - if ( uiVSurface == BACKBUFFER ) - { - return (BYTE *)LockBackBuffer( puiPitch ); - } + if ( uiVSurface == BACKBUFFER ) + { + return (BYTE *)LockBackBuffer( puiPitch ); + } #endif - if ( uiVSurface == FRAME_BUFFER ) - { - return (BYTE *)LockFrameBuffer( puiPitch ); - } + if ( uiVSurface == FRAME_BUFFER ) + { + return (BYTE *)LockFrameBuffer( puiPitch ); + } - if ( uiVSurface == MOUSE_BUFFER ) - { - return (BYTE *)LockMouseBuffer( puiPitch ); - } + if ( uiVSurface == MOUSE_BUFFER ) + { + return (BYTE *)LockMouseBuffer( puiPitch ); + } - // - // Otherwise, use list - // + // + // Otherwise, use list + // curr = gpVSurfaceHead; while( curr ) @@ -300,9 +300,9 @@ BYTE *LockVideoSurface( UINT32 uiVSurface, UINT32 *puiPitch ) return FALSE; } - // + // // Lock buffer - // + // return LockVideoSurfaceBuffer( curr->hVSurface, puiPitch ); @@ -312,34 +312,34 @@ void UnLockVideoSurface( UINT32 uiVSurface ) { VSURFACE_NODE *curr; - // - // Check if given backbuffer or primary buffer - // + // + // Check if given backbuffer or primary buffer + // #ifdef JA2 - if ( uiVSurface == PRIMARY_SURFACE ) - { - UnlockPrimarySurface(); - return; - } + if ( uiVSurface == PRIMARY_SURFACE ) + { + UnlockPrimarySurface(); + return; + } - if ( uiVSurface == BACKBUFFER ) - { - UnlockBackBuffer(); - return; - } + if ( uiVSurface == BACKBUFFER ) + { + UnlockBackBuffer(); + return; + } #endif - if ( uiVSurface == FRAME_BUFFER ) - { - UnlockFrameBuffer(); - return; - } + if ( uiVSurface == FRAME_BUFFER ) + { + UnlockFrameBuffer(); + return; + } - if ( uiVSurface == MOUSE_BUFFER ) - { - UnlockMouseBuffer(); - return; - } + if ( uiVSurface == MOUSE_BUFFER ) + { + UnlockMouseBuffer(); + return; + } curr = gpVSurfaceHead; while( curr ) @@ -352,12 +352,12 @@ void UnLockVideoSurface( UINT32 uiVSurface ) } if( !curr ) { - return; - } + return; + } - // + // // unlock buffer - // + // UnLockVideoSurfaceBuffer( curr->hVSurface ); } @@ -366,18 +366,18 @@ BOOLEAN SetVideoSurfaceTransparency( UINT32 uiIndex, COLORVAL TransColor ) { HVSURFACE hVSurface; - // + // // Get Video Surface - // + // - #ifdef _DEBUG - gubVSDebugCode = DEBUGSTR_SETVIDEOSURFACETRANSPARENCY; - #endif +#ifdef _DEBUG + gubVSDebugCode = DEBUGSTR_SETVIDEOSURFACETRANSPARENCY; +#endif CHECKF( GetVideoSurface( &hVSurface, uiIndex ) ); - // + // // Set transparency - // + // SetVideoSurfaceTransparencyColor( hVSurface, TransColor ); @@ -388,18 +388,18 @@ BOOLEAN AddVideoSurfaceRegion( UINT32 uiIndex, VSURFACE_REGION *pNewRegion ) { HVSURFACE hVSurface; - // + // // Get Video Surface - // + // - #ifdef _DEBUG - gubVSDebugCode = DEBUGSTR_ADDVIDEOSURFACEREGION; - #endif +#ifdef _DEBUG + gubVSDebugCode = DEBUGSTR_ADDVIDEOSURFACEREGION; +#endif CHECKF( GetVideoSurface( &hVSurface, uiIndex ) ); - // + // // Add Region - // + // CHECKF( AddVSurfaceRegion( hVSurface, pNewRegion ) ); @@ -415,13 +415,13 @@ BOOLEAN GetVideoSurfaceDescription( UINT32 uiIndex, UINT16 *usWidth, UINT16 *usH Assert( usHeight != NULL ); Assert( ubBitDepth != NULL ); - // + // // Get Video Surface - // + // - #ifdef _DEBUG - gubVSDebugCode = DEBUGSTR_GETVIDEOSURFACEDESCRIPTION; - #endif +#ifdef _DEBUG + gubVSDebugCode = DEBUGSTR_GETVIDEOSURFACEDESCRIPTION; +#endif CHECKF( GetVideoSurface( &hVSurface, uiIndex ) ); *usWidth = hVSurface->usWidth; @@ -435,33 +435,33 @@ BOOLEAN GetVideoSurface( HVSURFACE *hVSurface, UINT32 uiIndex ) { VSURFACE_NODE *curr; - #ifdef _DEBUG - CheckValidVSurfaceIndex( uiIndex ); - #endif +#ifdef _DEBUG + CheckValidVSurfaceIndex( uiIndex ); +#endif - if ( uiIndex == PRIMARY_SURFACE ) - { - *hVSurface = ghPrimary; + if ( uiIndex == PRIMARY_SURFACE ) + { + *hVSurface = ghPrimary; return TRUE; - } + } - if ( uiIndex == BACKBUFFER ) - { - *hVSurface = ghBackBuffer; + if ( uiIndex == BACKBUFFER ) + { + *hVSurface = ghBackBuffer; return TRUE; - } + } - if ( uiIndex == FRAME_BUFFER ) - { - *hVSurface = ghFrameBuffer; + if ( uiIndex == FRAME_BUFFER ) + { + *hVSurface = ghFrameBuffer; return TRUE; - } + } - if ( uiIndex == MOUSE_BUFFER ) - { - *hVSurface = ghMouseBuffer; + if ( uiIndex == MOUSE_BUFFER ) + { + *hVSurface = ghMouseBuffer; return TRUE; - } + } curr = gpVSurfaceHead; while( curr ) @@ -473,7 +473,7 @@ BOOLEAN GetVideoSurface( HVSURFACE *hVSurface, UINT32 uiIndex ) } curr = curr->next; } - return FALSE; + return FALSE; } BOOLEAN SetPrimaryVideoSurfaces( ) @@ -483,9 +483,9 @@ BOOLEAN SetPrimaryVideoSurfaces( ) // Delete surfaces if they exist DeletePrimaryVideoSurfaces( ); - // + // // Get Primary surface - // + // #ifdef JA2 pSurface = GetPrimarySurfaceObject(); CHECKF( pSurface != NULL ); @@ -493,9 +493,9 @@ BOOLEAN SetPrimaryVideoSurfaces( ) ghPrimary = CreateVideoSurfaceFromDDSurface( pSurface ); CHECKF( ghPrimary != NULL ); - // + // // Get Backbuffer surface - // + // pSurface = GetBackBufferObject( ); CHECKF( pSurface != NULL ); @@ -503,9 +503,9 @@ BOOLEAN SetPrimaryVideoSurfaces( ) ghBackBuffer = CreateVideoSurfaceFromDDSurface( pSurface ); CHECKF( ghBackBuffer != NULL ); - // + // // Get mouse buffer surface - // + // pSurface = GetMouseBufferObject( ); CHECKF( pSurface != NULL ); @@ -514,9 +514,9 @@ BOOLEAN SetPrimaryVideoSurfaces( ) #endif - // + // // Get frame buffer surface - // + // pSurface = GetFrameBufferObject( ); CHECKF( pSurface != NULL ); @@ -530,9 +530,9 @@ BOOLEAN SetPrimaryVideoSurfaces( ) void DeletePrimaryVideoSurfaces( ) { - // + // // If globals are not null, delete them - // + // if ( ghPrimary != NULL ) { @@ -546,7 +546,7 @@ void DeletePrimaryVideoSurfaces( ) ghBackBuffer = NULL; } - if ( ghFrameBuffer != NULL ) + if ( ghFrameBuffer != NULL ) { DeleteVideoSurface( ghFrameBuffer ); ghFrameBuffer = NULL; @@ -575,16 +575,16 @@ BOOLEAN BltVideoSurface(UINT32 uiDestVSurface, UINT32 uiSrcVSurface, UINT16 usRe HVSURFACE hDestVSurface; HVSURFACE hSrcVSurface; - #ifdef _DEBUG - gubVSDebugCode = DEBUGSTR_BLTVIDEOSURFACE_DST; - #endif +#ifdef _DEBUG + gubVSDebugCode = DEBUGSTR_BLTVIDEOSURFACE_DST; +#endif if( !GetVideoSurface( &hDestVSurface, uiDestVSurface ) ) { return FALSE; } - #ifdef _DEBUG - gubVSDebugCode = DEBUGSTR_BLTVIDEOSURFACE_SRC; - #endif +#ifdef _DEBUG + gubVSDebugCode = DEBUGSTR_BLTVIDEOSURFACE_SRC; +#endif if( !GetVideoSurface( &hSrcVSurface, uiSrcVSurface ) ) { return FALSE; @@ -608,9 +608,9 @@ BOOLEAN ColorFillVideoSurfaceArea(UINT32 uiDestVSurface, INT32 iDestX1, INT32 iD HVSURFACE hDestVSurface; SGPRect Clip; - #ifdef _DEBUG - gubVSDebugCode = DEBUGSTR_COLORFILLVIDEOSURFACEAREA; - #endif +#ifdef _DEBUG + gubVSDebugCode = DEBUGSTR_COLORFILLVIDEOSURFACEAREA; +#endif if( !GetVideoSurface( &hDestVSurface, uiDestVSurface ) ) { return FALSE; @@ -619,9 +619,9 @@ BOOLEAN ColorFillVideoSurfaceArea(UINT32 uiDestVSurface, INT32 iDestX1, INT32 iD BltFx.ColorFill = Color16BPP; BltFx.DestRegion = 0; - // + // // Clip fill region coords - // + // GetClippingRect(&Clip); @@ -712,9 +712,9 @@ BOOLEAN ImageFillVideoSurfaceArea(UINT32 uiDestVSurface, INT32 iDestX1, INT32 iD if((hblits==0) || (wblits==0)) return(FALSE); - // + // // Clip fill region coords - // + // GetClippingRect(&OldClip); @@ -777,98 +777,100 @@ BOOLEAN ImageFillVideoSurfaceArea(UINT32 uiDestVSurface, INT32 iDestX1, INT32 iD HVSURFACE CreateVideoSurface( VSURFACE_DESC *VSurfaceDesc ) { LPDIRECTDRAW2 lpDD2Object; - DDSURFACEDESC SurfaceDescription; + DDSURFACEDESC SurfaceDescription; DDPIXELFORMAT PixelFormat; LPDIRECTDRAWSURFACE lpDDS; LPDIRECTDRAWSURFACE2 lpDDS2; HVSURFACE hVSurface; - HIMAGE hImage; + HIMAGE hImage = NULL; SGPRect tempRect; UINT16 usHeight; UINT16 usWidth; UINT8 ubBitDepth; UINT32 fMemUsage; -//#ifdef JA2 + //#ifdef JA2 UINT32 uiRBitMask; UINT32 uiGBitMask; UINT32 uiBBitMask; -//#endif + //#endif //Clear the memory memset( &SurfaceDescription, 0, sizeof( DDSURFACEDESC ) ); - // + // // Get Direct Draw Object - // + // lpDD2Object = GetDirectDraw2Object( ); - // + // // The description structure contains memory usage flag - // + // #ifdef JA2 fMemUsage = VSurfaceDesc->fCreateFlags; #else fMemUsage = VSURFACE_SYSTEM_MEM_USAGE; #endif - // + // // Check creation options - // + // - do + //do + //{ + // + // Check if creating from file + // + + if ( VSurfaceDesc->fCreateFlags & VSURFACE_CREATE_FROMFILE ) { - // - // Check if creating from file - // + // + // Create himage object from file + // - if ( VSurfaceDesc->fCreateFlags & VSURFACE_CREATE_FROMFILE ) + hImage = CreateImage( VSurfaceDesc->ImageFile, IMAGE_ALLIMAGEDATA ); + + if ( hImage == NULL ) { - // - // Create himage object from file - // - - hImage = CreateImage( VSurfaceDesc->ImageFile, IMAGE_ALLIMAGEDATA ); - - if ( hImage == NULL ) - { - DbgMessage( TOPIC_VIDEOSURFACE, DBG_LEVEL_2, "Invalid Image Filename given" ); - return( NULL ); - } - - // - // Set values from himage - // - usHeight = hImage->usHeight; - usWidth = hImage->usWidth; - ubBitDepth = hImage->ubBitDepth; - break; + DbgMessage( TOPIC_VIDEOSURFACE, DBG_LEVEL_2, "Invalid Image Filename given" ); + return( NULL ); } + // + // Set values from himage + // + usHeight = hImage->usHeight; + usWidth = hImage->usWidth; + ubBitDepth = hImage->ubBitDepth; + // break; + } + else + { - // + // // If here, no special options given, // Set values from given description structure - // + // usHeight = VSurfaceDesc->usHeight; usWidth = VSurfaceDesc->usWidth; ubBitDepth = VSurfaceDesc->ubBitDepth; - } while( FALSE ); + } + //while( FALSE ); - // + // // Assertions - // + // Assert ( usHeight > 0 ); Assert ( usWidth > 0 ); - // + // // Setup Direct Draw Description // First do Pixel Format - // + // memset( &PixelFormat, 0, sizeof( PixelFormat ) ); PixelFormat.dwSize = sizeof( DDPIXELFORMAT ); @@ -876,50 +878,50 @@ HVSURFACE CreateVideoSurface( VSURFACE_DESC *VSurfaceDesc ) switch( ubBitDepth ) { - case 8: + case 8: - PixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8; - PixelFormat.dwRGBBitCount = 8; - break; + PixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8; + PixelFormat.dwRGBBitCount = 8; + break; - case 16: + case 16: - PixelFormat.dwFlags = DDPF_RGB; - PixelFormat.dwRGBBitCount = 16; + PixelFormat.dwFlags = DDPF_RGB; + PixelFormat.dwRGBBitCount = 16; - // - // Get current Pixel Format from DirectDraw - // + // + // Get current Pixel Format from DirectDraw + // -// We're using pixel formats too -- DB/Wiz + // We're using pixel formats too -- DB/Wiz -//#ifdef JA2 - CHECKF( GetPrimaryRGBDistributionMasks( &uiRBitMask, &uiGBitMask, &uiBBitMask ) ); - PixelFormat.dwRBitMask = uiRBitMask; - PixelFormat.dwGBitMask = uiGBitMask; - PixelFormat.dwBBitMask = uiBBitMask; -//#else -// PixelFormat.dwRBitMask = 0xf800; -// PixelFormat.dwGBitMask = 0x7e0; -// PixelFormat.dwBBitMask = 0x1f; -//#endif - break; + //#ifdef JA2 + CHECKF( GetPrimaryRGBDistributionMasks( &uiRBitMask, &uiGBitMask, &uiBBitMask ) ); + PixelFormat.dwRBitMask = uiRBitMask; + PixelFormat.dwGBitMask = uiGBitMask; + PixelFormat.dwBBitMask = uiBBitMask; + //#else + // PixelFormat.dwRBitMask = 0xf800; + // PixelFormat.dwGBitMask = 0x7e0; + // PixelFormat.dwBBitMask = 0x1f; + //#endif + break; - default: + default: - // - // If Here, an invalid format was given - // + // + // If Here, an invalid format was given + // - DbgMessage( TOPIC_VIDEOSURFACE, DBG_LEVEL_2, "Invalid BPP value, can only be 8 or 16." ); - return( FALSE ); + DbgMessage( TOPIC_VIDEOSURFACE, DBG_LEVEL_2, "Invalid BPP value, can only be 8 or 16." ); + return( FALSE ); } - SurfaceDescription.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT; + SurfaceDescription.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT; - // + // // Do memory description, based on specified flags - // + // do { @@ -940,32 +942,32 @@ HVSURFACE CreateVideoSurface( VSURFACE_DESC *VSurfaceDesc ) break; } - // + // // Once here, no mem flags were given, use default - // + // SurfaceDescription.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; } while( FALSE ); - // + // // Set other, common structure elements - // + // - SurfaceDescription.dwSize = sizeof(DDSURFACEDESC); - SurfaceDescription.dwWidth = usWidth; - SurfaceDescription.dwHeight = usHeight; + SurfaceDescription.dwSize = sizeof(DDSURFACEDESC); + SurfaceDescription.dwWidth = usWidth; + SurfaceDescription.dwHeight = usHeight; SurfaceDescription.ddpfPixelFormat = PixelFormat; - // + // // Create Surface - // + // DDCreateSurface ( lpDD2Object, &SurfaceDescription, &lpDDS, &lpDDS2 ); - // + // // Allocate memory for Video Surface data and initialize - // + // hVSurface = (HVSURFACE) MemAlloc( sizeof( SGPVSurface ) ); memset( hVSurface, 0, sizeof( SGPVSurface ) ); @@ -985,21 +987,21 @@ HVSURFACE CreateVideoSurface( VSURFACE_DESC *VSurfaceDesc ) hVSurface->fFlags = 0; hVSurface->pClipper = NULL; - // + // // Determine memory and other attributes of newly created surface - // + // DDGetSurfaceDescription ( lpDDS2, &SurfaceDescription ); - // + // // Fail if create tried for video but it's in system - // + // if ( VSurfaceDesc->fCreateFlags & VSURFACE_VIDEO_MEM_USAGE && SurfaceDescription.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY ) { - // + // // Return failure due to not in video - // + // DbgMessage( TOPIC_VIDEOSURFACE, DBG_LEVEL_2, String( "Failed to create Video Surface in video memory" ) ); DDReleaseSurface ( &lpDDS, &lpDDS2 ); @@ -1007,27 +1009,27 @@ HVSURFACE CreateVideoSurface( VSURFACE_DESC *VSurfaceDesc ) return( NULL ); } - // + // // Look for system memory - // + // if ( SurfaceDescription.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY ) { hVSurface->fFlags |= VSURFACE_SYSTEM_MEM_USAGE; } - // + // // Look for video memory - // + // if ( SurfaceDescription.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY ) { hVSurface->fFlags |= VSURFACE_VIDEO_MEM_USAGE; } - // + // // If in video memory, create backup surface - // + // if ( hVSurface->fFlags & VSURFACE_VIDEO_MEM_USAGE ) { @@ -1038,23 +1040,23 @@ HVSURFACE CreateVideoSurface( VSURFACE_DESC *VSurfaceDesc ) SurfaceDescription.dwHeight = usHeight; SurfaceDescription.ddpfPixelFormat = PixelFormat; - // + // // Create Surface - // + // DDCreateSurface ( lpDD2Object, &SurfaceDescription, &lpDDS, &lpDDS2 ); - // + // // Save surface to backup - // + // hVSurface->pSavedSurfaceData1 = lpDDS; hVSurface->pSavedSurfaceData = lpDDS2; } - // + // // Initialize surface with hImage , if given - // + // if ( VSurfaceDesc->fCreateFlags & VSURFACE_CREATE_FROMFILE ) { @@ -1064,25 +1066,25 @@ HVSURFACE CreateVideoSurface( VSURFACE_DESC *VSurfaceDesc ) tempRect.iBottom = hImage->usHeight-1; SetVideoSurfaceDataFromHImage( hVSurface, hImage, 0, 0, &tempRect ); - // + // // Set palette from himage - // + // if ( hImage->ubBitDepth == 8 ) { SetVideoSurfacePalette( hVSurface, hImage->pPalette ); } - // + // // Delete himage object - // + // DestroyImage( hImage ); } - // + // // All is well - // + // hVSurface->usHeight = usHeight; hVSurface->usWidth = usWidth; @@ -1090,7 +1092,7 @@ HVSURFACE CreateVideoSurface( VSURFACE_DESC *VSurfaceDesc ) giMemUsedInSurfaces += ( hVSurface->usHeight * hVSurface->usWidth * ( hVSurface->ubBitDepth / 8 ) ); - DbgMessage( TOPIC_VIDEOSURFACE, DBG_LEVEL_3, String("Success in Creating Video Surface" ) ); + DbgMessage( TOPIC_VIDEOSURFACE, DBG_LEVEL_3, String("Success in Creating Video Surface" ) ); return( hVSurface ); } @@ -1109,31 +1111,31 @@ BOOLEAN RestoreVideoSurface( HVSURFACE hVSurface ) Assert( hVSurface != NULL ); - // + // // Restore is only for VIDEO MEMORY - should check if VIDEO and QUIT if not - // + // if ( !( hVSurface->fFlags & VSURFACE_VIDEO_MEM_USAGE ) ) { - // + // // No second surfaace has been allocated, return failure - // + // - DbgMessage( TOPIC_VIDEOSURFACE, DBG_LEVEL_2, String("Failed to restore Video Surface surface" ) ); + DbgMessage( TOPIC_VIDEOSURFACE, DBG_LEVEL_2, String("Failed to restore Video Surface surface" ) ); return( FALSE ); } - // + // // Check for valid secondary surface - // + // if ( hVSurface->pSavedSurfaceData1 == NULL ) { - // + // // No secondary surface available - // + // - DbgMessage( TOPIC_VIDEOSURFACE, DBG_LEVEL_2, String("Failure in retoring- no secondary surface found" ) ); + DbgMessage( TOPIC_VIDEOSURFACE, DBG_LEVEL_2, String("Failure in retoring- no secondary surface found" ) ); return( FALSE ); } @@ -1236,15 +1238,15 @@ BOOLEAN SetVideoSurfaceDataFromHImage( HVSURFACE hVSurface, HIMAGE hImage, UINT1 // Set buffer BPP switch ( hImage->ubBitDepth ) { - case 8: + case 8: - fBufferBPP = BUFFER_8BPP; - break; + fBufferBPP = BUFFER_8BPP; + break; - case 16: + case 16: - fBufferBPP = BUFFER_16BPP; - break; + fBufferBPP = BUFFER_16BPP; + break; } } @@ -1279,7 +1281,7 @@ BOOLEAN SetVideoSurfaceDataFromHImage( HVSURFACE hVSurface, HIMAGE hImage, UINT1 // This HIMAGE function will transparently copy buffer if ( !CopyImageToBuffer( hImage, fBufferBPP, pDest, usEffectiveWidth, hVSurface->usHeight, usX, usY, &aRect ) ) { - DbgMessage( TOPIC_VIDEOSURFACE, DBG_LEVEL_2, String( "Error Occured Copying HIMAGE to HVSURFACE" )); + DbgMessage( TOPIC_VIDEOSURFACE, DBG_LEVEL_2, String( "Error Occured Copying HIMAGE to HVSURFACE" )); UnLockVideoSurfaceBuffer( hVSurface ); return( FALSE ); } @@ -1322,7 +1324,7 @@ BOOLEAN SetVideoSurfacePalette( HVSURFACE hVSurface, SGPPaletteEntry *pSrcPalett // Create 16BPP Palette hVSurface->p16BPPPalette = Create16BPPPalette( pSrcPalette ); - DbgMessage(TOPIC_VIDEOSURFACE, DBG_LEVEL_3, String("Video Surface Palette change successfull" )); + DbgMessage(TOPIC_VIDEOSURFACE, DBG_LEVEL_3, String("Video Surface Palette change successfull" )); return( TRUE ); } @@ -1330,8 +1332,8 @@ BOOLEAN SetVideoSurfacePalette( HVSURFACE hVSurface, SGPPaletteEntry *pSrcPalett // colorkey value. BOOLEAN SetVideoSurfaceTransparencyColor( HVSURFACE hVSurface, COLORVAL TransColor ) { - DDCOLORKEY ColorKey; - DWORD fFlags = CLR_INVALID; + DDCOLORKEY ColorKey; + DWORD fFlags = CLR_INVALID; LPDIRECTDRAWSURFACE2 lpDDSurface; // Assertions @@ -1348,21 +1350,21 @@ BOOLEAN SetVideoSurfaceTransparencyColor( HVSURFACE hVSurface, COLORVAL TransCol switch( hVSurface->ubBitDepth ) { - case 8: + case 8: - // Use color directly - ColorKey.dwColorSpaceLowValue = TransColor; - ColorKey.dwColorSpaceHighValue = TransColor; - break; + // Use color directly + ColorKey.dwColorSpaceLowValue = TransColor; + ColorKey.dwColorSpaceHighValue = TransColor; + break; - case 16: + case 16: - fFlags = Get16BPPColor( TransColor ); + fFlags = Get16BPPColor( TransColor ); - //fFlags now contains our closest match - ColorKey.dwColorSpaceLowValue = fFlags; - ColorKey.dwColorSpaceHighValue = ColorKey.dwColorSpaceLowValue; - break; + //fFlags now contains our closest match + ColorKey.dwColorSpaceLowValue = fFlags; + ColorKey.dwColorSpaceHighValue = ColorKey.dwColorSpaceLowValue; + break; } @@ -1386,10 +1388,10 @@ BOOLEAN DeleteVideoSurfaceFromIndex( UINT32 uiIndex ) { VSURFACE_NODE *curr; - #ifdef _DEBUG - gubVSDebugCode = DEBUGSTR_DELETEVIDEOSURFACEFROMINDEX; - CheckValidVSurfaceIndex( uiIndex ); - #endif +#ifdef _DEBUG + gubVSDebugCode = DEBUGSTR_DELETEVIDEOSURFACEFROMINDEX; + CheckValidVSurfaceIndex( uiIndex ); +#endif curr = gpVSurfaceHead; while( curr ) @@ -1419,16 +1421,16 @@ BOOLEAN DeleteVideoSurfaceFromIndex( UINT32 uiIndex ) } //The node is now detached. Now deallocate it. - #ifdef SGP_VIDEO_DEBUGGING - if( curr->pName ) - { - MemFree( curr->pName ); - } - if( curr->pCode ) - { - MemFree( curr->pCode ); - } - #endif +#ifdef SGP_VIDEO_DEBUGGING + if( curr->pName ) + { + MemFree( curr->pName ); + } + if( curr->pCode ) + { + MemFree( curr->pCode ); + } +#endif MemFree( curr ); guiVSurfaceSize--; @@ -1457,7 +1459,7 @@ BOOLEAN DeleteVideoSurface( HVSURFACE hVSurface ) //if ( hVSurface->pClipper != NULL ) //{ - // Release Clipper + // Release Clipper // DDReleaseClipper( (LPDIRECTDRAWCLIPPER)hVSurface->pClipper ); //} @@ -1474,7 +1476,7 @@ BOOLEAN DeleteVideoSurface( HVSURFACE hVSurface ) if ( hVSurface->pSavedSurfaceData != NULL ) { DDReleaseSurface( (LPDIRECTDRAWSURFACE*)&hVSurface->pSavedSurfaceData1, - (LPDIRECTDRAWSURFACE2*)&hVSurface->pSavedSurfaceData ); + (LPDIRECTDRAWSURFACE2*)&hVSurface->pSavedSurfaceData ); } // Release region data @@ -1713,19 +1715,19 @@ BOOLEAN BltVideoSurfaceToVideoSurface( HVSURFACE hDestVSurface, HVSURFACE hSrcVS // Check that both region and subrect are not given if ((fBltFlags&VS_BLT_SRCREGION) && (fBltFlags&VS_BLT_SRCSUBRECT)) { - DbgMessage(TOPIC_VIDEOSURFACE, DBG_LEVEL_2, String( "Inconsistant blit flags given" )); - return( FALSE ); + DbgMessage(TOPIC_VIDEOSURFACE, DBG_LEVEL_2, String( "Inconsistant blit flags given" )); + return( FALSE ); } // Check for dest src options if ( fBltFlags & VS_BLT_DESTREGION ) { - CHECKF( pBltFx != NULL ); - CHECKF( GetVSurfaceRegion( hDestVSurface, pBltFx->DestRegion, &aRegion ) ); + CHECKF( pBltFx != NULL ); + CHECKF( GetVSurfaceRegion( hDestVSurface, pBltFx->DestRegion, &aRegion ) ); - // Set starting coordinates from destination region - iDestY = aRegion.RegionCoords.iTop; - iDestX = aRegion.RegionCoords.iLeft; + // Set starting coordinates from destination region + iDestY = aRegion.RegionCoords.iTop; + iDestX = aRegion.RegionCoords.iLeft; } // Check for fill, if true, fill entire region with color @@ -1748,7 +1750,7 @@ BOOLEAN BltVideoSurfaceToVideoSurface( HVSURFACE hDestVSurface, HVSURFACE hSrcVS { CHECKF( GetVSurfaceRegion( hSrcVSurface, usIndex, &aRegion ) ) - SrcRect.top = (int)aRegion.RegionCoords.iTop; + SrcRect.top = (int)aRegion.RegionCoords.iTop; SrcRect.left = (int)aRegion.RegionCoords.iLeft; SrcRect.bottom = (int)aRegion.RegionCoords.iBottom; SrcRect.right = (int)aRegion.RegionCoords.iRight; @@ -1776,13 +1778,13 @@ BOOLEAN BltVideoSurfaceToVideoSurface( HVSURFACE hDestVSurface, HVSURFACE hSrcVS // Check Sizes, SRC size MUST be <= DEST size if ( hDestVSurface->usHeight < hSrcVSurface->usHeight ) { - DbgMessage(TOPIC_VIDEOSURFACE, DBG_LEVEL_2, String( "Incompatible height size given in Video Surface blit" )); - return( FALSE ); + DbgMessage(TOPIC_VIDEOSURFACE, DBG_LEVEL_2, String( "Incompatible height size given in Video Surface blit" )); + return( FALSE ); } if ( hDestVSurface->usWidth < hSrcVSurface->usWidth ) { - DbgMessage(TOPIC_VIDEOSURFACE, DBG_LEVEL_2, String( "Incompatible height size given in Video Surface blit" )); - return( FALSE ); + DbgMessage(TOPIC_VIDEOSURFACE, DBG_LEVEL_2, String( "Incompatible height size given in Video Surface blit" )); + return( FALSE ); } SrcRect.top = (int)0; @@ -1862,7 +1864,7 @@ BOOLEAN BltVideoSurfaceToVideoSurface( HVSURFACE hDestVSurface, HVSURFACE hSrcVS UnLockVideoSurfaceBuffer(hDestVSurface); return(TRUE); } -// For testing with non-DDraw blitting, uncomment to test -- DB + // For testing with non-DDraw blitting, uncomment to test -- DB #ifndef JA2 else { @@ -2035,7 +2037,7 @@ HVSURFACE CreateVideoSurfaceFromDDSurface( LPDIRECTDRAWSURFACE2 lpDDSurface ) } // All is well - DbgMessage( TOPIC_VIDEOSURFACE, DBG_LEVEL_0, String("Success in Creating Video Surface from DD Surface" ) ); + DbgMessage( TOPIC_VIDEOSURFACE, DBG_LEVEL_0, String("Success in Creating Video Surface from DD Surface" ) ); return( hVSurface ); } @@ -2188,7 +2190,7 @@ BOOLEAN BltVSurfaceUsingDD( HVSURFACE hDestVSurface, HVSURFACE hSrcVSurface, UIN UINT32 uiDDFlags; RECT DestRect; - // Blit using the correct blitter + // Blit using the correct blitter if ( fBltFlags & VS_BLT_FAST ) { @@ -2257,7 +2259,7 @@ BOOLEAN BltVSurfaceUsingDD( HVSURFACE hDestVSurface, HVSURFACE hSrcVSurface, UIN DDBltSurface( (LPDIRECTDRAWSURFACE2)hDestVSurface->pSurfaceData, &DestRect, (LPDIRECTDRAWSURFACE2)hSrcVSurface->pSurfaceData, - SrcRect, uiDDFlags, NULL ); + SrcRect, uiDDFlags, NULL ); } @@ -2285,43 +2287,43 @@ BOOLEAN InternalShadowVideoSurfaceRect( UINT32 uiDestVSurface, INT32 X1, INT32 // CLIP IT! // FIRST GET SURFACE - // + // // Get Video Surface - // - #ifdef _DEBUG - gubVSDebugCode = DEBUGSTR_SHADOWVIDEOSURFACERECT; - #endif + // +#ifdef _DEBUG + gubVSDebugCode = DEBUGSTR_SHADOWVIDEOSURFACERECT; +#endif CHECKF( GetVideoSurface( &hVSurface, uiDestVSurface ) ); if ( X1 < 0 ) - X1 = 0; + X1 = 0; if ( X2 < 0 ) - return( FALSE ); + return( FALSE ); if ( Y2 < 0 ) - return( FALSE ); + return( FALSE ); if ( Y1 < 0 ) - Y1 = 0; + Y1 = 0; if ( X2 >= hVSurface->usWidth ) - X2 = hVSurface->usWidth-1; + X2 = hVSurface->usWidth-1; if ( Y2 >= hVSurface->usHeight ) - Y2 = hVSurface->usHeight-1; + Y2 = hVSurface->usHeight-1; if ( X1 >= hVSurface->usWidth ) - return( FALSE ); + return( FALSE ); if ( Y1 >= hVSurface->usHeight ) - return( FALSE ); + return( FALSE ); if ( ( X2 - X1 ) <= 0 ) - return( FALSE ); + return( FALSE ); if ( ( Y2 - Y1 ) <= 0 ) - return( FALSE ); + return( FALSE ); area.iTop=Y1; @@ -2332,7 +2334,7 @@ BOOLEAN InternalShadowVideoSurfaceRect( UINT32 uiDestVSurface, INT32 X1, INT32 // Lock video surface pBuffer = (UINT16*)LockVideoSurface( uiDestVSurface, &uiPitch ); - //UnLockVideoSurface( uiDestVSurface ); + //UnLockVideoSurface( uiDestVSurface ); if ( pBuffer == NULL ) { @@ -2371,13 +2373,13 @@ BOOLEAN InternalShadowVideoSurfaceRect( UINT32 uiDestVSurface, INT32 X1, INT32 BOOLEAN ShadowVideoSurfaceRect( UINT32 uiDestVSurface, INT32 X1, INT32 Y1, INT32 X2, INT32 Y2) { - return( InternalShadowVideoSurfaceRect( uiDestVSurface, X1, Y1, X2, Y2, FALSE ) ); + return( InternalShadowVideoSurfaceRect( uiDestVSurface, X1, Y1, X2, Y2, FALSE ) ); } BOOLEAN ShadowVideoSurfaceRectUsingLowPercentTable( UINT32 uiDestVSurface, INT32 X1, INT32 Y1, INT32 X2, INT32 Y2) { - return( InternalShadowVideoSurfaceRect( uiDestVSurface, X1, Y1, X2, Y2, TRUE ) ); + return( InternalShadowVideoSurfaceRect( uiDestVSurface, X1, Y1, X2, Y2, TRUE ) ); } @@ -2397,7 +2399,7 @@ BOOLEAN BltVSurfaceUsingDDBlt( HVSURFACE hDestVSurface, HVSURFACE hSrcVSurface, } DDBltSurface( (LPDIRECTDRAWSURFACE2)hDestVSurface->pSurfaceData, DestRect, (LPDIRECTDRAWSURFACE2)hSrcVSurface->pSurfaceData, - SrcRect, uiDDFlags, NULL ); + SrcRect, uiDDFlags, NULL ); // Update backup surface with new data if ( hDestVSurface->fFlags & VSURFACE_VIDEO_MEM_USAGE && !(hDestVSurface->fFlags & VSURFACE_RESERVED_SURFACE) ) @@ -2419,16 +2421,16 @@ BOOLEAN BltStretchVideoSurface(UINT32 uiDestVSurface, UINT32 uiSrcVSurface, INT3 HVSURFACE hDestVSurface; HVSURFACE hSrcVSurface; - #ifdef _DEBUG - gubVSDebugCode = DEBUGSTR_BLTSTRETCHVIDEOSURFACE_DST; - #endif +#ifdef _DEBUG + gubVSDebugCode = DEBUGSTR_BLTSTRETCHVIDEOSURFACE_DST; +#endif if( !GetVideoSurface( &hDestVSurface, uiDestVSurface ) ) { return FALSE; } - #ifdef _DEBUG - gubVSDebugCode = DEBUGSTR_BLTSTRETCHVIDEOSURFACE_SRC; - #endif +#ifdef _DEBUG + gubVSDebugCode = DEBUGSTR_BLTSTRETCHVIDEOSURFACE_SRC; +#endif if( !GetVideoSurface( &hSrcVSurface, uiSrcVSurface ) ) { return FALSE; @@ -2440,9 +2442,9 @@ BOOLEAN BltStretchVideoSurface(UINT32 uiDestVSurface, UINT32 uiSrcVSurface, INT3 if(!BltVSurfaceUsingDDBlt( hDestVSurface, hSrcVSurface, fBltFlags, iDestX, iDestY, (RECT*)SrcRect, (RECT*)DestRect ) ) { - // + // // VO Blitter will set debug messages for error conditions - // + // return( FALSE ); } @@ -2463,9 +2465,9 @@ BOOLEAN ShadowVideoSurfaceImage( UINT32 uiDestVSurface, HVOBJECT hImageHandle, I BOOLEAN MakeVSurfaceFromVObject(UINT32 uiVObject, UINT16 usSubIndex, UINT32 *puiVSurface) { -HVOBJECT hSrcVObject; -UINT32 uiVSurface; -VSURFACE_DESC hDesc; + HVOBJECT hSrcVObject; + UINT32 uiVSurface; + VSURFACE_DESC hDesc; if(GetVideoObject(&hSrcVObject, uiVObject)) { @@ -2487,7 +2489,7 @@ VSURFACE_DESC hDesc; DeleteVideoSurfaceFromIndex(uiVSurface); } } - + return(FALSE); } @@ -2509,40 +2511,40 @@ void CheckValidVSurfaceIndex( UINT32 uiIndex ) CHAR8 str[60]; switch( gubVSDebugCode ) { - case DEBUGSTR_SETVIDEOSURFACETRANSPARENCY: - sprintf( str, "SetVideoSurfaceTransparency" ); - break; - case DEBUGSTR_ADDVIDEOSURFACEREGION: - sprintf( str, "AddVideoSurfaceRegion" ); - break; - case DEBUGSTR_GETVIDEOSURFACEDESCRIPTION: - sprintf( str, "GetVideoSurfaceDescription" ); - break; - case DEBUGSTR_BLTVIDEOSURFACE_DST: - sprintf( str, "BltVideoSurface (dest)" ); - break; - case DEBUGSTR_BLTVIDEOSURFACE_SRC: - sprintf( str, "BltVideoSurface (src)" ); - break; - case DEBUGSTR_COLORFILLVIDEOSURFACEAREA: - sprintf( str, "ColorFillVideoSurfaceArea" ); - break; - case DEBUGSTR_SHADOWVIDEOSURFACERECT: - sprintf( str, "ShadowVideoSurfaceRect" ); - break; - case DEBUGSTR_BLTSTRETCHVIDEOSURFACE_DST: - sprintf( str, "BltStretchVideoSurface (dest)" ); - break; - case DEBUGSTR_BLTSTRETCHVIDEOSURFACE_SRC: - sprintf( str, "BltStretchVideoSurface (src)" ); - break; - case DEBUGSTR_DELETEVIDEOSURFACEFROMINDEX: - sprintf( str, "DeleteVideoSurfaceFromIndex" ); - break; - case DEBUGSTR_NONE: - default: - sprintf( str, "GetVideoSurface" ); - break; + case DEBUGSTR_SETVIDEOSURFACETRANSPARENCY: + sprintf( str, "SetVideoSurfaceTransparency" ); + break; + case DEBUGSTR_ADDVIDEOSURFACEREGION: + sprintf( str, "AddVideoSurfaceRegion" ); + break; + case DEBUGSTR_GETVIDEOSURFACEDESCRIPTION: + sprintf( str, "GetVideoSurfaceDescription" ); + break; + case DEBUGSTR_BLTVIDEOSURFACE_DST: + sprintf( str, "BltVideoSurface (dest)" ); + break; + case DEBUGSTR_BLTVIDEOSURFACE_SRC: + sprintf( str, "BltVideoSurface (src)" ); + break; + case DEBUGSTR_COLORFILLVIDEOSURFACEAREA: + sprintf( str, "ColorFillVideoSurfaceArea" ); + break; + case DEBUGSTR_SHADOWVIDEOSURFACERECT: + sprintf( str, "ShadowVideoSurfaceRect" ); + break; + case DEBUGSTR_BLTSTRETCHVIDEOSURFACE_DST: + sprintf( str, "BltStretchVideoSurface (dest)" ); + break; + case DEBUGSTR_BLTSTRETCHVIDEOSURFACE_SRC: + sprintf( str, "BltStretchVideoSurface (src)" ); + break; + case DEBUGSTR_DELETEVIDEOSURFACEFROMINDEX: + sprintf( str, "DeleteVideoSurfaceFromIndex" ); + break; + case DEBUGSTR_NONE: + default: + sprintf( str, "GetVideoSurface" ); + break; } if( uiIndex == 0xffffffff ) { diff --git a/Strategic/AI Viewer.cpp b/Strategic/AI Viewer.cpp index 59331d9c..e1a2ea0a 100644 --- a/Strategic/AI Viewer.cpp +++ b/Strategic/AI Viewer.cpp @@ -455,7 +455,7 @@ void RenderStationaryGroups() INT32 x, y, xp, yp; CHAR16 str[20]; INT32 iSector = 0; - UINT8 ubIconColor; + UINT8 ubIconColor = 0; UINT8 ubGroupSize = 0; diff --git a/Strategic/Assignments.cpp b/Strategic/Assignments.cpp index e108316e..171ef77a 100644 --- a/Strategic/Assignments.cpp +++ b/Strategic/Assignments.cpp @@ -3950,7 +3950,7 @@ INT16 GetSoldierStudentPts( SOLDIERTYPE *pSoldier, INT8 bTrainStat, BOOLEAN fAtG INT8 bSkill = 0; INT16 sBestTrainingPts, sTrainingPtsDueToInstructor; - UINT16 usMaxTrainerPts, usBestMaxTrainerPts; + UINT16 usMaxTrainerPts, usBestMaxTrainerPts = 0; UINT32 uiCnt; SOLDIERTYPE * pTrainer; @@ -8106,7 +8106,7 @@ void HandleShadingOfLinesForSquadMenu( void ) UINT32 uiCounter; SOLDIERTYPE *pSoldier = NULL; UINT32 uiMaxSquad; - INT8 bResult; + INT8 bResult = 0; if ( ( fShowSquadMenu == FALSE ) || ( ghSquadBox == -1 ) ) diff --git a/Strategic/Creature Spreading.cpp b/Strategic/Creature Spreading.cpp index cb528178..e122e9ba 100644 --- a/Strategic/Creature Spreading.cpp +++ b/Strategic/Creature Spreading.cpp @@ -622,7 +622,7 @@ void AddCreaturesToBattle( UINT8 ubNumYoungMales, UINT8 ubNumYoungFemales, UINT8 { INT32 iRandom; SOLDIERTYPE *pSoldier; - MAPEDGEPOINTINFO MapEdgepointInfo; + MAPEDGEPOINTINFO MapEdgepointInfo = { }; UINT8 bDesiredDirection=0; UINT8 ubCurrSlot = 0; diff --git a/Strategic/Hourly Update.cpp b/Strategic/Hourly Update.cpp index 941b1e2e..9cd25363 100644 --- a/Strategic/Hourly Update.cpp +++ b/Strategic/Hourly Update.cpp @@ -180,7 +180,7 @@ UINT16 LarryItems[ NUM_LARRY_ITEMS ][ 3 ] = void HourlyLarryUpdate( void ) { SOLDIERTYPE * pSoldier; - INT8 bSlot, bBoozeSlot; + INT8 bSlot = NO_SLOT, bBoozeSlot; INT8 bLarryItemLoop; UINT16 usTemptation = 0; UINT16 usCashAmount; diff --git a/Strategic/Map Screen Helicopter.cpp b/Strategic/Map Screen Helicopter.cpp index 51f60254..e330b349 100644 --- a/Strategic/Map Screen Helicopter.cpp +++ b/Strategic/Map Screen Helicopter.cpp @@ -1,43 +1,43 @@ #ifdef PRECOMPILEDHEADERS - #include "Strategic All.h" +#include "Strategic All.h" #else - #include "Map Screen Helicopter.h" - #include "LaptopSave.h" - #include "Vehicles.h" - #include "Finances.h" - #include "Quests.h" - #include "Game Clock.h" - #include "strategic.h" - #include "Queen Command.h" - #include "Strategic Pathing.h" - #include "Random.h" - #include "Game Event Hook.h" - #include "String.h" - #include "Dialogue Control.h" - #include "Message.h" - #include "Strategic Movement.h" - #include "Soldier Profile.h" - #include "Assignments.h" - #include "PreBattle Interface.h" - #include "strategicmap.h" - #include "worlddef.h" - #include "worldman.h" - #include "tiledat.h" - #include "Map Screen Interface.h" - #include "Text.h" - #include "Squads.h" - #include "Player Command.h" - #include "Sound Control.h" - #include "GameSettings.h" - #include "meanwhile.h" - #include "Map Screen Interface Border.h" - #include "Strategic Event Handler.h" - #include "Overhead.h" - #include "Soldier Create.h" - #include "renderworld.h" - #include "soundman.h" - #include "Isometric Utils.h" - #include "Scheduling.h" +#include "Map Screen Helicopter.h" +#include "LaptopSave.h" +#include "Vehicles.h" +#include "Finances.h" +#include "Quests.h" +#include "Game Clock.h" +#include "strategic.h" +#include "Queen Command.h" +#include "Strategic Pathing.h" +#include "Random.h" +#include "Game Event Hook.h" +#include "String.h" +#include "Dialogue Control.h" +#include "Message.h" +#include "Strategic Movement.h" +#include "Soldier Profile.h" +#include "Assignments.h" +#include "PreBattle Interface.h" +#include "strategicmap.h" +#include "worlddef.h" +#include "worldman.h" +#include "tiledat.h" +#include "Map Screen Interface.h" +#include "Text.h" +#include "Squads.h" +#include "Player Command.h" +#include "Sound Control.h" +#include "GameSettings.h" +#include "meanwhile.h" +#include "Map Screen Interface Border.h" +#include "Strategic Event Handler.h" +#include "Overhead.h" +#include "Soldier Create.h" +#include "renderworld.h" +#include "soundman.h" +#include "Isometric Utils.h" +#include "Scheduling.h" #endif @@ -116,8 +116,8 @@ UINT8 ubRefuelList[ NUMBER_OF_REFUEL_SITES ][ 2 ] = INT16 sRefuelStartGridNo[ NUMBER_OF_REFUEL_SITES ] ={ - 9001, // drassen - 13068, // estoni + 9001, // drassen + 13068, // estoni }; // whether or not helicopter can refuel at this site @@ -204,7 +204,7 @@ void InitializeHelicopter( void ) fPlotForHelicopter = FALSE; pTempHelicopterPath = NULL; -// iTotalHeliDistanceSinceRefuel = 0; + // iTotalHeliDistanceSinceRefuel = 0; iTotalAccumulatedCostByPlayer = 0; fHelicopterDestroyed = FALSE; @@ -292,7 +292,7 @@ BOOLEAN HandleHeliEnteringSector( INT16 sX, INT16 sY ) { UINT8 ubNumEnemies; - + // check for SAM attack upon the chopper. If it's destroyed by the attack, do nothing else here if( HandleSAMSiteAttackOfHelicopterInSector( sX, sY ) == TRUE ) { @@ -344,7 +344,7 @@ BOOLEAN HandleHeliEnteringSector( INT16 sX, INT16 sY ) } // accumulate distance travelled -// AddSectorToHelicopterDistanceTravelled( ); + // AddSectorToHelicopterDistanceTravelled( ); // check if heli has any real path left @@ -387,30 +387,30 @@ BOOLEAN HandleHeliEnteringSector( INT16 sX, INT16 sY ) /* INT32 GetTotalDistanceHelicopterCanTravel( void ) { - return( MAX_HELICOPTER_DISTANCE ); +return( MAX_HELICOPTER_DISTANCE ); } INT32 HowFarHelicopterhasTravelledSinceRefueling( void ) { - // return total distance - return( iTotalHeliDistanceSinceRefuel ); +// return total distance +return( iTotalHeliDistanceSinceRefuel ); } INT32 HowFurtherCanHelicopterTravel( void ) { - // how many sectors further can we go on remaining fuel? - return( MAX_HELICOPTER_DISTANCE - ( HowFarHelicopterhasTravelledSinceRefueling( ) + DistanceOfIntendedHelicopterPath( ) ) ); +// how many sectors further can we go on remaining fuel? +return( MAX_HELICOPTER_DISTANCE - ( HowFarHelicopterhasTravelledSinceRefueling( ) + DistanceOfIntendedHelicopterPath( ) ) ); } void AddSectorToHelicopterDistanceTravelled( void ) { - // up the distance - iTotalHeliDistanceSinceRefuel++; +// up the distance +iTotalHeliDistanceSinceRefuel++; - //reset hover time - uiStartHoverTime = 0; +//reset hover time +uiStartHoverTime = 0; - return; +return; } */ @@ -439,7 +439,7 @@ INT32 LocationOfNearestRefuelPoint( BOOLEAN fNotifyPlayerIfNoSafeLZ ) return( iClosestLocation ); } - + INT32 FindLocationOfClosestRefuelSite( BOOLEAN fMustBeAvailable ) { INT32 iShortestDistance = 9999; @@ -486,14 +486,14 @@ INT32 DistanceToNearestRefuelPoint( INT16 sX, INT16 sY ) /* BOOLEAN IsSectorOutOfTheWay( INT16 sX, INT16 sY ) { - // check distance to nearest refuel point - if( DistanceToNearestRefuelPoint( sX, sY ) > HowFurtherCanHelicopterTravel( ) ) - { - return( TRUE ); - } +// check distance to nearest refuel point +if( DistanceToNearestRefuelPoint( sX, sY ) > HowFurtherCanHelicopterTravel( ) ) +{ +return( TRUE ); +} - return( FALSE ); +return( FALSE ); } */ @@ -505,12 +505,12 @@ void ReFuelHelicopter( void ) LandHelicopter( ); -/* + /* AddStrategicEvent( EVENT_HELICOPTER_DONE_REFUELING, GetWorldTotalMin() + REFUEL_HELICOPTER_DELAY, 0 ); // reset distance traveled iTotalHeliDistanceSinceRefuel = 0; -*/ + */ return; } @@ -557,7 +557,7 @@ void SkyriderDestroyed( void ) // zero out balance due gMercProfiles[ SKYRIDER ].iBalance = 0; -// iTotalHeliDistanceSinceRefuel = 0; + // iTotalHeliDistanceSinceRefuel = 0; iTotalAccumulatedCostByPlayer = 0; // remove vehicle and reset @@ -583,13 +583,13 @@ BOOLEAN CanHelicopterFly( void ) return( FALSE ); } -/* + /* // travelled too far? if( iTotalHeliDistanceSinceRefuel > MAX_HELICOPTER_DISTANCE ) { - return( FALSE ); + return( FALSE ); } -*/ + */ // is the pilot alive, well, and willing to help us? if( IsHelicopterPilotAvailable( ) == FALSE ) @@ -640,7 +640,7 @@ void LandHelicopter( void ) { // set the helictoper down, call arrive callback for this mvt group fHelicopterIsAirBorne = FALSE; - + // no longer hovering fHoveringHelicopter = FALSE; @@ -724,7 +724,7 @@ void HandleHeliHoverTooLong( void ) return; } - + // hovered too long, inform player heli is returning to base HeliCharacterDialogue( pSkyRider, RETURN_TO_BASE ); @@ -782,7 +782,7 @@ INT32 DistanceOfIntendedHelicopterPath( void ) } pNode = pVehicleList[ iHelicopterVehicleId ].pMercPath; - + // any path yet? if( pNode != NULL ) { @@ -904,8 +904,8 @@ void UpdateRefuelSiteAvailability( void ) { // if enemy controlled sector (ground OR air, don't want to fly into enemy air territory) if( ( StrategicMap[ CALCULATE_STRATEGIC_INDEX( ubRefuelList[ iCounter ][ 0 ], ubRefuelList[ iCounter ][ 1 ] ) ].fEnemyControlled == TRUE ) || - ( StrategicMap[ CALCULATE_STRATEGIC_INDEX( ubRefuelList[ iCounter ][ 0 ], ubRefuelList[ iCounter ][ 1 ] ) ].fEnemyAirControlled == TRUE ) || - ( ( iCounter == ESTONI_REFUELING_SITE ) && ( CheckFact( FACT_ESTONI_REFUELLING_POSSIBLE, 0 ) == FALSE ) ) ) + ( StrategicMap[ CALCULATE_STRATEGIC_INDEX( ubRefuelList[ iCounter ][ 0 ], ubRefuelList[ iCounter ][ 1 ] ) ].fEnemyAirControlled == TRUE ) || + ( ( iCounter == ESTONI_REFUELING_SITE ) && ( CheckFact( FACT_ESTONI_REFUELLING_POSSIBLE, 0 ) == FALSE ) ) ) { // mark refueling site as unavailable fRefuelingSiteAvailable[ iCounter ] = FALSE; @@ -919,7 +919,7 @@ void UpdateRefuelSiteAvailability( void ) if ( !fHelicopterAvailable && !fHelicopterDestroyed && fSkyRiderAvailable && ( iHelicopterVehicleId != -1 ) ) { if( ( pVehicleList[ iHelicopterVehicleId ].sSectorX == ubRefuelList[ iCounter ][ 0 ]) && - ( pVehicleList[ iHelicopterVehicleId ].sSectorY == ubRefuelList[ iCounter ][ 1 ]) ) + ( pVehicleList[ iHelicopterVehicleId ].sSectorY == ubRefuelList[ iCounter ][ 1 ]) ) { // no longer grounded DoScreenIndependantMessageBox( pSkyriderText[ 5 ], MSG_BOX_FLAG_OK, NULL ); @@ -941,14 +941,14 @@ void SetUpHelicopterForPlayer( INT16 sX, INT16 sY ) Assert( iHelicopterVehicleId != -1 ); - // WDS - Clean up inventory handling + // WDS - Clean up inventory handling //memset( &SoldierSkyRider, 0, SIZEOF_SOLDIERTYPE ); SoldierSkyRider.initialize(); SoldierSkyRider.ubProfile = SKYRIDER; SoldierSkyRider.bLife = 80; pSkyRider = &( SoldierSkyRider ); - + // set up for movement SetUpHelicopterForMovement( ); UpdateRefuelSiteAvailability( ); @@ -957,7 +957,7 @@ void SetUpHelicopterForPlayer( INT16 sX, INT16 sY ) gMercProfiles[ SKYRIDER ].fUseProfileInsertionInfo = FALSE; } - + return; } @@ -971,9 +971,9 @@ UINT8 MoveAllInHelicopterToFootMovementGroup( void ) INT8 bNewSquad; BOOLEAN fAnyoneAboard = FALSE; BOOLEAN fSuccess; - UINT8 ubInsertionCode; - BOOLEAN fInsertionCodeSet = FALSE; - UINT16 usInsertionData; + UINT8 ubInsertionCode = 0; + BOOLEAN fInsertionCodeSet = FALSE; + UINT16 usInsertionData = 0; // put these guys on their own squad (we need to return their group ID, and can only return one, so they need a unique one @@ -1002,20 +1002,20 @@ UINT8 MoveAllInHelicopterToFootMovementGroup( void ) AddCharacterToSquad( pSoldier, bNewSquad ); - // ATE: OK - the ubStrategicInsertionCode is set 'cause groupArrivesInsector has been - // called when buddy is added to a squad. However, the insertion code onlt sets set for - // the first merc, so the rest are going to use whatever they had previously.... - if ( !fInsertionCodeSet ) - { - ubInsertionCode = pSoldier->ubStrategicInsertionCode; - usInsertionData = pSoldier->usStrategicInsertionData; - fInsertionCodeSet = TRUE; - } - else - { - pSoldier->ubStrategicInsertionCode = ubInsertionCode; - pSoldier->usStrategicInsertionData = usInsertionData; - } + // ATE: OK - the ubStrategicInsertionCode is set 'cause groupArrivesInsector has been + // called when buddy is added to a squad. However, the insertion code onlt sets set for + // the first merc, so the rest are going to use whatever they had previously.... + if ( !fInsertionCodeSet ) + { + ubInsertionCode = pSoldier->ubStrategicInsertionCode; + usInsertionData = pSoldier->usStrategicInsertionData; + fInsertionCodeSet = TRUE; + } + else + { + pSoldier->ubStrategicInsertionCode = ubInsertionCode; + pSoldier->usStrategicInsertionData = usInsertionData; + } } } @@ -1048,22 +1048,22 @@ void HandleSkyRiderMonologueEvent( UINT32 uiEventCode, UINT32 uiSpecialCode ) switch( uiEventCode ) { - case( SKYRIDER_MONOLOGUE_EVENT_DRASSEN_SAM_SITE ): - SetExternMapscreenSpeechPanelXY( DEFAULT_EXTERN_PANEL_X_POS, 117 ); - HandleSkyRiderMonologueAboutDrassenSAMSite( uiSpecialCode ); - break; - case SKYRIDER_MONOLOGUE_EVENT_CAMBRIA_HOSPITAL: - SetExternMapscreenSpeechPanelXY( DEFAULT_EXTERN_PANEL_X_POS, 172 ); - HandleSkyRiderMonologueAboutCambriaHospital( uiSpecialCode ); - break; - case( SKYRIDER_MONOLOGUE_EVENT_OTHER_SAM_SITES ): - SetExternMapscreenSpeechPanelXY( 335, DEFAULT_EXTERN_PANEL_Y_POS ); - HandleSkyRiderMonologueAboutOtherSAMSites( uiSpecialCode ); - break; - case( SKYRIDER_MONOLOGUE_EVENT_ESTONI_REFUEL ): - SetExternMapscreenSpeechPanelXY( DEFAULT_EXTERN_PANEL_X_POS, DEFAULT_EXTERN_PANEL_Y_POS ); - HandleSkyRiderMonologueAboutEstoniRefuel( uiSpecialCode ); - break; + case( SKYRIDER_MONOLOGUE_EVENT_DRASSEN_SAM_SITE ): + SetExternMapscreenSpeechPanelXY( DEFAULT_EXTERN_PANEL_X_POS, 117 ); + HandleSkyRiderMonologueAboutDrassenSAMSite( uiSpecialCode ); + break; + case SKYRIDER_MONOLOGUE_EVENT_CAMBRIA_HOSPITAL: + SetExternMapscreenSpeechPanelXY( DEFAULT_EXTERN_PANEL_X_POS, 172 ); + HandleSkyRiderMonologueAboutCambriaHospital( uiSpecialCode ); + break; + case( SKYRIDER_MONOLOGUE_EVENT_OTHER_SAM_SITES ): + SetExternMapscreenSpeechPanelXY( 335, DEFAULT_EXTERN_PANEL_Y_POS ); + HandleSkyRiderMonologueAboutOtherSAMSites( uiSpecialCode ); + break; + case( SKYRIDER_MONOLOGUE_EVENT_ESTONI_REFUEL ): + SetExternMapscreenSpeechPanelXY( DEFAULT_EXTERN_PANEL_X_POS, DEFAULT_EXTERN_PANEL_Y_POS ); + HandleSkyRiderMonologueAboutEstoniRefuel( uiSpecialCode ); + break; } // update time @@ -1077,22 +1077,22 @@ void HandleSkyRiderMonologueAboutEstoniRefuel( UINT32 uiSpecialCode ) switch( uiSpecialCode ) { - case( 0 ): - CharacterDialogueWithSpecialEvent( SKYRIDER, SPIEL_ABOUT_ESTONI_AIRSPACE, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ] , DIALOGUE_EXTERNAL_NPC_UI , FALSE , FALSE , DIALOGUE_SPECIAL_EVENT_SKYRIDERMAPSCREENEVENT ,SKYRIDER_MONOLOGUE_EVENT_ESTONI_REFUEL, 1 ); - // if special event data 2 is true, then do dialogue, else this is just a trigger for an event - CharacterDialogue( SKYRIDER, SPIEL_ABOUT_ESTONI_AIRSPACE, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI, FALSE, FALSE ); + case( 0 ): + CharacterDialogueWithSpecialEvent( SKYRIDER, SPIEL_ABOUT_ESTONI_AIRSPACE, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ] , DIALOGUE_EXTERNAL_NPC_UI , FALSE , FALSE , DIALOGUE_SPECIAL_EVENT_SKYRIDERMAPSCREENEVENT ,SKYRIDER_MONOLOGUE_EVENT_ESTONI_REFUEL, 1 ); + // if special event data 2 is true, then do dialogue, else this is just a trigger for an event + CharacterDialogue( SKYRIDER, SPIEL_ABOUT_ESTONI_AIRSPACE, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI, FALSE, FALSE ); - CharacterDialogueWithSpecialEvent( SKYRIDER, SPIEL_ABOUT_ESTONI_AIRSPACE, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ] , DIALOGUE_EXTERNAL_NPC_UI , FALSE , FALSE , DIALOGUE_SPECIAL_EVENT_SKYRIDERMAPSCREENEVENT ,SKYRIDER_MONOLOGUE_EVENT_ESTONI_REFUEL, 2 ); - break; + CharacterDialogueWithSpecialEvent( SKYRIDER, SPIEL_ABOUT_ESTONI_AIRSPACE, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ] , DIALOGUE_EXTERNAL_NPC_UI , FALSE , FALSE , DIALOGUE_SPECIAL_EVENT_SKYRIDERMAPSCREENEVENT ,SKYRIDER_MONOLOGUE_EVENT_ESTONI_REFUEL, 2 ); + break; - case( 1 ): - // highlight Estoni - fShowEstoniRefuelHighLight = TRUE; - break; + case( 1 ): + // highlight Estoni + fShowEstoniRefuelHighLight = TRUE; + break; - case( 2 ): - fShowEstoniRefuelHighLight = FALSE; - break; + case( 2 ): + fShowEstoniRefuelHighLight = FALSE; + break; } return; } @@ -1102,40 +1102,40 @@ void HandleSkyRiderMonologueAboutDrassenSAMSite( UINT32 uiSpecialCode ) { switch( uiSpecialCode ) { - case( 0 ): - //gpCurrentTalkingFace = &gFacesData[ uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ] ]; - //gubCurrentTalkingID = SKYRIDER; - - // if special event data 2 is true, then do dialogue, else this is just a trigger for an event - CharacterDialogue( SKYRIDER, MENTION_DRASSEN_SAM_SITE, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI, FALSE, FALSE ); - CharacterDialogueWithSpecialEvent( SKYRIDER, MENTION_DRASSEN_SAM_SITE, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI , FALSE , TRUE , DIALOGUE_SPECIAL_EVENT_SKYRIDERMAPSCREENEVENT ,SKYRIDER_MONOLOGUE_EVENT_DRASSEN_SAM_SITE, 1 ); + case( 0 ): + //gpCurrentTalkingFace = &gFacesData[ uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ] ]; + //gubCurrentTalkingID = SKYRIDER; - if( SAMSitesUnderPlayerControl( SAM_2_X, SAM_2_Y ) == FALSE ) + // if special event data 2 is true, then do dialogue, else this is just a trigger for an event + CharacterDialogue( SKYRIDER, MENTION_DRASSEN_SAM_SITE, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI, FALSE, FALSE ); + CharacterDialogueWithSpecialEvent( SKYRIDER, MENTION_DRASSEN_SAM_SITE, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI , FALSE , TRUE , DIALOGUE_SPECIAL_EVENT_SKYRIDERMAPSCREENEVENT ,SKYRIDER_MONOLOGUE_EVENT_DRASSEN_SAM_SITE, 1 ); + + if( SAMSitesUnderPlayerControl( SAM_2_X, SAM_2_Y ) == FALSE ) + { + CharacterDialogue( SKYRIDER, SECOND_HALF_OF_MENTION_DRASSEN_SAM_SITE, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI, FALSE, FALSE ); + } + else + { + // Ian says don't use the SAM site quote unless player has tried flying already + if ( CheckFact( FACT_SKYRIDER_USED_IN_MAPSCREEN, SKYRIDER ) ) { - CharacterDialogue( SKYRIDER, SECOND_HALF_OF_MENTION_DRASSEN_SAM_SITE, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI, FALSE, FALSE ); - } - else - { - // Ian says don't use the SAM site quote unless player has tried flying already - if ( CheckFact( FACT_SKYRIDER_USED_IN_MAPSCREEN, SKYRIDER ) ) - { - CharacterDialogue( SKYRIDER, SAM_SITE_TAKEN, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI, FALSE, FALSE ); - gfSkyriderSaidCongratsOnTakingSAM = TRUE; - } + CharacterDialogue( SKYRIDER, SAM_SITE_TAKEN, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI, FALSE, FALSE ); + gfSkyriderSaidCongratsOnTakingSAM = TRUE; } + } - CharacterDialogueWithSpecialEvent( SKYRIDER, MENTION_DRASSEN_SAM_SITE, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI , FALSE , TRUE , DIALOGUE_SPECIAL_EVENT_SKYRIDERMAPSCREENEVENT ,SKYRIDER_MONOLOGUE_EVENT_DRASSEN_SAM_SITE, 2 ); - break; + CharacterDialogueWithSpecialEvent( SKYRIDER, MENTION_DRASSEN_SAM_SITE, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI , FALSE , TRUE , DIALOGUE_SPECIAL_EVENT_SKYRIDERMAPSCREENEVENT ,SKYRIDER_MONOLOGUE_EVENT_DRASSEN_SAM_SITE, 2 ); + break; - case( 1 ): - // highlight Drassen SAM site sector - fShowDrassenSAMHighLight = TRUE; - SetSAMSiteAsFound( SAM_SITE_TWO ); - break; + case( 1 ): + // highlight Drassen SAM site sector + fShowDrassenSAMHighLight = TRUE; + SetSAMSiteAsFound( SAM_SITE_TWO ); + break; - case( 2 ): - fShowDrassenSAMHighLight = FALSE; - break; + case( 2 ): + fShowDrassenSAMHighLight = FALSE; + break; } return; } @@ -1145,21 +1145,21 @@ void HandleSkyRiderMonologueAboutCambriaHospital( UINT32 uiSpecialCode ) { switch( uiSpecialCode ) { - case( 0 ): - //gpCurrentTalkingFace = &gFacesData[ uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ] ]; - //gubCurrentTalkingID = SKYRIDER; - - // if special event data 2 is true, then do dialogue, else this is just a trigger for an event - CharacterDialogue( SKYRIDER, MENTION_HOSPITAL_IN_CAMBRIA, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI, FALSE, FALSE ); - CharacterDialogueWithSpecialEvent( SKYRIDER, MENTION_HOSPITAL_IN_CAMBRIA, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI , FALSE , TRUE , DIALOGUE_SPECIAL_EVENT_SKYRIDERMAPSCREENEVENT ,SKYRIDER_MONOLOGUE_EVENT_CAMBRIA_HOSPITAL, 1 ); + case( 0 ): + //gpCurrentTalkingFace = &gFacesData[ uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ] ]; + //gubCurrentTalkingID = SKYRIDER; - // highlight Drassen hospital sector - fShowCambriaHospitalHighLight = TRUE; - break; + // if special event data 2 is true, then do dialogue, else this is just a trigger for an event + CharacterDialogue( SKYRIDER, MENTION_HOSPITAL_IN_CAMBRIA, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI, FALSE, FALSE ); + CharacterDialogueWithSpecialEvent( SKYRIDER, MENTION_HOSPITAL_IN_CAMBRIA, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI , FALSE , TRUE , DIALOGUE_SPECIAL_EVENT_SKYRIDERMAPSCREENEVENT ,SKYRIDER_MONOLOGUE_EVENT_CAMBRIA_HOSPITAL, 1 ); - case( 1 ): - fShowCambriaHospitalHighLight = FALSE; - break; + // highlight Drassen hospital sector + fShowCambriaHospitalHighLight = TRUE; + break; + + case( 1 ): + fShowCambriaHospitalHighLight = FALSE; + break; } return; } @@ -1171,32 +1171,32 @@ void HandleSkyRiderMonologueAboutOtherSAMSites( UINT32 uiSpecialCode ) switch( uiSpecialCode ) { - case( 0 ): - // do quote 21 - gpCurrentTalkingFace = &gFacesData[ uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ] ]; - gubCurrentTalkingID = SKYRIDER; + case( 0 ): + // do quote 21 + gpCurrentTalkingFace = &gFacesData[ uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ] ]; + gubCurrentTalkingID = SKYRIDER; - // if special event data 2 is true, then do dialogue, else this is just a trigger for an event - CharacterDialogue( SKYRIDER, SPIEL_ABOUT_OTHER_SAM_SITES, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI, FALSE, FALSE ); - CharacterDialogueWithSpecialEvent( SKYRIDER, SPIEL_ABOUT_OTHER_SAM_SITES, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ] , DIALOGUE_EXTERNAL_NPC_UI , FALSE , FALSE , DIALOGUE_SPECIAL_EVENT_SKYRIDERMAPSCREENEVENT ,SKYRIDER_MONOLOGUE_EVENT_OTHER_SAM_SITES, 1 ); - - CharacterDialogue( SKYRIDER, SECOND_HALF_OF_SPIEL_ABOUT_OTHER_SAM_SITES, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI, FALSE, FALSE ); - CharacterDialogueWithSpecialEvent( SKYRIDER, SPIEL_ABOUT_OTHER_SAM_SITES, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ] , DIALOGUE_EXTERNAL_NPC_UI , FALSE , FALSE , DIALOGUE_SPECIAL_EVENT_SKYRIDERMAPSCREENEVENT ,SKYRIDER_MONOLOGUE_EVENT_OTHER_SAM_SITES, 2 ); - - break; + // if special event data 2 is true, then do dialogue, else this is just a trigger for an event + CharacterDialogue( SKYRIDER, SPIEL_ABOUT_OTHER_SAM_SITES, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI, FALSE, FALSE ); + CharacterDialogueWithSpecialEvent( SKYRIDER, SPIEL_ABOUT_OTHER_SAM_SITES, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ] , DIALOGUE_EXTERNAL_NPC_UI , FALSE , FALSE , DIALOGUE_SPECIAL_EVENT_SKYRIDERMAPSCREENEVENT ,SKYRIDER_MONOLOGUE_EVENT_OTHER_SAM_SITES, 1 ); - case( 1 ): - // highlight other SAMs - fShowOtherSAMHighLight = TRUE; - // reveal other 3 SAM sites - SetSAMSiteAsFound( SAM_SITE_ONE ); - SetSAMSiteAsFound( SAM_SITE_THREE ); - SetSAMSiteAsFound( SAM_SITE_FOUR ); - break; + CharacterDialogue( SKYRIDER, SECOND_HALF_OF_SPIEL_ABOUT_OTHER_SAM_SITES, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ], DIALOGUE_EXTERNAL_NPC_UI, FALSE, FALSE ); + CharacterDialogueWithSpecialEvent( SKYRIDER, SPIEL_ABOUT_OTHER_SAM_SITES, uiExternalStaticNPCFaces[ SKYRIDER_EXTERNAL_FACE ] , DIALOGUE_EXTERNAL_NPC_UI , FALSE , FALSE , DIALOGUE_SPECIAL_EVENT_SKYRIDERMAPSCREENEVENT ,SKYRIDER_MONOLOGUE_EVENT_OTHER_SAM_SITES, 2 ); - case( 2 ): - fShowOtherSAMHighLight = FALSE; - break; + break; + + case( 1 ): + // highlight other SAMs + fShowOtherSAMHighLight = TRUE; + // reveal other 3 SAM sites + SetSAMSiteAsFound( SAM_SITE_ONE ); + SetSAMSiteAsFound( SAM_SITE_THREE ); + SetSAMSiteAsFound( SAM_SITE_FOUR ); + break; + + case( 2 ): + fShowOtherSAMHighLight = FALSE; + break; } return; } @@ -1316,12 +1316,12 @@ void HandleAnimationOfSectors( void ) { switch( gubBlitSectorLocatorCode ) { - case LOCATOR_COLOR_RED: // normal one used for mines (will now be overriden with yellow) - HandleBlitOfSectorLocatorIcon( gsSectorLocatorX, gsSectorLocatorY, 0, LOCATOR_COLOR_RED ); - break; - case LOCATOR_COLOR_YELLOW: // used for all other dialogues - HandleBlitOfSectorLocatorIcon( gsSectorLocatorX, gsSectorLocatorY, 0, LOCATOR_COLOR_YELLOW ); - break; + case LOCATOR_COLOR_RED: // normal one used for mines (will now be overriden with yellow) + HandleBlitOfSectorLocatorIcon( gsSectorLocatorX, gsSectorLocatorY, 0, LOCATOR_COLOR_RED ); + break; + case LOCATOR_COLOR_YELLOW: // used for all other dialogues + HandleBlitOfSectorLocatorIcon( gsSectorLocatorX, gsSectorLocatorY, 0, LOCATOR_COLOR_YELLOW ); + break; } } @@ -1344,7 +1344,7 @@ INT16 LastSectorInHelicoptersPath( void ) uiLocation = pVehicleList[ iHelicopterVehicleId ].sSectorX + pVehicleList[ iHelicopterVehicleId ].sSectorY * MAP_WORLD_X; pNode = pVehicleList[ iHelicopterVehicleId ].pMercPath; - + // any path yet? if( pNode != NULL ) { @@ -1375,166 +1375,166 @@ INT16 LastSectorInHelicoptersPath( void ) /* INT32 GetTotalCostOfHelicopterTrip( void ) { - // get cost of helicopter trip +// get cost of helicopter trip - PathStPtr pNode = NULL, pTempNode = NULL; - UINT32 uiCost = 0; - UINT32 uiLastTempPathSectorId = 0; - UINT32 iClosestRefuelPoint = 0; - UINT32 uiStartSectorNum = 0; - UINT32 uiLength = 0; +PathStPtr pNode = NULL, pTempNode = NULL; +UINT32 uiCost = 0; +UINT32 uiLastTempPathSectorId = 0; +UINT32 iClosestRefuelPoint = 0; +UINT32 uiStartSectorNum = 0; +UINT32 uiLength = 0; - // if the heli is on the move, what is the distance it will move..the length of the merc path, less the first node - if( CanHelicopterFly( ) == FALSE ) - { - // big number, no go - return( 0 ); - } +// if the heli is on the move, what is the distance it will move..the length of the merc path, less the first node +if( CanHelicopterFly( ) == FALSE ) +{ +// big number, no go +return( 0 ); +} - pNode = pVehicleList[ iHelicopterVehicleId ].pMercPath; - - // any path yet? - uiLastTempPathSectorId = pVehicleList[ iHelicopterVehicleId ].sSectorX + pVehicleList[ iHelicopterVehicleId ].sSectorY * MAP_WORLD_X; - uiStartSectorNum = uiLastTempPathSectorId; +pNode = pVehicleList[ iHelicopterVehicleId ].pMercPath; - if( pNode ) - { - pNode = pNode->pNext; - } +// any path yet? +uiLastTempPathSectorId = pVehicleList[ iHelicopterVehicleId ].sSectorX + pVehicleList[ iHelicopterVehicleId ].sSectorY * MAP_WORLD_X; +uiStartSectorNum = uiLastTempPathSectorId; - if( pNode != NULL ) - { - while( pNode) - { - if( uiLength == 0 ) - { - if( pNode->pNext ) - { - if( uiLastTempPathSectorId == pNode->pNext->uiSectorId ) - { - // do nothing - } - else - { - uiCost += GetCostOfPassageForHelicopter( ( UINT16 )( pNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pNode->uiSectorId / MAP_WORLD_X ) ); - } - } - else - { - uiCost += GetCostOfPassageForHelicopter( ( UINT16 )( pNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pNode->uiSectorId / MAP_WORLD_X ) ); - } - } - else - { - uiCost += GetCostOfPassageForHelicopter( ( UINT16 )( pNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pNode->uiSectorId / MAP_WORLD_X ) ); - } +if( pNode ) +{ +pNode = pNode->pNext; +} - uiLength++; - - uiLastTempPathSectorId = pNode ->uiSectorId; - pNode = pNode ->pNext; - } - } +if( pNode != NULL ) +{ +while( pNode) +{ +if( uiLength == 0 ) +{ +if( pNode->pNext ) +{ +if( uiLastTempPathSectorId == pNode->pNext->uiSectorId ) +{ +// do nothing +} +else +{ +uiCost += GetCostOfPassageForHelicopter( ( UINT16 )( pNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pNode->uiSectorId / MAP_WORLD_X ) ); +} +} +else +{ +uiCost += GetCostOfPassageForHelicopter( ( UINT16 )( pNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pNode->uiSectorId / MAP_WORLD_X ) ); +} +} +else +{ +uiCost += GetCostOfPassageForHelicopter( ( UINT16 )( pNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pNode->uiSectorId / MAP_WORLD_X ) ); +} + +uiLength++; + +uiLastTempPathSectorId = pNode ->uiSectorId; +pNode = pNode ->pNext; +} +} - pNode = NULL; +pNode = NULL; - if( pTempHelicopterPath ) - { - pNode = MoveToBeginningOfPathList( pTempHelicopterPath ); - } +if( pTempHelicopterPath ) +{ +pNode = MoveToBeginningOfPathList( pTempHelicopterPath ); +} - if( pNode ) - { - pNode = pNode->pNext; - } +if( pNode ) +{ +pNode = pNode->pNext; +} - // any path yet? - if( pNode != NULL ) - { - while( pNode ) - { - if( uiLength == 0 ) - { - if( pNode->pNext ) - { - if( uiLastTempPathSectorId == pNode->pNext->uiSectorId ) - { - // do nothing - } - else - { - uiCost += GetCostOfPassageForHelicopter( ( UINT16 )( pNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pNode->uiSectorId / MAP_WORLD_X ) ); - } - } - else - { - uiCost += GetCostOfPassageForHelicopter( ( UINT16 )( pNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pNode->uiSectorId / MAP_WORLD_X ) ); - } - } - else - { - uiCost += GetCostOfPassageForHelicopter( ( UINT16 )( pNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pNode->uiSectorId / MAP_WORLD_X ) ); - } +// any path yet? +if( pNode != NULL ) +{ +while( pNode ) +{ +if( uiLength == 0 ) +{ +if( pNode->pNext ) +{ +if( uiLastTempPathSectorId == pNode->pNext->uiSectorId ) +{ +// do nothing +} +else +{ +uiCost += GetCostOfPassageForHelicopter( ( UINT16 )( pNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pNode->uiSectorId / MAP_WORLD_X ) ); +} +} +else +{ +uiCost += GetCostOfPassageForHelicopter( ( UINT16 )( pNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pNode->uiSectorId / MAP_WORLD_X ) ); +} +} +else +{ +uiCost += GetCostOfPassageForHelicopter( ( UINT16 )( pNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pNode->uiSectorId / MAP_WORLD_X ) ); +} - uiLength++; +uiLength++; - //uiCost += GetCostOfPassageForHelicopter( ( UINT16 ) ( pNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pNode->uiSectorId / MAP_WORLD_X ) ); - uiLastTempPathSectorId = pNode ->uiSectorId; - pNode = pNode ->pNext; - } - } +//uiCost += GetCostOfPassageForHelicopter( ( UINT16 ) ( pNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pNode->uiSectorId / MAP_WORLD_X ) ); +uiLastTempPathSectorId = pNode ->uiSectorId; +pNode = pNode ->pNext; +} +} - iClosestRefuelPoint = ( INT16 )( CALCULATE_STRATEGIC_INDEX( ubRefuelList[ LocationOfNearestRefuelPoint( FALSE ) ][ 0 ], ubRefuelList[ LocationOfNearestRefuelPoint( FALSE ) ][ 1 ] ) ); +iClosestRefuelPoint = ( INT16 )( CALCULATE_STRATEGIC_INDEX( ubRefuelList[ LocationOfNearestRefuelPoint( FALSE ) ][ 0 ], ubRefuelList[ LocationOfNearestRefuelPoint( FALSE ) ][ 1 ] ) ); - pNode = NULL; +pNode = NULL; - if( uiLastTempPathSectorId != iClosestRefuelPoint ) - { - pNode = BuildAStrategicPath( pNode, ( INT16 )( uiLastTempPathSectorId ), ( INT16 )iClosestRefuelPoint, pVehicleList[ iHelicopterVehicleId ].ubMovementGroup, FALSE ); +if( uiLastTempPathSectorId != iClosestRefuelPoint ) +{ +pNode = BuildAStrategicPath( pNode, ( INT16 )( uiLastTempPathSectorId ), ( INT16 )iClosestRefuelPoint, pVehicleList[ iHelicopterVehicleId ].ubMovementGroup, FALSE ); // pNode = BuildAStrategicPath( pNode, ( INT16 )( uiLastTempPathSectorId ), ( INT16 )iClosestRefuelPoint, pVehicleList[ iHelicopterVehicleId ].ubMovementGroup, FALSE, TRUE ); - pNode = MoveToBeginningOfPathList( pNode ); - } +pNode = MoveToBeginningOfPathList( pNode ); +} - pTempNode = pNode; - uiLength = 0; +pTempNode = pNode; +uiLength = 0; - if( pTempNode ) - { - pTempNode = pTempNode->pNext; - } +if( pTempNode ) +{ +pTempNode = pTempNode->pNext; +} - while( pTempNode ) - { - if( uiLength == 0 ) - { - if( pTempNode->pNext ) - { - if( uiLastTempPathSectorId == pNode->pNext->uiSectorId ) - { - // do nothing - } - else - { - uiCost += GetCostOfPassageForHelicopter( ( UINT16 )( pTempNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pTempNode->uiSectorId / MAP_WORLD_X ) ); - } - } - else - { - uiCost += GetCostOfPassageForHelicopter( ( UINT16 )( pTempNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pTempNode->uiSectorId / MAP_WORLD_X ) ); - } - } - else - { - uiCost += GetCostOfPassageForHelicopter( ( UINT16 )( pTempNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pTempNode->uiSectorId / MAP_WORLD_X ) ); - } +while( pTempNode ) +{ +if( uiLength == 0 ) +{ +if( pTempNode->pNext ) +{ +if( uiLastTempPathSectorId == pNode->pNext->uiSectorId ) +{ +// do nothing +} +else +{ +uiCost += GetCostOfPassageForHelicopter( ( UINT16 )( pTempNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pTempNode->uiSectorId / MAP_WORLD_X ) ); +} +} +else +{ +uiCost += GetCostOfPassageForHelicopter( ( UINT16 )( pTempNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pTempNode->uiSectorId / MAP_WORLD_X ) ); +} +} +else +{ +uiCost += GetCostOfPassageForHelicopter( ( UINT16 )( pTempNode -> uiSectorId % MAP_WORLD_X ), ( UINT16 ) ( pTempNode->uiSectorId / MAP_WORLD_X ) ); +} - uiLength++; - pTempNode = pTempNode->pNext; - } - - return( ( INT32 )uiCost ); +uiLength++; +pTempNode = pTempNode->pNext; +} + +return( ( INT32 )uiCost ); } */ @@ -1580,7 +1580,7 @@ void HandleHelicopterOnGroundGraphic( void ) // see if we can find him and remove him if so.... pSoldier = FindSoldierByProfileID( SKYRIDER, FALSE ); - // ATE: Don't do this if buddy is on our team! + // ATE: Don't do this if buddy is on our team! if ( pSoldier != NULL && pSoldier->bTeam != gbPlayerNum ) { TacticalRemoveSoldier( pSoldier->ubID ); @@ -1636,7 +1636,7 @@ void HandleHelicopterOnGroundSkyriderProfile( void ) // see if we can find him and remove him if so.... pSoldier = FindSoldierByProfileID( SKYRIDER, FALSE ); - // ATE: Don't do this if buddy is on our team! + // ATE: Don't do this if buddy is on our team! if ( pSoldier != NULL && pSoldier->bTeam != gbPlayerNum ) { TacticalRemoveSoldier( pSoldier->ubID ); @@ -1682,7 +1682,7 @@ BOOLEAN IsHelicopterOnGroundAtRefuelingSite( UINT8 ubRefuelingSite ) // on the ground, but is it at this site or at another one? if ( ( ubRefuelList[ ubRefuelingSite ][ 0 ] == pVehicleList[ iHelicopterVehicleId ].sSectorX ) && - ( ubRefuelList[ ubRefuelingSite ][ 1 ] == pVehicleList[ iHelicopterVehicleId ].sSectorY ) ) + ( ubRefuelList[ ubRefuelingSite ][ 1 ] == pVehicleList[ iHelicopterVehicleId ].sSectorY ) ) { return(TRUE); } @@ -1718,7 +1718,7 @@ BOOLEAN WillAirRaidBeStopped( INT16 sSectorX, INT16 sSectorY ) DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("WillAirRaidBeStopped: enemy has no more airports")); return( TRUE ); } - + // which SAM controls this sector? ubSamNumber = ubSAMControlledSectors[ sSectorY ][ sSectorX ]; @@ -1849,16 +1849,16 @@ BOOLEAN HandleSAMSiteAttackOfHelicopterInSector( INT16 sSectorX, INT16 sSectorY // everyone die die die // play sound if ( PlayJA2StreamingSampleFromFile( "stsounds\\blah2.wav", RATE_11025, HIGHVOLUME, 1, MIDDLEPAN, HeliCrashSoundStopCallback ) == SOUND_ERROR ) - { - // Destroy here if we cannot play streamed sound sample.... - SkyriderDestroyed( ); - } - else - { - // otherwise it's handled in the callback - // remove any arrival events for the helicopter's group - DeleteStrategicEvent( EVENT_GROUP_ARRIVAL, pVehicleList[ iHelicopterVehicleId ].ubMovementGroup ); - } + { + // Destroy here if we cannot play streamed sound sample.... + SkyriderDestroyed( ); + } + else + { + // otherwise it's handled in the callback + // remove any arrival events for the helicopter's group + DeleteStrategicEvent( EVENT_GROUP_ARRIVAL, pVehicleList[ iHelicopterVehicleId ].ubMovementGroup ); + } // special return code indicating heli was destroyed return( TRUE ); @@ -1924,7 +1924,7 @@ void AddHeliPeice( INT16 sGridNo, UINT16 sOStruct ) void AddHelicopterToMaps( BOOLEAN fAdd, UINT8 ubSite ) { - INT16 sGridNo = sRefuelStartGridNo[ ubSite ]; + INT16 sGridNo = sRefuelStartGridNo[ ubSite ]; INT16 sOStruct = 0; INT16 usGridNo; INT16 sGridX, sGridY; @@ -1941,7 +1941,7 @@ void AddHelicopterToMaps( BOOLEAN fAdd, UINT8 ubSite ) // estoni sOStruct = FOURTHOSTRUCT1; } - + // are we adding or taking away if( fAdd ) @@ -1956,18 +1956,18 @@ void AddHelicopterToMaps( BOOLEAN fAdd, UINT8 ubSite ) InvalidateWorldRedundency(); SetRenderFlags( RENDER_FLAG_FULL ); - // ATE: If any mercs here, bump them off! - ConvertGridNoToXY( sGridNo, &sCentreGridX, &sCentreGridY ); + // ATE: If any mercs here, bump them off! + ConvertGridNoToXY( sGridNo, &sCentreGridX, &sCentreGridY ); - for( sGridY = sCentreGridY - 5; sGridY < sCentreGridY + 5; sGridY++ ) - { - for( sGridX = sCentreGridX - 5; sGridX < sCentreGridX + 5; sGridX++ ) - { - usGridNo = MAPROWCOLTOPOS( sGridY, sGridX ); + for( sGridY = sCentreGridY - 5; sGridY < sCentreGridY + 5; sGridY++ ) + { + for( sGridX = sCentreGridX - 5; sGridX < sCentreGridX + 5; sGridX++ ) + { + usGridNo = MAPROWCOLTOPOS( sGridY, sGridX ); - BumpAnyExistingMerc( usGridNo ); - } - } + BumpAnyExistingMerc( usGridNo ); + } + } } else { @@ -2011,8 +2011,8 @@ BOOLEAN IsSkyriderIsFlyingInSector( INT16 sSectorX, INT16 sSectorY ) BOOLEAN IsGroupTheHelicopterGroup( GROUP *pGroup ) { if( ( iHelicopterVehicleId != -1 ) && VehicleIdIsValid( iHelicopterVehicleId ) && - ( pVehicleList[ iHelicopterVehicleId ].ubMovementGroup != 0 ) && - ( pVehicleList[ iHelicopterVehicleId ].ubMovementGroup == pGroup->ubGroupID ) ) + ( pVehicleList[ iHelicopterVehicleId ].ubMovementGroup != 0 ) && + ( pVehicleList[ iHelicopterVehicleId ].ubMovementGroup == pGroup->ubGroupID ) ) { return( TRUE ); } @@ -2026,7 +2026,7 @@ INT16 GetNumSafeSectorsInPath( void ) // get the last sector value in the helictoper's path PathStPtr pNode = NULL; UINT32 uiLocation = 0; - UINT32 uiCount = 0; + UINT32 uiCount = 0; INT32 iHeliSector = -1; GROUP *pGroup; @@ -2052,7 +2052,7 @@ INT16 GetNumSafeSectorsInPath( void ) // first node: skip it if that's the sector the chopper is currently in, AND // we're NOT gonna be changing directions (not actually performed until waypoints are rebuilt AFTER plotting is done) if ( ( ( INT32 ) pNode->uiSectorId == iHeliSector ) && ( pNode->pNext != NULL ) && - !GroupBetweenSectorsAndSectorXYIsInDifferentDirection( pGroup, ( UINT8 ) GET_X_FROM_STRATEGIC_INDEX( pNode->pNext->uiSectorId ), ( UINT8 ) GET_Y_FROM_STRATEGIC_INDEX( pNode->pNext->uiSectorId ) ) ) + !GroupBetweenSectorsAndSectorXYIsInDifferentDirection( pGroup, ( UINT8 ) GET_X_FROM_STRATEGIC_INDEX( pNode->pNext->uiSectorId ), ( UINT8 ) GET_Y_FROM_STRATEGIC_INDEX( pNode->pNext->uiSectorId ) ) ) { pNode = pNode->pNext; } @@ -2061,17 +2061,17 @@ INT16 GetNumSafeSectorsInPath( void ) { uiLocation = pNode -> uiSectorId; - if ( !StrategicMap[ uiLocation ].fEnemyAirControlled ) - { - uiCount++; - } + if ( !StrategicMap[ uiLocation ].fEnemyAirControlled ) + { + uiCount++; + } pNode = pNode ->pNext; } } - pNode = MoveToBeginningOfPathList( pTempHelicopterPath ); + pNode = MoveToBeginningOfPathList( pTempHelicopterPath ); // any path yet? if( pNode != NULL ) { @@ -2079,8 +2079,8 @@ INT16 GetNumSafeSectorsInPath( void ) // we're NOT gonna be changing directions (not actually performed until waypoints are rebuilt AFTER plotting is done) // OR if the chopper has a mercpath, in which case this a continuation of it that would count the sector twice if ( ( ( ( INT32 ) pNode->uiSectorId == iHeliSector ) && ( pNode->pNext != NULL ) && - !GroupBetweenSectorsAndSectorXYIsInDifferentDirection( pGroup, ( UINT8 ) GET_X_FROM_STRATEGIC_INDEX( pNode->pNext->uiSectorId ), ( UINT8 ) GET_Y_FROM_STRATEGIC_INDEX( pNode->pNext->uiSectorId ) ) ) || - ( GetLengthOfPath( pVehicleList[ iHelicopterVehicleId ].pMercPath ) > 0 ) ) + !GroupBetweenSectorsAndSectorXYIsInDifferentDirection( pGroup, ( UINT8 ) GET_X_FROM_STRATEGIC_INDEX( pNode->pNext->uiSectorId ), ( UINT8 ) GET_Y_FROM_STRATEGIC_INDEX( pNode->pNext->uiSectorId ) ) ) || + ( GetLengthOfPath( pVehicleList[ iHelicopterVehicleId ].pMercPath ) > 0 ) ) { pNode = pNode->pNext; } @@ -2089,10 +2089,10 @@ INT16 GetNumSafeSectorsInPath( void ) { uiLocation = pNode -> uiSectorId; - if ( !StrategicMap[ uiLocation ].fEnemyAirControlled ) - { - uiCount++; - } + if ( !StrategicMap[ uiLocation ].fEnemyAirControlled ) + { + uiCount++; + } pNode = pNode ->pNext; } @@ -2107,7 +2107,7 @@ INT16 GetNumUnSafeSectorsInPath( void ) // get the last sector value in the helictoper's path PathStPtr pNode = NULL; UINT32 uiLocation = 0; - UINT32 uiCount = 0; + UINT32 uiCount = 0; INT32 iHeliSector = -1; GROUP *pGroup; @@ -2134,7 +2134,7 @@ INT16 GetNumUnSafeSectorsInPath( void ) // first node: skip it if that's the sector the chopper is currently in, AND // we're NOT gonna be changing directions (not actually performed until waypoints are rebuilt AFTER plotting is done) if ( ( ( INT32 ) pNode->uiSectorId == iHeliSector ) && ( pNode->pNext != NULL ) && - !GroupBetweenSectorsAndSectorXYIsInDifferentDirection( pGroup, ( UINT8 ) GET_X_FROM_STRATEGIC_INDEX( pNode->pNext->uiSectorId ), ( UINT8 ) GET_Y_FROM_STRATEGIC_INDEX( pNode->pNext->uiSectorId ) ) ) + !GroupBetweenSectorsAndSectorXYIsInDifferentDirection( pGroup, ( UINT8 ) GET_X_FROM_STRATEGIC_INDEX( pNode->pNext->uiSectorId ), ( UINT8 ) GET_Y_FROM_STRATEGIC_INDEX( pNode->pNext->uiSectorId ) ) ) { pNode = pNode->pNext; } @@ -2143,16 +2143,16 @@ INT16 GetNumUnSafeSectorsInPath( void ) { uiLocation = pNode -> uiSectorId; - if ( StrategicMap[ uiLocation ].fEnemyAirControlled ) - { - uiCount++; - } + if ( StrategicMap[ uiLocation ].fEnemyAirControlled ) + { + uiCount++; + } pNode = pNode ->pNext; } } - pNode = MoveToBeginningOfPathList( pTempHelicopterPath ); + pNode = MoveToBeginningOfPathList( pTempHelicopterPath ); // any path yet? if( pNode != NULL ) { @@ -2160,8 +2160,8 @@ INT16 GetNumUnSafeSectorsInPath( void ) // we're NOT gonna be changing directions (not actually performed until waypoints are rebuilt AFTER plotting is done) // OR if the chopper has a mercpath, in which case this a continuation of it that would count the sector twice if ( ( ( ( INT32 ) pNode->uiSectorId == iHeliSector ) && ( pNode->pNext != NULL ) && - !GroupBetweenSectorsAndSectorXYIsInDifferentDirection( pGroup, ( UINT8 ) GET_X_FROM_STRATEGIC_INDEX( pNode->pNext->uiSectorId ), ( UINT8 ) GET_Y_FROM_STRATEGIC_INDEX( pNode->pNext->uiSectorId ) ) ) || - ( GetLengthOfPath( pVehicleList[ iHelicopterVehicleId ].pMercPath ) > 0 ) ) + !GroupBetweenSectorsAndSectorXYIsInDifferentDirection( pGroup, ( UINT8 ) GET_X_FROM_STRATEGIC_INDEX( pNode->pNext->uiSectorId ), ( UINT8 ) GET_Y_FROM_STRATEGIC_INDEX( pNode->pNext->uiSectorId ) ) ) || + ( GetLengthOfPath( pVehicleList[ iHelicopterVehicleId ].pMercPath ) > 0 ) ) { pNode = pNode->pNext; } @@ -2170,10 +2170,10 @@ INT16 GetNumUnSafeSectorsInPath( void ) { uiLocation = pNode -> uiSectorId; - if ( StrategicMap[ uiLocation ].fEnemyAirControlled ) - { - uiCount++; - } + if ( StrategicMap[ uiLocation ].fEnemyAirControlled ) + { + uiCount++; + } pNode = pNode ->pNext; } diff --git a/Strategic/Map Screen Interface Map.cpp b/Strategic/Map Screen Interface Map.cpp index d48beb4f..6477edc8 100644 --- a/Strategic/Map Screen Interface Map.cpp +++ b/Strategic/Map Screen Interface Map.cpp @@ -6387,6 +6387,9 @@ void HandleLowerLevelMapBlit( void ) case( 3 ): GetVideoObject( &hHandle, guiSubLevel3 ); break; + default: + AssertMsg( 0, "Invalid underground sector level"); + return; } // handle the blt of the sublevel diff --git a/Strategic/Meanwhile.cpp b/Strategic/Meanwhile.cpp index cfa45eb7..c744d7a2 100644 --- a/Strategic/Meanwhile.cpp +++ b/Strategic/Meanwhile.cpp @@ -761,6 +761,7 @@ void ProcessImplicationsOfMeanwhile( void ) else { Assert( 0 ); + return; } gMercProfiles[ MADLAB ].sSectorX = sSectorX; gMercProfiles[ MADLAB ].sSectorY = sSectorY; diff --git a/Strategic/PreBattle Interface.cpp b/Strategic/PreBattle Interface.cpp index 10ba6e8b..9bb7c572 100644 --- a/Strategic/PreBattle Interface.cpp +++ b/Strategic/PreBattle Interface.cpp @@ -1745,7 +1745,7 @@ void PutNonSquadMercsInPlayerGroupOnSquads( GROUP *pGroup, BOOLEAN fExitVehicles PLAYERGROUP *pPlayer, *pNextPlayer; SOLDIERTYPE *pSoldier; INT8 bUniqueVehicleSquad = -1; - BOOLEAN fSuccess; + BOOLEAN fSuccess = FALSE; if ( pGroup->fVehicle ) diff --git a/Strategic/Queen Command.cpp b/Strategic/Queen Command.cpp index 671cf54e..22456056 100644 --- a/Strategic/Queen Command.cpp +++ b/Strategic/Queen Command.cpp @@ -1341,7 +1341,9 @@ void AddPossiblePendingEnemiesToBattle() else if( pGroup->ubSectorY > pGroup->ubPrevY ) ubInsertionCode = INSERTION_CODE_NORTH; else + { Assert(0); + } } else if( pGroup->ubNextX && pGroup->ubNextY ) { @@ -1354,11 +1356,15 @@ void AddPossiblePendingEnemiesToBattle() else if( pGroup->ubSectorY > pGroup->ubNextY ) ubInsertionCode = INSERTION_CODE_NORTH; else + { Assert(0); + } } else + { // The group has no movement orders. Where did it come from? Assert(0); + } if( pGroup->pEnemyGroup->ubElitesInBattle < pGroup->pEnemyGroup->ubNumElites ) { //Add an elite troop diff --git a/Strategic/Reinforcement.cpp b/Strategic/Reinforcement.cpp index a7413e38..e9399a42 100644 --- a/Strategic/Reinforcement.cpp +++ b/Strategic/Reinforcement.cpp @@ -1,28 +1,29 @@ #ifdef PRECOMPILEDHEADERS - #include "Strategic All.h" +#include "Strategic All.h" #else - #include "Town Militia.h" - #include "Militia Control.h" - #include "Campaign Types.h" - #include "strategic.h" - #include "strategicmap.h" - #include "Overhead.h" - #include "Strategic Town Loyalty.h" - #include "Utilities.h" - #include "random.h" - #include "text.h" - #include "Map Screen Interface.h" - #include "Interface.h" - #include "Laptopsave.h" - #include "finances.h" - #include "Game Clock.h" - #include "Assignments.h" - #include "squads.h" - #include "Soldier Create.h" - #include "Dialogue Control.h" - #include "Queen Command.h" - #include "GameSettings.h" - #include "Soldier Init List.h" +#include "Town Militia.h" +#include "Militia Control.h" +#include "Campaign Types.h" +#include "strategic.h" +#include "strategicmap.h" +#include "Overhead.h" +#include "Strategic Town Loyalty.h" +#include "Utilities.h" +#include "random.h" +#include "text.h" +#include "Map Screen Interface.h" +#include "Interface.h" +#include "Laptopsave.h" +#include "finances.h" +#include "Game Clock.h" +#include "Assignments.h" +#include "squads.h" +#include "Soldier Create.h" +#include "Dialogue Control.h" +#include "Queen Command.h" +#include "GameSettings.h" +#include "Soldier Init List.h" +#include "Inventory Choosing.h" #endif #include "Reinforcement.h" @@ -35,7 +36,7 @@ void GetNumberOfEnemiesInFiveSectors( INT16 sSectorX, INT16 sSectorY, UINT8 *pub UINT8 ubNumAdmins, ubNumTroops, ubNumElites; UINT16 pusMoveDir[4][3]; UINT8 ubDirNumber, ubIndex; - + GetNumberOfStationaryEnemiesInSector( sSectorX, sSectorY, pubNumAdmins, pubNumTroops, pubNumElites ); GetNumberOfMobileEnemiesInSectorWithoutRoadBlock( sSectorX, sSectorY, &ubNumAdmins, &ubNumTroops, &ubNumElites ); @@ -73,7 +74,7 @@ void GetNumberOfEnemiesInFiveSectors( INT16 sSectorX, INT16 sSectorY, UINT8 *pub ubNumAdmins--; } } - + GetNumberOfMobileEnemiesInSectorWithoutRoadBlock( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ), &ubNumAdmins, &ubNumTroops, &ubNumElites ); @@ -88,7 +89,7 @@ UINT8 NumEnemiesInFiveSectors( INT16 sMapX, INT16 sMapY ) UINT8 ubNumAdmins, ubNumTroops, ubNumElites; GetNumberOfEnemiesInFiveSectors( sMapX, sMapY, &ubNumAdmins, &ubNumTroops, &ubNumElites ); - + return ubNumAdmins + ubNumTroops + ubNumElites; } @@ -133,7 +134,7 @@ UINT8 CountAllMilitiaInFiveSectors(INT16 sMapX, INT16 sMapY) UINT8 ubResult = 0; UINT16 pusMoveDir[4][3]; UINT8 ubDirNumber, ubIndex; - + ubResult = CountAllMilitiaInSector( sMapX, sMapY ); if( !gGameExternalOptions.gfAllowReinforcements ) @@ -154,7 +155,7 @@ UINT8 MilitiaInFiveSectorsOfRank( INT16 sMapX, INT16 sMapY, UINT8 ubRank ) UINT8 ubResult = 0; UINT16 pusMoveDir[4][3]; UINT8 ubDirNumber, ubIndex; - + ubResult = MilitiaInSectorOfRank( sMapX, sMapY, ubRank ); if( !gGameExternalOptions.gfAllowReinforcements ) @@ -166,7 +167,7 @@ UINT8 MilitiaInFiveSectorsOfRank( INT16 sMapX, INT16 sMapY, UINT8 ubRank ) for( ubIndex = 0; ubIndex < ubDirNumber; ubIndex++ ) ubResult += MilitiaInSectorOfRank( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ), ubRank ); - + return ubResult; } @@ -176,13 +177,13 @@ BOOLEAN ARMoveBestMilitiaManFromAdjacentSector(INT16 sMapX, INT16 sMapY) UINT16 pusMoveDir[4][3]; UINT8 ubDirNumber; UINT8 ubRandom; - + if( !gGameExternalOptions.gfAllowReinforcements ) return FALSE; if( CountAllMilitiaInSector( sMapX, sMapY ) >= gGameExternalOptions.guiMaxMilitiaSquadSize || CountAllMilitiaInFiveSectors( sMapX, sMapY ) - CountAllMilitiaInSector( sMapX, sMapY ) == 0 ) - return FALSE; + return FALSE; GenerateDirectionInfos( sMapX, sMapY, &ubDirNumber, pusMoveDir, ( GetTownIdForSector( sMapX, sMapY ) != BLANK_SECTOR ? TRUE : FALSE ), TRUE, IS_ONLY_IN_CITIES ); @@ -191,7 +192,7 @@ BOOLEAN ARMoveBestMilitiaManFromAdjacentSector(INT16 sMapX, INT16 sMapY) while( !MoveOneBestMilitiaMan( SECTORX( pusMoveDir[ ubRandom ][ 0 ] ), SECTORY( pusMoveDir[ ubRandom ][ 0 ] ), sMapX, sMapY ) ) ubRandom = Random( ubDirNumber ); - + return TRUE; } @@ -199,7 +200,7 @@ BOOLEAN ARRemoveMilitiaMan( INT16 sMapX, INT16 sMapY, UINT8 ubRank ) { UINT16 pusMoveDir[4][3]; UINT8 ubDirNumber, ubRandom; - + if( MilitiaInSectorOfRank( sMapX, sMapY, ubRank ) ) { StrategicRemoveMilitiaFromSector( sMapX, sMapY, ubRank, 1 ); @@ -260,78 +261,24 @@ UINT8 DoReinforcementAsPendingEnemy( INT16 sMapX, INT16 sMapY ) GenerateDirectionInfos( sMapX, sMapY, &ubDirNumber, pusMoveDir, ( GetTownIdForSector( sMapX, sMapY ) != BLANK_SECTOR ? TRUE : FALSE ), TRUE, IS_ONLY_IN_CITIES ); - -#if 0 - // Combine this with the next part so that reinforcements from enemy groups can also come in from random sides for( ubIndex = 0; ubIndex < ubDirNumber; ubIndex++ ) - if( NumMobileEnemiesInSector( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) && GetEnemyGroupInSector( SECTORX( pusMoveDir[ ubIndex][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) ) + { + while ((pGroup = GetEnemyGroupInSector( SECTORX( pusMoveDir[ ubIndex][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) ) != NULL) { - pGroup = GetEnemyGroupInSector( SECTORX( pusMoveDir[ ubIndex][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ); - pGroup->ubPrevX = pGroup->ubSectorX; pGroup->ubPrevY = pGroup->ubSectorY; pGroup->ubSectorX = pGroup->ubNextX = (UINT8)sMapX; pGroup->ubSectorY = pGroup->ubNextY = (UINT8)sMapY; - return (UINT8)pusMoveDir[ ubIndex ][ 2 ]; + gfPendingEnemies = TRUE; + ResetMortarsOnTeamCount(); } -#endif + } - if( NumEnemiesInFiveSectors( sMapX, sMapY ) - NumEnemiesInSector( sMapX, sMapY ) == 0 ) - { - return 255; - }else - for(;;) + while( ubDirNumber > 0) { ubIndex = Random(ubDirNumber); -#if 0 -// This should be handled in AddPossiblePendingEnemiesToBattle - if( NumMobileEnemiesInSector( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) && GetEnemyGroupInSector( SECTORX( pusMoveDir[ ubIndex][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) ) - { - UINT8 numElite; - UINT8 numTroop; - UINT8 numAdmin; - - pGroup = GetEnemyGroupInSector( SECTORX( pusMoveDir[ ubIndex][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ); - pEnemyGroup = pGroup->pEnemyGroup; - numElite = pEnemyGroup->ubNumElites - pEnemyGroup->ubElitesInBattle; - numTroop = pEnemyGroup->ubNumTroops - pEnemyGroup->ubTroopsInBattle; - numAdmin = pEnemyGroup->ubNumAdmins - pEnemyGroup->ubAdminsInBattle; - - if (numElite + numTroop + numAdmin <= 1) - { - // The entire group has finally moved into the sector. - pGroup->ubPrevX = pGroup->ubSectorX; - pGroup->ubPrevY = pGroup->ubSectorY; - - pGroup->ubSectorX = pGroup->ubNextX = (UINT8)sMapX; - pGroup->ubSectorY = pGroup->ubNextY = (UINT8)sMapY; - - return (UINT8)pusMoveDir[ ubIndex ][ 2 ]; - } - - if (numAdmin + numTroop + numElite) - { - // Otherwise we move a soldier into the sector from the group - if( numElite ) - { - (pThisSector->ubNumElites)++; - (pEnemyGroup->ubElitesInBattle)++; - }else if( numTroop ) - { - (pThisSector->ubNumTroops)++; - (pEnemyGroup->ubTroopsInBattle)++; - }else if( numAdmin ) - { - (pThisSector->ubNumAdmins)++; - (pEnemyGroup->ubAdminsInBattle)++; - } - - return (UINT8)pusMoveDir[ ubIndex ][ 2 ]; - } - } -#endif if( NumEnemiesInSector( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) > gubReinforcementMinEnemyStaticGroupSize ) { @@ -363,7 +310,15 @@ UINT8 DoReinforcementAsPendingEnemy( INT16 sMapX, INT16 sMapY ) return (UINT8)pusMoveDir[ ubIndex ][ 2 ]; } + else + { + // If there are no reinforcements from this direction, remove this as a direction + memcpy( &(pusMoveDir[ubIndex][0]), &(pusMoveDir[ --ubDirNumber][0]), sizeof(pusMoveDir[0])); + } } + + // No reinforcements from other sectors are available + return 255; } @@ -391,7 +346,7 @@ UINT8 DoReinforcementAsPendingMilitia( INT16 sMapX, INT16 sMapY, UINT8 *pubRank if( !gGameExternalOptions.gfAllowReinforcements ) return 255; -// pThisSector = &SectorInfo[ SECTOR( sMapX, sMapY ) ]; + // pThisSector = &SectorInfo[ SECTOR( sMapX, sMapY ) ]; GenerateDirectionInfos( sMapX, sMapY, &ubDirNumber, pusMoveDir, ( GetTownIdForSector( sMapX, sMapY ) != BLANK_SECTOR ? TRUE : FALSE ), TRUE, IS_ONLY_IN_CITIES ); @@ -402,33 +357,33 @@ UINT8 DoReinforcementAsPendingMilitia( INT16 sMapX, INT16 sMapY, UINT8 *pubRank return 255; }else for(;;) - { - ubIndex = Random(ubDirNumber); - if( CountAllMilitiaInSector( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) ) { - pSector = &SectorInfo[ pusMoveDir[ ubIndex ][ 0 ] ]; + ubIndex = Random(ubDirNumber); + if( CountAllMilitiaInSector( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) ) + { + pSector = &SectorInfo[ pusMoveDir[ ubIndex ][ 0 ] ]; - if( pSector->ubNumberOfCivsAtLevel[ ELITE_MILITIA ] ) - { - StrategicAddMilitiaToSector( sMapX, sMapY,ELITE_MILITIA, 1 ); - StrategicRemoveMilitiaFromSector( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ),ELITE_MILITIA, 1 ); - *pubRank = ELITE_MILITIA; - }else if( pSector->ubNumberOfCivsAtLevel[ REGULAR_MILITIA ] ) - { - StrategicAddMilitiaToSector( sMapX, sMapY,REGULAR_MILITIA, 1 ); - StrategicRemoveMilitiaFromSector( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ),REGULAR_MILITIA, 1 ); - *pubRank = REGULAR_MILITIA; - }else if( pSector->ubNumberOfCivsAtLevel[ GREEN_MILITIA ] ) - { - StrategicAddMilitiaToSector( sMapX, sMapY,GREEN_MILITIA, 1 ); - StrategicRemoveMilitiaFromSector( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ),GREEN_MILITIA, 1 ); - *pubRank = GREEN_MILITIA; + if( pSector->ubNumberOfCivsAtLevel[ ELITE_MILITIA ] ) + { + StrategicAddMilitiaToSector( sMapX, sMapY,ELITE_MILITIA, 1 ); + StrategicRemoveMilitiaFromSector( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ),ELITE_MILITIA, 1 ); + *pubRank = ELITE_MILITIA; + }else if( pSector->ubNumberOfCivsAtLevel[ REGULAR_MILITIA ] ) + { + StrategicAddMilitiaToSector( sMapX, sMapY,REGULAR_MILITIA, 1 ); + StrategicRemoveMilitiaFromSector( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ),REGULAR_MILITIA, 1 ); + *pubRank = REGULAR_MILITIA; + }else if( pSector->ubNumberOfCivsAtLevel[ GREEN_MILITIA ] ) + { + StrategicAddMilitiaToSector( sMapX, sMapY,GREEN_MILITIA, 1 ); + StrategicRemoveMilitiaFromSector( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ),GREEN_MILITIA, 1 ); + *pubRank = GREEN_MILITIA; + } + + return (UINT8)pusMoveDir[ ubIndex ][ 2 ]; } - - return (UINT8)pusMoveDir[ ubIndex ][ 2 ]; } - } - + } @@ -441,42 +396,42 @@ void AddPossiblePendingMilitiaToBattle() static UINT8 ubPredefinedInsertionCode = 255; static UINT8 ubPredefinedRank = 255; -// if( !PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, 0 ) || !CountAllMilitiaInSector( gWorldSectorX, gWorldSectorY ) -// || !NumEnemiesInSector( gWorldSectorX, gWorldSectorY ) ) return; + // if( !PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, 0 ) || !CountAllMilitiaInSector( gWorldSectorX, gWorldSectorY ) + // || !NumEnemiesInSector( gWorldSectorX, gWorldSectorY ) ) return; if( !PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, 0 ) || !(gTacticalStatus.uiFlags & WANT_MILITIA_REINFORCEMENTS) || !NumEnemiesInSector( gWorldSectorX, gWorldSectorY ) ) return; -//gGameExternalOptions.guiMaxMilitiaSquadSize - CountAllMilitiaInSector( gWorldSectorX, gWorldSectorY ); + //gGameExternalOptions.guiMaxMilitiaSquadSize - CountAllMilitiaInSector( gWorldSectorX, gWorldSectorY ); ubSlots = NumFreeMilitiaSlots(); if( !ubSlots ) { //no available slots to add militia to. Try again later... return; } - + if( ubPredefinedInsertionCode != 255 && ubPredefinedRank != 255 && CountAllMilitiaInSector( gWorldSectorX, gWorldSectorY ) ) { ubNumElites = ubNumRegulars = ubNumGreens = 0; - // while( ubSlots ) + // while( ubSlots ) switch( ubPredefinedRank ) { - case ELITE_MILITIA: - ubSlots--; - ubNumElites++; - break; - case REGULAR_MILITIA: - ubSlots--; - ubNumRegulars++; - break; - case GREEN_MILITIA: - ubSlots--; - ubNumGreens++; - break; - default: - ubSlots--; + case ELITE_MILITIA: + ubSlots--; + ubNumElites++; + break; + case REGULAR_MILITIA: + ubSlots--; + ubNumRegulars++; + break; + case GREEN_MILITIA: + ubSlots--; + ubNumGreens++; + break; + default: + ubSlots--; } if( ubNumGreens || ubNumRegulars || ubNumElites ) @@ -488,7 +443,7 @@ void AddPossiblePendingMilitiaToBattle() if( ubSlots ) { //After going through the process, we have finished with some free slots and no more enemies to add. - //So, we can turn off the flag, as this check is no longer needed. + //So, we can turn off the flag, as this check is no longer needed. ubPredefinedInsertionCode = DoReinforcementAsPendingMilitia( gWorldSectorX, gWorldSectorY, &ubPredefinedRank ); if( ubPredefinedInsertionCode != 255 ) diff --git a/Strategic/Strategic Turns.cpp b/Strategic/Strategic Turns.cpp index 740d4059..b82cbea0 100644 --- a/Strategic/Strategic Turns.cpp +++ b/Strategic/Strategic Turns.cpp @@ -78,6 +78,9 @@ void HandleStrategicTurn( ) } else { + // If none of these conditions are true, then don't do an end of turn + uiCheckTime = 0xffffffff; + if ( giTimeCompressMode == TIME_COMPRESS_X1 || giTimeCompressMode == 0 ) { uiCheckTime = NUM_REAL_SEC_PER_TACTICAL_TURN; diff --git a/Strategic/Strategic_2005Express.vcproj b/Strategic/Strategic_2005Express.vcproj index 60c0f8ce..0629f18b 100644 --- a/Strategic/Strategic_2005Express.vcproj +++ b/Strategic/Strategic_2005Express.vcproj @@ -46,8 +46,9 @@ RuntimeLibrary="1" RuntimeTypeInfo="false" UsePrecompiledHeader="0" - WarningLevel="3" + WarningLevel="4" DebugInformationFormat="4" + DisableSpecificWarnings="4100" /> fTalking ) diff --git a/Tactical/Enemy Soldier Save.cpp b/Tactical/Enemy Soldier Save.cpp index 4e59e380..534ad043 100644 --- a/Tactical/Enemy Soldier Save.cpp +++ b/Tactical/Enemy Soldier Save.cpp @@ -35,7 +35,7 @@ #include "Scheduling.h" #endif -BOOLEAN AddPlacementToWorld( SOLDIERINITNODE *pNode ); +BOOLEAN AddPlacementToWorld( SOLDIERINITNODE *pNode, GROUP *pGroup = NULL ); BOOLEAN CountNumberOfElitesRegularsAdminsAndCreaturesFromEnemySoldiersTempFile( UINT8 *pubNumElites, UINT8 *pubNumRegulars, UINT8 *pubNumAdmins, UINT8 *pubNumCreatures ); diff --git a/Tactical/Handle Doors.cpp b/Tactical/Handle Doors.cpp index c81ba723..afc1ee5f 100644 --- a/Tactical/Handle Doors.cpp +++ b/Tactical/Handle Doors.cpp @@ -294,7 +294,7 @@ void InteractWithOpenableStruct( SOLDIERTYPE *pSoldier, STRUCTURE *pStructure, U { STRUCTURE * pBaseStructure; BOOLEAN fDoMenu = FALSE; - DOOR * pDoor; + DOOR * pDoor = NULL; DOOR_STATUS * pDoorStatus; BOOLEAN fTrapsFound = FALSE; diff --git a/Tactical/Handle Items.cpp b/Tactical/Handle Items.cpp index 2ca9c5b7..fd09c7de 100644 --- a/Tactical/Handle Items.cpp +++ b/Tactical/Handle Items.cpp @@ -1,65 +1,65 @@ #ifdef PRECOMPILEDHEADERS - #include "Tactical All.h" +#include "Tactical All.h" #else - #include "items.h" - #include "Action Items.h" - #include "handle Items.h" - #include "overhead.h" - #include "weapons.h" - #include "points.h" - #include "tiledef.h" - #include "worlddef.h" - #include "worldman.h" - #include "interface.h" - #include "renderworld.h" - #include "Animation Control.h" - #include "font control.h" - #include "render dirty.h" - #include "World items.h" - #include "text.h" - #include "Timer Control.h" - #include "wcheck.h" - #include "interface items.h" - #include "physics.h" - #include "soldier profile.h" - #include "interface dialogue.h" - #include "quests.h" - #include "message.h" - #include "isometric utils.h" - #include "los.h" - #include "dialogue control.h" - #include "ai.h" - #include "soldier macros.h" - #include "interface panels.h" - #include "Strategic Town Loyalty.h" - #include "soldier functions.h" - #include "Map Screen Helicopter.h" - #include "pathai.h" - #include "fov.h" - #include "MessageBoxScreen.h" - #include "explosion control.h" - #include "SkillCheck.h" - #include "Campaign.h" - #include "Random.h" - #include "structure wrap.h" - #include "interactive tiles.h" - #include "SaveLoadMap.h" - #include "ShopKeeper Interface.h" - #include "Arms Dealer Init.h" - #include "soldier add.h" - #include "sound control.h" - #include "squads.h" - #include "rotting corpses.h" - #include "soldier ani.h" - #include "Opplist.h" - #include "qarray.h" - #include "render fun.h" - #include "environment.h" - #include "Map Information.h" - #include "GameSettings.h" - #include "end game.h" - #include "interface control.h" - #include "Map Screen Interface Map Inventory.h" +#include "items.h" +#include "Action Items.h" +#include "handle Items.h" +#include "overhead.h" +#include "weapons.h" +#include "points.h" +#include "tiledef.h" +#include "worlddef.h" +#include "worldman.h" +#include "interface.h" +#include "renderworld.h" +#include "Animation Control.h" +#include "font control.h" +#include "render dirty.h" +#include "World items.h" +#include "text.h" +#include "Timer Control.h" +#include "wcheck.h" +#include "interface items.h" +#include "physics.h" +#include "soldier profile.h" +#include "interface dialogue.h" +#include "quests.h" +#include "message.h" +#include "isometric utils.h" +#include "los.h" +#include "dialogue control.h" +#include "ai.h" +#include "soldier macros.h" +#include "interface panels.h" +#include "Strategic Town Loyalty.h" +#include "soldier functions.h" +#include "Map Screen Helicopter.h" +#include "pathai.h" +#include "fov.h" +#include "MessageBoxScreen.h" +#include "explosion control.h" +#include "SkillCheck.h" +#include "Campaign.h" +#include "Random.h" +#include "structure wrap.h" +#include "interactive tiles.h" +#include "SaveLoadMap.h" +#include "ShopKeeper Interface.h" +#include "Arms Dealer Init.h" +#include "soldier add.h" +#include "sound control.h" +#include "squads.h" +#include "rotting corpses.h" +#include "soldier ani.h" +#include "Opplist.h" +#include "qarray.h" +#include "render fun.h" +#include "environment.h" +#include "Map Information.h" +#include "GameSettings.h" +#include "end game.h" +#include "interface control.h" +#include "Map Screen Interface Map Inventory.h" #endif #define NUM_ITEMS_LISTED 8 @@ -182,7 +182,7 @@ BOOLEAN HandleCheckForBadChangeToGetThrough( SOLDIERTYPE *pSoldier, SOLDIERTYPE -INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 usHandItem, BOOLEAN fFromUI ) +INT32 HandleItem( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bLevel, UINT16 usHandItem, BOOLEAN fFromUI ) { SOLDIERTYPE *pTargetSoldier = NULL; UINT16 usSoldierIndex; @@ -196,7 +196,6 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us BOOLEAN fAddingRaiseGunCost = FALSE; LEVELNODE *pIntNode; STRUCTURE *pStructure; - INT16 sGridNo; // Remove any previous actions @@ -207,8 +206,8 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us pSoldier->usAttackingWeapon = usHandItem; // Find soldier flags depend on if it's our own merc firing or a NPC - //if ( FindSoldier( usGridNo, &usSoldierIndex, &uiMercFlags, FIND_SOLDIER_GRIDNO ) ) - if ( ( usSoldierIndex = WhoIsThere2( usGridNo, bLevel ) ) != NO_SOLDIER ) + //if ( FindSoldier( sGridNo, &usSoldierIndex, &uiMercFlags, FIND_SOLDIER_GRIDNO ) ) + if ( ( usSoldierIndex = WhoIsThere2( sGridNo, bLevel ) ) != NO_SOLDIER ) { pTargetSoldier = MercPtrs[ usSoldierIndex ]; @@ -232,10 +231,10 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us gTacticalStatus.ubAttackBusyCount = 0; } -// if ( pTargetSoldier ) -// { -// pTargetSoldier->bBeingAttackedCount = 0; -// } + // if ( pTargetSoldier ) + // { + // pTargetSoldier->bBeingAttackedCount = 0; + // } // Check our soldier's life for unconscious! @@ -376,7 +375,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us } else { - sTargetGridNo = usGridNo; + sTargetGridNo = sGridNo; } // If it's a player guy, check ChanceToGetThrough to play quote @@ -626,6 +625,8 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us UINT8 ubGuyThere; INT16 sGotLocation = NOWHERE; BOOLEAN fGotAdjacent = FALSE; + sAdjustedGridNo = NOWHERE; + ubDirection = 0xff; for ( sCnt = 0; sCnt < NUM_WORLD_DIRECTIONS; sCnt++ ) { @@ -654,7 +655,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us if ( sGotLocation == NOWHERE ) { // See if we can get there to punch - sActionGridNo = FindAdjacentGridEx( pSoldier, usGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); + sActionGridNo = FindAdjacentGridEx( pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); if ( sActionGridNo != -1 ) { // OK, we've got somebody... @@ -667,9 +668,9 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us // Did we get a loaction? if ( sGotLocation != NOWHERE ) { - pSoldier->sTargetGridNo = usGridNo; + pSoldier->sTargetGridNo = sGridNo; - pSoldier->usActionData = usGridNo; + pSoldier->usActionData = sGridNo; // CHECK IF WE ARE AT THIS GRIDNO NOW if ( pSoldier->sGridNo != sGotLocation && fGotAdjacent ) { @@ -710,7 +711,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us if (gTacticalStatus.fAutoBandageMode) { - usMapPos = usGridNo; + usMapPos = sGridNo; } else { @@ -718,7 +719,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us } // See if we can get there to stab - sActionGridNo = FindAdjacentGridEx( pSoldier, usGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); + sActionGridNo = FindAdjacentGridEx( pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); if ( sActionGridNo == -1 ) { // Try another location... @@ -762,7 +763,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us } else { - pSoldier->sPendingActionData2 = usGridNo; + pSoldier->sPendingActionData2 = sGridNo; } } pSoldier->bPendingActionData3 = ubDirection; @@ -792,7 +793,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us if ( Item[usHandItem].wirecutters && pTargetSoldier == NULL ) // Madd: quick fix to allow wirecutter/knives { // See if we can get there to stab - sActionGridNo = FindAdjacentGridEx( pSoldier, usGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); + sActionGridNo = FindAdjacentGridEx( pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); if ( sActionGridNo != -1 ) { // Calculate AP costs... @@ -847,7 +848,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us INT16 sVehicleGridNo=-1; // For repair, check if we are over a vehicle, then get gridnot to edge of that vehicle! - if ( IsRepairableStructAtGridNo( usGridNo, &ubMercID ) == 2 ) + if ( IsRepairableStructAtGridNo( sGridNo, &ubMercID ) == 2 ) { INT16 sNewGridNo; UINT8 ubDirection; @@ -856,7 +857,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us if ( sNewGridNo != NOWHERE ) { - usGridNo = sNewGridNo; + sGridNo = sNewGridNo; sVehicleGridNo = MercPtrs[ ubMercID ]->sGridNo; @@ -865,7 +866,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us } // See if we can get there to stab - sActionGridNo = FindAdjacentGridEx( pSoldier, usGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); + sActionGridNo = FindAdjacentGridEx( pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); if ( sActionGridNo != -1 ) { @@ -925,7 +926,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us INT16 sVehicleGridNo=-1; // For repair, check if we are over a vehicle, then get gridnot to edge of that vehicle! - if ( IsRefuelableStructAtGridNo( usGridNo, &ubMercID ) ) + if ( IsRefuelableStructAtGridNo( sGridNo, &ubMercID ) ) { INT16 sNewGridNo; UINT8 ubDirection; @@ -934,7 +935,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us if ( sNewGridNo != NOWHERE ) { - usGridNo = sNewGridNo; + sGridNo = sNewGridNo; sVehicleGridNo = MercPtrs[ ubMercID ]->sGridNo; @@ -942,7 +943,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us } // See if we can get there to stab - sActionGridNo = FindAdjacentGridEx( pSoldier, usGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); + sActionGridNo = FindAdjacentGridEx( pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); if ( sActionGridNo != -1 ) { @@ -995,7 +996,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us if ( Item[usHandItem].jar ) { - sActionGridNo = FindAdjacentGridEx( pSoldier, usGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); + sActionGridNo = FindAdjacentGridEx( pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); if ( sActionGridNo != -1 ) { @@ -1049,12 +1050,12 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us LEVELNODE *pIntTile; // Get structure info for in tile! - pIntTile = GetCurInteractiveTileGridNoAndStructure( (INT16 *)&usGridNo, &pStructure ); + pIntTile = GetCurInteractiveTileGridNoAndStructure( (INT16 *)&sGridNo, &pStructure ); // We should not have null here if we are given this flag... if ( pIntTile != NULL ) { - sActionGridNo = FindAdjacentGridEx( pSoldier, usGridNo, &ubDirection, &sAdjustedGridNo, FALSE, TRUE ); + sActionGridNo = FindAdjacentGridEx( pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, FALSE, TRUE ); if ( sActionGridNo != -1 ) { @@ -1069,7 +1070,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us { // SEND PENDING ACTION pSoldier->ubPendingAction = MERC_ATTACH_CAN; - pSoldier->sPendingActionData2 = usGridNo; + pSoldier->sPendingActionData2 = sGridNo; pSoldier->bPendingActionData3 = ubDirection; pSoldier->ubPendingActionAnimCount = 0; @@ -1078,7 +1079,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us } else { - EVENT_SoldierBeginTakeBlood( pSoldier, usGridNo, ubDirection ); + EVENT_SoldierBeginTakeBlood( pSoldier, sGridNo, ubDirection ); } // OK, set UI @@ -1125,7 +1126,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us else // detonator { // Save gridno.... - pSoldier->sPendingActionData2 = usGridNo; + pSoldier->sPendingActionData2 = sGridNo; EVENT_SoldierBeginUseDetonator( pSoldier ); @@ -1164,16 +1165,16 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us if ( fDropBomb ) { // Save gridno.... - pSoldier->sPendingActionData2 = usGridNo; + pSoldier->sPendingActionData2 = sGridNo; - if ( pSoldier->sGridNo != usGridNo ) + if ( pSoldier->sGridNo != sGridNo ) { // SEND PENDING ACTION pSoldier->ubPendingAction = MERC_DROPBOMB; pSoldier->ubPendingActionAnimCount = 0; // WALK UP TO DEST FIRST - EVENT_InternalGetNewSoldierPath( pSoldier, usGridNo, pSoldier->usUIMovementMode, FALSE, TRUE ); + EVENT_InternalGetNewSoldierPath( pSoldier, sGridNo, pSoldier->usUIMovementMode, FALSE, TRUE ); } else { @@ -1197,19 +1198,19 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us // See if we can get there to stab if ( pSoldier->ubBodyType == BLOODCAT ) { - sActionGridNo = FindNextToAdjacentGridEx( pSoldier, usGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); + sActionGridNo = FindNextToAdjacentGridEx( pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); } - else if ( CREATURE_OR_BLOODCAT( pSoldier ) && PythSpacesAway( pSoldier->sGridNo, usGridNo ) > 1 ) + else if ( CREATURE_OR_BLOODCAT( pSoldier ) && PythSpacesAway( pSoldier->sGridNo, sGridNo ) > 1 ) { - sActionGridNo = FindNextToAdjacentGridEx( pSoldier, usGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); + sActionGridNo = FindNextToAdjacentGridEx( pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); if (sActionGridNo == -1) { - sActionGridNo = FindAdjacentGridEx( pSoldier, usGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); + sActionGridNo = FindAdjacentGridEx( pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); } } else { - sActionGridNo = FindAdjacentGridEx( pSoldier, usGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); + sActionGridNo = FindAdjacentGridEx( pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); } if ( sActionGridNo != -1 ) @@ -1260,7 +1261,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us //pSoldier->sLastTarget = sTargetGridNo; //pSoldier->ubTargetID = WhoIsThere2( sTargetGridNo, pSoldier->bTargetLevel ); -// gTacticalStatus.ubAttackBusyCount++; + // gTacticalStatus.ubAttackBusyCount++; DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("!!!!!!! Starting swipe attack, incrementing a.b.c in HandleItems to %d", gTacticalStatus.ubAttackBusyCount) ); DebugAttackBusy( "Swipe attack\n"); @@ -1290,7 +1291,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us } else { - sTargetGridNo = usGridNo; + sTargetGridNo = sGridNo; } sAPCost = MinAPsToAttack( pSoldier, sTargetGridNo, TRUE ); @@ -1347,7 +1348,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us pSoldier->ubTargetID = WhoIsThere2( sTargetGridNo, pSoldier->bTargetLevel ); // Increment attack counter... -// gTacticalStatus.ubAttackBusyCount++; + // gTacticalStatus.ubAttackBusyCount++; DebugAttackBusy( "Weapon fire\n"); @@ -1384,7 +1385,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 us // Found detonator... if ( IsDetonatorAttached ( &(pSoldier->inv[ usHandItem ] ) ) || IsRemoteDetonatorAttached( &(pSoldier->inv[ usHandItem ] ) ) ) { - StartBombMessageBox( pSoldier, usGridNo ); + StartBombMessageBox( pSoldier, sGridNo ); if ( fFromUI ) { @@ -1513,22 +1514,22 @@ void HandleSoldierThrowItem( SOLDIERTYPE *pSoldier, INT16 sGridNo ) // crouch throwing case ANIM_PRONE: - if ( sGridNo == pSoldier->sGridNo ) + if ( sGridNo == pSoldier->sGridNo ) + { + // OK, JUST DROP ITEM! + if ( pSoldier->pTempObject != NULL ) { - // OK, JUST DROP ITEM! - if ( pSoldier->pTempObject != NULL ) - { - AddItemToPool( sGridNo, pSoldier->pTempObject, 1, pSoldier->bLevel, 0, -1 ); - NotifySoldiersToLookforItems( ); + AddItemToPool( sGridNo, pSoldier->pTempObject, 1, pSoldier->bLevel, 0, -1 ); + NotifySoldiersToLookforItems( ); - MemFree( pSoldier->pTempObject ); - pSoldier->pTempObject = NULL; - } - break; + MemFree( pSoldier->pTempObject ); + pSoldier->pTempObject = NULL; } - ChangeSoldierStance( pSoldier, ANIM_CROUCH ); + break; + } + ChangeSoldierStance( pSoldier, ANIM_CROUCH ); - case ANIM_CROUCH: + case ANIM_CROUCH: // CHECK IF WE ARE NOT ON THE SAME GRIDNO if ( sGridNo == pSoldier->sGridNo ) { @@ -1544,18 +1545,18 @@ void HandleSoldierThrowItem( SOLDIERTYPE *pSoldier, INT16 sGridNo ) } else { - // CHANGE DIRECTION AT LEAST + // CHANGE DIRECTION AT LEAST ubDirection = (UINT8)GetDirectionFromGridNo( sGridNo, pSoldier ); - SoldierGotoStationaryStance( pSoldier ); + SoldierGotoStationaryStance( pSoldier ); EVENT_SetSoldierDesiredDirection( pSoldier, ubDirection ); - pSoldier->fTurningUntilDone = TRUE; + pSoldier->fTurningUntilDone = TRUE; - pSoldier->usPendingAnimation = THROW_ITEM_CROUCHED; + pSoldier->usPendingAnimation = THROW_ITEM_CROUCHED; } - break; -// + break; + // } } @@ -3474,17 +3475,17 @@ BOOLEAN DrawItemPoolList( ITEM_POOL *pItemPool, INT16 sGridNo, UINT8 bCommand, I // Set string if ( cnt == gbCurrentItemSel ) { - SetFontForeground( FONT_MCOLOR_LTGRAY ); - } - else - { - SetFontForeground( FONT_MCOLOR_DKGRAY ); - } + SetFontForeground( FONT_MCOLOR_LTGRAY ); + } + else + { + SetFontForeground( FONT_MCOLOR_DKGRAY ); + } swprintf( pStr, TacticalStr[ ITEMPOOL_POPUP_MORE_STR ] ); - gprintfdirty( sFontX, sY, pStr ); - mprintf( sFontX, sY, pStr ); - } - } + gprintfdirty( sFontX, sY, pStr ); + mprintf( sFontX, sY, pStr ); + } + } return( fSelectionDone ); @@ -5244,7 +5245,7 @@ INT16 FindNearestAvailableGridNoForItem( INT16 sSweetGridNo, INT8 ubRadius ) //create dummy soldier, and use the pathing to determine which nearby slots are //reachable. - // WDS - Clean up inventory handling + // WDS - Clean up inventory handling //memset( &soldier, 0, SIZEOF_SOLDIERTYPE ); soldier.initialize(); soldier.bTeam = 1; @@ -5351,7 +5352,7 @@ BOOLEAN CanPlayerUseRocketRifle( SOLDIERTYPE *pSoldier, BOOLEAN fDisplay ) UINT8 StealItems(SOLDIERTYPE* pSoldier,SOLDIERTYPE* pOpponent, UINT8* ubIndexRet) { UINT8 ubCount=0; - ITEM_POOL *pItemPool,*pTempItemPool,*pTempLastItemPool; + ITEM_POOL *pItemPool,*pTempItemPool,*pTempLastItemPool = NULL; OBJECTTYPE *pObject; UINT8 i; BOOLEAN fStealItem = FALSE; @@ -5362,7 +5363,7 @@ UINT8 StealItems(SOLDIERTYPE* pSoldier,SOLDIERTYPE* pOpponent, UINT8* ubIndexRet { fStealItem = FALSE; - // WDS - Clean up inventory handling + // WDS - Clean up inventory handling pObject=&pOpponent->inv[i]; if (pObject->usItem!=0) { @@ -5478,9 +5479,9 @@ void SoldierStealItemFromSoldier( SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, cnt++; if ( fPickup ) { - // WDS - Clean up inventory handling + // WDS - Clean up inventory handling // Make copy of item -// memcpy( &Object, pOpponent->inv+pTempItemPool->iItemIndex, sizeof( OBJECTTYPE ) ); + // memcpy( &Object, pOpponent->inv+pTempItemPool->iItemIndex, sizeof( OBJECTTYPE ) ); Object = pOpponent->inv[pTempItemPool->iItemIndex]; if ( ItemIsCool( &Object ) ) { diff --git a/Tactical/Handle Items.h b/Tactical/Handle Items.h index 4df1dcbc..65bf5e03 100644 --- a/Tactical/Handle Items.h +++ b/Tactical/Handle Items.h @@ -82,7 +82,7 @@ typedef struct // WDS - Clean up inventory handling class SOLDIERTYPE; -INT32 HandleItem( SOLDIERTYPE *pSoldier, UINT16 usGridNo, INT8 bLevel, UINT16 usHandItem, BOOLEAN fFromUI ); +INT32 HandleItem( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bLevel, UINT16 usHandItem, BOOLEAN fFromUI ); void SoldierPickupItem( SOLDIERTYPE *pSoldier, INT32 iItemIndex, INT16 sGridNo, INT8 bZLevel ); void HandleSoldierPickupItem( SOLDIERTYPE *pSoldier, INT32 iItemIndex, INT16 sGridNo, INT8 bZLevel ); void HandleFlashingItems( ); diff --git a/Tactical/Interface Dialogue.cpp b/Tactical/Interface Dialogue.cpp index c1065d71..f7e3be55 100644 --- a/Tactical/Interface Dialogue.cpp +++ b/Tactical/Interface Dialogue.cpp @@ -3597,7 +3597,7 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum case NPC_ACTION_START_DOCTORING: { - // reset fact he is expecting money fromt he player + // reset fact he is expecting money fromt the player SetFactFalse( FACT_VINCE_EXPECTING_MONEY ); // check fact diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index e98ce55d..19c9dcf7 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -2009,7 +2009,7 @@ void INVRenderItem( UINT32 uiBuffer, SOLDIERTYPE * pSoldier, OBJECTTYPE *pObjec { UINT16 uiStringLength; INVTYPE *pItem; - ETRLEObject *pTrav; + ETRLEObject *pTrav; UINT32 usHeight, usWidth; INT16 sCenX, sCenY, sNewY, sNewX; HVOBJECT hVObject; @@ -2050,7 +2050,7 @@ void INVRenderItem( UINT32 uiBuffer, SOLDIERTYPE * pSoldier, OBJECTTYPE *pObjec // Shadow area if(gGameSettings.fOptions[ TOPTION_SHOW_ITEM_SHADOW ]) BltVideoObjectOutlineShadowFromIndex( uiBuffer, GetInterfaceGraphicForItem( pItem ), pItem->ubGraphicNum, sCenX - 2, sCenY + 2 ); - + BltVideoObjectOutlineFromIndex( uiBuffer, GetInterfaceGraphicForItem( pItem ), pItem->ubGraphicNum, sCenX, sCenY, sOutlineColor, fOutline ); @@ -2106,7 +2106,7 @@ void INVRenderItem( UINT32 uiBuffer, SOLDIERTYPE * pSoldier, OBJECTTYPE *pObjec // SetFontForeground( FONT_MCOLOR_DKGRAY ); // break; //} - + swprintf( pStr, L"%d", pObject->ubGunShotsLeft ); if ( uiBuffer == guiSAVEBUFFER ) @@ -2234,7 +2234,7 @@ void INVRenderItem( UINT32 uiBuffer, SOLDIERTYPE * pSoldier, OBJECTTYPE *pObjec } mprintf( sNewX, sNewY, pStr ); gprintfinvalidate( sNewX, sNewY, pStr ); - + } @@ -2266,6 +2266,10 @@ void INVRenderItem( UINT32 uiBuffer, SOLDIERTYPE * pSoldier, OBJECTTYPE *pObjec sFontY = sY + 1; gprintfinvalidate( sFontX, sFontY, pStr ); + // Squelch the compiler warnings + sFontX2 = sX; + sFontY2 = sY; + if ( fLineSplit ) { VarFindFontCenterCoordinates( sX, sY, sWidth, sHeight , ITEM_FONT, &sFontX2, &sFontY2, pStr2 ); @@ -2273,25 +2277,24 @@ void INVRenderItem( UINT32 uiBuffer, SOLDIERTYPE * pSoldier, OBJECTTYPE *pObjec gprintfinvalidate( sFontX2, sFontY2, pStr2 ); } - } - - if ( *pubHighlightCounter == 2 ) - { - mprintf( sFontX, sFontY, pStr ); - - if ( fLineSplit ) + if ( *pubHighlightCounter == 2 ) { - mprintf( sFontX2, sFontY2, pStr2 ); + mprintf( sFontX, sFontY, pStr ); + + if ( fLineSplit ) + { + mprintf( sFontX2, sFontY2, pStr2 ); + } } - } - else if ( *pubHighlightCounter == 1 ) - { - *pubHighlightCounter = 0; - gprintfRestore( sFontX, sFontY, pStr ); - - if ( fLineSplit ) + else if ( *pubHighlightCounter == 1 ) { - gprintfRestore( sFontX2, sFontY2, pStr2 ); + *pubHighlightCounter = 0; + gprintfRestore( sFontX, sFontY, pStr ); + + if ( fLineSplit ) + { + gprintfRestore( sFontX2, sFontY2, pStr2 ); + } } } } @@ -4117,7 +4120,7 @@ void DeleteItemDescriptionBox( ) { INT32 cnt, cnt2; BOOLEAN fFound, fAllFound; - UINT8 ubAPCost; + UINT8 ubAPCost = 0; if( gfInItemDescBox == FALSE ) { diff --git a/Tactical/Interface Panels.cpp b/Tactical/Interface Panels.cpp index 86316630..d178b2ce 100644 --- a/Tactical/Interface Panels.cpp +++ b/Tactical/Interface Panels.cpp @@ -1827,7 +1827,7 @@ void RenderSMPanel( BOOLEAN *pfDirty ) INT16 sFontX, sFontY; INT16 usX, usY; CHAR16 sString[9]; - UINT32 cnt; + UINT32 cnt = 0xff000000; // Give a value that ought to crash it if this is really undefined for the robot static CHAR16 pStr[ 200 ], pMoraleStr[ 20 ]; if ( gubSelectSMPanelToMerc != NOBODY ) diff --git a/Tactical/Interface.cpp b/Tactical/Interface.cpp index eba801c4..ab2ea1a0 100644 --- a/Tactical/Interface.cpp +++ b/Tactical/Interface.cpp @@ -2968,7 +2968,7 @@ BOOLEAN AddTopMessage( UINT8 ubType, STR16 pzString ) void CreateTopMessage( UINT32 uiSurface, UINT8 ubType, STR16 psString ) { UINT32 uiBAR, uiPLAYERBAR, uiINTBAR; - VOBJECT_DESC VObjectDesc; + VOBJECT_DESC VObjectDesc; INT16 sX, sY; INT32 cnt2; INT16 sBarX = 0; @@ -2983,7 +2983,7 @@ void CreateTopMessage( UINT32 uiSurface, UINT8 ubType, STR16 psString ) if (iResolution == 0) { - FilenameForBPP("INTERFACE\\rect.sti", VObjectDesc.ImageFile); + FilenameForBPP("INTERFACE\\rect.sti", VObjectDesc.ImageFile); } else if (iResolution == 1) { @@ -2993,6 +2993,11 @@ void CreateTopMessage( UINT32 uiSurface, UINT8 ubType, STR16 psString ) { FilenameForBPP("INTERFACE\\rect_1024x768.sti", VObjectDesc.ImageFile); } + else + { + AssertMsg( 0, "Invalid resolution"); + return; + } if( !AddVideoObject( &VObjectDesc, &uiBAR ) ) AssertMsg(0, "Missing INTERFACE\\rect.sti" ); @@ -3003,40 +3008,44 @@ void CreateTopMessage( UINT32 uiSurface, UINT8 ubType, STR16 psString ) if (iResolution == 0) { FilenameForBPP("INTERFACE\\timebargreen.sti", VObjectDesc.ImageFile); - if( !AddVideoObject( &VObjectDesc, &uiPLAYERBAR ) ) - AssertMsg(0, "Missing INTERFACE\\timebargreen.sti" ); } else if (iResolution == 1) { FilenameForBPP("INTERFACE\\timebargreen_800x600.sti", VObjectDesc.ImageFile); - if( !AddVideoObject( &VObjectDesc, &uiPLAYERBAR ) ) - AssertMsg(0, "Missing INTERFACE\\timebargreen_800x600.sti" ); } else if (iResolution == 2) { FilenameForBPP("INTERFACE\\timebargreen_1024x768.sti", VObjectDesc.ImageFile); - if( !AddVideoObject( &VObjectDesc, &uiPLAYERBAR ) ) - AssertMsg(0, "Missing INTERFACE\\timebargreen_1024x768.sti" ); } + else + { + AssertMsg( 0, "Invalid resolution"); + return; + } + + if( !AddVideoObject( &VObjectDesc, &uiPLAYERBAR ) ) + AssertMsg(0, String( "Missing %s", VObjectDesc.ImageFile) ); if (iResolution == 0) { - FilenameForBPP("INTERFACE\\timebaryellow.sti", VObjectDesc.ImageFile); - if( !AddVideoObject( &VObjectDesc, &uiINTBAR ) ) - AssertMsg(0, "Missing INTERFACE\\timebaryellow.sti" ); + FilenameForBPP("INTERFACE\\timebaryellow.sti", VObjectDesc.ImageFile); } else if (iResolution == 1) { FilenameForBPP("INTERFACE\\timebaryellow_800x600.sti", VObjectDesc.ImageFile); - if( !AddVideoObject( &VObjectDesc, &uiINTBAR ) ) - AssertMsg(0, "Missing INTERFACE\\timebaryellow_800x600.sti" ); } else if (iResolution == 2) { FilenameForBPP("INTERFACE\\timebaryellow_1024x768.sti", VObjectDesc.ImageFile); - if( !AddVideoObject( &VObjectDesc, &uiINTBAR ) ) - AssertMsg(0, "Missing INTERFACE\\timebaryellow_1024x768.sti" ); } + else + { + AssertMsg( 0, "Invalid resolution"); + return; + } + + if( !AddVideoObject( &VObjectDesc, &uiINTBAR ) ) + AssertMsg(0, String( "Missing %s", VObjectDesc.ImageFile) ); // Change dest buffer SetFontDestBuffer( uiSurface , 0, 0, SCREEN_WIDTH , 20, FALSE ); @@ -3837,13 +3846,12 @@ void RenderAimCubeUI( ) if ( gfInAimCubeUI ) { + // Determine screen location.... + GetGridNoScreenPos( gCubeUIData.sGridNo, gCubeUIData.ubLevel, &sScreenX, &sScreenY ); // OK, given height if ( gCubeUIData.fShowHeight ) { - // Determine screen location.... - GetGridNoScreenPos( gCubeUIData.sGridNo, gCubeUIData.ubLevel, &sScreenX, &sScreenY ); - // Save background iBack = RegisterBackgroundRect( BGND_FLAG_SINGLE, NULL, sScreenX, (INT16)(sScreenY - 70 ), (INT16)(sScreenX + 40 ), (INT16)(sScreenY + 50 ) ); if ( iBack != -1 ) diff --git a/Tactical/LOS.cpp b/Tactical/LOS.cpp index c01a41d1..be5f1579 100644 --- a/Tactical/LOS.cpp +++ b/Tactical/LOS.cpp @@ -3576,6 +3576,8 @@ INT8 FireBulletGivenTarget( SOLDIERTYPE * pFirer, FLOAT dEndX, FLOAT dEndY, FLOA ddOrigHorizAngle = atan2( dDeltaY, dDeltaX ); ddOrigVerticAngle = atan2( dDeltaZ, (d2DDistance * 2.56f) ); + ddAdjustedHorizAngle = ddOrigHorizAngle; + ddAdjustedVerticAngle = ddOrigVerticAngle; ubShots = 1; fTracer = FALSE; diff --git a/Tactical/Militia Control.cpp b/Tactical/Militia Control.cpp index 0a4e7436..dd53323e 100644 --- a/Tactical/Militia Control.cpp +++ b/Tactical/Militia Control.cpp @@ -1059,7 +1059,7 @@ void HandleShadingOfLinesForMilitiaControlMenu( void ) BOOLEAN CheckIfRadioIsEquipped( void ) { SOLDIERTYPE *pSoldier = NULL; - INT8 bSlot; + INT8 bSlot = NO_SLOT; // do we have a radio ? //pSoldier = GetSelectedAssignSoldier( FALSE ); //do not use diff --git a/Tactical/Overhead.cpp b/Tactical/Overhead.cpp index e292f1a5..df8a8656 100644 --- a/Tactical/Overhead.cpp +++ b/Tactical/Overhead.cpp @@ -3111,7 +3111,7 @@ void RebuildAllSoldierShadeTables( ) void HandlePlayerTeamMemberDeath( SOLDIERTYPE *pSoldier ) { INT32 cnt; - INT32 iNewSelectedSoldier; + INT32 iNewSelectedSoldier = -1; SOLDIERTYPE *pTeamSoldier; BOOLEAN fMissionFailed = TRUE; INT8 bBuddyIndex; @@ -8340,6 +8340,9 @@ void DoCreatureTensionQuote( SOLDIERTYPE *pSoldier ) fCanDoQuote = FALSE; } break; + default: + AssertMsg(0, "Invalid quote"); + return; } if ( fCanDoQuote ) diff --git a/Tactical/PATHAI.cpp b/Tactical/PATHAI.cpp index e485c2a8..a130feae 100644 --- a/Tactical/PATHAI.cpp +++ b/Tactical/PATHAI.cpp @@ -1,46 +1,46 @@ /* - Filename : pathai.c - Author : Ray E. Bornert II - Date : 1992-MAR-15 +Filename : pathai.c +Author : Ray E. Bornert II +Date : 1992-MAR-15 - Skip list additions - Author : Chris Camfield - Date : 1997-NOV +Skip list additions +Author : Chris Camfield +Date : 1997-NOV */ #ifdef PRECOMPILEDHEADERS - #include "Tactical All.h" +#include "Tactical All.h" #else - #include - #include - #include "wcheck.h" - #include "stdlib.h" - #include "debug.h" - #include "MemMan.h" - #include "Overhead Types.h" - #include "Soldier Control.h" - #include "Animation Cache.h" - #include "Animation Data.h" - #include "Animation Control.h" - #include "container.h" - #include "interface.h" - #include +#include +#include +#include "wcheck.h" +#include "stdlib.h" +#include "debug.h" +#include "MemMan.h" +#include "Overhead Types.h" +#include "Soldier Control.h" +#include "Animation Cache.h" +#include "Animation Data.h" +#include "Animation Control.h" +#include "container.h" +#include "interface.h" +#include - #include "input.h" - #include "english.h" - #include "worlddef.h" - #include "worldman.h" - #include "renderworld.h" - #include "pathai.h" - #include "PathAIDebug.h" - #include "Points.h" - #include "ai.h" - #include "Random.h" - #include "message.h" - #include "structure wrap.h" - #include "keys.h" - #include "gamesettings.h" - #include "Buildings.h" +#include "input.h" +#include "english.h" +#include "worlddef.h" +#include "worldman.h" +#include "renderworld.h" +#include "pathai.h" +#include "PathAIDebug.h" +#include "Points.h" +#include "ai.h" +#include "Random.h" +#include "message.h" +#include "structure wrap.h" +#include "keys.h" +#include "gamesettings.h" +#include "Buildings.h" #endif #include "PathAIDebug.h" @@ -71,14 +71,14 @@ UINT8 gubBuildingInfoToSet; // ABSOLUTE maximums //#ifdef JA2EDITOR - #define ABSMAX_SKIPLIST_LEVEL 5 - #define ABSMAX_TRAIL_TREE (16384) - #define ABSMAX_PATHQ (512) +#define ABSMAX_SKIPLIST_LEVEL 5 +#define ABSMAX_TRAIL_TREE (16384) +#define ABSMAX_PATHQ (512) /* #else - #define ABSMAX_SKIPLIST_LEVEL 5 - #define ABSMAX_TRAIL_TREE (4096) - #define ABSMAX_PATHQ (512) +#define ABSMAX_SKIPLIST_LEVEL 5 +#define ABSMAX_TRAIL_TREE (4096) +#define ABSMAX_PATHQ (512) #endif */ @@ -163,7 +163,7 @@ static INT32 iSkipListLevelLimit[8] = {0, 4, 16, 64, 256, 1024, 4192, 16384 }; #define SETLOC( str, loc ) \ {\ -(str).iLocation = loc;\ + (str).iLocation = loc;\ } static TRAILCELLTYPE * trailCost; @@ -194,37 +194,37 @@ static path_t * pClosedHead; /* #define ClosedListAdd( pNew ) \ {\ - pNew->pNext[0] = pClosedHead;\ - pNew->pNext[1] = pClosedHead->pNext[1];\ - pClosedHead->pNext[1]->pNext[0] = pNew;\ - pClosedHead->pNext[1] = pNew;\ - pNew->iLocation = -1;\ - iClosedListSize++;\ +pNew->pNext[0] = pClosedHead;\ +pNew->pNext[1] = pClosedHead->pNext[1];\ +pClosedHead->pNext[1]->pNext[0] = pNew;\ +pClosedHead->pNext[1] = pNew;\ +pNew->iLocation = -1;\ +iClosedListSize++;\ } #define ClosedListGet( pNew )\ {\ - if (queRequestspNext, 0, sizeof( path_t *) * ABSMAX_SKIPLIST_LEVEL );\ - pNew->bLevel = RandomSkipListLevel();\ - }\ - else if (iClosedListSize > 0)\ - {\ - pNew = pClosedHead->pNext[0];\ - pNew->pNext[1]->pNext[0] = pNew->pNext[0];\ - pNew->pNext[0]->pNext[1] = pNew->pNext[1];\ - iClosedListSize--;\ - queRequests++;\ - memset( pNew->pNext, 0, sizeof( path_t *) * ABSMAX_SKIPLIST_LEVEL );\ - pNew->bLevel = RandomSkipListLevel();\ - }\ - else\ - {\ - pNew = NULL;\ - }\ +if (queRequestspNext, 0, sizeof( path_t *) * ABSMAX_SKIPLIST_LEVEL );\ +pNew->bLevel = RandomSkipListLevel();\ +}\ +else if (iClosedListSize > 0)\ +{\ +pNew = pClosedHead->pNext[0];\ +pNew->pNext[1]->pNext[0] = pNew->pNext[0];\ +pNew->pNext[0]->pNext[1] = pNew->pNext[1];\ +iClosedListSize--;\ +queRequests++;\ +memset( pNew->pNext, 0, sizeof( path_t *) * ABSMAX_SKIPLIST_LEVEL );\ +pNew->bLevel = RandomSkipListLevel();\ +}\ +else\ +{\ +pNew = NULL;\ +}\ } */ @@ -240,60 +240,60 @@ static path_t * pClosedHead; #define ClosedListGet( pNew )\ {\ if (queRequestsbLevel = RandomSkipListLevel();\ - }\ +{\ + pNew = pathQ + (queRequests);\ + queRequests++;\ + pNew->bLevel = RandomSkipListLevel();\ +}\ else if (iClosedListSize > 0)\ - {\ - pNew = pClosedHead->pNext[0];\ - pClosedHead->pNext[0] = pNew->pNext[0];\ - iClosedListSize--;\ - queRequests++;\ - memset( pNew->pNext, 0, sizeof( path_t *) * ABSMAX_SKIPLIST_LEVEL );\ - pNew->bLevel = RandomSkipListLevel();\ - }\ +{\ + pNew = pClosedHead->pNext[0];\ + pClosedHead->pNext[0] = pNew->pNext[0];\ + iClosedListSize--;\ + queRequests++;\ + memset( pNew->pNext, 0, sizeof( path_t *) * ABSMAX_SKIPLIST_LEVEL );\ + pNew->bLevel = RandomSkipListLevel();\ +}\ else\ - {\ - pNew = NULL;\ - }\ +{\ + pNew = NULL;\ +}\ } /* #define ClosedListAdd( pNew ) \ {\ - pNew->pNext[0] = pClosedHead;\ - pNew->pNext[1] = pClosedHead->pNext[1];\ - pClosedHead->pNext[1]->pNext[0] = pNew;\ - pClosedHead->pNext[1] = pNew;\ - pNew->iLocation = -1;\ - iClosedListSize++;\ +pNew->pNext[0] = pClosedHead;\ +pNew->pNext[1] = pClosedHead->pNext[1];\ +pClosedHead->pNext[1]->pNext[0] = pNew;\ +pClosedHead->pNext[1] = pNew;\ +pNew->iLocation = -1;\ +iClosedListSize++;\ } #define ClosedListGet( pNew )\ {\ - if (queRequestspNext, 0, sizeof( path_t *) * ABSMAX_SKIPLIST_LEVEL );\ - pNew->bLevel = RandomSkipListLevel();\ - }\ - else if (iClosedListSize > 0)\ - {\ - pNew = pClosedHead->pNext[0];\ - pNew->pNext[1]->pNext[0] = pNew->pNext[0];\ - pNew->pNext[0]->pNext[1] = pNew->pNext[1];\ - iClosedListSize--;\ - queRequests++;\ - memset( pNew->pNext, 0, sizeof( path_t *) * ABSMAX_SKIPLIST_LEVEL );\ - pNew->bLevel = RandomSkipListLevel();\ - }\ - else\ - {\ - pNew = NULL;\ - }\ +if (queRequestspNext, 0, sizeof( path_t *) * ABSMAX_SKIPLIST_LEVEL );\ +pNew->bLevel = RandomSkipListLevel();\ +}\ +else if (iClosedListSize > 0)\ +{\ +pNew = pClosedHead->pNext[0];\ +pNew->pNext[1]->pNext[0] = pNew->pNext[0];\ +pNew->pNext[0]->pNext[1] = pNew->pNext[1];\ +iClosedListSize--;\ +queRequests++;\ +memset( pNew->pNext, 0, sizeof( path_t *) * ABSMAX_SKIPLIST_LEVEL );\ +pNew->bLevel = RandomSkipListLevel();\ +}\ +else\ +{\ +pNew = NULL;\ +}\ } */ @@ -301,9 +301,9 @@ static path_t * pClosedHead; {\ pDel = pQueueHead->pNext[0];\ for (iLoop = 0; iLoop < __min( bSkipListLevel, pDel->bLevel ); iLoop++)\ - {\ - pQueueHead->pNext[iLoop] = pDel->pNext[iLoop];\ - }\ +{\ + pQueueHead->pNext[iLoop] = pDel->pNext[iLoop];\ +}\ iSkipListSize--;\ ClosedListAdd( pDel );\ } @@ -314,49 +314,49 @@ static path_t * pClosedHead; uiCost = TOTALCOST( pNew );\ memset( pUpdate, 0, MAX_SKIPLIST_LEVEL * sizeof( path_t *) );\ for (iCurrLevel = bSkipListLevel - 1; iCurrLevel >= 0; iCurrLevel--)\ - {\ - pNext = pCurr->pNext[iCurrLevel];\ - while (pNext)\ - {\ - if ( uiCost > TOTALCOST( pNext ) || (uiCost == TOTALCOST( pNext ) && FARTHER( pNew, pNext ) ) )\ - {\ - pCurr = pNext;\ - pNext = pCurr->pNext[iCurrLevel];\ - }\ +{\ + pNext = pCurr->pNext[iCurrLevel];\ + while (pNext)\ +{\ + if ( uiCost > TOTALCOST( pNext ) || (uiCost == TOTALCOST( pNext ) && FARTHER( pNew, pNext ) ) )\ +{\ + pCurr = pNext;\ + pNext = pCurr->pNext[iCurrLevel];\ +}\ else\ - {\ - break;\ - }\ - }\ - pUpdate[iCurrLevel] = pCurr;\ - }\ +{\ + break;\ +}\ +}\ + pUpdate[iCurrLevel] = pCurr;\ +}\ pCurr = pCurr->pNext[0];\ for (iCurrLevel = 0; iCurrLevel < pNew->bLevel; iCurrLevel++)\ - {\ - if (!(pUpdate[iCurrLevel]))\ - {\ - break;\ - }\ - pNew->pNext[iCurrLevel] = pUpdate[iCurrLevel]->pNext[iCurrLevel];\ - pUpdate[iCurrLevel]->pNext[iCurrLevel] = pNew;\ - }\ +{\ + if (!(pUpdate[iCurrLevel]))\ +{\ + break;\ +}\ + pNew->pNext[iCurrLevel] = pUpdate[iCurrLevel]->pNext[iCurrLevel];\ + pUpdate[iCurrLevel]->pNext[iCurrLevel] = pNew;\ +}\ iSkipListSize++;\ if (iSkipListSize > iSkipListLevelLimit[bSkipListLevel])\ - {\ - pCurr = pQueueHead;\ - pNext = pQueueHead->pNext[bSkipListLevel - 1];\ - while( pNext )\ - {\ - if (pNext->bLevel > bSkipListLevel)\ - {\ - pCurr->pNext[bSkipListLevel] = pNext;\ - pCurr = pNext;\ - }\ - pNext = pNext->pNext[bSkipListLevel - 1];\ - }\ - pCurr->pNext[bSkipListLevel] = pNext;\ - bSkipListLevel++;\ - }\ +{\ + pCurr = pQueueHead;\ + pNext = pQueueHead->pNext[bSkipListLevel - 1];\ + while( pNext )\ +{\ + if (pNext->bLevel > bSkipListLevel)\ +{\ + pCurr->pNext[bSkipListLevel] = pNext;\ + pCurr = pNext;\ +}\ + pNext = pNext->pNext[bSkipListLevel - 1];\ +}\ + pCurr->pNext[bSkipListLevel] = pNext;\ + bSkipListLevel++;\ +}\ } #define REMQUEHEADNODE() SkipListRemoveHead(); @@ -364,19 +364,19 @@ static path_t * pClosedHead; #define DELQUENODE(ndx) SkipListRemoveHead() #define REMAININGCOST(ptr) \ -( \ + ( \ (dy = abs(iDestY-iLocY)), \ (dx = abs(iDestX-iLocX)), \ ESTIMATE \ -) + ) /* #define REMAININGCOST(ptr) \ ( \ - (locY = (ptr)->iLocation/MAPWIDTH), \ - (locX = (ptr)->iLocation%MAPWIDTH), \ - (dy = abs(iDestY-locY)), \ - (dx = abs(iDestX-locX)), \ - ESTIMATE \ +(locY = (ptr)->iLocation/MAPWIDTH), \ +(locX = (ptr)->iLocation%MAPWIDTH), \ +(dy = abs(iDestY-locY)), \ +(dx = abs(iDestX-locX)), \ +ESTIMATE \ ) */ @@ -515,17 +515,17 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo INT32 iWaterToWater; UINT8 ubCurAPCost,ubAPCost; UINT8 ubNewAPCost=0; - #ifdef VEHICLE - //BOOLEAN fTurnSlow = FALSE; - //BOOLEAN fReverse = FALSE; // stuff for vehicles turning - BOOLEAN fMultiTile, fVehicle; - //INT32 iLastDir, iPrevToLastDir; - //INT8 bVehicleCheckDir; - //UINT16 adjLoc; - STRUCTURE_FILE_REF * pStructureFileRef=NULL; - UINT16 usAnimSurface; - //INT32 iCnt2, iCnt3; - #endif +#ifdef VEHICLE + //BOOLEAN fTurnSlow = FALSE; + //BOOLEAN fReverse = FALSE; // stuff for vehicles turning + BOOLEAN fMultiTile, fVehicle; + //INT32 iLastDir, iPrevToLastDir; + //INT8 bVehicleCheckDir; + //UINT16 adjLoc; + STRUCTURE_FILE_REF * pStructureFileRef=NULL; + UINT16 usAnimSurface; + //INT32 iCnt2, iCnt3; +#endif INT32 iLastDir = 0; @@ -562,8 +562,8 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo BOOLEAN fGoingThroughDoor = FALSE; // for one tile BOOLEAN fContinuousTurnNeeded; BOOLEAN fCloseGoodEnough; - UINT16 usMovementModeToUseForAPs; - INT16 sClosePathLimit; + UINT16 usMovementModeToUseForAPs; + INT16 sClosePathLimit = 0; #ifdef PATHAI_SKIPLIST_DEBUG CHAR8 zTempString[1000], zTS[50]; @@ -579,16 +579,16 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo if (iOrigination < 0 || iOrigination > WORLD_MAX) { - #ifdef JA2BETAVERSION - ScreenMsg( FONT_MCOLOR_RED, MSG_TESTVERSION, L"ERROR! Trying to calculate path from off-world gridno %d to %d", iOrigination, sDestination ); - #endif +#ifdef JA2BETAVERSION + ScreenMsg( FONT_MCOLOR_RED, MSG_TESTVERSION, L"ERROR! Trying to calculate path from off-world gridno %d to %d", iOrigination, sDestination ); +#endif return( 0 ); } else if (!GridNoOnVisibleWorldTile( (INT16) iOrigination ) ) { - #ifdef JA2BETAVERSION - ScreenMsg( FONT_MCOLOR_RED, MSG_TESTVERSION, L"ERROR! Trying to calculate path from non-visible gridno %d to %d", iOrigination, sDestination ); - #endif +#ifdef JA2BETAVERSION + ScreenMsg( FONT_MCOLOR_RED, MSG_TESTVERSION, L"ERROR! Trying to calculate path from non-visible gridno %d to %d", iOrigination, sDestination ); +#endif return( 0 ); } else if (s->bLevel != ubLevel) @@ -665,7 +665,7 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo /* if (gubNPCDistLimit == 0) { - return( FALSE ); + return( FALSE ); } */ } @@ -699,7 +699,7 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo gubNPCAPBudget -= ubAPCost; } } - + #ifdef COUNT_PATHS guiTotalPathChecks++; #endif @@ -714,7 +714,7 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo usAnimSurface = DetermineSoldierAnimationSurface( s, usMovementMode ); // Get structure ref... pStructureFileRef = GetAnimationStructureRef( s->ubID, usAnimSurface, usMovementMode ); - + if ( pStructureFileRef ) { fVehicle = ( (s->uiStatusFlags & SOLDIER_VEHICLE) != 0 ); @@ -724,13 +724,13 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo /* if (fVehicle && s->bReverse) { - fReverse = TRUE; + fReverse = TRUE; } */ /* if (fVehicle || s->ubBodyType == COW || s->ubBodyType == BLOODCAT) // or a vehicle { - fTurnSlow = TRUE; + fTurnSlow = TRUE; } */ if ( gfEstimatePath ) @@ -795,10 +795,10 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo iOriginationY = (iOrigination / MAPWIDTH); iOriginationX = (iOrigination % MAPWIDTH); } - + iDestY = (iDestination / MAPWIDTH); iDestX = (iDestination % MAPWIDTH); - + // if origin and dest is water, then user wants to stay in water! // so, check and set waterToWater flag accordingly if (iDestination == NOWHERE) @@ -808,9 +808,9 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo else { if (ISWATER(gubWorldMovementCosts[iOrigination][0][ubLevel]) && ISWATER(gubWorldMovementCosts[iDestination][0][ubLevel])) - iWaterToWater = 1; + iWaterToWater = 1; else - iWaterToWater = 0; + iWaterToWater = 0; } //setup Q and first path record @@ -875,24 +875,24 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo /* if (fTurnSlow) { - if (pCurrPtr->pNext[0] == 0) - { - if (fReverse) - { - iLastDir = gOppositeDirection[s->bDirection]; - } - else - { - iLastDir = s->bDirection; - } - // start prev-to-last dir at same as current (could cause a problem) - iPrevToLastDir = iLastDir; - } - else - { - iPrevToLastDir = trailTree[trailTree[pCurrPtr->sPathNdx].nextLink].dirDelta; - iLastDir = trailTree[pCurrPtr->sPathNdx].dirDelta; - } + if (pCurrPtr->pNext[0] == 0) + { + if (fReverse) + { + iLastDir = gOppositeDirection[s->bDirection]; + } + else + { + iLastDir = s->bDirection; + } + // start prev-to-last dir at same as current (could cause a problem) + iPrevToLastDir = iLastDir; + } + else + { + iPrevToLastDir = trailTree[trailTree[pCurrPtr->sPathNdx].nextLink].dirDelta; + iLastDir = trailTree[pCurrPtr->sPathNdx].dirDelta; + } } */ @@ -912,7 +912,7 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo } DELQUENODE( pCurrPtr ); - + if ( trailCostUsed[curLoc] == gubGlobalPathCount && trailCost[curLoc] < curCost) goto NEXTDIR; @@ -961,20 +961,20 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo /* if (fTurnSlow) { - if (iLastDir == iPrevToLastDir) - { - if ( iCnt != iLastDir && iCnt != gOneCDirection[ iLastDir ] && iCnt != gOneCCDirection[ iLastDir ]) - { - goto NEXTDIR; - } - } - else - { - if ( iCnt != iLastDir ) - { - goto NEXTDIR; - } - } + if (iLastDir == iPrevToLastDir) + { + if ( iCnt != iLastDir && iCnt != gOneCDirection[ iLastDir ] && iCnt != gOneCCDirection[ iLastDir ]) + { + goto NEXTDIR; + } + } + else + { + if ( iCnt != iLastDir ) + { + goto NEXTDIR; + } + } } */ @@ -1050,7 +1050,7 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo goto NEXTDIR; } - + //if (gpWorldLevelData[newLoc].sHeight != ubLevel) //ATE: Movement onto cliffs? Check vs the soldier's gridno height // CJC: PREVIOUS LOCATION's height @@ -1159,80 +1159,80 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo switch( nextCost ) { - case TRAVELCOST_DOOR_CLOSED_HERE: - fDoorIsObstacleIfClosed = TRUE; - iDoorGridNo = newLoc; - break; - case TRAVELCOST_DOOR_CLOSED_N: - fDoorIsObstacleIfClosed = TRUE; - iDoorGridNo = newLoc + dirDelta[ NORTH ]; - break; - case TRAVELCOST_DOOR_CLOSED_W: - fDoorIsObstacleIfClosed = TRUE; - iDoorGridNo = newLoc + dirDelta[ WEST ]; - break; - case TRAVELCOST_DOOR_OPEN_HERE: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = newLoc; - break; - case TRAVELCOST_DOOR_OPEN_N: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = newLoc + dirDelta[ NORTH ]; - break; - case TRAVELCOST_DOOR_OPEN_NE: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = newLoc + dirDelta[ NORTHEAST ]; - break; - case TRAVELCOST_DOOR_OPEN_E: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = newLoc + dirDelta[ EAST ]; - break; - case TRAVELCOST_DOOR_OPEN_SE: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = newLoc + dirDelta[ SOUTHEAST ]; - break; - case TRAVELCOST_DOOR_OPEN_S: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = newLoc + dirDelta[ SOUTH ]; - break; - case TRAVELCOST_DOOR_OPEN_SW: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = newLoc + dirDelta[ SOUTHWEST ]; - break; - case TRAVELCOST_DOOR_OPEN_W: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = newLoc + dirDelta[ WEST ]; - break; - case TRAVELCOST_DOOR_OPEN_NW: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = newLoc + dirDelta[ NORTHWEST ]; - break; - case TRAVELCOST_DOOR_OPEN_N_N: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = newLoc + dirDelta[ NORTH ] + dirDelta[ NORTH ]; - break; - case TRAVELCOST_DOOR_OPEN_NW_N: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = newLoc + dirDelta[ NORTHWEST ] + dirDelta[ NORTH ]; - break; - case TRAVELCOST_DOOR_OPEN_NE_N: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = newLoc + dirDelta[ NORTHEAST ] + dirDelta[ NORTH ]; - break; - case TRAVELCOST_DOOR_OPEN_W_W: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = newLoc + dirDelta[ WEST ] + dirDelta[ WEST ]; - break; - case TRAVELCOST_DOOR_OPEN_SW_W: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = newLoc + dirDelta[ SOUTHWEST ] + dirDelta[ WEST ]; - break; - case TRAVELCOST_DOOR_OPEN_NW_W: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = newLoc + dirDelta[ NORTHWEST ] + dirDelta[ WEST ]; - break; - default: - break; + case TRAVELCOST_DOOR_CLOSED_HERE: + fDoorIsObstacleIfClosed = TRUE; + iDoorGridNo = newLoc; + break; + case TRAVELCOST_DOOR_CLOSED_N: + fDoorIsObstacleIfClosed = TRUE; + iDoorGridNo = newLoc + dirDelta[ NORTH ]; + break; + case TRAVELCOST_DOOR_CLOSED_W: + fDoorIsObstacleIfClosed = TRUE; + iDoorGridNo = newLoc + dirDelta[ WEST ]; + break; + case TRAVELCOST_DOOR_OPEN_HERE: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = newLoc; + break; + case TRAVELCOST_DOOR_OPEN_N: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = newLoc + dirDelta[ NORTH ]; + break; + case TRAVELCOST_DOOR_OPEN_NE: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = newLoc + dirDelta[ NORTHEAST ]; + break; + case TRAVELCOST_DOOR_OPEN_E: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = newLoc + dirDelta[ EAST ]; + break; + case TRAVELCOST_DOOR_OPEN_SE: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = newLoc + dirDelta[ SOUTHEAST ]; + break; + case TRAVELCOST_DOOR_OPEN_S: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = newLoc + dirDelta[ SOUTH ]; + break; + case TRAVELCOST_DOOR_OPEN_SW: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = newLoc + dirDelta[ SOUTHWEST ]; + break; + case TRAVELCOST_DOOR_OPEN_W: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = newLoc + dirDelta[ WEST ]; + break; + case TRAVELCOST_DOOR_OPEN_NW: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = newLoc + dirDelta[ NORTHWEST ]; + break; + case TRAVELCOST_DOOR_OPEN_N_N: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = newLoc + dirDelta[ NORTH ] + dirDelta[ NORTH ]; + break; + case TRAVELCOST_DOOR_OPEN_NW_N: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = newLoc + dirDelta[ NORTHWEST ] + dirDelta[ NORTH ]; + break; + case TRAVELCOST_DOOR_OPEN_NE_N: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = newLoc + dirDelta[ NORTHEAST ] + dirDelta[ NORTH ]; + break; + case TRAVELCOST_DOOR_OPEN_W_W: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = newLoc + dirDelta[ WEST ] + dirDelta[ WEST ]; + break; + case TRAVELCOST_DOOR_OPEN_SW_W: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = newLoc + dirDelta[ SOUTHWEST ] + dirDelta[ WEST ]; + break; + case TRAVELCOST_DOOR_OPEN_NW_W: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = newLoc + dirDelta[ NORTHWEST ] + dirDelta[ WEST ]; + break; + default: + break; } if ( fPathingForPlayer && gpWorldLevelData[ iDoorGridNo ].ubExtFlags[0] & MAPELEMENT_EXT_DOOR_STATUS_PRESENT ) @@ -1327,11 +1327,11 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo // creatures and animals can't go in water nextCost = TRAVELCOST_OBSTACLE; } - + // Apr. '96 - moved up be ahead of AP_Budget stuff if ( ( nextCost >= NOPASS) ) // || ( nextCost == TRAVELCOST_DOOR ) ) - goto NEXTDIR; + goto NEXTDIR; } else @@ -1344,12 +1344,12 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo // WHAT THE??? hack. goto NEXTDIR; } - + // if contemplated tile is NOT final dest and someone there, disqualify route // when doing a reachable test, ignore all locations with people in them if (fPathAroundPeople && ( (newLoc != iDestination) || fCopyReachable) ) { - // ATE: ONLY cancel if they are moving..... + // ATE: ONLY cancel if they are moving..... ubMerc = WhoIsThere2( (UINT16) newLoc, s->bLevel); if ( ubMerc < NOBODY && ubMerc != s->ubID ) @@ -1357,9 +1357,9 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo // Check for movement.... //if ( fTurnBased || ( (Menptr[ ubMerc ].sFinalDestination == Menptr[ ubMerc ].sGridNo) || (Menptr[ ubMerc ].fDelayedMovement) ) ) //{ - goto NEXTDIR; + goto NEXTDIR; //} - // else + // else //{ // nextCost += 50; //} @@ -1386,22 +1386,22 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo // vehicles aren't moving any more.... if (fVehicle) { - // transmogrify pathing costs for vehicles! - switch(nextCost) - { - case TRAVELCOST_THICK : nextCost = TRAVELCOST_GRASS; - break; - case TRAVELCOST_SHORE : - case TRAVELCOST_KNEEDEEP: - case TRAVELCOST_DEEPWATER: -// case TRAVELCOST_VEINEND : -// case TRAVELCOST_VEINMID : - //case TRAVELCOST_DOOR : - case TRAVELCOST_FENCE : nextCost = TRAVELCOST_OBSTACLE; - break; + // transmogrify pathing costs for vehicles! + switch(nextCost) + { + case TRAVELCOST_THICK : nextCost = TRAVELCOST_GRASS; + break; + case TRAVELCOST_SHORE : + case TRAVELCOST_KNEEDEEP: + case TRAVELCOST_DEEPWATER: + // case TRAVELCOST_VEINEND : + // case TRAVELCOST_VEINMID : + //case TRAVELCOST_DOOR : + case TRAVELCOST_FENCE : nextCost = TRAVELCOST_OBSTACLE; + break; - default : break; - } + default : break; + } } */ } @@ -1409,29 +1409,29 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo // NEW Apr 21 by Ian: abort if cost exceeds budget if (gubNPCAPBudget) - { + { switch(nextCost) { - case TRAVELCOST_NONE : ubAPCost = 0; - break; + case TRAVELCOST_NONE : ubAPCost = 0; + break; - case TRAVELCOST_DIRTROAD: - case TRAVELCOST_FLAT : ubAPCost = AP_MOVEMENT_FLAT; - break; + case TRAVELCOST_DIRTROAD: + case TRAVELCOST_FLAT : ubAPCost = AP_MOVEMENT_FLAT; + break; //case TRAVELCOST_BUMPY : - case TRAVELCOST_GRASS : ubAPCost = AP_MOVEMENT_GRASS; - break; - case TRAVELCOST_THICK : ubAPCost = AP_MOVEMENT_BUSH; - break; - case TRAVELCOST_DEBRIS : ubAPCost = AP_MOVEMENT_RUBBLE; - break; - case TRAVELCOST_SHORE : ubAPCost = AP_MOVEMENT_SHORE; // wading shallow water - break; - case TRAVELCOST_KNEEDEEP: ubAPCost = AP_MOVEMENT_LAKE; // wading waist/chest deep - very slow - break; + case TRAVELCOST_GRASS : ubAPCost = AP_MOVEMENT_GRASS; + break; + case TRAVELCOST_THICK : ubAPCost = AP_MOVEMENT_BUSH; + break; + case TRAVELCOST_DEBRIS : ubAPCost = AP_MOVEMENT_RUBBLE; + break; + case TRAVELCOST_SHORE : ubAPCost = AP_MOVEMENT_SHORE; // wading shallow water + break; + case TRAVELCOST_KNEEDEEP: ubAPCost = AP_MOVEMENT_LAKE; // wading waist/chest deep - very slow + break; - case TRAVELCOST_DEEPWATER:ubAPCost = AP_MOVEMENT_OCEAN; // can swim, so it's faster than wading - break; + case TRAVELCOST_DEEPWATER:ubAPCost = AP_MOVEMENT_OCEAN; // can swim, so it's faster than wading + break; //case TRAVELCOST_VEINEND : //case TRAVELCOST_VEINMID : ubAPCost = AP_MOVEMENT_FLAT; // break; @@ -1439,124 +1439,124 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo //case TRAVELCOST_DOOR : ubAPCost = AP_MOVEMENT_FLAT; // break; - case TRAVELCOST_FENCE : ubAPCost = AP_JUMPFENCE; - -/* - if ( sSwitchValue == TRAVELCOST_FENCE ) - { - sPoints += sTileCost; + case TRAVELCOST_FENCE : ubAPCost = AP_JUMPFENCE; - // If we are changeing stance ( either before or after getting there.... - // We need to reflect that... - switch(usMovementMode) - { + /* + if ( sSwitchValue == TRAVELCOST_FENCE ) + { + sPoints += sTileCost; + + // If we are changeing stance ( either before or after getting there.... + // We need to reflect that... + switch(usMovementMode) + { case RUNNING: case WALKING : - // Add here cost to go from crouch to stand AFTER fence hop.... - // Since it's AFTER.. make sure we will be moving after jump... - if ( ( iCnt + 2 ) < iLastGrid ) - { - sPoints += AP_CROUCH; - } - break; + // Add here cost to go from crouch to stand AFTER fence hop.... + // Since it's AFTER.. make sure we will be moving after jump... + if ( ( iCnt + 2 ) < iLastGrid ) + { + sPoints += AP_CROUCH; + } + break; case SWATTING: - // Add cost to stand once there BEFORE.... - sPoints += AP_CROUCH; - break; + // Add cost to stand once there BEFORE.... + sPoints += AP_CROUCH; + break; case CRAWLING: - // Can't do it here..... - break; + // Can't do it here..... + break; - } - } + } + } -*/ - - break; + */ - case TRAVELCOST_OBSTACLE: - default : goto NEXTDIR; // Cost too much to be considered! - break; + break; + + case TRAVELCOST_OBSTACLE: + default : goto NEXTDIR; // Cost too much to be considered! + break; } - - // don't make the mistake of adding directly to - // ubCurAPCost, that must be preserved for remaining dirs! + + // don't make the mistake of adding directly to + // ubCurAPCost, that must be preserved for remaining dirs! if (iCnt & 1) { //ubAPCost++; //ubAPCost = gubDiagCost[ubAPCost]; ubAPCost = (ubAPCost * 14) / 10; } - - usMovementModeToUseForAPs = usMovementMode; - // ATE: if water, force to be walking always! - if ( nextCost == TRAVELCOST_SHORE || nextCost == TRAVELCOST_KNEEDEEP || nextCost == TRAVELCOST_DEEPWATER ) - { - usMovementModeToUseForAPs = WALKING; - } + usMovementModeToUseForAPs = usMovementMode; + + // ATE: if water, force to be walking always! + if ( nextCost == TRAVELCOST_SHORE || nextCost == TRAVELCOST_KNEEDEEP || nextCost == TRAVELCOST_DEEPWATER ) + { + usMovementModeToUseForAPs = WALKING; + } // adjust AP cost for movement mode switch( usMovementModeToUseForAPs ) { - case RUNNING: - case ADULTMONSTER_WALKING: - // save on casting - ubAPCost = ubAPCost * 10 / ( (UINT8) (RUNDIVISOR * 10)); - //ubAPCost = (INT16)(DOUBLE)( (sTileCost / RUNDIVISOR) ); break; - break; - case WALKING: - case ROBOT_WALK: - ubAPCost = (ubAPCost + WALKCOST); - break; - case SWATTING: - ubAPCost = (ubAPCost + SWATCOST); - break; - case CRAWLING: - ubAPCost = (ubAPCost + CRAWLCOST); - break; + case RUNNING: + case ADULTMONSTER_WALKING: + // save on casting + ubAPCost = ubAPCost * 10 / ( (UINT8) (RUNDIVISOR * 10)); + //ubAPCost = (INT16)(DOUBLE)( (sTileCost / RUNDIVISOR) ); break; + break; + case WALKING: + case ROBOT_WALK: + ubAPCost = (ubAPCost + WALKCOST); + break; + case SWATTING: + ubAPCost = (ubAPCost + SWATCOST); + break; + case CRAWLING: + ubAPCost = (ubAPCost + CRAWLCOST); + break; } if (nextCost == TRAVELCOST_FENCE) { switch( usMovementModeToUseForAPs ) { - case RUNNING: - case WALKING : - // Here pessimistically assume the path will continue after hopping the fence - ubAPCost += AP_CROUCH; - break; + case RUNNING: + case WALKING : + // Here pessimistically assume the path will continue after hopping the fence + ubAPCost += AP_CROUCH; + break; - case SWATTING: + case SWATTING: - // Add cost to stand once there BEFORE jumping.... - ubAPCost += AP_CROUCH; - break; + // Add cost to stand once there BEFORE jumping.... + ubAPCost += AP_CROUCH; + break; - case CRAWLING: + case CRAWLING: - // Can't do it here..... - goto NEXTDIR; + // Can't do it here..... + goto NEXTDIR; } } else if (nextCost == TRAVELCOST_NOT_STANDING) { switch(usMovementModeToUseForAPs) { - case RUNNING: - case WALKING : - // charge crouch APs for ducking head! - ubAPCost += AP_CROUCH; - break; + case RUNNING: + case WALKING : + // charge crouch APs for ducking head! + ubAPCost += AP_CROUCH; + break; - default: - break; + default: + break; } } else if (fGoingThroughDoor) @@ -1566,42 +1566,42 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo } - ubNewAPCost = ubCurAPCost + ubAPCost; + ubNewAPCost = ubCurAPCost + ubAPCost; - if (ubNewAPCost > gubNPCAPBudget) - goto NEXTDIR; + if (ubNewAPCost > gubNPCAPBudget) + goto NEXTDIR; + + } - } - //ATE: Uncommented out for doors, if we are at a door but not dest, continue! - // if ( nextCost == TRAVELCOST_DOOR ) //&& newLoc != iDestination) - // goto NEXTDIR; -/* + // if ( nextCost == TRAVELCOST_DOOR ) //&& newLoc != iDestination) + // goto NEXTDIR; + /* // FOLLOWING SECTION COMMENTED OUT ON MARCH 7/97 BY IC if (nextCost == SECRETCOST && !s->human) - goto NEXTDIR; + goto NEXTDIR; if (prevCost==VEINMIDCOST) - if (!ISVEIN(nextCost)) - goto NEXTDIR; + if (!ISVEIN(nextCost)) + goto NEXTDIR; //veining check if (nextCost==VEINMIDCOST) - if (!ISVEIN(prevCost)) - goto NEXTDIR; + if (!ISVEIN(prevCost)) + goto NEXTDIR; if (nextCost==VEINMIDCOST) - //if (ISVEIN(nextCost)) - nextCost=VEINCOST; + //if (ISVEIN(nextCost)) + nextCost=VEINCOST; else - if (nextCost==VEINENDCOST) - if (Grid[newLoc].land < LAKE1) - nextCost = VEINCOST; - else - nextCost = OCEANCOST+(10*PATHFACTOR); + if (nextCost==VEINENDCOST) + if (Grid[newLoc].land < LAKE1) + nextCost = VEINCOST; + else + nextCost = OCEANCOST+(10*PATHFACTOR); - */ + */ if ( fCloseGoodEnough ) { @@ -1615,12 +1615,12 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo } //make the destination look very attractive if (newLoc == iDestination) - nextCost = 0; + nextCost = 0; else - //if (_KeyDown(CTRL_DOWN) && nextCost < TRAVELCOST_VEINEND) - if (gfPlotDirectPath && nextCost < NOPASS) - nextCost = TRAVELCOST_FLAT; - + //if (_KeyDown(CTRL_DOWN) && nextCost < TRAVELCOST_VEINEND) + if (gfPlotDirectPath && nextCost < NOPASS) + nextCost = TRAVELCOST_FLAT; + //if (ISVEIN(prevCost)) @@ -1636,7 +1636,7 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo nextCost = EASYWATERCOST; } -// NOTE: on September 24, 1997, Chris went back to a diagonal bias system + // NOTE: on September 24, 1997, Chris went back to a diagonal bias system if (iCnt & 1) { // moving on a diagonal @@ -1653,50 +1653,50 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo newTotCost = curCost + nextCost; -/* -// no diagonal bias - straightforward costing regardless of direction + /* + // no diagonal bias - straightforward costing regardless of direction newTotCost = curCost + nextCost; -// NOTE: ON JAN 6TH, 1995, IAN COMMENTED OUT THE DIAGONAL BIAS AND -// UNCOMMENTED THE "NO DIAGONAL BIAS" -//diagonal bias - this makes diagonal moves cost more + // NOTE: ON JAN 6TH, 1995, IAN COMMENTED OUT THE DIAGONAL BIAS AND + // UNCOMMENTED THE "NO DIAGONAL BIAS" + //diagonal bias - this makes diagonal moves cost more - if (iCnt & 1) + if (iCnt & 1) // diagonal move costs 70 percent - //newTotCost += (nextCost/PATHFACTOR); - newTotCost += 1; -// newTotCost = curCost + ((prevCost+nextCost)*7)/10; -// else // non-diagonal costs only 50% -// newTotCost = curCost + (prevCost+nextCost)/2; -*/ + //newTotCost += (nextCost/PATHFACTOR); + newTotCost += 1; + // newTotCost = curCost + ((prevCost+nextCost)*7)/10; + // else // non-diagonal costs only 50% + // newTotCost = curCost + (prevCost+nextCost)/2; + */ // have we found a path to the current location that // costs less than the best so far to the same location? if (trailCostUsed[newLoc] != gubGlobalPathCount || newTotCost < trailCost[newLoc]) { - #if defined( PATHAI_VISIBLE_DEBUG ) +#if defined( PATHAI_VISIBLE_DEBUG ) - if (gfDisplayCoverValues && gfDrawPathPoints) + if (gfDisplayCoverValues && gfDrawPathPoints) + { + if (gsCoverValue[newLoc] == 0x7F7F) { - if (gsCoverValue[newLoc] == 0x7F7F) - { - gsCoverValue[newLoc] = usCounter++; - } - /* - else if (gsCoverValue[newLoc] >= 0) - { - gsCoverValue[newLoc]++; - } - else - { - gsCoverValue[newLoc]--; - } - */ + gsCoverValue[newLoc] = usCounter++; } - #endif + /* + else if (gsCoverValue[newLoc] >= 0) + { + gsCoverValue[newLoc]++; + } + else + { + gsCoverValue[newLoc]--; + } + */ + } +#endif //NEWQUENODE; { @@ -1724,9 +1724,9 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo if (pNewPtr == NULL) { - #ifdef COUNT_PATHS - guiFailedPathChecks++; - #endif +#ifdef COUNT_PATHS + guiFailedPathChecks++; +#endif gubNPCAPBudget = 0; gubNPCDistLimit = 0; return(0); @@ -1749,9 +1749,9 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo if (trailTreeNdx >= iMaxTrailTree) { - #ifdef COUNT_PATHS - guiFailedPathChecks++; - #endif +#ifdef COUNT_PATHS + guiFailedPathChecks++; +#endif gubNPCAPBudget = 0; gubNPCDistLimit = 0; return(0); @@ -1773,11 +1773,11 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo pNewPtr->usTotalCost = newTotCost + pNewPtr->usCostToGo; pNewPtr->ubLegDistance = LEGDISTANCE( iLocX, iLocY, iDestX, iDestY ); - + if (gubNPCAPBudget) { - //save the AP cost so far along this path - pNewPtr->ubTotalAPCost = ubNewAPCost; + //save the AP cost so far along this path + pNewPtr->ubTotalAPCost = ubNewAPCost; // update the AP costs in the AI array of path costs if necessary... if (fCopyPathCosts) { @@ -1790,7 +1790,7 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo //update the trail map to reflect the newer shorter path trailCost[newLoc] = (UINT16) newTotCost; trailCostUsed[newLoc] = gubGlobalPathCount; - + //do a sorted que insert of the new path // COMMENTED OUT TO DO BOUNDS CHECKER CC JAN 18 99 //QUEINSERT(pNewPtr); @@ -1846,71 +1846,71 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo } #ifdef PATHAI_SKIPLIST_DEBUG - // print out contents of queue + // print out contents of queue + { + INT32 iLoop; + INT8 bTemp; + + zTempString[0] = '\0'; + pCurr = pQueueHead; + iLoop = 0; + while( pCurr ) { - INT32 iLoop; - INT8 bTemp; - - zTempString[0] = '\0'; - pCurr = pQueueHead; - iLoop = 0; - while( pCurr ) + sprintf( zTS, "\t%ld", pCurr->sPathNdx ); + if (pCurr == pNewPtr) { - sprintf( zTS, "\t%ld", pCurr->sPathNdx ); - if (pCurr == pNewPtr) - { - strcat( zTS, "*" ); - } - strcat( zTempString, zTS ); - pCurr = pCurr->pNext[0]; - iLoop++; - if (iLoop > 50) - { - break; - } + strcat( zTS, "*" ); } - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, zTempString ); - - - zTempString[0] = '\0'; - pCurr = pQueueHead; - iLoop = 0; - while( pCurr ) + strcat( zTempString, zTS ); + pCurr = pCurr->pNext[0]; + iLoop++; + if (iLoop > 50) { - sprintf( zTS, "\t%d", pCurr->bLevel ); - strcat( zTempString, zTS ); - pCurr = pCurr->pNext[0]; - iLoop++; - if (iLoop > 50) - { - break; - } + break; } - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, zTempString ); - - zTempString[0] = '\0'; - bTemp = pQueueHead->bLevel; - pCurr = pQueueHead; - iLoop = 0; - while( pCurr ) - { - bTemp = pQueueHead->bLevel; - while ( pCurr->pNext[ bTemp - 1 ] == NULL ) - { - bTemp--; - } - sprintf( zTS, "\t%d", bTemp ); - strcat( zTempString, zTS ); - pCurr = pCurr->pNext[0]; - iLoop++; - if (iLoop > 50) - { - break; - } - } - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, zTempString ); - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "------" ); } + DebugMsg( TOPIC_JA2, DBG_LEVEL_3, zTempString ); + + + zTempString[0] = '\0'; + pCurr = pQueueHead; + iLoop = 0; + while( pCurr ) + { + sprintf( zTS, "\t%d", pCurr->bLevel ); + strcat( zTempString, zTS ); + pCurr = pCurr->pNext[0]; + iLoop++; + if (iLoop > 50) + { + break; + } + } + DebugMsg( TOPIC_JA2, DBG_LEVEL_3, zTempString ); + + zTempString[0] = '\0'; + bTemp = pQueueHead->bLevel; + pCurr = pQueueHead; + iLoop = 0; + while( pCurr ) + { + bTemp = pQueueHead->bLevel; + while ( pCurr->pNext[ bTemp - 1 ] == NULL ) + { + bTemp--; + } + sprintf( zTS, "\t%d", bTemp ); + strcat( zTempString, zTS ); + pCurr = pCurr->pNext[0]; + iLoop++; + if (iLoop > 50) + { + break; + } + } + DebugMsg( TOPIC_JA2, DBG_LEVEL_3, zTempString ); + DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "------" ); + } #endif } @@ -1938,22 +1938,22 @@ ENDOFLOOP: while (pathQNotEmpty && pathNotYetFound); - #if defined( PATHAI_VISIBLE_DEBUG ) - if (gfDisplayCoverValues && gfDrawPathPoints) +#if defined( PATHAI_VISIBLE_DEBUG ) + if (gfDisplayCoverValues && gfDrawPathPoints) + { + SetRenderFlags( RENDER_FLAG_FULL ); + if ( guiCurrentScreen == GAME_SCREEN ) { - SetRenderFlags( RENDER_FLAG_FULL ); - if ( guiCurrentScreen == GAME_SCREEN ) - { - RenderWorld(); - RenderCoverDebug( ); - InvalidateScreen( ); - EndFrameBufferRender(); - RefreshScreen( NULL ); - } + RenderWorld(); + RenderCoverDebug( ); + InvalidateScreen( ); + EndFrameBufferRender(); + RefreshScreen( NULL ); } - #endif + } +#endif + - // work finished. Did we find a path? if (pathQNotEmpty && pathFound) { @@ -1961,7 +1961,7 @@ ENDOFLOOP: _z=0; z = (INT16) pQueueHead->pNext[0]->sPathNdx; - + while (z) { _nextLink = trailTree[z].nextLink; @@ -1975,52 +1975,52 @@ ENDOFLOOP: // data and copy into soldier's database if (bCopy == COPYROUTE) { - z=_z; - + z=_z; + for (iCnt=0; z && (iCnt < MAX_PATH_LIST_SIZE); iCnt++) - { - s->usPathingData[iCnt] = (INT16) trailTree[z].stepDir; - - z = trailTree[z].nextLink; - } - + { + s->usPathingData[iCnt] = (INT16) trailTree[z].stepDir; + + z = trailTree[z].nextLink; + } + s->usPathIndex = 0; - s->usPathDataSize = (UINT16) iCnt; + s->usPathDataSize = (UINT16) iCnt; } else if (bCopy == NO_COPYROUTE) { - z=_z; + z=_z; for (iCnt=0; z != 0; iCnt++) - { - guiPathingData[ iCnt ] = trailTree[z].stepDir; - - z = trailTree[z].nextLink; - } - - giPathDataSize = (UINT16) iCnt; + { + guiPathingData[ iCnt ] = trailTree[z].stepDir; + + z = trailTree[z].nextLink; + } + + giPathDataSize = (UINT16) iCnt; } - #if defined( PATHAI_VISIBLE_DEBUG ) - if (gfDisplayCoverValues && gfDrawPathPoints) - { - SetRenderFlags( RENDER_FLAG_FULL ); - RenderWorld(); - RenderCoverDebug( ); - InvalidateScreen( ); - EndFrameBufferRender(); - RefreshScreen( NULL ); - } - #endif +#if defined( PATHAI_VISIBLE_DEBUG ) + if (gfDisplayCoverValues && gfDrawPathPoints) + { + SetRenderFlags( RENDER_FLAG_FULL ); + RenderWorld(); + RenderCoverDebug( ); + InvalidateScreen( ); + EndFrameBufferRender(); + RefreshScreen( NULL ); + } +#endif + - // return path length : serves as a "successful" flag and a path length counter - #ifdef COUNT_PATHS - guiSuccessfulPathChecks++; - #endif +#ifdef COUNT_PATHS + guiSuccessfulPathChecks++; +#endif gubNPCAPBudget = 0; gubNPCDistLimit = 0; @@ -2035,17 +2035,17 @@ ENDOFLOOP: return(iCnt); } - #ifdef COUNT_PATHS - if (fCopyReachable) - { - // actually this is a success - guiSuccessfulPathChecks++; - } - else - { - guiUnsuccessfulPathChecks++; - } - #endif +#ifdef COUNT_PATHS + if (fCopyReachable) + { + // actually this is a success + guiSuccessfulPathChecks++; + } + else + { + guiUnsuccessfulPathChecks++; + } +#endif // failed miserably, report... gubNPCAPBudget = 0; @@ -2063,7 +2063,7 @@ void GlobalReachableTest( INT16 sStartGridNo ) SOLDIERTYPE s; INT32 iCurrentGridNo =0; - // WDS - Clean up inventory handling + // WDS - Clean up inventory handling //memset( &s, 0, SIZEOF_SOLDIERTYPE ); s.initialize(); s.sGridNo = sStartGridNo; @@ -2087,7 +2087,7 @@ void LocalReachableTest( INT16 sStartGridNo, INT8 bRadius ) INT32 iCurrentGridNo = 0; INT32 iX, iY; - // WDS - Clean up inventory handling + // WDS - Clean up inventory handling //memset( &s, 0, SIZEOF_SOLDIERTYPE ); s.initialize(); s.sGridNo = sStartGridNo; @@ -2130,7 +2130,7 @@ void GlobalItemsReachableTest( INT16 sStartGridNo1, INT16 sStartGridNo2 ) SOLDIERTYPE s; INT32 iCurrentGridNo =0; - // WDS - Clean up inventory handling + // WDS - Clean up inventory handling //memset( &s, 0, SIZEOF_SOLDIERTYPE ); s.initialize(); s.sGridNo = sStartGridNo1; @@ -2158,7 +2158,7 @@ void RoofReachableTest( INT16 sStartGridNo, UINT8 ubBuildingID ) SOLDIERTYPE s; INT16 sGridNo; - // WDS - Clean up inventory handling + // WDS - Clean up inventory handling //memset( &s, 0, SIZEOF_SOLDIERTYPE ); s.initialize(); s.sGridNo = sStartGridNo; @@ -2169,7 +2169,7 @@ void RoofReachableTest( INT16 sStartGridNo, UINT8 ubBuildingID ) for( sGridNo = 0 ; sGridNo < NOWHERE ; ++sGridNo ) gpWorldLevelData[ sGridNo ].uiFlags &= (~MAPELEMENT_REACHABLE); - + gubBuildingInfoToSet = ubBuildingID; @@ -2188,35 +2188,35 @@ void ErasePath(char bEraseOldOne) { INT16 iCnt; - // NOTE: This routine must be called BEFORE anything happens that changes - // a merc's gridno, else the.... + // NOTE: This routine must be called BEFORE anything happens that changes + // a merc's gridno, else the.... - //EraseAPCursor(); + //EraseAPCursor(); - if ( gfUIHandleShowMoveGrid ) - { - gfUIHandleShowMoveGrid = FALSE; + if ( gfUIHandleShowMoveGrid ) + { + gfUIHandleShowMoveGrid = FALSE; - RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS4 ); - RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS9 ); - RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS2 ); - RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS13 ); - RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS15 ); - RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS19 ); - RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS20 ); - } + RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS4 ); + RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS9 ); + RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS2 ); + RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS13 ); + RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS15 ); + RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS19 ); + RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS20 ); + } if (!gusPathShown) - { - //OldPath = FALSE; - return; - } + { + //OldPath = FALSE; + return; + } - //if (OldPath > 0 && !eraseOldOne) - // return; + //if (OldPath > 0 && !eraseOldOne) + // return; - //OldPath = FALSE; + //OldPath = FALSE; @@ -2224,7 +2224,7 @@ void ErasePath(char bEraseOldOne) for (iCnt=0; iCnt < giPlotCnt; iCnt++) - { + { //Grid[PlottedPath[cnt]].fstep = 0; RemoveAllObjectsOfTypeRange( guiPlottedPath[iCnt], FOOTPRINTS, FOOTPRINTS ); @@ -2232,14 +2232,14 @@ void ErasePath(char bEraseOldOne) RemoveAllOnRoofsOfTypeRange( guiPlottedPath[iCnt], FOOTPRINTS, FOOTPRINTS ); //RemoveAllObjectsOfTypeRange( guiPlottedPath[iCnt], FIRSTPOINTERS, FIRSTPOINTERS ); - } + } - //for (cnt=0; cnt < GRIDSIZE; cnt++) - // Grid[cnt].fstep = 0; - //RemoveAllStructsOfTypeRange( gusEndPlotGridNo, GOODRING, GOODRING ); - - giPlotCnt = 0; - memset(guiPlottedPath,0,256*sizeof(UINT32)); + //for (cnt=0; cnt < GRIDSIZE; cnt++) + // Grid[cnt].fstep = 0; + //RemoveAllStructsOfTypeRange( gusEndPlotGridNo, GOODRING, GOODRING ); + + giPlotCnt = 0; + memset(guiPlottedPath,0,256*sizeof(UINT32)); } @@ -2249,90 +2249,90 @@ void ErasePath(char bEraseOldOne) INT16 PlotPath( SOLDIERTYPE *pSold, INT16 sDestGridno, INT8 bCopyRoute, INT8 bPlot, INT8 bStayOn, UINT16 usMovementMode, INT8 bStealth, INT8 bReverse , INT16 sAPBudget) { - INT16 sTileCost,sPoints=0,sTempGrid,sAnimCost=0; - INT16 sPointsWalk=0,sPointsCrawl=0,sPointsRun=0,sPointsSwat=0; - INT16 sExtraCostStand,sExtraCostSwat,sExtraCostCrawl; - INT32 iLastGrid; - INT32 iCnt; - INT16 sOldGrid=0; - INT16 sFootOrderIndex; - INT16 sSwitchValue; - INT16 sFootOrder[5] = { GREENSTEPSTART, PURPLESTEPSTART, BLUESTEPSTART, - ORANGESTEPSTART, REDSTEPSTART }; - UINT16 usTileIndex; - UINT16 usTileNum; - LEVELNODE *pNode; - UINT16 usMovementModeToUseForAPs; - BOOLEAN bIgnoreNextCost = FALSE; - INT16 sTestGridno; + INT16 sTileCost,sPoints=0,sTempGrid,sAnimCost=0; + INT16 sPointsWalk=0,sPointsCrawl=0,sPointsRun=0,sPointsSwat=0; + INT16 sExtraCostStand,sExtraCostSwat,sExtraCostCrawl; + INT32 iLastGrid; + INT32 iCnt; + INT16 sOldGrid=0; + INT16 sFootOrderIndex; + INT16 sSwitchValue; + INT16 sFootOrder[5] = { GREENSTEPSTART, PURPLESTEPSTART, BLUESTEPSTART, + ORANGESTEPSTART, REDSTEPSTART }; + UINT16 usTileIndex; + UINT16 usTileNum; + LEVELNODE *pNode; + UINT16 usMovementModeToUseForAPs; + BOOLEAN bIgnoreNextCost = FALSE; + INT16 sTestGridno; - if ( bPlot && gusPathShown ) - { - ErasePath(FALSE); - } + if ( bPlot && gusPathShown ) + { + ErasePath(FALSE); + } - gusAPtsToMove = 0; - sTempGrid = (INT16) pSold->sGridNo; - - sFootOrderIndex = 0; - + gusAPtsToMove = 0; + sTempGrid = (INT16) pSold->sGridNo; - //gubNPCMovementMode = (UINT8) usMovementMode; - // distance limit to reduce the cost of plotting a path to a location we can't reach + sFootOrderIndex = 0; - // For now, use known hight adjustment - if ( gfRecalculatingExistingPathCost || FindBestPath( pSold, sDestGridno, (INT8)pSold->bLevel, usMovementMode, bCopyRoute, 0 ) ) - { - // if soldier would be STARTING to run then he pays a penalty since it takes time to - // run full speed - if (pSold->usAnimState != RUNNING) - { + + //gubNPCMovementMode = (UINT8) usMovementMode; + // distance limit to reduce the cost of plotting a path to a location we can't reach + + // For now, use known hight adjustment + if ( gfRecalculatingExistingPathCost || FindBestPath( pSold, sDestGridno, (INT8)pSold->bLevel, usMovementMode, bCopyRoute, 0 ) ) + { + // if soldier would be STARTING to run then he pays a penalty since it takes time to + // run full speed + if (pSold->usAnimState != RUNNING) + { // for estimation purposes, always pay penalty sPointsRun = AP_START_RUN_COST; - } + } - // Add to points, those needed to start from different stance! - sPoints += MinAPsToStartMovement( pSold, usMovementMode ); + // Add to points, those needed to start from different stance! + sPoints += MinAPsToStartMovement( pSold, usMovementMode ); - // We should reduce points for starting to run if first tile is a fence... - sTestGridno = NewGridNo(pSold->sGridNo,(INT16) DirectionInc( (UINT16)guiPathingData[0])); - if ( gubWorldMovementCosts[ sTestGridno ][ (INT8)guiPathingData[0] ][ pSold->bLevel] == TRAVELCOST_FENCE ) - { - if ( usMovementMode == RUNNING && pSold->usAnimState != RUNNING ) - { - sPoints -= AP_START_RUN_COST; - } - } + // We should reduce points for starting to run if first tile is a fence... + sTestGridno = NewGridNo(pSold->sGridNo,(INT16) DirectionInc( (UINT16)guiPathingData[0])); + if ( gubWorldMovementCosts[ sTestGridno ][ (INT8)guiPathingData[0] ][ pSold->bLevel] == TRAVELCOST_FENCE ) + { + if ( usMovementMode == RUNNING && pSold->usAnimState != RUNNING ) + { + sPoints -= AP_START_RUN_COST; + } + } // FIRST, add up "startup" additional costs - such as intermediate animations, etc. -/* removing warning C4060 (jonathanl) + /* removing warning C4060 (jonathanl) switch(pSold->usAnimState) { - //case START_AID : - //case GIVING_AID : sAnimCost = AP_STOP_FIRST_AID; - // break; - //case TWISTOMACH : - //case COLLAPSED : sAnimCost = AP_GET_UP; - // break; - //case TWISTBACK : - //case UNCONSCIOUS : sAnimCost = (AP_ROLL_OVER+AP_GET_UP); - // break; + //case START_AID : + //case GIVING_AID : sAnimCost = AP_STOP_FIRST_AID; + // break; + //case TWISTOMACH : + //case COLLAPSED : sAnimCost = AP_GET_UP; + // break; + //case TWISTBACK : + //case UNCONSCIOUS : sAnimCost = (AP_ROLL_OVER+AP_GET_UP); + // break; - // case CROUCHING : if (usMovementMode == WALKING || usMovementMode == RUNNING) - // sAnimCost = AP_CROUCH; - // break; - } -*/ + // case CROUCHING : if (usMovementMode == WALKING || usMovementMode == RUNNING) + // sAnimCost = AP_CROUCH; + // break; + } + */ sPoints += sAnimCost; gusAPtsToMove += sAnimCost; - - - if (bStayOn) + + + if (bStayOn) { iLastGrid = giPathDataSize+1; } @@ -2341,7 +2341,7 @@ INT16 PlotPath( SOLDIERTYPE *pSold, INT16 sDestGridno, INT8 bCopyRoute, INT8 bPl iLastGrid = giPathDataSize; } - + for ( iCnt=0; iCnt < iLastGrid; iCnt++ ) { sExtraCostStand = 0; @@ -2358,94 +2358,94 @@ INT16 PlotPath( SOLDIERTYPE *pSold, INT16 sDestGridno, INT8 bCopyRoute, INT8 bPl // get the tile cost for that tile based on WALKING sTileCost = TerrainActionPoints( pSold, sTempGrid, (INT8)guiPathingData[iCnt], pSold->bLevel ); - usMovementModeToUseForAPs = usMovementMode; + 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 ) - { - usMovementModeToUseForAPs = WALKING; - } + // ATE - MAKE MOVEMENT ALWAYS WALK IF IN WATER + if ( gpWorldLevelData[ sTempGrid ].ubTerrainID == DEEP_WATER || gpWorldLevelData[ sTempGrid ].ubTerrainID == MED_WATER || gpWorldLevelData[ sTempGrid ].ubTerrainID == LOW_WATER ) + { + usMovementModeToUseForAPs = WALKING; + } - if ( bIgnoreNextCost ) - { - bIgnoreNextCost = FALSE; - } - else - { - // ATE: If we have a 'special cost, like jump fence... - if ( sSwitchValue == TRAVELCOST_FENCE ) - { - sPoints += sTileCost; + if ( bIgnoreNextCost ) + { + bIgnoreNextCost = FALSE; + } + else + { + // ATE: If we have a 'special cost, like jump fence... + if ( sSwitchValue == TRAVELCOST_FENCE ) + { + sPoints += sTileCost; - bIgnoreNextCost = TRUE; + bIgnoreNextCost = TRUE; - // If we are changeing stance ( either before or after getting there.... - // We need to reflect that... - switch( usMovementModeToUseForAPs ) - { - case RUNNING: - case WALKING : + // If we are changeing stance ( either before or after getting there.... + // We need to reflect that... + switch( usMovementModeToUseForAPs ) + { + case RUNNING: + case WALKING : - // Add here cost to go from crouch to stand AFTER fence hop.... - // Since it's AFTER.. make sure we will be moving after jump... - if ( ( iCnt + 2 ) < iLastGrid ) - { - sExtraCostStand += AP_CROUCH; + // Add here cost to go from crouch to stand AFTER fence hop.... + // Since it's AFTER.. make sure we will be moving after jump... + if ( ( iCnt + 2 ) < iLastGrid ) + { + sExtraCostStand += AP_CROUCH; - // ATE: if running, charge extra point to srart again - if ( usMovementModeToUseForAPs== RUNNING ) - { - sExtraCostStand++; - } + // ATE: if running, charge extra point to srart again + if ( usMovementModeToUseForAPs== RUNNING ) + { + sExtraCostStand++; + } - sPoints += sExtraCostStand; - } - break; + sPoints += sExtraCostStand; + } + break; - case SWATTING: + case SWATTING: - // Add cost to stand once there BEFORE.... - sExtraCostSwat += AP_CROUCH; - sPoints += sExtraCostSwat; - break; + // Add cost to stand once there BEFORE.... + sExtraCostSwat += AP_CROUCH; + sPoints += sExtraCostSwat; + break; - case CRAWLING: + case CRAWLING: - // Can't do it here..... - break; + // Can't do it here..... + break; - } - } - else if (sTileCost > 0) - { - // else, movement is adjusted based on mode... + } + } + else if (sTileCost > 0) + { + // else, movement is adjusted based on mode... - if (sSwitchValue == TRAVELCOST_NOT_STANDING) - { - switch( usMovementModeToUseForAPs ) - { - case RUNNING: - case WALKING : - // charge crouch APs for ducking head! - sExtraCostStand += AP_CROUCH; - break; + if (sSwitchValue == TRAVELCOST_NOT_STANDING) + { + switch( usMovementModeToUseForAPs ) + { + case RUNNING: + case WALKING : + // charge crouch APs for ducking head! + sExtraCostStand += AP_CROUCH; + break; - default: - break; - } - } + default: + break; + } + } - // so, then we must modify it for other movement styles and accumulate - switch( usMovementModeToUseForAPs ) - { - case RUNNING: sPoints += (INT16)(DOUBLE)( (sTileCost / RUNDIVISOR) ) + sExtraCostStand; break; - case WALKING : sPoints += (sTileCost + WALKCOST) + sExtraCostStand; break; - case SWATTING: sPoints += (sTileCost + SWATCOST) + sExtraCostSwat; break; - case CRAWLING: sPoints += (sTileCost + CRAWLCOST) + sExtraCostCrawl; break; - default : sPoints += sTileCost; break; - } - } - } + // so, then we must modify it for other movement styles and accumulate + switch( usMovementModeToUseForAPs ) + { + case RUNNING: sPoints += (INT16)(DOUBLE)( (sTileCost / RUNDIVISOR) ) + sExtraCostStand; break; + case WALKING : sPoints += (sTileCost + WALKCOST) + sExtraCostStand; break; + case SWATTING: sPoints += (sTileCost + SWATCOST) + sExtraCostSwat; break; + case CRAWLING: sPoints += (sTileCost + CRAWLCOST) + sExtraCostCrawl; break; + default : sPoints += sTileCost; break; + } + } + } // THIS NEXT SECTION ONLY NEEDS TO HAPPEN FOR CURSOR UI FEEDBACK, NOT ACTUAL COSTING @@ -2455,7 +2455,7 @@ INT16 PlotPath( SOLDIERTYPE *pSold, INT16 sDestGridno, INT8 bCopyRoute, INT8 bPl // store WALK cost sPointsWalk += (sTileCost + WALKCOST) + sExtraCostStand; - + // now get cost as if CRAWLING sPointsCrawl += (sTileCost + CRAWLCOST) + sExtraCostCrawl; @@ -2465,13 +2465,13 @@ INT16 PlotPath( SOLDIERTYPE *pSold, INT16 sDestGridno, INT8 bCopyRoute, INT8 bPl // now get cost as if RUNNING sPointsRun += (INT16)(DOUBLE)( (sTileCost / RUNDIVISOR) ) + sExtraCostStand; } - + if ( iCnt == 0 && bPlot ) { gusAPtsToMove = sPoints; - + giPlotCnt = 0; - + } @@ -2489,7 +2489,7 @@ INT16 PlotPath( SOLDIERTYPE *pSold, INT16 sDestGridno, INT8 bCopyRoute, INT8 bPl { usTileNum = 1; } - + // Are we a vehicle? if ( pSold->uiStatusFlags & SOLDIER_VEHICLE ) { @@ -2544,17 +2544,17 @@ INT16 PlotPath( SOLDIERTYPE *pSold, INT16 sDestGridno, INT8 bCopyRoute, INT8 bPl usTileIndex += sFootOrder[sFootOrderIndex]; } - + /* if ( sPoints <= sAPBudget) { - // find out which color we're using - usTileIndex += sFootOrder[sFootOrderIndex]; + // find out which color we're using + usTileIndex += sFootOrder[sFootOrderIndex]; } else { - // use red footprints ( offset by 16 ) - usTileIndex += REDSTEPSTART; + // use red footprints ( offset by 16 ) + usTileIndex += REDSTEPSTART; } */ @@ -2570,7 +2570,7 @@ INT16 PlotPath( SOLDIERTYPE *pSold, INT16 sDestGridno, INT8 bCopyRoute, INT8 bPl pNode->ubShadeLevel=DEFAULT_SHADE_LEVEL; pNode->ubNaturalShadeLevel=DEFAULT_SHADE_LEVEL; } - + // we need a footstep graphic LEAVING this tile @@ -2582,7 +2582,7 @@ INT16 PlotPath( SOLDIERTYPE *pSold, INT16 sDestGridno, INT8 bCopyRoute, INT8 bPl usTileNum = 1; } - + // this is a LEAVING footstep which is always the second set of 8 usTileNum += 8; @@ -2624,12 +2624,12 @@ INT16 PlotPath( SOLDIERTYPE *pSold, INT16 sDestGridno, INT8 bCopyRoute, INT8 bPl gusPathShown = TRUE; } - } // end of found a path + } // end of found a path - // reset distance limit - gubNPCDistLimit = 0; + // reset distance limit + gubNPCDistLimit = 0; - return(sPoints); + return(sPoints); } @@ -2687,7 +2687,7 @@ INT16 EstimatePlotPath( SOLDIERTYPE *pSold, INT16 sDestGridno, INT8 bCopyRoute, sRet = PlotPath( pSold, sDestGridno, bCopyRoute, bPlot, bStayOn, usMovementMode, bStealth, bReverse, sAPBudget); gfEstimatePath = FALSE; - + return( sRet ); } @@ -2711,83 +2711,83 @@ UINT8 InternalDoorTravelCost( SOLDIERTYPE * pSoldier, INT32 iGridNo, UINT8 ubMov switch( ubMovementCost ) { - case TRAVELCOST_DOOR_CLOSED_HERE: - fDoorIsObstacleIfClosed = TRUE; - iDoorGridNo = iGridNo; - ubReplacementCost = TRAVELCOST_DOOR; - break; - case TRAVELCOST_DOOR_CLOSED_N: - fDoorIsObstacleIfClosed = TRUE; - iDoorGridNo = iGridNo + dirDelta[ NORTH ]; - ubReplacementCost = TRAVELCOST_DOOR; - break; - case TRAVELCOST_DOOR_CLOSED_W: - fDoorIsObstacleIfClosed = TRUE; - iDoorGridNo = iGridNo + dirDelta[ WEST ]; - ubReplacementCost = TRAVELCOST_DOOR; - break; - case TRAVELCOST_DOOR_OPEN_HERE: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = iGridNo; - break; - case TRAVELCOST_DOOR_OPEN_N: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = iGridNo + dirDelta[ NORTH ]; - break; - case TRAVELCOST_DOOR_OPEN_NE: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = iGridNo + dirDelta[ NORTHEAST ]; - break; - case TRAVELCOST_DOOR_OPEN_E: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = iGridNo + dirDelta[ EAST ]; - break; - case TRAVELCOST_DOOR_OPEN_SE: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = iGridNo + dirDelta[ SOUTHEAST ]; - break; - case TRAVELCOST_DOOR_OPEN_S: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = iGridNo + dirDelta[ SOUTH ]; - break; - case TRAVELCOST_DOOR_OPEN_SW: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = iGridNo + dirDelta[ SOUTHWEST ]; - break; - case TRAVELCOST_DOOR_OPEN_W: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = iGridNo + dirDelta[ WEST ]; - break; - case TRAVELCOST_DOOR_OPEN_NW: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = iGridNo + dirDelta[ NORTHWEST ]; - break; - case TRAVELCOST_DOOR_OPEN_N_N: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = iGridNo + dirDelta[ NORTH ] + dirDelta[ NORTH ]; - break; - case TRAVELCOST_DOOR_OPEN_NW_N: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = iGridNo + dirDelta[ NORTHWEST ] + dirDelta[ NORTH ]; - break; - case TRAVELCOST_DOOR_OPEN_NE_N: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = iGridNo + dirDelta[ NORTHEAST ] + dirDelta[ NORTH ]; - break; - case TRAVELCOST_DOOR_OPEN_W_W: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = iGridNo + dirDelta[ WEST ] + dirDelta[ WEST ]; - break; - case TRAVELCOST_DOOR_OPEN_SW_W: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = iGridNo + dirDelta[ SOUTHWEST ] + dirDelta[ WEST ]; - break; - case TRAVELCOST_DOOR_OPEN_NW_W: - fDoorIsObstacleIfClosed = FALSE; - iDoorGridNo = iGridNo + dirDelta[ NORTHWEST ] + dirDelta[ WEST ]; - break; - default: - break; + case TRAVELCOST_DOOR_CLOSED_HERE: + fDoorIsObstacleIfClosed = TRUE; + iDoorGridNo = iGridNo; + ubReplacementCost = TRAVELCOST_DOOR; + break; + case TRAVELCOST_DOOR_CLOSED_N: + fDoorIsObstacleIfClosed = TRUE; + iDoorGridNo = iGridNo + dirDelta[ NORTH ]; + ubReplacementCost = TRAVELCOST_DOOR; + break; + case TRAVELCOST_DOOR_CLOSED_W: + fDoorIsObstacleIfClosed = TRUE; + iDoorGridNo = iGridNo + dirDelta[ WEST ]; + ubReplacementCost = TRAVELCOST_DOOR; + break; + case TRAVELCOST_DOOR_OPEN_HERE: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = iGridNo; + break; + case TRAVELCOST_DOOR_OPEN_N: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = iGridNo + dirDelta[ NORTH ]; + break; + case TRAVELCOST_DOOR_OPEN_NE: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = iGridNo + dirDelta[ NORTHEAST ]; + break; + case TRAVELCOST_DOOR_OPEN_E: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = iGridNo + dirDelta[ EAST ]; + break; + case TRAVELCOST_DOOR_OPEN_SE: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = iGridNo + dirDelta[ SOUTHEAST ]; + break; + case TRAVELCOST_DOOR_OPEN_S: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = iGridNo + dirDelta[ SOUTH ]; + break; + case TRAVELCOST_DOOR_OPEN_SW: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = iGridNo + dirDelta[ SOUTHWEST ]; + break; + case TRAVELCOST_DOOR_OPEN_W: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = iGridNo + dirDelta[ WEST ]; + break; + case TRAVELCOST_DOOR_OPEN_NW: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = iGridNo + dirDelta[ NORTHWEST ]; + break; + case TRAVELCOST_DOOR_OPEN_N_N: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = iGridNo + dirDelta[ NORTH ] + dirDelta[ NORTH ]; + break; + case TRAVELCOST_DOOR_OPEN_NW_N: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = iGridNo + dirDelta[ NORTHWEST ] + dirDelta[ NORTH ]; + break; + case TRAVELCOST_DOOR_OPEN_NE_N: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = iGridNo + dirDelta[ NORTHEAST ] + dirDelta[ NORTH ]; + break; + case TRAVELCOST_DOOR_OPEN_W_W: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = iGridNo + dirDelta[ WEST ] + dirDelta[ WEST ]; + break; + case TRAVELCOST_DOOR_OPEN_SW_W: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = iGridNo + dirDelta[ SOUTHWEST ] + dirDelta[ WEST ]; + break; + case TRAVELCOST_DOOR_OPEN_NW_W: + fDoorIsObstacleIfClosed = FALSE; + iDoorGridNo = iGridNo + dirDelta[ NORTHWEST ] + dirDelta[ WEST ]; + break; + default: + break; } if ( pSoldier && (pSoldier->uiStatusFlags & SOLDIER_MONSTER || pSoldier->uiStatusFlags & SOLDIER_ANIMAL) ) diff --git a/Tactical/Points.cpp b/Tactical/Points.cpp index 83d4d493..8e5a3432 100644 --- a/Tactical/Points.cpp +++ b/Tactical/Points.cpp @@ -1,37 +1,37 @@ #ifdef PRECOMPILEDHEADERS - #include "Tactical All.h" +#include "Tactical All.h" #else - #include "sgp.h" - #include "worlddef.h" - #include "points.h" - #include "overhead.h" - #include "Font control.h" - #include "interface.h" - #include "Isometric utils.h" - #include "pathai.h" - #include "interface.h" - #include "message.h" - #include "Animation Control.h" - #include "Weapons.h" +#include "sgp.h" +#include "worlddef.h" +#include "points.h" +#include "overhead.h" +#include "Font control.h" +#include "interface.h" +#include "Isometric utils.h" +#include "pathai.h" +#include "interface.h" +#include "message.h" +#include "Animation Control.h" +#include "Weapons.h" - #include "structure wrap.h" - #include "dialogue control.h" - #include "items.h" - #include "rt time defines.h" - #include "ai.h" - #include "handle ui.h" - #include "text.h" - #include "SkillCheck.h" - #include "wcheck.h" - #include "Soldier Profile.h" - #include "Soldier macros.h" - #include "Random.h" - #include "Campaign.h" - #include "drugs and alcohol.h" - #include "GameSettings.h" - #include "worldman.h" - #include "math.h" - #include "Interface Items.h" +#include "structure wrap.h" +#include "dialogue control.h" +#include "items.h" +#include "rt time defines.h" +#include "ai.h" +#include "handle ui.h" +#include "text.h" +#include "SkillCheck.h" +#include "wcheck.h" +#include "Soldier Profile.h" +#include "Soldier macros.h" +#include "Random.h" +#include "Campaign.h" +#include "drugs and alcohol.h" +#include "GameSettings.h" +#include "worldman.h" +#include "math.h" +#include "Interface Items.h" #endif //rain @@ -45,21 +45,21 @@ INT16 GetBreathPerAP( SOLDIERTYPE *pSoldier, UINT16 usAnimState ); INT16 TerrainActionPoints( SOLDIERTYPE *pSoldier, INT16 sGridno, INT8 bDir, INT8 bLevel ) { - INT16 sAPCost = 0; - INT16 sSwitchValue; - BOOLEAN fHiddenStructVisible; // Used for hidden struct visiblity + INT16 sAPCost = 0; + INT16 sSwitchValue; + BOOLEAN fHiddenStructVisible; // Used for hidden struct visiblity - if ( pSoldier->bStealthMode ) - sAPCost += AP_STEALTH_MODIFIER; - - if ( pSoldier->bReverse || gUIUseReverse ) - sAPCost += AP_REVERSE_MODIFIER; + if ( pSoldier->bStealthMode ) + sAPCost += AP_STEALTH_MODIFIER; - //if (GridCost[gridno] == NPCMINECOST) - // switchValue = BackupGridCost[gridno]; - //else + if ( pSoldier->bReverse || gUIUseReverse ) + sAPCost += AP_REVERSE_MODIFIER; - sSwitchValue = gubWorldMovementCosts[sGridno][bDir][ bLevel ]; + //if (GridCost[gridno] == NPCMINECOST) + // switchValue = BackupGridCost[gridno]; + //else + + sSwitchValue = gubWorldMovementCosts[sGridno][bDir][ bLevel ]; // Check reality vs what the player knows.... if ( pSoldier->bTeam == gbPlayerNum ) @@ -87,48 +87,48 @@ INT16 TerrainActionPoints( SOLDIERTYPE *pSoldier, INT16 sGridno, INT8 bDir, INT8 if (sSwitchValue >= TRAVELCOST_BLOCKED && sSwitchValue != TRAVELCOST_DOOR ) { - return(100); // Cost too much to be considered! + return(100); // Cost too much to be considered! } - - switch( sSwitchValue ) - { - case TRAVELCOST_DIRTROAD : - case TRAVELCOST_FLAT : sAPCost += AP_MOVEMENT_FLAT; - break; - //case TRAVELCOST_BUMPY : - case TRAVELCOST_GRASS : sAPCost += AP_MOVEMENT_GRASS; - break; - case TRAVELCOST_THICK : sAPCost += AP_MOVEMENT_BUSH; - break; - case TRAVELCOST_DEBRIS : sAPCost += AP_MOVEMENT_RUBBLE; - break; - case TRAVELCOST_SHORE : sAPCost += AP_MOVEMENT_SHORE; // wading shallow water - break; - case TRAVELCOST_KNEEDEEP : sAPCost += AP_MOVEMENT_LAKE; // wading waist/chest deep - very slow - break; - - case TRAVELCOST_DEEPWATER: sAPCost += AP_MOVEMENT_OCEAN; // can swim, so it's faster than wading - break; -/* - case TRAVELCOST_VEINEND : - case TRAVELCOST_VEINMID : sAPCost += AP_MOVEMENT_FLAT; - break; -*/ - case TRAVELCOST_DOOR : sAPCost += AP_MOVEMENT_FLAT; - break; + + switch( sSwitchValue ) + { + case TRAVELCOST_DIRTROAD : + case TRAVELCOST_FLAT : sAPCost += AP_MOVEMENT_FLAT; + break; + //case TRAVELCOST_BUMPY : + case TRAVELCOST_GRASS : sAPCost += AP_MOVEMENT_GRASS; + break; + case TRAVELCOST_THICK : sAPCost += AP_MOVEMENT_BUSH; + break; + case TRAVELCOST_DEBRIS : sAPCost += AP_MOVEMENT_RUBBLE; + break; + case TRAVELCOST_SHORE : sAPCost += AP_MOVEMENT_SHORE; // wading shallow water + break; + case TRAVELCOST_KNEEDEEP : sAPCost += AP_MOVEMENT_LAKE; // wading waist/chest deep - very slow + break; + + case TRAVELCOST_DEEPWATER: sAPCost += AP_MOVEMENT_OCEAN; // can swim, so it's faster than wading + break; + /* + case TRAVELCOST_VEINEND : + case TRAVELCOST_VEINMID : sAPCost += AP_MOVEMENT_FLAT; + break; + */ + case TRAVELCOST_DOOR : sAPCost += AP_MOVEMENT_FLAT; + break; // cost for jumping a fence REPLACES all other AP costs! - case TRAVELCOST_FENCE : return( AP_JUMPFENCE ); + case TRAVELCOST_FENCE : return( AP_JUMPFENCE ); - case TRAVELCOST_NONE : return( 0 ); + case TRAVELCOST_NONE : return( 0 ); - default: + default: - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Calc AP: Unrecongnized MP type %d in %d, direction %d", sSwitchValue, sGridno, bDir ) ); - break; + DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Calc AP: Unrecongnized MP type %d in %d, direction %d", sSwitchValue, sGridno, bDir ) ); + break; - } + } if (bDir & 1) { @@ -179,77 +179,77 @@ INT16 BreathPointAdjustmentForCarriedWeight( SOLDIERTYPE * pSoldier ) INT16 TerrainBreathPoints(SOLDIERTYPE * pSoldier, INT16 sGridno,INT8 bDir, UINT16 usMovementMode) { - INT32 iPoints=0; - UINT8 ubMovementCost; - + INT32 iPoints=0; + UINT8 ubMovementCost; + ubMovementCost = gubWorldMovementCosts[sGridno][bDir][0]; - switch( ubMovementCost ) - { + switch( ubMovementCost ) + { case TRAVELCOST_DIRTROAD : case TRAVELCOST_FLAT : iPoints = BP_MOVEMENT_FLAT; break; - //case TRAVELCOST_BUMPY : - case TRAVELCOST_GRASS : iPoints = BP_MOVEMENT_GRASS; break; - case TRAVELCOST_THICK : iPoints = BP_MOVEMENT_BUSH; break; - case TRAVELCOST_DEBRIS : iPoints = BP_MOVEMENT_RUBBLE; break; - case TRAVELCOST_SHORE : iPoints = BP_MOVEMENT_SHORE; break; // wading shallow water - case TRAVELCOST_KNEEDEEP : iPoints = BP_MOVEMENT_LAKE; break; // wading waist/chest deep - very slow - case TRAVELCOST_DEEPWATER : iPoints = BP_MOVEMENT_OCEAN; break; // can swim, so it's faster than wading -// case TRAVELCOST_VEINEND : -// case TRAVELCOST_VEINMID : iPoints = BP_MOVEMENT_FLAT; break; + //case TRAVELCOST_BUMPY : + case TRAVELCOST_GRASS : iPoints = BP_MOVEMENT_GRASS; break; + case TRAVELCOST_THICK : iPoints = BP_MOVEMENT_BUSH; break; + case TRAVELCOST_DEBRIS : iPoints = BP_MOVEMENT_RUBBLE; break; + case TRAVELCOST_SHORE : iPoints = BP_MOVEMENT_SHORE; break; // wading shallow water + case TRAVELCOST_KNEEDEEP : iPoints = BP_MOVEMENT_LAKE; break; // wading waist/chest deep - very slow + case TRAVELCOST_DEEPWATER : iPoints = BP_MOVEMENT_OCEAN; break; // can swim, so it's faster than wading + // case TRAVELCOST_VEINEND : + // case TRAVELCOST_VEINMID : iPoints = BP_MOVEMENT_FLAT; break; default: if ( IS_TRAVELCOST_DOOR( ubMovementCost ) ) { iPoints = BP_MOVEMENT_FLAT; break; } -/* -#ifdef TESTVERSION - NumMessage("ERROR: TerrainBreathPoints: Unrecognized grid cost = ", - GridCost[gridno]); -#endif -*/ - return(0); - } + /* + #ifdef TESTVERSION + NumMessage("ERROR: TerrainBreathPoints: Unrecognized grid cost = ", + GridCost[gridno]); + #endif + */ + return(0); + } iPoints = iPoints * BreathPointAdjustmentForCarriedWeight( pSoldier ) / 100; - // ATE - MAKE MOVEMENT ALWAYS WALK IF IN WATER + // ATE - MAKE MOVEMENT ALWAYS WALK IF IN WATER if ( gpWorldLevelData[ sGridno ].ubTerrainID == DEEP_WATER || gpWorldLevelData[ sGridno ].ubTerrainID == MED_WATER || gpWorldLevelData[ sGridno ].ubTerrainID == LOW_WATER ) - { - usMovementMode = WALKING; - } + { + usMovementMode = WALKING; + } // so, then we must modify it for other movement styles and accumulate switch(usMovementMode) { - case RUNNING: - case ADULTMONSTER_WALKING: - case BLOODCAT_RUN: - - iPoints *= BP_RUN_ENERGYCOSTFACTOR; break; + case RUNNING: + case ADULTMONSTER_WALKING: + case BLOODCAT_RUN: - case SIDE_STEP: - case WALK_BACKWARDS: - case BLOODCAT_WALK_BACKWARDS: - case MONSTER_WALK_BACKWARDS: - case WALKING : iPoints *= BP_WALK_ENERGYCOSTFACTOR; break; + iPoints *= BP_RUN_ENERGYCOSTFACTOR; break; - case START_SWAT: - case SWATTING: - case SWAT_BACKWARDS: - iPoints *= BP_SWAT_ENERGYCOSTFACTOR; break; - case CRAWLING: iPoints *= BP_CRAWL_ENERGYCOSTFACTOR; break; + case SIDE_STEP: + case WALK_BACKWARDS: + case BLOODCAT_WALK_BACKWARDS: + case MONSTER_WALK_BACKWARDS: + case WALKING : iPoints *= BP_WALK_ENERGYCOSTFACTOR; break; + + case START_SWAT: + case SWATTING: + case SWAT_BACKWARDS: + iPoints *= BP_SWAT_ENERGYCOSTFACTOR; break; + case CRAWLING: iPoints *= BP_CRAWL_ENERGYCOSTFACTOR; break; } // ATE: Adjust these by realtime movement - if (!(gTacticalStatus.uiFlags & TURNBASED) || !(gTacticalStatus.uiFlags & INCOMBAT ) ) - { + if (!(gTacticalStatus.uiFlags & TURNBASED) || !(gTacticalStatus.uiFlags & INCOMBAT ) ) + { // ATE: ADJUST FOR RT - MAKE BREATH GO A LITTLE FASTER! iPoints = (INT32)( iPoints * TB_BREATH_DEDUCT_MODIFIER ); - } + } return( (INT16) iPoints); @@ -268,47 +268,47 @@ INT16 ActionPointCost( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bDir, UINT16 u // Get switch value... sSwitchValue = gubWorldMovementCosts[ sGridNo ][ bDir ][ pSoldier->bLevel ]; - // Tile cost should not be reduced based on movement mode... - if ( sSwitchValue == TRAVELCOST_FENCE ) - { - return( sTileCost ); - } + // Tile cost should not be reduced based on movement mode... + if ( sSwitchValue == TRAVELCOST_FENCE ) + { + return( sTileCost ); + } - // ATE - MAKE MOVEMENT ALWAYS WALK IF IN WATER + // ATE - MAKE MOVEMENT ALWAYS WALK IF IN WATER if ( gpWorldLevelData[ sGridNo ].ubTerrainID == DEEP_WATER || gpWorldLevelData[ sGridNo ].ubTerrainID == MED_WATER || gpWorldLevelData[ sGridNo ].ubTerrainID == LOW_WATER ) - { - usMovementMode = WALKING; - } + { + usMovementMode = WALKING; + } // so, then we must modify it for other movement styles and accumulate if (sTileCost > 0) { switch(usMovementMode) { - case RUNNING: - case ADULTMONSTER_WALKING: - case BLOODCAT_RUN: - sPoints = (INT16)(DOUBLE)( (sTileCost / RUNDIVISOR) ); break; + case RUNNING: + case ADULTMONSTER_WALKING: + case BLOODCAT_RUN: + sPoints = (INT16)(DOUBLE)( (sTileCost / RUNDIVISOR) ); break; - case CROW_FLY: - case SIDE_STEP: - case WALK_BACKWARDS: - case ROBOT_WALK: - case BLOODCAT_WALK_BACKWARDS: - case MONSTER_WALK_BACKWARDS: - case LARVAE_WALK: - case WALKING : sPoints = (sTileCost + WALKCOST); break; + case CROW_FLY: + case SIDE_STEP: + case WALK_BACKWARDS: + case ROBOT_WALK: + case BLOODCAT_WALK_BACKWARDS: + case MONSTER_WALK_BACKWARDS: + case LARVAE_WALK: + case WALKING : sPoints = (sTileCost + WALKCOST); break; - case START_SWAT: - case SWAT_BACKWARDS: - case SWATTING: sPoints = (sTileCost + SWATCOST); break; - case CRAWLING: sPoints = (sTileCost + CRAWLCOST); break; + case START_SWAT: + case SWAT_BACKWARDS: + case SWATTING: sPoints = (sTileCost + SWATCOST); break; + case CRAWLING: sPoints = (sTileCost + CRAWLCOST); break; - default: + default: - // Invalid movement mode - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Invalid movement mode %d used in ActionPointCost", usMovementMode ) ); - sPoints = 1; + // Invalid movement mode + DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Invalid movement mode %d used in ActionPointCost", usMovementMode ) ); + sPoints = 1; } } @@ -316,17 +316,17 @@ INT16 ActionPointCost( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bDir, UINT16 u { switch(usMovementMode) { - case RUNNING: - case WALKING : - case LARVAE_WALK: - case SIDE_STEP: - case WALK_BACKWARDS: - // charge crouch APs for ducking head! - sPoints += AP_CROUCH; - break; + case RUNNING: + case WALKING : + case LARVAE_WALK: + case SIDE_STEP: + case WALK_BACKWARDS: + // charge crouch APs for ducking head! + sPoints += AP_CROUCH; + break; - default: - break; + default: + break; } } @@ -348,30 +348,30 @@ INT16 EstimateActionPointCost( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bDir, { switch(usMovementMode) { - case RUNNING: - case ADULTMONSTER_WALKING: - case BLOODCAT_RUN: - sPoints = (INT16)(DOUBLE)( (sTileCost / RUNDIVISOR) ); break; + case RUNNING: + case ADULTMONSTER_WALKING: + case BLOODCAT_RUN: + sPoints = (INT16)(DOUBLE)( (sTileCost / RUNDIVISOR) ); break; - case CROW_FLY: - case SIDE_STEP: - case ROBOT_WALK: - case WALK_BACKWARDS: - case BLOODCAT_WALK_BACKWARDS: - case MONSTER_WALK_BACKWARDS: - case LARVAE_WALK: - case WALKING : sPoints = (sTileCost + WALKCOST); break; + case CROW_FLY: + case SIDE_STEP: + case ROBOT_WALK: + case WALK_BACKWARDS: + case BLOODCAT_WALK_BACKWARDS: + case MONSTER_WALK_BACKWARDS: + case LARVAE_WALK: + case WALKING : sPoints = (sTileCost + WALKCOST); break; - case START_SWAT: - case SWAT_BACKWARDS: - case SWATTING: sPoints = (sTileCost + SWATCOST); break; - case CRAWLING: sPoints = (sTileCost + CRAWLCOST); break; + case START_SWAT: + case SWAT_BACKWARDS: + case SWATTING: sPoints = (sTileCost + SWATCOST); break; + case CRAWLING: sPoints = (sTileCost + CRAWLCOST); break; - default: + default: - // Invalid movement mode - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Invalid movement mode %d used in ActionPointCost", usMovementMode ) ); - sPoints = 1; + // Invalid movement mode + DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Invalid movement mode %d used in ActionPointCost", usMovementMode ) ); + sPoints = 1; } } @@ -385,54 +385,54 @@ INT16 EstimateActionPointCost( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bDir, // We need to reflect that... switch(usMovementMode) { - case SIDE_STEP: - case WALK_BACKWARDS: - case RUNNING: - case WALKING : + case SIDE_STEP: + case WALK_BACKWARDS: + case RUNNING: + case WALKING : - // Add here cost to go from crouch to stand AFTER fence hop.... - // Since it's AFTER.. make sure we will be moving after jump... - if ( ( bPathIndex + 2 ) < bPathLength ) - { - sPoints += AP_CROUCH; - } - break; - - case SWATTING: - case START_SWAT: - case SWAT_BACKWARDS: - - // Add cost to stand once there BEFORE.... + // Add here cost to go from crouch to stand AFTER fence hop.... + // Since it's AFTER.. make sure we will be moving after jump... + if ( ( bPathIndex + 2 ) < bPathLength ) + { sPoints += AP_CROUCH; - break; + } + break; - case CRAWLING: + case SWATTING: + case START_SWAT: + case SWAT_BACKWARDS: - // Can't do it here..... - break; + // Add cost to stand once there BEFORE.... + sPoints += AP_CROUCH; + break; + + case CRAWLING: + + // Can't do it here..... + break; } } else if (sSwitchValue == TRAVELCOST_NOT_STANDING) { switch(usMovementMode) { - case RUNNING: - case WALKING : - case SIDE_STEP: - case WALK_BACKWARDS: - // charge crouch APs for ducking head! - sPoints += AP_CROUCH; - break; + case RUNNING: + case WALKING : + case SIDE_STEP: + case WALK_BACKWARDS: + // charge crouch APs for ducking head! + sPoints += AP_CROUCH; + break; - default: - break; + default: + break; } } return( sPoints ); } - + BOOLEAN EnoughPoints( SOLDIERTYPE *pSoldier, INT16 sAPCost, INT32 iBPCost, BOOLEAN fDisplayMsg ) { @@ -456,12 +456,12 @@ BOOLEAN EnoughPoints( SOLDIERTYPE *pSoldier, INT16 sAPCost, INT32 iBPCost, BOOLE sAPCost = 0; } - #ifdef NETWORKED +#ifdef NETWORKED if( !IsTheSolderUnderMyControl( pSoldier->ubID) ) { return( TRUE ); } - #endif +#endif // Get New points sNewAP = pSoldier->bActionPoints - sAPCost; @@ -513,7 +513,7 @@ void DeductPoints( SOLDIERTYPE *pSoldier, INT16 sAPCost, INT32 iBPCost,BOOLEAN f DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Deduct Points (%d at %d) %d %d", pSoldier->ubID, pSoldier->sGridNo, sAPCost, iBPCost ) ); - if ( AM_A_ROBOT( pSoldier ) ) + if ( AM_A_ROBOT( pSoldier ) ) { // zap all breath costs for robot iBPCost = 0; @@ -550,7 +550,7 @@ void DeductPoints( SOLDIERTYPE *pSoldier, INT16 sAPCost, INT32 iBPCost,BOOLEAN f // Snap: moved this up, because it had no effect below // Take off 1 AP per 5 (negative) breath... pSoldier->bActionPoints -= ( pSoldier->sBreathRed + iBPCost - BREATH_RED_MAX ) - / ( 5 * BP_RATIO_RED_PTS_TO_NORMAL ); + / ( 5 * BP_RATIO_RED_PTS_TO_NORMAL ); if ( pSoldier->bActionPoints < 0 ) { pSoldier->bActionPoints = 0; @@ -565,7 +565,7 @@ void DeductPoints( SOLDIERTYPE *pSoldier, INT16 sAPCost, INT32 iBPCost,BOOLEAN f // Get new breath bNewBreath = ( pSoldier->bBreathMax * BP_RATIO_RED_PTS_TO_NORMAL - pSoldier->sBreathRed ) - / BP_RATIO_RED_PTS_TO_NORMAL; + / BP_RATIO_RED_PTS_TO_NORMAL; // Snap: This should never happen... if ( bNewBreath > pSoldier->bBreathMax ) @@ -590,49 +590,49 @@ void DeductPoints( SOLDIERTYPE *pSoldier, INT16 sAPCost, INT32 iBPCost,BOOLEAN f INT32 AdjustBreathPts(SOLDIERTYPE *pSold, INT32 iBPCost) { - INT16 sBreathFactor = 100; - UINT8 ubBandaged; + INT16 sBreathFactor = 100; + UINT8 ubBandaged; - //NumMessage("BEFORE adjustments, BREATH PTS = ",breathPts); + //NumMessage("BEFORE adjustments, BREATH PTS = ",breathPts); - // in real time, there IS no AP cost, (only breath cost) - /* - if (!(gTacticalStatus.uiFlags & TURNBASED) || !(gTacticalStatus.uiFlags & INCOMBAT ) ) - { - // ATE: ADJUST FOR RT - MAKE BREATH GO A LITTLE FASTER! - iBPCost *= TB_BREATH_DEDUCT_MODIFIER; - } - */ + // in real time, there IS no AP cost, (only breath cost) + /* + if (!(gTacticalStatus.uiFlags & TURNBASED) || !(gTacticalStatus.uiFlags & INCOMBAT ) ) + { + // ATE: ADJUST FOR RT - MAKE BREATH GO A LITTLE FASTER! + iBPCost *= TB_BREATH_DEDUCT_MODIFIER; + } + */ - // adjust breath factor for current breath deficiency - sBreathFactor += (100 - pSold->bBreath); + // adjust breath factor for current breath deficiency + sBreathFactor += (100 - pSold->bBreath); - // adjust breath factor for current life deficiency (but add 1/2 bandaging) - ubBandaged = pSold->bLifeMax - pSold->bLife - pSold->bBleeding; - //sBreathFactor += (pSold->bLifeMax - (pSold->bLife + (ubBandaged / 2))); - sBreathFactor += 100 * (pSold->bLifeMax - (pSold->bLife + (ubBandaged / 2))) / pSold->bLifeMax; + // adjust breath factor for current life deficiency (but add 1/2 bandaging) + ubBandaged = pSold->bLifeMax - pSold->bLife - pSold->bBleeding; + //sBreathFactor += (pSold->bLifeMax - (pSold->bLife + (ubBandaged / 2))); + sBreathFactor += 100 * (pSold->bLifeMax - (pSold->bLife + (ubBandaged / 2))) / pSold->bLifeMax; - if ( pSold->bStrength > 80 ) - { - // give % reduction to breath costs for high strength mercs - sBreathFactor -= (pSold->bStrength - 80) / 2; - } - -/* THIS IS OLD JAGGED ALLIANCE STUFF (left for possible future reference) + if ( pSold->bStrength > 80 ) + { + // give % reduction to breath costs for high strength mercs + sBreathFactor -= (pSold->bStrength - 80) / 2; + } - // apply penalty due to high temperature, heat, and hot Metaviran sun - // if INDOORS, in DEEP WATER, or possessing HEAT TOLERANCE trait - if ((ptr->terrtype == FLOORTYPE) || (ptr->terr >= OCEAN21) || - (ptr->trait == HEAT_TOLERANT)) - breathFactor += (Status.heatFactor / 5); // 20% of normal heat penalty - else - breathFactor += Status.heatFactor; // not used to this! -*/ + /* THIS IS OLD JAGGED ALLIANCE STUFF (left for possible future reference) + + // apply penalty due to high temperature, heat, and hot Metaviran sun + // if INDOORS, in DEEP WATER, or possessing HEAT TOLERANCE trait + if ((ptr->terrtype == FLOORTYPE) || (ptr->terr >= OCEAN21) || + (ptr->trait == HEAT_TOLERANT)) + breathFactor += (Status.heatFactor / 5); // 20% of normal heat penalty + else + breathFactor += Status.heatFactor; // not used to this! + */ - // if a non-swimmer type is thrashing around in deep water + // if a non-swimmer type is thrashing around in deep water if ( (pSold->ubProfile != NO_PROFILE ) && (gMercProfiles[ pSold->ubProfile ].bPersonalityTrait == NONSWIMMER) ) { if ( pSold->usAnimState == DEEP_WATER_TRED || pSold->usAnimState == DEEP_WATER_SWIM) @@ -641,19 +641,19 @@ INT32 AdjustBreathPts(SOLDIERTYPE *pSold, INT32 iBPCost) } } - if ( sBreathFactor == 0 ) - { + if ( sBreathFactor == 0 ) + { iBPCost = 0; - } - else if (iBPCost > 0) // breath DECREASE - // increase breath COST by breathFactor - iBPCost = ((iBPCost * sBreathFactor) / 100); - else // breath INCREASE - // decrease breath GAIN by breathFactor - iBPCost = ((iBPCost * 100) / sBreathFactor); + } + else if (iBPCost > 0) // breath DECREASE + // increase breath COST by breathFactor + iBPCost = ((iBPCost * sBreathFactor) / 100); + else // breath INCREASE + // decrease breath GAIN by breathFactor + iBPCost = ((iBPCost * 100) / sBreathFactor); - - return(iBPCost); + + return(iBPCost); } @@ -697,7 +697,7 @@ void UnusedAPsToBreath(SOLDIERTYPE *pSold) // If this value is -ve, we have a gain, else we have a loos which we should not really do // We just want to limit this to no gain if we were doing stuff... sBreathChange = 3 * sBreathPerAP; - + // Adjust for on drugs HandleBPEffectDueToDrugs( pSold, &sBreathChange ); @@ -716,7 +716,7 @@ void UnusedAPsToBreath(SOLDIERTYPE *pSold) sBreathPerAP = GetBreathPerAP( pSold, pSold->usLastMovementAnimPerRTBreathUpdate ); sRTBreathMod = sBreathPerAP * pSold->ubTilesMovedPerRTBreathUpdate; - + // Deduct some if we were exerting ourselves // We add here because to gain breath, sBreathChange needs to be -ve if ( sRTBreathMod > 0 ) @@ -765,29 +765,29 @@ void UnusedAPsToBreath(SOLDIERTYPE *pSold) // adjust for carried weight sBreathPerAP = sBreathPerAP * 100 / BreathPointAdjustmentForCarriedWeight( pSold ); - + if ( pSold->bTeam != CIV_TEAM && pSold->bTeam != gbPlayerNum) { switch( gGameOptions.ubDifficultyLevel ) { - case DIF_LEVEL_EASY: - sBreathChange = ((AP_MAXIMUM + gGameExternalOptions.iEasyAPBonus)- sUnusedAPs) * sBreathPerAP; - break; + case DIF_LEVEL_EASY: + sBreathChange = ((AP_MAXIMUM + gGameExternalOptions.iEasyAPBonus)- sUnusedAPs) * sBreathPerAP; + break; - case DIF_LEVEL_MEDIUM: - sBreathChange = ((AP_MAXIMUM + gGameExternalOptions.iExperiencedAPBonus)-sUnusedAPs) * sBreathPerAP; - break; + case DIF_LEVEL_MEDIUM: + sBreathChange = ((AP_MAXIMUM + gGameExternalOptions.iExperiencedAPBonus)-sUnusedAPs) * sBreathPerAP; + break; - case DIF_LEVEL_HARD: - sBreathChange = ((AP_MAXIMUM + gGameExternalOptions.iExpertAPBonus)- sUnusedAPs) * sBreathPerAP; - break; + case DIF_LEVEL_HARD: + sBreathChange = ((AP_MAXIMUM + gGameExternalOptions.iExpertAPBonus)- sUnusedAPs) * sBreathPerAP; + break; - case DIF_LEVEL_INSANE: - sBreathChange = ((AP_MAXIMUM + gGameExternalOptions.iInsaneAPBonus)- sUnusedAPs) * sBreathPerAP; - break; + case DIF_LEVEL_INSANE: + sBreathChange = ((AP_MAXIMUM + gGameExternalOptions.iInsaneAPBonus)- sUnusedAPs) * sBreathPerAP; + break; - default: - sBreathChange = (AP_MAXIMUM - sUnusedAPs) * sBreathPerAP; + default: + sBreathChange = (AP_MAXIMUM - sUnusedAPs) * sBreathPerAP; } } else @@ -828,15 +828,15 @@ INT16 GetBreathPerAP( SOLDIERTYPE *pSoldier, UINT16 usAnimState ) { switch( usAnimState ) { - case STANDING: + case STANDING: - sBreathPerAP = BP_PER_AP_LT_EFFORT; - break; + sBreathPerAP = BP_PER_AP_LT_EFFORT; + break; - case WALKING: + case WALKING: - sBreathPerAP = BP_PER_AP_MOD_EFFORT; - break; + sBreathPerAP = BP_PER_AP_MOD_EFFORT; + break; } } else @@ -844,15 +844,15 @@ INT16 GetBreathPerAP( SOLDIERTYPE *pSoldier, UINT16 usAnimState ) switch( usAnimState ) { - case STANDING: + case STANDING: - sBreathPerAP = BP_PER_AP_NO_EFFORT; - break; + sBreathPerAP = BP_PER_AP_NO_EFFORT; + break; - case WALKING: + case WALKING: - sBreathPerAP = BP_PER_AP_LT_EFFORT; - break; + sBreathPerAP = BP_PER_AP_LT_EFFORT; + break; } } fAnimTypeFound = TRUE; @@ -898,33 +898,33 @@ UINT8 CalcAPsToBurst( INT8 bBaseActionPoints, OBJECTTYPE * pObj ) { INT32 aps; - // base APs is what you'd get from CalcActionPoints(); + // base APs is what you'd get from CalcActionPoints(); // NB round UP, so 21-25 APs pay full aps = ( Weapon[ pObj->usItem ].bBurstAP * bBaseActionPoints + (AP_MAXIMUM - 1) ) / AP_MAXIMUM; /*if ( GetPercentBurstFireAPReduction(pObj)>0 ) { - aps = (aps * 100) / (100 + GetBurstFireAPReductionStatus(pObj) / (100/GetPercentBurstFireAPReduction(pObj))); + aps = (aps * 100) / (100 + GetBurstFireAPReductionStatus(pObj) / (100/GetPercentBurstFireAPReduction(pObj))); } if ( GetPercentAPReduction(pObj)>0 ) { - aps = (aps * 100) / (100 + GetAPReductionStatus(pObj) / (100/GetPercentAPReduction(pObj))); + aps = (aps * 100) / (100 + GetAPReductionStatus(pObj) / (100/GetPercentAPReduction(pObj))); }*/ - + DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("CalcAPsToBurst: before bonus aps = %d, std bonus = %d, burst bonus = %d", aps,GetPercentAPReduction(pObj),GetPercentBurstFireAPReduction(pObj))); // Snap: do this a little differently: % reduction means // aps <- aps * ( 100 - red ) / 100 aps = ( aps * ( 100 - GetPercentAPReduction(pObj) ) ) / 100; - + // Snap: moved this up to allow burst AP reduction up to 100% aps = __max( aps, ( Weapon[ pObj->usItem ].bBurstAP + 1 ) / 2 ); aps = ( aps * ( 100 - GetPercentBurstFireAPReduction(pObj) ) ) / 100; - + if ( aps < 0 ) aps = 0; else if ( aps > AP_MAXIMUM ) aps = AP_MAXIMUM; - + DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("CalcAPsToBurst: return aps = %d", aps)); return (UINT8) aps; } @@ -932,14 +932,14 @@ UINT8 CalcAPsToBurst( INT8 bBaseActionPoints, OBJECTTYPE * pObj ) UINT8 CalcAPsToAutofire( INT8 bBaseActionPoints, OBJECTTYPE * pObj, UINT8 bDoAutofire ) { -// INT8 bAttachPos; + // INT8 bAttachPos; INT32 aps=AP_MAXIMUM + 1; if ( GetAutofireShotsPerFiveAPs (pObj) ) { // Snap: Do this just like in CalcAPsToBurst const INT32 autofireaps = - aps = ( ( 5 * bDoAutofire * bBaseActionPoints ) / GetAutofireShotsPerFiveAPs(pObj) + (AP_MAXIMUM - 1) ) / AP_MAXIMUM; + aps = ( ( 5 * bDoAutofire * bBaseActionPoints ) / GetAutofireShotsPerFiveAPs(pObj) + (AP_MAXIMUM - 1) ) / AP_MAXIMUM; //DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("CalcAPsToAutofire: base aps = %d, # shots = %d",aps,pSoldier->bDoAutofire )); //check for spring and bolt @@ -961,15 +961,15 @@ UINT8 CalcAPsToAutofire( INT8 bBaseActionPoints, OBJECTTYPE * pObj, UINT8 bDoAut // aps = ( aps * 100 ) / (100 + pSoldier->inv[HANDPOS].bAttachStatus[ bAttachPos ] / 5); // DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("CalcAPsToAutofire: found reflex sight, aps = %d, # shots = %d",aps,pSoldier->bDoAutofire )); //} - + DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("CalcAPsToAutoFire: before bonus aps = %d, std bonus = %d, auto bonus = %d", aps,GetPercentAPReduction(pObj),GetPercentAutofireAPReduction(pObj))); aps = ( aps * ( 100 - GetPercentAPReduction(pObj) ) ) / 100; - + aps = __max( aps, ( autofireaps + 1 ) / 2 ); // Snap: extend the burst bonus to autofire as well? aps = ( aps * ( 100 - GetPercentAutofireAPReduction(pObj) ) ) / 100; - + if ( aps < 0 ) aps = 0; else if ( aps > AP_MAXIMUM ) aps = AP_MAXIMUM; } @@ -987,7 +987,7 @@ UINT8 CalcTotalAPsToAttack( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAddTur UINT8 ubDirection; INT16 sAdjustedGridNo; UINT32 uiItemClass; - + // LOOK IN BUDDY'S HAND TO DETERMINE WHAT TO DO HERE usItemNum = pSoldier->inv[HANDPOS].usItem; uiItemClass = Item[ usItemNum ].usItemClass; @@ -1012,9 +1012,9 @@ UINT8 CalcTotalAPsToAttack( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAddTur //ATE: HERE, need to calculate APs! if ( uiItemClass & IC_EXPLOSV ) { - sAPCost = MinAPsToAttack( pSoldier, sGridNo, ubAddTurningCost ); + sAPCost = MinAPsToAttack( pSoldier, sGridNo, ubAddTurningCost ); - //sAPCost = 5; + //sAPCost = 5; } if ( uiItemClass == IC_PUNCH || ( uiItemClass == IC_BLADE && uiItemClass != IC_THROWING_KNIFE ) ) @@ -1022,6 +1022,8 @@ UINT8 CalcTotalAPsToAttack( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAddTur // IF we are at this gridno, calc min APs but if not, calc cost to goto this lication if ( pSoldier->sGridNo != sGridNo ) { + sAdjustedGridNo = NOWHERE; + // OK, in order to avoid path calculations here all the time... save and check if it's changed! if ( pSoldier->sWalkToAttackGridNo == sGridNo ) { @@ -1146,7 +1148,7 @@ UINT8 MinAPsToAttack(SOLDIERTYPE *pSoldier, INT16 sGridno, UINT8 ubAddTurningCos // LOOK IN BUDDY'S HAND TO DETERMINE WHAT TO DO HERE uiItemClass = Item[ pSoldier->inv[HANDPOS].usItem ].usItemClass; } - + if ( uiItemClass == IC_BLADE || uiItemClass == IC_GUN || uiItemClass == IC_LAUNCHER || uiItemClass == IC_TENTACLES || uiItemClass == IC_THROWING_KNIFE ) { sAPCost = MinAPsToShootOrStab( pSoldier, sGridno, ubAddTurningCost, ubForceRaiseGunCost ); @@ -1159,7 +1161,7 @@ UINT8 MinAPsToAttack(SOLDIERTYPE *pSoldier, INT16 sGridno, UINT8 ubAddTurningCos { sAPCost = MinAPsToPunch( pSoldier, sGridno, ubAddTurningCost ); } - + return( (UINT8)sAPCost ); } @@ -1173,8 +1175,8 @@ INT8 CalcAimSkill( SOLDIERTYPE * pSoldier, UINT16 usWeapon ) bAimSkill = EffectiveMarksmanship( pSoldier ); } else - // for now use this for all other weapons - //if ( Item[ usInHand ].usItemClass == IC_BLADE ) + // for now use this for all other weapons + //if ( Item[ usInHand ].usItemClass == IC_BLADE ) { // KNIVES: modify aiming cost by avg of attacker's DEXTERITY & AGILITY bAimSkill = ( EffectiveDexterity( pSoldier ) + EffectiveAgility( pSoldier ) ) / 2; @@ -1186,7 +1188,7 @@ INT8 CalcAimSkill( SOLDIERTYPE * pSoldier, UINT16 usWeapon ) UINT8 BaseAPsToShootOrStab( INT8 bAPs, INT8 bAimSkill, OBJECTTYPE * pObj ) { INT32 Top, Bottom, rof; -// INT8 bAttachPos; + // INT8 bAttachPos; // Calculate default top & bottom of the magic "aiming" formula! @@ -1205,7 +1207,7 @@ UINT8 BaseAPsToShootOrStab( INT8 bAPs, INT8 bAimSkill, OBJECTTYPE * pObj ) { rof += GetRateOfFireBonus(pObj); } - + //Bottom = ( ( 50 + (bAimSkill / 2) ) * rof ) / 4; // add minimum aiming time to the overall minimum AP_cost @@ -1230,53 +1232,53 @@ UINT8 BaseAPsToShootOrStab( INT8 bAPs, INT8 bAimSkill, OBJECTTYPE * pObj ) void GetAPChargeForShootOrStabWRTGunRaises( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAddTurningCost, BOOLEAN *pfChargeTurning, BOOLEAN *pfChargeRaise ) { - UINT8 ubDirection; - UINT32 uiMercFlags; - UINT16 usTargID; - BOOLEAN fAddingTurningCost = FALSE; - BOOLEAN fAddingRaiseGunCost = FALSE; - - if ( sGridNo != NOWHERE ) - { - // OK, get a direction and see if we need to turn... - if (ubAddTurningCost) - { - // Given a gridno here, check if we are on a guy - if so - get his gridno - if ( FindSoldier( sGridNo, &usTargID, &uiMercFlags, FIND_SOLDIER_GRIDNO ) ) - { - sGridNo = MercPtrs[ usTargID ]->sGridNo; - } + UINT8 ubDirection; + UINT32 uiMercFlags; + UINT16 usTargID; + BOOLEAN fAddingTurningCost = FALSE; + BOOLEAN fAddingRaiseGunCost = FALSE; - ubDirection = (UINT8)GetDirectionFromGridNo( sGridNo, pSoldier ); + if ( sGridNo != NOWHERE ) + { + // OK, get a direction and see if we need to turn... + if (ubAddTurningCost) + { + // Given a gridno here, check if we are on a guy - if so - get his gridno + if ( FindSoldier( sGridNo, &usTargID, &uiMercFlags, FIND_SOLDIER_GRIDNO ) ) + { + sGridNo = MercPtrs[ usTargID ]->sGridNo; + } - // Is it the same as he's facing? - if ( ubDirection != pSoldier->bDirection ) - { - fAddingTurningCost = TRUE; - } - } - } - else - { - if (ubAddTurningCost) - { - // Assume we need to add cost! + ubDirection = (UINT8)GetDirectionFromGridNo( sGridNo, pSoldier ); + + // Is it the same as he's facing? + if ( ubDirection != pSoldier->bDirection ) + { fAddingTurningCost = TRUE; - } - } + } + } + } + else + { + if (ubAddTurningCost) + { + // Assume we need to add cost! + fAddingTurningCost = TRUE; + } + } - if ( Item[ pSoldier->inv[ HANDPOS ].usItem ].usItemClass == IC_THROWING_KNIFE ) - { - } - else - { - // Do we need to ready weapon? - if ( !( gAnimControl[ pSoldier->usAnimState ].uiFlags &( ANIM_FIREREADY | ANIM_FIRE ) ) ) - { - fAddingRaiseGunCost = TRUE; - } - } + if ( Item[ pSoldier->inv[ HANDPOS ].usItem ].usItemClass == IC_THROWING_KNIFE ) + { + } + else + { + // Do we need to ready weapon? + if ( !( gAnimControl[ pSoldier->usAnimState ].uiFlags &( ANIM_FIREREADY | ANIM_FIRE ) ) ) + { + fAddingRaiseGunCost = TRUE; + } + } (*pfChargeTurning) = fAddingTurningCost; (*pfChargeRaise ) = fAddingRaiseGunCost; @@ -1315,8 +1317,8 @@ UINT8 MinAPsToShootOrStab(SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAddTurni if ( Item[ usItem ].usItemClass == IC_THROWING_KNIFE ) { - // Do we need to stand up? - bAPCost += GetAPsToChangeStance( pSoldier, ANIM_STAND ); + // Do we need to stand up? + bAPCost += GetAPsToChangeStance( pSoldier, ANIM_STAND ); } if ( AM_A_ROBOT( pSoldier ) ) @@ -1347,11 +1349,11 @@ UINT8 MinAPsToShootOrStab(SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAddTurni if ( sGridNo != NOWHERE ) { - // Given a gridno here, check if we are on a guy - if so - get his gridno - if ( FindSoldier( sGridNo, &usTargID, &uiMercFlags, FIND_SOLDIER_GRIDNO ) ) - { - sGridNo = MercPtrs[ usTargID ]->sGridNo; - } + // Given a gridno here, check if we are on a guy - if so - get his gridno + if ( FindSoldier( sGridNo, &usTargID, &uiMercFlags, FIND_SOLDIER_GRIDNO ) ) + { + sGridNo = MercPtrs[ usTargID ]->sGridNo; + } } // if attacking a new target (or if the specific target is uncertain) @@ -1374,7 +1376,7 @@ UINT8 MinAPsToShootOrStab(SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAddTurni // look for an attached grenade launcher glItem = GetAttachedGrenadeLauncher( &(pSoldier->inv[ HANDPOS ])); - + // create temporary grenade launcher and use that if ( glItem != NONE ) { @@ -1386,19 +1388,19 @@ UINT8 MinAPsToShootOrStab(SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAddTurni CreateItem( UNDER_GLAUNCHER, 100, &GrenadeLauncher ); } - bAPCost += BaseAPsToShootOrStab( bFullAPs, bAimSkill, &GrenadeLauncher ); - + bAPCost += BaseAPsToShootOrStab( bFullAPs, bAimSkill, &GrenadeLauncher ); + } else if ( IsValidSecondHandShot( pSoldier ) ) { - // charge the maximum of the two - bAPCost += __max( - BaseAPsToShootOrStab( bFullAPs, bAimSkill, &(pSoldier->inv[HANDPOS]) ), - BaseAPsToShootOrStab( bFullAPs, bAimSkill, &(pSoldier->inv[SECONDHANDPOS]) ) ); + // charge the maximum of the two + bAPCost += __max( + BaseAPsToShootOrStab( bFullAPs, bAimSkill, &(pSoldier->inv[HANDPOS]) ), + BaseAPsToShootOrStab( bFullAPs, bAimSkill, &(pSoldier->inv[SECONDHANDPOS]) ) ); } else { - bAPCost += BaseAPsToShootOrStab( bFullAPs, bAimSkill, &(pSoldier->inv[HANDPOS]) ); + bAPCost += BaseAPsToShootOrStab( bFullAPs, bAimSkill, &(pSoldier->inv[HANDPOS]) ); } // the minimum AP cost of ANY shot can NEVER be more than merc's maximum APs! @@ -1421,83 +1423,83 @@ UINT8 MinAPsToShootOrStab(SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAddTurni UINT8 MinAPsToPunch(SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAddTurningCost) { - UINT8 bAPCost = 0; - UINT16 usTargID; - UINT8 ubDirection; + UINT8 bAPCost = 0; + UINT16 usTargID; + UINT8 ubDirection; - // bAimSkill = ( pSoldier->bDexterity + pSoldier->bAgility) / 2; - if ( sGridNo != NOWHERE ) - { - usTargID = WhoIsThere2( sGridNo, pSoldier->bTargetLevel ); + // bAimSkill = ( pSoldier->bDexterity + pSoldier->bAgility) / 2; + if ( sGridNo != NOWHERE ) + { + usTargID = WhoIsThere2( sGridNo, pSoldier->bTargetLevel ); - // Given a gridno here, check if we are on a guy - if so - get his gridno - if ( usTargID != NOBODY ) - { + // Given a gridno here, check if we are on a guy - if so - get his gridno + if ( usTargID != NOBODY ) + { sGridNo = MercPtrs[ usTargID ]->sGridNo; - // Check if target is prone, if so, calc cost... - if ( gAnimControl[ MercPtrs[ usTargID ]->usAnimState ].ubEndHeight == ANIM_PRONE ) + // Check if target is prone, if so, calc cost... + if ( gAnimControl[ MercPtrs[ usTargID ]->usAnimState ].ubEndHeight == ANIM_PRONE ) { bAPCost += GetAPsToChangeStance( pSoldier, ANIM_CROUCH ); } - else + else { - if ( pSoldier->sGridNo == sGridNo ) - { - bAPCost += GetAPsToChangeStance( pSoldier, ANIM_STAND ); - } + if ( pSoldier->sGridNo == sGridNo ) + { + bAPCost += GetAPsToChangeStance( pSoldier, ANIM_STAND ); + } } - } + } - if (ubAddTurningCost) - { - if ( pSoldier->sGridNo == sGridNo ) - { - // ATE: Use standing turn cost.... - ubDirection = (UINT8)GetDirectionFromGridNo( sGridNo, pSoldier ); + if (ubAddTurningCost) + { + if ( pSoldier->sGridNo == sGridNo ) + { + // ATE: Use standing turn cost.... + ubDirection = (UINT8)GetDirectionFromGridNo( sGridNo, pSoldier ); - // Is it the same as he's facing? - if ( ubDirection != pSoldier->bDirection ) - { - bAPCost += AP_LOOK_STANDING; - } - } - } + // Is it the same as he's facing? + if ( ubDirection != pSoldier->bDirection ) + { + bAPCost += AP_LOOK_STANDING; + } + } + } - } + } - bAPCost += 4; + bAPCost += 4; - return ( bAPCost ); + return ( bAPCost ); } INT8 MinPtsToMove(SOLDIERTYPE *pSoldier) { - // look around all 8 directions and return lowest terrain cost - INT32 cnt; - INT16 sLowest=127; - INT16 sGridno,sCost; + // look around all 8 directions and return lowest terrain cost + INT32 cnt; + INT16 sLowest=127; + INT16 sGridno,sCost; - if ( TANK( pSoldier ) ) - { - return( (INT8)sLowest); - } + if ( TANK( pSoldier ) ) + { + return( (INT8)sLowest); + } - for (cnt=0; cnt <= 7; cnt++) - { - sGridno = NewGridNo(pSoldier->sGridNo,DirectionInc((INT16) cnt)); - if (sGridno != pSoldier->sGridNo) + for (cnt=0; cnt <= 7; cnt++) + { + sGridno = NewGridNo(pSoldier->sGridNo,DirectionInc((INT16) cnt)); + if (sGridno != pSoldier->sGridNo) { - if ( (sCost=ActionPointCost( pSoldier, sGridno, (UINT8)cnt , pSoldier->usUIMovementMode ) ) < sLowest ) - { - sLowest = sCost; - } + if ( (sCost=ActionPointCost( pSoldier, sGridno, (UINT8)cnt , pSoldier->usUIMovementMode ) ) < sLowest ) + { + sLowest = sCost; + } } - } - return( (INT8)sLowest); + } + return( (INT8)sLowest); } INT8 PtsToMoveDirection(SOLDIERTYPE *pSoldier, INT8 bDirection ) @@ -1506,7 +1508,7 @@ INT8 PtsToMoveDirection(SOLDIERTYPE *pSoldier, INT8 bDirection ) INT8 bOverTerrainType; UINT16 usMoveModeToUse; - sGridno = NewGridNo( pSoldier->sGridNo, DirectionInc((INT16) bDirection ) ); + sGridno = NewGridNo( pSoldier->sGridNo, DirectionInc((INT16) bDirection ) ); usMoveModeToUse = pSoldier->usUIMovementMode; @@ -1518,16 +1520,16 @@ INT8 PtsToMoveDirection(SOLDIERTYPE *pSoldier, INT8 bDirection ) usMoveModeToUse = WALKING; } - sCost = ActionPointCost( pSoldier, sGridno, bDirection , usMoveModeToUse ); + sCost = ActionPointCost( pSoldier, sGridno, bDirection , usMoveModeToUse ); + + if ( gubWorldMovementCosts[ sGridno ][ bDirection ][ pSoldier->bLevel ] != TRAVELCOST_FENCE ) + { + if ( usMoveModeToUse == RUNNING && pSoldier->usAnimState != RUNNING ) + { + sCost += AP_START_RUN_COST; + } + } - if ( gubWorldMovementCosts[ sGridno ][ bDirection ][ pSoldier->bLevel ] != TRAVELCOST_FENCE ) - { - if ( usMoveModeToUse == RUNNING && pSoldier->usAnimState != RUNNING ) - { - sCost += AP_START_RUN_COST; - } - } - return( (INT8)sCost ); } @@ -1537,39 +1539,39 @@ INT8 MinAPsToStartMovement( SOLDIERTYPE * pSoldier, UINT16 usMovementMode ) switch( usMovementMode ) { - case RUNNING: - case WALKING: - if (gAnimControl[ pSoldier->usAnimState ].ubEndHeight == ANIM_PRONE) - { - bAPs += AP_CROUCH + AP_PRONE; - } - else if (gAnimControl[ pSoldier->usAnimState ].ubEndHeight == ANIM_CROUCH) - { - bAPs += AP_CROUCH; - } - break; - case SWATTING: - if (gAnimControl[ pSoldier->usAnimState ].ubEndHeight == ANIM_PRONE) - { - bAPs += AP_PRONE; - } - else if (gAnimControl[ pSoldier->usAnimState ].ubEndHeight == ANIM_STAND) - { - bAPs += AP_CROUCH; - } - break; - case CRAWLING: - if (gAnimControl[ pSoldier->usAnimState ].ubEndHeight == ANIM_STAND) - { - bAPs += AP_CROUCH + AP_PRONE; - } - else if (gAnimControl[ pSoldier->usAnimState ].ubEndHeight == ANIM_CROUCH) - { - bAPs += AP_CROUCH; - } - break; - default: - break; + case RUNNING: + case WALKING: + if (gAnimControl[ pSoldier->usAnimState ].ubEndHeight == ANIM_PRONE) + { + bAPs += AP_CROUCH + AP_PRONE; + } + else if (gAnimControl[ pSoldier->usAnimState ].ubEndHeight == ANIM_CROUCH) + { + bAPs += AP_CROUCH; + } + break; + case SWATTING: + if (gAnimControl[ pSoldier->usAnimState ].ubEndHeight == ANIM_PRONE) + { + bAPs += AP_PRONE; + } + else if (gAnimControl[ pSoldier->usAnimState ].ubEndHeight == ANIM_STAND) + { + bAPs += AP_CROUCH; + } + break; + case CRAWLING: + if (gAnimControl[ pSoldier->usAnimState ].ubEndHeight == ANIM_STAND) + { + bAPs += AP_CROUCH + AP_PRONE; + } + else if (gAnimControl[ pSoldier->usAnimState ].ubEndHeight == ANIM_CROUCH) + { + bAPs += AP_CROUCH; + } + break; + default: + break; } if (usMovementMode == RUNNING && pSoldier->usAnimState != RUNNING ) @@ -1699,7 +1701,7 @@ void DeductAmmo( SOLDIERTYPE *pSoldier, INT8 bInvPos ) { bAttachPos = FindAttachmentByClass( pObj, IC_BOMB ); } - + if (bAttachPos != ITEM_NOT_FOUND) { DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("DeductAmmo: deducting for GL: found attachment, about to decide whether to remove it")); @@ -1754,7 +1756,7 @@ UINT16 GetAPsToPickupItem( SOLDIERTYPE *pSoldier, UINT16 usMapPos ) if ( pSoldier->sGridNo != sActionGridNo ) { sAPCost = PlotPath( pSoldier, sActionGridNo, NO_COPYROUTE, NO_PLOT, TEMPORARY, (UINT16)pSoldier->usUIMovementMode, NOT_STEALTH, FORWARD, pSoldier->bActionPoints ); - + // If point cost is zero, return 0 if ( sAPCost != 0 ) { @@ -1764,7 +1766,7 @@ UINT16 GetAPsToPickupItem( SOLDIERTYPE *pSoldier, UINT16 usMapPos ) } else { - sAPCost += AP_PICKUP_ITEM; + sAPCost += AP_PICKUP_ITEM; } } @@ -1800,14 +1802,14 @@ INT8 GetAPsToReloadGunWithAmmo( OBJECTTYPE * pGun, OBJECTTYPE * pAmmo ) if ( GetMagSize(pGun) == Magazine[Item[pAmmo->usItem].ubClassIndex].ubMagSize ) { // normal situation -// return( AP_RELOAD_GUN ); + // return( AP_RELOAD_GUN ); return GetAPsToReload(pGun) ; } else { // trying to reload with wrong size of magazine return (GetAPsToReload(pGun) * 2); -// return( AP_RELOAD_GUN + AP_RELOAD_GUN ); + // return( AP_RELOAD_GUN + AP_RELOAD_GUN ); } } @@ -1820,12 +1822,12 @@ INT8 GetAPsToAutoReload( SOLDIERTYPE * pSoldier ) CHECKF( pSoldier ); pObj = &(pSoldier->inv[HANDPOS]); -// manual recharge + // manual recharge if (pObj->ubGunShotsLeft && !(pObj->ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) { return Weapon[Item[(pObj)->usItem].ubClassIndex].APsToReloadManually; } -// + // if (Item[pObj->usItem].usItemClass == IC_GUN || Item[pObj->usItem].usItemClass == IC_LAUNCHER) { @@ -1856,7 +1858,7 @@ INT8 GetAPsToAutoReload( SOLDIERTYPE * pSoldier ) bSlot2 = bSlot; } } - + if (bSlot2 == NO_SLOT) { bSlot2 = FindAmmoToReload( pSoldier, SECONDHANDPOS, bExcludeSlot ); @@ -1883,9 +1885,9 @@ INT8 GetAPsToAutoReload( SOLDIERTYPE * pSoldier ) UINT16 GetAPsToReloadRobot( SOLDIERTYPE *pSoldier, SOLDIERTYPE *pRobot ) { UINT16 sAPCost = 0; - INT16 sActionGridNo; - UINT8 ubDirection; - INT16 sAdjustedGridNo; + INT16 sActionGridNo; + UINT8 ubDirection; + INT16 sAdjustedGridNo; sActionGridNo = FindAdjacentGridEx( pSoldier, pRobot->sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE ); @@ -1991,25 +1993,25 @@ UINT16 GetAPsToLook( SOLDIERTYPE *pSoldier ) switch( gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) { // Now change to appropriate animation - case ANIM_STAND: - return( AP_LOOK_STANDING ); - break; + case ANIM_STAND: + return( AP_LOOK_STANDING ); + break; - case ANIM_CROUCH: - return( AP_LOOK_CROUCHED ); - break; + case ANIM_CROUCH: + return( AP_LOOK_CROUCHED ); + break; - case ANIM_PRONE: - // AP_PRONE is the AP cost to go to or from the prone stance. To turn while prone, your merc has to get up to - // crouched, turn, and then go back down. Hence you go up (AP_PRONE), turn (AP_LOOK_PRONE) and down (AP_PRONE). - return( AP_LOOK_PRONE + AP_PRONE + AP_PRONE ); - break; + case ANIM_PRONE: + // AP_PRONE is the AP cost to go to or from the prone stance. To turn while prone, your merc has to get up to + // crouched, turn, and then go back down. Hence you go up (AP_PRONE), turn (AP_LOOK_PRONE) and down (AP_PRONE). + return( AP_LOOK_PRONE + AP_PRONE + AP_PRONE ); + break; // no other values should be possible - default: - Assert( FALSE ); - return(0); - break; + default: + Assert( FALSE ); + return(0); + break; } } @@ -2079,7 +2081,7 @@ INT16 GetAPsToReadyWeapon( SOLDIERTYPE *pSoldier, UINT16 usAnimState ) // ATE: What was I thinking, hooking into animations like this.... //if ( usAnimState == READY_DUAL_STAND || usAnimState == READY_DUAL_CROUCH ) //{ - //return( AP_READY_DUAL ); + //return( AP_READY_DUAL ); //} if ( IsValidSecondHandShot( pSoldier ) ) { diff --git a/Tactical/Soldier Init List.cpp b/Tactical/Soldier Init List.cpp index 4296068c..e1626dea 100644 --- a/Tactical/Soldier Init List.cpp +++ b/Tactical/Soldier Init List.cpp @@ -524,7 +524,7 @@ void SortSoldierInitList() } -BOOLEAN AddPlacementToWorld( SOLDIERINITNODE *curr ) +BOOLEAN AddPlacementToWorld( SOLDIERINITNODE *curr, GROUP *pGroup = NULL ) { UINT8 ubProfile; SOLDIERCREATE_STRUCT tempDetailedPlacement; @@ -723,6 +723,12 @@ BOOLEAN AddPlacementToWorld( SOLDIERINITNODE *curr ) { curr->pSoldier = pSoldier; curr->ubSoldierID = ubID; + if (pGroup) + { + pSoldier->ubGroupID = pGroup->ubGroupID; + pSoldier->pGroup = pGroup; + } + AddSoldierToSectorNoCalculateDirection( ubID ); if( pSoldier->bActive && pSoldier->bInSector && pSoldier->bTeam == ENEMY_TEAM && !pSoldier->inv[ HANDPOS ].usItem ) diff --git a/Tactical/Soldier Tile.cpp b/Tactical/Soldier Tile.cpp index be8b8153..f5977c41 100644 --- a/Tactical/Soldier Tile.cpp +++ b/Tactical/Soldier Tile.cpp @@ -73,7 +73,7 @@ void OutputDebugInfoForTurnBasedNextTileWaiting( SOLDIERTYPE * pSoldier ) if ( (gTacticalStatus.uiFlags & INCOMBAT) && (pSoldier->usPathDataSize > 0) ) { UINT32 uiLoop; - UINT16 usTemp; + UINT16 usTemp = NOWHERE; UINT16 usNewGridNo; usNewGridNo = NewGridNo( pSoldier->sGridNo, DirectionInc( (UINT8)pSoldier->usPathingData[ pSoldier->usPathIndex ] ) ); diff --git a/Tactical/Spread Burst.cpp b/Tactical/Spread Burst.cpp index 841df7e8..5ae7965c 100644 --- a/Tactical/Spread Burst.cpp +++ b/Tactical/Spread Burst.cpp @@ -121,7 +121,7 @@ void AccumulateBurstLocation( INT16 sGridNo ) void PickBurstLocations( SOLDIERTYPE *pSoldier ) { - UINT8 ubShotsPerBurst; + UINT8 ubShotsPerBurst = 0; FLOAT dAccululator = 0; FLOAT dStep = 0; INT32 cnt; diff --git a/Tactical/Tactical_2005Express.vcproj b/Tactical/Tactical_2005Express.vcproj index 7d83bf85..7c42b095 100644 --- a/Tactical/Tactical_2005Express.vcproj +++ b/Tactical/Tactical_2005Express.vcproj @@ -46,8 +46,9 @@ RuntimeLibrary="1" RuntimeTypeInfo="false" UsePrecompiledHeader="0" - WarningLevel="3" + WarningLevel="4" DebugInformationFormat="4" + DisableSpecificWarnings="4100" /> sGridNo, &sXPos, &sYPos ); LightSpritePosition( pBullet->pAniTile->lightSprite, (INT16)(sXPos/CELL_X_SIZE), (INT16)(sYPos/CELL_Y_SIZE)); +#if 0 if ( pBullet->pFirer->bLevel > 0 ) // if firer on roof then { if ( FindBuilding(AniParams.sGridNo) != NULL ) // if this spot is still within the building's grid area @@ -460,6 +461,7 @@ void AddMissileTrail( BULLET *pBullet, FIXEDPT qCurrX, FIXEDPT qCurrY, FIXEDPT q LightSpritePower( pBullet->pAniTile->lightSprite, FALSE); } } +#endif return; } diff --git a/Tactical/opplist.cpp b/Tactical/opplist.cpp index cd4682bc..609ee48e 100644 --- a/Tactical/opplist.cpp +++ b/Tactical/opplist.cpp @@ -5066,7 +5066,7 @@ void ProcessNoise(UINT8 ubNoiseMaker, INT16 sGridNo, INT8 bLevel, UINT8 ubTerrTy INT8 bCheckTerrain = FALSE; UINT8 ubSourceTerrType, ubSource; INT8 bTellPlayer = FALSE, bHeard, bSeen; - UINT8 ubHeardLoudestBy, ubNoiseDir, ubLoudestNoiseDir; + UINT8 ubHeardLoudestBy = NOBODY, ubNoiseDir = 0xff, ubLoudestNoiseDir = 0xff; #ifdef RECORDOPPLIST diff --git a/TacticalAI/AIUtils.cpp b/TacticalAI/AIUtils.cpp index 4c0c0428..a8b8e0f1 100644 --- a/TacticalAI/AIUtils.cpp +++ b/TacticalAI/AIUtils.cpp @@ -869,7 +869,7 @@ INT16 ClosestReachableDisturbance(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK, INT16 *psLastLoc, *pusNoiseGridNo; INT8 *pbLastLevel; INT16 sGridNo=-1; - INT8 bLevel, bClosestLevel; + INT8 bLevel, bClosestLevel = -1; BOOLEAN fClimbingNecessary, fClosestClimbingNecessary = FALSE; INT32 iPathCost; INT16 sClosestDisturbance = NOWHERE; diff --git a/TacticalAI/Attacks.cpp b/TacticalAI/Attacks.cpp index 59d4d2bc..83194b30 100644 --- a/TacticalAI/Attacks.cpp +++ b/TacticalAI/Attacks.cpp @@ -1181,7 +1181,7 @@ void CalcBestStab(SOLDIERTYPE *pSoldier, ATTACKTYPE *pBestStab, BOOLEAN fBladeAt INT32 iAttackValue; INT32 iThreatValue,iHitRate,iBestHitRate,iPercentBetter, iEstDamage; BOOLEAN fSurpriseStab; - UINT8 ubRawAPCost,ubMinAPCost,ubMaxPossibleAimTime,ubAimTime,ubBestAimTime; + UINT8 ubRawAPCost,ubMinAPCost,ubMaxPossibleAimTime,ubAimTime,ubBestAimTime = 0; UINT8 ubChanceToHit,ubChanceToReallyHit,ubBestChanceToHit = 0; SOLDIERTYPE *pOpponent; UINT16 usTrueMovementMode; @@ -1394,7 +1394,7 @@ void CalcTentacleAttack(SOLDIERTYPE *pSoldier, ATTACKTYPE *pBestStab ) INT32 iAttackValue; INT32 iThreatValue,iHitRate,iBestHitRate, iEstDamage; BOOLEAN fSurpriseStab; - UINT8 ubRawAPCost,ubMinAPCost,ubMaxPossibleAimTime,ubAimTime,ubBestAimTime; + UINT8 ubRawAPCost,ubMinAPCost,ubMaxPossibleAimTime,ubAimTime,ubBestAimTime = 0; UINT8 ubChanceToHit,ubChanceToReallyHit,ubBestChanceToHit = 0; SOLDIERTYPE *pOpponent; diff --git a/TacticalAI/CreatureDecideAction.cpp b/TacticalAI/CreatureDecideAction.cpp index ded2618e..4fd9bc93 100644 --- a/TacticalAI/CreatureDecideAction.cpp +++ b/TacticalAI/CreatureDecideAction.cpp @@ -910,7 +910,7 @@ INT8 CreatureDecideActionBlack( SOLDIERTYPE * pSoldier ) INT8 bCanAttack; INT8 bSpitIn, bWeaponIn; UINT32 uiChance; - ATTACKTYPE BestShot, BestStab, BestAttack, CurrStab; + ATTACKTYPE BestShot = {}, BestStab = {}, BestAttack = {}, CurrStab = {}; BOOLEAN fRunAway = FALSE; BOOLEAN fChangeLevel; diff --git a/TacticalAI/DecideAction.cpp b/TacticalAI/DecideAction.cpp index 8ae9cc68..103788dc 100644 --- a/TacticalAI/DecideAction.cpp +++ b/TacticalAI/DecideAction.cpp @@ -1233,13 +1233,17 @@ INT8 DecideActionGreen(SOLDIERTYPE *pSoldier) INT16 sNoiseGridNo = MostImportantNoiseHeard(pSoldier,&iNoiseValue, &fClimb, &fReachable); UINT8 ubNoiseDir; - if (sNoiseGridNo != NOWHERE) - ubNoiseDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sNoiseGridNo),CenterY(sNoiseGridNo)); - - if ( sNoiseGridNo != NOWHERE && pSoldier->bDirection != ubNoiseDir ) - pSoldier->usActionData = ubNoiseDir; - else + if (sNoiseGridNo == NOWHERE || + (ubNoiseDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sNoiseGridNo),CenterY(sNoiseGridNo)) + ) == pSoldier->bDirection ) + + { pSoldier->usActionData = (UINT16)PreRandom(8); + } + else + { + pSoldier->usActionData = ubNoiseDir; + } } } while (pSoldier->usActionData == pSoldier->bDirection); @@ -1997,7 +2001,8 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK) } } - if ( fCivilian && !( pSoldier->ubBodyType == COW || pSoldier->ubBodyType == CRIPPLECIV ) ) + if ( fCivilian && !( pSoldier->ubBodyType == COW || pSoldier->ubBodyType == CRIPPLECIV ) && + gTacticalStatus.bBoxingState == NOT_BOXING) { if ( FindAIUsableObjClass( pSoldier, IC_WEAPON ) == ITEM_NOT_FOUND ) { @@ -3425,9 +3430,9 @@ INT8 DecideActionBlack(SOLDIERTYPE *pSoldier) #endif DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("DecideActionBlack: soldier = %d, orders = %d, attitude = %d",pSoldier->ubID,pSoldier->bOrders,pSoldier->bAttitude)); - ATTACKTYPE BestShot,BestThrow,BestStab,BestAttack; + ATTACKTYPE BestShot = {},BestThrow = {},BestStab = {},BestAttack = {}; BOOLEAN fCivilian = (PTR_CIVILIAN && (pSoldier->ubCivilianGroup == NON_CIV_GROUP || pSoldier->bNeutral || (pSoldier->ubBodyType >= FATCIV && pSoldier->ubBodyType <= CRIPPLECIV) ) ); - UINT8 ubBestStance, ubStanceCost; + UINT8 ubBestStance = 1, ubStanceCost; BOOLEAN fChangeStanceFirst; // before firing BOOLEAN fClimb; UINT8 ubBurstAPs; @@ -4128,6 +4133,8 @@ INT8 DecideActionBlack(SOLDIERTYPE *pSoldier) // if soldier has enough APs left to move at least 1 square's worth, // and either he can't attack any more, or his attack did wound someone + iCoverPercentBetter = 0; + if ( (ubCanMove && !SkipCoverCheck && !gfHiddenInterrupt && ((ubBestAttackAction == AI_ACTION_NONE) || pSoldier->bLastAttackHit) && (pSoldier->bTeam != gbPlayerNum || pSoldier->fAIFlags & AI_RTP_OPTION_CAN_SEEK_COVER) && @@ -5254,6 +5261,12 @@ void DecideAlertStatus( SOLDIERTYPE *pSoldier ) } } } + else if (gTacticalStatus.bBoxingState == DISQUALIFIED || + gTacticalStatus.bBoxingState == WON_ROUND || + gTacticalStatus.bBoxingState == LOST_ROUND) + { + pSoldier->bAlertStatus = STATUS_GREEN; + } } diff --git a/TacticalAI/FindLocations.cpp b/TacticalAI/FindLocations.cpp index b3ecc0cc..4a6a808d 100644 --- a/TacticalAI/FindLocations.cpp +++ b/TacticalAI/FindLocations.cpp @@ -535,7 +535,7 @@ INT16 FindBestNearbyCover(SOLDIERTYPE *pSoldier, INT32 morale, INT32 *piPercentB // all 32-bit integers for max. speed UINT32 uiLoop; INT32 iCurrentCoverValue, iCoverValue, iBestCoverValue; - INT32 iCurrentScale, iCoverScale, iBestCoverScale; + INT32 iCurrentScale = -1, iCoverScale = -1, iBestCoverScale = -1; INT32 iDistFromOrigin, iDistCoverFromOrigin, iThreatCertainty; INT16 sGridNo, sBestCover = NOWHERE; INT32 iPathCost; diff --git a/TacticalAI/Medical.cpp b/TacticalAI/Medical.cpp index 312d08e1..2376e007 100644 --- a/TacticalAI/Medical.cpp +++ b/TacticalAI/Medical.cpp @@ -225,8 +225,8 @@ BOOLEAN CanCharacterBeAutoBandagedByTeammate( SOLDIERTYPE *pSoldier ) INT8 FindBestPatient( SOLDIERTYPE * pSoldier, BOOLEAN * pfDoClimb ) { UINT8 cnt, cnt2; - INT16 bBestPriority = 0, sBestAdjGridNo; - INT16 sPatientGridNo, sBestPatientGridNo; + INT16 bBestPriority = 0, sBestAdjGridNo = NOWHERE; + INT16 sPatientGridNo = NOWHERE, sBestPatientGridNo = NOWHERE; INT16 sShortestPath = 1000, sPathCost, sOtherMedicPathCost; SOLDIERTYPE * pPatient; SOLDIERTYPE * pBestPatient = NULL; diff --git a/TacticalAI/NPC.cpp b/TacticalAI/NPC.cpp index ce7cc3ea..adaa012e 100644 --- a/TacticalAI/NPC.cpp +++ b/TacticalAI/NPC.cpp @@ -2168,7 +2168,7 @@ INT16 NPCConsiderInitiatingConv( SOLDIERTYPE * pNPC, UINT8 * pubDesiredMerc ) UINT8 ubNPC, ubMerc, ubDesiredMerc = NOBODY; UINT8 ubTalkDesire, ubHighestTalkDesire = 0; SOLDIERTYPE * pMerc; - SOLDIERTYPE * pDesiredMerc; + SOLDIERTYPE * pDesiredMerc = NULL; NPCQuoteInfo * pNPCQuoteInfoArray; CHECKF( pubDesiredMerc ); @@ -2215,16 +2215,17 @@ INT16 NPCConsiderInitiatingConv( SOLDIERTYPE * pNPC, UINT8 * pubDesiredMerc ) { ubHighestTalkDesire = ubTalkDesire; ubDesiredMerc = ubMerc; - pDesiredMerc = MercPtrs[ubMerc]; + pDesiredMerc = MercSlots[ubMerc]; sDesiredMercDist = PythSpacesAway( sMyGridNo, pDesiredMerc->sGridNo ); } else if (ubTalkDesire == ubHighestTalkDesire) { - sDist = PythSpacesAway( sMyGridNo, MercPtrs[ubMerc]->sGridNo ); + sDist = PythSpacesAway( sMyGridNo, MercSlots[ubMerc]->sGridNo ); if (sDist < sDesiredMercDist) { // we can say the same thing to this merc, and they're closer! ubDesiredMerc = ubMerc; + pDesiredMerc = MercSlots[ubMerc]; sDesiredMercDist = sDist; } } diff --git a/TacticalAI/TacticalAI_2005Express.vcproj b/TacticalAI/TacticalAI_2005Express.vcproj index 49af79fd..c1932a42 100644 --- a/TacticalAI/TacticalAI_2005Express.vcproj +++ b/TacticalAI/TacticalAI_2005Express.vcproj @@ -46,8 +46,9 @@ RuntimeLibrary="1" RuntimeTypeInfo="false" UsePrecompiledHeader="0" - WarningLevel="3" + WarningLevel="4" DebugInformationFormat="4" + DisableSpecificWarnings="4100" /> Position.x; @@ -2652,7 +2652,7 @@ BOOLEAN LoadPhysicsTableFromSavedGameFile( HWFILE hFile ) UINT16 RandomGridFromRadius( INT16 sSweetGridNo, INT8 ubMinRadius, INT8 ubMaxRadius ) { INT16 sX, sY; - INT16 sGridNo; + INT16 sGridNo = NOWHERE; INT32 leftmost; BOOLEAN fFound = FALSE; UINT32 cnt = 0; diff --git a/TileEngine/renderworld.cpp b/TileEngine/renderworld.cpp index 95d24e5c..e1847a60 100644 --- a/TileEngine/renderworld.cpp +++ b/TileEngine/renderworld.cpp @@ -777,10 +777,10 @@ void RenderTiles(UINT32 uiFlags, INT32 iStartPointX_M, INT32 iStartPointY_M, INT LEVELNODE *pNode; //, *pLand, *pStruct; //*pObject, *pTopmost, *pMerc; SOLDIERTYPE *pSoldier, *pSelSoldier; - HVOBJECT hVObject; + HVOBJECT hVObject = NULL; ETRLEObject *pTrav; TILE_ELEMENT *TileElem=NULL; - UINT32 uiDestPitchBYTES; + UINT32 uiDestPitchBYTES = 0; UINT8 *pDestBuf=NULL; UINT16 usAnimSurface; INT8 bXOddFlag = 0; @@ -1234,7 +1234,7 @@ void RenderTiles(UINT32 uiFlags, INT32 iStartPointX_M, INT32 iStartPointY_M, INT usImageIndex = pNode->pAniTile->sCurrentFrame; uiAniTileFlags = pNode->pAniTile->uiFlags; - // Position corpse based on it's float position + // Position corpse based on its float position if ( ( uiLevelNodeFlags & LEVELNODE_ROTTINGCORPSE ) ) { pCorpse = &( gRottingCorpse[ pNode->pAniTile->uiUserData ] ); diff --git a/TileEngine/structure.cpp b/TileEngine/structure.cpp index a8aae64b..9badb015 100644 --- a/TileEngine/structure.cpp +++ b/TileEngine/structure.cpp @@ -2163,7 +2163,7 @@ BOOLEAN FiniStructureDB( void ) INT8 GetBlockingStructureInfo( INT16 sGridNo, INT8 bDir, INT8 bNextDir, INT8 bLevel, INT8 *pStructHeight, STRUCTURE ** ppTallestStructure, BOOLEAN fWallsBlock ) { - STRUCTURE * pCurrent, *pStructure; + STRUCTURE * pCurrent, *pStructure = NULL; INT16 sDesiredLevel; BOOLEAN fOKStructOnLevel = FALSE; BOOLEAN fMinimumBlockingFound = FALSE; diff --git a/Utils/STIConvert.cpp b/Utils/STIConvert.cpp index 3fa7c529..c15c09a4 100644 --- a/Utils/STIConvert.cpp +++ b/Utils/STIConvert.cpp @@ -115,7 +115,7 @@ void WriteSTIFile( INT8 *pData, SGPPaletteEntry *pPalette, INT16 sWidth, INT16 s SGPPaletteEntry * pSGPPaletteEntry; STCIPaletteElement STCIPaletteEntry; - STCISubImage * pSubImageBuffer; + STCISubImage * pSubImageBuffer = NULL; UINT16 usNumberOfSubImages; UINT32 uiSubImageBufferSize=0; diff --git a/Utils/Utils_2005Express.vcproj b/Utils/Utils_2005Express.vcproj index 3b72eae7..a782266b 100644 --- a/Utils/Utils_2005Express.vcproj +++ b/Utils/Utils_2005Express.vcproj @@ -46,8 +46,9 @@ RuntimeLibrary="1" RuntimeTypeInfo="false" UsePrecompiledHeader="0" - WarningLevel="3" + WarningLevel="4" DebugInformationFormat="4" + DisableSpecificWarnings="4100" /> name; Attributes++ ) diff --git a/lua/lua_2005Express.vcproj b/lua/lua_2005Express.vcproj index 87430afe..e82d7d06 100644 --- a/lua/lua_2005Express.vcproj +++ b/lua/lua_2005Express.vcproj @@ -46,8 +46,9 @@ RuntimeLibrary="1" RuntimeTypeInfo="false" UsePrecompiledHeader="0" - WarningLevel="3" + WarningLevel="4" DebugInformationFormat="4" + DisableSpecificWarnings="4100" /> len; int newlen; STR8 newstr = NULL; @@ -227,7 +226,7 @@ static int LuaWStringToString( lua_State *L ) static int LuaWStringIndex( lua_State *L ) { - TWString *tw = (TWString*) luaL_checkudata( L, 1, "wstring" ); + luaL_checkudata( L, 1, "wstring" ); const CHAR8 *idx = luaL_checkstring( L, 2 ); // Disqualify metafunctions