diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..a1b12b5d7 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,46 @@ +root = true + +[*.{cpp,h}] +indent_style = tabs +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true + +# Charset encoding is an open topic, we would need to convert all files to the ideal encoding the world uses +# Visual Studio requires BOM to properly detect files as being utf if not using .editorconfig, but with .editorconfig we don't need the bom +#charset = utf-8 +#charset = utf-8-bom +# Currently windows-1252 seems to be used for most files, but thats not an officially supported .editorconfig encoding +#charset = windows-1252 + +# cmake +[*.json] +charset = utf-8 +indent_style = spaces +indent_size = 2 +trim_trailing_whitespace = true +insert_final_newline = true + +# github workflow +[*.{yml,yaml}] +charset = utf-8 +indent_style = spaces +indent_size = 2 +trim_trailing_whitespace = true +insert_final_newline = true + +# gamedir xml +[*.xml] +charset = utf-8 +indent_style = tabs +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true + +# gamedir ini +[*.ini] +charset = utf-8 +indent_style = tabs +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 85a063272..a4984532b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -96,20 +96,14 @@ jobs: then # if we build for a specific tag, use that as the game version # examples: - # - v1.3.3 - # - v1.3.2-rc2 + # - v1.13.1 + # - v1.13.2-rc2 GAME_VERSION="$GITHUB_REF_NAME" else - # tag the very first commit as v1.13, fixes git describe if no tags are around - if ! git rev-list v1.13 2>/dev/null - then - git tag v1.13 $(git rev-list --max-parents=0 HEAD) && git push origin v1.13 - fi - - # uses `git describe`, which tries to find a tag in the commit hierarchy + # uses `git describe`, which tries to find a tag in the commit hierarchy. or fall back to a v1.13 version # example five (5) commits after v1.13: # - v1.13-5-7g7ffa - GAME_VERSION="$(git describe --tags --match='v[0-9]*' $GITHUB_SHA)" + GAME_VERSION="$(git describe --tags --match='v[0-9]*' $GITHUB_SHA || echo v0-$(git rev-list --skip 1 --count $GITHUB_SHA)-g${GITHUB_SHA:0:8})" fi # max 15 CHAR8 GAME_VERSION="${GAME_VERSION:0:15}" @@ -201,7 +195,7 @@ jobs: - name: Delete Latest if: startsWith(github.ref, 'refs/tags/v') == false - uses: dev-drprasad/delete-tag-and-release@master + uses: dev-drprasad/delete-tag-and-release@v1.0 with: tag_name: "latest" env: diff --git a/.github/workflows/build_language.yml b/.github/workflows/build_language.yml index 7aa4ebf43..631bf45e5 100644 --- a/.github/workflows/build_language.yml +++ b/.github/workflows/build_language.yml @@ -187,7 +187,8 @@ jobs: set -eux # "-" separates words, "_" combines words, see double-click behavior - DIST_NAME="JA2-${GAME_VERSION}-G${GAMEDIR_COMMIT_SHA:0:4}L${GAMEDIR_LANGUAGES_COMMIT_SHA:0:4}-${{ inputs.language }}" + DIST_PREFIX='JA2_113' + DIST_NAME="${DIST_PREFIX}-${GAME_VERSION}-G${GAMEDIR_COMMIT_SHA:0:4}L${GAMEDIR_LANGUAGES_COMMIT_SHA:0:4}-${{ inputs.language }}" echo "DIST_NAME=$DIST_NAME" >> $GITHUB_ENV echo "If you encounter problems during gameplay, please provide the following version information: @@ -204,8 +205,8 @@ jobs: Gamedir Languages Repository: $GAMEDIR_LANGUAGES_REPOSITORY Gamedir Languages Commit SHA: $GAMEDIR_LANGUAGES_COMMIT_SHA Gamedir Languages Commit Date: $GAMEDIR_LANGUAGES_COMMIT_DATETIME - " > gamedir/ja2_1.13_version.txt - cat gamedir/ja2_1.13_version.txt + " > "gamedir/${DIST_PREFIX}-Version.txt" + cat "gamedir/${DIST_PREFIX}-Version.txt" - name: Create release archive shell: bash diff --git a/.gitignore b/.gitignore index 70a647057..22d2271de 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,11 @@ +# CLion +.idea/ +cmake-build-*/ + +# Visual Studio 2022 +.vs/ build/ lib/ -.vs/ -.idea/ \ No newline at end of file +out/ +CMakeSettings.json +/CMakeUserPresets.json diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..6da5fa52c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,172 @@ +cmake_minimum_required(VERSION 3.20) + +project(ja2) + +include(cmake/CopyUserPresetTemplate.cmake) +CopyUserPresetTemplate() + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +# lua51.lib and lua51.vc9.lib have been built with /MTx, so we must as well +# TODO: build our own Lua 5.1.2 from source so we can use whichever +set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + +add_compile_definitions(CINTERFACE XML_STATIC VFS_STATIC VFS_WITH_SLF VFS_WITH_7ZIP USE_VFS _CRT_SECURE_NO_DEPRECATE) +include_directories(${CMAKE_SOURCE_DIR} "ext/VFS/include" Utils TileEngine TacticalAI ModularizedTacticalAI Tactical Strategic "Standard Gaming Platform" Res Lua Laptop Multiplayer "Multiplayer/raknet" Editor Console) + +# external libraries +add_subdirectory("ext/libpng") +add_subdirectory("ext/zlib") +add_subdirectory("ext/VFS") +target_link_libraries(bfVFS PRIVATE 7z) + +# ja2export utility +add_subdirectory("ext/export/src") + +# static libraries whose source files, header files or header files included +# by header files do not rely on Applications or Languages preprocessor definitions, +# and therefore only need to be compiled once. Good. +add_subdirectory(Lua) + +# static libraries whose source files, header files or header files included +# by header files rely on Application and Language preprocessor definitions, and +# therefore need to be compiled multiple times. Very Bad. +add_subdirectory(TileEngine) +add_subdirectory(TacticalAI) +add_subdirectory(Utils) +add_subdirectory(Strategic) +add_subdirectory("Standard Gaming Platform") +add_subdirectory(Laptop) +add_subdirectory(Editor) +add_subdirectory(Console) +add_subdirectory(Tactical) +add_subdirectory(ModularizedTacticalAI) +# TODO: Rename 'Standard Gaming Platform' directory to 'SGP' so this can be refactored away +set(Ja2_Libs +TileEngine +TacticalAI +Utils +Strategic +SGP +Laptop +Editor +Console +Tactical +ModularizedTacticalAI +) + +# TODO: Move these units into their own directory to declutter the root dir and CMakeLists.txt file +set(Ja2Src +"aniviewscreen.cpp" +"Credits.cpp" +"Fade Screen.cpp" +"FeaturesScreen.cpp" +"GameInitOptionsScreen.cpp" +"gameloop.cpp" +"gamescreen.cpp" +"GameSettings.cpp" +"GameVersion.cpp" +"HelpScreen.cpp" +"Init.cpp" +"Intro.cpp" +"JA2 Splash.cpp" +"Ja25Update.cpp" +"jascreens.cpp" +"Language Defines.cpp" +"Loading Screen.cpp" +"MainMenuScreen.cpp" +"MessageBoxScreen.cpp" +"MPChatScreen.cpp" +"MPConnectScreen.cpp" +"MPHostScreen.cpp" +"MPJoinScreen.cpp" +"MPScoreScreen.cpp" +"MPXmlTeams.cpp" +"Multiplayer/client.cpp" +"Multiplayer/server.cpp" +"Multiplayer/transfer_rules.cpp" +"Options Screen.cpp" +"profiler.cpp" +"SaveLoadGame.cpp" +"SaveLoadScreen.cpp" +"SCREENS.cpp" +"Sys Globals.cpp" +"ub_config.cpp" +"XML_DifficultySettings.cpp" +"XML_IntroFiles.cpp" +"XML_Layout_MainMenu.cpp" +Res/ja2.rc +) + +set(Ja2_Libraries +"${PROJECT_SOURCE_DIR}/libexpatMT.lib" +"Dbghelp.lib" +Lua +"${PROJECT_SOURCE_DIR}/lua51.lib" +"${PROJECT_SOURCE_DIR}/lua51.vc9.lib" +"Winmm.lib" +"${PROJECT_SOURCE_DIR}/SMACKW32.LIB" +"${PROJECT_SOURCE_DIR}/binkw32.lib" +bfVFS +"${PROJECT_SOURCE_DIR}/Multiplayer/raknet/RakNetLibStatic.lib" +"ws2_32.lib" +) + +# simple function to validate Languages and Application choices +include(cmake/ValidateOptions.cmake) + +set(ValidLanguages CHINESE DUTCH ENGLISH FRENCH GERMAN ITALIAN POLISH RUSSIAN) +ValidateOptions("${ValidLanguages}" "Languages" "${Languages}" "LangTargets") + +set(ValidApplications JA2 JA2MAPEDITOR JA2UB JA2UBMAPEDITOR) +ValidateOptions("${ValidApplications}" "Applications" "${Applications}" "ApplicationTargets") + + +# preprocessor definitions for Debug build, per the legacy MSBuild +set(debugFlags $,JA2BETAVERSION;JA2TESTVERSION;DEBUG_ATTACKBUSY,>) + +# Due to widespread preprocessor definition abuse in the codebase, practically +# every library-language-executable combination is its own compilation target +# TODO: refactor preprocessor usage onto, ideally, a single translation unit +foreach(lang IN LISTS LangTargets) + foreach(exe IN LISTS ApplicationTargets) + set(Executable ${exe}_${lang}) + + # executable for an application/language combination, e.g. JA2_ENGLISH.exe + add_executable(${Executable} WIN32) + target_sources(${Executable} PRIVATE ${Ja2Src}) + + # Good libraries have already been built, can be simply linked here + target_link_libraries(${Executable} PRIVATE ${Ja2_Libraries}) + + # for each app/lang combination, the Very Bad libraries need to be built, + # with the appropriate preprocessor definitions + foreach(lib IN LISTS Ja2_Libs) + # syntactic sugar to hopefully make this more readable + set(VeryBadLib ${Executable}_${lib}) + set(isEditor $) + set(isUb $) + set(isUbEditor $) + + # static library for an app/lang combination, e.g. JA2_ENGLISH_SGP.lib + add_library(${VeryBadLib}) + target_sources(${VeryBadLib} PRIVATE ${${lib}Src}) + + target_compile_definitions(${VeryBadLib} PUBLIC + $ + $ + $ + ${debugFlags} + ${lang} + ) + target_link_libraries(${Executable} PUBLIC ${VeryBadLib}) + endforeach() + + # for SGP only + target_link_libraries(${Executable}_SGP PRIVATE "ddraw.lib" "${PROJECT_SOURCE_DIR}/fmodvc.lib") + target_link_libraries(${Executable}_SGP PUBLIC libpng) + target_compile_definitions(${Executable}_SGP PRIVATE NO_ZLIB_COMPRESSION) + endforeach() +endforeach() diff --git a/Console/CMakeLists.txt b/Console/CMakeLists.txt new file mode 100644 index 000000000..7c67cd0aa --- /dev/null +++ b/Console/CMakeLists.txt @@ -0,0 +1,6 @@ +set(ConsoleSrc +"${CMAKE_CURRENT_SOURCE_DIR}/Console.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Cursors.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Dialogs.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/FileStream.cpp" +PARENT_SCOPE) diff --git a/Console/Console.cpp b/Console/Console.cpp index c4d1241c1..e7453938e 100644 --- a/Console/Console.cpp +++ b/Console/Console.cpp @@ -189,18 +189,6 @@ Console::Console(LPCTSTR pszConfigFile, LPCTSTR pszShellCmdLine, LPCTSTR pszCons , m_nTextBgColor(0) { -#if 0 - m_strConfigFile = GetFullFilename(pszConfigFile); - - if (!_tcsicmp(pszReloadNewConfig, _T("yes"))) { - m_dwReloadNewConfigDefault = RELOAD_NEW_CONFIG_YES; - } else if (!_tcsicmp(pszReloadNewConfig, _T("no"))) { - m_dwReloadNewConfigDefault = RELOAD_NEW_CONFIG_NO; - } else { - m_dwReloadNewConfigDefault = RELOAD_NEW_CONFIG_PROMPT; - } - m_dwReloadNewConfig = m_dwReloadNewConfigDefault; -#endif m_mouseCursorOffset.x = 0; m_mouseCursorOffset.y = 0; @@ -210,26 +198,6 @@ Console::Console(LPCTSTR pszConfigFile, LPCTSTR pszShellCmdLine, LPCTSTR pszCons ::ZeroMemory(&m_rectSelection, sizeof(RECT)); -#if 0 - // get Console.exe directory - TCHAR szPathName[MAX_PATH]; - ::ZeroMemory(szPathName, sizeof(szPathName)); - ::GetModuleFileName(ghInstance, szPathName, MAX_PATH); - - tstring strExeDir(szPathName); - - strExeDir = strExeDir.substr(0, strExeDir.rfind(_T("\\"))); - strExeDir += TCHAR('\\'); - - // if no config file is given, get console.xml from the startup directory - if (m_strConfigFile.length() == 0) { - - m_strConfigFile = strExeDir + tstring(_T("console.xml")); - } - - // get readme filename - m_strReadmeFile = strExeDir + tstring(_T("Readme.txt")); -#endif ::ZeroMemory(&m_csbiCursor, sizeof(CONSOLE_SCREEN_BUFFER_INFO)); ::ZeroMemory(&m_csbiConsole, sizeof(CONSOLE_SCREEN_BUFFER_INFO)); @@ -591,16 +559,6 @@ void Console::OnActivateApp(BOOL bActivate, DWORD dwFlags) { DrawCursor(); } -#if 0 - if ((m_dwTransparency == TRANSPARENCY_ALPHA) && (m_byInactiveAlpha > 0)) { - if (bActivate) { - g_pfnSetLayeredWndAttr(m_hWnd, m_crBackground, m_byAlpha, LWA_ALPHA); - } else { - g_pfnSetLayeredWndAttr(m_hWnd, m_crBackground, m_byInactiveAlpha, LWA_ALPHA); - } - - } -#endif } ///////////////////////////////////////////////////////////////////////////// @@ -683,53 +641,6 @@ void Console::OnInputLangChangeRequest(WPARAM wParam, LPARAM lParam) { ///////////////////////////////////////////////////////////////////////////// void Console::OnLButtonDown(UINT uiFlags, POINTS points) { -#if 0 - RECT windowRect; - ::GetCursorPos(&m_mouseCursorOffset); - ::GetWindowRect(m_hWnd, &windowRect); - m_mouseCursorOffset.x -= windowRect.left; - m_mouseCursorOffset.y -= windowRect.top; - - if (!m_bMouseDragable || - (m_bInverseShift == !(uiFlags & MK_SHIFT))) { - - if (m_nCharWidth) { - - if (m_nTextSelection == TEXT_SELECTION_SELECTED) return; - - // fixed-width characters - // start copy text selection - ::SetCapture(m_hWnd); - - if (!m_nTextSelection) { - RECT rect; - rect.left = 0; - rect.top = 0; - rect.right = m_nClientWidth; - rect.bottom = m_nClientHeight; - ::FillRect(m_hdcSelection, &rect, m_hbrushSelection); - } - - m_nTextSelection = TEXT_SELECTION_SELECTING; - - m_coordSelOrigin.X = min(max(points.x - m_nInsideBorder, 0) / m_nCharWidth, m_dwColumns-1); - m_coordSelOrigin.Y = min(max(points.y - m_nInsideBorder, 0) / m_nCharHeight, m_dwRows-1); - - m_rectSelection.left = m_rectSelection.right = m_coordSelOrigin.X * m_nCharWidth + m_nInsideBorder; - m_rectSelection.top = m_rectSelection.bottom = m_coordSelOrigin.Y * m_nCharHeight + m_nInsideBorder; - - TRACE(_T("Starting point: %ix%i\n"), m_coordSelOrigin.X, m_coordSelOrigin.Y); - } - - } else { - if (m_nTextSelection) { - return; - } else if (m_bMouseDragable) { - // start to drag window - ::SetCapture(m_hWnd); - } - } -#endif } ///////////////////////////////////////////////////////////////////////////// @@ -825,88 +736,6 @@ void Console::OnMButtonDown(UINT uiFlags, POINTS points) { void Console::OnMouseMove(UINT uiFlags, POINTS points) { -#if 0 - RECT windowRect; - int deltaX, deltaY; - POINT point; - - if (uiFlags & MK_LBUTTON) { - - ::GetWindowRect(m_hWnd, &windowRect); - - point.x = points.x; - point.y = points.y; - - ::ClientToScreen(m_hWnd, &point); - - deltaX = point.x - windowRect.left - m_mouseCursorOffset.x; - deltaY = point.y - windowRect.top - m_mouseCursorOffset.y; - - if (deltaX | deltaY) { - -// TRACE(_T("m_nTextSelection: %i, Delta X: %i Delta Y: %i\n"), m_nTextSelection, deltaX, deltaY); - - if (m_nTextSelection) { - if ((!m_bMouseDragable) || (m_bInverseShift == !(uiFlags & MK_SHIFT))) { - - // some text has been selected, just return - if (m_nTextSelection == TEXT_SELECTION_SELECTED) return; - - // selecting text for copy/paste - COORD coordSel; - - ::InvalidateRect(m_hWnd, &m_rectSelection, FALSE); - - coordSel.X = min(max(points.x - m_nInsideBorder, 0) / m_nCharWidth, m_dwColumns-1); - coordSel.Y = min(max(points.y - m_nInsideBorder, 0) / m_nCharHeight, m_dwRows-1); - -// TRACE(_T("End point: %ix%i\n"), coordSel.X, coordSel.Y); - - if (coordSel.X >= m_coordSelOrigin.X) { - m_rectSelection.left = m_coordSelOrigin.X * m_nCharWidth + m_nInsideBorder; - m_rectSelection.right = (coordSel.X + 1) * m_nCharWidth + m_nInsideBorder; - } else { - m_rectSelection.left = coordSel.X * m_nCharWidth + m_nInsideBorder; - m_rectSelection.right = (m_coordSelOrigin.X + 1) * m_nCharWidth + m_nInsideBorder; - } - - if (coordSel.Y >= m_coordSelOrigin.Y) { - m_rectSelection.top = m_coordSelOrigin.Y * m_nCharHeight + m_nInsideBorder; - m_rectSelection.bottom = (coordSel.Y + 1) * m_nCharHeight + m_nInsideBorder; - } else { - m_rectSelection.top = coordSel.Y * m_nCharHeight + m_nInsideBorder; - m_rectSelection.bottom = (m_coordSelOrigin.Y + 1) * m_nCharHeight + m_nInsideBorder; - } - -// TRACE(_T("Selection rect: %i,%i x %i,%i\n"), m_rectSelection.left, m_rectSelection.top, m_rectSelection.right, m_rectSelection.bottom); - - ::InvalidateRect(m_hWnd, &m_rectSelection, FALSE); - } - - } else if (m_bMouseDragable) { - - // moving the window - HWND hwndZ; - 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; - } - - ::SetWindowPos( - m_hWnd, - hwndZ, - windowRect.left + deltaX, - windowRect.top + deltaY, - 0, - 0, - SWP_NOSIZE); - - ::PostMessage(m_hWnd, WM_PAINT, 0, 0); - } - } - } -#endif } ///////////////////////////////////////////////////////////////////////////// @@ -1101,17 +930,6 @@ void Console::OnTrayNotify(WPARAM wParam, LPARAM lParam) { ///////////////////////////////////////////////////////////////////////////// -#if 0 -void Console::OnWallpaperChanged(const TCHAR* pszFilename) { - - if (m_dwTransparency == TRANSPARENCY_FAKE) { - SetWindowTransparency(); - CreateBackgroundBitmap(); - RepaintWindow(); - } - -} -#endif ///////////////////////////////////////////////////////////////////////////// @@ -1120,746 +938,6 @@ void Console::OnWallpaperChanged(const TCHAR* pszFilename) { BOOL Console::GetOptions() { -#if 0 - class XmlException { - public: XmlException(BOOL bRet) : m_bRet(bRet){}; - BOOL m_bRet; - }; - - BOOL bRet = FALSE; - - IStream* pFileStream = NULL; - IXMLDocument* pConfigDoc = NULL; - IPersistStreamInit* pPersistStream = NULL; - IXMLElement* pRootElement = NULL; - IXMLElementCollection* pColl = NULL; - IXMLElement* pFontElement = NULL; - IXMLElement* pPositionElement = NULL; - IXMLElement* pAppearanceElement = NULL; - IXMLElement* pScrollbarElement = NULL; - IXMLElement* pBackgroundElement = NULL; - IXMLElement* pCursorElement = NULL; - IXMLElement* pBehaviorElement = NULL; - - try { - ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); - - USES_CONVERSION; - - // open file stream - if (!SUCCEEDED(CreateFileStream( - m_strConfigFile.c_str(), - GENERIC_READ, - 0, - NULL, - OPEN_EXISTING, - 0, - NULL, - &pFileStream))) { - - throw XmlException(FALSE); - } - - // create XML document instance - if (!SUCCEEDED(::CoCreateInstance( - CLSID_XMLDocument, - NULL, - CLSCTX_INPROC_SERVER, - IID_IXMLDocument, - (void**)&pConfigDoc))) { - - throw XmlException(FALSE); - } - - // load the configuration file - pConfigDoc->QueryInterface(IID_IPersistStreamInit, (void **)&pPersistStream); - - if (!SUCCEEDED(pPersistStream->Load(pFileStream))) throw XmlException(FALSE); - - // see if we're dealing with the skin - if (!SUCCEEDED(pConfigDoc->get_root(&pRootElement))) throw XmlException(FALSE); - - CComVariantOut varAttValue; - CComBSTROut bstr; - CComBSTROut strText; - tstring strTempText(_T("")); - - // root element must be CONSOLE - pRootElement->get_tagName(bstr.Out()); - bstr.ToUpper(); - - if (!(bstr == CComBSTR(_T("CONSOLE")))) throw XmlException(FALSE); - - pRootElement->getAttribute(CComBSTR(_T("title")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) { - m_strWindowTitle = OLE2T(varAttValue.bstrVal); - m_strWindowTitleCurrent = m_strWindowTitle; - } - - pRootElement->getAttribute(CComBSTR(_T("refresh")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) m_dwMasterRepaintInt = _ttol(OLE2T(varAttValue.bstrVal)); - - pRootElement->getAttribute(CComBSTR(_T("change_refresh")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) m_dwChangeRepaintInt = _ttol(OLE2T(varAttValue.bstrVal)); - if ((int)m_dwChangeRepaintInt < 5) m_dwChangeRepaintInt = 5; - - pRootElement->getAttribute(CComBSTR(_T("shell")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) m_strShell = OLE2T(varAttValue.bstrVal); - - pRootElement->getAttribute(CComBSTR(_T("editor")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) m_strConfigEditor = OLE2T(varAttValue.bstrVal); - - pRootElement->getAttribute(CComBSTR(_T("editor_params")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) m_strConfigEditorParams = OLE2T(varAttValue.bstrVal); - - pRootElement->get_children(&pColl); - if (!pColl) throw XmlException(TRUE); - - // get font settings - IXMLElementCollection* pFontColl = NULL; - if (!SUCCEEDED(pColl->item(CComVariant(_T("font")), CComVariant(0), (IDispatch**)&pFontElement))) throw XmlException(FALSE); - if (pFontElement) { - if (!SUCCEEDED(pFontElement->get_children(&pFontColl))) throw XmlException(FALSE); - - if (pFontColl) { - IXMLElement* pFontSubelement = NULL; - - if (!SUCCEEDED(pFontColl->item(CComVariant(_T("size")), CComVariant(0), (IDispatch**)&pFontSubelement))) throw XmlException(FALSE); - if (pFontSubelement) { - pFontSubelement->get_text(strText.Out()); - if (strText.Length() > 0) m_dwFontSize = _ttoi(OLE2T(strText)); - } - SAFERELEASE(pFontSubelement); - - if (!SUCCEEDED(pFontColl->item(CComVariant(_T("italic")), CComVariant(0), (IDispatch**)&pFontSubelement))) throw XmlException(FALSE); - if (pFontSubelement) { - pFontSubelement->get_text(strText.Out()); - m_bItalic = !_tcsicmp(OLE2T(strText), _T("true")); - } - SAFERELEASE(pFontSubelement); - - if (!SUCCEEDED(pFontColl->item(CComVariant(_T("bold")), CComVariant(0), (IDispatch**)&pFontSubelement))) throw XmlException(FALSE); - if (pFontSubelement) { - pFontSubelement->get_text(strText.Out()); - m_bBold = !_tcsicmp(OLE2T(strText), _T("true")); - } - SAFERELEASE(pFontSubelement); - - if (!SUCCEEDED(pFontColl->item(CComVariant(_T("name")), CComVariant(0), (IDispatch**)&pFontSubelement))) throw XmlException(FALSE); - if (pFontSubelement) { - pFontSubelement->get_text(strText.Out()); - if (strText.Length() > 0) m_strFontName = OLE2T(strText); - } - SAFERELEASE(pFontSubelement); - - if (!SUCCEEDED(pFontColl->item(CComVariant(_T("color")), CComVariant(0), (IDispatch**)&pFontSubelement))) throw XmlException(FALSE); - if (pFontSubelement) { - BYTE r = 0; - BYTE g = 0; - BYTE b = 0; - - varAttValue.Clear(); - pFontSubelement->getAttribute(CComBSTR(_T("r")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) r = _ttoi(OLE2T(varAttValue.bstrVal)); - varAttValue.Clear(); - pFontSubelement->getAttribute(CComBSTR(_T("g")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) g = _ttoi(OLE2T(varAttValue.bstrVal)); - varAttValue.Clear(); - pFontSubelement->getAttribute(CComBSTR(_T("b")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) b = _ttoi(OLE2T(varAttValue.bstrVal)); - - m_bUseFontColor = TRUE; - m_crFontColor = RGB(r, g, b); - } - SAFERELEASE(pFontSubelement); - - // get font color mapping - if (!SUCCEEDED(pFontColl->item(CComVariant(_T("colors")), CComVariant(0), (IDispatch**)&pFontSubelement))) throw XmlException(FALSE); - if (pFontSubelement) { - - IXMLElementCollection* pColorsColl = NULL; - - if (!SUCCEEDED(pFontSubelement->get_children(&pColorsColl))) throw XmlException(FALSE); - - if (pColorsColl) { - - for (int i = 0; i < 16; ++i) { - IXMLElement* pColorSubelement = NULL; - TCHAR szColorName[32]; - - _sntprintf(szColorName, sizeof(szColorName)/sizeof(TCHAR), _T("color_%02i"), i); - - if (!SUCCEEDED(pColorsColl->item(CComVariant(szColorName), CComVariant(0), (IDispatch**)&pColorSubelement))) throw XmlException(FALSE); - if (pColorSubelement) { - - BYTE r = 0; - BYTE g = 0; - BYTE b = 0; - - varAttValue.Clear(); - pColorSubelement->getAttribute(CComBSTR(_T("r")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) r = _ttoi(OLE2T(varAttValue.bstrVal)); - varAttValue.Clear(); - pColorSubelement->getAttribute(CComBSTR(_T("g")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) g = _ttoi(OLE2T(varAttValue.bstrVal)); - varAttValue.Clear(); - pColorSubelement->getAttribute(CComBSTR(_T("b")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) b = _ttoi(OLE2T(varAttValue.bstrVal)); - - Console::m_arrConsoleColors[i] = RGB(r, g, b); - } - - SAFERELEASE(pColorSubelement); - } - } - SAFERELEASE(pColorsColl); - } - SAFERELEASE(pFontSubelement); - } - SAFERELEASE(pFontColl); - } - - // get position settings - IXMLElementCollection* pPositionColl = NULL; - if (!SUCCEEDED(pColl->item(CComVariant(_T("position")), CComVariant(0), (IDispatch**)&pPositionElement))) throw XmlException(FALSE); - if (pPositionElement) { - if (!SUCCEEDED(pPositionElement->get_children(&pPositionColl))) throw XmlException(FALSE); - - if (pPositionColl) { - IXMLElement* pPositionSubelement = NULL; - - if (!m_bReloading) { - if (!SUCCEEDED(pPositionColl->item(CComVariant(_T("x")), CComVariant(0), (IDispatch**)&pPositionSubelement))) throw XmlException(FALSE); - if (pPositionSubelement) { - pPositionSubelement->get_text(strText.Out()); - if (strText.Length() > 0) m_nX = _ttoi(OLE2T(strText)); - } - SAFERELEASE(pPositionSubelement); - - if (!SUCCEEDED(pPositionColl->item(CComVariant(_T("y")), CComVariant(0), (IDispatch**)&pPositionSubelement))) throw XmlException(FALSE); - if (pPositionSubelement) { - pPositionSubelement->get_text(strText.Out()); - if (strText.Length() > 0) m_nY = _ttoi(OLE2T(strText)); - } - SAFERELEASE(pPositionSubelement); - } - - if (!SUCCEEDED(pPositionColl->item(CComVariant(_T("docked")), CComVariant(0), (IDispatch**)&pPositionSubelement))) throw XmlException(FALSE); - if (pPositionSubelement) { - pPositionSubelement->get_text(strText.Out()); - strTempText = OLE2T(strText); - - if (!_tcsicmp(strTempText.c_str(), _T("top left"))) { - m_dwDocked = DOCK_TOP_LEFT; - } else if (!_tcsicmp(strTempText.c_str(), _T("top right"))) { - m_dwDocked = DOCK_TOP_RIGHT; - } else if (!_tcsicmp(strTempText.c_str(), _T("bottom right"))) { - m_dwDocked = DOCK_BOTTOM_RIGHT; - } else if (!_tcsicmp(strTempText.c_str(), _T("bottom left"))) { - m_dwDocked = DOCK_BOTTOM_LEFT; - } else { - m_dwDocked = DOCK_NONE; - } - } - SAFERELEASE(pPositionSubelement); - - if (!SUCCEEDED(pPositionColl->item(CComVariant(_T("snap_distance")), CComVariant(0), (IDispatch**)&pPositionSubelement))) throw XmlException(FALSE); - if (pPositionSubelement) { - pPositionSubelement->get_text(strText.Out()); - if (strText.Length() > 0) m_nSnapDst = _ttoi(OLE2T(strText)); - } - SAFERELEASE(pPositionSubelement); - - if (!SUCCEEDED(pPositionColl->item(CComVariant(_T("z_order")), CComVariant(0), (IDispatch**)&pPositionSubelement))) throw XmlException(FALSE); - if (pPositionSubelement) { - pPositionSubelement->get_text(strText.Out()); - strTempText = OLE2T(strText); - - if (!_tcsicmp(strTempText.c_str(), _T("regular"))) { - m_dwCurrentZOrder = Z_ORDER_REGULAR; - m_dwOriginalZOrder = Z_ORDER_REGULAR; - } else if (!_tcsicmp(strTempText.c_str(), _T("on top"))) { - m_dwCurrentZOrder = Z_ORDER_ONTOP; - m_dwOriginalZOrder = Z_ORDER_ONTOP; - } else if (!_tcsicmp(strTempText.c_str(), _T("on bottom"))) { - m_dwCurrentZOrder = Z_ORDER_ONBOTTOM; - m_dwOriginalZOrder = Z_ORDER_ONBOTTOM; - } else { - m_dwCurrentZOrder = Z_ORDER_REGULAR; - m_dwOriginalZOrder = Z_ORDER_REGULAR; - } - } - SAFERELEASE(pPositionSubelement); - } - - SAFERELEASE(pPositionColl); - } - - // get appearance settings - IXMLElementCollection* pAppearanceColl = NULL; - if (!SUCCEEDED(pColl->item(CComVariant(_T("appearance")), CComVariant(0), (IDispatch**)&pAppearanceElement))) throw XmlException(FALSE); - if (pAppearanceElement) { - if (!SUCCEEDED(pAppearanceElement->get_children(&pAppearanceColl))) throw XmlException(FALSE); - - if (pAppearanceColl) { - IXMLElement* pAppearanaceSubelement = NULL; - - if (!SUCCEEDED(pAppearanceColl->item(CComVariant(_T("hide_console")), CComVariant(0), (IDispatch**)&pAppearanaceSubelement))) throw XmlException(FALSE); - if (pAppearanaceSubelement) { - pAppearanaceSubelement->get_text(strText.Out()); - if (!_tcsicmp(OLE2T(strText), _T("true"))) { - m_bHideConsole = TRUE; - } else { - m_bHideConsole = FALSE; - } - } - SAFERELEASE(pAppearanaceSubelement); - - if (!SUCCEEDED(pAppearanceColl->item(CComVariant(_T("hide_console_timeout")), CComVariant(0), (IDispatch**)&pAppearanaceSubelement))) throw XmlException(FALSE); - if (pAppearanaceSubelement) { - pAppearanaceSubelement->get_text(strText.Out()); - if (strText.Length() > 0) m_dwHideConsoleTimeout = _ttoi(OLE2T(strText)); - } - SAFERELEASE(pAppearanaceSubelement); - - if (!SUCCEEDED(pAppearanceColl->item(CComVariant(_T("start_minimized")), CComVariant(0), (IDispatch**)&pAppearanaceSubelement))) throw XmlException(FALSE); - if (pAppearanaceSubelement) { - pAppearanaceSubelement->get_text(strText.Out()); - if (!_tcsicmp(OLE2T(strText), _T("true"))) { - m_bStartMinimized = TRUE; - } else { - m_bStartMinimized = FALSE; - } - } - SAFERELEASE(pAppearanaceSubelement); - - IXMLElementCollection* pScrollbarColl = NULL; - if (!SUCCEEDED(pAppearanceColl->item(CComVariant(_T("scrollbar")), CComVariant(0), (IDispatch**)&pScrollbarElement))) throw XmlException(FALSE); - if (pScrollbarElement) { - if (!SUCCEEDED(pScrollbarElement->get_children(&pScrollbarColl))) throw XmlException(FALSE); - - if (pScrollbarColl) { - IXMLElement* pScrollbarSubelement = NULL; - - if (!SUCCEEDED(pScrollbarColl->item(CComVariant(_T("color")), CComVariant(0), (IDispatch**)&pScrollbarSubelement))) throw XmlException(FALSE); - if (pScrollbarSubelement) { - BYTE r = 0; - BYTE g = 0; - BYTE b = 0; - - pScrollbarSubelement->getAttribute(CComBSTR(_T("r")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) r = _ttoi(OLE2T(varAttValue.bstrVal)); - pScrollbarSubelement->getAttribute(CComBSTR(_T("g")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) g = _ttoi(OLE2T(varAttValue.bstrVal)); - pScrollbarSubelement->getAttribute(CComBSTR(_T("b")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) b = _ttoi(OLE2T(varAttValue.bstrVal)); - - m_crScrollbarColor = RGB(r, g, b); - } - SAFERELEASE(pScrollbarSubelement); - - if (!SUCCEEDED(pScrollbarColl->item(CComVariant(_T("style")), CComVariant(0), (IDispatch**)&pScrollbarSubelement))) throw XmlException(FALSE); - if (pScrollbarSubelement) { - pScrollbarSubelement->get_text(strText.Out()); - strTempText = OLE2T(strText); - - if (!_tcsicmp(strTempText.c_str(), _T("regular"))) { - m_nScrollbarStyle = FSB_REGULAR_MODE; - } else if (!_tcsicmp(strTempText.c_str(), _T("flat"))) { - m_nScrollbarStyle = FSB_FLAT_MODE; - } else if (!_tcsicmp(strTempText.c_str(), _T("encarta"))) { - m_nScrollbarStyle = FSB_ENCARTA_MODE; - } - } - SAFERELEASE(pScrollbarSubelement); - - - if (!SUCCEEDED(pScrollbarColl->item(CComVariant(_T("width")), CComVariant(0), (IDispatch**)&pScrollbarSubelement))) throw XmlException(FALSE); - if (pScrollbarSubelement) { - pScrollbarSubelement->get_text(strText.Out()); - if (strText.Length() > 0) m_nScrollbarWidth = _ttoi(OLE2T(strText)); - } - SAFERELEASE(pScrollbarSubelement); - - if (!SUCCEEDED(pScrollbarColl->item(CComVariant(_T("button_height")), CComVariant(0), (IDispatch**)&pScrollbarSubelement))) throw XmlException(FALSE); - if (pScrollbarSubelement) { - pScrollbarSubelement->get_text(strText.Out()); - if (strText.Length() > 0) m_nScrollbarButtonHeight = _ttoi(OLE2T(strText)); - } - SAFERELEASE(pScrollbarSubelement); - - if (!SUCCEEDED(pScrollbarColl->item(CComVariant(_T("thumb_height")), CComVariant(0), (IDispatch**)&pScrollbarSubelement))) throw XmlException(FALSE); - if (pScrollbarSubelement) { - pScrollbarSubelement->get_text(strText.Out()); - if (strText.Length() > 0) m_nScrollbarThunmbHeight = _ttoi(OLE2T(strText)); - } - SAFERELEASE(pScrollbarSubelement); - } - SAFERELEASE(pScrollbarColl); - } - - if (!SUCCEEDED(pAppearanceColl->item(CComVariant(_T("border")), CComVariant(0), (IDispatch**)&pAppearanaceSubelement))) throw XmlException(FALSE); - if (pAppearanaceSubelement) { - pAppearanaceSubelement->get_text(strText.Out()); - if (!_tcsicmp(OLE2T(strText), _T("true")) || !_tcsicmp(OLE2T(strText), _T("regular"))) { - m_dwWindowBorder = BORDER_REGULAR; - } else if (!_tcsicmp(OLE2T(strText), _T("thin"))) { - m_dwWindowBorder = BORDER_THIN; - } else { - m_dwWindowBorder = BORDER_NONE; - } - } - SAFERELEASE(pAppearanaceSubelement); - - if (!SUCCEEDED(pAppearanceColl->item(CComVariant(_T("inside_border")), CComVariant(0), (IDispatch**)&pAppearanaceSubelement))) throw XmlException(FALSE); - if (pAppearanaceSubelement) { - pAppearanaceSubelement->get_text(strText.Out()); - if (strText.Length() > 0) m_nInsideBorder = _ttoi(OLE2T(strText)); - } - SAFERELEASE(pAppearanaceSubelement); - - if (!SUCCEEDED(pAppearanceColl->item(CComVariant(_T("taskbar_button")), CComVariant(0), (IDispatch**)&pAppearanaceSubelement))) throw XmlException(FALSE); - if (pAppearanaceSubelement) { - pAppearanaceSubelement->get_text(strText.Out()); - if (!_tcsicmp(OLE2T(strText), _T("hide"))) { - m_dwTaskbarButton = TASKBAR_BUTTON_HIDE; - } else if (!_tcsicmp(OLE2T(strText), _T("tray"))) { - m_dwTaskbarButton = TASKBAR_BUTTON_TRAY; - } else { - m_dwTaskbarButton = TASKBAR_BUTTON_NORMAL; - } - } - SAFERELEASE(pAppearanaceSubelement); - - if (!SUCCEEDED(pAppearanceColl->item(CComVariant(_T("size")), CComVariant(0), (IDispatch**)&pAppearanaceSubelement))) throw XmlException(FALSE); - if (pAppearanaceSubelement) { - - pAppearanaceSubelement->getAttribute(CComBSTR(_T("rows")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) { - if (_tcsicmp(OLE2T(varAttValue.bstrVal), _T("max")) == 0) { - m_dwRows = 0; - } else { - m_dwRows = _ttoi(OLE2T(varAttValue.bstrVal)); - } - } - - pAppearanaceSubelement->getAttribute(CComBSTR(_T("columns")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) { - if (_tcsicmp(OLE2T(varAttValue.bstrVal), _T("max")) == 0) { - m_dwColumns = 0; - } else { - m_dwColumns = _ttoi(OLE2T(varAttValue.bstrVal)); - } - } - - pAppearanaceSubelement->getAttribute(CComBSTR(_T("buffer_rows")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) { - m_dwBufferRows = _ttoi(OLE2T(varAttValue.bstrVal)); - m_bUseTextBuffer = TRUE; - } else { - m_dwBufferRows = m_dwRows; - } - } - SAFERELEASE(pAppearanaceSubelement); - - if (!SUCCEEDED(pAppearanceColl->item(CComVariant(_T("transparency")), CComVariant(0), (IDispatch**)&pAppearanaceSubelement))) throw XmlException(FALSE); - if (pAppearanaceSubelement) { - pAppearanaceSubelement->getAttribute(CComBSTR(_T("alpha")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) m_byAlpha = (BYTE)_ttoi(OLE2T(varAttValue.bstrVal)); - pAppearanaceSubelement->getAttribute(CComBSTR(_T("inactive_alpha")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) m_byInactiveAlpha = (BYTE)_ttoi(OLE2T(varAttValue.bstrVal)); - - pAppearanaceSubelement->get_text(strText.Out()); - strTempText = OLE2T(strText); - - if (!_tcsicmp(strTempText.c_str(), _T("none"))) { - m_dwTransparency = TRANSPARENCY_NONE; - } else if (!_tcsicmp(strTempText.c_str(), _T("alpha"))) { - m_dwTransparency = TRANSPARENCY_ALPHA; - } else if (!_tcsicmp(strTempText.c_str(), _T("color key"))) { - m_dwTransparency = TRANSPARENCY_COLORKEY; - } else if (!_tcsicmp(strTempText.c_str(), _T("fake"))) { - m_dwTransparency = TRANSPARENCY_FAKE; - } - - } - SAFERELEASE(pAppearanaceSubelement); - - // get background settings - IXMLElementCollection* pBackgroundColl = NULL; - if (!SUCCEEDED(pAppearanceColl->item(CComVariant(_T("background")), CComVariant(0), (IDispatch**)&pBackgroundElement))) throw XmlException(FALSE); - if (pBackgroundElement) { - if (!SUCCEEDED(pBackgroundElement->get_children(&pBackgroundColl))) throw XmlException(FALSE); - - if (pBackgroundColl) { - IXMLElement* pBackgroundSubelement = NULL; - - if (!SUCCEEDED(pBackgroundColl->item(CComVariant(_T("color")), CComVariant(0), (IDispatch**)&pBackgroundSubelement))) throw XmlException(FALSE); - if (pBackgroundSubelement) { - BYTE r = 0; - BYTE g = 0; - BYTE b = 0; - - pBackgroundSubelement->getAttribute(CComBSTR(_T("r")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) r = _ttoi(OLE2T(varAttValue.bstrVal)); - pBackgroundSubelement->getAttribute(CComBSTR(_T("g")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) g = _ttoi(OLE2T(varAttValue.bstrVal)); - pBackgroundSubelement->getAttribute(CComBSTR(_T("b")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) b = _ttoi(OLE2T(varAttValue.bstrVal)); - - m_crBackground = RGB(r, g, b); - } - SAFERELEASE(pBackgroundSubelement); - - if (!SUCCEEDED(pBackgroundColl->item(CComVariant(_T("console_color")), CComVariant(0), (IDispatch**)&pBackgroundSubelement))) throw XmlException(FALSE); - if (pBackgroundSubelement) { - BYTE r = 0; - BYTE g = 0; - BYTE b = 0; - - pBackgroundSubelement->getAttribute(CComBSTR(_T("r")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) r = _ttoi(OLE2T(varAttValue.bstrVal)); - pBackgroundSubelement->getAttribute(CComBSTR(_T("g")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) g = _ttoi(OLE2T(varAttValue.bstrVal)); - pBackgroundSubelement->getAttribute(CComBSTR(_T("b")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) b = _ttoi(OLE2T(varAttValue.bstrVal)); - - m_crConsoleBackground = RGB(r, g, b); - } - SAFERELEASE(pBackgroundSubelement); - - if (!SUCCEEDED(pBackgroundColl->item(CComVariant(_T("tint")), CComVariant(0), (IDispatch**)&pBackgroundSubelement))) throw XmlException(FALSE); - if (pBackgroundSubelement) { - BYTE r = 0; - BYTE g = 0; - BYTE b = 0; - - pBackgroundSubelement->getAttribute(CComBSTR(_T("r")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) m_byTintR = _ttoi(OLE2T(varAttValue.bstrVal)); - pBackgroundSubelement->getAttribute(CComBSTR(_T("g")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) m_byTintG = _ttoi(OLE2T(varAttValue.bstrVal)); - pBackgroundSubelement->getAttribute(CComBSTR(_T("b")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) m_byTintB = _ttoi(OLE2T(varAttValue.bstrVal)); - pBackgroundSubelement->getAttribute(CComBSTR(_T("opacity")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) m_byTintOpacity = _ttoi(OLE2T(varAttValue.bstrVal)); - - if (m_byTintOpacity > 100) m_byTintOpacity = 50; - m_bTintSet = TRUE; - } - SAFERELEASE(pBackgroundSubelement); - - if (!SUCCEEDED(pBackgroundColl->item(CComVariant(_T("image")), CComVariant(0), (IDispatch**)&pBackgroundSubelement))) throw XmlException(FALSE); - if (pBackgroundSubelement) { - - pBackgroundSubelement->getAttribute(CComBSTR(_T("style")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) { - if (!_tcsicmp(OLE2T(varAttValue.bstrVal), _T("resize"))) { - m_dwBackgroundStyle = BACKGROUND_STYLE_RESIZE; - } else if (!_tcsicmp(OLE2T(varAttValue.bstrVal), _T("center"))) { - m_dwBackgroundStyle = BACKGROUND_STYLE_CENTER; - } else if (!_tcsicmp(OLE2T(varAttValue.bstrVal), _T("tile"))) { - m_dwBackgroundStyle = BACKGROUND_STYLE_TILE; - } - } - - pBackgroundSubelement->getAttribute(CComBSTR(_T("relative")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) { - if (!_tcsicmp(OLE2T(varAttValue.bstrVal), _T("true"))) { - m_bRelativeBackground = TRUE; - } else { - m_bRelativeBackground = FALSE; - } - } - - pBackgroundSubelement->getAttribute(CComBSTR(_T("extend")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) { - if (!_tcsicmp(OLE2T(varAttValue.bstrVal), _T("true"))) { - m_bExtendBackground = TRUE; - } else { - m_bExtendBackground = FALSE; - } - } - - pBackgroundSubelement->get_text(strText.Out()); - m_strBackgroundFile = OLE2T(strText); - m_bBitmapBackground = TRUE; - } - SAFERELEASE(pBackgroundSubelement); - } - SAFERELEASE(pBackgroundColl); - } - - IXMLElementCollection* pCursorColl = NULL; - if (!SUCCEEDED(pAppearanceColl->item(CComVariant(_T("cursor")), CComVariant(0), (IDispatch**)&pCursorElement))) throw XmlException(FALSE); - if (pCursorElement) { - if (!SUCCEEDED(pCursorElement->get_children(&pCursorColl))) throw XmlException(FALSE); - - if (pCursorColl) { - IXMLElement* pCursorSubelement = NULL; - - if (!SUCCEEDED(pCursorColl->item(CComVariant(_T("color")), CComVariant(0), (IDispatch**)&pCursorSubelement))) throw XmlException(FALSE); - if (pCursorSubelement) { - BYTE r = 0; - BYTE g = 0; - BYTE b = 0; - - pCursorSubelement->getAttribute(CComBSTR(_T("r")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) r = _ttoi(OLE2T(varAttValue.bstrVal)); - pCursorSubelement->getAttribute(CComBSTR(_T("g")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) g = _ttoi(OLE2T(varAttValue.bstrVal)); - pCursorSubelement->getAttribute(CComBSTR(_T("b")), varAttValue.Out()); - if (varAttValue.vt == VT_BSTR) b = _ttoi(OLE2T(varAttValue.bstrVal)); - - m_crCursorColor = RGB(r, g, b); - } - SAFERELEASE(pCursorSubelement); - - if (!SUCCEEDED(pCursorColl->item(CComVariant(_T("style")), CComVariant(0), (IDispatch**)&pCursorSubelement))) throw XmlException(FALSE); - if (pCursorSubelement) { - pCursorSubelement->get_text(strText.Out()); - strTempText = OLE2T(strText); - - if (!_tcsicmp(strTempText.c_str(), _T("none"))) { - m_dwCursorStyle = CURSOR_STYLE_NONE; - } else if (!_tcsicmp(strTempText.c_str(), _T("XTerm"))) { - m_dwCursorStyle = CURSOR_STYLE_XTERM; - } else if (!_tcsicmp(strTempText.c_str(), _T("block"))) { - m_dwCursorStyle = CURSOR_STYLE_BLOCK; - } else if (!_tcsicmp(strTempText.c_str(), _T("noblink block"))) { - m_dwCursorStyle = CURSOR_STYLE_NBBLOCK; - } else if (!_tcsicmp(strTempText.c_str(), _T("pulse block"))) { - m_dwCursorStyle = CURSOR_STYLE_PULSEBLOCK; - } else if (!_tcsicmp(strTempText.c_str(), _T("bar"))) { - m_dwCursorStyle = CURSOR_STYLE_BAR; - } else if (!_tcsicmp(strTempText.c_str(), _T("console"))) { - m_dwCursorStyle = CURSOR_STYLE_CONSOLE; - } else if (!_tcsicmp(strTempText.c_str(), _T("noblink line"))) { - m_dwCursorStyle = CURSOR_STYLE_NBHLINE; - } else if (!_tcsicmp(strTempText.c_str(), _T("horizontal line"))) { - m_dwCursorStyle = CURSOR_STYLE_HLINE; - } else if (!_tcsicmp(strTempText.c_str(), _T("vertical line"))) { - m_dwCursorStyle = CURSOR_STYLE_VLINE; - } else if (!_tcsicmp(strTempText.c_str(), _T("rect"))) { - m_dwCursorStyle = CURSOR_STYLE_RECT; - } else if (!_tcsicmp(strTempText.c_str(), _T("noblink rect"))) { - m_dwCursorStyle = CURSOR_STYLE_NBRECT; - } else if (!_tcsicmp(strTempText.c_str(), _T("pulse rect"))) { - m_dwCursorStyle = CURSOR_STYLE_PULSERECT; - } else if (!_tcsicmp(strTempText.c_str(), _T("fading block"))) { - m_dwCursorStyle = CURSOR_STYLE_FADEBLOCK; - } - } - SAFERELEASE(pCursorSubelement); - } - SAFERELEASE(pCursorColl); - } - - if (!SUCCEEDED(pAppearanceColl->item(CComVariant(_T("icon")), CComVariant(0), (IDispatch**)&pAppearanaceSubelement))) throw XmlException(FALSE); - if (pAppearanaceSubelement) { - pAppearanaceSubelement->get_text(strText.Out()); - if (strText.Length() > 0) m_strIconFilename = OLE2T(strText); - } - SAFERELEASE(pAppearanaceSubelement); - - } - SAFERELEASE(pAppearanceColl); - } - - // get behaviour settings - IXMLElementCollection* pBehaviorColl = NULL; - if (!SUCCEEDED(pColl->item(CComVariant(_T("behaviour")), CComVariant(0), (IDispatch**)&pBehaviorElement))) { - if (!SUCCEEDED(pColl->item(CComVariant(_T("behavior")), CComVariant(0), (IDispatch**)&pBehaviorElement))) throw XmlException(FALSE); - } - - if (pBehaviorElement) { - if (!SUCCEEDED(pBehaviorElement->get_children(&pBehaviorColl))) throw XmlException(FALSE); - - if (pBehaviorColl) { - IXMLElement* pBehaviourSubelement = NULL; - - if (!SUCCEEDED(pBehaviorColl->item(CComVariant(_T("mouse_drag")), CComVariant(0), (IDispatch**)&pBehaviourSubelement))) throw XmlException(FALSE); - if (pBehaviourSubelement) { - pBehaviourSubelement->get_text(strText.Out()); - if (!_tcsicmp(OLE2T(strText), _T("true"))) { - m_bMouseDragable = TRUE; - } else { - m_bMouseDragable = FALSE; - } - } - SAFERELEASE(pBehaviourSubelement); - - if (!SUCCEEDED(pBehaviorColl->item(CComVariant(_T("copy_on_select")), CComVariant(0), (IDispatch**)&pBehaviourSubelement))) throw XmlException(FALSE); - if (pBehaviourSubelement) { - pBehaviourSubelement->get_text(strText.Out()); - if (!_tcsicmp(OLE2T(strText), _T("true"))) { - m_bCopyOnSelect = TRUE; - } else { - m_bCopyOnSelect = FALSE; - } - } - SAFERELEASE(pBehaviourSubelement); - - if (!SUCCEEDED(pBehaviorColl->item(CComVariant(_T("inverse_shift")), CComVariant(0), (IDispatch**)&pBehaviourSubelement))) throw XmlException(FALSE); - if (pBehaviourSubelement) { - pBehaviourSubelement->get_text(strText.Out()); - if (!_tcsicmp(OLE2T(strText), _T("true"))) { - m_bInverseShift = TRUE; - } else { - m_bInverseShift = FALSE; - } - } - SAFERELEASE(pBehaviourSubelement); - - if (!SUCCEEDED(pBehaviorColl->item(CComVariant(_T("reload_new_config")), CComVariant(0), (IDispatch**)&pBehaviourSubelement))) throw XmlException(FALSE); - if (pBehaviourSubelement) { - pBehaviourSubelement->get_text(strText.Out()); - if (!_tcsicmp(OLE2T(strText), _T("yes"))) { - m_dwReloadNewConfig = RELOAD_NEW_CONFIG_YES; - } else if (!_tcsicmp(OLE2T(strText), _T("no"))) { - m_dwReloadNewConfig = RELOAD_NEW_CONFIG_NO; - } else { - m_dwReloadNewConfig = RELOAD_NEW_CONFIG_PROMPT; - } - } - SAFERELEASE(pBehaviourSubelement); - - if (!SUCCEEDED(pBehaviorColl->item(CComVariant(_T("disable_menu")), CComVariant(0), (IDispatch**)&pBehaviourSubelement))) throw XmlException(FALSE); - if (pBehaviourSubelement) { - pBehaviourSubelement->get_text(strText.Out()); - if (!_tcsicmp(OLE2T(strText), _T("true"))) { - m_bPopupMenuDisabled = TRUE; - } else { - m_bPopupMenuDisabled = FALSE; - } - } - SAFERELEASE(pBehaviourSubelement); - - } - SAFERELEASE(pBehaviorColl); - } - - bRet = TRUE; - - } catch (const XmlException& e) { - bRet = e.m_bRet; - } - - SAFERELEASE(pBehaviorElement); - SAFERELEASE(pCursorElement); - SAFERELEASE(pBackgroundElement); - SAFERELEASE(pScrollbarElement); - SAFERELEASE(pAppearanceElement); - SAFERELEASE(pPositionElement); - SAFERELEASE(pFontElement); - SAFERELEASE(pColl); - SAFERELEASE(pRootElement); - SAFERELEASE(pPersistStream); - SAFERELEASE(pConfigDoc); - SAFERELEASE(pFileStream); - - ::CoUninitialize(); - return bRet; -#endif return 1; } @@ -2175,284 +1253,12 @@ void Console::CreateOffscreenBuffers() { ///////////////////////////////////////////////////////////////////////////// -#if 0 -void Console::CreateBackgroundBitmap() { - - USES_CONVERSION; - - if (m_hbmpBackgroundOld) ::SelectObject(m_hdcBackground, m_hbmpBackgroundOld); - if (m_hbmpBackground) ::DeleteObject(m_hbmpBackground); - if (m_hdcBackground) ::DeleteDC(m_hdcBackground); - - if (!m_bBitmapBackground) return; - - // determine the total size of the background bitmap - DWORD dwPrimaryDisplayWidth = ::GetSystemMetrics(SM_CXSCREEN); - DWORD dwPrimaryDisplayHeight = ::GetSystemMetrics(SM_CYSCREEN); - - DWORD dwBackgroundWidth = 0; - DWORD dwBackgroundHeight = 0; - - if (m_bRelativeBackground) { - - if (g_bWin2000) { - // Win2K and later can handle multiple monitors - dwBackgroundWidth = ::GetSystemMetrics(SM_CXVIRTUALSCREEN); - dwBackgroundHeight = ::GetSystemMetrics(SM_CYVIRTUALSCREEN); - - // get offsets for virtual display - m_nBackgroundOffsetX = ::GetSystemMetrics(SM_XVIRTUALSCREEN); - m_nBackgroundOffsetY = ::GetSystemMetrics(SM_YVIRTUALSCREEN); - } else { - // WinNT compatibility (hope it works, I didn't test it) - dwBackgroundWidth = dwPrimaryDisplayWidth; - dwBackgroundHeight = dwBackgroundHeight; - } - - } else { - dwBackgroundWidth = m_nClientWidth; - dwBackgroundHeight = m_nClientHeight; - } - - // now, load the image... - fipImage image; - IMAGE_DATA imageData; - - if (!image.load(T2A(m_strBackgroundFile.c_str()))) { - m_bBitmapBackground = FALSE; - return; - } - - imageData.hdcImage = NULL; - imageData.dwImageWidth = image.getWidth(); - imageData.dwImageHeight = image.getHeight(); - - image.convertTo24Bits(); - - // ... if needed, tint the background image - if (m_bTintSet) { - - BYTE* pPixels = image.accessPixels(); - BYTE* pPixelsEnd = pPixels + 3*image.getWidth()*image.getHeight(); - BYTE* pPixelSubel = pPixels; - - while (pPixelSubel < pPixelsEnd) { - - *pPixelSubel = (BYTE) ((unsigned long)(*pPixelSubel * (100 - m_byTintOpacity) + m_byTintB*m_byTintOpacity)/100); - ++pPixelSubel; - *pPixelSubel = (BYTE) ((unsigned long)(*pPixelSubel * (100 - m_byTintOpacity) + m_byTintG*m_byTintOpacity)/100); - ++pPixelSubel; - *pPixelSubel = (BYTE) ((unsigned long)(*pPixelSubel * (100 - m_byTintOpacity) + m_byTintR*m_byTintOpacity)/100); - ++pPixelSubel; - } - } - - // create the basic image - HBITMAP hbmpImage = NULL; - HBITMAP hbmpImageOld = NULL; - - if (m_dwBackgroundStyle == BACKGROUND_STYLE_RESIZE) { - - if (m_bRelativeBackground) { - if (m_bExtendBackground) { - imageData.dwImageWidth = dwBackgroundWidth; - imageData.dwImageHeight = dwBackgroundHeight; - } else { - imageData.dwImageWidth = dwPrimaryDisplayWidth; - imageData.dwImageHeight = dwPrimaryDisplayHeight; - } - } else { - imageData.dwImageWidth = (DWORD)m_nClientWidth; - imageData.dwImageHeight = (DWORD)m_nClientHeight; - } - - if ((image.getWidth() != imageData.dwImageWidth) || (image.getHeight() != imageData.dwImageHeight)) { - image.rescale(imageData.dwImageWidth, imageData.dwImageHeight, FILTER_LANCZOS3); - } - } - - - // now, create a DC compatible with the screen and create the basic bitmap - HDC hdcDesktop = ::GetDCEx(m_hWnd, NULL, 0); - imageData.hdcImage = ::CreateCompatibleDC(hdcDesktop); - hbmpImage = ::CreateDIBitmap( - hdcDesktop, - image.getInfoHeader(), - CBM_INIT, - image.accessPixels(), - image.getInfo(), - DIB_RGB_COLORS); - hbmpImageOld= (HBITMAP)::SelectObject(imageData.hdcImage, hbmpImage); - ::ReleaseDC(m_hWnd, hdcDesktop); - - // create the background image - m_hdcBackground = ::CreateCompatibleDC(imageData.hdcImage); - m_hbmpBackground = ::CreateCompatibleBitmap(imageData.hdcImage, dwBackgroundWidth, dwBackgroundHeight); - m_hbmpBackgroundOld = (HBITMAP)::SelectObject(m_hdcBackground, m_hbmpBackground); - - RECT rectBackground; - rectBackground.left = 0; - rectBackground.top = 0; - rectBackground.right = dwBackgroundWidth; - rectBackground.bottom = dwBackgroundHeight; - - // fill the background with the proper background color in case the - // bitmap doesn't cover the entire background, - COLORREF crBackground; - - if (m_dwTransparency == TRANSPARENCY_FAKE) { - // get desktop background color - HKEY hkeyColors; - if (::RegOpenKeyEx(HKEY_CURRENT_USER, _T("Control Panel\\Colors"), 0, KEY_READ, &hkeyColors) == ERROR_SUCCESS) { - - TCHAR szData[MAX_PATH]; - DWORD dwDataSize = MAX_PATH; - - BYTE r = 0; - BYTE g = 0; - BYTE b = 0; - - ::ZeroMemory(szData, sizeof(szData)); - ::RegQueryValueEx(hkeyColors, _T("Background"), NULL, NULL, (BYTE*)szData, &dwDataSize); - - _stscanf(szData, _T("%i %i %i"), &r, &g, &b); - crBackground = RGB(r, g, b); - - ::RegCloseKey(hkeyColors); - } - } else { - ::CopyMemory(&crBackground, &m_crBackground, sizeof(COLORREF)); - } - - HBRUSH hBkBrush = ::CreateSolidBrush(crBackground); - ::FillRect(m_hdcBackground, &rectBackground, hBkBrush); - ::DeleteObject(hBkBrush); - - if (m_dwBackgroundStyle == BACKGROUND_STYLE_TILE) { - - // we're tiling the image, starting at coordinates (0, 0) of the virtual screen - DWORD dwX = 0; - DWORD dwY = 0; - - DWORD dwImageOffsetX = 0; - DWORD dwImageOffsetY = imageData.dwImageHeight + (m_nBackgroundOffsetY - (int)imageData.dwImageHeight*(m_nBackgroundOffsetY/(int)imageData.dwImageHeight)); - - while (dwY < dwBackgroundHeight) { - - dwX = 0; - dwImageOffsetX = imageData.dwImageWidth + (m_nBackgroundOffsetX - (int)imageData.dwImageWidth*(m_nBackgroundOffsetX/(int)imageData.dwImageWidth)); - - while (dwX < dwBackgroundWidth) { - - ::BitBlt( - m_hdcBackground, - dwX, - dwY, - imageData.dwImageWidth, - imageData.dwImageHeight, - imageData.hdcImage, - dwImageOffsetX, - dwImageOffsetY, - SRCCOPY); - - dwX += imageData.dwImageWidth - dwImageOffsetX; - dwImageOffsetX = 0; - } - - dwY += imageData.dwImageHeight - dwImageOffsetY; - dwImageOffsetY = 0; - } - - } else if (m_bExtendBackground || !m_bRelativeBackground) { - - switch (m_dwBackgroundStyle) { - case BACKGROUND_STYLE_RESIZE : - ::BitBlt( - m_hdcBackground, - 0, - 0, - dwBackgroundWidth, - dwBackgroundHeight, - imageData.hdcImage, - 0, - 0, - SRCCOPY); - break; - - case BACKGROUND_STYLE_CENTER : - ::BitBlt( - m_hdcBackground, - (dwBackgroundWidth <= imageData.dwImageWidth) ? 0 : (dwBackgroundWidth - imageData.dwImageWidth)/2, - (dwBackgroundHeight <= imageData.dwImageHeight) ? 0 : (dwBackgroundHeight - imageData.dwImageHeight)/2, - imageData.dwImageWidth, - imageData.dwImageHeight, - imageData.hdcImage, - (dwBackgroundWidth < imageData.dwImageWidth) ? (imageData.dwImageWidth - dwBackgroundWidth)/2 : 0, - (dwBackgroundHeight < imageData.dwImageHeight) ? (imageData.dwImageHeight - dwBackgroundHeight)/2 : 0, - SRCCOPY); - break; - } - } else { - ::EnumDisplayMonitors(NULL, NULL, Console::BackgroundEnumProc, (DWORD)&imageData); - } - - ::SelectObject(imageData.hdcImage, hbmpImageOld); - ::DeleteObject(hbmpImage); - ::DeleteDC(imageData.hdcImage); -} -#endif ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -#if 0 -BOOL CALLBACK Console::BackgroundEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) { - - IMAGE_DATA* pImageData = (IMAGE_DATA*)dwData; - - DWORD dwDisplayWidth = lprcMonitor->right - lprcMonitor->left; - DWORD dwDisplayHeight = lprcMonitor->bottom - lprcMonitor->top; - - DWORD dwPrimaryDisplayWidth = ::GetSystemMetrics(SM_CXSCREEN); - DWORD dwPrimaryDisplayHeight = ::GetSystemMetrics(SM_CYSCREEN); - - // center the image according to current display's size and position - switch (g_pConsole->m_dwBackgroundStyle) { - - case BACKGROUND_STYLE_RESIZE : - ::BitBlt( - g_pConsole->m_hdcBackground, - (dwDisplayWidth <= dwPrimaryDisplayWidth) ? lprcMonitor->left-g_pConsole->m_nBackgroundOffsetX : lprcMonitor->left-g_pConsole->m_nBackgroundOffsetX + (dwDisplayWidth - dwPrimaryDisplayWidth)/2, - (dwDisplayHeight <= dwPrimaryDisplayHeight) ? lprcMonitor->top-g_pConsole->m_nBackgroundOffsetY : lprcMonitor->top-g_pConsole->m_nBackgroundOffsetY + (dwDisplayHeight - dwPrimaryDisplayHeight)/2, - dwDisplayWidth, - dwDisplayHeight, - pImageData->hdcImage, - (dwDisplayWidth < dwPrimaryDisplayWidth) ? (dwPrimaryDisplayWidth - dwDisplayWidth)/2 : 0, - (dwDisplayHeight < dwPrimaryDisplayHeight) ? (dwPrimaryDisplayHeight - dwDisplayHeight)/2 : 0, - SRCCOPY); - - break; - - case BACKGROUND_STYLE_CENTER : - ::BitBlt( - g_pConsole->m_hdcBackground, - (dwDisplayWidth <= pImageData->dwImageWidth) ? lprcMonitor->left-g_pConsole->m_nBackgroundOffsetX : lprcMonitor->left-g_pConsole->m_nBackgroundOffsetX + (dwDisplayWidth - pImageData->dwImageWidth)/2, - (dwDisplayHeight <= pImageData->dwImageHeight) ? lprcMonitor->top-g_pConsole->m_nBackgroundOffsetY : lprcMonitor->top-g_pConsole->m_nBackgroundOffsetY + (dwDisplayHeight - pImageData->dwImageHeight)/2, - dwDisplayWidth, - dwDisplayHeight, - pImageData->hdcImage, - (dwDisplayWidth < pImageData->dwImageWidth) ? (pImageData->dwImageWidth - dwDisplayWidth)/2 : 0, - (dwDisplayHeight < pImageData->dwImageHeight) ? (pImageData->dwImageHeight - dwDisplayHeight)/2 : 0, - SRCCOPY); - - break; - } - - return TRUE; -} -#endif ///////////////////////////////////////////////////////////////////////////// @@ -2543,63 +1349,6 @@ void Console::CalcWindowSize() { ///////////////////////////////////////////////////////////////////////////// -#if 0 -void Console::SetWindowTransparency() { - // set alpha transparency (Win2000 and later only!) - if (g_bWin2000 && ((m_dwTransparency == TRANSPARENCY_ALPHA) || (m_dwTransparency == TRANSPARENCY_COLORKEY))) { - - ::SetWindowLong(m_hWnd, GWL_EXSTYLE, ::GetWindowLong(m_hWnd, GWL_EXSTYLE) | WS_EX_LAYERED); - g_pfnSetLayeredWndAttr(m_hWnd, m_crBackground, m_byAlpha, m_dwTransparency == TRANSPARENCY_ALPHA ? LWA_ALPHA : LWA_COLORKEY); - - } else if (m_dwTransparency == TRANSPARENCY_FAKE) { - // get wallpaper settings - HKEY hkeyDesktop; - if (::RegOpenKeyEx(HKEY_CURRENT_USER, _T("Control Panel\\Desktop"), 0, KEY_READ, &hkeyDesktop) == ERROR_SUCCESS) { - TCHAR szData[MAX_PATH]; - DWORD dwDataSize = MAX_PATH; - - DWORD dwWallpaperStyle; - DWORD dwTileWallpaper; - - ::ZeroMemory(szData, sizeof(szData)); - ::RegQueryValueEx(hkeyDesktop, _T("Wallpaper"), NULL, NULL, (BYTE*)szData, &dwDataSize); - - if (_tcslen(szData) > 0) { - m_bBitmapBackground = TRUE; - m_strBackgroundFile = szData; - m_bRelativeBackground = TRUE; - m_bExtendBackground = FALSE; - - // get wallpaper style and tile flag - dwDataSize = MAX_PATH; - ::ZeroMemory(szData, sizeof(szData)); - ::RegQueryValueEx(hkeyDesktop, _T("WallpaperStyle"), NULL, NULL, (BYTE*)szData, &dwDataSize); - - dwWallpaperStyle = _ttoi(szData); - - dwDataSize = MAX_PATH; - ::ZeroMemory(szData, sizeof(szData)); - ::RegQueryValueEx(hkeyDesktop, _T("TileWallpaper"), NULL, NULL, (BYTE*)szData, &dwDataSize); - - dwTileWallpaper = _ttoi(szData); - - if (dwTileWallpaper == 1) { - m_dwBackgroundStyle = BACKGROUND_STYLE_TILE; - } else { - - if (dwWallpaperStyle == 0) { - m_dwBackgroundStyle = BACKGROUND_STYLE_CENTER; - } else { - m_dwBackgroundStyle = BACKGROUND_STYLE_RESIZE; - } - } - } - - ::RegCloseKey(hkeyDesktop); - } - } -} -#endif ///////////////////////////////////////////////////////////////////////////// @@ -2660,17 +1409,10 @@ void Console::SetDefaultConsoleColors() { void Console::SetWindowSizeAndPosition() { // set window position -#if 0 - DWORD dwScreenWidth = ::GetSystemMetrics(g_bWin2000 ? SM_CXVIRTUALSCREEN : SM_CXSCREEN); - DWORD dwScreenHeight = ::GetSystemMetrics(g_bWin2000 ? SM_CYVIRTUALSCREEN : SM_CYSCREEN); - DWORD dwTop = ::GetSystemMetrics(g_bWin2000 ? SM_YVIRTUALSCREEN : 0); - DWORD dwLeft = ::GetSystemMetrics(g_bWin2000 ? SM_XVIRTUALSCREEN : 0); -#else DWORD dwScreenWidth = ::GetSystemMetrics(SM_CXSCREEN); DWORD dwScreenHeight = ::GetSystemMetrics(SM_CYSCREEN); DWORD dwTop = ::GetSystemMetrics(0); DWORD dwLeft = ::GetSystemMetrics(0); -#endif switch (m_dwDocked) { case DOCK_TOP_LEFT: @@ -2985,79 +1727,12 @@ void Console::ReloadSettings() { BOOL Console::StartShellProcess() { -#if 0 - if (m_strShell.length() == 0) { - TCHAR szComspec[MAX_PATH]; - - if (::GetEnvironmentVariable(_T("COMSPEC"), szComspec, MAX_PATH) > 0) { - m_strShell = szComspec; - } else { - m_strShell = _T("cmd.exe"); - } - } - - tstring strShellCmdLine(m_strShell); - if (m_strShellCmdLine.length() > 0) { - strShellCmdLine += _T(" "); - strShellCmdLine += m_strShellCmdLine; - } - -// strShellCmdLine = "cmd.exe"; - - // create the console window - TCHAR szConsoleTitle[MAX_PATH]; - ::AllocConsole(); - // we use this to avoid possible problems with multiple console instances running - _stprintf(szConsoleTitle, _T("%i"), ::GetCurrentThreadId()); - ::SetConsoleTitle(szConsoleTitle); - m_hStdOut = ::GetStdHandle(STD_OUTPUT_HANDLE); - while ((m_hWndConsole = ::FindWindow(NULL, szConsoleTitle)) == NULL) ::Sleep(50); - ::SetConsoleTitle(m_strWinConsoleTitle.c_str()); -#endif // this is a little hack needed to support columns greater than standard 80 RefreshStdOut(); InitConsoleWndSize(80); ResizeConsoleWindow(); -#if 0 - ::SetConsoleCtrlHandler(Console::CtrlHandler, TRUE); - - // setup the start up info struct - PROCESS_INFORMATION pi; - STARTUPINFO si; - ::ZeroMemory(&si, sizeof(STARTUPINFO)); - si.cb = sizeof(STARTUPINFO); - - if (!::CreateProcess( - NULL, - (TCHAR*)strShellCmdLine.c_str(), - NULL, - NULL, - TRUE, - 0, - NULL, - NULL, - &si, - &pi)) { - - return FALSE; - } - - if (m_dwHideConsoleTimeout > 0) { - ::ShowWindow(m_hWndConsole, SW_MINIMIZE); - ::SetTimer(m_hWnd, TIMER_SHOW_HIDE_CONSOLE, m_dwHideConsoleTimeout, NULL); - } else { - ShowHideConsole(); - } - - // close main thread handle - ::CloseHandle(pi.hThread); - - // set handles - m_hQuitEvent = ::CreateEvent(NULL, FALSE, FALSE, NULL); - m_hConsoleProcess = pi.hProcess; -#endif return TRUE; } @@ -3068,10 +1743,6 @@ BOOL Console::StartShellProcess() { ///////////////////////////////////////////////////////////////////////////// void Console::RefreshStdOut() { -#if 0 - if (m_hStdOutFresh) ::CloseHandle(m_hStdOutFresh); - m_hStdOutFresh = ::CreateFile(_T("CONOUT$"), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0); -#endif } ///////////////////////////////////////////////////////////////////////////// @@ -3091,73 +1762,6 @@ void Console::RefreshScreenBuffer() { si.nPos = (int)m_csbiConsole.srWindow.Top; ::FlatSB_SetScrollInfo(m_hWnd, SB_VERT, &si, TRUE); -#if 0 - if ((m_csbiConsole.srWindow.Right - m_csbiConsole.srWindow.Left + 1 != m_dwColumns) || (m_csbiConsole.srWindow.Bottom - m_csbiConsole.srWindow.Top + 1 != m_dwRows) || (m_csbiConsole.dwSize.Y != m_dwBufferRows)) { - m_dwColumns = m_csbiConsole.srWindow.Right - m_csbiConsole.srWindow.Left + 1; - m_dwRows = m_csbiConsole.srWindow.Bottom - m_csbiConsole.srWindow.Top + 1; - ResizeConsoleWindow(); - } - - COORD coordBufferSize; - COORD coordStart; - SMALL_RECT srRegion; - - coordStart.X = 0; - coordStart.Y = 0; - - coordBufferSize.X = m_dwColumns; - coordBufferSize.Y = m_dwRows; - - srRegion.Top = m_csbiConsole.srWindow.Top; - srRegion.Left = 0; - srRegion.Bottom = m_csbiConsole.srWindow.Top + m_dwRows - 1; - srRegion.Right = m_dwColumns - 1; - - DEL_ARR(m_pScreenBufferNew); - m_pScreenBufferNew = new CHAR_INFO[m_dwRows * m_dwColumns]; - ::ZeroMemory( m_pScreenBufferNew, m_dwRows * m_dwColumns * sizeof(CHAR_INFO)); - for (int i=0; i (DWORD) dwColumns * m_dwBufferRows) { - ::SetConsoleWindowInfo(m_hStdOutFresh, TRUE, &srConsoleRect); - ::SetConsoleScreenBufferSize(m_hStdOutFresh, coordConsoleSize); - } else if (((DWORD)csbi.dwSize.X < dwColumns) || ((DWORD)csbi.dwSize.Y < m_dwBufferRows) || ((DWORD)(csbi.srWindow.Bottom - csbi.srWindow.Top + 1) != m_dwRows)) { - ::SetConsoleScreenBufferSize(m_hStdOutFresh, coordConsoleSize); - ::SetConsoleWindowInfo(m_hStdOutFresh, TRUE, &srConsoleRect); - } -#endif } ///////////////////////////////////////////////////////////////////////////// @@ -3235,28 +1827,6 @@ void Console::ResizeConsoleWindow() { // 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 - if ((DWORD) csbi.dwSize.X * csbi.dwSize.Y > (DWORD) m_dwColumns * m_dwBufferRows) { - - if (m_bUseTextBuffer && (csbi.dwSize.Y > m_dwBufferRows)) { - coordBuffersSize.Y = m_dwBufferRows = csbi.dwSize.Y; - } - - ::SetConsoleWindowInfo(m_hStdOutFresh, TRUE, &srConsoleRect); - ::SetConsoleScreenBufferSize(m_hStdOutFresh, coordBuffersSize); - - // } else if (((DWORD)csbi.dwSize.X < m_dwColumns) || ((DWORD)csbi.dwSize.Y < m_dwBufferRows) || ((DWORD)(csbi.srWindow.Bottom - csbi.srWindow.Top + 1) != m_dwRows)) { - } else if ((DWORD) csbi.dwSize.X * csbi.dwSize.Y < (DWORD) m_dwColumns * m_dwBufferRows) { - - if (csbi.dwSize.Y < m_dwBufferRows) { - m_dwBufferRows = coordBuffersSize.Y = csbi.dwSize.Y; - } - - ::SetConsoleScreenBufferSize(m_hStdOutFresh, coordBuffersSize); - ::SetConsoleWindowInfo(m_hStdOutFresh, TRUE, &srConsoleRect); - } -#endif SetScrollbarStuff(); CalcWindowSize(); @@ -3290,15 +1860,6 @@ void Console::RepaintWindow() { rect.bottom = m_nClientHeight; rect.right = m_nClientWidth; -#if 0 - if (m_bBitmapBackground) { - if (m_bRelativeBackground) { - ::BitBlt(m_hdcConsole, 0, 0, m_nClientWidth, m_nClientHeight, m_hdcBackground, m_nX+m_nXBorderSize-m_nBackgroundOffsetX, m_nY+m_nCaptionSize+m_nYBorderSize-m_nBackgroundOffsetY, SRCCOPY); - } else { - ::BitBlt(m_hdcConsole, 0, 0, m_nClientWidth, m_nClientHeight, m_hdcBackground, 0, 0, SRCCOPY); - } - } else { -#endif ::FillRect(m_hdcConsole, &rect, m_hBkBrush); // } @@ -3473,15 +2034,6 @@ void Console::RepaintWindowChanges() { rect.bottom = dwY + m_nCharHeight; rect.right = dwX + m_nCharWidth; -#if 0 - if (m_bBitmapBackground) { - if (m_bRelativeBackground) { - ::BitBlt(m_hdcConsole, dwX, dwY, m_nCharWidth, m_nCharHeight, m_hdcBackground, m_nX+m_nXBorderSize-m_nBackgroundOffsetX+(int)dwX, m_nY+m_nCaptionSize+m_nYBorderSize-m_nBackgroundOffsetY+(int)dwY, SRCCOPY); - } else { - ::BitBlt(m_hdcConsole, dwX, dwY, m_nCharWidth, m_nCharHeight, m_hdcBackground, dwX, dwY, SRCCOPY); - } - } else { -#endif ::FillRect(m_hdcConsole, &rect, m_hBkBrush); // } @@ -3520,15 +2072,6 @@ void Console::RepaintWindowChanges() { rect.bottom = m_nClientHeight; rect.right = m_nClientWidth; -#if 0 - if (m_bBitmapBackground) { - if (m_bRelativeBackground) { - ::BitBlt(m_hdcConsole, 0, 0, m_nClientWidth, m_nClientHeight, m_hdcBackground, m_nX+m_nXBorderSize-m_nBackgroundOffsetX, m_nY+m_nCaptionSize+m_nYBorderSize-m_nBackgroundOffsetY, SRCCOPY); - } else { - ::BitBlt(m_hdcConsole, 0, 0, m_nClientWidth, m_nClientHeight, m_hdcBackground, 0, 0, SRCCOPY); - } - } else { -#endif ::FillRect(m_hdcConsole, &rect, m_hBkBrush); // } @@ -3579,27 +2122,9 @@ void Console::DrawCursor(BOOL bOnlyCursor) { ::InvalidateRect(m_hWnd, &rectCursorOld, FALSE); } -#if 0 - // now, see if the cursor is visible... - CONSOLE_CURSOR_INFO cinf; - ::GetConsoleCursorInfo(m_hStdOutFresh, &cinf); - - m_bCursorVisible = cinf.bVisible; -#endif // ... and draw it if (m_bCursorVisible) { -#if 0 - ::GetConsoleScreenBufferInfo(m_hStdOutFresh, &m_csbiCursor); - - if (m_csbiCursor.dwCursorPosition.Y < m_csbiCursor.srWindow.Top || m_csbiCursor.dwCursorPosition.Y > m_csbiCursor.srWindow.Bottom) { - m_bCursorVisible = FALSE; - return; - } - - // set proper cursor offset - m_csbiCursor.dwCursorPosition.Y -= m_csbiCursor.srWindow.Top; -#endif RECT rectCursor; if (!bOnlyCursor) { @@ -3696,33 +2221,6 @@ inline void Console::DrawCursorBackground(RECT& rectCursor) { ::SetTextColor(m_hdcConsole, m_bUseFontColor ? m_crFontColor : m_arrConsoleColors[m_pScreenBuffer[dwOffset].Attributes & 0xF]); -#if 0 - if (m_bBitmapBackground) { - if (m_bRelativeBackground) { - ::BitBlt( - m_hdcConsole, - rectCursor.left, - rectCursor.top, - rectCursor.right - rectCursor.left, - rectCursor.bottom - rectCursor.top, - m_hdcBackground, - m_nX+m_nXBorderSize-m_nBackgroundOffsetX + rectCursor.left, - m_nY+m_nCaptionSize+m_nYBorderSize-m_nBackgroundOffsetY + rectCursor.top, - SRCCOPY); - - } else { - ::BitBlt( - m_hdcConsole, - rectCursor.left, - rectCursor.top, - rectCursor.right - rectCursor.left, - rectCursor.bottom - rectCursor.top, - m_hdcBackground, - rectCursor.left, - rectCursor.top, SRCCOPY); - } - } else { -#endif ::FillRect(m_hdcConsole, &rectCursor, m_hBkBrush); // } @@ -3791,13 +2289,6 @@ void Console::ShowHideConsole() { ///////////////////////////////////////////////////////////////////////////// -#if 0 -void Console::ShowHideConsoleTimeout() { - - ::KillTimer(m_hWnd, TIMER_SHOW_HIDE_CONSOLE); - ShowHideConsole(); -} -#endif ///////////////////////////////////////////////////////////////////////////// @@ -3860,24 +2351,6 @@ BOOL Console::HandleMenuCommand(DWORD dwID) { PasteClipoardText(); return FALSE; -#if 0 - case ID_HIDE_CONSOLE: - m_bHideConsole = !m_bHideConsole; - ShowHideConsole(); - return FALSE; - - case ID_EDIT_CONFIG_FILE: - EditConfigFile(); - return FALSE; - - case ID_RELOAD_SETTINGS: - ReloadSettings(); - return FALSE; - - case ID_TOGGLE_ONTOP: - ToggleWindowOnTop(); - return FALSE; -#endif case ID_EXIT_CONSOLE: ::SendMessage(m_hWnd, WM_CLOSE, 0, 0); @@ -3893,32 +2366,6 @@ BOOL Console::HandleMenuCommand(DWORD dwID) { return TRUE; } -#if 0 - // check if it's one of config file submenu items - if ((dwID >= ID_FIRST_XML_FILE) && - (dwID <= ID_LAST_XML_FILE)) { - - TCHAR szFilename[MAX_PATH]; - ::ZeroMemory(szFilename, sizeof(szFilename)); - ::GetMenuString(m_hConfigFilesMenu, dwID, szFilename, MAX_PATH, MF_BYCOMMAND); - m_strConfigFile = tstring(szFilename); - - if (m_dwReloadNewConfig == RELOAD_NEW_CONFIG_PROMPT) { - if (::MessageBox( - m_hWndConsole, - _T("Load new settings?"), - _T("New configuration selected"), - MB_YESNO|MB_ICONQUESTION) == IDYES) { - - ReloadSettings(); - } - } else if (m_dwReloadNewConfig == RELOAD_NEW_CONFIG_YES) { - ReloadSettings(); - } - - return FALSE; - } -#endif return TRUE; } @@ -3930,10 +2377,6 @@ BOOL Console::HandleMenuCommand(DWORD dwID) { void Console::UpdateOnTopMenuItem() { -#if 0 - ::CheckMenuItem(::GetSubMenu(m_hPopupMenu, 0), ID_TOGGLE_ONTOP, MF_BYCOMMAND | ((m_dwCurrentZOrder == Z_ORDER_ONTOP) ? MF_CHECKED : MF_UNCHECKED)); - ::CheckMenuItem(m_hSysMenu, ID_TOGGLE_ONTOP, MF_BYCOMMAND | ((m_dwCurrentZOrder == Z_ORDER_ONTOP) ? MF_CHECKED : MF_UNCHECKED)); -#endif } ///////////////////////////////////////////////////////////////////////////// @@ -3943,10 +2386,6 @@ void Console::UpdateOnTopMenuItem() { void Console::UpdateHideConsoleMenuItem() { -#if 0 - ::CheckMenuItem(::GetSubMenu(m_hPopupMenu, 0), ID_HIDE_CONSOLE, MF_BYCOMMAND | (m_bHideConsole ? MF_CHECKED : MF_UNCHECKED)); - ::CheckMenuItem(m_hSysMenu, ID_HIDE_CONSOLE, MF_BYCOMMAND | (m_bHideConsole ? MF_CHECKED : MF_UNCHECKED)); -#endif } ///////////////////////////////////////////////////////////////////////////// @@ -3956,55 +2395,6 @@ void Console::UpdateHideConsoleMenuItem() { void Console::UpdateConfigFilesSubmenu() { -#if 0 - // populate m_hConfigFilesMenu - - // first, delete old items - while (::GetMenuItemCount(m_hConfigFilesMenu) != 0) ::DeleteMenu(m_hConfigFilesMenu, 0, MF_BYPOSITION); - - // then, enumerate the files - WIN32_FIND_DATA wfd; - HANDLE hWfd = NULL; - BOOL bMoreFiles = TRUE; - DWORD dwID = ID_FIRST_XML_FILE; - - ::ZeroMemory(&wfd, sizeof(WIN32_FIND_DATA)); - - // create the search mask... - int nBackslashPos = m_strConfigFile.rfind(_TCHAR('\\')); - tstring strConfigFileDir(m_strConfigFile.substr(0, nBackslashPos+1)); - tstring strSearchFileMask(strConfigFileDir + tstring(_T("*.xml"))); - - // ... and enumearate files - hWfd = ::FindFirstFile(strSearchFileMask.c_str(), &wfd); - while ((hWfd != INVALID_HANDLE_VALUE) && bMoreFiles) { - - MENUITEMINFO mii; - TCHAR szFilename[MAX_PATH]; - - _sntprintf(szFilename, MAX_PATH, _T("%s"), (strConfigFileDir + tstring(wfd.cFileName)).c_str()); - - ::ZeroMemory(&mii, sizeof(MENUITEMINFO)); - mii.cbSize = sizeof(MENUITEMINFO); - mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE; - mii.fType = MFT_RADIOCHECK | MFT_STRING; - mii.wID = dwID++; - mii.dwTypeData = szFilename; - mii.cch = _tcslen(wfd.cFileName); - - if (_tcsicmp(szFilename, m_strConfigFile.c_str()) == 0) { - mii.fState = MFS_CHECKED; - } else { - mii.fState = MFS_UNCHECKED; - } - - ::InsertMenuItem(m_hConfigFilesMenu, dwID-ID_FIRST_XML_FILE, TRUE, &mii); - - bMoreFiles = ::FindNextFile(hWfd, &wfd); - } - - ::FindClose(hWfd); -#endif } ///////////////////////////////////////////////////////////////////////////// @@ -4229,29 +2619,6 @@ void Console::SendTextToConsole(const wchar_t *pszText) m_pCursor->SetState(c_state); } -#if 0 - HANDLE hStdIn = ::CreateFile(_T("CONIN$"), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0); - - DWORD dwTextLen = _tcslen(pszText); - DWORD dwTextWritten = 0; - - INPUT_RECORD* pKeyEvents = new INPUT_RECORD[dwTextLen]; - ::ZeroMemory(pKeyEvents, sizeof(INPUT_RECORD)*dwTextLen); - - for (DWORD i = 0; i < dwTextLen; ++i) { - pKeyEvents[i].EventType = KEY_EVENT; - pKeyEvents[i].Event.KeyEvent.bKeyDown = TRUE; - pKeyEvents[i].Event.KeyEvent.wRepeatCount = 1; - pKeyEvents[i].Event.KeyEvent.wVirtualKeyCode = 0; - pKeyEvents[i].Event.KeyEvent.wVirtualScanCode = 0; - pKeyEvents[i].Event.KeyEvent.uChar.UnicodeChar = pszText[i]; - pKeyEvents[i].Event.KeyEvent.dwControlKeyState = 0; - } - ::WriteConsoleInput(hStdIn, pKeyEvents, dwTextLen, &dwTextWritten); - - DEL_ARR(pKeyEvents); - ::CloseHandle(hStdIn); -#endif } ///////////////////////////////////////////////////////////////////////////// @@ -4293,42 +2660,6 @@ void Console::GetDesktopRect(RECT& rectDesktop) { rectDesktop.bottom = rectDesktop.top + ::GetSystemMetrics(SM_CYVIRTUALSCREEN); } -#if 0 -} else { - // we keep this for WinNT compatibility - - rectDesktop.left= 0; - rectDesktop.top = 0; - rectDesktop.right = ::GetSystemMetrics(SM_CXSCREEN); - rectDesktop.bottom = ::GetSystemMetrics(SM_CYSCREEN); - - RECT rectTaskbar = {0, 0, 0, 0}; - HWND hWndTaskbar = ::FindWindow(_T("Shell_TrayWnd"), _T("")); - - - if (hWndTaskbar) { - - ::GetWindowRect(hWndTaskbar, &rectTaskbar); - - if ((rectTaskbar.top <= rectDesktop.top) && (rectTaskbar.left <= rectDesktop.left) && (rectTaskbar.right >= rectDesktop.right)) { - // top taskbar - rectDesktop.top += rectTaskbar.bottom; - - } else if ((rectTaskbar.top > rectDesktop.top) && (rectTaskbar.left <= rectDesktop.left)) { - // bottom taskbar - rectDesktop.bottom = rectTaskbar.top; - - } else if ((rectTaskbar.top <= rectDesktop.top) && (rectTaskbar.left > rectDesktop.left)) { - // right taskbar - rectDesktop.right = rectTaskbar.left; - - } else { - // left taskbar - rectDesktop.left += rectTaskbar.right; - } - } - } -#endif } ///////////////////////////////////////////////////////////////////////////// @@ -4416,22 +2747,6 @@ LRESULT CALLBACK Console::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM myself->OnActivateApp((BOOL)wParam, (DWORD)lParam); return 0; -#if 0 - case WM_SYSKEYDOWN: - case WM_SYSKEYUP: - MSG msg; - - ::ZeroMemory(&msg, sizeof(MSG)); - - msg.hwnd = myself->m_hWnd; - msg.message = uMsg; - msg.wParam = wParam; - msg.lParam = lParam; - - ::TranslateMessage(&msg); - ::PostMessage(myself->m_hWndConsole, uMsg, wParam, lParam); - return 0; -#endif case WM_CHAR: myself->OnChar( (WORD) wParam); @@ -4459,11 +2774,6 @@ LRESULT CALLBACK Console::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM myself->OnCursorTimer(); return 0; -#if 0 - case TIMER_SHOW_HIDE_CONSOLE: - myself->ShowHideConsoleTimeout(); - return 0; -#endif default: return 1; @@ -4519,16 +2829,6 @@ DWORD Console::MonitorThread() { // HANDLE arrHandles[] = { m_hStdOut}; for (;;) { // Infinite loop -#if 0 - DWORD dwWait = ::WaitForMultipleObjects(1, arrHandles, FALSE, INFINITE); - - if (dwWait == WAIT_OBJECT_0) { - ::PostMessage(m_hWnd, WM_CLOSE, 0, 0); - break; - } else if (dwWait == WAIT_OBJECT_0 + 1) { - break; - } else if (dwWait == WAIT_OBJECT_0 + 2) { -#endif AddOutput(); ::SetTimer(m_hWnd, TIMER_REPAINT_CHANGE, m_dwChangeRepaintInt, NULL); // we sleep here for a while, to prevent 'flooding' of m_hStdOut events diff --git a/Console/Cursors.cpp b/Console/Cursors.cpp index a74bd1b59..56579caef 100644 --- a/Console/Cursors.cpp +++ b/Console/Cursors.cpp @@ -327,13 +327,7 @@ void ConsoleCursor::Draw(LPRECT pRect) { if (m_bActive && m_bVisible) { -#if 0 - CONSOLE_CURSOR_INFO csi; - ::GetConsoleCursorInfo(m_hStdOut, &csi); - rect.top += (rect.bottom - rect.top) * (100-csi.dwSize)/100; -#else rect.top += (rect.bottom - rect.top) * 80 / 100; -#endif ::FillRect(m_hdcWindow, &rect, m_hActiveBrush); } @@ -706,38 +700,6 @@ FadeBlockCursor::FadeBlockCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCurs { m_uiTimer = ::SetTimer(hwndParent, CURSOR_TIMER, 35, NULL); -#if 0 - if (g_bWin2000) { - // on Win2000 we use real alpha blending - - // create a reasonable-sized bitmap, since AlphaBlt resizes - // destination rect if needed, and we don't need to redraw the mem DC - // each time - m_nBmpWidth = BLEND_BMP_WIDTH; - m_nBmpHeight= BLEND_BMP_HEIGHT; - m_hMemDC = ::CreateCompatibleDC(hdcWindow); - m_hBmp = ::CreateCompatibleBitmap(hdcWindow, m_nBmpWidth, m_nBmpHeight); - m_hBmpOld = (HBITMAP)::SelectObject(m_hMemDC, m_hBmp); - - HBRUSH hBrush= ::CreateSolidBrush(m_crCursorColor); - RECT rect; - rect.left = 0; - rect.top = 0; - rect.right = m_nBmpWidth; - rect.bottom = m_nBmpHeight; - - ::FillRect(m_hMemDC, &rect, hBrush); - ::DeleteObject(hBrush); - - m_nStep = -ALPHA_STEP; - - m_bfn.BlendOp = AC_SRC_OVER; - m_bfn.BlendFlags = 0; - m_bfn.SourceConstantAlpha = 255; - m_bfn.AlphaFormat = 0; - - } else { -#endif FakeBlend(); // } } @@ -746,13 +708,6 @@ FadeBlockCursor::~FadeBlockCursor() { if (m_uiTimer) ::KillTimer(m_hwndParent, m_uiTimer); -#if 0 - if (g_bWin2000) { - ::SelectObject(m_hMemDC, m_hBmpOld); - ::DeleteObject(m_hBmp); - ::DeleteDC(m_hMemDC); - } -#endif } ///////////////////////////////////////////////////////////////////////////// @@ -762,24 +717,6 @@ FadeBlockCursor::~FadeBlockCursor() { void FadeBlockCursor::Draw(LPRECT pRect) { -#if 0 - if (g_bWin2000) { - - g_pfnAlphaBlend( - m_hdcWindow, - pRect->left, - pRect->top, - pRect->right - pRect->left, - pRect->bottom - pRect->top, - m_hMemDC, - 0, - 0, - BLEND_BMP_WIDTH, - BLEND_BMP_HEIGHT, - m_bfn); - - } else { -#endif HBRUSH hBrush = ::CreateSolidBrush(m_arrColors[m_nIndex]); ::FillRect(m_hdcWindow, pRect, hBrush); @@ -793,17 +730,6 @@ void FadeBlockCursor::Draw(LPRECT pRect) { ///////////////////////////////////////////////////////////////////////////// void FadeBlockCursor::PrepareNext() { -#if 0 - if (g_bWin2000){ - if (m_bfn.SourceConstantAlpha < ALPHA_STEP) { - m_nStep = ALPHA_STEP; - } else if ((DWORD)m_bfn.SourceConstantAlpha + ALPHA_STEP > 255) { - m_nStep = -ALPHA_STEP; - } - - m_bfn.SourceConstantAlpha += m_nStep; - } else { -#endif if (m_nIndex == 0) { m_nStep = 1; } else if (m_nIndex == (FADE_STEPS)) { diff --git a/Console/Cursors.h b/Console/Cursors.h index a7e916097..3a1f4c173 100644 --- a/Console/Cursors.h +++ b/Console/Cursors.h @@ -337,12 +337,6 @@ class FadeBlockCursor : public Cursor { HMODULE m_hUser32; BLENDFUNCTION m_bfn; HDC m_hMemDC; -#if 0 - HBITMAP m_hBmp; - HBITMAP m_hBmpOld; - int m_nBmpWidth; - int m_nBmpHeight; -#endif }; ///////////////////////////////////////////////////////////////////////////// diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt new file mode 100644 index 000000000..75bed682f --- /dev/null +++ b/Editor/CMakeLists.txt @@ -0,0 +1,27 @@ +set(EditorSrc +"${CMAKE_CURRENT_SOURCE_DIR}/Cursor Modes.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Editor Callbacks.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Editor Modes.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Editor Taskbar Creation.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Editor Taskbar Utils.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Editor Undo.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/EditorBuildings.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/EditorItems.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/EditorMapInfo.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/EditorMercs.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/EditorTerrain.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/editscreen.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/edit_sys.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Item Statistics.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/LoadScreen.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/messagebox.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/newsmooth.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/popupmenu.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Road Smoothing.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Sector Summary.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/selectwin.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/SmartMethod.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/smooth.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Smoothing Utils.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_ActionItems.cpp" +PARENT_SCOPE) diff --git a/Editor/Editor Callbacks.cpp b/Editor/Editor Callbacks.cpp index fd102ba7d..9590e7b48 100644 --- a/Editor/Editor Callbacks.cpp +++ b/Editor/Editor Callbacks.cpp @@ -791,27 +791,7 @@ void ItemsLeftScrollCallback(GUI_BUTTON *btn, INT32 reason) { if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP) { -#if 0//dnl ch80 011213 - gfRenderTaskbar = TRUE; - if (_KeyDown( 17 ) ) // CTRL - { - if (_KeyDown( 16 ) ) // SHIFT - eInfo.sScrollIndex = 0; - else - eInfo.sScrollIndex = __max(eInfo.sScrollIndex - 60, 0); - } - else if (_KeyDown( 16 ) ) // SHIFT - eInfo.sScrollIndex = __max(eInfo.sScrollIndex - 6, 0); - else - eInfo.sScrollIndex--; - - if( !eInfo.sScrollIndex ) - DisableButton( iEditorButton[ITEMS_LEFTSCROLL] ); - if( eInfo.sScrollIndex < ((eInfo.sNumItems+1)/2)-6 ) - EnableButton( iEditorButton[ITEMS_RIGHTSCROLL] ); -#else ScrollEditorItemsInfo(FALSE); -#endif } } @@ -819,26 +799,7 @@ void ItemsRightScrollCallback(GUI_BUTTON *btn, INT32 reason) { if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP) { -#if 0//dnl ch80 011213 - gfRenderTaskbar = TRUE; - if (_KeyDown( 17 ) ) // CTRL - { - if (_KeyDown( 16 ) ) // SHIFT - eInfo.sScrollIndex = max( ((eInfo.sNumItems+1)/2)-6, 0); - else - eInfo.sScrollIndex = __min(eInfo.sScrollIndex + 60, (eInfo.sNumItems+1)/2-6); - } - else if (_KeyDown( 16 ) ) // SHIFT - eInfo.sScrollIndex = __min(eInfo.sScrollIndex + 6, (eInfo.sNumItems+1)/2-6); - else - eInfo.sScrollIndex++; - - EnableButton( iEditorButton[ITEMS_LEFTSCROLL] ); - if( eInfo.sScrollIndex == max( ((eInfo.sNumItems+1)/2)-6, 0) ) - DisableButton( iEditorButton[ITEMS_RIGHTSCROLL] ); -#else ScrollEditorItemsInfo(TRUE); -#endif } } diff --git a/Editor/Editor Undo.cpp b/Editor/Editor Undo.cpp index 370f6e744..0d09d8b97 100644 --- a/Editor/Editor Undo.cpp +++ b/Editor/Editor Undo.cpp @@ -367,56 +367,6 @@ void CropStackToMaxLength( INT32 iMaxCmds ) } } -#if 0//dnl ch86 200214 -//We are adding a light to the undo list. We won't save the mapelement, nor will -//we validate the gridno in the binary tree. This works differently than a mapelement, -//because lights work on a different system. By setting the fLightSaved flag to TRUE, -//this will handle the way the undo command is handled. If there is no lightradius in -//our saved light, then we intend on erasing the light upon undo execution, otherwise, we -//save the light radius and light ID, so that we place it during undo execution. -void AddLightToUndoList( INT32 iMapIndex, INT32 iLightRadius, UINT8 ubLightID ) -{ - undo_stack *pNode; - undo_struct *pUndoInfo; - - if( !gfUndoEnabled ) - return; - //When executing an undo command (by adding a light or removing one), that command - //actually tries to add it to the undo list. So we wrap the execution of the undo - //command by temporarily setting this flag, so it'll ignore, and not place a new undo - //command. When finished, the flag is cleared, and lights are again allowed to be saved - //in the undo list. - if( gfIgnoreUndoCmdsForLights ) - return; - - pNode = (undo_stack*)MemAlloc( sizeof( undo_stack ) ); - if( !pNode ) - return; - - pUndoInfo = (undo_struct *)MemAlloc( sizeof( undo_struct ) ); - if( !pUndoInfo ) - { - MemFree( pNode ); - return; - } - - pUndoInfo->fLightSaved = TRUE; - //if ubLightRadius is 0, then we don't need to save the light information because we - //will erase it when it comes time to execute the undo command. - pUndoInfo->ubLightRadius = (UINT8)iLightRadius; - pUndoInfo->ubLightID = ubLightID; - pUndoInfo->iMapIndex = iMapIndex; - pUndoInfo->pMapTile = NULL; - - //Add to undo stack - pNode->iCmdCount = 1; - pNode->pData = pUndoInfo; - pNode->pNext = gpTileUndoStack; - gpTileUndoStack = pNode; - - CropStackToMaxLength( MAX_UNDO_COMMAND_LENGTH ); -} -#endif BOOLEAN AddToUndoList( INT32 iMapIndex ) { @@ -543,11 +493,7 @@ BOOLEAN AddToUndoListCmd( INT32 iMapIndex, INT32 iCmdCount ) { // this loop won't execute for single-tile structures; for multi-tile structures, we have to // add to the undo list all the other tiles covered by the structure -#if 0//dnl ch83 080114 - iCoveredMapIndex = pStructure->sBaseGridNo + pStructure->pDBStructureRef->ppTile[ubLoop]->sPosRelToBase; -#else iCoveredMapIndex = AddPosRelToBase(pStructure->sBaseGridNo, pStructure->pDBStructureRef->ppTile[ubLoop]); -#endif AddToUndoList( iCoveredMapIndex ); } pStructure = pStructure->pNext; @@ -575,19 +521,11 @@ void CheckMapIndexForMultiTileStructures( UINT32 usMapIndex ) // for multi-tile structures we have to add, to the undo list, all the other tiles covered by the structure if (pStructure->fFlags & STRUCTURE_BASE_TILE) { -#if 0//dnl ch83 080114 - iCoveredMapIndex = usMapIndex + pStructure->pDBStructureRef->ppTile[ubLoop]->sPosRelToBase; -#else iCoveredMapIndex = AddPosRelToBase(usMapIndex, pStructure->pDBStructureRef->ppTile[ubLoop]); -#endif } else { -#if 0//dnl ch83 080114 - iCoveredMapIndex = pStructure->sBaseGridNo + pStructure->pDBStructureRef->ppTile[ubLoop]->sPosRelToBase; -#else iCoveredMapIndex = AddPosRelToBase(pStructure->sBaseGridNo, pStructure->pDBStructureRef->ppTile[ubLoop]); -#endif } AddToUndoList( iCoveredMapIndex ); } @@ -636,26 +574,6 @@ BOOLEAN ExecuteUndoList( void ) while ( (iCurCount < iCmdCount) && (gpTileUndoStack != NULL) ) { iUndoMapIndex = gpTileUndoStack->pData->iMapIndex; -#if 0//dnl ch86 201214 - fExitGrid = ExitGridAtGridNo( iUndoMapIndex ); - - // Find which map tile we are to "undo" - if( gpTileUndoStack->pData->fLightSaved ) - { //We saved a light, so delete that light - INT16 sX, sY; - //Turn on this flag so that the following code, when executed, doesn't attempt to - //add lights to the undo list. That would cause problems... - gfIgnoreUndoCmdsForLights = TRUE; - ConvertGridNoToXY( iUndoMapIndex, &sX, &sY ); - if( !gpTileUndoStack->pData->ubLightRadius ) - RemoveLight( sX, sY ); - else - PlaceLight( gpTileUndoStack->pData->ubLightRadius, sX, sY, gpTileUndoStack->pData->ubLightID ); - //Turn off the flag so lights can again be added to the undo list. - gfIgnoreUndoCmdsForLights = FALSE; - } - else -#endif { // We execute the undo command node by simply swapping the contents // of the undo's MAP_ELEMENT with the world's element. SwapMapElementWithWorld( iUndoMapIndex, gpTileUndoStack->pData->pMapTile ); @@ -730,19 +648,8 @@ BOOLEAN ExecuteUndoList( void ) //an undo is called, the item is erased, but a cursor is added! I'm quickly //hacking around this by erasing all cursors here. RemoveAllTopmostsOfTypeRange( iUndoMapIndex, FIRSTPOINTERS, FIRSTPOINTERS ); -#if 0//dnl ch86 110214 - if( fExitGrid && !ExitGridAtGridNo( iUndoMapIndex ) ) - { //An exitgrid has been removed, so get rid of the associated indicator. - RemoveTopmost( iUndoMapIndex, FIRSTPOINTERS8 ); - } - else if( !fExitGrid && ExitGridAtGridNo( iUndoMapIndex ) ) - { //An exitgrid has been added, so add the associated indicator - AddTopmostToTail( iUndoMapIndex, FIRSTPOINTERS8 ); - } -#else if(gfShowExitGrids && fExitGrid) AddTopmostToTail(iUndoMapIndex, FIRSTPOINTERS8); -#endif } return( TRUE ); diff --git a/Editor/EditorBuildings.cpp b/Editor/EditorBuildings.cpp index 4f343c086..fd7f9c29c 100644 --- a/Editor/EditorBuildings.cpp +++ b/Editor/EditorBuildings.cpp @@ -366,44 +366,8 @@ void PasteMapElementToNewMapElement( INT32 iSrcGridNo, INT32 iDstGridNo ) AddTopmostToTail( iDstGridNo, pNode->usIndex ); pNode = pNode->pNext; } -#if 0//dnl ch86 110214 - for ( usType = FIRSTROOF; usType <= LASTSLANTROOF; usType++ ) - { - HideStructOfGivenType( iDstGridNo, usType, (BOOLEAN)(!fBuildingShowRoofs) ); - } -#endif } -#if 0//dnl ch86 220214 -void MoveBuilding( INT32 iMapIndex ) -{ - BUILDINGLAYOUTNODE *curr; - INT32 iOffset; - if( !gpBuildingLayoutList ) - return; - SortBuildingLayout( iMapIndex ); - iOffset = iMapIndex - gsBuildingLayoutAnchorGridNo; - if(iOffset == 0)//dnl ch32 080909 - return; - //First time, set the undo gridnos to everything effected. - curr = gpBuildingLayoutList; - while( curr ) - { - AddToUndoList( curr->sGridNo ); - AddToUndoList( curr->sGridNo + iOffset ); - curr = curr->next; - } - //Now, move the building - curr = gpBuildingLayoutList; - while( curr ) - { - PasteMapElementToNewMapElement( curr->sGridNo, curr->sGridNo + iOffset ); - DeleteStuffFromMapTile( curr->sGridNo ); - curr = curr->next; - } - MarkWorldDirty(); -} -#else void MoveBuilding( INT32 iMapIndex ) { INT8 bLightType; @@ -465,7 +429,6 @@ void MoveBuilding( INT32 iMapIndex ) MarkWorldDirty(); LightSpriteRenderAll(); } -#endif void PasteBuilding( INT32 iMapIndex ) { diff --git a/Editor/EditorItems.cpp b/Editor/EditorItems.cpp index bf756c031..b6c96847d 100644 --- a/Editor/EditorItems.cpp +++ b/Editor/EditorItems.cpp @@ -1032,16 +1032,10 @@ void DeleteSelectedItem() if( gpEditingItemPool == gpItemPool ) gpEditingItemPool = NULL; RemoveItemFromPool( sGridNo, gpItemPool->iItemIndex, 0 ); -#if 0//dnl ch86 220214 - gpItemPool = NULL; - //determine if there are still any items at this location - if( GetItemPoolFromGround( sGridNo, &gpItemPool ) ) -#else ITEM_POOL *pItemPoolOld = gpItemPool; GetItemPoolFromGround(sGridNo, &gpItemPool); UpdateItemPoolInUndoList(sGridNo, pItemPoolOld, gpItemPool); if(gpItemPool) -#endif { //reset display for remaining items SpecifyItemToEdit( &gWorldItems[ gpItemPool->iItemIndex ].object, gpItemPool->sGridNo ); } diff --git a/Editor/EditorMercs.h b/Editor/EditorMercs.h index 2f6c0eb6e..71e66ccdd 100644 --- a/Editor/EditorMercs.h +++ b/Editor/EditorMercs.h @@ -1,5 +1,281 @@ +#pragma once + #include "BuildDefines.h" +//----------------------------------------------- +// +// civilian "sub teams": +enum +{ + NON_CIV_GROUP = 0, + REBEL_CIV_GROUP, + KINGPIN_CIV_GROUP, + SANMONA_ARMS_GROUP, + ANGELS_GROUP, + BEGGARS_CIV_GROUP, + TOURISTS_CIV_GROUP, + ALMA_MILITARY_CIV_GROUP, + DOCTORS_CIV_GROUP, + COUPLE1_CIV_GROUP, + HICKS_CIV_GROUP, + WARDEN_CIV_GROUP, + JUNKYARD_CIV_GROUP, + FACTORY_KIDS_GROUP, + QUEENS_CIV_GROUP, + UNNAMED_CIV_GROUP_15, + UNNAMED_CIV_GROUP_16, + UNNAMED_CIV_GROUP_17, + UNNAMED_CIV_GROUP_18, + UNNAMED_CIV_GROUP_19, + ASSASSIN_CIV_GROUP, // Flugente: enemy assassins belong to this group + POW_PRISON_CIV_GROUP, // Flugente: prisoners of war the player caught are in this group + UNNAMED_CIV_GROUP_22, + UNNAMED_CIV_GROUP_23, + VOLUNTEER_CIV_GROUP, // Flugente: civilians that the player recruited + BOUNTYHUNTER_CIV_GROUP, // Flugente: hostile bounty hunters + DOWNEDPILOT_CIV_GROUP, // Flugente: downed pilots + SCIENTIST_GROUP, // Flugente: enemy civilian personnel + RADAR_TECHNICIAN_GROUP, + AIRPORT_STAFF_GROUP, + BARRACK_STAFF_GROUP, + FACTORY_GROUP, + ADMINISTRATIVE_STAFF_GROUP, + LOYAL_CIV_GROUP, // civil population deeply loyal to the queen + BLACKMARKET_GROUP, // black market dealer and bodyguards + UNNAMED_CIV_GROUP_35, + UNNAMED_CIV_GROUP_36, + UNNAMED_CIV_GROUP_37, + UNNAMED_CIV_GROUP_38, + UNNAMED_CIV_GROUP_39, + UNNAMED_CIV_GROUP_40, + UNNAMED_CIV_GROUP_41, + UNNAMED_CIV_GROUP_42, + UNNAMED_CIV_GROUP_43, + UNNAMED_CIV_GROUP_44, + UNNAMED_CIV_GROUP_45, + UNNAMED_CIV_GROUP_46, + UNNAMED_CIV_GROUP_47, + UNNAMED_CIV_GROUP_48, + UNNAMED_CIV_GROUP_49, + UNNAMED_CIV_GROUP_50, + UNNAMED_CIV_GROUP_51, + UNNAMED_CIV_GROUP_52, + UNNAMED_CIV_GROUP_53, + UNNAMED_CIV_GROUP_54, + UNNAMED_CIV_GROUP_55, + UNNAMED_CIV_GROUP_56, + UNNAMED_CIV_GROUP_57, + UNNAMED_CIV_GROUP_58, + UNNAMED_CIV_GROUP_59, + UNNAMED_CIV_GROUP_60, + UNNAMED_CIV_GROUP_61, + UNNAMED_CIV_GROUP_62, + UNNAMED_CIV_GROUP_63, + UNNAMED_CIV_GROUP_64, + UNNAMED_CIV_GROUP_65, + UNNAMED_CIV_GROUP_66, + UNNAMED_CIV_GROUP_67, + UNNAMED_CIV_GROUP_68, + UNNAMED_CIV_GROUP_69, + UNNAMED_CIV_GROUP_70, + UNNAMED_CIV_GROUP_71, + UNNAMED_CIV_GROUP_72, + UNNAMED_CIV_GROUP_73, + UNNAMED_CIV_GROUP_74, + UNNAMED_CIV_GROUP_75, + UNNAMED_CIV_GROUP_76, + UNNAMED_CIV_GROUP_77, + UNNAMED_CIV_GROUP_78, + UNNAMED_CIV_GROUP_79, + UNNAMED_CIV_GROUP_80, + UNNAMED_CIV_GROUP_81, + UNNAMED_CIV_GROUP_82, + UNNAMED_CIV_GROUP_83, + UNNAMED_CIV_GROUP_84, + UNNAMED_CIV_GROUP_85, + UNNAMED_CIV_GROUP_86, + UNNAMED_CIV_GROUP_87, + UNNAMED_CIV_GROUP_88, + UNNAMED_CIV_GROUP_89, + UNNAMED_CIV_GROUP_90, + UNNAMED_CIV_GROUP_91, + UNNAMED_CIV_GROUP_92, + UNNAMED_CIV_GROUP_93, + UNNAMED_CIV_GROUP_94, + UNNAMED_CIV_GROUP_95, + UNNAMED_CIV_GROUP_96, + UNNAMED_CIV_GROUP_97, + UNNAMED_CIV_GROUP_98, + UNNAMED_CIV_GROUP_99, + UNNAMED_CIV_GROUP_100, + UNNAMED_CIV_GROUP_101, + UNNAMED_CIV_GROUP_102, + UNNAMED_CIV_GROUP_103, + UNNAMED_CIV_GROUP_104, + UNNAMED_CIV_GROUP_105, + UNNAMED_CIV_GROUP_106, + UNNAMED_CIV_GROUP_107, + UNNAMED_CIV_GROUP_108, + UNNAMED_CIV_GROUP_109, + UNNAMED_CIV_GROUP_110, + UNNAMED_CIV_GROUP_111, + UNNAMED_CIV_GROUP_112, + UNNAMED_CIV_GROUP_113, + UNNAMED_CIV_GROUP_114, + UNNAMED_CIV_GROUP_115, + UNNAMED_CIV_GROUP_116, + UNNAMED_CIV_GROUP_117, + UNNAMED_CIV_GROUP_118, + UNNAMED_CIV_GROUP_119, + UNNAMED_CIV_GROUP_120, + UNNAMED_CIV_GROUP_121, + UNNAMED_CIV_GROUP_122, + UNNAMED_CIV_GROUP_123, + UNNAMED_CIV_GROUP_124, + UNNAMED_CIV_GROUP_125, + UNNAMED_CIV_GROUP_126, + UNNAMED_CIV_GROUP_127, + UNNAMED_CIV_GROUP_128, + UNNAMED_CIV_GROUP_129, + UNNAMED_CIV_GROUP_130, + UNNAMED_CIV_GROUP_131, + UNNAMED_CIV_GROUP_132, + UNNAMED_CIV_GROUP_133, + UNNAMED_CIV_GROUP_134, + UNNAMED_CIV_GROUP_135, + UNNAMED_CIV_GROUP_136, + UNNAMED_CIV_GROUP_137, + UNNAMED_CIV_GROUP_138, + UNNAMED_CIV_GROUP_139, + UNNAMED_CIV_GROUP_140, + + UNNAMED_CIV_GROUP_141, + UNNAMED_CIV_GROUP_142, + UNNAMED_CIV_GROUP_143, + UNNAMED_CIV_GROUP_144, + UNNAMED_CIV_GROUP_145, + UNNAMED_CIV_GROUP_146, + UNNAMED_CIV_GROUP_147, + UNNAMED_CIV_GROUP_148, + UNNAMED_CIV_GROUP_149, + UNNAMED_CIV_GROUP_150, + UNNAMED_CIV_GROUP_151, + UNNAMED_CIV_GROUP_152, + UNNAMED_CIV_GROUP_153, + UNNAMED_CIV_GROUP_154, + UNNAMED_CIV_GROUP_155, + UNNAMED_CIV_GROUP_156, + UNNAMED_CIV_GROUP_157, + UNNAMED_CIV_GROUP_158, + UNNAMED_CIV_GROUP_159, + UNNAMED_CIV_GROUP_160, + UNNAMED_CIV_GROUP_161, + UNNAMED_CIV_GROUP_162, + UNNAMED_CIV_GROUP_163, + UNNAMED_CIV_GROUP_164, + UNNAMED_CIV_GROUP_165, + UNNAMED_CIV_GROUP_166, + UNNAMED_CIV_GROUP_167, + UNNAMED_CIV_GROUP_168, + UNNAMED_CIV_GROUP_169, + UNNAMED_CIV_GROUP_170, + + UNNAMED_CIV_GROUP_171, + UNNAMED_CIV_GROUP_172, + UNNAMED_CIV_GROUP_173, + UNNAMED_CIV_GROUP_174, + UNNAMED_CIV_GROUP_175, + UNNAMED_CIV_GROUP_176, + UNNAMED_CIV_GROUP_177, + UNNAMED_CIV_GROUP_178, + UNNAMED_CIV_GROUP_179, + UNNAMED_CIV_GROUP_180, + UNNAMED_CIV_GROUP_181, + UNNAMED_CIV_GROUP_182, + UNNAMED_CIV_GROUP_183, + UNNAMED_CIV_GROUP_184, + UNNAMED_CIV_GROUP_185, + UNNAMED_CIV_GROUP_186, + UNNAMED_CIV_GROUP_187, + UNNAMED_CIV_GROUP_188, + UNNAMED_CIV_GROUP_189, + UNNAMED_CIV_GROUP_190, + UNNAMED_CIV_GROUP_191, + UNNAMED_CIV_GROUP_192, + UNNAMED_CIV_GROUP_193, + UNNAMED_CIV_GROUP_194, + UNNAMED_CIV_GROUP_195, + UNNAMED_CIV_GROUP_196, + UNNAMED_CIV_GROUP_197, + UNNAMED_CIV_GROUP_198, + UNNAMED_CIV_GROUP_199, + UNNAMED_CIV_GROUP_200, + + UNNAMED_CIV_GROUP_201, + UNNAMED_CIV_GROUP_202, + UNNAMED_CIV_GROUP_203, + UNNAMED_CIV_GROUP_204, + UNNAMED_CIV_GROUP_205, + UNNAMED_CIV_GROUP_206, + UNNAMED_CIV_GROUP_207, + UNNAMED_CIV_GROUP_208, + UNNAMED_CIV_GROUP_209, + UNNAMED_CIV_GROUP_210, + UNNAMED_CIV_GROUP_211, + UNNAMED_CIV_GROUP_212, + UNNAMED_CIV_GROUP_213, + UNNAMED_CIV_GROUP_214, + UNNAMED_CIV_GROUP_215, + UNNAMED_CIV_GROUP_216, + UNNAMED_CIV_GROUP_217, + UNNAMED_CIV_GROUP_218, + UNNAMED_CIV_GROUP_219, + UNNAMED_CIV_GROUP_220, + UNNAMED_CIV_GROUP_221, + UNNAMED_CIV_GROUP_222, + UNNAMED_CIV_GROUP_223, + UNNAMED_CIV_GROUP_224, + UNNAMED_CIV_GROUP_225, + UNNAMED_CIV_GROUP_226, + UNNAMED_CIV_GROUP_227, + UNNAMED_CIV_GROUP_228, + UNNAMED_CIV_GROUP_229, + UNNAMED_CIV_GROUP_230, + + UNNAMED_CIV_GROUP_231, + UNNAMED_CIV_GROUP_232, + UNNAMED_CIV_GROUP_233, + UNNAMED_CIV_GROUP_234, + UNNAMED_CIV_GROUP_235, + UNNAMED_CIV_GROUP_236, + UNNAMED_CIV_GROUP_237, + UNNAMED_CIV_GROUP_238, + UNNAMED_CIV_GROUP_239, + UNNAMED_CIV_GROUP_240, + UNNAMED_CIV_GROUP_241, + UNNAMED_CIV_GROUP_242, + UNNAMED_CIV_GROUP_243, + UNNAMED_CIV_GROUP_244, + UNNAMED_CIV_GROUP_245, + UNNAMED_CIV_GROUP_246, + UNNAMED_CIV_GROUP_247, + UNNAMED_CIV_GROUP_248, + UNNAMED_CIV_GROUP_249, + UNNAMED_CIV_GROUP_250, + + UNNAMED_CIV_GROUP_251, + UNNAMED_CIV_GROUP_252, + UNNAMED_CIV_GROUP_253, + UNNAMED_CIV_GROUP_254, + NUM_CIV_GROUPS +}; + +#define CIV_GROUP_NEUTRAL 0 +#define CIV_GROUP_WILL_EVENTUALLY_BECOME_HOSTILE 1 +#define CIV_GROUP_WILL_BECOME_HOSTILE 2 +#define CIV_GROUP_HOSTILE 3 + + #ifdef JA2EDITOR #ifndef __EDITORMERCS_H @@ -110,6 +386,13 @@ void HandleMercInventoryPanel( INT16 sX, INT16 sY, INT8 bEvent ); extern UINT16 gusMercsNewItemIndex; extern BOOLEAN gfRenderMercInfo; +//NOTE: The editor uses these enumerations, so please update the text as well if you modify or +// add new groups. Try to abbreviate the team name as much as possible. The text is in +// EditorMercs.c +extern CHAR16 gszCivGroupNames[ NUM_CIV_GROUPS ][ 128 ]; +// +//----------------------------------------------- + void ChangeCivGroup( UINT8 ubNewCivGroup ); #define MERCINV_LGSLOT_WIDTH 48 diff --git a/Editor/LoadScreen.cpp b/Editor/LoadScreen.cpp index 2e0ce9672..81a9e0248 100644 --- a/Editor/LoadScreen.cpp +++ b/Editor/LoadScreen.cpp @@ -562,7 +562,7 @@ void CreateFileDialog( STR16 zTitle ) //File list window iFileDlgButtons[4] = CreateHotSpot( (iScreenWidthOffset + 179+4), (iScreenHeightOffset + 69+3), (179+4+240), (69+120+3), MSYS_PRIORITY_HIGH-1, BUTTON_NO_CALLBACK, FDlgNamesCallback); //Title button - iFileDlgButtons[5] = CreateTextButton(zTitle, HUGEFONT, FONT_LTKHAKI, FONT_DKKHAKI, + iFileDlgButtons[5] = CreateTextButton(zTitle, GetHugeFont(), FONT_LTKHAKI, FONT_DKKHAKI, BUTTON_USE_DEFAULT,iScreenWidthOffset + 179, iScreenHeightOffset + 39,281,30,BUTTON_NO_TOGGLE, MSYS_PRIORITY_HIGH-2,BUTTON_NO_CALLBACK,BUTTON_NO_CALLBACK); DisableButton(iFileDlgButtons[5]); @@ -1013,7 +1013,7 @@ UINT32 ProcessFileIO() case INITIATE_MAP_SAVE: //draw save message StartFrameBufferRender( ); SaveFontSettings(); - SetFont( HUGEFONT ); + SetFont( GetHugeFont() ); SetFontForeground( FONT_LTKHAKI ); SetFontShadow( FONT_DKKHAKI ); SetFontBackground( 0 ); diff --git a/Editor/Sector Summary.cpp b/Editor/Sector Summary.cpp index 6f1645fc8..aa4865524 100644 --- a/Editor/Sector Summary.cpp +++ b/Editor/Sector Summary.cpp @@ -239,11 +239,6 @@ enum{ SUMMARY_LOAD, SUMMARY_SAVE, SUMMARY_OVERRIDE, -#if 0 - SUMMARY_NEW_GROUNDLEVEL, - SUMMARY_NEW_BASEMENTLEVEL, - SUMMARY_NEW_CAVELEVEL, -#endif SUMMARY_UPDATE, SUMMARY_SCIFI, SUMMARY_REAL, @@ -351,17 +346,6 @@ void CreateSummaryWindow() CreateCheckBoxButton( ( INT16 ) ( MAP_LEFT + 110 ), ( INT16 ) ( MAP_BOTTOM + 59 ), "EDITOR\\smcheckbox.sti", MSYS_PRIORITY_HIGH, SummaryOverrideCallback ); -#if 0 - iSummaryButton[ SUMMARY_NEW_GROUNDLEVEL ] = - CreateSimpleButton( MAP_LEFT, MAP_BOTTOM+58, "EDITOR\\new.sti", BUTTON_NO_TOGGLE, MSYS_PRIORITY_HIGH, SummaryNewGroundLevelCallback ); - SetButtonFastHelpText( iSummaryButton[ SUMMARY_NEW_GROUNDLEVEL ], L"New map" ); - iSummaryButton[ SUMMARY_NEW_BASEMENTLEVEL ] = - CreateSimpleButton( MAP_LEFT+32, MAP_BOTTOM+58, "EDITOR\\new.sti", BUTTON_NO_TOGGLE, MSYS_PRIORITY_HIGH, SummaryNewBasementLevelCallback ); - SetButtonFastHelpText( iSummaryButton[ SUMMARY_NEW_BASEMENTLEVEL ], L"New basement" ); - iSummaryButton[ SUMMARY_NEW_CAVELEVEL ] = - CreateSimpleButton( MAP_LEFT+64, MAP_BOTTOM+58, "EDITOR\\new.sti", BUTTON_NO_TOGGLE, MSYS_PRIORITY_HIGH, SummaryNewCaveLevelCallback ); - SetButtonFastHelpText( iSummaryButton[ SUMMARY_NEW_CAVELEVEL ], L"New cave level" ); -#endif iSummaryButton[ SUMMARY_UPDATE ] = @@ -1824,28 +1808,6 @@ void SummaryToggleProgressCallback( GUI_BUTTON *btn, INT32 reason ) #include "Tile Surface.h" -void PerformTest() -{ -#if 0 - OutputDebugString( "PERFORMING A NEW TEST -------------------------------------------------\n" ); - memset( gbDefaultSurfaceUsed, 0, sizeof( gbDefaultSurfaceUsed ) ); - giCurrentTilesetID = -1; - switch( Random( 3 ) ) - { - case 0: - LoadWorld( "J9.dat" ); - break; - case 1: - LoadWorld( "J9_b1.dat" ); - break; - case 2: - LoadWorld( "J9_b2.dat" ); - break; - } -#endif -} - - BOOLEAN HandleSummaryInput( InputAtom *pEvent ) { if( !gfSummaryWindowActive ) @@ -1871,17 +1833,6 @@ BOOLEAN HandleSummaryInput( InputAtom *pEvent ) else if( gfWorldLoaded ) DestroySummaryWindow(); break; - case F6: - PerformTest(); - break; - case F7: - for( x = 0; x < 10; x++ ) - PerformTest(); - break; - case F8: - for( x = 0; x < 100; x++ ) - PerformTest(); - break; case 'y':case 'Y': if( gusNumEntriesWithOutdatedOrNoSummaryInfo && !gfOutdatedDenied ) { @@ -3029,16 +2980,6 @@ void SummaryUpdateCallback( GUI_BUTTON *btn, INT32 reason ) SetProgressBarTitle( 0, pSummaryUpdateCallbackText[0], BLOCKFONT2, FONT_RED, FONT_NEARBLACK ); SetProgressBarMsgAttributes( 0, SMALLCOMPFONT, FONT_BLACK, FONT_BLACK ); -#if 0 - // 0verhaul: This should NOT be freed. An array index can be freed when it is recalculated, - // as this function is about to do. And then it SHOULD be freed first, which it wasn't doing. - // Either way, using this pointer is not a safe way to free the current sector's summary data. - if( gpCurrentSectorSummary ) - { - MemFree( gpCurrentSectorSummary ); - gpCurrentSectorSummary = NULL; - } -#endif sprintf( str, "%c%d", gsSelSectorY + 'A' - 1, gsSelSectorX ); EvaluateWorld( str, (UINT8)giCurrLevel ); @@ -3134,11 +3075,11 @@ void ApologizeOverrideAndForceUpdateEverything() //Draw it DrawButton( iSummaryButton[ SUMMARY_BACKGROUND ] ); InvalidateRegion( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); - SetFont( HUGEFONT ); + SetFont( GetHugeFont() ); SetFontForeground( FONT_RED ); SetFontShadow( FONT_NEARBLACK ); swprintf( str, pApologizeOverrideAndForceUpdateEverythingText[0] ); - mprintf( (iScreenWidthOffset + 320) - StringPixLength( str, HUGEFONT )/2, iScreenHeightOffset + 105, str ); + mprintf( (iScreenWidthOffset + 320) - StringPixLength( str, GetHugeFont() )/2, iScreenHeightOffset + 105, str ); SetFont( FONT10ARIAL ); SetFontForeground( FONT_YELLOW ); swprintf( str, pApologizeOverrideAndForceUpdateEverythingText[1], gusNumberOfMapsToBeForceUpdated ); @@ -3252,220 +3193,6 @@ void ApologizeOverrideAndForceUpdateEverything() gusNumberOfMapsToBeForceUpdated = 0; } -#if 0//dnl ch81 041213 this function is screwed up so decide to rewrite it -//CHRISL: ADB changed the way this load file is handled -extern int gEnemyPreservedTempFileVersion[256]; -extern int gCivPreservedTempFileVersion[256]; -void SetupItemDetailsMode( BOOLEAN fAllowRecursion ) -{ - HWFILE hfile; - UINT32 uiNumBytesRead; - UINT32 uiNumItems; - CHAR8 szFilename[40]; - BASIC_SOLDIERCREATE_STRUCT basic; - SOLDIERCREATE_STRUCT priority; - INT32 i, j; - UINT16 usNumItems; - OBJECTTYPE *pItem; - UINT16 usPEnemyIndex, usNEnemyIndex; - - SUMMARYFILE *s = gpCurrentSectorSummary; - MAPCREATE_STRUCT *m = &gpCurrentSectorSummary->MapInfo; - - //Clear memory for all the item summaries loaded - if( gpWorldItemsSummaryArray ) - { - delete[]( gpWorldItemsSummaryArray ); - gpWorldItemsSummaryArray = NULL; - gusWorldItemsSummaryArraySize = 0; - } - if( gpPEnemyItemsSummaryArray ) - { - delete[]( gpPEnemyItemsSummaryArray ); - gpPEnemyItemsSummaryArray = NULL; - gusPEnemyItemsSummaryArraySize = 0; - } - if( gpNEnemyItemsSummaryArray ) - { - delete[]( gpNEnemyItemsSummaryArray ); - gpNEnemyItemsSummaryArray = NULL; - gusNEnemyItemsSummaryArraySize = 0; - } - - if( !gpCurrentSectorSummary->uiNumItemsPosition ) - { //Don't have one, so generate them - if( gpCurrentSectorSummary->ubSummaryVersion == GLOBAL_SUMMARY_VERSION ) - gusNumEntriesWithOutdatedOrNoSummaryInfo++; - SummaryUpdateCallback( ButtonList[ iSummaryButton[ SUMMARY_UPDATE ] ], MSYS_CALLBACK_REASON_LBUTTON_UP ); - } - //Open the original map for the sector - sprintf( szFilename, "MAPS\\%S", gszFilename ); - hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - if( !hfile ) - { //The file couldn't be found! - return; - } - // ADB: The uiNumItemsPosition may be 0 here due to the recursion further down. - // If so, skip the read - uiNumItems = 0; - if (gpCurrentSectorSummary->uiNumItemsPosition) - { - //Now fileseek directly to the file position where the number of world items are stored - if( !FileSeek( hfile, gpCurrentSectorSummary->uiNumItemsPosition, FILE_SEEK_FROM_START ) ) - { //Position couldn't be found! - FileClose( hfile ); - return; - } - //Now load the number of world items from the map. - FileRead( hfile, &uiNumItems, 4, &uiNumBytesRead ); - if( uiNumBytesRead != 4 ) - { //Invalid situation. - FileClose( hfile ); - return; - } - } - - //Now compare this number with the number the summary thinks we should have. If they are different, - //then the summary doesn't match the map. What we will do is force regenerate the map so that they do - //match - if( uiNumItems != gpCurrentSectorSummary->usNumItems && fAllowRecursion ) - { - FileClose( hfile ); - gpCurrentSectorSummary->uiNumItemsPosition = 0; - SetupItemDetailsMode( FALSE ); - return; - } - //Passed the gauntlet, so now allocate memory for it, and load all the world items into this array. - ShowButton( iSummaryButton[ SUMMARY_SCIFI ] ); - ShowButton( iSummaryButton[ SUMMARY_REAL ] ); - ShowButton( iSummaryButton[ SUMMARY_ENEMY ] ); - gpWorldItemsSummaryArray = new WORLDITEM[ uiNumItems ]; - gusWorldItemsSummaryArraySize = gpCurrentSectorSummary->usNumItems; - for (unsigned int x = 0; x < uiNumItems; ++x) - { - gpWorldItemsSummaryArray[x].Load(hfile, s->dMajorMapVersion, m->ubMapVersion); - } - - //NOW, do the enemy's items! - //We need to do two passes. The first pass simply processes all the enemies and counts all the droppable items - //keeping track of two different values. The first value is the number of droppable items that come off of - //enemy detailed placements, the other counter keeps track of the number of droppable items that come off of - //normal enemy placements. After doing this, the memory is allocated for the tables that will store all the item - //summary information, then the second pass will repeat the process, except it will record the actual items. - - //PASS #1 - if( !FileSeek( hfile, gpCurrentSectorSummary->uiEnemyPlacementPosition, FILE_SEEK_FROM_START ) ) - { //Position couldn't be found! - FileClose( hfile ); - return; - } - for( i = 0; i < gpCurrentSectorSummary->MapInfo.ubNumIndividuals ; i++ ) - { - FileRead( hfile, &basic, sizeof( BASIC_SOLDIERCREATE_STRUCT ), &uiNumBytesRead ); - if( uiNumBytesRead != sizeof( BASIC_SOLDIERCREATE_STRUCT ) ) - { //Invalid situation. - FileClose( hfile ); - return; - } - if( basic.fDetailedPlacement ) - { //skip static priority placement - if ( !priority.Load(hfile, SAVE_GAME_VERSION, false) ) - { //Invalid situation. - FileClose( hfile ); - return; - } - } - else - { //non detailed placements don't have items, so skip - continue; - } - if( basic.bTeam == ENEMY_TEAM ) - { - //Count the items that this enemy placement drops - usNumItems = 0; - for( j = 0; j < 9; j++ ) - { - pItem = &priority.Inv[ gbMercSlotTypes[ j ] ]; - if( pItem->exists() == true && !( (*pItem).fFlags & OBJECT_UNDROPPABLE ) ) - { - usNumItems++; - } - } - if( basic.fPriorityExistance ) - { - gusPEnemyItemsSummaryArraySize += usNumItems; - } - else - { - gusNEnemyItemsSummaryArraySize += usNumItems; - } - } - } - - //Pass 1 completed, so now allocate enough space to hold all the items - if( gusPEnemyItemsSummaryArraySize ) - { - gpPEnemyItemsSummaryArray = new OBJECTTYPE[ gusPEnemyItemsSummaryArraySize ]; - } - if( gusNEnemyItemsSummaryArraySize ) - { - gpNEnemyItemsSummaryArray = new OBJECTTYPE[ gusNEnemyItemsSummaryArraySize ]; - } - - //PASS #2 - //During this pass, simply copy all the data instead of counting it, now that we have already done so. - usPEnemyIndex = usNEnemyIndex = 0; - if( !FileSeek( hfile, gpCurrentSectorSummary->uiEnemyPlacementPosition, FILE_SEEK_FROM_START ) ) - { //Position couldn't be found! - FileClose( hfile ); - return; - } - for( i = 0; i < gpCurrentSectorSummary->MapInfo.ubNumIndividuals ; i++ ) - { - FileRead( hfile, &basic, sizeof( BASIC_SOLDIERCREATE_STRUCT ), &uiNumBytesRead ); - if( uiNumBytesRead != sizeof( BASIC_SOLDIERCREATE_STRUCT ) ) - { //Invalid situation. - FileClose( hfile ); - return; - } - if( basic.fDetailedPlacement ) - { //skip static priority placement - if ( !priority.Load(hfile, SAVE_GAME_VERSION, false) ) - { //Invalid situation. - FileClose( hfile ); - return; - } - } - else - { //non detailed placements don't have items, so skip - continue; - } - if( basic.bTeam == ENEMY_TEAM ) - { - //Copy the items that this enemy placement drops - usNumItems = 0; - for( j = 0; j < 9; j++ ) - { - pItem = &priority.Inv[ gbMercSlotTypes[ j ] ]; - if( pItem->exists() == true && !( (*pItem).fFlags & OBJECT_UNDROPPABLE ) ) - { - if( basic.fPriorityExistance ) - { - gpPEnemyItemsSummaryArray[ usPEnemyIndex ] = *pItem; - usPEnemyIndex++; - } - else - { - gpNEnemyItemsSummaryArray[ usNEnemyIndex ] = *pItem; - usNEnemyIndex++; - } - } - } - } - } - FileClose( hfile ); -} -#else void SetupItemDetailsMode(BOOLEAN fAllowRecursion) { UINT32 uiNumItems, uiFileSize, uiBytesRead; @@ -3630,7 +3357,6 @@ L01: } } } -#endif UINT8 GetCurrentSummaryVersion() { diff --git a/Editor/editscreen.cpp b/Editor/editscreen.cpp index beebb1086..a62be1e59 100644 --- a/Editor/editscreen.cpp +++ b/Editor/editscreen.cpp @@ -505,8 +505,6 @@ BOOLEAN EditModeShutdown( void ) RemoveLightPositionHandles( ); - MapOptimize(); - RemoveCursors(); fHelpScreen = FALSE; @@ -2090,22 +2088,7 @@ void HandleKeyboardShortcuts( ) // item left scroll if( iCurrentTaskbar == TASK_ITEMS || gubCurrMercMode == MERC_GETITEMMODE ) { -#if 0//dnl ch80 011213 - if( eInfo.sScrollIndex ) - { - if( EditorInputEvent.usKeyState & CTRL_DOWN ) - eInfo.sScrollIndex = __max(eInfo.sScrollIndex - 60, 0); - else - eInfo.sScrollIndex--; - - if( !eInfo.sScrollIndex ) - DisableButton( iEditorButton[ITEMS_LEFTSCROLL] ); - if( eInfo.sScrollIndex < ((eInfo.sNumItems+1)/2)-6 ) - EnableButton( iEditorButton[ITEMS_RIGHTSCROLL] ); - } -#else ScrollEditorItemsInfo(FALSE); -#endif } else { @@ -2120,21 +2103,7 @@ void HandleKeyboardShortcuts( ) // item right scroll if( iCurrentTaskbar == TASK_ITEMS || gubCurrMercMode == MERC_GETITEMMODE ) { -#if 0//dnl ch80 011213 - if( eInfo.sScrollIndex < max( ((eInfo.sNumItems+1)/2)-6, 0) ) - { - if( EditorInputEvent.usKeyState & CTRL_DOWN ) - eInfo.sScrollIndex = __min(eInfo.sScrollIndex + 60, (eInfo.sNumItems+1)/2-6); - else - eInfo.sScrollIndex++; - - EnableButton( iEditorButton[ITEMS_LEFTSCROLL] ); - if( eInfo.sScrollIndex == max( ((eInfo.sNumItems+1)/2)-6, 0) ) - DisableButton( iEditorButton[ITEMS_RIGHTSCROLL] ); - } -#else ScrollEditorItemsInfo(TRUE); -#endif } else { @@ -2149,22 +2118,7 @@ void HandleKeyboardShortcuts( ) // item left scroll by page if( iCurrentTaskbar == TASK_ITEMS || gubCurrMercMode == MERC_GETITEMMODE ) { -#if 0//dnl ch80 011213 - if( eInfo.sScrollIndex ) - { - if( EditorInputEvent.usKeyState & CTRL_DOWN ) - eInfo.sScrollIndex = 0; - else - eInfo.sScrollIndex = __max(eInfo.sScrollIndex - 6, 0); - - if( !eInfo.sScrollIndex ) - DisableButton( iEditorButton[ITEMS_LEFTSCROLL] ); - if( eInfo.sScrollIndex < ((eInfo.sNumItems+1)/2)-6 ) - EnableButton( iEditorButton[ITEMS_RIGHTSCROLL] ); - } -#else ScrollEditorItemsInfo(FALSE); -#endif } //gfRenderTaskbar = TRUE; break; @@ -2172,21 +2126,7 @@ void HandleKeyboardShortcuts( ) // item right scroll by page if( iCurrentTaskbar == TASK_ITEMS || gubCurrMercMode == MERC_GETITEMMODE ) { -#if 0//dnl ch80 011213 - if( eInfo.sScrollIndex < max( ((eInfo.sNumItems+1)/2)-6, 0) ) - { - if( EditorInputEvent.usKeyState & CTRL_DOWN ) - eInfo.sScrollIndex = max( ((eInfo.sNumItems+1)/2)-6, 0); - else - eInfo.sScrollIndex = __min(eInfo.sScrollIndex + 6, (eInfo.sNumItems+1)/2-6); - - EnableButton( iEditorButton[ITEMS_LEFTSCROLL] ); - if( eInfo.sScrollIndex == max( ((eInfo.sNumItems+1)/2)-6, 0) ) - DisableButton( iEditorButton[ITEMS_RIGHTSCROLL] ); - } -#else ScrollEditorItemsInfo(TRUE); -#endif } //gfRenderTaskbar = TRUE; break; @@ -3264,65 +3204,6 @@ BOOLEAN PlaceLight( INT16 sRadius, INT16 iMapX, INT16 iMapY, INT16 sType, INT8 b // Returns TRUE if deleted the light, otherwise, returns FALSE. // i.e. FALSE is not an error condition! // -#if 0//dnl ch86 210214 -BOOLEAN RemoveLight( INT16 iMapX, INT16 iMapY ) -{ - INT32 iCount; - UINT16 cnt; - SOLDIERTYPE *pSoldier; - BOOLEAN fSoldierLight; - BOOLEAN fRemovedLight; - INT32 iMapIndex = 0; - UINT32 uiLastLightType = 0; - UINT8 *pLastLightName = NULL; - - fRemovedLight = FALSE; - - // Check all lights if any at this given position - for(iCount=0; iCount < MAX_LIGHT_SPRITES; iCount++) - { - if(LightSprites[iCount].uiFlags & LIGHT_SPR_ACTIVE) - { - if ( LightSprites[iCount].iX == iMapX && LightSprites[iCount].iY == iMapY ) - { - // Found a light, so let's see if it belong to a merc! - fSoldierLight = FALSE; - for ( cnt = 0; cnt < MAX_NUM_SOLDIERS && !fSoldierLight; cnt++ ) - { - if ( GetSoldier( &pSoldier, cnt ) ) - { - if ( pSoldier->iLight == iCount ) - fSoldierLight = TRUE; - } - } - - if ( !fSoldierLight ) - { - // Ok, it's not a merc's light so kill it! - pLastLightName = (UINT8 *) LightSpriteGetTypeName( iCount ); - uiLastLightType = LightSprites[iCount].uiLightType; - LightSpritePower( iCount, FALSE ); - LightSpriteDestroy( iCount ); - fRemovedLight = TRUE; - iMapIndex = ((INT32)iMapY * WORLD_COLS) + (INT32)iMapX; - RemoveAllObjectsOfTypeRange( iMapIndex, GOODRING, GOODRING ); - } - } - } - } - if( fRemovedLight ) - { - UINT16 usRadius; - //Assuming that the light naming convention doesn't change, then this following conversion - //should work. Basically, the radius values aren't stored in the lights, so I have pull - //the radius out of the filename. Ex: L-RO5.LHT - usRadius = pLastLightName[4] - 0x30; - AddLightToUndoList( iMapIndex, usRadius, (UINT8)uiLastLightType ); - } - - return( fRemovedLight ); -} -#else BOOLEAN RemoveLight(INT16 iMapX, INT16 iMapY, INT8 bLightType) { INT32 iCount, iMapIndex; @@ -3340,7 +3221,6 @@ BOOLEAN RemoveLight(INT16 iMapX, INT16 iMapY, INT8 bLightType) RemoveAllObjectsOfTypeRange(iMapIndex, GOODRING, GOODRING); return(fRemovedLight); } -#endif //---------------------------------------------------------------------------------------------- // ShowLightPositionHandles @@ -3459,97 +3339,6 @@ BOOLEAN CheckForSlantRoofs( void ) -//---------------------------------------------------------------------------------------------- -// MapOptimize -// -// Runs through all map locations, and if it's outside the visible world, then we remove -// EVERYTHING from it since it will never be seen! -// -// If it can be seen, then we remove all extraneous land tiles. We find the tile that has the first -// FULL TILE indicator, and delete anything that may come after it (it'll never be seen anyway) -// -// Doing the above has shown to free up about 1.1 Megs on the default map. Deletion of non-viewable -// land pieces alone gained us about 600 K of memory. -// -void MapOptimize(void) -{ -#if 0 - INT32 GridNo; - LEVELNODE *start, *head, *end, *node, *temp; - MAP_ELEMENT *pMapTile; - BOOLEAN fFound, fChangedHead, fChangedTail; - - for( GridNo = 0; GridNo < WORLD_MAX; GridNo++ ) - { - if ( !GridNoOnVisibleWorldTile( GridNo ) ) - { - // Tile isn't in viewable area so trash everything in it - TrashMapTile( GridNo ); - } - else - { - // Tile is in viewable area so try to optimize any extra land pieces - pMapTile = &gpWorldLevelData[ GridNo ]; - - node = start = pMapTile->pLandStart; - head = pMapTile->pLandHead; - - if ( start == NULL ) - node = start = head; - - end = pMapTile->pLandTail; - - fChangedHead = fChangedTail = fFound = FALSE; - while ( !fFound && node != NULL ) - { - if ( gTileDatabase[node->usIndex].ubFullTile == 1 ) - fFound = TRUE; - else - node = node->pNext; - } - - if(fFound) - { - // Delete everything up to the start node -/* -// Not having this means we still keep the smoothing - - while( head != start && head != NULL ) - { - fChangedHead = TRUE; - temp = head->pNext; - MemFree( head ); - head = temp; - if ( head ) - head->pPrev = NULL; - } -*/ - - // Now delete from the end to "node" - while( end != node && end != NULL ) - { - fChangedTail = TRUE; - temp = end->pPrev; - MemFree( end ); - end = temp; - if ( end ) - end->pNext = NULL; - } - - if ( fChangedHead ) - pMapTile->pLandHead = head; - - if ( fChangedTail ) - pMapTile->pLandTail = end; - } - } - } - -#endif -} - - - //---------------------------------------------------------------------------------------------- // CheckForFences // @@ -3929,29 +3718,11 @@ void HandleMouseClicksInGameScreen()//dnl ch80 011213 { if(iLastMapIndexRB != iMapIndex && iLastMapIndexRB == -1) iLastMapIndexRB = iMapIndex; -#if 0 - gfRenderWorld = TRUE; - switch(iDrawMode) - { - default: - gfRenderWorld = fPrevState; - break; - } -#endif } else if(_MiddleButtonDown) { if(iLastMapIndexMB != iMapIndex && iLastMapIndexMB == -1) iLastMapIndexMB = iMapIndex; -#if 0 - gfRenderWorld = TRUE; - switch(iDrawMode) - { - default: - gfRenderWorld = fPrevState; - break; - } -#endif } else if(!_LeftButtonDown) { @@ -4192,15 +3963,6 @@ void HandleMouseClicksInGameScreen()//dnl ch80 011213 { if(iMapIndex == iLastMapIndexMB)// MiddleClick performed on same tile { -#if 0 - gfRenderWorld = TRUE; - switch(iDrawMode) - { - default: - gfRenderWorld = fPrevState; - break; - } -#endif } iLastMapIndexMB = -1; } diff --git a/Editor/editscreen.h b/Editor/editscreen.h index 78e0d0250..1f3c591a0 100644 --- a/Editor/editscreen.h +++ b/Editor/editscreen.h @@ -57,8 +57,6 @@ void HideEditorToolbar( INT32 iOldTaskMode ); void ProcessSelectionArea(); -void MapOptimize(void); - extern UINT16 GenericButtonFillColors[40]; //These go together. The taskbar has a specific color scheme. diff --git a/GameSettings.cpp b/GameSettings.cpp index 7981d3008..778046307 100644 --- a/GameSettings.cpp +++ b/GameSettings.cpp @@ -284,7 +284,7 @@ BOOLEAN LoadGameSettings() gGameSettings.fOptions[TOPTION_RTCONFIRM] = iniReader.ReadBoolean("JA2 Game Settings","TOPTION_RTCONFIRM" , FALSE ); gGameSettings.fOptions[TOPTION_SLEEPWAKE_NOTIFICATION] = iniReader.ReadBoolean("JA2 Game Settings","TOPTION_SLEEPWAKE_NOTIFICATION" , TRUE ); gGameSettings.fOptions[TOPTION_USE_METRIC_SYSTEM] = iniReader.ReadBoolean("JA2 Game Settings","TOPTION_USE_METRIC_SYSTEM" , TRUE ); - gGameSettings.fOptions[TOPTION_MERC_ALWAYS_LIGHT_UP] = iniReader.ReadBoolean("JA2 Game Settings","TOPTION_MERC_ALWAYS_LIGHT_UP" , FALSE ); + gGameSettings.fOptions[TOPTION_MERC_CASTS_LIGHT] = iniReader.ReadBoolean("JA2 Game Settings", "TOPTION_MERC_CASTS_LIGHT" , FALSE); gGameSettings.fOptions[TOPTION_SMART_CURSOR] = iniReader.ReadBoolean("JA2 Game Settings","TOPTION_SMART_CURSOR" , FALSE ); gGameSettings.fOptions[TOPTION_SNAP_CURSOR_TO_DOOR] = iniReader.ReadBoolean("JA2 Game Settings","TOPTION_SNAP_CURSOR_TO_DOOR" , TRUE ); gGameSettings.fOptions[TOPTION_GLOW_ITEMS] = iniReader.ReadBoolean("JA2 Game Settings","TOPTION_GLOW_ITEMS" , TRUE ); @@ -332,6 +332,8 @@ BOOLEAN LoadGameSettings() else gGameSettings.fOptions[TOPTION_TOGGLE_TURN_MODE] = FALSE; + gGameSettings.fOptions[TOPTION_ALT_START_AIM] = iniReader.ReadBoolean("JA2 Game Settings", "TOPTION_ALT_START_AIM" , FALSE); // Start at max aiming level instead of default no aiming + gGameSettings.fOptions[TOPTION_ALT_PATHFINDING] = iniReader.ReadBoolean("JA2 Game Settings", "TOPTION_ALT_PATHFINDING" , FALSE); // A* pathfinding gGameSettings.fOptions[TOPTION_MERCENARY_FORMATIONS] = iniReader.ReadBoolean("JA2 Game Settings","TOPTION_MERCENARY_FORMATIONS" , TRUE ); // Flugente: mercenary formations gGameSettings.fOptions[TOPTION_SHOW_ENEMY_LOCATION] = iniReader.ReadBoolean("JA2 Game Settings","TOPTION_SHOW_ENEMY_LOCATION" , FALSE); // sevenfm: show locations of known enemies gGameSettings.fOptions[TOPTION_REPORT_MISS_MARGIN] = iniReader.ReadBoolean("JA2 Game Settings","TOPTION_REPORT_MISS_MARGIN" , FALSE ); // HEADROCK HAM 4: Shot offset report @@ -353,7 +355,6 @@ BOOLEAN LoadGameSettings() gGameSettings.fOptions[TOPTION_DEBUG_MODE_OPTIONS_END] = iniReader.ReadBoolean("JA2 Game Settings","TOPTION_DEBUG_MODE_OPTIONS_END" , FALSE ); gGameSettings.fOptions[TOPTION_LAST_OPTION] = iniReader.ReadBoolean("JA2 Game Settings","TOPTION_LAST_OPTION" , FALSE ); gGameSettings.fOptions[NUM_GAME_OPTIONS] = iniReader.ReadBoolean("JA2 Game Settings","NUM_GAME_OPTIONS" , FALSE ); - gGameSettings.fOptions[TOPTION_MERC_CASTS_LIGHT] = iniReader.ReadBoolean("JA2 Game Settings","TOPTION_MERC_CASTS_LIGHT" , TRUE ); gGameSettings.fOptions[TOPTION_HIDE_BULLETS] = iniReader.ReadBoolean("JA2 Game Settings","TOPTION_HIDE_BULLETS" , FALSE ); gGameSettings.fOptions[TOPTION_TRACKING_MODE] = iniReader.ReadBoolean("JA2 Game Settings","TOPTION_TRACKING_MODE" , TRUE ); gGameSettings.fOptions[TOPTION_DISABLE_CURSOR_SWAP] = iniReader.ReadBoolean("JA2 Game Settings","TOPTION_DISABLE_CURSOR_SWAP" , FALSE ); @@ -572,7 +573,7 @@ BOOLEAN SaveGameSettings() settings << "TOPTION_RTCONFIRM = " << (gGameSettings.fOptions[TOPTION_RTCONFIRM] ? "TRUE" : "FALSE" ) << endl; settings << "TOPTION_SLEEPWAKE_NOTIFICATION = " << (gGameSettings.fOptions[TOPTION_SLEEPWAKE_NOTIFICATION] ? "TRUE" : "FALSE" ) << endl; settings << "TOPTION_USE_METRIC_SYSTEM = " << (gGameSettings.fOptions[TOPTION_USE_METRIC_SYSTEM] ? "TRUE" : "FALSE" ) << endl; - settings << "TOPTION_MERC_ALWAYS_LIGHT_UP = " << (gGameSettings.fOptions[TOPTION_MERC_ALWAYS_LIGHT_UP] ? "TRUE" : "FALSE" ) << endl; + settings << "TOPTION_MERC_CASTS_LIGHT = " << (gGameSettings.fOptions[TOPTION_MERC_CASTS_LIGHT] ? "TRUE" : "FALSE") << endl; settings << "TOPTION_SMART_CURSOR = " << (gGameSettings.fOptions[TOPTION_SMART_CURSOR] ? "TRUE" : "FALSE" ) << endl; settings << "TOPTION_SNAP_CURSOR_TO_DOOR = " << (gGameSettings.fOptions[TOPTION_SNAP_CURSOR_TO_DOOR] ? "TRUE" : "FALSE" ) << endl; settings << "TOPTION_GLOW_ITEMS = " << (gGameSettings.fOptions[TOPTION_GLOW_ITEMS] ? "TRUE" : "FALSE" ) << endl; @@ -608,12 +609,14 @@ BOOLEAN SaveGameSettings() settings << "TOPTION_AUTO_FAST_FORWARD_MODE = " << (gGameSettings.fOptions[TOPTION_AUTO_FAST_FORWARD_MODE] ? "TRUE" : "FALSE" ) << endl; settings << "TOPTION_SHOW_LAST_ENEMY = " << (gGameSettings.fOptions[TOPTION_SHOW_LAST_ENEMY] ? "TRUE" : "FALSE" ) << endl; settings << "TOPTION_SHOW_LBE_CONTENT = " << (gGameSettings.fOptions[TOPTION_SHOW_LBE_CONTENT] ? "TRUE" : "FALSE" ) << endl; - settings << "TOPTION_INVERT_WHEEL = " << (gGameSettings.fOptions[TOPTION_INVERT_WHEEL] ? "TRUE" : "FALSE" ) << endl; + settings << "TOPTION_INVERT_WHEEL = " << (gGameSettings.fOptions[TOPTION_INVERT_WHEEL] ? "TRUE" : "FALSE" ) << endl; settings << "TOPTION_ZOMBIES = " << (gGameSettings.fOptions[TOPTION_ZOMBIES] ? "TRUE" : "FALSE" ) << endl; settings << "TOPTION_ENABLE_INVENTORY_POPUPS = " << (gGameSettings.fOptions[TOPTION_ENABLE_INVENTORY_POPUPS] ? "TRUE" : "FALSE" ) << endl; // the_bob : enable popups for picking items from sector inv settings << "TOPTION_MERCENARY_FORMATIONS = " << (gGameSettings.fOptions[TOPTION_MERCENARY_FORMATIONS] ? "TRUE" : "FALSE" ) << endl; settings << "TOPTION_SHOW_ENEMY_LOCATION = " << (gGameSettings.fOptions[TOPTION_SHOW_ENEMY_LOCATION] ? "TRUE" : "FALSE" ) << endl; + settings << "TOPTION_ALT_START_AIM = " << (gGameSettings.fOptions[TOPTION_ALT_START_AIM] ? "TRUE" : "FALSE") << endl; + settings << "TOPTION_ALT_PATHFINDING = " << (gGameSettings.fOptions[TOPTION_ALT_PATHFINDING] ? "TRUE" : "FALSE") << endl; settings << "TOPTION_CHEAT_MODE_OPTIONS_HEADER = " << (gGameSettings.fOptions[TOPTION_CHEAT_MODE_OPTIONS_HEADER] ? "TRUE" : "FALSE" ) << endl; settings << "TOPTION_FORCE_BOBBY_RAY_SHIPMENTS = " << (gGameSettings.fOptions[TOPTION_FORCE_BOBBY_RAY_SHIPMENTS] ? "TRUE" : "FALSE" ) << endl; @@ -633,7 +636,6 @@ BOOLEAN SaveGameSettings() settings << ";******************************************************************************************************************************" << endl; settings << "TOPTION_LAST_OPTION = " << (gGameSettings.fOptions[TOPTION_LAST_OPTION] ? "TRUE" : "FALSE" ) << endl; settings << "NUM_GAME_OPTIONS = " << (gGameSettings.fOptions[NUM_GAME_OPTIONS] ? "TRUE" : "FALSE" ) << endl; - settings << "TOPTION_MERC_CASTS_LIGHT = " << (gGameSettings.fOptions[TOPTION_MERC_CASTS_LIGHT] ? "TRUE" : "FALSE" ) << endl; settings << "TOPTION_HIDE_BULLETS = " << (gGameSettings.fOptions[TOPTION_HIDE_BULLETS] ? "TRUE" : "FALSE" ) << endl; settings << "TOPTION_TRACKING_MODE = " << (gGameSettings.fOptions[TOPTION_TRACKING_MODE] ? "TRUE" : "FALSE" ) << endl; settings << "NUM_ALL_GAME_OPTIONS = " << (gGameSettings.fOptions[NUM_ALL_GAME_OPTIONS] ? "TRUE" : "FALSE" ) << endl; @@ -777,7 +779,7 @@ void InitGameSettings() gGameSettings.fOptions[ TOPTION_RTCONFIRM ] = FALSE; gGameSettings.fOptions[ TOPTION_SLEEPWAKE_NOTIFICATION ] = TRUE; gGameSettings.fOptions[ TOPTION_USE_METRIC_SYSTEM ] = TRUE; - gGameSettings.fOptions[ TOPTION_MERC_ALWAYS_LIGHT_UP ] = FALSE; + gGameSettings.fOptions[TOPTION_MERC_CASTS_LIGHT] = FALSE; gGameSettings.fOptions[ TOPTION_SMART_CURSOR ] = FALSE; gGameSettings.fOptions[ TOPTION_SNAP_CURSOR_TO_DOOR ] = TRUE; gGameSettings.fOptions[ TOPTION_GLOW_ITEMS ] = TRUE; @@ -841,7 +843,9 @@ void InitGameSettings() gGameSettings.fOptions[TOPTION_INVERT_WHEEL] = FALSE; gGameSettings.fOptions[ TOPTION_MERCENARY_FORMATIONS ] = FALSE; // Flugente: mercenary formations - gGameSettings.fOptions[ TOPTION_SHOW_ENEMY_LOCATION ] = FALSE; // sevenfm: show locations of known enemies + gGameSettings.fOptions[TOPTION_SHOW_ENEMY_LOCATION] = FALSE; // sevenfm: show locations of known enemies + gGameSettings.fOptions[TOPTION_ALT_START_AIM] = FALSE; + gGameSettings.fOptions[TOPTION_ALT_PATHFINDING] = FALSE; // arynn: Cheat/Debug Menu gGameSettings.fOptions[ TOPTION_CHEAT_MODE_OPTIONS_HEADER ] = FALSE; @@ -870,8 +874,6 @@ void InitGameSettings() gGameSettings.fOptions[ NUM_GAME_OPTIONS ] = FALSE; // Toggles prior to this will be able to be toggled by the player // JA2Gold - gGameSettings.fOptions[ TOPTION_MERC_CASTS_LIGHT ] = TRUE; - gGameSettings.fOptions[ TOPTION_HIDE_BULLETS ] = FALSE; gGameSettings.fOptions[ TOPTION_TRACKING_MODE ] = TRUE; diff --git a/GameSettings.h b/GameSettings.h index 5f5db0adc..8be6f7ca5 100644 --- a/GameSettings.h +++ b/GameSettings.h @@ -33,7 +33,7 @@ enum // TOPTION_DISPLAY_ENEMY_INDICATOR, //Displays the number of enemies seen by the merc, ontop of their portrait TOPTION_SLEEPWAKE_NOTIFICATION, TOPTION_USE_METRIC_SYSTEM, //If set, uses the metric system - TOPTION_MERC_ALWAYS_LIGHT_UP, + TOPTION_MERC_CASTS_LIGHT, TOPTION_SMART_CURSOR, TOPTION_SNAP_CURSOR_TO_DOOR, TOPTION_GLOW_ITEMS, @@ -103,6 +103,8 @@ enum // sevenfm: new settings TOPTION_SHOW_ENEMY_LOCATION, + TOPTION_ALT_START_AIM, + TOPTION_ALT_PATHFINDING, // arynn: Debug/Cheat TOPTION_CHEAT_MODE_OPTIONS_HEADER, @@ -127,8 +129,6 @@ enum //These options will NOT be toggable by the Player // JA2Gold - TOPTION_MERC_CASTS_LIGHT, - TOPTION_HIDE_BULLETS, TOPTION_TRACKING_MODE, diff --git a/GameVersion.cpp b/GameVersion.cpp index 25aee3770..d91a7c510 100644 --- a/GameVersion.cpp +++ b/GameVersion.cpp @@ -1,52 +1,40 @@ #include "Types.h" #include "GameVersion.h" - + // // Keeps track of the game version // - -// ------------------------------ -// MAP EDITOR (Release and Debug) BUILD VERSION -// ------------------------------ -#ifdef JA2EDITOR + +#ifdef JA2EDITOR // map editor #ifdef JA2UB - CHAR16 zProductLabel[64] = { L"Unfinished Business - Map Editor v1.13" }; + CHAR16 zProductLabel[64] = { L"JA2 1.13 Unfinished Business - Map Editor" }; #else - CHAR16 zProductLabel[64] = { L"Map Editor v1.13" }; + CHAR16 zProductLabel[64] = { L"JA2 1.13 - Map Editor" }; #endif -// ------------------------------ -// DEBUG BUILD VERSIONS -// ------------------------------ -#elif defined JA2BETAVERSION +#elif defined JA2BETAVERSION // debug - //DEBUG BUILD VERSION #ifdef JA2UB - CHAR16 zProductLabel[64] = { L"Debug: Unfinished Business - v1.13" }; + CHAR16 zProductLabel[64] = { L"Debug: JA2 1.13 Unfinished Business" }; #elif defined (JA113DEMO) - CHAR16 zProductLabel[64] = { L"Debug: JA2 Demo - v1.13" }; + CHAR16 zProductLabel[64] = { L"Debug: JA2 1.13 Demo" }; #else - CHAR16 zProductLabel[64] = { L"Debug: v1.13" }; + CHAR16 zProductLabel[64] = { L"Debug: JA2 1.13" }; #endif #elif defined CRIPPLED_VERSION - //RELEASE BUILD VERSION s - CHAR16 zProductLabel[64] = { L"Beta v. 0.98" }; + CHAR16 zProductLabel[64] = { L"JA2 113 Beta-0.98" }; -// ------------------------------ -// RELEASE BUILD VERSIONS -// ------------------------------ -#else +#else // release - //RELEASE BUILD VERSION #ifdef JA2UB - CHAR16 zProductLabel[64] = { L"Unfinished Business - v1.13" }; + CHAR16 zProductLabel[64] = { L"JA2 1.13 Unfinished Business" }; #elif defined (JA113DEMO) - CHAR16 zProductLabel[64] = { L"JA2 Demo - v1.13" }; + CHAR16 zProductLabel[64] = { L"JA2 1.13 Demo" }; #else - CHAR16 zProductLabel[64] = { L"v1.13" }; + CHAR16 zProductLabel[64] = { L"JA2 1.13" }; #endif #endif diff --git a/Laptop/CMakeLists.txt b/Laptop/CMakeLists.txt new file mode 100644 index 000000000..c62b34bb1 --- /dev/null +++ b/Laptop/CMakeLists.txt @@ -0,0 +1,101 @@ +set(LaptopSrc +"${CMAKE_CURRENT_SOURCE_DIR}/aim.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/AimArchives.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/AimFacialIndex.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/AimHistory.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/AimLinks.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/AimMembers.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/AimPolicies.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/AimSort.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/BaseTable.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/BobbyR.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/BobbyRAmmo.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/BobbyRArmour.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/BobbyRGuns.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/BobbyRMailOrder.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/BobbyRMisc.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/BobbyRShipments.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/BobbyRUsed.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/BriefingRoom.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/BriefingRoomM.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/BriefingRoom_Data.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/BrokenLink.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/CampaignHistoryMain.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/CampaignHistory_Summary.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/CampaignStats.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/CharProfile.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/DropDown.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/DynamicDialogueWidget.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/email.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Encyclopedia_Data_new.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Encyclopedia_new.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/FacilityProduction.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/files.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/finances.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/florist Cards.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/florist Gallery.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/florist Order Form.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/florist.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/funeral.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/GunEmporium.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/history.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP AboutUs.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Attribute Entrance.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Attribute Finish.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Attribute Selection.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Background.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Begin Screen.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Character and Disability Entrance.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Character Trait.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Color Choosing.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Compile Character.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Confirm.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Disability Trait.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Finish.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Gear Entrance.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Gear.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP HomePage.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP MainPage.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Minor Trait.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Personality Entrance.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Personality Finish.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Personality Quiz.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Portraits.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Prejudice.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Skill Trait.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Text System.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMP Voices.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/IMPVideoObjects.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/insurance Comments.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/insurance Contract.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/insurance Info.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/insurance.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Intelmarket.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/laptop.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/merccompare.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/mercs Account.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/mercs Files.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/mercs No Account.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/mercs.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/MilitiaInterface.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/MilitiaWebsite.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/personnel.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/PMC.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/PostalService.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/sirtech.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Store Inventory.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/WHO.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_AIMAvailability.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_BriefingRoom.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_CampaignStatsEvents.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_ConditionsForMercAvailability.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_DeliveryMethods.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Email.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_EmailMercAvailable.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_EmailMercLevelUp.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_History.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_IMPPortraits.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_IMPVoices.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_OldAIMArchive.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_ShippingDestinations.cpp" +PARENT_SCOPE) diff --git a/Laptop/Encyclopedia_Data_new.cpp b/Laptop/Encyclopedia_Data_new.cpp index 07be98a02..5de9ac67b 100644 --- a/Laptop/Encyclopedia_Data_new.cpp +++ b/Laptop/Encyclopedia_Data_new.cpp @@ -1324,13 +1324,8 @@ void GameInitEncyclopediaData_NEW( ) giEncyclopedia_DataBtnImage = BUTTON_NO_IMAGE; memset( giEncyclopedia_DataFilterBtn, BUTTON_NO_SLOT, sizeof(giEncyclopedia_DataFilterBtn) ); giEncyclopedia_DataFilterBtnImage = BUTTON_NO_IMAGE; -#if 0//debug - memset( gbEncyclopediaData_ItemVisible, ENC_ITEM_DISCOVERED_NOT_REACHABLE, sizeof(gbEncyclopediaData_ItemVisible) ); - gbEncyclopediaData_ItemVisible[1] = ENC_ITEM_NOT_DISCOVERED; -#else if( guiCurrentScreen == MAINMENU_SCREEN ) EncyclopediaInitItemsVisibility(); -#endif // do following only once at start of JA2 CHECKV( guiCurrentScreen == 0 ); //prepare indexes for subfilter texts defined in _LanguageText.cpp, assuming there are blank separators between filter button texts ("1", "2", "3", "", "1", "", "1", "2", "3", "4") diff --git a/Laptop/Encyclopedia_new.cpp b/Laptop/Encyclopedia_new.cpp index f9ae0cf92..e1c5ac39b 100644 --- a/Laptop/Encyclopedia_new.cpp +++ b/Laptop/Encyclopedia_new.cpp @@ -38,11 +38,7 @@ #include "vobject.h"//video objects #include "Utils/Cursors.h" #include "Text.h"//button text -#ifdef ENC_USE_BUTTONSYSTEM #include "Button System.h" -#else - #include "WordWrap.h"//centered text -#endif #include "Encyclopedia_new.h" //#include "Encrypted File.h" //#include "Soldier Profile.h" @@ -68,13 +64,8 @@ UINT32 guiEncyclopediaAimLogo; ///@} ///@{ buttons, graphics and regions for main page -#ifdef ENC_USE_BUTTONSYSTEM INT32 giEncyclopediaBtn[ ENC_NUM_SUBPAGES ]; INT32 giEncyclopediaBtnImage; -#else -MOUSE_REGION gEncyclopediaBtnRegions[ ENC_NUM_SUBPAGES ]; -UINT32 guiEncyclopediaBtnImage; -#endif #define ENC_BTN_GAP 6 #define ENC_AIMLOGO_GAP_TOP 20 #define ENC_AIMLOGO_GAP_BOTTOM 40 @@ -85,11 +76,7 @@ ENC_SUBPAGE_T geENC_SubPage; ///< Current sub page /////// //prototypes -#ifdef ENC_USE_BUTTONSYSTEM void BtnEncyclopedia_newSelectDataPageBtnCallBack ( GUI_BUTTON *btn, INT32 reason ); -#else -void BtnEncyclopedia_newSelectDataPageRegionCallBack( MOUSE_REGION * pRegion, INT32 iReason ); -#endif /////// //functions @@ -108,11 +95,8 @@ void BtnEncyclopedia_newSelectDataPageRegionCallBack( MOUSE_REGION * pRegion, IN void GameInitEncyclopedia_NEW() { // initialize gui handles -#ifdef ENC_USE_BUTTONSYSTEM memset( giEncyclopediaBtn, BUTTON_NO_SLOT, sizeof(giEncyclopediaBtn) ); giEncyclopediaBtnImage = BUTTON_NO_IMAGE; -#else -#endif // check for files only on start of JA2 CHECKV( guiCurrentScreen == 0 && gGameExternalOptions.gEncyclopedia ); @@ -178,7 +162,6 @@ BOOLEAN EnterEncyclopedia_NEW( ) CHECKF(hVObject);CHECKF(hVObject->pETRLEObject); logoBottomY = hVObject->pETRLEObject->usHeight + LAPTOP_SCREEN_WEB_UL_Y + ENC_AIMLOGO_GAP_TOP; -#ifdef ENC_USE_BUTTONSYSTEM//use button system ////// // load button graphic for the data pages giEncyclopediaBtnImage = LoadButtonImage( "ENCYCLOPEDIA\\CONTENTBUTTON.STI", BUTTON_NO_IMAGE, 0, BUTTON_NO_IMAGE , 0, BUTTON_NO_IMAGE ); @@ -202,34 +185,6 @@ BOOLEAN EnterEncyclopedia_NEW( ) GetButtonPtr( giEncyclopediaBtn[ i ] )->fShiftImage = TRUE; //SpecifyButtonSoundScheme( giEncyclopediaDataBtn[ i ], BUTTON_SOUND_SCHEME_BIGSWITCH3 ); } -#else - ////// - // load button graphic for the data pages - VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE; - FilenameForBPP( "ENCYCLOPEDIA\\CONTENTBUTTON.STI", VObjectDesc.ImageFile ); - CHECKF( AddVideoObject( &VObjectDesc, &guiEncyclopediaBtnImage ) ); - ////// - // create mouse regions for data buttons and set user data - GetVideoObject( &hVObject, guiEncyclopediaBtnImage ); - CHECKF(hVObject);CHECKF(hVObject->pETRLEObject); - buttonSizeX = hVObject->pETRLEObject->usWidth;//get width of buttons from image - buttonSizeY = hVObject->pETRLEObject->usHeight;//get heigth of buttons from image - - for ( UINT8 i = 0; i < ENC_NUM_SUBPAGES; i++ ) - { - MSYS_DefineRegion( &gEncyclopediaBtnRegions[i], - LAPTOP_SCREEN_UL_X + (LAPTOP_SCREEN_WIDTH)/2 - buttonSizeX/2,//upper left x: center of laptop screen - 1/2 buttonsize - logoBottomY + ENC_AIMLOGO_GAP_BOTTOM + i * (ENC_BTN_GAP + buttonSizeY),//upper left y: below logo + logo gap + previous buttons and button gaps - LAPTOP_SCREEN_UL_X + (LAPTOP_SCREEN_WIDTH)/2 + buttonSizeX/2,//lower right x: center of laptop screen + 1/2 buttonsize - logoBottomY + ENC_AIMLOGO_GAP_BOTTOM + buttonSizeY + i * (ENC_BTN_GAP + buttonSizeY),//lower right y: below logo + logo gap + button height + previous buttons and button gaps - MSYS_PRIORITY_HIGH,//priority - CURSOR_WWW,//cursor - MSYS_NO_CALLBACK,//moveCB - BtnEncyclopedia_newSelectDataPageRegionCallBack); - MSYS_SetRegionUserData( &gEncyclopediaBtnRegions[i], 0, i + 1 ); - CHECKF( MSYS_AddRegion( &gEncyclopediaBtnRegions[i] ) ); - } -#endif return TRUE; } @@ -252,7 +207,6 @@ BOOLEAN ExitEncyclopedia_NEW( ) // destroy AIM logo success &= DeleteVideoObjectFromIndex( guiEncyclopediaAimLogo ); -#ifdef ENC_USE_BUTTONSYSTEM//use button system // destroy buttons for ( UINT8 i = 0; i < ENC_NUM_SUBPAGES; i++ ) if ( giEncyclopediaBtn[ i ] != BUTTON_NO_SLOT ) @@ -270,13 +224,6 @@ BOOLEAN ExitEncyclopedia_NEW( ) } else success = FALSE; -#else - // destroy button graphic - success &= DeleteVideoObjectFromIndex( guiEncyclopediaBtnImage ); - // destroy mouseregions for buttons - for (UINT8 i = 0; i < ENC_NUM_SUBPAGES; i++) - MSYS_RemoveRegion( &gEncyclopediaBtnRegions[i] ); -#endif return success; } @@ -303,20 +250,7 @@ void RenderEncyclopedia_NEW( ) CHECKV( BltVideoObjectFromIndex( FRAME_BUFFER, guiEncyclopediaAimLogo, 0, x, y, VO_BLT_SRCTRANSPARENCY, NULL ) ); // render Buttons for Data pages -#ifdef ENC_USE_BUTTONSYSTEM RenderButtons(); -#else - for ( UINT8 i = 0; i < ENC_NUM_SUBPAGES; i++ ) - { - x = gEncyclopediaBtnRegions[ i ].RegionTopLeftX; - y = gEncyclopediaBtnRegions[ i ].RegionTopLeftY; - //Btn graphic - CHECKV( BltVideoObjectFromIndex( FRAME_BUFFER, guiEncyclopediaBtnImage, 0, x, y, VO_BLT_SRCTRANSPARENCY, NULL ) ); - //Btn text - y += (gEncyclopediaBtnRegions[ i ].RegionBottomRightY - y)/2 - GetFontHeight( FONT12ARIAL )/2; - DrawTextToScreen( pMenuStrings[ i ], x, y, (UINT16)gEncyclopediaBtnRegions[ i ].RegionBottomRightX - x, FONT12ARIAL, FONT_FCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED ); - } -#endif // finish render CHECKV ( RenderWWWProgramTitleBar() ); InvalidateRegion(LAPTOP_SCREEN_UL_X,LAPTOP_SCREEN_WEB_UL_Y,LAPTOP_SCREEN_LR_X,LAPTOP_SCREEN_WEB_LR_Y); @@ -401,7 +335,6 @@ void ChangingEncyclopediaSubPage( UINT8 ubSubPageNumber ) ////////////// //Callback functions -#ifdef ENC_USE_BUTTONSYSTEM//use button system void BtnEncyclopedia_newSelectDataPageBtnCallBack( GUI_BUTTON *btn, INT32 reason ) { if( reason & MSYS_CALLBACK_REASON_LBUTTON_DWN ) @@ -430,35 +363,5 @@ void BtnEncyclopedia_newSelectDataPageBtnCallBack( GUI_BUTTON *btn, INT32 reason InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY); } } -#else -/** -* @brief Callback for data page buttons. -* Userdata at index 0 is used to determine which button is pressed. -*/ -void BtnEncyclopedia_newSelectDataPageRegionCallBack( MOUSE_REGION * pRegion, INT32 iReason ) -{ - CHECKV( gGameExternalOptions.gEncyclopedia ); - if (iReason & MSYS_CALLBACK_REASON_INIT) - { - } - else if(iReason & MSYS_CALLBACK_REASON_LBUTTON_UP) - { - UINT8 selectedButton = (UINT8)MSYS_GetRegionUserData( pRegion, 0 ); - - if( selectedButton == 0 ) - { - guiCurrentLaptopMode = LAPTOP_MODE_ENCYCLOPEDIA; - } - else if( selectedButton > 0 && selectedButton <= ENC_NUM_SUBPAGES ) - { - ChangingEncyclopediaSubPage ( selectedButton ); - guiCurrentLaptopMode = LAPTOP_MODE_ENCYCLOPEDIA_DATA; - } - } - else if (iReason & MSYS_CALLBACK_REASON_RBUTTON_UP) - { - } -} -#endif #endif diff --git a/Laptop/IMP Gear.cpp b/Laptop/IMP Gear.cpp index 20fab5f49..e8da0ada3 100644 --- a/Laptop/IMP Gear.cpp +++ b/Laptop/IMP Gear.cpp @@ -69,6 +69,7 @@ extern BOOLEAN bBigBody; #define IMP_GEAR_SPACE_BETWEEN_BOXES 1 +#define IMP_GEAR_INV_SLOTS 25 //******************************************************************* // // Local Variables @@ -76,7 +77,7 @@ extern BOOLEAN bBigBody; //******************************************************************* INV_REGIONS gIMPGearInvData[NUM_INV_SLOTS]; MOUSE_REGION gIMPGearInvRegion[NUM_INV_SLOTS]; -MOUSE_REGION gIMPGearInvPoolRegion[25]; +MOUSE_REGION gIMPGearInvPoolRegion[IMP_GEAR_INV_SLOTS]; UINT32 gIMPInvDoneButtonImage; UINT32 gIMPInvDoneButton; UINT32 gIMPInvArrowButtonImage[2]; @@ -237,10 +238,11 @@ void ExitIMPGear( void ) { MSYS_RemoveRegion(&gIMPGearInvRegion[cnt]); } - for (size_t i = 0; i < 25; i++) + for (size_t i = 0; i < IMP_GEAR_INV_SLOTS; i++) { MSYS_RemoveRegion(&gIMPGearInvPoolRegion[i]); } + fShowIMPItemHighLight = FALSE; } @@ -859,7 +861,7 @@ void IMPCloseInventoryPool(void) { MSYS_EnableRegion(&gIMPGearInvRegion[cnt]); } - for (size_t i = 0; i < 25; i++) + for (size_t i = 0; i < IMP_GEAR_INV_SLOTS; i++) { MSYS_DisableRegion(&gIMPGearInvPoolRegion[i]); } @@ -946,7 +948,7 @@ void IMPInvClickCallback(MOUSE_REGION* pRegion, INT32 iReason) MSYS_DisableRegion(&gIMPGearInvRegion[cnt]); } - for (size_t i = 0; i < 25; i++) + for (size_t i = 0; i < IMP_GEAR_INV_SLOTS; i++) { MSYS_EnableRegion(&gIMPGearInvPoolRegion[i]); } @@ -1104,7 +1106,7 @@ void InitImpGearCoords(void) } // Inventory pool slots - for (size_t i = 0; i < 25; i++) + for (size_t i = 0; i < IMP_GEAR_INV_SLOTS; i++) { const UINT32 xOffset = gIMPInvPoolLayout.x + 24; // top left coords of the first item slot in selection grid sti const UINT32 yOffset = gIMPInvPoolLayout.y + 8; @@ -1187,12 +1189,19 @@ void DrawItemTextToInvPool(STR16 itemName, UINT32 x, UINT32 y) void RenderImpGearSelectionChoices(UINT32 pocket) { + CHAR16 tooltipText[5000]; const UINT32 xOffset = gIMPInvPoolLayout.x + 24; // top left coords of the first item slot in selection grid sti const UINT32 yOffset = gIMPInvPoolLayout.y + 8; const UINT32 xStep = 72; // steps to the next slot column and row const UINT32 yStep = 32; - - const UINT32 pageShift = gIMPCurrentInventoryPoolPage * 25; + + // Reset item slot tooltips + for (size_t i = 0; i < IMP_GEAR_INV_SLOTS; i++) + { + SetRegionFastHelpText(&gIMPGearInvPoolRegion[i], szIMPGearPocketText[55]); + } + + const UINT32 pageShift = gIMPCurrentInventoryPoolPage * IMP_GEAR_INV_SLOTS; UINT32 end = gIMPPossibleItems[pocket].size(); if (gIMPCurrentInventoryPoolPage < gIMPLastInventoryPoolPage) { @@ -1211,7 +1220,17 @@ void RenderImpGearSelectionChoices(UINT32 pocket) const auto xText = x; const auto yText = y + 24; DrawItemTextToInvPool(gIMPPossibleItems[pocket][i].second, xText, yText); + // Update tool tip to contain item name + const auto itemIndex = gIMPPossibleItems[pocket][i].first; + if (itemIndex != 0) + { + extern void GetHelpTextForItemInLaptop(STR16 pzStr, UINT16 usItemNumber); + GetHelpTextForItemInLaptop(tooltipText, itemIndex); + wcscat(tooltipText, L"\n"); + wcscat(tooltipText, szIMPGearPocketText[55]); + SetRegionFastHelpText(&gIMPGearInvPoolRegion[i - pageShift], tooltipText); + } // Check if currently selected item is shown in pool and adjust glow coordinates if (item == gIMPPocketSelectedItems[pocket].first) @@ -1476,4 +1495,4 @@ void RenderIMPGearBodytype(void) } BltVideoObjectFromIndex(FRAME_BUFFER, gIMPINVENTORY, index, x, y, VO_BLT_SRCTRANSPARENCY, NULL); -} \ No newline at end of file +} diff --git a/ModularizedTacticalAI/CMakeLists.txt b/ModularizedTacticalAI/CMakeLists.txt new file mode 100644 index 000000000..0c4c78ba9 --- /dev/null +++ b/ModularizedTacticalAI/CMakeLists.txt @@ -0,0 +1,14 @@ +set(ModularizedTacticalAISrc +"${CMAKE_CURRENT_SOURCE_DIR}/src/LegacyArmedVehiclePlan.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/src/AbstractPlanFactory.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/src/CrowPlan.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/src/LegacyAIPlan.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/src/LegacyAIPlanFactory.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/src/LegacyCreaturePlan.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/src/LegacyZombiePlan.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/src/NullPlan.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/src/NullPlanFactory.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/src/Plan.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/src/PlanFactoryLibrary.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/src/PlanList.cpp" +PARENT_SCOPE) diff --git a/Standard Gaming Platform/CMakeLists.txt b/Standard Gaming Platform/CMakeLists.txt new file mode 100644 index 000000000..e804d0378 --- /dev/null +++ b/Standard Gaming Platform/CMakeLists.txt @@ -0,0 +1,43 @@ +set(SGPSrc +"${CMAKE_CURRENT_SOURCE_DIR}/Button Sound Control.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Button System.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Compression.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Container.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Cursor Control.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/DEBUG.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/debug_util.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/debug_win_util.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/DirectDraw Calls.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/DirectX Common.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/English.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/FileCat.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/FileMan.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Flic.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Font.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/himage.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/impTGA.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/input.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Install.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Ja2 Libs.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/LibraryDataBase.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/line.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/MemMan.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/mousesystem.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/PCX.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/PngLoader.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Random.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/readdir.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/RegInst.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/sgp.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/sgp_logger.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/shading.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/soundman.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/STCI.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/stringicmp.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/timer.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/video.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/vobject.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/vobject_blitters.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/vsurface.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/WinFont.cpp" +PARENT_SCOPE) diff --git a/Standard Gaming Platform/Mss.h b/Standard Gaming Platform/Mss.h index c89f8e5d7..bd0e38b6b 100644 --- a/Standard Gaming Platform/Mss.h +++ b/Standard Gaming Platform/Mss.h @@ -277,12 +277,8 @@ extern "C" { #define DXDEF __declspec(dllexport) #else - #if 1 /*def __BORLANDC__*/ #define DXDEC extern #define DXDEF - #else - #define DXDEC __declspec(dllimport) - #endif #endif diff --git a/Standard Gaming Platform/PngLoader.cpp b/Standard Gaming Platform/PngLoader.cpp index b817851d1..88453b61d 100644 --- a/Standard Gaming Platform/PngLoader.cpp +++ b/Standard Gaming Platform/PngLoader.cpp @@ -179,62 +179,6 @@ bool IndexedSTIImage::addImage(UINT8 *data, UINT32 data_size, UINT32 image_width return true; -#if 0 - unsigned int uiBufferPos = 0; - - bool bZeroRun = false; - UINT8 uiRunLength = 0; - UINT8 *uiRunStartPosition = data; - if(*data == 0) - { - bZeroRun = true; - } - bool done = false; - UINT32 scanline = 0; - while(!done) - { - if(bZeroRun) - { - while((*data == 0) && (uiRunLength < 128) && (uiBufferPos < data_size) && (scanline < image_width)) - { - data++; - uiRunLength++; - uiBufferPos++; - scanline++; - } - uiRunStartPosition = compressed; - *compressed++ = uiRunLength | iCOMPRESS_TRANSPARENT; - compressed_size += 1; - } - else - { - uiRunStartPosition = compressed++; - while((*data != 0) && (uiRunLength < 128) && (uiBufferPos < data_size) && (scanline < image_width)) - { - *compressed++ = *data++; - uiRunLength++; - uiBufferPos++; - scanline++; - } - *uiRunStartPosition = uiRunLength; - compressed_size += uiRunLength+1; - } - // prepare next run - uiRunLength = 0; - bZeroRun = (*data != 0) ? false : true; - if(scanline == image_width) - { - scanline = 0; - // "close" scanline with a zero - *compressed++ = 0; - compressed_size += 1; - } - if(uiBufferPos >= data_size) - { - done = true; - } - } -#endif } @@ -870,7 +814,6 @@ bool LoadJPCFileToImage(HIMAGE hImage, UINT16 fContents) void Load32bppPNGImage(HIMAGE hImage, png::png_bytepp rows, png::png_infop info) { -#if 1 hImage->pETRLEObject = (ETRLEObject*)MemAlloc(1 * sizeof(ETRLEObject)); if(!hImage->pETRLEObject) { @@ -908,37 +851,6 @@ void Load32bppPNGImage(HIMAGE hImage, png::png_bytepp rows, png::png_infop info) } hImage->fFlags |= IMAGE_BITMAPDATA; -#else - UINT32 SIZE = info->height * info->width; - hImage->p16BPPData = new UINT16[SIZE]; - memset(hImage->p16BPPData, 0, SIZE*sizeof(UINT16)); - UINT16* dest_row = NULL; - UINT32 rgbcolor = 0; - for(unsigned int i=0; iheight; ++i) - { - dest_row = &(hImage->p16BPPData[i*info->width]); - png_bytep row_i = rows[i]; - for(unsigned int sx = 0, dx = 0; sx < 4*info->width; sx+=4, dx+=1) - { - if(row_i[sx+3] == 255) - { - rgbcolor = FROMRGB(row_i[sx], row_i[sx+1], row_i[sx+2]); - if(rgbcolor == 0) - { - // since we already use rgb(0,0,0) as a fully transparent color, - // the color black will be mapped to rgb(0,1,0), because green has the most bits - //rgbcolor = 1 << 8; - rgbcolor = FROMRGB(0,1,0); - } - dest_row[dx] = Get16BPPColor(rgbcolor); - } - else - { - dest_row[dx] = Get16BPPColor(0); - } - } - } -#endif } @@ -1039,65 +951,6 @@ void LoadPalettedPNGImage(HIMAGE hImage, png::png_bytepp rows, png::png_infop in SGP_THROW_IFFALSE( etrle_size > 0, L"ETRLE compression of PNG image failed" ); subim.sOffsetX = subimage.sOffsetX; subim.sOffsetY = subimage.sOffsetY; -#if 0 - unsigned int uiBufferPos = 0; - - bool bZeroRun = false; - UINT8 uiRunLength = 0; - UINT8 *uiRunStartPosition = data; - if(*data == 0) - { - bZeroRun = true; - } - bool done = false; - UINT32 scanline = 0; - while(!done) - { - if(bZeroRun) - { - while((*data == 0) && (uiRunLength < 128) && (uiBufferPos < SIZE) && (scanline < info->width)) - { - data++; - uiRunLength++; - uiBufferPos++; - scanline++; - } - uiRunStartPosition = compressed; - *compressed++ = uiRunLength | COMPRESS_TRANSPARENT; - compressed_size += 1; - *compressed++ = 0; - compressed_size += 1; - } - else - { - uiRunStartPosition = compressed++; - while((*data != 0) && (uiRunLength < 128) && (uiBufferPos < SIZE) && (scanline < info->width)) - { - *compressed++ = *data++; - uiRunLength++; - uiBufferPos++; - scanline++; - } - *uiRunStartPosition = uiRunLength | COMPRESS_NON_TRANSPARENT; - compressed_size += uiRunLength+1; - } - // prepare next run - uiRunLength = 0; - bZeroRun = (*data != 0) ? false : true; - if(scanline == info->width) - { - scanline = 0; - // "close" scanline with a zero - *compressed++ = 0; - compressed_size += 1; - } - if(uiBufferPos >= SIZE) - { - done = true; - } - } - UINT32 etrle_size = compressed_size; -#endif //subimage.uiDataLength = compressed_size; subimage.uiDataLength = etrle_size; subimage.uiDataOffset = 0; diff --git a/Standard Gaming Platform/himage.cpp b/Standard Gaming Platform/himage.cpp index 08d8dcaf9..f2c84bdd7 100644 --- a/Standard Gaming Platform/himage.cpp +++ b/Standard Gaming Platform/himage.cpp @@ -129,86 +129,6 @@ HIMAGE CreateImage( SGPFILENAME ImageFile, UINT16 fContents, ImageFileType::Test CHAR8 ExtensionSep[] = "."; UINT32 iFileLoader; -#if 0 - SGPFILENAME Extension; - STR StrPtr; - - // Depending on extension of filename, use different image readers - // Get extension - StrPtr = strstr( ImageFile, ExtensionSep ); - - if ( StrPtr == NULL ) - { - // No extension given, use default internal loader extension - DbgMessage( TOPIC_HIMAGE, DBG_LEVEL_2, "No extension given, using default" ); - strcat( ImageFile, ".PCX" ); - strcpy( Extension, ".PCX" ); - } - else - { - strcpy( Extension, StrPtr+1 ); - } - - // Determine type from Extension - do - { - iFileLoader = UNKNOWN_FILE_READER; - - if ( _stricmp( Extension, "PCX" ) == 0 ) - { - iFileLoader = PCX_FILE_READER; - break; - } - else if ( _stricmp( Extension, "TGA" ) == 0 ) - { - iFileLoader = TGA_FILE_READER; - break; - } - else if ( _stricmp( Extension, "STI" ) == 0 ) - { -#ifdef USE_VFS - // see if there is a .jpc file first and when that fails, try .sti - vfs::Path str(ImageFile); - vfs::String::str_t const& findext = str.c_wcs(); - vfs::String::size_t dot = findext.find_last_of(vfs::Const::DOT()); - vfs::String fname = findext.substr(0,dot).append(CONST_DOTJPC); - if(getVFS()->fileExists(fname)) - { - iFileLoader = JPC_FILE_READER; - strncpy(ImageFile, fname.utf8().c_str(), fname.length()); - ImageFile[fname.length()] = 0; - break; - } -#endif - iFileLoader = STCI_FILE_READER; - break; - } - else if ( _stricmp( Extension, "PNG" ) == 0 ) - { - iFileLoader = PNG_FILE_READER; - break; - } -#ifdef USE_VFS - else if ( vfs::StrCmp::Equal(Extension, L"jpc.7z") ) - { - iFileLoader = JPC_FILE_READER; - break; - } -#endif - } while ( FALSE ); - - // Determine if resource exists before creating image structure - if ( !FileExists( ImageFile ) ) - { - //If in debig, make fatal! -#ifdef _DEBUG - //FatalError( "Resource file %s does not exist.", ImageFile ); -#endif - DbgMessage( TOPIC_HIMAGE, DBG_LEVEL_2, String("Resource file %s does not exist.", ImageFile) ); - - return( NULL ); - } -#else std::string filename(ImageFile); iFileLoader = ImageFileType::getFileReaderType(filename, order); if ( iFileLoader == UNKNOWN_FILE_READER ) @@ -222,7 +142,6 @@ HIMAGE CreateImage( SGPFILENAME ImageFile, UINT16 fContents, ImageFileType::Test return( NULL ); } -#endif // Create memory for image structure hImage = (HIMAGE)MemAlloc( sizeof( image_type ) ); diff --git a/Standard Gaming Platform/impTGA.cpp b/Standard Gaming Platform/impTGA.cpp index 15f2d89db..8c4564c06 100644 --- a/Standard Gaming Platform/impTGA.cpp +++ b/Standard Gaming Platform/impTGA.cpp @@ -269,29 +269,6 @@ BOOLEAN ReadUncompRGBImage( HIMAGE hImage, HWFILE hFile, UINT8 uiImgID, UINT8 ui hImage->fFlags |= IMAGE_BITMAPDATA; } - #if 0 - // 32 bit not yet allowed in SGP - else if ( uiImagePixelSize == 32 ) - { - iNumValues = uiWidth * uiHeight; - - for ( i=0 ; i "; - - // Reset the pressed keys - gfKeyState[ ALT ] = FALSE; - gfKeyState[ 219 ] = FALSE; // "\" -#endif } } } @@ -1018,30 +1006,6 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC SHOWEXCEPTION(ex); } -#if 0 - else - { - // Windows hasn't processed any messages, therefore we handle the rest -#ifdef LUACONSOLE - PollConsole( ); -#endif - - if (gfApplicationActive == FALSE) - { - // Well we got nothing to do but to wait for a message to activate - WaitMessage(); - } - else - { - // Well, the game is active, so we handle the game stuff - GameLoop(); - - // After this frame, reset input given flag - gfSGPInputReceived = FALSE; - } - } - } -#endif // This is the normal exit point diff --git a/Standard Gaming Platform/shading.cpp b/Standard Gaming Platform/shading.cpp index 0480410fa..321551393 100644 --- a/Standard Gaming Platform/shading.cpp +++ b/Standard Gaming Platform/shading.cpp @@ -232,29 +232,6 @@ void BuildIntensityTable(void) -#if 0 - - UINT32 lumin; - UINT32 rmod, gmod, bmod; - - for(red=0; red < 256; red+=4) - for(green=0; green < 256; green+=4) - for(blue=0; blue < 256; blue+=4) - { - index=Get16BPPColor(FROMRGB(red, green, blue)); - - lumin=( red*299/1000)+ ( green*587/1000 ) + ( blue*114/1000 ); - - //lumin = __min(lumin, 255); - rmod=(255*lumin)/256; - gmod=(100*lumin)/256; - bmod=(100*lumin)/256; - - //rmod = __m( 255, rmod ); - - IntensityTable[index]=Get16BPPColor( FROMRGB( rmod, gmod , bmod ) ); - } -#endif diff --git a/Standard Gaming Platform/soundman.cpp b/Standard Gaming Platform/soundman.cpp index f0f1cba17..22077f741 100644 --- a/Standard Gaming Platform/soundman.cpp +++ b/Standard Gaming Platform/soundman.cpp @@ -1852,16 +1852,6 @@ UINT32 uiCount; return(FALSE); } -// Lesh modifications -// Sound debug -static struct SoundLog { - sgp::Logger_ID id; - SoundLog() { - id = sgp::Logger::instance().createLogger(); - sgp::Logger::instance().connectFile(id, SndDebugFileName, true, sgp::Logger::FLUSH_ON_DELETE); - } -} s_SoundLog; - //***************************************************************************************** // SoundLog // Writes string into log file @@ -1872,6 +1862,13 @@ static struct SoundLog { //***************************************************************************************** void SoundLog(CHAR8 *strMessage) { + static struct SoundLog { + sgp::Logger_ID id; + SoundLog() { + id = sgp::Logger::instance().createLogger(); + sgp::Logger::instance().connectFile(id, SndDebugFileName, true, sgp::Logger::FLUSH_ON_DELETE); + } + } s_SoundLog; #ifndef USE_VFS if ((SndDebug = fopen(SndDebugFileName, "a+t")) != NULL) { diff --git a/Standard Gaming Platform/stringicmp.cpp b/Standard Gaming Platform/stringicmp.cpp index b354b5796..b1881ed43 100644 --- a/Standard Gaming Platform/stringicmp.cpp +++ b/Standard Gaming Platform/stringicmp.cpp @@ -11,20 +11,6 @@ bool TStringiLess::operator() (std::string const& s1, std::string const& s2) con // An MSVC compliance issue... //using std::toupper; -#if 0 - std::string::const_iterator p1 = s1.begin(); - std::string::const_iterator p2 = s2.begin(); - - while (p1 != s1.end() && p2 != s2.end() && toupper(*p1) == toupper(*p2)) { - ++p1; - ++p2; - } - - if (p1 == s1.end()) return p2 != s2.end(); - if (p2 == s2.end()) return false; - - return toupper(*p1) < toupper(*p2); -#else const char *p1 = s1.c_str(); const char *p2 = s2.c_str(); @@ -37,5 +23,4 @@ bool TStringiLess::operator() (std::string const& s1, std::string const& s2) con if (!*p2) return false; return toupper(*p1) < toupper(*p2); -#endif } diff --git a/Standard Gaming Platform/video.cpp b/Standard Gaming Platform/video.cpp index 6104b6792..0432e5121 100644 --- a/Standard Gaming Platform/video.cpp +++ b/Standard Gaming Platform/video.cpp @@ -1493,13 +1493,6 @@ void ScrollJA2Background(UINT32 uiDirection, INT16 sScrollXIncrement, INT16 sScr #endif -#if 0 - StripRegions[ 0 ].left = gsVIEWPORT_START_X ; - StripRegions[ 0 ].right = gsVIEWPORT_END_X ; - StripRegions[ 0 ].top = gsVIEWPORT_WINDOW_START_Y ; - StripRegions[ 0 ].bottom = gsVIEWPORT_WINDOW_END_Y ; - usNumStrips = 1; -#endif for ( cnt = 0; cnt < usNumStrips; cnt++ ) { @@ -1596,28 +1589,6 @@ void ScrollJA2Background(UINT32 uiDirection, INT16 sScrollXIncrement, INT16 sScr ExecuteVideoOverlaysToAlternateBuffer( BACKBUFFER ); -#if 0 - - // Erase mouse from old position - if (gMouseCursorBackground[ uiCurrentMouseBackbuffer ].fRestore == TRUE ) - { - - do - { - ReturnCode = IDirectDrawSurface2_SGPBltFast(gpBackBuffer, usMouseXPos, usMouseYPos, gMouseCursorBackground[uiCurrentMouseBackbuffer].pSurface, (LPRECT)&MouseRegion, DDBLTFAST_NOCOLORKEY); - if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING)) - { - DirectXAttempt ( ReturnCode, __LINE__, __FILE__ ); - - if (ReturnCode == DDERR_SURFACELOST || (IS_ERROR(ReturnCode) && ++iDXLoopCount > iMaxDXLoopCount)) - { - - } - } - } while (ReturnCode != DD_OK); - } - -#endif } @@ -1786,14 +1757,6 @@ void RefreshScreen(void *DummyVariable) // Either Method (1) or (2) // { -#if 0 - if ( gfRenderScroll ) - { - ScrollJA2Background( guiScrollDirection, gsScrollXIncrement, gsScrollYIncrement, gpPrimarySurface, gpBackBuffer, TRUE, PREVIOUS_MOUSE_DATA ); - // ScrollJA2Background( guiScrollDirection, gsScrollXIncrement, gsScrollYIncrement, gpBackBuffer, gpBackBuffer, TRUE, PREVIOUS_MOUSE_DATA ); - gfForceFullScreenRefresh = TRUE; - } -#endif if (gfForceFullScreenRefresh == TRUE) { // diff --git a/Standard Gaming Platform/vobject.cpp b/Standard Gaming Platform/vobject.cpp index 505166699..d8ade50c9 100644 --- a/Standard Gaming Platform/vobject.cpp +++ b/Standard Gaming Platform/vobject.cpp @@ -1,12 +1,12 @@ - #include "DirectDraw Calls.h" - #include - #include "debug.h" - #include "video.h" - #include "himage.h" - #include "vobject.h" - #include "wcheck.h" - #include "vobject_blitters.h" - #include "sgp.h" +#include "DirectDraw Calls.h" +#include +#include "debug.h" +#include "video.h" +#include "himage.h" +#include "vobject.h" +#include "wcheck.h" +#include "vobject_blitters.h" +#include "sgp.h" #include @@ -589,6 +589,7 @@ HVOBJECT CreateVideoObject( VOBJECT_DESC *VObjectDesc ) hVObject->usNumberOf16BPPObjects = 1; hVObject->ubBitDepth = hImage->ubBitDepth; + strncpy(hVObject->ImageFile, hImage->ImageFile, SGPFILENAME_LEN); if ( VObjectDesc->fCreateFlags & VOBJECT_CREATE_FROMFILE ) { @@ -627,6 +628,7 @@ HVOBJECT CreateVideoObject( VOBJECT_DESC *VObjectDesc ) hVObject->usNumberOf16BPPObjects = 1; hVObject->ubBitDepth = hImage->ubBitDepth; + strncpy(hVObject->ImageFile, hImage->ImageFile, SGPFILENAME_LEN); if ( VObjectDesc->fCreateFlags & VOBJECT_CREATE_FROMFILE ) { @@ -656,6 +658,7 @@ HVOBJECT CreateVideoObject( VOBJECT_DESC *VObjectDesc ) hVObject->pETRLEObject = TempETRLEData.pETRLEObject; hVObject->pPixData = TempETRLEData.pPixData; hVObject->uiSizePixData = TempETRLEData.uiSizePixData; + strncpy(hVObject->ImageFile, hImage->ImageFile, SGPFILENAME_LEN); // Set palette from himage if ( hImage->ubBitDepth == 8 ) @@ -897,9 +900,10 @@ UINT32 count; // // ******************************************************************* -// High level blit function encapsolates ALL effects and BPP +// High level blit function encapsulates ALL effects and BPP BOOLEAN BltVideoObjectToBuffer( UINT16 *pBuffer, UINT32 uiDestPitchBYTES, HVOBJECT hSrcVObject, UINT16 usIndex, INT32 iDestX, INT32 iDestY, INT32 fBltFlags, blt_fx *pBltFx ) { + CHAR8 errorText[512]; // Sometimes an exception is thrown in that method. //BF __try { @@ -920,24 +924,18 @@ BOOLEAN BltVideoObjectToBuffer( UINT16 *pBuffer, UINT32 uiDestPitchBYTES, HVOBJE switch( hSrcVObject->ubBitDepth ) { case 32: - SGP_THROW_IFFALSE(usIndex < hSrcVObject->usNumberOf16BPPObjects, L"index larger that number images"); + sprintf(errorText, "Video object index is larger than the number of images. Filename: %s", hSrcVObject->ImageFile); + SGP_THROW_IFFALSE(usIndex < hSrcVObject->usNumberOf16BPPObjects, errorText); image = &hSrcVObject->p16BPPObject[usIndex]; -#if 0 - Blt16BPPTo16BPPTrans( pBuffer, uiDestPitchBYTES, - image->p16BPPData, image->usWidth * sizeof(UINT16), - iDestX, iDestY, - 0, 0, image->usWidth, image->usHeight, - 0 ); -#else Blt32BPPTo16BPPTrans( pBuffer, uiDestPitchBYTES, (UINT32*)image->p16BPPData, image->usWidth * sizeof(UINT32), iDestX, iDestY, 0, 0, image->usWidth, image->usHeight); -#endif break; case 16: - SGP_THROW_IFFALSE(usIndex < hSrcVObject->usNumberOf16BPPObjects, L"index larger that number images"); + sprintf(errorText, "Video object index is larger than the number of images. Filename: %s", hSrcVObject->ImageFile); + SGP_THROW_IFFALSE(usIndex < hSrcVObject->usNumberOf16BPPObjects, errorText); image = &hSrcVObject->p16BPPObject[usIndex]; if ( fBltFlags & VO_BLT_SRCTRANSPARENCY ) { @@ -957,8 +955,8 @@ BOOLEAN BltVideoObjectToBuffer( UINT16 *pBuffer, UINT32 uiDestPitchBYTES, HVOBJE break; case 8: - - SGP_THROW_IFFALSE( hSrcVObject->usNumberOfObjects > usIndex, L"Video object index is larger than the number of subimages"); + sprintf(errorText, "Video object index is larger than the number of sub images. Filename: %s", hSrcVObject->ImageFile); + SGP_THROW_IFFALSE( hSrcVObject->usNumberOfObjects > usIndex, errorText); // Switch based on flags given do { @@ -1569,9 +1567,10 @@ BOOLEAN BltVideoObjectOutline(UINT32 uiDestVSurface, HVOBJECT hSrcVObject, UINT1 BOOLEAN BltVideoObjectOutlineShadowFromIndex(UINT32 uiDestVSurface, UINT32 uiSrcVObject, UINT16 usIndex, INT32 iDestX, INT32 iDestY ) { - UINT16 *pBuffer; - UINT32 uiPitch; - HVOBJECT hSrcVObject; + CHAR8 errorText[512]; + UINT16 *pBuffer; + UINT32 uiPitch; + HVOBJECT hSrcVObject; // Lock video surface pBuffer = (UINT16*)LockVideoSurface( uiDestVSurface, &uiPitch ); @@ -1600,14 +1599,16 @@ BOOLEAN BltVideoObjectOutlineShadowFromIndex(UINT32 uiDestVSurface, UINT32 uiSrc } else if(hSrcVObject->ubBitDepth == 16) { - SGP_THROW_IFFALSE(usIndex < hSrcVObject->usNumberOf16BPPObjects, L"index larger that number images"); + sprintf(errorText, "Video object index is larger than the number of images. Filename: %s", hSrcVObject->ImageFile); + SGP_THROW_IFFALSE(usIndex < hSrcVObject->usNumberOf16BPPObjects, errorText); SixteenBPPObjectInfo &image = hSrcVObject->p16BPPObject[0]; Blt16BPPTo16BPPTransShadow(pBuffer, uiPitch, image.p16BPPData, image.usWidth * sizeof(UINT16), iDestX, iDestY, 0, 0, image.usWidth, image.usHeight, 0x1F); } else if(hSrcVObject->ubBitDepth == 32) { - SGP_THROW_IFFALSE(usIndex < hSrcVObject->usNumberOf16BPPObjects, L"index larger that number images"); + sprintf(errorText, "Video object index is larger than the number of images. Filename: %s", hSrcVObject->ImageFile); + SGP_THROW_IFFALSE(usIndex < hSrcVObject->usNumberOf16BPPObjects, errorText); SixteenBPPObjectInfo &image = hSrcVObject->p16BPPObject[0]; Blt32BPPTo16BPPTransShadow(pBuffer, uiPitch, (UINT32*)image.p16BPPData, image.usWidth * sizeof(UINT32), iDestX, iDestY, 0, 0, image.usWidth, image.usHeight); diff --git a/Standard Gaming Platform/vobject.h b/Standard Gaming Platform/vobject.h index 98e1ca207..0cdd55533 100644 --- a/Standard Gaming Platform/vobject.h +++ b/Standard Gaming Platform/vobject.h @@ -84,30 +84,26 @@ typedef struct // The video object contains different data based on it's type, compressed or not typedef struct TAG_HVOBJECT { - UINT32 fFlags; // Special flags - UINT32 uiSizePixData; // ETRLE data size - SGPPaletteEntry *pPaletteEntry; // 8BPP Palette - COLORVAL TransparentColor; // Defaults to 0,0,0 - UINT16 *p16BPPPalette; // A 16BPP palette used for 8->16 blits + UINT32 fFlags; // Special flags + UINT32 uiSizePixData; // ETRLE data size + SGPPaletteEntry *pPaletteEntry; // 8BPP Palette + COLORVAL TransparentColor; // Defaults to 0,0,0 + UINT16 *p16BPPPalette; // A 16BPP palette used for 8->16 blits - PTR pPixData; // ETRLE pixel data - ETRLEObject *pETRLEObject; // Object offset data etc + PTR pPixData; // ETRLE pixel data + ETRLEObject *pETRLEObject; // Object offset data etc SixteenBPPObjectInfo *p16BPPObject; - UINT16 *pShades[HVOBJECT_SHADE_TABLES]; // Shading tables - UINT16 *pShadeCurrent; - UINT16 *pGlow; // glow highlight table - UINT8 *pShade8; // 8-bit shading index table - UINT8 *pGlow8; // 8-bit glow table - ZStripInfo **ppZStripInfo; // Z-value strip info arrays - - UINT16 usNumberOf16BPPObjects; - UINT16 usNumberOfObjects; // Total number of objects - UINT8 ubBitDepth; // BPP - - // Reserved for added room and 32-byte boundaries - BYTE bReserved[ 1 ]; - + UINT16 *pShades[HVOBJECT_SHADE_TABLES]; // Shading tables + UINT16 *pShadeCurrent; + UINT16 *pGlow; // glow highlight table + UINT8 *pShade8; // 8-bit shading index table + UINT8 *pGlow8; // 8-bit glow table + ZStripInfo **ppZStripInfo; // Z-value strip info arrays + UINT16 usNumberOf16BPPObjects; + UINT16 usNumberOfObjects; // Total number of objects + UINT8 ubBitDepth; // BPP + SGPFILENAME ImageFile; } SGPVObject, *HVOBJECT; diff --git a/Standard Gaming Platform/vobject_blitters.cpp b/Standard Gaming Platform/vobject_blitters.cpp index 8d527293c..999aa63e6 100644 --- a/Standard Gaming Platform/vobject_blitters.cpp +++ b/Standard Gaming Platform/vobject_blitters.cpp @@ -224,7 +224,6 @@ BOOLEAN Blt32BPPTo16BPPTransShadow(UINT16 *pDst, UINT32 uiDstPitch, UINT32 *pSrc //alpha = 255; if(alpha > 0) { -#if 1 // the darker shade tmpVal = ShadeTable[*pDstPtr]; @@ -249,9 +248,6 @@ BOOLEAN Blt32BPPTo16BPPTransShadow(UINT16 *pDst, UINT32 uiDstPitch, UINT32 *pSrc newcolor = FROMRGB(red,green,blue); *pDstPtr = Get16BPPColor(newcolor); -#else - *pDstPtr = ShadeTable[*pDstPtr]; -#endif } pSrcPtr++; pDstPtr++; @@ -7258,7 +7254,6 @@ BOOLEAN Blt16BPPTo16BPPTrans(UINT16 *pDest, UINT32 uiDestPitch, UINT16 *pSrc, UI pDestPtr = (UINT16*)((UINT8 *)pDest+(iDestYPos*uiDestPitch)+(iDestXPos*2)); uiLineSkipDest = uiDestPitch - (uiWidth*2); uiLineSkipSrc = uiSrcPitch - (uiWidth*2); -#if 1 do { UINT32 w = uiWidth; @@ -7273,36 +7268,6 @@ BOOLEAN Blt16BPPTo16BPPTrans(UINT16 *pDest, UINT32 uiDestPitch, UINT16 *pSrc, UI pDestPtr = (UINT16*)((UINT8*)pDestPtr + uiLineSkipDest); } while (--uiHeight != 0); -#else -__asm { - mov esi, pSrcPtr - mov edi, pDestPtr - mov ebx, uiHeight - mov dx, usTrans - -BlitNewLine: - mov ecx, uiWidth - -Blit2: - mov ax, [esi] - cmp ax, dx - je Blit3 - - mov [edi], ax - -Blit3: - add esi, 2 - add edi, 2 - dec ecx - jnz Blit2 - - add edi, uiLineSkipDest - add esi, uiLineSkipSrc - dec ebx - jnz BlitNewLine - - } -#endif return(TRUE); } @@ -7318,7 +7283,6 @@ BOOLEAN Blt16BPPTo16BPPTransShadow(UINT16 *pDest, UINT32 uiDestPitch, UINT16 *pS pDestPtr = (UINT16*)((UINT8 *)pDest + (iDestYPos * uiDestPitch) + (iDestXPos * 2)); uiLineSkipDest = uiDestPitch - (uiWidth * 2); uiLineSkipSrc = uiSrcPitch - (uiWidth * 2); -#if 1 do { UINT32 w = uiWidth; @@ -7336,7 +7300,6 @@ BOOLEAN Blt16BPPTo16BPPTransShadow(UINT16 *pDest, UINT32 uiDestPitch, UINT16 *pS pDestPtr = (UINT16*)((UINT8*)pDestPtr + uiLineSkipDest); } while (--uiHeight != 0); -#endif return TRUE; } @@ -9649,51 +9612,6 @@ BOOLEAN Blt8BPPDataTo16BPPBufferTransShadowZNBAlpha(UINT16 *pBuffer, UINT32 uiDe } -#if 0 - -BlitNTL4: - - // TEST FOR Z FIRST! - mov ax, [ebx] - cmp ax, usZValue - ja BlitNTL8 - - // Write it NOW! - jmp BlitNTL7 - -BlitNTL8: - - test uiLineFlag, 1 - jz BlitNTL6 - - test edi, 2 - jz BlitNTL5 - jmp BlitNTL9 - -BlitNTL6: - test edi, 2 - jnz BlitNTL5 - -BlitNTL7: - - // Write normal z value - mov ax, usZValue - mov [ebx], ax - jmp BlitNTL10 - -BlitNTL9: - - // Write high z - mov ax, 32767 - mov [ebx], ax - -BlitNTL10: - - xor eax, eax - mov al, [esi] - mov ax, [edx+eax*2] - mov [edi], ax -#endif /********************************************************************************************** diff --git a/Strategic/Auto Resolve.cpp b/Strategic/Auto Resolve.cpp index 087ec7e1a..c602e12c7 100644 --- a/Strategic/Auto Resolve.cpp +++ b/Strategic/Auto Resolve.cpp @@ -2204,19 +2204,6 @@ void CreateAutoResolveInterface() ubRegMilitia += bonusRegularMilitia; ubGreenMilitia += bonusGreenMilitia; - // This block should be unnecessary. If the counts do not line up, there is a bug. -#if 0 - while( ubEliteMilitia + ubRegMilitia + ubGreenMilitia < gpAR->ubCivs ) - { - switch( PreRandom( 3 ) ) - { - case 0: ubEliteMilitia++; break; - case 1: ubRegMilitia++; break; - case 2: ubGreenMilitia++; break; - } - } -#endif - cnt = 0; // Add the militia in this sector ARCreateMilitiaSquad( &cnt, ubEliteMilitia, ubRegMilitia, ubGreenMilitia, gpAR->ubSectorX, gpAR->ubSectorY); diff --git a/Strategic/CMakeLists.txt b/Strategic/CMakeLists.txt new file mode 100644 index 000000000..8e15ba341 --- /dev/null +++ b/Strategic/CMakeLists.txt @@ -0,0 +1,66 @@ +set(StrategicSrc +"${CMAKE_CURRENT_SOURCE_DIR}/AI Viewer.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/ASD.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Assignments.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Auto Resolve.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Campaign Init.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Creature Spreading.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Facilities.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Game Clock.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Game Event Hook.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Game Events.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Game Init.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Hourly Update.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Ja25 Strategic Ai.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Luaglobal.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/LuaInitNPCs.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Map Screen Helicopter.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Map Screen Interface Border.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Map Screen Interface Bottom.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Map Screen Interface Map Inventory.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Map Screen Interface Map.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Map Screen Interface TownMine Info.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Map Screen Interface.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/MapScreen Quotes.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/mapscreen.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Meanwhile.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Merc Contract.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/MilitiaIndividual.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/MilitiaSquads.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/MiniEvents.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Player Command.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/PreBattle Interface.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Queen Command.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Quest Debug System.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Quests.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Rebel Command.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Reinforcement.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Scheduling.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Strategic AI.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Strategic Event Handler.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Strategic Merc Handler.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Strategic Mines LUA.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Strategic Mines.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Strategic Movement Costs.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Strategic Movement.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Strategic Pathing.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Strategic Status.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Strategic Town Loyalty.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/strategic town reputation.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Strategic Turns.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/strategic.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/strategicmap.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Town Militia.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/UndergroundInit.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Army.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Bloodcats.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_CoolnessBySector.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Creatures.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_ExtraItems.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Facilities.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_FacilityTypes.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Minerals.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_SectorNames.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_SquadNames.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_UniformColors.cpp" +PARENT_SCOPE) diff --git a/Strategic/Game Event Hook.cpp b/Strategic/Game Event Hook.cpp index ba2fa54ec..6c2ea4287 100644 --- a/Strategic/Game Event Hook.cpp +++ b/Strategic/Game Event Hook.cpp @@ -101,18 +101,6 @@ BOOLEAN ExecuteStrategicEvent( STRATEGICEVENT *pEvent ) { BOOLEAN bMercDayOne = FALSE; -// BF : file access is bad, especially if a function is called so often. -#if 0 - // Kaiden: Opening the INI File - CIniReader iniReader("..\\Ja2_Options.ini"); - - if(is_networked) memset(&iniReader, 0, sizeof (CIniReader) );//disable ini in mp (taking default values) - - //Kaiden: Getting Value for MERC Available on Day one? - // for some reason, this can't be in gamesettings.cpp - // or it won't work. - bMercDayOne = iniReader.ReadBoolean("Options","MERC_DAY_ONE",FALSE); -#endif DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"ExecuteStrategicEvent"); if( gGameExternalOptions.gfEnableEmergencyButton_SkipStrategicEvents && _KeyDown( NUM_LOCK ) ) diff --git a/Strategic/LuaInitNPCs.cpp b/Strategic/LuaInitNPCs.cpp index c379eab2b..e799bb236 100644 --- a/Strategic/LuaInitNPCs.cpp +++ b/Strategic/LuaInitNPCs.cpp @@ -12786,22 +12786,7 @@ static bool locationStringToCoordinates_AltSector(std::string loc, UINT8* x, UIN } // gather column -#if 0 - loc = loc.substr(1); - stringstream ss = stringstream(); - if (loc[0] >= '0' && loc[0] <= '9') - { - ss << loc[0]; - loc = loc.substr(1); - } - if (loc[0] >= '0' && loc[0] <= '9') - { - ss << loc[0]; - loc = loc.substr(1); - } -#else stringstream ss(loc.substr(1)); -#endif int col = 0; ss >> col; if (col >= 1 && col <= 16) @@ -12840,22 +12825,7 @@ static bool locationStringToCoordinates(std::string loc, UINT8* x, UINT8* y, UIN } // gather column -#if 0 - loc = loc.substr(1); - stringstream ss = stringstream(); - if (loc[0] >= '0' && loc[0] <= '9') - { - ss << loc[0]; - loc = loc.substr(1); - } - if (loc[0] >= '0' && loc[0] <= '9') - { - ss << loc[0]; - loc = loc.substr(1); - } -#else stringstream ss(loc); -#endif int col = 0; ss >> col; if (col >= 1 && col <= 16) diff --git a/Strategic/Map Screen Interface Border.cpp b/Strategic/Map Screen Interface Border.cpp index 213559d09..4155783dd 100644 --- a/Strategic/Map Screen Interface Border.cpp +++ b/Strategic/Map Screen Interface Border.cpp @@ -124,7 +124,7 @@ BOOLEAN LoadMapBorderGraphics( void ) { FilenameForBPP( "INTERFACE\\MBS.sti", VObjectDesc.ImageFile ); } - else if (iResolution == _1280x720) + else if (isWidescreenUI()) { FilenameForBPP("INTERFACE\\MBS_1280x720.sti", VObjectDesc.ImageFile); } diff --git a/Strategic/Map Screen Interface Bottom.cpp b/Strategic/Map Screen Interface Bottom.cpp index 7b975bb87..f2c1845fa 100644 --- a/Strategic/Map Screen Interface Bottom.cpp +++ b/Strategic/Map Screen Interface Bottom.cpp @@ -266,7 +266,7 @@ void HandleLoadOfMapBottomGraphics( void ) { FilenameForBPP( "INTERFACE\\map_screen_bottom.sti", VObjectDesc.ImageFile ); } - else if (iResolution == _1280x720) + else if (isWidescreenUI()) { FilenameForBPP("INTERFACE\\map_screen_bottom_1280x720.sti", VObjectDesc.ImageFile); } @@ -1292,7 +1292,7 @@ void EnableDisableBottomButtonsAndRegions( void ) { DisableButton( giMapInvDoneButton ); } - else + else if (!isWidescreenUI()) { EnableButton( giMapInvDoneButton ); } diff --git a/Strategic/Map Screen Interface Map Inventory.cpp b/Strategic/Map Screen Interface Map Inventory.cpp index c0ab1771a..826e4c7be 100644 --- a/Strategic/Map Screen Interface Map Inventory.cpp +++ b/Strategic/Map Screen Interface Map Inventory.cpp @@ -40,6 +40,7 @@ #include "Interface Items.h" #include "Food.h" // added by Flugente #include "Campaign Types.h" // added by Flugente +#include "mapscreen.h" //forward declarations of common classes to eliminate includes class OBJECTTYPE; @@ -448,7 +449,7 @@ BOOLEAN LoadInventoryPoolGraphic( void ) { sprintf( VObjectDesc.ImageFile, "INTERFACE\\sector_inventory.sti" ); } - else if (iResolution == _1280x720) + else if (isWidescreenUI()) { sprintf(VObjectDesc.ImageFile, "INTERFACE\\sector_inventory_1280x720.sti"); } @@ -1091,24 +1092,8 @@ void SaveSeenAndUnseenItems( void ) //make list of seen items for ( UINT32 i = 0; i < pInventoryPoolList.size(); i++ ) { -#if 0 - if ( pInventoryPoolList[ i ].object.exists() ) - { - pInventoryPoolList[ i ].fExists = TRUE; - pInventoryPoolList[ i ].bVisible = TRUE; - //Check - if(TileIsOutOfBounds( pInventoryPoolList[ i ].sGridNo) && !( pInventoryPoolList[ i ].usFlags & WORLD_ITEM_GRIDNO_NOT_SET_USE_ENTRY_POINT ) ) - { - pInventoryPoolList[ i ].usFlags |= WORLD_ITEM_GRIDNO_NOT_SET_USE_ENTRY_POINT; - - // Display warning..... - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_BETAVERSION, L"Error: Trying to add item ( %d: %s ) to invalid gridno in unloaded sector. Please Report.", pInventoryPoolList[ i ].object.usItem, ItemNames[ pInventoryPoolList[ i ].object.usItem] ); - } - -#else if ( pInventoryPoolList[i].fExists ) { -#endif worldItemsSaveList.push_back(pInventoryPoolList[i]); iExistingItems++; } @@ -3625,45 +3610,6 @@ void HandleMouseInCompatableItemForMapSectorInventory( INT32 iCurrentSlot ) { SOLDIERTYPE *pSoldier = NULL; static BOOLEAN fItemWasHighLighted = FALSE; -#if 0 - if( iCurrentSlot == -1 ) - { - giCompatibleItemBaseTime = 0; - } - - if( fChangedInventorySlots == TRUE ) - { - giCompatibleItemBaseTime = 0; - fChangedInventorySlots = FALSE; - } - - // reset the base time to the current game clock - if( giCompatibleItemBaseTime == 0 ) - { - giCompatibleItemBaseTime = GetJA2Clock( ); - - if( fItemWasHighLighted == TRUE ) - { - fTeamPanelDirty = TRUE; - fMapPanelDirty = TRUE; - fItemWasHighLighted = FALSE; - } - } - - ResetCompatibleItemArray( ); - ResetMapSectorInventoryPoolHighLights( ); - - if( iCurrentSlot == -1 ) - { - return; - } - - // Check also that we're not beyond the resize. - if (pInventoryPoolList.size() < (UINT32)(iCurrentSlot + ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ) )) - { - return; - } -#else //if same slot then before dont recalculate if ( !fChangedInventorySlots ) return; @@ -3689,36 +3635,10 @@ void HandleMouseInCompatableItemForMapSectorInventory( INT32 iCurrentSlot ) } return; } -#endif // given this slot value, check if anything in the displayed sector inventory or on the mercs inventory is compatable if( fShowInventoryFlag ) { -#if 0 - // check if any compatable items in the soldier inventory matches with this item - if( gfCheckForCursorOverMapSectorInventoryItem ) - { - pSoldier = &Menptr[ gCharactersList[ bSelectedInfoChar ].usSolID ]; - if( pSoldier ) - { - if( HandleCompatibleAmmoUIForMapScreen( pSoldier, iCurrentSlot + ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ), TRUE, FALSE ) ) - { - if( GetJA2Clock( ) - giCompatibleItemBaseTime > 100 ) - { - if( fItemWasHighLighted == FALSE ) - { - fTeamPanelDirty = TRUE; - fItemWasHighLighted = TRUE; - } - } - } - } - } - else - { - giCompatibleItemBaseTime = 0; - } -#else //Soldier inventory is shown, highlight those items pSoldier = &Menptr[ gCharactersList[ bSelectedInfoChar ].usSolID ]; if( pSoldier ) @@ -3729,40 +3649,17 @@ void HandleMouseInCompatableItemForMapSectorInventory( INT32 iCurrentSlot ) } fTeamPanelDirty = TRUE; } -#endif } // now handle for the sector inventory if( fShowMapInventoryPool ) { -#if 0 - // check if any compatable items in the soldier inventory matches with this item - if( gfCheckForCursorOverMapSectorInventoryItem ) - { - if( HandleCompatibleAmmoUIForMapInventory( pSoldier, iCurrentSlot, ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ) , TRUE, FALSE ) ) - { - if( GetJA2Clock( ) - giCompatibleItemBaseTime > 100 ) - { - if( fItemWasHighLighted == FALSE ) - { - fItemWasHighLighted = TRUE; - fMapPanelDirty = TRUE; - } - } - } - } - else - { - giCompatibleItemBaseTime = 0; - } -#else if( HandleCompatibleAmmoUIForMapInventory( pSoldier, iCurrentSlot, ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ) , TRUE, FALSE ) ) { fItemWasHighLighted = TRUE;//remember that something is highlighted } fMapPanelDirty = TRUE; -#endif } fChangedInventorySlots = FALSE; @@ -3870,79 +3767,11 @@ void CheckGridNoOfItemsInMapScreenMapInventory() void SortSectorInventory( std::vector& pInventory, UINT32 uiSizeOfArray ) { -#if 0//dnl ch75 011113 return code from v1.12 as current one is terrible slow - //first, compress the inventory by stacking like items that are reachable, while moving empty items towards the back - for (std::vector::iterator iter = pInventory.begin(); iter != pInventory.end(); ++iter) { - //if object exists, we want to try to stack it - if (iter->fExists && iter->object.exists() == true) { - - //ADB TODO if it is active and reachable etc, alternatively if it's on the same gridNo -#if 0 - if (iter->object.ubNumberOfObjects < ItemSlotLimit( iter->object.usItem, STACK_SIZE_LIMIT )) { - std::vector::iterator second = iter; - for (++second; second != pInventory.end(); ++second) { - if (second->object.usItem == iter->object.usItem - && second->object.exists() == true) { - iter->object.AddObjectsToStack(second->object, second->object.ubNumberOfObjects); - if (iter->object.ubNumberOfObjects >= ItemSlotLimit( iter->object.usItem, STACK_SIZE_LIMIT )) { - break; - } - } - } - } -#endif - } - else { - //object does not exist, so compress the list - std::vector::iterator second = iter; - for (++second; second != pInventory.end(); ++second) { - if (second->fExists && second->object.exists() == true) { - *iter = *second; - second->initialize(); - break; - } - } - if (second == pInventory.end()) { - //we reached the end of the list without finding any active item, so we can break out of this loop too! - break; - } - } - } - - //once compressed, we need only sort the existing items - //all empty items should be at the back!!! - std::vector::iterator endSort = pInventory.begin(); - for (unsigned int x = 1; x < pInventory.size(); ++x) { - if (pInventory[x].fExists && pInventory[x].object.exists() == true) { - ++endSort; - } - else { - break; - } - } - ++endSort; - - //ADB I'm not sure qsort will work with OO data, so replace it with stl sort, which is faster anyways - std::sort(pInventory.begin(), endSort); - - //then compress it by removing the empty objects, we know they are at the back - //we want the size to equal x * MAP_INVENTORY_POOL_SLOT_COUNT - for (unsigned int x = 1; x <= pInventory.size() / MAP_INVENTORY_POOL_SLOT_COUNT && pInventory.size() > x * MAP_INVENTORY_POOL_SLOT_COUNT; ++x) { - if (pInventory[x * MAP_INVENTORY_POOL_SLOT_COUNT].fExists == false - && pInventory[x * MAP_INVENTORY_POOL_SLOT_COUNT].object.exists() == false) { - //we have found a page where the first item on the page does not exist, resize to this - //we may have just cut off a blank page leaving the previous page full with no place to put - //any new objects, but ResizeInventoryList after this will take care of that. - pInventory.resize(x * MAP_INVENTORY_POOL_SLOT_COUNT); - } - } -#else #if _ITERATOR_DEBUG_LEVEL > 1//dnl ch75 061113 under debug VS2010 throws exceptions after qsort but not under VS2005 and VS2008, all release version seems to work fine std::sort(pInventory.begin(), pInventory.begin() + uiSizeOfArray); #else qsort((LPVOID)&pInventory.front(), (size_t)uiSizeOfArray, sizeof(WORLDITEM), MapScreenSectorInventoryCompare); #endif -#endif } INT32 MapScreenSectorInventoryCompare( const void *pNum1, const void *pNum2) @@ -3955,31 +3784,10 @@ INT32 MapScreenSectorInventoryCompare( const void *pNum1, const void *pNum2) UINT16 ubItem2Quality; //dnl ch75 071113 without below fix sort will create mess when use empty slots because fExists remain TRUE after item is removed from inventory so decide to rather check ubNumberOfObjects -#if 0 - if(!(pFirst->fExists && pFirst->object.ubNumberOfObjects && pFirst->object.usItem) && (pFirst->fExists | pFirst->object.ubNumberOfObjects | pFirst->object.usItem)) - { - pFirst->fExists = FALSE; - pFirst->object.ubNumberOfObjects = 0; - pFirst->object.usItem = NONE; - return(1); - } - if(!(pSecond->fExists && pSecond->object.ubNumberOfObjects && pSecond->object.usItem) && (pSecond->fExists | pSecond->object.ubNumberOfObjects | pSecond->object.usItem)) - { - pSecond->fExists = FALSE; - pSecond->object.ubNumberOfObjects = 0; - pSecond->object.usItem = NONE; - return(-1); - } - if(!pFirst->fExists) - return(1); - if(!pSecond->fExists) - return(-1); -#else if(!pFirst->object.ubNumberOfObjects) return(1); if(!pSecond->object.ubNumberOfObjects) return(-1); -#endif usItem1Index = pFirst->object.usItem; usItem2Index = pSecond->object.usItem; @@ -4157,20 +3965,7 @@ BOOLEAN SortInventoryPoolQ(void) { if(pInventoryPoolList.size() > 0) { -#if 0//dnl ch75 311013 - for(INT32 iSlotCounter=0; iSlotCounter<(INT32)pInventoryPoolList.size(); iSlotCounter++) - if(pInventoryPoolList[iSlotCounter].object.usItem == NOTHING && pInventoryPoolList[iSlotCounter].object.exists() == false) - { - pInventoryPoolList[iSlotCounter].fExists = FALSE; - pInventoryPoolList[iSlotCounter].bVisible = FALSE; - } SortSectorInventory(pInventoryPoolList, pInventoryPoolList.size()); - iLastInventoryPoolPage = (pInventoryPoolList.size() - 1) / MAP_INVENTORY_POOL_SLOT_COUNT; - if(iCurrentInventoryPoolPage > iLastInventoryPoolPage) - iCurrentInventoryPoolPage = iLastInventoryPoolPage; -#else - SortSectorInventory(pInventoryPoolList, pInventoryPoolList.size()); -#endif } fMapPanelDirty = TRUE; return(TRUE); @@ -6227,8 +6022,8 @@ void HandleItemCooldownFunctions( OBJECTTYPE* itemStack, INT32 deltaSeconds, BOO FLOAT newguntemperature = max(0.0f, guntemperature - tickspassed * cooldownfactor ); // ... calculate new temperature ... -#if 0//def JA2TESTVERSION - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"World: Item temperature lowered from %4.2f to %4.2f", guntemperature, newguntemperature ); +#if JA2TESTVERSION + ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"World: Item temperature lowered from %4.2f to %4.2f", guntemperature, newguntemperature); #endif (*itemStack)[i]->data.bTemperature = newguntemperature; // ... set new temperature @@ -6247,8 +6042,8 @@ void HandleItemCooldownFunctions( OBJECTTYPE* itemStack, INT32 deltaSeconds, BOO (*iter)[i]->data.bTemperature = newtemperature; // ... set new temperature -#if 0//def JA2TESTVERSION - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"World: Item temperature lowered from %4.2f to %4.2f", temperature, newtemperature ); +#if JA2TESTVERSION + ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"World: Item temperature lowered from %4.2f to %4.2f", temperature, newtemperature); #endif // we assume that there can exist only 1 underbarrel weapon per gun diff --git a/Strategic/Map Screen Interface Map.cpp b/Strategic/Map Screen Interface Map.cpp index ce90cf0df..cfa3d83b9 100644 --- a/Strategic/Map Screen Interface Map.cpp +++ b/Strategic/Map Screen Interface Map.cpp @@ -1819,7 +1819,7 @@ BOOLEAN InitializePalettesForMap( void ) if (iResolution >= _640x480 && iResolution < _800x600) strcpy(vs_desc.ImageFile, "INTERFACE\\b_map.pcx"); - else if (iResolution == _1280x720) + else if (isWidescreenUI()) strcpy(vs_desc.ImageFile, "INTERFACE\\b_map_1280x720.pcx"); else if (iResolution < _1024x768) strcpy(vs_desc.ImageFile, "INTERFACE\\b_map_800x600.pcx"); @@ -6717,7 +6717,7 @@ void HandleLowerLevelMapBlit( void ) offsetY = yVal; imageIndex = 0; } - else if (iResolution == _1280x720) + else if (isWidescreenUI()) { offsetX = xVal + 21; offsetY = yVal + 17; diff --git a/Strategic/Merc Contract.cpp b/Strategic/Merc Contract.cpp index 14e42d7d2..727ad39e1 100644 --- a/Strategic/Merc Contract.cpp +++ b/Strategic/Merc Contract.cpp @@ -1373,42 +1373,6 @@ BOOLEAN HandleFiredDeadMerc( SOLDIERTYPE *pSoldier ) { AddCharacterToDeadList( pSoldier ); -#if 0 - //if the dead merc is in the current sector - if( pSoldier->sSectorX == gWorldSectorX && - pSoldier->sSectorY == gWorldSectorY && - pSoldier->bSectorZ == gbWorldSectorZ ) - { - TurnSoldierIntoCorpse( pSoldier, FALSE, FALSE ); - } - else - { - ROTTING_CORPSE_DEFINITION Corpse; - - // Setup some values! - Corpse.ubBodyType = pSoldier->ubBodyType; - Corpse.sGridNo = pSoldier->sInsertionGridNo; - Corpse.dXPos = pSoldier->dXPos; - Corpse.dYPos = pSoldier->dYPos; - Corpse.sHeightAdjustment = pSoldier->sHeightAdjustment; - - SET_PALETTEREP_ID ( Corpse.HeadPal, pSoldier->HeadPal ); - SET_PALETTEREP_ID ( Corpse.VestPal, pSoldier->VestPal ); - SET_PALETTEREP_ID ( Corpse.SkinPal, pSoldier->SkinPal ); - SET_PALETTEREP_ID ( Corpse.PantsPal, pSoldier->PantsPal ); - - Corpse.bDirection = pSoldier->ubDirection; - - // Set time of death - Corpse.uiTimeOfDeath = GetWorldTotalMin( ); - - // Set type - Corpse.ubType = (UINT8)gubAnimSurfaceCorpseID[ pSoldier->ubBodyType][ pSoldier->usAnimState ]; - - //Add the rotting corpse info to the sectors unloaded rotting corpse file - AddRottingCorpseToUnloadedSectorsRottingCorpseFile( pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ, &Corpse); - } -#endif return( TRUE ); } diff --git a/Strategic/Player Command.cpp b/Strategic/Player Command.cpp index 57378482b..efa91292c 100644 --- a/Strategic/Player Command.cpp +++ b/Strategic/Player Command.cpp @@ -523,22 +523,10 @@ BOOLEAN SetThisSectorAsEnemyControlled( INT16 sMapX, INT16 sMapY, INT8 bMapZ, BO UpdateRefuelSiteAvailability( ); } - //shadooow: re-enable quest if player loses control of the N7 prison and quest was disabled previously - if (sMapX == gModSettings.ubMeanwhileInterrogatePOWSectorX && sMapY == gModSettings.ubMeanwhileInterrogatePOWSectorY && gubQuest[QUEST_INTERROGATION] == QUESTCANNOTSTART) - { - gubQuest[QUEST_INTERROGATION] = QUESTNOTSTARTED; - } - //shadooow: re-enable quest if player loses control of the Alma prison and quest was disabled previously - if (sMapX == gModSettings.ubInitialPOWSectorX && sMapY == gModSettings.ubInitialPOWSectorY && gubQuest[QUEST_HELD_IN_ALMA] == QUESTCANNOTSTART) - { - gubQuest[QUEST_HELD_IN_ALMA] = QUESTNOTSTARTED; - } #ifndef JA2UB - //shadooow: re-enable quest if player loses control of the Tixa prison and quest was disabled previously - if (sMapX == gModSettings.ubTixaPrisonSectorX && sMapY == gModSettings.ubTixaPrisonSectorY && gubQuest[QUEST_HELD_IN_TIXA] == QUESTCANNOTSTART) - { - gubQuest[QUEST_HELD_IN_TIXA] = QUESTNOTSTARTED; - } + HandlePOWQuestState(Q_RESET, QUEST_INTERROGATION, sMapX, sMapY, bMapZ); + HandlePOWQuestState(Q_RESET, QUEST_HELD_IN_ALMA, sMapX, sMapY, bMapZ); + HandlePOWQuestState(Q_RESET, QUEST_HELD_IN_TIXA, sMapX, sMapY, bMapZ); #endif // Flugente: reduce workforce SectorInfo[SECTOR( sMapX, sMapY )].usWorkers = SectorInfo[SECTOR( sMapX, sMapY )].usWorkers * gGameExternalOptions.dInitialWorkerRate; diff --git a/Strategic/PreBattle Interface.cpp b/Strategic/PreBattle Interface.cpp index 72ec674af..81909888a 100644 --- a/Strategic/PreBattle Interface.cpp +++ b/Strategic/PreBattle Interface.cpp @@ -2141,6 +2141,15 @@ void PutNonSquadMercsInPlayerGroupOnSquads( GROUP *pGroup, BOOLEAN fExitVehicles // because if this is a simultaneous group attack, the mercs could be coming from different sides, and the // placement screen can't handle mercs on the same squad arriving from difference edges! fSuccess = AddCharacterToSquad( pSoldier, bUniqueVehicleSquad ); + // if we failed, create another squad + if (!fSuccess) + { + bUniqueVehicleSquad = GetFirstEmptySquad(); + if (bUniqueVehicleSquad != -1) + { + fSuccess = AddCharacterToSquad(pSoldier, bUniqueVehicleSquad); + } + } } //CHRISL: So what's supposed to happen in the merc is assigned to a vehicle but fExitVehicles is FALSE? else diff --git a/Strategic/Queen Command.cpp b/Strategic/Queen Command.cpp index c725d71d3..b964eed51 100644 --- a/Strategic/Queen Command.cpp +++ b/Strategic/Queen Command.cpp @@ -41,6 +41,7 @@ #include "Morale.h" #include "CampaignStats.h" // added by Flugente #include "ASD.h" // added by Flugente + #include "Interface Panels.h" #ifdef JA2BETAVERSION extern BOOLEAN gfClearCreatureQuest; @@ -2716,43 +2717,31 @@ void BeginCaptureSquence( ) void EndCaptureSequence( ) { -#ifdef JA2UB -// no UB -#else - +#ifndef JA2UB // Set flag... if( !( gStrategicStatus.uiFlags & STRATEGIC_PLAYER_CAPTURED_FOR_RESCUE ) || !(gStrategicStatus.uiFlags & STRATEGIC_PLAYER_CAPTURED_FOR_ESCAPE) ) { - // CJC Dec 1 2002: fixing multiple captures: - //gStrategicStatus.uiFlags |= STRATEGIC_PLAYER_CAPTURED_FOR_RESCUE; - if ( gubQuest[ QUEST_HELD_IN_ALMA ] == QUESTNOTSTARTED ) { - // CJC Dec 1 2002: fixing multiple captures: gStrategicStatus.uiFlags |= STRATEGIC_PLAYER_CAPTURED_FOR_RESCUE; StartQuest( QUEST_HELD_IN_ALMA, gWorldSectorX, gWorldSectorY ); } - // CJC Dec 1 2002: fixing multiple captures: - //else if ( gubQuest[ QUEST_HELD_IN_ALMA ] == QUESTDONE ) - else if (gubQuest[QUEST_HELD_IN_ALMA] != QUESTINPROGRESS && gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED) + else if (gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED) { - // CJC Dec 1 2002: fixing multiple captures: gStrategicStatus.uiFlags |= STRATEGIC_PLAYER_CAPTURED_FOR_RESCUE; StartQuest(QUEST_HELD_IN_TIXA, gWorldSectorX, gWorldSectorY); } - else if (gubQuest[QUEST_HELD_IN_ALMA] != QUESTINPROGRESS && gubQuest[QUEST_HELD_IN_TIXA] != QUESTINPROGRESS && gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED) + else if (gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED) { StartQuest( QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY ); - // CJC Dec 1 2002: fixing multiple captures: gStrategicStatus.uiFlags |= STRATEGIC_PLAYER_CAPTURED_FOR_ESCAPE; // OK! - Schedule Meanwhile now! HandleInterrogationMeanwhileScene(); } - // CJC Dec 1 2002: fixing multiple captures else { - // !?!? set both flags + // Set both flags if we can't start any of the three POW quests gStrategicStatus.uiFlags |= STRATEGIC_PLAYER_CAPTURED_FOR_RESCUE; gStrategicStatus.uiFlags |= STRATEGIC_PLAYER_CAPTURED_FOR_ESCAPE; } @@ -2760,16 +2749,22 @@ void EndCaptureSequence( ) #endif } +int CalculateMaximumPrisonerAmount() +{ +#ifndef JA2UB + if (gubQuest[QUEST_HELD_IN_ALMA] == QUESTNOTSTARTED) { return std::size(gModSettings.iInitialPOWGridNo); } + if (gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED) { return std::size(gModSettings.iTixaPrisonPOWGridNo); } + if (gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED) { return std::size(gModSettings.iMeanwhileInterrogatePOWGridNo); } +#endif + return 0; +} + void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier ) { - UINT32 i; - BOOLEAN fMadeCorpse; - INT32 iNumEnemiesInSector; - +#ifndef JA2UB AssertNotNIL(pSoldier); // ATE: Check first if ! in player captured sequence already - // CJC Dec 1 2002: fixing multiple captures if ( ( gStrategicStatus.uiFlags & STRATEGIC_PLAYER_CAPTURED_FOR_RESCUE ) && (gStrategicStatus.uiFlags & STRATEGIC_PLAYER_CAPTURED_FOR_ESCAPE) ) { return; @@ -2780,6 +2775,7 @@ void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier ) { pSoldier->stats.bLife = 0; pSoldier->iHealableInjury = 0; // added by SANDRO + BOOLEAN fMadeCorpse; HandleSoldierDeath( pSoldier, &fMadeCorpse ); return; } @@ -2800,32 +2796,31 @@ void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier ) return; } - // ATE: Patch fix If in a vehicle, remove from vehicle... - TakeSoldierOutOfVehicle( pSoldier ); - - HandleMoraleEvent( pSoldier, MORALE_MERC_CAPTURED, pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ ); - - // Change to POW.... - //-add him to a POW assignment/group - if( ( pSoldier->bAssignment != ASSIGNMENT_POW ) ) + if (gStrategicStatus.ubNumCapturedForRescue >= CalculateMaximumPrisonerAmount()) { - SetTimeOfAssignmentChangeForMerc( pSoldier ); + SetTimeOfAssignmentChangeForMerc(pSoldier); + return; } - ChangeSoldiersAssignment( pSoldier, ASSIGNMENT_POW ); - RemoveCharacterFromSquads( pSoldier ); - - WORLDITEM WorldItem; - std::vector pWorldItem; - -#ifdef JA2UB - if (gStrategicStatus.ubNumCapturedForRescue < 3 && (gubQuest[QUEST_HELD_IN_ALMA] == QUESTNOTSTARTED || gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED)) -#else if (gStrategicStatus.ubNumCapturedForRescue < 3 && (gubQuest[QUEST_HELD_IN_ALMA] == QUESTNOTSTARTED || gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED || gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED)) -#endif { - INT32 itemdropoffgridno = -1; + // ATE: Patch fix If in a vehicle, remove from vehicle... + TakeSoldierOutOfVehicle(pSoldier); + HandleMoraleEvent(pSoldier, MORALE_MERC_CAPTURED, pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ); + + // Change to POW.... + //-add him to a POW assignment/group + if ((pSoldier->bAssignment != ASSIGNMENT_POW)) + { + SetTimeOfAssignmentChangeForMerc(pSoldier); + } + + ChangeSoldiersAssignment(pSoldier, ASSIGNMENT_POW); + RemoveCharacterFromSquads(pSoldier); + + + INT32 itemdropoffgridno = -1; // Is this the first one..? if ( gubQuest[QUEST_HELD_IN_ALMA] == QUESTNOTSTARTED ) { @@ -2837,7 +2832,6 @@ void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier ) pSoldier->usStrategicInsertionData = gModSettings.iInitialPOWGridNo[gStrategicStatus.ubNumCapturedForRescue]; itemdropoffgridno = gModSettings.iInitialPOWItemGridNo[gStrategicStatus.ubNumCapturedForRescue]; } - #ifndef JA2UB else if (gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED) { //-teleport him to Tixa as originally planned @@ -2848,7 +2842,6 @@ void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier ) pSoldier->usStrategicInsertionData = gModSettings.iTixaPrisonPOWGridNo[gStrategicStatus.ubNumCapturedForRescue]; itemdropoffgridno = gModSettings.iTixaPrisonPOWItemGridNo[gStrategicStatus.ubNumCapturedForRescue]; } - #endif else //if ( gubQuest[QUEST_HELD_IN_ALMA] == QUESTDONE ) { //-teleport him to N7 @@ -2860,8 +2853,10 @@ void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier ) } // OK, drop all items! + WORLDITEM WorldItem; + std::vector pWorldItem; UINT32 invsize = pSoldier->inv.size(); - for ( i = 0; i < invsize; ++i ) + for (UINT32 i = 0; i < invsize; ++i ) { if ( pSoldier->inv[i].exists() ) { @@ -2883,34 +2878,40 @@ void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier ) pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO; gStrategicStatus.ubNumCapturedForRescue++; - } - //Bandaging him would prevent him from dying (due to low HP) - pSoldier->bBleeding = 0; + //Bandaging him would prevent him from dying (due to low HP) + pSoldier->bBleeding = 0; - // wake him up - if ( pSoldier->flags.fMercAsleep ) - { - PutMercInAwakeState( pSoldier ); - pSoldier->flags.fForcedToStayAwake = FALSE; - } + // wake him up + if ( pSoldier->flags.fMercAsleep ) + { + PutMercInAwakeState( pSoldier ); + pSoldier->flags.fForcedToStayAwake = FALSE; + } - //Set his life to 50% + or - 10 HP. - INT8 oldlife = pSoldier->stats.bLife; - pSoldier->stats.bLife = max(35, pSoldier->stats.bLifeMax / 2); + //Set his life to 50% + or - 10 HP. + INT8 oldlife = pSoldier->stats.bLife; + pSoldier->stats.bLife = max(35, pSoldier->stats.bLifeMax / 2); - if ( pSoldier->stats.bLife >= 45 ) - { - pSoldier->stats.bLife += (INT8)(10 - Random( 21 ) ); - } + if ( pSoldier->stats.bLife >= 45 ) + { + pSoldier->stats.bLife += (INT8)(10 - Random( 21 ) ); + } - // SANDRO - make the lost life insta-healable - pSoldier->iHealableInjury = ((pSoldier->stats.bLifeMax - pSoldier->stats.bLife) * 100); + // SANDRO - make the lost life insta-healable + pSoldier->iHealableInjury = ((pSoldier->stats.bLifeMax - pSoldier->stats.bLife) * 100); - // make him quite exhausted when found - pSoldier->bBreath = pSoldier->bBreathMax = 50; - pSoldier->sBreathRed = 0; - pSoldier->flags.fMercCollapsedFlag = FALSE; + // make him quite exhausted when found + pSoldier->bBreath = pSoldier->bBreathMax = 50; + pSoldier->sBreathRed = 0; + pSoldier->flags.fMercCollapsedFlag = FALSE; + + + RemoveSoldierFromTacticalSector(pSoldier, TRUE); + RemovePlayerFromTeamSlotGivenMercID(pSoldier->ubID); + SelectNextAvailSoldier(pSoldier); + } +#endif } diff --git a/Strategic/Quests.cpp b/Strategic/Quests.cpp index 2e0d25d9d..55b7bb23a 100644 --- a/Strategic/Quests.cpp +++ b/Strategic/Quests.cpp @@ -1596,9 +1596,7 @@ void CheckForQuests( UINT32 uiDay ) { // This function gets called at 8:00 AM time of the day -#ifdef TESTQUESTS ScreenMsg( MSG_FONT_RED, MSG_DEBUG, L"Checking For Quests, Day %d", uiDay ); -#endif #ifdef JA2UB // ------------------------------------------------------------------------------- @@ -1609,9 +1607,7 @@ void CheckForQuests( UINT32 uiDay ) if( gubQuest[ QUEST_DESTROY_MISSLES ] == QUESTNOTSTARTED ) { StartQuest( QUEST_DESTROY_MISSLES, -1, -1 ); -#ifdef TESTQUESTS ScreenMsg( MSG_FONT_RED, MSG_DEBUG, L"Started DESTORY MISSLES quest"); -#endif } //Ja25: No deliver letter quest, dont start it #else @@ -1623,11 +1619,9 @@ void CheckForQuests( UINT32 uiDay ) if (gubQuest[QUEST_DELIVER_LETTER] == QUESTNOTSTARTED) { StartQuest( QUEST_DELIVER_LETTER, -1, -1 ); -#ifdef TESTQUESTS if (!is_networked) ScreenMsg( MSG_FONT_RED, MSG_DEBUG, L"Started DELIVER LETTER quest"); -#endif } #endif // This quest gets turned OFF through conversation with Miguel - when user hands @@ -1737,9 +1731,84 @@ void GiveQuestRewardPoint( INT16 sQuestSectorX, INT16 sQuestsSectorY, INT8 bExpR } } +void HandlePOWQuestState(PowQuestState state, Quests quest, INT16 mapX, INT16 mapY, INT8 mapZ) +{ +#ifndef JA2UB + bool correctSector = false; + switch (quest) + { + case QUEST_HELD_IN_ALMA: + correctSector = (mapX == gModSettings.ubInitialPOWSectorX && mapY == gModSettings.ubInitialPOWSectorY && mapZ == 0); + break; + case QUEST_INTERROGATION: + correctSector = (mapX == gModSettings.ubMeanwhileInterrogatePOWSectorX && mapY == gModSettings.ubMeanwhileInterrogatePOWSectorY && mapZ == 0); + break; + case QUEST_HELD_IN_TIXA: + correctSector = (mapX == gModSettings.ubTixaPrisonSectorX && mapY == gModSettings.ubTixaPrisonSectorY && mapZ == 0); + break; + default: + break; + } - - - - - + if (correctSector) + { + switch (state) + { + case Q_FAIL: + // End quest if player loses prison + if (gubQuest[quest] == QUESTINPROGRESS) + { + // Quest failed + InternalEndQuest(quest, mapX, mapY, FALSE); + } + else if (gubQuest[quest] == QUESTCANNOTSTART) + { + // Re-enable quest if player loses control of the prison and quest was disabled previously + gubQuest[quest] = QUESTNOTSTARTED; + } + break; + case Q_SUCCESS: + // End quest if player takes control of the prison + if (gubQuest[quest] == QUESTINPROGRESS) + { + // Complete quest + EndQuest(quest, mapX, mapY); + } + else if (gubQuest[quest] == QUESTNOTSTARTED) + { + // Disable quest if player takes control of the prison + gubQuest[quest] = QUESTCANNOTSTART; + } + break; + case Q_RESET: + // Re-enable quest if player loses control of the prison and quest was disabled previously + if (gubQuest[quest] == QUESTCANNOTSTART) + { + gubQuest[quest] = QUESTNOTSTARTED; + } + break; + case Q_END: + if (gubQuest[quest] == QUESTINPROGRESS) + { + EndQuest(quest, mapX, mapY); + HandleNPCDoAction(0, NPC_ACTION_GRANT_EXPERIENCE_3, 0); + } + break; + case Q_LEFT_SECTOR: + // End interrogation quest if we left the sector, but haven't killed all enemies + if (gubQuest[quest] == QUESTINPROGRESS) + { + // Finish quest, although not give points here... + InternalEndQuest(quest, mapX, mapY, FALSE); + // ... give them manually, but halved + GiveQuestRewardPoint(mapX, mapY, 4, NO_PROFILE); + // Also let us know we finished the quest + ResetHistoryFact(quest, mapX, mapY); + } + break; + default: + break; + } + } +#endif +} diff --git a/Strategic/Quests.h b/Strategic/Quests.h index f3a6b017d..71dfca2fd 100644 --- a/Strategic/Quests.h +++ b/Strategic/Quests.h @@ -756,10 +756,13 @@ extern BOOLEAN CheckForNewShipment( void ); extern BOOLEAN CheckTalkerFemale( void ); extern BOOLEAN CheckTalkerUnpropositionedFemale( void ); +enum PowQuestState +{ + Q_FAIL, + Q_SUCCESS, + Q_RESET, + Q_END, + Q_LEFT_SECTOR +}; +void HandlePOWQuestState(PowQuestState state, Quests quest, INT16 mapX, INT16 mapY, INT8 mapZ); #endif - - - - - - diff --git a/Strategic/Strategic Movement.cpp b/Strategic/Strategic Movement.cpp index 9ed5170b1..5b884b569 100644 --- a/Strategic/Strategic Movement.cpp +++ b/Strategic/Strategic Movement.cpp @@ -4453,7 +4453,7 @@ void CheckMembersOfMvtGroupAndComplainAboutBleeding( SOLDIERTYPE *pSoldier ) return; } - // make sure there are members in the group..if so, then run through and make each bleeder compain + // make sure there are members in the group..if so, then run through and make each bleeder complain pPlayer = pGroup->pPlayerList; // is there a player list? @@ -6274,4 +6274,4 @@ void GetInfoFromGroupsInSector( INT16 sSectorX, INT16 sSectorY, UINT8 ubTeam, BO } pGroup = pGroup->next; } -} \ No newline at end of file +} diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index 78dbc2508..11c395634 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -4952,7 +4952,7 @@ UINT32 MapScreenHandle(void) VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE; if (!is_networked) { - if (iResolution == _1280x720) + if (isWidescreenUI()) { FilenameForBPP("INTERFACE\\newgoldpiece3_1280x720.sti", VObjectDesc.ImageFile); } @@ -4972,7 +4972,7 @@ UINT32 MapScreenHandle(void) else { // OJW - 20081204 - change mapscreen interface for MP games - if (iResolution == _1280x720) + if (isWidescreenUI()) { FilenameForBPP("INTERFACE\\mpgoldpiece3_1280x720.sti", VObjectDesc.ImageFile); } @@ -5708,7 +5708,7 @@ UINT32 MapScreenHandle(void) HandleCharBarRender( ); } - if( fShowInventoryFlag || fDisableDueToBattleRoster ) + if( (fShowInventoryFlag && !isWidescreenUI()) || fDisableDueToBattleRoster ) { for( iCounter = 0; iCounter < MAX_SORT_METHODS; iCounter++ ) { @@ -15668,6 +15668,7 @@ void ChangeSelectedInfoChar( INT8 bCharNumber, BOOLEAN fResetSelectedList ) } fCharacterInfoPanelDirty = TRUE; + fResetMapCoords = TRUE; // if showing sector inventory if ( fShowMapInventoryPool ) @@ -17968,4 +17969,4 @@ void initMapViewAndBorderCoordinates(void) UI_MAP.HeliETA.Upper_Popup_Y = (50 + iScreenHeightOffset - 100); UI_MAP.HeliETA.Alternate_Height = 97; } -} \ No newline at end of file +} diff --git a/Strategic/strategicmap.cpp b/Strategic/strategicmap.cpp index 3fe5133a7..e1dd54c47 100644 --- a/Strategic/strategicmap.cpp +++ b/Strategic/strategicmap.cpp @@ -2215,7 +2215,7 @@ BOOLEAN SetCurrentWorldSector( INT16 sMapX, INT16 sMapY, INT8 bMapZ ) // GridNo = NOWHERE, which causes this assertion to fail //CHRISL: There's also an issue with vehicles. Soldiers in any vehicle are considered to be in sGridNo = NOWHERE // This will result in an assertion error, so let's skip the assertion if the merc is assigned to a vehicle - if ( !(MercPtrs[i]->flags.uiStatusFlags & SOLDIER_DEAD) && MercPtrs[i]->bAssignment != VEHICLE && !SPY_LOCATION( MercPtrs[i]->bAssignment ) ) + if (!(MercPtrs[i]->flags.uiStatusFlags & SOLDIER_DEAD) && MercPtrs[i]->bAssignment != VEHICLE && !SPY_LOCATION(MercPtrs[i]->bAssignment) && MercPtrs[i]->bAssignment != ASSIGNMENT_POW) { //Assert( !MercPtrs[i]->bActive || !MercPtrs[i]->bInSector || MercPtrs[i]->sGridNo != NOWHERE || MercPtrs[i]->bVehicleID == iHelicopterVehicleId ); Assert( !MercPtrs[i]->bActive || !MercPtrs[i]->bInSector || !TileIsOutOfBounds( MercPtrs[i]->sGridNo ) || MercPtrs[i]->bVehicleID == iHelicopterVehicleId ); @@ -2265,7 +2265,7 @@ BOOLEAN SetCurrentWorldSector( INT16 sMapX, INT16 sMapY, INT8 bMapZ ) // GridNo = NOWHERE, which causes this assertion to fail //CHRISL: There's also an issue with vehicles. Soldiers in any vehicle are considered to be in sGridNo = NOWHERE // This will result in an assertion error, so let's skip the assertion if the merc is assigned to a vehicle - if ( !(MercPtrs[i]->flags.uiStatusFlags & SOLDIER_DEAD) && MercPtrs[i]->bAssignment != VEHICLE ) + if (!(MercPtrs[i]->flags.uiStatusFlags & SOLDIER_DEAD) && MercPtrs[i]->bAssignment != VEHICLE && MercPtrs[i]->bAssignment != ASSIGNMENT_POW) { //Assert( !MercPtrs[i]->bActive || !MercPtrs[i]->bInSector || MercPtrs[i]->sGridNo != NOWHERE || MercPtrs[i]->bVehicleID == iHelicopterVehicleId ); Assert( !MercPtrs[i]->bActive || !MercPtrs[i]->bInSector || !TileIsOutOfBounds( MercPtrs[i]->sGridNo ) || MercPtrs[i]->bVehicleID == iHelicopterVehicleId ); @@ -3290,23 +3290,9 @@ void UpdateMercsInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) } // ATE: Call actions based on what POW we are on... - if ( gubQuest[QUEST_HELD_IN_ALMA] == QUESTINPROGRESS ) - { - // Complete quest - EndQuest( QUEST_HELD_IN_ALMA, sSectorX, sSectorY ); - - // Do action - HandleNPCDoAction( 0, NPC_ACTION_GRANT_EXPERIENCE_3, 0 ); - } #ifndef JA2UB - else if (gubQuest[QUEST_HELD_IN_TIXA] == QUESTINPROGRESS) - { - // Complete quest - EndQuest(QUEST_HELD_IN_TIXA, sSectorX, sSectorY); - - // Do action - HandleNPCDoAction(0, NPC_ACTION_GRANT_EXPERIENCE_3, 0); - } + HandlePOWQuestState(Q_END, QUEST_HELD_IN_ALMA, sSectorX, sSectorY, bSectorZ); + HandlePOWQuestState(Q_END, QUEST_HELD_IN_TIXA, sSectorX, sSectorY, bSectorZ); #endif } } @@ -4301,6 +4287,68 @@ void JumpIntoAdjacentSector( UINT8 ubTacticalDirection, UINT8 ubJumpCode, INT32 } } +void JumpIntoEscapedSector(UINT8 ubTacticalDirection) +{ + // Remove any incapacitated mercs from current squads and assign them to new squad + UINT32 i = gTacticalStatus.Team[gbPlayerNum].bFirstID; + UINT32 const lastID = gTacticalStatus.Team[gbPlayerNum].bLastID; + INT8 currentSquad = -1; + + for (SOLDIERTYPE* pSoldier = MercPtrs[i]; i <= lastID; ++i, ++pSoldier) + { + // Are we not active in sector + if (!pSoldier->bActive || !pSoldier->bInSector || pSoldier->stats.bLife >= OKLIFE) + { + continue; + } + if (currentSquad == -1) + { + currentSquad = AddCharacterToUniqueSquad(pSoldier); + continue; + } + if (!AddCharacterToSquad(pSoldier, currentSquad)) + { + currentSquad = AddCharacterToUniqueSquad(pSoldier); + } + } + + // Retreat squads that are capable of it + for (size_t i = 0; i < NUMBER_OF_SQUADS; i++) + { + for (size_t j = 0; j < NUMBER_OF_SOLDIERS_PER_SQUAD; j++) + { + SOLDIERTYPE* pSoldier = Squad[i][j]; + if (pSoldier && OK_CONTROLLABLE_MERC(pSoldier)) + { + GROUP* pGroup = GetGroup(pSoldier->ubGroupID); + switch (ubTacticalDirection) + { + case NORTH: + pGroup->ubPrevX = pGroup->ubSectorX; + pGroup->ubPrevY = pGroup->ubSectorY - 1; + break; + case EAST: + pGroup->ubPrevX = pGroup->ubSectorX + 1; + pGroup->ubPrevY = pGroup->ubSectorY; + break; + case SOUTH: + pGroup->ubPrevX = pGroup->ubSectorX; + pGroup->ubPrevY = pGroup->ubSectorY + 1; + break; + case WEST: + pGroup->ubPrevX = pGroup->ubSectorX - 1; + pGroup->ubPrevY = pGroup->ubSectorY; + break; + default: + break; + } + + RetreatGroupToPreviousSector(pGroup); + break; + } + } + } +} void HandleSoldierLeavingSectorByThemSelf( SOLDIERTYPE *pSoldier ) { @@ -4361,17 +4409,7 @@ void AllMercsWalkedToExitGrid( ) (gubAdjacentJumpCode == JUMP_ALL_LOAD_NEW || gubAdjacentJumpCode == JUMP_SINGLE_LOAD_NEW) ) { HandleLoyaltyImplicationsOfMercRetreat( RETREAT_TACTICAL_TRAVERSAL, gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); - - // End inetrrogation quest if we left the sector, but haven't killed all enemies - if ( gWorldSectorX == 7 && gWorldSectorY == 14 && gbWorldSectorZ == 0 && gubQuest[QUEST_INTERROGATION] == QUESTINPROGRESS ) - { - // Finish quest, although not give points here... - InternalEndQuest( QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY, FALSE ); - // ... give them manually, but halved - GiveQuestRewardPoint( gWorldSectorX, gWorldSectorY, 4, NO_PROFILE ); - // Also get us know, we finished the quest - ResetHistoryFact( QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY ); - } + HandlePOWQuestState(Q_END, QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY, gbWorldSectorZ); } //////////////////////////////////////////////////////////////////////////////////////// @@ -4539,17 +4577,7 @@ void AllMercsHaveWalkedOffSector( ) (gubAdjacentJumpCode == JUMP_ALL_LOAD_NEW || gubAdjacentJumpCode == JUMP_SINGLE_LOAD_NEW) ) { HandleLoyaltyImplicationsOfMercRetreat( RETREAT_TACTICAL_TRAVERSAL, gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); - - // End inetrrogation quest if we left the sector, but haven't killed all enemies - if ( gWorldSectorX == 7 && gWorldSectorY == 14 && gbWorldSectorZ == 0 && gubQuest[QUEST_INTERROGATION] == QUESTINPROGRESS ) - { - // Finish quest, although not give points here... - InternalEndQuest( QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY, FALSE ); - // ... give them manually, but halved - GiveQuestRewardPoint( gWorldSectorX, gWorldSectorY, 4, NO_PROFILE ); - // Also get us know, we finished the quest - ResetHistoryFact( QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY ); - } + HandlePOWQuestState(Q_END, QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY, gbWorldSectorZ); } //////////////////////////////////////////////////////////////////////////////////////// } @@ -6921,6 +6949,47 @@ BOOLEAN EscapeDirectionIsValid( INT8 * pbDirection ) } return(*pbDirection != -1); } + +bool IsEscapeDirectionValid(WorldDirections pbDirection) +{ + bool isValid = false; + UINT8 const ubSectorID = SECTOR(gWorldSectorX, gWorldSectorY); + + switch (pbDirection) + { + case NORTH: + if (!(gWorldSectorY - 1 < MINIMUM_VALID_Y_COORDINATE || gMapInformation.sNorthGridNo == NOWHERE || + SectorInfo[ubSectorID].ubTraversability[NORTH_STRATEGIC_MOVE] == GROUNDBARRIER || SectorInfo[ubSectorID].ubTraversability[NORTH_STRATEGIC_MOVE] == EDGEOFWORLD)) + { + isValid = true; + } + break; + case EAST: + if (!(gWorldSectorX + 1 > MAXIMUM_VALID_X_COORDINATE || gMapInformation.sEastGridNo == NOWHERE || + SectorInfo[ubSectorID].ubTraversability[EAST_STRATEGIC_MOVE] == GROUNDBARRIER || SectorInfo[ubSectorID].ubTraversability[EAST_STRATEGIC_MOVE] == EDGEOFWORLD)) + { + isValid = true; + } + break; + case SOUTH: + if (!(gWorldSectorY + 1 > MAXIMUM_VALID_Y_COORDINATE || gMapInformation.sSouthGridNo == NOWHERE || + SectorInfo[ubSectorID].ubTraversability[SOUTH_STRATEGIC_MOVE] == GROUNDBARRIER || SectorInfo[ubSectorID].ubTraversability[SOUTH_STRATEGIC_MOVE] == EDGEOFWORLD)) + { + isValid = true; + } + break; + case WEST: + if (!(gWorldSectorX - 1 < MINIMUM_VALID_X_COORDINATE || gMapInformation.sWestGridNo == NOWHERE || + SectorInfo[ubSectorID].ubTraversability[WEST_STRATEGIC_MOVE] == GROUNDBARRIER || SectorInfo[ubSectorID].ubTraversability[WEST_STRATEGIC_MOVE] == EDGEOFWORLD)) + { + isValid = true; + } + break; + } + + return isValid; +} + #ifdef JA2UB @@ -7968,4 +8037,4 @@ UINT8 tryToRecoverSquadsAndMovementGroups(SOLDIERTYPE* pCharacter) { } CheckSquadMovementGroups(); return GetSoldierGroupId(pCharacter); -} \ No newline at end of file +} diff --git a/Strategic/strategicmap.h b/Strategic/strategicmap.h index 2bbffc8f3..e43191c5b 100644 --- a/Strategic/strategicmap.h +++ b/Strategic/strategicmap.h @@ -119,7 +119,7 @@ void GetMapFileName(INT16 sMapX,INT16 sMapY, INT8 bSectorZ, STR8 bString, BOOLEA // Called from within tactical..... void JumpIntoAdjacentSector( UINT8 ubDirection, UINT8 ubJumpCode, INT32 sAdditionalData );//dnl ch56 151009 - +void JumpIntoEscapedSector(UINT8 ubTacticalDirection); BOOLEAN CanGoToTacticalInSector( INT16 sX, INT16 sY, UINT8 ubZ ); @@ -207,6 +207,7 @@ BOOLEAN HandlePotentialBringUpAutoresolveToFinishBattle( int pSectorX, int pSect BOOLEAN MapExists( UINT8 * szFilename ); BOOLEAN EscapeDirectionIsValid( INT8 * pbDirection ); +bool IsEscapeDirectionValid(WorldDirections pbDirection); //Used for determining the type of error message that comes up when you can't traverse to //an adjacent sector. THESE VALUES DO NOT NEED TO BE SAVED! extern BOOLEAN gfInvalidTraversal; @@ -235,4 +236,4 @@ BOOLEAN CanRequestMilitiaReinforcements( INT16 sMapX, INT16 sMapY, INT16 sSrcMap // Bob: check and try to fix issues with squad and group assignment UINT8 tryToRecoverSquadsAndMovementGroups(SOLDIERTYPE* pCharacter); -#endif \ No newline at end of file +#endif diff --git a/Tactical/Arms Dealer Init.cpp b/Tactical/Arms Dealer Init.cpp index d20658d74..9f1a5f398 100644 --- a/Tactical/Arms Dealer Init.cpp +++ b/Tactical/Arms Dealer Init.cpp @@ -45,58 +45,6 @@ void RemoveNonIntelItems(); UINT8 gubLastSpecialItemAddedAtElement = 255; // Flugente 2012-12-19: merchant data has been externalised - see XML_Merchants.cpp -#if 0 -// THIS STRUCTURE HAS UNCHANGING INFO THAT DOESN'T GET SAVED/RESTORED/RESET -// TODO: externalize -const ARMS_DEALER_INFO DefaultarmsDealerInfo[ NUM_ARMS_DEALERS ] = -{ - //Buying Selling Merc ID# Type Initial Flags - //Price Price Of Cash - //Modifier Modifier Dealer - -/* Tony */ { 0.75f, 1.25f, TONY, ARMS_DEALER_BUYS_SELLS, 15000, ARMS_DEALER_SOME_USED_ITEMS | ARMS_DEALER_GIVES_CHANGE, 15000, 15000, 0, 1, 10, 1, 10, 2, 3, false, false }, -/* Franz Hinkle */ { 1.0f, 1.5f, FRANZ, ARMS_DEALER_BUYS_SELLS, 5000, ARMS_DEALER_SOME_USED_ITEMS | ARMS_DEALER_GIVES_CHANGE, 5000, 5000, 0, 1, 10, 0, 100, 1, 2, false, true }, -/* Keith Hemps */ { 0.75f, 1.0f, KEITH, ARMS_DEALER_BUYS_SELLS, 1500, ARMS_DEALER_ONLY_USED_ITEMS | ARMS_DEALER_GIVES_CHANGE, 1500, 1500, 0, 1, 10, 0, 100, 1, 2, false, true }, -/* Jake Cameron */ { 0.8f, 1.1f, JAKE, ARMS_DEALER_BUYS_SELLS, 2500, ARMS_DEALER_ONLY_USED_ITEMS | ARMS_DEALER_GIVES_CHANGE, 2500, 2500, 0, 1, 10, 0, 100, 1, 2, false, true }, -/* Gabby Mulnick*/ { 1.0f, 1.0f, GABBY, ARMS_DEALER_BUYS_SELLS, 3000, ARMS_DEALER_GIVES_CHANGE , 3000, 3000, 0, 1, 10, 0, 100, 1, 2, false, true }, - -#ifdef JA2UB -/* Devin Connell*/ //ja25 ub Biggins//{ 0.75f, 1.25f, DEVIN, ARMS_DEALER_SELLS_ONLY, 5000, ARMS_DEALER_GIVES_CHANGE , 5000, 5000, 0, 3, 10, 0, 10, 2, 3, false, false }, -#else -/* Devin Connell*/ { 0.75f, 1.25f, DEVIN, ARMS_DEALER_SELLS_ONLY, 5000, ARMS_DEALER_GIVES_CHANGE , 5000, 5000, 0, 3, 10, 0, 10, 2, 3, false, false }, -#endif - -/* Howard Filmore*/ { 1.0f, 1.0f, HOWARD, ARMS_DEALER_SELLS_ONLY, 3000, ARMS_DEALER_GIVES_CHANGE , 3000, 3000, 0, 1, 10, 0, 100, 1, 2, false, true }, -/* Sam Rozen */ { 1.0f, 1.0f, SAM, ARMS_DEALER_SELLS_ONLY, 3000, ARMS_DEALER_GIVES_CHANGE , 3000, 3000, 0, 1, 10, 0, 100, 1, 2, false, true }, -/* Frank */ { 1.0f, 1.0f, FRANK, ARMS_DEALER_SELLS_ONLY, 500, ARMS_DEALER_ACCEPTS_GIFTS , 500, 500, 0, 1, 10, 0, 100, 1, 2, false, true }, - -/* Bar Bro 1 */ { 1.0f, 1.0f, HERVE, ARMS_DEALER_SELLS_ONLY, 250, ARMS_DEALER_ACCEPTS_GIFTS , 250, 250, 0, 1, 10, 0, 100, 1, 2, false, true }, -/* Bar Bro 2 */ { 1.0f, 1.0f, PETER, ARMS_DEALER_SELLS_ONLY, 250, ARMS_DEALER_ACCEPTS_GIFTS , 250, 250, 0, 1, 10, 0, 100, 1, 2, false, true }, -/* Bar Bro 3 */ { 1.0f, 1.0f, ALBERTO, ARMS_DEALER_SELLS_ONLY, 250, ARMS_DEALER_ACCEPTS_GIFTS , 250, 250, 0, 1, 10, 0, 100, 1, 2, false, true }, -/* Bar Bro 4 */ { 1.0f, 1.0f, CARLO, ARMS_DEALER_SELLS_ONLY, 250, ARMS_DEALER_ACCEPTS_GIFTS , 250, 250, 0, 1, 10, 0, 100, 1, 2, false, true }, - -/* Micky O'Brien*/ { 1.0f, 1.4f, MICKY, ARMS_DEALER_BUYS_ONLY, 10000, ARMS_DEALER_HAS_NO_INVENTORY | ARMS_DEALER_GIVES_CHANGE, 10000, 10000, 0, 1, 10, 1, 10, 1, 2, false, true }, - - //Repair Repair - //Speed Cost -/* Arnie Brunzwell*/{ 0.1f, 0.8f, ARNIE, ARMS_DEALER_REPAIRS, 1500, ARMS_DEALER_HAS_NO_INVENTORY | ARMS_DEALER_GIVES_CHANGE, 1500, 1500, 0, 1, 10, 1, 10, 1, 2, false, true }, -/* Fredo */ { 0.6f, 0.6f, FREDO, ARMS_DEALER_REPAIRS, 1000, ARMS_DEALER_HAS_NO_INVENTORY | ARMS_DEALER_GIVES_CHANGE, 1000, 1000, 0, 1, 10, 1, 10, 1, 2, false, true }, -#ifdef JA2UB -/* Raul */ { 0.80f, 1.8f, PERKO, ARMS_DEALER_BUYS_SELLS, 20000, ARMS_DEALER_SOME_USED_ITEMS | ARMS_DEALER_GIVES_CHANGE , 1000, 1000, 0, 1, 10, 1, 10, 1, 2, false, true }, -#else -/* Perko */ { 1.0f, 0.4f, PERKO, ARMS_DEALER_REPAIRS, 1000, ARMS_DEALER_HAS_NO_INVENTORY | ARMS_DEALER_GIVES_CHANGE, 1000, 1000, 0, 1, 10, 1, 10, 1, 2, false, true }, -#endif - -/* Elgin */ { 1.0f, 1.0f, DRUGGIST, ARMS_DEALER_SELLS_ONLY, 500, ARMS_DEALER_ACCEPTS_GIFTS , 500, 500, 0, 1, 10, 1, 10, 1, 2, false, true }, -/* Manny */ { 1.0f, 1.0f, MANNY, ARMS_DEALER_SELLS_ONLY, 500, ARMS_DEALER_ACCEPTS_GIFTS , 500, 500, 0, 1, 10, 1, 10, 1, 2, false, true }, - -#ifdef JA2UB -/* Betty */ { 0.75f, 1.25f, 73, ARMS_DEALER_BUYS_SELLS, 10000, ARMS_DEALER_SOME_USED_ITEMS | ARMS_DEALER_GIVES_CHANGE , 1000, 1000, 0, 1, 10, 1, 10, 1, 2, false, true }, -#endif - - -}; -#endif std::vector armsDealerInfo (NUM_ARMS_DEALERS); diff --git a/Tactical/CMakeLists.txt b/Tactical/CMakeLists.txt new file mode 100644 index 000000000..ebecb65da --- /dev/null +++ b/Tactical/CMakeLists.txt @@ -0,0 +1,157 @@ +set(TacticalSrc +"${CMAKE_CURRENT_SOURCE_DIR}/Air Raid.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Animation Cache.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Animation Control.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Animation Data.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Arms Dealer Init.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/ArmsDealerInvInit.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Auto Bandage.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Boxing.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/bullets.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Campaign.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Civ Quotes.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Dialogue Control.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Disease.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/DisplayCover.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Drugs And Alcohol.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/DynamicDialogue.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/End Game.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Enemy Soldier Save.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/EnemyItemDrops.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Faces.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Food.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/fov.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/GAP.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Handle Doors.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Handle Items.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Handle UI Plan.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Handle UI.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Interface Control.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Interface Cursors.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Interface Dialogue.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Interface Enhanced.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Interface Items.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Interface Panels.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Interface Utils.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Interface.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/InterfaceItemImages.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Inventory Choosing.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Item Types.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Items.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Ja25_Tactical.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Keys.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/LogicalBodyTypes/AbstractXMLLoader.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/LogicalBodyTypes/BodyType.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/LogicalBodyTypes/BodyTypeDB.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/LogicalBodyTypes/EnumeratorDB.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/LogicalBodyTypes/Filter.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/LogicalBodyTypes/FilterDB.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/LogicalBodyTypes/Layers.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/LogicalBodyTypes/PaletteDB.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/LogicalBodyTypes/PaletteTable.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/LogicalBodyTypes/SurfaceCache.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/LogicalBodyTypes/SurfaceDB.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/LogicalBodyTypes/XMLParseException.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/LOS.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Map Information.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Merc Entering.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Merc Hiring.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Militia Control.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Minigame.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Morale.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/opplist.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Overhead.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/PATHAI.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Points.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/QARRAY.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Rain.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/RandomMerc.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Real Time Input.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Rotting Corpses.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/ShopKeeper Interface.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/SkillCheck.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/SkillMenu.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Soldier Add.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Soldier Ani.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Soldier Control.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Soldier Create.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Soldier Find.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Soldier Init List.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Soldier Profile.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Soldier Tile.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/SoldierTooltips.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Spread Burst.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Squads.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Strategic Exit GUI.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Structure Wrap.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Tactical Save.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Tactical Turns.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/TeamTurns.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Turn Based Input.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/UI Cursors.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Vehicles.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/VehicleMenu.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Weapons.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/World Items.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_AmmoStrings.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_AmmoTypes.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Armour.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_AttachmentInfo.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Attachments.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_AttachmentSlots.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Background.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_BurstSounds.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_CivGroupNames.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Clothes.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_ComboMergeInfo.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_CompatibleFaceItems.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Disease.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Drugs.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_EnemyAmmoDrops.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_EnemyArmourDrops.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_EnemyExplosiveDrops.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_EnemyItemChoice.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_EnemyMiscDrops.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_EnemyNames.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_EnemyRank.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_EnemyWeaponChoice.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_EnemyWeaponDrops.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Explosive.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Food.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_FoodOpinions.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_HiddenNames.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_IMPItemChoices.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_IncompatibleAttachments.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_InteractiveTiles.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_ItemAdjustments.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Keys.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Launchable.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_LBEPocket.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_LBEPocketPopup.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_LoadBearingEquipment.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_LoadScreenHints.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Locks.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Magazine.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Merchants.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_MercStartingGear.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Merge.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_MilitiaIndividual.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_NewFaceGear.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Opinions.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Profiles.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Qarray.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_RandomItem.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_RandomStats.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_RPCFacesSmall.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_SectorLoadscreens.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_SoldierProfiles.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Sounds.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_SpreadPatterns.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_StructureConstruct.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_StructureDeconstruct.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Structure_Move.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Taunts.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_AdditionalTileProperties.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_TonyInventory.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Vehicles.cpp" +PARENT_SCOPE) diff --git a/Tactical/Civ Quotes.cpp b/Tactical/Civ Quotes.cpp index 07753c648..4bcf45e3f 100644 --- a/Tactical/Civ Quotes.cpp +++ b/Tactical/Civ Quotes.cpp @@ -197,42 +197,12 @@ BOOLEAN GetCivQuoteText(UINT16 ubCivQuoteID, UINT16 ubEntryID, STR16 zQuote ) void SurrenderMessageBoxCallBack( UINT8 ubExitValue ) { - SOLDIERTYPE *pTeamSoldier; - INT32 cnt = 0; - if ( ubExitValue == MSG_BOX_RETURN_YES ) { - // CJC Dec 1 2002: fix multiple captures - BeginCaptureSquence(); - - // Do capture.... - cnt = gTacticalStatus.Team[ gbPlayerNum ].bFirstID; - - for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; cnt++,pTeamSoldier++) - { - // Are we active and in sector..... - if ( pTeamSoldier->bActive && pTeamSoldier->bInSector ) - { - if ( pTeamSoldier->stats.bLife != 0 ) - { - EnemyCapturesPlayerSoldier( pTeamSoldier ); - - RemoveSoldierFromTacticalSector( pTeamSoldier, TRUE ); - } - } - } - - EndCaptureSequence( ); - - gfSurrendered = TRUE; - SetCustomizableTimerCallbackAndDelay( 3000, CaptureTimerCallback, FALSE ); - - ActionDone( gCivQuoteData.pCiv ); - } - else - { - ActionDone( gCivQuoteData.pCiv ); + AttemptToCapturePlayerSoldiers(); } + gTacticalStatus.fEnemyFlags |= ENEMY_OFFERED_SURRENDER; + ActionDone( gCivQuoteData.pCiv ); } void ShutDownQuoteBox( BOOLEAN fForce ) @@ -2383,4 +2353,4 @@ BOOLEAN PlayVoiceTaunt(SOLDIERTYPE *pCiv, TAUNTTYPE iTauntType, SOLDIERTYPE *pTa } return TRUE; -} \ No newline at end of file +} diff --git a/Tactical/GAP.cpp b/Tactical/GAP.cpp index 0b3cb6675..5478734aa 100644 --- a/Tactical/GAP.cpp +++ b/Tactical/GAP.cpp @@ -10,35 +10,6 @@ SUBSEQUENTSOUNDS subsequentsounds; -#if 0 -static void AILCALLBACK timer_func( UINT32 user ) -{ - AudioGapList *pGapList; - - pGapList = (AudioGapList*)user; - - pGapList->gap_monitor_timer += GAP_TIMER_INTERVAL; - - if ( pGapList->audio_gap_active ) - { - if ( (pGapList->gap_monitor_timer / 1000) > pGapList->end[ pGapList->gap_monitor_current] ) - { - pGapList->audio_gap_active = 0; - pGapList->gap_monitor_current++; - } - } - else - { - if ( pGapList->gap_monitor_current < pGapList->count ) - { - if ( ( pGapList->gap_monitor_timer / 1000) >= pGapList->start[ pGapList->gap_monitor_current ]) - { - pGapList->audio_gap_active = 1; - } - } - } -} -#endif void AudioGapListInit( CHAR8 *zSoundFile, AudioGapList *pGapList ) diff --git a/Tactical/Handle UI.cpp b/Tactical/Handle UI.cpp index a438e5005..86a50e133 100644 --- a/Tactical/Handle UI.cpp +++ b/Tactical/Handle UI.cpp @@ -88,6 +88,11 @@ #include "Map Screen Interface.h" // added by Flugente for SquadNames #include "Keys.h" // added by silversurfer for door handling from the side +#include "AIInternals.h" +extern BOOLEAN gubWorldTileInLight[MAX_ALLOWED_WORLD_MAX]; +extern BOOLEAN gubIsCorpseThere[MAX_ALLOWED_WORLD_MAX]; +extern INT32 gubMerkCanSeeThisTile[MAX_ALLOWED_WORLD_MAX]; + ////////////////////////////////////////////////////////////////////////////// // SANDRO - In this file, all APBPConstants[AP_CROUCH] and APBPConstants[AP_PRONE] were changed to GetAPsCrouch() and GetAPsProne() // On the bottom here, there are these functions made @@ -1365,74 +1370,74 @@ UINT32 UIHandleEndTurn( UI_EVENT *pUIEvent ) SaveGame(SAVE__END_TURN_NUM, zString ); } - // Flugente: this stuff is only ever used in AStar pathing and is a unnecessary waste of resources otherwise, so I'm putting an end to this -#ifdef USE_ASTAR_PATHS ////ddd enemy turn optimization - if ( (gTacticalStatus.uiFlags & TURNBASED) && (gTacticalStatus.uiFlags & INCOMBAT ) ) + if (gGameSettings.fOptions[TOPTION_ALT_PATHFINDING]) { - memset( gubWorldTileInLight, FALSE, sizeof( gubWorldTileInLight ) ); - memset( gubIsCorpseThere, FALSE, sizeof( gubIsCorpseThere ) ); - memset( gubMerkCanSeeThisTile, FALSE, sizeof( gubMerkCanSeeThisTile ) ); + if ( (gTacticalStatus.uiFlags & TURNBASED) && (gTacticalStatus.uiFlags & INCOMBAT ) ) + { + memset( gubWorldTileInLight, FALSE, sizeof( gubWorldTileInLight ) ); + memset( gubIsCorpseThere, FALSE, sizeof( gubIsCorpseThere ) ); + memset( gubMerkCanSeeThisTile, FALSE, sizeof( gubMerkCanSeeThisTile ) ); - //sevenfm translated: unwinding of loop. When changing WORLD_MAX to another value will need some cleaning! dangerous code! ;) + //sevenfm translated: unwinding of loop. When changing WORLD_MAX to another value will need some cleaning! dangerous code! ;) - // WANNE: We had a custom user map (Tixa, J9), where the following loop caused an unhandled exception. - // The crash occurd at ~index 16000 when calling the method IsCorpseAtGridNo() ... - // I don't know what causes it ... - // Just try/catch (ugly, but works). - __try - { - for(UINT32 i=0; i<(UINT32)WORLD_MAX; i+=4) - { - gubWorldTileInLight[i] = InLightAtNight(i, gpWorldLevelData[ i ].sHeight); - gubIsCorpseThere[i] = IsCorpseAtGridNo( i, gpWorldLevelData[ i ].sHeight ); - gubWorldTileInLight[i+1] = InLightAtNight(i+1, gpWorldLevelData[ i+1 ].sHeight); - gubIsCorpseThere[i+1] = IsCorpseAtGridNo( i+1, gpWorldLevelData[ i+1 ].sHeight ); - gubWorldTileInLight[i+2] = InLightAtNight(i+2, gpWorldLevelData[ i+2 ].sHeight); - gubIsCorpseThere[i+2] = IsCorpseAtGridNo( i+2, gpWorldLevelData[ i+2 ].sHeight ); - gubWorldTileInLight[i+3] = InLightAtNight(i+3, gpWorldLevelData[ i+3 ].sHeight); - gubIsCorpseThere[i+3] = IsCorpseAtGridNo( i+3, gpWorldLevelData[ i+3 ].sHeight ); - } - } - __except( EXCEPTION_EXECUTE_HANDLER ) - { - // WANNE: Ignore, so the game can continue ... - } - - INT32 tcnt = gTacticalStatus.Team[ gbPlayerNum ].bFirstID; - SOLDIERTYPE *tS; - - INT16 sXOffset, sYOffset; - INT32 sGridNo; - UINT16 usSightLimit=0; - - for ( tS = MercPtrs[ tcnt ]; tcnt <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; ++tcnt, tS++ ) - { - if ( tS->stats.bLife >= OKLIFE && tS->sGridNo != NOWHERE && tS->bInSector ) + // WANNE: We had a custom user map (Tixa, J9), where the following loop caused an unhandled exception. + // The crash occurd at ~index 16000 when calling the method IsCorpseAtGridNo() ... + // I don't know what causes it ... + // Just try/catch (ugly, but works). + __try + { + for(UINT32 i=0; i<(UINT32)WORLD_MAX; i+=4) + { + gubWorldTileInLight[i] = InLightAtNight(i, gpWorldLevelData[ i ].sHeight); + gubIsCorpseThere[i] = IsCorpseAtGridNo( i, gpWorldLevelData[ i ].sHeight ); + gubWorldTileInLight[i+1] = InLightAtNight(i+1, gpWorldLevelData[ i+1 ].sHeight); + gubIsCorpseThere[i+1] = IsCorpseAtGridNo( i+1, gpWorldLevelData[ i+1 ].sHeight ); + gubWorldTileInLight[i+2] = InLightAtNight(i+2, gpWorldLevelData[ i+2 ].sHeight); + gubIsCorpseThere[i+2] = IsCorpseAtGridNo( i+2, gpWorldLevelData[ i+2 ].sHeight ); + gubWorldTileInLight[i+3] = InLightAtNight(i+3, gpWorldLevelData[ i+3 ].sHeight); + gubIsCorpseThere[i+3] = IsCorpseAtGridNo( i+3, gpWorldLevelData[ i+3 ].sHeight ); + } + } + __except( EXCEPTION_EXECUTE_HANDLER ) { - //loop through all the gridnos that we are interested in - for (sYOffset = -30; sYOffset <= 30; ++sYOffset) + // WANNE: Ignore, so the game can continue ... + } + + INT32 tcnt = gTacticalStatus.Team[ gbPlayerNum ].bFirstID; + SOLDIERTYPE *tS; + + INT16 sXOffset, sYOffset; + INT32 sGridNo; + UINT16 usSightLimit=0; + + for ( tS = MercPtrs[ tcnt ]; tcnt <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; ++tcnt, tS++ ) + { + if ( tS->stats.bLife >= OKLIFE && tS->sGridNo != NOWHERE && tS->bInSector ) { - for (sXOffset = -30; sXOffset <= 30; ++sXOffset) + //loop through all the gridnos that we are interested in + for (sYOffset = -30; sYOffset <= 30; ++sYOffset) { - sGridNo = tS->sGridNo + sXOffset + (MAXCOL * sYOffset); - - if ( sGridNo <= 0 || sGridNo >= WORLD_MAX ) - continue; - - //usSightLimit = tS->GetMaxDistanceVisible(sGridNo, FALSE, CALC_FROM_WANTED_DIR); - if(gubMerkCanSeeThisTile[sGridNo]==0) + for (sXOffset = -30; sXOffset <= 30; ++sXOffset) { - gubMerkCanSeeThisTile[sGridNo]=//SoldierToVirtualSoldierLineOfSightTest( tS, sGridNo, FALSE, ANIM_STAND, TRUE, usSightLimit ); - SoldierToVirtualSoldierLineOfSightTest( tS, sGridNo, tS->pathing.bLevel, ANIM_STAND, TRUE, CALC_FROM_WANTED_DIR); - } - }//fo - } - }//if + sGridNo = tS->sGridNo + sXOffset + (MAXCOL * sYOffset); + + if ( sGridNo <= 0 || sGridNo >= WORLD_MAX ) + continue; + + //usSightLimit = tS->GetMaxDistanceVisible(sGridNo, FALSE, CALC_FROM_WANTED_DIR); + if(gubMerkCanSeeThisTile[sGridNo]==0) + { + gubMerkCanSeeThisTile[sGridNo]=//SoldierToVirtualSoldierLineOfSightTest( tS, sGridNo, FALSE, ANIM_STAND, TRUE, usSightLimit ); + SoldierToVirtualSoldierLineOfSightTest( tS, sGridNo, tS->pathing.bLevel, ANIM_STAND, TRUE, CALC_FROM_WANTED_DIR); + } + }//fo + } + }//if + } } } //ddd enemy turn optimization** -#endif // End our turn! if (is_server || !is_client) @@ -3920,14 +3925,6 @@ void UIHandleSoldierStanceChange( UINT8 ubSoldierID, INT8 bNewStance ) pSoldier->usUIMovementMode = pSoldier->GetMoveStateBasedOnStance( bNewStance ); pSoldier->ubDesiredHeight = NO_DESIRED_HEIGHT; -#if 0 - if ( pSoldier->usUIMovementMode == CRAWLING && gAnimControl[ pSoldier->usAnimState ].ubEndHeight != ANIM_PRONE ) - { - pSoldier->usDontUpdateNewGridNoOnMoveAnimChange = LOCKED_NO_NEWGRIDNO; - pSoldier->pathing.bPathStored = FALSE; - } - else -#endif { pSoldier->usDontUpdateNewGridNoOnMoveAnimChange = 1; } @@ -7433,9 +7430,7 @@ BOOLEAN IsValidJumpLocation( SOLDIERTYPE *pSoldier, INT32 sGridNo, BOOLEAN fChec } // This ain't gonna happen with backpack - if((UsingNewInventorySystem() == true) && pSoldier->inv[BPACKPOCKPOS].exists() == true - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) + if (!pSoldier->CanClimbWithCurrentBackpack()) { return( FALSE ); } diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index c993ec667..d914c65e9 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -2761,19 +2761,6 @@ void INVRenderINVPanelItem( SOLDIERTYPE *pSoldier, INT16 sPocket, UINT8 fDirtyLe } } -#if 0 - if ( gbInvalidPlacementSlot[ sPocket ] ) - { - if ( sPocket != SECONDHANDPOS ) - { - // If we are in inv panel and our guy is not = cursor guy... - if ( !gfSMDisableForItems ) - { - fHatchItOut = TRUE; - } - } - } -#endif if (AM_A_ROBOT(pSoldier) && sPocket == HANDPOS) fHatchItOut = FALSE; @@ -3808,7 +3795,6 @@ void INVRenderItem( UINT32 uiBuffer, SOLDIERTYPE * pSoldier, OBJECTTYPE *pObjec { SetFontBackground( FONT_MCOLOR_BLACK ); SetFontForeground( FONT_MCOLOR_DKGRAY ); -#if 1 //CHRISL: Moved this condition to the start so that stacked guns will show number in stack if ( ubStatusIndex != RENDER_ITEM_NOSTATUS ) { @@ -3833,7 +3819,6 @@ void INVRenderItem( UINT32 uiBuffer, SOLDIERTYPE * pSoldier, OBJECTTYPE *pObjec gprintfinvalidate( sNewX, sNewY, pStr ); } } -#endif if ( pItem->usItemClass == IC_GUN && !Item[pObject->usItem].rocketlauncher ) { @@ -3941,35 +3926,6 @@ void INVRenderItem( UINT32 uiBuffer, SOLDIERTYPE * pSoldier, OBJECTTYPE *pObjec } } } -#if 0 - else - { - if ( ubStatusIndex != RENDER_ITEM_NOSTATUS ) - { - // Now display # of items - if ( pObject->ubNumberOfObjects > 1 ) - { - SetFontForeground( FONT_GRAY4 ); - - sNewY = sY + sHeight - 10; - swprintf( pStr, L"%d", pObject->ubNumberOfObjects ); - - // Get length of string - uiStringLength=StringPixLength(pStr, ITEM_FONT ); - - sNewX = sX + sWidth - uiStringLength - 4; - - if ( uiBuffer == guiSAVEBUFFER ) - { - RestoreExternBackgroundRect( sNewX, sNewY, 15, 15 ); - } - mprintf( sNewX, sNewY, pStr ); - gprintfinvalidate( sNewX, sNewY, pStr ); - } - - } - } -#endif if ( ItemHasAttachments( pObject, pSoldier, iter ) ) { if ( !IsGrenadeLauncherAttached( pObject, iter ) ) diff --git a/Tactical/Interface Panels.cpp b/Tactical/Interface Panels.cpp index 456d6c749..e3b27cd95 100644 --- a/Tactical/Interface Panels.cpp +++ b/Tactical/Interface Panels.cpp @@ -4632,10 +4632,7 @@ void BtnClimbCallback(GUI_BUTTON *btn,INT32 reason) if ( fNearLowerLevel ) { - if ((UsingNewInventorySystem() == true) && gpSMCurrentMerc->inv[BPACKPOCKPOS].exists() == true - //JMich.BackpackClimb - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)gpSMCurrentMerc->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[gpSMCurrentMerc->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[gpSMCurrentMerc->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) + if (!gpSMCurrentMerc->CanClimbWithCurrentBackpack()) { ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, NewInvMessage[NIV_NO_CLIMB]); return; @@ -4646,10 +4643,7 @@ void BtnClimbCallback(GUI_BUTTON *btn,INT32 reason) if ( fNearHeigherLevel ) { - if ((UsingNewInventorySystem() == true) && gpSMCurrentMerc->inv[BPACKPOCKPOS].exists() == true - //JMich.BackpackClimb - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)gpSMCurrentMerc->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[gpSMCurrentMerc->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[gpSMCurrentMerc->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) + if (!gpSMCurrentMerc->CanClimbWithCurrentBackpack()) { ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, NewInvMessage[NIV_NO_CLIMB]); return; @@ -4662,10 +4656,7 @@ void BtnClimbCallback(GUI_BUTTON *btn,INT32 reason) if (gGameExternalOptions.fCanClimbOnWalls == TRUE) { - if ((UsingNewInventorySystem() == true) && gpSMCurrentMerc->inv[BPACKPOCKPOS].exists() == true - //JMich.BackpackClimb - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)gpSMCurrentMerc->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[gpSMCurrentMerc->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[gpSMCurrentMerc->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) + if (!gpSMCurrentMerc->CanClimbWithCurrentBackpack()) { ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, NewInvMessage[NIV_NO_CLIMB]); return; @@ -4681,10 +4672,7 @@ void BtnClimbCallback(GUI_BUTTON *btn,INT32 reason) if ( FindFenceJumpDirection( gpSMCurrentMerc, gpSMCurrentMerc->sGridNo, gpSMCurrentMerc->ubDirection, &bDirection ) ) { - if ((UsingNewInventorySystem() == true) && gpSMCurrentMerc->inv[BPACKPOCKPOS].exists() == true - //JMich.BackpackClimb - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)gpSMCurrentMerc->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[gpSMCurrentMerc->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[gpSMCurrentMerc->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) + if (!gpSMCurrentMerc->CanClimbWithCurrentBackpack()) { ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, NewInvMessage[NIV_NO_CLIMB]); return; diff --git a/Tactical/Interface.h b/Tactical/Interface.h index e531076b5..ff767245b 100644 --- a/Tactical/Interface.h +++ b/Tactical/Interface.h @@ -5,6 +5,7 @@ #include "mousesystem.h" #include "structure.h" #include "Assignments.h" // added by Flugente for the stat-enums +#include #define MAX_UICOMPOSITES 4 diff --git a/Tactical/Item Types.cpp b/Tactical/Item Types.cpp index 55bd75b2d..de7478ad3 100644 --- a/Tactical/Item Types.cpp +++ b/Tactical/Item Types.cpp @@ -594,13 +594,7 @@ LBENODE* OBJECTTYPE::GetLBEPointer(unsigned int index) bool OBJECTTYPE::exists() { -#if 0//dnl ch75 011113 - if(this == NULL) - return(FALSE); - return (ubNumberOfObjects > 0 && usItem != NOTHING); -#else return(this && ubNumberOfObjects && usItem); -#endif } void OBJECTTYPE::SpliceData(OBJECTTYPE& sourceObject, unsigned int numToSplice, StackedObjects::iterator beginIter) diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index 00ec359e4..55a457fef 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -3031,49 +3031,6 @@ UINT16 CalculateItemSize( OBJECTTYPE *pObject ) currentSize = __max(iSize + testSize, currentSize); currentSize = __min(currentSize, maxSize); } -#if 0 -//old method - UINT16 newSize, testSize, maxSize; - UINT8 cnt=0; - newSize = 0; - maxSize = max(iSize, LoadBearingEquipment[Item[pObject->usItem].ubClassIndex].lbeFilledSize); - // Look for the ItemSize of the largest item in this LBENODE - for(UINT16 x = 0; x < invsize; ++x) - { - if(pLBE->inv[x].exists() == true) - { - testSize = CalculateItemSize(&(pLBE->inv[x])); - //Now that we have the size of one item, we want to factor in the number of items since two - // items take up more space then one. - testSize = testSize + pLBE->inv[x].ubNumberOfObjects - 1; - testSize = min(testSize,34); - //We also need to increase the size of guns so they'll fit with the rest of our calculations. - if(testSize < 5) - testSize += 10; - if(testSize < 10) - testSize += 18; - //Finally, we want to factor in multiple pockets. We'll do this by counting the number of filled - // pockets, then add this count total to our newSize when everything is finished. - cnt++; - newSize = max(testSize, newSize); - } - } - //Add the total number of filled pockets to our NewSize to account for multiple pockets being used - newSize += cnt; - newSize = min(newSize,34); - // If largest item is smaller then LBE, don't change ItemSize - if(newSize > 0 && newSize < iSize) { - iSize = iSize; - } - // if largest item is larget then LBE but smaller then max size, partially increase ItemSize - else if(newSize >= iSize && newSize < maxSize) { - iSize = newSize; - } - // if largest item is larger then max size, reset ItemSize to max size - else if(newSize >= maxSize) { - iSize = maxSize; - } -#endif } } } @@ -8458,19 +8415,7 @@ BOOLEAN CreateItem( UINT16 usItem, INT16 bStatus, OBJECTTYPE * pObj ) { (*pObj).fFlags |= OBJECT_UNDROPPABLE; } -#if 0//dnl ch74 201013 create default attachments rather at gun status instead of 100% - for(UINT8 cnt = 0; cnt < MAX_DEFAULT_ATTACHMENTS; cnt++){ - if(Item [ usItem ].defaultattachments[cnt] == 0) - break; - - //cannot use gTempObject - OBJECTTYPE defaultAttachment; - CreateItem(Item [ usItem ].defaultattachments[cnt],100,&defaultAttachment); - pObj->AttachObject(NULL,&defaultAttachment, FALSE); - } -#else AttachDefaultAttachments(pObj);//dnl ch75 261013 -#endif } DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("CreateItem: return %d",fRet)); @@ -12644,44 +12589,7 @@ UINT16 PickARandomLaunchable(UINT16 itemIndex) UINT16 usNumMatches = 0; UINT16 usRandom = 0; UINT16 lowestCoolness = LowestLaunchableCoolness(itemIndex); -#if 0 - //DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("PickARandomLaunchable: itemIndex = %d", itemIndex)); - // WANNE: This should fix the hang on the merc positioning screen (fix by Razer) - //while( !usNumMatches ) - { //Count the number of valid launchables - for( i = 0; i < MAXITEMS; ++i ) - { - if ( Item[i].usItemClass == 0 ) - break; - //Madd: quickfix: make it not choose best grenades right away. - if( ValidLaunchable( i, itemIndex ) && ItemIsLegal(i) && Item[i].ubCoolness <= max(HighestPlayerProgressPercentage()/10,lowestCoolness) ) - usNumMatches++; - } - } - - if( usNumMatches ) - { - usRandom = (UINT16)Random( usNumMatches ); - for( i = 0; i < MAXITEMS; ++i ) - { - if ( Item[i].usItemClass == 0 ) - break; - - if( ValidLaunchable( i, itemIndex ) && ItemIsLegal(i) && Item[i].ubCoolness <= max(HighestPlayerProgressPercentage()/10,lowestCoolness) ) - { - if( usRandom ) - usRandom--; - else - { - return i; - } - } - } - } -#endif - - // Flugente: the above code is highly dubious.. why do we loop over all items 2 times, and why that obscure usRandom--; business? This can cause an underflow! BOOLEAN isnight = NightTime(); UINT16 maxcoolness = max( HighestPlayerProgressPercentage() / 10, lowestCoolness ); diff --git a/Tactical/Keys.cpp b/Tactical/Keys.cpp index 306a1055c..b5e9c0c30 100644 --- a/Tactical/Keys.cpp +++ b/Tactical/Keys.cpp @@ -1167,6 +1167,11 @@ BOOLEAN LoadDoorTableFromDoorTableTempFile( ) +static auto ComplainAboutMissingDoorStructure(const INT32 GridNo) { +#if JA2TESTVERSION + ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_BETAVERSION, L"Door structure data at %d was not found", GridNo); +#endif +} // fOpen is True if the door is open, false if it is closed BOOLEAN ModifyDoorStatus( INT32 sGridNo, BOOLEAN fOpen, BOOLEAN fPerceivedOpen ) @@ -1190,9 +1195,7 @@ BOOLEAN ModifyDoorStatus( INT32 sGridNo, BOOLEAN fOpen, BOOLEAN fPerceivedOpen ) if ( pBaseStructure == NULL ) { -#if 0 - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_BETAVERSION, L"Door structure data at %d was not found", sGridNo ); -#endif + ComplainAboutMissingDoorStructure(sGridNo); return( FALSE ); } @@ -1314,9 +1317,7 @@ BOOLEAN IsDoorOpen( INT32 sGridNo ) if ( pBaseStructure == NULL ) { -#if 0 - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_BETAVERSION, L"Door structure data at %d was not found", sGridNo ); -#endif + ComplainAboutMissingDoorStructure(sGridNo); return( FALSE ); } @@ -1367,6 +1368,7 @@ DOOR_STATUS *GetDoorStatus( INT32 sGridNo ) if ( pBaseStructure == NULL ) { + ComplainAboutMissingDoorStructure(sGridNo); return( NULL ); } @@ -1527,9 +1529,7 @@ void SyncronizeDoorStatusToStructureData( DOOR_STATUS *pDoorStatus ) if ( pBaseStructure == NULL ) { -#if 0 - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_BETAVERSION, L"Door structure data at %d was not found", pDoorStatus->sGridNo ); -#endif + ComplainAboutMissingDoorStructure(pDoorStatus->sGridNo); return; } @@ -1611,9 +1611,7 @@ void InternalUpdateDoorGraphicFromStatus( DOOR_STATUS *pDoorStatus, BOOLEAN fUse if ( pBaseStructure == NULL ) { -#if 0 - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_BETAVERSION, L"Door structure data at %d was not found", pDoorStatus->sGridNo ); -#endif + ComplainAboutMissingDoorStructure(pDoorStatus->sGridNo); return; } diff --git a/Tactical/LOS.cpp b/Tactical/LOS.cpp index 6196e0e2e..276aaf691 100644 --- a/Tactical/LOS.cpp +++ b/Tactical/LOS.cpp @@ -4805,15 +4805,7 @@ INT8 FireBulletGivenTargetNCTH( SOLDIERTYPE * pFirer, FLOAT dEndX, FLOAT dEndY, dDeltaX = dEndX - dStartX; dDeltaY = dEndY - dStartY; dDeltaZ = dEndZ - dStartZ; -#if 0//dnl ch60 020913 isn't true see reason in FireBulletGivenTarget - //lal bugfix - if( dDeltaZ > 0 ) - d2DDistance = Distance3D( dDeltaX, dDeltaY, dDeltaZ ); - else - d2DDistance = Distance2D( dDeltaX, dDeltaY ); -#else d2DDistance = Distance2D( dDeltaX, dDeltaY ); -#endif iDistance = (INT32) d2DDistance; if ( d2DDistance != iDistance ) @@ -5304,15 +5296,9 @@ INT8 FireBulletGivenTarget( SOLDIERTYPE * pFirer, FLOAT dEndX, FLOAT dEndY, FLOA dDeltaX = dEndX - dStartX; dDeltaY = dEndY - dStartY; dDeltaZ = dEndZ - dStartZ; -#if 0//dnl ch60 311009 this isn't correct, e.g. if you try head shot from prone to standing target at 1 tile, Distance3D will calculate 7,8 tile distance, this means that you will always hit target regard of CTH calculation, correct usage will be Distance3D(dDeltaX, dDeltaY, CONVERT_HEIGHTUNITS_TO_DISTANCE(dDeltaZ)) but we need here 2D distance as was in original v1.12 - //lal bugfix - if( dDeltaZ > 0 ) - d2DDistance = Distance3D( dDeltaX, dDeltaY, dDeltaZ ); - else - d2DDistance = Distance2D( dDeltaX, dDeltaY ); -#else + /* see previous commit for historically interesting comment on the reason Distance2D instead + of Distance3D is used here */ d2DDistance = Distance2D( dDeltaX, dDeltaY ); -#endif iDistance = (INT32) d2DDistance; if ( d2DDistance != iDistance ) @@ -5813,15 +5799,7 @@ INT8 FireFragmentGivenTarget( UINT8 ubOwner, FLOAT dStartX, FLOAT dStartY, FLOAT dDeltaX = dEndX - dStartX; dDeltaY = dEndY - dStartY; dDeltaZ = dEndZ - dStartZ; -#if 0//dnl ch60 030913 - //lal bugfix - if( dDeltaZ > 0 ) - d2DDistance = Distance3D( dDeltaX, dDeltaY, dDeltaZ ); - else - d2DDistance = Distance2D( dDeltaX, dDeltaY ); -#else d2DDistance = Distance2D( dDeltaX, dDeltaY ); -#endif iDistance = (INT32) d2DDistance; if ( d2DDistance != iDistance ) @@ -5990,15 +5968,7 @@ INT8 FireBulletGivenTargetTrapOnly( SOLDIERTYPE* pThrower, OBJECTTYPE* pObj, INT dDeltaX = dEndX - dStartX; dDeltaY = dEndY - dStartY; dDeltaZ = dEndZ - dStartZ; -#if 0//dnl ch60 030913 - //lal bugfix - if( dDeltaZ > 0 ) - d2DDistance = Distance3D( dDeltaX, dDeltaY, dDeltaZ ); - else - d2DDistance = Distance2D( dDeltaX, dDeltaY ); -#else d2DDistance = Distance2D( dDeltaX, dDeltaY ); -#endif iDistance = (INT32) d2DDistance; if ( d2DDistance != iDistance ) @@ -8584,11 +8554,7 @@ void AdjustTargetCenterPoint( SOLDIERTYPE *pShooter, INT32 iTargetGridNo, FLOAT /////////////////////////////////////////////////////////////////////// // Find distance between shooter and target, in points. FLOAT d2DDistance=0; -#if 0//dnl ch60 030913 - d2DDistance = Distance3D( dDeltaX, dDeltaY, CONVERT_HEIGHTUNITS_TO_DISTANCE( dDeltaZ ) ); -#else d2DDistance = Distance2D( dDeltaX, dDeltaY ); -#endif // Round it upwards. INT32 iDistance = (INT32) d2DDistance; if ( d2DDistance != iDistance ) diff --git a/Tactical/LogicalBodyTypes/Filter.cpp b/Tactical/LogicalBodyTypes/Filter.cpp index 1c303a03c..9db01c0f3 100644 --- a/Tactical/LogicalBodyTypes/Filter.cpp +++ b/Tactical/LogicalBodyTypes/Filter.cpp @@ -2,6 +2,21 @@ namespace LogicalBodyTypes { +INT32 CompareAttachment(SOLDIERTYPE* pSoldier, INVENTORY_SLOT slot, UINT8 index) +{ + INT32 cmp_val = 0; + + if (pSoldier->inv[slot].objectStack.size() > 0) + { + OBJECTTYPE* const attachment = pSoldier->inv[slot].objectStack.front().GetAttachmentAtIndex(index); + if (attachment) { cmp_val = attachment->usItem; } + else { cmp_val = 0; } + } + else { cmp_val = 0; } + + return cmp_val; +} + Filter::Filter(void) { } @@ -210,6 +225,30 @@ bool Filter::Match(SOLDIERTYPE* pSoldier) { case REQ_WEARING_BACKPACK: cmp_val = pSoldier->inv[BPACKPOCKPOS].exists(); break; + case REQ_HELMETPOSATTACHMENT0: + cmp_val = CompareAttachment(pSoldier, HELMETPOS, 0); + break; + case REQ_HELMETPOSATTACHMENT1: + cmp_val = CompareAttachment(pSoldier, HELMETPOS, 1); + break; + case REQ_HELMETPOSATTACHMENT2: + cmp_val = CompareAttachment(pSoldier, HELMETPOS, 2); + break; + case REQ_HELMETPOSATTACHMENT3: + cmp_val = CompareAttachment(pSoldier, HELMETPOS, 3); + break; + case REQ_LEGPOSATTACHMENT0: + cmp_val = CompareAttachment(pSoldier, LEGPOS, 0); + break; + case REQ_LEGPOSATTACHMENT1: + cmp_val = CompareAttachment(pSoldier, LEGPOS, 1); + break; + case REQ_LEGPOSATTACHMENT2: + cmp_val = CompareAttachment(pSoldier, LEGPOS, 2); + break; + case REQ_LEGPOSATTACHMENT3: + cmp_val = CompareAttachment(pSoldier, LEGPOS, 3); + break; default: if (q < NUM_REQTYPESINV) { cmp_val = pSoldier->inv[q].usItem; diff --git a/Tactical/LogicalBodyTypes/Filter.h b/Tactical/LogicalBodyTypes/Filter.h index ac6870870..e0f4d7198 100644 --- a/Tactical/LogicalBodyTypes/Filter.h +++ b/Tactical/LogicalBodyTypes/Filter.h @@ -64,6 +64,14 @@ public: REQ_HELMET_AMOR_PROTECTION, REQ_HELMET_AMOR_COVERAGE, REQ_WEARING_BACKPACK, + REQ_HELMETPOSATTACHMENT0, + REQ_HELMETPOSATTACHMENT1, + REQ_HELMETPOSATTACHMENT2, + REQ_HELMETPOSATTACHMENT3, + REQ_LEGPOSATTACHMENT0, + REQ_LEGPOSATTACHMENT1, + REQ_LEGPOSATTACHMENT2, + REQ_LEGPOSATTACHMENT3, NUM_REQTYPES, // 3rd byte is for operator flags _REQ_BTWN = 0x20000, @@ -86,7 +94,7 @@ public: }; typedef std::pair NumberPair; typedef std::list StringList; - typedef std::list NumberList; + typedef std::vector NumberList; union criterionVariant { INT32 number; std::wstring* string; diff --git a/Tactical/LogicalBodyTypes/FilterDB.cpp b/Tactical/LogicalBodyTypes/FilterDB.cpp index 4cb3030e5..78f9662ea 100644 --- a/Tactical/LogicalBodyTypes/FilterDB.cpp +++ b/Tactical/LogicalBodyTypes/FilterDB.cpp @@ -270,7 +270,7 @@ namespace LogicalBodyTypes { /***************************************** Filter enum criterion types ******************************************/ - LOGBT_ENUMDB_ADD("IntegerFilterCriterionTypes", 33, + LOGBT_ENUMDB_ADD("IntegerFilterCriterionTypes", 41, Filter::REQ_HELMETPOS, Filter::REQ_VESTPOS, Filter::REQ_LEGPOS, @@ -303,7 +303,15 @@ namespace LogicalBodyTypes { Filter::REQ_VEST_AMOR_COVERAGE, Filter::REQ_HELMET_AMOR_PROTECTION, Filter::REQ_HELMET_AMOR_COVERAGE, - Filter::REQ_WEARING_BACKPACK + Filter::REQ_WEARING_BACKPACK, + Filter::REQ_HELMETPOSATTACHMENT0, + Filter::REQ_HELMETPOSATTACHMENT1, + Filter::REQ_HELMETPOSATTACHMENT2, + Filter::REQ_HELMETPOSATTACHMENT3, + Filter::REQ_LEGPOSATTACHMENT0, + Filter::REQ_LEGPOSATTACHMENT1, + Filter::REQ_LEGPOSATTACHMENT2, + Filter::REQ_LEGPOSATTACHMENT3 ); /***************************************** diff --git a/Tactical/Map Information.cpp b/Tactical/Map Information.cpp index 24c5ff73e..0ff75813e 100644 --- a/Tactical/Map Information.cpp +++ b/Tactical/Map Information.cpp @@ -199,327 +199,6 @@ void SaveMapInformation(HWFILE hFile, FLOAT dMajorMapVersion, UINT8 ubMinorMapVe //loading and won't be permanently updated until the map is saved, regardless of changes. void UpdateOldVersionMap() { -#if 0 //This code is no longer needed since the major version update from 1.0 to 4.0 - //However, I am keeping it in for reference. - SOLDIERINITNODE *curr; - INT32 i; - LEVELNODE *pStruct; - //VERSION 0 -- obsolete November 14, 1997 - if( gMapInformation.ubMapVersion == 0 ) - { - //Soldier information contained two fixable bugs. - gMapInformation.ubMapVersion++; - curr = gSoldierInitHead; - while( curr ) - { - //Bug #01) Nodes without detailed slots weren't initialized. - if( !curr->pBasicPlacement->fDetailedPlacement ) - curr->pDetailedPlacement = NULL; - //Bug #02) The attitude variable was accidentally being generated like attributes - // which put it completely out of range. - if( curr->pBasicPlacement->bAttitude > 7 ) - curr->pBasicPlacement->bAttitude = (INT8)Random(8); - //go to next node - curr = curr->next; - } - } - //VERSION 1 -- obsolete January 7, 1998 - if( gMapInformation.ubMapVersion == 1 ) - { - gMapInformation.ubMapVersion++; - //Bug #03) Removing all wall decals from map, because of new changes to the slots - // as well as certain decals found commonly in illegal places. - for( i = 0; i < WORLD_MAX; i++ ) - { - RemoveAllStructsOfTypeRange( i, FIRSTWALLDECAL, LASTWALLDECAL ); - RemoveAllStructsOfTypeRange( i, FIFTHWALLDECAL, SIXTHWALLDECAL ); - } - } - //VERSION 2 -- obsolete February 3, 1998 - if( gMapInformation.ubMapVersion == 2 ) - { - gMapInformation.ubMapVersion++; - curr = gSoldierInitHead; - while( curr ) - { - //Bug #04) Assign enemy mercs default army color code if applicable - if( curr->pBasicPlacement->bTeam == ENEMY_TEAM && !curr->pBasicPlacement->ubSoldierClass ) - { - if( !curr->pDetailedPlacement ) - { - curr->pBasicPlacement->ubSoldierClass = SOLDIER_CLASS_ARMY; - } - else if( curr->pDetailedPlacement && curr->pDetailedPlacement->ubProfile == NO_PROFILE ) - { - curr->pBasicPlacement->ubSoldierClass = SOLDIER_CLASS_ARMY; - curr->pDetailedPlacement->ubSoldierClass = SOLDIER_CLASS_ARMY; - } - } - curr = curr->next; - } - } - //VERSION 3 -- obsolete February 9, 1998 - if( gMapInformation.ubMapVersion == 3 ) - { - gMapInformation.ubMapVersion++; - //Bug #05) Move entry points down if necessary. - ValidateEntryPointGridNo( &gMapInformation.sNorthGridNo ); - ValidateEntryPointGridNo( &gMapInformation.sEastGridNo ); - ValidateEntryPointGridNo( &gMapInformation.sSouthGridNo ); - ValidateEntryPointGridNo( &gMapInformation.sWestGridNo ); - } - //VERSION 4 -- obsolete February 25, 1998 - if( gMapInformation.ubMapVersion == 4 ) - { - gMapInformation.ubMapVersion++; - //6) Change all doors to FIRSTDOOR - for( i = 0; i < WORLD_MAX; ++i ) - { - //NOTE: Here are the index values for the various doors - //DOOR OPEN CLOSED - //FIRST 916 912 - //SECOND 936 932 - //THIRD 956 952 - //FOURTH 976 972 - pStruct = gpWorldLevelData[ i ].pStructHead; - while( pStruct ) - { - //outside topleft - if( pStruct->usIndex == 932 || pStruct->usIndex == 952 || pStruct->usIndex == 972 ) - { - ReplaceStructIndex( i, pStruct->usIndex, 912 ); - break; - } - else if( pStruct->usIndex == 936 || pStruct->usIndex == 956 || pStruct->usIndex == 976 ) - { - ReplaceStructIndex( i, pStruct->usIndex, 916 ); - break; - } - //outside topright - else if( pStruct->usIndex == 927 || pStruct->usIndex == 947 || pStruct->usIndex == 967 ) - { - ReplaceStructIndex( i, pStruct->usIndex, 907 ); - break; - } - else if( pStruct->usIndex == 931 || pStruct->usIndex == 951 || pStruct->usIndex == 971 ) - { - ReplaceStructIndex( i, pStruct->usIndex, 911 ); - break; - } - //inside topleft - else if( pStruct->usIndex == 942 || pStruct->usIndex == 962 || pStruct->usIndex == 982 ) - { - ReplaceStructIndex( i, pStruct->usIndex, 922 ); - break; - } - else if( pStruct->usIndex == 946 || pStruct->usIndex == 966 || pStruct->usIndex == 986 ) - { - ReplaceStructIndex( i, pStruct->usIndex, 926 ); - break; - } - //inside topright - else if( pStruct->usIndex == 937 || pStruct->usIndex == 957 || pStruct->usIndex == 977 ) - { - ReplaceStructIndex( i, pStruct->usIndex, 917 ); - break; - } - else if( pStruct->usIndex == 941 || pStruct->usIndex == 961 || pStruct->usIndex == 981 ) - { - ReplaceStructIndex( i, pStruct->usIndex, 921 ); - break; - } - pStruct = pStruct->pNext; - } - } - } - //VERSION 5 -- obsolete March 4, 1998 - if( gMapInformation.ubMapVersion == 5 ) - { - gMapInformation.ubMapVersion++; - //Bug 7) Remove all exit grids (the format has changed) - for( i = 0; i < WORLD_MAX; i++ ) - RemoveExitGridFromWorld( i ); - } - //VERSION 6 -- obsolete March 9, 1998 - if( gMapInformation.ubMapVersion == 6 ) - { //Bug 8) Change droppable status of merc items so that they are all undroppable. - gMapInformation.ubMapVersion++; - curr = gSoldierInitHead; - while( curr ) - { - //Bug #04) Assign enemy mercs default army color code if applicable - if( curr->pDetailedPlacement ) - { - INT32 invsize = (INT32)curr->pDetailedPlacement->Inv.size(); - for( i = 0; i < invsize; ++i ) - { //make all items undroppable, even if it is empty. This will allow for - //random item generation, while empty, droppable slots are locked as empty - //during random item generation. - curr->pDetailedPlacement->Inv[ i ].fFlags |= OBJECT_UNDROPPABLE; - } - } - curr = curr->next; - } - } - //VERSION 7 -- obsolete April 14, 1998 - if( gMapInformation.ubMapVersion == 7 ) - { - gMapInformation.ubMapVersion++; - //Bug 9) Priority placements have been dropped in favor of splitting it into two categories. - // The first is Detailed placements, and the second is priority existance. So, all - // current detailed placements will also have priority existance. - curr = gSoldierInitHead; - while( curr ) - { - if( curr->pDetailedPlacement ) - { - curr->pBasicPlacement->fPriorityExistance = TRUE; - } - curr = curr->next; - } - } - - if( gMapInformation.ubMapVersion == 14 ) - { //Toast all of the ambiguous road pieces that ended up wrapping the byte. - LEVELNODE *pStruct, *pStruct2; - INT32 i; - for( i = 0; i < WORLD_MAX; i++ ) - { - pStruct = gpWorldLevelData[ i ].pObjectHead; - if( pStruct && pStruct->usIndex == 1078 && i < WORLD_MAX-2 && i >= 320 ) - { //This is the only detectable road piece that we can repair. - pStruct2 = gpWorldLevelData[ i+1 ].pObjectHead; - if( pStruct2 && pStruct2->usIndex == 1081 ) - { - RemoveObject( i, pStruct->usIndex ); - RemoveObject( i+1, pStruct->usIndex+1 ); - RemoveObject( i+2, pStruct->usIndex+2 ); - RemoveObject( i-160, pStruct->usIndex-160 ); - RemoveObject( i-159, pStruct->usIndex-159 ); - RemoveObject( i-158, pStruct->usIndex-158 ); - RemoveObject( i-320, pStruct->usIndex-320 ); - RemoveObject( i-319, pStruct->usIndex-319 ); - RemoveObject( i-318, pStruct->usIndex-318 ); - AddObjectToTail( i, 1334 ); - AddObjectToTail( i-160, 1335 ); - AddObjectToTail( i-320, 1336 ); - AddObjectToTail( i+1, 1337 ); - AddObjectToTail( i-159, 1338 ); - AddObjectToTail( i-319, 1339 ); - AddObjectToTail( i+2, 1340 ); - AddObjectToTail( i-158, 1341 ); - AddObjectToTail( i-318, 1342 ); - } - } - else if( pStruct && pStruct->usIndex >= 1079 && pStruct->usIndex < 1115 ) - { - RemoveObject( i, pStruct->usIndex ); - } - } - } - - if( gMapInformation.ubMapVersion <= 7 ) - { - if( gfEditMode ) - { - #ifdef JA2TESTVERSION - ScreenMsg( FONT_MCOLOR_RED, MSG_ERROR, L"Currently loaded map is corrupt! Allowing the map to load anyway!" ); - #endif - } - else - { - if( gbWorldSectorZ ) - { - AssertMsg( 0, String( "Currently loaded map (%c%d_b%d.dat) is invalid -- less than the minimum supported version.", gWorldSectorY + 'A' - 1, gWorldSectorX, gbWorldSectorZ ) ); - } - else if( !gbWorldSectorZ ) - { - AssertMsg( 0, String( "Currently loaded map (%c%d.dat) is invalid -- less than the minimum supported version.", gWorldSectorY + 'A' - 1, gWorldSectorX ) ); - } - } - } - //VERSION 8 -- obsolete April 18, 1998 - if( gMapInformation.ubMapVersion == 8 ) - { - gMapInformation.ubMapVersion++; - //Bug 10) Padding on detailed placements is uninitialized. Clear all data starting at - // fKillSlotIfOwnerDies. - curr = gSoldierInitHead; - while( curr ) - { - if( curr->pDetailedPlacement ) - { - //The size 120 was hand calculated. The remaining padding was 118 bytes - //and there were two one byte fields cleared, fKillSlotIfOwnerDies and ubScheduleID - memset( &curr->pDetailedPlacement->fKillSlotIfOwnerDies, 0, 120 ); - } - curr = curr->next; - } - } - //Version 9 -- Kris -- obsolete April 27, 1998 - if( gMapInformation.ubMapVersion == 9 ) - { - gMapInformation.ubMapVersion++; - curr = gSoldierInitHead; - while( curr ) - { - //Bug 11) Convert all wheelchaired placement bodytypes to cows. Result of change in the animation database. - if( curr->pDetailedPlacement && curr->pDetailedPlacement->ubBodyType == CRIPPLECIV ) - { - curr->pDetailedPlacement->ubBodyType = COW; - curr->pBasicPlacement->ubBodyType = COW; - } - curr = curr->next; - } - } - if( gMapInformation.ubMapVersion < 12 ) - { - gMapInformation.ubMapVersion = 12; - gMapInformation.sCenterGridNo = -1; - } - if( gMapInformation.ubMapVersion < 13 ) - { //replace all merc ammo inventory slots status value with the max ammo that the clip can hold. - INT32 cnt; - OBJECTTYPE *pItem; - gMapInformation.ubMapVersion++; - //Bug 10) Padding on detailed placements is uninitialized. Clear all data starting at - // fKillSlotIfOwnerDies. - curr = gSoldierInitHead; - while( curr ) - { - if( curr->pDetailedPlacement ) - { - UINT32 invsize = curr->pDetailedPlacement->Inv.size(); - for ( UINT32 i = 0; i < invsize; ++i ) - { - pItem = &curr->pDetailedPlacement->Inv[ i ]; - if( Item[ pItem->usItem ].usItemClass & IC_AMMO ) - { - for( cnt = 0; cnt < pItem->ubNumberOfObjects; ++cnt ) - { - pItem->shots.ubShotsLeft[ cnt ] = Magazine[ Item[ pItem->usItem ].ubClassIndex ].ubMagSize; - } - } - } - } - curr = curr->next; - } - } - if( gMapInformation.ubMapVersion < 14 ) - { - gMapInformation.ubMapVersion++; - if( !gfCaves && !gfBasement ) - { - ReplaceObsoleteRoads(); - } - } - if( gMapInformation.ubMapVersion < 15 ) - { //Do nothing. The object layer was expanded from 1 byte to 2 bytes, effecting the - //size of the maps. This was due to the fact that the ROADPIECES tileset contains - //over 300 pieces, hence requiring a size increase of the tileset subindex for this - //layer only. - } -#endif //end of MAJOR VERSION 3.0 obsolete code if( gMapInformation.ubMapVersion < 15 ) { AssertMsg( 0, "Map is less than minimum supported version." ); diff --git a/Tactical/Militia Control.cpp b/Tactical/Militia Control.cpp index b69df0418..935d78524 100644 --- a/Tactical/Militia Control.cpp +++ b/Tactical/Militia Control.cpp @@ -299,21 +299,6 @@ void PrepareMilitiaForTactical( BOOLEAN fPrepareAll) // If the sector is already loaded, don't add the existing militia for( x = 1; x < guiDirNumber ; ++x ) { -#if 0 - // ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%ld,%ld,%ld,%ld", gpAttackDirs[ x ][ 0 ], gpAttackDirs[ x ][1], gpAttackDirs[ x ][2], gpAttackDirs[ x ][3] ); - if( gfMSResetMilitia ) - { - if( gpAttackDirs[ x ][ 3 ] != INSERTION_CODE_CENTER ) - { - AddSoldierInitListMilitiaOnEdge( gpAttackDirs[ x ][ 3 ], gpAttackDirs[ x ][0], gpAttackDirs[ x ][1], gpAttackDirs[ x ][2] ); - ubGreen -= gpAttackDirs[ x ][0]; - ubRegs -= gpAttackDirs[ x ][1]; - ubElites -= gpAttackDirs[ x ][2]; - } - } - //else - //{ -#endif AddSoldierInitListMilitiaOnEdge( gpAttackDirs[ x ][ 3 ], gpAttackDirs[ x ][0], gpAttackDirs[ x ][1], gpAttackDirs[ x ][2] ); } diff --git a/Tactical/Overhead Types.h b/Tactical/Overhead Types.h index 0b6c82ebd..9a349c5fe 100644 --- a/Tactical/Overhead Types.h +++ b/Tactical/Overhead Types.h @@ -335,280 +335,6 @@ extern UINT8 giMAXIMUM_NUMBER_OF_CIVS; #define LAN_TEAM_FOUR 9 //hayden -//----------------------------------------------- -// -// civilian "sub teams": -enum -{ - NON_CIV_GROUP = 0, - REBEL_CIV_GROUP, - KINGPIN_CIV_GROUP, - SANMONA_ARMS_GROUP, - ANGELS_GROUP, - BEGGARS_CIV_GROUP, - TOURISTS_CIV_GROUP, - ALMA_MILITARY_CIV_GROUP, - DOCTORS_CIV_GROUP, - COUPLE1_CIV_GROUP, - HICKS_CIV_GROUP, - WARDEN_CIV_GROUP, - JUNKYARD_CIV_GROUP, - FACTORY_KIDS_GROUP, - QUEENS_CIV_GROUP, - UNNAMED_CIV_GROUP_15, - UNNAMED_CIV_GROUP_16, - UNNAMED_CIV_GROUP_17, - UNNAMED_CIV_GROUP_18, - UNNAMED_CIV_GROUP_19, - ASSASSIN_CIV_GROUP, // Flugente: enemy assassins belong to this group - POW_PRISON_CIV_GROUP, // Flugente: prisoners of war the player caught are in this group - UNNAMED_CIV_GROUP_22, - UNNAMED_CIV_GROUP_23, - VOLUNTEER_CIV_GROUP, // Flugente: civilians that the player recruited - BOUNTYHUNTER_CIV_GROUP, // Flugente: hostile bounty hunters - DOWNEDPILOT_CIV_GROUP, // Flugente: downed pilots - SCIENTIST_GROUP, // Flugente: enemy civilian personnel - RADAR_TECHNICIAN_GROUP, - AIRPORT_STAFF_GROUP, - BARRACK_STAFF_GROUP, - FACTORY_GROUP, - ADMINISTRATIVE_STAFF_GROUP, - LOYAL_CIV_GROUP, // civil population deeply loyal to the queen - BLACKMARKET_GROUP, // black market dealer and bodyguards - UNNAMED_CIV_GROUP_35, - UNNAMED_CIV_GROUP_36, - UNNAMED_CIV_GROUP_37, - UNNAMED_CIV_GROUP_38, - UNNAMED_CIV_GROUP_39, - UNNAMED_CIV_GROUP_40, - UNNAMED_CIV_GROUP_41, - UNNAMED_CIV_GROUP_42, - UNNAMED_CIV_GROUP_43, - UNNAMED_CIV_GROUP_44, - UNNAMED_CIV_GROUP_45, - UNNAMED_CIV_GROUP_46, - UNNAMED_CIV_GROUP_47, - UNNAMED_CIV_GROUP_48, - UNNAMED_CIV_GROUP_49, - UNNAMED_CIV_GROUP_50, - UNNAMED_CIV_GROUP_51, - UNNAMED_CIV_GROUP_52, - UNNAMED_CIV_GROUP_53, - UNNAMED_CIV_GROUP_54, - UNNAMED_CIV_GROUP_55, - UNNAMED_CIV_GROUP_56, - UNNAMED_CIV_GROUP_57, - UNNAMED_CIV_GROUP_58, - UNNAMED_CIV_GROUP_59, - UNNAMED_CIV_GROUP_60, - UNNAMED_CIV_GROUP_61, - UNNAMED_CIV_GROUP_62, - UNNAMED_CIV_GROUP_63, - UNNAMED_CIV_GROUP_64, - UNNAMED_CIV_GROUP_65, - UNNAMED_CIV_GROUP_66, - UNNAMED_CIV_GROUP_67, - UNNAMED_CIV_GROUP_68, - UNNAMED_CIV_GROUP_69, - UNNAMED_CIV_GROUP_70, - UNNAMED_CIV_GROUP_71, - UNNAMED_CIV_GROUP_72, - UNNAMED_CIV_GROUP_73, - UNNAMED_CIV_GROUP_74, - UNNAMED_CIV_GROUP_75, - UNNAMED_CIV_GROUP_76, - UNNAMED_CIV_GROUP_77, - UNNAMED_CIV_GROUP_78, - UNNAMED_CIV_GROUP_79, - UNNAMED_CIV_GROUP_80, - UNNAMED_CIV_GROUP_81, - UNNAMED_CIV_GROUP_82, - UNNAMED_CIV_GROUP_83, - UNNAMED_CIV_GROUP_84, - UNNAMED_CIV_GROUP_85, - UNNAMED_CIV_GROUP_86, - UNNAMED_CIV_GROUP_87, - UNNAMED_CIV_GROUP_88, - UNNAMED_CIV_GROUP_89, - UNNAMED_CIV_GROUP_90, - UNNAMED_CIV_GROUP_91, - UNNAMED_CIV_GROUP_92, - UNNAMED_CIV_GROUP_93, - UNNAMED_CIV_GROUP_94, - UNNAMED_CIV_GROUP_95, - UNNAMED_CIV_GROUP_96, - UNNAMED_CIV_GROUP_97, - UNNAMED_CIV_GROUP_98, - UNNAMED_CIV_GROUP_99, - UNNAMED_CIV_GROUP_100, - UNNAMED_CIV_GROUP_101, - UNNAMED_CIV_GROUP_102, - UNNAMED_CIV_GROUP_103, - UNNAMED_CIV_GROUP_104, - UNNAMED_CIV_GROUP_105, - UNNAMED_CIV_GROUP_106, - UNNAMED_CIV_GROUP_107, - UNNAMED_CIV_GROUP_108, - UNNAMED_CIV_GROUP_109, - UNNAMED_CIV_GROUP_110, - UNNAMED_CIV_GROUP_111, - UNNAMED_CIV_GROUP_112, - UNNAMED_CIV_GROUP_113, - UNNAMED_CIV_GROUP_114, - UNNAMED_CIV_GROUP_115, - UNNAMED_CIV_GROUP_116, - UNNAMED_CIV_GROUP_117, - UNNAMED_CIV_GROUP_118, - UNNAMED_CIV_GROUP_119, - UNNAMED_CIV_GROUP_120, - UNNAMED_CIV_GROUP_121, - UNNAMED_CIV_GROUP_122, - UNNAMED_CIV_GROUP_123, - UNNAMED_CIV_GROUP_124, - UNNAMED_CIV_GROUP_125, - UNNAMED_CIV_GROUP_126, - UNNAMED_CIV_GROUP_127, - UNNAMED_CIV_GROUP_128, - UNNAMED_CIV_GROUP_129, - UNNAMED_CIV_GROUP_130, - UNNAMED_CIV_GROUP_131, - UNNAMED_CIV_GROUP_132, - UNNAMED_CIV_GROUP_133, - UNNAMED_CIV_GROUP_134, - UNNAMED_CIV_GROUP_135, - UNNAMED_CIV_GROUP_136, - UNNAMED_CIV_GROUP_137, - UNNAMED_CIV_GROUP_138, - UNNAMED_CIV_GROUP_139, - UNNAMED_CIV_GROUP_140, - - UNNAMED_CIV_GROUP_141, - UNNAMED_CIV_GROUP_142, - UNNAMED_CIV_GROUP_143, - UNNAMED_CIV_GROUP_144, - UNNAMED_CIV_GROUP_145, - UNNAMED_CIV_GROUP_146, - UNNAMED_CIV_GROUP_147, - UNNAMED_CIV_GROUP_148, - UNNAMED_CIV_GROUP_149, - UNNAMED_CIV_GROUP_150, - UNNAMED_CIV_GROUP_151, - UNNAMED_CIV_GROUP_152, - UNNAMED_CIV_GROUP_153, - UNNAMED_CIV_GROUP_154, - UNNAMED_CIV_GROUP_155, - UNNAMED_CIV_GROUP_156, - UNNAMED_CIV_GROUP_157, - UNNAMED_CIV_GROUP_158, - UNNAMED_CIV_GROUP_159, - UNNAMED_CIV_GROUP_160, - UNNAMED_CIV_GROUP_161, - UNNAMED_CIV_GROUP_162, - UNNAMED_CIV_GROUP_163, - UNNAMED_CIV_GROUP_164, - UNNAMED_CIV_GROUP_165, - UNNAMED_CIV_GROUP_166, - UNNAMED_CIV_GROUP_167, - UNNAMED_CIV_GROUP_168, - UNNAMED_CIV_GROUP_169, - UNNAMED_CIV_GROUP_170, - - UNNAMED_CIV_GROUP_171, - UNNAMED_CIV_GROUP_172, - UNNAMED_CIV_GROUP_173, - UNNAMED_CIV_GROUP_174, - UNNAMED_CIV_GROUP_175, - UNNAMED_CIV_GROUP_176, - UNNAMED_CIV_GROUP_177, - UNNAMED_CIV_GROUP_178, - UNNAMED_CIV_GROUP_179, - UNNAMED_CIV_GROUP_180, - UNNAMED_CIV_GROUP_181, - UNNAMED_CIV_GROUP_182, - UNNAMED_CIV_GROUP_183, - UNNAMED_CIV_GROUP_184, - UNNAMED_CIV_GROUP_185, - UNNAMED_CIV_GROUP_186, - UNNAMED_CIV_GROUP_187, - UNNAMED_CIV_GROUP_188, - UNNAMED_CIV_GROUP_189, - UNNAMED_CIV_GROUP_190, - UNNAMED_CIV_GROUP_191, - UNNAMED_CIV_GROUP_192, - UNNAMED_CIV_GROUP_193, - UNNAMED_CIV_GROUP_194, - UNNAMED_CIV_GROUP_195, - UNNAMED_CIV_GROUP_196, - UNNAMED_CIV_GROUP_197, - UNNAMED_CIV_GROUP_198, - UNNAMED_CIV_GROUP_199, - UNNAMED_CIV_GROUP_200, - - UNNAMED_CIV_GROUP_201, - UNNAMED_CIV_GROUP_202, - UNNAMED_CIV_GROUP_203, - UNNAMED_CIV_GROUP_204, - UNNAMED_CIV_GROUP_205, - UNNAMED_CIV_GROUP_206, - UNNAMED_CIV_GROUP_207, - UNNAMED_CIV_GROUP_208, - UNNAMED_CIV_GROUP_209, - UNNAMED_CIV_GROUP_210, - UNNAMED_CIV_GROUP_211, - UNNAMED_CIV_GROUP_212, - UNNAMED_CIV_GROUP_213, - UNNAMED_CIV_GROUP_214, - UNNAMED_CIV_GROUP_215, - UNNAMED_CIV_GROUP_216, - UNNAMED_CIV_GROUP_217, - UNNAMED_CIV_GROUP_218, - UNNAMED_CIV_GROUP_219, - UNNAMED_CIV_GROUP_220, - UNNAMED_CIV_GROUP_221, - UNNAMED_CIV_GROUP_222, - UNNAMED_CIV_GROUP_223, - UNNAMED_CIV_GROUP_224, - UNNAMED_CIV_GROUP_225, - UNNAMED_CIV_GROUP_226, - UNNAMED_CIV_GROUP_227, - UNNAMED_CIV_GROUP_228, - UNNAMED_CIV_GROUP_229, - UNNAMED_CIV_GROUP_230, - - UNNAMED_CIV_GROUP_231, - UNNAMED_CIV_GROUP_232, - UNNAMED_CIV_GROUP_233, - UNNAMED_CIV_GROUP_234, - UNNAMED_CIV_GROUP_235, - UNNAMED_CIV_GROUP_236, - UNNAMED_CIV_GROUP_237, - UNNAMED_CIV_GROUP_238, - UNNAMED_CIV_GROUP_239, - UNNAMED_CIV_GROUP_240, - UNNAMED_CIV_GROUP_241, - UNNAMED_CIV_GROUP_242, - UNNAMED_CIV_GROUP_243, - UNNAMED_CIV_GROUP_244, - UNNAMED_CIV_GROUP_245, - UNNAMED_CIV_GROUP_246, - UNNAMED_CIV_GROUP_247, - UNNAMED_CIV_GROUP_248, - UNNAMED_CIV_GROUP_249, - UNNAMED_CIV_GROUP_250, - - UNNAMED_CIV_GROUP_251, - UNNAMED_CIV_GROUP_252, - UNNAMED_CIV_GROUP_253, - UNNAMED_CIV_GROUP_254, - NUM_CIV_GROUPS -}; - -#define CIV_GROUP_NEUTRAL 0 -#define CIV_GROUP_WILL_EVENTUALLY_BECOME_HOSTILE 1 -#define CIV_GROUP_WILL_BECOME_HOSTILE 2 -#define CIV_GROUP_HOSTILE 3 - - // boxing state enum BoxingStates { @@ -621,15 +347,6 @@ enum BoxingStates LOST_ROUND } ; -//NOTE: The editor uses these enumerations, so please update the text as well if you modify or -// add new groups. Try to abbreviate the team name as much as possible. The text is in -// EditorMercs.c -#ifdef JA2EDITOR - extern CHAR16 gszCivGroupNames[ NUM_CIV_GROUPS ][ 128 ]; -#endif -// -//----------------------------------------------- - // PALETTE SUBSITUTION TYPES typedef struct { diff --git a/Tactical/Overhead.cpp b/Tactical/Overhead.cpp index 81f265f97..36e5881de 100644 --- a/Tactical/Overhead.cpp +++ b/Tactical/Overhead.cpp @@ -1,5 +1,7 @@ #include #include +#include +#include #include "wcheck.h" #include "stdlib.h" #include "debug.h" @@ -1178,12 +1180,6 @@ BOOLEAN ExecuteOverhead( ) pSoldier->flags.fSoldierWasMoving = FALSE; HandlePlacingRoofMarker( pSoldier, pSoldier->sGridNo, TRUE, FALSE ); - - if ( !gGameSettings.fOptions[ TOPTION_MERC_ALWAYS_LIGHT_UP ] ) - { - pSoldier->DeleteSoldierLight( ); - pSoldier->SetCheckSoldierLightFlag( ); - } } } else @@ -7600,35 +7596,11 @@ BOOLEAN CheckForEndOfBattle( BOOLEAN fAnEnemyRetreated ) HandleGlobalLoyaltyEvent(GLOBAL_LOYALTY_BATTLE_LOST, gWorldSectorX, gWorldSectorY, gbWorldSectorZ); } - // SANDRO - end quest if cleared the sector after interrogation (sector N7 by Meduna) - if ( gWorldSectorX == gModSettings.ubMeanwhileInterrogatePOWSectorX && gWorldSectorY == gModSettings.ubMeanwhileInterrogatePOWSectorY && - gbWorldSectorZ == 0) - { - if (gubQuest[QUEST_INTERROGATION] == QUESTINPROGRESS) - { - // Quest failed - InternalEndQuest(QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY, FALSE); - } - else if (gubQuest[QUEST_INTERROGATION] == QUESTCANNOTSTART) - { - //shadooow: re-enable quest if player loses control of the N7 prison and quest was disabled previously - gubQuest[QUEST_INTERROGATION] = QUESTNOTSTARTED; - } - } - //shadooow: re-enable quest if player loses control of the Alma prison and quest was disabled previously - if (gWorldSectorX == gModSettings.ubInitialPOWSectorX && gWorldSectorY == gModSettings.ubInitialPOWSectorY && - gbWorldSectorZ == 0 && gubQuest[QUEST_HELD_IN_ALMA] == QUESTCANNOTSTART) - { - gubQuest[QUEST_HELD_IN_ALMA] = QUESTNOTSTARTED; - } #ifndef JA2UB - //shadooow: re-enable quest if player loses control of the Tixa prison and quest was disabled previously - if (gWorldSectorX == gModSettings.ubTixaPrisonSectorX && gWorldSectorY == gModSettings.ubTixaPrisonSectorY && - gbWorldSectorZ == 0 && gubQuest[QUEST_HELD_IN_TIXA] == QUESTCANNOTSTART) - { - gubQuest[QUEST_HELD_IN_TIXA] = QUESTNOTSTARTED; - } - #endif + HandlePOWQuestState(Q_FAIL, QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY, gbWorldSectorZ); + HandlePOWQuestState(Q_FAIL, QUEST_HELD_IN_ALMA, gWorldSectorX, gWorldSectorY, gbWorldSectorZ); + HandlePOWQuestState(Q_FAIL, QUEST_HELD_IN_TIXA, gWorldSectorX, gWorldSectorY, gbWorldSectorZ); + #endif // Play death music #ifdef NEWMUSIC @@ -7824,51 +7796,12 @@ BOOLEAN CheckForEndOfBattle( BOOLEAN fAnEnemyRetreated ) if (!is_networked) ShouldBeginAutoBandage( ); } - // SANDRO - end quest if cleared the sector after interrogation (sector N7 by Meduna) - if ( gWorldSectorX == gModSettings.ubMeanwhileInterrogatePOWSectorX && gWorldSectorY == gModSettings.ubMeanwhileInterrogatePOWSectorY && - gbWorldSectorZ == 0) - { - if (gubQuest[QUEST_INTERROGATION] == QUESTINPROGRESS) - { - // Complete quest - EndQuest( QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY ); - } - else if(gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED) - { - //shadooow: disable quest if player takes control of the N7 prison - gubQuest[QUEST_INTERROGATION] = QUESTCANNOTSTART; - } - } - //shadooow: disable quest if player takes control of the Alma prison - if (gWorldSectorX == gModSettings.ubInitialPOWSectorX && gWorldSectorY == gModSettings.ubInitialPOWSectorY && - gbWorldSectorZ == 0) - { - if (gubQuest[QUEST_HELD_IN_ALMA] == QUESTINPROGRESS) - { - // Complete quest - EndQuest(QUEST_HELD_IN_ALMA, gWorldSectorX, gWorldSectorY); - } - else if (gubQuest[QUEST_HELD_IN_ALMA] == QUESTNOTSTARTED) - { - gubQuest[QUEST_HELD_IN_ALMA] = QUESTCANNOTSTART; - } - } - #ifndef JA2UB - //shadooow: disable quest if player takes control of the Tixa prison - if (gWorldSectorX == gModSettings.ubTixaPrisonSectorX && gWorldSectorY == gModSettings.ubTixaPrisonSectorY && - gbWorldSectorZ == 0 && gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED) - { - if (gubQuest[QUEST_HELD_IN_TIXA] == QUESTINPROGRESS) - { - // Complete quest - EndQuest(QUEST_HELD_IN_TIXA, gWorldSectorX, gWorldSectorY); - } - else if (gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED) - { - gubQuest[QUEST_HELD_IN_TIXA] = QUESTCANNOTSTART; - } - } - #endif + + #ifndef JA2UB + HandlePOWQuestState(Q_SUCCESS, QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY, gbWorldSectorZ); + HandlePOWQuestState(Q_SUCCESS, QUEST_HELD_IN_ALMA, gWorldSectorX, gWorldSectorY, gbWorldSectorZ); + HandlePOWQuestState(Q_SUCCESS, QUEST_HELD_IN_TIXA, gWorldSectorX, gWorldSectorY, gbWorldSectorZ); + #endif // Say battle end quote.... if (fAnEnemyRetreated) @@ -8593,16 +8526,14 @@ BOOLEAN CheckForLosingEndOfBattle( ) { //if( GetWorldDay() > STARTDAY_ALLOW_PLAYER_CAPTURE_FOR_RESCUE && !( gStrategicStatus.uiFlags & STRATEGIC_PLAYER_CAPTURED_FOR_RESCUE )) { - #ifdef JA2UB - if (gubQuest[QUEST_HELD_IN_ALMA] == QUESTNOTSTARTED || (gubQuest[QUEST_HELD_IN_ALMA] != QUESTINPROGRESS && gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED)) - #else - if ( gubQuest[ QUEST_HELD_IN_ALMA ] == QUESTNOTSTARTED || gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED || (gubQuest[QUEST_HELD_IN_ALMA] != QUESTINPROGRESS && gubQuest[QUEST_HELD_IN_TIXA] != QUESTINPROGRESS && gubQuest[ QUEST_INTERROGATION ] == QUESTNOTSTARTED ) ) - #endif + #ifndef JA2UB + if ( gubQuest[ QUEST_HELD_IN_ALMA ] == QUESTNOTSTARTED || gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED || gubQuest[ QUEST_INTERROGATION ] == QUESTNOTSTARTED ) { fDoCapture = TRUE; // CJC Dec 1 2002: fix capture sequences BeginCaptureSquence(); } + #endif } } } @@ -8638,8 +8569,6 @@ BOOLEAN CheckForLosingEndOfBattle( ) if ( pTeamSoldier->stats.bLife != 0 && fDoCapture ) { EnemyCapturesPlayerSoldier( pTeamSoldier ); - - RemoveSoldierFromTacticalSector( pTeamSoldier, TRUE ); } } @@ -9302,11 +9231,6 @@ void HandleSuppressionFire( UINT8 ubTargetedMerc, UINT8 ubCausedAttacker ) { DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: suppression: change stance/cower")); CancelAIAction( pSoldier, TRUE ); -#if 0 - pSoldier->aiData.bAction = AI_ACTION_CHANGE_STANCE; - pSoldier->aiData.usActionData = ubNewStance; - pSoldier->aiData.bActionInProgress = TRUE; -#endif } // go for it! @@ -9648,38 +9572,6 @@ SOLDIERTYPE *InternalReduceAttackBusyCount( ) UINT32 cnt; UINT8 ubID; -#if 0 - // 0verhaul: None of this is necessary anymore with the new attack busy system - if (ubID == NOBODY) - { - pSoldier = NULL; - pTarget = NULL; - } - else - { - pSoldier = MercPtrs[ ubID ]; - if ( ubTargetID != NOBODY) - { - pTarget = MercPtrs[ ubTargetID ]; - } - else - { - pTarget = NULL; - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String(">>Target ptr is null!" ) ); - } - } - - if (fCalledByAttacker) - { - if (pSoldier && Item[pSoldier->inv[HANDPOS].usItem].usItemClass & IC_GUN) - { - if (pSoldier->bBulletsLeft > 0) - { - return( pTarget ); - } - } - } -#endif // if ((gTacticalStatus.uiFlags & TURNBASED) && (gTacticalStatus.uiFlags & INCOMBAT)) // { @@ -9720,7 +9612,7 @@ SOLDIERTYPE *InternalReduceAttackBusyCount( ) pSoldier = NULL; - if (gTacticalStatus.ubCurrentTeam == gbPlayerNum) + if (gTacticalStatus.ubCurrentTeam == gbPlayerNum && gusSelectedSoldier < TOTAL_SOLDIERS) { pSoldier = MercPtrs[ gusSelectedSoldier ]; } @@ -9741,7 +9633,7 @@ SOLDIERTYPE *InternalReduceAttackBusyCount( ) // If we still haven't figured out who last acted, it could be that the team number changed during the attack. Unfortunately this // can happen during a switch from real-time. For now we will assume the last actor was a PC, but a real "Who started this?" pointer // would work quite well. If only I could close all the holes that the UI opens so that one routine could handle everything. - if (!pSoldier) + if (!pSoldier && gusSelectedSoldier < TOTAL_SOLDIERS) { if (is_networked) { @@ -9804,15 +9696,6 @@ SOLDIERTYPE *InternalReduceAttackBusyCount( ) return( NULL ); } #endif -#if 0 - // 0verhaul: This is moved to the end loop where everybody's state is reset for the next action - if (pTarget) - { - // reset # of shotgun pellets hit by - pTarget->bNumPelletsHitBy = 0; - // reset flag for making "ow" sound on being shot - } -#endif if (pSoldier) { @@ -10105,17 +9988,6 @@ SOLDIERTYPE *InternalReduceAttackBusyCount( ) SOLDIERTYPE * ReduceAttackBusyCount( ) { -#if 0 - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("ReduceAttackBusyCount") ); - if ( ubID == NOBODY ) - { - return( InternalReduceAttackBusyCount( ubID, fCalledByAttacker, NOBODY ) ); - } - else - { - return( InternalReduceAttackBusyCount( ubID, fCalledByAttacker, MercPtrs[ ubID ]->ubTargetID ) ); - } -#endif // 0verhaul: This is now a simple subroutine. return InternalReduceAttackBusyCount( ); } @@ -10132,26 +10004,6 @@ SOLDIERTYPE * FreeUpAttacker( ) return( ReduceAttackBusyCount( ) ); } -#if 0 -// 0verhaul: These routines are declared obsolete. Call ReduceAttackBusyCount instead. -SOLDIERTYPE * FreeUpAttackerGivenTarget( UINT8 ubID, UINT8 ubTargetID ) -{ - // Strange as this may seem, this function returns a pointer to - // the *target* in case the target has changed sides as a result - // of being attacked - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("FreeUpAttackerGivenTarget") ); - return( InternalReduceAttackBusyCount( ubID, TRUE, ubTargetID ) ); -} - -SOLDIERTYPE * ReduceAttackBusyGivenTarget( UINT8 ubID, UINT8 ubTargetID ) -{ - // Strange as this may seem, this function returns a pointer to - // the *target* in case the target has changed sides as a result - // of being attacked - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("ReduceAttackBusyGivenTarget") ); - return( InternalReduceAttackBusyCount( ubID, FALSE, ubTargetID ) ); -} -#endif void StopMercAnimation( BOOLEAN fStop ) @@ -10381,7 +10233,10 @@ void DoneFadeOutDueToDeath( ) void EndBattleWithUnconsciousGuysCallback( UINT8 bExitValue ) { // Enter mapscreen..... - if(!is_client)CheckAndHandleUnloadingOfCurrentWorld(); + if (!is_client) + { + CheckAndHandleUnloadingOfCurrentWorld(); + } else { ScreenMsg( FONT_LTGREEN, MSG_CHAT, MPClientMessage[40] ); @@ -10525,6 +10380,12 @@ void DoPOWPathChecks( ) pSoldier->aiData.bNeutral = FALSE; AddCharacterToAnySquad( pSoldier ); pSoldier->DoMercBattleSound( BATTLE_SOUND_COOL1 ); + + // Decrement amount of prisoners + if (gStrategicStatus.ubNumCapturedForRescue > 0) + { + gStrategicStatus.ubNumCapturedForRescue--; + } } } } @@ -11175,6 +11036,107 @@ void HandleTurncoatAttempt( SOLDIERTYPE* pSoldier ) } } +void EscapeTimerCallback() +{ + const bool chanceToEscape = Chance(75); + bool escaped = false; + // Look for an escape direction for remaining mercs + std::array possibleEscapeDirections{ NORTH, EAST, SOUTH, WEST }; + std::random_device rd; + std::mt19937 g(rd()); + std::shuffle(possibleEscapeDirections.begin(), possibleEscapeDirections.end(), g); + + for (const auto direction : possibleEscapeDirections) + { + if (IsEscapeDirectionValid(direction) && chanceToEscape && gbWorldSectorZ == 0) // There is no escaping underground! For now.. + { + escaped = true; + ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szPrisonerTextStr[STR_PRISONER_ESCAPE]); + + JumpIntoEscapedSector(direction); + break; + } + } + + if (!escaped) + { + ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szPrisonerTextStr[STR_PRISONER_NO_ESCAPE]); + } +} + +void AttemptToCapturePlayerSoldiers() +{ +#ifdef JA2UB + ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szPrisonerTextStr[STR_PRISONER_REFUSE_TAKE_PRISONERS]); +#else + // in order for this to work, there must be no militia present, the enemy must not already have offered asked you to surrender, and certain quests may not be active + if (!(gTacticalStatus.fEnemyFlags & ENEMY_OFFERED_SURRENDER) && gTacticalStatus.Team[MILITIA_TEAM].bMenInSector == 0) + { + gTacticalStatus.fEnemyFlags |= ENEMY_OFFERED_SURRENDER; + + if (gubQuest[QUEST_HELD_IN_ALMA] == QUESTNOTSTARTED || gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED || gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED) + { + BeginCaptureSquence(); + const UINT8 currentPOWs = gStrategicStatus.ubNumCapturedForRescue; + // Do capture + UINT32 i = gTacticalStatus.Team[gbPlayerNum].bFirstID; + UINT32 const lastID = gTacticalStatus.Team[gbPlayerNum].bLastID; + for (SOLDIERTYPE* pSoldier = MercPtrs[i]; i <= lastID; ++i, ++pSoldier) + { + // Are we active and in sector + if (pSoldier->bActive && pSoldier->bInSector && pSoldier->bAssignment != ASSIGNMENT_POW) + { + if (pSoldier->stats.bLife != 0) + { + EnemyCapturesPlayerSoldier(pSoldier); + } + } + } + EndCaptureSequence(); + + if (currentPOWs < gStrategicStatus.ubNumCapturedForRescue) + { + gfSurrendered = TRUE; + } + else + { + ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szPrisonerTextStr[STR_PRISONER_REFUSE_TAKE_PRISONERS]); + } + } + } + else + { + ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szPrisonerTextStr[STR_PRISONER_REFUSE_TAKE_PRISONERS]); + } + + if (gfSurrendered == TRUE) + { + // If we have any remaining active mercs in sector after capture, give them a chance to escape from the clutches of Deidranna's soldiers! + bool activeMercs = false; + + UINT32 i = gTacticalStatus.Team[gbPlayerNum].bFirstID; + UINT32 lastId = gTacticalStatus.Team[gbPlayerNum].bLastID; + for (SOLDIERTYPE* pSoldier = MercPtrs[i]; i <= lastId; ++i, ++pSoldier) + { + // Are we active and in sector + const bool inSector = (pSoldier->sSectorX == gWorldSectorX && pSoldier->sSectorY == gWorldSectorY && pSoldier->bSectorZ == gbWorldSectorZ); + if (pSoldier->bActive && inSector && pSoldier->stats.bLife >= OKLIFE && pSoldier->bAssignment != ASSIGNMENT_POW) + { + activeMercs = true; + break; + } + } + + if (activeMercs) + { + SetCustomizableTimerCallbackAndDelay(500, EscapeTimerCallback, FALSE); + } + SetCustomizableTimerCallbackAndDelay(500, CaptureTimerCallback, FALSE); + CheckForEndOfBattle(FALSE); + } +#endif +} + void PrisonerSurrenderMessageBoxCallBack( UINT8 ubExitValue ) { SOLDIERTYPE *pSoldier = NULL; @@ -11339,49 +11301,7 @@ void PrisonerSurrenderMessageBoxCallBack( UINT8 ubExitValue ) return; } - // in order for this to work, there must be no militia present, the enemy must not already have offered asked you to surrender, and certain quests may not be active - if ( !( gTacticalStatus.fEnemyFlags & ENEMY_OFFERED_SURRENDER ) && gTacticalStatus.Team[ MILITIA_TEAM ].bMenInSector == 0 ) - { - #ifdef JA2UB - if (gubQuest[QUEST_HELD_IN_ALMA] == QUESTNOTSTARTED || (gubQuest[QUEST_HELD_IN_ALMA] != QUESTINPROGRESS && gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED)) - #else - if (gubQuest[QUEST_HELD_IN_ALMA] == QUESTNOTSTARTED || gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED || (gubQuest[QUEST_HELD_IN_ALMA] != QUESTINPROGRESS && gubQuest[QUEST_HELD_IN_TIXA] != QUESTINPROGRESS && gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED)) - #endif - { - gTacticalStatus.fEnemyFlags |= ENEMY_OFFERED_SURRENDER; - - // CJC Dec 1 2002: fix multiple captures - BeginCaptureSquence(); - - // Do capture.... - uiCnt = gTacticalStatus.Team[ gbPlayerNum ].bFirstID; - for ( pSoldier = MercPtrs[ uiCnt ]; uiCnt <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; ++uiCnt, ++pSoldier) - { - // Are we active and in sector..... - if ( pSoldier->bActive && pSoldier->bInSector ) - { - if ( pSoldier->stats.bLife != 0 ) - { - EnemyCapturesPlayerSoldier( pSoldier ); - - RemoveSoldierFromTacticalSector( pSoldier, TRUE ); - } - } - } - - EndCaptureSequence( ); - - gfSurrendered = TRUE; - SetCustomizableTimerCallbackAndDelay( 3000, CaptureTimerCallback, FALSE ); - - success = TRUE; - } - } - - if ( !success ) - { - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szPrisonerTextStr[ STR_PRISONER_REFUSE_TAKE_PRISONERS ] ); - } + SetCustomizableTimerCallbackAndDelay(500, AttemptToCapturePlayerSoldiers, FALSE); } // we distract the enemy by essentially talking them to death else if ( ubExitValue == 3 ) diff --git a/Tactical/Overhead.h b/Tactical/Overhead.h index 47d936539..16c42a6fe 100644 --- a/Tactical/Overhead.h +++ b/Tactical/Overhead.h @@ -4,7 +4,7 @@ #include #include #include "Soldier Control.h" -#include "overhead types.h" +#include #include "soldier find.h" #include "Campaign Types.h" // added by Flugente for SECTORINFO and UNDERGROUND_SECTORINFO #define ADD_SOLDIER_NO_PROFILE_ID 200 @@ -433,6 +433,6 @@ void VIPFleesToMeduna(); BOOLEAN IsCivFactionMemberAliveInSector( UINT8 usCivilianGroup ); BOOLEAN IsFreeSlotAvailable( int aTeam ); - +void AttemptToCapturePlayerSoldiers(); #endif diff --git a/Tactical/PATHAI.H b/Tactical/PATHAI.H index 2f0f949cc..c48a06a35 100644 --- a/Tactical/PATHAI.H +++ b/Tactical/PATHAI.H @@ -10,12 +10,6 @@ #define _PATHAI_H #include "isometric utils.h" -// WANNE: Please do not use ASTAR pathing, -// because it is a HUGH PERFORMANCE KILLER on big maps!! -//#define USE_ASTAR_PATHS - -#ifdef USE_ASTAR_PATHS - namespace ASTAR { #include "BinaryHeap.hpp" #include @@ -188,8 +182,6 @@ private: };//end namespace ASTAR -#endif// USE_ASTAR_PATHS - BOOLEAN InitPathAI( void ); void ShutDownPathAI( void ); diff --git a/Tactical/PATHAI.cpp b/Tactical/PATHAI.cpp index 0ca1e1662..fa31d2599 100644 --- a/Tactical/PATHAI.cpp +++ b/Tactical/PATHAI.cpp @@ -49,12 +49,12 @@ class OBJECTTYPE; class SOLDIERTYPE; -#ifdef USE_ASTAR_PATHS #include "BinaryHeap.hpp" -#include "AIInternals.h" #include "opplist.h" #include "weapons.h" -#endif +extern BOOLEAN gubWorldTileInLight[MAX_ALLOWED_WORLD_MAX]; +extern BOOLEAN gubIsCorpseThere[MAX_ALLOWED_WORLD_MAX]; +extern INT32 gubMerkCanSeeThisTile[MAX_ALLOWED_WORLD_MAX]; //#include "dnlprocesstalk.h"//dnl??? extern UINT16 gubAnimSurfaceIndex[ TOTALBODYTYPES ][ NUMANIMATIONSTATES ]; @@ -454,9 +454,6 @@ UINT32 guiFailedPathChecks = 0; UINT32 guiUnsuccessfulPathChecks = 0; #endif -#ifdef USE_ASTAR_PATHS - - //ADB the extra cover feature is supposed to pick a path of the same distance as one calculated with the feature off, //but a safer path, usually farther away from an enemy or following behind some cover. //however it has not been tested and it may need some work, I haven't touched it in a while @@ -647,7 +644,7 @@ int AStarPathfinder::GetPath(SOLDIERTYPE *s , fCloseGoodEnough = ( (fFlags & PATH_CLOSE_GOOD_ENOUGH) != 0); fConsiderPersonAtDestAsObstacle = (BOOLEAN)( fPathingForPlayer && fPathAroundPeople && !(fFlags & PATH_IGNORE_PERSON_AT_DEST) ); - if ( fNonSwimmer && Water( dest ) ) + if ( fNonSwimmer && Water( dest, 0 ) ) { DebugMsg( TOPIC_JA2, DBG_LEVEL_0, String( "ASTAR: path failed, water" ) ); return( 0 ); @@ -708,7 +705,6 @@ int AStarPathfinder::GetPath(SOLDIERTYPE *s , guiTotalPathChecks++; #endif -#ifdef VEHICLE fMultiTile = ((pSoldier->flags.uiStatusFlags & SOLDIER_MULTITILE) != 0); if ( fMultiTile == false) @@ -758,7 +754,6 @@ int AStarPathfinder::GetPath(SOLDIERTYPE *s , fContinuousTurnNeeded = FALSE; } } -#endif if (fContinuousTurnNeeded == false) { @@ -802,17 +797,6 @@ int AStarPathfinder::GetPath(SOLDIERTYPE *s , if (gfDisplayCoverValues && gfDrawPathPoints) { SetRenderFlags( RENDER_FLAG_FULL ); -// The RenderCoverDebugInfo call is now made by RenderWorld. So don't try to call it here -#if 0 - if ( guiCurrentScreen == GAME_SCREEN ) - { - RenderWorld(); - RenderCoverDebug( ); - InvalidateScreen( ); - EndFrameBufferRender(); - RefreshScreen( NULL ); - } -#endif } #endif @@ -901,13 +885,6 @@ int AStarPathfinder::GetPath(SOLDIERTYPE *s , if (gfDisplayCoverValues && gfDrawPathPoints) { SetRenderFlags( RENDER_FLAG_FULL ); -#if 0 - RenderWorld(); - RenderCoverDebug( ); - InvalidateScreen( ); - EndFrameBufferRender(); - RefreshScreen( NULL ); -#endif } #endif @@ -1088,7 +1065,6 @@ void AStarPathfinder::ExecuteAStarLogic() continue; } -#ifdef VEHICLE //has side effects, including setting loop counters int retVal = VehicleObstacleCheck(); if (retVal == 1) @@ -1099,7 +1075,6 @@ void AStarPathfinder::ExecuteAStarLogic() { return; } -#endif //calc the cost to move from the current node to here INT16 terrainCost = EstimateActionPointCost( pSoldier, CurrentNode, direction, movementMode, 0, 3 ); @@ -1412,7 +1387,7 @@ INT16 AStarPathfinder::CalcAP(int const terrainCost, UINT8 const direction) } // Flugente: dragging someone - if ( pSoldier->IsDraggingSomeone( ) ) + if ( pSoldier->IsDragging( false ) ) { movementAPCost *= gItemSettings.fDragAPCostModifier; } @@ -1769,7 +1744,6 @@ int AStarPathfinder::CalcH() int x = abs(n1->x - n2->x); int y = abs(n1->y - n2->y); -#if 1 if (x >= y) { return this->travelcostDiag * y + this->travelcostOrth * (x-y); @@ -1778,35 +1752,6 @@ int AStarPathfinder::CalcH() { return this->travelcostDiag * x + this->travelcostOrth * (y-x); } -#else - // Try a real distance method. This should underestimate in some cases - // However, the distances need to be increased for the moment because running orthogonal is 1AP while running diagonal is 2AP - // so the total to reach a diagonal tile is identical for 2 moves. So we have to trick the pathing calc into thinking it's - // a longer distance and also calculate the other costs accordingly. - - x *= 100; - y *= 100; - - int d = x*x + y*y; - int r = 1200; // Just a guess - - if (d == 0) - { - return d; - } - - while (1) - { - int gr = (r + (d/r)) / 2; - if (gr == r || gr == r+1) - { - break; - } - r = gr; - } - - return r * travelcostOrth; -#endif } #ifdef ASTAR_USING_EXTRACOVER @@ -2116,7 +2061,6 @@ int AStarPathfinder::CalcCoverValue(INT32 sMyGridNo, INT32 iMyThreat, INT32 iMyA } #endif //#ifdef ASTAR_USING_EXTRACOVER -#ifdef VEHICLE void AStarPathfinder::InitVehicle() { fMultiTile = ((pSoldier->flags.uiStatusFlags & SOLDIER_MULTITILE) != 0); @@ -2263,7 +2207,6 @@ int AStarPathfinder::VehicleObstacleCheck() } return 0; } -#endif bool AStarPathfinder::WantToTraverse() { @@ -2411,7 +2354,6 @@ bool AStarPathfinder::IsSomeoneInTheWay() return false; } -#endif//end ifdef USE_ASTAR_PATHS INT8 RandomSkipListLevel( void ) { @@ -2484,27 +2426,29 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT32 sDestination, INT8 bLevel, INT16 usMov { s->sPlotSrcGrid = s->sGridNo; -#ifdef USE_ASTAR_PATHS -//ddd -CHAR8 errorBuf[511]; UINT32 b,e; -b=GetJA2Clock();//return s->sGridNo+6; - - int retVal = ASTAR::AStarPathfinder::GetInstance().GetPath(s, sDestination, bLevel, usMovementMode, bCopy, fFlags); - - e=GetJA2Clock();sprintf(errorBuf, "timefind bestpath= %d",e-b );LiveMessage(errorBuf); - - if (retVal || TileIsOutOfBounds(sDestination)) { - return retVal; - } - else { - DebugMsg( TOPIC_JA2, DBG_LEVEL_0, String( "ASTAR path failed!" ) ); - } - - // if (TileIsOutOfBounds(sDestination)) + if (gGameSettings.fOptions[TOPTION_ALT_PATHFINDING]) { - return 0; + CHAR8 errorBuf[511]; UINT32 b,e; + b=GetJA2Clock();//return s->sGridNo+6; + + int retVal = ASTAR::AStarPathfinder::GetInstance().GetPath(s, sDestination, bLevel, usMovementMode, bCopy, fFlags); + + e=GetJA2Clock();sprintf(errorBuf, "timefind bestpath= %d",e-b );LiveMessage(errorBuf); + + if (retVal || TileIsOutOfBounds(sDestination)) { + return retVal; + } + else { + DebugMsg( TOPIC_JA2, DBG_LEVEL_0, String( "ASTAR path failed!" ) ); + } + + // if (TileIsOutOfBounds(sDestination)) + { + return 0; + } } -#else + else + { //__try //{ INT32 iDestination = sDestination, iOrigination; @@ -2523,7 +2467,6 @@ b=GetJA2Clock();//return s->sGridNo+6; INT32 iWaterToWater; INT16 ubCurAPCost,ubAPCost; INT16 ubNewAPCost=0; - #ifdef VEHICLE //BOOLEAN fTurnSlow = FALSE; //BOOLEAN fReverse = FALSE; // stuff for vehicles turning BOOLEAN fMultiTile, fVehicle; @@ -2534,7 +2477,6 @@ b=GetJA2Clock();//return s->sGridNo+6; UINT16 usAnimSurface; //INT32 iCnt2, iCnt3; BOOLEAN fVehicleIgnoreObstacles = FALSE; - #endif INT32 iLastDir = 0; @@ -2636,9 +2578,7 @@ if(!GridNoOnVisibleWorldTile(iDestination)) fTurnBased = ( (gTacticalStatus.uiFlags & TURNBASED) && (gTacticalStatus.uiFlags & INCOMBAT) ); fPathingForPlayer = ( (s->bTeam == gbPlayerNum) && (!gTacticalStatus.fAutoBandageMode) && !(s->flags.uiStatusFlags & SOLDIER_PCUNDERAICONTROL) ); - fNonFenceJumper = !( IS_MERC_BODY_TYPE( s ) ) || (UsingNewInventorySystem() == true && s->inv[BPACKPOCKPOS].exists() == true - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)s->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[s->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[s->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE)));//Moa: added backpack check + fNonFenceJumper = !( IS_MERC_BODY_TYPE( s ) ) || (!s->CanClimbWithCurrentBackpack());//Moa: added backpack check // Flugente: nonswimmers are those who are not mercs and not boats fNonSwimmer = !(IS_MERC_BODY_TYPE( s ) ); @@ -2759,7 +2699,6 @@ if(!GridNoOnVisibleWorldTile(iDestination)) guiTotalPathChecks++; #endif -#ifdef VEHICLE fMultiTile = ((s->flags.uiStatusFlags & SOLDIER_MULTITILE) != 0); if (fMultiTile) @@ -2819,7 +2758,6 @@ if(!GridNoOnVisibleWorldTile(iDestination)) fContinuousTurnNeeded = FALSE; } -#endif if (!fContinuousTurnNeeded) { @@ -2962,7 +2900,6 @@ if(!GridNoOnVisibleWorldTile(iDestination)) } #endif -#ifdef VEHICLE /* if (fTurnSlow) { @@ -2987,7 +2924,6 @@ if(!GridNoOnVisibleWorldTile(iDestination)) } */ -#endif if (gubNPCAPBudget) { @@ -3048,7 +2984,6 @@ if(!GridNoOnVisibleWorldTile(iDestination)) //for ( iCnt = iLoopStart; iCnt != iLoopEnd; iCnt = (iCnt + iLoopIncrement) % MAXDIR ) for ( iCnt = iLoopStart; ; ) { -#ifdef VEHICLE /* if (fTurnSlow) { @@ -3130,7 +3065,6 @@ if(!GridNoOnVisibleWorldTile(iDestination)) } } -#endif newLoc = curLoc + dirDelta[iCnt]; @@ -3479,7 +3413,6 @@ if(!GridNoOnVisibleWorldTile(iDestination)) } } -#ifdef VEHICLE if (fMultiTile) { // vehicle test for obstacles: prevent movement to next tile if @@ -3518,7 +3451,6 @@ if(!GridNoOnVisibleWorldTile(iDestination)) } */ } -#endif // NEW Apr 21 by Ian: abort if cost exceeds budget if (gubNPCAPBudget) @@ -4276,7 +4208,7 @@ ENDOFLOOP: //{ // return (0); //} -#endif + } } void GlobalReachableTest( INT32 sStartGridNo ) diff --git a/Tactical/Points.cpp b/Tactical/Points.cpp index 53cbe3f14..020d8df1e 100644 --- a/Tactical/Points.cpp +++ b/Tactical/Points.cpp @@ -118,9 +118,7 @@ INT16 TerrainActionPoints( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bDir, INT8 //CHRISL: We can't jump a fence while wearing a backpack, to consider fences as impassible // SANDRO - Headrocks change to backpack check implemented - if(sSwitchValue == TRAVELCOST_FENCE && UsingNewInventorySystem() == true && pSoldier->inv[BPACKPOCKPOS].exists() == true - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) + if(sSwitchValue == TRAVELCOST_FENCE && !pSoldier->CanClimbWithCurrentBackpack()) { return(-1); } @@ -679,7 +677,6 @@ INT16 EstimateActionPointCost( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bDir, // Get switch value... sSwitchValue = gubWorldMovementCosts[ sGridNo ][ bDir ][ pSoldier->pathing.bLevel ]; -#if 1 //Moa: set to 0 to use original copy and paste code from ActionPointCost() if ( sSwitchValue == TRAVELCOST_FENCE ) { // If we are changeing stance ( either before or after getting there.... @@ -737,191 +734,6 @@ INT16 EstimateActionPointCost( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bDir, sPoints += ActionPointCost( pSoldier, sGridNo, bDir, usMovementMode ); return (sPoints); -#else - // Tile cost should not be reduced based on movement mode... - if ( sSwitchValue == TRAVELCOST_FENCE ) - { - return( sTileCost ); - } - - - // WANNE.WATER: If our soldier is not on the ground level and the tile is a "water" tile, then simply set the tile to "FLAT_GROUND" - // This should fix "problems" for special modified maps - UINT8 ubTerrainID = gpWorldLevelData[ sGridNo ].ubTerrainID; - - if ( TERRAIN_IS_WATER( ubTerrainID) && pSoldier->pathing.bLevel > 0 ) - ubTerrainID = FLAT_GROUND; - - // ATE - MAKE MOVEMENT ALWAYS WALK IF IN WATER - if ( TERRAIN_IS_WATER( ubTerrainID) ) - { - usMovementMode = WALKING; - } - - // so, then we must modify it for other movement styles and accumulate - // CHRISL: Adjusted system to use different move costs while wearing a backpack - if (sTileCost > 0) - { - /////////////////////////////////////////////////////////////////////////////////////////////////////////// - // SANDRO - This part have been modified "a bit" - // Check movement modifiers - switch( usMovementMode ) - { - case RUNNING: - case ADULTMONSTER_WALKING: - case BLOODCAT_RUN: - sPoints = sTileCost + APBPConstants[AP_MODIFIER_RUN]; - 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 : - case WALKING_ALTERNATIVE_RDY : - case SIDE_STEP_ALTERNATIVE_RDY : - sPoints = sTileCost + APBPConstants[AP_MODIFIER_WALK]; - if (!(pSoldier->MercInWater()) && ( (gAnimControl[ pSoldier->usAnimState ].uiFlags & ANIM_FIREREADY ) || (gAnimControl[ pSoldier->usAnimState ].uiFlags & ANIM_FIRE ) ) && !(gAnimControl[ pSoldier->usAnimState ].uiFlags & ANIM_ALT_WEAPON_HOLDING ) ) - { - sPoints += APBPConstants[AP_MODIFIER_READY]; - } - break; - case SIDE_STEP_WEAPON_RDY: - case SIDE_STEP_DUAL_RDY: - case WALKING_WEAPON_RDY: - case WALKING_DUAL_RDY: - sPoints = sTileCost + APBPConstants[AP_MODIFIER_WALK] + APBPConstants[AP_MODIFIER_READY]; - break; - case START_SWAT: - case SWAT_BACKWARDS: - case SWATTING: - sPoints = sTileCost + APBPConstants[AP_MODIFIER_SWAT]; - break; - case CRAWLING: - sPoints = sTileCost + APBPConstants[AP_MODIFIER_CRAWL]; - break; - - default: - - // Invalid movement mode - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Invalid movement mode %d used in ActionPointCost", usMovementMode ) ); - sPoints = sTileCost; - break; - } - - // Check for reverse mode - if ( pSoldier->bReverse || gUIUseReverse ) - sPoints += APBPConstants[AP_REVERSE_MODIFIER]; - - // STOMP traits - Athletics trait decreases movement cost - if ( gGameOptions.fNewTraitSystem && HAS_SKILL_TRAIT( pSoldier, ATHLETICS_NT )) - { - sPoints = max(1, (INT16)((sPoints * (100 - gSkillTraitValues.ubATAPsMovementReduction) / 100) + 0.5)); - } - - // Flugente: riot shields lower movement speed - if ( pSoldier->IsRiotShieldEquipped( ) ) - sPoints *= gItemSettings.fShieldMovementAPCostModifier; - - // Flugente: dragging someone - if ( pSoldier->IsDraggingSomeone( ) ) - sPoints *= gItemSettings.fDragAPCostModifier; - - // Check if doors if not player's merc (they have to open them manually) - if ( sSwitchValue == TRAVELCOST_DOOR && pSoldier->bTeam != gbPlayerNum ) - { - sPoints += GetAPsToOpenDoor( pSoldier ) + GetAPsToOpenDoor( pSoldier ); // Include open and close costs! - } - // Check for stealth mode - if ( pSoldier->bStealthMode ) - { - // STOMP traits - Stealthy trait decreases stealth AP modifier - if ( gGameOptions.fNewTraitSystem && HAS_SKILL_TRAIT( pSoldier, STEALTHY_NT )) - { - sPoints += (max(0, (INT16)((APBPConstants[AP_STEALTH_MODIFIER] * (100 - gSkillTraitValues.ubSTStealthModeSpeedBonus) / 100) + 0.5))); - } - else - { - sPoints += APBPConstants[AP_STEALTH_MODIFIER]; - } - } - // Check for backpack - if((UsingNewInventorySystem() == true) && FindBackpackOnSoldier( pSoldier ) != ITEM_NOT_FOUND ) - sPoints += APBPConstants[AP_MODIFIER_PACK]; - - /////////////////////////////////////////////////////////////////////////////////////////////////////////// - } - - // Get switch value... - sSwitchValue = gubWorldMovementCosts[ sGridNo ][ bDir ][ pSoldier->pathing.bLevel ]; - - // ATE: If we have a 'special cost, like jump fence... - if ( sSwitchValue == TRAVELCOST_FENCE ) - { - // If we are changeing stance ( either before or after getting there.... - // We need to reflect that... - switch(usMovementMode) - { - case SIDE_STEP: - case SIDE_STEP_WEAPON_RDY: - case SIDE_STEP_DUAL_RDY: - case WALK_BACKWARDS: - case RUNNING: - case WALKING : - case WALKING_WEAPON_RDY: - case WALKING_DUAL_RDY: - case WALKING_ALTERNATIVE_RDY : - case SIDE_STEP_ALTERNATIVE_RDY: - - // 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 += GetAPsCrouch(pSoldier, TRUE); // SANDRO changed.. - } - break; - - case SWATTING: - case START_SWAT: - case SWAT_BACKWARDS: - - // Add cost to stand once there BEFORE.... - sPoints += GetAPsCrouch(pSoldier, TRUE); // SANDRO changed.. - break; - - case CRAWLING: - - // Can't do it here..... - break; - } - } - else if (sSwitchValue == TRAVELCOST_NOT_STANDING) - { - switch(usMovementMode) - { - case RUNNING: - case WALKING : - case WALKING_WEAPON_RDY: - case WALKING_DUAL_RDY: - case SIDE_STEP: - case SIDE_STEP_WEAPON_RDY: - case SIDE_STEP_DUAL_RDY: - case WALK_BACKWARDS: - case WALKING_ALTERNATIVE_RDY : - case SIDE_STEP_ALTERNATIVE_RDY: - // charge crouch APs for ducking head! - sPoints += GetAPsCrouch(pSoldier, TRUE); // SANDRO changed.. - break; - - default: - break; - } - } - - return( sPoints ); -#endif } @@ -2563,20 +2375,6 @@ INT16 MinAPsToShootOrStab(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 bAimTime, // Do we need to stand up? bAPCost += GetAPsToChangeStance( pSoldier, ANIM_STAND ); } -#if 0//dnl ch73 021013 relocate this to MinAPsToPunch - // blunt weapons & blades - else if ( Item[ usUBItem ].usItemClass == IC_PUNCH || Item[ usUBItem ].usItemClass == IC_BLADE ) - { - if ( usTargID != NOBODY ) - { - // Check if target is prone, if so, calc cost... - if ( gAnimControl[ MercPtrs[ usTargID ]->usAnimState ].ubEndHeight == ANIM_PRONE ) - bAPCost += GetAPsToChangeStance( pSoldier, ANIM_CROUCH ); - else - bAPCost += GetAPsToChangeStance( pSoldier, ANIM_STAND ); - } - } -#endif else if(Item[usItem].rocketlauncher || Item[usItem].grenadelauncher || Item[usItem].mortar)//dnl ch72 260913 move this here from bottom, need to change as rocketlaucher could be fired from crouch too { if(gAnimControl[pSoldier->usAnimState].ubEndHeight == ANIM_PRONE || Item[usItem].mortar && gAnimControl[pSoldier->usAnimState].ubEndHeight == ANIM_STAND) @@ -2594,10 +2392,6 @@ INT16 MinAPsToShootOrStab(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 bAimTime, //Calculate usTurningCost if (!TileIsOutOfBounds(sGridNo)) { -#if 0//dnl ch73 021013 relocate this to MinAPsToPunch - // Buggler: actual melee ap deduction for turning applies only when target is 1 tile away - if ( !( ( Item[ usUBItem ].usItemClass == IC_PUNCH || Item[ usUBItem ].usItemClass == IC_BLADE ) && usRange > 1 ) ) -#endif { if(Item[usItem].rocketlauncher || Item[usItem].grenadelauncher || Item[usItem].mortar)//dnl ch72 260913 { @@ -2652,11 +2446,6 @@ INT16 MinAPsToShootOrStab(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 bAimTime, bAPCost += APBPConstants[AP_UNJAM]; } -#if 0//dnl ch63 240813 this seems very wrong, in most case (pSoldier->bActionPoints > bFullAps) and this will return less points then is actually required and could cancel some AI actions, like throwing grenades - // the minimum AP cost of ANY shot can NEVER be more than merc's maximum APs! - if ( bAPCost > bFullAPs ) - bAPCost = bFullAPs; -#endif // this SHOULD be impossible, but nevertheless... if ( bAPCost < 1 ) bAPCost = 1; @@ -3812,73 +3601,8 @@ INT16 MinAPsToThrow( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 ubAddTurningCos INT32 iFullAPs; INT32 iAPCost = APBPConstants[AP_MIN_AIM_ATTACK]; UINT16 usInHand; -#if 0//dnl ch72 180913 - UINT16 usTargID; - UINT32 uiMercFlags; - UINT8 ubDirection; - - if(pSoldier->bWeaponMode == WM_ATTACHED_GL || pSoldier->bWeaponMode == WM_ATTACHED_GL_BURST || pSoldier->bWeaponMode == WM_ATTACHED_GL_AUTO)//dnl ch63 240813 - usInHand = GetAttachedGrenadeLauncher(&pSoldier->inv[HANDPOS]); - else -#endif // make sure the guy's actually got a throwable item in his hand! usInHand = pSoldier->inv[HANDPOS].usItem; -#if 0//dnl ch72 180913 this goes down because of new trait system - if ( ( !(Item[ usInHand ].usItemClass & IC_GRENADE) && - !(Item[ usInHand ].usItemClass & IC_LAUNCHER)) ) - { - //AXP 25.03.2007: See if we are about to throw grenade (grenade was not in hand, but in temp object) - if ( pSoldier->pTempObject != NULL && pSoldier->pThrowParams != NULL && - pSoldier->pThrowParams->ubActionCode == THROW_ARM_ITEM && (Item[ pSoldier->pTempObject->usItem ].usItemClass & IC_GRENADE) ) - { - //nothing here - } - else - { -#ifdef JA2TESTVERSION - ScreenMsg( MSG_FONT_YELLOW, MSG_DEBUG, L"MinAPsToThrow - Called when in-hand item is %d", usInHand ); -#endif - return(0); - } - } - - if (!TileIsOutOfBounds(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; - } - - /*// OK, get a direction and see if we need to turn... - if (ubAddTurningCost) - { - ubDirection = (UINT8)GetDirectionFromGridNo( sGridNo, pSoldier ); - - // Is it the same as he's facing? - if ( ubDirection != pSoldier->ubDirection ) - { - //Lalien: disabled it again - //AXP 25.03.2007: Reenabled look cost - //iAPCost += GetAPsToLook( pSoldier ); - } - }*/ - } - /*else - { - // Assume we need to add cost! - //iAPCost += GetAPsToLook( pSoldier ); - }*/ - - // if attacking a new target (or if the specific target is uncertain) - //AXP 25.03.2007: Aim-at-same-tile AP cost/bonus doesn't make any sense for thrown objects - //if ( ( sGridNo != pSoldier->sLastTarget ) ) - //{ - // iAPCost += APBPConstants[AP_CHANGE_TARGET]; - //} - - //iAPCost += GetAPsToChangeStance( pSoldier, ANIM_STAND ); // moved lower - SANDRO -#endif // Calculate default top & bottom of the magic "aiming" formula) diff --git a/Tactical/Real Time Input.cpp b/Tactical/Real Time Input.cpp index b23b93e53..f62e77de5 100644 --- a/Tactical/Real Time Input.cpp +++ b/Tactical/Real Time Input.cpp @@ -798,28 +798,6 @@ void QueryRTLeftButton( UINT32 *puiNewEvent ) { // ATE: Select everybody in squad and make move! { -#if 0 - SOLDIERTYPE * pTeamSoldier; - INT32 cnt; - SOLDIERTYPE *pFirstSoldier = NULL; - - // OK, loop through all guys who are 'multi-selected' and - // check if our currently selected guy is amoung the - // lucky few.. if not, change to a guy who is... - cnt = gTacticalStatus.Team[ gbPlayerNum ].bFirstID; - for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; cnt++, pTeamSoldier++ ) - { - // Default turn off - pTeamSoldier->flags.uiStatusFlags &= (~SOLDIER_MULTI_SELECTED ); - - // If controllable - if ( OK_CONTROLLABLE_MERC( pTeamSoldier ) && pTeamSoldier->bAssignment == MercPtrs[ gusSelectedSoldier ]->bAssignment ) - { - pTeamSoldier->flags.uiStatusFlags |= SOLDIER_MULTI_SELECTED; - } - } - EndMultiSoldierSelection( FALSE ); -#endif // Make move! *puiNewEvent = C_MOVE_MERC; @@ -888,36 +866,6 @@ void QueryRTLeftButton( UINT32 *puiNewEvent ) } -#if 0 - fDone = FALSE; - if( GetSoldier( &pSoldier, gusUIFullTargetID ) && gpItemPointer == NULL ) - { - if( ( guiUIFullTargetFlags & OWNED_MERC ) && ( guiUIFullTargetFlags & VISIBLE_MERC ) && !( guiUIFullTargetFlags & DEAD_MERC ) &&( pSoldier->bAssignment >= ON_DUTY )&&!( pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE ) ) - { - fShowAssignmentMenu = TRUE; - gfRTClickLeftHoldIntercepted = TRUE; - CreateDestroyAssignmentPopUpBoxes( ); - SetTacticalPopUpAssignmentBoxXY( ); - DetermineBoxPositions( ); - DetermineWhichAssignmentMenusCanBeShown( ); - fFirstClickInAssignmentScreenMask = TRUE; - gfIgnoreScrolling = TRUE; - - fDone = TRUE; - } - else - { - fShowAssignmentMenu = FALSE; - CreateDestroyAssignmentPopUpBoxes( ); - DetermineWhichAssignmentMenusCanBeShown( ); - } - } - - if( fDone == TRUE ) - { - break; - } -#endif break; @@ -2162,12 +2110,9 @@ void HandleMouseRTX1Button( UINT32 *puiNewEvent ) BOOLEAN fNearHeigherLevel; BOOLEAN fNearLowerLevel; INT8 bDirection; - // CHRISL: Turn off manual jumping while wearing a backpack - if (UsingNewInventorySystem() == true && pjSoldier->inv[BPACKPOCKPOS].exists() == true - //JMich.BackpackClimb - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) + // CHRISL: Turn off manual jumping while wearing a backpack + if (!pjSoldier->CanClimbWithCurrentBackpack()) return; // Make sure the merc is not collapsed! @@ -2259,12 +2204,9 @@ void HandleRTJump( void ) BOOLEAN fNearHeigherLevel; BOOLEAN fNearLowerLevel; INT8 bDirection; - // CHRISL: Turn off manual jumping while wearing a backpack - if (UsingNewInventorySystem() == true && pjSoldier->inv[BPACKPOCKPOS].exists() == true - //JMich.BackpackClimb - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) + // CHRISL: Turn off manual jumping while wearing a backpack + if (!pjSoldier->CanClimbWithCurrentBackpack()) return; // Make sure the merc is not collapsed! diff --git a/Tactical/Rotting Corpses.cpp b/Tactical/Rotting Corpses.cpp index c58273e7b..93882d899 100644 --- a/Tactical/Rotting Corpses.cpp +++ b/Tactical/Rotting Corpses.cpp @@ -660,11 +660,7 @@ INT32 AddRottingCorpse( ROTTING_CORPSE_DEFINITION *pCorpseDef ) for (ubLoop = 0; ubLoop < pDBStructureRef->pDBStructure->ubNumberOfTiles; ubLoop++) { ppTile = pDBStructureRef->ppTile; -#if 0//dnl ch83 080114 - sTileGridNo = pCorpseDef->sGridNo + ppTile[ ubLoop ]->sPosRelToBase; -#else sTileGridNo = AddPosRelToBase(pCorpseDef->sGridNo, ppTile[ubLoop]); -#endif //Remove blood RemoveBlood( sTileGridNo, pCorpseDef->bLevel ); } @@ -1544,52 +1540,6 @@ ROTTING_CORPSE *FindCorpseBasedOnStructure( INT32 sGridNo, INT8 asLevel, STRUCT void CorpseHit( INT32 sGridNo, INT8 asLevel, UINT16 usStructureID ) { -#if 0 - STRUCTURE *pStructure, *pBaseStructure; - ROTTING_CORPSE *pCorpse = NULL; - INT32 sBaseGridNo; - - pStructure = FindStructureByID( sGridNo, usStructureID ); - - // Get base.... - pBaseStructure = FindBaseStructure( pStructure ); - - // Find base gridno... - sBaseGridNo = pBaseStructure->sGridNo; - - // Get corpse ID..... - pCorpse = FindCorpseBasedOnStructure( sBaseGridNo, asLevel, pBaseStructure ); - - if ( pCorpse == NULL ) - { - #ifdef JA2TESTVERSION - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_TESTVERSION, L"Bullet hit corpse but corpse cannot be found at: %d", sBaseGridNo ); - #endif - return; - } - - // Twitch the bugger... - #ifdef JA2BETAVERSION - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_TESTVERSION, L"Corpse hit" ); - #endif - - if ( GridNoOnScreen( sBaseGridNo ) ) - { - // Twitch.... - // Set frame... - SetAniTileFrame( pCorpse->pAniTile, 1 ); - - // Go reverse... - pCorpse->pAniTile->uiFlags |= ( ANITILE_BACKWARD | ANITILE_PAUSE_AFTER_LOOP ); - - // Turn off pause... - pCorpse->pAniTile->uiFlags &= (~ANITILE_PAUSED); - } - - // PLay a sound.... - PlayJA2Sample( (UINT32)( BULLET_IMPACT_2 ), RATE_11025, SoundVolume( MIDVOLUME, sGridNo ), 1, SoundDir( sGridNo ) ); - -#endif } void VaporizeCorpse( INT32 sGridNo, INT8 asLevel, UINT16 usStructureID ) diff --git a/Tactical/Soldier Ani.cpp b/Tactical/Soldier Ani.cpp index cf6025fb7..e60f7bec2 100644 --- a/Tactical/Soldier Ani.cpp +++ b/Tactical/Soldier Ani.cpp @@ -3206,14 +3206,14 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier ) case 762: { // CODE: Set off Trigger - INT8 bPanicTrigger; - - bPanicTrigger = ClosestPanicTrigger( pSoldier ); - SetOffPanicBombs( pSoldier->ubID, bPanicTrigger ); + INT8 bPanicTrigger = ClosestPanicTrigger( pSoldier ); + if (bPanicTrigger != -1) + { + SetOffPanicBombs( pSoldier->ubID, bPanicTrigger ); + } // any AI guy has been specially given keys for this, now take them // away pSoldier->flags.bHasKeys = pSoldier->flags.bHasKeys >> 1; - } break; @@ -4857,48 +4857,6 @@ BOOLEAN HandleUnjamAnimation( SOLDIERTYPE *pSoldier ) -#if 0 -//OK, if here, if our health is still good, but we took a lot of damage, try to fall down! -if ( pSoldier->stats.bLife >= OKLIFE ) -{ - // Randomly fall back or forward, if we are in the standing hit animation - if ( pSoldier->usAnimState == GENERIC_HIT_STAND || pSoldier->usAnimState == RIFLE_STAND_HIT ) - { - INT8 bTestDirection = pSoldier->ubDirection; - BOOLEAN fForceDirection = FALSE; - BOOLEAN fDoFallback = FALSE; - - // As the damage pretty brutal? - - // TRY FALLING BACKWARDS, ( ONLY IF WE ARE A MERC! ) - if ( Random( 1000 ) > 40 && IS_MERC_BODY_TYPE( pSoldier ) ) - { - // CHECK IF WE HAVE AN ATTACKER, TAKE OPPOSITE DIRECTION! - if ( pSoldier->ubAttackerID != NOBODY ) - { - // Find direction! - bTestDirection = (INT8)GetDirectionFromGridNo( MercPtrs[ pSoldier->ubAttackerID ]->sGridNo, pSoldier ); - fForceDirection = TRUE; - } - - sNewGridNo = NewGridNo( pSoldier->sGridNo, (UINT16)(-1 * DirectionInc( bTestDirection ) ) ); - - if ( NewOKDestination( pSoldier, sNewGridNo, TRUE, pSoldier->pathing.bLevel ) && OKHeightDest( pSoldier, sNewGridNo ) ) - { - // ALL'S OK HERE..... IF WE FORCED DIRECTION, SET! - if ( fForceDirection ) - { - pSoldier->EVENT_SetSoldierDirection( bTestDirection ); - pSoldier->EVENT_SetSoldierDesiredDirection( bTestDirection ); - } - pSoldier->ChangeSoldierState( FALLBACK_HIT_STAND, 0, FALSE ); - return; - } - } - } -} - -#endif BOOLEAN OKFallDirection( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bLevel, UINT8 ubTestDirection, UINT16 usAnimState ) { diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 7439c1bdf..51fb72787 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -13,6 +13,7 @@ #include "Animation Data.h" #include "Animation Control.h" #include "container.h" +#define _USE_MATH_DEFINES // for C #include #include "pathai.h" #include "Random.h" @@ -3632,29 +3633,6 @@ BOOLEAN SOLDIERTYPE::EVENT_InitNewSoldierAnim( UINT16 usNewState, UINT16 usStart // Unset paused for no APs..... this->AdjustNoAPToFinishMove( FALSE ); -#if 0 - // 0verhaul: This is a test. The only time I have been able to make this code hit is when - // the player goes prone while moving. And that is not what this part is intended for. I - // have seen the soldier in the middle of crawling, get up, turn, and then go prone again to - // continue along his path. But this code was not hit for that part. And this code seems - // to be made for that part. So apparently they found another way to deal with it. So - // I disabled the "locked" code for usDontUpdateNewGridNoOnMoveAnimChange since it can cause - // problems of its own. Now we see if we can do without this part too. - if ( usNewState == CRAWLING && this->usDontUpdateNewGridNoOnMoveAnimChange == 1 ) - { - if ( this->flags.bTurningFromPronePosition != TURNING_FROM_PRONE_ENDING_UP_FROM_MOVE ) - { - this->flags.bTurningFromPronePosition = TURNING_FROM_PRONE_START_UP_FROM_MOVE; - } - - // ATE: IF we are starting to crawl, but have to getup to turn first...... - if ( this->flags.bTurningFromPronePosition == TURNING_FROM_PRONE_START_UP_FROM_MOVE ) - { - usNewState = PRONE_UP; - this->flags.bTurningFromPronePosition = TURNING_FROM_PRONE_ENDING_UP_FROM_MOVE; - } - } -#endif // We are about to start moving // Handle buddy beginning to move... @@ -3794,20 +3772,8 @@ BOOLEAN SOLDIERTYPE::EVENT_InitNewSoldierAnim( UINT16 usNewState, UINT16 usStart // 0verhaul: Okay, here is a question: Is the "non-interrupt" supposed to be transferrable to other anims? // That is, if one anim is not interruptable but it chains to another anim, should the "not interruptable" flag // remain? I'm going to try out the theory that new animations should reset the "don't interrupt" flag. -#if 0 - if ( uiNewAnimFlags & ANIM_NONINTERRUPT ) - { - this->flags.fInNonintAnim = TRUE; - } - - if ( uiNewAnimFlags & ANIM_RT_NONINTERRUPT ) - { - this->flags.fRTInNonintAnim = TRUE; - } -#else this->flags.fInNonintAnim = (uiNewAnimFlags & ANIM_NONINTERRUPT) != 0; this->flags.fRTInNonintAnim = (uiNewAnimFlags & ANIM_RT_NONINTERRUPT) != 0; -#endif // CHECK IF WE ARE NOT AIMING, IF NOT, RESET LAST TAGRET! if ( !(gAnimControl[this->usAnimState].uiFlags & ANIM_FIREREADY) && !(gAnimControl[usNewState].uiFlags & ANIM_FIREREADY) ) @@ -3953,33 +3919,6 @@ BOOLEAN SOLDIERTYPE::EVENT_InitNewSoldierAnim( UINT16 usNewState, UINT16 usStart if ( !this->flags.fDontChargeAPsForStanceChange ) { - // CHRISL - // SANDRO - APBPConstants[AP_CROUCH] changed to GetAPsCrouch() -#if 0//dnl ch70 160913 this is wrong we cannot just add constants to sAPCost this must be done in GetAPsCrouch and GetAPsProne because all preactions calculation will show incorrect values under cursor - if ( (UsingNewInventorySystem( ) == true) && FindBackpackOnSoldier( this ) != ITEM_NOT_FOUND && !this->flags.ZipperFlag ) - { - if ( usNewState == KNEEL_UP || usNewState == BIGMERC_CROUCH_TRANS_OUTOF ) - { - sAPCost = GetAPsCrouch( this, FALSE ) + 2; - sBPCost = APBPConstants[BP_CROUCH] + 2; - } - else if ( usNewState == KNEEL_DOWN || usNewState == BIGMERC_CROUCH_TRANS_INTO ) - { - sAPCost = GetAPsCrouch( this, FALSE ) + 1; - sBPCost = APBPConstants[BP_CROUCH] + 1; - } - else - { - sAPCost = GetAPsCrouch( this, FALSE ); - sBPCost = APBPConstants[BP_CROUCH]; - } - } - else - { - sAPCost = GetAPsCrouch( this, FALSE ); - sBPCost = APBPConstants[BP_CROUCH]; - } -#else if ( UsingNewInventorySystem( ) ) { if ( usNewState == KNEEL_UP || usNewState == BIGMERC_CROUCH_TRANS_OUTOF ) @@ -3998,7 +3937,6 @@ BOOLEAN SOLDIERTYPE::EVENT_InitNewSoldierAnim( UINT16 usNewState, UINT16 usStart sAPCost = GetAPsCrouch( this, FALSE ); sBPCost = APBPConstants[BP_CROUCH]; } -#endif DeductPoints( this, sAPCost, sBPCost ); } this->flags.fDontChargeAPsForStanceChange = FALSE; @@ -4010,53 +3948,25 @@ BOOLEAN SOLDIERTYPE::EVENT_InitNewSoldierAnim( UINT16 usNewState, UINT16 usStart // ATE: If we are NOT waiting for prone down... if ( this->flags.bTurningFromPronePosition < TURNING_FROM_PRONE_START_UP_FROM_MOVE && !this->flags.fDontChargeAPsForStanceChange ) { - // silversurfer: of course we deduct points for stance changes! - // ATE: Don't do this if we are still 'moving'.... - // SANDRO - APBPConstants[AP_PRONE] changed to GetAPsProne() - //if ( this->sGridNo == this->pathing.sFinalDestination || this->pathing.usPathIndex == 0 ) - //{ - // CHRISL -#if 0//dnl ch70 160913 this is wrong we cannot just add constants to sAPCost this must be done in GetAPsCrouch and GetAPsProne because all preactions calculation will show incorrect values under cursor - if ( (UsingNewInventorySystem( ) == true) && FindBackpackOnSoldier( this ) != ITEM_NOT_FOUND && !this->flags.ZipperFlag ) + if ( UsingNewInventorySystem( ) ) + { + if ( usNewState == PRONE_UP ) { - if ( usNewState == PRONE_UP ) - { - sAPCost = GetAPsProne( this, FALSE ) + 2; - sBPCost = APBPConstants[BP_PRONE] + 2; - } - else - { - sAPCost = GetAPsProne( this, FALSE ) + 1; - sBPCost = APBPConstants[BP_PRONE] + 1; - } + sAPCost = GetAPsProne( this, TRUE * 2 ); + sBPCost = APBPConstants[BP_PRONE] + 2; } else { - sAPCost = GetAPsProne( this, FALSE ); - sBPCost = APBPConstants[BP_PRONE]; + sAPCost = GetAPsProne( this, TRUE ); + sBPCost = APBPConstants[BP_PRONE] + 1; } -#else - if ( UsingNewInventorySystem( ) ) - { - if ( usNewState == PRONE_UP ) - { - sAPCost = GetAPsProne( this, TRUE * 2 ); - sBPCost = APBPConstants[BP_PRONE] + 2; - } - else - { - sAPCost = GetAPsProne( this, TRUE ); - sBPCost = APBPConstants[BP_PRONE] + 1; - } - } - else - { - sAPCost = GetAPsProne( this, FALSE ); - sBPCost = APBPConstants[BP_PRONE]; - } -#endif - DeductPoints( this, sAPCost, sBPCost ); - //} + } + else + { + sAPCost = GetAPsProne( this, FALSE ); + sBPCost = APBPConstants[BP_PRONE]; + } + DeductPoints( this, sAPCost, sBPCost ); } this->flags.fDontChargeAPsForStanceChange = FALSE; break; @@ -4392,18 +4302,6 @@ BOOLEAN SOLDIERTYPE::EVENT_InitNewSoldierAnim( UINT16 usNewState, UINT16 usStart // Reset some animation values this->flags.fForceShade = FALSE; - // CHECK IF WE ARE AT AN IDLE ACTION -#if 0 - if ( gAnimControl[usNewState].uiFlags & ANIM_IDLE ) - { - this->aiData.bAction = ACTION_DONE; - } - else - { - this->aiData.bAction = ACTION_BUSY; - } -#endif - // ATE; For some animations that could use some variations, do so.... if ( usNewState == CHARIOTS_OF_FIRE || usNewState == BODYEXPLODING ) { @@ -4578,10 +4476,7 @@ void SOLDIERTYPE::EVENT_InternalSetSoldierPosition( FLOAT dNewXPos, FLOAT dNewYP if ( !(this->flags.uiStatusFlags & (SOLDIER_DRIVER | SOLDIER_PASSENGER)) ) { - if ( gGameSettings.fOptions[TOPTION_MERC_ALWAYS_LIGHT_UP] ) - { - this->SetCheckSoldierLightFlag( ); - } + this->SetCheckSoldierLightFlag( ); } // ATE: Mirror calls if we are a vehicle ( for all our passengers ) @@ -5032,18 +4927,6 @@ void SOLDIERTYPE::EVENT_FireSoldierWeapon( INT32 sTargetGridNo ) // break; //} -#if 0 - // 0verhaul: This does not go here! In spite of this function's name, it is not the actual "fire" function. - // In fact this sets the muzzle flash even while the soldier may be turning to shoot, which can cause - // problems for real-time shooting. - - // The correct place for this is UseGun, which already has code to set or reset the flash. - - if ( IsFlashSuppressor( &this->inv[this->ubAttackingHand], this ) ) - this->flags.fMuzzleFlash = FALSE; - else - this->flags.fMuzzleFlash = TRUE; -#endif DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "EVENT_FireSoldierWeapon: Muzzle flash = %d", this->flags.fMuzzleFlash ) ); @@ -5063,42 +4946,6 @@ void SOLDIERTYPE::EVENT_FireSoldierWeapon( INT32 sTargetGridNo ) //this->sLastTarget = sTargetGridNo; this->ubTargetID = WhoIsThere2( sTargetGridNo, this->bTargetLevel ); -#if 0 - // if (Item[this->inv[HANDPOS].usItem].usItemClass & IC_GUN) - { - if ( this->bDoBurst ) - { - // This is NOT the bullets to fire. That is done as a check of bDoBurst against the weapon burst count or - // bDoAutofire, or single-fire. So let the bullet count be managed by the firing code. - // Set the TOTAL number of bullets to be fired - // Can't shoot more bullets than we have in our magazine! - if ( this->bDoAutofire ) - this->bBulletsLeft = __min( this->bDoAutofire, this->inv[this->ubAttackingHand][0]->data.gun.ubGunShotsLeft ); - else - { - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "EVENT_FireSoldierWeapon: do burst" ); - if ( this->bWeaponMode == WM_ATTACHED_GL_BURST ) - this->bBulletsLeft = __min( Weapon[GetAttachedGrenadeLauncher( &this->inv[this->ubAttackingHand] )].ubShotsPerBurst, this->inv[this->ubAttackingHand][0]->data.gun.ubGunShotsLeft ); - else - this->bBulletsLeft = __min( GetShotsPerBurst( &this->inv[this->ubAttackingHand] ), this->inv[this->ubAttackingHand][0]->data.gun.ubGunShotsLeft ); - } - } - else if ( IsValidSecondHandShot( this ) ) - { - // two-pistol attack - two bullets! - this->bBulletsLeft = 2; - } - else - { - this->bBulletsLeft = 1; - } - - if ( AmmoTypes[this->inv[this->ubAttackingHand][0]->data.gun.ubGunAmmoType].numberOfBullets > 1 ) - { - this->bBulletsLeft *= AmmoTypes[this->inv[this->ubAttackingHand][0]->data.gun.ubGunAmmoType].numberOfBullets; - } - } -#endif DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "!!!!!!! Starting attack, bullets left %d", this->bBulletsLeft ) ); // Convert our grid-not into an XY @@ -5168,26 +5015,6 @@ void SOLDIERTYPE::EVENT_FireSoldierWeapon( INT32 sTargetGridNo ) } else { -#if 0//dnl ch72 250913 move this above as need to be done before calling SoldierReadyWeapon - // IF WE ARE IN REAl-TIME, FIRE IMMEDIATELY! - if ( ((gTacticalStatus.uiFlags & REALTIME) || !(gTacticalStatus.uiFlags & INCOMBAT)) ) - { - //fDoFireRightAway = TRUE; - } - - // Check if our weapon has no intermediate anim... - if ( Item[this->inv[HANDPOS].usItem].rocketlauncher || Item[this->inv[HANDPOS].usItem].grenadelauncher || Item[this->inv[HANDPOS].usItem].mortar ) - ///* switch( this->inv[ HANDPOS ].usItem ) - // { - //case RPG7: - //case ROCKET_LAUNCHER: - //case MORTAR: - //case GLAUNCHER:*/ - - fDoFireRightAway = TRUE; - // break; - //} -#endif if ( fDoFireRightAway ) { // Set to true so we don't get toasted twice for APs.. @@ -5883,24 +5710,6 @@ void SOLDIERTYPE::EVENT_SoldierGotHit( UINT16 usWeaponIndex, INT16 sDamage, INT1 DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "EVENT_SoldierGotHit" ); -#if 0 - // 0verhaul: Under the new ABC system this is no longer necessary. - // ATE: If we have gotten hit, but are still in our attack animation, reduce count! - switch ( this->usAnimState ) - { - case SHOOT_ROCKET: - case SHOOT_MORTAR: - case THROW_ITEM: - // crouch throwing - case THROW_ITEM_CROUCHED: - // crouch throwing - case LOB_ITEM: - - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "@@@@@@@ Freeing up attacker - ATTACK ANIMATION %s ENDED BY HIT ANIMATION, Now %d", gAnimControl[this->usAnimState].zAnimStr, gTacticalStatus.ubAttackBusyCount ) ); - ReduceAttackBusyCount( this->ubID, FALSE ); - break; - } -#endif // DO STUFF COMMON FOR ALL TYPES if ( ubAttackerID != NOBODY ) @@ -5911,22 +5720,6 @@ void SOLDIERTYPE::EVENT_SoldierGotHit( UINT16 usWeaponIndex, INT16 sDamage, INT1 // Set attacker's ID this->ubAttackerID = ubAttackerID; -#if 0 - // 0verhaul: Slashing out more unnecessary and reworked code - if ( !(this->flags.uiStatusFlags & SOLDIER_VEHICLE) ) - { - // Increment being attacked count - this->bBeingAttackedCount++; - } - - // if defender is a vehicle, there will be no hit animation played! - if ( !(this->flags.uiStatusFlags & SOLDIER_VEHICLE) ) - { - // Increment the number of people busy doing stuff because of an attack (busy doing hit anim!) - gTacticalStatus.ubAttackBusyCount++; - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "!!!!!!! Person got hit, attack count now %d", gTacticalStatus.ubAttackBusyCount ) ); - } -#endif // ATE; Save hit location info...( for later anim determination stuff ) this->ubHitLocation = ubHitLocation; @@ -6250,34 +6043,6 @@ void SOLDIERTYPE::EVENT_SoldierGotHit( UINT16 usWeaponIndex, INT16 sDamage, INT1 } -#if 0 - // 0verhaul: None of this hairyness is necessary anymore! Hazaa! - // CJC: moved to after SoldierTakeDamage so that any quotes from the defender - // will not be said if they are knocked out or killed - if ( ubReason != TAKE_DAMAGE_TENTACLES && ubReason != TAKE_DAMAGE_OBJECT ) - { - // OK, OK: THis is hairy, however, it's ness. because the normal freeup call uses the - // attckers intended target, and here we want to use thier actual target.... - - // ATE: If it's from GUNFIRE damage, keep in mind bullets... - if ( Item[usWeaponIndex].usItemClass & IC_GUN ) - { - pNewSoldier = FreeUpAttackerGivenTarget( this->ubAttackerID, this->ubID ); - } - else - { - pNewSoldier = ReduceAttackBusyGivenTarget( this->ubAttackerID, this->ubID ); - } - - if ( pNewSoldier != NULL ) - { - //warning, if this code is ever uncommented, rename all this - //to this in this function, then init this to this - this = pNewSoldier; - } - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "!!!!!!! Tried to free up attacker, attack count now %d", gTacticalStatus.ubAttackBusyCount ) ); - } -#endif // Flugente: moved the damage calculation into a separate function sBreathLoss = max( 1, (INT16)(sBreathLoss * (100 - this->GetDamageResistance( FALSE, TRUE )) / 100) ); @@ -7338,15 +7103,6 @@ BOOLEAN SOLDIERTYPE::EVENT_InternalGetNewSoldierPath( INT32 sDestGridNo, UINT16 return(FALSE); } - // we can use the soldier's level here because we don't have pathing across levels right now... -#if 0 - // Uhhmmmm, the name of this function has "NEWPath" in it. - if ( this->pathing.bPathStored ) - { - fContinue = TRUE; - } - else -#endif { iDest = FindBestPath( this, sDestGridNo, this->pathing.bLevel, usMovementAnim, COPYROUTE, fFlags ); fContinue = (iDest != 0); @@ -8790,32 +8546,6 @@ UINT8 gRedGlowR[] = }; -#if 0 -UINT8 gOrangeGlowR[] = -{ - 0, // Normal shades - 20, - 40, - 60, - 80, - 100, - 120, - 140, - 160, - 180, - - 0, // For gray palettes - 20, - 40, - 60, - 80, - 100, - 120, - 140, - 160, - 180, -}; -#endif UINT8 gOrangeGlowR[] = { @@ -8844,32 +8574,6 @@ UINT8 gOrangeGlowR[] = }; -#if 0 -UINT8 gOrangeGlowG[] = -{ - 0, // Normal shades - 5, - 10, - 25, - 30, - 35, - 40, - 45, - 50, - 55, - - 0, // For gray palettes - 5, - 10, - 25, - 30, - 35, - 40, - 45, - 50, - 55, -}; -#endif UINT8 gOrangeGlowG[] = { @@ -9726,10 +9430,7 @@ void MoveMercFacingDirection( SOLDIERTYPE *pSoldier, BOOLEAN fReverse, FLOAT dMo void SOLDIERTYPE::BeginSoldierClimbUpRoof(void) { //CHRISL: Disable climbing up to a roof while wearing a backpack - if ((UsingNewInventorySystem() == true) && this->inv[BPACKPOCKPOS].exists() == true - //JMich.BackpackClimb - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)this->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[this->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[this->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) + if (!this->CanClimbWithCurrentBackpack()) { ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, NewInvMessage[NIV_NO_CLIMB]); return; @@ -10023,6 +9724,17 @@ UINT32 SleepDartSuccumbChance( SOLDIERTYPE * pSoldier ) return(uiChance); } +BOOLEAN SOLDIERTYPE::CanClimbWithCurrentBackpack() +{ + // only apply backpack climbing limitations to player mercs + if (UsingNewInventorySystem() == true && this->inv[BPACKPOCKPOS].exists() == true && this->bTeam == OUR_TEAM + && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)this->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[this->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) + && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[this->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) + return FALSE; + + return TRUE; +} + void SOLDIERTYPE::BeginSoldierGetup( void ) { // RETURN IF WE ARE BEING SERVICED @@ -12038,28 +11750,6 @@ UINT8 GetDirectionFromXY( INT16 sXPos, INT16 sYPos, SOLDIERTYPE *pSoldier ) return(atan8( sXPos2, sYPos2, sXPos, sYPos )); } -#if 0 -UINT8 atan8( INT16 x1, INT16 y1, INT16 x2, INT16 y2 ) -{ - static int trig[8] = {2, 3, 4, 5, 6, 7, 8, 1}; - // returned values are N=1, NE=2, E=3, SE=4, S=5, SW=6, W=7, NW=8 - double dx = (x2 - x1); - double dy = (y2 - y1); - double a; - int i, k; - if ( dx == 0 ) - dx = 0.00390625; // 1/256th -#define PISLICES (8) - a = (atan2( dy, dx ) + PI / PISLICES) / (PI / (PISLICES / 2)); - i = (int)a; - if ( a>0 ) - k = i; else - if ( a<0 ) - k = i + (PISLICES - 1); else - k = 0; - return(trig[k]); -} -#endif //#if 0 UINT8 atan8( INT16 sXPos, INT16 sYPos, INT16 sXPos2, INT16 sYPos2 ) @@ -12422,22 +12112,6 @@ void SendGetNewSoldierPathEvent( SOLDIERTYPE *pSoldier, INT32 sDestGridNo, UINT1 void SendChangeSoldierStanceEvent( SOLDIERTYPE *pSoldier, UINT8 ubNewStance ) { -#if 0 - EV_S_CHANGESTANCE SChangeStance; - -#ifdef NETWORKED - if ( !IsTheSolderUnderMyControl( pSoldier->ubID ) ) - return; -#endif - - SChangeStance.ubNewStance = ubNewStance; - SChangeStance.usSoldierID = pSoldier->ubID; - SChangeStance.sXPos = pSoldier->sX; - SChangeStance.sYPos = pSoldier->sY; - SChangeStance.uiUniqueId = pSoldier->uiUniqueSoldierIdValue; - - AddGameEvent( S_CHANGESTANCE, 0, &SChangeStance ); -#endif if ( ((pSoldier->ubID > 19 && !is_server) || (pSoldier->ubID > 119 && is_server)) && is_networked )return; @@ -12460,51 +12134,6 @@ void SendBeginFireWeaponEvent( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo ) AddGameEvent( S_BEGINFIREWEAPON, 0, &SBeginFireWeapon ); } -#if 0 -// This function is now obsolete. Just call ReduceAttackBusyCount. - -// This function just encapolates the check for turnbased and having an attacker in the first place -void ReleaseSoldiersAttacker( SOLDIERTYPE *pSoldier ) -{ - INT32 cnt; - UINT8 ubNumToFree; - - //if ( gTacticalStatus.uiFlags & TURNBASED && (gTacticalStatus.uiFlags & INCOMBAT) ) - { - // ATE: Removed... - //if ( pSoldier->ubAttackerID != NOBODY ) - { - // JA2 Gold - // set next-to-previous attacker, so long as this isn't a repeat attack - if ( pSoldier->ubPreviousAttackerID != pSoldier->ubAttackerID ) - { - pSoldier->ubNextToPreviousAttackerID = pSoldier->ubPreviousAttackerID; - } - - // get previous attacker id - pSoldier->ubPreviousAttackerID = pSoldier->ubAttackerID; - - // Copy BeingAttackedCount here.... - ubNumToFree = pSoldier->bBeingAttackedCount; - // Zero it out BEFORE, as supression may increase it again... - pSoldier->bBeingAttackedCount = 0; - - for ( cnt = 0; cnt < ubNumToFree; cnt++ ) - { - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "@@@@@@@ Freeing up attacker of %d (attacker is %d) - releasesoldierattacker num to free is %d", pSoldier->ubID, pSoldier->ubAttackerID, ubNumToFree ) ); - ReduceAttackBusyCount( pSoldier->ubAttackerID, FALSE ); - } - - // ATE: Set to NOBODY if this person is NOT dead - // otherise, we keep it so the kill can be awarded! - if ( pSoldier->stats.bLife != 0 && pSoldier->ubBodyType != QUEENMONSTER ) - { - pSoldier->ubAttackerID = NOBODY; - } - } - } -} -#endif BOOLEAN SOLDIERTYPE::MercInWater( void ) { @@ -17688,78 +17317,13 @@ void SOLDIERTYPE::HandleFlashLights( ) fLightChanged = TRUE; } - // not possible to get this bonus on a roof, due to our lighting system - if ( !this->pathing.bLevel ) - { - UINT8 flashlightrange = this->GetBestEquippedFlashLightRange( ); + if ( AddBestFlashLight() ) + { + // take note: we own a light source + this->usSoldierFlagMask |= SOLDIER_LIGHT_OWNER; - // if no flashlight is found, this will be 0 - if ( flashlightrange ) - { - // the range at which we create additional light sources to the side - UINT8 firstexpand = 8; - UINT8 secondexpand = 12; - - // depending on our direction, alter range - if ( this->ubDirection == NORTHEAST || this->ubDirection == NORTHWEST || this->ubDirection == SOUTHEAST || this->ubDirection == SOUTHWEST ) - { - flashlightrange = sqrt( (FLOAT)flashlightrange*(FLOAT)flashlightrange / 2.0f ); - firstexpand = sqrt( (FLOAT)firstexpand*(FLOAT)firstexpand / 2.0f ); - secondexpand = sqrt( (FLOAT)secondexpand*(FLOAT)secondexpand / 2.0f ); - } - - // we determine the height of the next tile in our direction. Because of the way structures are handled, we sometimes have to take the very tile we're occupying right now - INT32 nextGridNoinSight = this->sGridNo; - - for ( UINT8 i = 0; i < flashlightrange; ++i ) - { - nextGridNoinSight = NewGridNo( nextGridNoinSight, DirectionInc( this->ubDirection ) ); - - if ( SoldierToVirtualSoldierLineOfSightTest( this, nextGridNoinSight, this->pathing.bLevel, gAnimControl[this->usAnimState].ubEndHeight, FALSE ) ) - CreatePersonalLight( nextGridNoinSight, this->ubID ); - - // after a certain range, add new lights to the side to simulate a light cone - if ( i > firstexpand ) - { - INT8 sidedir1 = (this->ubDirection + 2) % NUM_WORLD_DIRECTIONS; - INT8 sidedir2 = (this->ubDirection - 2) % NUM_WORLD_DIRECTIONS; - - INT32 sideGridNo1 = NewGridNo( nextGridNoinSight, DirectionInc( sidedir1 ) ); - sideGridNo1 = NewGridNo( sideGridNo1, DirectionInc( sidedir1 ) ); - - if ( SoldierToVirtualSoldierLineOfSightTest( this, sideGridNo1, this->pathing.bLevel, gAnimControl[this->usAnimState].ubEndHeight, FALSE, NO_DISTANCE_LIMIT ) ) - CreatePersonalLight( sideGridNo1, this->ubID ); - - if ( i > secondexpand ) - { - sideGridNo1 = NewGridNo( sideGridNo1, DirectionInc( sidedir1 ) ); - - if ( SoldierToVirtualSoldierLineOfSightTest( this, sideGridNo1, this->pathing.bLevel, gAnimControl[this->usAnimState].ubEndHeight, FALSE, NO_DISTANCE_LIMIT ) ) - CreatePersonalLight( sideGridNo1, this->ubID ); - } - - INT32 sideGridNo2 = NewGridNo( nextGridNoinSight, DirectionInc( sidedir2 ) ); - sideGridNo2 = NewGridNo( sideGridNo2, DirectionInc( sidedir2 ) ); - - if ( SoldierToVirtualSoldierLineOfSightTest( this, sideGridNo2, this->pathing.bLevel, gAnimControl[this->usAnimState].ubEndHeight, FALSE, NO_DISTANCE_LIMIT ) ) - CreatePersonalLight( sideGridNo2, this->ubID ); - - if ( i > secondexpand ) - { - sideGridNo2 = NewGridNo( sideGridNo2, DirectionInc( sidedir2 ) ); - - if ( SoldierToVirtualSoldierLineOfSightTest( this, sideGridNo2, this->pathing.bLevel, gAnimControl[this->usAnimState].ubEndHeight, FALSE, NO_DISTANCE_LIMIT ) ) - CreatePersonalLight( sideGridNo2, this->ubID ); - } - } - } - - // take note: we own a light source - this->usSoldierFlagMask |= SOLDIER_LIGHT_OWNER; - - fLightChanged = TRUE; - } - } + fLightChanged = TRUE; + } if ( fLightChanged ) { @@ -17805,6 +17369,162 @@ UINT8 SOLDIERTYPE::GetBestEquippedFlashLightRange( ) return(bestrange); } +bool SOLDIERTYPE::AddBestFlashLight() +{ + // not possible to get this bonus on a roof, due to our lighting system + if ( this->pathing.bLevel != 0 ) + { + return false; + } + + UINT8 maxRange = this->GetBestEquippedFlashLightRange(); + if ( maxRange < 1 ) + { + return false; + } + + // we don't use the flashlight to run better at night (light up our shoes), we use it to find enemies! + UINT8 minRange = 4; + if ( minRange > maxRange ) + { + minRange = maxRange; + } + + float maxAngle = 45; + maxAngle *= PI / 180 / 2; // convert to rad and halven + + auto forward = DirectionInc(this->ubDirection); + auto left = DirectionInc(DirectionIfTurnedClockwise(this->ubDirection, 6)); + auto leftLeft = DirectionInc(DirectionIfTurnedClockwise(this->ubDirection, 5)); + auto right = DirectionInc(DirectionIfTurnedClockwise(this->ubDirection, 2)); + auto rightRight = DirectionInc(DirectionIfTurnedClockwise(this->ubDirection, 3)); + + bool isDiagonal = this->ubDirection == NORTHEAST || this->ubDirection == NORTHWEST || this->ubDirection == SOUTHEAST || this->ubDirection == SOUTHWEST; + + struct position_2d + { + INT16 x, y; + + position_2d(INT32 gridNo) + { + ConvertGridNoToXY(gridNo, &x, &y); + } + position_2d(INT16 _x, INT16 _y) : x{_x}, y{_y} + { + } + }; + struct vector_2d + { + INT16 dx, dy; + float length; + + vector_2d(INT8 direction) + { + ConvertDirectionToVectorInXY(direction, &dx, &dy); + length = CalcLength(dx, dy); + } + vector_2d(position_2d from, position_2d to) + { + dx = to.x - from.x; + dy = to.y - from.y; + length = CalcLength(dx, dy); + } + vector_2d(INT16 _dx, INT16 _dy) : dx{_dx}, dy{_dy} + { + length = CalcLength(dx, dy); + } + + float GetAngle( vector_2d other ) + { + auto dot = dx * other.dx + dy * other.dy; + return acos(dot / (length * other.length)); + } + + static float CalcLength(float dx, float dy) + { + return sqrt(powf(dx, 2) + powf(dy, 2)); + } + }; + + position_2d soldierPos(this->sGridNo); + vector_2d soldierDir(this->ubDirection); + + auto is_in_area = [&](INT32 sGridNoToTest) -> bool + { + vector_2d v(soldierPos, position_2d(sGridNoToTest)); + + if (v.length > maxRange) + { + return false; + } + + if (v.length < minRange) + { + return false; + } + + auto coneAngle = soldierDir.GetAngle( v ); + if (coneAngle > maxAngle) + { + return false; + } + + return true; + }; + + auto add_light_if_in_line_of_sight = [&, this]( INT32 sGridNoToTest, bool allowSkip ) -> void + { + if (allowSkip) // improve performance by skipping 3/4 of the lights + { + INT16 sXPos, sYPos; + ConvertGridNoToXY( sGridNoToTest, &sXPos, &sYPos ); + if (!(sXPos % 2 == 0 && sYPos % 2 == 0)) + { + return; + } + } + + if ( SoldierToVirtualSoldierLineOfSightTest( this, sGridNoToTest, this->pathing.bLevel, gAnimControl[this->usAnimState].ubEndHeight, false, NO_DISTANCE_LIMIT ) ) + { + CreatePersonalLight( sGridNoToTest, this->ubID ); + } + }; + + auto travel_direction_to_add_light = [&]( INT32 startingGridNo, INT16 directionIncrementer ) + { + for ( auto currentGridNo = startingGridNo; !OutOfBounds( currentGridNo, -1 ) && is_in_area( currentGridNo ); currentGridNo += directionIncrementer ) + { + add_light_if_in_line_of_sight( currentGridNo, true); + } + }; + + for ( auto currentGridNo = this->sGridNo; !OutOfBounds( currentGridNo, -1 ); currentGridNo += forward ) + { + vector_2d v(soldierPos, position_2d(currentGridNo)); + if ( v.length < minRange ) + { + continue; + } + else if (v.length > maxRange) + { + break; + } + + add_light_if_in_line_of_sight( currentGridNo, false ); + + travel_direction_to_add_light( currentGridNo, left ); + travel_direction_to_add_light( currentGridNo, right ); + + if ( isDiagonal ) + { + travel_direction_to_add_light( NewGridNo( currentGridNo, leftLeft ), left ); + travel_direction_to_add_light( NewGridNo( currentGridNo, rightRight ), right ); + } + } + + return true; +} + // Flugente: soldier profiles // retrieves the correct sub-array INT8 SOLDIERTYPE::GetSoldierProfileType( UINT8 usTeam ) @@ -22196,13 +21916,15 @@ void SoldierCollapse( SOLDIERTYPE *pSoldier ) if ( pSoldier->flags.uiStatusFlags & SOLDIER_ENEMY ) { - // sevenfm: bPanicTriggerIsAlarm is always not NULL pointer - //if ( !(gTacticalStatus.bPanicTriggerIsAlarm) && (gTacticalStatus.ubTheChosenOne == pSoldier->ubID) ) if ( gTacticalStatus.ubTheChosenOne == pSoldier->ubID ) { - // replace this guy as the chosen one! - gTacticalStatus.ubTheChosenOne = NOBODY; - MakeClosestEnemyChosenOne( ); + auto bPanicTrigger = ClosestPanicTrigger(pSoldier); + if (bPanicTrigger != -1 && !(gTacticalStatus.bPanicTriggerIsAlarm[bPanicTrigger])) + { + // replace this guy as the chosen one! + gTacticalStatus.ubTheChosenOne = NOBODY; + MakeClosestEnemyChosenOne( ); + } } if ( (gTacticalStatus.uiFlags & TURNBASED) && (gTacticalStatus.uiFlags & INCOMBAT) && (pSoldier->flags.uiStatusFlags & SOLDIER_UNDERAICONTROL) ) diff --git a/Tactical/Soldier Control.h b/Tactical/Soldier Control.h index eff711d09..e02e1de0a 100644 --- a/Tactical/Soldier Control.h +++ b/Tactical/Soldier Control.h @@ -1772,6 +1772,7 @@ public: void DoNinjaAttack( void ); void PickDropItemAnimation( void ); + BOOLEAN CanClimbWithCurrentBackpack(); void BeginSoldierGetup( void ); void BeginSoldierClimbUpRoof( void ); @@ -1935,7 +1936,8 @@ public: //void AddDrugValues(UINT8 uDrugType, UINT8 usEffect, UINT8 usTravelRate, UINT8 usSideEffect ); void HandleFlashLights(); - UINT8 GetBestEquippedFlashLightRange(); + bool AddBestFlashLight(); + UINT8 GetBestEquippedFlashLightRange(); // Flugente: soldier profiles INT8 GetSoldierProfileType(UINT8 usTeam); // retrieves the correct sub-array diff --git a/Tactical/Soldier Tile.cpp b/Tactical/Soldier Tile.cpp index 306e97cc0..b43c0e471 100644 --- a/Tactical/Soldier Tile.cpp +++ b/Tactical/Soldier Tile.cpp @@ -355,21 +355,6 @@ INT8 TileIsClear( SOLDIERTYPE *pSoldier, INT8 bDirection, INT32 sGridNo, INT8 b pSoldier->flags.fBlockedByAnotherMerc = FALSE; return( MOVE_TILE_STATIONARY_BLOCKED ); } - else - { -#if 0 - // Check if there is a reserved marker here at least.... - sNewGridNo = NewGridNo( sGridNo, DirectionInc( bDirection ) ); - - if ( ( gpWorldLevelData[ sNewGridNo ].uiFlags & MAPELEMENT_MOVEMENT_RESERVED ) ) - { - if ( gpWorldLevelData[ sNewGridNo ].ubReservedSoldierID != pSoldier->ubID ) - { - return( MOVE_TILE_TEMP_BLOCKED ); - } - } -#endif - } } // Unset flag for blocked by soldier... diff --git a/Tactical/Turn Based Input.cpp b/Tactical/Turn Based Input.cpp index e906847b1..a9aa6b8fd 100644 --- a/Tactical/Turn Based Input.cpp +++ b/Tactical/Turn Based Input.cpp @@ -255,7 +255,6 @@ void CreatePlayerControlledMonster(); void ChangeCurrentSquad( INT32 iSquad ); void HandleSelectMercSlot( UINT8 ubPanelSlot, INT8 bCode ); void EscapeUILock( ); -void TestCapture( ); #ifdef JA2BETAVERSION void ToggleMapEdgepoints(); @@ -2975,14 +2974,6 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) } break; -#if 0//dnl ch75 021113 - case '\"': - Testing(1); - break; - case '\'': - Testing(2); - break; -#endif case '`': @@ -3872,10 +3863,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) if ( fNearLowerLevel ) { // No climbing when wearing a backpack! - if ((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true - //JMich.BackpackClimb - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) + if (!pjSoldier->CanClimbWithCurrentBackpack()) { ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, NewInvMessage[NIV_NO_CLIMB] ); return; @@ -3891,10 +3879,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) if ( fNearHeigherLevel ) { // No climbing when wearing a backpack! - if ((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true - //JMich.BackpackClimb - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) + if (!pjSoldier->CanClimbWithCurrentBackpack()) { ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, NewInvMessage[NIV_NO_CLIMB] ); return; @@ -3910,10 +3895,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) // Jump over fence if ( FindFenceJumpDirection( pjSoldier, pjSoldier->sGridNo, pjSoldier->ubDirection, &bDirection ) ) { - if ((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true - //JMich.BackpackClimb - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) + if (!pjSoldier->CanClimbWithCurrentBackpack()) { //Moa: no jumping whith backpack //sAPCost = GetAPsToJumpFence( pjSoldier, TRUE ); @@ -3938,10 +3920,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) if (gGameExternalOptions.fCanClimbOnWalls == TRUE) { // No climbing when wearing a backpack! - if ((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true - //JMich.BackpackClimb - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) + if (!pjSoldier->CanClimbWithCurrentBackpack()) { ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, NewInvMessage[NIV_NO_CLIMB] ); return; @@ -3977,10 +3956,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) if ( FindWindowJumpDirection( lSoldier, lSoldier->sGridNo, lSoldier->ubDirection, &bDirection ) ) { - if ((UsingNewInventorySystem() == true) && lSoldier->inv[BPACKPOCKPOS].exists() == true - //JMich.BackpackClimb - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)lSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[lSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[lSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) + if (!lSoldier->CanClimbWithCurrentBackpack()) { //Moa: no jumping with backpack //sAPCost = GetAPsToJumpThroughWindows( lSoldier, TRUE ); @@ -4232,21 +4208,6 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) } else if ( fCtrl ) { -#if 0 - if ( INFORMATION_CHEAT_LEVEL() ) - { - if ( gfUIShowCurIntTile ^= TRUE ) - { - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_TESTVERSION, L"Turning Enhanced mouse detection ON." ); - gubIntTileCheckFlags = INTILE_CHECK_FULL; - } - else - { - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_TESTVERSION, L"Turning Enhanced mouse detection OFF." ); - gubIntTileCheckFlags = INTILE_CHECK_SELECTIVE; - } - } -#endif } else { @@ -4499,9 +4460,8 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) { if ( CHEATER_CHEAT_LEVEL( ) ) { - TestCapture( ); - - //EnterCombatMode( gbPlayerNum ); + // Test Capturing Mercs as POW + AttemptToCapturePlayerSoldiers(); } } else if ( fCtrl && fShift ) @@ -6559,42 +6519,6 @@ void HandleStealthChangeFromUIKeys( ) } } - - -void TestCapture( ) -{ - INT32 cnt; - SOLDIERTYPE *pSoldier; - UINT32 uiNumChosen = 0; - - //StartQuest( QUEST_HELD_IN_ALMA, gWorldSectorX, gWorldSectorY ); - //EndQuest( QUEST_HELD_IN_ALMA, gWorldSectorX, gWorldSectorY ); - - BeginCaptureSquence( ); - - gStrategicStatus.uiFlags &= (~STRATEGIC_PLAYER_CAPTURED_FOR_RESCUE ); - - // loop through soldiers and pick 3 lucky ones.... - for ( cnt = gTacticalStatus.Team[gbPlayerNum].bFirstID, pSoldier=MercPtrs[cnt]; cnt <= gTacticalStatus.Team[gbPlayerNum].bLastID; cnt++, pSoldier++ ) - { - if ( pSoldier->stats.bLife >= OKLIFE && pSoldier->bActive && pSoldier->bInSector ) - { - if ( uiNumChosen < 3 ) - { - EnemyCapturesPlayerSoldier( pSoldier ); - - // Remove them from tectical.... - pSoldier->RemoveSoldierFromGridNo( ); - - uiNumChosen++; - } - } - } - - EndCaptureSequence( ); -} - - void PopupAssignmentMenuInTactical( SOLDIERTYPE *pSoldier ) { // do something @@ -7667,11 +7591,7 @@ void HandleTBJump( void ) if ( fNearLowerLevel ) { // CHRISL: Turn off manual jumping while wearing a backpack - if (UsingNewInventorySystem() == true && pjSoldier->inv[BPACKPOCKPOS].exists() == true - //JMich.BackpackClimb - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) - + if (!pjSoldier->CanClimbWithCurrentBackpack()) return; if ( EnoughPoints( pjSoldier, GetAPsToClimbRoof( pjSoldier, TRUE ), GetBPsToClimbRoof( pjSoldier, TRUE ), FALSE ) ) @@ -7683,11 +7603,7 @@ void HandleTBJump( void ) if ( fNearHeigherLevel ) { // No climbing when wearing a backpack! - if ((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true - //JMich.BackpackClimb - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) - + if (!pjSoldier->CanClimbWithCurrentBackpack()) return; if ( EnoughPoints( pjSoldier, GetAPsToClimbRoof( pjSoldier, FALSE ), GetBPsToClimbRoof( pjSoldier, FALSE ), FALSE ) ) @@ -7699,11 +7615,7 @@ void HandleTBJump( void ) // Jump over fence if ( FindFenceJumpDirection( pjSoldier, pjSoldier->sGridNo, pjSoldier->ubDirection, &bDirection ) ) { - if ((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true - //JMich.BackpackClimb - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) - + if (!pjSoldier->CanClimbWithCurrentBackpack()) { sAPCost = GetAPsToJumpFence( pjSoldier, TRUE ); sBPCost = GetBPsToJumpFence( pjSoldier, TRUE ); @@ -7726,11 +7638,7 @@ void HandleTBJump( void ) if ( FindWallJumpDirection( pjSoldier, pjSoldier->sGridNo, pjSoldier->ubDirection, &bDirection ) ) { // No climbing when wearing a backpack! - if ((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true - //JMich.BackpackClimb - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) - + if (!pjSoldier->CanClimbWithCurrentBackpack()) return; if ( EnoughPoints( pjSoldier, GetAPsToJumpWall( pjSoldier, FALSE ), GetBPsToJumpWall( pjSoldier, FALSE ), FALSE ) ) @@ -7754,11 +7662,7 @@ void HandleTBJumpThroughWindow( void ){ { if ( FindWindowJumpDirection( pjSoldier, pjSoldier->sGridNo, pjSoldier->ubDirection, &bDirection ) ) { - if ((UsingNewInventorySystem() == true) && pjSoldier->inv[BPACKPOCKPOS].exists() == true - //JMich.BackpackClimb - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pjSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pjSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pjSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) - + if (!pjSoldier->CanClimbWithCurrentBackpack()) { sAPCost = GetAPsToJumpThroughWindows( pjSoldier, TRUE ); sBPCost = GetBPsToJumpThroughWindows( pjSoldier, TRUE ); diff --git a/Tactical/UI Cursors.cpp b/Tactical/UI Cursors.cpp index ab2bb5ab7..b51cd4ff6 100644 --- a/Tactical/UI Cursors.cpp +++ b/Tactical/UI Cursors.cpp @@ -136,13 +136,13 @@ BOOLEAN GetMouseRecalcAndShowAPFlags( UINT32 *puiCursorFlags, BOOLEAN *pfShowAPs // FUNCTIONS FOR CURSOR DETERMINATION! UINT8 GetProperItemCursor( UINT8 ubSoldierID, UINT16 ubItemIndex, INT32 usMapPos, BOOLEAN fActivated ) { - SOLDIERTYPE *pSoldier; - UINT32 uiCursorFlags; - BOOLEAN fShowAPs = FALSE; - BOOLEAN fRecalc = FALSE; + SOLDIERTYPE *pSoldier; + UINT32 uiCursorFlags; + BOOLEAN fShowAPs = FALSE; + BOOLEAN fRecalc = FALSE; INT32 sTargetGridNo = usMapPos; - UINT8 ubCursorID=0; - UINT8 ubItemCursor; + UINT8 ubCursorID=0; + UINT8 ubItemCursor = 0; pSoldier = MercPtrs[ ubSoldierID ]; @@ -350,6 +350,7 @@ UINT8 HandleActivatedTargetCursor( SOLDIERTYPE *pSoldier, INT32 usMapPos, BOOLEA UINT16 usCursor=0; BOOLEAN fMaxPointLimitHit = FALSE; UINT16 usInHand; + extern UINT32 guiNewUICursor; UINT16 reverse = 0; @@ -457,6 +458,30 @@ UINT8 HandleActivatedTargetCursor( SOLDIERTYPE *pSoldier, INT32 usMapPos, BOOLEA gsCurrentActionPoints = CalcTotalAPsToAttack( pSoldier, usMapPos, TRUE, (INT8)(pSoldier->aiData.bShownAimTime ) ); } + const bool isCursorOnTarget = ( + guiNewUICursor == ACTION_SHOOT_UICURSOR || guiNewUICursor == ACTION_TARGETBURST_UICURSOR || + guiNewUICursor == ACTION_FLASH_SHOOT_UICURSOR || guiNewUICursor == ACTION_FLASH_BURST_UICURSOR || + guiNewUICursor == ACTION_NOCHANCE_SHOOT_UICURSOR || guiNewUICursor == ACTION_NOCHANCE_BURST_UICURSOR + ); + // Start at maximum aiming levels if the option is toggled + if (gGameSettings.fOptions[TOPTION_ALT_START_AIM] && isCursorOnTarget) + { + pSoldier->aiData.bShownAimTime = maxAimLevels; + sAPCosts = CalcTotalAPsToAttack(pSoldier, usMapPos, TRUE, pSoldier->aiData.bShownAimTime); + // Determine if we can afford! + while (!EnoughPoints(pSoldier, sAPCosts, 0, FALSE)) + { + pSoldier->aiData.bShownAimTime -= 1; + if (pSoldier->aiData.bShownAimTime < 0) + { + pSoldier->aiData.bShownAimTime = REFINE_AIM_1; + break; + } + sAPCosts = CalcTotalAPsToAttack(pSoldier, usMapPos, TRUE, pSoldier->aiData.bShownAimTime); + } + gsCurrentActionPoints = sAPCosts; + } + // If we don't have any points and we are at the first refine, do nothing but warn! if ( !EnoughPoints( pSoldier, gsCurrentActionPoints, 0 , FALSE ) && (pSoldier->aiData.bShownAimTime == 0)) { @@ -4004,4 +4029,4 @@ UINT8 DefaultAutofireBulletsByGunClass( SOLDIERTYPE* pSoldier ) } return ubBullets; -} \ No newline at end of file +} diff --git a/Tactical/Vehicles.cpp b/Tactical/Vehicles.cpp index c0075dbe3..d67d18ae9 100644 --- a/Tactical/Vehicles.cpp +++ b/Tactical/Vehicles.cpp @@ -2018,20 +2018,6 @@ void HandleCriticalHitForVehicleInLocation( UINT8 ubID, INT16 sDmg, INT32 sGridN SOLDIERTYPE *pSoldier; BOOLEAN fMadeCorpse = FALSE; -#if 0 - { - // injure someone inside - iRand = Random( gNewVehicle[ pVehicleList[ ubID ].ubVehicleType ].iNewSeatingCapacities ); - if( pVehicleList[ ubID ].pPassengers[ iRand ] ) - { - // hurt this person - InjurePersonInVehicle( ( INT16 )ubID, pVehicleList[ ubID ].pPassengers[ iRand ], ( UINT8 )( sDmg / 2 ) ); - } - } - - ScreenMsg( FONT_BLACK, MSG_INTERFACE, sCritLocationStrings[ iCrit ] ); - } -#endif pSoldier = GetSoldierStructureForVehicle( ubID ); Assert(pSoldier); diff --git a/Tactical/World Items.cpp b/Tactical/World Items.cpp index c097a3bf6..dd544fb43 100644 --- a/Tactical/World Items.cpp +++ b/Tactical/World Items.cpp @@ -875,19 +875,6 @@ void LoadWorldItemsFromMap( INT8 **hBuffer, float dMajorMapVersion, int ubMinorM { //all armed bombs are buried dummyItem.bVisible = BURIED; } -#if 0//dnl ch74 201013 this is already done in OBJECTTYPE::Load() - //Madd: ok, so this drives me nuts -- why bother with default attachments if the map isn't going to load them for you? - //this should fix that... - for(UINT8 cnt = 0; cnt < MAX_DEFAULT_ATTACHMENTS; cnt++) - { - if(Item [ dummyItem.object.usItem ].defaultattachments[cnt] == 0) - break; - - OBJECTTYPE defaultAttachment; - CreateItem(Item [ dummyItem.object.usItem ].defaultattachments[cnt],100,&defaultAttachment); - dummyItem.object.AttachObject(NULL,&defaultAttachment, FALSE); - } -#endif // sevenfm: don't allow max repair threshold less than current object status dummyItem.object[0]->data.sRepairThreshold = __max(dummyItem.object[0]->data.sRepairThreshold, dummyItem.object[0]->data.objectStatus); AddItemToPoolAndGetIndex( dummyItem.sGridNo, &dummyItem.object, dummyItem.bVisible, dummyItem.ubLevel, dummyItem.usFlags, dummyItem.bRenderZHeightAboveLevel, dummyItem.soldierID, &iItemIndex ); diff --git a/Tactical/XML_LBEPocket.cpp b/Tactical/XML_LBEPocket.cpp index 29ee6b1f6..e4a6cadc1 100644 --- a/Tactical/XML_LBEPocket.cpp +++ b/Tactical/XML_LBEPocket.cpp @@ -189,18 +189,8 @@ lbepocketParseData * pData = (lbepocketParseData *)userData; else if(strcmp(name, "pName") == 0) { pData->curElement = ELEMENT; -#if 0 - if(MAX_CHAR_DATA_LENGTH >= strlen(pData->szCharData)) - strcpy(pData->curLBEPocket.pName,pData->szCharData); - else - { - strncpy(pData->curLBEPocket.pName,pData->szCharData,MAX_CHAR_DATA_LENGTH); - pData->curLBEPocket.pName[MAX_CHAR_DATA_LENGTH] = '\0'; - } -#else MultiByteToWideChar( CP_UTF8, 0, pData->szCharData, -1, pData->curLBEPocket.pName, sizeof(pData->curLBEPocket.pName)/sizeof(pData->curLBEPocket.pName[0]) ); pData->curLBEPocket.pName[sizeof(pData->curLBEPocket.pName)/sizeof(pData->curLBEPocket.pName[0]) - 1] = '\0'; -#endif } else if(strcmp(name, "pSilhouette") == 0) { diff --git a/Tactical/bullets.cpp b/Tactical/bullets.cpp index f8b47ea2d..3548b30c2 100644 --- a/Tactical/bullets.cpp +++ b/Tactical/bullets.cpp @@ -554,15 +554,6 @@ void AddMissileTrail( BULLET *pBullet, FIXEDPT qCurrX, FIXEDPT qCurrY, FIXEDPT q ConvertGridNoToCenterCellXY( pBullet->sGridNo, &sXPos, &sYPos ); LightSpritePosition( pBullet->pAniTile->lightSprite, (INT16)(sXPos/CELL_X_SIZE), (INT16)(sYPos/CELL_Y_SIZE)); -#if 0 - if ( pBullet->pFirer->pathing.bLevel > 0 ) // if firer on roof then - { - if ( FindBuilding(AniParams.sGridNo) != NULL ) // if this spot is still within the building's grid area - { - LightSpritePower( pBullet->pAniTile->lightSprite, FALSE); - } - } -#endif return; } diff --git a/Tactical/opplist.cpp b/Tactical/opplist.cpp index 6164964a6..274413f91 100644 --- a/Tactical/opplist.cpp +++ b/Tactical/opplist.cpp @@ -1383,19 +1383,6 @@ INT16 DistanceVisible(SOLDIERTYPE *pSoldier, INT8 bFacingDir, INT8 bSubjectDir, // let tanks see and be seen further (at night) if ( (ARMED_VEHICLE( pSoldier ) && sDistVisible > 0) || (pSubject && ARMED_VEHICLE( pSubject )) ) { -#if 0 - if ( ARMED_VEHICLE(pSoldier) && sDistVisible > 0 && pSubject) - { - sDistVisible = __max( sDistVisible + 5, pSubject->GetMaxDistanceVisible(pSoldier->sGridNo, pSoldier->pathing.bLevel) ); - } - else - { - sDistVisible = __max( sDistVisible + 5, pSoldier->GetMaxDistanceVisible() ); - } -#endif - // 0verhaul: This bit of code 1) seems to have no real reason to exist (MaxDistVisible just calls this function anyway), - // and 2) causes infinite recursion because MaxDistVisible just calls this function, which comes right back here. Just - // add 5 to sDistVisible and go on. sDistVisible = sDistVisible + 5; } diff --git a/TacticalAI/AIMain.cpp b/TacticalAI/AIMain.cpp index ee36d5137..b195326e2 100644 --- a/TacticalAI/AIMain.cpp +++ b/TacticalAI/AIMain.cpp @@ -1921,25 +1921,6 @@ INT8 ExecuteAction(SOLDIERTYPE *pSoldier) UINT16 usHandItem = pSoldier->inv[HANDPOS].usItem; INT8 bSlot; -#if 0//dnl ch64 260813 decision to use machinegun or cannon is done in DecideAction, this here will just lead into burst with cannon if decision was use machinegun - if (TANK(pSoldier)) - { - // No cannon selected to fire - if (!Item[pSoldier->inv[HANDPOS].usItem].cannon) - { - // 50 % chance, that the tank fires with the explosive cannon - UINT32 fireWithCannon = GetRndNum(2); - if (fireWithCannon) - { - UINT32 tankCannonIndex = GetTankCannonIndex(); - if (tankCannonIndex > 0) - { - usHandItem = tankCannonIndex; - } - } - } - } -#endif UINT16 usSoldierIndex; // added by SANDRO #ifdef TESTAICONTROL diff --git a/TacticalAI/AIUtils.cpp b/TacticalAI/AIUtils.cpp index 6096beeaf..a511bc895 100644 --- a/TacticalAI/AIUtils.cpp +++ b/TacticalAI/AIUtils.cpp @@ -784,10 +784,7 @@ BOOLEAN IsActionAffordable(SOLDIERTYPE *pSoldier, INT8 bAction) break; case AI_ACTION_JUMP_WINDOW: - if((UsingNewInventorySystem() == true) && pSoldier->inv[BPACKPOCKPOS].exists() == true - //JMich.BackpackClimb - && ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb ) - && ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE))) + if (!pSoldier->CanClimbWithCurrentBackpack()) bMinPointsNeeded = GetAPsToJumpThroughWindows( pSoldier, TRUE ); else bMinPointsNeeded = GetAPsToJumpFence( pSoldier, FALSE ); diff --git a/TacticalAI/CMakeLists.txt b/TacticalAI/CMakeLists.txt new file mode 100644 index 000000000..53ef7ec00 --- /dev/null +++ b/TacticalAI/CMakeLists.txt @@ -0,0 +1,17 @@ +set(TacticalAISrc +"${CMAKE_CURRENT_SOURCE_DIR}/AIList.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/AIMain.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/AIUtils.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Attacks.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/CreatureDecideAction.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/DecideAction.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/FindLocations.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Knowledge.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Medical.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Movement.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/NPC.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/PanicButtons.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/QuestDebug.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Realtime.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/ZombieDecideAction.cpp" +PARENT_SCOPE) diff --git a/TacticalAI/DecideAction.cpp b/TacticalAI/DecideAction.cpp index 3415fc4d8..eb421ce88 100644 --- a/TacticalAI/DecideAction.cpp +++ b/TacticalAI/DecideAction.cpp @@ -4974,7 +4974,7 @@ INT16 ubMinAPCost; bPanicTrigger = ClosestPanicTrigger( pSoldier ); // if it's an alarm trigger and team is alerted, ignore it - if ( !(gTacticalStatus.bPanicTriggerIsAlarm[ bPanicTrigger ] && gTacticalStatus.Team[pSoldier->bTeam].bAwareOfOpposition) && PythSpacesAway( pSoldier->sGridNo, gTacticalStatus.sPanicTriggerGridNo[ bPanicTrigger ] ) < 10) + if ( bPanicTrigger != -1 && !(gTacticalStatus.bPanicTriggerIsAlarm[ bPanicTrigger ] && gTacticalStatus.Team[pSoldier->bTeam].bAwareOfOpposition) && PythSpacesAway( pSoldier->sGridNo, gTacticalStatus.sPanicTriggerGridNo[ bPanicTrigger ] ) < 10) { PossiblyMakeThisEnemyChosenOne( pSoldier ); } @@ -5161,19 +5161,14 @@ INT16 ubMinAPCost; } // offer surrender? -#ifdef JA2UB -#else +#ifndef JA2UB if ( pSoldier->bTeam == ENEMY_TEAM && pSoldier->bVisible == TRUE && !(gTacticalStatus.fEnemyFlags & ENEMY_OFFERED_SURRENDER) && pSoldier->stats.bLife >= pSoldier->stats.bLifeMax / 2 && !ARMED_VEHICLE( pSoldier ) && !ENEMYROBOT( pSoldier ) ) { if ( gTacticalStatus.Team[ MILITIA_TEAM ].bMenInSector == 0 && gTacticalStatus.Team[ CREATURE_TEAM ].bMenInSector == 0 && NumPCsInSector() < 4 && gTacticalStatus.Team[ ENEMY_TEAM ].bMenInSector >= NumPCsInSector() * 3 ) { - //if( GetWorldDay() > STARTDAY_ALLOW_PLAYER_CAPTURE_FOR_RESCUE && !( gStrategicStatus.uiFlags & STRATEGIC_PLAYER_CAPTURED_FOR_RESCUE ) ) + if (gubQuest[QUEST_HELD_IN_ALMA] == QUESTNOTSTARTED || gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED || gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED) { - if (gubQuest[QUEST_HELD_IN_ALMA] == QUESTNOTSTARTED || gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED || (gubQuest[QUEST_HELD_IN_ALMA] != QUESTINPROGRESS && gubQuest[QUEST_HELD_IN_TIXA] != QUESTINPROGRESS && gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED)) - { - gTacticalStatus.fEnemyFlags |= ENEMY_OFFERED_SURRENDER; - return( AI_ACTION_OFFER_SURRENDER ); - } + return( AI_ACTION_OFFER_SURRENDER ); } } } @@ -9586,15 +9581,13 @@ INT8 ArmedVehicleDecideActionBlack( SOLDIERTYPE *pSoldier ) } // offer surrender? -#ifdef JA2UB -#else +#ifndef JA2UB if ( pSoldier->bTeam == ENEMY_TEAM && pSoldier->bVisible == TRUE && !(gTacticalStatus.fEnemyFlags & ENEMY_OFFERED_SURRENDER) && pSoldier->stats.bLife >= pSoldier->stats.bLifeMax / 2 && !ARMED_VEHICLE( pSoldier ) && !ENEMYROBOT( pSoldier ) ) { if ( gTacticalStatus.Team[MILITIA_TEAM].bMenInSector == 0 && gTacticalStatus.Team[CREATURE_TEAM].bMenInSector == 0 && NumPCsInSector( ) < 4 && gTacticalStatus.Team[ENEMY_TEAM].bMenInSector >= NumPCsInSector( ) * 3 ) { - if ( gubQuest[QUEST_HELD_IN_ALMA] == QUESTNOTSTARTED || (gubQuest[QUEST_HELD_IN_ALMA] == QUESTDONE && gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED) ) + if (gubQuest[QUEST_HELD_IN_ALMA] == QUESTNOTSTARTED || gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED || gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED) { - gTacticalStatus.fEnemyFlags |= ENEMY_OFFERED_SURRENDER; return(AI_ACTION_OFFER_SURRENDER); } } @@ -10413,4 +10406,4 @@ void LogKnowledgeInfo(SOLDIERTYPE *pSoldier) //swprintf( pStrInfo, L"%s[%d] %s %s\n", pStrInfo, oppID, MercPtrs[oppID]->GetName(), SeenStr(pSoldier->aiData.bOppList[oppID]) ); } } -} \ No newline at end of file +} diff --git a/TacticalAI/FindLocations.cpp b/TacticalAI/FindLocations.cpp index b78bff215..826c45c64 100644 --- a/TacticalAI/FindLocations.cpp +++ b/TacticalAI/FindLocations.cpp @@ -2946,85 +2946,7 @@ INT32 FindClosestClimbPoint (SOLDIERTYPE *pSoldier, BOOLEAN fClimbUp ) BOOLEAN CanClimbFromHere (SOLDIERTYPE * pSoldier, BOOLEAN fUp ) { -#if 1 return FindDirectionForClimbing( pSoldier, pSoldier->sGridNo, pSoldier->pathing.bLevel) != DIRECTION_IRRELEVANT; -#else - BUILDING * pBuilding; - INT32 i; - INT32 iSearchRange = 1; - INT16 sMaxLeft, sMaxRight, sMaxUp, sMaxDown, sXOffset, sYOffset; - - //DebugMsg( TOPIC_JA2AI , DBG_LEVEL_3 , "CanClimbFromHere"); - - - // determine maximum horizontal limits - sMaxLeft = min( iSearchRange, (pSoldier->sGridNo % MAXCOL)); - sMaxRight = min( iSearchRange, MAXCOL - ((pSoldier->sGridNo % MAXCOL) + 1)); - - // determine maximum vertical limits - sMaxUp = min( iSearchRange, (pSoldier->sGridNo / MAXROW)); - sMaxDown = min( iSearchRange, MAXROW - ((pSoldier->sGridNo / MAXROW) + 1)); - - INT32 sGridNo=NOWHERE; - - for (sYOffset = -sMaxUp; sYOffset <= sMaxDown; sYOffset++) - { - for (sXOffset = -sMaxLeft; sXOffset <= sMaxRight; sXOffset++) - { - // calculate the next potential gridno - sGridNo = pSoldier->sGridNo + sXOffset + (MAXCOL * sYOffset); - //DebugMsg( TOPIC_JA2AI , DBG_LEVEL_3 , String("Checking grid %d" , sGridNo )); - - //NumMessage("Testing gridno #",gridno); - if ( !(sGridNo >=0 && sGridNo < WORLD_MAX) ) - { - continue; - } - - - if ( sGridNo == pSoldier->pathing.sBlackList ) - { - continue; - } - - - // OK, this place shows potential. How useful is it as cover? - //NumMessage("Promising seems gridno #",gridno); - - // Kaiden: From this point down I've removed an unneccessary call to - // FindBuilding, The original code that was from this point till the - // end of the function is now commented out AFTER the function. - - pBuilding = FindBuilding ( sGridNo ); - - if ( pBuilding != NULL) - { - if ( fUp ) - { - - for (i = 0 ; i < pBuilding->ubNumClimbSpots; i++) - { - if (pBuilding->sUpClimbSpots[ i ] == pSoldier->sGridNo && - (WhoIsThere2( pBuilding->sUpClimbSpots[ i ], 0 ) == NOBODY) - && (WhoIsThere2( pBuilding->sDownClimbSpots[ i ], 1 ) == NOBODY) ) - return TRUE; - } - } - else - { - for (i = 0 ; i < pBuilding->ubNumClimbSpots; i++) - { - if (pBuilding->sDownClimbSpots[ i ] == pSoldier->sGridNo && - (WhoIsThere2( pBuilding->sUpClimbSpots[ i ], 0 ) == NOBODY) - && (WhoIsThere2( pBuilding->sDownClimbSpots[ i ], 1 ) == NOBODY) ) - return TRUE; - } - } - } - } - } - return FALSE; -#endif } // OK, this place shows potential. How useful is it as cover? //NumMessage("Promising seems gridno #",gridno); diff --git a/TileEngine/Buildings.cpp b/TileEngine/Buildings.cpp index ef40eee3b..dfcaa7c8e 100644 --- a/TileEngine/Buildings.cpp +++ b/TileEngine/Buildings.cpp @@ -9,9 +9,9 @@ #define ROOF_LOCATION_CHANCE 8 -UINT8* gubBuildingInfo = NULL; -BUILDING gBuildings[ MAX_BUILDINGS ]; -UINT8 gubNumberOfBuildings; +UINT8* gubBuildingInfo = NULL; +BUILDING gBuildings[ MAX_BUILDINGS ]; +UINT8 gubNumberOfBuildings; #ifdef ROOF_DEBUG extern INT16 gsCoverValue[WORLD_MAX]; @@ -19,544 +19,32 @@ UINT8 gubNumberOfBuildings; #include "renderworld.h" #endif -// WANNE: Overhauls new building climbing only works with A* enabled -// ------------------------- -// A* building climbing - BEGIN -// ------------------------- -#ifdef USE_ASTAR_PATHS - BUILDING * CreateNewBuilding( UINT8 * pubBuilding ) { - if (gubNumberOfBuildings >= MAX_BUILDINGS) + if (gGameSettings.fOptions[TOPTION_ALT_PATHFINDING]) { - return( NULL ); - } - - // increment # of buildings - gubNumberOfBuildings++; - - // clear entry - gBuildings[ gubNumberOfBuildings ].ubNumClimbSpots = 0; - *pubBuilding = gubNumberOfBuildings; - - // return pointer (have to subtract 1 since we just added 1 - return( &(gBuildings[ gubNumberOfBuildings ]) ); -} - -BUILDING * FindBuilding( INT32 sGridNo ) -{ - UINT8 ubBuildingID; - - if ( TileIsOutOfBounds( sGridNo ) ) - { - return( NULL ); - } - - // id 0 indicates no building - ubBuildingID = gubBuildingInfo[ sGridNo ]; - - if ( ubBuildingID == NO_BUILDING ) - { - return( NULL ); - - /* - // need extra checks to see if is valid spot... - // must have valid room information and be a flat-roofed - // building - if ( InARoom( sGridNo, &ubRoomNo ) && (FindStructure( sGridNo, STRUCTURE_NORMAL_ROOF ) != NULL) ) - { - return( GenerateBuilding( sGridNo ) ); - } - else + if (gubNumberOfBuildings >= MAX_BUILDINGS) { return( NULL ); } - */ - } - else if ( ubBuildingID > gubNumberOfBuildings ) // huh? - { - return( NULL ); - } - - return( &(gBuildings[ ubBuildingID ]) ); -} - -BOOLEAN InBuilding( INT32 sGridNo ) -{ - if ( FindBuilding( sGridNo ) == NULL ) - { - return( FALSE ); - } - return( TRUE ); -} - -BOOLEAN SameBuilding( INT32 sGridNo1, INT32 sGridNo2 ) -{ - if ( gubBuildingInfo[ sGridNo1 ] == NO_BUILDING ) - { - return( FALSE ); - } - if ( gubBuildingInfo[ sGridNo2 ] == NO_BUILDING ) - { - return( FALSE ); - } - return( (BOOLEAN) (gubBuildingInfo[ sGridNo1] == gubBuildingInfo[ sGridNo2 ]) ); -} - -BUILDING * GenerateBuilding( INT32 sDesiredSpot ) -{ - BUILDING * pBuilding; - UINT8 ubBuildingID = 0; - - pBuilding = CreateNewBuilding( &ubBuildingID ); - if (!pBuilding) - { - return( NULL ); - } - - // Set reachable - RoofReachableTest( sDesiredSpot, ubBuildingID ); - - // 0verhaul: The RoofReachableTest now finds ALL of the climb points for each climbable building, instead of a max of - // 21 climb points (and a min of 0) for each building. It claims an extended map flag to mark a tile as a climb point. - // So the array of up-climbs and down-climbs is now obsolete. FindClosestClimbPoint is now updated to search the map - // for these flags. - return( pBuilding ); -} - -void GenerateBuildings( void ) -{ - INT32 uiLoop; - - // init building structures and variables - memset( gubBuildingInfo, 0, WORLD_MAX * sizeof( UINT8 ) ); - memset( &gBuildings, 0, MAX_BUILDINGS * sizeof( BUILDING ) ); - gubNumberOfBuildings = 0; - - if ( (gbWorldSectorZ > 0) || gfEditMode) - { - return; - } - -#ifdef ROOF_DEBUG - memset( gsCoverValue, 0x7F, sizeof( INT16 ) * WORLD_MAX ); -#endif - - // reset ALL reachable flags - // do once before we start building generation for - // whole map - for ( uiLoop = 0; uiLoop < WORLD_MAX; uiLoop++ ) - { - gpWorldLevelData[ uiLoop ].uiFlags &= ~(MAPELEMENT_REACHABLE); - gpWorldLevelData[ uiLoop ].ubExtFlags[0] &= ~(MAPELEMENT_EXT_ROOFCODE_VISITED); - } - - // search through world - // for each location in a room try to find building info - for ( uiLoop = 0; uiLoop < WORLD_MAX; uiLoop++ ) - { - if ( (gusWorldRoomInfo[ uiLoop ] != NO_ROOM) && (gubBuildingInfo[ uiLoop ] == NO_BUILDING) && (FindStructure( uiLoop, STRUCTURE_NORMAL_ROOF ) != NULL) ) - { - GenerateBuilding( uiLoop ); - } - } -} - -INT32 FindClosestClimbPoint( SOLDIERTYPE *pSoldier, INT32 sStartGridNo, INT32 sDesiredGridNo, BOOLEAN fClimbUp ) -{ - BUILDING * pBuilding; - INT32 sGridNo; - INT32 sTestGridNo; - UINT8 ubTestDir; - INT32 sDistance, sClosestDistance = 1000, sClosestSpot= NOWHERE; - - pBuilding = FindBuilding( sDesiredGridNo ); - if (!pBuilding) - { - return( NOWHERE ); - } - - for (sGridNo = 0; sGridNo < WORLD_MAX; sGridNo++) - { - if (gubBuildingInfo[ sGridNo ] == gubBuildingInfo[ sDesiredGridNo ] && - gpWorldLevelData[ sGridNo ].ubExtFlags[1] & MAPELEMENT_EXT_CLIMBPOINT) - { - // Found a climb point for this building - if (fClimbUp) - { - for (ubTestDir = 0; ubTestDir < NUM_WORLD_DIRECTIONS; ubTestDir += 2) - { - sTestGridNo = NewGridNo( sGridNo, DirectionInc( ubTestDir)); - if (gpWorldLevelData[ sTestGridNo ].ubExtFlags[0] & MAPELEMENT_EXT_CLIMBPOINT) - { - // Found a matching climb point - if ( (WhoIsThere2( sTestGridNo, 0 ) == NOBODY || sTestGridNo == pSoldier->sGridNo) - && (WhoIsThere2( sGridNo, 1 ) == NOBODY) && - (!pSoldier || !InGas( pSoldier, sTestGridNo ) ) ) - { - // And it's open - sDistance = PythSpacesAway( sStartGridNo, sTestGridNo ); - if (sDistance < sClosestDistance ) - { - sClosestDistance = sDistance; - sClosestSpot = sTestGridNo; - } - } - } - } - } - else - { - for (ubTestDir = 0; ubTestDir < NUM_WORLD_DIRECTIONS; ubTestDir += 2) - { - sTestGridNo = NewGridNo( sGridNo, DirectionInc( ubTestDir)); - if (gpWorldLevelData[ sTestGridNo ].ubExtFlags[0] & MAPELEMENT_EXT_CLIMBPOINT) - { - // Found a matching climb point - if ( (WhoIsThere2( sTestGridNo, 0 ) == NOBODY) && - (WhoIsThere2( sGridNo, 1 ) == NOBODY || sGridNo == pSoldier->sGridNo) && - (!pSoldier || !InGas( pSoldier, sTestGridNo ) ) ) - { - // And it's open - sDistance = PythSpacesAway( sStartGridNo, sGridNo ); - if (sDistance < sClosestDistance ) - { - sClosestDistance = sDistance; - sClosestSpot = sGridNo; - } - } - } - } - } - } - } - - return( sClosestSpot ); -} - -// ------------------------- -// A* building climbing - END -// ------------------------- - -// ------------------------- -// JA2 vanilla building climbing - BEGIN -// ------------------------- -#else - -BUILDING * CreateNewBuilding( UINT8 * pubBuilding ) -{ - if (gubNumberOfBuildings >= MAX_BUILDINGS-1) - { - return( NULL ); - } - // increment # of buildings - gubNumberOfBuildings++; - - // clear entry - gBuildings[ gubNumberOfBuildings ].ubNumClimbSpots = 0; - *pubBuilding = gubNumberOfBuildings; - - // return pointer (have to subtract 1 since we just added 1 - return( &(gBuildings[ gubNumberOfBuildings ]) ); -} - -BUILDING * GenerateBuilding( INT32 sDesiredSpot ) -{ - INT32 uiLoop; - INT32 uiLoop2; - INT32 sTempGridNo, sNextTempGridNo, sVeryTemporaryGridNo; - INT32 sStartGridNo, sCurrGridNo, sPrevGridNo = NOWHERE, sRightGridNo; - UINT8 ubDirection, ubTempDirection; - BOOLEAN fFoundDir, fFoundWall; - UINT32 uiChanceIn = ROOF_LOCATION_CHANCE; // chance of a location being considered - INT32 sWallGridNo; - INT8 bDesiredOrientation; - INT8 bSkipSpots = 0; - SOLDIERTYPE FakeSoldier; - BUILDING * pBuilding; - UINT8 ubBuildingID = 0; - INT32 iLoopCount = 0; - - pBuilding = CreateNewBuilding( &ubBuildingID ); - if (!pBuilding) - { - return( NULL ); - } - - FakeSoldier.sGridNo = sDesiredSpot; - FakeSoldier.pathing.bLevel = 1; - FakeSoldier.bTeam = 1; - - // Set reachable - RoofReachableTest( sDesiredSpot, ubBuildingID ); - - // From sGridNo, search until we find a spot that isn't part of the building - ubDirection = NORTHWEST; - sTempGridNo = sDesiredSpot; - // using diagonal directions to hopefully prevent picking a - // spot that - while( (gpWorldLevelData[ sTempGridNo ].uiFlags & MAPELEMENT_REACHABLE ) ) - { - sNextTempGridNo = NewGridNo( sTempGridNo, DirectionInc( ubDirection ) ); - if ( sTempGridNo == sNextTempGridNo ) - { - // hit edge of map!??! - return( NULL ); - } - else - { - sTempGridNo = sNextTempGridNo; - } - } - - // we've got our spot - sStartGridNo = sTempGridNo; - - sCurrGridNo = sStartGridNo; - sVeryTemporaryGridNo = NewGridNo( sCurrGridNo, DirectionInc( EAST ) ); - if ( gpWorldLevelData[ sVeryTemporaryGridNo ].uiFlags & MAPELEMENT_REACHABLE ) - { - // go north first - ubDirection = NORTH; } else { - // go that way (east) - ubDirection = EAST; + if (gubNumberOfBuildings >= MAX_BUILDINGS - 1) + { + return(NULL); + } } - - gpWorldLevelData[ sStartGridNo ].ubExtFlags[0] |= MAPELEMENT_EXT_ROOFCODE_VISITED; - - uiLoop2 = 0; - while(uiLoop2 < WORLD_MAX) - { - // if point to (2 clockwise) is not part of building and is not visited, - // or is starting point, turn! - sRightGridNo = NewGridNo( sCurrGridNo, DirectionInc( gTwoCDirection[ ubDirection ] ) ); - sTempGridNo = sRightGridNo; - if ( ( ( !(gpWorldLevelData[ sTempGridNo ].uiFlags & MAPELEMENT_REACHABLE) && !(gpWorldLevelData[ sTempGridNo ].ubExtFlags[0] & MAPELEMENT_EXT_ROOFCODE_VISITED) ) || (sTempGridNo == sStartGridNo) ) && (sCurrGridNo != sStartGridNo) ) - { - iLoopCount++; - - if ( iLoopCount >= 10 ) - { - return( NULL ); - } - ubDirection = gTwoCDirection[ ubDirection ]; - // try in that direction - continue; - } - iLoopCount = 0; - - // if spot ahead is part of building, turn - sTempGridNo = NewGridNo( sCurrGridNo, DirectionInc( ubDirection ) ); - if ( gpWorldLevelData[ sTempGridNo ].uiFlags & MAPELEMENT_REACHABLE ) - { - // first search for a spot that is neither part of the building or visited - - // we KNOW that the spot in the original direction is blocked, so only loop 3 times - ubTempDirection = gTwoCDirection[ ubDirection ]; - fFoundDir = FALSE; - for ( uiLoop = 0; uiLoop < 3; uiLoop++ ) - { - sTempGridNo = NewGridNo( sCurrGridNo, DirectionInc( ubTempDirection ) ); - if ( !(gpWorldLevelData[ sTempGridNo ].uiFlags & MAPELEMENT_REACHABLE) && !(gpWorldLevelData[ sTempGridNo ].ubExtFlags[0] & MAPELEMENT_EXT_ROOFCODE_VISITED) ) - { - // this is the way to go! - fFoundDir = TRUE; - break; - } - ubTempDirection = gTwoCDirection[ ubTempDirection ]; - } - if (!fFoundDir) - { - // now search for a spot that is just not part of the building - ubTempDirection = gTwoCDirection[ ubDirection ]; - fFoundDir = FALSE; - for ( uiLoop = 0; uiLoop < 3; uiLoop++ ) - { - sTempGridNo = NewGridNo( sCurrGridNo, DirectionInc( ubTempDirection ) ); - if ( !(gpWorldLevelData[ sTempGridNo ].uiFlags & MAPELEMENT_REACHABLE) ) - { - // this is the way to go! - fFoundDir = TRUE; - break; - } - ubTempDirection = gTwoCDirection[ ubTempDirection ]; - } - if (!fFoundDir) - { - // WTF is going on? - return( NULL ); - } - } - ubDirection = ubTempDirection; - // try in that direction - continue; - } - - // move ahead - sPrevGridNo = sCurrGridNo; - sCurrGridNo = sTempGridNo; - sRightGridNo = NewGridNo( sCurrGridNo, DirectionInc( gTwoCDirection[ ubDirection ] ) ); - -#ifdef ROOF_DEBUG - if (gsCoverValue[sCurrGridNo] == 0x7F7F) - { - gsCoverValue[sCurrGridNo] = 1; - } - else if (gsCoverValue[sCurrGridNo] >= 0) - { - gsCoverValue[sCurrGridNo]++; - } - - DebugAI( String( "Roof code visits %d", sCurrGridNo ) ); -#endif - - if (sCurrGridNo == sStartGridNo) - { - // done - break; - } - - if ( !(gpWorldLevelData[ sCurrGridNo ].ubExtFlags[0] & MAPELEMENT_EXT_ROOFCODE_VISITED) ) - { - gpWorldLevelData[ sCurrGridNo ].ubExtFlags[0] |= MAPELEMENT_EXT_ROOFCODE_VISITED; - - if( InARoom(sCurrGridNo, NULL) ) - gubBuildingInfo[ sCurrGridNo ] = ubBuildingID; - - // consider this location as possible climb gridno - // there must be a regular wall adjacent to this for us to consider it a - // climb gridno - - // if the direction is east or north, the wall would be in our gridno; - // if south or west, the wall would be in the gridno two clockwise - fFoundWall = FALSE; - - // There must not be roof here either. There are places where a pitched roof butts up against a flat roof. - // Don't mark such a border as a climb point. Otherwise AI units will get stuck. - if (FindStructure( sCurrGridNo, STRUCTURE_ROOF ) == NULL && - NewOKDestination( &FakeSoldier, sCurrGridNo, FALSE, 0 ) ) - { - switch( ubDirection ) - { - case NORTH: - sWallGridNo = sCurrGridNo; - bDesiredOrientation = OUTSIDE_TOP_RIGHT; - break; - case EAST: - sWallGridNo = sCurrGridNo; - bDesiredOrientation = OUTSIDE_TOP_LEFT; - break; - case SOUTH: - sWallGridNo = ( sCurrGridNo + DirectionInc( gTwoCDirection[ ubDirection ] ) ); - bDesiredOrientation = OUTSIDE_TOP_RIGHT; - break; - case WEST: - sWallGridNo = ( sCurrGridNo + DirectionInc( gTwoCDirection[ ubDirection ] ) ); - bDesiredOrientation = OUTSIDE_TOP_LEFT; - break; - default: - // what the heck? - return( NULL ); - } - - if (bDesiredOrientation == OUTSIDE_TOP_LEFT) - { - if (WallExistsOfTopLeftOrientation( sWallGridNo )) - { - fFoundWall = TRUE; - } - } - else - { - if (WallExistsOfTopRightOrientation( sWallGridNo )) - { - fFoundWall = TRUE; - } - } - } - if (fFoundWall) - { -#ifdef ROOF_DEBUG - gsCoverValue[sCurrGridNo] = 50; -#endif - if (bSkipSpots > 0) - { - bSkipSpots--; - } - else if ( Random( uiChanceIn ) == 0 ) - { - pBuilding->sUpClimbSpots[ pBuilding->ubNumClimbSpots ] = sCurrGridNo; - pBuilding->sDownClimbSpots[ pBuilding->ubNumClimbSpots ] = sRightGridNo; - pBuilding->ubNumClimbSpots++; - - if ( pBuilding->ubNumClimbSpots == MAX_CLIMBSPOTS_PER_BUILDING) - { - // gotta stop! - return( pBuilding ); - } - - // if location is added as a spot, reset uiChanceIn - uiChanceIn = ROOF_LOCATION_CHANCE; -#ifdef ROOF_DEBUG - gsCoverValue[sCurrGridNo] = 99; -#endif - // skip the next spot - bSkipSpots = 1; - } - else - { - // didn't pick this location, so increase chance that next location - // will be considered - if (uiChanceIn > 2) - { - uiChanceIn--; - } - } - } - else - { - // can't select this spot - if ( ( !TileIsOutOfBounds(sPrevGridNo)) && (pBuilding->ubNumClimbSpots > 0) ) - { - if ( pBuilding->sDownClimbSpots[ pBuilding->ubNumClimbSpots - 1 ] == sCurrGridNo ) - { - // unselect previous spot - pBuilding->ubNumClimbSpots--; - // overwrote a selected spot so go into automatic selection for later - uiChanceIn = 1; -#ifdef ROOF_DEBUG - // reset marker - gsCoverValue[sPrevGridNo] = 1; -#endif - } - } - - // skip the next gridno - bSkipSpots = 1; - } - } - uiLoop2++; - } - // If we've run out of loop before we've run out of building, then there is - // something that has gone pear shaped - if(uiLoop2 >= WORLD_MAX) - { - INT32 x = 0; - INT32 y = 0; - while((sDesiredSpot - ((y + 1) * WORLD_COLS)) >= 0) - { - ++y; - } - x = sDesiredSpot - (y * WORLD_COLS); - DebugMsg (TOPIC_JA2,DBG_LEVEL_2,String( "113/UC Warning! Building Walk Algorithm has covered the entire map! Building %d located at [%d,%d] must be bogus.", ubBuildingID, x, y )); - } - - // at end could prune # of locations if there are too many - - return( pBuilding ); + + // increment # of buildings + gubNumberOfBuildings++; + + // clear entry + gBuildings[ gubNumberOfBuildings ].ubNumClimbSpots = 0; + *pubBuilding = gubNumberOfBuildings; + + // return pointer (have to subtract 1 since we just added 1 + return( &(gBuildings[ gubNumberOfBuildings ]) ); } BUILDING * FindBuilding( INT32 sGridNo ) @@ -604,16 +92,339 @@ BOOLEAN InBuilding( INT32 sGridNo ) //if ( FindBuilding( sGridNo ) == NULL ) if (FindBuilding(sGridNo) || InARoom(sGridNo, NULL) && FindStructure(sGridNo, STRUCTURE_ROOF)) { - return( FALSE ); + return(FALSE); } - return( TRUE ); + return(TRUE); } +BOOLEAN SameBuilding( INT32 sGridNo1, INT32 sGridNo2 ) +{ + if ( gubBuildingInfo[ sGridNo1 ] == NO_BUILDING ) + { + return( FALSE ); + } + if ( gubBuildingInfo[ sGridNo2 ] == NO_BUILDING ) + { + return( FALSE ); + } + return( (BOOLEAN) (gubBuildingInfo[ sGridNo1] == gubBuildingInfo[ sGridNo2 ]) ); +} + +BUILDING * GenerateBuilding( INT32 sDesiredSpot ) +{ + UINT8 ubBuildingID = 0; + BUILDING* pBuilding = CreateNewBuilding(&ubBuildingID); + if (!pBuilding) + { + return(NULL); + } + + // RoofReachableTest() is called in the original codepath so this if conditional is commented out for now. + // TODO: Convert original pathfinding code to use the same climbing spot flag as A* so we can get rid of the whole else clause + //if (gGameSettings.fOptions[TOPTION_ALT_PATHFINDING]) + //{ + + // // Set reachable + // RoofReachableTest(sDesiredSpot, ubBuildingID); + + // // 0verhaul: The RoofReachableTest now finds ALL of the climb points for each climbable building, instead of a max of + // // 21 climb points (and a min of 0) for each building. It claims an extended map flag to mark a tile as a climb point. + // // So the array of up-climbs and down-climbs is now obsolete. FindClosestClimbPoint is now updated to search the map + // // for these flags. + // return(pBuilding); + //} + //else + { + INT32 uiLoop; + INT32 uiLoop2; + INT32 sTempGridNo, sNextTempGridNo, sVeryTemporaryGridNo; + INT32 sStartGridNo, sCurrGridNo, sPrevGridNo = NOWHERE, sRightGridNo; + UINT8 ubDirection, ubTempDirection; + BOOLEAN fFoundDir, fFoundWall; + UINT32 uiChanceIn = ROOF_LOCATION_CHANCE; // chance of a location being considered + INT32 sWallGridNo; + INT8 bDesiredOrientation; + INT8 bSkipSpots = 0; + SOLDIERTYPE FakeSoldier; + INT32 iLoopCount = 0; + + FakeSoldier.sGridNo = sDesiredSpot; + FakeSoldier.pathing.bLevel = 1; + FakeSoldier.bTeam = 1; + + // Set reachable + RoofReachableTest(sDesiredSpot, ubBuildingID); + + // From sGridNo, search until we find a spot that isn't part of the building + ubDirection = NORTHWEST; + sTempGridNo = sDesiredSpot; + // using diagonal directions to hopefully prevent picking a + // spot that + while ((gpWorldLevelData[sTempGridNo].uiFlags & MAPELEMENT_REACHABLE)) + { + sNextTempGridNo = NewGridNo(sTempGridNo, DirectionInc(ubDirection)); + if (sTempGridNo == sNextTempGridNo) + { + // hit edge of map!??! + return(NULL); + } + else + { + sTempGridNo = sNextTempGridNo; + } + } + + // we've got our spot + sStartGridNo = sTempGridNo; + + sCurrGridNo = sStartGridNo; + sVeryTemporaryGridNo = NewGridNo(sCurrGridNo, DirectionInc(EAST)); + if (gpWorldLevelData[sVeryTemporaryGridNo].uiFlags & MAPELEMENT_REACHABLE) + { + // go north first + ubDirection = NORTH; + } + else + { + // go that way (east) + ubDirection = EAST; + } + + gpWorldLevelData[sStartGridNo].ubExtFlags[0] |= MAPELEMENT_EXT_ROOFCODE_VISITED; + + uiLoop2 = 0; + while (uiLoop2 < WORLD_MAX) + { + // if point to (2 clockwise) is not part of building and is not visited, + // or is starting point, turn! + sRightGridNo = NewGridNo(sCurrGridNo, DirectionInc(gTwoCDirection[ubDirection])); + sTempGridNo = sRightGridNo; + if (((!(gpWorldLevelData[sTempGridNo].uiFlags & MAPELEMENT_REACHABLE) && !(gpWorldLevelData[sTempGridNo].ubExtFlags[0] & MAPELEMENT_EXT_ROOFCODE_VISITED)) || (sTempGridNo == sStartGridNo)) && (sCurrGridNo != sStartGridNo)) + { + iLoopCount++; + + if (iLoopCount >= 10) + { + return(NULL); + } + ubDirection = gTwoCDirection[ubDirection]; + // try in that direction + continue; + } + iLoopCount = 0; + + // if spot ahead is part of building, turn + sTempGridNo = NewGridNo(sCurrGridNo, DirectionInc(ubDirection)); + if (gpWorldLevelData[sTempGridNo].uiFlags & MAPELEMENT_REACHABLE) + { + // first search for a spot that is neither part of the building or visited + + // we KNOW that the spot in the original direction is blocked, so only loop 3 times + ubTempDirection = gTwoCDirection[ubDirection]; + fFoundDir = FALSE; + for (uiLoop = 0; uiLoop < 3; uiLoop++) + { + sTempGridNo = NewGridNo(sCurrGridNo, DirectionInc(ubTempDirection)); + if (!(gpWorldLevelData[sTempGridNo].uiFlags & MAPELEMENT_REACHABLE) && !(gpWorldLevelData[sTempGridNo].ubExtFlags[0] & MAPELEMENT_EXT_ROOFCODE_VISITED)) + { + // this is the way to go! + fFoundDir = TRUE; + break; + } + ubTempDirection = gTwoCDirection[ubTempDirection]; + } + if (!fFoundDir) + { + // now search for a spot that is just not part of the building + ubTempDirection = gTwoCDirection[ubDirection]; + fFoundDir = FALSE; + for (uiLoop = 0; uiLoop < 3; uiLoop++) + { + sTempGridNo = NewGridNo(sCurrGridNo, DirectionInc(ubTempDirection)); + if (!(gpWorldLevelData[sTempGridNo].uiFlags & MAPELEMENT_REACHABLE)) + { + // this is the way to go! + fFoundDir = TRUE; + break; + } + ubTempDirection = gTwoCDirection[ubTempDirection]; + } + if (!fFoundDir) + { + // WTF is going on? + return(NULL); + } + } + ubDirection = ubTempDirection; + // try in that direction + continue; + } + + // move ahead + sPrevGridNo = sCurrGridNo; + sCurrGridNo = sTempGridNo; + sRightGridNo = NewGridNo(sCurrGridNo, DirectionInc(gTwoCDirection[ubDirection])); + +#ifdef ROOF_DEBUG + if (gsCoverValue[sCurrGridNo] == 0x7F7F) + { + gsCoverValue[sCurrGridNo] = 1; + } + else if (gsCoverValue[sCurrGridNo] >= 0) + { + gsCoverValue[sCurrGridNo]++; + } + + DebugAI(String("Roof code visits %d", sCurrGridNo)); +#endif + + if (sCurrGridNo == sStartGridNo) + { + // done + break; + } + + if (!(gpWorldLevelData[sCurrGridNo].ubExtFlags[0] & MAPELEMENT_EXT_ROOFCODE_VISITED)) + { + gpWorldLevelData[sCurrGridNo].ubExtFlags[0] |= MAPELEMENT_EXT_ROOFCODE_VISITED; + + if (InARoom(sCurrGridNo, NULL)) + gubBuildingInfo[sCurrGridNo] = ubBuildingID; + + // consider this location as possible climb gridno + // there must be a regular wall adjacent to this for us to consider it a + // climb gridno + + // if the direction is east or north, the wall would be in our gridno; + // if south or west, the wall would be in the gridno two clockwise + fFoundWall = FALSE; + + // There must not be roof here either. There are places where a pitched roof butts up against a flat roof. + // Don't mark such a border as a climb point. Otherwise AI units will get stuck. + if (FindStructure(sCurrGridNo, STRUCTURE_ROOF) == NULL && + NewOKDestination(&FakeSoldier, sCurrGridNo, FALSE, 0)) + { + switch (ubDirection) + { + case NORTH: + sWallGridNo = sCurrGridNo; + bDesiredOrientation = OUTSIDE_TOP_RIGHT; + break; + case EAST: + sWallGridNo = sCurrGridNo; + bDesiredOrientation = OUTSIDE_TOP_LEFT; + break; + case SOUTH: + sWallGridNo = (sCurrGridNo + DirectionInc(gTwoCDirection[ubDirection])); + bDesiredOrientation = OUTSIDE_TOP_RIGHT; + break; + case WEST: + sWallGridNo = (sCurrGridNo + DirectionInc(gTwoCDirection[ubDirection])); + bDesiredOrientation = OUTSIDE_TOP_LEFT; + break; + default: + // what the heck? + return(NULL); + } + + if (bDesiredOrientation == OUTSIDE_TOP_LEFT) + { + if (WallExistsOfTopLeftOrientation(sWallGridNo)) + { + fFoundWall = TRUE; + } + } + else + { + if (WallExistsOfTopRightOrientation(sWallGridNo)) + { + fFoundWall = TRUE; + } + } + } + if (fFoundWall) + { +#ifdef ROOF_DEBUG + gsCoverValue[sCurrGridNo] = 50; +#endif + if (bSkipSpots > 0) + { + bSkipSpots--; + } + else if (Random(uiChanceIn) == 0) + { + pBuilding->sUpClimbSpots[pBuilding->ubNumClimbSpots] = sCurrGridNo; + pBuilding->sDownClimbSpots[pBuilding->ubNumClimbSpots] = sRightGridNo; + pBuilding->ubNumClimbSpots++; + + if (pBuilding->ubNumClimbSpots == MAX_CLIMBSPOTS_PER_BUILDING) + { + // gotta stop! + return(pBuilding); + } + + // if location is added as a spot, reset uiChanceIn + uiChanceIn = ROOF_LOCATION_CHANCE; +#ifdef ROOF_DEBUG + gsCoverValue[sCurrGridNo] = 99; +#endif + // skip the next spot + bSkipSpots = 1; + } + else + { + // didn't pick this location, so increase chance that next location + // will be considered + if (uiChanceIn > 2) + { + uiChanceIn--; + } + } + } + else + { + // can't select this spot + if ((!TileIsOutOfBounds(sPrevGridNo)) && (pBuilding->ubNumClimbSpots > 0)) + { + if (pBuilding->sDownClimbSpots[pBuilding->ubNumClimbSpots - 1] == sCurrGridNo) + { + // unselect previous spot + pBuilding->ubNumClimbSpots--; + // overwrote a selected spot so go into automatic selection for later + uiChanceIn = 1; +#ifdef ROOF_DEBUG + // reset marker + gsCoverValue[sPrevGridNo] = 1; +#endif + } + } + + // skip the next gridno + bSkipSpots = 1; + } + } + uiLoop2++; + } + // If we've run out of loop before we've run out of building, then there is + // something that has gone pear shaped + if (uiLoop2 >= WORLD_MAX) + { + INT32 x = 0; + INT32 y = 0; + while ((sDesiredSpot - ((y + 1) * WORLD_COLS)) >= 0) + { + ++y; + } + x = sDesiredSpot - (y * WORLD_COLS); + DebugMsg(TOPIC_JA2, DBG_LEVEL_2, String("113/UC Warning! Building Walk Algorithm has covered the entire map! Building %d located at [%d,%d] must be bogus.", ubBuildingID, x, y)); + } + // at end could prune # of locations if there are too many + return(pBuilding); + } +} void GenerateBuildings( void ) { - INT32 uiLoop; - // init building structures and variables memset( gubBuildingInfo, 0, WORLD_MAX * sizeof( UINT8 ) ); memset( &gBuildings, 0, MAX_BUILDINGS * sizeof( BUILDING ) ); @@ -631,7 +442,7 @@ void GenerateBuildings( void ) // reset ALL reachable flags // do once before we start building generation for // whole map - for ( uiLoop = 0; uiLoop < WORLD_MAX; uiLoop++ ) + for (INT32 uiLoop = 0; uiLoop < WORLD_MAX; uiLoop++ ) { gpWorldLevelData[ uiLoop ].uiFlags &= ~(MAPELEMENT_REACHABLE); gpWorldLevelData[ uiLoop ].ubExtFlags[0] &= ~(MAPELEMENT_EXT_ROOFCODE_VISITED); @@ -639,7 +450,7 @@ void GenerateBuildings( void ) // search through world // for each location in a room try to find building info - for ( uiLoop = 0; uiLoop < WORLD_MAX; uiLoop++ ) + for (INT32 uiLoop = 0; uiLoop < WORLD_MAX; uiLoop++ ) { if ( (gusWorldRoomInfo[ uiLoop ] != NO_ROOM) && (gubBuildingInfo[ uiLoop ] == NO_BUILDING) && (FindStructure( uiLoop, STRUCTURE_NORMAL_ROOF ) != NULL) ) { @@ -650,66 +461,103 @@ void GenerateBuildings( void ) INT32 FindClosestClimbPoint( SOLDIERTYPE *pSoldier, INT32 sStartGridNo, INT32 sDesiredGridNo, BOOLEAN fClimbUp ) { - BUILDING * pBuilding; - INT32 sDistance, sClosestDistance = 1000, sClosestSpot= NOWHERE; - - pBuilding = FindBuilding( sDesiredGridNo ); + BUILDING* pBuilding = FindBuilding( sDesiredGridNo ); if (!pBuilding) { return( NOWHERE ); } - - // WANNE: Reworked climbing code from sevenfm - UINT8 ubNumClimbSpots; - INT32 * psClimbSpots; - UINT8 ubLoop; - ubNumClimbSpots = pBuilding->ubNumClimbSpots; - - if (fClimbUp) + INT32 sDistance, sClosestDistance = 1000, sClosestSpot = NOWHERE; + if (gGameSettings.fOptions[TOPTION_ALT_PATHFINDING]) { - psClimbSpots = pBuilding->sUpClimbSpots; - } - else - { - psClimbSpots = pBuilding->sDownClimbSpots; - } - - for ( ubLoop = 0; ubLoop < ubNumClimbSpots; ubLoop++ ) - { - if( (WhoIsThere2( pBuilding->sUpClimbSpots[ ubLoop ], 0 ) == NOBODY || - WhoIsThere2( pBuilding->sUpClimbSpots[ ubLoop ], 0 ) == pSoldier->ubID ) && - (WhoIsThere2( pBuilding->sDownClimbSpots[ ubLoop ], 1 ) == NOBODY || - WhoIsThere2( pBuilding->sDownClimbSpots[ ubLoop ], 1 ) == pSoldier->ubID) && - !InGas( pSoldier, psClimbSpots[ ubLoop] ) && - !Water( psClimbSpots[ ubLoop], pSoldier->pathing.bLevel) ) + for (INT32 sGridNo = 0; sGridNo < WORLD_MAX; sGridNo++) { - sDistance = PythSpacesAway( sStartGridNo, psClimbSpots[ ubLoop ] ); - if (sDistance < sClosestDistance ) + if (gubBuildingInfo[sGridNo] == gubBuildingInfo[sDesiredGridNo] && + gpWorldLevelData[sGridNo].ubExtFlags[1] & MAPELEMENT_EXT_CLIMBPOINT) { - sClosestDistance = sDistance; - sClosestSpot = psClimbSpots[ ubLoop ]; + // Found a climb point for this building + if (fClimbUp) + { + for (UINT8 ubTestDir = 0; ubTestDir < NUM_WORLD_DIRECTIONS; ubTestDir += 2) + { + INT32 sTestGridNo = NewGridNo(sGridNo, DirectionInc(ubTestDir)); + if (gpWorldLevelData[sTestGridNo].ubExtFlags[0] & MAPELEMENT_EXT_CLIMBPOINT) + { + // Found a matching climb point + if ((WhoIsThere2(sTestGridNo, 0) == NOBODY || sTestGridNo == pSoldier->sGridNo) + && (WhoIsThere2(sGridNo, 1) == NOBODY) && + (!pSoldier || !InGas(pSoldier, sTestGridNo))) + { + // And it's open + sDistance = PythSpacesAway(sStartGridNo, sTestGridNo); + if (sDistance < sClosestDistance) + { + sClosestDistance = sDistance; + sClosestSpot = sTestGridNo; + } + } + } + } + } + else + { + for (UINT8 ubTestDir = 0; ubTestDir < NUM_WORLD_DIRECTIONS; ubTestDir += 2) + { + INT32 sTestGridNo = NewGridNo(sGridNo, DirectionInc(ubTestDir)); + if (gpWorldLevelData[sTestGridNo].ubExtFlags[0] & MAPELEMENT_EXT_CLIMBPOINT) + { + // Found a matching climb point + if ((WhoIsThere2(sTestGridNo, 0) == NOBODY) && + (WhoIsThere2(sGridNo, 1) == NOBODY || sGridNo == pSoldier->sGridNo) && + (!pSoldier || !InGas(pSoldier, sTestGridNo))) + { + // And it's open + sDistance = PythSpacesAway(sStartGridNo, sGridNo); + if (sDistance < sClosestDistance) + { + sClosestDistance = sDistance; + sClosestSpot = sGridNo; + } + } + } + } + } } } } - + else + { + // WANNE: Reworked climbing code from sevenfm + INT32* psClimbSpots; + UINT8 ubNumClimbSpots = pBuilding->ubNumClimbSpots; + + if (fClimbUp) + { + psClimbSpots = pBuilding->sUpClimbSpots; + } + else + { + psClimbSpots = pBuilding->sDownClimbSpots; + } + + for (UINT8 ubLoop = 0; ubLoop < ubNumClimbSpots; ubLoop++) + { + if ((WhoIsThere2(pBuilding->sUpClimbSpots[ubLoop], 0) == NOBODY || + WhoIsThere2(pBuilding->sUpClimbSpots[ubLoop], 0) == pSoldier->ubID) && + (WhoIsThere2(pBuilding->sDownClimbSpots[ubLoop], 1) == NOBODY || + WhoIsThere2(pBuilding->sDownClimbSpots[ubLoop], 1) == pSoldier->ubID) && + !InGas(pSoldier, psClimbSpots[ubLoop]) && + !Water(psClimbSpots[ubLoop], pSoldier->pathing.bLevel)) + { + sDistance = PythSpacesAway(sStartGridNo, psClimbSpots[ubLoop]); + if (sDistance < sClosestDistance) + { + sClosestDistance = sDistance; + sClosestSpot = psClimbSpots[ubLoop]; + } + } + } + } + return( sClosestSpot ); } - -BOOLEAN SameBuilding( INT32 sGridNo1, INT32 sGridNo2 ) -{ - if ( gubBuildingInfo[ sGridNo1 ] == NO_BUILDING ) - { - return( FALSE ); - } - if ( gubBuildingInfo[ sGridNo2 ] == NO_BUILDING ) - { - return( FALSE ); - } - return( (BOOLEAN) (gubBuildingInfo[ sGridNo1] == gubBuildingInfo[ sGridNo2 ]) ); -} - -#endif -// ------------------------- -// JA2 vanilla building climbing - END -// ------------------------- diff --git a/TileEngine/CMakeLists.txt b/TileEngine/CMakeLists.txt new file mode 100644 index 000000000..a8b6e4d3e --- /dev/null +++ b/TileEngine/CMakeLists.txt @@ -0,0 +1,39 @@ +set(TileEngineSrc +"${CMAKE_CURRENT_SOURCE_DIR}/Ambient Control.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Buildings.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/environment.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Exit Grids.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Explosion Control.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Fog Of War.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Interactive Tiles.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Isometric Utils.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/LightEffects.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/lighting.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Map Edgepoints.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/overhead map.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/phys math.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/physics.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/pits.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Radar Screen.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Render Dirty.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Render Fun.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Render Z.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/renderworld.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/SaveLoadMap.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Shade Table Util.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Simple Render Utils.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Smell.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/SmokeEffects.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/structure.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/sysutil.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Tactical Placement GUI.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Tile Animation.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Tile Cache.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Tile Surface.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/TileDat.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/tiledef.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/WorldDat.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/worlddef.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/worldman.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_ExplosionData.cpp" +PARENT_SCOPE) diff --git a/TileEngine/Exit Grids.cpp b/TileEngine/Exit Grids.cpp index 4ada6bb00..036b48d54 100644 --- a/TileEngine/Exit Grids.cpp +++ b/TileEngine/Exit Grids.cpp @@ -12,68 +12,14 @@ #include "SaveLoadMap.h" #include "Text.h" -#if 0//dnl ch86 180214 -BOOLEAN gfLoadingExitGrids = FALSE; - -//used by editor. -EXITGRID gExitGrid = {0,1,1,0}; - -BOOLEAN gfOverrideInsertionWithExitGrid = FALSE; - -// - -#define MAX_EXITGRIDS 4096 - -EXITGRID gpExitGrids[MAX_EXITGRIDS]; -UINT guiExitGridsCount = 0; - - -//INT32 ConvertExitGridToINT32( EXITGRID *pExitGrid ) -//{ -// INT32 iExitGridInfo; -// iExitGridInfo = (pExitGrid->ubGotoSectorX-1)<< 28; -// iExitGridInfo += (pExitGrid->ubGotoSectorY-1)<< 24; -// iExitGridInfo += pExitGrid->ubGotoSectorZ << 20; -// iExitGridInfo += pExitGrid->usGridNo & 0x0000ffff; -// return iExitGridInfo; -//} -// -//void ConvertINT32ToExitGrid( INT32 iExitGridInfo, EXITGRID *pExitGrid ) -//{ -// //convert the int into 4 unsigned bytes. -// pExitGrid->ubGotoSectorX = (UINT8)(((iExitGridInfo & 0xf0000000)>>28)+1); -// pExitGrid->ubGotoSectorY = (UINT8)(((iExitGridInfo & 0x0f000000)>>24)+1); -// pExitGrid->ubGotoSectorZ = (UINT8)((iExitGridInfo & 0x00f00000)>>20); -// pExitGrid->usGridNo = (UINT16)(iExitGridInfo & 0x0000ffff); -//} -#else BOOLEAN gfLoadingExitGrids = FALSE; BOOLEAN gfOverrideInsertionWithExitGrid = FALSE; EXITGRID gExitGrid; EXITGRID *ExitGridTable = NULL; UINT16 gusNumExitGrids = 0; -#endif BOOLEAN GetExitGrid( UINT32 usMapIndex, EXITGRID *pExitGrid ) { -#if 0//dnl ch86 170214 - LEVELNODE *pShadow; - pShadow = gpWorldLevelData[ usMapIndex ].pShadowHead; - //Search through object layer for an exitgrid - while( pShadow ) - { - if ( pShadow->uiFlags & LEVELNODE_EXITGRID ) - { -// -// ConvertINT32ToExitGrid( pShadow->iExitGridInfo, pExitGrid ); - memcpy(pExitGrid, pShadow->pExitGridInfo, sizeof(EXITGRID)); -// - return TRUE; - } - pShadow = pShadow->pNext; - } - return FALSE; -#else INT32 i = 0; while(i < gusNumExitGrids) { @@ -85,7 +31,6 @@ BOOLEAN GetExitGrid( UINT32 usMapIndex, EXITGRID *pExitGrid ) i++; } return(FALSE); -#endif } BOOLEAN ExitGridAtGridNo( UINT32 usMapIndex ) @@ -123,42 +68,6 @@ BOOLEAN GetExitGridLevelNode( UINT32 usMapIndex, LEVELNODE **ppLevelNode ) void AddExitGridToWorld( INT32 iMapIndex, EXITGRID *pExitGrid ) { -#if 0//dnl ch86 180214 - LEVELNODE *pShadow, *tail; - pShadow = gpWorldLevelData[ iMapIndex ].pShadowHead; - - //Search through object layer for an exitgrid - while( pShadow ) - { - tail = pShadow; - if( pShadow->uiFlags & LEVELNODE_EXITGRID ) - { //we have found an existing exitgrid in this node, so replace it with the new information. - memcpy(pShadow->pExitGridInfo, pExitGrid, sizeof(EXITGRID));//dnl ch80 011213 - return; - } - pShadow = pShadow->pNext; - } - - // Add levelnode - AddShadowToHead( iMapIndex, MOCKFLOOR1 ); - // Get new node - pShadow = gpWorldLevelData[ iMapIndex ].pShadowHead; - - //fill in the information for the new exitgrid levelnode. -// -// pShadow->iExitGridInfo = ConvertExitGridToINT32( pExitGrid ); - memcpy(gpExitGrids + guiExitGridsCount, pExitGrid, sizeof(EXITGRID)); - pShadow->pExitGridInfo = gpExitGrids + guiExitGridsCount; - guiExitGridsCount++; -// - pShadow->uiFlags |= ( LEVELNODE_EXITGRID | LEVELNODE_HIDDEN ); - - //Add the exit grid to the sector, only if we call ApplyMapChangesToMapTempFile() first. - if( !gfEditMode && !gfLoadingExitGrids ) - { - AddExitGridToMapTempFile( iMapIndex, pExitGrid, gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); - } -#else pExitGrid->iMapIndex = iMapIndex; INT32 i = 0, j = -1; while(i < gusNumExitGrids) @@ -196,18 +105,10 @@ void AddExitGridToWorld( INT32 iMapIndex, EXITGRID *pExitGrid ) if(!gfEditMode && !gfLoadingExitGrids) AddExitGridToMapTempFile(iMapIndex, pExitGrid, gWorldSectorX, gWorldSectorY, gbWorldSectorZ); } -#endif } void RemoveExitGridFromWorld( INT32 iMapIndex ) { -#if 0//dnl ch86 180214 - UINT16 usDummy; - if( TypeExistsInShadowLayer( iMapIndex, MOCKFLOOR, &usDummy ) ) - { - RemoveAllShadowsOfTypeRange( iMapIndex, MOCKFLOOR, MOCKFLOOR ); - } -#else INT32 i = 0; while(i < gusNumExitGrids) { @@ -219,7 +120,6 @@ void RemoveExitGridFromWorld( INT32 iMapIndex ) } i++; } -#endif } void TrashExitGridTable(void)//dnl ch86 170214 @@ -284,37 +184,15 @@ void LoadExitGrids(INT8** hBuffer, FLOAT dMajorMapVersion) UINT16 usNumExitGrids; INT32 usMapIndex; EXITGRID ExitGrid; -#if 0//dnl ch86 170214 - // New world is loading so trash all old EXITGRID's - memset(gpExitGrids, 0, sizeof(gpExitGrids)); - guiExitGridsCount = 0; -#else TrashExitGridTable(); -#endif gfLoadingExitGrids = TRUE; LOADDATA(&usNumExitGrids, *hBuffer, sizeof(usNumExitGrids)); for(int i=0; ifFlags & TILE_ON_ROOF ) ) { -#if 0//dnl ch83 080114 - sStructGridNo = pBase->sGridNo + ppTile[ubLoop]->sPosRelToBase; -#else sStructGridNo = AddPosRelToBase(pBase->sGridNo, ppTile[ubLoop]); -#endif // there might be two structures in this tile, one on each level, but we just want to // delete one on each pass @@ -1456,11 +1452,7 @@ void ExplosiveDamageGridNo( INT32 sGridNo, INT16 sWoundAmt, UINT32 uiDist, BOOLE for ( ubLoop = BASE_TILE; ubLoop < ubNumberOfTiles; ubLoop++) { -#if 0//dnl ch83 080114 - sNewGridNo = sBaseGridNo + ppTile[ubLoop]->sPosRelToBase; -#else sNewGridNo = AddPosRelToBase(sBaseGridNo, ppTile[ubLoop]); -#endif // look in adjacent tiles for ( ubLoop2 = 0; ubLoop2 < NUM_WORLD_DIRECTIONS; ubLoop2++ ) { diff --git a/TileEngine/Isometric Utils.cpp b/TileEngine/Isometric Utils.cpp index 1315070b9..5f68cf493 100644 --- a/TileEngine/Isometric Utils.cpp +++ b/TileEngine/Isometric Utils.cpp @@ -91,6 +91,11 @@ UINT8 gOneCCDirection[ NUM_WORLD_DIRECTIONS ] = WEST }; +UINT8 DirectionIfTurnedClockwise(UINT8 facing, UINT8 times) +{ + return (facing + times) % NUM_WORLD_DIRECTIONS; +} + // DIRECTION FACING DIRECTION WE WANT TO GOTO UINT8 gPurpendicularDirection[ NUM_WORLD_DIRECTIONS ][ NUM_WORLD_DIRECTIONS ] = { @@ -664,16 +669,6 @@ BOOLEAN GetMouseWorldCoordsInCenter( INT16 *psMouseX, INT16 *psMouseY ) return( TRUE ); } -#if 0 -// 0verhaul -// I did that (or actually uncasted a bunch of stuff and re-typed others to correct them), so -// no worries -// (jonathanl) to save me having to cast all the previous code -BOOLEAN GetMouseMapPos( UINT32 *psMapPos ) -{ - return GetMouseMapPos( (INT32 *)psMapPos ); -} -#endif BOOLEAN GetMouseMapPos( INT32 *psMapPos ) { @@ -912,6 +907,15 @@ INT16 sDeltaScreenX, sDeltaScreenY; } +INT16 DirectionToVectorX[NUM_WORLD_DIRECTIONS] = {0, 1, 1, 1, 0, -1, -1, -1}; +INT16 DirectionToVectorY[NUM_WORLD_DIRECTIONS] = {-1, -1, 0, 1, 1, 1, 0, -1}; +void ConvertDirectionToVectorInXY( UINT8 ubDirection, INT16* sXDir, INT16* sYDir ) +{ + Assert(ubDirection >= 0 && ubDirection < NUM_WORLD_DIRECTIONS); + *sXDir = DirectionToVectorX[ubDirection]; + *sYDir = DirectionToVectorY[ubDirection]; +} + void ConvertGridNoToXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos ) { *sYPos = sGridNo / WORLD_COLS; @@ -1295,11 +1299,7 @@ BOOLEAN GridNoOnVisibleWorldTile( INT32 sGridNo ) // Get screen coordinates for current position of soldier GetWorldXYAbsoluteScreenXY( sXMapPos, sYMapPos, &sWorldX, &sWorldY); -#if 0//dnl ch53 151009 - if ( sWorldX > 0 && sWorldX < ( gsTRX - gsTLX - 20 ) && sWorldY > 20 && sWorldY < ( gsBLY - gsTLY - 20 ) ) -#else if ( sWorldX >= 30 && sWorldX <= (gsTRX - gsTLX - 30) && sWorldY >= 20 && sWorldY <= (gsBLY - gsTLY - 10) ) -#endif { return GridNoOnWalkableWorldTile(sGridNo); } @@ -1307,31 +1307,6 @@ BOOLEAN GridNoOnVisibleWorldTile( INT32 sGridNo ) return( FALSE ); } -#if 0//dnl ch53 101009 -// This function is used when we care about astetics with the top Y portion of the -// gma eplay area -// mostly due to UI bar that comes down.... -BOOLEAN GridNoOnVisibleWorldTileGivenYLimits( INT32 sGridNo ) -{ - INT16 sWorldX; - INT16 sWorldY; - INT16 sXMapPos, sYMapPos; - - // Check for valid gridno... - ConvertGridNoToXY( sGridNo, &sXMapPos, &sYMapPos ); - - // Get screen coordinates for current position of soldier - GetWorldXYAbsoluteScreenXY( sXMapPos, sYMapPos, &sWorldX, &sWorldY); - - if ( sWorldX > 0 && sWorldX < ( gsTRX - gsTLX - 20 ) && - sWorldY > 40 && sWorldY < ( gsBLY - gsTLY - 20 ) ) - { - return( TRUE ); - } - - return( FALSE ); -} -#endif BOOLEAN GridNoOnEdgeOfMap( INT32 sGridNo, INT8 * pbDirection ) { diff --git a/TileEngine/Isometric Utils.h b/TileEngine/Isometric Utils.h index eaa5f2b38..7da2f67e4 100644 --- a/TileEngine/Isometric Utils.h +++ b/TileEngine/Isometric Utils.h @@ -30,6 +30,8 @@ extern UINT8 gTwoCDirection[ NUM_WORLD_DIRECTIONS ]; extern UINT8 gOneCDirection[ NUM_WORLD_DIRECTIONS ]; extern UINT8 gOneCCDirection[ NUM_WORLD_DIRECTIONS ]; +UINT8 DirectionIfTurnedClockwise(UINT8 facing, UINT8 times); + extern UINT8 gPurpendicularDirection[ NUM_WORLD_DIRECTIONS ][ NUM_WORLD_DIRECTIONS ]; // Macros @@ -40,6 +42,7 @@ extern UINT8 gPurpendicularDirection[ NUM_WORLD_DIRECTIONS ][ NUM_WORLD_DIRECTIO #define GETWORLDINDEXFROMWORLDCOORDS( y, x ) ( (INT32) ( x / CELL_X_SIZE ) ) + WORLD_COLS * ( (INT32) ( y / CELL_Y_SIZE ) ) +void ConvertDirectionToVectorInXY(UINT8 ubDirection, INT16* sXDir, INT16* sYDir); void ConvertGridNoToXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos ); void ConvertGridNoToCellXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos ); void ConvertGridNoToCenterCellXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos ); diff --git a/TileEngine/Render Fun.cpp b/TileEngine/Render Fun.cpp index 6248840c7..e2ecd20cf 100644 --- a/TileEngine/Render Fun.cpp +++ b/TileEngine/Render Fun.cpp @@ -208,11 +208,7 @@ void ExamineGridNoForSlantRoofExtraGraphic( INT32 sCheckGridNo ) for ( ubLoop = 0; ubLoop < pBase->pDBStructureRef->pDBStructure->ubNumberOfTiles; ubLoop++ ) { ppTile = pBase->pDBStructureRef->ppTile; -#if 0//dnl ch83 080114 - sGridNo = pBase->sGridNo + ppTile[ ubLoop ]->sPosRelToBase; -#else sGridNo = AddPosRelToBase(pBase->sGridNo, ppTile[ubLoop]); -#endif if (sGridNo < 0 || sGridNo > WORLD_MAX) { continue; diff --git a/TileEngine/lighting.cpp b/TileEngine/lighting.cpp index b2f01d3ba..f873eaf18 100644 --- a/TileEngine/lighting.cpp +++ b/TileEngine/lighting.cpp @@ -540,12 +540,6 @@ UINT8 ubTravelCost; //bDirection = atan8( iX, iY, iSrcX, iSrcY ); bDirection = atan8( iSrcX, iSrcY, iX, iY ); -#if 0 - if ( usTileNo == 20415 && bDirection == 3 ) - { - int i = 0; - } -#endif ubTravelCost = gubWorldMovementCosts[ usTileNo ][ bDirection ][ 0 ]; @@ -564,50 +558,6 @@ UINT8 ubTravelCost; } } -#if 0 - pStruct = gpWorldLevelData[ usTileNo ].pStructHead; - while ( pStruct != NULL ) - { - if ( pStruct->usIndex < giNumberOfTiles ) - { - GetTileType( pStruct->usIndex, &uiType ); - - // ATE: Changed to use last decordations rather than last decal - // Could maybe check orientation value? Depends on our - // use of the orientation value flags.. - if((uiType >= FIRSTWALL) && (uiType <=LASTDECORATIONS )) - { - GetWallOrientation(pStruct->usIndex, &usWallOrientation); - - bWallCount++; - } - } - - pStruct=pStruct->pNext; - } - - if ( bWallCount ) - { - // ATE: If TWO or more - assume it's BLOCKED and return TRUE - if ( bWallCount != 1 ) - { - return( TRUE ); - } - - switch(usWallOrientation) - { - case INSIDE_TOP_RIGHT: - case OUTSIDE_TOP_RIGHT: - return( iSrcX < iX ); - - case INSIDE_TOP_LEFT: - case OUTSIDE_TOP_LEFT: - return( iSrcY < iY ); - - } - } - -#endif return(FALSE); } @@ -2152,28 +2102,6 @@ BOOLEAN LightIlluminateWall(INT16 iSourceX, INT16 iSourceY, INT16 iTileX, INT16 // return( LightTileHasWall( iSourceX, iSourceY, iTileX, iTileY ) ); -#if 0 -UINT16 usWallOrientation; - - GetWallOrientation(pStruct->usIndex, &usWallOrientation); - - switch(usWallOrientation) - { - case NO_ORIENTATION: - return(TRUE); - - case INSIDE_TOP_RIGHT: - case OUTSIDE_TOP_RIGHT: - return(iSourceX >= iTileX); - - case INSIDE_TOP_LEFT: - case OUTSIDE_TOP_LEFT: - return(iSourceY >= iTileY); - - } - return(FALSE); - -#endif return( TRUE ); } diff --git a/TileEngine/overhead map.cpp b/TileEngine/overhead map.cpp index 8f42f1923..c2b5a0528 100644 --- a/TileEngine/overhead map.cpp +++ b/TileEngine/overhead map.cpp @@ -995,15 +995,8 @@ void RenderOverheadMap( INT16 sStartPointX_M, INT16 sStartPointY_M, INT16 sStart // Black color for the background! //ColorFillVideoSurfaceArea( FRAME_BUFFER, sStartPointX_S, sStartPointY_S, sEndXS, sEndYS, 0 ); -#if 0//dnl ch79 291113 - if(gfTacticalPlacementGUIActive)//dnl ch45 021009 Skip overwrite buttons area which is not refresh during scroll //dnl ch77 211113 - ColorFillVideoSurfaceArea(uiBigMap, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-160, 0); - else - ColorFillVideoSurfaceArea(uiBigMap, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-120, 0); -#else if(uiVSurface == FRAME_BUFFER)//dnl ch82 090114 ColorFillVideoSurfaceArea(FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-(gfTacticalPlacementGUIActive?160:120), 0); -#endif fInterfacePanelDirty = DIRTYLEVEL2; InvalidateScreen(); diff --git a/TileEngine/physics.cpp b/TileEngine/physics.cpp index da184a9b6..a08b72365 100644 --- a/TileEngine/physics.cpp +++ b/TileEngine/physics.cpp @@ -1457,43 +1457,6 @@ BOOLEAN PhysicsMoveObject( REAL_OBJECT *pObject ) -#if 0 -{ - LEVELNODE *pNode; - INT32 sNewGridNo; - - //Determine new gridno - sNewGridNo = MAPROWCOLTOPOS( ( pObject->Position.y / CELL_Y_SIZE ), ( pObject->Position.x / CELL_X_SIZE ) ); - - // Look at old gridno - if ( sNewGridNo != pObject->sGridNo ) - { - // We're at a new gridno! - - // First find levelnode of our object and delete - pNode = gpWorldLevelData[ pObject->sGridNo ].pStructHead; - - // LOOP THORUGH OBJECT LAYER - while( pNode != NULL ) - { - if ( pNode->uiFlags & LEVELNODE_PHYSICSOBJECT ) - { - if ( pNode->iPhysicsObjectID == pObject->iID ) - { - RemoveStruct( pObject->sGridNo, pNode->usIndex ); - break; - } - } - - pNode = ppNode->pNext; - } - - // Set new gridno, add - } - // Add new object / update position - -} -#endif void ObjectHitWindow( INT32 sGridNo, UINT16 usStructureID, BOOLEAN fBlowWindowSouth, BOOLEAN fLargeForce ) { diff --git a/TileEngine/renderworld.cpp b/TileEngine/renderworld.cpp index a2fd01fbe..5258b73a0 100644 --- a/TileEngine/renderworld.cpp +++ b/TileEngine/renderworld.cpp @@ -354,14 +354,6 @@ UINT32 uiAdditiveLayerUsedFlags = 0xffffffff; // Array of shade values to use..... #define NUM_GLOW_FRAMES 30 -#if 0 -INT16 gsGlowFrames[] = -{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -}; -#endif INT16 gsGlowFrames[] = { @@ -1042,6 +1034,11 @@ inline UINT16 * GetShadeTable(LEVELNODE * pNode, SOLDIERTYPE * pSoldier, SOLDIER // Shade guy always lighter than scene default! { const auto GridNo = pSoldier->sGridNo; + if (GridNo == NOWHERE) + { + pShadeTable = pPaletteTable->pCurrentShade = pPaletteTable->pShades[DEFAULT_SHADE_LEVEL]; + return pShadeTable; + } UINT8 ubShadeLevel = gpWorldLevelData[GridNo].pLandHead->ubShadeLevel; // If merc is on a roof, shade according to roof brightness if (pSoldier->pathing.bLevel > 0 && gpWorldLevelData[GridNo].pRoofHead != NULL) @@ -1603,36 +1600,6 @@ void RenderTiles(UINT32 uiFlags, INT32 iStartPointX_M, INT32 iStartPointY_M, INT fRenderTile = TRUE; } - // If we are on the struct layer, check for if it's hidden! - if (uiRowFlags & (TILES_STATIC_STRUCTURES | TILES_DYNAMIC_STRUCTURES | TILES_STATIC_SHADOWS | TILES_DYNAMIC_SHADOWS)) - { - if (fUseTileElem) - { -#if 0 - // DONOT RENDER IF IT'S A HIDDEN STRUCT AND TILE IS NOT REVEALED - if (uiTileElemFlags & HIDDEN_TILE) - { - // IF WORLD IS NOT REVEALED, QUIT -#ifdef JA2EDITOR - if (!gfEditMode) -#endif - { - if (!(gpWorldLevelData[uiTileIndex].uiFlags & MAPELEMENT_REVEALED) && !(gTacticalStatus.uiFlags&SHOW_ALL_MERCS)) - { - //CONTINUE, DONOT RENDER - if (!fLinkedListDirection) - pNode = pNode->pPrevNode; - else - pNode = pNode->pNext; - - continue; - } - } - } -#endif - } - } - if (fRenderTile) { // Set flag to set layer as used @@ -9084,33 +9051,6 @@ void SetMercGlowNormal( ) -#if 0 - if ( gAnimControl[ pSoldier->usAnimState ].uiFlags & ANIM_MOVING ) - { - if ( sZOffsetY > 0 ) - { - sZOffsetY++; - } - if ( sZOffsetX > 0 ) - { - sZOffsetX++; - } - } - - sZOffsetX = pNode->pStructureData->pDBStructureRef->pDBStructure->bZTileOffsetX;\ - sZOffsetY = pNode->pStructureData->pDBStructureRef->pDBStructure->bZTileOffsetY;\ - - - if ( ( pSoldier->flags.uiStatusFlags & SOLDIER_MULTITILE ) )\ - {\ - sZOffsetX = pNode->pStructureData->pDBStructureRef->pDBStructure->bZTileOffsetX;\ - sZOffsetY = pNode->pStructureData->pDBStructureRef->pDBStructure->bZTileOffsetY;\ -\ - sWorldY = GetMapXYWorldY( sMapX + sZOffsetX, sMapY + sZOffsetY );\ - }\ - else - -#endif void SetRenderCenter( INT16 sNewX, INT16 sNewY ) diff --git a/TileEngine/structure.cpp b/TileEngine/structure.cpp index 7f8a33c06..49264a512 100644 --- a/TileEngine/structure.cpp +++ b/TileEngine/structure.cpp @@ -660,11 +660,7 @@ BOOLEAN OkayToAddStructureToTile( INT32 sBaseGridNo, INT16 sCubeOffset, DB_STRUC } ppTile = pDBStructureRef->ppTile; -#if 0//dnl ch83 080114 - sGridNo = sBaseGridNo + ppTile[ubTileIndex]->sPosRelToBase; -#else sGridNo = AddPosRelToBase(sBaseGridNo, ppTile[ubTileIndex]); -#endif if (sGridNo < 0 || sGridNo > WORLD_MAX) { return( FALSE ); @@ -835,16 +831,8 @@ BOOLEAN OkayToAddStructureToTile( INT32 sBaseGridNo, INT16 sCubeOffset, DB_STRUC } for (bLoop2 = 0; bLoop2 < pDBStructure->ubNumberOfTiles; bLoop2++) { -#if 0//dnl ch83 080114 - if ( sBaseGridNo + ppTile[bLoop2]->sPosRelToBase == sOtherGridNo) - { - // obstacle will straddle wall! - return( FALSE ); - } -#else if(AddPosRelToBase(sBaseGridNo, ppTile[bLoop2]) == sOtherGridNo) return(FALSE);// obstacle will straddle wall! -#endif } } } @@ -1107,11 +1095,7 @@ STRUCTURE * InternalAddStructureToWorld( INT32 sBaseGridNo, INT8 bLevel, DB_STRU MemFree( ppStructure ); return( NULL ); } -#if 0//dnl ch83 080114 - ppStructure[ubLoop]->sGridNo = sBaseGridNo + ppTile[ubLoop]->sPosRelToBase; -#else ppStructure[ubLoop]->sGridNo = AddPosRelToBase(sBaseGridNo, ppTile[ubLoop]); -#endif if (ubLoop != BASE_TILE) { #ifdef JA2EDITOR @@ -1319,11 +1303,7 @@ BOOLEAN DeleteStructureFromWorld( STRUCTURE * pStructure ) // Free all the tiles for (ubLoop = BASE_TILE; ubLoop < ubNumberOfTiles; ubLoop++) { -#if 0//dnl ch83 080114 - sGridNo = sBaseGridNo + ppTile[ubLoop]->sPosRelToBase; -#else sGridNo = AddPosRelToBase(sBaseGridNo, ppTile[ubLoop]); -#endif // there might be two structures in this tile, one on each level, but we just want to // delete one on each pass pCurrent = FindStructureByID( sGridNo, usStructureID ); diff --git a/TileEngine/tiledef.cpp b/TileEngine/tiledef.cpp index 8318ed462..26ca0d4c9 100644 --- a/TileEngine/tiledef.cpp +++ b/TileEngine/tiledef.cpp @@ -594,23 +594,6 @@ UINT8 gubEncryptionArray2[ BASE_NUMBER_OF_ROTATION_ARRAYS * 3 ][ NEW_ROTATION_AR }, }; -#if 0 -// These values coorespond to TerrainTypeDefines order -UINT8 gTileTypeMovementCost[ NUM_TERRAIN_TYPES ] = -{ - TRAVELCOST_FLAT, // NO_TERRAIN - TRAVELCOST_FLAT, // FLAT GROUND - TRAVELCOST_FLATFLOOR, // FLAT FLOOR - TRAVELCOST_PAVEDROAD, // PAVED ROAD - TRAVELCOST_DIRTROAD, // DIRT ROAD - TRAVELCOST_GRASS, // LOW_GRASS - TRAVELCOST_THICK, // HIGH GRASS - TRAVELCOST_TRAINTRACKS, // TRAIN TRACKS - TRAVELCOST_SHORE, // LOW WATER - TRAVELCOST_KNEEDEEP, // MED WATER - TRAVELCOST_DEEPWATER, // DEEP WATER -}; -#else // These values coorespond to TerrainTypeDefines order UINT8 gTileTypeMovementCost[ NUM_TERRAIN_TYPES ] = { @@ -626,7 +609,6 @@ UINT8 gTileTypeMovementCost[ NUM_TERRAIN_TYPES ] = TRAVELCOST_SHORE, // MED WATER TRAVELCOST_SHORE, // DEEP WATER }; -#endif ADDITIONAL_TILE_PROPERTIES_VALUES zAdditionalTileProperties; diff --git a/TileEngine/worlddef.cpp b/TileEngine/worlddef.cpp index a311df9c4..bf616f584 100644 --- a/TileEngine/worlddef.cpp +++ b/TileEngine/worlddef.cpp @@ -145,14 +145,11 @@ UINT32 gSurfaceMemUsage; //UINT8 gubWorldMovementCosts[ WORLD_MAX ][MAXDIR][2]; UINT8 (*gubWorldMovementCosts)[MAXDIR][2] = NULL;//dnl ch43 260909 -// Flugente: this stuff is only ever used in AStar pathing and is a unnecessary waste of resources otherwise, so I'm putting an end to this -#ifdef USE_ASTAR_PATHS //ddd to speed up search of illuminated tiles in PATH AI -BOOLEAN gubWorldTileInLight[ MAX_ALLOWED_WORLD_MAX ]; -BOOLEAN gubIsCorpseThere[ MAX_ALLOWED_WORLD_MAX ]; -INT32 gubMerkCanSeeThisTile[ MAX_ALLOWED_WORLD_MAX ]; +BOOLEAN gubWorldTileInLight[ MAX_ALLOWED_WORLD_MAX ]; +BOOLEAN gubIsCorpseThere[ MAX_ALLOWED_WORLD_MAX ]; +INT32 gubMerkCanSeeThisTile[ MAX_ALLOWED_WORLD_MAX ]; //ddd -#endif // set to nonzero (locs of base gridno of structure are good) to have it defined by structure code INT16 gsRecompileAreaTop = 0; @@ -2276,15 +2273,6 @@ BOOLEAN SaveWorld(const STR8 puiFilename, FLOAT dMajorMapVersion, UINT8 ubMinorM { SaveMapLights( hfile ); } -#if 0//dnl ch74 191013 from 050611 Scheinworld reported problem with basement levels and similar maps which doesn't need entry points so decide to remove this check completely - if(gMapInformation.sCenterGridNo == -1 || gMapInformation.ubEditorSmoothingType == SMOOTHING_NORMAL && (gMapInformation.sNorthGridNo == -1 && gMapInformation.sEastGridNo == -1 && gMapInformation.sSouthGridNo == -1 && gMapInformation.sWestGridNo == -1))//dnl ch17 290909 - { - swprintf(gzErrorCatchString, L"SAVE ABORTED! Center and at least one of (N,S,E,W) entry point should be set."); - gfErrorCatch = TRUE; - FileClose(hfile); - return(FALSE); - } -#endif gMapInformation.ubMapVersion = ubMinorMapVersion;//dnl ch74 241013 all this years MapInfo saves incorrect version :-( SaveMapInformation(hfile, dMajorMapVersion, ubMinorMapVersion);//dnl ch33 150909 diff --git a/TileEngine/worlddef.h b/TileEngine/worlddef.h index 0d60208e8..847d902f5 100644 --- a/TileEngine/worlddef.h +++ b/TileEngine/worlddef.h @@ -281,18 +281,6 @@ typedef struct // World Data extern MAP_ELEMENT *gpWorldLevelData; - -// Flugente: this stuff is only ever used in AStar pathing and is a unnecessary waste of resources otherwise, so I'm putting an end to this -#ifdef USE_ASTAR_PATHS -// World Movement Costs -//UINT8 gubWorldMovementCosts[ WORLD_MAX ][MAXDIR][2]; -//ddd Tables to track tactical value of grid tiles -extern BOOLEAN gubWorldTileInLight[ MAX_ALLOWED_WORLD_MAX ]; -extern BOOLEAN gubIsCorpseThere[ MAX_ALLOWED_WORLD_MAX ]; //Tracks position of corpses for AI avoidance -extern INT32 gubMerkCanSeeThisTile[ MAX_ALLOWED_WORLD_MAX ]; //Tracks visibility my mercs -//ddd -#endif - extern UINT8 (*gubWorldMovementCosts)[MAXDIR][2];//dnl ch43 260909 //dnl ch44 290909 Translation routine diff --git a/TileEngine/worldman.cpp b/TileEngine/worldman.cpp index cfba1961b..6f869e308 100644 --- a/TileEngine/worldman.cpp +++ b/TileEngine/worldman.cpp @@ -2293,10 +2293,6 @@ BOOLEAN RemoveShadow( INT32 iMapIndex, UINT16 usIndex ) { pOldShadow->pNext = pShadow->pNext; } -#if 0//#ifdef JA2EDITOR//dnl ch80 011213 //dnl ch86 190214 - if(pShadow->uiFlags & LEVELNODE_EXITGRID && pShadow->pExitGridInfo) - memset(pShadow->pExitGridInfo, 0, sizeof(EXITGRID)); -#endif // Delete memory assosiated with item MemFree( pShadow ); guiLevelNodes--; diff --git a/Utils/CMakeLists.txt b/Utils/CMakeLists.txt new file mode 100644 index 000000000..0a11b8bb2 --- /dev/null +++ b/Utils/CMakeLists.txt @@ -0,0 +1,57 @@ +set(UtilsSrc +"${CMAKE_CURRENT_SOURCE_DIR}/Animated ProgressBar.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Cinematics Bink.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Cinematics.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Cursors.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Debug Control.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/dsutil.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Encrypted File.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Event Manager.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Event Pump.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/ExportStrings.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Font Control.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/ImportStrings.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/INIReader.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/KeyMap.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/LocalizedStrings.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/MapUtility.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/MercTextBox.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/message.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Multi Language Graphic Utils.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Multilingual Text Code Generator.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Music Control.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/PopUpBox.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/popup_class.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/popup_definition.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Quantize Wrap.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Quantize.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Slider.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Sound Control.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/STIConvert.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Text Input.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Text Utils.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Timer Control.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/Utilities.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/WordWrap.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XMLProperties.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XMLWriter.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Items.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_Language.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/XML_SenderNameList.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/_ChineseText.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/_DutchText.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/_EnglishText.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/_FrenchText.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/_GermanText.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/_ItalianText.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/_Ja25ChineseText.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/_Ja25DutchText.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/_Ja25EnglishText.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/_Ja25FrenchText.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/_Ja25GermanText.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/_Ja25ItalianText.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/_Ja25PolishText.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/_Ja25RussianText.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/_PolishText.cpp" +"${CMAKE_CURRENT_SOURCE_DIR}/_RussianText.cpp" +PARENT_SCOPE) diff --git a/Utils/Cursors.cpp b/Utils/Cursors.cpp index 28c083c7d..2338d366e 100644 --- a/Utils/Cursors.cpp +++ b/Utils/Cursors.cpp @@ -1857,32 +1857,6 @@ void DrawMouseText( ) } //if ( gpItemPointer != NULL ) -#if 0 - { - if ( gpItemPointer->ubNumberOfObjects > 1 ) - { - SetFontDestBuffer( MOUSE_BUFFER , 0, 0, 64, 64, FALSE ); - - swprintf( pStr, L"x%d", gpItemPointer->ubNumberOfObjects ); - - FindFontCenterCoordinates( 0, 0, gsCurMouseWidth, gsCurMouseHeight, pStr, TINYFONT1, &sX, &sY ); - - SetFont( TINYFONT1 ); - - SetFontBackground( FONT_MCOLOR_BLACK ); - SetFontForeground( FONT_MCOLOR_WHITE ); - SetFontShadow( DEFAULT_SHADOW ); - - if ( !( gViewportRegion.uiFlags & MSYS_MOUSE_IN_AREA ) ) - { - mprintf( sX + 10, sY - 10, L"x%d", gpItemPointer->ubNumberOfObjects ); - } - - // reset - SetFontDestBuffer( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE ); - } - } -#endif } void UpdateAnimatedCursorFrames( UINT32 uiCursorIndex ) @@ -2004,51 +1978,3 @@ HVOBJECT GetCursorFileVideoObject( UINT32 uiCursorFile ) { return( CursorFileDatabase[ uiCursorFile ].hVObject ); } - - -void SyncPairedCursorFrames( UINT32 uiSrcIndex, UINT32 uiDestIndex ) -{ -#if 0 - CursorData *pSrcCurData, *pDestCurData; - CursorImage *pSrcCurImage, *pDestCurImage; - UINT32 cnt; - INT32 iCurFrame = -1; - - if ( uiSrcIndex == VIDEO_NO_CURSOR || uiDestIndex == VIDEO_NO_CURSOR ) - { - return; - } - - pSrcCurData = &( CursorDatabase[ uiSrcIndex ] ); - pDestCurData = &( CursorDatabase[ uiDestIndex ] ); - - // Get Current frame from src - for ( cnt = 0; cnt < pSrcCurData->usNumComposites; cnt++ ) - { - pSrcCurImage = &( pSrcCurData->Composites[ cnt ] ); - - if ( CursorFileDatabase[ pSrcCurImage->uiFileIndex ].fFlags & ANIMATED_CURSOR ) - { - iCurFrame = pSrcCurImage->uiCurrentFrame; - break; - } - } - - // If we are not an animated cursor, return now - if ( iCurFrame == -1 ) - { - return; - } - - // Update dest - for ( cnt = 0; cnt < pDestCurData->usNumComposites; cnt++ ) - { - pDestCurImage = &( pDestCurData->Composites[ cnt ] ); - - if ( CursorFileDatabase[ pDestCurImage->uiFileIndex ].fFlags & ANIMATED_CURSOR ) - { - pDestCurImage->uiCurrentFrame = iCurFrame; - } - } -#endif -} diff --git a/Utils/Cursors.h b/Utils/Cursors.h index 988da59c4..0a763a156 100644 --- a/Utils/Cursors.h +++ b/Utils/Cursors.h @@ -311,8 +311,6 @@ void HandleAnimatedCursors( ); void DrawMouseActionPoints( ); void UpdateAnimatedCursorFrames( UINT32 uiCursorIndex ); -void SyncPairedCursorFrames( UINT32 uiSrcCursor, UINT32 uiDestCursor ); - void SetCursorSpecialFrame( UINT32 uiCursor, UINT8 ubFrame ); void SetCursorFlags( UINT32 uiCursor, UINT8 ubFlags ); diff --git a/Utils/Font Control.cpp b/Utils/Font Control.cpp index a419c6f17..945fe2a39 100644 --- a/Utils/Font Control.cpp +++ b/Utils/Font Control.cpp @@ -93,6 +93,14 @@ UINT16 CreateFontPaletteTables(HVOBJECT pObj ); extern UINT16 gzFontName[32]; +auto GetHugeFont() -> INT32 { +#if defined(JA2EDITOR) && defined(ENGLISH) + return gpHugeFont; +#else + return gp16PointArial; +#endif +} + BOOLEAN InitializeFonts( ) { //INT16 zWinFontName[128]; // unused (jonathanl) diff --git a/Utils/Font Control.h b/Utils/Font Control.h index f0c1a6bc8..db5856cdd 100644 --- a/Utils/Font Control.h +++ b/Utils/Font Control.h @@ -89,11 +89,6 @@ extern HVOBJECT gvoBlockFontNarrow; extern INT32 gp14PointHumanist; extern HVOBJECT gvo14PointHumanist; -#ifdef JA2EDITOR -extern INT32 gpHugeFont; -extern HVOBJECT gvoHugeFont; -#endif - //extern INT32 giSubTitleWinFont; @@ -124,12 +119,7 @@ extern BOOLEAN gfFontsInit; #define BLOCKFONTNARROW gpBlockFontNarrow #define FONT14HUMANIST gp14PointHumanist -#if defined( JA2EDITOR ) && defined( ENGLISH ) - #define HUGEFONT gpHugeFont -#else - #define HUGEFONT gp16PointArial -#endif - +auto GetHugeFont() -> INT32; #define FONT_SHADE_RED 6 #define FONT_SHADE_BLUE 1 diff --git a/Utils/Sound Control.cpp b/Utils/Sound Control.cpp index 71ea2e72e..2598dc28e 100644 --- a/Utils/Sound Control.cpp +++ b/Utils/Sound Control.cpp @@ -631,40 +631,6 @@ UINT32 CalculateSoundEffectsVolume( UINT32 uiVolume ) } -#if 0 -int x,dif,absDif; - - // This function calculates the general LEFT / RIGHT direction of a gridno - // based on the middle of your screen. - - x = Gridx(gridno); - - dif = ScreenMiddleX - x; - - if ( (absDif=abs(dif)) > 32) - { - // OK, NOT the middle. - - // Is it outside the screen? - if (absDif > HalfWindowWidth) - { - // yes, outside... - if (dif > 0) - return(25); - else - return(102); - } - else // inside screen - if (dif > 0) - return(LEFTSIDE); - else - return(RIGHTSIDE); - } - else // hardly any difference, so sound should be played from middle - return(MIDDLE); - -} -#endif // == Lesh slightly changed this function ============ INT32 SoundDir( INT32 sGridNo ) diff --git a/Utils/Text Input.cpp b/Utils/Text Input.cpp index 4b50981ea..3efcb415b 100644 --- a/Utils/Text Input.cpp +++ b/Utils/Text Input.cpp @@ -751,7 +751,6 @@ BOOLEAN HandleTextInput( InputAtom *Event ) } //For any number of reasons, these ALT and CTRL combination key presses //will be processed externally -#if 1 if( Event->usKeyState & CTRL_DOWN ) { if( Event->usParam == 'c' || Event->usParam == 'C' ) @@ -786,7 +785,6 @@ BOOLEAN HandleTextInput( InputAtom *Event ) return FALSE; } } -#endif if( Event->usKeyState & ALT_DOWN || Event->usKeyState & CTRL_DOWN && Event->usParam != DEL ) return FALSE; //F1-F12 regardless of state are processed externally as well. diff --git a/Utils/Text Utils.cpp b/Utils/Text Utils.cpp index f3d156be7..757a20c73 100644 --- a/Utils/Text Utils.cpp +++ b/Utils/Text Utils.cpp @@ -11,382 +11,14 @@ BOOLEAN LoadItemInfo(UINT16 ubIndex, STR16 pNameString, STR16 pInfoString ) if (pNameString != NULL) { -#if 0 - j = -1; - for (int i=0;i<80;i++) - { - j++; - if ( j<(int)strlen(Item[ubIndex].szLongItemName )) - { - pNameString[i] = Item[ubIndex].szLongItemName [j]; - - #ifdef GERMAN - // We have a german special character - if (Item[ubIndex].szLongItemName [j] == -61) - { - // This character determines the special character - switch (Item[ubIndex].szLongItemName [j + 1]) - { - // - case -68: - pNameString[i] = 252; - // Skip next character, because "umlaute" have 2 chars - j++; - break; - // - case -100: - pNameString[i] = 220; - j++; - break; - // - case -92: - pNameString[i] = 228; - j++; - break; - // - case -124: - pNameString[i] = 196; - j++; - break; - // - case -74: - pNameString[i] = 246; - j++; - break; - // - case -106: - pNameString[i] = 214; - j++; - break; - // - case -97: - pNameString[i] = 223; - j++; - break; - } - } - #endif - - #ifdef POLISH - switch( pNameString[ i ] ) - { - case 260: pNameString[ i ] = 165; break; - case 262: pNameString[ i ] = 198; break; - case 280: pNameString[ i ] = 202; break; - case 321: pNameString[ i ] = 163; break; - case 323: pNameString[ i ] = 209; break; - case 211: pNameString[ i ] = 211; break; - - case 346: pNameString[ i ] = 338; break; - case 379: pNameString[ i ] = 175; break; - case 377: pNameString[ i ] = 143; break; - case 261: pNameString[ i ] = 185; break; - case 263: pNameString[ i ] = 230; break; - case 281: pNameString[ i ] = 234; break; - - case 322: pNameString[ i ] = 179; break; - case 324: pNameString[ i ] = 241; break; - case 243: pNameString[ i ] = 243; break; - case 347: pNameString[ i ] = 339; break; - case 380: pNameString[ i ] = 191; break; - case 378: pNameString[ i ] = 376; break; - } - #endif - - #ifdef RUSSIAN - if ((unsigned char)Item[ubIndex].szLongItemName [j] == 208) //d0 - { - // This character determines the special character - switch ( (unsigned char)Item[ubIndex].szLongItemName [j + 1] ) - { - //capital letters - case 129: pNameString[ i ] = 197; j++; break; //U+0401 d0 81 CYRILLIC CAPITAL LETTER IO - - case 144: pNameString[ i ] = 192; j++; break; //U+0410 A d0 90 CYRILLIC CAPITAL LETTER A - case 145: pNameString[ i ] = 193; j++; break; - case 146: pNameString[ i ] = 194; j++; break; - case 147: pNameString[ i ] = 195; j++; break; - case 148: pNameString[ i ] = 196; j++; break; - case 149: pNameString[ i ] = 197; j++; break; - case 150: pNameString[ i ] = 198; j++; break; - case 151: pNameString[ i ] = 199; j++; break; - case 152: pNameString[ i ] = 200; j++; break; - case 153: pNameString[ i ] = 201; j++; break; - case 154: pNameString[ i ] = 202; j++; break; - case 155: pNameString[ i ] = 203; j++; break; - case 156: pNameString[ i ] = 204; j++; break; - case 157: pNameString[ i ] = 205; j++; break; - case 158: pNameString[ i ] = 206; j++; break; - case 159: pNameString[ i ] = 207; j++; break; - case 160: pNameString[ i ] = 208; j++; break; - case 161: pNameString[ i ] = 209; j++; break; - case 162: pNameString[ i ] = 210; j++; break; - case 163: pNameString[ i ] = 211; j++; break; - case 164: pNameString[ i ] = 212; j++; break; - case 165: pNameString[ i ] = 213; j++; break; - case 166: pNameString[ i ] = 214; j++; break; - case 167: pNameString[ i ] = 215; j++; break; - case 168: pNameString[ i ] = 216; j++; break; - case 169: pNameString[ i ] = 217; j++; break; - case 170: pNameString[ i ] = 218; j++; break; - case 171: pNameString[ i ] = 219; j++; break; - case 172: pNameString[ i ] = 220; j++; break; - case 173: pNameString[ i ] = 221; j++; break; - case 174: pNameString[ i ] = 222; j++; break; - case 175: pNameString[ i ] = 223; j++; break; //U+042F d0 af CYRILLIC CAPITAL LETTER YA - - //small letters - case 176: pNameString[ i ] = 224; j++; break; //U+0430 a d0 b0 CYRILLIC SMALL LETTER A - case 177: pNameString[ i ] = 225; j++; break; - case 178: pNameString[ i ] = 226; j++; break; - case 179: pNameString[ i ] = 227; j++; break; - case 180: pNameString[ i ] = 228; j++; break; - case 181: pNameString[ i ] = 229; j++; break; - case 182: pNameString[ i ] = 230; j++; break; - case 183: pNameString[ i ] = 231; j++; break; - case 184: pNameString[ i ] = 232; j++; break; - case 185: pNameString[ i ] = 233; j++; break; - case 186: pNameString[ i ] = 234; j++; break; - case 187: pNameString[ i ] = 235; j++; break; - case 188: pNameString[ i ] = 236; j++; break; - case 189: pNameString[ i ] = 237; j++; break; - case 190: pNameString[ i ] = 238; j++; break; - case 191: pNameString[ i ] = 239; j++; break; //U+043F d0 bf CYRILLIC SMALL LETTER PE - } - } - - if ( ((unsigned char)Item[ubIndex].szLongItemName [j] == 209) ) //d1 - { - // This character determines the special character - switch ( (unsigned char)Item[ubIndex].szLongItemName [j + 1] ) - { - case 128: pNameString[ i ] = 240; j++; break; //U+0440 p d1 80 CYRILLIC SMALL LETTER ER - case 129: pNameString[ i ] = 241; j++; break; - case 130: pNameString[ i ] = 242; j++; break; - case 131: pNameString[ i ] = 243; j++; break; - case 132: pNameString[ i ] = 244; j++; break; - case 133: pNameString[ i ] = 245; j++; break; - case 134: pNameString[ i ] = 246; j++; break; - case 135: pNameString[ i ] = 247; j++; break; - case 136: pNameString[ i ] = 248; j++; break; - case 137: pNameString[ i ] = 249; j++; break; - case 138: pNameString[ i ] = 250; j++; break; - case 139: pNameString[ i ] = 251; j++; break; - case 140: pNameString[ i ] = 252; j++; break; - case 141: pNameString[ i ] = 253; j++; break; - case 142: pNameString[ i ] = 254; j++; break; - case 143: pNameString[ i ] = 255; j++; break; //U+044F d1 8f CYRILLIC SMALL LETTER YA - - case 145: pNameString[ i ] = 229; j++; break; //U+0451 d1 91 CYRILLIC SMALL LETTER IO - } - } - #endif - - } - else - { - pNameString[i] ='\0'; - } - } -#else wcsncpy( pNameString, Item[ubIndex].szLongItemName, 80); pNameString[79] ='\0'; -#endif } if(pInfoString != NULL) { -#if 0 - j = -1; - for (int i=0;i<400;i++) - { - j++; - if ( j<(int)strlen(Item[ubIndex].szItemDesc )) - { - pInfoString[i] = Item[ubIndex].szItemDesc [j]; - - #ifdef GERMAN - // We have a german special character - if (Item[ubIndex].szItemDesc [j] == -61) - { - // This character determines the special character - switch (Item[ubIndex].szItemDesc [j + 1]) - { - // - case -68: - pInfoString[i] = 252; - // Skip next character, because "umlaute" have 2 chars - j++; - break; - // - case -100: - pInfoString[i] = 220; - j++; - break; - // - case -92: - pInfoString[i] = 228; - j++; - break; - // - case -124: - pInfoString[i] = 196; - j++; - break; - // - case -74: - pInfoString[i] = 246; - j++; - break; - // - case -106: - pInfoString[i] = 214; - j++; - break; - // - case -97: - pInfoString[i] = 223; - j++; - break; - } - } - #endif - - #ifdef POLISH - switch( pNameString[ i ] ) - { - case 260: pInfoString[ i ] = 165; break; - case 262: pInfoString[ i ] = 198; break; - case 280: pInfoString[ i ] = 202; break; - case 321: pInfoString[ i ] = 163; break; - case 323: pInfoString[ i ] = 209; break; - case 211: pInfoString[ i ] = 211; break; - - case 346: pInfoString[ i ] = 338; break; - case 379: pInfoString[ i ] = 175; break; - case 377: pInfoString[ i ] = 143; break; - case 261: pInfoString[ i ] = 185; break; - case 263: pInfoString[ i ] = 230; break; - case 281: pInfoString[ i ] = 234; break; - - case 322: pInfoString[ i ] = 179; break; - case 324: pInfoString[ i ] = 241; break; - case 243: pInfoString[ i ] = 243; break; - case 347: pInfoString[ i ] = 339; break; - case 380: pInfoString[ i ] = 191; break; - case 378: pInfoString[ i ] = 376; break; - } - #endif - - - #ifdef RUSSIAN - if ((unsigned char)Item[ubIndex].szItemDesc [j] == 208) //d0 - { - // This character determines the special character - switch ( (unsigned char)Item[ubIndex].szItemDesc [j + 1] ) - { - //capital letters - case 129: pInfoString[ i ] = 197; j++; break; //U+0401 d0 81 CYRILLIC CAPITAL LETTER IO - - case 144: pInfoString[ i ] = 192; j++; break; //U+0410 A d0 90 CYRILLIC CAPITAL LETTER A - case 145: pInfoString[ i ] = 193; j++; break; - case 146: pInfoString[ i ] = 194; j++; break; - case 147: pInfoString[ i ] = 195; j++; break; - case 148: pInfoString[ i ] = 196; j++; break; - case 149: pInfoString[ i ] = 197; j++; break; - case 150: pInfoString[ i ] = 198; j++; break; - case 151: pInfoString[ i ] = 199; j++; break; - case 152: pInfoString[ i ] = 200; j++; break; - case 153: pInfoString[ i ] = 201; j++; break; - case 154: pInfoString[ i ] = 202; j++; break; - case 155: pInfoString[ i ] = 203; j++; break; - case 156: pInfoString[ i ] = 204; j++; break; - case 157: pInfoString[ i ] = 205; j++; break; - case 158: pInfoString[ i ] = 206; j++; break; - case 159: pInfoString[ i ] = 207; j++; break; - case 160: pInfoString[ i ] = 208; j++; break; - case 161: pInfoString[ i ] = 209; j++; break; - case 162: pInfoString[ i ] = 210; j++; break; - case 163: pInfoString[ i ] = 211; j++; break; - case 164: pInfoString[ i ] = 212; j++; break; - case 165: pInfoString[ i ] = 213; j++; break; - case 166: pInfoString[ i ] = 214; j++; break; - case 167: pInfoString[ i ] = 215; j++; break; - case 168: pInfoString[ i ] = 216; j++; break; - case 169: pInfoString[ i ] = 217; j++; break; - case 170: pInfoString[ i ] = 218; j++; break; - case 171: pInfoString[ i ] = 219; j++; break; - case 172: pInfoString[ i ] = 220; j++; break; - case 173: pInfoString[ i ] = 221; j++; break; - case 174: pInfoString[ i ] = 222; j++; break; - case 175: pInfoString[ i ] = 223; j++; break; //U+042F d0 af CYRILLIC CAPITAL LETTER YA - - //small letters - case 176: pInfoString[ i ] = 224; j++; break; //U+0430 a d0 b0 CYRILLIC SMALL LETTER A - case 177: pInfoString[ i ] = 225; j++; break; - case 178: pInfoString[ i ] = 226; j++; break; - case 179: pInfoString[ i ] = 227; j++; break; - case 180: pInfoString[ i ] = 228; j++; break; - case 181: pInfoString[ i ] = 229; j++; break; - case 182: pInfoString[ i ] = 230; j++; break; - case 183: pInfoString[ i ] = 231; j++; break; - case 184: pInfoString[ i ] = 232; j++; break; - case 185: pInfoString[ i ] = 233; j++; break; - case 186: pInfoString[ i ] = 234; j++; break; - case 187: pInfoString[ i ] = 235; j++; break; - case 188: pInfoString[ i ] = 236; j++; break; - case 189: pInfoString[ i ] = 237; j++; break; - case 190: pInfoString[ i ] = 238; j++; break; - case 191: pInfoString[ i ] = 239; j++; break; //U+043F d0 bf CYRILLIC SMALL LETTER PE - } - } - - if ( ((unsigned char)Item[ubIndex].szItemDesc [j] == 209) ) //d1 - { - // This character determines the special character - switch ( (unsigned char)Item[ubIndex].szItemDesc [j + 1] ) - { - case 128: pInfoString[ i ] = 240; j++; break; //U+0440 p d1 80 CYRILLIC SMALL LETTER ER - case 129: pInfoString[ i ] = 241; j++; break; - case 130: pInfoString[ i ] = 242; j++; break; - case 131: pInfoString[ i ] = 243; j++; break; - case 132: pInfoString[ i ] = 244; j++; break; - case 133: pInfoString[ i ] = 245; j++; break; - case 134: pInfoString[ i ] = 246; j++; break; - case 135: pInfoString[ i ] = 247; j++; break; - case 136: pInfoString[ i ] = 248; j++; break; - case 137: pInfoString[ i ] = 249; j++; break; - case 138: pInfoString[ i ] = 250; j++; break; - case 139: pInfoString[ i ] = 251; j++; break; - case 140: pInfoString[ i ] = 252; j++; break; - case 141: pInfoString[ i ] = 253; j++; break; - case 142: pInfoString[ i ] = 254; j++; break; - case 143: pInfoString[ i ] = 255; j++; break; //U+044F d1 8f CYRILLIC SMALL LETTER YA - - case 145: pInfoString[ i ] = 229; j++; break; //U+0451 d1 91 CYRILLIC SMALL LETTER IO - } - } - - //if ( ((unsigned char)Item[ubIndex].szItemDesc [j] == 211) ) //d3 - //{ - // // This character determines the special character - // switch ( (unsigned char)Item[ubIndex].szItemDesc [j + 1] ) - // { - // case 162: pInfoString[ i ] = 20; j++; break;//U+04E2 d3a2 CYRILLIC CAPITAL LETTER I WITH MACRON - // case 163: pInfoString[ i ] = 20; j++; break;//U+04E3 d3a3 CYRILLIC SMALL LETTER I WITH MACRON - // } - //} - #endif - } - else - { - pInfoString[i] ='\0'; - } - } -#else wcsncpy( pInfoString, Item[ubIndex].szItemDesc, 400); pInfoString[399] ='\0'; -#endif } return(TRUE); @@ -396,187 +28,8 @@ BOOLEAN LoadBRName(UINT16 ubIndex, STR16 pNameString ) { if (pNameString != NULL) { -#if 0 - int j = -1; - - for (int i=0;i<80;i++) - { - j++; - if ( j<(int)strlen(Item[ubIndex].szBRName)) - { - pNameString[i] = Item[ubIndex].szBRName [j]; - - #ifdef GERMAN - // We have a german special character - if (Item[ubIndex].szBRName [j] == -61) - { - // This character determines the special character - switch (Item[ubIndex].szBRName [j + 1]) - { - // - case -68: - pNameString[i] = 252; - // Skip next character, because "umlaute" have 2 chars - j++; - break; - // - case -100: - pNameString[i] = 220; - j++; - break; - // - case -92: - pNameString[i] = 228; - j++; - break; - // - case -124: - pNameString[i] = 196; - j++; - break; - // - case -74: - pNameString[i] = 246; - j++; - break; - // - case -106: - pNameString[i] = 214; - j++; - break; - // - case -97: - pNameString[i] = 223; - j++; - break; - } - } - #endif - - #ifdef POLISH - switch( pNameString[ i ] ) - { - case 260: pNameString[ i ] = 165; break; - case 262: pNameString[ i ] = 198; break; - case 280: pNameString[ i ] = 202; break; - case 321: pNameString[ i ] = 163; break; - case 323: pNameString[ i ] = 209; break; - case 211: pNameString[ i ] = 211; break; - - case 346: pNameString[ i ] = 338; break; - case 379: pNameString[ i ] = 175; break; - case 377: pNameString[ i ] = 143; break; - case 261: pNameString[ i ] = 185; break; - case 263: pNameString[ i ] = 230; break; - case 281: pNameString[ i ] = 234; break; - - case 322: pNameString[ i ] = 179; break; - case 324: pNameString[ i ] = 241; break; - case 243: pNameString[ i ] = 243; break; - case 347: pNameString[ i ] = 339; break; - case 380: pNameString[ i ] = 191; break; - case 378: pNameString[ i ] = 376; break; - } - #endif - - #ifdef RUSSIAN - if ((unsigned char)Item[ubIndex].szBRName [j] == 208) //d0 - { - // This character determines the special character - switch ( (unsigned char)Item[ubIndex].szBRName [j + 1] ) - { - //capital letters - case 129: pNameString[ i ] = 197; j++; break; //U+0401 d0 81 CYRILLIC CAPITAL LETTER IO - - case 144: pNameString[ i ] = 192; j++; break; //U+0410 A d0 90 CYRILLIC CAPITAL LETTER A - case 145: pNameString[ i ] = 193; j++; break; - case 146: pNameString[ i ] = 194; j++; break; - case 147: pNameString[ i ] = 195; j++; break; - case 148: pNameString[ i ] = 196; j++; break; - case 149: pNameString[ i ] = 197; j++; break; - case 150: pNameString[ i ] = 198; j++; break; - case 151: pNameString[ i ] = 199; j++; break; - case 152: pNameString[ i ] = 200; j++; break; - case 153: pNameString[ i ] = 201; j++; break; - case 154: pNameString[ i ] = 202; j++; break; - case 155: pNameString[ i ] = 203; j++; break; - case 156: pNameString[ i ] = 204; j++; break; - case 157: pNameString[ i ] = 205; j++; break; - case 158: pNameString[ i ] = 206; j++; break; - case 159: pNameString[ i ] = 207; j++; break; - case 160: pNameString[ i ] = 208; j++; break; - case 161: pNameString[ i ] = 209; j++; break; - case 162: pNameString[ i ] = 210; j++; break; - case 163: pNameString[ i ] = 211; j++; break; - case 164: pNameString[ i ] = 212; j++; break; - case 165: pNameString[ i ] = 213; j++; break; - case 166: pNameString[ i ] = 214; j++; break; - case 167: pNameString[ i ] = 215; j++; break; - case 168: pNameString[ i ] = 216; j++; break; - case 169: pNameString[ i ] = 217; j++; break; - case 170: pNameString[ i ] = 218; j++; break; - case 171: pNameString[ i ] = 219; j++; break; - case 172: pNameString[ i ] = 220; j++; break; - case 173: pNameString[ i ] = 221; j++; break; - case 174: pNameString[ i ] = 222; j++; break; - case 175: pNameString[ i ] = 223; j++; break; //U+042F d0 af CYRILLIC CAPITAL LETTER YA - - //small letters - case 176: pNameString[ i ] = 224; j++; break; //U+0430 a d0 b0 CYRILLIC SMALL LETTER A - case 177: pNameString[ i ] = 225; j++; break; - case 178: pNameString[ i ] = 226; j++; break; - case 179: pNameString[ i ] = 227; j++; break; - case 180: pNameString[ i ] = 228; j++; break; - case 181: pNameString[ i ] = 229; j++; break; - case 182: pNameString[ i ] = 230; j++; break; - case 183: pNameString[ i ] = 231; j++; break; - case 184: pNameString[ i ] = 232; j++; break; - case 185: pNameString[ i ] = 233; j++; break; - case 186: pNameString[ i ] = 234; j++; break; - case 187: pNameString[ i ] = 235; j++; break; - case 188: pNameString[ i ] = 236; j++; break; - case 189: pNameString[ i ] = 237; j++; break; - case 190: pNameString[ i ] = 238; j++; break; - case 191: pNameString[ i ] = 239; j++; break; //U+043F d0 bf CYRILLIC SMALL LETTER PE - } - } - - if ( ((unsigned char)Item[ubIndex].szBRName [j] == 209) ) //d1 - { - // This character determines the special character - switch ( (unsigned char)Item[ubIndex].szBRName [j + 1] ) - { - case 128: pNameString[ i ] = 240; j++; break; //U+0440 p d1 80 CYRILLIC SMALL LETTER ER - case 129: pNameString[ i ] = 241; j++; break; - case 130: pNameString[ i ] = 242; j++; break; - case 131: pNameString[ i ] = 243; j++; break; - case 132: pNameString[ i ] = 244; j++; break; - case 133: pNameString[ i ] = 245; j++; break; - case 134: pNameString[ i ] = 246; j++; break; - case 135: pNameString[ i ] = 247; j++; break; - case 136: pNameString[ i ] = 248; j++; break; - case 137: pNameString[ i ] = 249; j++; break; - case 138: pNameString[ i ] = 250; j++; break; - case 139: pNameString[ i ] = 251; j++; break; - case 140: pNameString[ i ] = 252; j++; break; - case 141: pNameString[ i ] = 253; j++; break; - case 142: pNameString[ i ] = 254; j++; break; - case 143: pNameString[ i ] = 255; j++; break; //U+044F d1 8f CYRILLIC SMALL LETTER YA - - case 145: pNameString[ i ] = 229; j++; break; //U+0451 d1 91 CYRILLIC SMALL LETTER IO - } - } - #endif - } - else - { - pNameString[i] ='\0'; - } - } -#else wcsncpy( pNameString, Item[ubIndex].szBRName, 80); pNameString[79] ='\0'; -#endif } return TRUE; } @@ -585,188 +38,8 @@ BOOLEAN LoadBRDesc(UINT16 ubIndex, STR16 pDescString ) { if (pDescString != NULL) { -#if 0 - int j = -1; - - for (int i=0;i<400;i++) - { - j++; - if ( j<(int)strlen(Item[ubIndex].szBRDesc)) - { - pDescString[i] = Item[ubIndex].szBRDesc [j]; - - // WANNE: German specific characters - #ifdef GERMAN - // We have a german special character - if (Item[ubIndex].szBRDesc [j] == -61) - { - // This character determines the special character - switch (Item[ubIndex].szBRDesc [j + 1]) - { - // - case -68: - pDescString[i] = 252; - // Skip next character, because "umlaute" have 2 chars - j++; - break; - // - case -100: - pDescString[i] = 220; - j++; - break; - // - case -92: - pDescString[i] = 228; - j++; - break; - // - case -124: - pDescString[i] = 196; - j++; - break; - // - case -74: - pDescString[i] = 246; - j++; - break; - // - case -106: - pDescString[i] = 214; - j++; - break; - // - case -97: - pDescString[i] = 223; - j++; - break; - } - } - #endif - - #ifdef POLISH - switch( pDescString[ i ] ) - { - case 260: pDescString[ i ] = 165; break; - case 262: pDescString[ i ] = 198; break; - case 280: pDescString[ i ] = 202; break; - case 321: pDescString[ i ] = 163; break; - case 323: pDescString[ i ] = 209; break; - case 211: pDescString[ i ] = 211; break; - - case 346: pDescString[ i ] = 338; break; - case 379: pDescString[ i ] = 175; break; - case 377: pDescString[ i ] = 143; break; - case 261: pDescString[ i ] = 185; break; - case 263: pDescString[ i ] = 230; break; - case 281: pDescString[ i ] = 234; break; - - case 322: pDescString[ i ] = 179; break; - case 324: pDescString[ i ] = 241; break; - case 243: pDescString[ i ] = 243; break; - case 347: pDescString[ i ] = 339; break; - case 380: pDescString[ i ] = 191; break; - case 378: pDescString[ i ] = 376; break; - } - #endif - - #ifdef RUSSIAN - if ((unsigned char)Item[ubIndex].szBRDesc [j] == 208) //d0 - { - // This character determines the special character - switch ( (unsigned char)Item[ubIndex].szBRDesc [j + 1] ) - { - //capital letters - case 129: pDescString[ i ] = 197; j++; break; //U+0401 d0 81 CYRILLIC CAPITAL LETTER IO - - case 144: pDescString[ i ] = 192; j++; break; //U+0410 A d0 90 CYRILLIC CAPITAL LETTER A - case 145: pDescString[ i ] = 193; j++; break; - case 146: pDescString[ i ] = 194; j++; break; - case 147: pDescString[ i ] = 195; j++; break; - case 148: pDescString[ i ] = 196; j++; break; - case 149: pDescString[ i ] = 197; j++; break; - case 150: pDescString[ i ] = 198; j++; break; - case 151: pDescString[ i ] = 199; j++; break; - case 152: pDescString[ i ] = 200; j++; break; - case 153: pDescString[ i ] = 201; j++; break; - case 154: pDescString[ i ] = 202; j++; break; - case 155: pDescString[ i ] = 203; j++; break; - case 156: pDescString[ i ] = 204; j++; break; - case 157: pDescString[ i ] = 205; j++; break; - case 158: pDescString[ i ] = 206; j++; break; - case 159: pDescString[ i ] = 207; j++; break; - case 160: pDescString[ i ] = 208; j++; break; - case 161: pDescString[ i ] = 209; j++; break; - case 162: pDescString[ i ] = 210; j++; break; - case 163: pDescString[ i ] = 211; j++; break; - case 164: pDescString[ i ] = 212; j++; break; - case 165: pDescString[ i ] = 213; j++; break; - case 166: pDescString[ i ] = 214; j++; break; - case 167: pDescString[ i ] = 215; j++; break; - case 168: pDescString[ i ] = 216; j++; break; - case 169: pDescString[ i ] = 217; j++; break; - case 170: pDescString[ i ] = 218; j++; break; - case 171: pDescString[ i ] = 219; j++; break; - case 172: pDescString[ i ] = 220; j++; break; - case 173: pDescString[ i ] = 221; j++; break; - case 174: pDescString[ i ] = 222; j++; break; - case 175: pDescString[ i ] = 223; j++; break; //U+042F d0 af CYRILLIC CAPITAL LETTER YA - - //small letters - case 176: pDescString[ i ] = 224; j++; break; //U+0430 a d0 b0 CYRILLIC SMALL LETTER A - case 177: pDescString[ i ] = 225; j++; break; - case 178: pDescString[ i ] = 226; j++; break; - case 179: pDescString[ i ] = 227; j++; break; - case 180: pDescString[ i ] = 228; j++; break; - case 181: pDescString[ i ] = 229; j++; break; - case 182: pDescString[ i ] = 230; j++; break; - case 183: pDescString[ i ] = 231; j++; break; - case 184: pDescString[ i ] = 232; j++; break; - case 185: pDescString[ i ] = 233; j++; break; - case 186: pDescString[ i ] = 234; j++; break; - case 187: pDescString[ i ] = 235; j++; break; - case 188: pDescString[ i ] = 236; j++; break; - case 189: pDescString[ i ] = 237; j++; break; - case 190: pDescString[ i ] = 238; j++; break; - case 191: pDescString[ i ] = 239; j++; break; //U+043F d0 bf CYRILLIC SMALL LETTER PE - } - } - - if ( ((unsigned char)Item[ubIndex].szBRDesc [j] == 209) ) //d1 - { - // This character determines the special character - switch ( (unsigned char)Item[ubIndex].szBRDesc [j + 1] ) - { - case 128: pDescString[ i ] = 240; j++; break; //U+0440 p d1 80 CYRILLIC SMALL LETTER ER - case 129: pDescString[ i ] = 241; j++; break; - case 130: pDescString[ i ] = 242; j++; break; - case 131: pDescString[ i ] = 243; j++; break; - case 132: pDescString[ i ] = 244; j++; break; - case 133: pDescString[ i ] = 245; j++; break; - case 134: pDescString[ i ] = 246; j++; break; - case 135: pDescString[ i ] = 247; j++; break; - case 136: pDescString[ i ] = 248; j++; break; - case 137: pDescString[ i ] = 249; j++; break; - case 138: pDescString[ i ] = 250; j++; break; - case 139: pDescString[ i ] = 251; j++; break; - case 140: pDescString[ i ] = 252; j++; break; - case 141: pDescString[ i ] = 253; j++; break; - case 142: pDescString[ i ] = 254; j++; break; - case 143: pDescString[ i ] = 255; j++; break; //U+044F d1 8f CYRILLIC SMALL LETTER YA - - case 145: pDescString[ i ] = 229; j++; break; //U+0451 d1 91 CYRILLIC SMALL LETTER IO - } - } - #endif - } - else - { - pDescString[i] ='\0'; - } - } -#else wcsncpy( pDescString, Item[ubIndex].szBRDesc, 400); pDescString[399] ='\0'; -#endif } return TRUE; @@ -776,192 +49,8 @@ BOOLEAN LoadShortNameItemInfo(UINT16 ubIndex, STR16 pNameString ) { if(pNameString != NULL) { -#if 0 - int j = -1; - - for (int i=0;i<80;i++) - { - j++; - - if ( i<(int)wcslen(Item[ubIndex].szItemName)) - { - pNameString[i] = Item[ubIndex].szItemName [j]; - - // WANNE: German specific characters - #ifdef GERMAN - // We have a german special character - if (Item[ubIndex].szItemName [j] == -61) - { - // This character determines the special character - switch (Item[ubIndex].szItemName [j + 1]) - { - // - case -68: - pNameString[i] = 252; - // Skip next character, because "umlaute" have 2 chars - j++; - break; - // - case -100: - pNameString[i] = 220; - j++; - break; - // - case -92: - pNameString[i] = 228; - j++; - break; - // - case -124: - pNameString[i] = 196; - j++; - break; - // - case -74: - pNameString[i] = 246; - j++; - break; - // - case -106: - pNameString[i] = 214; - j++; - break; - // - case -97: - pNameString[i] = 223; - j++; - break; - } - } - #endif - - #ifdef POLISH - switch( pNameString[ i ] ) - { - case 260: pNameString[ i ] = 165; break; - case 262: pNameString[ i ] = 198; break; - case 280: pNameString[ i ] = 202; break; - case 321: pNameString[ i ] = 163; break; - case 323: pNameString[ i ] = 209; break; - case 211: pNameString[ i ] = 211; break; - - case 346: pNameString[ i ] = 338; break; - case 379: pNameString[ i ] = 175; break; - case 377: pNameString[ i ] = 143; break; - case 261: pNameString[ i ] = 185; break; - case 263: pNameString[ i ] = 230; break; - case 281: pNameString[ i ] = 234; break; - - case 322: pNameString[ i ] = 179; break; - case 324: pNameString[ i ] = 241; break; - case 243: pNameString[ i ] = 243; break; - case 347: pNameString[ i ] = 339; break; - case 380: pNameString[ i ] = 191; break; - case 378: pNameString[ i ] = 376; break; - } - #endif - - - - #ifdef RUSSIAN - if ((unsigned char)Item[ubIndex].szItemName [j] == 208) //d0 - { - // This character determines the special character - switch ( (unsigned char)Item[ubIndex].szItemName [j + 1] ) - { - //capital letters - case 129: pNameString[ i ] = 197; j++; break; //U+0401 d0 81 CYRILLIC CAPITAL LETTER IO - - case 144: pNameString[ i ] = 192; j++; break; //U+0410 A d0 90 CYRILLIC CAPITAL LETTER A - case 145: pNameString[ i ] = 193; j++; break; - case 146: pNameString[ i ] = 194; j++; break; - case 147: pNameString[ i ] = 195; j++; break; - case 148: pNameString[ i ] = 196; j++; break; - case 149: pNameString[ i ] = 197; j++; break; - case 150: pNameString[ i ] = 198; j++; break; - case 151: pNameString[ i ] = 199; j++; break; - case 152: pNameString[ i ] = 200; j++; break; - case 153: pNameString[ i ] = 201; j++; break; - case 154: pNameString[ i ] = 202; j++; break; - case 155: pNameString[ i ] = 203; j++; break; - case 156: pNameString[ i ] = 204; j++; break; - case 157: pNameString[ i ] = 205; j++; break; - case 158: pNameString[ i ] = 206; j++; break; - case 159: pNameString[ i ] = 207; j++; break; - case 160: pNameString[ i ] = 208; j++; break; - case 161: pNameString[ i ] = 209; j++; break; - case 162: pNameString[ i ] = 210; j++; break; - case 163: pNameString[ i ] = 211; j++; break; - case 164: pNameString[ i ] = 212; j++; break; - case 165: pNameString[ i ] = 213; j++; break; - case 166: pNameString[ i ] = 214; j++; break; - case 167: pNameString[ i ] = 215; j++; break; - case 168: pNameString[ i ] = 216; j++; break; - case 169: pNameString[ i ] = 217; j++; break; - case 170: pNameString[ i ] = 218; j++; break; - case 171: pNameString[ i ] = 219; j++; break; - case 172: pNameString[ i ] = 220; j++; break; - case 173: pNameString[ i ] = 221; j++; break; - case 174: pNameString[ i ] = 222; j++; break; - case 175: pNameString[ i ] = 223; j++; break; //U+042F d0 af CYRILLIC CAPITAL LETTER YA - - //small letters - case 176: pNameString[ i ] = 224; j++; break; //U+0430 a d0 b0 CYRILLIC SMALL LETTER A - case 177: pNameString[ i ] = 225; j++; break; - case 178: pNameString[ i ] = 226; j++; break; - case 179: pNameString[ i ] = 227; j++; break; - case 180: pNameString[ i ] = 228; j++; break; - case 181: pNameString[ i ] = 229; j++; break; - case 182: pNameString[ i ] = 230; j++; break; - case 183: pNameString[ i ] = 231; j++; break; - case 184: pNameString[ i ] = 232; j++; break; - case 185: pNameString[ i ] = 233; j++; break; - case 186: pNameString[ i ] = 234; j++; break; - case 187: pNameString[ i ] = 235; j++; break; - case 188: pNameString[ i ] = 236; j++; break; - case 189: pNameString[ i ] = 237; j++; break; - case 190: pNameString[ i ] = 238; j++; break; - case 191: pNameString[ i ] = 239; j++; break; //U+043F d0 bf CYRILLIC SMALL LETTER PE - } - } - - if ( ((unsigned char)Item[ubIndex].szItemName [j] == 209) ) //d1 - { - // This character determines the special character - switch ( (unsigned char)Item[ubIndex].szItemName [j + 1] ) - { - case 128: pNameString[ i ] = 240; j++; break; //U+0440 p d1 80 CYRILLIC SMALL LETTER ER - case 129: pNameString[ i ] = 241; j++; break; - case 130: pNameString[ i ] = 242; j++; break; - case 131: pNameString[ i ] = 243; j++; break; - case 132: pNameString[ i ] = 244; j++; break; - case 133: pNameString[ i ] = 245; j++; break; - case 134: pNameString[ i ] = 246; j++; break; - case 135: pNameString[ i ] = 247; j++; break; - case 136: pNameString[ i ] = 248; j++; break; - case 137: pNameString[ i ] = 249; j++; break; - case 138: pNameString[ i ] = 250; j++; break; - case 139: pNameString[ i ] = 251; j++; break; - case 140: pNameString[ i ] = 252; j++; break; - case 141: pNameString[ i ] = 253; j++; break; - case 142: pNameString[ i ] = 254; j++; break; - case 143: pNameString[ i ] = 255; j++; break; //U+044F d1 8f CYRILLIC SMALL LETTER YA - - case 145: pNameString[ i ] = 229; j++; break; //U+0451 d1 91 CYRILLIC SMALL LETTER IO - } - } - #endif - - } - else - { - pNameString[i] ='\0'; - } - } -#else wcsncpy( pNameString, Item[ubIndex].szItemName, 80 ); pNameString[79] ='\0'; -#endif } return(TRUE); diff --git a/Utils/Text.h b/Utils/Text.h index 2ed7ca035..25dabaeb1 100644 --- a/Utils/Text.h +++ b/Utils/Text.h @@ -886,6 +886,8 @@ enum STR_PRISONER_DETECTION_VIP, STR_PRISONER_REFUSE_SURRENDER_LEADER, STR_PRISONER_TURN_VOLUNTEER, + STR_PRISONER_ESCAPE, + STR_PRISONER_NO_ESCAPE, TEXT_NUM_PRISONER_STR }; diff --git a/Utils/Utilities.cpp b/Utils/Utilities.cpp index 8b6836c75..a2634b5fb 100644 --- a/Utils/Utilities.cpp +++ b/Utils/Utilities.cpp @@ -393,115 +393,18 @@ BOOLEAN HandleJA2CDCheck( ) #endif -#ifdef NOCDCHECK return( TRUE ); -#else - BOOLEAN fFailed = FALSE; - CHAR8 zCdLocation[ SGPFILENAME_LEN ]; - CHAR8 zCdFile[ SGPFILENAME_LEN ]; - INT32 cnt; - HWFILE hFile; - - // Check for a file on CD.... - if( GetCDromDriveLetter( zCdLocation ) ) - { - for ( cnt = 0; cnt < 5; cnt++ ) - { - // OK, build filename - sprintf( zCdFile, "%s%s", zCdLocation, gCheckFilenames[ cnt ] ); - - hFile = FileOpen( zCdFile, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - - // Check if it exists... - if ( !hFile ) - { - fFailed = TRUE; - FileClose( hFile ); - break; - } - - // Check min size -//#ifndef GERMAN -// if ( FileGetSize( hFile ) < gCheckFileMinSizes[ cnt ] ) -// { -// fFailed = TRUE; -// FileClose( hFile ); -// break; -// } -//#endif - - FileClose( hFile ); - - } - } - else - { - fFailed = TRUE; - } - - if ( fFailed ) - { - CHAR8 zErrorMessage[256]; - - sprintf( zErrorMessage, "%S", gzLateLocalizedString[ 56 ] ); - // Pop up message boc and get answer.... - if ( MessageBox( NULL, zErrorMessage, "Jagged Alliance 2 v1.13", MB_OK ) == IDOK ) - { - return( FALSE ); - } - } - - return( TRUE ); - -#endif } BOOLEAN HandleJA2CDCheckTwo( ) { -#ifdef NOCDCHECK return( TRUE ); -#else - BOOLEAN fFailed = TRUE; - CHAR8 zCdLocation[ SGPFILENAME_LEN ]; - CHAR8 zCdFile[ SGPFILENAME_LEN ]; - - // Check for a file on CD.... - if( GetCDromDriveLetter( zCdLocation ) ) - { - // OK, build filename - sprintf( zCdFile, "%s%s", zCdLocation, gCheckFilenames[ Random( 2 ) ] ); - - // Check if it exists... - if ( FileExists( zCdFile ) ) - { - fFailed = FALSE; - } - } - - if ( fFailed ) - { - CHAR8 zErrorMessage[256]; - - sprintf( zErrorMessage, "%S", gzLateLocalizedString[ 56 ] ); - // Pop up message boc and get answer.... - if ( MessageBox( NULL, zErrorMessage, "Jagged Alliance 2 v1.13", MB_OK ) == IDOK ) - { - return( FALSE ); - } - } - else - { - return( TRUE ); - } - - return( FALSE ); -#endif } diff --git a/Utils/XML_Items.cpp b/Utils/XML_Items.cpp index ce4cac81f..7a576d561 100644 --- a/Utils/XML_Items.cpp +++ b/Utils/XML_Items.cpp @@ -384,9 +384,6 @@ static void XMLCALL itemEndElementHandle(void *userData, const XML_Char *name) { itemParseData * pData = (itemParseData *)userData; -#if 0 - char temp; -#endif if(pData->currentDepth <= pData->maxReadDepth) //we're at the end of an element that we've been reading { @@ -438,136 +435,40 @@ itemEndElementHandle(void *userData, const XML_Char *name) // pData->curItem.szItemName[MAX_CHAR_DATA_LENGTH] = '\0'; //} -#if 0 - if(MAX_CHAR_DATA_LENGTH >= strlen(pData->szCharData)) - strcpy(pData->curItem.szItemName,pData->szCharData); - else - { - strncpy(pData->curItem.szItemName,pData->szCharData,MAX_CHAR_DATA_LENGTH); - pData->curItem.szItemName[MAX_CHAR_DATA_LENGTH] = '\0'; - } - - for(int i=0;iszCharData),MAX_CHAR_DATA_LENGTH);i++) - { - temp = pData->szCharData[i]; - pData->curItem.szItemName[i] = temp; - //DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("itemEndElementHandle: itemname[%d] = %s, temp = %s",i,&pData->curItem.szItemName[i],&temp)); - } -#else MultiByteToWideChar( CP_UTF8, 0, pData->szCharData, -1, pData->curItem.szItemName, sizeof(pData->curItem.szItemName)/sizeof(pData->curItem.szItemName[0]) ); pData->curItem.szItemName[sizeof(pData->curItem.szItemName)/sizeof(pData->curItem.szItemName[0]) - 1] = '\0'; -#endif } else if(strcmp(name, "szLongItemName") == 0) { //DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"itemEndElementHandle: longitemname"); pData->curElement = ELEMENT; -#if 0 - if(MAX_CHAR_DATA_LENGTH >= strlen(pData->szCharData)) - { - strcpy(pData->curItem.szLongItemName,pData->szCharData); - } - else - { - strncpy(pData->curItem.szLongItemName,pData->szCharData,MAX_CHAR_DATA_LENGTH); - pData->curItem.szLongItemName[MAX_CHAR_DATA_LENGTH] = '\0'; - } - - for(int i=0;iszCharData),MAX_CHAR_DATA_LENGTH);i++) - { - temp = pData->szCharData[i]; - pData->curItem.szLongItemName[i] = temp; - //DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("itemEndElementHandle: longitemname[%d] = %s, temp = %s",i,&pData->curItem.szLongItemName[i],&temp)); - } - //if(MAX_CHAR_DATA_LENGTH >= strlen(pData->szCharData)) - //{ - // strcpy(pData->curItem.szLongItemName,pData->szCharData); - //} - //else - //{ - // strncpy(pData->curItem.szLongItemName,pData->szCharData,MAX_CHAR_DATA_LENGTH); - // pData->curItem.szLongItemName[MAX_CHAR_DATA_LENGTH] = '\0'; - //} -#else MultiByteToWideChar( CP_UTF8, 0, pData->szCharData, -1, pData->curItem.szLongItemName, sizeof(pData->curItem.szLongItemName)/sizeof(pData->curItem.szLongItemName[0]) ); pData->curItem.szLongItemName[sizeof(pData->curItem.szLongItemName)/sizeof(pData->curItem.szLongItemName[0]) - 1] = '\0'; -#endif } else if(strcmp(name, "szItemDesc") == 0) { //DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"itemEndElementHandle: itemdesc"); pData->curElement = ELEMENT; -#if 0 - if(MAX_CHAR_DATA_LENGTH >= strlen(pData->szCharData)) - strcpy(pData->curItem.szItemDesc,pData->szCharData); - else - { - strncpy(pData->curItem.szItemDesc,pData->szCharData,MAX_CHAR_DATA_LENGTH); - pData->curItem.szItemDesc[MAX_CHAR_DATA_LENGTH] = '\0'; - } - - for(int i=0;iszCharData),MAX_CHAR_DATA_LENGTH);i++) - { - temp = pData->szCharData[i]; - pData->curItem.szItemDesc[i] = temp; - //DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("itemEndElementHandle: itemdesc[%d] = %s, temp = %s",i,&pData->curItem.szItemDesc[i],&temp)); - } -#else MultiByteToWideChar( CP_UTF8, 0, pData->szCharData, -1, pData->curItem.szItemDesc, sizeof(pData->curItem.szItemDesc)/sizeof(pData->curItem.szItemDesc[0]) ); pData->curItem.szItemDesc[sizeof(pData->curItem.szItemDesc)/sizeof(pData->curItem.szItemDesc[0]) - 1] = '\0'; -#endif } else if(strcmp(name, "szBRName") == 0) { //DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"itemEndElementHandle: brname"); pData->curElement = ELEMENT; -#if 0 - if(MAX_CHAR_DATA_LENGTH >= strlen(pData->szCharData)) - strcpy(pData->curItem.szBRName,pData->szCharData); - else - { - strncpy(pData->curItem.szBRName,pData->szCharData,MAX_CHAR_DATA_LENGTH); - pData->curItem.szBRName[MAX_CHAR_DATA_LENGTH] = '\0'; - } - - for(int i=0;iszCharData),MAX_CHAR_DATA_LENGTH);i++) - { - temp = pData->szCharData[i]; - pData->curItem.szBRName[i] = temp; - //DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("itemEndElementHandle: BRname[%d] = %s, temp = %s",i,&pData->curItem.szBRName[i],&temp)); - } -#else MultiByteToWideChar( CP_UTF8, 0, pData->szCharData, -1, pData->curItem.szBRName, sizeof(pData->curItem.szBRName)/sizeof(pData->curItem.szBRName[0]) ); pData->curItem.szBRName[sizeof(pData->curItem.szBRName)/sizeof(pData->curItem.szBRName[0]) - 1] = '\0'; -#endif } else if(strcmp(name, "szBRDesc") == 0) { //DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"itemEndElementHandle: brdesc"); pData->curElement = ELEMENT; -#if 0 - if(MAX_CHAR_DATA_LENGTH >= strlen(pData->szCharData)) - strcpy(pData->curItem.szBRDesc,pData->szCharData); - else - { - strncpy(pData->curItem.szBRDesc,pData->szCharData,MAX_CHAR_DATA_LENGTH); - pData->curItem.szBRDesc[MAX_CHAR_DATA_LENGTH] = '\0'; - } - - for(int i=0;iszCharData),MAX_CHAR_DATA_LENGTH);i++) - { - temp = pData->szCharData[i]; - pData->curItem.szBRDesc[i] = temp; - //DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("itemEndElementHandle: BRdesc[%d] = %s, temp = %s",i,&pData->curItem.szBRDesc[i],&temp)); - } -#else MultiByteToWideChar( CP_UTF8, 0, pData->szCharData, -1, pData->curItem.szBRDesc, sizeof(pData->curItem.szBRDesc)/sizeof(pData->curItem.szBRDesc[0]) ); pData->curItem.szBRDesc[sizeof(pData->curItem.szBRDesc)/sizeof(pData->curItem.szBRDesc[0]) - 1] = '\0'; -#endif } else if(strcmp(name, "usItemClass") == 0) { diff --git a/Utils/_ChineseText.cpp b/Utils/_ChineseText.cpp index 8ab30522e..695fc5929 100644 --- a/Utils/_ChineseText.cpp +++ b/Utils/_ChineseText.cpp @@ -6532,7 +6532,7 @@ STR16 zOptionsToggleText[] = L"实时确认", //"Real Time Confirmation", L"显示睡觉/醒来时的提示", //"Display sleep/wake notifications", L"使用公制系统", //"Use Metric System", - L"佣兵移动时高亮显示", //"Merc Lights during Movement", + L"佣兵假光", //"Highlight Mercs", L"锁定佣兵", //"Snap Cursor to Mercs", L"锁定门", //"Snap Cursor to Doors", L"物品闪亮", //"Make Items Glow", @@ -6574,6 +6574,8 @@ STR16 zOptionsToggleText[] = L"反转鼠标滚轮", //L"Invert mouse wheel", L"保持佣兵间距", // when multiple mercs are selected, they will try to keep their relative distances L"显示已知敌人位置", //L"Show enemy location", show locator on last known enemy location + L"Start at maximum aim", + L"Alternative pathfinding", L"--作弊模式选项--", // TOPTION_CHEAT_MODE_OPTIONS_HEADER, L"强制 Bobby Ray 送货", // force all pending Bobby Ray shipments L"-----------------", // TOPTION_CHEAT_MODE_OPTIONS_END @@ -6634,8 +6636,8 @@ STR16 zOptionsScreenHelpText[] = //Use the metric system L"打开时,使用公制系统,否则使用英制系统。", - //Merc Lighted movement - L"打开时,佣兵移动时会照亮地表,切换虚拟佣兵光照。(|G)\n(关闭这个选项会使游戏的显示速度变快)", + //Highlight Mercs + L"打开时,切换虚拟佣兵照明。(|G)", //Smart cursor L"打开时,光标移动到佣兵身上时会高亮显示佣兵。", @@ -6693,6 +6695,8 @@ STR16 zOptionsScreenHelpText[] = L"打开时,反转鼠标滚轮方向。", L"打开时,当选择多个佣兵,在前进时会保持彼此的间距。|C|t|r|l+|A|l|t+|G \n(按|S|h|i|f|t+点击人物头像可以加入或移出队伍)", //L"When ON and multiple mercs are selected, they will try to keep their relative distances while moving.\n(press |C|t|r|l+|A|l|t+|G to toggle mode or |S|h|i|f|t + click to move in formation)", TODO.Translate L"打开时,会显示已知敌人最后移动的位置。", //L"When ON, shows last known enemy location.", + L"When ON, aiming at enemy will start at maximum aiming instead of default no aim", + L"When ON, Use A* pathfinding algorithm, instead of original", L"(text not rendered)TOPTION_CHEAT_MODE_OPTIONS_HEADER", L"强制 Bobby Ray 出货", L"(text not rendered)TOPTION_CHEAT_MODE_OPTIONS_END", @@ -9194,6 +9198,8 @@ STR16 szPrisonerTextStr[]= L"一个高阶军官%s被发现!", //L"A high-ranking army officer in %s has been revealed!", L"敌方领袖拒绝考虑投降!", //L"The enemy leader refuses to even consider surrender!", L"%d名囚犯自愿加入我军。", //L"%d prisoners volunteered to join our forces.", + L"Some of your mercs managed to escape the enemy capture!", + L"No possible escape is seen, it's a fight to the death!" }; STR16 szMTATextStr[]= diff --git a/Utils/_DutchText.cpp b/Utils/_DutchText.cpp index 97a534ed2..77e4cba5b 100644 --- a/Utils/_DutchText.cpp +++ b/Utils/_DutchText.cpp @@ -6534,7 +6534,7 @@ STR16 zOptionsToggleText[] = L"Bevestiging Real-Time", L"Slaap/wakker-berichten", L"Metrieke Stelsel", - L"Huurling Oplichten", + L"Licht Huurlingen Op", L"Auto-Cursor naar Huurling", L"Auto-Cursor naar Deuren", L"Items Oplichten", @@ -6576,6 +6576,8 @@ STR16 zOptionsToggleText[] = L"Invert mouse wheel", // TODO.Translate L"Formation Movement", // when multiple mercs are selected, they will try to keep their relative distances // TODO.Translate L"Show enemy location", // show locator on last known enemy location + L"Start at maximum aim", + L"Alternative pathfinding", L"--Cheat Mode Options--", // TOPTION_CHEAT_MODE_OPTIONS_HEADER, L"Force Bobby Ray shipments", // force all pending Bobby Ray shipments L"-----------------", // TOPTION_CHEAT_MODE_OPTIONS_END @@ -6636,8 +6638,8 @@ STR16 zOptionsScreenHelpText[] = //Use the metric system L"Wanneer INGESCHAKELD wordt het metrieke stelsel gebruikt, anders het Imperiale stelsel.", - //Merc Lighted movement - L"Wanneer INGESCHAKELD, de huurling verlicht de grond tijdens het lopen. Schakel UIT voor sneller spelen.\nToggle artificial merc light. (|G)", // TODO.Translate + //Highlight Mercs + L"Wanneer INGESCHAKELD, wordt de huurling gemarkeerd (niet zichtbaar voor vijanden).\nSchakel in het spel met (|G)", //Smart cursor L"Wanneer INGESCHAKELD zullen huurlingen dichtbij de cursor automatisch oplichten.", @@ -6695,6 +6697,8 @@ STR16 zOptionsScreenHelpText[] = L"When ON, inverts mouse wheel directions.", // TODO.Translate L"When ON and multiple mercs are selected, they will try to keep their relative distances while moving.\n(press |C|t|r|l+|A|l|t+|G to toggle mode or |S|h|i|f|t + click to move in formation)", //TODO.Translate L"When ON, shows last known enemy location.", //TODO.Translate + L"When ON, aiming at enemy will start at maximum aiming instead of default no aim", + L"When ON, Use A* pathfinding algorithm, instead of original", L"(text not rendered)TOPTION_CHEAT_MODE_OPTIONS_HEADER", L"Force all pending Bobby Ray shipments", L"(text not rendered)TOPTION_CHEAT_MODE_OPTIONS_END", @@ -9205,6 +9209,8 @@ STR16 szPrisonerTextStr[]= L"A high-ranking army officer in %s has been revealed!", // TODO.Translate L"The enemy leader refuses to even consider surrender!", L"%d prisoners volunteered to join our forces.", + L"Some of your mercs managed to escape the enemy capture!", + L"No possible escape is seen, it's a fight to the death!" }; STR16 szMTATextStr[]= // TODO.Translate diff --git a/Utils/_EnglishText.cpp b/Utils/_EnglishText.cpp index d56f2cbf0..bc75fc678 100644 --- a/Utils/_EnglishText.cpp +++ b/Utils/_EnglishText.cpp @@ -6532,7 +6532,7 @@ STR16 zOptionsToggleText[] = L"Real Time Confirmation", L"Sleep/Wake Notifications", L"Use Metric System", - L"Merc Lights during Movement", + L"Highlight Mercs", L"Snap Cursor to Mercs", L"Snap Cursor to Doors", L"Make Items Glow", @@ -6574,6 +6574,8 @@ STR16 zOptionsToggleText[] = L"Invert Mouse Wheel", L"Formation Movement", // when multiple mercs are selected, they will try to keep their relative distances L"Show enemy location", // show locator on last known enemy location + L"Start at maximum aim", + L"Alternative pathfinding", L"--Cheat Mode Options--", // TOPTION_CHEAT_MODE_OPTIONS_HEADER, L"Force Bobby Ray Shipments", // force all pending Bobby Ray shipments L"-----------------", // TOPTION_CHEAT_MODE_OPTIONS_END @@ -6634,8 +6636,8 @@ STR16 zOptionsScreenHelpText[] = //Use the metric system L"When ON, uses the metric system for measurements; otherwise it uses the Imperial system.", - //Merc Lighted movement - L"When ON, the merc will light the ground while walking. Turn OFF for faster frame rate.\nToggle artificial merc light. (|G)", + //Highlight Mercs + L"When ON, highlights the mercenary (Not visible to enemies).\nToggle in-game with (|G)", //Smart cursor L"When ON, moving the cursor near your mercs will automatically highlight them.", @@ -6693,6 +6695,8 @@ STR16 zOptionsScreenHelpText[] = L"When ON, inverts mouse wheel directions.", L"When ON and multiple mercs are selected, they will try to keep their relative distances while moving.\n(press |C|t|r|l+|A|l|t+|G to toggle mode or |S|h|i|f|t + click to move in formation)", L"When ON, shows last known enemy location.", + L"When ON, aiming at enemy will start at maximum aiming instead of default no aim", + L"When ON, Use A* pathfinding algorithm, instead of original", L"(text not rendered)TOPTION_CHEAT_MODE_OPTIONS_HEADER", L"Force all pending Bobby Ray shipments", L"(text not rendered)TOPTION_CHEAT_MODE_OPTIONS_END", @@ -9194,6 +9198,8 @@ STR16 szPrisonerTextStr[]= L"A high-ranking army officer in %s has been revealed!", L"The enemy leader refuses to even consider surrender!", L"%d prisoners volunteered to join our forces.", + L"Some of your mercs managed to escape the enemy capture!", + L"No possible escape is seen, it's a fight to the death!" }; STR16 szMTATextStr[]= diff --git a/Utils/_FrenchText.cpp b/Utils/_FrenchText.cpp index 07bacfb1f..dc183be94 100644 --- a/Utils/_FrenchText.cpp +++ b/Utils/_FrenchText.cpp @@ -1778,7 +1778,7 @@ STR16 pShowHighGroundText[] = }; //Item Statistics.cpp -CHAR16 gszActionItemDesc[ 34 ][ 30 ] = // NUM_ACTIONITEMS = 34 +/*CHAR16 gszActionItemDesc[34][30] = // NUM_ACTIONITEMS = 34 { L"Mine klaxon", L"Mine Flash", @@ -1815,9 +1815,9 @@ CHAR16 gszActionItemDesc[ 34 ][ 30 ] = // NUM_ACTIONITEMS = 34 L"Alarme chtsvg", L"Grd lacrymo", }; +*/ + -//Item Statistics.cpp -/* STR16 pUpdateItemStatsPanelText[] = { L"Drapeaux M./A.", //0 @@ -1849,7 +1849,7 @@ STR16 pUpdateItemStatsPanelText[] = L"R", L"S", }; -*/ + STR16 pSetupGameTypeFlagsText[] = { @@ -6539,7 +6539,7 @@ STR16 zOptionsToggleText[] = L"Confirmation temps réel", L"Notifications sommeil/réveil", L"Système métrique", - L"Mouvemts mercenaires éclairés", + L"Mettez en surbrillance les mercenaires", L"Figer curseur sur mercenaires", L"Figer curseur sur les portes", L"Objets en surbrillance", @@ -6581,6 +6581,8 @@ STR16 zOptionsToggleText[] = L"Inverser molette/souris", L"Déplacement tactique", // when multiple mercs are selected, they will try to keep their relative distances L"Show enemy location", // show locator on last known enemy location + L"Start at maximum aim", + L"Alternative pathfinding", L"--Options mode triche--", // TOPTION_CHEAT_MODE_OPTIONS_HEADER, L"Forcer envois Bobby Ray", // force all pending Bobby Ray shipments L"-----------------", // TOPTION_CHEAT_MODE_OPTIONS_END @@ -6641,8 +6643,8 @@ STR16 zOptionsScreenHelpText[] = //Use the metric system L"Activez cette option pour que le jeu utilise le système métrique.", - //Merc Lighted movement - L"Activez cette option pour éclairer les environs des mercenaires.Désactivez-la, si votre machine n'est pas suffisamment puissante.\nBasculera éclairage du mercenaire. (|G)", + //Highlight Mercs + L"Lorsqu'il est activé, le mercenaire est mis en surbrillance (invisible pour les ennemis).\nBasculer dans le jeu avec (|G)", //Smart cursor L"Activez cette option pour que le curseur se positionne directement sur un mercenaire quand il est à proximité.", @@ -6699,6 +6701,8 @@ STR16 zOptionsScreenHelpText[] = L"Si activé, inverse le sens de la molette de la souris.", L"When ON and multiple mercs are selected, they will try to keep their relative distances while moving.\n(press |C|t|r|l+|A|l|t+|G to toggle mode or |S|h|i|f|t + click to move in formation)", //TODO.Translate L"When ON, shows last known enemy location.", //TODO.Translate + L"When ON, aiming at enemy will start at maximum aiming instead of default no aim", + L"When ON, Use A* pathfinding algorithm, instead of original", L"(text not rendered)TOPTION_CHEAT_MODE_OPTIONS_HEADER", L"Forcer tous les envois en attente de Bobby Ray", L"(text not rendered)TOPTION_CHEAT_MODE_OPTIONS_END", @@ -9187,6 +9191,8 @@ STR16 szPrisonerTextStr[]= L"A high-ranking army officer in %s has been revealed!", // TODO.Translate L"The enemy leader refuses to even consider surrender!", L"%d prisoners volunteered to join our forces.", + L"Some of your mercs managed to escape the enemy capture!", + L"No possible escape is seen, it's a fight to the death!" }; STR16 szMTATextStr[]= diff --git a/Utils/_GermanText.cpp b/Utils/_GermanText.cpp index ccfa579f9..d2d6009a3 100644 --- a/Utils/_GermanText.cpp +++ b/Utils/_GermanText.cpp @@ -6405,7 +6405,7 @@ STR16 zOptionsToggleText[] = L"Bestätigung bei Echtzeit", L"Schlaf-/Wachmeldung anzeigen", L"Metrisches System benutzen", - L"Boden beleuchten", + L"Markieren Sie Söldner", L"Cursor autom. auf Söldner", L"Cursor autom. auf Türen", L"Gegenstände leuchten", @@ -6447,6 +6447,8 @@ STR16 zOptionsToggleText[] = L"Mausradrichtung umkehren", L"Bewegung in Formation", // when multiple mercs are selected, they will try to keep their relative distances L"Show enemy location", // show locator on last known enemy location + L"Start at maximum aim", + L"Alternative pathfinding", L"--Cheat Mode Options--", // TOPTION_CHEAT_MODE_OPTIONS_HEADER, L"Erzwinge BR Lieferung", // force all pending Bobby Ray shipments L"-----------------", // TOPTION_CHEAT_MODE_OPTIONS_END @@ -6507,8 +6509,8 @@ STR16 zOptionsScreenHelpText[] = //Use the metric system L"Mit dieser Option wird im Spiel das metrische anstelle des imperialen Maßsystems verwendet (z.B. Meter und Kilogramm).", - //Merc Lighted movement - L"Diese Funktion beleuchtet für den Spieler die Umgebung des Söldners - auch beim Bewegen. AUSgeschaltet erhöht sich die Bildwiederholrate.\nToggle artificial merc light. (|G)", // TODO.Translate + //Highlight Mercs + L"Wenn AN, wird der Söldner hervorgehoben (für Feinde nicht sichtbar).\nIm Spiel umschalten mit (|G)", //Smart cursor L"Wenn diese Funktion aktiviert ist, springt der Cursor immer automatisch auf Söldner in seiner direkten Nähe.", @@ -6566,6 +6568,8 @@ STR16 zOptionsScreenHelpText[] = L"Wenn diese Funktion aktiviert ist, wird die Mausradrichtung umgekehrt", L"When ON and multiple mercs are selected, they will try to keep their relative distances while moving.\n(press |C|t|r|l+|A|l|t+|G to toggle mode or |S|h|i|f|t + click to move in formation)", //TODO.Translate L"When ON, shows last known enemy location.", //TODO.Translate + L"When ON, aiming at enemy will start at maximum aiming instead of default no aim", + L"When ON, Use A* pathfinding algorithm, instead of original", L"(text not rendered)TOPTION_CHEAT_MODE_OPTIONS_HEADER", L"Force all pending Bobby Ray shipments", L"(text not rendered)TOPTION_CHEAT_MODE_OPTIONS_END", @@ -9047,6 +9051,8 @@ STR16 szPrisonerTextStr[]= L"Ein ranghoher Offizier in %s wurde enttarnt!", L"Der feindliche Anführer denkt nicht mal an Kapitulation!", L"%d Gefangene sind uns als Freiwillige beigetreten.", + L"Some of your mercs managed to escape the enemy capture!", + L"No possible escape is seen, it's a fight to the death!" }; STR16 szMTATextStr[]= diff --git a/Utils/_ItalianText.cpp b/Utils/_ItalianText.cpp index 9e3f0ded4..9a3463944 100644 --- a/Utils/_ItalianText.cpp +++ b/Utils/_ItalianText.cpp @@ -6517,7 +6517,7 @@ STR16 zOptionsToggleText[] = L"Conferma in tempo reale", L"Visualizza gli avvertimenti sveglio/addormentato", L"Utilizza il sistema metrico", - L"Tragitto illuminato durante gli spostamenti", + L"Evidenzia Merc", L"Sposta il cursore sui mercenari", L"Sposta il cursore sulle porte", L"Evidenzia gli oggetti", @@ -6559,6 +6559,8 @@ STR16 zOptionsToggleText[] = L"Invert mouse wheel", // TODO.Translate L"Formation Movement", // when multiple mercs are selected, they will try to keep their relative distances // TODO.Translate L"Show enemy location", // show locator on last known enemy location + L"Start at maximum aim", + L"Alternative pathfinding", L"--Cheat Mode Options--", // TOPTION_CHEAT_MODE_OPTIONS_HEADER, L"Force Bobby Ray shipments", // force all pending Bobby Ray shipments L"-----------------", // TOPTION_CHEAT_MODE_OPTIONS_END @@ -6619,8 +6621,8 @@ STR16 zOptionsScreenHelpText[] = //Use the metric system L"Se attivata, utilizza il sistema metrico di misurazione; altrimenti ricorre al sistema britannico.", - //Merc Lighted movement - L"Se attivata, il mercenario mostrerà il terreno su cui cammina. Disattivatela per un aggiornamento più veloce.\nToggle artificial merc light. (|G)", // TODO.Translate + //Highlight Mercs + L"Quando attivato, evidenzia il mercenario (non visibile ai nemici).\nAttiva/disattiva nel gioco con (|G)", //Smart cursor L"Se attivata, muovendo il cursore vicino ai vostri mercenari li evidenzierà automaticamente.", @@ -6678,6 +6680,8 @@ STR16 zOptionsScreenHelpText[] = L"When ON, inverts mouse wheel directions.", // TODO.Translate L"When ON and multiple mercs are selected, they will try to keep their relative distances while moving.\n(press |C|t|r|l+|A|l|t+|G to toggle mode or |S|h|i|f|t + click to move in formation)", //TODO.Translate L"When ON, shows last known enemy location.", //TODO.Translate + L"When ON, aiming at enemy will start at maximum aiming instead of default no aim", + L"When ON, Use A* pathfinding algorithm, instead of original", L"(text not rendered)TOPTION_CHEAT_MODE_OPTIONS_HEADER", L"Force all pending Bobby Ray shipments", L"(text not rendered)TOPTION_CHEAT_MODE_OPTIONS_END", @@ -9195,6 +9199,8 @@ STR16 szPrisonerTextStr[]= L"A high-ranking army officer in %s has been revealed!", // TODO.Translate L"The enemy leader refuses to even consider surrender!", L"%d prisoners volunteered to join our forces.", + L"Some of your mercs managed to escape the enemy capture!", + L"No possible escape is seen, it's a fight to the death!" }; STR16 szMTATextStr[]= // TODO.Translate diff --git a/Utils/_PolishText.cpp b/Utils/_PolishText.cpp index 5ebff373c..187348df0 100644 --- a/Utils/_PolishText.cpp +++ b/Utils/_PolishText.cpp @@ -6535,7 +6535,7 @@ STR16 zOptionsToggleText[] = L"Potwierdzenia Real-Time", L"Najemnik śpi/budzi się", L"Używaj systemu metrycznego", - L"Oświetlenie podczas ruchu", + L"Wyróżnij najemników", L"Przyciągaj kursor do najemników", L"Przyciągaj kursor do drzwi", L"Pulsujące przedmioty", @@ -6578,6 +6578,8 @@ STR16 zOptionsToggleText[] = L"Invert mouse wheel", // TODO.Translate L"Formation Movement", // when multiple mercs are selected, they will try to keep their relative distances // TODO.Translate L"Show enemy location", // show locator on last known enemy location + L"Start at maximum aim", + L"Alternative pathfinding", L"--Cheat Mode Options--", // TOPTION_CHEAT_MODE_OPTIONS_HEADER, L"Force Bobby Ray shipments", // force all pending Bobby Ray shipments L"-----------------", // TOPTION_CHEAT_MODE_OPTIONS_END @@ -6638,8 +6640,8 @@ STR16 zOptionsScreenHelpText[] = //Use the metric system L"Jeśli WŁĄCZONE, gra będzie używała systemu metrycznego.", - //Merc Lighted movement - L"Jeśli WŁĄCZONE, teren wokół najemnika będzie oświetlony podczas ruchu. Może spowolnić działanie gry.\nToggle artificial merc light. (|G)", // TODO.Translate + //Highlight Mercs + L"Gdy jest włączony, podświetla najemnika (niewidoczny dla wrogów).\nPrzełącz w grze za pomocą (|G)", //Smart cursor L"Jeśli WŁĄCZONE, kursor będzie automatycznie ustawiał się na najemnikach gdy znajdzie się w ich pobliżu.", @@ -6697,6 +6699,8 @@ STR16 zOptionsScreenHelpText[] = L"When ON, inverts mouse wheel directions.", // TODO.Translate L"When ON and multiple mercs are selected, they will try to keep their relative distances while moving.\n(press |C|t|r|l+|A|l|t+|G to toggle mode or |S|h|i|f|t + click to move in formation)", //TODO.Translate L"When ON, shows last known enemy location.", //TODO.Translate + L"When ON, aiming at enemy will start at maximum aiming instead of default no aim", + L"When ON, Use A* pathfinding algorithm, instead of original", L"(text not rendered)TOPTION_CHEAT_MODE_OPTIONS_HEADER", L"Wymuś wszystkie oczekiwane dostawy od Bobby Ray's.", L"(text not rendered)TOPTION_CHEAT_MODE_OPTIONS_END", @@ -9209,6 +9213,8 @@ STR16 szPrisonerTextStr[]= L"A high-ranking army officer in %s has been revealed!", // TODO.Translate L"The enemy leader refuses to even consider surrender!", L"%d prisoners volunteered to join our forces.", + L"Some of your mercs managed to escape the enemy capture!", + L"No possible escape is seen, it's a fight to the death!" }; STR16 szMTATextStr[]= // TODO.Translate diff --git a/Utils/_RussianText.cpp b/Utils/_RussianText.cpp index 4078205f2..c1d100e13 100644 --- a/Utils/_RussianText.cpp +++ b/Utils/_RussianText.cpp @@ -6528,7 +6528,7 @@ STR16 zOptionsToggleText[] = L"Игра в реальном времени", L"Подтверждение сна/подъема", L"Метрическая система", - L"Движущаяся подсветка бойца", + L"Выделите наемников", L"Курсор на бойцов", L"Курсор на дверь", L"Мерцание вещей", @@ -6570,6 +6570,8 @@ STR16 zOptionsToggleText[] = L"Инвертировать колесо мыши", L"Боевой порядок", // when multiple mercs are selected, they will try to keep their relative distances L"Показывать расположение", // show locator on last known enemy location + L"Start at maximum aim", + L"Alternative pathfinding", L"--Читерские настройки--", // TOPTION_CHEAT_MODE_OPTIONS_HEADER, L"Ускорить доставку Бобби Рэя", // force all pending Bobby Ray shipments L"-----------------", // TOPTION_CHEAT_MODE_OPTIONS_END @@ -6630,8 +6632,8 @@ STR16 zOptionsScreenHelpText[] = //Use the metric system L"Если включено, то используется метрическая система мер,\nиначе будет британская.", - //Merc Lighted movement - L"При ходьбе карта подсвечивается вокруг бойца.\nОтключите эту настройку для повышения\nпроизводительности системы (|G).", + //Highlight Mercs + L"При включении выделяет наемника (не виден врагам).\nПереключиться в игре с помощью (|G)", //Smart cursor L"Если включено, то перемещение курсора возле наёмника\nавтоматически выбирает его.", @@ -6689,6 +6691,8 @@ STR16 zOptionsScreenHelpText[] = L"Если включено, инвертирует направление\nпрокрутки колеса мыши.", L"Если выбрано несколько наёмников,\nони будут пытаться сохранять взаимное расположение\nи дистанцию при движении\n(нажмите |C|t|r|l+|A|l|t+|G для переключения или |S|h|i|f|t + клик для движения).", L"Если включено, показывает известное расположение противника\n(нажмите |S|h|i|f|t, чтобы показать источник шума).", + L"When ON, aiming at enemy will start at maximum aiming instead of default no aim", + L"When ON, Use A* pathfinding algorithm, instead of original", L"(text not rendered)TOPTION_CHEAT_MODE_OPTIONS_HEADER", L"Выберите этот пункт,\nчтобы груз Бобби Рэя прибыл немедленно.", L"(text not rendered)TOPTION_CHEAT_MODE_OPTIONS_END", @@ -9189,6 +9193,8 @@ STR16 szPrisonerTextStr[]= L"В %s был раскрыт высокопоставленный офицер!", L"Вражеский командир отказывается даже подумать о сдаче!", L"%d заключенных добровольно присоединились к нашим силам.", + L"Some of your mercs managed to escape the enemy capture!", + L"No possible escape is seen, it's a fight to the death!" }; STR16 szMTATextStr[]= diff --git a/Utils/message.cpp b/Utils/message.cpp index f77a941be..4c6163c48 100644 --- a/Utils/message.cpp +++ b/Utils/message.cpp @@ -10,6 +10,7 @@ #include "renderworld.h" #include "local.h" #include "interface.h" + #include "mapscreen.h" #include "Map Screen Interface Bottom.h" #include "WordWrap.h" #include "Sound Control.h" @@ -1036,7 +1037,7 @@ void MapScreenMessage( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ... ) // HEADROCK HAM 3.6: Allow for longer lines. // Lejardo ARSProject MAP_LINE_WIDTH = (INTERFACE_WIDTH - 330); - if (iResolution == _1280x720) + if (isWidescreenUI()) { MAP_LINE_WIDTH = 685; } @@ -1129,7 +1130,7 @@ void DisplayStringsInMapScreenMessageList( void ) UINT16 usSpacing; UINT16 MessageStartX = (SCREEN_WIDTH - INTERFACE_WIDTH) / 2; UINT16 MessageEndX = MessageStartX + (INTERFACE_WIDTH - 330); - if (iResolution == _1280x720) + if (isWidescreenUI()) { MessageStartX = 0; MessageEndX = 705; diff --git a/cmake/CopyUserPresetTemplate.cmake b/cmake/CopyUserPresetTemplate.cmake new file mode 100644 index 000000000..484f7ec80 --- /dev/null +++ b/cmake/CopyUserPresetTemplate.cmake @@ -0,0 +1,11 @@ +function(CopyUserPresetTemplate) + if( + NOT DEFINED Languages AND + NOT DEFINED Applications AND + NOT EXISTS "${CMAKE_SOURCE_DIR}/CMakePresets.json" AND + NOT EXISTS "${CMAKE_SOURCE_DIR}/CMakeUserPresets.json" + ) + file(COPY "${CMAKE_SOURCE_DIR}/cmake/presets/CMakeUserPresets.json" DESTINATION "${CMAKE_SOURCE_DIR}") + message(FATAL_ERROR "No existing preset was found, copied a preset template to ${CMAKE_SOURCE_DIR}/CMakeUserPresets.json.") + endif() +endfunction() diff --git a/cmake/ValidateOptions.cmake b/cmake/ValidateOptions.cmake new file mode 100644 index 000000000..3085695d4 --- /dev/null +++ b/cmake/ValidateOptions.cmake @@ -0,0 +1,15 @@ +function(ValidateOptions ValidOptions ChoiceName Choice RetVal) + if(Choice) + foreach(x IN LISTS Choice) + if(NOT x IN_LIST ValidOptions) + message(FATAL_ERROR "${ChoiceName}=\"${x}\" is not supported. Valid options are: ${ValidOptions}.") + endif() + endforeach() + else() + set(isDefault "by default.") + set(Choice ${ValidOptions}) + endif() + message(STATUS "Configuring ${ChoiceName}=\"${Choice}\" ${isDefault}") + + set(${RetVal} ${Choice} PARENT_SCOPE) +endfunction() diff --git a/cmake/presets/CMakeUserPresets.json b/cmake/presets/CMakeUserPresets.json new file mode 100644 index 000000000..ffbc4788b --- /dev/null +++ b/cmake/presets/CMakeUserPresets.json @@ -0,0 +1,44 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "__userBase", + "hidden": true, + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/${presetName}", + "cacheVariables": { + // Valid choices: ENGLISH;GERMAN;FRENCH;ITALIAN;POLISH;DUTCH;RUSSIAN;CHINESE. If empty (""), will configure all. + "Languages": "ENGLISH", + // Valid choices: JA2;JA2MAPEDITOR;JA2UB;JA2UBMAPEDITOR. If empty (""), will configure all. + "Applications": "JA2", + // For debugging: enter your desired gamedir. e.g. C:/Games/JA2 + "CMAKE_RUNTIME_OUTPUT_DIRECTORY": "." + }, + "architecture": { + "value": "x86", + "strategy": "external" + } + }, + { + "name": "1dot13 RelWithDebInfo", + "inherits": "__userBase", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "RelWithDebInfo" + } + }, + { + "name": "1dot13 Release", + "inherits": "__userBase", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "1dot13 Debug", + "inherits": "__userBase", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + } + ] +} diff --git a/ext/export/src/CMakeLists.txt b/ext/export/src/CMakeLists.txt new file mode 100644 index 000000000..6753f13fc --- /dev/null +++ b/ext/export/src/CMakeLists.txt @@ -0,0 +1,29 @@ +option(BUILD_JA2EXPORT "Build the Ja2Export tool." ON) + +if(BUILD_JA2EXPORT) + message(STATUS "Configuring Ja2Export") + + add_executable(Ja2Export + init_vfs.cpp + main.cpp + progress_bar.cpp + ja2/himage.cpp + ja2/XMLWriter.cpp + export/jsd/export_jsd.cpp + export/jsd/structure.cpp + export/slf/export_slf.cpp + export/sti/export_sti.cpp + export/sti/Image.cpp + export/sti/stci_image_utils.cpp + export/sti/STCI_lib.cpp + ) + target_include_directories(Ja2Export PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}" + ) + target_link_libraries(Ja2Export PUBLIC bfVFS libpng) + set_target_properties(Ja2Export PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} + ) +else() + message(STATUS "BUILD_JA2EXPORT set to \"OFF\", not configuring Ja2Export by default") +endif() diff --git a/ext/export/src/main.cpp b/ext/export/src/main.cpp index 7a6902ace..013af7213 100644 --- a/ext/export/src/main.cpp +++ b/ext/export/src/main.cpp @@ -81,16 +81,16 @@ int wmain(int argc, wchar_t **argv) param_list.push_back(*argv++); }; - std::auto_ptr cmd_help(new HelpCommand()); + auto cmd_help{ std::make_unique() }; g_command_map[HelpCommand::commandString] = cmd_help.get(); - std::auto_ptr cmd_sti(new ja2xp::CExportSTI()); + auto cmd_sti{ std::make_unique() }; g_command_map[ja2xp::CExportSTI::commandString] = cmd_sti.get(); - std::auto_ptr cmd_slf(new ja2xp::CExportSLF()); + auto cmd_slf{ std::make_unique() }; g_command_map[ja2xp::CExportSLF::commandString] = cmd_slf.get(); - std::auto_ptr cmd_jsd(new ja2xp::CExportJSD()); + auto cmd_jsd{ std::make_unique() }; g_command_map[ja2xp::CExportJSD::commandString] = cmd_jsd.get(); if(!param_list.empty()) diff --git a/ext/libpng/CMakeLists.txt b/ext/libpng/CMakeLists.txt new file mode 100644 index 000000000..7380c1a4e --- /dev/null +++ b/ext/libpng/CMakeLists.txt @@ -0,0 +1,20 @@ +add_library(libpng +"png.c" +"pngerror.c" +"pnggccrd.c" +"pngget.c" +"pngmem.c" +"pngpread.c" +"pngread.c" +"pngrio.c" +"pngrtran.c" +"pngrutil.c" +"pngset.c" +"pngtrans.c" +"pngwio.c" +"pngwrite.c" +"pngwtran.c" +"pngwutil.c" +) +target_include_directories(libpng PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(libpng PUBLIC zlib) diff --git a/ext/zlib/CMakeLists.txt b/ext/zlib/CMakeLists.txt new file mode 100644 index 000000000..0a987afcc --- /dev/null +++ b/ext/zlib/CMakeLists.txt @@ -0,0 +1,18 @@ +add_library(zlib +"gzread.c" +"gzlib.c" +"gzclose.c" +"crc32.c" +"zutil.c" +"uncompr.c" +"compress.c" +"inffast.c" +"inflate.c" +"adler32.c" +"infback.c" +"deflate.c" +"gzwrite.c" +"inftrees.c" +"trees.c" +) +target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/lua/CMakeLists.txt b/lua/CMakeLists.txt new file mode 100644 index 000000000..9e8f21b6c --- /dev/null +++ b/lua/CMakeLists.txt @@ -0,0 +1,12 @@ +add_library(Lua +"lua.cpp" +"lua_class_interface.cpp" +"lua_env.cpp" +"lua_function.cpp" +"lua_state.cpp" +"lua_strategic.cpp" +"lua_table.cpp" +"lua_tactical.cpp" +"lwstring.cpp" +) +target_include_directories(Lua PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})