diff --git a/.github/workflows/build-deprecated.yml b/.github/workflows/build-deprecated.yml new file mode 100644 index 0000000000..fa948eb378 --- /dev/null +++ b/.github/workflows/build-deprecated.yml @@ -0,0 +1,83 @@ +name: build + +# runs every 4 months +on: + workflow_dispatch: + schedule: + - cron: "0 0 1 */4 *" + +jobs: + msvcxp: + name: WinXP ${{ matrix.arch }} ${{ matrix.build_type }} (${{ matrix.portable }}) + runs-on: windows-2022 + strategy: + matrix: + arch: [x86, x86_64] + build_type: [Release] + portable: [Non-Portable] + include: + - arch: x86 + platform: Win32 + - arch: x86_64 + platform: x64 + + steps: + - uses: actions/checkout@v3 + + - name: Install v141_xp Toolchain + continue-on-error: true + shell: powershell + run: | + Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\" + $InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" + $WorkLoads = '--add Microsoft.VisualStudio.Component.WinXP' + $Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"", $WorkLoads, '--quiet', '--norestart', '--nocache') + $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden + if ($process.ExitCode -eq 0) { + Write-Host "components have been successfully added" + } else { + Write-Host "components were not installed" + } + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.1 + + - name: Create Build Environment + run: cmake -E make_directory ${{ github.workspace }}/build + + - name: Configure CMake + shell: bash + working-directory: ${{ github.workspace }}/build + run: | + OPTIONS="-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=bin" + if [ "${{ matrix.portable }}" == "Portable" ]; then + OPTIONS+=" -DBuildPortableVersion=ON" + else + OPTIONS+=" -DBuildPortableVersion=OFF" + fi + OPTIONS+=" -DBuildJK2SPEngine=ON -DBuildJK2SPGame=ON -DBuildJK2SPRdVanilla=ON" + cmake $GITHUB_WORKSPACE -T v141_xp -A ${{ matrix.platform }} $OPTIONS + + - name: Build + working-directory: ${{ github.workspace }}/build + shell: bash + run: cmake --build . --config ${{ matrix.build_type }} -j $NUMBER_OF_PROCESSORS + + - name: Install + if: ${{ matrix.build_type == 'Release' }} + working-directory: ${{ github.workspace }}/build + shell: bash + run: cmake --install . --config ${{ matrix.build_type }} + + - uses: actions/upload-artifact@v3 + if: ${{ matrix.build_type == 'Release' }} + with: + name: OpenJK-windowsxp-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} + path: ${{ github.workspace }}/build/bin/JediAcademy + if-no-files-found: error + + - uses: actions/upload-artifact@v3 + if: ${{ matrix.build_type == 'Release' }} + with: + name: OpenJO-windowsxp-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} + path: ${{ github.workspace }}/build/bin/JediOutcast + if-no-files-found: error diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d288148501..c0555f0f91 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -165,13 +165,18 @@ jobs: macos: name: macOS ${{ matrix.arch }} ${{ matrix.build_type }} (${{ matrix.portable}}) - runs-on: macos-12 + runs-on: ${{ matrix.runner }} strategy: fail-fast: false matrix: - arch: [x86_64] + runner: [macos-12, macos-14] build_type: [Debug, Release] portable: [Non-Portable] + include: + - runner: macos-12 + arch: x86_64 + - runner: macos-14 + arch: arm64 steps: - uses: actions/checkout@v3 @@ -210,7 +215,7 @@ jobs: working-directory: ${{ github.workspace }}/install/JediAcademy shell: bash run: | - chmod +x openjk.x86_64.app/Contents/MacOS/openjk.x86_64 + chmod +x openjk.${{ matrix.arch }}.app/Contents/MacOS/openjk.${{ matrix.arch }} tar -czvf openjk-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz * - name: Create OpenJO binary archive @@ -218,7 +223,7 @@ jobs: working-directory: ${{ github.workspace }}/install/JediOutcast shell: bash run: | - chmod +x openjo_sp.x86_64.app/Contents/MacOS/openjo_sp.x86_64 + chmod +x openjo_sp.${{ matrix.arch }}.app/Contents/MacOS/openjo_sp.${{ matrix.arch }} tar -czvf openjo_sp-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz * - uses: actions/upload-artifact@v3 @@ -254,12 +259,14 @@ jobs: mv ./OpenJK-linux-x86-Release-Non-Portable/* OpenJK-rend2-linux-x86.tar.gz mv ./OpenJK-linux-x86_64-Release-Non-Portable/* OpenJK-rend2-linux-x86_64.tar.gz mv ./OpenJK-macos-x86_64-Release-Non-Portable/* OpenJK-rend2-macos-x86_64.tar.gz + mv ./OpenJK-macos-arm64-Release-Non-Portable/* OpenJK-rend2-macos-arm64.tar.gz 7z a -r OpenJO-rend2-windows-x86.zip ./OpenJO-windows-x86-Release-Non-Portable/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' 7z a -r OpenJO-rend2-windows-x86_64.zip ./OpenJO-windows-x86_64-Release-Non-Portable/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' mv ./OpenJO-linux-x86-Release-Non-Portable/* OpenJO-rend2-linux-x86.tar.gz mv ./OpenJO-linux-x86_64-Release-Non-Portable/* OpenJO-rend2-linux-x86_64.tar.gz mv ./OpenJO-macos-x86_64-Release-Non-Portable/* OpenJO-rend2-macos-x86_64.tar.gz + mv ./OpenJO-macos-arm64-Release-Non-Portable/* OpenJO-rend2-macos-arm64.tar.gz - name: Create latest build uses: marvinpinto/action-automatic-releases@latest @@ -300,6 +307,10 @@ jobs: artifact_name: OpenJK-rend2-macos-x86_64.tar.gz zip: false + - artifact_dir: OpenJK-macos-arm64-Release-Non-Portable + artifact_name: OpenJK-macos-arm64.tar.gz + zip: false + - artifact_dir: OpenJO-windows-x86-Release-Non-Portable/JediOutcast artifact_name: OpenJO-rend2-windows-x86.zip zip: true @@ -320,6 +331,10 @@ jobs: artifact_name: OpenJO-rend2-macos-x86_64.tar.gz zip: false + - artifact_dir: OpenJO-macos-arm64-Release-Non-Portable + artifact_name: OpenJO-macos-arm64.tar.gz + zip: false + steps: - uses: actions/checkout@v3 with: diff --git a/.gitignore b/.gitignore index a8a1494a1f..87aa203888 100644 --- a/.gitignore +++ b/.gitignore @@ -182,6 +182,7 @@ pip-log.txt ## clangd ############# .clangd +compile_commands.json ############# ## CLion @@ -192,4 +193,4 @@ pip-log.txt ## CMake Builds ############# [Bb]uild*/ -cmake-build-* \ No newline at end of file +cmake-build-* diff --git a/CMakeLists.txt b/CMakeLists.txt index 2be755ea6c..eb0da8aa40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,7 @@ option(BuildMPGame "Whether to create projects for the MP server-side gamecode ( option(BuildMPCGame "Whether to create projects for the MP clientside gamecode (cgamex86.dll)" ON) option(BuildMPUI "Whether to create projects for the MP UI code (uix86.dll)" ON) option(BuildMPRend2 "Whether to create projects for the EXPERIMENTAL MP rend2 renderer (rd-rend2_x86.dll)" ON) + option(BuildSPEngine "Whether to create projects for the SP engine (openjk_sp.exe)" ON) option(BuildSPGame "Whether to create projects for the SP gamecode (jagamex86.dll)" ON) option(BuildSPRdVanilla "Whether to create projects for the SP default renderer (rdsp-vanilla_x86.dll)" ON) @@ -97,6 +98,14 @@ endif() #============================================================================= list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake/Modules") +if(CMAKE_EXPORT_COMPILE_COMMANDS) + add_custom_target( + copy-compile-commands ALL + ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_BINARY_DIR}/compile_commands.json + ${CMAKE_CURRENT_LIST_DIR}) +endif() + #============================================================================= # # Architecture/OS defines @@ -197,11 +206,11 @@ if(WIN64) endif() if (APPLE) - set(SharedDefines "MACOS_X") + set(SharedDefines ${SharedDefines} "MACOS_X") endif() if (NOT WIN32 AND NOT APPLE) - set(SharedDefines "ARCH_STRING=\"${Architecture}\"") + set(SharedDefines ${SharedDefines} "ARCH_STRING=\"${Architecture}\"") endif() if(CMAKE_SYSTEM_NAME MATCHES "BSD") diff --git a/README.md b/README.md index 069c314e9d..88e23d3c64 100644 --- a/README.md +++ b/README.md @@ -1,99 +1,105 @@ # OpenJK -OpenJK is an effort by the JACoders group to maintain and improve the game engines on which the Jedi Academy (JA) and Jedi Outcast (JO) games run on, while maintaining *full backwards compatibility* with the existing games. *This project does not attempt to rebalance or otherwise modify core gameplay*. +OpenJK is a community effort to maintain and improve the game and engine powering Jedi Academy and Jedi Outcast, while maintaining _full backwards compatibility_ with the existing games and mods. +This project does not intend to add major features, rebalance, or otherwise modify core gameplay. Our aims are to: -* Improve the stability of the engine by fixing bugs and improving performance. -* Provide a clean base from which new JO and JA code modifications can be made. -* Make available this engine to more operating systems. To date, we have ports on Linux and macOS. -Currently, the most stable portion of this project is the Jedi Academy multiplayer code, with the single player code in a reasonable state. +- Improve the stability of the engine by fixing bugs and improving performance. +- Support more hardware (x86_64, Arm, Apple Silicon) and software platforms (Linux, macOS) +- Provide a clean base from which new code modifications can be made. -Rough support for Jedi Outcast single player is also available, however this should be considered heavily work in progress. This is not currently actively worked on or tested. OpenJK does not have Jedi Outcast multiplayer support. +[![discord](https://img.shields.io/badge/discord-join-7289DA.svg?logo=discord&longCache=true&style=flat)](https://discord.gg/dPNCfeQ) +[![forum](https://img.shields.io/badge/forum-JKHub.org%20OpenJK-brightgreen.svg)](https://jkhub.org/forums/forum/49-openjk/) -Please use discretion when making issue requests on GitHub. The [JKHub sub-forum](https://jkhub.org/forums/forum/49-openjk/) is a better place for support queries, discussions, and feature requests. +[![build](https://github.com/JACoders/OpenJK/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/JACoders/OpenJK/actions/workflows/build.yml?query=branch%3Amaster) +[![coverity](https://scan.coverity.com/projects/1153/badge.svg)](https://scan.coverity.com/projects/1153) - -[![Forum](https://img.shields.io/badge/forum-JKHub.org%20OpenJK-brightgreen.svg)](https://jkhub.org/forums/forum/49-openjk/) +## Supported Games -[![Coverity Scan Build Status](https://scan.coverity.com/projects/1153/badge.svg)](https://scan.coverity.com/projects/1153) +| Game | Single Player | Multi Player | +| - | - | - | +| Jedi Academy | ✅ Stable | ✅ Stable | +| Jedi Outcast | 😧 Works, needs attention | 🙅 Not supported - consider [JK2MV](https://jk2mv.org) | -## License +Please direct support queries, discussions and feature requests to the JKHub sub-forum or Discord linked above. -OpenJK is licensed under GPLv2 as free software. You are free to use, modify and redistribute OpenJK following the terms in LICENSE.txt. +## License +OpenJK is licensed under GPLv2 as free software. You are free to use, modify and redistribute OpenJK following the terms in [LICENSE.txt](https://github.com/JACoders/OpenJK/blob/master/LICENSE.txt) ## For players -To install OpenJK, you will first need Jedi Academy installed. If you don't already own the game you can buy it from online stores such as [Steam](http://store.steampowered.com/app/6020/), [Amazon](http://www.amazon.com/Star-Wars-Jedi-Knight-Academy-Pc/dp/B0000A2MCN) or [GOG](https://www.gog.com/game/star_wars_jedi_knight_jedi_academy). +To install OpenJK, you will first need Jedi Academy installed. If you don't already own the game you can buy it from online stores such as [Steam](https://store.steampowered.com/app/6020/), [Amazon](https://www.amazon.com/Star-Wars-Jedi-Knight-Academy-Pc/dp/B0000A2MCN) or [GOG](https://www.gog.com/game/star_wars_jedi_knight_jedi_academy). -Installing and running OpenJK: +Download the [latest build](https://github.com/JACoders/OpenJK/releases/tag/latest) ([alt link](https://builds.openjk.org)) for your operating system. -1. [Download the latest build](http://builds.openjk.org) for your operating system. -2. Extract the contents of the file into the Jedi Academy `GameData/` folder. For Steam users, this will be in `/steamapps/common/Jedi Academy/GameData`. -3. Run `openjk.x86.exe` (Windows), `openjk.i386` (Linux 32-bit), `openjk.x86_64` (Linux 64-bit) or the `OpenJK` app bundle (macOS), depending on your operating system. +Installing and running OpenJK: +1. Extract the contents of the file into the Jedi Academy `GameData/` folder. For Steam users, this will be in `/steamapps/common/Jedi Academy/GameData/`. +1. Run `openjk.x86.exe` (Windows), `openjk.i386` (Linux 32-bit), `openjk.x86_64` (Linux 64-bit) or the `OpenJK` app bundle (macOS), depending on your operating system. -**Linux Instructions** +### Linux Instructions -If you do not have a windows partition and need to download the game base. +If you do not have an existing JKA installation and need to download the base game: -1. Download and Install SteamCMD [SteamCMD](https://developer.valvesoftware.com/wiki/SteamCMD#Linux) . -2. Set the download path using steamCMD, force_install_dir . -3. Using SteamCMD Set the platform to windows to download any windows game on steam. @sSteamCmdForcePlatformType "windows" -4. Using SteamCMD download the game, app_update 6020. -5. [Download the latest build](http://builds.openjk.org) for your operating system. -6. Extract the contents of the file into the Jedi Academy `GameData/` folder. For Steam users, this will be in `/steamapps/common/Jedi Academy/GameData`. +1. Download and Install SteamCMD [SteamCMD](https://developer.valvesoftware.com/wiki/SteamCMD#Linux). +1. Set the download path using steamCMD: `force_install_dir /path/to/install/jka/` +1. Using SteamCMD Set the platform to windows to download any windows game on steam. @sSteamCmdForcePlatformType "windows" +1. Using SteamCMD download the game, `app_update 6020`. +Extract the contents of the file into the Jedi Academy `GameData/` folder. For Steam users, this will be in `/steamapps/common/Jedi Academy/GameData/`. -**macOS Instructions** +### macOS Instructions If you have the Mac App Store Version of Jedi Academy, follow these steps to get OpenJK runnning under macOS: -1. Install [Homebrew](http://brew.sh/) if you don't have it. -2. Open the Terminal app, and enter the command `brew install sdl2`. -3. Extract the contents of the OpenJK DMG ([Download the latest build](http://builds.openjk.org)) into the game directory `/Applications/Star Wars Jedi Knight: Jedi Academy.app/Contents/` -4. Run `OpenJK.app` or `OpenJK SP.app` -5. Savegames, Config Files and Log Files are stored in `/Users//Library/Application Support/OpenJK/` - +1. Install [Homebrew](https://brew.sh/) if you don't have it. +1. Open the Terminal app, and enter the command `brew install sdl2`. +1. Extract the contents of the OpenJK DMG into the game directory `/Applications/Star Wars Jedi Knight: Jedi Academy.app/Contents/` +1. Run `OpenJK.app` or `OpenJK SP.app` +1. Savegames, Config Files and Log Files are stored in `/Users/$USER/Library/Application Support/OpenJK/` ## For Developers - ### Building OpenJK -* [Compilation guide](https://github.com/JACoders/OpenJK/wiki/Compilation-guide) -* [Debugging guide](https://github.com/JACoders/OpenJK/wiki/Debugging) - +- [Compilation guide](https://github.com/JACoders/OpenJK/wiki/Compilation-guide) +- [Debugging guide](https://github.com/JACoders/OpenJK/wiki/Debugging) ### Contributing to OpenJK -* [Fork](https://github.com/JACoders/OpenJK/fork) the project on GitHub -* Create a new branch and make your changes -* Send a [pull request](https://help.github.com/articles/creating-a-pull-request) to upstream (JACoders/OpenJK) - +- [Fork](https://github.com/JACoders/OpenJK/fork) the project on GitHub +- Create a new branch and make your changes +- Send a [pull request](https://help.github.com/articles/creating-a-pull-request) to upstream (JACoders/OpenJK) ### Using OpenJK as a base for a new mod -* [Fork](https://github.com/JACoders/OpenJK/fork) the project on GitHub -* Change the GAMEVERSION define in codemp/game/g_local.h from "OpenJK" to your project name -* If you make a nice change, please consider back-porting to upstream via pull request as described above. This is so everyone benefits without having to reinvent the wheel for every project. - - -## Maintainers (in alphabetical order) - -* Ensiform -* Razish -* Xycaleth - - -## Significant contributors (in alphabetical order) - -* eezstreet -* exidl -* ImperatorPrime -* mrwonko -* redsaurus -* Scooper -* Sil -* smcv +- [Fork](https://github.com/JACoders/OpenJK/fork) the project on GitHub +- Change the `GAMEVERSION` define in [codemp/game/g_local.h](https://github.com/JACoders/OpenJK/blob/master/codemp/game/g_local.h) from "OpenJK" to your project name +- If you make a nice change, please consider back-porting to upstream via pull request as described above. This is so everyone benefits without having to reinvent the wheel for every project. + +## Maintainers (full list: [@JACoders](https://github.com/orgs/JACoders/people)) + +Leads: + +- [Ensiform](https://github.com/ensiform) +- [razor](https://github.com/Razish) +- [Xycaleth](https://github.com/xycaleth) + +## Significant contributors ([full list](https://github.com/JACoders/OpenJK/graphs/contributors)) + +- [bibendovsky](https://github.com/bibendovsky) (save games, platform support) +- [BobaFett](https://github.com/Lrns123) +- [BSzili](https://github.com/BSzili) (JK2, platform support) +- [Cat](https://github.com/deepy) (infra) +- [Didz](https://github.com/dionrhys) +- [eezstreet](https://github.com/eezstreet) +- exidl (SDL2, platform support) +- [ImperatorPrime](https://github.com/ImperatorPrime) (JK2) +- [mrwonko](https://github.com/mrwonko) +- [redsaurus](https://github.com/redsaurus) +- [Scooper](https://github.com/xScooper) +- [Sil](https://github.com/TheSil) +- [smcv](https://github.com/smcv) (debian packaging) +- [Tristamus](https://tristamus.com>) (icon) diff --git a/cmake/Modules/InstallZIP.cmake b/cmake/Modules/InstallZIP.cmake index 090b946d03..70168942db 100644 --- a/cmake/Modules/InstallZIP.cmake +++ b/cmake/Modules/InstallZIP.cmake @@ -41,35 +41,35 @@ if(WIN32) set(ZIP_COMMAND "${ZIP_EXECUTABLE}" -P "" ) endif() endif() - + if(NOT ZIP_EXECUTABLE) find_program(ZIP_EXECUTABLE wzzip PATHS "$ENV{ProgramW6432}/WinZip") if(ZIP_EXECUTABLE) set(ZIP_COMMAND "${ZIP_EXECUTABLE}" -P "" ) endif() endif() - + if(NOT ZIP_EXECUTABLE) find_program(ZIP_EXECUTABLE 7z PATHS "$ENV{ProgramFiles}/7-Zip") if(ZIP_EXECUTABLE) set(ZIP_COMMAND "${ZIP_EXECUTABLE}" a -tzip "" ) endif() endif() - + if(NOT ZIP_EXECUTABLE) find_program(ZIP_EXECUTABLE 7z PATHS "$ENV{ProgramW6432}/7-Zip") if(ZIP_EXECUTABLE) set(ZIP_COMMAND "${ZIP_EXECUTABLE}" a -tzip "" ) endif() endif() - + if(NOT ZIP_EXECUTABLE) find_program(ZIP_EXECUTABLE winrar PATHS "$ENV{ProgramFiles}/WinRAR") if(ZIP_EXECUTABLE) set(ZIP_COMMAND "${ZIP_EXECUTABLE}" a "" ) endif() endif() - + if(NOT ZIP_EXECUTABLE) find_program(ZIP_EXECUTABLE winrar PATHS "$ENV{ProgramW6432}/WinRAR") if(ZIP_EXECUTABLE) @@ -85,7 +85,7 @@ if(NOT ZIP_EXECUTABLE) else() find_program(ZIP_EXECUTABLE zip) endif() - + if(ZIP_EXECUTABLE) set(ZIP_COMMAND "${ZIP_EXECUTABLE}" -r "" . -i) endif() @@ -94,7 +94,7 @@ endif() function(add_zip_command output) set(MultiValueArgs FILES DEPENDS) cmake_parse_arguments(ARGS "" "" "${MultiValueArgs}" ${ARGN}) - + set(ZipCommand ${ZIP_COMMAND}) string(REPLACE "${output}" ZipCommand "${ZipCommand}") string(REPLACE "${ARGS_FILES}" ZipCommand "${ZipCommand}") diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 9c75852c7b..8b108f1a22 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -195,7 +195,7 @@ if(BuildSPEngine OR BuildJK2SPEngine) ) source_group("common" FILES ${SPEngineCommonFiles}) set(SPEngineFiles ${SPEngineFiles} ${SPEngineCommonFiles}) - + set(SPEngineCommonSafeFiles "${SharedDir}/qcommon/safe/files.cpp" "${SharedDir}/qcommon/safe/files.h" diff --git a/code/cgame/cg_credits.cpp b/code/cgame/cg_credits.cpp index 68ff647634..27e1789f65 100644 --- a/code/cgame/cg_credits.cpp +++ b/code/cgame/cg_credits.cpp @@ -216,7 +216,7 @@ static bool SortBySurname(const StringAndSize_t &str1, const StringAndSize_t &st { std::string::const_reverse_iterator rstart1 = std::find_if(str1.str.rbegin(), str1.str.rend(), isspace); std::string::const_reverse_iterator rstart2 = std::find_if(str2.str.rbegin(), str2.str.rend(), isspace); - + return Q_stricmp(&*rstart1.base(), &*rstart2.base()) < 0; } diff --git a/code/cgame/cg_local.h b/code/cgame/cg_local.h index 3a1f7e8bff..8c0960f8b4 100644 --- a/code/cgame/cg_local.h +++ b/code/cgame/cg_local.h @@ -1231,4 +1231,6 @@ void CG_ClearLightStyles( void ); void CG_RunLightStyles( void ); void CG_SetLightstyle( int i ); +int CG_MagicFontToReal( int menuFontIndex ); + #endif //__CG_LOCAL_H__ diff --git a/code/cgame/cg_main.cpp b/code/cgame/cg_main.cpp index 86bf1a0c78..db6f7dc4e0 100644 --- a/code/cgame/cg_main.cpp +++ b/code/cgame/cg_main.cpp @@ -4353,13 +4353,50 @@ void CG_DrawDataPadForceSelect( void ) const float textScale = 1.0f; CG_DisplayBoxedText(textboxXPos,textboxYPos,textboxWidth,textboxHeight,va("%s%s",text,text2), - 4, + CG_MagicFontToReal(4), textScale, colorTable[CT_WHITE] ); } } +int CG_MagicFontToReal( int menuFontIndex ) +{ + // As the engine supports multiple renderers now we can no longer assume the + // order of fontindex values to be the same as it was on vanilla jasp with + // vanilla assets. Sadly the code uses magic numbers in various places that + // no longer match. This function tries to map these magic numbers to the + // fonts the would refer to on vanilla jasp with vanilla assets. + + static int fonthandle_aurabesh; + static int fonthandle_ergoec; + static int fonthandle_anewhope; + static int fonthandle_arialnb; + + static qboolean fontsRegistered = qfalse; + + if ( !fontsRegistered ) + { // Only try registering the fonts once + fonthandle_aurabesh = cgi_R_RegisterFont( "aurabesh" ); + fonthandle_ergoec = cgi_R_RegisterFont( "ergoec" ); + fonthandle_anewhope = cgi_R_RegisterFont( "anewhope" ); + fonthandle_arialnb = cgi_R_RegisterFont( "arialnb" ); + + fontsRegistered = qtrue; + } + + // Default fonts from a clean installation + switch ( menuFontIndex ) { + case 1: return fonthandle_aurabesh; + case 2: return fonthandle_ergoec; + case 3: return fonthandle_anewhope; + case 4: return fonthandle_arialnb; + + default: + return cgs.media.qhFontMedium; + } +} + // actually, these are pretty pointless so far in CHC, since in TA codebase they were used only so init some HUD // function ptrs to allow cinematics in onscreen displays. So far, we don't use those, but here they are anyway... // diff --git a/code/cgame/cg_view.cpp b/code/cgame/cg_view.cpp index 01cb293e07..7b8b2a9d4f 100644 --- a/code/cgame/cg_view.cpp +++ b/code/cgame/cg_view.cpp @@ -2141,7 +2141,6 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) { if ( !cg.hyperspace ) { CG_AddPacketEntities(qfalse); // adter calcViewValues, so predicted player state is correct CG_AddMarks(); - CG_AddLocalEntities(); CG_DrawMiscEnts(); } @@ -2211,6 +2210,10 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) { CG_AddTestModel(); } + if ( !cg.hyperspace ) { + CG_AddLocalEntities(); + } + memcpy( cg.refdef.areamask, cg.snap->areamask, sizeof( cg.refdef.areamask ) ); // update audio positions diff --git a/code/cgame/cg_weapons.cpp b/code/cgame/cg_weapons.cpp index dc90ee497e..09a5b20ad4 100644 --- a/code/cgame/cg_weapons.cpp +++ b/code/cgame/cg_weapons.cpp @@ -1685,7 +1685,7 @@ void CG_DrawDataPadWeaponSelect( void ) textboxXPos, textboxYPos, textboxWidth, textboxHeight, text, - 4, + CG_MagicFontToReal(4), textScale, colorTable[CT_WHITE] ); diff --git a/code/client/client.h b/code/client/client.h index 131842a95d..b50feb9983 100644 --- a/code/client/client.h +++ b/code/client/client.h @@ -207,6 +207,15 @@ typedef struct { qhandle_t whiteShader; qhandle_t consoleShader; int consoleFont; + + // Cursor + qboolean cursorActive; + qhandle_t cursorShader; + int cursorX; + int cursorY; + + // Engine menu + int menuFont; } clientStatic_t; #define CON_TEXTSIZE 0x30000 //was 32768 diff --git a/code/game/g_roff.cpp b/code/game/g_roff.cpp index 5dd6381f42..d49649c26e 100644 --- a/code/game/g_roff.cpp +++ b/code/game/g_roff.cpp @@ -86,7 +86,7 @@ static void G_RoffNotetrackCallback( gentity_t *ent, const char *notetrack) // notetrack = "loop rof relative"; // notetrack = "loop sfx sound/vehicles/tie/loop.wav"; // notetrack = "loop sfx kill"; - //'loop rof' notes: + //'loop rof' notes: // (1) absolute ==> reset rof to original delta position/rotation world location before looping. // (2) relative ==> reset rof to original delta position/rotation at current location before looping. //'loop sfx' notes: @@ -742,7 +742,7 @@ void G_Roff( gentity_t *ent ) move_rotate2_t *data = &((move_rotate2_t *)roff->data)[ ent->roff_ctr ]; VectorCopy( data->origin_delta, org ); VectorCopy( data->rotate_delta, ang ); - + if ( data->mStartNote != -1 ) { for ( int n = 0; n < data->mNumNotes; n++ ) diff --git a/code/game/g_svcmds.cpp b/code/game/g_svcmds.cpp index f7d4faa344..0374e14091 100644 --- a/code/game/g_svcmds.cpp +++ b/code/game/g_svcmds.cpp @@ -907,7 +907,7 @@ static svcmd_t svcmds[] = { { "saberColor", Svcmd_SaberColor_f, CMD_CHEAT }, { "saber", Svcmd_Saber_f, CMD_CHEAT }, { "saberBlade", Svcmd_SaberBlade_f, CMD_CHEAT }, - + { "setForceJump", Svcmd_ForceSetLevel_f, CMD_CHEAT }, { "setSaberThrow", Svcmd_ForceSetLevel_f, CMD_CHEAT }, { "setForceHeal", Svcmd_ForceSetLevel_f, CMD_CHEAT }, @@ -926,29 +926,29 @@ static svcmd_t svcmds[] = { { "setForceSight", Svcmd_ForceSetLevel_f, CMD_CHEAT }, { "setForceAll", Svcmd_SetForceAll_f, CMD_CHEAT }, { "setSaberAll", Svcmd_SetSaberAll_f, CMD_CHEAT }, - + { "saberAttackCycle", Svcmd_SaberAttackCycle_f, CMD_NONE }, - + { "runscript", Svcmd_RunScript_f, CMD_CHEAT }, - + { "playerTeam", Svcmd_PlayerTeam_f, CMD_CHEAT }, - + { "control", Svcmd_Control_f, CMD_CHEAT }, { "grab", Svcmd_Grab_f, CMD_CHEAT }, { "knockdown", Svcmd_Knockdown_f, CMD_CHEAT }, { "playerModel", Svcmd_PlayerModel_f, CMD_NONE }, { "playerTint", Svcmd_PlayerTint_f, CMD_NONE }, - + { "nexttestaxes", G_NextTestAxes, CMD_NONE }, - + { "exitview", Svcmd_ExitView_f, CMD_NONE }, - + { "iknowkungfu", Svcmd_IKnowKungfu_f, CMD_CHEAT }, - + { "secrets", Svcmd_Secrets_f, CMD_NONE }, { "difficulty", Svcmd_Difficulty_f, CMD_NONE }, - + //{ "say", Svcmd_Say_f, qtrue }, //{ "toggleallowvote", Svcmd_ToggleAllowVote_f, qfalse }, //{ "toggleuserinfovalidation", Svcmd_ToggleUserinfoValidation_f, qfalse }, @@ -966,7 +966,7 @@ qboolean ConsoleCommand( void ) { if ( !command ) return qfalse; - + if ( (command->flags & CMD_CHEAT) && !g_cheats->integer ) { diff --git a/code/game/wp_saberLoad.cpp b/code/game/wp_saberLoad.cpp index 1b89f34b8f..298d1775eb 100644 --- a/code/game/wp_saberLoad.cpp +++ b/code/game/wp_saberLoad.cpp @@ -490,7 +490,7 @@ static void Saber_ParseSaberType( saberInfo_t *saber, const char **p ) { if ( COM_ParseString( p, &value ) ) return; saberType = GetIDForString( SaberTable, value ); - if ( saberType >= SABER_SINGLE && saberType <= NUM_SABERS ) + if ( saberType >= SABER_SINGLE && saberType < NUM_SABERS ) saber->type = (saberType_t)saberType; } static void Saber_ParseSaberModel( saberInfo_t *saber, const char **p ) { diff --git a/code/qcommon/common.cpp b/code/qcommon/common.cpp index 41f2da9e55..0e64a80b97 100644 --- a/code/qcommon/common.cpp +++ b/code/qcommon/common.cpp @@ -1105,6 +1105,9 @@ void Com_Init( char *commandLine ) { com_homepath = Cvar_Get("com_homepath", "", CVAR_INIT); + // Init network before filesystem + NET_Init(); + FS_InitFilesystem (); //uses z_malloc //re.R_InitWorldEffects(); // this doesn't do much but I want to be sure certain variables are intialized. diff --git a/code/qcommon/cvar.cpp b/code/qcommon/cvar.cpp index 77d8e4b4a7..a5cef1e158 100644 --- a/code/qcommon/cvar.cpp +++ b/code/qcommon/cvar.cpp @@ -481,11 +481,11 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) { return var; } -static void Cvar_QSortByName( cvar_t **a, int n ) +static void Cvar_QSortByName( cvar_t **a, int n ) { cvar_t *temp; cvar_t *m; - int i, j; + int i, j; i = 0; j = n; @@ -497,10 +497,10 @@ static void Cvar_QSortByName( cvar_t **a, int n ) while ( strcmp( a[j]->name, m->name ) < 0 ) j--; if ( i <= j ) { - temp = a[i]; - a[i] = a[j]; + temp = a[i]; + a[i] = a[j]; a[j] = temp; - i++; + i++; j--; } } while ( i <= j ); @@ -510,7 +510,7 @@ static void Cvar_QSortByName( cvar_t **a, int n ) } -static void Cvar_Sort( void ) +static void Cvar_Sort( void ) { cvar_t *list[ MAX_CVARS ], *var; int count; @@ -529,7 +529,7 @@ static void Cvar_Sort( void ) } Cvar_QSortByName( &list[0], count-1 ); - + cvar_vars = NULL; // relink cvars diff --git a/code/qcommon/files.cpp b/code/qcommon/files.cpp index c35d0e00f5..d105742d2f 100644 --- a/code/qcommon/files.cpp +++ b/code/qcommon/files.cpp @@ -2685,6 +2685,29 @@ void FS_Which_f( void ) { Com_Printf( "File not found: \"%s\"\n", filename ); } +/* +============ +FS_Restart_f +============ +*/ +static qboolean FS_CanRestartInPlace( void ) { + int i; + for ( i = 1; i < MAX_FILE_HANDLES; i++ ) { + // If we have an active filehandle for a module that references a zip file we cannot restart. + if ( fsh[i].fileSize ) { + if ( fsh[i].zipFile ) return qfalse; + } + } + return qtrue; +} +static void FS_Restart_f( void ) { + if ( !FS_CanRestartInPlace() ) { + Com_Printf( "^3WARNING: Cannot restart file system due to active file handles for pk3 files inside of modules.\n" ); + return; + } + FS_Restart( qtrue ); +} + //=========================================================================== static int QDECL paksort( const void *a, const void *b ) { @@ -2704,7 +2727,6 @@ Sets fs_gamedir, adds the directory to the head of the path, then loads the zip headers ================ */ -#define MAX_PAKFILES 1024 static void FS_AddGameDirectory( const char *path, const char *dir ) { searchpath_t *sp; int i; @@ -2714,7 +2736,6 @@ static void FS_AddGameDirectory( const char *path, const char *dir ) { char curpath[MAX_OSPATH + 1], *pakfile; int numfiles; char **pakfiles; - char *sorted[MAX_PAKFILES]; // this fixes the case where fs_basepath is the same as fs_cdpath // which happens on full installs @@ -2748,20 +2769,13 @@ static void FS_AddGameDirectory( const char *path, const char *dir ) { pakfiles = Sys_ListFiles( curpath, ".pk3", NULL, &numfiles, qfalse ); - // sort them so that later alphabetic matches override - // earlier ones. This makes pak1.pk3 override pak0.pk3 - if ( numfiles > MAX_PAKFILES ) { - numfiles = MAX_PAKFILES; + if ( numfiles > 1 ) { + qsort( pakfiles, numfiles, sizeof(char*), paksort ); } - for ( i = 0 ; i < numfiles ; i++ ) { - sorted[i] = pakfiles[i]; - } - - qsort( sorted, numfiles, sizeof(char*), paksort ); for ( i = 0 ; i < numfiles ; i++ ) { - pakfile = FS_BuildOSPath( path, dir, sorted[i] ); - if ( ( pak = FS_LoadZipFile( pakfile, sorted[i] ) ) == 0 ) + pakfile = FS_BuildOSPath( path, dir, pakfiles[i] ); + if ( ( pak = FS_LoadZipFile( pakfile, pakfiles[i] ) ) == 0 ) continue; Q_strncpyz(pak->pakPathname, curpath, sizeof(pak->pakPathname)); // store the game name for downloading @@ -2819,13 +2833,14 @@ FS_Shutdown Frees all resources and closes all files ================ */ -void FS_Shutdown( void ) { +void FS_Shutdown( qboolean keepModuleFiles ) { searchpath_t *p, *next; int i; for(i = 0; i < MAX_FILE_HANDLES; i++) { if (fsh[i].fileSize) { - FS_FCloseFile(i); + if ( !keepModuleFiles ) FS_FCloseFile(i); + else if ( fsh[i].zipFile ) Com_Error(ERR_FATAL, "FS_Shutdown: tried to keep module files when at least one module file is inside of a pak"); } } @@ -2850,6 +2865,7 @@ void FS_Shutdown( void ) { Cmd_RemoveCommand( "fdir" ); Cmd_RemoveCommand( "touchFile" ); Cmd_RemoveCommand( "which" ); + Cmd_RemoveCommand( "fs_restart" ); } /* @@ -2935,6 +2951,7 @@ void FS_Startup( const char *gameName ) { Cmd_AddCommand ("fdir", FS_NewDir_f ); Cmd_AddCommand ("touchFile", FS_TouchFile_f ); Cmd_AddCommand ("which", FS_Which_f ); + Cmd_AddCommand ("fs_restart", FS_Restart_f ); // print the current search paths FS_Path_f(); @@ -2998,10 +3015,10 @@ void FS_InitFilesystem( void ) { FS_Restart ================ */ -void FS_Restart( void ) { +void FS_Restart( qboolean inPlace ) { // free anything we currently have loaded - FS_Shutdown(); + FS_Shutdown( inPlace ); // try to start up normally FS_Startup( BASEGAME ); diff --git a/code/qcommon/ojk_saved_game_helper_fwd.h b/code/qcommon/ojk_saved_game_helper_fwd.h index 60b360fcbc..b44ef99c6d 100644 --- a/code/qcommon/ojk_saved_game_helper_fwd.h +++ b/code/qcommon/ojk_saved_game_helper_fwd.h @@ -291,7 +291,7 @@ class SavedGameClassArchiver { public: enum { is_implemented = false }; - + static void sg_export( SavedGameHelper& saved_game, const T& instance) diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index 17d75dc9bd..b1647f473b 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -445,7 +445,9 @@ issues. qboolean FS_Initialized(); void FS_InitFilesystem (void); -void FS_Shutdown( void ); +void FS_Shutdown( qboolean inPlace = qfalse ); + +void FS_Restart( qboolean inPlace = qfalse ); qboolean FS_ConditionalRestart( void ); diff --git a/code/qcommon/safe/memory.h b/code/qcommon/safe/memory.h index 1299509102..5caec82d91 100644 --- a/code/qcommon/safe/memory.h +++ b/code/qcommon/safe/memory.h @@ -80,7 +80,7 @@ namespace Zone using other = Allocator< U, tag >; }; }; - + template< typename T > using UniquePtr = std::unique_ptr< T, Deleter >; diff --git a/code/rd-common/tr_font.cpp b/code/rd-common/tr_font.cpp index 8724a18311..253d58fd51 100644 --- a/code/rd-common/tr_font.cpp +++ b/code/rd-common/tr_font.cpp @@ -1019,6 +1019,7 @@ CFontInfo::CFontInfo(const char *_fontName) m_fAltSBCSFontScaleFactor = -1; #endif m_bIsFakeAlienLanguage = !strcmp(_fontName,"aurabesh"); // dont try and make SBCS or asian overrides for this + m_isVariant = qfalse; len = ri.FS_ReadFile(fontName, NULL); if (len == sizeof(dfontdat_t)) @@ -1284,7 +1285,7 @@ void CFontInfo::UpdateAsianIfNeeded( bool bForceReEval /* = false */ ) case eTaiwanese: case eJapanese: #ifndef JK2_MODE - case eChinese: + case eChinese: #endif m_AsianGlyph.horizAdvance = iCappedHeight + 3; // need to force some spacing for these // case eThai: // this is done dynamically elsewhere, since Thai glyphs are variable width diff --git a/code/rd-rend2/tr_init.cpp b/code/rd-rend2/tr_init.cpp index 08bda041fc..f15ebf7240 100644 --- a/code/rd-rend2/tr_init.cpp +++ b/code/rd-rend2/tr_init.cpp @@ -313,7 +313,7 @@ static void R_Splash() { const GLfloat black[] = { 0.0f, 0.0f, 0.0f, 1.0f }; - qglViewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); + GL_SetViewportAndScissor( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); qglClearBufferfv(GL_COLOR, 0, black); qglClear(GL_DEPTH_BUFFER_BIT); @@ -1122,17 +1122,18 @@ RB_TakeVideoFrameCmd const void *RB_TakeVideoFrameCmd( const void *data ) { const videoFrameCommand_t *cmd; - byte *cBuf; - size_t memcount, linelen; - int padwidth, avipadwidth, padlen, avipadlen; - GLint packAlign; - + // finish any 2D drawing if needed if (tess.numIndexes) RB_EndSurface(); cmd = (const videoFrameCommand_t *)data; #ifndef REND2_SP + byte *cBuf; + size_t memcount, linelen; + int padwidth, avipadwidth, padlen, avipadlen; + GLint packAlign; + qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign); linelen = cmd->width * 3; @@ -1239,6 +1240,7 @@ void GL_SetDefaultState( void ) qglEnable(GL_PROGRAM_POINT_SIZE); qglDisable( GL_CULL_FACE ); qglDisable( GL_BLEND ); + glState.blend = false; qglEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); diff --git a/code/rd-vanilla/tr_ghoul2.cpp b/code/rd-vanilla/tr_ghoul2.cpp index d51432f223..b05263c10d 100644 --- a/code/rd-vanilla/tr_ghoul2.cpp +++ b/code/rd-vanilla/tr_ghoul2.cpp @@ -3569,7 +3569,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean // first up, go load in the animation file we need that has the skeletal animation info for this model mdxm->animIndex = RE_RegisterModel(va ("%s.gla",mdxm->animName)); - + char animGLAName[MAX_QPATH]; char *strippedName; char *slash = NULL; @@ -3593,7 +3593,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean { RE_RegisterModel(va("models/players/%s_%s/%s_%s.gla", strippedName, mapname, strippedName, mapname)); } - } + } #ifndef JK2_MODE bool isAnOldModelFile = false; @@ -3611,7 +3611,11 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean #ifndef JK2_MODE else { - assert (tr.models[mdxm->animIndex]->mdxa->numBones == mdxm->numBones); + // let us mix JK2/JKA models and animations + if (tr.models[mdxm->animIndex]->mdxa->numBones != 53 && tr.models[mdxm->animIndex]->mdxa->numBones != 72 && mdxm->numBones != 53 && + mdxm->numBones != 72) { + assert(tr.models[mdxm->animIndex]->mdxa->numBones == mdxm->numBones); + } if (tr.models[mdxm->animIndex]->mdxa->numBones != mdxm->numBones) { if ( isAnOldModelFile ) diff --git a/code/rd-vanilla/tr_image.cpp b/code/rd-vanilla/tr_image.cpp index 276698ec0b..a13badd43d 100644 --- a/code/rd-vanilla/tr_image.cpp +++ b/code/rd-vanilla/tr_image.cpp @@ -890,7 +890,7 @@ qboolean RE_RegisterImages_LevelLoadEnd(void) { //ri.Printf( PRINT_DEVELOPER, "RE_RegisterImages_LevelLoadEnd():\n"); - qboolean imageDeleted = qtrue; + qboolean imageDeleted = qfalse; for (AllocatedImages_t::iterator itImage = AllocatedImages.begin(); itImage != AllocatedImages.end(); /* blank */) { qboolean bEraseOccured = qfalse; diff --git a/code/rd-vanilla/tr_shader.cpp b/code/rd-vanilla/tr_shader.cpp index 204d1dc175..abf8ec4c9b 100644 --- a/code/rd-vanilla/tr_shader.cpp +++ b/code/rd-vanilla/tr_shader.cpp @@ -2478,7 +2478,7 @@ Ghoul2 Insert End // functioned because rgbGen identity doesn't work with setcolor. // // We match against retail version of gfx/menus/radar/arrow_w by calculating - // the hash value of the shader text, and comparing it against a + // the hash value of the shader text, and comparing it against a // precalculated value. if ( shaderHash == RETAIL_ARROW_W_SHADER_HASH && Q_stricmp( shader.name, "gfx/menus/radar/arrow_w" ) == 0 ) diff --git a/code/ui/ui_atoms.cpp b/code/ui/ui_atoms.cpp index 69ccfb6e3b..21488388bb 100644 --- a/code/ui/ui_atoms.cpp +++ b/code/ui/ui_atoms.cpp @@ -441,6 +441,9 @@ UI_RegisterFont ================= */ +int registeredFontsCount = 0; +int registeredFonts[MAX_FONTS]; + int UI_RegisterFont(const char *fontName) { int iFontIndex = ui.R_RegisterFont(fontName); @@ -449,6 +452,22 @@ int UI_RegisterFont(const char *fontName) iFontIndex = ui.R_RegisterFont("ergoec"); // fall back } + // Store font + if ( iFontIndex ) + { + int i; + for ( i = 0; i < registeredFontsCount; i++ ) + { + if ( registeredFonts[i] == iFontIndex ) break; + } + + if ( i == registeredFontsCount ) + { // It's not in the list: add it + if ( registeredFontsCount >= MAX_FONTS ) Com_Printf( "^3UI_RegisterFont: MAX_FONTS (%i) exceeded\n", MAX_FONTS ); + else registeredFonts[registeredFontsCount++] = iFontIndex; + } + } + return iFontIndex; } diff --git a/code/ui/ui_local.h b/code/ui/ui_local.h index e39c4f902d..6767efd5dd 100644 --- a/code/ui/ui_local.h +++ b/code/ui/ui_local.h @@ -246,4 +246,8 @@ void trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum ); void _UI_Refresh( int realtime ); +#define MAX_FONTS 64 +extern int registeredFontsCount; +extern int registeredFonts[MAX_FONTS]; + #endif diff --git a/code/ui/ui_main.cpp b/code/ui/ui_main.cpp index b6d4fed156..6f678c738d 100644 --- a/code/ui/ui_main.cpp +++ b/code/ui/ui_main.cpp @@ -994,7 +994,7 @@ static qboolean UI_RunMenuScript ( const char **args ) if (uiInfo.modList[uiInfo.modIndex].modName) { Cvar_Set( "fs_game", uiInfo.modList[uiInfo.modIndex].modName); - extern void FS_Restart( void ); + extern void FS_Restart( qboolean inPlace = qfalse ); FS_Restart(); Cbuf_ExecuteText( EXEC_APPEND, "vid_restart;" ); } @@ -2432,7 +2432,7 @@ void UI_FreeAllSpecies( void ) UI_FreeSpecies(&uiInfo.playerSpecies[i]); } free(uiInfo.playerSpecies); - + uiInfo.playerSpeciesCount = 0; uiInfo.playerSpecies = NULL; } diff --git a/code/ui/ui_shared.cpp b/code/ui/ui_shared.cpp index 0306ba6c72..2f5cbdf877 100644 --- a/code/ui/ui_shared.cpp +++ b/code/ui/ui_shared.cpp @@ -352,7 +352,7 @@ qboolean MenuParse_font( itemDef_t *item) if (!DC->Assets.fontRegistered) { - DC->Assets.qhMediumFont = DC->registerFont(menu->font); + DC->Assets.qhMediumFont = UI_RegisterFont(menu->font); DC->Assets.fontRegistered = qtrue; } return qtrue; @@ -1047,7 +1047,7 @@ static void Item_ApplyHacks( itemDef_t *item ) { Com_Printf( "Disabling eax field because current platform does not support EAX.\n"); } } - + if ( item->type == ITEM_TYPE_TEXT && item->window.name && !Q_stricmp( item->window.name, "eax_icon") && item->cvarTest && !Q_stricmp( item->cvarTest, "s_UseOpenAL" ) && item->enableCvar && (item->cvarFlags & CVAR_HIDE) ) { if( item->parent ) { @@ -1085,7 +1085,7 @@ static void Item_ApplyHacks( itemDef_t *item ) { Com_Printf( "Extended sound quality field to contain very high option.\n"); } } - + if ( item->type == ITEM_TYPE_MULTI && item->window.name && !Q_stricmp( item->window.name, "voice") && item->cvar && !Q_stricmp( item->cvar, "g_subtitles" ) ) { multiDef_t *multiPtr = (multiDef_t *)item->typeData; int i; @@ -3072,18 +3072,19 @@ qboolean ItemParse_name( itemDef_t *item) return qtrue; } -int MenuFontToReal( int menuFontIndex ) +int UI_MenuFontToReal( int menuFontIndex ) { - // Default fonts from a clean installation - switch ( menuFontIndex ) { - case 1: return UI_RegisterFont( "aurabesh" ); - case 2: return UI_RegisterFont( "ergoec" ); - case 3: return UI_RegisterFont( "anewhope" ); - case 4: return UI_RegisterFont( "arialnb" ); + // The font array starts at 0, but the valid font indexes start at 1. As the + // original menu files have direct font indexes we need to subtract 1 from + // the given index to get the correct index for our mapping array. + menuFontIndex--; - default: - return DC->Assets.qhMediumFont; - } + // Make sure we don't go out of bound, fallback to medium font + if ( menuFontIndex < 0 || menuFontIndex >= registeredFontsCount ) + return DC->Assets.qhMediumFont; + + // Use the mapped index + return registeredFonts[menuFontIndex]; } qboolean ItemParse_font( itemDef_t *item ) @@ -3094,7 +3095,7 @@ qboolean ItemParse_font( itemDef_t *item ) } // Translate to real font - item->font = MenuFontToReal( item->font ); + item->font = UI_MenuFontToReal( item->font ); return qtrue; } @@ -8277,7 +8278,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw) while (1) { // FIXME - add some type of parameter in the menu file like descfont to specify the font for the descriptions for this menu. - textWidth = DC->textWidth(textPtr, fDescScale, MenuFontToReal(4)); // item->font); + textWidth = DC->textWidth(textPtr, fDescScale, UI_MenuFontToReal(4)); // item->font); if (parent->descAlignment == ITEM_ALIGN_RIGHT) { @@ -8313,7 +8314,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw) } // FIXME - add some type of parameter in the menu file like descfont to specify the font for the descriptions for this menu. - DC->drawText(xPos, parent->descY + iYadj, fDescScale, parent->descColor, textPtr, 0, parent->descTextStyle, MenuFontToReal(4)); //item->font); + DC->drawText(xPos, parent->descY + iYadj, fDescScale, parent->descColor, textPtr, 0, parent->descTextStyle, UI_MenuFontToReal(4)); //item->font); break; } } diff --git a/code/win32/game.rc b/code/win32/game.rc index 7b9d377284..3632640c44 100644 --- a/code/win32/game.rc +++ b/code/win32/game.rc @@ -27,18 +27,18 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // TEXTINCLUDE // -1 TEXTINCLUDE +1 TEXTINCLUDE BEGIN "resource.h\0" END -2 TEXTINCLUDE +2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END -3 TEXTINCLUDE +3 TEXTINCLUDE BEGIN "\r\n" "\0" diff --git a/code/win32/winquake.rc b/code/win32/winquake.rc index 8be20e493c..751d5b49b3 100644 --- a/code/win32/winquake.rc +++ b/code/win32/winquake.rc @@ -27,18 +27,18 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // TEXTINCLUDE // -1 TEXTINCLUDE +1 TEXTINCLUDE BEGIN "resource.h\0" END -2 TEXTINCLUDE +2 TEXTINCLUDE BEGIN "#include ""winres.h""\r\n" "\0" END -3 TEXTINCLUDE +3 TEXTINCLUDE BEGIN "\0" END diff --git a/codeJK2/cgame/FX_DEMP2.cpp b/codeJK2/cgame/FX_DEMP2.cpp index d0c44789f5..e0a01527c2 100644 --- a/codeJK2/cgame/FX_DEMP2.cpp +++ b/codeJK2/cgame/FX_DEMP2.cpp @@ -100,12 +100,12 @@ void FX_DEMP2_AltDetonate( vec3_t org, float size ) ex->startTime = cg.time; ex->endTime = ex->startTime + 1300; - + ex->radius = size; ex->refEntity.customShader = cgi_R_RegisterShader( "gfx/effects/demp2shell" ); ex->refEntity.hModel = cgi_R_RegisterModel( "models/items/sphere.md3" ); VectorCopy( org, ex->refEntity.origin ); - + ex->color[0] = ex->color[1] = ex->color[2] = 255.0f; } diff --git a/codeJK2/cgame/FX_Disruptor.cpp b/codeJK2/cgame/FX_Disruptor.cpp index a141bcf025..899022ba25 100644 --- a/codeJK2/cgame/FX_Disruptor.cpp +++ b/codeJK2/cgame/FX_Disruptor.cpp @@ -36,10 +36,10 @@ static vec3_t WHITE ={1.0f,1.0f,1.0f}; void FX_DisruptorMainShot( vec3_t start, vec3_t end ) { - FX_AddLine( start, end, 0.1f, 4.0f, 0.0f, + FX_AddLine( start, end, 0.1f, 4.0f, 0.0f, 1.0f, 0.0f, 0.0f, WHITE, WHITE, 0.0f, - 120, cgi_R_RegisterShader( "gfx/effects/redLine" ), + 120, cgi_R_RegisterShader( "gfx/effects/redLine" ), FX_SIZE_LINEAR | FX_ALPHA_LINEAR ); } @@ -51,10 +51,10 @@ FX_DisruptorAltShot */ void FX_DisruptorAltShot( vec3_t start, vec3_t end, qboolean fullCharge ) { - FX_AddLine( start, end, 0.1f, 10.0f, 0.0f, + FX_AddLine( start, end, 0.1f, 10.0f, 0.0f, 1.0f, 0.0f, 0.0f, WHITE, WHITE, 0.0f, - 175, cgi_R_RegisterShader( "gfx/effects/redLine" ), + 175, cgi_R_RegisterShader( "gfx/effects/redLine" ), FX_SIZE_LINEAR | FX_ALPHA_LINEAR ); if ( fullCharge ) @@ -62,10 +62,10 @@ void FX_DisruptorAltShot( vec3_t start, vec3_t end, qboolean fullCharge ) vec3_t YELLER={0.8f,0.7f,0.0f}; // add some beef - FX_AddLine( start, end, 0.1f, 7.0f, 0.0f, + FX_AddLine( start, end, 0.1f, 7.0f, 0.0f, 1.0f, 0.0f, 0.0f, YELLER, YELLER, 0.0f, - 150, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), + 150, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), FX_SIZE_LINEAR | FX_ALPHA_LINEAR ); } } @@ -85,7 +85,7 @@ void FX_DisruptorAltMiss( vec3_t origin, vec3_t normal ) VectorCopy( c1, c2 ); c1[2] += 4; c2[2] += 12; - + VectorAdd( origin, normal, pos ); pos[2] += 28; diff --git a/codeJK2/cgame/FxPrimitives.h b/codeJK2/cgame/FxPrimitives.h index b81fe3e9fb..14db076df9 100644 --- a/codeJK2/cgame/FxPrimitives.h +++ b/codeJK2/cgame/FxPrimitives.h @@ -85,7 +85,7 @@ along with this program; if not, see . #define FX_DEPTH_HACK 0x00100000 #define FX_RELATIVE 0x00200000 #define FX_SET_SHADER_TIME 0x00400000 // by having the effects system set the shader time, we can make animating textures start at the correct time -#define FX_EXPENSIVE_PHYSICS 0x00800000 +#define FX_EXPENSIVE_PHYSICS 0x00800000 #define FX_ATTACHED_MODEL 0x01000000 @@ -138,7 +138,7 @@ class CEffect { // Game pausing can cause dumb time things to happen, so kill the effect in this instance if ( mTimeStart > theFxHelper.mTime ) { return false; - } + } return true; } @@ -222,7 +222,7 @@ class CLight : public CEffect void Draw() { - theFxHelper.AddLightToScene( mOrigin1, mRefEnt.radius, + theFxHelper.AddLightToScene( mOrigin1, mRefEnt.radius, mRefEnt.lightingOrigin[0], mRefEnt.lightingOrigin[1], mRefEnt.lightingOrigin[2] ); } @@ -231,7 +231,7 @@ class CLight : public CEffect CLight() {} virtual ~CLight() {} virtual bool Update(); - + inline void SetSizeStart( float sz ) { mSizeStart = sz; } inline void SetSizeEnd( float sz ) { mSizeEnd = sz; } inline void SetSizeParm( float parm ) { mSizeParm = parm; } @@ -277,7 +277,7 @@ class CParticle : public CEffect vec3_t mRGBStart; vec3_t mRGBEnd; float mRGBParm; - + float mAlphaStart; float mAlphaEnd; float mAlphaParm; @@ -297,7 +297,7 @@ class CParticle : public CEffect bool Cull(); void Draw(); - + public: inline CParticle() { mRefEnt.reType = RT_SPRITE; mClientID = -1; } @@ -375,7 +375,7 @@ class CBezier : public CLine virtual void Die() {} virtual bool Update(); - + void DrawSegment( vec3_t start, vec3_t end, float texcoord1, float texcoord2 ); inline void SetControlPoints( const vec3_t ctrl1, const vec3_t ctrl2 ) { VectorCopy( ctrl1, mControl1 ); VectorCopy( ctrl2, mControl2 ); } @@ -496,10 +496,10 @@ class CEmitter : public CParticle vec3_t mOldOrigin; // we use these to do some nice vec3_t mLastOrigin; // tricks... - vec3_t mOldVelocity; // + vec3_t mOldVelocity; // int mOldTime; - vec3_t mAngles; // for a rotating thing, using a delta + vec3_t mAngles; // for a rotating thing, using a delta vec3_t mAngleDelta; // as opposed to an end angle is probably much easier int mEmitterFxID; // if we have emitter fx, this is our id @@ -514,7 +514,7 @@ class CEmitter : public CParticle public: CEmitter() { - // There may or may not be a model, but if there isn't one, + // There may or may not be a model, but if there isn't one, // we just won't bother adding the refEnt in our Draw func mRefEnt.reType = RT_MODEL; } diff --git a/codeJK2/cgame/FxScheduler.h b/codeJK2/cgame/FxScheduler.h index f40fe5fbbc..febfd65608 100644 --- a/codeJK2/cgame/FxScheduler.h +++ b/codeJK2/cgame/FxScheduler.h @@ -42,19 +42,19 @@ typedef sstring_t fxString_t; #define FX_MAX_EFFECTS 150 // how many effects the system can store #define FX_MAX_EFFECT_COMPONENTS 24 // how many primitives an effect can hold, this should be plenty #define FX_MAX_PRIM_NAME 32 - + //----------------------------------------------- // These are spawn flags for primitiveTemplates //----------------------------------------------- #define FX_ORG_ON_SPHERE 0x00001 // Pretty dang expensive, calculates a point on a sphere/ellipsoid -#define FX_AXIS_FROM_SPHERE 0x00002 // Can be used in conjunction with org_on_sphere to cause particles to move out +#define FX_AXIS_FROM_SPHERE 0x00002 // Can be used in conjunction with org_on_sphere to cause particles to move out // from the center of the sphere #define FX_ORG_ON_CYLINDER 0x00004 // calculate point on cylinder/disk #define FX_ORG2_FROM_TRACE 0x00010 #define FX_TRACE_IMPACT_FX 0x00020 // if trace impacts, we should play one of the specified impact fx files -#define FX_ORG2_IS_OFFSET 0x00040 // template specified org2 should be the offset from a trace endpos or +#define FX_ORG2_IS_OFFSET 0x00040 // template specified org2 should be the offset from a trace endpos or // passed in org2. You might use this to lend a random flair to the endpos. // Note: this is done pre-trace, so you may have to specify large numbers for this @@ -76,7 +76,7 @@ typedef sstring_t fxString_t; // // CMediaHandles // -// Primitive templates might want to use a list of sounds, shaders +// Primitive templates might want to use a list of sounds, shaders // or models to get a bit more variation in their effects. // //----------------------------------------------------------------- @@ -101,7 +101,7 @@ class CMediaHandles // CFxRange // // Primitive templates typically use this class to define each of -// its members. This is done to make it easier to create effects +// its members. This is done to make it easier to create effects // with a desired range of characteristics. // //----------------------------------------------------------------- @@ -166,11 +166,11 @@ enum EPrimType // // CPrimitiveTemplate // -// The primitive template is used to spawn 1 or more fx primitives +// The primitive template is used to spawn 1 or more fx primitives // with the range of characteristics defined by the template. // -// As such, I just made this one huge shared class knowing that -// there won't be many of them in memory at once, and we won't +// As such, I just made this one huge shared class knowing that +// there won't be many of them in memory at once, and we won't // be dynamically creating and deleting them mid-game. Also, // note that not every primitive type will use all of these fields. // @@ -182,8 +182,8 @@ class CPrimitiveTemplate // These kinds of things should not even be allowed to be accessed publicly bool mCopy; - int mRefCount; // For a copy of a primitive...when we figure out how many items we want to spawn, - // we'll store that here and then decrement us for each we actually spawn. When we + int mRefCount; // For a copy of a primitive...when we figure out how many items we want to spawn, + // we'll store that here and then decrement us for each we actually spawn. When we // hit zero, we are no longer used and so we can just free ourselves char mName[FX_MAX_PRIM_NAME]; @@ -563,8 +563,8 @@ class PagedPoolAllocator // // CFxScheduler // -// The scheduler not only handles requests to play an effect, it -// tracks the request throughout its life if necessary, creating +// The scheduler not only handles requests to play an effect, it +// tracks the request throughout its life if necessary, creating // any of the delayed components as needed. // //----------------------------------------------------------------- @@ -611,7 +611,7 @@ class CFxScheduler public: CFxScheduler(); - + int RegisterEffect( const char *file, bool bHasCorrectPath = false ); // handles pre-caching @@ -621,7 +621,7 @@ class CFxScheduler void PlayEffect( int id, vec3_t origin, vec3_t axis[3], const int boltInfo=-1, const int entNum=-1 ); void PlayEffect( const char *file, vec3_t org ); // uses a default up axis void PlayEffect( const char *file, vec3_t org, vec3_t fwd ); // builds arbitrary perp. right vector, does a cross product to define up - void PlayEffect( const char *file, vec3_t origin, + void PlayEffect( const char *file, vec3_t origin, vec3_t axis[3], const int boltInfo, const int entNum ); void PlayEffect( const char *file, int clientID ); diff --git a/codeJK2/cgame/FxSystem.cpp b/codeJK2/cgame/FxSystem.cpp index d4a47ffd0f..80c1cd443e 100644 --- a/codeJK2/cgame/FxSystem.cpp +++ b/codeJK2/cgame/FxSystem.cpp @@ -49,7 +49,7 @@ void SFxHelper::Print( const char *msg, ... ) va_start( argptr, msg ); Q_vsnprintf (text, sizeof(text), msg, argptr); va_end( argptr ); - + gi.Printf( text ); #endif @@ -108,7 +108,7 @@ void SFxHelper::PlaySound( vec3_t org, int entityNum, int entchannel, int sfxHan } //------------------------------------------------------ -void SFxHelper::Trace( trace_t *tr, vec3_t start, vec3_t min, vec3_t max, +void SFxHelper::Trace( trace_t *tr, vec3_t start, vec3_t min, vec3_t max, vec3_t end, int skipEntNum, int flags ) { CG_Trace( tr, start, min, max, end, skipEntNum, flags ); diff --git a/codeJK2/cgame/FxSystem.h b/codeJK2/cgame/FxSystem.h index fb83979ce0..1f91e255df 100644 --- a/codeJK2/cgame/FxSystem.h +++ b/codeJK2/cgame/FxSystem.h @@ -36,7 +36,7 @@ along with this program; if not, see . extern vmCvar_t fx_debug; extern vmCvar_t fx_freeze; -extern void CG_CalcEntityLerpPositions( centity_t * ); +extern void CG_CalcEntityLerpPositions( centity_t * ); struct SFxHelper { diff --git a/codeJK2/cgame/FxUtil.cpp b/codeJK2/cgame/FxUtil.cpp index 8df8097c86..d6b3f14879 100644 --- a/codeJK2/cgame/FxUtil.cpp +++ b/codeJK2/cgame/FxUtil.cpp @@ -47,7 +47,7 @@ int mParticles; int mOParticles; int mLines; int mTails; -qboolean fxInitialized = qfalse; +qboolean fxInitialized = qfalse; //------------------------- // FX_Free @@ -100,7 +100,7 @@ void FX_Stop( void ) // Preps system for use //------------------------- int FX_Init( void ) -{ +{ if ( fxInitialized == qfalse ) { fxInitialized = qtrue; @@ -210,13 +210,13 @@ void FX_Add( void ) for ( i = 0, ef = effectList; i < MAX_EFFECTS; i++, ef++ ) { if ( ef->mEffect != 0 ) - { + { // Effect is active if ( theFxHelper.mTime > ef->mKillTime ) - { + { // Clean up old effects, calling any death effects as needed // this flag just has to be cleared otherwise death effects might not happen correctly - ef->mEffect->ClearFlags( FX_KILL_ON_IMPACT ); + ef->mEffect->ClearFlags( FX_KILL_ON_IMPACT ); FX_FreeMember( ef ); } else @@ -385,8 +385,8 @@ void FX_AddPrimitive( CEffect **pEffect, int killTime ) //------------------------- // FX_AddParticle //------------------------- -CParticle *FX_AddParticle( const vec3_t org, const vec3_t vel, const vec3_t accel, float size1, float size2, float sizeParm, - float alpha1, float alpha2, float alphaParm, +CParticle *FX_AddParticle( const vec3_t org, const vec3_t vel, const vec3_t accel, float size1, float size2, float sizeParm, + float alpha1, float alpha2, float alphaParm, const vec3_t sRGB, const vec3_t eRGB, float rgbParm, float rotation, float rotationDelta, const vec3_t min, const vec3_t max, float elasticity, @@ -760,7 +760,7 @@ CElectricity *FX_AddElectricity( vec3_t start, vec3_t end, float size1, float si // in the editor, fx may now be NULL? if ( fx ) { - fx->Initialize(); + fx->Initialize(); } } @@ -771,12 +771,12 @@ CElectricity *FX_AddElectricity( vec3_t start, vec3_t end, float size1, float si //------------------------- // FX_AddTail //------------------------- -CTail *FX_AddTail( vec3_t org, vec3_t vel, vec3_t accel, - float size1, float size2, float sizeParm, +CTail *FX_AddTail( vec3_t org, vec3_t vel, vec3_t accel, + float size1, float size2, float sizeParm, float length1, float length2, float lengthParm, float alpha1, float alpha2, float alphaParm, vec3_t sRGB, vec3_t eRGB, float rgbParm, - vec3_t min, vec3_t max, float elasticity, + vec3_t min, vec3_t max, float elasticity, int deathID, int impactID, int killTime, qhandle_t shader, int flags = 0 ) { @@ -865,12 +865,12 @@ CTail *FX_AddTail( vec3_t org, vec3_t vel, vec3_t accel, //------------------------- // FX_AddTail //------------------------- -CTail *FX_AddTail( int clientID, vec3_t org, vec3_t vel, vec3_t accel, - float size1, float size2, float sizeParm, +CTail *FX_AddTail( int clientID, vec3_t org, vec3_t vel, vec3_t accel, + float size1, float size2, float sizeParm, float length1, float length2, float lengthParm, float alpha1, float alpha2, float alphaParm, vec3_t sRGB, vec3_t eRGB, float rgbParm, - vec3_t min, vec3_t max, float elasticity, + vec3_t min, vec3_t max, float elasticity, int deathID, int impactID, int killTime, qhandle_t shader, int flags = 0 ) { @@ -961,7 +961,7 @@ CTail *FX_AddTail( int clientID, vec3_t org, vec3_t vel, vec3_t accel, //------------------------- // FX_AddCylinder //------------------------- -CCylinder *FX_AddCylinder( vec3_t start, vec3_t normal, +CCylinder *FX_AddCylinder( vec3_t start, vec3_t normal, float size1s, float size1e, float sizeParm, float size2s, float size2e, float size2Parm, float length1, float length2, float lengthParm, @@ -1059,12 +1059,12 @@ CCylinder *FX_AddCylinder( vec3_t start, vec3_t normal, //------------------------- // FX_AddEmitter //------------------------- -CEmitter *FX_AddEmitter( vec3_t org, vec3_t vel, vec3_t accel, +CEmitter *FX_AddEmitter( vec3_t org, vec3_t vel, vec3_t accel, float size1, float size2, float sizeParm, float alpha1, float alpha2, float alphaParm, vec3_t rgb1, vec3_t rgb2, float rgbParm, vec3_t angs, vec3_t deltaAngs, - vec3_t min, vec3_t max, float elasticity, + vec3_t min, vec3_t max, float elasticity, int deathID, int impactID, int emitterID, float density, float variance, int killTime, qhandle_t model, int flags = 0 ) @@ -1289,7 +1289,7 @@ COrientedParticle *FX_AddOrientedParticle( vec3_t org, vec3_t norm, vec3_t vel, //------------------------- // FX_AddPoly //------------------------- -CPoly *FX_AddPoly( vec3_t *verts, vec2_t *st, int numVerts, +CPoly *FX_AddPoly( vec3_t *verts, vec2_t *st, int numVerts, vec3_t vel, vec3_t accel, float alpha1, float alpha2, float alphaParm, vec3_t rgb1, vec3_t rgb2, float rgbParm, @@ -1363,7 +1363,7 @@ CPoly *FX_AddPoly( vec3_t *verts, vec2_t *st, int numVerts, //------------------------- // FX_AddBezier //------------------------- -CBezier *FX_AddBezier( const vec3_t start, const vec3_t end, +CBezier *FX_AddBezier( const vec3_t start, const vec3_t end, const vec3_t control1, const vec3_t control1Vel, const vec3_t control2, const vec3_t control2Vel, float size1, float size2, float sizeParm, @@ -1498,7 +1498,7 @@ CFlash *FX_AddFlash( vec3_t origin, vec3_t sRGB, vec3_t eRGB, float rgbParm, fx->SetFlags( flags ); // fx->SetSTScale( 1.0f, 1.0f ); - + fx->Init(); FX_AddPrimitive( (CEffect**)&fx, killTime ); @@ -1509,7 +1509,7 @@ CFlash *FX_AddFlash( vec3_t origin, vec3_t sRGB, vec3_t eRGB, float rgbParm, //------------------------------------------------------- // Functions for limited backward compatibility with EF. -// These calls can be used for simple programmatic +// These calls can be used for simple programmatic // effects, temp effects or debug graphics. // Note that this is not an all-inclusive list of // fx add functions from EF, nor are the calls guaranteed @@ -1517,13 +1517,13 @@ CFlash *FX_AddFlash( vec3_t origin, vec3_t sRGB, vec3_t eRGB, float rgbParm, //------------------------------------------------------- //--------------------------------------------------- -void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, - float scale, float dscale, - float sAlpha, float eAlpha, - float rotation, float bounce, +void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, + float scale, float dscale, + float sAlpha, float eAlpha, + float rotation, float bounce, int life, qhandle_t shader, int flags ) { - FX_AddParticle( origin, vel, accel, scale, scale, 0, + FX_AddParticle( origin, vel, accel, scale, scale, 0, sAlpha, eAlpha, FX_ALPHA_LINEAR, WHITE, WHITE, 0, rotation, 0, @@ -1533,14 +1533,14 @@ void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, } //--------------------------------------------------- -void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, - float scale, float dscale, - float sAlpha, float eAlpha, - vec3_t sRGB, vec3_t eRGB, - float rotation, float bounce, +void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, + float scale, float dscale, + float sAlpha, float eAlpha, + vec3_t sRGB, vec3_t eRGB, + float rotation, float bounce, int life, qhandle_t shader, int flags ) { - FX_AddParticle( origin, vel, accel, scale, scale, 0, + FX_AddParticle( origin, vel, accel, scale, scale, 0, sAlpha, eAlpha, FX_ALPHA_LINEAR, sRGB, eRGB, 0, rotation, 0, @@ -1550,9 +1550,9 @@ void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, } //--------------------------------------------------- -void FX_AddLine( vec3_t start, vec3_t end, float stScale, - float width, float dwidth, - float sAlpha, float eAlpha, +void FX_AddLine( vec3_t start, vec3_t end, float stScale, + float width, float dwidth, + float sAlpha, float eAlpha, int life, qhandle_t shader, int flags ) { FX_AddLine( start, end, width, width, 0, @@ -1562,10 +1562,10 @@ void FX_AddLine( vec3_t start, vec3_t end, float stScale, } //--------------------------------------------------- -void FX_AddLine( vec3_t start, vec3_t end, float stScale, - float width, float dwidth, - float sAlpha, float eAlpha, - vec3_t sRGB, vec3_t eRGB, +void FX_AddLine( vec3_t start, vec3_t end, float stScale, + float width, float dwidth, + float sAlpha, float eAlpha, + vec3_t sRGB, vec3_t eRGB, int life, qhandle_t shader, int flags ) { FX_AddLine( start, end, width, width, 0, @@ -1575,18 +1575,18 @@ void FX_AddLine( vec3_t start, vec3_t end, float stScale, } //--------------------------------------------------- -void FX_AddQuad( vec3_t origin, vec3_t normal, - vec3_t vel, vec3_t accel, - float sradius, float eradius, - float salpha, float ealpha, - vec3_t sRGB, vec3_t eRGB, +void FX_AddQuad( vec3_t origin, vec3_t normal, + vec3_t vel, vec3_t accel, + float sradius, float eradius, + float salpha, float ealpha, + vec3_t sRGB, vec3_t eRGB, float rotation, int life, qhandle_t shader, int flags ) { - FX_AddOrientedParticle( origin, normal, vel, accel, + FX_AddOrientedParticle( origin, normal, vel, accel, sradius, eradius, 0.0f, salpha, ealpha, 0.0f, sRGB, eRGB, 0.0f, - rotation, 0.0f, + rotation, 0.0f, NULL, NULL, 0.0f, 0, 0, life, shader, 0 ); } diff --git a/codeJK2/cgame/FxUtil.h b/codeJK2/cgame/FxUtil.h index 7aed5d510e..4a708f7d37 100644 --- a/codeJK2/cgame/FxUtil.h +++ b/codeJK2/cgame/FxUtil.h @@ -36,12 +36,12 @@ void FX_Stop( void ); // ditches all active effects without touching the templat bool FX_ActiveFx(void); // returns whether there are any active or scheduled effects -CParticle *FX_AddParticle( const vec3_t org, const vec3_t vel, const vec3_t accel, - float size1, float size2, float sizeParm, - float alpha1, float alpha2, float alphaParm, +CParticle *FX_AddParticle( const vec3_t org, const vec3_t vel, const vec3_t accel, + float size1, float size2, float sizeParm, + float alpha1, float alpha2, float alphaParm, const vec3_t rgb1, const vec3_t rgb2, float rgbParm, float rotation, float rotationDelta, - const vec3_t min, const vec3_t max, float elasticity, + const vec3_t min, const vec3_t max, float elasticity, int deathID, int impactID, int killTime, qhandle_t shader, int flags ); @@ -52,7 +52,7 @@ CParticle *FX_AddParticle( int clientID, const vec3_t org, const vec3_t vel, con float rotation, float rotationDelta, int killTime, qhandle_t shader, int flags ); -CLine *FX_AddLine( vec3_t start, vec3_t end, +CLine *FX_AddLine( vec3_t start, vec3_t end, float size1, float size2, float sizeParm, float alpha1, float alpha2, float alphaParm, vec3_t rgb1, vec3_t rgb2, float rgbParm, @@ -68,25 +68,25 @@ CElectricity *FX_AddElectricity( vec3_t start, vec3_t end, float size1, float si vec3_t sRGB, vec3_t eRGB, float rgbParm, float chaos, int killTime, qhandle_t shader, int flags ); -CTail *FX_AddTail( vec3_t org, vec3_t vel, vec3_t accel, - float size1, float size2, float sizeParm, +CTail *FX_AddTail( vec3_t org, vec3_t vel, vec3_t accel, + float size1, float size2, float sizeParm, float length1, float length2, float lengthParm, float alpha1, float alpha2, float alphaParm, vec3_t rgb1, vec3_t rgb2, float rgbParm, - vec3_t min, vec3_t max, float elasticity, + vec3_t min, vec3_t max, float elasticity, int deathID, int impactID, int killTime, qhandle_t shader, int flags ); -CTail *FX_AddTail( int clientID, vec3_t org, vec3_t vel, vec3_t accel, - float size1, float size2, float sizeParm, +CTail *FX_AddTail( int clientID, vec3_t org, vec3_t vel, vec3_t accel, + float size1, float size2, float sizeParm, float length1, float length2, float lengthParm, float alpha1, float alpha2, float alphaParm, vec3_t sRGB, vec3_t eRGB, float rgbParm, - vec3_t min, vec3_t max, float elasticity, + vec3_t min, vec3_t max, float elasticity, int deathID, int impactID, int killTime, qhandle_t shader, int flags ); -CCylinder *FX_AddCylinder( vec3_t start, vec3_t normal, +CCylinder *FX_AddCylinder( vec3_t start, vec3_t normal, float size1s, float size1e, float size1Parm, float size2s, float size2e, float size2Parm, float length1, float length2, float lengthParm, @@ -99,7 +99,7 @@ CEmitter *FX_AddEmitter( vec3_t org, vec3_t vel, vec3_t accel, float alpha1, float alpha2, float alphaParm, vec3_t rgb1, vec3_t rgb2, float rgbParm, vec3_t angs, vec3_t deltaAngs, - vec3_t min, vec3_t max, float elasticity, + vec3_t min, vec3_t max, float elasticity, int deathID, int impactID, int emitterID, float density, float variance, int killTime, qhandle_t model, int flags ); @@ -129,38 +129,38 @@ CFlash *FX_AddFlash( vec3_t origin, vec3_t sRGB, vec3_t eRGB, float rgbParm, // Included for backwards compatibility with CHC and for doing quick programmatic effects. -void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, - float scale, float dscale, - float sAlpha, float eAlpha, - float rotation, float bounce, +void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, + float scale, float dscale, + float sAlpha, float eAlpha, + float rotation, float bounce, int life, qhandle_t shader, int flags = 0 ); -void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, - float scale, float dscale, - float sAlpha, float eAlpha, - vec3_t sRGB, vec3_t eRGB, - float rotation, float bounce, +void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, + float scale, float dscale, + float sAlpha, float eAlpha, + vec3_t sRGB, vec3_t eRGB, + float rotation, float bounce, int life, qhandle_t shader, int flags = 0 ); -void FX_AddLine( vec3_t start, vec3_t end, float stScale, - float width, float dwidth, - float sAlpha, float eAlpha, +void FX_AddLine( vec3_t start, vec3_t end, float stScale, + float width, float dwidth, + float sAlpha, float eAlpha, int life, qhandle_t shader, int flags = 0 ); -void FX_AddLine( vec3_t start, vec3_t end, float stScale, - float width, float dwidth, - float sAlpha, float eAlpha, - vec3_t sRGB, vec3_t eRGB, +void FX_AddLine( vec3_t start, vec3_t end, float stScale, + float width, float dwidth, + float sAlpha, float eAlpha, + vec3_t sRGB, vec3_t eRGB, int life, qhandle_t shader, int flags = 0 ); -void FX_AddQuad( vec3_t origin, vec3_t normal, - vec3_t vel, vec3_t accel, - float sradius, float eradius, - float salpha, float ealpha, - vec3_t sRGB, vec3_t eRGB, +void FX_AddQuad( vec3_t origin, vec3_t normal, + vec3_t vel, vec3_t accel, + float sradius, float eradius, + float salpha, float ealpha, + vec3_t sRGB, vec3_t eRGB, float rotation, int life, qhandle_t shader, int flags = 0 ); -CBezier *FX_AddBezier( const vec3_t start, const vec3_t end, +CBezier *FX_AddBezier( const vec3_t start, const vec3_t end, const vec3_t control1, const vec3_t control1Vel, const vec3_t control2, const vec3_t control2Vel, float size1, float size2, float sizeParm, diff --git a/codeJK2/cgame/animtable.h b/codeJK2/cgame/animtable.h index c7911b3e00..4c29d0cf5a 100644 --- a/codeJK2/cgame/animtable.h +++ b/codeJK2/cgame/animtable.h @@ -36,24 +36,24 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_DEATH5), //# Fifth Death anim ENUM2STRING(BOTH_DEATH6), //# Sixth Death anim ENUM2STRING(BOTH_DEATH7), //# Seventh Death anim - ENUM2STRING(BOTH_DEATH8), //# - ENUM2STRING(BOTH_DEATH9), //# - ENUM2STRING(BOTH_DEATH10), //# + ENUM2STRING(BOTH_DEATH8), //# + ENUM2STRING(BOTH_DEATH9), //# + ENUM2STRING(BOTH_DEATH10), //# ENUM2STRING(BOTH_DEATH11), //# - ENUM2STRING(BOTH_DEATH12), //# - ENUM2STRING(BOTH_DEATH13), //# - ENUM2STRING(BOTH_DEATH14), //# - ENUM2STRING(BOTH_DEATH15), //# - ENUM2STRING(BOTH_DEATH16), //# - ENUM2STRING(BOTH_DEATH17), //# - ENUM2STRING(BOTH_DEATH18), //# - ENUM2STRING(BOTH_DEATH19), //# - ENUM2STRING(BOTH_DEATH20), //# - ENUM2STRING(BOTH_DEATH21), //# - ENUM2STRING(BOTH_DEATH22), //# - ENUM2STRING(BOTH_DEATH23), //# - ENUM2STRING(BOTH_DEATH24), //# - ENUM2STRING(BOTH_DEATH25), //# + ENUM2STRING(BOTH_DEATH12), //# + ENUM2STRING(BOTH_DEATH13), //# + ENUM2STRING(BOTH_DEATH14), //# + ENUM2STRING(BOTH_DEATH15), //# + ENUM2STRING(BOTH_DEATH16), //# + ENUM2STRING(BOTH_DEATH17), //# + ENUM2STRING(BOTH_DEATH18), //# + ENUM2STRING(BOTH_DEATH19), //# + ENUM2STRING(BOTH_DEATH20), //# + ENUM2STRING(BOTH_DEATH21), //# + ENUM2STRING(BOTH_DEATH22), //# + ENUM2STRING(BOTH_DEATH23), //# + ENUM2STRING(BOTH_DEATH24), //# + ENUM2STRING(BOTH_DEATH25), //# ENUM2STRING(BOTH_DEATHFORWARD1), //# First Death in which they get thrown forward ENUM2STRING(BOTH_DEATHFORWARD2), //# Second Death in which they get thrown forward @@ -85,24 +85,24 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_DEAD5), //# Fifth Death finished pose ENUM2STRING(BOTH_DEAD6), //# Sixth Death finished pose ENUM2STRING(BOTH_DEAD7), //# Seventh Death finished pose - ENUM2STRING(BOTH_DEAD8), //# - ENUM2STRING(BOTH_DEAD9), //# - ENUM2STRING(BOTH_DEAD10), //# + ENUM2STRING(BOTH_DEAD8), //# + ENUM2STRING(BOTH_DEAD9), //# + ENUM2STRING(BOTH_DEAD10), //# ENUM2STRING(BOTH_DEAD11), //# - ENUM2STRING(BOTH_DEAD12), //# - ENUM2STRING(BOTH_DEAD13), //# - ENUM2STRING(BOTH_DEAD14), //# - ENUM2STRING(BOTH_DEAD15), //# - ENUM2STRING(BOTH_DEAD16), //# - ENUM2STRING(BOTH_DEAD17), //# - ENUM2STRING(BOTH_DEAD18), //# - ENUM2STRING(BOTH_DEAD19), //# - ENUM2STRING(BOTH_DEAD20), //# - ENUM2STRING(BOTH_DEAD21), //# - ENUM2STRING(BOTH_DEAD22), //# - ENUM2STRING(BOTH_DEAD23), //# - ENUM2STRING(BOTH_DEAD24), //# - ENUM2STRING(BOTH_DEAD25), //# + ENUM2STRING(BOTH_DEAD12), //# + ENUM2STRING(BOTH_DEAD13), //# + ENUM2STRING(BOTH_DEAD14), //# + ENUM2STRING(BOTH_DEAD15), //# + ENUM2STRING(BOTH_DEAD16), //# + ENUM2STRING(BOTH_DEAD17), //# + ENUM2STRING(BOTH_DEAD18), //# + ENUM2STRING(BOTH_DEAD19), //# + ENUM2STRING(BOTH_DEAD20), //# + ENUM2STRING(BOTH_DEAD21), //# + ENUM2STRING(BOTH_DEAD22), //# + ENUM2STRING(BOTH_DEAD23), //# + ENUM2STRING(BOTH_DEAD24), //# + ENUM2STRING(BOTH_DEAD25), //# ENUM2STRING(BOTH_DEADFORWARD1), //# First thrown forward death finished pose ENUM2STRING(BOTH_DEADFORWARD2), //# Second thrown forward death finished pose ENUM2STRING(BOTH_DEADBACKWARD1), //# First thrown backward death finished pose @@ -115,7 +115,7 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_DEADFLOP2), //# React to being shot from Second Death finished pose ENUM2STRING(BOTH_DEADFLOP3), //# React to being shot from Third Death finished pose ENUM2STRING(BOTH_DEADFLOP4), //# React to being shot from Fourth Death finished pose - ENUM2STRING(BOTH_DEADFLOP5), //# React to being shot from Fifth Death finished pose + ENUM2STRING(BOTH_DEADFLOP5), //# React to being shot from Fifth Death finished pose ENUM2STRING(BOTH_DEADFORWARD1_FLOP), //# React to being shot First thrown forward death finished pose ENUM2STRING(BOTH_DEADFORWARD2_FLOP), //# React to being shot Second thrown forward death finished pose ENUM2STRING(BOTH_DEADBACKWARD1_FLOP), //# React to being shot First thrown backward death finished pose @@ -138,17 +138,17 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_PAIN6), //# Sixth take pain anim - from behind ENUM2STRING(BOTH_PAIN7), //# Seventh take pain anim - from behind ENUM2STRING(BOTH_PAIN8), //# Eigth take pain anim - from behind - ENUM2STRING(BOTH_PAIN9), //# - ENUM2STRING(BOTH_PAIN10), //# - ENUM2STRING(BOTH_PAIN11), //# - ENUM2STRING(BOTH_PAIN12), //# - ENUM2STRING(BOTH_PAIN13), //# - ENUM2STRING(BOTH_PAIN14), //# - ENUM2STRING(BOTH_PAIN15), //# - ENUM2STRING(BOTH_PAIN16), //# - ENUM2STRING(BOTH_PAIN17), //# - ENUM2STRING(BOTH_PAIN18), //# - ENUM2STRING(BOTH_PAIN19), //# + ENUM2STRING(BOTH_PAIN9), //# + ENUM2STRING(BOTH_PAIN10), //# + ENUM2STRING(BOTH_PAIN11), //# + ENUM2STRING(BOTH_PAIN12), //# + ENUM2STRING(BOTH_PAIN13), //# + ENUM2STRING(BOTH_PAIN14), //# + ENUM2STRING(BOTH_PAIN15), //# + ENUM2STRING(BOTH_PAIN16), //# + ENUM2STRING(BOTH_PAIN17), //# + ENUM2STRING(BOTH_PAIN18), //# + ENUM2STRING(BOTH_PAIN19), //# ENUM2STRING(BOTH_PAIN20), //# GETTING SHOCKED //# #sep ENUM2STRING(BOTH_ ATTACKS @@ -679,9 +679,9 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_STAND5_REELO), //# Reelo in his stand5 position (cin #18) ENUM2STRING(BOTH_STAND1TOSTAND5), //# Transition from stand1 to stand5 ENUM2STRING(BOTH_STAND5TOSTAND1), //# Transition from stand5 to stand1 - ENUM2STRING(BOTH_STAND5TOAIM), //# Transition of Kye aiming his gun at Desann (cin #9) - ENUM2STRING(BOTH_STAND5STARTLEDLOOKLEFT), //# Kyle turning to watch the bridge drop (cin #9) - ENUM2STRING(BOTH_STARTLEDLOOKLEFTTOSTAND5), //# Kyle returning to stand 5 from watching the bridge drop (cin #9) + ENUM2STRING(BOTH_STAND5TOAIM), //# Transition of Kye aiming his gun at Desann (cin #9) + ENUM2STRING(BOTH_STAND5STARTLEDLOOKLEFT), //# Kyle turning to watch the bridge drop (cin #9) + ENUM2STRING(BOTH_STARTLEDLOOKLEFTTOSTAND5), //# Kyle returning to stand 5 from watching the bridge drop (cin #9) ENUM2STRING(BOTH_STAND5TOSTAND8), //# Transition from stand5 to stand8 ENUM2STRING(BOTH_STAND7TOSTAND8), //# Tavion putting hands on back of chair (cin #11) ENUM2STRING(BOTH_STAND8TOSTAND5), //# Transition from stand8 to stand5 @@ -698,11 +698,11 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_CONSOLE1START), //# typing at a console ENUM2STRING(BOTH_CONSOLE1), //# typing at a console ENUM2STRING(BOTH_CONSOLE1STOP), //# typing at a console - ENUM2STRING(BOTH_CONSOLE2START), //# typing at a console with comm link in hand (cin #5) - ENUM2STRING(BOTH_CONSOLE2), //# typing at a console with comm link in hand (cin #5) - ENUM2STRING(BOTH_CONSOLE2STOP), //# typing at a console with comm link in hand (cin #5) - ENUM2STRING(BOTH_CONSOLE2HOLDCOMSTART), //# lean in to type at console while holding comm link in hand (cin #5) - ENUM2STRING(BOTH_CONSOLE2HOLDCOMSTOP), //# lean away after typing at console while holding comm link in hand (cin #5) + ENUM2STRING(BOTH_CONSOLE2START), //# typing at a console with comm link in hand (cin #5) + ENUM2STRING(BOTH_CONSOLE2), //# typing at a console with comm link in hand (cin #5) + ENUM2STRING(BOTH_CONSOLE2STOP), //# typing at a console with comm link in hand (cin #5) + ENUM2STRING(BOTH_CONSOLE2HOLDCOMSTART), //# lean in to type at console while holding comm link in hand (cin #5) + ENUM2STRING(BOTH_CONSOLE2HOLDCOMSTOP), //# lean away after typing at console while holding comm link in hand (cin #5) ENUM2STRING(BOTH_GUARD_LOOKAROUND1), //# Cradling weapon and looking around ENUM2STRING(BOTH_GUARD_IDLE1), //# Cradling weapon and standing @@ -732,9 +732,9 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_TALKGESTURE7START), //# Start touches Kyle on shoulder ENUM2STRING(BOTH_TALKGESTURE7), //# Hold touches Kyle on shoulder ENUM2STRING(BOTH_TALKGESTURE7STOP), //# Ending touches Kyle on shoulder - ENUM2STRING(BOTH_TALKGESTURE8START), //# Lando's chin hold - ENUM2STRING(BOTH_TALKGESTURE8), //# Lando's chin hold - ENUM2STRING(BOTH_TALKGESTURE8STOP), //# Lando's chin hold + ENUM2STRING(BOTH_TALKGESTURE8START), //# Lando's chin hold + ENUM2STRING(BOTH_TALKGESTURE8), //# Lando's chin hold + ENUM2STRING(BOTH_TALKGESTURE8STOP), //# Lando's chin hold ENUM2STRING(BOTH_TALKGESTURE9), //# Same as gesture 2 but with the right hand ENUM2STRING(BOTH_TALKGESTURE10), //# Shoulder shrug ENUM2STRING(BOTH_TALKGESTURE11START), //# Arms folded across chest @@ -779,9 +779,9 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_REACH1START), //# Monmothma reaching for crystal ENUM2STRING(BOTH_REACH1STOP), //# Monmothma reaching for crystal - ENUM2STRING(BOTH_EXAMINE1START), //# Start Mon Mothma examining crystal - ENUM2STRING(BOTH_EXAMINE1), //# Mon Mothma examining crystal - ENUM2STRING(BOTH_EXAMINE1STOP), //# Stop Mon Mothma examining crystal + ENUM2STRING(BOTH_EXAMINE1START), //# Start Mon Mothma examining crystal + ENUM2STRING(BOTH_EXAMINE1), //# Mon Mothma examining crystal + ENUM2STRING(BOTH_EXAMINE1STOP), //# Stop Mon Mothma examining crystal ENUM2STRING(BOTH_EXAMINE2START), //# Start Kyle tossing crystal ENUM2STRING(BOTH_EXAMINE2), //# Hold Kyle tossing crystal ENUM2STRING(BOTH_EXAMINE2STOP), //# End Kyle tossing crystal @@ -960,7 +960,7 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_WALKBACK2), //# Walk2 backwards ENUM2STRING(BOTH_RUNBACK1), //# Run1 backwards ENUM2STRING(BOTH_RUNBACK2), //# Run1 backwards - + //# #sep BOTH_ JUMPING ENUM2STRING(BOTH_JUMP1), //# Jump - wind-up and leave ground ENUM2STRING(BOTH_INAIR1), //# In air loop (from jump) @@ -1024,24 +1024,24 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_DIVE1), //# Dive! ENUM2STRING(BOTH_ENGAGETAUNT), - ENUM2STRING(BOTH_ARIAL_LEFT), //# - ENUM2STRING(BOTH_ARIAL_RIGHT), //# - ENUM2STRING(BOTH_CARTWHEEL_LEFT), //# - ENUM2STRING(BOTH_CARTWHEEL_RIGHT), //# - ENUM2STRING(BOTH_FLIP_LEFT), //# - ENUM2STRING(BOTH_FLIP_BACK1), //# - ENUM2STRING(BOTH_FLIP_BACK2), //# - ENUM2STRING(BOTH_FLIP_BACK3), //# - ENUM2STRING(BOTH_BUTTERFLY_LEFT), //# - ENUM2STRING(BOTH_BUTTERFLY_RIGHT), //# - ENUM2STRING(BOTH_WALL_RUN_RIGHT), //# + ENUM2STRING(BOTH_ARIAL_LEFT), //# + ENUM2STRING(BOTH_ARIAL_RIGHT), //# + ENUM2STRING(BOTH_CARTWHEEL_LEFT), //# + ENUM2STRING(BOTH_CARTWHEEL_RIGHT), //# + ENUM2STRING(BOTH_FLIP_LEFT), //# + ENUM2STRING(BOTH_FLIP_BACK1), //# + ENUM2STRING(BOTH_FLIP_BACK2), //# + ENUM2STRING(BOTH_FLIP_BACK3), //# + ENUM2STRING(BOTH_BUTTERFLY_LEFT), //# + ENUM2STRING(BOTH_BUTTERFLY_RIGHT), //# + ENUM2STRING(BOTH_WALL_RUN_RIGHT), //# ENUM2STRING(BOTH_WALL_RUN_RIGHT_FLIP),//# - ENUM2STRING(BOTH_WALL_RUN_RIGHT_STOP),//# - ENUM2STRING(BOTH_WALL_RUN_LEFT), //# + ENUM2STRING(BOTH_WALL_RUN_RIGHT_STOP),//# + ENUM2STRING(BOTH_WALL_RUN_LEFT), //# ENUM2STRING(BOTH_WALL_RUN_LEFT_FLIP),//# - ENUM2STRING(BOTH_WALL_RUN_LEFT_STOP),//# - ENUM2STRING(BOTH_WALL_FLIP_RIGHT), //# - ENUM2STRING(BOTH_WALL_FLIP_LEFT), //# + ENUM2STRING(BOTH_WALL_RUN_LEFT_STOP),//# + ENUM2STRING(BOTH_WALL_FLIP_RIGHT), //# + ENUM2STRING(BOTH_WALL_FLIP_LEFT), //# ENUM2STRING(BOTH_WALL_FLIP_FWD), //# ENUM2STRING(BOTH_KNOCKDOWN1), //# knocked backwards ENUM2STRING(BOTH_KNOCKDOWN2), //# knocked backwards hard @@ -1112,7 +1112,7 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = //# #sep BOTH_ SWIMMING ENUM2STRING(BOTH_SWIM_IDLE1), //# Swimming Idle 1 ENUM2STRING(BOTH_SWIMFORWARD), //# Swim forward loop - + //# #sep ENUM2STRING(BOTH_ LYING ENUM2STRING(BOTH_LIE_DOWN1), //# From a stand position), get down on ground), face down ENUM2STRING(BOTH_LIE_DOWN2), //# From a stand position), get down on ground), face up @@ -1128,7 +1128,7 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_INJURED2), //# Injured pose 2 ENUM2STRING(BOTH_INJURED3), //# Injured pose 3 ENUM2STRING(BOTH_INJURED6), //# Injured pose 6 - ENUM2STRING(BOTH_INJURED6ATTACKSTART), //# Start attack while in injured 6 pose + ENUM2STRING(BOTH_INJURED6ATTACKSTART), //# Start attack while in injured 6 pose ENUM2STRING(BOTH_INJURED6ATTACKSTOP), //# End attack while in injured 6 pose ENUM2STRING(BOTH_INJURED6COMBADGE), //# Hit combadge while in injured 6 pose ENUM2STRING(BOTH_INJURED6POINT), //# Chang points to door while in injured state @@ -1145,7 +1145,7 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_SLEEP6START), //# Kyle leaning back to sleep (cin 20) ENUM2STRING(BOTH_SLEEP6STOP), //# Kyle waking up and shaking his head (cin 21) ENUM2STRING(BOTH_SLEEP1GETUP), //# alarmed and getting up out of sleep1 pose to stand - ENUM2STRING(BOTH_SLEEP1GETUP2), //# + ENUM2STRING(BOTH_SLEEP1GETUP2), //# ENUM2STRING(BOTH_SLEEP2GETUP), //# alarmed and getting up out of sleep2 pose to stand ENUM2STRING(BOTH_SLEEP3GETUP), //# alarmed and getting up out of sleep3 pose to stand ENUM2STRING(BOTH_SLEEP3DEATH), //# death in chair), from sleep3 idle @@ -1220,7 +1220,7 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_COCKPIT_CONSOLE1), //# type at controls ENUM2STRING(BOTH_COCKPIT_CONSOLE2), //# type at controls - ENUM2STRING(BOTH_COCKPIT_CONSOLE2_PARTIAL), //# last part of console2 anim (cin #1) used by Jan + ENUM2STRING(BOTH_COCKPIT_CONSOLE2_PARTIAL), //# last part of console2 anim (cin #1) used by Jan ENUM2STRING(BOTH_COCKPIT_HEADNOD), //# nod head yes while sitting ENUM2STRING(BOTH_COCKPIT_HEADSHAKE), //# shake head no while sitting @@ -1234,11 +1234,11 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_COCKPIT_TALKGESTURE7STOP), //# Lando's supporting hand away from Kyle (cin #21) ENUM2STRING(BOTH_COCKPIT_TALKGESTURE8START), //# Hand to Lando's chin (cin #21) ENUM2STRING(BOTH_COCKPIT_TALKGESTURE8STOP), //# hand away from Lando's chin *cin #21) - ENUM2STRING(BOTH_COCKPIT_TALKGESTURE11START), //# - ENUM2STRING(BOTH_COCKPIT_TALKGESTURE11STOP), //# + ENUM2STRING(BOTH_COCKPIT_TALKGESTURE11START), //# + ENUM2STRING(BOTH_COCKPIT_TALKGESTURE11STOP), //# - ENUM2STRING(BOTH_COCKPIT_SLEEP6START), //# - ENUM2STRING(BOTH_COCKPIT_SLEEP6STOP), //# + ENUM2STRING(BOTH_COCKPIT_SLEEP6START), //# + ENUM2STRING(BOTH_COCKPIT_SLEEP6STOP), //# //================================================= //ANIMS IN WHICH ONLY THE UPPER OBJECTS ARE IN MD3 @@ -1377,10 +1377,10 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(FACE_TALK2), //# semi-quiet ENUM2STRING(FACE_TALK3), //# semi-loud ENUM2STRING(FACE_TALK4), //# loud - ENUM2STRING(FACE_ALERT), //# - ENUM2STRING(FACE_SMILE), //# - ENUM2STRING(FACE_FROWN), //# - ENUM2STRING(FACE_DEAD), //# + ENUM2STRING(FACE_ALERT), //# + ENUM2STRING(FACE_SMILE), //# + ENUM2STRING(FACE_FROWN), //# + ENUM2STRING(FACE_DEAD), //# //must be terminated {NULL,-1} diff --git a/codeJK2/cgame/cg_camera.cpp b/codeJK2/cgame/cg_camera.cpp index 5abb11956a..a25020850d 100644 --- a/codeJK2/cgame/cg_camera.cpp +++ b/codeJK2/cgame/cg_camera.cpp @@ -81,7 +81,7 @@ void CGCam_Enable( void ) client_camera.bar_alpha_source = 0.0f; client_camera.bar_alpha_dest = 1.0f; - + client_camera.bar_height_source = 0.0f; client_camera.bar_height_dest = 480/10; client_camera.bar_height = 0.0f; @@ -142,7 +142,7 @@ void CGCam_Disable( void ) client_camera.bar_alpha_source = 1.0f; client_camera.bar_alpha_dest = 0.0f; - + client_camera.bar_height_source = 480/10; client_camera.bar_height_dest = 0.0f; @@ -200,7 +200,7 @@ void CGCam_Move( vec3_t dest, float duration ) client_camera.info_state |= CAMERA_MOVING; VectorCopy( dest, client_camera.origin2 ); - + client_camera.move_duration = duration; client_camera.move_time = cg.time; } @@ -242,7 +242,7 @@ void CGCam_Pan( vec3_t dest, vec3_t panDirection, float duration ) //FIXME: make the dest an absolute value, and pass in a //panDirection as well. If a panDirection's axis value is //zero, find the shortest difference for that axis. - //Store the delta in client_camera.angles2. + //Store the delta in client_camera.angles2. for( i = 0; i < 3; i++ ) { dest[i] = AngleNormalize360( dest[i] ); @@ -300,7 +300,7 @@ void CGCam_Pan( vec3_t dest, vec3_t panDirection, float duration ) //VectorCopy( dest, client_camera.angles2 ); client_camera.info_state |= CAMERA_PANNING; - + client_camera.pan_duration = duration; client_camera.pan_time = cg.time; } @@ -332,10 +332,10 @@ void CGCam_Roll( float dest, float duration ) //FIXME/NOTE: this will override current panning!!! client_camera.info_state |= CAMERA_PANNING; - + VectorCopy( client_camera.angles, client_camera.angles2 ); client_camera.angles2[2] = AngleDelta( dest, client_camera.angles[2] ); - + client_camera.pan_duration = duration; client_camera.pan_time = cg.time; } @@ -447,7 +447,7 @@ void CGCam_Follow( const char *cameraGroup, float speed, float initLerp ) {//Turn off all aiming return; } - + if ( Q_stricmp("NULL", (char *)cameraGroup) == 0 ) {//Turn off all aiming return; @@ -661,7 +661,7 @@ void CGCam_FollowUpdate ( void ) centity_t *fromCent = NULL; int num_subjects = 0, i; qboolean focused = qfalse; - + if ( client_camera.cameraGroup[0] ) { //Stay centered in my cameraGroup, if I have one @@ -718,11 +718,11 @@ void CGCam_FollowUpdate ( void ) else { VectorCopy(from->currentOrigin, focus[num_subjects]); - } + } //FIXME: make a list here of their s.numbers instead so we can do other stuff with the list below if ( from->client ) {//Track to their eyes - FIXME: maybe go off a tag? - //FIXME: + //FIXME: //Based on FOV and distance to subject from camera, pick the point that //keeps eyes 3/4 up from bottom of screen... what about bars? focus[num_subjects][2] += from->client->ps.viewheight; @@ -735,7 +735,7 @@ void CGCam_FollowUpdate ( void ) num_subjects++; } - if ( !num_subjects ) // Bad cameragroup + if ( !num_subjects ) // Bad cameragroup { #ifndef FINAL_BUILD gi.Printf(S_COLOR_RED"ERROR: Camera Focus unable to locate cameragroup: %s\n", client_camera.cameraGroup); @@ -774,7 +774,7 @@ void CGCam_FollowUpdate ( void ) //Get desired angle vectoangles(dir, cameraAngles); - + if ( client_camera.followInitLerp ) {//Lerping float frac = cg.frametime/100.0f * client_camera.followSpeed/100.f; @@ -830,10 +830,10 @@ void CGCam_TrackEntUpdate ( void ) reached = qtrue; } } - + if ( trackEnt && reached ) { - + if ( trackEnt->target && trackEnt->target[0] ) {//Find our next path_corner newTrackEnt = G_Find( NULL, FOFS(targetname), trackEnt->target ); @@ -867,8 +867,8 @@ void CGCam_TrackEntUpdate ( void ) if ( newTrackEnt ) {//Update will lerp this - client_camera.info_state |= CAMERA_TRACKING; - client_camera.trackEntNum = newTrackEnt->s.number; + client_camera.info_state |= CAMERA_TRACKING; + client_camera.trackEntNum = newTrackEnt->s.number; VectorCopy( newTrackEnt->currentOrigin, client_camera.trackToOrg ); } @@ -913,7 +913,7 @@ void CGCam_TrackUpdate ( void ) return; } else if ( client_camera.subjectSpeed > 0.05f ) - {//Don't start moving until subject moves + {//Don't start moving until subject moves VectorSubtract( client_camera.subjectPos, client_camera.origin, vec ); dist = VectorNormalize(vec); dot = DotProduct(goalVec, vec); @@ -940,13 +940,13 @@ void CGCam_TrackUpdate ( void ) adjust = (client_camera.distance - dist);//Speed up } } - + //Speed of the focus + our error //desiredSpeed = aimCent->gent->speed + (adjust * cg.frametime/100.0f);//cg.frameInterpolation); desiredSpeed = (adjust);// * cg.frametime/100.0f);//cg.frameInterpolation); - + //self->moveInfo.speed = desiredSpeed; - + //Don't change speeds faster than 10 every 10th of a second float max_allowed_accel = MAX_ACCEL_PER_FRAME * (cg.frametime/100.0f); @@ -974,7 +974,7 @@ void CGCam_TrackUpdate ( void ) { //slowDown = qtrue; } - + //FIXME: this probably isn't right, round it out more VectorScale( goalVec, cg.frametime/100.0f, goalVec ); @@ -1113,7 +1113,7 @@ void CGCam_Update( void ) } } } - else + else { checkFollow = qtrue; } @@ -1193,7 +1193,7 @@ void CGCam_DrawWideScreen( void ) modulate[0] = modulate[1] = modulate[2] = 0.0f; modulate[3] = client_camera.bar_alpha; - + CG_FillRect( cg.refdef.x, cg.refdef.y, 640, client_camera.bar_height, modulate ); CG_FillRect( cg.refdef.x, cg.refdef.y + 480 - client_camera.bar_height, 640, client_camera.bar_height, modulate ); } @@ -1336,7 +1336,7 @@ void CGCam_StartRoff( char *roff ) CGCam_FollowDisable(); CGCam_TrackDisable(); - // Set up the roff state info..we'll hijack the moving and panning code until told otherwise + // Set up the roff state info..we'll hijack the moving and panning code until told otherwise // ...CAMERA_FOLLOWING would be a case that could override this.. client_camera.info_state |= CAMERA_MOVING; client_camera.info_state |= CAMERA_PANNING; @@ -1374,7 +1374,7 @@ static void CGCam_StopRoff( void ) ------------------------------------------------------ CGCam_Roff -Applies the sampled roff data to the camera and does +Applies the sampled roff data to the camera and does the lerping itself...this is done because the current camera interpolation doesn't seem to work all that great when you are adjusting the camera org and angles @@ -1422,7 +1422,7 @@ static void CGCam_Roff( void ) #ifdef _DEBUG if ( cg_developer.integer ) { - Com_Printf( S_COLOR_GREEN"CamROFF : o:<%.2f %.2f %.2f> a:<%.2f %.2f %.2f>\n", + Com_Printf( S_COLOR_GREEN"CamROFF : o:<%.2f %.2f %.2f> a:<%.2f %.2f %.2f>\n", org[0], org[1], org[2], ang[0], ang[1], ang[2] ); } @@ -1454,7 +1454,7 @@ static void CGCam_Roff( void ) if ( ++client_camera.roff_frame >= roff->frames ) { - CGCam_StopRoff(); + CGCam_StopRoff(); return; } diff --git a/codeJK2/cgame/cg_camera.h b/codeJK2/cgame/cg_camera.h index 7f068458bb..d3772ab734 100644 --- a/codeJK2/cgame/cg_camera.h +++ b/codeJK2/cgame/cg_camera.h @@ -50,7 +50,7 @@ typedef struct camera_s //Position / Facing information vec3_t origin; vec3_t angles; - + vec3_t origin2; vec3_t angles2; @@ -95,7 +95,7 @@ typedef struct camera_s float bar_alpha_source; float bar_alpha_dest; float bar_time; - + float bar_height_source; float bar_height_dest; float bar_height; @@ -123,9 +123,9 @@ typedef struct camera_s // ROFF information - char sRoff[MAX_QPATH]; // name of a cached roff + char sRoff[MAX_QPATH]; // name of a cached roff int roff_frame; // current frame in the roff data - int next_roff_time; // time when it's ok to apply the next roff frame + int next_roff_time; // time when it's ok to apply the next roff frame } camera_t; diff --git a/codeJK2/cgame/cg_consolecmds.cpp b/codeJK2/cgame/cg_consolecmds.cpp index 6a67a67b55..7be6eb72f3 100644 --- a/codeJK2/cgame/cg_consolecmds.cpp +++ b/codeJK2/cgame/cg_consolecmds.cpp @@ -63,7 +63,7 @@ Debugging command to print the current position */ static void CG_Viewpos_f (void) { CG_Printf ("%s (%i %i %i) : %i\n", cgs.mapname, (int)cg.refdef.vieworg[0], - (int)cg.refdef.vieworg[1], (int)cg.refdef.vieworg[2], + (int)cg.refdef.vieworg[1], (int)cg.refdef.vieworg[2], (int)cg.refdefViewAngles[YAW]); } @@ -74,7 +74,7 @@ void CG_WriteCam_f (void) static int numCams; numCams++; - + targetname = CG_Argv(1); if( !targetname || !targetname[0] ) @@ -184,10 +184,10 @@ void CG_ToggleLAGoggles( void ) } } -void CG_LoadHud_f( void) +void CG_LoadHud_f( void) { const char *hudSet = cg_hudFiles.string; - if ( hudSet[0] == '\0' ) + if ( hudSet[0] == '\0' ) hudSet = "ui/jk2hud.txt"; CG_LoadMenus(hudSet); diff --git a/codeJK2/cgame/cg_credits.cpp b/codeJK2/cgame/cg_credits.cpp index 4ffde22e99..7ce10c56f1 100644 --- a/codeJK2/cgame/cg_credits.cpp +++ b/codeJK2/cgame/cg_credits.cpp @@ -126,7 +126,7 @@ static const char *Capitalize( const char *psTest ) static char sTemp[MAX_LINE_BYTES]; Q_strncpyz(sTemp, psTest, sizeof(sTemp)); - + if (!cgi_Language_IsAsian()) { Q_strupr(sTemp); // capitalise titles (if not asian!!!!) @@ -136,7 +136,7 @@ static const char *Capitalize( const char *psTest ) } static bool CountsAsWhiteSpaceForCaps( char c ) -{ +{ return !!(isspace(c) || c == '-' || c == '.' || c == '(' || c == ')'); } static const char *UpperCaseFirstLettersOnly( const char *psTest ) @@ -144,7 +144,7 @@ static const char *UpperCaseFirstLettersOnly( const char *psTest ) static char sTemp[MAX_LINE_BYTES]; Q_strncpyz(sTemp, psTest, sizeof(sTemp)); - + if (!cgi_Language_IsAsian()) { Q_strlwr(sTemp); @@ -188,7 +188,7 @@ static const char *GetSubString(std::string &strResult) if (!strlen(strResult.c_str())) return NULL; - + Q_strncpyz(sTemp,strResult.c_str(),sizeof(sTemp)); char *psSemiColon = strchr(sTemp,';'); @@ -214,7 +214,7 @@ static bool SortBySurname(const StringAndSize_t &str1, const StringAndSize_t &st { std::string::const_reverse_iterator rstart1 = std::find_if(str1.str.rbegin(), str1.str.rend(), isspace); std::string::const_reverse_iterator rstart2 = std::find_if(str2.str.rbegin(), str2.str.rend(), isspace); - + return Q_stricmp(&*rstart1.base(), &*rstart2.base()) < 0; } @@ -231,14 +231,14 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color ) memcpy(gv4Color,pv4Color,sizeof(gv4Color)); // memcpy so we can poke into alpha channel // first, ask the strlen of the final string... - // + // int iStrLen = cgi_SP_GetStringTextString( psStripReference, NULL, 0 ); if (!iStrLen) { #ifndef FINAL_BUILD Com_Printf("WARNING: CG_Credits_Init(): invalid text key :'%s'\n", psStripReference); #endif - return; + return; } // // malloc space to hold it... @@ -246,7 +246,7 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color ) char *psMallocText = (char *) cgi_Z_Malloc( iStrLen+1, TAG_TEMP_WORKSPACE ); // // now get the string... - // + // iStrLen = cgi_SP_GetStringTextString( psStripReference, psMallocText, iStrLen+1 ); //ensure we found a match if (!iStrLen) @@ -256,7 +256,7 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color ) #ifndef FINAL_BUILD Com_Printf("WARNING: CG_Credits_Init(): invalid text key :'%s'\n", psStripReference); #endif - return; + return; } // read whole string in and process as cards, lines etc... @@ -278,7 +278,7 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color ) while (*psTextParse != '\0') { // read a line... - // + // char sLine[MAX_LINE_BYTES]; sLine[0]='\0'; qboolean bWasCommand = qtrue; @@ -383,17 +383,17 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color ) switch (eMode) { case eNothing: break; - case eLine: + case eLine: { CreditLine_t CreditLine; - CreditLine.iLine = iLineNumber++; + CreditLine.iLine = iLineNumber++; CreditLine.strText = sLine; CreditData.CreditLines.push_back( CreditLine ); } break; - case eDotEntry: + case eDotEntry: { CreditLine_t CreditLine; CreditLine.iLine = iLineNumber; @@ -425,7 +425,7 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color ) } break; - case eTitle: + case eTitle: { iLineNumber++; // leading blank line @@ -441,7 +441,7 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color ) case eCard: { CreditCard_t CreditCard; - + std::string strResult(sLine); const char *p; while ((p=GetSubString(strResult)) != NULL) diff --git a/codeJK2/cgame/cg_draw.cpp b/codeJK2/cgame/cg_draw.cpp index 35b02669eb..d0a0df6603 100644 --- a/codeJK2/cgame/cg_draw.cpp +++ b/codeJK2/cgame/cg_draw.cpp @@ -102,7 +102,7 @@ CG_DrawHead Used for both the status bar and the scoreboard ================ */ -void CG_DrawHead( float x, float y, float w, float h, int speaker_i, vec3_t headAngles ) +void CG_DrawHead( float x, float y, float w, float h, int speaker_i, vec3_t headAngles ) { qhandle_t hm = 0; qhandle_t hs = 0; @@ -130,7 +130,7 @@ void CG_DrawHead( float x, float y, float w, float h, int speaker_i, vec3_t head } if ( !hm ) - { + { return; } @@ -154,7 +154,7 @@ void CG_DrawHead( float x, float y, float w, float h, int speaker_i, vec3_t head // calculate distance so the head nearly fills the box // assume heads are taller than wide - len = 0.7 * ( maxs[2] - mins[2] ); + len = 0.7 * ( maxs[2] - mins[2] ); origin[0] = len / 0.268; // len / tan( fov/2 ) CG_Draw3DModel( x, y, w, h, hm, hs, origin, headAngles ); @@ -171,9 +171,9 @@ static void CG_DrawTalk(centity_t *cent) float size; vec3_t angles; // int totalLines,y,i; - vec4_t color; + vec4_t color; - if ( cg.gameNextTextTime > cg.time) + if ( cg.gameNextTextTime > cg.time) { color[0] = colorTable[CT_BLACK][0]; color[1] = colorTable[CT_BLACK][1]; @@ -228,7 +228,7 @@ static void CG_DrawHUDRightFrame1(int x,int y) { cgi_R_SetColor( colorTable[CT_WHITE] ); // Inner gray wire frame - CG_DrawPic( x, y, 80, 80, cgs.media.HUDInnerRight ); // + CG_DrawPic( x, y, 80, 80, cgs.media.HUDInnerRight ); // } /* @@ -326,10 +326,10 @@ static void CG_DrawForcePower(centity_t *cent,int x,int y) } cgi_R_SetColor( calcColor); - CG_DrawPic( x + forceTicPos[i].x, - y + forceTicPos[i].y, - forceTicPos[i].width, - forceTicPos[i].height, + CG_DrawPic( x + forceTicPos[i].x, + y + forceTicPos[i].y, + forceTicPos[i].width, + forceTicPos[i].height, forceTicPos[i].tic ); value -= inc; @@ -412,10 +412,10 @@ static void CG_DrawAmmo(centity_t *cent,int x,int y) && cg.predicted_player_state.weaponTime > 100 )) { numColor_i = CT_LTGREY; - } - else + } + else { - if ( value > 0 ) + if ( value > 0 ) { if (cg.oldAmmoTime > cg.time) { @@ -425,14 +425,14 @@ static void CG_DrawAmmo(centity_t *cent,int x,int y) { numColor_i = CT_HUD_ORANGE; } - } - else + } + else { numColor_i = CT_RED; } } - cgi_R_SetColor( colorTable[numColor_i] ); + cgi_R_SetColor( colorTable[numColor_i] ); CG_DrawNumField(x + 29, y + 26, 3, value, 6, 12, NUM_FONT_SMALL,qfalse); inc = (float) ammoData[weaponData[cent->currentState.weapon].ammoIndex].max / MAX_TICS; @@ -459,10 +459,10 @@ static void CG_DrawAmmo(centity_t *cent,int x,int y) } cgi_R_SetColor( calcColor); - CG_DrawPic( x + ammoTicPos[i].x, - y + ammoTicPos[i].y, - ammoTicPos[i].width, - ammoTicPos[i].height, + CG_DrawPic( x + ammoTicPos[i].x, + y + ammoTicPos[i].y, + ammoTicPos[i].width, + ammoTicPos[i].height, ammoTicPos[i].tic ); value -= inc; @@ -479,7 +479,7 @@ static void CG_DrawHUDLeftFrame1(int x,int y) { // Inner gray wire frame cgi_R_SetColor( colorTable[CT_WHITE] ); - CG_DrawPic( x, y, 80, 80, cgs.media.HUDInnerLeft ); + CG_DrawPic( x, y, 80, 80, cgs.media.HUDInnerLeft ); } /* @@ -511,18 +511,18 @@ static void CG_DrawHealth(int x,int y) calcColor[0] *= healthPercent; calcColor[1] *= healthPercent; calcColor[2] *= healthPercent; - cgi_R_SetColor( calcColor); + cgi_R_SetColor( calcColor); CG_DrawPic( x, y, 80, 80, cgs.media.HUDHealth ); // Draw the ticks if (cg.HUDHealthFlag) { - cgi_R_SetColor( colorTable[CT_HUD_RED] ); + cgi_R_SetColor( colorTable[CT_HUD_RED] ); CG_DrawPic( x, y, 80, 80, cgs.media.HUDHealthTic ); } - cgi_R_SetColor( colorTable[CT_HUD_RED] ); - CG_DrawNumField (x + 16, y + 40, 3, ps->stats[STAT_HEALTH], 6, 12, + cgi_R_SetColor( colorTable[CT_HUD_RED] ); + CG_DrawNumField (x + 16, y + 40, 3, ps->stats[STAT_HEALTH], 6, 12, NUM_FONT_SMALL,qtrue); } @@ -552,8 +552,8 @@ static void CG_DrawArmor(int x,int y) calcColor[0] *= armorPercent; calcColor[1] *= armorPercent; calcColor[2] *= armorPercent; - cgi_R_SetColor( calcColor); - CG_DrawPic( x, y, 80, 80, cgs.media.HUDArmor1 ); + cgi_R_SetColor( calcColor); + CG_DrawPic( x, y, 80, 80, cgs.media.HUDArmor1 ); // Inner Armor circular if (armorPercent>0) @@ -568,7 +568,7 @@ static void CG_DrawArmor(int x,int y) calcColor[0] *= armorPercent; calcColor[1] *= armorPercent; calcColor[2] *= armorPercent; - cgi_R_SetColor( calcColor); + cgi_R_SetColor( calcColor); CG_DrawPic( x, y, 80, 80, cgs.media.HUDArmor2 ); // Inner Armor circular /* if (ps->stats[STAT_ARMOR]) // Is there armor? Draw the HUD Armor TIC @@ -601,12 +601,12 @@ static void CG_DrawArmor(int x,int y) if (cg.HUDArmorFlag) { - cgi_R_SetColor( colorTable[CT_HUD_GREEN] ); - CG_DrawPic( x, y, 80, 80, cgs.media.HUDArmorTic ); + cgi_R_SetColor( colorTable[CT_HUD_GREEN] ); + CG_DrawPic( x, y, 80, 80, cgs.media.HUDArmorTic ); } */ - cgi_R_SetColor( colorTable[CT_HUD_GREEN] ); - CG_DrawNumField (x + 16 + 14, y + 40 + 14, 3, ps->stats[STAT_ARMOR], 6, 12, + cgi_R_SetColor( colorTable[CT_HUD_GREEN] ); + CG_DrawNumField (x + 16 + 14, y + 40 + 14, 3, ps->stats[STAT_ARMOR], 6, 12, NUM_FONT_SMALL,qfalse); } @@ -664,12 +664,12 @@ static qboolean CG_DrawCustomHealthHud( centity_t *cent ) // we just calc the display value from the sum of health and armor if ( g_entities[cg.snap->ps.viewEntity].activator ) // ensure we can look back to the atst_drivable to get the max health { - health = ( g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR] ) / + health = ( g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR] ) / (float)(g_entities[cg.snap->ps.viewEntity].max_health + g_entities[cg.snap->ps.viewEntity].activator->max_health ); } else { - health = ( g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR]) / + health = ( g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR]) / (float)(g_entities[cg.snap->ps.viewEntity].max_health + 800 ); // hacked max armor since we don't have an activator...should never happen } @@ -748,14 +748,14 @@ extern void cgi_UI_Menu_Paint( void *menu, qboolean force ); static void CG_DrawHUD( centity_t *cent ) { int x,y,value; - + if (cgi_UI_GetMenuInfo("lefthud",&x,&y)) { // Draw all the HUD elements --eez cgi_UI_Menu_Paint( cgi_UI_GetMenuByName( "lefthud" ), qtrue ); // Draw armor & health values - if ( cg_draw2D.integer == 2 ) + if ( cg_draw2D.integer == 2 ) { CG_DrawSmallStringColor(x+5, y - 60,va("Armor:%d",cg.snap->ps.stats[STAT_ARMOR]), colorTable[CT_HUD_GREEN] ); CG_DrawSmallStringColor(x+5, y - 40,va("Health:%d",cg.snap->ps.stats[STAT_HEALTH]), colorTable[CT_HUD_GREEN] ); @@ -773,7 +773,7 @@ static void CG_DrawHUD( centity_t *cent ) cgi_UI_Menu_Paint( cgi_UI_GetMenuByName( "righthud" ), qtrue ); // Draw armor & health values - if ( cg_draw2D.integer == 2 ) + if ( cg_draw2D.integer == 2 ) { if ( cent->currentState.weapon != WP_SABER && cent->currentState.weapon != WP_STUN_BATON && cent->gent ) { @@ -841,7 +841,7 @@ void CG_DrawDataPadHUD( centity_t *cent ) missionInfo_Updated = qfalse; // Set which force power to show. - // cg_updatedDataPadForcePower is set from Q3_Interface, because force powers would only be given + // cg_updatedDataPadForcePower is set from Q3_Interface, because force powers would only be given // from a script. if (cg_updatedDataPadForcePower1.integer) { @@ -967,7 +967,7 @@ static void CG_DrawZoomMask( void ) cgi_R_SetColor( colorTable[CT_WHITE] ); CG_DrawPic( 34, 48, 570, 362, cgs.media.binocularStatic ); } - + CG_DrawBinocularNumbers( power ); // Black out the area behind the battery display @@ -997,7 +997,7 @@ static void CG_DrawZoomMask( void ) color1[2] = 0.7f + Q_flrand(-1.0f, 1.0f) * 0.1f; color1[3] = 1.0f; cgi_R_SetColor( color1 ); - + CG_DrawPic( 4, 282 - level, 16, 16, cgs.media.binocularArrow ); } else @@ -1037,7 +1037,7 @@ static void CG_DrawZoomMask( void ) } } //------------ - // Disruptor + // Disruptor //-------------------------------- else if ( cg.zoomMode == 2 ) { @@ -1053,7 +1053,7 @@ static void CG_DrawZoomMask( void ) level = 1.0f; } - // Using a magic number to convert the zoom level to a rotation amount that correlates more or less with the zoom artwork. + // Using a magic number to convert the zoom level to a rotation amount that correlates more or less with the zoom artwork. level *= 103.0f; // Draw target mask @@ -1064,7 +1064,7 @@ static void CG_DrawZoomMask( void ) if ( level >= 99 ) { // Fully zoomed, so make the rotating insert pulse - color1[0] = 1.0f; + color1[0] = 1.0f; color1[1] = 1.0f; color1[2] = 1.0f; color1[3] = 0.7f + sin( cg.time * 0.01f ) * 0.3f; @@ -1085,7 +1085,7 @@ static void CG_DrawZoomMask( void ) max = 1.0f; } - color1[0] = (1.0f - max) * 2.0f; + color1[0] = (1.0f - max) * 2.0f; color1[1] = max * 1.5f; color1[2] = 0.0f; color1[3] = 1.0f; @@ -1147,7 +1147,7 @@ static void CG_DrawZoomMask( void ) CG_DrawPic( 34, 29, 580, 410, cgs.media.laGogglesStatic ); CG_DrawPic( 570, 140, 12, 160, cgs.media.laGogglesSideBit ); - + float light = (128-cent->gent->lightLevel) * 0.5f; if ( light < -81 ) // saber can really jack up local light levels....?magic number?? @@ -1195,7 +1195,7 @@ static void CG_DrawZoomMask( void ) CG_DrawPic( 65, 94, 16, 16, cgs.media.binocularCircle ); } - + CG_DrawPic( 0, 0, 640, 480, cgs.media.laGogglesMask ); } } @@ -1206,7 +1206,7 @@ CG_DrawStats ================ */ -static void CG_DrawStats( void ) +static void CG_DrawStats( void ) { centity_t *cent; @@ -1234,7 +1234,7 @@ static void CG_DrawStats( void ) if (( drawHud ) && ( cg_drawHUD.integer )) { - CG_DrawHUD( cent ); + CG_DrawHUD( cent ); } CG_DrawTalk(cent); @@ -1251,16 +1251,16 @@ static void CG_DrawPickupItem( void ) { float *fadeColor; value = cg.itemPickup; - if ( value && cg_items[ value ].icon != -1 ) + if ( value && cg_items[ value ].icon != -1 ) { fadeColor = CG_FadeColor( cg.itemPickupTime, 3000 ); - if ( fadeColor ) + if ( fadeColor ) { CG_RegisterItemVisuals( value ); cgi_R_SetColor( fadeColor ); CG_DrawPic( 573, 340, ICON_SIZE, ICON_SIZE, cg_items[ value ].icon ); //CG_DrawBigString( ICON_SIZE + 16, 398, bg_itemlist[ value ].classname, fadeColor[0] ); - //CG_DrawProportionalString( ICON_SIZE + 16, 398, + //CG_DrawProportionalString( ICON_SIZE + 16, 398, // bg_itemlist[ value ].classname, CG_SMALLFONT,fadeColor ); cgi_R_SetColor( NULL ); } @@ -1292,7 +1292,7 @@ void CG_DrawCredits(void) if (cg.creditsStart) { - if ( !CG_Credits_Running() ) + if ( !CG_Credits_Running() ) { cgi_Cvar_Set( "cg_endcredits", "0" ); CMD_CGCam_Disable(); @@ -1315,7 +1315,7 @@ CROSSHAIR CG_DrawCrosshair ================= */ -static void CG_DrawCrosshair( vec3_t worldPoint ) +static void CG_DrawCrosshair( vec3_t worldPoint ) { float w, h; qhandle_t hShader; @@ -1324,7 +1324,7 @@ static void CG_DrawCrosshair( vec3_t worldPoint ) float f; float x, y; - if ( !cg_drawCrosshair.integer ) + if ( !cg_drawCrosshair.integer ) { return; } @@ -1440,7 +1440,7 @@ static void CG_DrawCrosshair( vec3_t worldPoint ) ecolor[3] = (cg.time - cg.forceCrosshairStartTime) / 300.0f; } - // clamp + // clamp if ( ecolor[3] < 0 ) { ecolor[3] = 0; @@ -1518,19 +1518,19 @@ static void CG_DrawCrosshair( vec3_t worldPoint ) if ( !Q_stricmp( "misc_panel_turret", g_entities[cg.snap->ps.viewEntity].classname )) { // draws a custom crosshair that is twice as large as normal - cgi_R_DrawStretchPic( x + cg.refdef.x + 320 - w, - y + cg.refdef.y + 240 - h, - w * 2, h * 2, 0, 0, 1, 1, cgs.media.turretCrossHairShader ); + cgi_R_DrawStretchPic( x + cg.refdef.x + 320 - w, + y + cg.refdef.y + 240 - h, + w * 2, h * 2, 0, 0, 1, 1, cgs.media.turretCrossHairShader ); } } - else + else { hShader = cgs.media.crosshairShader[ cg_drawCrosshair.integer % NUM_CROSSHAIRS ]; - cgi_R_DrawStretchPic( x + cg.refdef.x + 0.5 * (640 - w), - y + cg.refdef.y + 0.5 * (480 - h), - w, h, 0, 0, 1, 1, hShader ); + cgi_R_DrawStretchPic( x + cg.refdef.x + 0.5 * (640 - w), + y + cg.refdef.y + 0.5 * (480 - h), + w, h, 0, 0, 1, 1, hShader ); } if ( cg.forceCrosshairStartTime && cg_crosshairForceHint.integer ) // drawing extra bits @@ -1543,10 +1543,10 @@ static void CG_DrawCrosshair( vec3_t worldPoint ) w *= 2.0f; h *= 2.0f; - cgi_R_DrawStretchPic( x + cg.refdef.x + 0.5f * ( 640 - w ), y + cg.refdef.y + 0.5f * ( 480 - h ), - w, h, - 0, 0, 1, 1, - cgs.media.forceCoronaShader ); + cgi_R_DrawStretchPic( x + cg.refdef.x + 0.5f * ( 640 - w ), y + cg.refdef.y + 0.5f * ( 480 - h ), + w, h, + 0, 0, 1, 1, + cgs.media.forceCoronaShader ); } cgi_R_SetColor( NULL ); @@ -1605,13 +1605,13 @@ static void CG_ScanForRocketLock( void ) traceEnt = &g_entities[g_crosshairEntNum]; - if ( !traceEnt || g_crosshairEntNum <= 0 || g_crosshairEntNum >= ENTITYNUM_WORLD || (!traceEnt->client && traceEnt->s.weapon != WP_TURRET ) || !traceEnt->health + if ( !traceEnt || g_crosshairEntNum <= 0 || g_crosshairEntNum >= ENTITYNUM_WORLD || (!traceEnt->client && traceEnt->s.weapon != WP_TURRET ) || !traceEnt->health || ( traceEnt && traceEnt->client && traceEnt->client->ps.powerups[PW_CLOAKED] )) { // see how much locking we have int dif = ( cg.time - g_rocketLockTime ) / ( 1200.0f / 8.0f ); - // 8 is full locking....also if we just traced onto the world, + // 8 is full locking....also if we just traced onto the world, // give them 1/2 second of slop before dropping the lock if ( dif < 8 && g_rocketSlackTime + 500 < cg.time ) { @@ -1636,7 +1636,7 @@ static void CG_ScanForRocketLock( void ) { g_rocketLockTime = cg.time - 1200; // doh, hacking the time so the targetting still gets drawn full } - } + } // keep locking to this thing for one second after it gets out of view if ( g_rocketLockTime + 2000.0f < cg.time ) // since time was hacked above, I'm compensating so that 2000ms is really only 1000ms @@ -1681,7 +1681,7 @@ CG_ScanForCrosshairEntity ================= */ extern float forcePushPullRadius[]; -static void CG_ScanForCrosshairEntity( qboolean scanAll ) +static void CG_ScanForCrosshairEntity( qboolean scanAll ) { trace_t trace; gentity_t *traceEnt = NULL; @@ -1701,7 +1701,7 @@ static void CG_ScanForCrosshairEntity( qboolean scanAll ) VectorMA( start, 2048, d_f, end );//4028 is max for mind trick //YES! This is very very bad... but it works! James made me do it. Really, he did. Blame James. - gi.trace( &trace, start, vec3_origin, vec3_origin, end, + gi.trace( &trace, start, vec3_origin, vec3_origin, end, ignoreEnt, MASK_OPAQUE|CONTENTS_SHOTCLIP|CONTENTS_BODY|CONTENTS_ITEM, G2_NOCOLLIDE, 10 );// ); took out CONTENTS_SOLID| so you can target people through glass.... took out CONTENTS_CORPSE so disintegrated guys aren't shown, could just remove their body earlier too... if ( trace.entityNum < ENTITYNUM_WORLD ) @@ -1785,7 +1785,7 @@ static void CG_ScanForCrosshairEntity( qboolean scanAll ) if ( cg_dynamicCrosshair.integer ) {//100% accurate vec3_t d_f, d_rt, d_up; - if ( cg.snap->ps.weapon == WP_NONE || + if ( cg.snap->ps.weapon == WP_NONE || cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_STUN_BATON ) { if ( cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD ) @@ -1824,17 +1824,17 @@ static void CG_ScanForCrosshairEntity( qboolean scanAll ) VectorMA( start, 4096, cg.refdef.viewaxis[0], end );//was 8192 } //YES! This is very very bad... but it works! James made me do it. Really, he did. Blame James. - gi.trace( &trace, start, vec3_origin, vec3_origin, end, + gi.trace( &trace, start, vec3_origin, vec3_origin, end, ignoreEnt, MASK_OPAQUE|CONTENTS_SHOTCLIP|CONTENTS_BODY|CONTENTS_ITEM, G2_NOCOLLIDE, 10 );// ); took out CONTENTS_SOLID| so you can target people through glass.... took out CONTENTS_CORPSE so disintegrated guys aren't shown, could just remove their body earlier too... /* - CG_Trace( &trace, start, vec3_origin, vec3_origin, end, + CG_Trace( &trace, start, vec3_origin, vec3_origin, end, cg.snap->ps.clientNum, MASK_PLAYERSOLID|CONTENTS_CORPSE|CONTENTS_ITEM ); */ //FIXME: pick up corpses if ( trace.startsolid || trace.allsolid ) { - // trace should not be allowed to pick up anything if it started solid. I tried actually moving the trace start back, which also worked, + // trace should not be allowed to pick up anything if it started solid. I tried actually moving the trace start back, which also worked, // but the dynamic cursor drawing caused it to render around the clip of the gun when I pushed the blaster all the way into a wall. // It looked quite horrible...but, if this is bad for some reason that I don't know trace.entityNum = ENTITYNUM_NONE; @@ -1842,7 +1842,7 @@ static void CG_ScanForCrosshairEntity( qboolean scanAll ) traceEnt = &g_entities[trace.entityNum]; } - + // if the object is "dead", don't show it /* if ( cg.crosshairClientNum && g_entities[cg.crosshairClientNum].health <= 0 ) @@ -1891,13 +1891,13 @@ static void CG_ScanForCrosshairEntity( qboolean scanAll ) // if the player is in fog, don't show it content = cgi_CM_PointContents( trace.endpos, 0 ); - if ( content & CONTENTS_FOG ) + if ( content & CONTENTS_FOG ) { return; } // if the player is cloaked, don't show it - if ( cg_entities[ trace.entityNum ].currentState.powerups & ( 1 << PW_CLOAKED )) + if ( cg_entities[ trace.entityNum ].currentState.powerups & ( 1 << PW_CLOAKED )) { return; } @@ -1918,7 +1918,7 @@ static void CG_ScanForCrosshairEntity( qboolean scanAll ) CG_DrawCrosshairNames ===================== */ -static void CG_DrawCrosshairNames( void ) +static void CG_DrawCrosshairNames( void ) { qboolean scanAll = qfalse; centity_t *player = &cg_entities[0]; @@ -1966,8 +1966,8 @@ static void CG_DrawRocketLocking( int lockEntNum, int lockTime ) if ( CG_WorldCoordToScreenCoord( org, &cx, &cy )) { // we care about distance from enemy to eye, so this is good enough - float sz = Distance( gent->currentOrigin, cg.refdef.vieworg ) / 1024.0f; - + float sz = Distance( gent->currentOrigin, cg.refdef.vieworg ) / 1024.0f; + if ( cg.zoomMode > 0 ) { if ( cg.overrides.active & CG_OVERRIDE_FOV ) @@ -1994,7 +1994,7 @@ static void CG_DrawRocketLocking( int lockEntNum, int lockTime ) vec4_t color={0.0f,0.0f,0.0f,0.0f}; cy += sz * 0.5f; - + // well now, take our current lock time and divide that by 8 wedge slices to get the current lock amount int dif = ( cg.time - g_rocketLockTime ) / ( 1200.0f / 8.0f ); @@ -2095,10 +2095,10 @@ static float CG_DrawSnapshot( float y ) { char *s; int w; - s = va( "time:%i snap:%i cmd:%i", cg.snap->serverTime, + s = va( "time:%i snap:%i cmd:%i", cg.snap->serverTime, cg.latestSnapshotNum, cgs.serverCommandSequence ); - w = cgi_R_Font_StrLenPixels(s, cgs.media.qhFontMedium, 1.0f); + w = cgi_R_Font_StrLenPixels(s, cgs.media.qhFontMedium, 1.0f); cgi_R_Font_DrawString(635 - w, y+2, s, colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.0f); return y + BIGCHAR_HEIGHT + 10; @@ -2141,7 +2141,7 @@ static float CG_DrawFPS( float y ) { fps = 1000 * FPS_FRAMES / total; s = va( "%ifps", fps ); - const int w = cgi_R_Font_StrLenPixels(s, cgs.media.qhFontMedium, 1.0f); + const int w = cgi_R_Font_StrLenPixels(s, cgs.media.qhFontMedium, 1.0f); cgi_R_Font_DrawString(635 - w, y+2, s, colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.0f); return y + BIGCHAR_HEIGHT + 10; @@ -2165,7 +2165,7 @@ static float CG_DrawTimer( float y ) { s = va( "%i:%i%i", mins, tens, seconds ); - w = cgi_R_Font_StrLenPixels(s, cgs.media.qhFontMedium, 1.0f); + w = cgi_R_Font_StrLenPixels(s, cgs.media.qhFontMedium, 1.0f); cgi_R_Font_DrawString(635 - w, y+2, s, colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.0f); return y + BIGCHAR_HEIGHT + 10; @@ -2201,7 +2201,7 @@ static void CG_DrawAmmoWarning( void ) { //s = "LOW AMMO WARNING"; } - w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 1.0f); + w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 1.0f); cgi_R_Font_DrawString(320 - w/2, 64, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 1.0f); } @@ -2253,24 +2253,24 @@ CG_Draw2D ================= */ extern void CG_SaberClashFlare( void ); -static void CG_Draw2D( void ) +static void CG_Draw2D( void ) { char text[1024]={0}; int w,y_pos; centity_t *cent = &cg_entities[cg.snap->ps.clientNum]; // if we are taking a levelshot for the menu, don't draw anything - if ( cg.levelShot ) + if ( cg.levelShot ) { return; } - if ( cg_draw2D.integer == 0 ) + if ( cg_draw2D.integer == 0 ) { return; } - if ( cg.snap->ps.pm_type == PM_INTERMISSION ) + if ( cg.snap->ps.pm_type == PM_INTERMISSION ) { CG_DrawIntermission(); return; @@ -2295,7 +2295,7 @@ static void CG_Draw2D( void ) } CG_DrawScrollText(); - CG_DrawCaptionText(); + CG_DrawCaptionText(); if ( in_camera ) {//still draw the saber clash flare, but nothing else @@ -2306,14 +2306,14 @@ static void CG_Draw2D( void ) if ( CG_RenderingFromMiscCamera()) { // purposely doing an early out when in a misc_camera, change it if needed. - + // allowing center print when in camera mode, probably just an alpha thing - dmv CG_DrawCenterString(); return; } // don't draw any status if dead - if ( cg.snap->ps.stats[STAT_HEALTH] > 0 ) + if ( cg.snap->ps.stats[STAT_HEALTH] > 0 ) { if ( !(cent->gent && cent->gent->s.eFlags & (EF_LOCKED_TO_WEAPON |EF_IN_ATST))) { @@ -2350,10 +2350,10 @@ static void CG_Draw2D( void ) float y = 0; if (cg_drawSnapshot.integer) { y=CG_DrawSnapshot(y); - } + } if (cg_drawFPS.integer) { y=CG_DrawFPS(y); - } + } if (cg_drawTimer.integer) { y=CG_DrawTimer(y); } @@ -2364,7 +2364,7 @@ static void CG_Draw2D( void ) } if (missionInfo_Updated) - { + { if (cg.predicted_player_state.pm_type != PM_DEAD) { // Was a objective given? @@ -2406,7 +2406,7 @@ static void CG_Draw2D( void ) } cgi_R_Font_DrawString(x_pos, y_pos, text, colorTable[CT_LTRED1], cgs.media.qhFontMedium, -1, 1.0f); - if (cg_updatedDataPadForcePower1.integer) + if (cg_updatedDataPadForcePower1.integer) { y_pos += 25; cgi_SP_GetStringTextString("INGAME_NEW_FORCE_POWER_INFO", text, sizeof(text) ); @@ -2418,7 +2418,7 @@ static void CG_Draw2D( void ) cgi_R_Font_DrawString(x_pos, y_pos, text, colorTable[CT_LTRED1], cgs.media.qhFontMedium, -1, 1.0f); } - if (cg_updatedDataPadObjective.integer) + if (cg_updatedDataPadObjective.integer) { y_pos += 25; cgi_SP_GetStringTextString( "INGAME_NEW_OBJECTIVE_INFO", text, sizeof(text) ); diff --git a/codeJK2/cgame/cg_drawtools.cpp b/codeJK2/cgame/cg_drawtools.cpp index badda5920b..0fd67f4e18 100644 --- a/codeJK2/cgame/cg_drawtools.cpp +++ b/codeJK2/cgame/cg_drawtools.cpp @@ -45,7 +45,7 @@ CG_Scissor Coordinates are 640*480 virtual values ================= */ -void CG_Scissor( float x, float y, float width, float height) +void CG_Scissor( float x, float y, float width, float height) { cgi_R_Scissor( x, y, width, height); @@ -74,7 +74,7 @@ A width of 0 will draw with the original image width Can also specify the exact texture coordinates ================= */ -void CG_DrawPic2( float x, float y, float width, float height, float s1, float t1, float s2, float t2, qhandle_t hShader ) +void CG_DrawPic2( float x, float y, float width, float height, float s1, float t1, float s2, float t2, qhandle_t hShader ) { cgi_R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, hShader ); } @@ -137,8 +137,8 @@ void CG_DrawChar( int x, int y, int width, int height, int ch ) { size = 0.0625; cgi_R_DrawStretchPic( ax, ay, aw, ah, - fcol, frow, - fcol + size, frow + size, + fcol, frow, + fcol + size, frow + size, cgs.media.charsetShader ); */ @@ -149,7 +149,7 @@ void CG_DrawChar( int x, int y, int width, int height, int ch ) { size = 0.03125; size2 = 0.0625; - cgi_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol + size, frow + size2, + cgi_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol + size, frow + size2, cgs.media.charsetShader ); } @@ -165,7 +165,7 @@ to a fixed color. Coordinates are at 640 by 480 virtual resolution ================== */ -void CG_DrawStringExt( int x, int y, const char *string, const float *setColor, +void CG_DrawStringExt( int x, int y, const char *string, const float *setColor, qboolean forceColor, qboolean shadow, int charWidth, int charHeight ) { vec4_t color; const char *s; @@ -272,7 +272,7 @@ void CG_TileClear( void ) { w = cgs.glconfig.vidWidth; h = cgs.glconfig.vidHeight; - if ( cg.refdef.x == 0 && cg.refdef.y == 0 && + if ( cg.refdef.x == 0 && cg.refdef.y == 0 && cg.refdef.width == w && cg.refdef.height == h ) { return; // full screen rendering } @@ -335,7 +335,7 @@ Take x,y positions as if 640 x 480 and scales them to the proper resolution ============== */ -void CG_DrawNumField (int x, int y, int width, int value,int charWidth,int charHeight,int style,qboolean zeroFill) +void CG_DrawNumField (int x, int y, int width, int value,int charWidth,int charHeight,int style,qboolean zeroFill) { char num[16], *ptr; int l; @@ -450,7 +450,7 @@ void CG_DrawNumField (int x, int y, int width, int value,int charWidth,int charH CG_DrawProportionalString ================= */ -void CG_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color ) +void CG_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color ) { //assert(!style);//call this directly if you need style (OR it into the font handle) cgi_R_Font_DrawString (x, y, str, color, cgs.media.qhFontMedium, -1, 1.0f); diff --git a/codeJK2/cgame/cg_effects.cpp b/codeJK2/cgame/cg_effects.cpp index eb2dd990d6..63add3c3ef 100644 --- a/codeJK2/cgame/cg_effects.cpp +++ b/codeJK2/cgame/cg_effects.cpp @@ -38,7 +38,7 @@ CG_MakeExplosion ==================== */ /* -localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, +localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, qhandle_t hModel, int numFrames, qhandle_t shader, int msec, qboolean isSprite, float scale, int flags ) { @@ -56,7 +56,7 @@ localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, ex = CG_AllocLocalEntity(); if ( isSprite ) { - ex->leType = LE_SPRITE_EXPLOSION; + ex->leType = LE_SPRITE_EXPLOSION; ex->refEntity.rotation = rand() % 360; ex->radius = scale; VectorScale( dir, 16, tmpVec ); @@ -81,7 +81,7 @@ localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, ex->startTime = cg.time - offset; ex->endTime = ex->startTime + msec; - + // bias the time so all shader effects start correctly ex->refEntity.shaderTime = ex->startTime / 1000.0f; @@ -108,7 +108,7 @@ localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, } */ // When calling this version, just pass in a zero for the flags -//localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, +//localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, // qhandle_t hModel, int numFrames, qhandle_t shader, // int msec, qboolean isSprite, float scale ) { // return CG_MakeExplosion( origin, dir, hModel, numFrames, shader, msec, isSprite, scale, 0 ); @@ -129,17 +129,17 @@ localEntity_t *CG_AddTempLight( vec3_t origin, float scale, vec3_t color, int ms ex = CG_AllocLocalEntity(); - ex->leType = LE_LIGHT; + ex->leType = LE_LIGHT; ex->startTime = cg.time; ex->endTime = ex->startTime + msec; - + // set origin VectorCopy ( origin, ex->refEntity.origin); VectorCopy ( origin, ex->refEntity.oldorigin ); VectorCopy( color, ex->lightColor ); - ex->light = scale; + ex->light = scale; return ex; } @@ -201,9 +201,9 @@ void CG_SurfaceExplosion( vec3_t origin, vec3_t normal, float radius, float shak //Sparks numSparks = 16 + (Q_flrand(0.0f, 1.0f) * 16.0f); - + for ( i = 0; i < numSparks; i++ ) - { + { scale = 0.25f + (Q_flrand(0.0f, 1.0f) * 2.0f); dscale = -scale*0.5; @@ -237,16 +237,16 @@ void CG_SurfaceExplosion( vec3_t origin, vec3_t normal, float radius, float shak VectorSet( temp_vel, velocity[0] + (Q_flrand(-1.0f, 1.0f) * 8.0f), velocity[1] + (Q_flrand(-1.0f, 1.0f) * 8.0f), velocity[2] + (Q_flrand(-1.0f, 1.0f) * 8.0f) ); FX_AddSprite( temp_org, - temp_vel, - NULL, - 64.0f + (Q_flrand(0.0f, 1.0f) * 32.0f), - 16.0f, - 1.0f, + temp_vel, + NULL, + 64.0f + (Q_flrand(0.0f, 1.0f) * 32.0f), + 16.0f, + 1.0f, 0.0f, 20.0f + (Q_flrand(-1.0f, 1.0f) * 90.0f), 0.5f, - 1500.0f, - cgs.media.smokeShader, FXF_USE_ALPHA_CHAN ); + 1500.0f, + cgs.media.smokeShader, FXF_USE_ALPHA_CHAN ); } //Core of the explosion @@ -399,7 +399,7 @@ Fun chunk spewer ------------------------- */ -void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t mins, const vec3_t maxs, +void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t mins, const vec3_t maxs, float speed, int numChunks, material_t chunkType, int customChunk, float baseScale ) { localEntity_t *le; @@ -565,7 +565,7 @@ void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t mins le->bounceFactor = 0.2f + Q_flrand(0.0f, 1.0f) * 0.2f; le->leFlags |= LEF_TUMBLE; le->ownerGentNum = owner; - le->leBounceSoundType = bounce; + le->leBounceSoundType = bounce; // Make sure that we have the desired start size set le->radius = Q_flrand( baseScale * 0.75f, baseScale * 1.25f ); @@ -579,7 +579,7 @@ void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t mins } } -void CG_TestLine( vec3_t start, vec3_t end, int time, unsigned int color, int radius ) +void CG_TestLine( vec3_t start, vec3_t end, int time, unsigned int color, int radius ) { localEntity_t *le; refEntity_t *re; @@ -626,7 +626,7 @@ void CG_TestLine( vec3_t start, vec3_t end, int time, unsigned int color, int ra // //---------------------------- -// Since we have shared verts when we tesselate the glass sheet, it helps to have a +// Since we have shared verts when we tesselate the glass sheet, it helps to have a // random offset table set up up front...so that we can have more random looking breaks. static float offX[20][20], @@ -664,7 +664,7 @@ static void CG_DoGlassQuad( vec3_t p[4], vec2_t uv[4], bool stick, int time, vec rgb1, rgb1, 0.0f, // rgb start, rgb end, rgb parm ( not used ) rotDelta, bounce, time, // rotation amount, bounce, and time to delay motion for ( zero if no delay ); 3500 + Q_flrand(0.0f, 1.0f) * 1000, // life - cgi_R_RegisterShader( "gfx/misc/test_crackle" ), + cgi_R_RegisterShader( "gfx/misc/test_crackle" ), FX_APPLY_PHYSICS | FX_ALPHA_NONLINEAR | FX_USE_ALPHA ); if ( Q_flrand(0.0f, 1.0f) > 0.95f && pol ) @@ -708,7 +708,7 @@ static void CG_CalcBiLerp( vec3_t verts[4], vec3_t subVerts[4], vec2_t uv[4] ) VectorMA( temp, uv[3][1], subVerts[3], subVerts[3] ); } // bilinear -//f(p',q') = (1 - y) × {[(1 - x) × f(p,q)] + [x × f(p,q+1)]} + y × {[(1 - x) × f(p+1,q)] + [x × f(p+1,q+1)]}. +//f(p',q') = (1 - y) × {[(1 - x) × f(p,q)] + [x × f(p,q+1)]} + y × {[(1 - x) × f(p+1,q)] + [x × f(p+1,q+1)]}. static void CG_CalcHeightWidth( vec3_t verts[4], float *height, float *width ) @@ -718,24 +718,24 @@ static void CG_CalcHeightWidth( vec3_t verts[4], float *height, float *width ) VectorSubtract( verts[3], verts[0], dir1 ); // v VectorSubtract( verts[1], verts[0], dir2 ); // p-a CrossProduct( dir1, dir2, cross ); - *width = VectorNormalize( cross ) / VectorNormalize( dir1 ); // v + *width = VectorNormalize( cross ) / VectorNormalize( dir1 ); // v VectorSubtract( verts[2], verts[0], dir2 ); // p-a CrossProduct( dir1, dir2, cross ); - *width += VectorNormalize( cross ) / VectorNormalize( dir1 ); // v + *width += VectorNormalize( cross ) / VectorNormalize( dir1 ); // v *width *= 0.5f; VectorSubtract( verts[1], verts[0], dir1 ); // v VectorSubtract( verts[2], verts[0], dir2 ); // p-a CrossProduct( dir1, dir2, cross ); - *height = VectorNormalize( cross ) / VectorNormalize( dir1 ); // v + *height = VectorNormalize( cross ) / VectorNormalize( dir1 ); // v VectorSubtract( verts[3], verts[0], dir2 ); // p-a CrossProduct( dir1, dir2, cross ); - *height += VectorNormalize( cross ) / VectorNormalize( dir1 ); // v + *height += VectorNormalize( cross ) / VectorNormalize( dir1 ); // v *height *= 0.5f; } -//Consider a line in 3D with position vector "a" and direction vector "v" and +//Consider a line in 3D with position vector "a" and direction vector "v" and // let "p" be the position vector of an arbitrary point in 3D -//dist = len( crossprod(p-a,v) ) / len(v); +//dist = len( crossprod(p-a,v) ) / len(v); void CG_InitGlass( void ) { @@ -905,9 +905,9 @@ void CG_DoGlass( vec3_t verts[4], vec3_t normal, vec3_t dmgPt, vec3_t dmgDir, fl VectorSet2( biPoints[3], xx, zz + stepHeight ); CG_CalcBiLerp( verts, subVerts, biPoints ); - + float dif = DistanceSquared( subVerts[0], dmgPt ) * timeDecay - Q_flrand(0.0f, 1.0f) * 32; - + // If we decrease dif, we are increasing the impact area, making it more likely to blow out large holes dif -= dmgRadius * dmgRadius; @@ -974,7 +974,7 @@ void CG_DrawTargetBeam( vec3_t start, vec3_t end, vec3_t norm, const char *beamF SEffectTemplate *temp; // overriding the effect, so give us a copy first - temp = theFxScheduler.GetEffectCopy( beamFx, &handle ); + temp = theFxScheduler.GetEffectCopy( beamFx, &handle ); VectorSubtract( start, end, dir ); VectorNormalize( dir ); diff --git a/codeJK2/cgame/cg_ents.cpp b/codeJK2/cgame/cg_ents.cpp index 7fcb0c6f0d..bad8c736c9 100644 --- a/codeJK2/cgame/cg_ents.cpp +++ b/codeJK2/cgame/cg_ents.cpp @@ -42,18 +42,18 @@ Modifies the entities position and axis by the given tag location ====================== */ -void CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent, +void CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName ) { int i; orientation_t lerped; - + // lerp the tag cgi_R_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame, 1.0f - parent->backlerp, tagName ); // FIXME: allow origin offsets along tag? VectorCopy( parent->origin, entity->origin ); - for ( i = 0 ; i < 3 ; i++ ) + for ( i = 0 ; i < 3 ; i++ ) { VectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin ); } @@ -71,7 +71,7 @@ Modifies the entities position and axis by the given tag location ====================== */ -void CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent, +void CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName, orientation_t *tagOrient ) { int i; orientation_t lerped; @@ -84,7 +84,7 @@ void CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *pare if ( tagOrient ) { VectorCopy( lerped.origin, tagOrient->origin ); - for ( i = 0 ; i < 3 ; i++ ) + for ( i = 0 ; i < 3 ; i++ ) { VectorCopy( lerped.axis[i], tagOrient->axis[i] ); } @@ -149,9 +149,9 @@ static void CG_EntityEffects( centity_t *cent ) { VectorCopy(*CG_SetEntitySoundPosition( cent ),v3Origin); // add loop sound - if ( cent->currentState.loopSound ) + if ( cent->currentState.loopSound ) { - + sfxHandle_t sfx = ( cent->currentState.eType == ET_MOVER ) ? cent->currentState.loopSound : cgs.sound_precache[ cent->currentState.loopSound ]; cgi_S_AddLoopingSound( cent->currentState.number, v3Origin/*cent->lerpOrigin*/, vec3_origin, sfx ); @@ -178,7 +178,7 @@ void CG_AddRefEntWithTransportEffect ( centity_t *cent, refEntity_t *ent ) if ( ent->renderfx & RF_PULSATE && cent->gent->owner && cent->gent->owner->health && !cent->gent->owner->s.number && cent->gent->owner->client && //only for player - cent->gent->owner->client->ps.saberEntityState == SES_RETURNING && + cent->gent->owner->client->ps.saberEntityState == SES_RETURNING && cent->currentState.saberActive == qfalse ) { // if we are the saber and we have been dropped, do a glow so it can be spotted easier @@ -351,7 +351,7 @@ CG_General ================== */ extern int CG_SaberHumSoundForEnt( gentity_t *gent ); -static void CG_General( centity_t *cent ) +static void CG_General( centity_t *cent ) { refEntity_t ent; entityState_t *s1; @@ -424,7 +424,7 @@ Ghoul2 Insert End } // player model - if (s1->number == cg.snap->ps.clientNum) + if (s1->number == cg.snap->ps.clientNum) { ent.renderfx |= RF_THIRD_PERSON; // only draw from mirrors } @@ -441,7 +441,7 @@ Ghoul2 Insert Start //------------------------------------------------------- // Start of chair //------------------------------------------------------- - if ( cent->gent->s.weapon == WP_EMPLACED_GUN || ( cent->gent->activator && cent->gent->activator->owner && + if ( cent->gent->s.weapon == WP_EMPLACED_GUN || ( cent->gent->activator && cent->gent->activator->owner && cent->gent->activator->s.eFlags & EF_LOCKED_TO_WEAPON )) { vec3_t temp; @@ -453,9 +453,9 @@ Ghoul2 Insert Start VectorSet( temp, 0, 0, 1 ); // add a big scorch mark under the gun - CG_ImpactMark( cgs.media.scavMarkShader, cent->lerpOrigin, temp, + CG_ImpactMark( cgs.media.scavMarkShader, cent->lerpOrigin, temp, 0, 1,1,1, 1.0f, qfalse, 92, qtrue ); - CG_ImpactMark( cgs.media.scavMarkShader, cent->lerpOrigin, temp, + CG_ImpactMark( cgs.media.scavMarkShader, cent->lerpOrigin, temp, 90, 1,1,1, 1.0f, qfalse, 48, qtrue ); } else @@ -468,13 +468,13 @@ Ghoul2 Insert Start } // shadow under the gun - CG_ImpactMark( cgs.media.shadowMarkShader, cent->lerpOrigin, temp, + CG_ImpactMark( cgs.media.shadowMarkShader, cent->lerpOrigin, temp, 0, 1,1,1, 1.0f, qfalse, 32, qtrue ); } } - if ( cent->gent->activator && cent->gent->activator->owner && - cent->gent->activator->s.eFlags & EF_LOCKED_TO_WEAPON && + if ( cent->gent->activator && cent->gent->activator->owner && + cent->gent->activator->s.eFlags & EF_LOCKED_TO_WEAPON && cent->gent->activator->owner->s.number == cent->currentState.number ) // gun number must be same as current entities number { centity_t *cc = &cg_entities[cent->gent->activator->s.number]; @@ -491,7 +491,7 @@ const weaponData_t *wData = NULL; // not animating..pausing was leaving the barrels in a bad state gi.G2API_PauseBoneAnim( ¢->gent->ghoul2[cent->gent->playerModel], "model_root", cg.time ); -// gi.G2API_SetBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->rootBone, +// gi.G2API_SetBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->rootBone, // 0, 0, BONE_ANIM_OVERRIDE, 1.0f, cg.time ); } @@ -504,7 +504,7 @@ const weaponData_t *wData = NULL; bolt = cent->gent->handLBolt; } - gi.G2API_GetBoltMatrix( cent->gent->ghoul2, 0, bolt, + gi.G2API_GetBoltMatrix( cent->gent->ghoul2, 0, bolt, &boltMatrix, cent->lerpAngles, cent->lerpOrigin, cg.time, cgs.model_draw, cent->currentState.modelScale ); @@ -536,13 +536,13 @@ const weaponData_t *wData = NULL; if ( cc->currentState.eFlags & EF_FIRING || cc->currentState.eFlags & EF_ALT_FIRING ) { - gi.G2API_SetBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->rootBone, + gi.G2API_SetBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->rootBone, 0, 3, BONE_ANIM_OVERRIDE_FREEZE, 0.6f, cg.time, -1, -1 ); - + if ( effect ) { // We got an effect and we're firing, so let 'er rip. - theFxScheduler.PlayEffect( effect, cc->gent->client->renderInfo.muzzlePoint, + theFxScheduler.PlayEffect( effect, cc->gent->client->renderInfo.muzzlePoint, cc->gent->client->renderInfo.muzzleDir ); } } @@ -570,14 +570,14 @@ const weaponData_t *wData = NULL; { if ( cent->gent->owner->client->ps.saberLength > 0 ) { - CG_AddSaberBlade( &cg_entities[cent->gent->owner->s.number], - &cg_entities[cent->gent->s.number], NULL, ent.renderfx, + CG_AddSaberBlade( &cg_entities[cent->gent->owner->s.number], + &cg_entities[cent->gent->s.number], NULL, ent.renderfx, cent->gent->weaponModel, cent->lerpOrigin, cent->lerpAngles ); } else if ( cent->gent->owner->client->ps.saberEventFlags & SEF_INWATER ) { - CG_CheckSaberInWater( &cg_entities[cent->gent->owner->s.number], - &cg_entities[cent->gent->s.number], cent->gent->weaponModel, + CG_CheckSaberInWater( &cg_entities[cent->gent->owner->s.number], + &cg_entities[cent->gent->s.number], cent->gent->weaponModel, cent->lerpOrigin, cent->lerpAngles ); } } @@ -589,8 +589,8 @@ const weaponData_t *wData = NULL; {//saber is in-flight and active, play a sound on it if ( cent->gent->owner->client->ps.saberEntityState == SES_RETURNING ) { - cgi_S_AddLoopingSound( cent->currentState.number, - cent->lerpOrigin, vec3_origin, + cgi_S_AddLoopingSound( cent->currentState.number, + cent->lerpOrigin, vec3_origin, CG_SaberHumSoundForEnt( cent->gent->owner ) ); } else @@ -609,7 +609,7 @@ const weaponData_t *wData = NULL; spinSound = cgi_S_RegisterSound( "sound/weapons/saber/saberspin1.wav" ); break; } - cgi_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, + cgi_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, spinSound ); /* if ( cg_weapons[WP_SABER].missileSound ) @@ -623,14 +623,14 @@ const weaponData_t *wData = NULL; { if ( cent->gent->owner->client->ps.saberLength > 0 ) {//only add the blade if it's on - CG_AddSaberBlade( &cg_entities[cent->gent->owner->s.number], - &cg_entities[cent->gent->s.number], NULL, ent.renderfx, + CG_AddSaberBlade( &cg_entities[cent->gent->owner->s.number], + &cg_entities[cent->gent->s.number], NULL, ent.renderfx, 0, cent->lerpOrigin, cent->lerpAngles ); } else if ( cent->gent->owner->client->ps.saberEventFlags & SEF_INWATER ) { - CG_CheckSaberInWater( &cg_entities[cent->gent->owner->s.number], - &cg_entities[cent->gent->s.number], 0, cent->lerpOrigin, + CG_CheckSaberInWater( &cg_entities[cent->gent->owner->s.number], + &cg_entities[cent->gent->s.number], 0, cent->lerpOrigin, cent->lerpAngles ); } } @@ -653,7 +653,7 @@ const weaponData_t *wData = NULL; { if ( cg_weapons[WP_SABER].firingSound ) { - cgi_S_AddLoopingSound( cent->currentState.number, + cgi_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, cg_weapons[WP_SABER].firingSound ); } } @@ -673,7 +673,7 @@ const weaponData_t *wData = NULL; spinSound = cgi_S_RegisterSound( "sound/weapons/saber/saberspin1.wav" ); break; } - cgi_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, + cgi_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, spinSound ); /* if ( cg_weapons[WP_SABER].missileSound ) @@ -683,7 +683,7 @@ const weaponData_t *wData = NULL; */ } } - CG_AddSaberBlade( &cg_entities[cent->gent->owner->s.number], + CG_AddSaberBlade( &cg_entities[cent->gent->owner->s.number], NULL, &ent, ent.renderfx, 0, NULL, NULL ); if ( cent->gent->owner->health ) @@ -736,7 +736,7 @@ Ghoul2 Insert End VectorMA( ent.origin, 6.6f, ent.axis[0], beamOrg );// forward // overriding the effect, so give us a copy first - temp = theFxScheduler.GetEffectCopy( "tripMine/laser", &handle ); + temp = theFxScheduler.GetEffectCopy( "tripMine/laser", &handle ); if ( temp ) { @@ -808,7 +808,7 @@ Ghoul2 Insert End float t = (float)(cent->gent->painDebounceTime - cg.time ) / 1000.0f; // Only display when we have damage - if ( t >= 0.0f && t <= 1.0f ) + if ( t >= 0.0f && t <= 1.0f ) { t *= Q_flrand(0.0f, 1.0f); @@ -817,7 +817,7 @@ Ghoul2 Insert End ent.renderfx &= ~RF_ALPHA_FADE; ent.renderfx |= RF_RGB_TINT; ent.customShader = cgi_R_RegisterShader( "gfx/misc/ion_shield" ); - + cgi_R_AddRefEntityToScene( &ent ); } } @@ -853,7 +853,7 @@ static void CG_Speaker( centity_t *cent ) { CG_Item ================== */ -static void CG_Item( centity_t *cent ) +static void CG_Item( centity_t *cent ) { refEntity_t ent; entityState_t *es; @@ -863,7 +863,7 @@ static void CG_Item( centity_t *cent ) float scale; es = ¢->currentState; - if ( es->modelindex >= bg_numItems ) + if ( es->modelindex >= bg_numItems ) { CG_Error( "Bad item index %i on entity", es->modelindex ); } @@ -872,7 +872,7 @@ Ghoul2 Insert Start */ // if set to invisible, skip - if ( (!es->modelindex && !cent->gent->ghoul2.IsValid() ) || ( es->eFlags & EF_NODRAW ) ) + if ( (!es->modelindex && !cent->gent->ghoul2.IsValid() ) || ( es->eFlags & EF_NODRAW ) ) { return; } @@ -887,7 +887,7 @@ Ghoul2 Insert End item = &bg_itemlist[ es->modelindex ]; - if ( cg_simpleItems.integer ) + if ( cg_simpleItems.integer ) { memset( &ent, 0, sizeof( ent ) ); ent.reType = RT_SPRITE; @@ -932,15 +932,15 @@ Ghoul2 Insert End // weaponInfo_t *wi; // // wi = &cg_weapons[item->giTag]; -// cent->lerpOrigin[0] -= +// cent->lerpOrigin[0] -= // wi->weaponMidpoint[0] * ent.axis[0][0] + // wi->weaponMidpoint[1] * ent.axis[1][0] + // wi->weaponMidpoint[2] * ent.axis[2][0]; -// cent->lerpOrigin[1] -= +// cent->lerpOrigin[1] -= // wi->weaponMidpoint[0] * ent.axis[0][1] + // wi->weaponMidpoint[1] * ent.axis[1][1] + // wi->weaponMidpoint[2] * ent.axis[2][1]; -// cent->lerpOrigin[2] -= +// cent->lerpOrigin[2] -= // wi->weaponMidpoint[0] * ent.axis[0][2] + // wi->weaponMidpoint[1] * ent.axis[1][2] + // wi->weaponMidpoint[2] * ent.axis[2][2]; @@ -956,7 +956,7 @@ Ghoul2 Insert End /* Ghoul2 Insert Start */ - CG_SetGhoul2Info(&ent, cent); + CG_SetGhoul2Info(&ent, cent); /* Ghoul2 Insert End */ @@ -971,7 +971,7 @@ Ghoul2 Insert End { //VectorClear( spinAngles ); spinAngles[PITCH] -= 75; } - + if( item->giType != IT_HOLOCRON ) { AnglesToAxis( spinAngles, ent.axis ); @@ -979,7 +979,7 @@ Ghoul2 Insert End // items without glow textures need to keep a minimum light value // so they are always visible -/* if (( item->giType == IT_WEAPON ) || ( item->giType == IT_ARMOR )) +/* if (( item->giType == IT_WEAPON ) || ( item->giType == IT_ARMOR )) { ent.renderfx |= RF_MINLIGHT; } @@ -1052,12 +1052,12 @@ static void CG_Missile( centity_t *cent ) { if ( cent->gent->alt_fire ) { // add trails - if ( weapon->alt_missileTrailFunc ) + if ( weapon->alt_missileTrailFunc ) weapon->alt_missileTrailFunc( cent, weapon ); // add dynamic light if ( wData->alt_missileDlight ) - cgi_R_AddLightToScene(cent->lerpOrigin, wData->alt_missileDlight, + cgi_R_AddLightToScene(cent->lerpOrigin, wData->alt_missileDlight, wData->alt_missileDlightColor[0], wData->alt_missileDlightColor[1], wData->alt_missileDlightColor[2] ); // add missile sound @@ -1071,12 +1071,12 @@ static void CG_Missile( centity_t *cent ) { else { // add trails - if ( weapon->missileTrailFunc ) + if ( weapon->missileTrailFunc ) weapon->missileTrailFunc( cent, weapon ); // add dynamic light if ( wData->missileDlight ) - cgi_R_AddLightToScene(cent->lerpOrigin, wData->missileDlight, + cgi_R_AddLightToScene(cent->lerpOrigin, wData->missileDlight, wData->missileDlightColor[0], wData->missileDlightColor[1], wData->missileDlightColor[2] ); // add missile sound @@ -1095,7 +1095,7 @@ static void CG_Missile( centity_t *cent ) { /* Ghoul2 Insert Start */ - CG_SetGhoul2Info(&ent, cent); + CG_SetGhoul2Info(&ent, cent); /* Ghoul2 Insert End @@ -1168,7 +1168,7 @@ static void CG_Mover( centity_t *cent ) { Ghoul2 Insert Start */ - CG_SetGhoul2Info(&ent, cent); + CG_SetGhoul2Info(&ent, cent); /* Ghoul2 Insert End */ @@ -1198,7 +1198,7 @@ Ghoul2 Insert End } // add the secondary model - if ( s1->solid == SOLID_BMODEL && s1->modelindex2 ) + if ( s1->solid == SOLID_BMODEL && s1->modelindex2 ) { // vec3_t org; if ( !(s1->eFlags & EF_NODRAW) ) @@ -1277,7 +1277,7 @@ void CG_Beam( centity_t *cent, int color ) { /* Ghoul2 Insert Start */ - CG_SetGhoul2Info(&ent, cent); + CG_SetGhoul2Info(&ent, cent); /* Ghoul2 Insert End @@ -1287,12 +1287,12 @@ Ghoul2 Insert End cgi_R_AddRefEntityToScene(&ent); } -static vec2_t st[] = +static vec2_t st[] = { { 0.0f, 0.0f }, { 1.0f, 0.0f }, { 1.0f, 1.0f }, { 0.0f, 1.0f } }; -void CG_Cube( vec3_t mins, vec3_t maxs, vec3_t color, float alpha ) +void CG_Cube( vec3_t mins, vec3_t maxs, vec3_t color, float alpha ) { vec3_t point[4], rot={0,0,0}; int vec[3]; @@ -1316,22 +1316,22 @@ void CG_Cube( vec3_t mins, vec3_t maxs, vec3_t color, float alpha ) point[2][vec[1]] = maxs[vec[1]]; point[2][vec[2]] = maxs[vec[2]]; - + point[3][vec[1]] = maxs[vec[1]]; point[3][vec[2]] = mins[vec[2]]; //- face point[0][vec[0]] = point[1][vec[0]] = point[2][vec[0]] = point[3][vec[0]] = mins[vec[0]]; - FX_AddPoly( point, st, 4, NULL, NULL, alpha, alpha, 0.0f, - color, color, 0.0f, rot, 0.0f, 0.0f, + FX_AddPoly( point, st, 4, NULL, NULL, alpha, alpha, 0.0f, + color, color, 0.0f, rot, 0.0f, 0.0f, 100, cgs.media.solidWhiteShader, 0 ); //+ face point[0][vec[0]] = point[1][vec[0]] = point[2][vec[0]] = point[3][vec[0]] = maxs[vec[0]]; - FX_AddPoly( point, st, 4, NULL, NULL, alpha, alpha, 0.0f, - color, color, 0.0f, rot, 0.0f, 0.0f, + FX_AddPoly( point, st, 4, NULL, NULL, alpha, alpha, 0.0f, + color, color, 0.0f, rot, 0.0f, 0.0f, 100, cgs.media.solidWhiteShader, 0 ); } } @@ -1360,7 +1360,7 @@ void CG_CubeOutline( vec3_t mins, vec3_t maxs, int time, unsigned int color, flo point3[vec[1]] = maxs[vec[1]]; point3[vec[2]] = maxs[vec[2]]; - + point4[vec[1]] = maxs[vec[1]]; point4[vec[2]] = mins[vec[2]]; @@ -1382,7 +1382,7 @@ void CG_CubeOutline( vec3_t mins, vec3_t maxs, int time, unsigned int color, flo } } -void CG_Line( vec3_t start, vec3_t end, vec3_t color, float alpha ) +void CG_Line( vec3_t start, vec3_t end, vec3_t color, float alpha ) { /*FX_AddLine( start, end, @@ -1391,8 +1391,8 @@ void CG_Line( vec3_t start, vec3_t end, vec3_t color, float alpha ) 1.0f, alpha, alpha, - color, - color, + color, + color, 100.0f, cgs.media.whiteShader );*/ } @@ -1432,7 +1432,7 @@ static void CG_Portal( centity_t *cent ) { /* Ghoul2 Insert Start */ - CG_SetGhoul2Info(&ent, cent); + CG_SetGhoul2Info(&ent, cent); /* Ghoul2 Insert End */ @@ -1503,7 +1503,7 @@ Ghoul2 Insert End */ return; } - + //FIXME: prediction on clients in timescale results in jerky positional translation if ( cent->interpolate ) { @@ -1549,7 +1549,7 @@ Ghoul2 Insert End Ghoul2 Insert End */ } - if ( cent->currentState.pos.trType == TR_INTERPOLATE ) + if ( cent->currentState.pos.trType == TR_INTERPOLATE ) { // this will linearize a sine or parabolic curve, but it is important // to not extrapolate player positions if more recent data is available @@ -1575,7 +1575,7 @@ Ghoul2 Insert End { EvaluateTrajectory( ¢->currentState.apos, cg.snap->serverTime, cent->lerpAngles ); } - if ( cent->currentState.pos.trType == TR_INTERPOLATE ) + if ( cent->currentState.pos.trType == TR_INTERPOLATE ) { EvaluateTrajectory( ¢->currentState.pos, cg.snap->serverTime, cent->lerpOrigin ); /* @@ -1587,7 +1587,7 @@ Ghoul2 Insert End return; } } - + // FIXME: if it's blocked, it wigs out, draws it in a predicted spot, but never // makes it there - we need to predict it in the right place if this is happens... @@ -1637,7 +1637,7 @@ Ghoul2 Insert End // FIXME: perform general error decay? } #else -void CG_CalcEntityLerpPositions( centity_t *cent ) +void CG_CalcEntityLerpPositions( centity_t *cent ) { if ( cent->currentState.number == cg.snap->ps.clientNum) { @@ -1676,7 +1676,7 @@ OutputDebugString(va("[%3d] nonext %4.2f t=%6d st = %6d nst = %6d b=%6.2f } //FIXME: prediction on clients in timescale results in jerky positional translation - if (cent->interpolate && + if (cent->interpolate && (cent->currentState.number == cg.snap->ps.clientNum || cent->interpolate && cent->currentState.pos.trType == TR_INTERPOLATE ) ) { @@ -1685,7 +1685,7 @@ OutputDebugString(va("[%3d] nonext %4.2f t=%6d st = %6d nst = %6d b=%6.2f // it would be an internal error to find an entity that interpolates without // a snapshot ahead of the current one - if ( cg.nextSnap == NULL ) + if ( cg.nextSnap == NULL ) { CG_Error( "CG_AddCEntity: cg.nextSnap == NULL" ); } @@ -1769,7 +1769,7 @@ void CG_DLightThink ( centity_t *cent ) vec4_t currentRGBA; gentity_t *owner = NULL; int i; - + if ( percentage >= 1.0f ) {//We hit the end percentage = 1.0f; @@ -1810,7 +1810,7 @@ void CG_DLightThink ( centity_t *cent ) cent->gent->e_clThinkFunc = clThinkF_NULL; cent->gent->s.eType = ET_GENERAL; cent->gent->svFlags &= ~SVF_BROADCAST; - return; + return; break; default: break; @@ -1917,7 +1917,7 @@ extern cvar_t *g_saberRealisticCombat; owner->weaponModel = -1; } } - if ( owner->client->NPC_class == CLASS_PROTOCOL + if ( owner->client->NPC_class == CLASS_PROTOCOL || g_dismemberment->integer >= 11381138 || g_saberRealisticCombat->integer ) { @@ -1942,7 +1942,7 @@ void CG_MatrixEffect ( centity_t *cent ) float totalElapsedTime = (float)(cg.time - cent->currentState.time); float elapsedTime = totalElapsedTime; if ( totalElapsedTime > cent->currentState.eventParm //MATRIX_EFFECT_TIME - || (cent->currentState.weapon&&g_entities[cent->currentState.otherEntityNum].client&&g_entities[cent->currentState.otherEntityNum].client->ps.groundEntityNum!=ENTITYNUM_NONE) + || (cent->currentState.weapon&&g_entities[cent->currentState.otherEntityNum].client&&g_entities[cent->currentState.otherEntityNum].client->ps.groundEntityNum!=ENTITYNUM_NONE) || cg.missionStatusShow ) {//time is up or this is a falling spin and they hit the ground or mission end screen is up cg.overrides.active &= ~(/*CG_OVERRIDE_3RD_PERSON_ENT|*/CG_OVERRIDE_3RD_PERSON_RNG|CG_OVERRIDE_3RD_PERSON_ANG|CG_OVERRIDE_3RD_PERSON_POF); @@ -1955,14 +1955,14 @@ void CG_MatrixEffect ( centity_t *cent ) cent->gent->e_clThinkFunc = clThinkF_NULL; return; } - else + else { while ( elapsedTime > MATRIX_EFFECT_TIME ) { elapsedTime -= MATRIX_EFFECT_TIME; } } - + MatrixMode = qtrue; //FIXME: move the position towards them and back? @@ -1973,7 +1973,7 @@ void CG_MatrixEffect ( centity_t *cent ) cg.overrides.active |= CG_OVERRIDE_3RD_PERSON_ANG; cg.overrides.thirdPersonAngle = 360.0f*elapsedTime/MATRIX_EFFECT_TIME; - if ( !cent->currentState.weapon ) + if ( !cent->currentState.weapon ) {//go ahead and do all the slowdown and vert bob stuff //slowdown float timescale = (elapsedTime/MATRIX_EFFECT_TIME); @@ -2052,7 +2052,7 @@ static void CG_Clouds( centity_t *cent ) if ( cent->gent->spawnflags & 1 ) // TUBE type, the one with a hole in the middle { ent.rotation = cent->gent->random; - ent.renderfx = RF_GROW;// tube flag + ent.renderfx = RF_GROW;// tube flag } if ( cent->gent->spawnflags & 2 ) // ALT type, uses a different shader @@ -2063,7 +2063,7 @@ static void CG_Clouds( centity_t *cent ) { ent.customShader = cgi_R_RegisterShader( "gfx/world/haze" ); } - + cgi_R_AddRefEntityToScene( &ent ); } @@ -2073,7 +2073,7 @@ CG_AddCEntity =============== */ -static void CG_AddCEntity( centity_t *cent ) +static void CG_AddCEntity( centity_t *cent ) { // event-only entities will have been dealt with already if ( cent->currentState.eType >= ET_EVENTS ) { @@ -2168,24 +2168,24 @@ void CG_AddPacketEntities( void ) { playerState_t *ps; // set cg.frameInterpolation - if ( cg.nextSnap ) + if ( cg.nextSnap ) { int delta; delta = (cg.nextSnap->serverTime - cg.snap->serverTime); - if ( delta == 0 ) + if ( delta == 0 ) { cg.frameInterpolation = 0; - } - else + } + else { cg.frameInterpolation = (float)( cg.time - cg.snap->serverTime ) / delta; } //OutputDebugString(va("interp %4.2f ct=%6d nt=%6d st=%6d\n",cg.frameInterpolation,cg.time,cg.nextSnap->serverTime,cg.snap->serverTime)); - } - else + } + else { - cg.frameInterpolation = 0; // actually, it should never be used, because + cg.frameInterpolation = 0; // actually, it should never be used, because // no entities should be marked as interpolating //OutputDebugString(va("noterp %4.2f ct=%6d nt=%6d st=%6d\n",cg.frameInterpolation,cg.time,0,cg.snap->serverTime)); } diff --git a/codeJK2/cgame/cg_info.cpp b/codeJK2/cgame/cg_info.cpp index e8a6b5be5d..bdb726966a 100644 --- a/codeJK2/cgame/cg_info.cpp +++ b/codeJK2/cgame/cg_info.cpp @@ -28,7 +28,7 @@ along with this program; if not, see . static const int missionYpos = 79; -const char *showLoadPowersName[] = +const char *showLoadPowersName[] = { "INGAME_HEAL2", "INGAME_JUMP2", @@ -71,7 +71,7 @@ static void MissionPrint_Line(const int color, const int objectIndex, int &missi /* CG_DisplayBoxedText(70,50,500,300,finalText, cgs.media.qhFontSmall, 1.0f, - colorTable[color] + colorTable[color] ); */ if (pixelLen < 500) // One shot - small enough to print entirely on one line @@ -102,7 +102,7 @@ static void MissionPrint_Line(const int color, const int objectIndex, int &missi holdText2[1] = '\0'; strBegin = str; - while( *str ) + while( *str ) { holdText2[0] = *str; pixelLen += cgi_R_Font_StrLenPixels(holdText2, cgs.media.qhFontMedium, 1.0f); @@ -110,7 +110,7 @@ static void MissionPrint_Line(const int color, const int objectIndex, int &missi pixelLen += 2; // For kerning ++charLen; - if (pixelLen > 500 ) + if (pixelLen > 500 ) { //Reached max length of this line //step back until we find a space while ((charLen) && (*str != ' ' )) @@ -134,7 +134,7 @@ static void MissionPrint_Line(const int color, const int objectIndex, int &missi CG_DrawProportionalString(108, y, holdText, CG_SMALLFONT, colorTable[color] ); ++missionYcnt; - } + } else if (*(str+1) == '\0') { ++charLen; @@ -146,10 +146,10 @@ static void MissionPrint_Line(const int color, const int objectIndex, int &missi ++missionYcnt; break; } - ++str; + ++str; - } + } } // Special case hack @@ -272,7 +272,7 @@ static void CG_DrawForceCount( const int force, int x, float *y, const int pad,q sscanf( s, "%d",&val ); - if ((val<1) || (val> NUM_FORCE_POWERS)) + if ((val<1) || (val> NUM_FORCE_POWERS)) { return; } @@ -293,7 +293,7 @@ static void CG_DrawForceCount( const int force, int x, float *y, const int pad,q for ( int i = 0; i < val; i++ ) { - CG_DrawPic( x - iconSize - i * (iconSize + 10) , *y, iconSize, iconSize, force_icons[force] ); + CG_DrawPic( x - iconSize - i * (iconSize + 10) , *y, iconSize, iconSize, force_icons[force] ); } } @@ -333,9 +333,9 @@ static void CG_LoadScreen_PersonalInfo(void) CG_DrawForceCount( FP_SABERTHROW, x, &y, pad,&hasForcePowers ); CG_DrawForceCount( FP_SABER_OFFENSE, x, &y, pad,&hasForcePowers ); CG_DrawForceCount( FP_SABER_DEFENSE, x, &y, pad,&hasForcePowers ); - + if (hasForcePowers) - { + { cgi_SP_GetStringTextString( "INGAME_CURRENTFORCEPOWERS", text, sizeof(text) ); CG_DrawProportionalString( 200, 65, text, CG_CENTER | CG_BIGFONT, colorTable[CT_WHITE] ); } @@ -397,7 +397,7 @@ void CG_DrawInformation( void ) { levelshot = cgi_R_RegisterShaderNoMip( va( "levelshots/%s", s ) ); if (!levelshot) { - levelshot = cgi_R_RegisterShaderNoMip( "menu/art/unknownmap" ); + levelshot = cgi_R_RegisterShaderNoMip( "menu/art/unknownmap" ); } extern SavedGameJustLoaded_e g_eSavedGameJustLoaded; // hack! (hey, it's the last week of coding, ok? @@ -450,15 +450,15 @@ void CG_DrawInformation( void ) { // map-specific message (long map name) s = CG_ConfigString( CS_MESSAGE ); - if ( s[0] ) + if ( s[0] ) { if (s[0] == '@') - { + { char text[1024]={0}; cgi_SP_GetStringTextString( s+1, text, sizeof(text) ); cgi_R_Font_DrawString( 15, y, va("\"%s\"",text),colorTable[CT_WHITE],cgs.media.qhFontMedium, -1, 1.0f ); } - else + else { cgi_R_Font_DrawString( 15, y, va("\"%s\"",s),colorTable[CT_WHITE],cgs.media.qhFontMedium, -1, 1.0f ); } diff --git a/codeJK2/cgame/cg_local.h b/codeJK2/cgame/cg_local.h index fa696e1f6a..67946c5d66 100644 --- a/codeJK2/cgame/cg_local.h +++ b/codeJK2/cgame/cg_local.h @@ -55,9 +55,9 @@ along with this program; if not, see . // Zoom vars #define ZOOM_TIME 150 // not currently used? #define MAX_ZOOM_FOV 3.0f -#define ZOOM_IN_TIME 1500.0f +#define ZOOM_IN_TIME 1500.0f #define ZOOM_OUT_TIME 100.0f -#define ZOOM_START_PERCENT 0.3f +#define ZOOM_START_PERCENT 0.3f #define ITEM_BLOB_TIME 200 #define MUZZLE_FLASH_TIME 20 @@ -120,7 +120,7 @@ typedef struct { float pitchAngle; qboolean pitching; - int animationNumber; + int animationNumber; animation_t *animation; int animationTime; // time when the first frame of the animation will be exact } lerpFrame_t; @@ -143,7 +143,7 @@ typedef struct { // centity_t have a direct corespondence with gentity_t in the game, but // only the entityState_t is directly communicated to the cgame -struct centity_s +struct centity_s { entityState_t currentState; // from cg.frame entityState_t nextState; // from cg.nextFrame, if available @@ -164,7 +164,7 @@ struct centity_s int errorTime; // decay the error from this time vec3_t errorOrigin; vec3_t errorAngles; - + qboolean extrapolated; // false if origin / angles is an interpolation vec3_t rawOrigin; vec3_t rawAngles; @@ -174,7 +174,7 @@ struct centity_s // exact interpolated position of entity on this frame vec3_t lerpOrigin; vec3_t lerpAngles; - + //Pointer to corresponding gentity gentity_t *gent; }; @@ -218,7 +218,7 @@ typedef enum { LEF_NO_RANDOM_ROTATE= 0x0008 // MakeExplosion adds random rotate which could be bad in some cases } leFlag_t; -typedef enum +typedef enum { LEBS_NONE, LEBS_METAL, @@ -299,10 +299,10 @@ typedef struct { // all cg.stepTime, cg.duckTime, cg.landTime, etc are set to cg.time when the action // occurs, and they will have visible effects for #define STEP_TIME or whatever msec after - + typedef struct { int clientFrame; // incremented each frame - + qboolean levelShot; // taking a level menu screenshot // there are only one or two snapshot_t that are relevent at a time @@ -342,7 +342,7 @@ typedef struct { float landChange; // for landing hard int landTime; - + // input state sent to server int weaponSelect; int saberAnimLevelPending; @@ -380,8 +380,8 @@ typedef struct { int centerPrintLines; // Scrolling text, caption text and LCARS text use this - char printText[MAX_PRINTTEXT][128]; - int printTextY; + char printText[MAX_PRINTTEXT][128]; + int printTextY; char captionText[MAX_CAPTIONTEXT][256/*128*/]; // bosted for taiwanese squealy radio static speech in kejim post int captionTextY; @@ -504,7 +504,7 @@ Ghoul2 Insert End #define MAX_SHOWPOWERS 7 -extern int showPowers[MAX_SHOWPOWERS]; +extern int showPowers[MAX_SHOWPOWERS]; extern char *showPowersName[MAX_SHOWPOWERS]; extern int force_icons[NUM_FORCE_POWERS]; #define MAX_DPSHOWPOWERS 11 @@ -529,7 +529,7 @@ typedef struct char *file; // File name of graphic/ text if STRING int ingameEnum; // Index to ingame_text[] qhandle_t graphic; // Handle of graphic if GRAPHIC - int min; // + int min; // int max; int target; // Final value int inc; @@ -711,14 +711,14 @@ void CG_DrawPic( float x, float y, float width, float height, qhandle_t hShader void CG_DrawPic2( float x, float y, float width, float height, float s1, float t1, float s2, float t2, qhandle_t hShader ); void CG_DrawRotatePic( float x, float y, float width, float height,float angle, qhandle_t hShader ); void CG_DrawRotatePic2( float x, float y, float width, float height,float angle, qhandle_t hShader ); -void CG_DrawString( float x, float y, const char *string, +void CG_DrawString( float x, float y, const char *string, float charWidth, float charHeight, const float *modulate ); void CG_PrintInterfaceGraphics(int min,int max); void CG_DrawNumField (int x, int y, int width, int value,int charWidth,int charHeight,int style,qboolean zeroFill); void CG_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color ); -void CG_DrawStringExt( int x, int y, const char *string, const float *setColor, +void CG_DrawStringExt( int x, int y, const char *string, const float *setColor, qboolean forceColor, qboolean shadow, int charWidth, int charHeight ); void CG_DrawSmallStringColor( int x, int y, const char *s, vec4_t color ); @@ -744,7 +744,7 @@ void CG_GameText(int y ); // void CG_DrawScrollText( void ); void CG_DrawCaptionText( void ); -void CG_DrawCenterString( void ); +void CG_DrawCenterString( void ); // @@ -759,7 +759,7 @@ void CG_GetTagWorldPosition( refEntity_t *model, char *tag, vec3_t pos, vec3_t a // cg_predict.c // int CG_PointContents( const vec3_t point, int passEntityNum ); -void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, +void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, const int skipNumber, const int mask, const EG2_Collision eG2TraceType=G2_NOCOLLIDE, const int useLod=0 ); void CG_PredictPlayerState( void ); @@ -779,9 +779,9 @@ void CG_AddPacketEntities( void ); void CG_Beam( centity_t *cent, int color ); void CG_AdjustPositionForMover( const vec3_t in, int moverNum, int atTime, vec3_t out ); -void CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent, +void CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName ); -void CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent, +void CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName, orientation_t *tagOrient ); /* @@ -818,7 +818,7 @@ void CG_AddViewWeapon (playerState_t *ps); void CG_DrawWeaponSelect( void ); void CG_OutOfAmmoChange( void ); // should this be in pmove? -void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t min, const vec3_t maxs, +void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t min, const vec3_t maxs, float speed, int numChunks, material_t chunkType, int customChunk, float baseScale ); @@ -827,11 +827,11 @@ void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t min, // void CG_InitMarkPolys( void ); void CG_AddMarks( void ); -void CG_ImpactMark( qhandle_t markShader, - const vec3_t origin, const vec3_t dir, - float orientation, - float r, float g, float b, float a, - qboolean alphaFade, +void CG_ImpactMark( qhandle_t markShader, + const vec3_t origin, const vec3_t dir, + float orientation, + float r, float g, float b, float a, + qboolean alphaFade, float radius, qboolean temporary ); // @@ -845,11 +845,11 @@ void CG_AddLocalEntities( void ); // cg_effects.c // -/*localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, +/*localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, qhandle_t hModel, int numframes, qhandle_t shader, int msec, qboolean isSprite, float scale = 1.0f );// Overloaded -localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, +localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, qhandle_t hModel, int numframes, qhandle_t shader, int msec, qboolean isSprite, float scale, int flags );// Overloaded */ @@ -965,7 +965,7 @@ void cgi_CM_TransformedBoxTrace( trace_t *results, const vec3_t start, const vec const vec3_t origin, const vec3_t angles ); // Returns the projection of a polygon onto the solid brushes in the world -int cgi_CM_MarkFragments( int numPoints, const vec3_t *points, +int cgi_CM_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ); @@ -992,7 +992,7 @@ void cgi_R_LoadWorldMap( const char *mapname ); // all media should be registered during level startup to prevent // hitches during gameplay qhandle_t cgi_R_RegisterModel( const char *name ); // returns rgb axis if not found -qhandle_t cgi_R_RegisterSkin( const char *name ); +qhandle_t cgi_R_RegisterSkin( const char *name ); qhandle_t cgi_R_RegisterShader( const char *name ); // returns default shader if not found qhandle_t cgi_R_RegisterShaderNoMip( const char *name ); // returns all white if not found qhandle_t cgi_R_RegisterFont( const char *name ); @@ -1017,18 +1017,18 @@ void cgi_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *v void cgi_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ); void cgi_R_RenderScene( const refdef_t *fd ); void cgi_R_SetColor( const float *rgba ); // NULL = 1,1,1,1 -void cgi_R_DrawStretchPic( float x, float y, float w, float h, +void cgi_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ); void cgi_R_DrawScreenShot( float x, float y, float w, float h); void cgi_R_ModelBounds( qhandle_t model, vec3_t mins, vec3_t maxs ); -void cgi_R_LerpTag( orientation_t *tag, qhandle_t mod, int startFrame, int endFrame, +void cgi_R_LerpTag( orientation_t *tag, qhandle_t mod, int startFrame, int endFrame, float frac, const char *tagName ); // Does weird, barely controllable rotation behaviour -void cgi_R_DrawRotatePic( float x, float y, float w, float h, +void cgi_R_DrawRotatePic( float x, float y, float w, float h, float s1, float t1, float s2, float t2,float a, qhandle_t hShader ); // rotates image around exact center point of passed in coords -void cgi_R_DrawRotatePic2( float x, float y, float w, float h, +void cgi_R_DrawRotatePic2( float x, float y, float w, float h, float s1, float t1, float s2, float t2,float a, qhandle_t hShader ); void cgi_R_LAGoggles( void ); void cgi_R_Scissor( float x, float y, float w, float h); @@ -1061,7 +1061,7 @@ qboolean cgi_GetServerCommand( int serverCommandNumber ); // this will always be at least one higher than the number in the current // snapshot, and it may be quite a few higher if it is a fast computer on // a lagged connection -int cgi_GetCurrentCmdNumber( void ); +int cgi_GetCurrentCmdNumber( void ); qboolean cgi_GetUserCmd( int cmdNumber, usercmd_t *ucmd ); // used for the weapon select and zoom diff --git a/codeJK2/cgame/cg_localents.cpp b/codeJK2/cgame/cg_localents.cpp index d25a8e1eca..dd1a72ec4e 100644 --- a/codeJK2/cgame/cg_localents.cpp +++ b/codeJK2/cgame/cg_localents.cpp @@ -119,10 +119,10 @@ or generates more localentities along a trail. CG_FragmentBounceSound ================ */ -void CG_FragmentBounceSound( localEntity_t *le, trace_t *trace ) +void CG_FragmentBounceSound( localEntity_t *le, trace_t *trace ) { // half the fragments will make a bounce sounds - if ( rand() & 1 ) + if ( rand() & 1 ) { sfxHandle_t s = 0; @@ -146,7 +146,7 @@ void CG_FragmentBounceSound( localEntity_t *le, trace_t *trace ) // bouncers only make the sound once... // FIXME: arbitrary...change if it bugs you le->leBounceSoundType = LEBS_NONE; - } + } else if ( rand() & 1 ) { // we may end up bouncing again, but each bounce reduces the chance of playing the sound again or they may make a lot of noise when they settle @@ -161,7 +161,7 @@ void CG_FragmentBounceSound( localEntity_t *le, trace_t *trace ) CG_ReflectVelocity ================ */ -void CG_ReflectVelocity( localEntity_t *le, trace_t *trace ) +void CG_ReflectVelocity( localEntity_t *le, trace_t *trace ) { vec3_t velocity; float dot; @@ -179,9 +179,9 @@ void CG_ReflectVelocity( localEntity_t *le, trace_t *trace ) le->pos.trTime = cg.time; // check for stop, making sure that even on low FPS systems it doesn't bobble - if ( trace->allsolid || - ( trace->plane.normal[2] > 0 && - ( le->pos.trDelta[2] < 40 || le->pos.trDelta[2] < -cg.frametime * le->pos.trDelta[2] ) ) ) + if ( trace->allsolid || + ( trace->plane.normal[2] > 0 && + ( le->pos.trDelta[2] < 40 || le->pos.trDelta[2] < -cg.frametime * le->pos.trDelta[2] ) ) ) { le->pos.trType = TR_STATIONARY; } @@ -192,25 +192,25 @@ void CG_ReflectVelocity( localEntity_t *le, trace_t *trace ) CG_AddFragment ================ */ -void CG_AddFragment( localEntity_t *le ) +void CG_AddFragment( localEntity_t *le ) { vec3_t newOrigin; trace_t trace; // used to sink into the ground, but it looks better to maybe just fade them out int t; - + t = le->endTime - cg.time; - if ( t < FRAG_FADE_TIME ) + if ( t < FRAG_FADE_TIME ) { le->refEntity.renderfx |= RF_ALPHA_FADE; le->refEntity.shaderRGBA[0] = le->refEntity.shaderRGBA[1] = le->refEntity.shaderRGBA[2] = 255; le->refEntity.shaderRGBA[3] = ((float)t / FRAG_FADE_TIME) * 255.0f; } - if ( le->pos.trType == TR_STATIONARY ) + if ( le->pos.trType == TR_STATIONARY ) { - if ( !(cgi_CM_PointContents( le->refEntity.origin, 0 ) & CONTENTS_SOLID )) + if ( !(cgi_CM_PointContents( le->refEntity.origin, 0 ) & CONTENTS_SOLID )) { // thing is no longer in solid, so let gravity take it back VectorCopy( le->refEntity.origin, le->pos.trBase ); @@ -229,7 +229,7 @@ void CG_AddFragment( localEntity_t *le ) le->refEntity.renderfx |= RF_LIGHTING_ORIGIN; VectorCopy( newOrigin, le->refEntity.lightingOrigin ); - + // trace a line from previous position to new position CG_Trace( &trace, le->refEntity.origin, NULL, NULL, newOrigin, le->ownerGentNum, CONTENTS_SOLID ); if ( trace.fraction == 1.0 ) { @@ -256,7 +256,7 @@ void CG_AddFragment( localEntity_t *le ) // if it is in a nodrop zone, remove it // this keeps gibs from waiting at the bottom of pits of death // and floating levels - if ( cgi_CM_PointContents( trace.endpos, 0 ) & CONTENTS_NODROP ) + if ( cgi_CM_PointContents( trace.endpos, 0 ) & CONTENTS_NODROP ) { CG_FreeLocalEntity( le ); return; @@ -363,20 +363,20 @@ static void CG_AddPuff( localEntity_t *le ) { CG_AddLocalLight ================ */ -static void CG_AddLocalLight( localEntity_t *le ) +static void CG_AddLocalLight( localEntity_t *le ) { // There should be a light if this is being used, but hey... - if ( le->light ) + if ( le->light ) { float light; light = (float)( cg.time - le->startTime ) / ( le->endTime - le->startTime ); - if ( light < 0.5 ) + if ( light < 0.5 ) { light = 1.0; - } - else + } + else { light = 1.0 - ( light - 0.5 ) * 2; } @@ -548,7 +548,7 @@ CG_AddLocalEntities =================== */ -void CG_AddLocalEntities( void ) +void CG_AddLocalEntities( void ) { localEntity_t *le, *next; diff --git a/codeJK2/cgame/cg_playerstate.cpp b/codeJK2/cgame/cg_playerstate.cpp index 3491570df2..62876256de 100644 --- a/codeJK2/cgame/cg_playerstate.cpp +++ b/codeJK2/cgame/cg_playerstate.cpp @@ -36,7 +36,7 @@ CG_CheckAmmo If the ammo has gone low enough to generate the warning, play a sound ============== */ -void CG_CheckAmmo( void ) +void CG_CheckAmmo( void ) { // int i; int total; @@ -44,18 +44,18 @@ void CG_CheckAmmo( void ) // int weapons; #if 0 - + // see about how many seconds of ammo we have remaining weapons = cg.snap->ps.stats[ STAT_WEAPONS ]; total = 0; - for ( i = WP_STUN_BATON; i < WP_NUM_WEAPONS i++ ) + for ( i = WP_STUN_BATON; i < WP_NUM_WEAPONS i++ ) { if ( ! ( weapons & ( 1 << i ) ) ) continue; /* - switch ( i ) + switch ( i ) { case WP_ROCKET_LAUNCHER: case WP_GRENADE_LAUNCHER: @@ -68,8 +68,8 @@ void CG_CheckAmmo( void ) break; } */ - - if ( total >= 5000 ) + + if ( total >= 5000 ) { cg.lowAmmoWarning = 0; return; @@ -97,7 +97,7 @@ void CG_CheckAmmo( void ) if (!total) // We're completely freak'in out! { cg.lowAmmoWarning = 2; - } + } else // Got a little left { cg.lowAmmoWarning = 1; @@ -172,7 +172,7 @@ void CG_DamageFeedback( int yawByte, int pitchByte, int damage ) { } cg.v_dmg_roll = kick * left; - + cg.v_dmg_pitch = -kick * front; if ( front <= 0.1 ) { @@ -359,7 +359,7 @@ void CG_TransitionPlayerState( playerState_t *ps, playerState_t *ops ) { CG_CheckPlayerstateEvents( ps, ops ); // smooth the ducking viewheight change - if ( ps->viewheight != ops->viewheight ) + if ( ps->viewheight != ops->viewheight ) { if ( !cg.nextFrameTeleport ) {//when we crouch/uncrouch in mid-air, our viewhieght doesn't actually change in diff --git a/codeJK2/cgame/cg_predict.cpp b/codeJK2/cgame/cg_predict.cpp index 6c92ef4d85..8c73e52138 100644 --- a/codeJK2/cgame/cg_predict.cpp +++ b/codeJK2/cgame/cg_predict.cpp @@ -43,7 +43,7 @@ of the entities that are actually solid, to make for more efficient collision detection ==================== */ -void CG_BuildSolidList( void ) +void CG_BuildSolidList( void ) { int i; centity_t *cent; @@ -55,13 +55,13 @@ void CG_BuildSolidList( void ) return; } - for ( i = 0 ; i < cg.snap->numEntities ; i++ ) + for ( i = 0 ; i < cg.snap->numEntities ; i++ ) { if ( cg.snap->entities[ i ].number < ENTITYNUM_WORLD ) { cent = &cg_entities[ cg.snap->entities[ i ].number ]; - if ( cent->gent != NULL && cent->gent->s.solid ) + if ( cent->gent != NULL && cent->gent->s.solid ) { cg_solidEntities[cg_numSolidEntities] = cent; cg_numSolidEntities++; @@ -106,7 +106,7 @@ void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const vec3_t cmodel = cgi_CM_InlineModel( ent->modelindex ); VectorCopy( cent->lerpAngles, angles ); - //Hmm... this would cause traces against brush movers to snap at 20fps (as with the third person camera)... + //Hmm... this would cause traces against brush movers to snap at 20fps (as with the third person camera)... //Let's use the lerpOrigin for now and see if it breaks anything... //EvaluateTrajectory( ¢->currentState.pos, cg.snap->serverTime, origin ); VectorCopy( cent->lerpOrigin, origin ); @@ -148,7 +148,7 @@ void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const vec3_t CG_Trace ================ */ -void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, +void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, const int skipNumber, const int mask, const EG2_Collision eG2TraceType/*=G2_NOCOLLIDE*/, const int useLod/*=0*/) { trace_t t; @@ -203,7 +203,7 @@ void CG_SetClientViewAngles( vec3_t angles, qboolean overrideViewEnt ) { if ( cg.snap->ps.viewEntity <= 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD || overrideViewEnt ) {//don't clamp angles when looking through a viewEntity - for( int i = 0; i < 3; i++ ) + for( int i = 0; i < 3; i++ ) { cg.predicted_player_state.viewangles[PITCH] = angles[i]; cg.predicted_player_state.delta_angles[i] = 0; @@ -355,7 +355,7 @@ void CG_InterpolatePlayerState( qboolean grabAngles ) { } // if the next frame is a teleport, we can't lerp to it - if ( cg.nextFrameTeleport ) + if ( cg.nextFrameTeleport ) { return; } @@ -364,23 +364,23 @@ void CG_InterpolatePlayerState( qboolean grabAngles ) { { f = (float)( cg.time - prev->serverTime ) / ( next->serverTime - prev->serverTime ); - + i = next->ps.bobCycle; - if ( i < prev->ps.bobCycle ) + if ( i < prev->ps.bobCycle ) { i += 256; // handle wraparound } out->bobCycle = prev->ps.bobCycle + f * ( i - prev->ps.bobCycle ); - for ( i = 0 ; i < 3 ; i++ ) + for ( i = 0 ; i < 3 ; i++ ) { out->origin[i] = prev->ps.origin[i] + f * (next->ps.origin[i] - prev->ps.origin[i] ); - if ( !grabAngles ) + if ( !grabAngles ) { - out->viewangles[i] = LerpAngle( + out->viewangles[i] = LerpAngle( prev->ps.viewangles[i], next->ps.viewangles[i], f ); } - out->velocity[i] = prev->ps.velocity[i] + + out->velocity[i] = prev->ps.velocity[i] + f * (next->ps.velocity[i] - prev->ps.velocity[i] ); } } @@ -390,7 +390,7 @@ void CG_InterpolatePlayerState( qboolean grabAngles ) { if (out->groundEntityNum>0) { pent=&cg_entities[out->groundEntityNum]; - if (pent->currentState.eType == ET_MOVER ) + if (pent->currentState.eType == ET_MOVER ) { onPlat=true; @@ -398,8 +398,8 @@ void CG_InterpolatePlayerState( qboolean grabAngles ) { } if ( - cg.validPPS && - cg_smoothPlayerPos.value>0.0f && + cg.validPPS && + cg_smoothPlayerPos.value>0.0f && cg_smoothPlayerPos.value<1.0f && !onPlat ) @@ -420,7 +420,7 @@ void CG_InterpolatePlayerState( qboolean grabAngles ) { EvaluateTrajectory( &pent->currentState.pos,cg.snap->serverTime, p1 ); - if ( cg.nextSnap &&cg.nextSnap->serverTime > cg.snap->serverTime) + if ( cg.nextSnap &&cg.nextSnap->serverTime > cg.snap->serverTime) { EvaluateTrajectory( &pent->nextState.pos,cg.nextSnap->serverTime, p2 ); lerpTime=float(cg.nextSnap->serverTime - cg.snap->serverTime); @@ -445,8 +445,8 @@ void CG_InterpolatePlayerState( qboolean grabAngles ) { VectorAdd(out->origin,vel,out->origin); - if (cg.validPPS && - cg_smoothPlayerPlat.value>0.0f && + if (cg.validPPS && + cg_smoothPlayerPlat.value>0.0f && cg_smoothPlayerPlat.value<1.0f ) { @@ -552,7 +552,7 @@ void CG_TouchTriggerPrediction( void ) { continue; } - cgi_CM_BoxTrace( &trace, cg.predicted_player_state.origin, cg.predicted_player_state.origin, + cgi_CM_BoxTrace( &trace, cg.predicted_player_state.origin, cg.predicted_player_state.origin, cg_pmove.mins, cg_pmove.maxs, cmodel, -1 ); if ( !trace.startsolid ) { @@ -643,7 +643,7 @@ void CG_PredictPlayerState( void ) { current = cgi_GetCurrentCmdNumber(); if ( current - cmdNum >= CMD_BACKUP ) { - return; + return; } // get the most recent information we have @@ -651,7 +651,7 @@ void CG_PredictPlayerState( void ) { // we should always be predicting at least one frame if ( cmdNum >= current ) { - return; + return; } // run cmds @@ -671,7 +671,7 @@ void CG_PredictPlayerState( void ) { cg.thisFrameTeleport = qfalse; } else { vec3_t adjusted; - CG_AdjustPositionForMover( cg.predicted_player_state.origin, + CG_AdjustPositionForMover( cg.predicted_player_state.origin, cg.predicted_player_state.groundEntityNum, cg.oldTime, adjusted ); VectorSubtract( oldPlayerState.origin, adjusted, delta ); @@ -709,7 +709,7 @@ void CG_PredictPlayerState( void ) { if ( player_locked || (ent && !ent->s.number&&ent->aimDebounceTime>level.time) || (ent && ent->client && ent->client->ps.pm_time && (ent->client->ps.pm_flags&PMF_TIME_KNOCKBACK)) || - (ent && ent->forcePushTime > level.time) ) + (ent && ent->forcePushTime > level.time) ) {//lock out player control unless dead //VectorClear( cg_pmove.cmd.angles ); cg_pmove.cmd.forwardmove = 0; @@ -720,15 +720,15 @@ void CG_PredictPlayerState( void ) { CG_CheckModifyUCmd( &cg_pmove.cmd, NULL ); //FIXME: prediction on clients in timescale results in jerky positional translation Pmove( &cg_pmove ); - + // add push trigger movement effects CG_TouchTriggerPrediction(); } while ( cmdNum < current ); // adjust for the movement of the groundentity - CG_AdjustPositionForMover( cg.predicted_player_state.origin, - cg.predicted_player_state.groundEntityNum, + CG_AdjustPositionForMover( cg.predicted_player_state.origin, + cg.predicted_player_state.groundEntityNum, cg.time, cg.predicted_player_state.origin ); // fire events and other transition triggered things diff --git a/codeJK2/cgame/cg_scoreboard.cpp b/codeJK2/cgame/cg_scoreboard.cpp index 27fb1acb30..d2d3c80a30 100644 --- a/codeJK2/cgame/cg_scoreboard.cpp +++ b/codeJK2/cgame/cg_scoreboard.cpp @@ -61,7 +61,7 @@ static void Scoreboard_Draw( void ) CG_DrawPic(120, 100, 18, 12, cgs.media.whiteShader); // Middle Top CG_DrawPic(120, 353, 18, 4, cgs.media.whiteShader); // Middle Bottom - + CG_DrawPic(130,357, 482, 18, cgs.media.whiteShader); // Bottom // Left side box @@ -97,7 +97,7 @@ void CG_MissionFailed(void) cgi_SP_GetStringTextString( "INGAME_MISSIONFAILED", text, sizeof(text) ); - w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 1.2f); + w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 1.2f); cgi_R_Font_DrawString(320 - w/2, y, text, colorTable[CT_HUD_RED], cgs.media.qhFontMedium, -1, 1.2f); switch (statusTextIndex) @@ -140,11 +140,11 @@ void CG_MissionFailed(void) break; } - w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 1.2f); + w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 1.2f); cgi_R_Font_DrawString(320 - w/2, y+30, text, colorTable[CT_HUD_RED], cgs.media.qhFontMedium, -1, 1.2f); cgi_SP_GetStringTextString( "INGAME_RELOADMISSION", text, sizeof(text) ); - w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 1.0f); + w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 1.0f); cgi_R_Font_DrawString(320 - w/2, 450, text, colorTable[CT_CYAN], cgs.media.qhFontSmall, -1, 1.0f); } @@ -162,17 +162,17 @@ void CG_MissionCompletion(void) const int pad = 18; cgi_SP_GetStringTextString( "INGAME_MISSIONCOMPLETION", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 1.2f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 1.2f); cgi_R_Font_DrawString(320 - w/2, 53, text, colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.2f); x = 75; y =86; cgi_SP_GetStringTextString( "INGAME_SECRETAREAS", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_SP_GetStringTextString( "INGAME_SECRETAREAS_OF", text, sizeof(text) ); - cgi_R_Font_DrawString(x+w, y, va("%d %s %d", - cg_entities[0].gent->client->sess.missionStats.secretsFound, + cgi_R_Font_DrawString(x+w, y, va("%d %s %d", + cg_entities[0].gent->client->sess.missionStats.secretsFound, text, cg_entities[0].gent->client->sess.missionStats.totalSecrets ), @@ -180,7 +180,7 @@ w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_ENEMIESKILLED", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w,y, va("%d",cg_entities[0].gent->client->sess.missionStats.enemiesKilled), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); /* @@ -189,16 +189,16 @@ w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cg_entities[0].gent->client->sess.missionStats.enemiesKilled, text, cg_entities[0].gent->client->sess.missionStats.enemiesSpawned - ), + ), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); */ y +=pad; y +=pad; cgi_SP_GetStringTextString( "INGAME_FAVORITEWEAPON", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); - + int wpn=0,i; int max_wpn = cg_entities[0].gent->client->sess.missionStats.weaponUsed[0]; for (i = 1; iclient->sess.missionStats.shotsFired), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_HITS", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.hits), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_ACCURACY", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); const float percent = cg_entities[0].gent->client->sess.missionStats.shotsFired? 100.0f * (float)cg_entities[0].gent->client->sess.missionStats.hits / cg_entities[0].gent->client->sess.missionStats.shotsFired : 0; cgi_R_Font_DrawString(x+w, y, va("%.2f%%",percent), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); @@ -251,43 +251,43 @@ w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_HEAL", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.forceUsed[FP_HEAL]), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_SPEED", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.forceUsed[FP_SPEED]), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_PULL", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.forceUsed[FP_PULL]), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_PUSH", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.forceUsed[FP_PUSH]), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString("INGAME_MINDTRICK", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.forceUsed[FP_TELEPATHY]), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_GRIP", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.forceUsed[FP_GRIP]), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_LIGHTNING", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.forceUsed[FP_LIGHTNING]), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); @@ -299,37 +299,37 @@ w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_THROWN", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.saberThrownCnt), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_BLOCKS", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.saberBlocksCnt), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_LEGATTACKS", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.legAttacksCnt), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_ARMATTACKS", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.armAttacksCnt), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_BODYATTACKS", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.torsoAttacksCnt), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_OTHERATTACKS", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.otherAttacksCnt), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); } @@ -343,16 +343,16 @@ Draw the normal in-game scoreboard return value is bool to NOT draw centerstring ================= */ -qboolean CG_DrawScoreboard( void ) +qboolean CG_DrawScoreboard( void ) { // don't draw anything if the menu is up - if ( cg_paused.integer ) + if ( cg_paused.integer ) { return qfalse; } // Character is either dead, or a script has brought up the screen - if (((cg.predicted_player_state.pm_type == PM_DEAD) && (cg.missionStatusDeadTime < level.time)) + if (((cg.predicted_player_state.pm_type == PM_DEAD) && (cg.missionStatusDeadTime < level.time)) || (cg.missionStatusShow)) { CG_MissionFailed(); diff --git a/codeJK2/cgame/cg_servercmds.cpp b/codeJK2/cgame/cg_servercmds.cpp index b5c4d3226e..88df7f522f 100644 --- a/codeJK2/cgame/cg_servercmds.cpp +++ b/codeJK2/cgame/cg_servercmds.cpp @@ -139,7 +139,7 @@ void CG_ParseServerinfo( void ) { { // failed again, give up for now... // - } + } } if (!Q_stricmp(cgs.stripLevelName[0],"BESPIN_PLATFORM")) { @@ -148,7 +148,7 @@ void CG_ParseServerinfo( void ) { { // failed again, give up for now... // - } + } } } } @@ -179,7 +179,7 @@ static void CG_ConfigStringModified( void ) { if ( num == CS_ITEMS ) { int i; for ( i = 1 ; i < bg_numItems ; i++ ) { - if ( str[ i ] == '1' ) + if ( str[ i ] == '1' ) { if (bg_itemlist[i].classname) { @@ -204,11 +204,11 @@ static void CG_ConfigStringModified( void ) { if ( str[0] != '*' ) { cgs.sound_precache[ num-CS_SOUNDS] = cgi_S_RegisterSound( str ); } - } - else if ( num >= CS_EFFECTS && num < CS_EFFECTS + MAX_FX ) + } + else if ( num >= CS_EFFECTS && num < CS_EFFECTS + MAX_FX ) { theFxScheduler.RegisterEffect( str ); - } + } else if ( num >= CS_PLAYERS && num < CS_PLAYERS+MAX_CLIENTS ) { CG_NewClientinfo( num - CS_PLAYERS ); CG_RegisterClientModels( num - CS_PLAYERS ); diff --git a/codeJK2/cgame/cg_snapshot.cpp b/codeJK2/cgame/cg_snapshot.cpp index 586c25548f..fdfb9c40ab 100644 --- a/codeJK2/cgame/cg_snapshot.cpp +++ b/codeJK2/cgame/cg_snapshot.cpp @@ -73,7 +73,7 @@ void CG_TransitionEntity( centity_t *cent ) { CG_SetInitialSnapshot This will only happen on the very first snapshot, or -on tourney restarts. All other times will use +on tourney restarts. All other times will use CG_TransitionSnapshot instead. ================== */ @@ -144,7 +144,7 @@ void CG_TransitionSnapshot( void ) { // sort out solid entities //CG_BuildSolidList(); - for ( i = 0 ; i < cg.snap->numEntities ; i++ ) + for ( i = 0 ; i < cg.snap->numEntities ; i++ ) { if ( 1 )//cg.snap->entities[ i ].number != 0 ) // I guess the player adds his/her events elsewhere, so doing this also gives us double events for the player! { @@ -180,9 +180,9 @@ void CG_SetEntityNextState( centity_t *cent, entityState_t *state ) { cent->nextState = *state; // since we can't interpolate ghoul2 stuff from one frame to another, I'm just going to copy the ghoul2 info directly into the current state now -// CGhoul2Info *currentModel = &state->ghoul2[1]; +// CGhoul2Info *currentModel = &state->ghoul2[1]; // cent->gent->ghoul2 = state->ghoul2; -// CGhoul2Info *newModel = ¢->gent->ghoul2[1]; +// CGhoul2Info *newModel = ¢->gent->ghoul2[1]; // if this frame is a teleport, or the entity wasn't in the @@ -399,7 +399,7 @@ void CG_ProcessSnapshots( void ) { CG_TransitionSnapshot(); } while ( 1 ); - if ( cg.snap->serverTime > cg.time ) + if ( cg.snap->serverTime > cg.time ) { cg.time=cg.snap->serverTime; #if _DEBUG @@ -407,7 +407,7 @@ void CG_ProcessSnapshots( void ) { #endif } - if ( cg.nextSnap != NULL && cg.nextSnap->serverTime <= cg.time ) + if ( cg.nextSnap != NULL && cg.nextSnap->serverTime <= cg.time ) { cg.time=cg.nextSnap->serverTime-1; #if _DEBUG diff --git a/codeJK2/cgame/cg_syscalls.cpp b/codeJK2/cgame/cg_syscalls.cpp index d4e637c845..d1b2d1be7d 100644 --- a/codeJK2/cgame/cg_syscalls.cpp +++ b/codeJK2/cgame/cg_syscalls.cpp @@ -52,7 +52,7 @@ NORETURN void cgi_Error( const char *fmt ) { } int cgi_Milliseconds( void ) { - return Q_syscall( CG_MILLISECONDS ); + return Q_syscall( CG_MILLISECONDS ); } void cgi_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags ) { @@ -148,7 +148,7 @@ void cgi_CM_TransformedBoxTrace( trace_t *results, const vec3_t start, const vec Q_syscall( CG_CM_TRANSFORMEDBOXTRACE, results, start, end, mins, maxs, model, brushmask, origin, angles ); } -int cgi_CM_MarkFragments( int numPoints, const vec3_t *points, +int cgi_CM_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ) { @@ -305,7 +305,7 @@ void cgi_R_SetColor( const float *rgba ) { Q_syscall( CG_R_SETCOLOR, rgba ); } -void cgi_R_DrawStretchPic( float x, float y, float w, float h, +void cgi_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ) { Q_syscall( CG_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader ); } @@ -318,19 +318,19 @@ void cgi_R_ModelBounds( qhandle_t model, vec3_t mins, vec3_t maxs ) { Q_syscall( CG_R_MODELBOUNDS, model, mins, maxs ); } -void cgi_R_LerpTag( orientation_t *tag, qhandle_t mod, int startFrame, int endFrame, +void cgi_R_LerpTag( orientation_t *tag, qhandle_t mod, int startFrame, int endFrame, float frac, const char *tagName ) { Q_syscall( CG_R_LERPTAG, tag, mod, startFrame, endFrame, PASSFLOAT(frac), tagName ); } -void cgi_R_DrawRotatePic( float x, float y, float w, float h, - float s1, float t1, float s2, float t2,float a, qhandle_t hShader ) +void cgi_R_DrawRotatePic( float x, float y, float w, float h, + float s1, float t1, float s2, float t2,float a, qhandle_t hShader ) { Q_syscall( CG_R_DRAWROTATEPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), PASSFLOAT(a), hShader ); } -void cgi_R_DrawRotatePic2( float x, float y, float w, float h, - float s1, float t1, float s2, float t2,float a, qhandle_t hShader ) +void cgi_R_DrawRotatePic2( float x, float y, float w, float h, + float s1, float t1, float s2, float t2,float a, qhandle_t hShader ) { Q_syscall( CG_R_DRAWROTATEPIC2, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), PASSFLOAT(a), hShader ); } @@ -340,7 +340,7 @@ void cgi_R_LAGoggles( void ) Q_syscall( CG_R_LA_GOGGLES ); } -void cgi_R_Scissor( float x, float y, float w, float h) +void cgi_R_Scissor( float x, float y, float w, float h) { Q_syscall( CG_R_SCISSOR, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h)); } @@ -421,7 +421,7 @@ void cgi_R_WorldEffectCommand( const char *command ) int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits, const char *psAudioFile /* = NULL */) { return Q_syscall(CG_CIN_PLAYCINEMATIC, arg0, xpos, ypos, width, height, bits, psAudioFile); } - + // stops playing the cinematic and ends it. should always return FMV_EOF // cinematics must be stopped in reverse order of when they are started e_status trap_CIN_StopCinematic(int handle) { @@ -433,13 +433,13 @@ e_status trap_CIN_StopCinematic(int handle) { e_status trap_CIN_RunCinematic (int handle) { return (e_status) Q_syscall(CG_CIN_RUNCINEMATIC, handle); } - + // draws the current frame void trap_CIN_DrawCinematic (int handle) { Q_syscall(CG_CIN_DRAWCINEMATIC, handle); } - + // allows you to resize the animation dynamically void trap_CIN_SetExtents (int handle, int x, int y, int w, int h) { diff --git a/codeJK2/cgame/cg_view.cpp b/codeJK2/cgame/cg_view.cpp index e3dcdd650d..ec09ba7f98 100644 --- a/codeJK2/cgame/cg_view.cpp +++ b/codeJK2/cgame/cg_view.cpp @@ -49,7 +49,7 @@ enhanced into a single model testing facility. Model viewing can begin with either "testmodel " or "testgun ". -The names must be the full pathname after the basedir, like +The names must be the full pathname after the basedir, like "models/weapons/v_launch/tris.md3" or "players/male/tris.md3" Testmodel will create a fake entity 100 units in front of the current view @@ -134,7 +134,7 @@ void CG_ListModelSurfaces_f (void) void CG_ListModelBones_f (void) { // test to see if we got enough args - if ( cgi_Argc() < 2 ) + if ( cgi_Argc() < 2 ) { return; } @@ -146,7 +146,7 @@ void CG_ListModelBones_f (void) void CG_TestModelSurfaceOnOff_f(void) { // test to see if we got enough args - if ( cgi_Argc() < 3 ) + if ( cgi_Argc() < 3 ) { return; } @@ -159,14 +159,14 @@ void CG_TestModelSetAnglespre_f(void) { vec3_t angles; - if ( cgi_Argc() < 3 ) + if ( cgi_Argc() < 3 ) { return; } CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)cg.testModelEntity.ghoul2); - angles[0] = atof(CG_Argv(2)); - angles[1] = atof(CG_Argv(3)); + angles[0] = atof(CG_Argv(2)); + angles[1] = atof(CG_Argv(3)); angles[2] = atof(CG_Argv(4)); gi.G2API_SetBoneAngles(&ghoul2[cg.testModel], CG_Argv(1), angles, BONE_ANGLES_PREMULT, POSITIVE_X, POSITIVE_Z, POSITIVE_Y, NULL, 0, 0); } @@ -175,14 +175,14 @@ void CG_TestModelSetAnglespost_f(void) { vec3_t angles; - if ( cgi_Argc() < 3 ) + if ( cgi_Argc() < 3 ) { return; } CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)cg.testModelEntity.ghoul2); - angles[0] = atof(CG_Argv(2)); - angles[1] = atof(CG_Argv(3)); + angles[0] = atof(CG_Argv(2)); + angles[1] = atof(CG_Argv(3)); angles[2] = atof(CG_Argv(4)); gi.G2API_SetBoneAngles(&ghoul2[cg.testModel], CG_Argv(1), angles, BONE_ANGLES_POSTMULT, POSITIVE_X, POSITIVE_Z, POSITIVE_Y, NULL, 0, 0); } @@ -284,7 +284,7 @@ void CG_TestModelPrevSkin_f (void) { static void CG_AddTestModel (void) { int i; - // re-register the model, because the level may have changed + // re-register the model, because the level may have changed /* cg.testModelEntity.hModel = cgi_R_RegisterModel( cg.testModelName ); if (! cg.testModelEntity.hModel ) { CG_Printf ("Can't register model\n"); @@ -366,7 +366,7 @@ cg.refdefViewAngles =============== */ - + /* =============== CG_CalcIdealThirdPersonViewTarget @@ -438,7 +438,7 @@ static void CG_CalcIdealThirdPersonViewTarget(void) } } - + /* =============== @@ -544,7 +544,7 @@ static void CG_UpdateThirdPersonTargetDamp(void) VectorCopy(cameraIdealTarget, cameraCurTarget); } else if (cg_thirdPersonTargetDamp.value>=0.0) - { + { // Calculate the difference from the current position to the new one. VectorSubtract(cameraIdealTarget, cameraCurTarget, targetdiff); @@ -553,10 +553,10 @@ static void CG_UpdateThirdPersonTargetDamp(void) dampfactor = 1.0-cg_thirdPersonTargetDamp.value; // We must exponent the amount LEFT rather than the amount bled off dtime = (float)(cg.time-cameraLastFrame) * (1.0/cg_timescale.value) * (1.0/(float)CAMERA_DAMP_INTERVAL); // Our dampfactor is geared towards a time interval equal to "1". - // Note that since there are a finite number of "practical" delta millisecond values possible, + // Note that since there are a finite number of "practical" delta millisecond values possible, // the ratio should be initialized into a chart ultimately. ratio = pow(dampfactor, dtime); - + // This value is how much distance is "left" from the ideal. VectorMA(cameraIdealTarget, -ratio, targetdiff, cameraCurTarget); ///////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -587,8 +587,8 @@ static void CG_UpdateThirdPersonCameraDamp(void) // Set the cameraIdealLoc CG_CalcIdealThirdPersonViewLocation(); - - + + // First thing we do is calculate the appropriate damping factor for the camera. dampfactor=0.0f; if ( CG_OnMovingPlat( &cg.snap->ps ) ) @@ -605,7 +605,7 @@ static void CG_UpdateThirdPersonCameraDamp(void) pitch = Q_fabs(cameraFocusAngles[PITCH]); // The higher the pitch, the larger the factor, so as you look up, it damps a lot less. - pitch /= 89.0; + pitch /= 89.0; dampfactor = (1.0-cg.overrides.thirdPersonCameraDamp)*(pitch*pitch); dampfactor += cg.overrides.thirdPersonCameraDamp; @@ -619,7 +619,7 @@ static void CG_UpdateThirdPersonCameraDamp(void) pitch = Q_fabs(cameraFocusAngles[PITCH]); // The higher the pitch, the larger the factor, so as you look up, it damps a lot less. - pitch /= 89.0; + pitch /= 89.0; dampfactor = (1.0-cg_thirdPersonCameraDamp.value)*(pitch*pitch); dampfactor += cg_thirdPersonCameraDamp.value; @@ -636,7 +636,7 @@ static void CG_UpdateThirdPersonCameraDamp(void) VectorCopy(cameraIdealLoc, cameraCurLoc); } else if (dampfactor>=0.0) - { + { // Calculate the difference from the current position to the new one. VectorSubtract(cameraIdealLoc, cameraCurLoc, locdiff); @@ -645,10 +645,10 @@ static void CG_UpdateThirdPersonCameraDamp(void) dampfactor = 1.0-dampfactor; // We must exponent the amount LEFT rather than the amount bled off dtime = (float)(cg.time-cameraLastFrame) * (1.0/cg_timescale.value) * (1.0/(float)CAMERA_DAMP_INTERVAL); // Our dampfactor is geared towards a time interval equal to "1". - // Note that since there are a finite number of "practical" delta millisecond values possible, + // Note that since there are a finite number of "practical" delta millisecond values possible, // the ratio should be initialized into a chart ultimately. ratio = pow(dampfactor, dtime); - + // This value is how much distance is "left" from the ideal. VectorMA(cameraIdealLoc, -ratio, locdiff, cameraCurLoc); ///////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -702,7 +702,7 @@ CG_OffsetThirdPersonView =============== */ extern qboolean MatrixMode; -static void CG_OffsetThirdPersonView( void ) +static void CG_OffsetThirdPersonView( void ) { vec3_t diff; float deltayaw; @@ -714,7 +714,7 @@ static void CG_OffsetThirdPersonView( void ) VectorCopy( cg.refdefViewAngles, cameraFocusAngles ); // if dead, look at killer - if ( cg.predicted_player_state.stats[STAT_HEALTH] <= 0 ) + if ( cg.predicted_player_state.stats[STAT_HEALTH] <= 0 ) { if ( MatrixMode ) { @@ -937,7 +937,7 @@ static void CG_OffsetThirdPersonOverheadView( void ) { VectorCopy( cg.refdef.vieworg, view ); - // Move straight up from the player, making sure to always go at least the min camera height, + // Move straight up from the player, making sure to always go at least the min camera height, // otherwise, the camera will clip into the head of the player. float tpRange = cg.overrides.thirdPersonRange ? cg.overrides.thirdPersonRange : cg_thirdPersonRange.value; if ( tpRange < MIN_CAMERA_HEIGHT ) @@ -963,17 +963,17 @@ static void CG_OffsetThirdPersonOverheadView( void ) { angs[PITCH] = MAX_CAMERA_PITCH; } - // Convert our new desired camera angles and store them where they will get used by the engine + // Convert our new desired camera angles and store them where they will get used by the engine // when setting up the actual camera view. AnglesToAxis( angs, cg.refdef.viewaxis ); cg.refdefViewAngles[PITCH] = 0; g_entities[0].client->ps.delta_angles[PITCH] = 0; - + // Trace a ray from the origin to the viewpoint to make sure the view isn't // in a solid block. CG_Trace( &trace, cg.refdef.vieworg, mins, maxs, view, cg.predicted_player_state.clientNum, MASK_CAMERACLIP); - if ( trace.fraction != 1.0 ) + if ( trace.fraction != 1.0 ) { VectorCopy( trace.endpos, cg.refdef.vieworg ); } @@ -986,11 +986,11 @@ static void CG_OffsetThirdPersonOverheadView( void ) { // this causes a compiler bug on mac MrC compiler static void CG_StepOffset( void ) { int timeDelta; - + // smooth out stair climbing timeDelta = cg.time - cg.stepTime; if ( timeDelta < STEP_TIME ) { - cg.refdef.vieworg[2] -= cg.stepChange + cg.refdef.vieworg[2] -= cg.stepChange * (STEP_TIME - timeDelta) / STEP_TIME; } } @@ -1015,7 +1015,7 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) { float f; vec3_t predictedVelocity; int timeDelta; - + if ( cg.snap->ps.pm_type == PM_INTERMISSION ) { return; } @@ -1024,7 +1024,7 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) { angles = cg.refdefViewAngles; // if dead, fix the angle and don't add any kick - if ( cg.snap->ps.stats[STAT_HEALTH] <= 0 ) + if ( cg.snap->ps.stats[STAT_HEALTH] <= 0 ) { angles[ROLL] = 40; angles[PITCH] = -15; @@ -1084,7 +1084,7 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) { delta = DotProduct ( predictedVelocity, cg.refdef.viewaxis[0]); angles[PITCH] += delta * cg_runpitch.value; - + delta = DotProduct ( predictedVelocity, cg.refdef.viewaxis[1]); angles[ROLL] -= delta * cg_runroll.value; @@ -1172,7 +1172,7 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) { { #define NECK_LENGTH 8 vec3_t forward, up; - + cg.refdef.vieworg[2] -= NECK_LENGTH; AngleVectors( cg.refdefViewAngles, forward, NULL, up ); VectorMA( cg.refdef.vieworg, 3, forward, cg.refdef.vieworg ); @@ -1184,7 +1184,7 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) { //====================================================================== /* void CG_ZoomDown_f( void ) - { + { // Ignore zoom requests when yer paused if ( cg_paused.integer || in_camera ) { @@ -1218,9 +1218,9 @@ void CG_ZoomDown_f( void ) cgi_S_StartSound( cg.refdef.vieworg, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.zoomEnd ); } } - + void CG_ZoomUp_f( void ) - { + { // Ignore zoom requests when yer paused if ( cg_paused.integer || in_camera ) { @@ -1244,7 +1244,7 @@ Calcs Y FOV from given X FOV #define WAVE_AMPLITUDE 1 #define WAVE_FREQUENCY 0.4 -qboolean CG_CalcFOVFromX( float fov_x ) +qboolean CG_CalcFOVFromX( float fov_x ) { float x; float fov_y; @@ -1265,7 +1265,7 @@ qboolean CG_CalcFOVFromX( float fov_x ) fov_y = fov_y * 360 / M_PI; // there's a problem with this, it only takes the leafbrushes into account, not the entity brushes, - // so if you give slime/water etc properties to a func_door area brush in order to move the whole water + // so if you give slime/water etc properties to a func_door area brush in order to move the whole water // level up/down this doesn't take into account the door position, so warps the view the whole time // whether the water is up or not. Fortunately there's only one slime area in Trek that you can be under, // so lose it... @@ -1344,9 +1344,9 @@ static qboolean CG_CalcFov( void ) { // if in intermission, use a fixed value fov_x = 80; } - else if ( cg.snap - && cg.snap->ps.viewEntity > 0 - && cg.snap->ps.viewEntity < ENTITYNUM_WORLD + else if ( cg.snap + && cg.snap->ps.viewEntity > 0 + && cg.snap->ps.viewEntity < ENTITYNUM_WORLD && (!cg.renderingThirdPerson || g_entities[cg.snap->ps.viewEntity].e_DieFunc == dieF_camera_die) ) { // if in entity camera view, use a special FOV @@ -1375,8 +1375,8 @@ static qboolean CG_CalcFov( void ) { fov_x = 120;//FIXME: read from the NPC's fov stats? } } - } - else if ( (!cg.zoomMode || cg.zoomMode > 2) && (cg.snap->ps.forcePowersActive&(1<client->ps.forcePowerDuration[FP_SPEED] )//cg.renderingThirdPerson && + } + else if ( (!cg.zoomMode || cg.zoomMode > 2) && (cg.snap->ps.forcePowersActive&(1<client->ps.forcePowerDuration[FP_SPEED] )//cg.renderingThirdPerson && { fov_x = CG_ForceSpeedFOV(); } else { @@ -1428,7 +1428,7 @@ static qboolean CG_CalcFov( void ) { if ( zoomSoundTime < cg.time ) { sfxHandle_t snd; - + if ( cg.zoomMode == 1 ) { snd = cgs.media.zoomLoop; @@ -1440,7 +1440,7 @@ static qboolean CG_CalcFov( void ) { // huh? This could probably just be added as a looping sound?? cgi_S_StartSound( cg.refdef.vieworg, ENTITYNUM_WORLD, CHAN_LOCAL, snd ); - zoomSoundTime = cg.time + 150; + zoomSoundTime = cg.time + 150; } } } @@ -1466,7 +1466,7 @@ CG_DamageBlendBlob =============== */ -static void CG_DamageBlendBlob( void ) +static void CG_DamageBlendBlob( void ) { int t; int maxTime; @@ -1508,13 +1508,13 @@ CG_SaberClashFlare extern int g_saberFlashTime; extern vec3_t g_saberFlashPos; extern qboolean CG_WorldCoordToScreenCoord(vec3_t worldCoord, int *x, int *y); -void CG_SaberClashFlare( void ) +void CG_SaberClashFlare( void ) { int t, maxTime = 150; t = cg.time - g_saberFlashTime; - if ( t <= 0 || t >= maxTime ) + if ( t <= 0 || t >= maxTime ) { return; } @@ -1653,8 +1653,8 @@ static qboolean CG_CalcViewValues( void ) { } } - if ( (cg.renderingThirdPerson||cg.snap->ps.weapon == WP_SABER||cg.snap->ps.weapon == WP_MELEE) - && !cg.zoomMode + if ( (cg.renderingThirdPerson||cg.snap->ps.weapon == WP_SABER||cg.snap->ps.weapon == WP_MELEE) + && !cg.zoomMode && !viewEntIsCam ) { // back away from character @@ -1678,8 +1678,8 @@ static qboolean CG_CalcViewValues( void ) { } CG_OffsetThirdPersonView(); // } - } - else + } + else { // offset for local bobbing and kicks CG_OffsetFirstPersonView( qfalse ); @@ -1717,7 +1717,7 @@ static qboolean CG_CalcViewValues( void ) { /* if ( in_camera ) { - Com_Printf( "%s %s\n", vtos(client_camera.origin), vtos(cg.refdef.vieworg) ); + Com_Printf( "%s %s\n", vtos(client_camera.origin), vtos(cg.refdef.vieworg) ); } */ @@ -1732,7 +1732,7 @@ static qboolean CG_CalcViewValues( void ) { AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis ); - if ( cg.hyperspace ) + if ( cg.hyperspace ) { cg.refdef.rdflags |= RDF_NOWORLDMODEL | RDF_HYPERSPACE; } @@ -1747,16 +1747,16 @@ static qboolean CG_CalcViewValues( void ) { CG_PowerupTimerSounds ===================== */ -static void CG_PowerupTimerSounds( void ) +static void CG_PowerupTimerSounds( void ) { int i, time; - + // powerup timers going away - for ( i = 0 ; i < MAX_POWERUPS ; i++ ) + for ( i = 0 ; i < MAX_POWERUPS ; i++ ) { time = cg.snap->ps.powerups[i]; - if ( time > 0 && time < cg.time ) + if ( time > 0 && time < cg.time ) { // add any special powerup expiration sounds here // switch( i ) @@ -1879,11 +1879,11 @@ wasForceSpeed=isForceSpeed; float mYawOverride = 0.0f; if ( cg.snap->ps.clientNum == 0 ) {//pointless check, but.. - if ( cg_entities[0].gent->s.eFlags & EF_LOCKED_TO_WEAPON ) + if ( cg_entities[0].gent->s.eFlags & EF_LOCKED_TO_WEAPON ) { speed *= 0.25f; } - if ( cg_entities[0].gent->s.eFlags & EF_IN_ATST ) + if ( cg_entities[0].gent->s.eFlags & EF_IN_ATST ) { mPitchOverride = 0.01f; mYawOverride = 0.0075f; @@ -1913,10 +1913,10 @@ wasForceSpeed=isForceSpeed; if ( in_camera ) { // The camera takes over the view - CGCam_RenderScene(); + CGCam_RenderScene(); } else - { + { //Finish any fading that was happening CGCam_UpdateFade(); // build cg.refdef @@ -1928,14 +1928,13 @@ wasForceSpeed=isForceSpeed; // first person blend blobs, done after AnglesToAxis if ( !cg.renderingThirdPerson ) { - CG_DamageBlendBlob(); + CG_DamageBlendBlob(); } // build the render lists if ( !cg.hyperspace ) { CG_AddPacketEntities(); // adter calcViewValues, so predicted player state is correct CG_AddMarks(); - CG_AddLocalEntities(); } //check for opaque water @@ -1977,8 +1976,8 @@ wasForceSpeed=isForceSpeed; } // Don't draw the in-view weapon when in camera mode - if ( !in_camera - && !cg_pano.integer + if ( !in_camera + && !cg_pano.integer && cg.snap->ps.weapon != WP_SABER && ( cg.snap->ps.viewEntity == 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD ) ) { @@ -1990,7 +1989,7 @@ wasForceSpeed=isForceSpeed; CG_AddViewWeapon( &g_entities[cg.snap->ps.viewEntity ].client->ps ); // HAX - because I wanted to --eez } - if ( !cg.hyperspace ) + if ( !cg.hyperspace ) { //Add all effects theFxScheduler.AddScheduledEffects( ); @@ -2000,7 +1999,11 @@ wasForceSpeed=isForceSpeed; if ( cg.testModelEntity.hModel ) { CG_AddTestModel(); } - + + if ( !cg.hyperspace ) { + CG_AddLocalEntities(); + } + cg.refdef.time = cg.time; memcpy( cg.refdef.areamask, cg.snap->areamask, sizeof( cg.refdef.areamask ) ); @@ -2015,7 +2018,7 @@ wasForceSpeed=isForceSpeed; if ( cg_pano.integer ) { // let's grab a panorama! cg.levelShot = qtrue; //hide the 2d - VectorClear(cg.refdefViewAngles); + VectorClear(cg.refdefViewAngles); cg.refdefViewAngles[YAW] = -360 * cg_pano.integer/cg_panoNumShots.integer; //choose angle AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis ); CG_DrawActive( stereoView ); diff --git a/codeJK2/game/AI_Atst.cpp b/codeJK2/game/AI_Atst.cpp index 952e8b4aa5..01da26ae4f 100644 --- a/codeJK2/game/AI_Atst.cpp +++ b/codeJK2/game/AI_Atst.cpp @@ -21,7 +21,7 @@ along with this program; if not, see . */ #include "g_headers.h" - + #include "b_local.h" @@ -65,7 +65,7 @@ static void ATST_PlayEffect( gentity_t *self, const int boltID, const char *fx ) mdxaBone_t boltMatrix; vec3_t org, dir; - gi.G2API_GetBoltMatrix( self->ghoul2, self->playerModel, + gi.G2API_GetBoltMatrix( self->ghoul2, self->playerModel, boltID, &boltMatrix, self->currentAngles, self->currentOrigin, (cg.time?cg.time:level.time), NULL, self->s.modelScale ); @@ -88,7 +88,7 @@ Called by NPC's and player in an ATST void G_ATSTCheckPain( gentity_t *self, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { int newBolt; - + if ( rand() & 1 ) { G_SoundOnEnt( self, CHAN_LESS_ATTEN, "sound/chars/atst/atst_damaged1" ); @@ -116,7 +116,7 @@ void G_ATSTCheckPain( gentity_t *self, gentity_t *other, vec3_t point, int damag else if ((hitLoc==HL_ARM_RT) && (self->locationDamage[HL_ARM_RT] > RIGHT_ARM_HEALTH)) // Blow it up? { if (self->locationDamage[hitLoc] >= RIGHT_ARM_HEALTH) - { + { newBolt = gi.G2API_AddBolt( &self->ghoul2[self->playerModel], "*flash4" ); if ( newBolt != -1 ) { @@ -134,7 +134,7 @@ void G_ATSTCheckPain( gentity_t *self, gentity_t *other, vec3_t point, int damag NPC_ATST_Pain ------------------------- */ -void NPC_ATST_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_ATST_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { G_ATSTCheckPain( self, other, point, damage, mod, hitLoc ); NPC_Pain( self, inflictor, other, point, damage, mod ); @@ -206,7 +206,7 @@ void ATST_Attack( void ) NPC_FaceEnemy( qtrue ); // Rate our distance to the target, and our visibilty - float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); distance_e distRate = ( distance > MIN_MELEE_RANGE_SQR ) ? DIST_LONG : DIST_MELEE; qboolean visible = NPC_ClearLOS( NPC->enemy ); qboolean advance = (qboolean)(distance > MIN_DISTANCE_SQR); @@ -259,7 +259,7 @@ void ATST_Attack( void ) { altAttack = qtrue; } - else + else { NPC_ChangeWeapon( WP_NONE ); } @@ -328,7 +328,7 @@ void NPC_BSATST_Default( void ) else if ( NPCInfo->scriptFlags & SCF_LOOK_FOR_ENEMIES ) { ATST_Patrol(); - } + } else { ATST_Idle(); diff --git a/codeJK2/game/AI_Default.cpp b/codeJK2/game/AI_Default.cpp index 55ddda93c3..f0a8aed4fa 100644 --- a/codeJK2/game/AI_Default.cpp +++ b/codeJK2/game/AI_Default.cpp @@ -95,10 +95,10 @@ void NPC_StandIdle( void ) newIdle = Q_irand( 0, MAX_IDLE_ANIMS ); } - + //Start that animation going NPC_SetAnim( NPC, SETANIM_BOTH, baseSeq + newIdle, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD ); - + int newTime = PM_AnimLength( NPC->client->clientInfo.animFileIndex, (animNumber_t) (baseSeq + newIdle) ); //Don't do this again for a random amount of time @@ -174,7 +174,7 @@ qboolean NPC_StandTrackAndShoot (gentity_t *NPC, qboolean canDuck) } -void NPC_BSIdle( void ) +void NPC_BSIdle( void ) { //FIXME if there is no nav data, we need to do something else // if we're stuck, try to move around it @@ -233,7 +233,7 @@ void NPC_BSStandGuard (void) { NPCInfo->tempBehavior = BS_DEFAULT; } - + if( NPCInfo->behaviorState == BS_STAND_GUARD ) { NPCInfo->behaviorState = BS_STAND_AND_SHOOT; @@ -279,7 +279,7 @@ void NPC_BSHuntAndKill( void ) enemyDist = VectorLength(vec); if( enemyDist > 48 && ((enemyDist*1.5)*(enemyDist*1.5) >= NPC_MaxDistSquaredForWeapon() || oEVis != VIS_SHOOT || - //!(ucmd.buttons & BUTTON_ATTACK) || + //!(ucmd.buttons & BUTTON_ATTACK) || enemyDist > IdealDistance(NPC)*3 ) ) {//We should close in? NPCInfo->goalEntity = NPC->enemy; @@ -303,7 +303,7 @@ void NPC_BSHuntAndKill( void ) }//otherwise, stay where we are } } - else + else {//ok, stand guard until we find an enemy if( NPCInfo->tempBehavior == BS_HUNT_AND_KILL ) { @@ -331,7 +331,7 @@ void NPC_BSStandAndShoot (void) //FIXME: //When they're all dead, go to some script or wander off to sickbay? - + if(NPC->client->playerTeam && NPC->client->enemyTeam) { //FIXME: don't realize this right away- or else enemies show up and we're standing around @@ -382,7 +382,7 @@ void NPC_BSStandAndShoot (void) } NPC_CheckEnemy(qtrue, qfalse); - + if(NPCInfo->duckDebounceTime > level.time && NPC->client->ps.weapon != WP_SABER ) { ucmd.upmove = -127; @@ -390,7 +390,7 @@ void NPC_BSStandAndShoot (void) { NPC_CheckCanAttack(1.0, qtrue); } - return; + return; } if(NPC->enemy) @@ -432,7 +432,7 @@ void NPC_BSRunAndShoot (void) //NPCInfo->combatMove = qtrue; NPC_CheckEnemy( qtrue, qfalse ); - + if ( NPCInfo->duckDebounceTime > level.time ) // && NPCInfo->hidingGoal ) { ucmd.upmove = -127; @@ -440,7 +440,7 @@ void NPC_BSRunAndShoot (void) { NPC_CheckCanAttack( 1.0, qfalse ); } - return; + return; } if ( NPC->enemy ) @@ -457,13 +457,13 @@ void NPC_BSRunAndShoot (void) if ( VectorLength( vec ) > 128 || NPC->cantHitEnemyCounter >= 10 ) {//run at enemy if too far away //The cantHitEnemyCounter getting high has other repercussions - //100 (10 seconds) will make you try to pick a new enemy... + //100 (10 seconds) will make you try to pick a new enemy... //But we're chasing, so we clamp it at 50 here if ( NPC->cantHitEnemyCounter > 60 ) { NPC->cantHitEnemyCounter = 60; } - + if ( NPC->cantHitEnemyCounter >= (NPCInfo->stats.aggression+1) * 10 ) { NPC_LostEnemyDecideChase(); @@ -484,9 +484,9 @@ void NPC_BSRunAndShoot (void) //of a thin wall or something else blocking out shot. That //would make us just stand there and not go around it... //but maybe it's okay- might look like we're waiting for - //him to come out...? + //him to come out...? //Current solution: runs around if cantHitEnemyCounter gets - //to 10 (1 second). + //to 10 (1 second). } } else @@ -514,7 +514,7 @@ void NPC_BSFace (void) if( NPC_UpdateAngles ( qtrue, qtrue ) ) { Q3_TaskIDComplete( NPC, TID_BSTATE ); - + NPCInfo->desiredYaw = client->ps.viewangles[YAW]; NPCInfo->desiredPitch = client->ps.viewangles[PITCH]; @@ -566,7 +566,7 @@ void NPC_BSPointShoot (qboolean shoot) {//FIXME: needs to hold this down if using a weapon that requires it, like phaser... ucmd.buttons |= BUTTON_ATTACK; } - + if ( !shoot || !(NPC->svFlags & SVF_LOCKEDENEMY) ) {//If locked_enemy is on, dont complete until it is destroyed... Q3_TaskIDComplete( NPC, TID_BSTATE ); @@ -596,7 +596,7 @@ void NPC_BSPointShoot (qboolean shoot) float dist = VectorLength( dir ); float yawMiss, yawMissAllow = NPC->enemy->maxs[0]; float pitchMiss, pitchMissAllow = (NPC->enemy->maxs[2] - NPC->enemy->mins[2])/2; - + if ( yawMissAllow < 8.0f ) { yawMissAllow = 8.0f; @@ -616,9 +616,9 @@ void NPC_BSPointShoot (qboolean shoot) } } } - + return; - + finished: NPCInfo->desiredYaw = client->ps.viewangles[YAW]; NPCInfo->desiredPitch = client->ps.viewangles[PITCH]; @@ -664,7 +664,7 @@ void NPC_BSShoot(void) enemyVisibility = VIS_SHOOT; - if ( client->ps.weaponstate != WEAPON_READY && client->ps.weaponstate != WEAPON_FIRING ) + if ( client->ps.weaponstate != WEAPON_READY && client->ps.weaponstate != WEAPON_FIRING ) { client->ps.weaponstate = WEAPON_READY; } @@ -673,12 +673,12 @@ void NPC_BSShoot(void) } /* -void NPC_BSPatrol( void ) +void NPC_BSPatrol( void ) Same as idle, but you look for enemies every "vigilance" using your angles, HFOV, VFOV and visrange, and listen for sounds within earshot... */ -void NPC_BSPatrol( void ) +void NPC_BSPatrol( void ) { //int alertEventNum; @@ -726,7 +726,7 @@ void NPC_BSDefault(void) extern void NPC_CheckGetNewWeapon( void ); extern void NPC_BSST_Attack( void ); -void NPC_BSDefault( void ) +void NPC_BSDefault( void ) { // vec3_t enemyDir; // float enemyDist; @@ -741,7 +741,7 @@ void NPC_BSDefault( void ) qboolean move = qtrue; // qboolean shoot = qfalse; - + if( NPCInfo->scriptFlags & SCF_FIRE_WEAPON ) { WeaponThink( qtrue ); @@ -785,8 +785,8 @@ void NPC_BSDefault( void ) { // just use the stormtrooper attack AI... NPC_CheckGetNewWeapon(); - if ( NPC->client->leader - && NPCInfo->goalEntity == NPC->client->leader + if ( NPC->client->leader + && NPCInfo->goalEntity == NPC->client->leader && !Q3_TaskIDPending( NPC, TID_MOVE_NAV ) ) { NPC_ClearGoal(); @@ -822,7 +822,7 @@ void NPC_BSDefault( void ) enemyLOS = qfalse; enemyCS = qfalse; } - + if ( enemyCS && enemyShotFOV ) {//can hit enemy if we want NPC->cantHitEnemyCounter = 0; @@ -883,7 +883,7 @@ void NPC_BSDefault( void ) {//pick a new one NPC_CheckEnemy( qtrue, qfalse ); } - + if ( enemyPVS && enemyLOS )//&& !enemyShotFOV ) {//have a clear LOS to him//, but not looking at him //Find the desired angles @@ -899,9 +899,9 @@ void NPC_BSDefault( void ) if ( UpdateGoal() ) {//have a goal - if ( !NPC->enemy - && NPC->client->leader - && NPCInfo->goalEntity == NPC->client->leader + if ( !NPC->enemy + && NPC->client->leader + && NPCInfo->goalEntity == NPC->client->leader && !Q3_TaskIDPending( NPC, TID_MOVE_NAV ) ) { NPC_BSFollowLeader(); diff --git a/codeJK2/game/AI_Droid.cpp b/codeJK2/game/AI_Droid.cpp index f911137d4b..a21c45416d 100644 --- a/codeJK2/game/AI_Droid.cpp +++ b/codeJK2/game/AI_Droid.cpp @@ -20,7 +20,7 @@ along with this program; if not, see . =========================================================================== */ #include "g_headers.h" - + #include "b_local.h" //static void R5D2_LookAround( void ); @@ -51,13 +51,13 @@ void R2D2_PartsMove(void) { NPC->pos1[1] = AngleNormalize360( NPC->pos1[1]); - NPC->pos1[0]+=Q_irand( -20, 20 ); // Roll - NPC->pos1[1]=Q_irand( -20, 20 ); - NPC->pos1[2]=Q_irand( -20, 20 ); + NPC->pos1[0]+=Q_irand( -20, 20 ); // Roll + NPC->pos1[1]=Q_irand( -20, 20 ); + NPC->pos1[2]=Q_irand( -20, 20 ); if (NPC->genericBone1) { - gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone1, NPC->pos1, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, 0 ); + gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone1, NPC->pos1, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, 0 ); } TIMER_Set( NPC, "eyeDelay", Q_irand( 100, 1000 ) ); } @@ -194,11 +194,11 @@ void Droid_Run( void ) if ( NPCInfo->localState == LSTATE_BACKINGUP ) { ucmd.forwardmove = -127; - NPCInfo->desiredYaw += 5; + NPCInfo->desiredYaw += 5; NPCInfo->localState = LSTATE_NONE; // So he doesn't constantly backup. } - else + else { ucmd.forwardmove = 64; //If we have somewhere to go, then do that @@ -225,7 +225,7 @@ void Droid_Spin( void ) R2D2_TurnAnims(); - + // Head is gone, spin and spark if ( NPC->client->NPC_class == CLASS_R5D2 ) { @@ -247,7 +247,7 @@ void Droid_Spin( void ) ucmd.forwardmove = Q_irand( -64, 64); if (TIMER_Done(NPC,"roam")) - { + { TIMER_Set( NPC, "roam", Q_irand( 250, 1000 ) ); NPCInfo->desiredYaw = Q_irand( 0, 360 ); // Go in random directions } @@ -264,7 +264,7 @@ void Droid_Spin( void ) } } } - else + else { if (TIMER_Done(NPC,"roam")) { @@ -284,7 +284,7 @@ void Droid_Spin( void ) NPC_BSDroid_Pain ------------------------- */ -void NPC_Droid_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_Droid_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { int anim; float pain_chance; @@ -303,7 +303,7 @@ void NPC_Droid_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve { if (!(self->spawnflags & 2)) // Doesn't have to ALWAYSDIE { - if ((self->NPC->localState != LSTATE_SPINNING) && + if ((self->NPC->localState != LSTATE_SPINNING) && (!gi.G2API_GetSurfaceRenderStatus( &self->ghoul2[self->playerModel], "head" ))) { gi.G2API_SetSurfaceOnOff( &self->ghoul2[self->playerModel], "head", TURN_OFF ); @@ -339,7 +339,7 @@ void NPC_Droid_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve // Spin around in pain self->NPC->localState = LSTATE_SPINNING; TIMER_Set( self, "roam", Q_irand(1000,2000)); - } + } } } else if (self->client->NPC_class == CLASS_MOUSE) @@ -380,7 +380,7 @@ void NPC_Droid_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve // Spin around in pain self->NPC->localState = LSTATE_SPINNING; TIMER_Set( self, "roam", Q_irand(1000,2000)); - } + } } else if ( self->client->NPC_class == CLASS_INTERROGATOR && ( mod == MOD_DEMP2 || mod == MOD_DEMP2_ALT ) && other ) { @@ -500,7 +500,7 @@ static void R5D2_OffsetLook( float offset, vec3_t out ) angles[YAW] += offset; AngleVectors( angles, forward, NULL, NULL ); VectorMA( NPC->currentOrigin, 64, forward, out ); - + CalcEntitySpot( NPC, SPOT_HEAD, temp ); out[2] = temp[2]; } diff --git a/codeJK2/game/AI_GalakMech.cpp b/codeJK2/game/AI_GalakMech.cpp index 8d8738e6a9..b3ad869f87 100644 --- a/codeJK2/game/AI_GalakMech.cpp +++ b/codeJK2/game/AI_GalakMech.cpp @@ -30,7 +30,7 @@ extern qboolean G_StandardHumanoid( const char *modelName ); extern void G_AddVoiceEvent( gentity_t *self, int event, int speakDebounceTime ); extern qboolean Q3_TaskIDPending( gentity_t *ent, taskID_t taskType ); extern void NPC_AimAdjust( int change ); -extern qboolean WP_LobFire( gentity_t *self, vec3_t start, vec3_t target, vec3_t mins, vec3_t maxs, int clipmask, +extern qboolean WP_LobFire( gentity_t *self, vec3_t start, vec3_t target, vec3_t mins, vec3_t maxs, int clipmask, vec3_t velocity, qboolean tracePath, int ignoreEntNum, int enemyNum, float minSpeed, float maxSpeed, float idealSpeed, qboolean mustHit ); extern qboolean InFront( vec3_t spot, vec3_t from, vec3_t fromAngles, float threshHold = 0.0f ); @@ -126,7 +126,7 @@ static void GM_CreateExplosion( gentity_t *self, const int boltID, qboolean doSm mdxaBone_t boltMatrix; vec3_t org, dir; - gi.G2API_GetBoltMatrix( self->ghoul2, self->playerModel, + gi.G2API_GetBoltMatrix( self->ghoul2, self->playerModel, boltID, &boltMatrix, self->currentAngles, self->currentOrigin, (cg.time?cg.time:level.time), NULL, self->s.modelScale ); @@ -255,7 +255,7 @@ NPC_GM_Pain */ extern void NPC_SetPainEvent( gentity_t *self ); -void NPC_GM_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_GM_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, vec3_t point, int damage, int mod,int hitLoc ) { if ( self->client->ps.powerups[PW_GALAK_SHIELD] == 0 ) {//shield is currently down @@ -387,13 +387,13 @@ static qboolean GM_Move( void ) qboolean moved = NPC_MoveToGoal( qtrue ); navInfo_t info; - + //Get the move info NAV_GetLastMove( info ); //FIXME: if we bump into another one of our guys and can't get around him, just stop! //If we hit our target, then stop and fire! - if ( info.flags & NIF_COLLISION ) + if ( info.flags & NIF_COLLISION ) { if ( info.blocker == NPC->enemy ) { @@ -454,7 +454,7 @@ static void GM_CheckMoveState( void ) if ( ( NPCInfo->goalEntity != NPC->enemy ) && ( NPCInfo->goalEntity != NULL ) ) { //Did we make it? - if ( NAV_HitNavGoal( NPC->currentOrigin, NPC->mins, NPC->maxs, NPCInfo->goalEntity->currentOrigin, 16, qfalse ) || + if ( NAV_HitNavGoal( NPC->currentOrigin, NPC->mins, NPC->maxs, NPCInfo->goalEntity->currentOrigin, 16, qfalse ) || ( !Q3_TaskIDPending( NPC, TID_MOVE_NAV ) && enemyLOS && enemyDist <= 10000 ) ) {//either hit our navgoal or our navgoal was not a crucial (scripted) one (maybe a combat point) and we're scouting and found our enemy NPC_ReachedGoal(); @@ -602,7 +602,7 @@ void NPC_BSGM_Attack( void ) } //FIXME: if killed enemy, use victory anim - if ( NPC->enemy && NPC->enemy->health <= 0 + if ( NPC->enemy && NPC->enemy->health <= 0 && !NPC->enemy->s.number ) {//my enemy is dead if ( NPC->client->ps.torsoAnim == BOTH_STAND2TO1 ) @@ -693,7 +693,7 @@ void NPC_BSGM_Attack( void ) VectorNormalize( smackDir ); //hurt them G_Sound( NPC->enemy, G_SoundIndex( "sound/weapons/galak/skewerhit.wav" ) ); - G_Damage( NPC->enemy, NPC, NPC, smackDir, NPC->currentOrigin, (g_spskill->integer+1)*Q_irand( 5, 10), DAMAGE_NO_ARMOR|DAMAGE_NO_KNOCKBACK, MOD_CRUSH ); + G_Damage( NPC->enemy, NPC, NPC, smackDir, NPC->currentOrigin, (g_spskill->integer+1)*Q_irand( 5, 10), DAMAGE_NO_ARMOR|DAMAGE_NO_KNOCKBACK, MOD_CRUSH ); if ( NPC->client->ps.torsoAnim == BOTH_ATTACK4 ) {//smackdown int knockAnim = BOTH_KNOCKDOWN1; @@ -800,10 +800,10 @@ void NPC_BSGM_Attack( void ) } } } - else + else {//Okay, we're not in a special attack, see if we should switch weapons or start a special attack /* - if ( NPC->s.weapon == WP_REPEATER + if ( NPC->s.weapon == WP_REPEATER && !(NPCInfo->scriptFlags & SCF_ALT_FIRE)//using rapid-fire && NPC->enemy->s.weapon == WP_SABER //enemy using saber && NPC->client && (NPC->client->ps.saberEventFlags&SEF_DEFLECTED) @@ -818,9 +818,9 @@ void NPC_BSGM_Attack( void ) } } else*/ - if ( !NPC->client->ps.powerups[PW_GALAK_SHIELD] - && enemyDist < MELEE_DIST_SQUARED - && InFront( NPC->enemy->currentOrigin, NPC->currentOrigin, NPC->client->ps.viewangles, 0.3f ) + if ( !NPC->client->ps.powerups[PW_GALAK_SHIELD] + && enemyDist < MELEE_DIST_SQUARED + && InFront( NPC->enemy->currentOrigin, NPC->currentOrigin, NPC->client->ps.viewangles, 0.3f ) && G_StandardHumanoid( NPC->enemy->NPC_type ) )//within 80 and in front {//our shield is down, and enemy within 80, if very close, use melee attack to slap away if ( TIMER_Done( NPC, "attackDelay" ) ) @@ -848,13 +848,13 @@ void NPC_BSGM_Attack( void ) && TIMER_Done( NPC, "attackDelay" ) && InFront( NPC->enemy->currentOrigin, NPC->currentOrigin, NPC->client->ps.viewangles, 0.3f ) && ((!Q_irand( 0, 10*(2-g_spskill->integer))&& enemyDist > MIN_LOB_DIST_SQUARED&& enemyDist < MAX_LOB_DIST_SQUARED) - ||(!TIMER_Done( NPC, "noLob" )&&!TIMER_Done( NPC, "noRapid" ))) + ||(!TIMER_Done( NPC, "noLob" )&&!TIMER_Done( NPC, "noRapid" ))) && NPC->enemy->s.weapon != WP_TURRET ) {//sometimes use the laser beam attack, but only after he's taken down our generator shoot = qfalse; NPC_GM_StartLaser(); } - else if ( enemyDist < MIN_LOB_DIST_SQUARED + else if ( enemyDist < MIN_LOB_DIST_SQUARED && (NPC->enemy->s.weapon != WP_TURRET || Q_stricmp( "PAS", NPC->enemy->classname )) && TIMER_Done( NPC, "noRapid" ) )//256 {//enemy within 256 @@ -902,7 +902,7 @@ void NPC_BSGM_Attack( void ) { int hit = NPC_ShotEntity( NPC->enemy, impactPos ); gentity_t *hitEnt = &g_entities[hit]; - if ( hit == NPC->enemy->s.number + if ( hit == NPC->enemy->s.number || ( hitEnt && hitEnt->client && hitEnt->client->playerTeam == NPC->client->enemyTeam ) || ( hitEnt && hitEnt->takedamage ) ) {//can hit enemy or will hit glass or other breakable, so shoot anyway @@ -961,7 +961,7 @@ void NPC_BSGM_Attack( void ) int hit = NPC_ShotEntity( NPC->enemy, impactPos ); gentity_t *hitEnt = &g_entities[hit]; - if ( hit == NPC->enemy->s.number + if ( hit == NPC->enemy->s.number || ( hitEnt && hitEnt->client && hitEnt->client->playerTeam == NPC->client->enemyTeam ) || ( hitEnt && hitEnt->takedamage ) ) {//can hit enemy or will hit glass or other breakable, so shoot anyway @@ -1021,7 +1021,7 @@ void NPC_BSGM_Attack( void ) vec3_t mins = {-REPEATER_ALT_SIZE,-REPEATER_ALT_SIZE,-REPEATER_ALT_SIZE}, maxs = {REPEATER_ALT_SIZE,REPEATER_ALT_SIZE,REPEATER_ALT_SIZE}; CalcEntitySpot( NPC, SPOT_WEAPON, muzzle ); - + VectorCopy( NPC->enemy->currentOrigin, target ); target[0] += Q_flrand( -5, 5 )+(Q_flrand(-1.0f, 1.0f)*(6-NPCInfo->currentAim)*2); @@ -1029,7 +1029,7 @@ void NPC_BSGM_Attack( void ) target[2] += Q_flrand( -5, 5 )+(Q_flrand(-1.0f, 1.0f)*(6-NPCInfo->currentAim)*2); //Find the desired angles - qboolean clearshot = WP_LobFire( NPC, muzzle, target, mins, maxs, MASK_SHOT|CONTENTS_LIGHTSABER, + qboolean clearshot = WP_LobFire( NPC, muzzle, target, mins, maxs, MASK_SHOT|CONTENTS_LIGHTSABER, velocity, qtrue, NPC->s.number, NPC->enemy->s.number, 300, 1100, 1500, qtrue ); if ( VectorCompare( vec3_origin, velocity ) || (!clearshot&&enemyLOS&&enemyCS) ) @@ -1077,11 +1077,11 @@ void NPC_BSGM_Attack( void ) if ( AImove && !NPC->lockCount ) {//move toward goal - if ( NPCInfo->goalEntity + if ( NPCInfo->goalEntity && NPC->client->ps.legsAnim != BOTH_ALERT1 - && NPC->client->ps.legsAnim != BOTH_ATTACK2 + && NPC->client->ps.legsAnim != BOTH_ATTACK2 && NPC->client->ps.legsAnim != BOTH_ATTACK4 - && NPC->client->ps.legsAnim != BOTH_ATTACK5 + && NPC->client->ps.legsAnim != BOTH_ATTACK5 && NPC->client->ps.legsAnim != BOTH_ATTACK7 ) { AImove = GM_Move(); @@ -1146,11 +1146,11 @@ void NPC_BSGM_Attack( void ) if ( NPC->client->ps.powerups[PW_GALAK_SHIELD] > 0 ) { NPC->client->ps.powerups[PW_BATTLESUIT] = level.time + ARMOR_EFFECT_TIME; - G_Damage( NPC->enemy, NPC, NPC, NULL, NPC->currentOrigin, 100, DAMAGE_NO_KNOCKBACK, MOD_ELECTROCUTE ); + G_Damage( NPC->enemy, NPC, NPC, NULL, NPC->currentOrigin, 100, DAMAGE_NO_KNOCKBACK, MOD_ELECTROCUTE ); } else { - G_Damage( NPC->enemy, NPC, NPC, NULL, NPC->currentOrigin, 100, DAMAGE_NO_KNOCKBACK, MOD_CRUSH ); + G_Damage( NPC->enemy, NPC, NPC, NULL, NPC->currentOrigin, 100, DAMAGE_NO_KNOCKBACK, MOD_CRUSH ); } } } @@ -1170,7 +1170,7 @@ void NPC_BSGM_Attack( void ) VectorSubtract( NPC->enemy->currentOrigin, NPC->currentOrigin, smackDir ); smackDir[2] += 30; VectorNormalize( smackDir ); - G_Damage( NPC->enemy, NPC, NPC, smackDir, NPC->currentOrigin, (g_spskill->integer+1)*Q_irand( 5, 10), DAMAGE_NO_KNOCKBACK, MOD_ELECTROCUTE ); + G_Damage( NPC->enemy, NPC, NPC, smackDir, NPC->currentOrigin, (g_spskill->integer+1)*Q_irand( 5, 10), DAMAGE_NO_KNOCKBACK, MOD_ELECTROCUTE ); //throw them G_Throw( NPC->enemy, smackDir, 100 ); NPC->enemy->s.powerups |= ( 1 << PW_SHOCKED ); @@ -1212,7 +1212,7 @@ void NPC_BSGM_Default( void ) { WeaponThink( qtrue ); } - + if ( NPC->client->ps.stats[STAT_ARMOR] <= 0 ) {//armor gone if ( !NPCInfo->investigateDebounceTime ) diff --git a/codeJK2/game/AI_Grenadier.cpp b/codeJK2/game/AI_Grenadier.cpp index 125eaf8ebd..0c1e1d8a0a 100644 --- a/codeJK2/game/AI_Grenadier.cpp +++ b/codeJK2/game/AI_Grenadier.cpp @@ -94,7 +94,7 @@ void NPC_Grenadier_PlayConfusionSound( gentity_t *self ) TIMER_Set( self, "flee", 0 ); self->NPC->squadState = SQUAD_IDLE; self->NPC->tempBehavior = BS_DEFAULT; - + //self->NPC->behaviorState = BS_PATROL; G_ClearEnemy( self );//FIXME: or just self->enemy = NULL;? @@ -108,7 +108,7 @@ NPC_ST_Pain ------------------------- */ -void NPC_Grenadier_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod ) +void NPC_Grenadier_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod ) { self->NPC->localState = LSTATE_UNDERFIRE; @@ -133,7 +133,7 @@ static void Grenadier_HoldPosition( void ) { NPC_FreeCombatPoint( NPCInfo->combatPoint, qtrue ); NPCInfo->goalEntity = NULL; - + /*if ( TIMER_Done( NPC, "stand" ) ) {//FIXME: what if can't shoot from this pos? TIMER_Set( NPC, "duck", Q_irand( 2000, 4000 ) ); @@ -153,13 +153,13 @@ static qboolean Grenadier_Move( void ) qboolean moved = NPC_MoveToGoal( qtrue ); navInfo_t info; - + //Get the move info NAV_GetLastMove( info ); //FIXME: if we bump into another one of our guys and can't get around him, just stop! //If we hit our target, then stop and fire! - if ( info.flags & NIF_COLLISION ) + if ( info.flags & NIF_COLLISION ) { if ( info.blocker == NPC->enemy ) { @@ -238,8 +238,8 @@ void NPC_BSGrenadier_Patrol( void ) NPCInfo->lastAlertID = level.alertEvents[alertEvent].ID; if ( level.alertEvents[alertEvent].level == AEL_DISCOVERED ) { - if ( level.alertEvents[alertEvent].owner && - level.alertEvents[alertEvent].owner->client && + if ( level.alertEvents[alertEvent].owner && + level.alertEvents[alertEvent].owner->client && level.alertEvents[alertEvent].owner->health >= 0 && level.alertEvents[alertEvent].owner->client->playerTeam == NPC->client->enemyTeam ) {//an enemy @@ -266,15 +266,15 @@ void NPC_BSGrenadier_Patrol( void ) //NOTE: stops walking or doing anything else below vec3_t dir, angles; float o_yaw, o_pitch; - + VectorSubtract( NPCInfo->investigateGoal, NPC->client->renderInfo.eyePoint, dir ); vectoangles( dir, angles ); - + o_yaw = NPCInfo->desiredYaw; o_pitch = NPCInfo->desiredPitch; NPCInfo->desiredYaw = angles[YAW]; NPCInfo->desiredPitch = angles[PITCH]; - + NPC_UpdateAngles( qtrue, qtrue ); NPCInfo->desiredYaw = o_yaw; @@ -361,7 +361,7 @@ static void Grenadier_CheckMoveState( void ) if ( ( NPCInfo->goalEntity != NPC->enemy ) && ( NPCInfo->goalEntity != NULL ) ) { //Did we make it? - if ( NAV_HitNavGoal( NPC->currentOrigin, NPC->mins, NPC->maxs, NPCInfo->goalEntity->currentOrigin, 16, FlyingCreature( NPC ) ) || + if ( NAV_HitNavGoal( NPC->currentOrigin, NPC->mins, NPC->maxs, NPCInfo->goalEntity->currentOrigin, 16, FlyingCreature( NPC ) ) || ( NPCInfo->squadState == SQUAD_SCOUT && enemyLOS && enemyDist <= 10000 ) ) { //int newSquadState = SQUAD_STAND_AND_SHOOT; @@ -554,12 +554,12 @@ void NPC_BSGrenadier_Attack( void ) } } else if ( InFOV( NPC->enemy->currentOrigin, NPC->currentOrigin, NPC->client->ps.viewangles, 45, 90 ) ) - {//in front of me + {//in front of me //can we shoot our target? //FIXME: how accurate/necessary is this check? int hit = NPC_ShotEntity( NPC->enemy ); gentity_t *hitEnt = &g_entities[hit]; - if ( hit == NPC->enemy->s.number + if ( hit == NPC->enemy->s.number || ( hitEnt && hitEnt->client && hitEnt->client->playerTeam == NPC->client->enemyTeam ) ) { VectorCopy( NPC->enemy->currentOrigin, NPCInfo->enemyLastSeenLocation ); @@ -661,13 +661,13 @@ void NPC_BSGrenadier_Attack( void ) if ( shoot ) {//try to shoot if it's time if ( TIMER_Done( NPC, "attackDelay" ) ) - { + { if( !(NPCInfo->scriptFlags & SCF_FIRE_WEAPON) ) // we've already fired, no need to do it again here { WeaponThink( qtrue ); TIMER_Set( NPC, "attackDelay", NPCInfo->shotTime-level.time ); } - + } } } diff --git a/codeJK2/game/AI_Howler.cpp b/codeJK2/game/AI_Howler.cpp index 3930b0d8b4..0332b8716f 100644 --- a/codeJK2/game/AI_Howler.cpp +++ b/codeJK2/game/AI_Howler.cpp @@ -20,7 +20,7 @@ along with this program; if not, see . =========================================================================== */ #include "g_headers.h" - + #include "b_local.h" // These define the working combat range for these suckers @@ -91,7 +91,7 @@ void Howler_Patrol( void ) return; } } - + /* ------------------------- Howler_Move @@ -169,7 +169,7 @@ void Howler_Combat( void ) // Sometimes I have problems with facing the enemy I'm attacking, so force the issue so I don't look dumb NPC_FaceEnemy( qtrue ); - float distance = DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); qboolean advance = (qboolean)( distance > MIN_DISTANCE_SQR ? qtrue : qfalse ); @@ -195,7 +195,7 @@ void Howler_Combat( void ) NPC_Howler_Pain ------------------------- */ -void NPC_Howler_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_Howler_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { if ( damage >= 10 ) { diff --git a/codeJK2/game/AI_ImperialProbe.cpp b/codeJK2/game/AI_ImperialProbe.cpp index a7fb3aeb2d..fbb58c3925 100644 --- a/codeJK2/game/AI_ImperialProbe.cpp +++ b/codeJK2/game/AI_ImperialProbe.cpp @@ -67,7 +67,7 @@ Hunter_MaintainHeight #define VELOCITY_DECAY 0.85f void ImperialProbe_MaintainHeight( void ) -{ +{ float dif; // vec3_t endPos; // trace_t trace; @@ -79,7 +79,7 @@ void ImperialProbe_MaintainHeight( void ) if ( NPC->enemy ) { // Find the height difference - dif = NPC->enemy->currentOrigin[2] - NPC->currentOrigin[2]; + dif = NPC->enemy->currentOrigin[2] - NPC->currentOrigin[2]; // cap to prevent dramatic height shifts if ( fabs( dif ) > 8 ) @@ -153,7 +153,7 @@ void ImperialProbe_MaintainHeight( void ) ucmd.upmove = -32; } else - { + { if ( NPC->client->ps.velocity[2] ) { NPC->client->ps.velocity[2] *= VELOCITY_DECAY; @@ -293,7 +293,7 @@ void ImperialProbe_FireBlaster(void) mdxaBone_t boltMatrix; //FIXME: use {0, NPC->client->ps.legsYaw, 0} - gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, + gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, NPC->genericBolt1, &boltMatrix, NPC->currentAngles, NPC->currentOrigin, (cg.time?cg.time:level.time), NULL, NPC->s.modelScale ); @@ -327,7 +327,7 @@ void ImperialProbe_FireBlaster(void) { missile->damage = 5; } - else + else { missile->damage = 10; } @@ -416,7 +416,7 @@ void ImperialProbe_AttackDecision( void ) NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_RUN1, SETANIM_FLAG_NORMAL); // Rate our distance to the target, and our visibilty - float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); // distance_e distRate = ( distance > MIN_MELEE_RANGE_SQR ) ? DIST_LONG : DIST_MELEE; qboolean visible = NPC_ClearLOS( NPC->enemy ); qboolean advance = (qboolean)(distance > MIN_DISTANCE_SQR); @@ -443,10 +443,10 @@ void ImperialProbe_AttackDecision( void ) NPC_BSDroid_Pain ------------------------- */ -void NPC_Probe_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_Probe_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { float pain_chance; - + VectorCopy( self->NPC->lastPathAngles, self->s.angles ); if ( self->health < 30 || mod == MOD_DEMP2 || mod == MOD_DEMP2_ALT ) // demp2 always messes them up real good @@ -472,7 +472,7 @@ void NPC_Probe_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve self->NPC->stats.moveType = MT_RUNJUMP; self->client->ps.gravity = g_gravity->value*.1; } - + if ( (mod == MOD_DEMP2 || mod == MOD_DEMP2_ALT) && other ) { vec3_t dir; @@ -490,7 +490,7 @@ void NPC_Probe_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve self->client->ps.powerups[PW_SHOCKED] = level.time + 3000; self->NPC->localState = LSTATE_DROP; - } + } } else { @@ -499,7 +499,7 @@ void NPC_Probe_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve if ( Q_flrand(0.0f, 1.0f) < pain_chance ) // Spin around in pain? { NPC_SetAnim( self, SETANIM_BOTH, BOTH_PAIN1, SETANIM_FLAG_OVERRIDE); - } + } } NPC_Pain( self, inflictor, other, point, damage, mod); @@ -582,8 +582,8 @@ void ImperialProbe_Wait(void) if ( trace.fraction != 1.0f ) { - G_Damage(NPC, NPC->enemy, NPC->enemy, NULL, NULL, 2000, 0,MOD_UNKNOWN); - } + G_Damage(NPC, NPC->enemy, NPC->enemy, NULL, NULL, 2000, 0,MOD_UNKNOWN); + } } NPC_UpdateAngles( qtrue, qtrue ); diff --git a/codeJK2/game/AI_Interrogator.cpp b/codeJK2/game/AI_Interrogator.cpp index c81111f08a..550d6796bb 100644 --- a/codeJK2/game/AI_Interrogator.cpp +++ b/codeJK2/game/AI_Interrogator.cpp @@ -93,18 +93,18 @@ void Interrogator_PartsMove(void) if ((NPC->pos1[1] < 60) || (NPC->pos1[1] > 300)) { - NPC->pos1[1]+=Q_irand( -20, 20 ); // Pitch + NPC->pos1[1]+=Q_irand( -20, 20 ); // Pitch } else if (NPC->pos1[1] > 180) { - NPC->pos1[1]=Q_irand( 300, 360 ); // Pitch + NPC->pos1[1]=Q_irand( 300, 360 ); // Pitch } - else + else { - NPC->pos1[1]=Q_irand( 0, 60 ); // Pitch + NPC->pos1[1]=Q_irand( 0, 60 ); // Pitch } - gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone1, NPC->pos1, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, 0 ); + gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone1, NPC->pos1, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, 0 ); TIMER_Set( NPC, "syringeDelay", Q_irand( 100, 1000 ) ); } @@ -133,13 +133,13 @@ void Interrogator_PartsMove(void) } NPC->pos2[0] = AngleNormalize360( NPC->pos2[0]); - gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone2, NPC->pos2, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, 0 ); + gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone2, NPC->pos2, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, 0 ); } // Claw NPC->pos3[1] += Q_irand( 10, 30 ); NPC->pos3[1] = AngleNormalize360( NPC->pos3[1]); - gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone3, NPC->pos3, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, 0 ); + gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone3, NPC->pos3, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, 0 ); } @@ -152,7 +152,7 @@ Interrogator_MaintainHeight ------------------------- */ void Interrogator_MaintainHeight( void ) -{ +{ float dif; // vec3_t endPos; // trace_t trace; @@ -165,7 +165,7 @@ void Interrogator_MaintainHeight( void ) if ( NPC->enemy ) { // Find the height difference - dif = (NPC->enemy->currentOrigin[2] + NPC->enemy->maxs[2]) - NPC->currentOrigin[2]; + dif = (NPC->enemy->currentOrigin[2] + NPC->enemy->maxs[2]) - NPC->currentOrigin[2]; // cap to prevent dramatic height shifts if ( fabs( dif ) > 2 ) @@ -277,7 +277,7 @@ void Interrogator_Strafe( void ) if ( NPC->enemy ) { // Find the height difference - dif = (NPC->enemy->currentOrigin[2] + 32) - NPC->currentOrigin[2]; + dif = (NPC->enemy->currentOrigin[2] + 32) - NPC->currentOrigin[2]; // cap to prevent dramatic height shifts if ( fabs( dif ) > 8 ) @@ -289,7 +289,7 @@ void Interrogator_Strafe( void ) } - // Set the strafe start time + // Set the strafe start time NPC->fx_time = level.time; NPCInfo->standTime = level.time + 3000 + Q_flrand(0.0f, 1.0f) * 500; } @@ -415,7 +415,7 @@ void Interrogator_Attack( void ) } // Rate our distance to the target, and our visibilty - float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); qboolean visible = NPC_ClearLOS( NPC->enemy ); qboolean advance = (qboolean)(distance > MIN_DISTANCE*MIN_DISTANCE ); diff --git a/codeJK2/game/AI_Mark1.cpp b/codeJK2/game/AI_Mark1.cpp index 7c9bdaddb9..ff25e8dd9c 100644 --- a/codeJK2/game/AI_Mark1.cpp +++ b/codeJK2/game/AI_Mark1.cpp @@ -105,7 +105,7 @@ void NPC_Mark1_Part_Explode( gentity_t *self, int bolt ) mdxaBone_t boltMatrix; vec3_t org, dir; - gi.G2API_GetBoltMatrix( self->ghoul2, self->playerModel, + gi.G2API_GetBoltMatrix( self->ghoul2, self->playerModel, bolt, &boltMatrix, self->currentAngles, self->currentOrigin, (cg.time?cg.time:level.time), NULL, self->s.modelScale ); @@ -145,7 +145,7 @@ void Mark1Dead_FireRocket (void) int damage = 50; - gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, + gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, NPC->genericBolt5, &boltMatrix, NPC->currentAngles, NPC->currentOrigin, (cg.time?cg.time:level.time), NULL, NPC->s.modelScale ); @@ -190,9 +190,9 @@ void Mark1Dead_FireBlaster (void) mdxaBone_t boltMatrix; int bolt; - bolt = NPC->genericBolt1; + bolt = NPC->genericBolt1; - gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, + gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, bolt, &boltMatrix, NPC->currentAngles, NPC->currentOrigin, (cg.time?cg.time:level.time), NULL, NPC->s.modelScale ); @@ -228,7 +228,7 @@ void Mark1_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int // Is he dead already? anim = self->client->ps.legsAnim; - if (((anim==BOTH_DEATH1) || (anim==BOTH_DEATH2)) && (self->client->ps.torsoAnimTimer==0)) + if (((anim==BOTH_DEATH1) || (anim==BOTH_DEATH2)) && (self->client->ps.torsoAnimTimer==0)) { // This is because self->health keeps getting zeroed out. HL_NONE acts as health in this case. self->locationDamage[HL_NONE] += damage; if (self->locationDamage[HL_NONE] > 50) @@ -332,10 +332,10 @@ NPC_Mark1_Pain - look at what was hit and see if it should be removed from the model. ------------------------- */ -void NPC_Mark1_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_Mark1_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { int newBolt,i,chance; - + NPC_Pain( self, inflictor, other, point, damage, mod ); G_Sound( self, G_SoundIndex("sound/chars/mark1/misc/mark1_pain")); @@ -344,7 +344,7 @@ void NPC_Mark1_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve if (hitLoc==HL_CHEST) { chance = Q_irand( 1, 4); - + if ((chance == 1) && (damage > 5)) { NPC_SetAnim( self, SETANIM_BOTH, BOTH_PAIN1, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD ); @@ -368,7 +368,7 @@ void NPC_Mark1_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve else if ((hitLoc==HL_ARM_RT) && (self->locationDamage[HL_ARM_RT] > RIGHT_ARM_HEALTH)) // Blow it up? { if (self->locationDamage[hitLoc] >= RIGHT_ARM_HEALTH) - { + { newBolt = gi.G2API_AddBolt( &self->ghoul2[self->playerModel], "*flash4" ); if ( newBolt != -1 ) { @@ -387,7 +387,7 @@ void NPC_Mark1_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve if ((hitLoc==HL_GENERIC1+i) && (self->locationDamage[HL_GENERIC1+i] > AMMO_POD_HEALTH)) // Blow it up? { if (self->locationDamage[hitLoc] >= AMMO_POD_HEALTH) - { + { newBolt = gi.G2API_AddBolt( &self->ghoul2[self->playerModel], va("*torso_tube%d",(i+1)) ); if ( newBolt != -1 ) { @@ -445,28 +445,28 @@ void Mark1_FireBlaster(void) int bolt; // Which muzzle to fire from? - if ((NPCInfo->localState <= LSTATE_FIRED0) || (NPCInfo->localState == LSTATE_FIRED4)) + if ((NPCInfo->localState <= LSTATE_FIRED0) || (NPCInfo->localState == LSTATE_FIRED4)) { NPCInfo->localState = LSTATE_FIRED1; - bolt = NPC->genericBolt1; + bolt = NPC->genericBolt1; } else if (NPCInfo->localState == LSTATE_FIRED1) { NPCInfo->localState = LSTATE_FIRED2; - bolt = NPC->genericBolt2; + bolt = NPC->genericBolt2; } else if (NPCInfo->localState == LSTATE_FIRED2) { NPCInfo->localState = LSTATE_FIRED3; - bolt = NPC->genericBolt3; + bolt = NPC->genericBolt3; } else { NPCInfo->localState = LSTATE_FIRED4; - bolt = NPC->genericBolt4; + bolt = NPC->genericBolt4; } - gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, + gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, bolt, &boltMatrix, NPC->currentAngles, NPC->currentOrigin, (cg.time?cg.time:level.time), NULL, NPC->s.modelScale ); @@ -513,7 +513,7 @@ void Mark1_BlasterAttack(qboolean advance ) if ( TIMER_Done( NPC, "attackDelay" ) ) // Attack? { chance = Q_irand( 1, 5); - + NPCInfo->burstCount++; if (NPCInfo->burstCount<3) // Too few shots this burst? @@ -574,7 +574,7 @@ void Mark1_FireRocket(void) int damage = 50; - gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, + gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, NPC->genericBolt5, &boltMatrix, NPC->currentAngles, NPC->currentOrigin, (cg.time?cg.time:level.time), NULL, NPC->s.modelScale ); @@ -656,7 +656,7 @@ void Mark1_AttackDecision( void ) } // Rate our distance to the target and visibility - float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); distance_e distRate = ( distance > MIN_MELEE_RANGE_SQR ) ? DIST_LONG : DIST_MELEE; qboolean visible = NPC_ClearLOS( NPC->enemy ); qboolean advance = (qboolean)(distance > MIN_DISTANCE_SQR); @@ -686,7 +686,7 @@ void Mark1_AttackDecision( void ) distRate = DIST_MELEE; } else // It should never get here, but just in case - { + { NPC->health = 0; NPC->client->ps.stats[STAT_HEALTH] = 0; GEntity_DieFunc(NPC, NPC, NPC, 100, MOD_UNKNOWN); diff --git a/codeJK2/game/AI_Mark2.cpp b/codeJK2/game/AI_Mark2.cpp index 8d37ddcccc..9ae2e0b37a 100644 --- a/codeJK2/game/AI_Mark2.cpp +++ b/codeJK2/game/AI_Mark2.cpp @@ -77,7 +77,7 @@ void NPC_Mark2_Part_Explode( gentity_t *self, int bolt ) mdxaBone_t boltMatrix; vec3_t org, dir; - gi.G2API_GetBoltMatrix( self->ghoul2, self->playerModel, + gi.G2API_GetBoltMatrix( self->ghoul2, self->playerModel, bolt, &boltMatrix, self->currentAngles, self->currentOrigin, (cg.time?cg.time:level.time), NULL, self->s.modelScale ); @@ -99,10 +99,10 @@ NPC_Mark2_Pain - look at what was hit and see if it should be removed from the model. ------------------------- */ -void NPC_Mark2_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_Mark2_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { int newBolt,i; - + NPC_Pain( self, inflictor, other, point, damage, mod ); for (i=0;i<3;i++) @@ -110,7 +110,7 @@ void NPC_Mark2_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve if ((hitLoc==HL_GENERIC1+i) && (self->locationDamage[HL_GENERIC1+i] > AMMO_POD_HEALTH)) // Blow it up? { if (self->locationDamage[hitLoc] >= AMMO_POD_HEALTH) - { + { newBolt = gi.G2API_AddBolt( &self->ghoul2[self->playerModel], va("torso_canister%d",(i+1)) ); if ( newBolt != -1 ) { @@ -162,7 +162,7 @@ void Mark2_FireBlaster(qboolean advance) gentity_t *missile; mdxaBone_t boltMatrix; - gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, + gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, NPC->genericBolt1, &boltMatrix, NPC->currentAngles, NPC->currentOrigin, (cg.time?cg.time:level.time), NULL, NPC->s.modelScale ); @@ -232,7 +232,7 @@ void Mark2_AttackDecision( void ) { NPC_FaceEnemy( qtrue ); - float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); qboolean visible = NPC_ClearLOS( NPC->enemy ); qboolean advance = (qboolean)(distance > MIN_DISTANCE_SQR); @@ -241,7 +241,7 @@ void Mark2_AttackDecision( void ) { NPC->flags &= ~FL_SHIELDED; NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_RUN1START, SETANIM_FLAG_HOLD|SETANIM_FLAG_OVERRIDE ); - if ((NPC->client->ps.legsAnimTimer==0) && + if ((NPC->client->ps.legsAnimTimer==0) && NPC->client->ps.torsoAnim == BOTH_RUN1START ) { NPCInfo->localState = LSTATE_NONE; // He's up again. diff --git a/codeJK2/game/AI_MineMonster.cpp b/codeJK2/game/AI_MineMonster.cpp index eac149a7cb..2ef79be180 100644 --- a/codeJK2/game/AI_MineMonster.cpp +++ b/codeJK2/game/AI_MineMonster.cpp @@ -20,7 +20,7 @@ along with this program; if not, see . =========================================================================== */ #include "g_headers.h" - + #include "b_local.h" extern void G_SoundOnEnt( gentity_t *ent, soundChannel_t channel, const char *soundPath ); @@ -103,7 +103,7 @@ void MineMonster_Patrol( void ) return; } } - + /* ------------------------- MineMonster_Move @@ -153,7 +153,7 @@ void MineMonster_Attack( void ) if ( !TIMER_Exists( NPC, "attacking" )) { // usually try and play a jump attack if the player somehow got above them....or just really rarely - if ( NPC->enemy && ((NPC->enemy->currentOrigin[2] - NPC->currentOrigin[2] > 10 && Q_flrand(0.0f, 1.0f) > 0.1f ) + if ( NPC->enemy && ((NPC->enemy->currentOrigin[2] - NPC->currentOrigin[2] > 10 && Q_flrand(0.0f, 1.0f) > 0.1f ) || Q_flrand(0.0f, 1.0f) > 0.8f )) { // Going to do ATTACK4 @@ -224,7 +224,7 @@ void MineMonster_Combat( void ) // Sometimes I have problems with facing the enemy I'm attacking, so force the issue so I don't look dumb NPC_FaceEnemy( qtrue ); - float distance = DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); qboolean advance = (qboolean)( distance > MIN_DISTANCE_SQR ? qtrue : qfalse ); @@ -250,7 +250,7 @@ void MineMonster_Combat( void ) NPC_MineMonster_Pain ------------------------- */ -void NPC_MineMonster_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_MineMonster_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { G_AddEvent( self, EV_PAIN, floor((float)self->health/self->max_health*100.0f) ); diff --git a/codeJK2/game/AI_Remote.cpp b/codeJK2/game/AI_Remote.cpp index 520ffdb65e..09e388c325 100644 --- a/codeJK2/game/AI_Remote.cpp +++ b/codeJK2/game/AI_Remote.cpp @@ -50,7 +50,7 @@ void NPC_Remote_Precache(void) NPC_Remote_Pain ------------------------- */ -void NPC_Remote_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_Remote_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { SaveNPCGlobals(); SetNPCGlobals( self ); @@ -66,7 +66,7 @@ Remote_MaintainHeight ------------------------- */ void Remote_MaintainHeight( void ) -{ +{ float dif; // Update our angles regardless @@ -89,7 +89,7 @@ void Remote_MaintainHeight( void ) TIMER_Set( NPC,"heightChange",Q_irand( 1000, 3000 )); // Find the height difference - dif = (NPC->enemy->currentOrigin[2] + Q_irand( 0, NPC->enemy->maxs[2]+8 )) - NPC->currentOrigin[2]; + dif = (NPC->enemy->currentOrigin[2] + Q_irand( 0, NPC->enemy->maxs[2]+8 )) - NPC->currentOrigin[2]; // cap to prevent dramatic height shifts if ( fabs( dif ) > 2 ) @@ -259,7 +259,7 @@ void Remote_Fire (void) CalcEntitySpot( NPC->enemy, SPOT_HEAD, enemy_org1 ); VectorCopy( NPC->currentOrigin, muzzle1 ); - + VectorSubtract (enemy_org1, muzzle1, delta1); vectoangles ( delta1, angleToEnemy1 ); @@ -315,7 +315,7 @@ void Remote_Attack( void ) if ( TIMER_Done(NPC,"spin") ) { TIMER_Set( NPC, "spin", Q_irand( 250, 1500 ) ); - NPCInfo->desiredYaw += Q_irand( -200, 200 ); + NPCInfo->desiredYaw += Q_irand( -200, 200 ); } // Always keep a good height off the ground Remote_MaintainHeight(); @@ -328,7 +328,7 @@ void Remote_Attack( void ) } // Rate our distance to the target, and our visibilty - float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); // distance_e distRate = ( distance > MIN_MELEE_RANGE_SQR ) ? DIST_LONG : DIST_MELEE; qboolean visible = NPC_ClearLOS( NPC->enemy ); float idealDist = MIN_DISTANCE_SQR+(MIN_DISTANCE_SQR*Q_flrand( 0, 1 )); diff --git a/codeJK2/game/AI_Seeker.cpp b/codeJK2/game/AI_Seeker.cpp index e347a64234..69d20abda6 100644 --- a/codeJK2/game/AI_Seeker.cpp +++ b/codeJK2/game/AI_Seeker.cpp @@ -54,7 +54,7 @@ void NPC_Seeker_Precache(void) } //------------------------------------ -void NPC_Seeker_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_Seeker_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { if ( !(self->svFlags & SVF_CUSTOM_GRAVITY )) {//void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, vec3_t dir, vec3_t point, int damage, int dflags, int mod, int hitLoc=HL_NONE ); @@ -70,7 +70,7 @@ void NPC_Seeker_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, v //------------------------------------ void Seeker_MaintainHeight( void ) -{ +{ float dif; // Update our angles regardless @@ -84,7 +84,7 @@ void Seeker_MaintainHeight( void ) TIMER_Set( NPC,"heightChange",Q_irand( 1000, 3000 )); // Find the height difference - dif = (NPC->enemy->currentOrigin[2] + Q_flrand( NPC->enemy->maxs[2]/2, NPC->enemy->maxs[2]+8 )) - NPC->currentOrigin[2]; + dif = (NPC->enemy->currentOrigin[2] + Q_flrand( NPC->enemy->maxs[2]/2, NPC->enemy->maxs[2]+8 )) - NPC->currentOrigin[2]; // cap to prevent dramatic height shifts if ( fabs( dif ) > 2 ) @@ -320,7 +320,7 @@ void Seeker_Ranged( qboolean visible, qboolean advance ) { Seeker_Hunt( visible, advance ); } -} +} //------------------------------------ void Seeker_Attack( void ) @@ -329,7 +329,7 @@ void Seeker_Attack( void ) Seeker_MaintainHeight(); // Rate our distance to the target, and our visibilty - float distance = DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); qboolean visible = NPC_ClearLOS( NPC->enemy ); qboolean advance = (qboolean)(distance > MIN_DISTANCE_SQR); @@ -359,7 +359,7 @@ void Seeker_FindEnemy( void ) numFound = gi.EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); - for ( int i = 0 ; i < numFound ; i++ ) + for ( int i = 0 ; i < numFound ; i++ ) { ent = entityList[i]; @@ -404,7 +404,7 @@ void Seeker_FollowPlayer( void ) float dis = DistanceHorizontalSquared( NPC->currentOrigin, g_entities[0].currentOrigin ); vec3_t pt, dir; - + if ( dis < MIN_DISTANCE_SQR ) { // generally circle the player closely till we take an enemy..this is our target point diff --git a/codeJK2/game/AI_Sentry.cpp b/codeJK2/game/AI_Sentry.cpp index 6d56d5163f..b96ebc9df7 100644 --- a/codeJK2/game/AI_Sentry.cpp +++ b/codeJK2/game/AI_Sentry.cpp @@ -96,8 +96,8 @@ void sentry_use( gentity_t *self, gentity_t *other, gentity_t *activator) NPC_Sentry_Pain ------------------------- */ -void NPC_Sentry_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) -{ +void NPC_Sentry_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +{ NPC_Pain( self, inflictor, other, point, damage, mod ); if ( mod == MOD_DEMP2 || mod == MOD_DEMP2_ALT ) @@ -106,7 +106,7 @@ void NPC_Sentry_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, v TIMER_Set( self, "attackDelay", Q_irand( 9000, 12000) ); self->flags |= FL_SHIELDED; NPC_SetAnim( self, SETANIM_BOTH, BOTH_FLY_SHIELDED, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD ); - G_SoundOnEnt( self, CHAN_AUTO, "sound/chars/sentry/misc/sentry_pain" ); + G_SoundOnEnt( self, CHAN_AUTO, "sound/chars/sentry/misc/sentry_pain" ); self->NPC->localState = LSTATE_ACTIVE; } @@ -154,7 +154,7 @@ void Sentry_Fire (void) { NPCInfo->localState = LSTATE_POWERING_UP; - G_SoundOnEnt( NPC, CHAN_AUTO, "sound/chars/sentry/misc/sentry_shield_open" ); + G_SoundOnEnt( NPC, CHAN_AUTO, "sound/chars/sentry/misc/sentry_shield_open" ); NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_POWERUP1, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD ); TIMER_Set( NPC, "powerup", 250 ); return; @@ -171,17 +171,17 @@ void Sentry_Fire (void) switch( which ) { case 0: - bolt = NPC->genericBolt1; + bolt = NPC->genericBolt1; break; case 1: - bolt = NPC->genericBolt2; + bolt = NPC->genericBolt2; break; case 2: default: - bolt = NPC->genericBolt3; + bolt = NPC->genericBolt3; } - gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, + gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, bolt, &boltMatrix, NPC->currentAngles, NPC->currentOrigin, (cg.time?cg.time:level.time), NULL, NPC->s.modelScale ); @@ -225,7 +225,7 @@ Sentry_MaintainHeight ------------------------- */ void Sentry_MaintainHeight( void ) -{ +{ float dif; NPC->s.loopSound = G_SoundIndex( "sound/chars/sentry/misc/sentry_hover_1_lp" ); @@ -237,7 +237,7 @@ void Sentry_MaintainHeight( void ) if ( NPC->enemy ) { // Find the height difference - dif = (NPC->enemy->currentOrigin[2]+NPC->enemy->maxs[2]) - NPC->currentOrigin[2]; + dif = (NPC->enemy->currentOrigin[2]+NPC->enemy->maxs[2]) - NPC->currentOrigin[2]; // cap to prevent dramatic height shifts if ( fabs( dif ) > 8 ) @@ -503,7 +503,7 @@ void Sentry_AttackDecision( void ) } // Rate our distance to the target and visibilty - float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); qboolean visible = NPC_ClearLOS( NPC->enemy ); qboolean advance = (qboolean)(distance > MIN_DISTANCE_SQR); diff --git a/codeJK2/game/AI_Sniper.cpp b/codeJK2/game/AI_Sniper.cpp index c76231e067..361ef28ea9 100644 --- a/codeJK2/game/AI_Sniper.cpp +++ b/codeJK2/game/AI_Sniper.cpp @@ -109,7 +109,7 @@ NPC_ST_Pain ------------------------- */ -void NPC_Sniper_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod ) +void NPC_Sniper_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod ) { self->NPC->localState = LSTATE_UNDERFIRE; @@ -134,7 +134,7 @@ static void Sniper_HoldPosition( void ) { NPC_FreeCombatPoint( NPCInfo->combatPoint, qtrue ); NPCInfo->goalEntity = NULL; - + /*if ( TIMER_Done( NPC, "stand" ) ) {//FIXME: what if can't shoot from this pos? TIMER_Set( NPC, "duck", Q_irand( 2000, 4000 ) ); @@ -154,13 +154,13 @@ static qboolean Sniper_Move( void ) qboolean moved = NPC_MoveToGoal( qtrue ); navInfo_t info; - + //Get the move info NAV_GetLastMove( info ); //FIXME: if we bump into another one of our guys and can't get around him, just stop! //If we hit our target, then stop and fire! - if ( info.flags & NIF_COLLISION ) + if ( info.flags & NIF_COLLISION ) { if ( info.blocker == NPC->enemy ) { @@ -241,8 +241,8 @@ void NPC_BSSniper_Patrol( void ) NPCInfo->lastAlertID = level.alertEvents[alertEvent].ID; if ( level.alertEvents[alertEvent].level == AEL_DISCOVERED ) { - if ( level.alertEvents[alertEvent].owner && - level.alertEvents[alertEvent].owner->client && + if ( level.alertEvents[alertEvent].owner && + level.alertEvents[alertEvent].owner->client && level.alertEvents[alertEvent].owner->health >= 0 && level.alertEvents[alertEvent].owner->client->playerTeam == NPC->client->enemyTeam ) {//an enemy @@ -270,15 +270,15 @@ void NPC_BSSniper_Patrol( void ) //NOTE: stops walking or doing anything else below vec3_t dir, angles; float o_yaw, o_pitch; - + VectorSubtract( NPCInfo->investigateGoal, NPC->client->renderInfo.eyePoint, dir ); vectoangles( dir, angles ); - + o_yaw = NPCInfo->desiredYaw; o_pitch = NPCInfo->desiredPitch; NPCInfo->desiredYaw = angles[YAW]; NPCInfo->desiredPitch = angles[PITCH]; - + NPC_UpdateAngles( qtrue, qtrue ); NPCInfo->desiredYaw = o_yaw; @@ -365,7 +365,7 @@ static void Sniper_CheckMoveState( void ) if ( ( NPCInfo->goalEntity != NPC->enemy ) && ( NPCInfo->goalEntity != NULL ) ) { //Did we make it? - if ( NAV_HitNavGoal( NPC->currentOrigin, NPC->mins, NPC->maxs, NPCInfo->goalEntity->currentOrigin, 16, FlyingCreature( NPC ) ) || + if ( NAV_HitNavGoal( NPC->currentOrigin, NPC->mins, NPC->maxs, NPCInfo->goalEntity->currentOrigin, 16, FlyingCreature( NPC ) ) || ( NPCInfo->squadState == SQUAD_SCOUT && enemyLOS && enemyDist <= 10000 ) ) { //int newSquadState = SQUAD_STAND_AND_SHOOT; @@ -515,7 +515,7 @@ qboolean Sniper_EvaluateShot( int hit ) } gentity_t *hitEnt = &g_entities[hit]; - if ( hit == NPC->enemy->s.number + if ( hit == NPC->enemy->s.number || ( hitEnt && hitEnt->client && hitEnt->client->playerTeam == NPC->client->enemyTeam ) || ( hitEnt && hitEnt->takedamage && ((hitEnt->svFlags&SVF_GLASS_BRUSH)||hitEnt->health < 40||NPC->s.weapon == WP_EMPLACED_GUN) ) || ( hitEnt && (hitEnt->svFlags&SVF_GLASS_BRUSH)) ) @@ -649,7 +649,7 @@ NPC_BSSniper_Attack void Sniper_StartHide( void ) { int duckTime = Q_irand( 2000, 5000 ); - + TIMER_Set( NPC, "duck", duckTime ); TIMER_Set( NPC, "watch", 500 ); TIMER_Set( NPC, "attackDelay", duckTime + Q_irand( 500, 2000 ) ); @@ -806,9 +806,9 @@ void NPC_BSSniper_Attack( void ) TIMER_Set( NPC, "duck", -1 ); } - if ( TIMER_Done( NPC, "duck" ) - && TIMER_Done( NPC, "watch" ) - && (TIMER_Get( NPC, "attackDelay" )-level.time) > 1000 + if ( TIMER_Done( NPC, "duck" ) + && TIMER_Done( NPC, "watch" ) + && (TIMER_Get( NPC, "attackDelay" )-level.time) > 1000 && NPC->attackDebounceTime < level.time ) { if ( enemyLOS && (NPCInfo->scriptFlags&SCF_ALT_FIRE) ) diff --git a/codeJK2/game/AI_Utils.cpp b/codeJK2/game/AI_Utils.cpp index 0ff327ad92..62e0c45c09 100644 --- a/codeJK2/game/AI_Utils.cpp +++ b/codeJK2/game/AI_Utils.cpp @@ -20,7 +20,7 @@ along with this program; if not, see . =========================================================================== */ -// These utilities are meant for strictly non-player, non-team NPCs. +// These utilities are meant for strictly non-player, non-team NPCs. // These functions are in their own file because they are only intended // for use with NPCs who's logic has been overriden from the original // AI code, and who's code resides in files with the AI_ prefix. @@ -246,9 +246,9 @@ qboolean AI_TryJoinPreviousGroup( gentity_t *self ) int i; for ( i = 0; i < MAX_FRAME_GROUPS; i++ ) { - if ( level.groups[i].numGroup - && level.groups[i].numGroup < (MAX_GROUP_MEMBERS - 1) - //&& level.groups[i].enemy != NULL + if ( level.groups[i].numGroup + && level.groups[i].numGroup < (MAX_GROUP_MEMBERS - 1) + //&& level.groups[i].enemy != NULL && level.groups[i].enemy == self->enemy ) {//has members, not full and has my enemy if ( AI_ValidateGroupMember( &level.groups[i], self ) ) @@ -272,7 +272,7 @@ qboolean AI_GetNextEmptyGroup( gentity_t *self ) {//try to just put us in one that already exists return qfalse; } - + //okay, make a whole new one, then for ( int i = 0; i < MAX_FRAME_GROUPS; i++ ) { @@ -367,7 +367,7 @@ qboolean AI_ValidateGroupMember( AIGroupInfo_t *group, gentity_t *member ) member->client->ps.weapon == WP_EMPLACED_GUN || member->client->ps.weapon == WP_BOT_LASER || // Probe droid - Laser blast member->client->ps.weapon == WP_MELEE || - member->client->ps.weapon == WP_TURRET || // turret guns + member->client->ps.weapon == WP_TURRET || // turret guns member->client->ps.weapon == WP_ATST_MAIN || member->client->ps.weapon == WP_ATST_SIDE || member->client->ps.weapon == WP_TIE_FIGHTER ) @@ -489,7 +489,7 @@ void AI_GetGroup( gentity_t *self ) {//FIXME: keep track of those who aren't angry yet and see if we should wake them after we assemble the core group continue; } - + //store it AI_InsertGroupMember( self->NPC->group, member ); @@ -506,7 +506,7 @@ void AI_GetGroup( gentity_t *self ) for ( i = 0; i < numWaiters; i++ ) { waiter = &g_entities[waiters[i]]; - + for ( j = 0; j < self->NPC->group->numGroup; j++ ) { member = &g_entities[self->NPC->group->member[j]; @@ -712,7 +712,7 @@ qboolean AI_RefreshGroup( AIGroupInfo_t *group ) int i;//, j; //see if we should merge with another group - for ( i = 0; i < MAX_FRAME_GROUPS; i++ ) + for ( i = 0; i < MAX_FRAME_GROUPS; i++ ) { if ( &level.groups[i] == group ) { @@ -934,9 +934,9 @@ void AI_UpdateGroups( void ) return; } //Clear all Groups - for ( int i = 0; i < MAX_FRAME_GROUPS; i++ ) + for ( int i = 0; i < MAX_FRAME_GROUPS; i++ ) { - if ( !level.groups[i].numGroup || AI_RefreshGroup( &level.groups[i] ) == qfalse )//level.groups[i].enemy == NULL || + if ( !level.groups[i].numGroup || AI_RefreshGroup( &level.groups[i] ) == qfalse )//level.groups[i].enemy == NULL || { memset( &level.groups[i], 0, sizeof( level.groups[i] ) ); } @@ -958,7 +958,7 @@ qboolean AI_GroupContainsEntNum( AIGroupInfo_t *group, int entNum ) } return qfalse; } -//Overload +//Overload /* void AI_GetGroup( AIGroupInfo_t &group, gentity_t *ent, int radius ) diff --git a/codeJK2/game/CMakeLists.txt b/codeJK2/game/CMakeLists.txt index 00f898e0d5..2790dc81fe 100644 --- a/codeJK2/game/CMakeLists.txt +++ b/codeJK2/game/CMakeLists.txt @@ -1,17 +1,17 @@ #============================================================================ # Copyright (C) 2013 - 2018, OpenJK contributors -# +# # This file is part of the OpenJK source code. -# +# # OpenJK is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, see . #============================================================================ @@ -127,7 +127,7 @@ set(JK2SPGameGameFiles "${JK2SPDir}/game/wp_stun_baton.cpp" "${JK2SPDir}/game/wp_thermal.cpp" "${JK2SPDir}/game/wp_trip_mine.cpp" - "${JK2SPDir}/game/Q3_Interface.h" + "${JK2SPDir}/game/Q3_Interface.h" "${JK2SPDir}/game/Q3_Registers.h" "${JK2SPDir}/game/ai.h" "${JK2SPDir}/game/anims.h" diff --git a/codeJK2/game/G_Timer.cpp b/codeJK2/game/G_Timer.cpp index b074b6a35c..068db56a8d 100644 --- a/codeJK2/game/G_Timer.cpp +++ b/codeJK2/game/G_Timer.cpp @@ -49,9 +49,9 @@ static int TIMER_GetCount(int num) count++; p = p->next; } - + return count; -} +} /* @@ -184,7 +184,7 @@ void TIMER_Save( void ) saved_game.write_chunk( INT_ID('T', 'I', 'M', 'E'), numTimers); - + gtimer_t *p = g_timers[j]; assert ((numTimers && p) || (!numTimers && !p)); @@ -253,7 +253,7 @@ void TIMER_Load( void ) saved_game.read_chunk( INT_ID('T', 'S', 'L', 'N'), length); - + if ( length >= 1024 ) { assert( 0 ); continue; @@ -325,9 +325,9 @@ gtimer_t *TIMER_GetExisting(int num, const char *identifier) p = p->next; } - + return NULL; -} +} @@ -389,8 +389,8 @@ qboolean TIMER_Done( gentity_t *ent, const char *identifier ) ------------------------- TIMER_Done2 -Returns false if timer has been -started but is not done...or if +Returns false if timer has been +started but is not done...or if timer was never started ------------------------- */ diff --git a/codeJK2/game/NPC_combat.cpp b/codeJK2/game/NPC_combat.cpp index dbf7d67ec8..a0b3b23c85 100644 --- a/codeJK2/game/NPC_combat.cpp +++ b/codeJK2/game/NPC_combat.cpp @@ -85,7 +85,7 @@ void G_AngerAlert( gentity_t *self ) return; } //FIXME: hmm.... with all the other new alerts now, is this still neccesary or even a good idea...? - G_AlertTeam( self, self->enemy, ANGER_ALERT_RADIUS, ANGER_ALERT_SOUND_RADIUS ); + G_AlertTeam( self, self->enemy, ANGER_ALERT_RADIUS, ANGER_ALERT_SOUND_RADIUS ); } /* @@ -155,7 +155,7 @@ void G_AttackDelay( gentity_t *self, gentity_t *enemy ) VectorNormalize( dir ); AngleVectors( self->client->renderInfo.eyeAngles, fwd, NULL, NULL ); //dir[2] = fwd[2] = 0;//ignore z diff? - + attDelay = (4-g_spskill->integer)*500;//initial: from 1000ms delay on hard to 2000ms delay on easy if ( self->client->playerTeam == TEAM_PLAYER ) {//invert @@ -191,14 +191,14 @@ void G_AttackDelay( gentity_t *self, gentity_t *enemy ) case CLASS_TRANDOSHAN: attDelay -= Q_irand( 500, 1500 ); break; - case CLASS_JAN: - case CLASS_LANDO: + case CLASS_JAN: + case CLASS_LANDO: case CLASS_PRISONER: case CLASS_REBEL: attDelay -= Q_irand( 500, 1500 ); break; - case CLASS_GALAKMECH: - case CLASS_ATST: + case CLASS_GALAKMECH: + case CLASS_ATST: attDelay -= Q_irand( 1000, 2000 ); break; case CLASS_REELO: @@ -210,10 +210,10 @@ void G_AttackDelay( gentity_t *self, gentity_t *enemy ) return; break; case CLASS_INTERROGATOR: - case CLASS_PROBE: - case CLASS_MARK1: - case CLASS_MARK2: - case CLASS_SENTRY: + case CLASS_PROBE: + case CLASS_MARK1: + case CLASS_MARK2: + case CLASS_SENTRY: return; break; case CLASS_REMOTE: @@ -225,12 +225,12 @@ void G_AttackDelay( gentity_t *self, gentity_t *enemy ) case CLASS_RODIAN: case CLASS_WEEQUAY: break; - case CLASS_JEDI: + case CLASS_JEDI: case CLASS_SHADOWTROOPER: case CLASS_TAVION: case CLASS_REBORN: - case CLASS_LUKE: - case CLASS_DESANN: + case CLASS_LUKE: + case CLASS_DESANN: break; */ default: @@ -285,7 +285,7 @@ void G_AttackDelay( gentity_t *self, gentity_t *enemy ) case WP_EMPLACED_GUN: return; break; - case WP_TURRET: // turret guns + case WP_TURRET: // turret guns return; break; case WP_BOT_LASER: // Probe droid - Laser blast @@ -347,7 +347,7 @@ void G_AimSet( gentity_t *self, int aim ); void G_SetEnemy( gentity_t *self, gentity_t *enemy ) { int event = 0; - + //Must be valid if ( enemy == NULL ) return; @@ -379,12 +379,12 @@ void G_SetEnemy( gentity_t *self, gentity_t *enemy ) assert( enemy != self ); } #endif// _DEBUG - + // if ( enemy->client && enemy->client->playerTeam == TEAM_DISGUISE ) // {//unmask the player // enemy->client->playerTeam = TEAM_PLAYER; // } - + if ( self->client && self->NPC && enemy->client && enemy->client->playerTeam == self->client->playerTeam ) {//Probably a damn script! if ( self->NPC->charmedTime > level.time ) @@ -435,15 +435,15 @@ void G_SetEnemy( gentity_t *self, gentity_t *enemy ) event = Q_irand(EV_ANGER1, EV_ANGER3); } } - + if ( event ) {//yell G_AddVoiceEvent( self, event, 2000 ); } } - + if ( self->s.weapon == WP_BLASTER || self->s.weapon == WP_REPEATER || - self->s.weapon == WP_THERMAL || self->s.weapon == WP_BLASTER_PISTOL + self->s.weapon == WP_THERMAL || self->s.weapon == WP_BLASTER_PISTOL || self->s.weapon == WP_BOWCASTER ) {//Hmm, how about sniper and bowcaster? //When first get mad, aim is bad @@ -470,7 +470,7 @@ void G_SetEnemy( gentity_t *self, gentity_t *enemy ) G_AimSet( self, Q_irand( self->NPC->stats.aim - (maxErr*(3-g_spskill->integer)), self->NPC->stats.aim - (minErr*(3-g_spskill->integer)) ) ); } } - + //Alert anyone else in the area if ( Q_stricmp( "desperado", self->NPC_type ) != 0 && Q_stricmp( "paladin", self->NPC_type ) != 0 ) {//special holodeck enemies exception @@ -503,7 +503,7 @@ void G_SetEnemy( gentity_t *self, gentity_t *enemy ) } return; } - + //Otherwise, just picking up another enemy if ( event ) @@ -517,41 +517,41 @@ void G_SetEnemy( gentity_t *self, gentity_t *enemy ) } /* -int ChooseBestWeapon( void ) +int ChooseBestWeapon( void ) { int n; int weapon; // check weapons in the NPC's weapon preference order - for ( n = 0; n < MAX_WEAPONS; n++ ) + for ( n = 0; n < MAX_WEAPONS; n++ ) { weapon = NPCInfo->weaponOrder[n]; - if ( weapon == WP_NONE ) + if ( weapon == WP_NONE ) { break; } - if ( !HaveWeapon( weapon ) ) + if ( !HaveWeapon( weapon ) ) { continue; } - if ( client->ps.ammo[weaponData[weapon].ammoIndex] ) + if ( client->ps.ammo[weaponData[weapon].ammoIndex] ) { return weapon; } } // check weapons serially (mainly in case a weapon is not on the NPC's list) - for ( weapon = 1; weapon < WP_NUM_WEAPONS; weapon++ ) + for ( weapon = 1; weapon < WP_NUM_WEAPONS; weapon++ ) { - if ( !HaveWeapon( weapon ) ) + if ( !HaveWeapon( weapon ) ) { continue; } - if ( client->ps.ammo[weaponData[weapon].ammoIndex] ) + if ( client->ps.ammo[weaponData[weapon].ammoIndex] ) { return weapon; } @@ -561,7 +561,7 @@ int ChooseBestWeapon( void ) } */ -void ChangeWeapon( gentity_t *ent, int newWeapon ) +void ChangeWeapon( gentity_t *ent, int newWeapon ) { if ( !ent || !ent->client || !ent->NPC ) { @@ -574,7 +574,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->attackHold = 0; ent->NPC->currentAmmo = ent->client->ps.ammo[weaponData[newWeapon].ammoIndex]; - switch ( newWeapon ) + switch ( newWeapon ) { case WP_BRYAR_PISTOL://prifle ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON; @@ -588,7 +588,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->burstSpacing = 1000;//attack debounce else if ( g_spskill->integer == 1 ) ent->NPC->burstSpacing = 750;//attack debounce - else + else ent->NPC->burstSpacing = 500;//attack debounce break; @@ -599,7 +599,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->burstSpacing = 600;//attack debounce else if ( g_spskill->integer == 1 ) ent->NPC->burstSpacing = 400;//attack debounce - else + else ent->NPC->burstSpacing = 200;//attack debounce break; @@ -638,7 +638,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->burstSpacing = 1000;//attack debounce else if ( g_spskill->integer == 1 ) ent->NPC->burstSpacing = 750;//attack debounce - else + else ent->NPC->burstSpacing = 500;//attack debounce break; @@ -657,7 +657,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->burstSpacing = 1500;//attack debounce else if ( g_spskill->integer == 1 ) ent->NPC->burstSpacing = 1000;//attack debounce - else + else ent->NPC->burstSpacing = 500;//attack debounce } break; @@ -686,7 +686,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->burstSpacing = 2500;//attack debounce else if ( g_spskill->integer == 1 ) ent->NPC->burstSpacing = 2000;//attack debounce - else + else ent->NPC->burstSpacing = 1500;//attack debounce break; @@ -697,7 +697,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->burstSpacing = 3000;//attack debounce else if ( g_spskill->integer == 1 ) ent->NPC->burstSpacing = 2500;//attack debounce - else + else ent->NPC->burstSpacing = 2000;//attack debounce break; @@ -721,7 +721,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->burstSpacing = 1500;//attack debounce else if ( g_spskill->integer == 1 ) ent->NPC->burstSpacing = 1000;//attack debounce - else + else ent->NPC->burstSpacing = 500;//attack debounce } else @@ -731,7 +731,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->burstSpacing = 1000;//attack debounce else if ( g_spskill->integer == 1 ) ent->NPC->burstSpacing = 750;//attack debounce - else + else ent->NPC->burstSpacing = 500;//attack debounce // ent->NPC->burstSpacing = 1000;//attackdebounce } @@ -750,7 +750,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->burstSpacing = 1000;//attack debounce else if ( g_spskill->integer == 1 ) ent->NPC->burstSpacing = 750;//attack debounce - else + else ent->NPC->burstSpacing = 500;//attack debounce break; @@ -764,7 +764,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) // ent->NPC->burstSpacing = 300;//attack debounce // else if ( g_spskill->integer == 1 ) // ent->NPC->burstSpacing = 200;//attack debounce - // else + // else // ent->NPC->burstSpacing = 100;//attack debounce } else @@ -784,7 +784,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) { ent->NPC->burstSpacing = ent->owner->wait + 200;//attack debounce } - else + else { ent->NPC->burstSpacing = ent->owner->wait;//attack debounce } @@ -800,7 +800,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) { ent->NPC->burstSpacing = 1000;//attack debounce } - else + else { ent->NPC->burstSpacing = 800;//attack debounce } @@ -814,7 +814,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) } } -void NPC_ChangeWeapon( int newWeapon ) +void NPC_ChangeWeapon( int newWeapon ) { qboolean changing = qfalse; if ( newWeapon != NPC->client->ps.weapon ) @@ -843,13 +843,13 @@ void NPC_ApplyWeaponFireDelay(void) How long, if at all, in msec the actual fire should delay from the time the attack was started */ void NPC_ApplyWeaponFireDelay(void) -{ +{ if ( NPC->attackDebounceTime > level.time ) {//Just fired, if attacking again, must be a burst fire, so don't add delay //NOTE: Borg AI uses attackDebounceTime "incorrectly", so this will always return for them! return; } - + switch(client->ps.weapon) { case WP_BOT_LASER: @@ -859,7 +859,7 @@ void NPC_ApplyWeaponFireDelay(void) case WP_THERMAL: if ( client->ps.clientNum ) - {//NPCs delay... + {//NPCs delay... //FIXME: player should, too, but would feel weird in 1st person, even though it // would look right in 3rd person. Really should have a wind-up anim // for player as he holds down the fire button to throw, then play @@ -886,11 +886,11 @@ void NPC_ApplyWeaponFireDelay(void) ShootThink ------------------------- */ -void ShootThink( void ) +void ShootThink( void ) { int delay; /* - if ( enemyVisibility != VIS_SHOOT) + if ( enemyVisibility != VIS_SHOOT) return; */ @@ -900,21 +900,21 @@ void ShootThink( void ) NPC_ApplyWeaponFireDelay(); - if ( NPCInfo->aiFlags & NPCAI_BURST_WEAPON ) + if ( NPCInfo->aiFlags & NPCAI_BURST_WEAPON ) { - if ( !NPCInfo->burstCount ) + if ( !NPCInfo->burstCount ) { NPCInfo->burstCount = Q_irand( NPCInfo->burstMin, NPCInfo->burstMax ); delay = 0; } - else + else { NPCInfo->burstCount--; - if ( NPCInfo->burstCount == 0 ) + if ( NPCInfo->burstCount == 0 ) { delay = NPCInfo->burstSpacing; } - else + else { delay = 0; } @@ -935,7 +935,7 @@ void ShootThink( void ) { delay = NPC->owner->random + 100; } - else + else { delay = NPC->owner->random; } @@ -950,7 +950,7 @@ void ShootThink( void ) { delay = 300; } - else + else { delay = 200; } @@ -958,7 +958,7 @@ void ShootThink( void ) } } } - else + else { delay = NPCInfo->burstSpacing; } @@ -968,16 +968,16 @@ void ShootThink( void ) } /* -static void WeaponThink( qboolean inCombat ) +static void WeaponThink( qboolean inCombat ) FIXME makes this so there's a delay from event that caused us to check to actually doing it Added: hacks for Borg */ -void WeaponThink( qboolean inCombat ) +void WeaponThink( qboolean inCombat ) { ucmd.buttons &= ~BUTTON_ATTACK; - if ( client->ps.weaponstate == WEAPON_RAISING || client->ps.weaponstate == WEAPON_DROPPING ) + if ( client->ps.weaponstate == WEAPON_RAISING || client->ps.weaponstate == WEAPON_DROPPING ) { ucmd.weapon = client->ps.weapon; return; @@ -988,19 +988,19 @@ void WeaponThink( qboolean inCombat ) return; } - if ( client->ps.weaponstate != WEAPON_READY && client->ps.weaponstate != WEAPON_FIRING && client->ps.weaponstate != WEAPON_IDLE) + if ( client->ps.weaponstate != WEAPON_READY && client->ps.weaponstate != WEAPON_FIRING && client->ps.weaponstate != WEAPON_IDLE) { return; } - if ( level.time < NPCInfo->shotTime ) + if ( level.time < NPCInfo->shotTime ) { return; } //MCG - Begin - //For now, no-one runs out of ammo - if(NPC->client->ps.ammo[ weaponData[client->ps.weapon].ammoIndex ] < 10) // checkme + //For now, no-one runs out of ammo + if(NPC->client->ps.ammo[ weaponData[client->ps.weapon].ammoIndex ] < 10) // checkme // if(NPC->client->ps.ammo[ client->ps.weapon ] < 10) { Add_Ammo (NPC, client->ps.weapon, 100); @@ -1014,7 +1014,7 @@ void WeaponThink( qboolean inCombat ) HaveWeapon */ -qboolean HaveWeapon( int weapon ) +qboolean HaveWeapon( int weapon ) { return (qboolean)(client->ps.stats[STAT_WEAPONS] & (1 << weapon)); } @@ -1055,7 +1055,7 @@ this function does not check teams, invulnerability, notarget, etc.... Added: If can't shoot center, try head, if not, see if it's close enough to try anyway. */ -qboolean CanShoot ( gentity_t *ent, gentity_t *shooter ) +qboolean CanShoot ( gentity_t *ent, gentity_t *shooter ) { trace_t tr; vec3_t muzzle; @@ -1069,18 +1069,18 @@ qboolean CanShoot ( gentity_t *ent, gentity_t *shooter ) traceEnt = &g_entities[ tr.entityNum ]; // point blank, baby! - if (tr.startsolid && (shooter->NPC) && (shooter->NPC->touchedByPlayer) ) + if (tr.startsolid && (shooter->NPC) && (shooter->NPC->touchedByPlayer) ) { traceEnt = shooter->NPC->touchedByPlayer; } - + if ( ShotThroughGlass( &tr, ent, spot, MASK_SHOT ) ) { traceEnt = &g_entities[ tr.entityNum ]; } // shot is dead on - if ( traceEnt == ent ) + if ( traceEnt == ent ) { return qtrue; } @@ -1090,7 +1090,7 @@ qboolean CanShoot ( gentity_t *ent, gentity_t *shooter ) CalcEntitySpot( ent, SPOT_HEAD, spot ); gi.trace ( &tr, muzzle, NULL, NULL, spot, shooter->s.number, MASK_SHOT, G2_NOCOLLIDE, 0 ); traceEnt = &g_entities[ tr.entityNum ]; - if ( traceEnt == ent) + if ( traceEnt == ent) { return qtrue; } @@ -1105,7 +1105,7 @@ qboolean CanShoot ( gentity_t *ent, gentity_t *shooter ) } //MCG - End // shot would hit a non-client - if ( !traceEnt->client ) + if ( !traceEnt->client ) { return qfalse; } @@ -1113,13 +1113,13 @@ qboolean CanShoot ( gentity_t *ent, gentity_t *shooter ) // shot is blocked by another player // he's already dead, so go ahead - if ( traceEnt->health <= 0 ) + if ( traceEnt->health <= 0 ) { return qtrue; } // don't deliberately shoot a teammate - if ( traceEnt->client && ( traceEnt->client->playerTeam == shooter->client->playerTeam ) ) + if ( traceEnt->client && ( traceEnt->client->playerTeam == shooter->client->playerTeam ) ) { return qfalse; } @@ -1130,31 +1130,31 @@ qboolean CanShoot ( gentity_t *ent, gentity_t *shooter ) /* -void NPC_CheckPossibleEnemy( gentity_t *other, visibility_t vis ) +void NPC_CheckPossibleEnemy( gentity_t *other, visibility_t vis ) Added: hacks for scripted NPCs */ -void NPC_CheckPossibleEnemy( gentity_t *other, visibility_t vis ) +void NPC_CheckPossibleEnemy( gentity_t *other, visibility_t vis ) { // is he is already our enemy? - if ( other == NPC->enemy ) + if ( other == NPC->enemy ) return; - if ( other->flags & FL_NOTARGET ) + if ( other->flags & FL_NOTARGET ) return; // we already have an enemy and this guy is in our FOV, see if this guy would be better - if ( NPC->enemy && vis == VIS_FOV ) + if ( NPC->enemy && vis == VIS_FOV ) { - if ( NPCInfo->enemyLastSeenTime - level.time < 2000 ) + if ( NPCInfo->enemyLastSeenTime - level.time < 2000 ) { return; } - if ( enemyVisibility == VIS_UNKNOWN ) + if ( enemyVisibility == VIS_UNKNOWN ) { enemyVisibility = NPC_CheckVisibility ( NPC->enemy, CHECK_360|CHECK_FOV ); } - if ( enemyVisibility == VIS_FOV ) + if ( enemyVisibility == VIS_FOV ) { return; } @@ -1165,14 +1165,14 @@ void NPC_CheckPossibleEnemy( gentity_t *other, visibility_t vis ) G_SetEnemy( NPC, other ); } - if ( vis == VIS_FOV ) + if ( vis == VIS_FOV ) { NPCInfo->enemyLastSeenTime = level.time; VectorCopy( other->currentOrigin, NPCInfo->enemyLastSeenLocation ); NPCInfo->enemyLastHeardTime = 0; VectorClear( NPCInfo->enemyLastHeardLocation ); - } - else + } + else { NPCInfo->enemyLastSeenTime = 0; VectorClear( NPCInfo->enemyLastSeenLocation ); @@ -1195,7 +1195,7 @@ Only makes you keep your weapon up after you fire */ int NPC_AttackDebounceForWeapon (void) { - switch ( NPC->client->ps.weapon ) + switch ( NPC->client->ps.weapon ) { /* case WP_BLASTER://scav rifle @@ -1215,7 +1215,7 @@ int NPC_AttackDebounceForWeapon (void) break; case WP_BOT_LASER: - + if ( g_spskill->integer == 0 ) return 2000; @@ -1239,7 +1239,7 @@ float NPC_MaxDistSquaredForWeapon (void) return NPCInfo->stats.shootDistance * NPCInfo->stats.shootDistance; } - switch ( NPC->s.weapon ) + switch ( NPC->s.weapon ) { case WP_BLASTER://scav rifle return 1024 * 1024;//should be shorter? @@ -1325,7 +1325,7 @@ qboolean NPC_EnemyTooFar(gentity_t *enemy, float dist, qboolean toShoot) { vec3_t vec; - + if ( !toShoot ) {//Not trying to actually press fire button with this check if ( NPC->client->ps.weapon == WP_SABER ) @@ -1333,7 +1333,7 @@ qboolean NPC_EnemyTooFar(gentity_t *enemy, float dist, qboolean toShoot) return qfalse; } } - + if(!dist) { @@ -1383,8 +1383,8 @@ gentity_t *NPC_PickEnemy( gentity_t *closestTo, int enemyTeam, qboolean checkVis return NULL; } - if ( NPCInfo->behaviorState == BS_STAND_AND_SHOOT || - NPCInfo->behaviorState == BS_HUNT_AND_KILL ) + if ( NPCInfo->behaviorState == BS_STAND_AND_SHOOT || + NPCInfo->behaviorState == BS_HUNT_AND_KILL ) {//Formations guys don't require inFov to pick up a target //These other behavior states are active battle states and should not //use FOV. FOV checks are for enemies who are patrolling, guarding, etc. @@ -1399,7 +1399,7 @@ gentity_t *NPC_PickEnemy( gentity_t *closestTo, int enemyTeam, qboolean checkVis { if( newenemy->health > 0 ) { - if( enemyTeam == TEAM_PLAYER || newenemy->client->playerTeam == enemyTeam || + if( enemyTeam == TEAM_PLAYER || newenemy->client->playerTeam == enemyTeam || ( enemyTeam == TEAM_PLAYER ) ) {//FIXME: check for range and FOV or vis? if( newenemy != NPC->lastEnemy ) @@ -1434,9 +1434,9 @@ gentity_t *NPC_PickEnemy( gentity_t *closestTo, int enemyTeam, qboolean checkVis {//They're only hidden from a certain direction, check float dot; VectorNormalize( diff ); - dot = DotProduct( newenemy->client->hiddenDir, diff ); + dot = DotProduct( newenemy->client->hiddenDir, diff ); if ( dot > 0.5 ) - {//I'm not looking in the right dir toward them to see them + {//I'm not looking in the right dir toward them to see them failed = qtrue; } else @@ -1576,9 +1576,9 @@ gentity_t *NPC_PickEnemy( gentity_t *closestTo, int enemyTeam, qboolean checkVis float dot; VectorNormalize( diff ); - dot = DotProduct( newenemy->client->hiddenDir, diff ); + dot = DotProduct( newenemy->client->hiddenDir, diff ); if ( dot > 0.5 ) - {//I'm not looking in the right dir toward them to see them + {//I'm not looking in the right dir toward them to see them continue; } else @@ -1643,7 +1643,7 @@ gentity_t *NPC_PickEnemy( gentity_t *closestTo, int enemyTeam, qboolean checkVis } } - + if (findClosest) {//FIXME: you can pick up an enemy around a corner this way. return closestEnemy; @@ -1750,7 +1750,7 @@ gentity_t *NPC_PickAlly ( qboolean facingEachOther, float range, qboolean ignore } } - + return closestAlly; } @@ -1820,7 +1820,7 @@ gentity_t *NPC_CheckEnemy( qboolean findNew, qboolean tooFarOk, qboolean setEnem } else if ( !gi.inPVS(NPC->currentOrigin, NPC->enemy->currentOrigin ) ) {//FIXME: should this be a line-of site check? - //FIXME: a lot of things check PVS AGAIN when deciding whether + //FIXME: a lot of things check PVS AGAIN when deciding whether //or not to shoot, redundant! //Should we lose the enemy? //FIXME: if lose enemy, run lostenemyscript @@ -1869,7 +1869,7 @@ gentity_t *NPC_CheckEnemy( qboolean findNew, qboolean tooFarOk, qboolean setEnem } closestTo = NPC; - //FIXME: check your defendEnt, if you have one, see if their enemy is different + //FIXME: check your defendEnt, if you have one, see if their enemy is different //than yours, or, if they don't have one, pick the closest enemy to THEM? if ( NPCInfo->defendEnt ) {//Trying to protect someone @@ -1928,7 +1928,7 @@ gentity_t *NPC_CheckEnemy( qboolean findNew, qboolean tooFarOk, qboolean setEnem } } } - + if ( !forcefindNew ) { if ( !foundenemy ) @@ -1939,13 +1939,13 @@ gentity_t *NPC_CheckEnemy( qboolean findNew, qboolean tooFarOk, qboolean setEnem G_ClearEnemy(NPC); } } - + NPC->cantHitEnemyCounter = 0; } //FIXME: if we can't find any at all, go into INdependant NPC AI, pursue and kill } - if ( NPC->enemy && NPC->enemy->client ) + if ( NPC->enemy && NPC->enemy->client ) { if(NPC->enemy->client->playerTeam) { @@ -1989,15 +1989,15 @@ qboolean NPC_ClearShot( gentity_t *ent ) { gi.trace ( &tr, muzzle, NULL, NULL, ent->currentOrigin, NPC->s.number, MASK_SHOT, G2_NOCOLLIDE, 0 ); } - + if ( tr.startsolid || tr.allsolid ) { return qfalse; } - if ( tr.entityNum == ent->s.number ) + if ( tr.entityNum == ent->s.number ) return qtrue; - + return qfalse; } @@ -2034,7 +2034,7 @@ int NPC_ShotEntity( gentity_t *ent, vec3_t impactPos ) CalcEntitySpot( NPC, SPOT_WEAPON, muzzle ); } CalcEntitySpot( ent, SPOT_CHEST, targ ); - + // add aim error // use weapon instead of specific npc types, although you could add certain npc classes if you wanted // if ( NPC->client->playerTeam == TEAM_SCAVENGERS ) @@ -2148,7 +2148,7 @@ qboolean NPC_CheckCanAttack (float attack_scale, qboolean stationary) NPC_AimWiggle( enemy_org ); CalcEntitySpot( NPC, SPOT_WEAPON, muzzle ); - + VectorSubtract (enemy_org, muzzle, delta); vectoangles ( delta, angleToEnemy ); distanceToEnemy = VectorNormalize(delta); @@ -2179,7 +2179,7 @@ qboolean NPC_CheckCanAttack (float attack_scale, qboolean stationary) if(enemyVisibility >= VIS_FOV) {//He's in our FOV - + attack_ok = qtrue; //CalcEntitySpot( NPC->enemy, SPOT_HEAD, enemy_head); @@ -2273,7 +2273,7 @@ qboolean NPC_CheckCanAttack (float attack_scale, qboolean stationary) {//Too close to shoot! attack_ok = qfalse; } - else + else {//Hey, it might kill him, do it! attack_scale *= 2;// } @@ -2329,12 +2329,12 @@ IdealDistance determines what the NPC's ideal distance from it's enemy should be in the current situation */ -float IdealDistance ( gentity_t *self ) +float IdealDistance ( gentity_t *self ) { float ideal; ideal = 225 - 20 * NPCInfo->stats.aggression; - switch ( NPC->s.weapon ) + switch ( NPC->s.weapon ) { case WP_ROCKET_LAUNCHER: ideal += 200; @@ -2389,7 +2389,7 @@ void SP_point_combat( gentity_t *self ) } VectorCopy( self->currentOrigin, level.combatPoints[level.numCombatPoints].origin ); - + level.combatPoints[level.numCombatPoints].flags = self->spawnflags; level.combatPoints[level.numCombatPoints].occupied = qfalse; @@ -2444,7 +2444,7 @@ static int NPC_CollectCombatPoints( const vec3_t origin, const float radius, com ///Make sure this is an investigate combat point if ( ( flags & CP_INVESTIGATE ) && ( level.combatPoints[i].flags & CPF_INVESTIGATE ) ) continue; - + //Squad points are only valid if we're looking for them if ( ( level.combatPoints[i].flags & CPF_SQUAD ) && ( ( flags & CP_SQUAD ) == qfalse ) ) continue; @@ -2572,7 +2572,7 @@ int NPC_FindCombatPoint( const vec3_t position, const vec3_t avoidPosition, vec3 continue; } } - else + else { if ( (*cpi).first > DistanceSquared( position, enemyPosition ) ) { @@ -2603,7 +2603,7 @@ int NPC_FindCombatPoint( const vec3_t position, const vec3_t avoidPosition, vec3 if ( flags & CP_FLANK ) { vec3_t eDir2Me, eDir2CP; - + VectorSubtract( position, enemyPosition, eDir2Me ); VectorNormalize( eDir2Me ); @@ -2611,7 +2611,7 @@ int NPC_FindCombatPoint( const vec3_t position, const vec3_t avoidPosition, vec3 VectorNormalize( eDir2CP ); const float dot = DotProduct( eDir2Me, eDir2CP ); - + //Not far enough behind enemy from current pos if ( dot >= 0.4 ) continue; @@ -2623,7 +2623,7 @@ int NPC_FindCombatPoint( const vec3_t position, const vec3_t avoidPosition, vec3 { vec3_t eDir, gDir; vec3_t wpOrg; - + VectorSubtract( position, enemyPosition, eDir ); VectorNormalize( eDir ); @@ -2642,7 +2642,7 @@ int NPC_FindCombatPoint( const vec3_t position, const vec3_t avoidPosition, vec3 VectorNormalize( gDir ); float dot = DotProduct( gDir, eDir ); - + //Don't want to run at enemy if ( dot >= MIN_AVOID_DOT ) continue; @@ -2651,7 +2651,7 @@ int NPC_FindCombatPoint( const vec3_t position, const vec3_t avoidPosition, vec3 if ( DistanceSquared( wpOrg, enemyPosition ) < avoidDist ) continue; } - + //Okay, now make sure it's not blocked gi.trace( &tr, level.combatPoints[i].origin, NPC->mins, NPC->maxs, level.combatPoints[i].origin, NPC->s.number, NPC->clipmask, G2_NOCOLLIDE, 0 ); if ( tr.allsolid || tr.startsolid ) @@ -2721,7 +2721,7 @@ int NPC_FindSquadPoint( vec3_t position ) //Must be vacant if ( level.combatPoints[i].occupied == qtrue ) continue; - + dist = DistanceSquared( position, level.combatPoints[i].origin ); //The point cannot take us past the player @@ -2783,7 +2783,7 @@ qboolean NPC_FreeCombatPoint( int combatPointID, qboolean failed ) //Free it level.combatPoints[combatPointID].occupied = qfalse; - + return qtrue; } @@ -2824,9 +2824,9 @@ gentity_t *NPC_SearchForWeapons( void ) // } if(!PInUse(i)) continue; - + found=&g_entities[i]; - + //FIXME: Also look for ammo_racks that have weapons on them? if ( found->s.eType != ET_ITEM ) { @@ -2847,7 +2847,7 @@ gentity_t *NPC_SearchForWeapons( void ) dist = DistanceSquared( found->currentOrigin, NPC->currentOrigin ); if ( dist < bestDist ) { - if ( !navigator.GetBestPathBetweenEnts( NPC, found, NF_CLEAR_PATH ) + if ( !navigator.GetBestPathBetweenEnts( NPC, found, NF_CLEAR_PATH ) || navigator.GetBestNodeAltRoute( NPC->waypoint, found->waypoint ) == WAYPOINT_NONE ) {//can't possibly have a route to any OR can't possibly have a route to this one OR don't have a route to this one if ( NAV_ClearPathToPoint( NPC, NPC->mins, NPC->maxs, found->currentOrigin, NPC->clipmask, ENTITYNUM_NONE ) ) @@ -2886,7 +2886,7 @@ void NPC_CheckGetNewWeapon( void ) { if ( NPC->s.weapon == WP_NONE && NPC->enemy ) {//if running away because dropped weapon... - if ( NPCInfo->goalEntity + if ( NPCInfo->goalEntity && NPCInfo->goalEntity == NPCInfo->tempGoal && NPCInfo->goalEntity->enemy && !NPCInfo->goalEntity->enemy->inuse ) @@ -2899,7 +2899,7 @@ void NPC_CheckGetNewWeapon( void ) if ( foundWeap ) {//try to nav to it /* - if ( !navigator.GetBestPathBetweenEnts( NPC, foundWeap, NF_CLEAR_PATH ) + if ( !navigator.GetBestPathBetweenEnts( NPC, foundWeap, NF_CLEAR_PATH ) || navigator.GetBestNodeAltRoute( NPC->waypoint, foundWeap->waypoint ) == WAYPOINT_NONE ) {//can't possibly have a route to any OR can't possibly have a route to this one OR don't have a route to this one if ( !NAV_ClearPathToPoint( NPC, NPC->mins, NPC->maxs, foundWeap->currentOrigin, NPC->clipmask, ENTITYNUM_NONE ) ) diff --git a/codeJK2/game/NPC_goal.cpp b/codeJK2/game/NPC_goal.cpp index 6b79122e91..b6eb757d09 100644 --- a/codeJK2/game/NPC_goal.cpp +++ b/codeJK2/game/NPC_goal.cpp @@ -30,17 +30,17 @@ extern qboolean FlyingCreature( gentity_t *ent ); SetGoal */ -void SetGoal( gentity_t *goal, float rating ) +void SetGoal( gentity_t *goal, float rating ) { NPCInfo->goalEntity = goal; // NPCInfo->goalEntityNeed = rating; NPCInfo->goalTime = level.time; // NAV_ClearLastRoute(NPC); - if ( goal ) + if ( goal ) { // Debug_NPCPrintf( NPC, debugNPCAI, DEBUG_LEVEL_INFO, "NPC_SetGoal: %s @ %s (%f)\n", goal->classname, vtos( goal->currentOrigin), rating ); } - else + else { // Debug_NPCPrintf( NPC, debugNPCAI, DEBUG_LEVEL_INFO, "NPC_SetGoal: NONE\n" ); } @@ -51,26 +51,26 @@ void SetGoal( gentity_t *goal, float rating ) NPC_SetGoal */ -void NPC_SetGoal( gentity_t *goal, float rating ) +void NPC_SetGoal( gentity_t *goal, float rating ) { - if ( goal == NPCInfo->goalEntity ) + if ( goal == NPCInfo->goalEntity ) { return; } - if ( !goal ) + if ( !goal ) { // Debug_NPCPrintf( NPC, debugNPCAI, DEBUG_LEVEL_ERROR, "NPC_SetGoal: NULL goal\n" ); return; } - if ( goal->client ) + if ( goal->client ) { // Debug_NPCPrintf( NPC, debugNPCAI, DEBUG_LEVEL_ERROR, "NPC_SetGoal: goal is a client\n" ); return; } - if ( NPCInfo->goalEntity ) + if ( NPCInfo->goalEntity ) { // Debug_NPCPrintf( NPC, debugNPCAI, DEBUG_LEVEL_INFO, "NPC_SetGoal: push %s\n", NPCInfo->goalEntity->classname ); NPCInfo->lastGoalEntity = NPCInfo->goalEntity; @@ -85,11 +85,11 @@ void NPC_SetGoal( gentity_t *goal, float rating ) NPC_ClearGoal */ -void NPC_ClearGoal( void ) +void NPC_ClearGoal( void ) { gentity_t *goal; - if ( !NPCInfo->lastGoalEntity ) + if ( !NPCInfo->lastGoalEntity ) { SetGoal( NULL, 0.0 ); return; @@ -98,7 +98,7 @@ void NPC_ClearGoal( void ) goal = NPCInfo->lastGoalEntity; NPCInfo->lastGoalEntity = NULL; // NAV_ClearLastRoute(NPC); - if ( goal->inuse && !(goal->s.eFlags & EF_NODRAW) ) + if ( goal->inuse && !(goal->s.eFlags & EF_NODRAW) ) { // Debug_NPCPrintf( NPC, debugNPCAI, DEBUG_LEVEL_INFO, "NPC_ClearGoal: pop %s\n", goal->classname ); SetGoal( goal, 0 );//, NPCInfo->lastGoalEntityNeed @@ -156,7 +156,7 @@ ReachedGoal id removed checks against waypoints and is now checking surfaces */ //qboolean NAV_HitNavGoal( vec3_t point, vec3_t mins, vec3_t maxs, gentity_t *goal, qboolean flying ); -qboolean ReachedGoal( gentity_t *goal ) +qboolean ReachedGoal( gentity_t *goal ) { //FIXME: For script waypoints, need a special check /* @@ -170,18 +170,18 @@ qboolean ReachedGoal( gentity_t *goal ) return NAV_HitNavGoal( NPC->currentOrigin, NPC->mins, NPC->maxs, goal, FlyingCreature( NPC ) ); } - if ( goal == NPCInfo->tempGoal && !(goal->svFlags & SVF_NAVGOAL)) + if ( goal == NPCInfo->tempGoal && !(goal->svFlags & SVF_NAVGOAL)) {//MUST touch waypoints, even if moving to it //This is odd, it just checks to see if they are on the same //surface and the tempGoal in in the FOV - does NOT check distance! // are we on same surface? - + //FIXME: NPC->waypoint reset every frame, need to find it first //Should we do that here? (Still will do it only once per frame) if ( NPC->waypoint >= 0 && NPC->waypoint < num_waypoints ) { goalWpNum = NAV_FindWaypointAt ( goal->currentOrigin ); - if ( NPC->waypoint != goalWpNum ) + if ( NPC->waypoint != goalWpNum ) { return qfalse; } @@ -193,7 +193,7 @@ qboolean ReachedGoal( gentity_t *goal ) // is it in our FOV vectoangles ( vec, angles ); delta = AngleDelta ( NPC->client->ps.viewangles[YAW], angles[YAW] ); - if ( fabs ( delta ) > NPCInfo->stats.hfov ) + if ( fabs ( delta ) > NPCInfo->stats.hfov ) { return qfalse; } @@ -219,16 +219,16 @@ qboolean ReachedGoal( gentity_t *goal ) return qfalse; } */ - if ( NPCInfo->aiFlags & NPCAI_TOUCHED_GOAL ) + if ( NPCInfo->aiFlags & NPCAI_TOUCHED_GOAL ) { NPCInfo->aiFlags &= ~NPCAI_TOUCHED_GOAL; return qtrue; } /* - if ( goal->s.eFlags & EF_NODRAW ) + if ( goal->s.eFlags & EF_NODRAW ) { goalWpNum = NAV_FindWaypointAt( goal->currentOrigin ); - if ( NPC->waypoint == goalWpNum ) + if ( NPC->waypoint == goalWpNum ) { return qtrue; } @@ -238,7 +238,7 @@ qboolean ReachedGoal( gentity_t *goal ) if(goal->client && goal->health <= 0) {//trying to get to dead guy goalWpNum = NAV_FindWaypointAt( goal->currentOrigin ); - if ( NPC->waypoint == goalWpNum ) + if ( NPC->waypoint == goalWpNum ) { VectorSubtract(NPC->currentOrigin, goal->currentOrigin, vec); vec[2] = 0; @@ -249,12 +249,12 @@ qboolean ReachedGoal( gentity_t *goal ) } } } -*/ +*/ return NAV_HitNavGoal( NPC->currentOrigin, NPC->mins, NPC->maxs, goal->currentOrigin, NPCInfo->goalRadius, FlyingCreature( NPC ) ); } /* -static gentity_t *UpdateGoal( void ) +static gentity_t *UpdateGoal( void ) Id removed a lot of shit here... doesn't seem to handle waypoints independantly of goalentity @@ -263,11 +263,11 @@ In fact, doesn't seem to be any waypoint info on entities at all any more? MCG - Since goal is ALWAYS goalEntity, took out a lot of sending goal entity pointers around for no reason */ -gentity_t *UpdateGoal( void ) +gentity_t *UpdateGoal( void ) { gentity_t *goal; - if ( !NPCInfo->goalEntity ) + if ( !NPCInfo->goalEntity ) { return NULL; } @@ -280,7 +280,7 @@ gentity_t *UpdateGoal( void ) goal = NPCInfo->goalEntity; - if ( ReachedGoal( goal ) ) + if ( ReachedGoal( goal ) ) { NPC_ReachedGoal(); goal = NULL;//so they don't keep trying to move to it diff --git a/codeJK2/game/NPC_misc.cpp b/codeJK2/game/NPC_misc.cpp index 8ee9116a10..859f6ada81 100644 --- a/codeJK2/game/NPC_misc.cpp +++ b/codeJK2/game/NPC_misc.cpp @@ -73,7 +73,7 @@ void Debug_NPCPrintf (gentity_t *printNPC, cvar_t *cv, int debugLevel, char *fmt return; } - if ( debugNPCName->string[0] && Q_stricmp( debugNPCName->string, printNPC->targetname) != 0 ) + if ( debugNPCName->string[0] && Q_stricmp( debugNPCName->string, printNPC->targetname) != 0 ) { return; } diff --git a/codeJK2/game/NPC_move.cpp b/codeJK2/game/NPC_move.cpp index 0ed5725780..aee1b3263e 100644 --- a/codeJK2/game/NPC_move.cpp +++ b/codeJK2/game/NPC_move.cpp @@ -127,7 +127,7 @@ static void NPC_LadderMove( vec3_t dir ) //ALSO: Need to be able to get off at top //ALSO: Need to play an anim //ALSO: Need transitionary anims? - + if ( ( dir[2] > 0 ) || ( dir[2] < 0 && NPC->client->ps.groundEntityNum == ENTITYNUM_NONE ) ) { //Set our movement direction @@ -155,7 +155,7 @@ inline qboolean NPC_GetMoveInformation( vec3_t dir, float *distance ) //Get our move info VectorSubtract( NPCInfo->goalEntity->currentOrigin, NPC->currentOrigin, dir ); *distance = VectorNormalize( dir ); - + VectorCopy( NPCInfo->goalEntity->currentOrigin, NPCInfo->blockedDest ); return qtrue; @@ -210,7 +210,7 @@ qboolean NPC_GetMoveDirection( vec3_t out, float *distance ) { //Can't reach goal, just face vectoangles( frameNavInfo.direction, angles ); - NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); + NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); VectorCopy( frameNavInfo.direction, out ); *distance = frameNavInfo.distance; return qfalse; @@ -224,7 +224,7 @@ qboolean NPC_GetMoveDirection( vec3_t out, float *distance ) { //FIXME: Emit a warning, this is a worst case scenario //FIXME: if we have a clear path to our goal (exluding bodies), but then this - // check (against bodies only) fails, shouldn't we fall back + // check (against bodies only) fails, shouldn't we fall back // to macro navigation? Like so: if ( !(frameNavInfo.flags&NIF_MACRO_NAV) ) {//we had a clear path to goal and didn't try macro nav, but can't avoid collision so try macro nav here @@ -233,7 +233,7 @@ qboolean NPC_GetMoveDirection( vec3_t out, float *distance ) { //Can't reach goal, just face vectoangles( frameNavInfo.direction, angles ); - NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); + NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); VectorCopy( frameNavInfo.direction, out ); *distance = frameNavInfo.distance; return qfalse; @@ -291,7 +291,7 @@ qboolean NPC_GetMoveDirectionAltRoute( vec3_t out, float *distance, qboolean try { //Can't reach goal, just face vectoangles( frameNavInfo.direction, angles ); - NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); + NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); VectorCopy( frameNavInfo.direction, out ); *distance = frameNavInfo.distance; return qfalse; @@ -313,7 +313,7 @@ qboolean NPC_GetMoveDirectionAltRoute( vec3_t out, float *distance, qboolean try { //Can't reach goal, just face vectoangles( frameNavInfo.direction, angles ); - NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); + NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); VectorCopy( frameNavInfo.direction, out ); *distance = frameNavInfo.distance; return qfalse; @@ -377,7 +377,7 @@ void G_UcmdMoveForDir( gentity_t *self, usercmd_t *cmd, vec3_t dir ) /* vec3_t wishvel; - for ( int i = 0 ; i < 3 ; i++ ) + for ( int i = 0 ; i < 3 ; i++ ) { wishvel[i] = forward[i]*cmd->forwardmove + right[i]*cmd->rightmove; } @@ -399,7 +399,7 @@ NPC_MoveToGoal #if AI_TIMERS extern int navTime; #endif// AI_TIMERS -qboolean NPC_MoveToGoal( qboolean tryStraight ) +qboolean NPC_MoveToGoal( qboolean tryStraight ) { #if AI_TIMERS int startTime = GetTime(0); @@ -443,12 +443,12 @@ qboolean NPC_MoveToGoal( qboolean tryStraight ) //FIXME: strafe instead of turn if change in dir is small and temporary NPCInfo->desiredPitch = 0.0f; NPCInfo->desiredYaw = AngleNormalize360( NPCInfo->lastPathAngles[YAW] ); - + //Pitch towards the goal and also update if flying or swimming if ( NPCInfo->stats.moveType == MT_FLYSWIM ) { NPCInfo->desiredPitch = AngleNormalize360( NPCInfo->lastPathAngles[PITCH] ); - + if ( dir[2] ) { float scale = (dir[2] * distance); @@ -487,7 +487,7 @@ qboolean NPC_SlideMoveToGoal( void ) float saveYaw = NPC->client->ps.viewangles[YAW]; NPCInfo->combatMove = qtrue; - + qboolean ret = NPC_MoveToGoal( qtrue ); NPCInfo->desiredYaw = saveYaw; diff --git a/codeJK2/game/NPC_reactions.cpp b/codeJK2/game/NPC_reactions.cpp index 209f3e607d..187bb0d8e1 100644 --- a/codeJK2/game/NPC_reactions.cpp +++ b/codeJK2/game/NPC_reactions.cpp @@ -71,7 +71,7 @@ static void NPC_CheckAttacker( gentity_t *other, int mod ) //FIXME: I don't see anything in here that would stop teammates from taking a teammate // as an enemy. Ideally, there would be code before this to prevent that from // happening, but that is presumptuous. - + //valid ent - FIXME: a VALIDENT macro would be nice here if ( !other ) return; @@ -83,7 +83,7 @@ static void NPC_CheckAttacker( gentity_t *other, int mod ) return; //Don't take a target that doesn't want to be - if ( other->flags & FL_NOTARGET ) + if ( other->flags & FL_NOTARGET ) return; if ( NPC->svFlags & SVF_LOCKEDENEMY ) @@ -226,7 +226,7 @@ void NPC_ChoosePainAnimation( gentity_t *self, gentity_t *other, vec3_t point, i int pain_anim = -1; float pain_chance; - + if ( self->s.weapon == WP_THERMAL && self->client->fireDelay > 0 ) {//don't interrupt thermal throwing anim return; @@ -256,7 +256,7 @@ void NPC_ChoosePainAnimation( gentity_t *self, gentity_t *other, vec3_t point, i {//ally shot by player always complains pain_chance = 1.1f; } - else + else { if ( other && (other->s.weapon == WP_SABER || mod == MOD_ELECTROCUTE || mod == MOD_CRUSH/*FIXME:MOD_FORCE_GRIP*/) ) { @@ -341,7 +341,7 @@ void NPC_ChoosePainAnimation( gentity_t *self, gentity_t *other, vec3_t point, i { G_AddVoiceEvent( self, Q_irand(EV_CHOKE1, EV_CHOKE3), 0 ); } - + //Setup the timing for it if ( mod == MOD_ELECTROCUTE ) { @@ -357,22 +357,22 @@ void NPC_ChoosePainAnimation( gentity_t *self, gentity_t *other, vec3_t point, i NPC_Pain =============== */ -void NPC_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod, int hitLoc ) +void NPC_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod, int hitLoc ) { team_t otherTeam = TEAM_FREE; int voiceEvent = -1; - if ( self->NPC == NULL ) + if ( self->NPC == NULL ) return; - if ( other == NULL ) + if ( other == NULL ) return; //or just remove ->pain in player_die? if ( self->client->ps.pm_type == PM_DEAD ) return; - if ( other == self ) + if ( other == self ) return; //MCG: Ignore damage from your own team for now @@ -385,15 +385,15 @@ void NPC_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t p // } } - if ( self->client->playerTeam - && other->client - && otherTeam == self->client->playerTeam - && (!player->client->ps.viewEntity || other->s.number != player->client->ps.viewEntity)) + if ( self->client->playerTeam + && other->client + && otherTeam == self->client->playerTeam + && (!player->client->ps.viewEntity || other->s.number != player->client->ps.viewEntity)) {//hit by a teammate if ( other != self->enemy && self != other->enemy ) {//we weren't already enemies - if ( self->enemy || other->enemy - || (other->s.number&&other->s.number!=player->client->ps.viewEntity) + if ( self->enemy || other->enemy + || (other->s.number&&other->s.number!=player->client->ps.viewEntity) /*|| (!other->s.number&&Q_irand( 0, 3 ))*/ ) {//if one of us actually has an enemy already, it's okay, just an accident OR wasn't hit by player or someone controlled by player OR player hit ally and didn't get 25% chance of getting mad (FIXME:accumulate anger+base on diff?) //FIXME: player should have to do a certain amount of damage to ally or hit them several times to make them mad @@ -402,7 +402,7 @@ void NPC_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t p {//Run any pain instructions if ( self->health <= (self->max_health/3) && G_ActivateBehavior(self, BSET_FLEE) ) { - + } else// if( VALIDSTRING( self->behaviorSet[BSET_PAIN] ) ) { @@ -519,7 +519,7 @@ NPC_Touch ------------------------- */ extern qboolean INV_SecurityKeyGive( gentity_t *target, const char *keyname ); -void NPC_Touch(gentity_t *self, gentity_t *other, trace_t *trace) +void NPC_Touch(gentity_t *self, gentity_t *other, trace_t *trace) { if(!self->NPC) return; @@ -570,15 +570,15 @@ void NPC_Touch(gentity_t *self, gentity_t *other, trace_t *trace) } } - if ( other->client ) + if ( other->client ) {//FIXME: if pushing against another bot, both ucmd.rightmove = 127??? //Except if not facing one another... - if ( other->health > 0 ) + if ( other->health > 0 ) { NPCInfo->touchedByPlayer = other; } - if ( other == NPCInfo->goalEntity ) + if ( other == NPCInfo->goalEntity ) { NPCInfo->aiFlags |= NPCAI_TOUCHED_GOAL; } @@ -610,9 +610,9 @@ void NPC_Touch(gentity_t *self, gentity_t *other, trace_t *trace) } */ } - else + else {//FIXME: check for SVF_NONNPC_ENEMY flag here? - if ( other->health > 0 ) + if ( other->health > 0 ) { if ( NPC->enemy == other && (other->svFlags&SVF_NONNPC_ENEMY) ) { @@ -620,7 +620,7 @@ void NPC_Touch(gentity_t *self, gentity_t *other, trace_t *trace) } } - if ( other == NPCInfo->goalEntity ) + if ( other == NPCInfo->goalEntity ) { NPCInfo->aiFlags |= NPCAI_TOUCHED_GOAL; } @@ -757,7 +757,7 @@ void NPC_Respond( gentity_t *self, int userNum ) case CLASS_JEDI: if ( !self->enemy ) { - if ( !(self->svFlags&SVF_IGNORE_ENEMIES) + if ( !(self->svFlags&SVF_IGNORE_ENEMIES) && (self->NPC->scriptFlags&SCF_LOOK_FOR_ENEMIES) && self->client->enemyTeam == TEAM_ENEMY ) { @@ -896,7 +896,7 @@ void NPC_Respond( gentity_t *self, int userNum ) default: break; } - + if ( event != -1 ) { //hack here because we reuse some "combat" and "extra" sounds @@ -973,7 +973,7 @@ NPC_Use */ extern void Add_Batteries( gentity_t *ent, int *count ); -void NPC_Use( gentity_t *self, gentity_t *other, gentity_t *activator ) +void NPC_Use( gentity_t *self, gentity_t *other, gentity_t *activator ) { if (self->client->ps.pm_type == PM_DEAD) {//or just remove ->pain in player_die? @@ -1040,7 +1040,7 @@ void NPC_CheckPlayerAim( void ) if ( player && player->client && player->client->ps.weapon > (int)(WP_NONE) && player->client->ps.weapon < (int)(WP_TRICORDER) ) {//player has a weapon ready - if ( g_crosshairEntNum == NPC->s.number && level.time - g_crosshairEntTime < 200 + if ( g_crosshairEntNum == NPC->s.number && level.time - g_crosshairEntTime < 200 && g_crosshairSameEntTime >= 3000 && g_crosshairEntDist < 256 ) {//if the player holds the crosshair on you for a few seconds //ask them what the fuck they're doing diff --git a/codeJK2/game/NPC_senses.cpp b/codeJK2/game/NPC_senses.cpp index bf7ee9dfdf..57e7febf03 100644 --- a/codeJK2/game/NPC_senses.cpp +++ b/codeJK2/game/NPC_senses.cpp @@ -40,7 +40,7 @@ qboolean G_ClearLineOfSight(const vec3_t point1, const vec3_t point2, int ignore trace_t tr; gi.trace ( &tr, point1, NULL, NULL, point2, ignore, clipmask, G2_NOCOLLIDE, 0 ); - if ( tr.fraction == 1.0 ) + if ( tr.fraction == 1.0 ) { return qtrue; } @@ -52,7 +52,7 @@ qboolean G_ClearLineOfSight(const vec3_t point1, const vec3_t point2, int ignore VectorCopy(tr.endpos, newpoint1); gi.trace (&tr, newpoint1, NULL, NULL, point2, hit->s.number, clipmask, G2_NOCOLLIDE, 0 ); - if ( tr.fraction == 1.0 ) + if ( tr.fraction == 1.0 ) { return qtrue; } @@ -70,7 +70,7 @@ or take any AI related factors (for example, the NPC's reaction time) into accou FIXME do we need fat and thin version of this? */ -qboolean CanSee ( gentity_t *ent ) +qboolean CanSee ( gentity_t *ent ) { trace_t tr; vec3_t eyes; @@ -81,7 +81,7 @@ qboolean CanSee ( gentity_t *ent ) CalcEntitySpot( ent, SPOT_ORIGIN, spot ); gi.trace ( &tr, eyes, NULL, NULL, spot, NPC->s.number, MASK_OPAQUE, G2_NOCOLLIDE, 0 ); ShotThroughGlass (&tr, ent, spot, MASK_OPAQUE); - if ( tr.fraction == 1.0 ) + if ( tr.fraction == 1.0 ) { return qtrue; } @@ -89,7 +89,7 @@ qboolean CanSee ( gentity_t *ent ) CalcEntitySpot( ent, SPOT_HEAD, spot ); gi.trace ( &tr, eyes, NULL, NULL, spot, NPC->s.number, MASK_OPAQUE, G2_NOCOLLIDE, 0 ); ShotThroughGlass (&tr, ent, spot, MASK_OPAQUE); - if ( tr.fraction == 1.0 ) + if ( tr.fraction == 1.0 ) { return qtrue; } @@ -97,7 +97,7 @@ qboolean CanSee ( gentity_t *ent ) CalcEntitySpot( ent, SPOT_LEGS, spot ); gi.trace ( &tr, eyes, NULL, NULL, spot, NPC->s.number, MASK_OPAQUE, G2_NOCOLLIDE, 0 ); ShotThroughGlass (&tr, ent, spot, MASK_OPAQUE); - if ( tr.fraction == 1.0 ) + if ( tr.fraction == 1.0 ) { return qtrue; } @@ -138,11 +138,11 @@ qboolean InFOV( vec3_t spot, vec3_t from, vec3_t fromAngles, int hFOV, int vFOV VectorSubtract ( spot, from, deltaVector ); vectoangles ( deltaVector, angles ); - + deltaAngles[PITCH] = AngleDelta ( fromAngles[PITCH], angles[PITCH] ); deltaAngles[YAW] = AngleDelta ( fromAngles[YAW], angles[YAW] ); - if ( fabs ( deltaAngles[PITCH] ) <= vFOV && fabs ( deltaAngles[YAW] ) <= hFOV ) + if ( fabs ( deltaAngles[PITCH] ) <= vFOV && fabs ( deltaAngles[YAW] ) <= hFOV ) { return qtrue; } @@ -152,7 +152,7 @@ qboolean InFOV( vec3_t spot, vec3_t from, vec3_t fromAngles, int hFOV, int vFOV //NPC to position -qboolean InFOV( vec3_t origin, gentity_t *from, int hFOV, int vFOV ) +qboolean InFOV( vec3_t origin, gentity_t *from, int hFOV, int vFOV ) { vec3_t fromAngles, eyes; @@ -172,7 +172,7 @@ qboolean InFOV( vec3_t origin, gentity_t *from, int hFOV, int vFOV ) //Entity to entity -qboolean InFOV ( gentity_t *ent, gentity_t *from, int hFOV, int vFOV ) +qboolean InFOV ( gentity_t *ent, gentity_t *from, int hFOV, int vFOV ) { vec3_t eyes; vec3_t spot; @@ -205,7 +205,7 @@ qboolean InFOV ( gentity_t *ent, gentity_t *from, int hFOV, int vFOV ) vectoangles ( deltaVector, angles ); deltaAngles[PITCH] = AngleDelta ( fromAngles[PITCH], angles[PITCH] ); deltaAngles[YAW] = AngleDelta ( fromAngles[YAW], angles[YAW] ); - if ( fabs ( deltaAngles[PITCH] ) <= vFOV && fabs ( deltaAngles[YAW] ) <= hFOV ) + if ( fabs ( deltaAngles[PITCH] ) <= vFOV && fabs ( deltaAngles[YAW] ) <= hFOV ) { return qtrue; } @@ -215,7 +215,7 @@ qboolean InFOV ( gentity_t *ent, gentity_t *from, int hFOV, int vFOV ) vectoangles ( deltaVector, angles ); deltaAngles[PITCH] = AngleDelta ( fromAngles[PITCH], angles[PITCH] ); deltaAngles[YAW] = AngleDelta ( fromAngles[YAW], angles[YAW] ); - if ( fabs ( deltaAngles[PITCH] ) <= vFOV && fabs ( deltaAngles[YAW] ) <= hFOV ) + if ( fabs ( deltaAngles[PITCH] ) <= vFOV && fabs ( deltaAngles[YAW] ) <= hFOV ) { return qtrue; } @@ -225,7 +225,7 @@ qboolean InFOV ( gentity_t *ent, gentity_t *from, int hFOV, int vFOV ) vectoangles ( deltaVector, angles ); deltaAngles[PITCH] = AngleDelta ( fromAngles[PITCH], angles[PITCH] ); deltaAngles[YAW] = AngleDelta ( fromAngles[YAW], angles[YAW] ); - if ( fabs ( deltaAngles[PITCH] ) <= vFOV && fabs ( deltaAngles[YAW] ) <= hFOV ) + if ( fabs ( deltaAngles[PITCH] ) <= vFOV && fabs ( deltaAngles[YAW] ) <= hFOV ) { return qtrue; } @@ -233,7 +233,7 @@ qboolean InFOV ( gentity_t *ent, gentity_t *from, int hFOV, int vFOV ) return qfalse; } -qboolean InVisrange ( gentity_t *ent ) +qboolean InVisrange ( gentity_t *ent ) {//FIXME: make a calculate visibility for ents that takes into account //lighting, movement, turning, crouch/stand up, other anims, hide brushes, etc. vec3_t eyes; @@ -280,23 +280,23 @@ qboolean InVisrange ( gentity_t *ent ) NPC_CheckVisibility */ -visibility_t NPC_CheckVisibility ( gentity_t *ent, int flags ) +visibility_t NPC_CheckVisibility ( gentity_t *ent, int flags ) { // flags should never be 0 - if ( !flags ) + if ( !flags ) { return VIS_NOT; } // check PVS - if ( flags & CHECK_PVS ) + if ( flags & CHECK_PVS ) { - if ( !gi.inPVS ( ent->currentOrigin, NPC->currentOrigin ) ) + if ( !gi.inPVS ( ent->currentOrigin, NPC->currentOrigin ) ) { return VIS_NOT; } } - if ( !(flags & (CHECK_360|CHECK_FOV|CHECK_SHOOT)) ) + if ( !(flags & (CHECK_360|CHECK_FOV|CHECK_SHOOT)) ) { return VIS_PVS; } @@ -304,7 +304,7 @@ visibility_t NPC_CheckVisibility ( gentity_t *ent, int flags ) // check within visrange if (flags & CHECK_VISRANGE) { - if( !InVisrange ( ent ) ) + if( !InVisrange ( ent ) ) { return VIS_PVS; } @@ -312,36 +312,36 @@ visibility_t NPC_CheckVisibility ( gentity_t *ent, int flags ) // check 360 degree visibility //Meaning has to be a direct line of site - if ( flags & CHECK_360 ) + if ( flags & CHECK_360 ) { - if ( !CanSee ( ent ) ) + if ( !CanSee ( ent ) ) { return VIS_PVS; } } - if ( !(flags & (CHECK_FOV|CHECK_SHOOT)) ) + if ( !(flags & (CHECK_FOV|CHECK_SHOOT)) ) { return VIS_360; } // check FOV - if ( flags & CHECK_FOV ) + if ( flags & CHECK_FOV ) { - if ( !InFOV ( ent, NPC, NPCInfo->stats.hfov, NPCInfo->stats.vfov) ) + if ( !InFOV ( ent, NPC, NPCInfo->stats.hfov, NPCInfo->stats.vfov) ) { return VIS_360; } } - if ( !(flags & CHECK_SHOOT) ) + if ( !(flags & CHECK_SHOOT) ) { return VIS_FOV; } // check shootability - if ( flags & CHECK_SHOOT ) + if ( flags & CHECK_SHOOT ) { - if ( !CanShoot ( ent, NPC ) ) + if ( !CanShoot ( ent, NPC ) ) { return VIS_FOV; } @@ -467,7 +467,7 @@ static int G_CheckSightEvents( gentity_t *self, int hFOV, int vFOV, float maxSee if ( G_ClearLOS( self, level.alertEvents[i].position ) == qfalse ) continue; - //FIXME: possibly have the light level at this point affect the + //FIXME: possibly have the light level at this point affect the // visibility/alert level of this event? Would also // need to take into account how bright the event // itself is. A lightsaber would stand out more @@ -606,7 +606,7 @@ void AddSoundEvent( gentity_t *owner, vec3_t position, float radius, alertEventL return; } } - + if ( owner == NULL && alertLevel < AEL_DANGER ) //allows un-owned danger alerts return; @@ -669,7 +669,7 @@ void AddSightEvent( gentity_t *owner, vec3_t position, float radius, alertEventL level.alertEvents[ level.numAlertEvents ].radius = radius; level.alertEvents[ level.numAlertEvents ].level = alertLevel; level.alertEvents[ level.numAlertEvents ].type = AET_SIGHT; - level.alertEvents[ level.numAlertEvents ].owner = owner; + level.alertEvents[ level.numAlertEvents ].owner = owner; level.alertEvents[ level.numAlertEvents ].addLight = addLight; //will get added to actual light at that point when it's checked level.alertEvents[ level.numAlertEvents ].ID = level.curAlertID++; level.alertEvents[ level.numAlertEvents ].timestamp = level.time; @@ -764,7 +764,7 @@ qboolean G_ClearLOS( gentity_t *self, const vec3_t start, const vec3_t end ) { trace_t tr; int traceCount = 0; - + //FIXME: ENTITYNUM_NONE ok? gi.trace ( &tr, start, NULL, NULL, end, ENTITYNUM_NONE, CONTENTS_OPAQUE/*CONTENTS_SOLID*//*(CONTENTS_SOLID|CONTENTS_MONSTERCLIP)*/, G2_NOCOLLIDE, 0 ); while ( tr.fraction < 1.0 && traceCount < 3 ) @@ -781,7 +781,7 @@ qboolean G_ClearLOS( gentity_t *self, const vec3_t start, const vec3_t end ) return qfalse; } - if ( tr.fraction == 1.0 ) + if ( tr.fraction == 1.0 ) return qtrue; return qfalse; @@ -818,13 +818,13 @@ qboolean G_ClearLOS( gentity_t *self, const vec3_t start, gentity_t *ent ) } //NPC's eyes to entity -qboolean G_ClearLOS( gentity_t *self, gentity_t *ent ) +qboolean G_ClearLOS( gentity_t *self, gentity_t *ent ) { vec3_t eyes; //Calculate my position CalcEntitySpot( self, SPOT_HEAD_LEAN, eyes ); - + return G_ClearLOS( self, eyes, ent ); } @@ -835,7 +835,7 @@ qboolean G_ClearLOS( gentity_t *self, const vec3_t end ) //Calculate the my position CalcEntitySpot( self, SPOT_HEAD_LEAN, eyes ); - + return G_ClearLOS( self, eyes, end ); } @@ -853,11 +853,11 @@ float NPC_GetHFOVPercentage( vec3_t spot, vec3_t from, vec3_t facing, float hFOV VectorSubtract ( spot, from, deltaVector ); vectoangles ( deltaVector, angles ); - + delta = fabs( AngleDelta ( facing[YAW], angles[YAW] ) ); if ( delta > hFOV ) - return 0.0f; + return 0.0f; return ( ( hFOV - delta ) / hFOV ); } @@ -876,11 +876,11 @@ float NPC_GetVFOVPercentage( vec3_t spot, vec3_t from, vec3_t facing, float vFOV VectorSubtract ( spot, from, deltaVector ); vectoangles ( deltaVector, angles ); - + delta = fabs( AngleDelta ( facing[PITCH], angles[PITCH] ) ); if ( delta > vFOV ) - return 0.0f; + return 0.0f; return ( ( vFOV - delta ) / vFOV ); } @@ -888,7 +888,7 @@ float NPC_GetVFOVPercentage( vec3_t spot, vec3_t from, vec3_t facing, float vFOV #define MAX_INTEREST_DIST ( 256 * 256 ) /* ------------------------- -NPC_FindLocalInterestPoint +NPC_FindLocalInterestPoint ------------------------- */ diff --git a/codeJK2/game/NPC_sounds.cpp b/codeJK2/game/NPC_sounds.cpp index 21917661c5..aaec4a3360 100644 --- a/codeJK2/game/NPC_sounds.cpp +++ b/codeJK2/game/NPC_sounds.cpp @@ -67,12 +67,12 @@ void G_AddVoiceEvent( gentity_t *self, int event, int speakDebounceTime ) return; } - + if ( (self->NPC->scriptFlags&SCF_NO_COMBAT_TALK) && ( (event >= EV_ANGER1 && event <= EV_VICTORY3) || (event >= EV_CHASE1 && event <= EV_SUSPICIOUS5) ) )//(event < EV_FF_1A || event > EV_FF_3C) && (event < EV_RESPOND1 || event > EV_MISSION3) ) { return; } - + if ( (self->NPC->scriptFlags&SCF_NO_ALERT_TALK) && (event >= EV_GIVEUP1 && event <= EV_SUSPICIOUS5) ) { return; @@ -110,7 +110,7 @@ void NPC_PlayConfusionSound( gentity_t *self ) //reset him to be totally unaware again TIMER_Set( self, "enemyLastVisible", 0 ); self->NPC->tempBehavior = BS_DEFAULT; - + //self->NPC->behaviorState = BS_PATROL; G_ClearEnemy( self );//FIXME: or just self->enemy = NULL;? diff --git a/codeJK2/game/NPC_spawn.cpp b/codeJK2/game/NPC_spawn.cpp index f5343ef5c4..28cf40cff1 100644 --- a/codeJK2/game/NPC_spawn.cpp +++ b/codeJK2/game/NPC_spawn.cpp @@ -152,7 +152,7 @@ painFunc_t NPC_PainFunc( gentity_t *ent ) case CLASS_MARK2: func = painF_NPC_Mark2_Pain; break; - case CLASS_ATST: + case CLASS_ATST: func = painF_NPC_ATST_Pain; break; case CLASS_GALAKMECH: @@ -200,7 +200,7 @@ void NPC_SetMiscDefaultData( gentity_t *ent ) case TEAM_PLAYER: //ent->flags |= FL_NO_KNOCKBACK; if ( ent->client->NPC_class == CLASS_SEEKER ) - { + { ent->NPC->defaultBehavior = BS_DEFAULT; ent->client->ps.gravity = 0; ent->svFlags |= SVF_CUSTOM_GRAVITY; @@ -266,9 +266,9 @@ void NPC_SetMiscDefaultData( gentity_t *ent ) } break; - case TEAM_NEUTRAL: + case TEAM_NEUTRAL: - if ( Q_stricmp( ent->NPC_type, "gonk" ) == 0 ) + if ( Q_stricmp( ent->NPC_type, "gonk" ) == 0 ) { // I guess we generically make them player usable ent->svFlags |= SVF_PLAYER_USABLE; @@ -277,14 +277,14 @@ void NPC_SetMiscDefaultData( gentity_t *ent ) switch ( g_spskill->integer ) { case 0: // EASY - ent->client->ps.batteryCharge = MAX_BATTERIES * 0.8f; + ent->client->ps.batteryCharge = MAX_BATTERIES * 0.8f; break; case 1: // MEDIUM - ent->client->ps.batteryCharge = MAX_BATTERIES * 0.75f; + ent->client->ps.batteryCharge = MAX_BATTERIES * 0.75f; break; default : case 2: // HARD - ent->client->ps.batteryCharge = MAX_BATTERIES * 0.5f; + ent->client->ps.batteryCharge = MAX_BATTERIES * 0.5f; break; } } @@ -317,13 +317,13 @@ void NPC_SetMiscDefaultData( gentity_t *ent ) } else if( ent->client->NPC_class == CLASS_PROBE || ent->client->NPC_class == CLASS_REMOTE || ent->client->NPC_class == CLASS_INTERROGATOR || ent->client->NPC_class == CLASS_SENTRY) - { + { ent->NPC->defaultBehavior = BS_DEFAULT; ent->client->ps.gravity = 0; ent->svFlags |= SVF_CUSTOM_GRAVITY; ent->NPC->stats.moveType = MT_FLYSWIM; } - else + else { G_CreateG2AttachedWeaponModel( ent, weaponData[ent->client->ps.weapon].weaponMdl ); switch ( ent->client->ps.weapon ) @@ -406,9 +406,9 @@ int NPC_WeaponsForTeam( team_t team, int spawnflags, const char *NPC_type ) // case TEAM_IMPERIAL: case TEAM_ENEMY: - if ( Q_stricmp( "tavion", NPC_type ) == 0 || - Q_strncmp( "reborn", NPC_type, 6 ) == 0 || - Q_stricmp( "desann", NPC_type ) == 0 || + if ( Q_stricmp( "tavion", NPC_type ) == 0 || + Q_strncmp( "reborn", NPC_type, 6 ) == 0 || + Q_stricmp( "desann", NPC_type ) == 0 || Q_strncmp( "shadowtrooper", NPC_type, 13 ) == 0 ) return ( 1 << WP_SABER); // return ( 1 << WP_IMPERIAL_BLADE); @@ -504,11 +504,11 @@ int NPC_WeaponsForTeam( team_t team, int spawnflags, const char *NPC_type ) if (( Q_stricmp( "probe", NPC_type ) == 0 ) || ( Q_stricmp( "seeker", NPC_type ) == 0 )) { return ( 1 << WP_BOT_LASER); - } + } if ( Q_stricmp( "remote", NPC_type ) == 0 ) { return ( 1 << WP_BOT_LASER ); - } + } if ( Q_stricmp( "trandoshan", NPC_type ) == 0 ) { return (1<NPC->stats.health ) // Was health supplied in NPC.cfg? { - + if ( ent->client->NPC_class != CLASS_REBORN - && ent->client->NPC_class != CLASS_SHADOWTROOPER + && ent->client->NPC_class != CLASS_SHADOWTROOPER //&& ent->client->NPC_class != CLASS_TAVION - //&& ent->client->NPC_class != CLASS_DESANN + //&& ent->client->NPC_class != CLASS_DESANN && ent->client->NPC_class != CLASS_JEDI ) {// up everyone except jedi ent->NPC->stats.health += ent->NPC->stats.health/4 * g_spskill->integer; // 100% on easy, 125% on medium, 150% on hard } - + ent->max_health = client->pers.maxHealth = client->ps.stats[STAT_MAX_HEALTH] = ent->NPC->stats.health; } else @@ -928,7 +928,7 @@ void NPC_Begin (gentity_t *ent) ent->e_DieFunc = dieF_player_die; ent->waterlevel = 0; ent->watertype = 0; - + //visible to player and NPCs if ( ent->client->NPC_class != CLASS_R2D2 && ent->client->NPC_class != CLASS_R5D2 && @@ -941,7 +941,7 @@ void NPC_Begin (gentity_t *ent) ent->s.eFlags &= ~EF_NODRAW; NPC_SetFX_SpawnStates( ent ); - + client->ps.friction = 6; NPC_SetWeapons(ent); @@ -1046,7 +1046,7 @@ void NPC_Begin (gentity_t *ent) // initialize animations and other things memset( &ucmd, 0, sizeof( ucmd ) ); VectorCopyM( client->pers.cmd_angles, ucmd.angles ); - + ent->client->ps.groundEntityNum = ENTITYNUM_NONE; if ( ent->NPC->aiFlags & NPCAI_MATCHPLAYERWEAPON ) @@ -1089,14 +1089,14 @@ gNPC_t *New_NPC_t() NPC_StasisSpawn_Go ------------------------- */ -/* +/* qboolean NPC_StasisSpawn_Go( gentity_t *ent ) { //Setup an owner pointer if we need it if VALIDSTRING( ent->ownername ) { ent->owner = G_Find( NULL, FOFS( targetname ), ent->ownername ); - + if ( ( ent->owner ) && ( ent->owner->health <= 0 ) ) {//our spawner thing is broken if ( ent->target2 && ent->target2[0] ) @@ -1180,7 +1180,7 @@ void NPC_Spawn_Go( gentity_t *ent ) if( ent->count != -1 ) { ent->count--; - + if( ent->count <= 0 ) { ent->e_UseFunc = useF_NULL;//never again @@ -1190,28 +1190,28 @@ void NPC_Spawn_Go( gentity_t *ent ) newent = G_Spawn(); - if ( newent == NULL ) + if ( newent == NULL ) { gi.Printf ( S_COLOR_RED"ERROR: NPC G_Spawn failed\n" ); - + goto finish; return; } - + newent->svFlags |= SVF_NPC; newent->fullName = ent->fullName; - newent->NPC = New_NPC_t(); - if ( newent->NPC == NULL ) - { - gi.Printf ( S_COLOR_RED"ERROR: NPC G_Alloc NPC failed\n" ); + newent->NPC = New_NPC_t(); + if ( newent->NPC == NULL ) + { + gi.Printf ( S_COLOR_RED"ERROR: NPC G_Alloc NPC failed\n" ); goto finish; return; - } + } newent->NPC->tempGoal = G_Spawn(); - - if ( newent->NPC->tempGoal == NULL ) + + if ( newent->NPC->tempGoal == NULL ) { newent->NPC = NULL; goto finish; @@ -1223,19 +1223,19 @@ void NPC_Spawn_Go( gentity_t *ent ) newent->NPC->tempGoal->svFlags |= SVF_NOCLIENT; newent->client = (gclient_t *)G_Alloc (sizeof(gclient_t)); - - if ( newent->client == NULL ) + + if ( newent->client == NULL ) { gi.Printf ( S_COLOR_RED"ERROR: NPC G_Alloc client failed\n" ); goto finish; return; } - + memset ( newent->client, 0, sizeof(*newent->client) ); //==NPC_Connect( newent, net_name );=================================== - if ( ent->NPC_type == NULL ) + if ( ent->NPC_type == NULL ) { ent->NPC_type = "random"; } @@ -1256,7 +1256,7 @@ void NPC_Spawn_Go( gentity_t *ent ) { newent->svFlags |= SVF_NO_EXTRA_SOUNDS; } - + if ( ent->message ) {//has a key newent->message = ent->message;//transfer the key name @@ -1280,9 +1280,9 @@ void NPC_Spawn_Go( gentity_t *ent ) else if ( !Q_stricmp( ent->NPC_type, "test" ) ) { int n; - for ( n = 0; n < 1 ; n++) + for ( n = 0; n < 1 ; n++) { - if ( !(g_entities[n].svFlags & SVF_NPC) && g_entities[n].client) + if ( !(g_entities[n].svFlags & SVF_NPC) && g_entities[n].client) { VectorCopy(g_entities[n].s.origin, newent->s.origin); newent->client->playerTeam = g_entities[n].client->playerTeam; @@ -1304,7 +1304,7 @@ void NPC_Spawn_Go( gentity_t *ent ) newent->target3 = ent->target3;//??? newent->target4 = ent->target4;//ffire death newent->wait = ent->wait; - + for( index = BSET_FIRST; index < NUM_BSETS; index++) { if ( ent->behaviorSet[index] ) @@ -1316,7 +1316,7 @@ void NPC_Spawn_Go( gentity_t *ent ) newent->classname = "NPC"; newent->NPC_type = ent->NPC_type; gi.unlinkentity(newent); - + VectorCopy(ent->s.origin, newent->s.origin); VectorCopy(ent->s.origin, newent->client->ps.origin); VectorCopy(ent->s.origin, newent->currentOrigin); @@ -1326,7 +1326,7 @@ void NPC_Spawn_Go( gentity_t *ent ) VectorCopy(ent->s.angles, newent->currentAngles); VectorCopy(ent->s.angles, newent->client->ps.viewangles); newent->NPC->desiredYaw =ent->s.angles[YAW]; - + gi.linkentity(newent); newent->spawnflags = ent->spawnflags; @@ -1341,7 +1341,7 @@ void NPC_Spawn_Go( gentity_t *ent ) //==New stuff===================================================================== newent->s.eType = ET_PLAYER; - + //FIXME: Call CopyParms if ( ent->parms ) { @@ -1367,7 +1367,7 @@ void NPC_Spawn_Go( gentity_t *ent ) VectorCopy( newent->currentOrigin, newent->s.apos.trBase ); VectorClear( newent->s.apos.trDelta ); newent->s.apos.trDuration = 0; - + newent->NPC->combatPoint = -1; newent->flags |= FL_NOTARGET;//So he's ignored until he's fully spawned @@ -1418,9 +1418,9 @@ void NPC_StasisSpawnEffect( gentity_t *ent ) AngleVectors( ent->s.angles, forward, NULL, NULL ); VectorMA( ent->currentOrigin, 24, forward, end ); VectorMA( ent->currentOrigin, -20, forward, start ); - + start[2] += 64; - + taper = qtrue; } else @@ -1906,14 +1906,14 @@ void SP_NPC_Jedi( gentity_t *self) { self->NPC_type = "jeditrainer"; } - else + else { /* if ( !Q_irand( 0, 2 ) ) { self->NPC_type = "JediF"; } - else + else */if ( Q_irand( 0, 1 ) ) { self->NPC_type = "Jedi"; @@ -2076,7 +2076,7 @@ void SP_NPC_Ugnaught( gentity_t *self) /*QUAKED NPC_Gran(1 0 0) (-16 -16 -24) (16 16 40) SHOOTER BOXER x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY Uses grenade -SHOOTER - uses blaster instead of +SHOOTER - uses blaster instead of BOXER - uses fists only DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it CINEMATIC - Will spawn with no default AI (BS_CINEMATIC) @@ -2353,7 +2353,7 @@ void SP_NPC_Reborn( gentity_t *self) self->NPC_type = "reborn"; } } - + WP_SetSaberModel( NULL, CLASS_REBORN ); SP_NPC_spawner( self ); } @@ -2378,7 +2378,7 @@ void SP_NPC_ShadowTrooper( gentity_t *self) self->NPC_type = "ShadowTrooper2"; } } - + NPC_ShadowTrooper_Precache(); WP_SetSaberModel( NULL, CLASS_SHADOWTROOPER ); @@ -2711,7 +2711,7 @@ NOTSOLID - Starts not solid STARTINSOLID - Don't try to fix if spawn in solid SHY - Spawner is shy -R2D2 Droid - you probably know this one already. +R2D2 Droid - you probably know this one already. NOTARGET by default */ @@ -2789,12 +2789,12 @@ void SP_NPC_Droid_Protocol( gentity_t *self) NPC_Spawn_f */ -static void NPC_Spawn_f(void) +static void NPC_Spawn_f(void) { gentity_t *NPCspawner = G_Spawn(); vec3_t forward, end; trace_t trace; - + if(!NPCspawner) { gi.Printf( S_COLOR_RED"NPC_Spawn Error: Out of entities!\n" ); @@ -2803,7 +2803,7 @@ static void NPC_Spawn_f(void) NPCspawner->e_ThinkFunc = thinkF_G_FreeEntity; NPCspawner->nextthink = level.time + FRAMETIME; - + const char *npc_type = gi.argv( 2 ); if (!*npc_type ) { @@ -2917,7 +2917,7 @@ static void NPC_Spawn_f(void) NPC_Kill_f */ -void NPC_Kill_f( void ) +void NPC_Kill_f( void ) { int n; gentity_t *player; @@ -2976,7 +2976,7 @@ void NPC_Kill_f( void ) } } - for ( n = 1; n < ENTITYNUM_MAX_NORMAL; n++) + for ( n = 1; n < ENTITYNUM_MAX_NORMAL; n++) { player = &g_entities[n]; if (!player->inuse) { @@ -3042,13 +3042,13 @@ Svcmd_NPC_f parse and dispatch bot commands */ qboolean showBBoxes = qfalse; -void Svcmd_NPC_f( void ) +void Svcmd_NPC_f( void ) { char *cmd; cmd = gi.argv( 1 ); - if ( !*cmd ) + if ( !*cmd ) { gi.Printf( "Valid NPC commands are:\n" ); gi.Printf( " spawn [NPC type (from NCPCs.cfg)]\n" ); @@ -3056,11 +3056,11 @@ void Svcmd_NPC_f( void ) gi.Printf( " showbounds (draws exact bounding boxes of NPCs)\n" ); gi.Printf( " score [NPC targetname] (prints number of kills per NPC)\n" ); } - else if ( Q_stricmp( cmd, "spawn" ) == 0 ) + else if ( Q_stricmp( cmd, "spawn" ) == 0 ) { NPC_Spawn_f(); } - else if ( Q_stricmp( cmd, "kill" ) == 0 ) + else if ( Q_stricmp( cmd, "kill" ) == 0 ) { NPC_Kill_f(); } diff --git a/codeJK2/game/NPC_utils.cpp b/codeJK2/game/NPC_utils.cpp index da44b88c8b..c2c8d4c2c7 100644 --- a/codeJK2/game/NPC_utils.cpp +++ b/codeJK2/game/NPC_utils.cpp @@ -38,7 +38,7 @@ void GetAnglesForDirection( const vec3_t p1, const vec3_t p2, vec3_t out ); extern void Q3_DebugPrint( int level, const char *format, ... ); /* -void CalcEntitySpot ( gentity_t *ent, spot_t spot, vec3_t point ) +void CalcEntitySpot ( gentity_t *ent, spot_t spot, vec3_t point ) Added: Uses shootAngles if a NPC has them @@ -46,7 +46,7 @@ Added: Uses shootAngles if a NPC has them extern void ViewHeightFix(const gentity_t *const ent); extern void AddLeanOfs(const gentity_t *const ent, vec3_t point); extern void SubtractLeanOfs(const gentity_t *const ent, vec3_t point); -void CalcEntitySpot ( const gentity_t *ent, const spot_t spot, vec3_t point ) +void CalcEntitySpot ( const gentity_t *ent, const spot_t spot, vec3_t point ) { vec3_t forward, up, right; vec3_t start, end; @@ -57,7 +57,7 @@ void CalcEntitySpot ( const gentity_t *ent, const spot_t spot, vec3_t point ) return; } ViewHeightFix(ent); - switch ( spot ) + switch ( spot ) { case SPOT_ORIGIN: if(VectorCompare(ent->currentOrigin, vec3_origin)) @@ -94,7 +94,7 @@ void CalcEntitySpot ( const gentity_t *ent, const spot_t spot, vec3_t point ) else { VectorCopy ( ent->currentOrigin, point ); - if ( ent->client ) + if ( ent->client ) { point[2] += ent->client->ps.viewheight; } @@ -131,7 +131,7 @@ void CalcEntitySpot ( const gentity_t *ent, const spot_t spot, vec3_t point ) else { VectorCopy ( ent->currentOrigin, point ); - if ( ent->client ) + if ( ent->client ) { point[2] += ent->client->ps.viewheight; } @@ -164,7 +164,7 @@ void CalcEntitySpot ( const gentity_t *ent, const spot_t spot, vec3_t point ) case SPOT_GROUND: // if entity is on the ground, just use it's absmin - if ( ent->s.groundEntityNum != -1 ) + if ( ent->s.groundEntityNum != -1 ) { VectorCopy( ent->currentOrigin, point ); point[2] = ent->absmin[2]; @@ -177,7 +177,7 @@ void CalcEntitySpot ( const gentity_t *ent, const spot_t spot, vec3_t point ) VectorCopy( start, end ); end[2] -= 64; gi.trace( &tr, start, ent->mins, ent->maxs, end, ent->s.number, MASK_PLAYERSOLID, G2_NOCOLLIDE, 0 ); - if ( tr.fraction < 1.0 ) + if ( tr.fraction < 1.0 ) { VectorCopy( tr.endpos, point); break; @@ -197,7 +197,7 @@ void CalcEntitySpot ( const gentity_t *ent, const spot_t spot, vec3_t point ) //=================================================================================== /* -qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) +qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) Added: option to do just pitch or just yaw @@ -206,7 +206,7 @@ Does not include "aim" in it's calculations FIXME: stop compressing angles into shorts!!!! */ extern cvar_t *g_timescale; -qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) +qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) { #if 1 @@ -219,7 +219,7 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) // if angle changes are locked; just keep the current angles // aimTime isn't even set anymore... so this code was never reached, but I need a way to lock NPC's yaw, so instead of making a new SCF_ flag, just use the existing render flag... - dmv - if ( !NPC->enemy && ( (level.time < NPCInfo->aimTime) || NPC->client->renderInfo.renderFlags & RF_LOCKEDANGLE) ) + if ( !NPC->enemy && ( (level.time < NPCInfo->aimTime) || NPC->client->renderInfo.renderFlags & RF_LOCKEDANGLE) ) { if(doPitch) targetPitch = NPCInfo->lockedDesiredPitch; @@ -227,7 +227,7 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) if(doYaw) targetYaw = NPCInfo->lockedDesiredYaw; } - else + else { // we're changing the lockedDesired Pitch/Yaw below so it's lost it's original meaning, get rid of the lock flag NPC->client->renderInfo.renderFlags &= ~RF_LOCKEDANGLE; @@ -242,7 +242,7 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) { targetYaw = NPCInfo->desiredYaw; NPCInfo->lockedDesiredYaw = NPCInfo->desiredYaw; - } + } } if ( NPC->s.weapon == WP_EMPLACED_GUN ) @@ -259,39 +259,39 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) { yawSpeed *= 1.0f/g_timescale->value; } - + if( doYaw ) { // decay yaw error error = AngleDelta ( NPC->client->ps.viewangles[YAW], targetYaw ); if( fabs(error) > MIN_ANGLE_ERROR ) { - if ( error ) + if ( error ) { exact = qfalse; decay = 60.0 + yawSpeed * 3; decay *= 50.0f / 1000.0f;//msec - if ( error < 0.0 ) + if ( error < 0.0 ) { error += decay; - if ( error > 0.0 ) + if ( error > 0.0 ) { error = 0.0; } } - else + else { error -= decay; - if ( error < 0.0 ) + if ( error < 0.0 ) { error = 0.0; } } } } - + ucmd.angles[YAW] = ANGLE2SHORT( targetYaw + error ) - client->ps.delta_angles[YAW]; } @@ -302,25 +302,25 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) error = AngleDelta ( NPC->client->ps.viewangles[PITCH], targetPitch ); if ( fabs(error) > MIN_ANGLE_ERROR ) { - if ( error ) + if ( error ) { exact = qfalse; decay = 60.0 + yawSpeed * 3; decay *= 50.0f / 1000.0f;//msec - if ( error < 0.0 ) + if ( error < 0.0 ) { error += decay; - if ( error > 0.0 ) + if ( error > 0.0 ) { error = 0.0; } } - else + else { error -= decay; - if ( error < 0.0 ) + if ( error < 0.0 ) { error = 0.0; } @@ -351,14 +351,14 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) qboolean doSound = qfalse; // if angle changes are locked; just keep the current angles - if ( level.time < NPCInfo->aimTime ) + if ( level.time < NPCInfo->aimTime ) { if(doPitch) targetPitch = NPCInfo->lockedDesiredPitch; if(doYaw) targetYaw = NPCInfo->lockedDesiredYaw; } - else + else { if(doPitch) targetPitch = NPCInfo->desiredPitch; @@ -384,7 +384,7 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) if(NPC->client->playerTeam == TEAM_BORG&& NPCInfo->behaviorState != BS_FACE&&NPCInfo->tempBehavior!= BS_FACE) {//HACK - borg turn more jittery - if ( error ) + if ( error ) { exact = qfalse; @@ -399,18 +399,18 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) } } - if ( error < 0.0)//-10.0 ) + if ( error < 0.0)//-10.0 ) { error += decay; - if ( error > 0.0 ) + if ( error > 0.0 ) { error = 0.0; } } - else if ( error > 0.0)//10.0 ) + else if ( error > 0.0)//10.0 ) { error -= decay; - if ( error < 0.0 ) + if ( error < 0.0 ) { error = 0.0; } @@ -418,26 +418,26 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) } } else*/ - - if ( error ) + + if ( error ) { exact = qfalse; decay = 60.0 + yawSpeed * 3; decay *= 50.0 / 1000.0;//msec - if ( error < 0.0 ) + if ( error < 0.0 ) { error += decay; - if ( error > 0.0 ) + if ( error > 0.0 ) { error = 0.0; } } - else + else { error -= decay; - if ( error < 0.0 ) + if ( error < 0.0 ) { error = 0.0; } @@ -458,7 +458,7 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) if(NPC->client->playerTeam == TEAM_BORG&& NPCInfo->behaviorState != BS_FACE&&NPCInfo->tempBehavior!= BS_FACE) {//HACK - borg turn more jittery - if ( error ) + if ( error ) { exact = qfalse; @@ -473,18 +473,18 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) } } - if ( error < 0.0)//-10.0 ) + if ( error < 0.0)//-10.0 ) { error += decay; - if ( error > 0.0 ) + if ( error > 0.0 ) { error = 0.0; } } - else if ( error > 0.0)//10.0 ) + else if ( error > 0.0)//10.0 ) { error -= decay; - if ( error < 0.0 ) + if ( error < 0.0 ) { error = 0.0; } @@ -492,26 +492,26 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) } } else*/ - - if ( error ) + + if ( error ) { exact = qfalse; decay = 60.0 + yawSpeed * 3; decay *= 50.0 / 1000.0;//msec - if ( error < 0.0 ) + if ( error < 0.0 ) { error += decay; - if ( error > 0.0 ) + if ( error > 0.0 ) { error = 0.0; } } - else + else { error -= decay; - if ( error < 0.0 ) + if ( error < 0.0 ) { error = 0.0; } @@ -553,11 +553,11 @@ void NPC_AimWiggle( vec3_t enemy_org ) } /* -qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) +qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) Includes aim when determining angles - so they don't always hit... */ -qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) +qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) { #if 0 @@ -568,7 +568,7 @@ qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) float targetYaw = 0; qboolean exact = qtrue; - if ( level.time < NPCInfo->aimTime ) + if ( level.time < NPCInfo->aimTime ) { if( doPitch ) targetPitch = NPCInfo->lockedDesiredPitch; @@ -576,7 +576,7 @@ qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) if( doYaw ) targetYaw = NPCInfo->lockedDesiredYaw; } - else + else { if( doPitch ) { @@ -588,7 +588,7 @@ qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) { targetYaw = NPCInfo->desiredYaw; NPCInfo->lockedDesiredYaw = NPCInfo->desiredYaw; - } + } } if( doYaw ) @@ -603,7 +603,7 @@ qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) if ( diff ) exact = qfalse; - + ucmd.angles[YAW] = ANGLE2SHORT( targetYaw + diff + error ) - client->ps.delta_angles[YAW]; } @@ -616,14 +616,14 @@ qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) if ( diff ) exact = qfalse; - + ucmd.angles[PITCH] = ANGLE2SHORT( targetPitch + diff + error ) - client->ps.delta_angles[PITCH]; } ucmd.angles[ROLL] = ANGLE2SHORT ( NPC->client->ps.viewangles[ROLL] ) - client->ps.delta_angles[ROLL]; return exact; - + #else float error, diff; @@ -633,14 +633,14 @@ qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) qboolean exact = qtrue; // if angle changes are locked; just keep the current angles - if ( level.time < NPCInfo->aimTime ) + if ( level.time < NPCInfo->aimTime ) { if(doPitch) targetPitch = NPCInfo->lockedDesiredPitch; if(doYaw) targetYaw = NPCInfo->lockedDesiredYaw; } - else + else { if(doPitch) targetPitch = NPCInfo->desiredPitch; @@ -671,31 +671,31 @@ qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) { // decay yaw diff diff = AngleDelta ( NPC->client->ps.viewangles[YAW], targetYaw ); - - if ( diff) + + if ( diff) { exact = qfalse; decay = 60.0 + 80.0; decay *= 50.0f / 1000.0f;//msec - if ( diff < 0.0 ) + if ( diff < 0.0 ) { diff += decay; - if ( diff > 0.0 ) + if ( diff > 0.0 ) { diff = 0.0; } } - else + else { diff -= decay; - if ( diff < 0.0 ) + if ( diff < 0.0 ) { diff = 0.0; } } } - + // add yaw error based on NPCInfo->aim value error = NPCInfo->lastAimErrorYaw; @@ -713,30 +713,30 @@ qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) { // decay pitch diff diff = AngleDelta ( NPC->client->ps.viewangles[PITCH], targetPitch ); - if ( diff) + if ( diff) { exact = qfalse; decay = 60.0 + 80.0; decay *= 50.0f / 1000.0f;//msec - if ( diff < 0.0 ) + if ( diff < 0.0 ) { diff += decay; - if ( diff > 0.0 ) + if ( diff > 0.0 ) { diff = 0.0; } } - else + else { diff -= decay; - if ( diff < 0.0 ) + if ( diff < 0.0 ) { diff = 0.0; } } } - + error = NPCInfo->lastAimErrorPitch; ucmd.angles[PITCH] = ANGLE2SHORT( targetPitch + diff + error ) - client->ps.delta_angles[PITCH]; @@ -752,12 +752,12 @@ qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) //=================================================================================== /* -static void NPC_UpdateShootAngles (vec3_t angles, qboolean doPitch, qboolean doYaw ) +static void NPC_UpdateShootAngles (vec3_t angles, qboolean doPitch, qboolean doYaw ) Does update angles on shootAngles */ -void NPC_UpdateShootAngles (vec3_t angles, qboolean doPitch, qboolean doYaw ) +void NPC_UpdateShootAngles (vec3_t angles, qboolean doPitch, qboolean doYaw ) {//FIXME: shoot angles either not set right or not used! float error; float decay; @@ -774,22 +774,22 @@ void NPC_UpdateShootAngles (vec3_t angles, qboolean doPitch, qboolean doYaw ) { // decay yaw error error = AngleDelta ( NPCInfo->shootAngles[YAW], targetYaw ); - if ( error ) + if ( error ) { decay = 60.0 + 80.0 * NPCInfo->stats.aim; decay *= 100.0f / 1000.0f;//msec - if ( error < 0.0 ) + if ( error < 0.0 ) { error += decay; - if ( error > 0.0 ) + if ( error > 0.0 ) { error = 0.0; } } - else + else { error -= decay; - if ( error < 0.0 ) + if ( error < 0.0 ) { error = 0.0; } @@ -802,22 +802,22 @@ void NPC_UpdateShootAngles (vec3_t angles, qboolean doPitch, qboolean doYaw ) { // decay pitch error error = AngleDelta ( NPCInfo->shootAngles[PITCH], targetPitch ); - if ( error ) + if ( error ) { decay = 60.0 + 80.0 * NPCInfo->stats.aim; decay *= 100.0f / 1000.0f;//msec - if ( error < 0.0 ) + if ( error < 0.0 ) { error += decay; - if ( error > 0.0 ) + if ( error > 0.0 ) { error = 0.0; } } - else + else { error -= decay; - if ( error < 0.0 ) + if ( error < 0.0 ) { error = 0.0; } @@ -879,7 +879,7 @@ qboolean G_ActivateBehavior (gentity_t *self, int bset ) } bs_name = self->behaviorSet[bset]; - + if( !(VALIDSTRING( bs_name )) ) { return qfalse; @@ -898,10 +898,10 @@ qboolean G_ActivateBehavior (gentity_t *self, int bset ) else { /* - char newname[MAX_FILENAME_LENGTH]; + char newname[MAX_FILENAME_LENGTH]; sprintf((char *) &newname, "%s/%s", Q3_SCRIPT_DIR, bs_name ); */ - + //FIXME: between here and actually getting into the ICARUS_RunScript function, the stack gets blown! if ( ( ICARUS_entFilter == -1 ) || ( ICARUS_entFilter == self->s.number ) ) { @@ -1288,7 +1288,7 @@ qboolean NPC_FacePosition( vec3_t position, qboolean doPitch ) //Find the delta between our goal and our current facing float yawDelta = AngleNormalize360( NPCInfo->desiredYaw - ( SHORT2ANGLE( ucmd.angles[YAW] + client->ps.delta_angles[YAW] ) ) ); - + //See if we are facing properly if ( fabs( yawDelta ) > VALID_ATTACK_CONE ) facing = qfalse; @@ -1298,7 +1298,7 @@ qboolean NPC_FacePosition( vec3_t position, qboolean doPitch ) //Find the delta between our goal and our current facing float currentAngles = ( SHORT2ANGLE( ucmd.angles[PITCH] + client->ps.delta_angles[PITCH] ) ); float pitchDelta = NPCInfo->desiredPitch - currentAngles; - + //See if we are facing properly if ( fabs( pitchDelta ) > VALID_ATTACK_CONE ) facing = qfalse; diff --git a/codeJK2/game/Q3_Interface.cpp b/codeJK2/game/Q3_Interface.cpp index 4be6d5216f..24c8e819a2 100644 --- a/codeJK2/game/Q3_Interface.cpp +++ b/codeJK2/game/Q3_Interface.cpp @@ -22,7 +22,7 @@ along with this program; if not, see . // ICARUS Engine Interface File // -// This file is the only section of the ICARUS systems that +// This file is the only section of the ICARUS systems that // is not directly portable from engine to engine. // // -- jweier @@ -83,7 +83,7 @@ extern qboolean stop_icarus; //#define stringIDExpand(str, strEnum) str,strEnum /* -stringID_table_t tagsTable [] = +stringID_table_t tagsTable [] = { } */ @@ -151,7 +151,7 @@ stringID_table_t WPTable[] = // NPC enemy weapons ENUM2STRING(WP_EMPLACED_GUN), ENUM2STRING(WP_BOT_LASER), // Probe droid - Laser blast - ENUM2STRING(WP_TURRET), // turret guns + ENUM2STRING(WP_TURRET), // turret guns ENUM2STRING(WP_ATST_MAIN), ENUM2STRING(WP_ATST_SIDE), ENUM2STRING(WP_TIE_FIGHTER), @@ -407,7 +407,7 @@ stringID_table_t setTable[] = {"", SET_}, }; -qboolean COM_ParseString( char **data, char **s ); +qboolean COM_ParseString( char **data, char **s ); //======================================================================= @@ -423,7 +423,7 @@ vec4_t textcolor_scroll; ============ Q3_ReadScript Description : Reads in a file and attaches the script directory properly - Return type : static int + Return type : static int Argument : const char *name Argument : void **buf ============ @@ -436,9 +436,9 @@ static int Q3_ReadScript( const char *name, void **buf ) /* ============ -Q3_CenterPrint +Q3_CenterPrint Description : Prints a message in the center of the screen - Return type : static void + Return type : static void Argument : const char *format Argument : ... ============ @@ -513,7 +513,7 @@ static void SetTextColor ( vec4_t textcolor,const char *color) { VectorCopy4( colorTable[CT_WHITE], textcolor ); } - else + else { VectorCopy4( colorTable[CT_WHITE], textcolor ); } @@ -614,8 +614,8 @@ static void Q3_TaskIDSet( gentity_t *ent, taskID_t taskType, int taskID ) /* ============ Q3_CheckStringCounterIncrement - Description : - Return type : static float + Description : + Return type : static float Argument : const char *string ============ */ @@ -788,7 +788,7 @@ static void Q3_SetMissionFailed(const char *TextEnum) ent->health = 0; //FIXME: what about other NPCs? Scripts? - // statusTextIndex is looked at on the client side. + // statusTextIndex is looked at on the client side. statusTextIndex = GetIDForString( missionFailedTable, TextEnum ); cg.missionStatusShow = qtrue; if ( ent->client ) @@ -952,7 +952,7 @@ static unsigned int Q3_GetTime( void ) G_AddSexToMunroString Take any string, look for "kyle/" replace with "kyla/" based on "sex" -And: Take any string, look for "/mr_" replace with "/ms_" based on "sex" +And: Take any string, look for "/mr_" replace with "/ms_" based on "sex" returns qtrue if changed to ms ============= */ @@ -1055,7 +1055,7 @@ static int Q3_PlaySound( int taskID, int entID, const char *name, const char *ch if (g_subtitles->integer == 1 || (ent->NPC && (ent->NPC->scriptFlags & SCF_USE_SUBTITLES) ) ) // Show all text { if ( in_camera) // Cinematic - { + { gi.SendServerCommand( 0, "ct \"%s\" %i", finalName, soundHandle ); } else //if (precacheWav[i].speaker==SP_NONE) // lower screen text @@ -1073,7 +1073,7 @@ static int Q3_PlaySound( int taskID, int entID, const char *name, const char *ch else if (g_subtitles->integer == 2) // Show only talking head text and CINEMATIC { if ( in_camera) // Cinematic text - { + { gi.SendServerCommand( 0, "ct \"%s\" %i", finalName, soundHandle); } } @@ -1176,7 +1176,7 @@ static void Q3_SetOrigin( int entID, vec3_t origin ) VectorClear (ent->client->ps.velocity); ent->client->ps.pm_time = 160; // hold time ent->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; - + ent->client->ps.eFlags ^= EF_TELEPORT_BIT; // G_KillBox (ent); @@ -1193,8 +1193,8 @@ static void Q3_SetOrigin( int entID, vec3_t origin ) /* ============ MoveOwner - Description : - Return type : void + Description : + Return type : void Argument : gentity_t *self ============ */ @@ -1242,7 +1242,7 @@ static qboolean Q3_SetTeleportDest( int entID, vec3_t org ) teleporter->e_ThinkFunc = thinkF_MoveOwner; teleporter->nextthink = level.time + FRAMETIME; - + return qfalse; } else @@ -1309,8 +1309,8 @@ static void Q3_SetVelocity( int entID, int axis, float speed ) /* ============ Q3_SetAdjustAreaPortals - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean shields ============ @@ -1331,8 +1331,8 @@ static void Q3_SetAdjustAreaPortals( int entID, qboolean adjust ) /* ============ Q3_SetDmgByHeavyWeapOnly - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean dmg ============ @@ -1346,15 +1346,15 @@ static void Q3_SetDmgByHeavyWeapOnly( int entID, qboolean dmg ) Q3_DebugPrint( WL_WARNING, "Q3_SetDmgByHeavyWeapOnly: invalid entID %d\n", entID); return; } - + ent->flags = (dmg) ? (ent->flags|FL_DMG_BY_HEAVY_WEAP_ONLY) : (ent->flags&~FL_DMG_BY_HEAVY_WEAP_ONLY); } /* ============ Q3_SetShielded - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean dmg ============ @@ -1368,15 +1368,15 @@ static void Q3_SetShielded( int entID, qboolean dmg ) Q3_DebugPrint( WL_WARNING, "Q3_SetShielded: invalid entID %d\n", entID); return; } - + ent->flags = (dmg) ? (ent->flags|FL_SHIELDED) : (ent->flags&~FL_SHIELDED); } /* ============ Q3_SetNoGroups - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean dmg ============ @@ -1396,7 +1396,7 @@ static void Q3_SetNoGroups( int entID, qboolean noGroups ) Q3_DebugPrint( WL_WARNING, "Q3_SetNoGroups: ent %s is not an NPC!\n", ent->targetname ); return; } - + ent->NPC->scriptFlags = noGroups ? (ent->NPC->scriptFlags|SCF_NO_GROUPS) : (ent->NPC->scriptFlags&~SCF_NO_GROUPS); } @@ -1412,18 +1412,18 @@ void moverCallback( gentity_t *ent ) { //complete the task Q3_TaskIDComplete( ent, TID_MOVE_NAV ); - + // play sound ent->s.loopSound = 0;//stop looping sound G_PlayDoorSound( ent, BMS_END );//play end sound - if ( ent->moverState == MOVER_1TO2 ) + if ( ent->moverState == MOVER_1TO2 ) {//reached open // reached pos2 MatchTeam( ent, MOVER_POS2, level.time ); //SetMoverState( ent, MOVER_POS2, level.time ); - } - else if ( ent->moverState == MOVER_2TO1 ) + } + else if ( ent->moverState == MOVER_2TO1 ) {//reached closed MatchTeam( ent, MOVER_POS1, level.time ); //SetMoverState( ent, MOVER_POS1, level.time ); @@ -1527,11 +1527,11 @@ static void Q3_Lerp2Start( int entID, int taskID, float duration ) gentity_t *ent = &g_entities[entID]; if(!ent) - { + { Q3_DebugPrint( WL_WARNING, "Q3_Lerp2Start: invalid entID %d\n", entID); return; } - + if ( ent->client || ent->NPC || Q_stricmp(ent->classname, "target_scriptrunner") == 0 ) { Q3_DebugPrint( WL_ERROR, "Q3_Lerp2Start: ent %d is NOT a mover!\n", entID); @@ -1554,7 +1554,7 @@ static void Q3_Lerp2Start( int entID, int taskID, float duration ) ent->s.pos.trDuration = duration * 10; //In seconds ent->s.pos.trTime = level.time; - + Q3_TaskIDSet( ent, TID_MOVE_NAV, taskID ); // starting sound G_PlayDoorLoopSound( ent ); @@ -1579,7 +1579,7 @@ static void Q3_Lerp2End( int entID, int taskID, float duration ) Q3_DebugPrint( WL_WARNING, "Q3_Lerp2End: invalid entID %d\n", entID); return; } - + if ( ent->client || ent->NPC || Q_stricmp(ent->classname, "target_scriptrunner") == 0 ) { Q3_DebugPrint( WL_ERROR, "Q3_Lerp2End: ent %d is NOT a mover!\n", entID); @@ -1610,7 +1610,7 @@ static void Q3_Lerp2End( int entID, int taskID, float duration ) ent->s.pos.trDuration = duration * 10; //In seconds ent->s.time = level.time; - + Q3_TaskIDSet( ent, TID_MOVE_NAV, taskID ); // starting sound G_PlayDoorLoopSound( ent ); @@ -1638,7 +1638,7 @@ static void Q3_Lerp2Pos( int taskID, int entID, vec3_t origin, vec3_t angles, fl Q3_DebugPrint( WL_WARNING, "Q3_Lerp2Pos: invalid entID %d\n", entID); return; } - + if ( ent->client || ent->NPC || Q_stricmp(ent->classname, "target_scriptrunner") == 0 ) { Q3_DebugPrint( WL_ERROR, "Q3_Lerp2Pos: ent %d is NOT a mover!\n", entID); @@ -1755,7 +1755,7 @@ static void Q3_Lerp2Origin( int taskID, int entID, vec3_t origin, float duration Q3_DebugPrint( WL_WARNING, "Q3_Lerp2Origin: invalid entID %d\n", entID); return; } - + if ( ent->client || ent->NPC || Q_stricmp(ent->classname, "target_scriptrunner") == 0 ) { Q3_DebugPrint( WL_ERROR, "Q3_Lerp2Origin: ent %d is NOT a mover!\n", entID); @@ -1825,7 +1825,7 @@ static void Q3_SetOriginOffset( int entID, int axis, float offset ) Q3_DebugPrint( WL_WARNING, "Q3_SetOriginOffset: invalid entID %d\n", entID); return; } - + if ( ent->client || ent->NPC || Q_stricmp(ent->classname, "target_scriptrunner") == 0 ) { Q3_DebugPrint( WL_ERROR, "Q3_SetOriginOffset: ent %d is NOT a mover!\n", entID); @@ -1860,7 +1860,7 @@ static void Q3_Lerp2Angles( int taskID, int entID, vec3_t angles, float duration Q3_DebugPrint( WL_WARNING, "Q3_Lerp2Angles: invalid entID %d\n", entID); return; } - + if ( ent->client || ent->NPC || Q_stricmp(ent->classname, "target_scriptrunner") == 0 ) { Q3_DebugPrint( WL_ERROR, "Q3_Lerp2Angles: ent %d is NOT a mover!\n", entID); @@ -1888,7 +1888,7 @@ static void Q3_Lerp2Angles( int taskID, int entID, vec3_t angles, float duration } ent->s.apos.trTime = level.time; - + Q3_TaskIDSet( ent, TID_ANGLE_FACE, taskID ); //ent->e_ReachedFunc = reachedF_NULL; @@ -1921,7 +1921,7 @@ static int Q3_GetTag( int entID, const char *name, int lookup, vec3_t info ) case TYPE_ANGLES: //return TAG_GetAngles( ent->targetname, name, info ); return TAG_GetAngles( ent->ownername, name, info ); - break; + break; } return false; @@ -2002,8 +2002,8 @@ static void Q3_SetNavGoal( int entID, const char *name ) /* ============ SetLowerAnim - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int animID ============ @@ -2030,9 +2030,9 @@ static void SetLowerAnim( int entID, int animID) /* ============ -SetUpperAnim - Description : - Return type : static void +SetUpperAnim + Description : + Return type : static void Argument : int entID Argument : int animID ============ @@ -2076,7 +2076,7 @@ static qboolean Q3_SetAnimUpper( int entID, const char *anim_name ) Q3_DebugPrint( WL_WARNING, "Q3_SetAnimUpper: unknown animation sequence '%s'\n", anim_name ); return qfalse; } - + if ( !PM_HasAnimation( &g_entities[entID], animID ) ) { return qfalse; @@ -2107,7 +2107,7 @@ static qboolean Q3_SetAnimLower( int entID, const char *anim_name ) Q3_DebugPrint( WL_WARNING, "Q3_SetAnimLower: unknown animation sequence '%s'\n", anim_name ); return qfalse; } - + if ( !PM_HasAnimation( &g_entities[entID], animID ) ) { return qfalse; @@ -2120,8 +2120,8 @@ static qboolean Q3_SetAnimLower( int entID, const char *anim_name ) /* ============ Q3_SetAnimHoldTime - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int int_data Argument : qboolean lower @@ -2144,7 +2144,7 @@ static void Q3_SetAnimHoldTime( int entID, int int_data, qboolean lower ) Q3_DebugPrint( WL_ERROR, "Q3_SetAnimHoldTime: ent %d is NOT a player or NPC!\n", entID); return; } - + if(lower) { PM_SetLegsAnimTimer( ent, &ent->client->ps.legsAnimTimer, int_data ); @@ -2297,7 +2297,7 @@ static void Q3_SetLeader( int entID, const char *name ) } } -stringID_table_t teamTable [] = +stringID_table_t teamTable [] = { ENUM2STRING(TEAM_FREE), ENUM2STRING(TEAM_PLAYER), @@ -2310,8 +2310,8 @@ stringID_table_t teamTable [] = /* ============ Q3_SetPlayerTeam - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : const char *teamName ============ @@ -2341,8 +2341,8 @@ static void Q3_SetPlayerTeam( int entID, const char *teamName ) /* ============ Q3_SetEnemyTeam - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : const char *teamName ============ @@ -2362,7 +2362,7 @@ static void Q3_SetEnemyTeam( int entID, const char *teamName ) Q3_DebugPrint( WL_ERROR, "Q3_SetEnemyTeam: ent %d is NOT a player or NPC!\n", entID); return; } - + ent->client->enemyTeam = (team_t)GetIDForString( teamTable, teamName ); } @@ -2370,8 +2370,8 @@ static void Q3_SetEnemyTeam( int entID, const char *teamName ) /* ============ Q3_SetHealth - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int data ============ @@ -2385,7 +2385,7 @@ static void Q3_SetHealth( int entID, int data ) Q3_DebugPrint( WL_WARNING, "Q3_SetHealth: invalid entID %d\n", entID); return; } - + if ( data < 0 ) { data = 0; @@ -2406,7 +2406,7 @@ static void Q3_SetHealth( int entID, int data ) ent->client->ps.stats[STAT_HEALTH] = data; if ( ent->s.number == 0 ) - {//clamp health to max + {//clamp health to max if ( ent->client->ps.stats[STAT_HEALTH] > ent->client->ps.stats[STAT_MAX_HEALTH] ) { ent->health = ent->client->ps.stats[STAT_HEALTH] = ent->client->ps.stats[STAT_MAX_HEALTH]; @@ -2427,8 +2427,8 @@ static void Q3_SetHealth( int entID, int data ) /* ============ Q3_SetArmor - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int data ============ @@ -2442,7 +2442,7 @@ static void Q3_SetArmor( int entID, int data ) Q3_DebugPrint( WL_WARNING, "Q3_SetArmor: invalid entID %d\n", entID); return; } - + if(!ent->client) { return; @@ -2461,11 +2461,11 @@ static void Q3_SetArmor( int entID, int data ) /* ============ Q3_SetBState - Description : - Return type : static qboolean + Description : + Return type : static qboolean Argument : int entID Argument : const char *bs_name -FIXME: this should be a general NPC wrapper function +FIXME: this should be a general NPC wrapper function that is called ANY time a bState is changed... ============ */ @@ -2479,7 +2479,7 @@ static qboolean Q3_SetBState( int entID, const char *bs_name ) Q3_DebugPrint( WL_WARNING, "Q3_SetBState: invalid entID %d\n", entID); return qtrue; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetBState: '%s' is not an NPC\n", ent->targetname ); @@ -2492,7 +2492,7 @@ static qboolean Q3_SetBState( int entID, const char *bs_name ) if ( bSID == BS_SEARCH || bSID == BS_WANDER ) { //FIXME: Reimplement - + if( ent->waypoint != WAYPOINT_NONE ) { NPC_BSSearchStart( ent->waypoint, bSID ); @@ -2520,7 +2520,7 @@ static qboolean Q3_SetBState( int entID, const char *bs_name ) } } } - + ent->NPC->tempBehavior = BS_DEFAULT;//need to clear any temp behaviour if ( ent->NPC->behaviorState == BS_NOCLIP && bSID != BS_NOCLIP ) @@ -2589,8 +2589,8 @@ static qboolean Q3_SetBState( int entID, const char *bs_name ) /* ============ Q3_SetTempBState - Description : - Return type : static qboolean + Description : + Return type : static qboolean Argument : int entID Argument : const char *bs_name ============ @@ -2605,7 +2605,7 @@ static qboolean Q3_SetTempBState( int entID, const char *bs_name ) Q3_DebugPrint( WL_WARNING, "Q3_SetTempBState: invalid entID %d\n", entID); return qtrue; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetTempBState: '%s' is not an NPC\n", ent->targetname ); @@ -2639,8 +2639,8 @@ static qboolean Q3_SetTempBState( int entID, const char *bs_name ) /* ============ Q3_SetDefaultBState - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : const char *bs_name ============ @@ -2655,7 +2655,7 @@ static void Q3_SetDefaultBState( int entID, const char *bs_name ) Q3_DebugPrint( WL_WARNING, "Q3_SetDefaultBState: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetDefaultBState: '%s' is not an NPC\n", ent->targetname ); @@ -2673,8 +2673,8 @@ static void Q3_SetDefaultBState( int entID, const char *bs_name ) /* ============ Q3_SetDPitch - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float data ============ @@ -2688,13 +2688,13 @@ static void Q3_SetDPitch( int entID, float data ) Q3_DebugPrint( WL_WARNING, "Q3_SetDPitch: invalid entID %d\n", entID); return; } - + if ( !ent->NPC || !ent->client ) { Q3_DebugPrint( WL_ERROR, "Q3_SetDPitch: '%s' is not an NPC\n", ent->targetname ); return; } - + int pitchMin = -ent->client->renderInfo.headPitchRangeUp + 1; int pitchMax = ent->client->renderInfo.headPitchRangeDown - 1; @@ -2724,8 +2724,8 @@ static void Q3_SetDPitch( int entID, float data ) /* ============ Q3_SetDYaw - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float data ============ @@ -2733,13 +2733,13 @@ Q3_SetDYaw static void Q3_SetDYaw( int entID, float data ) { gentity_t *ent = &g_entities[entID]; - + if ( !ent ) { Q3_DebugPrint( WL_WARNING, "Q3_SetDYaw: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetDYaw: '%s' is not an NPC\n", ent->targetname ); @@ -2760,8 +2760,8 @@ static void Q3_SetDYaw( int entID, float data ) /* ============ Q3_SetShootDist - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float data ============ @@ -2775,7 +2775,7 @@ static void Q3_SetShootDist( int entID, float data ) Q3_DebugPrint( WL_WARNING, "Q3_SetShootDist: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetShootDist: '%s' is not an NPC\n", ent->targetname ); @@ -2789,8 +2789,8 @@ static void Q3_SetShootDist( int entID, float data ) /* ============ Q3_SetVisrange - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float data ============ @@ -2804,7 +2804,7 @@ static void Q3_SetVisrange( int entID, float data ) Q3_DebugPrint( WL_WARNING, "Q3_SetVisrange: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetVisrange: '%s' is not an NPC\n", ent->targetname ); @@ -2818,8 +2818,8 @@ static void Q3_SetVisrange( int entID, float data ) /* ============ Q3_SetEarshot - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float data ============ @@ -2833,7 +2833,7 @@ static void Q3_SetEarshot( int entID, float data ) Q3_DebugPrint( WL_WARNING, "Q3_SetEarshot: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetEarshot: '%s' is not an NPC\n", ent->targetname ); @@ -2847,8 +2847,8 @@ static void Q3_SetEarshot( int entID, float data ) /* ============ Q3_SetVigilance - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float data ============ @@ -2862,7 +2862,7 @@ static void Q3_SetVigilance( int entID, float data ) Q3_DebugPrint( WL_WARNING, "Q3_SetVigilance: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetVigilance: '%s' is not an NPC\n", ent->targetname ); @@ -2876,8 +2876,8 @@ static void Q3_SetVigilance( int entID, float data ) /* ============ Q3_SetVFOV - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int data ============ @@ -2891,7 +2891,7 @@ static void Q3_SetVFOV( int entID, int data ) Q3_DebugPrint( WL_WARNING, "Q3_SetVFOV: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetVFOV: '%s' is not an NPC\n", ent->targetname ); @@ -2905,8 +2905,8 @@ static void Q3_SetVFOV( int entID, int data ) /* ============ Q3_SetHFOV - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int data ============ @@ -2920,7 +2920,7 @@ static void Q3_SetHFOV( int entID, int data ) Q3_DebugPrint( WL_WARNING, "Q3_SetHFOV: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetHFOV: '%s' is not an NPC\n", ent->targetname ); @@ -2934,8 +2934,8 @@ static void Q3_SetHFOV( int entID, int data ) /* ============ Q3_SetWidth - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float data ============ @@ -2943,13 +2943,13 @@ Q3_SetWidth static void Q3_SetWidth( int entID, int data ) { gentity_t *ent = &g_entities[entID]; - + if ( !ent ) { Q3_DebugPrint( WL_WARNING, "Q3_SetWidth: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetWidth: '%s' is not an NPC\n", ent->targetname ); @@ -2963,8 +2963,8 @@ static void Q3_SetWidth( int entID, int data ) /* ============ Q3_GetTimeScale - Description : - Return type : static unsigned int + Description : + Return type : static unsigned int Argument : void ============ */ @@ -2978,8 +2978,8 @@ static unsigned int Q3_GetTimeScale( void ) /* ============ Q3_SetTimeScale - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : const char *data ============ @@ -2993,8 +2993,8 @@ static void Q3_SetTimeScale( int entID, const char *data ) /* ============ Q3_SetInvisible - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : qboolean invisible ============ @@ -3008,7 +3008,7 @@ static void Q3_SetInvisible( int entID, qboolean invisible ) Q3_DebugPrint( WL_WARNING, "Q3_SetInvisible: invalid entID %d\n", entID); return; } - + if ( invisible ) { self->s.eFlags |= EF_NODRAW; @@ -3031,8 +3031,8 @@ static void Q3_SetInvisible( int entID, qboolean invisible ) /* ============ Q3_SetVampire - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : qboolean vampire ============ @@ -3046,7 +3046,7 @@ static void Q3_SetVampire( int entID, qboolean vampire ) Q3_DebugPrint( WL_WARNING, "Q3_SetVampire: entID %d not a client\n", entID); return; } - + if ( vampire ) { self->client->ps.powerups[PW_DISINT_2] = Q3_INFINITE; @@ -3059,8 +3059,8 @@ static void Q3_SetVampire( int entID, qboolean vampire ) /* ============ Q3_SetGreetAllies - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : qboolean greet ============ @@ -3074,7 +3074,7 @@ static void Q3_SetGreetAllies( int entID, qboolean greet ) Q3_DebugPrint( WL_WARNING, "Q3_SetGreetAllies: invalid entID %d\n", entID); return; } - + if ( !self->NPC ) { Q3_DebugPrint( WL_WARNING, "Q3_SetGreetAllies: ent %s is not an NPC!\n", self->targetname ); @@ -3094,9 +3094,9 @@ static void Q3_SetGreetAllies( int entID, qboolean greet ) /* ============ -Q3_SetViewTarget - Description : - Return type : static void +Q3_SetViewTarget + Description : + Return type : static void Argument : int entID Argument : const char *name ============ @@ -3112,26 +3112,26 @@ static void Q3_SetViewTarget (int entID, const char *name) Q3_DebugPrint( WL_WARNING, "Q3_SetViewTarget: invalid entID %d\n", entID); return; } - + if ( !self->client ) { Q3_DebugPrint( WL_ERROR, "Q3_SetViewTarget: '%s' is not a player/NPC!\n", self->targetname ); return; } - + //FIXME: Exception handle here if (viewtarget == NULL) { Q3_DebugPrint( WL_WARNING, "Q3_SetViewTarget: can't find ViewTarget: '%s'\n", name ); return; } - + //FIXME: should we set behavior to BS_FACE and keep facing this ent as it moves //around for a script-specified length of time...? VectorCopy ( self->currentOrigin, selfspot ); selfspot[2] += self->client->ps.viewheight; - if ( viewtarget->client && (!g_skippingcin || !g_skippingcin->integer ) ) + if ( viewtarget->client && (!g_skippingcin || !g_skippingcin->integer ) ) { VectorCopy ( viewtarget->client->renderInfo.eyePoint, viewspot ); } @@ -3139,9 +3139,9 @@ static void Q3_SetViewTarget (int entID, const char *name) { VectorCopy ( viewtarget->currentOrigin, viewspot ); } - + VectorSubtract( viewspot, selfspot, viewvec ); - + vectoangles( viewvec, viewangles ); Q3_SetDYaw( entID, viewangles[YAW] ); @@ -3154,9 +3154,9 @@ static void Q3_SetViewTarget (int entID, const char *name) /* ============ -Q3_SetWatchTarget - Description : - Return type : static void +Q3_SetWatchTarget + Description : + Return type : static void Argument : int entID Argument : const char *name ============ @@ -3171,13 +3171,13 @@ static void Q3_SetWatchTarget (int entID, const char *name) Q3_DebugPrint( WL_WARNING, "Q3_SetWatchTarget: invalid entID %d\n", entID); return; } - + if ( !self->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetWatchTarget: '%s' is not an NPC!\n", self->targetname ); return; } - + if ( Q_stricmp( "NULL", name ) == 0 || Q_stricmp( "NONE", name ) == 0 || ( self->targetname && (Q_stricmp( self->targetname, name ) == 0) ) ) {//clearing watchTarget self->NPC->watchTarget = NULL; @@ -3189,7 +3189,7 @@ static void Q3_SetWatchTarget (int entID, const char *name) Q3_DebugPrint( WL_WARNING, "Q3_SetWatchTarget: can't find WatchTarget: '%s'\n", name ); return; } - + self->NPC->watchTarget = watchTarget; } @@ -3236,7 +3236,7 @@ void Q3_SetICARUSFreeze( int entID, const char *name, qboolean freeze ) Q3_DebugPrint( WL_WARNING, "Q3_SetICARUSFreeze: invalid ent %s\n", name); return; } - + if ( freeze ) { self->svFlags |= SVF_ICARUS_FREEZE; @@ -3250,8 +3250,8 @@ void Q3_SetICARUSFreeze( int entID, const char *name, qboolean freeze ) /* ============ Q3_SetViewEntity - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : const char *name ============ @@ -3274,7 +3274,7 @@ void Q3_SetViewEntity(int entID, const char *name) Q3_DebugPrint( WL_ERROR, "Q3_SetViewEntity: invalid entID %d\n", entID); return; } - + if ( !self->client ) { Q3_DebugPrint( WL_ERROR, "Q3_SetViewEntity: '%s' is not a player!\n", self->targetname ); @@ -3286,7 +3286,7 @@ void Q3_SetViewEntity(int entID, const char *name) G_ClearViewEntity( self ); return; } - + if ( viewtarget == NULL ) { Q3_DebugPrint( WL_WARNING, "Q3_SetViewEntity: can't find ViewEntity: '%s'\n", name ); @@ -3298,9 +3298,9 @@ void Q3_SetViewEntity(int entID, const char *name) /* ============ -Q3_SetWeapon - Description : - Return type : static void +Q3_SetWeapon + Description : + Return type : static void Argument : int entID Argument : const char *wp_name ============ @@ -3319,7 +3319,7 @@ static void Q3_SetWeapon (int entID, const char *wp_name) Q3_DebugPrint( WL_WARNING, "Q3_SetWeapon: invalid entID %d\n", entID); return; } - + if ( !self->client ) { Q3_DebugPrint( WL_ERROR, "Q3_SetWeapon: '%s' is not a player/NPC!\n", self->targetname ); @@ -3403,9 +3403,9 @@ static void Q3_SetWeapon (int entID, const char *wp_name) /* ============ -Q3_SetItem - Description : - Return type : static void +Q3_SetItem + Description : + Return type : static void Argument : int entID Argument : const char *wp_name ============ @@ -3420,7 +3420,7 @@ static void Q3_SetItem (int entID, const char *item_name) Q3_DebugPrint( WL_WARNING, "Q3_SetWeapon: invalid entID %d\n", entID); return; } - + if ( !self->client ) { Q3_DebugPrint( WL_ERROR, "Q3_SetWeapon: '%s' is not a player/NPC!\n", self->targetname ); @@ -3429,7 +3429,7 @@ static void Q3_SetItem (int entID, const char *item_name) inv = GetIDForString( INVTable, item_name ); - + gitem_t *item = FindItemForInventory(inv); RegisterItem( item ); //make sure the item is cached in case this runs at startup @@ -3442,7 +3442,7 @@ static void Q3_SetItem (int entID, const char *item_name) { self->client->ps.inventory[inv] = 1; return; - } + } // else Bacta, seeker, sentry if( self->client->ps.inventory[inv] < 5 ) { @@ -3454,9 +3454,9 @@ static void Q3_SetItem (int entID, const char *item_name) /* ============ -Q3_SetWalkSpeed - Description : - Return type : static void +Q3_SetWalkSpeed + Description : + Return type : static void Argument : int entID Argument : int int_data ============ @@ -3470,7 +3470,7 @@ static void Q3_SetWalkSpeed (int entID, int int_data) Q3_DebugPrint( WL_WARNING, "Q3_SetWalkSpeed: invalid entID %d\n", entID); return; } - + if ( !self->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetWalkSpeed: '%s' is not an NPC!\n", self->targetname ); @@ -3488,9 +3488,9 @@ static void Q3_SetWalkSpeed (int entID, int int_data) /* ============ -Q3_SetRunSpeed - Description : - Return type : static void +Q3_SetRunSpeed + Description : + Return type : static void Argument : int entID Argument : int int_data ============ @@ -3504,7 +3504,7 @@ static void Q3_SetRunSpeed (int entID, int int_data) Q3_DebugPrint( WL_WARNING, "Q3_SetRunSpeed: invalid entID %d\n", entID); return; } - + if ( !self->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetRunSpeed: '%s' is not an NPC!\n", self->targetname ); @@ -3522,9 +3522,9 @@ static void Q3_SetRunSpeed (int entID, int int_data) /* ============ -Q3_SetYawSpeed - Description : - Return type : static void +Q3_SetYawSpeed + Description : + Return type : static void Argument : int entID Argument : float float_data ============ @@ -3538,7 +3538,7 @@ static void Q3_SetYawSpeed (int entID, float float_data) Q3_DebugPrint( WL_WARNING, "Q3_SetYawSpeed: invalid entID %d\n", entID); return; } - + if ( !self->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetYawSpeed: '%s' is not an NPC!\n", self->targetname ); @@ -3552,8 +3552,8 @@ static void Q3_SetYawSpeed (int entID, float float_data) /* ============ Q3_SetAggression - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int int_data ============ @@ -3568,7 +3568,7 @@ static void Q3_SetAggression(int entID, int int_data) Q3_DebugPrint( WL_WARNING, "Q3_SetAggression: invalid entID %d\n", entID); return; } - + if ( !self->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetAggression: '%s' is not an NPC!\n", self->targetname ); @@ -3585,8 +3585,8 @@ static void Q3_SetAggression(int entID, int int_data) /* ============ Q3_SetAim - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int int_data ============ @@ -3600,7 +3600,7 @@ static void Q3_SetAim(int entID, int int_data) Q3_DebugPrint( WL_WARNING, "Q3_SetAim: invalid entID %d\n", entID); return; } - + if ( !self->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetAim: '%s' is not an NPC!\n", self->targetname ); @@ -3617,8 +3617,8 @@ static void Q3_SetAim(int entID, int int_data) /* ============ Q3_SetFriction - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int int_data ============ @@ -3632,7 +3632,7 @@ static void Q3_SetFriction(int entID, int int_data) Q3_DebugPrint( WL_WARNING, "Q3_SetFriction: invalid entID %d\n", entID); return; } - + if ( !self->client ) { Q3_DebugPrint( WL_ERROR, "Q3_SetFriction: '%s' is not an NPC/player!\n", self->targetname ); @@ -3646,8 +3646,8 @@ static void Q3_SetFriction(int entID, int int_data) /* ============ Q3_SetGravity - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float float_data ============ @@ -3661,7 +3661,7 @@ static void Q3_SetGravity(int entID, float float_data) Q3_DebugPrint( WL_WARNING, "Q3_SetGravity: invalid entID %d\n", entID); return; } - + if ( !self->client ) { Q3_DebugPrint( WL_ERROR, "Q3_SetGravity: '%s' is not an NPC/player!\n", self->targetname ); @@ -3677,8 +3677,8 @@ static void Q3_SetGravity(int entID, float float_data) /* ============ Q3_SetWait - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float float_data ============ @@ -3692,7 +3692,7 @@ static void Q3_SetWait(int entID, float float_data) Q3_DebugPrint( WL_WARNING, "Q3_SetWait: invalid entID %d\n", entID); return; } - + self->wait = float_data; } @@ -3706,7 +3706,7 @@ static void Q3_SetShotSpacing(int entID, int int_data) Q3_DebugPrint( WL_WARNING, "Q3_SetShotSpacing: invalid entID %d\n", entID); return; } - + if ( !self->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetShotSpacing: '%s' is not an NPC!\n", self->targetname ); @@ -3720,8 +3720,8 @@ static void Q3_SetShotSpacing(int entID, int int_data) /* ============ Q3_SetFollowDist - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float float_data ============ @@ -3735,7 +3735,7 @@ static void Q3_SetFollowDist(int entID, float float_data) Q3_DebugPrint( WL_WARNING, "Q3_SetFollowDist: invalid entID %d\n", entID); return; } - + if ( !self->client || !self->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetFollowDist: '%s' is not an NPC!\n", self->targetname ); @@ -3749,8 +3749,8 @@ static void Q3_SetFollowDist(int entID, float float_data) /* ============ Q3_SetScale - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float float_data ============ @@ -3764,7 +3764,7 @@ static void Q3_SetScale(int entID, float float_data) Q3_DebugPrint( WL_WARNING, "Q3_SetScale: invalid entID %d\n", entID); return; } - + self->s.scale = float_data; } @@ -3772,8 +3772,8 @@ static void Q3_SetScale(int entID, float float_data) /* ============ Q3_SetCount - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : const char *data ============ @@ -3789,7 +3789,7 @@ static void Q3_SetCount(int entID, const char *data) Q3_DebugPrint( WL_WARNING, "Q3_SetCount: invalid entID %d\n", entID); return; } - + if ( (val = Q3_CheckStringCounterIncrement( data )) ) { self->count += (int)(val); @@ -3803,9 +3803,9 @@ static void Q3_SetCount(int entID, const char *data) /* ============ -Q3_SetSquadName - Description : - Return type : static void +Q3_SetSquadName + Description : + Return type : static void Argument : int entID Argument : const char *squadname ============ @@ -3820,7 +3820,7 @@ static void Q3_SetSquadName (int entID, const char *squadname) Q3_DebugPrint( WL_WARNING, "Q3_SetSquadName: invalid entID %d\n", entID); return; } - + if ( !self->client ) { Q3_DebugPrint( WL_ERROR, "Q3_SetSquadName: '%s' is not an NPC/player!\n", self->targetname ); @@ -3840,9 +3840,9 @@ static void Q3_SetSquadName (int entID, const char *squadname) /* ============ -Q3_SetTargetName - Description : - Return type : static void +Q3_SetTargetName + Description : + Return type : static void Argument : int entID Argument : const char *targetname ============ @@ -3877,9 +3877,9 @@ static void Q3_SetTargetName (int entID, const char *targetname) /* ============ -Q3_SetTarget - Description : - Return type : static void +Q3_SetTarget + Description : + Return type : static void Argument : int entID Argument : const char *target ============ @@ -3907,8 +3907,8 @@ static void Q3_SetTarget (int entID, const char *target) /* ============ Q3_SetTarget2 - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : const char *target ============ @@ -3934,9 +3934,9 @@ static void Q3_SetTarget2 (int entID, const char *target2) } /* ============ -Q3_SetRemoveTarget - Description : - Return type : static void +Q3_SetRemoveTarget + Description : + Return type : static void Argument : int entID Argument : const char *target ============ @@ -3970,9 +3970,9 @@ static void Q3_SetRemoveTarget (int entID, const char *target) /* ============ -Q3_SetPainTarget - Description : - Return type : void +Q3_SetPainTarget + Description : + Return type : void Argument : int entID Argument : const char *targetname ============ @@ -3999,9 +3999,9 @@ static void Q3_SetPainTarget (int entID, const char *targetname) /* ============ -Q3_SetFullName - Description : - Return type : static void +Q3_SetFullName + Description : + Return type : static void Argument : int entID Argument : const char *fullName ============ @@ -4098,8 +4098,8 @@ static void Q3_SetForcePowerLevel ( int entID, int forcePower, int forceLevel ) /* ============ Q3_SetParm - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : int parmNum Argument : const char *parmValue @@ -4165,13 +4165,13 @@ static void Q3_SetCaptureGoal( int entID, const char *name ) Q3_DebugPrint( WL_WARNING, "Q3_SetCaptureGoal: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetCaptureGoal: '%s' is not an NPC!\n", ent->targetname ); return; } - + //FIXME: Exception handle here if (goal == NULL) { @@ -4207,7 +4207,7 @@ static void Q3_SetEvent( int entID, const char *event_name ) Q3_DebugPrint( WL_WARNING, "Q3_SetEvent: invalid entID %d\n", entID); return; } - + event = GetIDForString( eventTable, event_name ); switch( event ) { @@ -4247,7 +4247,7 @@ Uses an entity static void Q3_Use( int entID, const char *target ) { gentity_t *ent = &g_entities[entID]; - + if ( !ent ) { Q3_DebugPrint( WL_WARNING, "Q3_Use: invalid entID %d\n", entID); @@ -4354,7 +4354,7 @@ static qboolean Q3_SetBehaviorSet( int entID, int toSet, const char *scriptname) { // gi.TagFree( ent->behaviorSet[bSet] ); } - + ent->behaviorSet[bSet] = G_NewString( (char *) scriptname ); //FIXME: This really isn't good... } @@ -4384,7 +4384,7 @@ static void Q3_SetDelayScriptTime(int entID, int delayTime) ent->delayScriptTime = level.time + delayTime; } - + /* ============ Q3_SetIgnorePain @@ -4401,7 +4401,7 @@ static void Q3_SetIgnorePain( int entID, qboolean data) Q3_DebugPrint( WL_WARNING, "Q3_SetIgnorePain: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetIgnorePain: '%s' is not an NPC!\n", ent->targetname ); @@ -4427,7 +4427,7 @@ static void Q3_SetIgnoreEnemies( int entID, qboolean data) Q3_DebugPrint( WL_WARNING, "Q3_SetIgnoreEnemies: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetIgnoreEnemies: '%s' is not an NPC!\n", ent->targetname ); @@ -4460,7 +4460,7 @@ static void Q3_SetIgnoreAlerts( int entID, qboolean data) Q3_DebugPrint( WL_WARNING, "Q3_SetIgnoreAlerts: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetIgnoreAlerts: '%s' is not an NPC!\n", ent->targetname ); @@ -4544,7 +4544,7 @@ static void Q3_SetDontFire( int entID, qboolean add) Q3_DebugPrint( WL_WARNING, "Q3_SetDontFire: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetDontFire: '%s' is not an NPC!\n", ent->targetname ); @@ -4577,7 +4577,7 @@ static void Q3_SetFireWeapon(int entID, qboolean add) Q3_DebugPrint( WL_WARNING, "Q3_FireWeapon: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetFireWeapon: '%s' is not an NPC!\n", ent->targetname ); @@ -4611,7 +4611,7 @@ static void Q3_SetInactive(int entID, qboolean add) Q3_DebugPrint( WL_WARNING, "Q3_SetInactive: invalid entID %d\n", entID); return; } - + if(add) { ent->svFlags |= SVF_INACTIVE; @@ -4638,7 +4638,7 @@ static void Q3_SetFuncUsableVisible(int entID, qboolean visible ) Q3_DebugPrint( WL_WARNING, "Q3_SetFuncUsableVisible: invalid entID %d\n", entID); return; } - + // Yeah, I know that this doesn't even do half of what the func_usable use code does, but if I've got two things on top of each other...and only // one is visible at a time....and neither can ever be used......and finally, the shader on it has the shader_anim stuff going on....It doesn't seem // like I can easily use the other version without nasty side effects. @@ -4676,7 +4676,7 @@ static void Q3_SetLockedEnemy ( int entID, qboolean locked) Q3_DebugPrint( WL_ERROR, "Q3_SetLockedEnemy: '%s' is not an NPC!\n", ent->targetname ); return; } - + //FIXME: make an NPCAI_FLAG if(locked) { @@ -4707,7 +4707,7 @@ static void Q3_SetCinematicSkipScript( char *scriptname ) { Q_strncpyz(cinematicSkipScript,scriptname,sizeof(cinematicSkipScript)); } - + } /* @@ -4879,7 +4879,7 @@ static void Q3_SetForcedMarch( int entID, qboolean add) ============ Q3_SetChaseEnemies -indicates whether the npc should chase after an enemy +indicates whether the npc should chase after an enemy ============ */ static void Q3_SetChaseEnemies( int entID, qboolean add) @@ -5423,7 +5423,7 @@ static void Q3_SetInvincible( int entID, qboolean invincible) } return; } - + if ( invincible ) { ent->flags |= FL_GODMODE; @@ -5436,8 +5436,8 @@ static void Q3_SetInvincible( int entID, qboolean invincible) /* ============ Q3_SetForceInvincible - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : qboolean forceInv ============ @@ -5451,7 +5451,7 @@ static void Q3_SetForceInvincible( int entID, qboolean forceInv ) Q3_DebugPrint( WL_WARNING, "Q3_SetForceInvincible: entID %d not a client\n", entID); return; } - + Q3_SetInvincible( entID, forceInv ); if ( forceInv ) { @@ -5499,8 +5499,8 @@ static void Q3_SetNoAvoid( int entID, qboolean noAvoid) /* ============ SolidifyOwner - Description : - Return type : void + Description : + Return type : void Argument : gentity_t *self ============ */ @@ -5542,7 +5542,7 @@ Q3_SetSolid static qboolean Q3_SetSolid( int entID, qboolean solid) { gentity_t *ent = &g_entities[entID]; - + if ( !ent ) { Q3_DebugPrint( WL_WARNING, "Q3_SetSolid: invalid entID %d\n", entID); @@ -5561,7 +5561,7 @@ static qboolean Q3_SetSolid( int entID, qboolean solid) solidifier->e_ThinkFunc = thinkF_SolidifyOwner; solidifier->nextthink = level.time + FRAMETIME; - + ent->contents = oldContents; return qfalse; } @@ -5713,7 +5713,7 @@ static void Q3_SetLockAngle( int entID, const char *lockAngle) { ent->client->renderInfo.renderFlags |= RF_LOCKEDANGLE; - + if(Q_stricmp("auto", lockAngle) == 0) {//use current yaw if( ent->NPC ) // I need this to work on NPCs, so their locked value @@ -5812,7 +5812,7 @@ static void Q3_AddRHandModel( int entID, char *addModel) if ( ent->cinematicModel != -1 ) { // attach it to the hand - gi.G2API_AttachG2Model(&ent->ghoul2[ent->cinematicModel], &ent->ghoul2[ent->playerModel], + gi.G2API_AttachG2Model(&ent->ghoul2[ent->cinematicModel], &ent->ghoul2[ent->playerModel], ent->handRBolt, ent->playerModel); } } @@ -5830,7 +5830,7 @@ static void Q3_AddLHandModel( int entID, char *addModel) if ( ent->cinematicModel != -1 ) { // attach it to the hand - gi.G2API_AttachG2Model(&ent->ghoul2[ent->cinematicModel], &ent->ghoul2[ent->playerModel], + gi.G2API_AttachG2Model(&ent->ghoul2[ent->cinematicModel], &ent->ghoul2[ent->playerModel], ent->handLBolt, ent->playerModel); } } @@ -5911,7 +5911,7 @@ static void Q3_Face( int entID,int expression, float holdtime) Q3_DebugPrint( WL_ERROR, "Q3_Face: '%s' is not an NPC/player!\n", ent->targetname ); return; } - + //FIXME: change to milliseconds to be consistant! holdtime *= 1000; @@ -5963,8 +5963,8 @@ static void Q3_Face( int entID,int expression, float holdtime) /* ============ Q3_SetPlayerUsable - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean usable ============ @@ -5992,8 +5992,8 @@ static void Q3_SetPlayerUsable( int entID, qboolean usable ) /* ============ Q3_SetDisableShaderAnims - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int disabled ============ @@ -6021,8 +6021,8 @@ static void Q3_SetDisableShaderAnims( int entID, int disabled ) /* ============ Q3_SetShaderAnim - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int disabled ============ @@ -6050,8 +6050,8 @@ static void Q3_SetShaderAnim( int entID, int disabled ) /* ============ Q3_SetStartFrame - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int startFrame ============ @@ -6083,8 +6083,8 @@ static void Q3_SetStartFrame( int entID, int startFrame ) /* ============ Q3_SetEndFrame - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int endFrame ============ @@ -6114,8 +6114,8 @@ static void Q3_SetEndFrame( int entID, int endFrame ) /* ============ Q3_SetAnimFrame - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int startFrame ============ @@ -6185,8 +6185,8 @@ void InflateOwner( gentity_t *self ) /* ============ Q3_SetLoopAnim - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean loopAnim ============ @@ -6214,8 +6214,8 @@ static void Q3_SetLoopAnim( int entID, qboolean loopAnim ) /* ============ Q3_SetShields - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean shields ============ @@ -6249,8 +6249,8 @@ static void Q3_SetShields( int entID, qboolean shields ) /* ============ Q3_SetSaberActive - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean shields ============ @@ -6283,8 +6283,8 @@ static void Q3_SetSaberActive( int entID, qboolean active ) /* ============ Q3_SetNoKnockback - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean noKnockback ============ @@ -6312,8 +6312,8 @@ static void Q3_SetNoKnockback( int entID, qboolean noKnockback ) /* ============ Q3_SetCleanDamagingEnts - Description : - Return type : void + Description : + Return type : void ============ */ static void Q3_SetCleanDamagingEnts( void ) @@ -6354,8 +6354,8 @@ static void Q3_SetCleanDamagingEnts( void ) /* ============ Q3_SetInterface - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : const char *data ============ @@ -6368,8 +6368,8 @@ static void Q3_SetInterface( int entID, const char *data ) /* ============ Q3_SetLocation - Description : - Return type : qboolean + Description : + Return type : qboolean Argument : int entID Argument : const char *location ============ @@ -6378,7 +6378,7 @@ static qboolean Q3_SetLocation( int entID, const char *location ) { gentity_t *ent = &g_entities[entID]; char *currentLoc; - + if ( !ent ) { return qtrue; @@ -6397,8 +6397,8 @@ static qboolean Q3_SetLocation( int entID, const char *location ) /* ============ Q3_SetPlayerLocked - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean locked ============ @@ -6418,8 +6418,8 @@ static void Q3_SetPlayerLocked( int entID, qboolean locked ) /* ============ Q3_SetLockPlayerWeapons - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean locked ============ @@ -6434,15 +6434,15 @@ static void Q3_SetLockPlayerWeapons( int entID, qboolean locked ) { ent->flags |= FL_LOCK_PLAYER_WEAPONS; } - + } /* ============ Q3_SetNoImpactDamage - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean locked ============ @@ -6457,7 +6457,7 @@ static void Q3_SetNoImpactDamage( int entID, qboolean noImp ) { ent->flags |= FL_NO_IMPACT_DMG; } - + } extern void CG_CameraAutoAim( const char *name ); @@ -6466,8 +6466,8 @@ extern void CG_CameraAutoTrack( const char *name ); /* ============ Q3_SetVar - Description : - Return type : static void + Description : + Return type : static void Argument : int taskID Argument : int entID Argument : const char *type_name @@ -6480,7 +6480,7 @@ void Q3_SetVar( int taskID, int entID, const char *type_name, const char *data ) float float_data; float val = 0.0f; - + if ( vret != VTYPE_NONE ) { switch ( vret ) @@ -6518,8 +6518,8 @@ void Q3_SetVar( int taskID, int entID, const char *type_name, const char *data ) /* ============ Q3_Set - Description : - Return type : void + Description : + Return type : void Argument : int taskID Argument : int entID Argument : const char *type_name @@ -6580,7 +6580,7 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da float_data = atof((char *) data); Q3_SetVelocity( entID, 0, float_data); break; - + case SET_YVELOCITY: float_data = atof((char *) data); Q3_SetVelocity( entID, 1, float_data); @@ -6659,7 +6659,7 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da } } break; - + case SET_ANIM_HOLDTIME_LOWER: int_data = atoi((char *) data); Q3_SetAnimHoldTime( entID, int_data, qtrue ); @@ -6862,14 +6862,14 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da else if(!Q_stricmp("false", ((char *)data))) Q3_SetIgnoreAlerts( entID, qfalse); break; - + case SET_DONTSHOOT: if(!Q_stricmp("true", ((char *)data))) Q3_SetDontShoot( entID, qtrue); else if(!Q_stricmp("false", ((char *)data))) Q3_SetDontShoot( entID, qfalse); break; - + case SET_DONTFIRE: if(!Q_stricmp("true", ((char *)data))) Q3_SetDontFire( entID, qtrue); @@ -6913,17 +6913,17 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da float_data = atof((char *) data); Q3_SetVisrange( entID, float_data ); break; - + case SET_EARSHOT: float_data = atof((char *) data); Q3_SetEarshot( entID, float_data ); break; - + case SET_VIGILANCE: float_data = atof((char *) data); Q3_SetVigilance( entID, float_data ); break; - + case SET_VFOV: int_data = atoi((char *) data); Q3_SetVFOV( entID, int_data ); @@ -6945,7 +6945,7 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da case SET_TARGET2: Q3_SetTarget2( entID, (char *) data ); break; - + case SET_LOCATION: if ( !Q3_SetLocation( entID, (char *) data ) ) { @@ -7026,128 +7026,128 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da case SET_WALKING: if(!Q_stricmp("true", ((char *)data))) - Q3_SetWalking( entID, qtrue); + Q3_SetWalking( entID, qtrue); else - Q3_SetWalking( entID, qfalse); + Q3_SetWalking( entID, qfalse); break; case SET_RUNNING: if(!Q_stricmp("true", ((char *)data))) - Q3_SetRunning( entID, qtrue); + Q3_SetRunning( entID, qtrue); else - Q3_SetRunning( entID, qfalse); + Q3_SetRunning( entID, qfalse); break; case SET_CHASE_ENEMIES: if(!Q_stricmp("true", ((char *)data))) - Q3_SetChaseEnemies( entID, qtrue); + Q3_SetChaseEnemies( entID, qtrue); else - Q3_SetChaseEnemies( entID, qfalse); + Q3_SetChaseEnemies( entID, qfalse); break; case SET_LOOK_FOR_ENEMIES: if(!Q_stricmp("true", ((char *)data))) - Q3_SetLookForEnemies( entID, qtrue); + Q3_SetLookForEnemies( entID, qtrue); else - Q3_SetLookForEnemies( entID, qfalse); + Q3_SetLookForEnemies( entID, qfalse); break; case SET_FACE_MOVE_DIR: if(!Q_stricmp("true", ((char *)data))) - Q3_SetFaceMoveDir( entID, qtrue); + Q3_SetFaceMoveDir( entID, qtrue); else - Q3_SetFaceMoveDir( entID, qfalse); + Q3_SetFaceMoveDir( entID, qfalse); break; case SET_ALT_FIRE: if(!Q_stricmp("true", ((char *)data))) - Q3_SetAltFire( entID, qtrue); + Q3_SetAltFire( entID, qtrue); else - Q3_SetAltFire( entID, qfalse); + Q3_SetAltFire( entID, qfalse); break; case SET_DONT_FLEE: if(!Q_stricmp("true", ((char *)data))) - Q3_SetDontFlee( entID, qtrue); + Q3_SetDontFlee( entID, qtrue); else - Q3_SetDontFlee( entID, qfalse); + Q3_SetDontFlee( entID, qfalse); break; case SET_FORCED_MARCH: if(!Q_stricmp("true", ((char *)data))) - Q3_SetForcedMarch( entID, qtrue); + Q3_SetForcedMarch( entID, qtrue); else - Q3_SetForcedMarch( entID, qfalse); + Q3_SetForcedMarch( entID, qfalse); break; case SET_NO_RESPONSE: if(!Q_stricmp("true", ((char *)data))) - Q3_SetNoResponse( entID, qtrue); + Q3_SetNoResponse( entID, qtrue); else - Q3_SetNoResponse( entID, qfalse); + Q3_SetNoResponse( entID, qfalse); break; case SET_NO_COMBAT_TALK: if(!Q_stricmp("true", ((char *)data))) - Q3_SetCombatTalk( entID, qtrue); + Q3_SetCombatTalk( entID, qtrue); else - Q3_SetCombatTalk( entID, qfalse); + Q3_SetCombatTalk( entID, qfalse); break; case SET_NO_ALERT_TALK: if(!Q_stricmp("true", ((char *)data))) - Q3_SetAlertTalk( entID, qtrue); + Q3_SetAlertTalk( entID, qtrue); else - Q3_SetAlertTalk( entID, qfalse); + Q3_SetAlertTalk( entID, qfalse); break; case SET_USE_CP_NEAREST: if(!Q_stricmp("true", ((char *)data))) - Q3_SetUseCpNearest( entID, qtrue); + Q3_SetUseCpNearest( entID, qtrue); else - Q3_SetUseCpNearest( entID, qfalse); + Q3_SetUseCpNearest( entID, qfalse); break; case SET_NO_FORCE: if(!Q_stricmp("true", ((char *)data))) - Q3_SetNoForce( entID, qtrue); + Q3_SetNoForce( entID, qtrue); else - Q3_SetNoForce( entID, qfalse); + Q3_SetNoForce( entID, qfalse); break; case SET_NO_ACROBATICS: if(!Q_stricmp("true", ((char *)data))) - Q3_SetNoAcrobatics( entID, qtrue); + Q3_SetNoAcrobatics( entID, qtrue); else - Q3_SetNoAcrobatics( entID, qfalse); + Q3_SetNoAcrobatics( entID, qfalse); break; case SET_USE_SUBTITLES: if(!Q_stricmp("true", ((char *)data))) - Q3_SetUseSubtitles( entID, qtrue); + Q3_SetUseSubtitles( entID, qtrue); else - Q3_SetUseSubtitles( entID, qfalse); + Q3_SetUseSubtitles( entID, qfalse); break; case SET_NO_FALLTODEATH: if(!Q_stricmp("true", ((char *)data))) - Q3_SetNoFallToDeath( entID, qtrue); + Q3_SetNoFallToDeath( entID, qtrue); else - Q3_SetNoFallToDeath( entID, qfalse); + Q3_SetNoFallToDeath( entID, qfalse); break; case SET_DISMEMBERABLE: if(!Q_stricmp("true", ((char *)data))) - Q3_SetDismemberable( entID, qtrue); + Q3_SetDismemberable( entID, qtrue); else - Q3_SetDismemberable( entID, qfalse); + Q3_SetDismemberable( entID, qfalse); break; case SET_MORELIGHT: if(!Q_stricmp("true", ((char *)data))) - Q3_SetMoreLight( entID, qtrue); + Q3_SetMoreLight( entID, qtrue); else - Q3_SetMoreLight( entID, qfalse); + Q3_SetMoreLight( entID, qfalse); break; @@ -7161,23 +7161,23 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da case SET_UNDYING: if(!Q_stricmp("true", ((char *)data))) - Q3_SetUndying( entID, qtrue); + Q3_SetUndying( entID, qtrue); else - Q3_SetUndying( entID, qfalse); + Q3_SetUndying( entID, qfalse); break; case SET_INVINCIBLE: if(!Q_stricmp("true", ((char *)data))) - Q3_SetInvincible( entID, qtrue); + Q3_SetInvincible( entID, qtrue); else - Q3_SetInvincible( entID, qfalse); + Q3_SetInvincible( entID, qfalse); break; case SET_NOAVOID: if(!Q_stricmp("true", ((char *)data))) - Q3_SetNoAvoid( entID, qtrue); + Q3_SetNoAvoid( entID, qtrue); else - Q3_SetNoAvoid( entID, qfalse); + Q3_SetNoAvoid( entID, qfalse); break; case SET_SOLID: @@ -7229,7 +7229,7 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da else Q3_SetPlayerLocked( entID, qfalse ); break; - + case SET_LOCK_PLAYER_WEAPONS: if( !Q_stricmp("true", ((char *)data)) ) Q3_SetLockPlayerWeapons( entID, qtrue ); @@ -7246,18 +7246,18 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da case SET_FORWARDMOVE: int_data = atoi((char *) data); - Q3_SetForwardMove( entID, int_data); + Q3_SetForwardMove( entID, int_data); break; case SET_RIGHTMOVE: int_data = atoi((char *) data); - Q3_SetRightMove( entID, int_data); + Q3_SetRightMove( entID, int_data); break; case SET_LOCKYAW: - Q3_SetLockAngle( entID, data); + Q3_SetLockAngle( entID, data); break; - + case SET_CAMERA_GROUP: Q3_CameraGroup(entID, (char *)data); break; @@ -7302,21 +7302,21 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da break; case SET_SCROLLTEXT: - Q3_ScrollText( (char *)data ); + Q3_ScrollText( (char *)data ); break; case SET_LCARSTEXT: - Q3_LCARSText( (char *)data ); + Q3_LCARSText( (char *)data ); break; case SET_CAPTIONTEXTCOLOR: - Q3_SetCaptionTextColor ( (char *)data ); + Q3_SetCaptionTextColor ( (char *)data ); break; case SET_CENTERTEXTCOLOR: - Q3_SetCenterTextColor ( (char *)data ); + Q3_SetCenterTextColor ( (char *)data ); break; case SET_SCROLLTEXTCOLOR: - Q3_SetScrollTextColor ( (char *)data ); + Q3_SetScrollTextColor ( (char *)data ); break; case SET_PLAYER_USABLE: @@ -7334,7 +7334,7 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da int_data = atoi((char *) data); Q3_SetStartFrame(entID, int_data); break; - + case SET_ENDFRAME: int_data = atoi((char *) data); Q3_SetEndFrame(entID, int_data); @@ -7348,7 +7348,7 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da Q3_SetAnimFrame(entID, int_data); return; break; - + case SET_LOOP_ANIM: if(!Q_stricmp("true", ((char *)data))) { @@ -7382,7 +7382,7 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da Q3_SetShields(entID, qfalse); } break; - + case SET_SABERACTIVE: if(!Q_stricmp("true", ((char *)data))) { @@ -7404,7 +7404,7 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da Q3_SetAdjustAreaPortals( entID, qfalse ); } break; - + case SET_DMG_BY_HEAVY_WEAP_ONLY: if(!Q_stricmp("true", ((char *)data))) { @@ -7546,7 +7546,7 @@ extern void LockDoors(gentity_t *const ent); case SET_OBJECTIVE_SHOW: missionInfo_Updated = qtrue; // Activate flashing text - gi.cvar_set("cg_updatedDataPadObjective", "1"); + gi.cvar_set("cg_updatedDataPadObjective", "1"); Q3_SetObjective((const char *) data ,SET_OBJ_SHOW); Q3_SetObjective((const char *) data ,SET_OBJ_PENDING); @@ -7556,7 +7556,7 @@ extern void LockDoors(gentity_t *const ent); break; case SET_OBJECTIVE_SUCCEEDED: missionInfo_Updated = qtrue; // Activate flashing text - gi.cvar_set("cg_updatedDataPadObjective", "1"); + gi.cvar_set("cg_updatedDataPadObjective", "1"); Q3_SetObjective((const char *) data ,SET_OBJ_SUCCEEDED); break; case SET_OBJECTIVE_FAILED: @@ -7574,7 +7574,7 @@ extern void LockDoors(gentity_t *const ent); case SET_MISSIONSTATUSTEXT: Q3_SetStatusText((const char *) data); break; - + case SET_MISSIONSTATUSTIME: int_data = atoi((char *) data); cg.missionStatusDeadTime = level.time + int_data; @@ -7647,7 +7647,7 @@ extern void LockDoors(gentity_t *const ent); int_data = atoi((char *) data); Q3_SetForcePowerLevel( entID, (toSet-SET_FORCE_HEAL_LEVEL), int_data ); break; - + default: //Q3_DebugPrint( WL_ERROR, "Q3_Set: '%s' is not a valid set field\n", type_name ); Q3_SetVar( taskID, entID, type_name, data ); @@ -7662,8 +7662,8 @@ extern void LockDoors(gentity_t *const ent); /* ============ Q3_Kill - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : const char *name ============ @@ -7722,8 +7722,8 @@ static void Q3_Kill( int entID, const char *name ) /* ============ Q3_RemoveEnt - Description : - Return type : void + Description : + Return type : void Argument : gentity_t *victim ============ */ @@ -7769,8 +7769,8 @@ static void Q3_RemoveEnt( gentity_t *victim ) /* ============ Q3_Remove - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : const char *name ============ @@ -7820,8 +7820,8 @@ static void Q3_Remove( int entID, const char *name ) /* ============ MakeOwnerInvis - Description : - Return type : void + Description : + Return type : void Argument : gentity_t *self ============ */ @@ -7841,8 +7841,8 @@ void MakeOwnerInvis(gentity_t *self) /* ============ MakeOwnerEnergy - Description : - Return type : void + Description : + Return type : void Argument : gentity_t *self ============ */ @@ -7859,8 +7859,8 @@ void MakeOwnerEnergy(gentity_t *self) /* ============ RemoveOwner - Description : - Return type : void + Description : + Return type : void Argument : gentity_t *self ============ */ @@ -7885,8 +7885,8 @@ void RemoveOwner (gentity_t *self) /* ============ Q3_GetFloat - Description : - Return type : int + Description : + Return type : int Argument : int entID Argument : int type Argument : const char *name @@ -7938,7 +7938,7 @@ static int Q3_GetFloat( int entID, int type, const char *name, float *value ) } *value = atof( ent->parms->parm[toGet - SET_PARM1] ); break; - + case SET_COUNT: *value = ent->count; break; @@ -8513,8 +8513,8 @@ static int Q3_GetFloat( int entID, int type, const char *name, float *value ) /* ============ Q3_GetVector - Description : - Return type : int + Description : + Return type : int Argument : int entID Argument : int type Argument : const char *name @@ -8561,7 +8561,7 @@ static int Q3_GetVector( int entID, int type, const char *name, vec3_t value ) case SET_ANGLES: VectorCopy(ent->currentAngles, value); break; - + case SET_TELEPORT_DEST://## %v="0.0 0.0 0.0" # Set origin here as soon as the area is clear Q3_DebugPrint( WL_WARNING, "Q3_GetVector: SET_TELEPORT_DEST not implemented\n" ); return false; @@ -8581,8 +8581,8 @@ static int Q3_GetVector( int entID, int type, const char *name, vec3_t value ) /* ============ Q3_GetString - Description : - Return type : int + Description : + Return type : int Argument : int entID Argument : int type Argument : const char *name @@ -8881,8 +8881,8 @@ static int Q3_GetString( int entID, int type, const char *name, char **value ) /* ============ Q3_Evaluate - Description : - Return type : int + Description : + Return type : int Argument : int p1Type Argument : const char *p1 Argument : int p2Type @@ -9078,7 +9078,7 @@ static int Q3_Evaluate( int p1Type, const char *p1, int p2Type, const char *p2, } break; - + default: Q3_DebugPrint( WL_ERROR, "Q3_Evaluate unknown operator used!\n"); break; @@ -9143,11 +9143,11 @@ void Q3_DebugPrint( int level, const char *format, ... ) case WL_ERROR: Com_Printf ( S_COLOR_RED"ERROR: %s", text ); break; - + case WL_WARNING: Com_Printf ( S_COLOR_YELLOW"WARNING: %s", text ); break; - + case WL_DEBUG: { int entNum; @@ -9202,7 +9202,7 @@ static void Q3_Play( int taskID, int entID, const char *type, const char *name ) // These need to be initialised up front... VectorCopy( ent->currentOrigin, ent->pos1 ); VectorCopy( ent->currentAngles, ent->pos2 ); - + gi.linkentity( ent ); } } @@ -9212,7 +9212,7 @@ static void Q3_Play( int taskID, int entID, const char *type, const char *name ) ============ Interface_Init Description : Inits the interface for the game - Return type : void + Return type : void Argument : interface_export_t *pe ============ */ @@ -9233,7 +9233,7 @@ void Interface_Init( interface_export_t *pe ) pe->I_Lerp2Angles = Q3_Lerp2Angles; pe->I_GetTag = Q3_GetTag; pe->I_Lerp2Start = Q3_Lerp2Start; - pe->I_Lerp2End = Q3_Lerp2End; + pe->I_Lerp2End = Q3_Lerp2End; pe->I_Use = Q3_Use; pe->I_Kill = Q3_Kill; pe->I_Remove = Q3_Remove; diff --git a/codeJK2/game/Q3_Interface.h b/codeJK2/game/Q3_Interface.h index ecff2f7bdb..9420cd94e4 100644 --- a/codeJK2/game/Q3_Interface.h +++ b/codeJK2/game/Q3_Interface.h @@ -47,7 +47,7 @@ typedef enum //# setType_e SET_PARM15,//## %s="" # Set entity parm15 SET_PARM16,//## %s="" # Set entity parm16 - // NOTE!!! If you add any other SET_xxxxxxSCRIPT types, make sure you update the 'case' statements in + // NOTE!!! If you add any other SET_xxxxxxSCRIPT types, make sure you update the 'case' statements in // ICARUS_InterrogateScript() (game/g_ICARUS.cpp), or the script-precacher won't find them. //# #sep Scripts and other file paths @@ -67,7 +67,7 @@ typedef enum //# setType_e SET_FFDEATHSCRIPT,//## %s="NULL" !!"W:\game\base\scripts\!!#*.txt" # Script to run when player kills a teammate SET_MINDTRICKSCRIPT,//## %s="NULL" !!"W:\game\base\scripts\!!#*.txt" # Script to run when player kills a teammate SET_VIDEO_PLAY,//## %s="filename" !!"W:\game\base\video\!!#*.roq" # Play a video (inGame) - SET_CINEMATIC_SKIPSCRIPT, //## %s="filename" !!"W:\game\base\scripts\!!#*.txt" # Script to run when skipping the running cinematic + SET_CINEMATIC_SKIPSCRIPT, //## %s="filename" !!"W:\game\base\scripts\!!#*.txt" # Script to run when skipping the running cinematic //# #sep Standard strings SET_ENEMY,//## %s="NULL" # Set enemy by targetname @@ -109,7 +109,7 @@ typedef enum //# setType_e SET_ORIGIN,//## %v="0.0 0.0 0.0" # Set origin explicitly or with TAG SET_ANGLES,//## %v="0.0 0.0 0.0" # Set angles explicitly or with TAG SET_TELEPORT_DEST,//## %v="0.0 0.0 0.0" # Set origin here as soon as the area is clear - + //# #sep floats SET_XVELOCITY,//## %f="0.0" # Velocity along X axis SET_YVELOCITY,//## %f="0.0" # Velocity along Y axis @@ -264,7 +264,7 @@ typedef enum //# setType_e SET_TACTICAL_HIDE, //## %t="TACTICAL" # Hide tactical info on mission objectives screen SET_OBJECTIVE_CLEARALL, //## # Force all objectives to be hidden /* - SET_OBJECTIVEFOSTER, + SET_OBJECTIVEFOSTER, */ SET_MISSIONSTATUSTEXT, //## %t="STATUSTEXT" # Text to appear in mission status screen SET_MENU_SCREEN,//## %t="MENUSCREENS" # Brings up specified menu screen @@ -276,7 +276,7 @@ typedef enum //# setType_e //# #eol SET_ -} setType_t; +} setType_t; // this enum isn't used directly by the game, it's mainly for BehavEd to scan for... diff --git a/codeJK2/game/Q3_Registers.cpp b/codeJK2/game/Q3_Registers.cpp index f278c09085..3685161a04 100644 --- a/codeJK2/game/Q3_Registers.cpp +++ b/codeJK2/game/Q3_Registers.cpp @@ -87,7 +87,7 @@ void Q3_DeclareVariable( int type, const char *name ) varFloats[ name ] = 0.0f; break; - case TK_STRING: + case TK_STRING: varStrings[ name ] = "NULL"; break; @@ -238,7 +238,7 @@ int Q3_SetFloatVariable( const char *name, float value ) return VTYPE_FLOAT; (*vfi).second = value; - + return true; } @@ -302,7 +302,7 @@ void Q3_VariableSaveFloats( varFloat_m &fmap ) { //Save out the map id int idSize = strlen( ((*vfi).first).c_str() ); - + //Save out the real data saved_game.write_chunk( INT_ID('F', 'I', 'D', 'L'), @@ -342,7 +342,7 @@ void Q3_VariableSaveStrings( varString_m &smap ) { //Save out the map id int idSize = strlen( ((*vsi).first).c_str() ); - + //Save out the real data saved_game.write_chunk( INT_ID('S', 'I', 'D', 'L'), @@ -403,7 +403,7 @@ void Q3_VariableLoadFloats( varFloat_m &fmap ) for ( int i = 0; i < numFloats; i++ ) { int idSize = 0; - + saved_game.read_chunk( INT_ID('F', 'I', 'D', 'L'), idSize); @@ -453,7 +453,7 @@ void Q3_VariableLoadStrings( int type, varString_m &fmap ) for ( int i = 0; i < numFloats; i++ ) { int idSize = 0; - + saved_game.read_chunk( INT_ID('S', 'I', 'D', 'L'), idSize); diff --git a/codeJK2/game/anims.h b/codeJK2/game/anims.h index cb479b89f2..028e71c32a 100644 --- a/codeJK2/game/anims.h +++ b/codeJK2/game/anims.h @@ -39,24 +39,24 @@ typedef enum //# animNumber_e BOTH_DEATH5, //# Fifth Death anim BOTH_DEATH6, //# Sixth Death anim BOTH_DEATH7, //# Seventh Death anim - BOTH_DEATH8, //# - BOTH_DEATH9, //# - BOTH_DEATH10, //# + BOTH_DEATH8, //# + BOTH_DEATH9, //# + BOTH_DEATH10, //# BOTH_DEATH11, //# - BOTH_DEATH12, //# - BOTH_DEATH13, //# - BOTH_DEATH14, //# - BOTH_DEATH15, //# - BOTH_DEATH16, //# - BOTH_DEATH17, //# - BOTH_DEATH18, //# - BOTH_DEATH19, //# - BOTH_DEATH20, //# - BOTH_DEATH21, //# - BOTH_DEATH22, //# - BOTH_DEATH23, //# - BOTH_DEATH24, //# - BOTH_DEATH25, //# + BOTH_DEATH12, //# + BOTH_DEATH13, //# + BOTH_DEATH14, //# + BOTH_DEATH15, //# + BOTH_DEATH16, //# + BOTH_DEATH17, //# + BOTH_DEATH18, //# + BOTH_DEATH19, //# + BOTH_DEATH20, //# + BOTH_DEATH21, //# + BOTH_DEATH22, //# + BOTH_DEATH23, //# + BOTH_DEATH24, //# + BOTH_DEATH25, //# BOTH_DEATHFORWARD1, //# First Death in which they get thrown forward BOTH_DEATHFORWARD2, //# Second Death in which they get thrown forward @@ -88,24 +88,24 @@ typedef enum //# animNumber_e BOTH_DEAD5, //# Fifth Death finished pose BOTH_DEAD6, //# Sixth Death finished pose BOTH_DEAD7, //# Seventh Death finished pose - BOTH_DEAD8, //# - BOTH_DEAD9, //# - BOTH_DEAD10, //# + BOTH_DEAD8, //# + BOTH_DEAD9, //# + BOTH_DEAD10, //# BOTH_DEAD11, //# - BOTH_DEAD12, //# - BOTH_DEAD13, //# - BOTH_DEAD14, //# - BOTH_DEAD15, //# - BOTH_DEAD16, //# - BOTH_DEAD17, //# - BOTH_DEAD18, //# - BOTH_DEAD19, //# - BOTH_DEAD20, //# - BOTH_DEAD21, //# - BOTH_DEAD22, //# - BOTH_DEAD23, //# - BOTH_DEAD24, //# - BOTH_DEAD25, //# + BOTH_DEAD12, //# + BOTH_DEAD13, //# + BOTH_DEAD14, //# + BOTH_DEAD15, //# + BOTH_DEAD16, //# + BOTH_DEAD17, //# + BOTH_DEAD18, //# + BOTH_DEAD19, //# + BOTH_DEAD20, //# + BOTH_DEAD21, //# + BOTH_DEAD22, //# + BOTH_DEAD23, //# + BOTH_DEAD24, //# + BOTH_DEAD25, //# BOTH_DEADFORWARD1, //# First thrown forward death finished pose BOTH_DEADFORWARD2, //# Second thrown forward death finished pose BOTH_DEADBACKWARD1, //# First thrown backward death finished pose @@ -118,7 +118,7 @@ typedef enum //# animNumber_e BOTH_DEADFLOP2, //# React to being shot from Second Death finished pose BOTH_DEADFLOP3, //# React to being shot from Third Death finished pose BOTH_DEADFLOP4, //# React to being shot from Fourth Death finished pose - BOTH_DEADFLOP5, //# React to being shot from Fifth Death finished pose + BOTH_DEADFLOP5, //# React to being shot from Fifth Death finished pose BOTH_DEADFORWARD1_FLOP, //# React to being shot First thrown forward death finished pose BOTH_DEADFORWARD2_FLOP, //# React to being shot Second thrown forward death finished pose BOTH_DEADBACKWARD1_FLOP, //# React to being shot First thrown backward death finished pose @@ -141,17 +141,17 @@ typedef enum //# animNumber_e BOTH_PAIN6, //# Sixth take pain anim - from behind BOTH_PAIN7, //# Seventh take pain anim - from behind BOTH_PAIN8, //# Eigth take pain anim - from behind - BOTH_PAIN9, //# - BOTH_PAIN10, //# - BOTH_PAIN11, //# - BOTH_PAIN12, //# - BOTH_PAIN13, //# - BOTH_PAIN14, //# - BOTH_PAIN15, //# - BOTH_PAIN16, //# - BOTH_PAIN17, //# - BOTH_PAIN18, //# - BOTH_PAIN19, //# + BOTH_PAIN9, //# + BOTH_PAIN10, //# + BOTH_PAIN11, //# + BOTH_PAIN12, //# + BOTH_PAIN13, //# + BOTH_PAIN14, //# + BOTH_PAIN15, //# + BOTH_PAIN16, //# + BOTH_PAIN17, //# + BOTH_PAIN18, //# + BOTH_PAIN19, //# BOTH_PAIN20, //# GETTING SHOCKED //# #sep BOTH_ ATTACKS @@ -682,9 +682,9 @@ typedef enum //# animNumber_e BOTH_STAND5_REELO, //# Reelo in his stand5 position (cin #18) BOTH_STAND1TOSTAND5, //# Transition from stand1 to stand5 BOTH_STAND5TOSTAND1, //# Transition from stand5 to stand1 - BOTH_STAND5TOAIM, //# Transition of Kye aiming his gun at Desann (cin #9) - BOTH_STAND5STARTLEDLOOKLEFT, //# Kyle turning to watch the bridge drop (cin #9) - BOTH_STARTLEDLOOKLEFTTOSTAND5, //# Kyle returning to stand 5 from watching the bridge drop (cin #9) + BOTH_STAND5TOAIM, //# Transition of Kye aiming his gun at Desann (cin #9) + BOTH_STAND5STARTLEDLOOKLEFT, //# Kyle turning to watch the bridge drop (cin #9) + BOTH_STARTLEDLOOKLEFTTOSTAND5, //# Kyle returning to stand 5 from watching the bridge drop (cin #9) BOTH_STAND5TOSTAND8, //# Transition from stand5 to stand8 BOTH_STAND7TOSTAND8, //# Tavion putting hands on back of chair (cin #11) BOTH_STAND8TOSTAND5, //# Transition from stand8 to stand5 @@ -701,11 +701,11 @@ typedef enum //# animNumber_e BOTH_CONSOLE1START, //# typing at a console BOTH_CONSOLE1, //# typing at a console BOTH_CONSOLE1STOP, //# typing at a console - BOTH_CONSOLE2START, //# typing at a console with comm link in hand (cin #5) - BOTH_CONSOLE2, //# typing at a console with comm link in hand (cin #5) - BOTH_CONSOLE2STOP, //# typing at a console with comm link in hand (cin #5) - BOTH_CONSOLE2HOLDCOMSTART, //# lean in to type at console while holding comm link in hand (cin #5) - BOTH_CONSOLE2HOLDCOMSTOP, //# lean away after typing at console while holding comm link in hand (cin #5) + BOTH_CONSOLE2START, //# typing at a console with comm link in hand (cin #5) + BOTH_CONSOLE2, //# typing at a console with comm link in hand (cin #5) + BOTH_CONSOLE2STOP, //# typing at a console with comm link in hand (cin #5) + BOTH_CONSOLE2HOLDCOMSTART, //# lean in to type at console while holding comm link in hand (cin #5) + BOTH_CONSOLE2HOLDCOMSTOP, //# lean away after typing at console while holding comm link in hand (cin #5) BOTH_GUARD_LOOKAROUND1, //# Cradling weapon and looking around BOTH_GUARD_IDLE1, //# Cradling weapon and standing @@ -734,9 +734,9 @@ typedef enum //# animNumber_e BOTH_TALKGESTURE7START, //# Start touches Kyle on shoulder BOTH_TALKGESTURE7, //# Hold touches Kyle on shoulder BOTH_TALKGESTURE7STOP, //# Ending touches Kyle on shoulder - BOTH_TALKGESTURE8START, //# Lando's chin hold - BOTH_TALKGESTURE8, //# Lando's chin hold - BOTH_TALKGESTURE8STOP, //# Lando's chin hold + BOTH_TALKGESTURE8START, //# Lando's chin hold + BOTH_TALKGESTURE8, //# Lando's chin hold + BOTH_TALKGESTURE8STOP, //# Lando's chin hold BOTH_TALKGESTURE9, //# Same as gesture 2 but with the right hand BOTH_TALKGESTURE10, //# Shoulder shrug BOTH_TALKGESTURE11START, //# Arms folded across chest @@ -776,13 +776,13 @@ typedef enum //# animNumber_e BOTH_SITHEADSHAKE, //# Head shake NO from seated position BOTH_SIT2HEADTILTLSTART, //# Head tilt to left from seated position 2 BOTH_SIT2HEADTILTLSTOP, //# Head tilt to left from seated position 2 - + BOTH_REACH1START, //# Monmothma reaching for crystal BOTH_REACH1STOP, //# Monmothma reaching for crystal - BOTH_EXAMINE1START, //# Start Mon Mothma examining crystal - BOTH_EXAMINE1, //# Mon Mothma examining crystal - BOTH_EXAMINE1STOP, //# Stop Mon Mothma examining crystal + BOTH_EXAMINE1START, //# Start Mon Mothma examining crystal + BOTH_EXAMINE1, //# Mon Mothma examining crystal + BOTH_EXAMINE1STOP, //# Stop Mon Mothma examining crystal BOTH_EXAMINE2START, //# Start Kyle tossing crystal BOTH_EXAMINE2, //# Hold Kyle tossing crystal BOTH_EXAMINE2STOP, //# End Kyle tossing crystal @@ -959,7 +959,7 @@ typedef enum //# animNumber_e BOTH_WALKBACK2, //# Walk2 backwards BOTH_RUNBACK1, //# Run1 backwards BOTH_RUNBACK2, //# Run1 backwards - + //# #sep BOTH_ JUMPING BOTH_JUMP1, //# Jump - wind-up and leave ground BOTH_INAIR1, //# In air loop (from jump) @@ -1023,24 +1023,24 @@ typedef enum //# animNumber_e BOTH_DIVE1, //# Dive! BOTH_ENGAGETAUNT, - BOTH_ARIAL_LEFT, //# - BOTH_ARIAL_RIGHT, //# - BOTH_CARTWHEEL_LEFT, //# - BOTH_CARTWHEEL_RIGHT, //# - BOTH_FLIP_LEFT, //# - BOTH_FLIP_BACK1, //# - BOTH_FLIP_BACK2, //# - BOTH_FLIP_BACK3, //# - BOTH_BUTTERFLY_LEFT, //# - BOTH_BUTTERFLY_RIGHT, //# - BOTH_WALL_RUN_RIGHT, //# + BOTH_ARIAL_LEFT, //# + BOTH_ARIAL_RIGHT, //# + BOTH_CARTWHEEL_LEFT, //# + BOTH_CARTWHEEL_RIGHT, //# + BOTH_FLIP_LEFT, //# + BOTH_FLIP_BACK1, //# + BOTH_FLIP_BACK2, //# + BOTH_FLIP_BACK3, //# + BOTH_BUTTERFLY_LEFT, //# + BOTH_BUTTERFLY_RIGHT, //# + BOTH_WALL_RUN_RIGHT, //# BOTH_WALL_RUN_RIGHT_FLIP,//# - BOTH_WALL_RUN_RIGHT_STOP,//# - BOTH_WALL_RUN_LEFT, //# + BOTH_WALL_RUN_RIGHT_STOP,//# + BOTH_WALL_RUN_LEFT, //# BOTH_WALL_RUN_LEFT_FLIP,//# - BOTH_WALL_RUN_LEFT_STOP,//# - BOTH_WALL_FLIP_RIGHT, //# - BOTH_WALL_FLIP_LEFT, //# + BOTH_WALL_RUN_LEFT_STOP,//# + BOTH_WALL_FLIP_RIGHT, //# + BOTH_WALL_FLIP_LEFT, //# BOTH_WALL_FLIP_FWD, //# BOTH_KNOCKDOWN1, //# knocked backwards BOTH_KNOCKDOWN2, //# knocked backwards hard @@ -1127,7 +1127,7 @@ typedef enum //# animNumber_e BOTH_INJURED2, //# Injured pose 2 BOTH_INJURED3, //# Injured pose 3 BOTH_INJURED6, //# Injured pose 6 - BOTH_INJURED6ATTACKSTART, //# Start attack while in injured 6 pose + BOTH_INJURED6ATTACKSTART, //# Start attack while in injured 6 pose BOTH_INJURED6ATTACKSTOP, //# End attack while in injured 6 pose BOTH_INJURED6COMBADGE, //# Hit combadge while in injured 6 pose BOTH_INJURED6POINT, //# Chang points to door while in injured state @@ -1144,7 +1144,7 @@ typedef enum //# animNumber_e BOTH_SLEEP6START, //# Kyle leaning back to sleep (cin 20) BOTH_SLEEP6STOP, //# Kyle waking up and shaking his head (cin 21) BOTH_SLEEP1GETUP, //# alarmed and getting up out of sleep1 pose to stand - BOTH_SLEEP1GETUP2, //# + BOTH_SLEEP1GETUP2, //# BOTH_SLEEP2GETUP, //# alarmed and getting up out of sleep2 pose to stand BOTH_SLEEP3GETUP, //# alarmed and getting up out of sleep3 pose to stand BOTH_SLEEP3DEATH, //# death in chair, from sleep3 idle @@ -1220,7 +1220,7 @@ typedef enum //# animNumber_e BOTH_COCKPIT_CONSOLE1, //# type at controls BOTH_COCKPIT_CONSOLE2, //# type at controls - BOTH_COCKPIT_CONSOLE2_PARTIAL, //# last part of console2 anim (cin #1) used by Jan + BOTH_COCKPIT_CONSOLE2_PARTIAL, //# last part of console2 anim (cin #1) used by Jan BOTH_COCKPIT_HEADNOD, //# nod head yes while sitting BOTH_COCKPIT_HEADSHAKE, //# shake head no while sitting @@ -1234,11 +1234,11 @@ typedef enum //# animNumber_e BOTH_COCKPIT_TALKGESTURE7STOP, //# Lando's supporting hand away from Kyle (cin #21) BOTH_COCKPIT_TALKGESTURE8START, //# Hand to Lando's chin (cin #21) BOTH_COCKPIT_TALKGESTURE8STOP, //# hand away from Lando's chin *cin #21) - BOTH_COCKPIT_TALKGESTURE11START, //# - BOTH_COCKPIT_TALKGESTURE11STOP, //# + BOTH_COCKPIT_TALKGESTURE11START, //# + BOTH_COCKPIT_TALKGESTURE11STOP, //# - BOTH_COCKPIT_SLEEP6START, //# - BOTH_COCKPIT_SLEEP6STOP, //# + BOTH_COCKPIT_SLEEP6START, //# + BOTH_COCKPIT_SLEEP6STOP, //# //================================================= //ANIMS IN WHICH ONLY THE UPPER OBJECTS ARE IN MD3 @@ -1375,10 +1375,10 @@ typedef enum //# animNumber_e FACE_TALK2, //# semi-quiet FACE_TALK3, //# semi-loud FACE_TALK4, //# loud - FACE_ALERT, //# - FACE_SMILE, //# - FACE_FROWN, //# - FACE_DEAD, //# + FACE_ALERT, //# + FACE_SMILE, //# + FACE_FROWN, //# + FACE_DEAD, //# //# #eol MAX_ANIMATIONS, diff --git a/codeJK2/game/b_local.h b/codeJK2/game/b_local.h index 7684ddc1db..d518196572 100644 --- a/codeJK2/game/b_local.h +++ b/codeJK2/game/b_local.h @@ -251,7 +251,7 @@ inline qboolean NPC_ClearLOS( const vec3_t end ) { return G_ClearLOS( NPC, end ); } -inline qboolean NPC_ClearLOS( gentity_t *ent ) +inline qboolean NPC_ClearLOS( gentity_t *ent ) { return G_ClearLOS( NPC, ent ); } diff --git a/codeJK2/game/b_public.h b/codeJK2/game/b_public.h index 6f08c8292b..5816a9e639 100644 --- a/codeJK2/game/b_public.h +++ b/codeJK2/game/b_public.h @@ -40,7 +40,7 @@ along with this program; if not, see . #define NPCAI_LOST 0x00002000 //Can't nav to his goal #define NPCAI_SHIELDS 0x00004000 //Has shields, borg can adapt #define NPCAI_GREET_ALLIES 0x00008000 //Say hi to nearby allies -#define NPCAI_FORM_TELE_NAV 0x00010000 //Tells formation people to use nav info to get to +#define NPCAI_FORM_TELE_NAV 0x00010000 //Tells formation people to use nav info to get to #define NPCAI_ENROUTE_TO_HOMEWP 0x00020000 //Lets us know to run our lostenemyscript when we get to homeWp #define NPCAI_MATCHPLAYERWEAPON 0x00040000 //Match the player's weapon except when it changes during cinematics #define NPCAI_DIE_ON_IMPACT 0x00100000 //Next time you crashland, die! @@ -249,7 +249,7 @@ class gNPC_t int investigateSoundDebounceTime; int greetingDebounceTime;//when we can greet someone next gentity_t *eventOwner; - + //bState-specific fields gentity_t *coverTarg; jumpState_t jumpState; @@ -316,7 +316,7 @@ class gNPC_t int goalRadius; //FIXME: These may be redundant - + /* int weaponTime; //Time until refire is valid int jumpTime; @@ -341,7 +341,7 @@ class gNPC_t gentity_t *watchTarget; //for BS_CINEMATIC, keeps facing this ent int ffireCount; //sigh... you'd think I'd be able to find a way to do this without having to use 3 int fields, but... - int ffireDebounce; + int ffireDebounce; int ffireFadeDebounce; diff --git a/codeJK2/game/bg_pangles.cpp b/codeJK2/game/bg_pangles.cpp index 7fe3aa55fd..2ccad066ae 100644 --- a/codeJK2/game/bg_pangles.cpp +++ b/codeJK2/game/bg_pangles.cpp @@ -47,7 +47,7 @@ void BG_G2SetBoneAngles( centity_t *cent, gentity_t *gent, int boneIndex, const { if (boneIndex!=-1) { - gi.G2API_SetBoneAnglesIndex( ¢->gent->ghoul2[0], boneIndex, angles, flags, up, left, forward, modelList, 0, 0 ); + gi.G2API_SetBoneAnglesIndex( ¢->gent->ghoul2[0], boneIndex, angles, flags, up, left, forward, modelList, 0, 0 ); } } @@ -60,7 +60,7 @@ void PM_ScaleUcmd( playerState_t *ps, usercmd_t *cmd, gentity_t *gent ) //clamp the turn rate int maxPitchSpeed = MAX_PITCHSPEED_X_WING;//switch, eventually? Or read from file? int diff = AngleNormalize180(SHORT2ANGLE((cmd->angles[PITCH]+ps->delta_angles[PITCH]))) - floor(ps->viewangles[PITCH]); - + if ( diff > maxPitchSpeed ) { cmd->angles[PITCH] = ANGLE2SHORT( ps->viewangles[PITCH] + maxPitchSpeed ) - ps->delta_angles[PITCH]; @@ -113,7 +113,7 @@ qboolean PM_AdjustAngleForWallRun( gentity_t *ent, usercmd_t *ucmd, qboolean doM if (( ent->client->ps.legsAnim == BOTH_WALL_RUN_RIGHT || ent->client->ps.legsAnim == BOTH_WALL_RUN_LEFT ) && ent->client->ps.legsAnimTimer > 500 ) {//wall-running and not at end of anim //stick to wall, if there is one - vec3_t rt, traceTo, mins = {ent->mins[0],ent->mins[1],0}, maxs = {ent->maxs[0],ent->maxs[1],24}, fwdAngles = {0, ent->client->ps.viewangles[YAW], 0}; + vec3_t rt, traceTo, mins = {ent->mins[0],ent->mins[1],0}, maxs = {ent->maxs[0],ent->maxs[1],24}, fwdAngles = {0, ent->client->ps.viewangles[YAW], 0}; trace_t trace; float dist, yawAdjust; @@ -317,7 +317,7 @@ qboolean PM_AdjustAnglesForBackAttack( gentity_t *ent, usercmd_t *ucmd ) ucmd->angles[PITCH] = ANGLE2SHORT( ent->client->ps.viewangles[PITCH] ) - ent->client->ps.delta_angles[PITCH]; ucmd->angles[YAW] = ANGLE2SHORT( ent->client->ps.viewangles[YAW] ) - ent->client->ps.delta_angles[YAW]; } - else + else {//keep player facing away from their enemy vec3_t enemyBehindDir; VectorSubtract( ent->currentOrigin, ent->enemy->currentOrigin, enemyBehindDir ); @@ -397,7 +397,7 @@ are being updated isntead of a full move //FIXME: Now that they pmove twice per think, they snap-look really fast ================ */ -void PM_UpdateViewAngles( playerState_t *ps, usercmd_t *cmd, gentity_t *gent ) +void PM_UpdateViewAngles( playerState_t *ps, usercmd_t *cmd, gentity_t *gent ) { short temp; float pitchMin=-75, pitchMax=75, yawMin=0, yawMax=0; //just to shut up warnings @@ -406,12 +406,12 @@ void PM_UpdateViewAngles( playerState_t *ps, usercmd_t *cmd, gentity_t *gent ) trace_t trace; qboolean lockedYaw = qfalse; - if ( ps->pm_type == PM_INTERMISSION ) + if ( ps->pm_type == PM_INTERMISSION ) { return; // no view changes at all } - if ( ps->pm_type != PM_SPECTATOR && ps->stats[STAT_HEALTH] <= 0 ) + if ( ps->pm_type != PM_SPECTATOR && ps->stats[STAT_HEALTH] <= 0 ) { return; // no view changes at all } @@ -426,7 +426,7 @@ void PM_UpdateViewAngles( playerState_t *ps, usercmd_t *cmd, gentity_t *gent ) { pitchMin = 0 - gent->client->renderInfo.headPitchRangeUp - gent->client->renderInfo.torsoPitchRangeUp; pitchMax = gent->client->renderInfo.headPitchRangeDown + gent->client->renderInfo.torsoPitchRangeDown; - + yawMin = 0 - gent->client->renderInfo.headYawRangeLeft - gent->client->renderInfo.torsoYawRangeLeft; yawMax = gent->client->renderInfo.headYawRangeRight + gent->client->renderInfo.torsoYawRangeRight; @@ -450,32 +450,32 @@ void PM_UpdateViewAngles( playerState_t *ps, usercmd_t *cmd, gentity_t *gent ) const short pitchClampMax = ANGLE2SHORT(pitchMax); // circularly clamp the angles with deltas - for (i=0 ; i<3 ; i++) + for (i=0 ; i<3 ; i++) { temp = cmd->angles[i] + ps->delta_angles[i]; - if ( i == PITCH ) + if ( i == PITCH ) { //FIXME get this limit from the NPCs stats? // don't let the player look up or down more than 90 degrees - if ( temp > pitchClampMax ) + if ( temp > pitchClampMax ) { ps->delta_angles[i] = (pitchClampMax - cmd->angles[i]) & 0xffff; //& clamp to short temp = pitchClampMax; - } - else if ( temp < pitchClampMin ) + } + else if ( temp < pitchClampMin ) { ps->delta_angles[i] = (pitchClampMin - cmd->angles[i]) & 0xffff; //& clamp to short temp = pitchClampMin; } } - if ( i == ROLL && ps->vehicleModel != 0 ) + if ( i == ROLL && ps->vehicleModel != 0 ) { - if ( temp > pitchClampMax ) + if ( temp > pitchClampMax ) { ps->delta_angles[i] = (pitchClampMax - cmd->angles[i]) & 0xffff; temp = pitchClampMax; - } - else if ( temp < pitchClampMin ) + } + else if ( temp < pitchClampMin ) { ps->delta_angles[i] = (pitchClampMin - cmd->angles[i]) & 0xffff; temp = pitchClampMin; @@ -484,14 +484,14 @@ void PM_UpdateViewAngles( playerState_t *ps, usercmd_t *cmd, gentity_t *gent ) //FIXME: Are we losing precision here? Is this why it jitters? ps->viewangles[i] = SHORT2ANGLE(temp); - if ( i == YAW && lockedYaw) + if ( i == YAW && lockedYaw) { // don't let the player look left or right more than the clamp, if any - if ( AngleSubtract(ps->viewangles[i], gent->client->renderInfo.lockYaw) > yawMax ) + if ( AngleSubtract(ps->viewangles[i], gent->client->renderInfo.lockYaw) > yawMax ) { ps->viewangles[i] = yawMax; - } - else if ( AngleSubtract(ps->viewangles[i], gent->client->renderInfo.lockYaw) < yawMin ) + } + else if ( AngleSubtract(ps->viewangles[i], gent->client->renderInfo.lockYaw) < yawMin ) { ps->viewangles[i] = yawMin; } diff --git a/codeJK2/game/bg_public.h b/codeJK2/game/bg_public.h index 3a23d2f9aa..64bdfb68d3 100644 --- a/codeJK2/game/bg_public.h +++ b/codeJK2/game/bg_public.h @@ -93,7 +93,7 @@ typedef enum { } pmtype_t; typedef enum { - WEAPON_READY, + WEAPON_READY, WEAPON_RAISING, WEAPON_DROPPING, WEAPON_FIRING, @@ -154,7 +154,7 @@ typedef struct { // callbacks to test the world // these will be different functions during game and cgame - void (*trace)( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, + void (*trace)( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, const int passEntityNum, const int contentMask, const EG2_Collision eG2TraceType/* = (EG2_Collision)0*/, const int useLod/* = 0 */); int (*pointcontents)( const vec3_t point, int passEntityNum ); } pmove_t; @@ -191,7 +191,7 @@ void PM_SetSaberMove(short newMove); typedef enum { PERS_SCORE, // !!! MUST NOT CHANGE, SERVER AND GAME BOTH REFERENCE !!! PERS_HITS, // total points damage inflicted so damage beeps can sound on change - PERS_TEAM, + PERS_TEAM, PERS_SPAWN_COUNT, // incremented every respawn // PERS_REWARD_COUNT, // incremented for each reward sound PERS_ATTACKER, // clientnum of last damage inflicter @@ -200,7 +200,7 @@ typedef enum { PERS_ACCURACY_SHOTS, // scoreboard - number of player shots PERS_ACCURACY_HITS, // scoreboard - number of player shots that hit an enemy PERS_ENEMIES_KILLED, // scoreboard - number of enemies player killed - PERS_TEAMMATES_KILLED // scoreboard - number of teammates killed + PERS_TEAMMATES_KILLED // scoreboard - number of teammates killed } persEnum_t; @@ -273,7 +273,7 @@ typedef enum { typedef enum { EV_NONE, - + EV_FOOTSTEP, EV_FOOTSTEP_METAL, EV_FOOTSPLASH, @@ -474,7 +474,7 @@ class animation_t #define MAX_RANDOM_ANIMSOUNDS 8 -typedef struct animsounds_s +typedef struct animsounds_s { int keyFrame; //Frame to play sound on int soundIndex[MAX_RANDOM_ANIMSOUNDS]; //sound file to play - FIXME: should be an index, handle random some other way? @@ -558,7 +558,7 @@ typedef enum { //--------------------------------------------------------- // gitem_t->type -typedef enum +typedef enum { IT_BAD, IT_WEAPON, @@ -568,7 +568,7 @@ typedef enum IT_HOLDABLE, IT_BATTERY, IT_HOLOCRON, - + } itemType_t; @@ -599,7 +599,7 @@ extern const int bg_numItems; //============================================================================== /* -typedef struct ginfoitem_s +typedef struct ginfoitem_s { char *infoString;// Text message vec3_t color; // Text color diff --git a/codeJK2/game/channels.h b/codeJK2/game/channels.h index c8aa2c7f67..b64f4b0e41 100644 --- a/codeJK2/game/channels.h +++ b/codeJK2/game/channels.h @@ -24,9 +24,9 @@ typedef enum //# soundChannel_e { CHAN_AUTO, //## %s !!"W:\game\base\!!sound\*.wav;*.mp3" # Auto-picks an empty channel to play sound on CHAN_LOCAL, //## %s !!"W:\game\base\!!sound\*.wav;*.mp3" # menu sounds, etc - CHAN_WEAPON,//## %s !!"W:\game\base\!!sound\*.wav;*.mp3" + CHAN_WEAPON,//## %s !!"W:\game\base\!!sound\*.wav;*.mp3" CHAN_VOICE, //## %s !!"W:\game\base\!!sound\voice\*.wav;*.mp3" # Voice sounds cause mouth animation - CHAN_VOICE_ATTEN, //## %s !!"W:\game\base\!!sound\voice\*.wav;*.mp3" # Causes mouth animation but still use normal sound falloff + CHAN_VOICE_ATTEN, //## %s !!"W:\game\base\!!sound\voice\*.wav;*.mp3" # Causes mouth animation but still use normal sound falloff CHAN_ITEM, //## %s !!"W:\game\base\!!sound\*.wav;*.mp3" CHAN_BODY, //## %s !!"W:\game\base\!!sound\*.wav;*.mp3" CHAN_AMBIENT,//## %s !!"W:\game\base\!!sound\*.wav;*.mp3" # added for ambient sounds diff --git a/codeJK2/game/events.h b/codeJK2/game/events.h index 5d7f7a8f32..1bec0677b2 100644 --- a/codeJK2/game/events.h +++ b/codeJK2/game/events.h @@ -27,6 +27,6 @@ typedef enum //# eventType_e { EV_BAD = 0, -} eventType_t; +} eventType_t; #endif //__EVENTS__ \ No newline at end of file diff --git a/codeJK2/game/fields.h b/codeJK2/game/fields.h index c801467629..de27c1f9e0 100644 --- a/codeJK2/game/fields.h +++ b/codeJK2/game/fields.h @@ -39,17 +39,17 @@ along with this program; if not, see . #define STOFS(x) offsetof(spawn_temp_t, x) #define LLOFS(x) offsetof(level_locals_t, x) #define CLOFS(x) offsetof(gclient_t, x) -#define NPCOFS(x) offsetof(gNPC_t, x) +#define NPCOFS(x) offsetof(gNPC_t, x) // #define strFOFS(x) #x,FOFS(x) #define strSTOFS(x) #x,STOFS(x) -#define strLLOFS(x) #x,LLOFS(x) +#define strLLOFS(x) #x,LLOFS(x) #define strCLOFS(x) #x,CLOFS(x) #define strNPCOFS(x) #x,NPCOFS(x) typedef enum { -// F_INT, +// F_INT, // F_SHORT, // F_FLOAT, F_STRING, // string @@ -65,7 +65,7 @@ typedef enum // F_PLAYERSTATE, - F_BEHAVIORSET, // special scripting string ptr array handler + F_BEHAVIORSET, // special scripting string ptr array handler F_ALERTEVENT, // special handler for alertevent struct in level_locals_t F_AIGROUPS, // some AI grouping stuff of Mike's diff --git a/codeJK2/game/g_ICARUS.cpp b/codeJK2/game/g_ICARUS.cpp index c5fb26dac8..d75076c589 100644 --- a/codeJK2/game/g_ICARUS.cpp +++ b/codeJK2/game/g_ICARUS.cpp @@ -156,11 +156,11 @@ void ICARUS_Shutdown( void ) gentity_t *ent = &g_entities[0];; //Release all ICARUS resources from the entities - for ( int i = 0; i < globals.num_entities; i++, ent++ ) + for ( int i = 0; i < globals.num_entities; i++, ent++ ) { if ( !ent->inuse ) continue; - + ICARUS_FreeEnt( ent ); } @@ -209,7 +209,7 @@ void ICARUS_FreeEnt( gentity_t *ent ) if VALIDSTRING( ent->script_targetname ) { char temp[1024]; - + strncpy( (char *) temp, ent->script_targetname, 1023 ); temp[ 1023 ] = 0; @@ -223,7 +223,7 @@ void ICARUS_FreeEnt( gentity_t *ent ) //Delete the sequencer and the task manager iICARUS->DeleteSequencer( ent->sequencer ); - + //Clean up the pointers ent->sequencer = NULL; ent->taskManager = NULL; @@ -234,7 +234,7 @@ void ICARUS_FreeEnt( gentity_t *ent ) ============== ICARUS_ValidEnt -Determines whether or not an entity needs ICARUS information +Determines whether or not an entity needs ICARUS information ============== */ @@ -271,7 +271,7 @@ Associate the entity's id and name so that it can be referenced later void ICARUS_AssociateEnt( gentity_t *ent ) { char temp[1024]; - + if ( VALIDSTRING( ent->script_targetname ) == false ) return; @@ -306,8 +306,8 @@ bool ICARUS_RegisterScript( const char *name, bool bCalledDuringInterrogate /* = // if ( ei != ICARUS_BufferList.end() ) return (bCalledDuringInterrogate)?false:true; - - sprintf((char *) newname, "%s%s", name, IBI_EXT ); + + sprintf((char *) newname, "%s%s", name, IBI_EXT ); // small update here, if called during interrogate, don't let gi.FS_ReadFile() complain because it can't @@ -315,15 +315,15 @@ bool ICARUS_RegisterScript( const char *name, bool bCalledDuringInterrogate /* = // the ifndef, this just cuts down on internal error reports while testing release mode... // qboolean qbIgnoreFileRead = qfalse; - // + // // NOTENOTE: For the moment I've taken this back out, to avoid doubling the number of fopen()'s per file. -#if 0//#ifndef FINAL_BUILD +#if 0//#ifndef FINAL_BUILD if (bCalledDuringInterrogate) { fileHandle_t file; gi.FS_FOpenFile( newname, &file, FS_READ ); - + if ( file == NULL ) { qbIgnoreFileRead = qtrue; // warn disk code further down not to try FS_ReadFile() @@ -341,7 +341,7 @@ bool ICARUS_RegisterScript( const char *name, bool bCalledDuringInterrogate /* = { // File not found, but keep quiet during interrogate stage, because of stuff like BS_RUN_AND_SHOOT as scriptname // - if (!bCalledDuringInterrogate) + if (!bCalledDuringInterrogate) { Com_Printf(S_COLOR_RED"Could not open file '%s'\n", newname ); } @@ -350,7 +350,7 @@ bool ICARUS_RegisterScript( const char *name, bool bCalledDuringInterrogate /* = pscript = new pscript_t; - pscript->buffer = (char *) gi.Malloc(length, TAG_ICARUS, qfalse); + pscript->buffer = (char *) gi.Malloc(length, TAG_ICARUS, qfalse); memcpy (pscript->buffer, buffer, length); pscript->length = length; @@ -439,7 +439,7 @@ void ICARUS_InterrogateScript( const char *filename ) break; case ID_PLAY: // to cache ROFF files - + sVal1 = (const char *) block.GetMemberData( 0 ); if (!Q_stricmp(sVal1,"PLAY_ROFF")) @@ -447,19 +447,19 @@ void ICARUS_InterrogateScript( const char *filename ) sVal1 = (const char *) block.GetMemberData( 1 ); G_LoadRoff(sVal1); - } + } break; //Run commands case ID_RUN: - + sVal1 = (const char *) block.GetMemberData( 0 ); - + COM_StripExtension( sVal1, (char *) temp, sizeof( temp ) ); ICARUS_InterrogateScript( (const char *) &temp ); - + break; - + case ID_SOUND: sVal1 = (const char *) block.GetMemberData( 1 ); //0 is channel, 1 is filename G_SoundIndex(sVal1); @@ -475,7 +475,7 @@ void ICARUS_InterrogateScript( const char *filename ) { sVal1 = (const char *) block.GetMemberData( 0 ); sVal2 = (const char *) block.GetMemberData( 1 ); - + //Get the id for this set identifier setID = GetIDForString( setTable, sVal1 ); @@ -510,7 +510,7 @@ extern cvar_t *com_buildScript; { fileHandle_t file; char name[MAX_OSPATH]; - + if (strstr(sVal2, "/") == NULL && strstr(sVal2, "\\") == NULL) { Com_sprintf (name, sizeof(name), "video/%s", sVal2); } else { @@ -650,11 +650,11 @@ void Svcmd_ICARUS_f( void ) { g_ICARUSDebug->integer = WL_DEBUG; if ( VALIDSTRING( gi.argv( 2 ) ) ) - { + { gentity_t *ent = G_Find( NULL, FOFS( script_targetname ), gi.argv(2) ); if ( ent == NULL ) - { + { Com_Printf( "Entity \"%s\" not found!\n", gi.argv(2) ); return; } @@ -666,9 +666,9 @@ void Svcmd_ICARUS_f( void ) return; } - + Com_Printf("Logging ICARUS info for all entities\n"); - + return; } } diff --git a/codeJK2/game/g_active.cpp b/codeJK2/game/g_active.cpp index d204f64116..7b4f4cda74 100644 --- a/codeJK2/game/g_active.cpp +++ b/codeJK2/game/g_active.cpp @@ -104,19 +104,19 @@ int G_FindLookItem( gentity_t *self ) VectorCopy( self->currentOrigin, center ); - for ( i = 0 ; i < 3 ; i++ ) + for ( i = 0 ; i < 3 ; i++ ) { mins[i] = center[i] - radius; maxs[i] = center[i] + radius; } numListedEntities = gi.EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); - + if ( !numListedEntities ) { return ENTITYNUM_NONE; } - for ( e = 0 ; e < numListedEntities ; e++ ) + for ( e = 0 ; e < numListedEntities ; e++ ) { ent = entityList[ e ]; @@ -263,8 +263,8 @@ qboolean G_ValidateLookEnemy( gentity_t *self, gentity_t *enemy ) } if ( !enemy->client || !enemy->NPC ) {//not valid - if ( (enemy->svFlags&SVF_NONNPC_ENEMY) - && enemy->s.weapon == WP_TURRET + if ( (enemy->svFlags&SVF_NONNPC_ENEMY) + && enemy->s.weapon == WP_TURRET && enemy->noDamageTeam != self->client->playerTeam && enemy->health > 0 ) {//a turret @@ -275,7 +275,7 @@ qboolean G_ValidateLookEnemy( gentity_t *self, gentity_t *enemy ) return qfalse; } } - else + else { if ( enemy->client->playerTeam == self->client->playerTeam ) {//on same team @@ -291,7 +291,7 @@ qboolean G_ValidateLookEnemy( gentity_t *self, gentity_t *enemy ) } } - if ( (!InFront( enemy->currentOrigin, self->currentOrigin, self->client->ps.viewangles, 0.0f) || !G_ClearLOS( self, self->client->renderInfo.eyePoint, enemy ) ) + if ( (!InFront( enemy->currentOrigin, self->currentOrigin, self->client->ps.viewangles, 0.0f) || !G_ClearLOS( self, self->client->renderInfo.eyePoint, enemy ) ) && ( DistanceHorizontalSquared( enemy->currentOrigin, self->currentOrigin ) > 65536 || fabs(enemy->currentOrigin[2]-self->currentOrigin[2]) > 384 ) ) {//(not in front or not clear LOS) & greater than 256 away return qfalse; @@ -322,19 +322,19 @@ void G_ChooseLookEnemy( gentity_t *self, usercmd_t *ucmd ) VectorCopy( self->currentOrigin, center ); - for ( i = 0 ; i < 3 ; i++ ) + for ( i = 0 ; i < 3 ; i++ ) { mins[i] = center[i] - radius; maxs[i] = center[i] + radius; } numListedEntities = gi.EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); - + if ( !numListedEntities ) {//should we clear the enemy? return; } - for ( e = 0 ; e < numListedEntities ; e++ ) + for ( e = 0 ; e < numListedEntities ; e++ ) { ent = entityList[ e ]; @@ -442,14 +442,14 @@ void P_DamageFeedback( gentity_t *player ) { // world damage (falling, slime, etc) uses a special code // to make the blend blob centered instead of positional - if ( client->damage_fromWorld ) + if ( client->damage_fromWorld ) { client->ps.damagePitch = 255; client->ps.damageYaw = 255; client->damage_fromWorld = qfalse; - } - else + } + else { vectoangles( client->damage_from, angles ); client->ps.damagePitch = angles[PITCH]/360.0 * 256; @@ -478,7 +478,7 @@ Check for lava / slime contents and drowning void P_WorldEffects( gentity_t *ent ) { int mouthContents = 0; - if ( ent->client->noclip ) + if ( ent->client->noclip ) { ent->client->airOutTime = level.time + 12000; // don't need air return; @@ -491,14 +491,14 @@ void P_WorldEffects( gentity_t *ent ) { // // check for drowning // - if ( (mouthContents&(CONTENTS_WATER|CONTENTS_SLIME)) ) + if ( (mouthContents&(CONTENTS_WATER|CONTENTS_SLIME)) ) { if ( ent->client->NPC_class == CLASS_SWAMPTROOPER ) {//they have air tanks ent->client->airOutTime = level.time + 12000; // don't need air ent->damage = 2; } - else if ( ent->client->airOutTime < level.time) + else if ( ent->client->airOutTime < level.time) {// if out of air, start drowning // drown! ent->client->airOutTime += 1000; @@ -509,24 +509,24 @@ void P_WorldEffects( gentity_t *ent ) { ent->damage = 15; // play a gurp sound instead of a normal pain sound - if (ent->health <= ent->damage) + if (ent->health <= ent->damage) { G_AddEvent( ent, EV_WATER_DROWN, 0 ); - } + } else { G_AddEvent( ent, Q_irand(EV_WATER_GURP1, EV_WATER_GURP2), 0 ); - } + } // don't play a normal pain sound ent->painDebounceTime = level.time + 200; - G_Damage (ent, NULL, NULL, NULL, NULL, + G_Damage (ent, NULL, NULL, NULL, NULL, ent->damage, DAMAGE_NO_ARMOR, MOD_WATER); } } - } - else + } + else { ent->client->airOutTime = level.time + 12000; ent->damage = 2; @@ -535,18 +535,18 @@ void P_WorldEffects( gentity_t *ent ) { // // check for sizzle damage (move to pmove?) // - if (ent->waterlevel && + if (ent->waterlevel && (ent->watertype&(CONTENTS_LAVA|CONTENTS_SLIME)) ) { if (ent->health > 0 && ent->painDebounceTime < level.time ) { if (ent->watertype & CONTENTS_LAVA) { - G_Damage (ent, NULL, NULL, NULL, NULL, + G_Damage (ent, NULL, NULL, NULL, NULL, 15*ent->waterlevel, 0, MOD_LAVA); } if (ent->watertype & CONTENTS_SLIME) { - G_Damage (ent, NULL, NULL, NULL, NULL, + G_Damage (ent, NULL, NULL, NULL, NULL, 1, 0, MOD_SLIME); } } @@ -595,7 +595,7 @@ void DoImpact( gentity_t *self, gentity_t *other, qboolean damageSelf ) VectorCopy( self->client->ps.velocity, velocity ); my_mass = self->mass; } - else + else { VectorCopy( self->s.pos.trDelta, velocity ); if ( self->s.pos.trType == TR_GRAVITY ) @@ -674,7 +674,7 @@ void DoImpact( gentity_t *self, gentity_t *other, qboolean damageSelf ) if( ( force >= 1 && other->s.number != 0 ) || force >= 10) { - /* + /* dprint("Damage other ("); dprint(loser.classname); dprint("): "); @@ -693,7 +693,7 @@ void DoImpact( gentity_t *self, gentity_t *other, qboolean damageSelf ) else if ( other->takedamage ) { if ( !self->client || !other->s.number || !other->client ) - {//aw, fuck it, clients no longer take impact damage from other clients, unless you're the player + {//aw, fuck it, clients no longer take impact damage from other clients, unless you're the player G_Damage( other, self, self, velocity, self->currentOrigin, force, DAMAGE_NO_ARMOR, MOD_IMPACT ); } else @@ -745,7 +745,7 @@ void DoImpact( gentity_t *self, gentity_t *other, qboolean damageSelf ) if ( magnitude >= 1 ) { //FIXME: Put in a thingtype impact sound function - /* + /* dprint("Damage self ("); dprint(self.classname); dprint("): "); @@ -766,7 +766,7 @@ void DoImpact( gentity_t *self, gentity_t *other, qboolean damageSelf ) } //FIXME: slow my velocity some? - + self->lastImpact = level.time; /* @@ -887,7 +887,7 @@ void G_TouchTriggersLerped( gentity_t *ent ) { if ( touched[i] == qtrue ) { continue;//already touched this move } - if ( ent->client->ps.stats[STAT_HEALTH] <= 0 ) + if ( ent->client->ps.stats[STAT_HEALTH] <= 0 ) { if ( Q_stricmp( "trigger_teleport", hit->classname ) || !(hit->spawnflags&16/*TTSF_DEAD_OK*/) ) {//dead clients can only touch tiogger_teleports that are marked as touchable @@ -1004,7 +1004,7 @@ Find all trigger entities that ent's current position touches. Spectators will only interact with teleporters. ============ */ -void G_MoverTouchPushTriggers( gentity_t *ent, vec3_t oldOrg ) +void G_MoverTouchPushTriggers( gentity_t *ent, vec3_t oldOrg ) { int i, num; float step, stepSize, dist; @@ -1014,7 +1014,7 @@ void G_MoverTouchPushTriggers( gentity_t *ent, vec3_t oldOrg ) const vec3_t range = { 40, 40, 52 }; // non-moving movers don't hit triggers! - if ( !VectorLengthSquared( ent->s.pos.trDelta ) ) + if ( !VectorLengthSquared( ent->s.pos.trDelta ) ) { return; } @@ -1040,7 +1040,7 @@ void G_MoverTouchPushTriggers( gentity_t *ent, vec3_t oldOrg ) VectorAdd( checkSpot, ent->mins, mins ); VectorAdd( checkSpot, ent->maxs, maxs ); - for ( i=0 ; ie_TouchFunc == touchF_NULL ) + if ( hit->e_TouchFunc == touchF_NULL ) { continue; } - if ( !( hit->contents & CONTENTS_TRIGGER ) ) + if ( !( hit->contents & CONTENTS_TRIGGER ) ) { continue; } - if ( !gi.EntityContact( mins, maxs, hit ) ) + if ( !gi.EntityContact( mins, maxs, hit ) ) { continue; } memset( &trace, 0, sizeof(trace) ); - if ( hit->e_TouchFunc != touchF_NULL ) + if ( hit->e_TouchFunc != touchF_NULL ) { GEntity_TouchFunc(hit, ent, &trace); } @@ -1135,30 +1135,30 @@ Returns qfalse if the client is dropped ================= */ qboolean ClientInactivityTimer( gclient_t *client ) { - if ( ! g_inactivity->integer ) + if ( ! g_inactivity->integer ) { // give everyone some time, so if the operator sets g_inactivity during // gameplay, everyone isn't kicked client->inactivityTime = level.time + 60 * 1000; client->inactivityWarning = qfalse; - } - else if ( client->usercmd.forwardmove || - client->usercmd.rightmove || + } + else if ( client->usercmd.forwardmove || + client->usercmd.rightmove || client->usercmd.upmove || (client->usercmd.buttons & BUTTON_ATTACK) || - (client->usercmd.buttons & BUTTON_ALT_ATTACK) ) + (client->usercmd.buttons & BUTTON_ALT_ATTACK) ) { client->inactivityTime = level.time + g_inactivity->integer * 1000; client->inactivityWarning = qfalse; - } - else if ( !client->pers.localClient ) + } + else if ( !client->pers.localClient ) { - if ( level.time > client->inactivityTime ) + if ( level.time > client->inactivityTime ) { gi.DropClient( client - level.clients, "Dropped due to inactivity" ); return qfalse; } - if ( level.time > client->inactivityTime - 10000 && !client->inactivityWarning ) + if ( level.time > client->inactivityTime - 10000 && !client->inactivityWarning ) { client->inactivityWarning = qtrue; gi.SendServerCommand( client - level.clients, "cp \"Ten seconds until inactivity drop!\n\"" ); @@ -1183,7 +1183,7 @@ void ClientTimerActions( gentity_t *ent, int msec ) { client = ent->client; client->timeResidual += msec; - while ( client->timeResidual >= 1000 ) + while ( client->timeResidual >= 1000 ) { client->timeResidual -= 1000; @@ -1260,11 +1260,11 @@ void ClientEvents( gentity_t *ent, int oldEventSequence ) { } /* //FIXME: isn't there a more accurate way to calculate damage from falls? - if ( event == EV_FALL_FAR ) + if ( event == EV_FALL_FAR ) { damage = 50; - } - else + } + else { damage = 25; } @@ -1328,8 +1328,8 @@ qboolean G_CheckClampUcmd( gentity_t *ent, usercmd_t *ucmd ) { qboolean overridAngles = qfalse; - if ( (!ent->s.number&&ent->aimDebounceTime>level.time) - || (ent->client->ps.pm_time && (ent->client->ps.pm_flags&PMF_TIME_KNOCKBACK)) + if ( (!ent->s.number&&ent->aimDebounceTime>level.time) + || (ent->client->ps.pm_time && (ent->client->ps.pm_flags&PMF_TIME_KNOCKBACK)) || ent->forcePushTime > level.time ) {//being knocked back, can't do anything! ucmd->buttons = 0; @@ -1393,7 +1393,7 @@ qboolean G_CheckClampUcmd( gentity_t *ent, usercmd_t *ucmd ) } } - if ( ent->client->ps.saberMove == LS_A_BACK || ent->client->ps.saberMove == LS_A_BACK_CR + if ( ent->client->ps.saberMove == LS_A_BACK || ent->client->ps.saberMove == LS_A_BACK_CR || ent->client->ps.saberMove == LS_A_BACKSTAB ) {//can't move or turn during back attacks ucmd->forwardmove = ucmd->rightmove = 0; @@ -1422,7 +1422,7 @@ qboolean G_CheckClampUcmd( gentity_t *ent, usercmd_t *ucmd ) } } } - else if ( ent->client->ps.torsoAnim == BOTH_WALL_FLIP_BACK1 + else if ( ent->client->ps.torsoAnim == BOTH_WALL_FLIP_BACK1 || ent->client->ps.torsoAnim == BOTH_WALL_FLIP_BACK2 ) { //pull back the view @@ -1620,7 +1620,7 @@ NPC_GetRunSpeed ------------------------- */ #define BORG_RUN_INCR 25 -#define SPECIES_RUN_INCR 25 +#define SPECIES_RUN_INCR 25 #define STASIS_RUN_INCR 20 #define WARBOT_RUN_INCR 20 @@ -1832,7 +1832,7 @@ void G_StopCinematicSkip( void ) void G_StartCinematicSkip( void ) { - + if (cinematicSkipScript[0]) { ICARUS_RunScript( &g_entities[0], va( "%s/%s", Q3_SCRIPT_DIR, cinematicSkipScript ) ); @@ -1840,7 +1840,7 @@ void G_StartCinematicSkip( void ) gi.cvar_set("skippingCinematic", "1"); gi.cvar_set("timescale", "100"); } - else + else { // no... so start skipping... gi.cvar_set("skippingCinematic", "1"); @@ -1848,7 +1848,7 @@ void G_StartCinematicSkip( void ) } } -void G_CheckClientIdle( gentity_t *ent, usercmd_t *ucmd ) +void G_CheckClientIdle( gentity_t *ent, usercmd_t *ucmd ) { if ( !ent || !ent->client || ent->health <= 0 ) { @@ -1862,15 +1862,15 @@ void G_CheckClientIdle( gentity_t *ent, usercmd_t *ucmd ) } return; } - if ( !VectorCompare( vec3_origin, ent->client->ps.velocity ) - || ucmd->buttons || ucmd->forwardmove || ucmd->rightmove || ucmd->upmove - || !PM_StandingAnim( ent->client->ps.legsAnim ) - || ent->enemy + if ( !VectorCompare( vec3_origin, ent->client->ps.velocity ) + || ucmd->buttons || ucmd->forwardmove || ucmd->rightmove || ucmd->upmove + || !PM_StandingAnim( ent->client->ps.legsAnim ) + || ent->enemy || ent->client->ps.legsAnimTimer || ent->client->ps.torsoAnimTimer ) {//FIXME: also check for turning? - if ( !VectorCompare( vec3_origin, ent->client->ps.velocity ) - || ucmd->buttons || ucmd->forwardmove || ucmd->rightmove || ucmd->upmove + if ( !VectorCompare( vec3_origin, ent->client->ps.velocity ) + || ucmd->buttons || ucmd->forwardmove || ucmd->rightmove || ucmd->upmove || ent->enemy ) { //if in an idle, break out @@ -1959,8 +1959,8 @@ void G_CheckMovingLoopingSounds( gentity_t *ent, usercmd_t *ucmd ) } else {//not moving under your own control, stop loopSound - if ( ent->client->NPC_class == CLASS_R2D2 || ent->client->NPC_class == CLASS_R5D2 - || ent->client->NPC_class == CLASS_MARK2 || ent->client->NPC_class == CLASS_MOUSE + if ( ent->client->NPC_class == CLASS_R2D2 || ent->client->NPC_class == CLASS_R5D2 + || ent->client->NPC_class == CLASS_MARK2 || ent->client->NPC_class == CLASS_MOUSE || ent->client->NPC_class == CLASS_PROBE ) { ent->s.loopSound = 0; @@ -1980,7 +1980,7 @@ usually be a couple times for each server frame on fast clients. */ extern int G_FindLocalInterestPoint( gentity_t *self ); -void ClientThink_real( gentity_t *ent, usercmd_t *ucmd ) +void ClientThink_real( gentity_t *ent, usercmd_t *ucmd ) { gclient_t *client; pmove_t pm; @@ -1991,7 +1991,7 @@ void ClientThink_real( gentity_t *ent, usercmd_t *ucmd ) qboolean controlledByPlayer = qfalse; //Don't let the player do anything if in a camera - if ( ent->s.number == 0 ) + if ( ent->s.number == 0 ) { extern cvar_t *g_skippingcin; @@ -2071,7 +2071,7 @@ extern cvar_t *g_skippingcin; { int diff = AngleNormalize180(SHORT2ANGLE(ucmd->angles[YAW]+ent->client->ps.delta_angles[YAW]) - floor(ent->client->ps.viewangles[YAW])); int slide = floor(((float)(diff))/120.0f*-127.0f); - + if ( (slide > 0 && ucmd->rightmove >= 0) || ((slide < 0 && ucmd->rightmove <= 0)) ) {//note: don't want these to conflict right now because that seems to feel really weird //gi.Printf( "slide %i, diff %i, yaw %i\n", slide, diff, ucmd->angles[YAW] ); @@ -2094,7 +2094,7 @@ extern cvar_t *g_skippingcin; ucmd->angles[YAW] = ANGLE2SHORT( ent->client->ps.viewangles[YAW] ) - ent->client->ps.delta_angles[YAW]; } } - else + else { if ( g_skippingcin->integer ) {//We're skipping the cinematic and it's over now @@ -2117,10 +2117,10 @@ extern cvar_t *g_skippingcin; if ( cg.zoomMode == 2 ) { // Any kind of movement when the player is NOT ducked when the disruptor gun is zoomed will cause us to auto-magically un-zoom - if ( ( (ucmd->forwardmove||ucmd->rightmove) + if ( ( (ucmd->forwardmove||ucmd->rightmove) && ucmd->upmove >= 0 //crouching-moving is ok - && !(ucmd->buttons&BUTTON_USE)/*leaning is ok*/ - ) + && !(ucmd->buttons&BUTTON_USE)/*leaning is ok*/ + ) || ucmd->upmove > 0 //jumping not allowed ) { @@ -2171,9 +2171,9 @@ extern cvar_t *g_skippingcin; } if ( ent->client ) { - if ( ent->client->NPC_class == CLASS_GONK || - ent->client->NPC_class == CLASS_MOUSE || - ent->client->NPC_class == CLASS_R2D2 || + if ( ent->client->NPC_class == CLASS_GONK || + ent->client->NPC_class == CLASS_MOUSE || + ent->client->NPC_class == CLASS_R2D2 || ent->client->NPC_class == CLASS_R5D2 ) {//no jumping or strafing in these guys ucmd->upmove = ucmd->rightmove = 0; @@ -2205,17 +2205,17 @@ extern cvar_t *g_skippingcin; else if ( ent->client->ps.groundEntityNum < ENTITYNUM_WORLD && !ent->client->ps.forceJumpCharge ) {//standing on an entity and not currently force jumping gentity_t *groundEnt = &g_entities[ent->client->ps.groundEntityNum]; - if ( groundEnt && - groundEnt->client && - groundEnt->client->ps.groundEntityNum != ENTITYNUM_NONE && + if ( groundEnt && + groundEnt->client && + groundEnt->client->ps.groundEntityNum != ENTITYNUM_NONE && groundEnt->health > 0 && - !PM_InRoll( &groundEnt->client->ps ) - && !(groundEnt->client->ps.eFlags&EF_LOCKED_TO_WEAPON) + !PM_InRoll( &groundEnt->client->ps ) + && !(groundEnt->client->ps.eFlags&EF_LOCKED_TO_WEAPON) && !inSpinFlipAttack ) {//landed on a live client who is on the ground, jump off them and knock them down if ( ent->health > 0 ) { - if ( !PM_InRoll( &ent->client->ps ) + if ( !PM_InRoll( &ent->client->ps ) && !PM_FlippingAnim( ent->client->ps.legsAnim ) ) { if ( ent->s.number && ent->s.weapon == WP_SABER ) @@ -2282,7 +2282,7 @@ extern cvar_t *g_skippingcin; {//can't knock down desann unless you're luke //FIXME: should he smack you away like Galak Mech? } - else if ( + else if ( ( ( (groundEnt->s.number&&(groundEnt->s.weapon!=WP_SABER||!groundEnt->NPC||groundEnt->NPC->ranks.number||G_ControlledByPlayer(groundEnt)) && !Q_irand( 0, 3 )&&cg.renderingThirdPerson&&!cg.zoomMode) )//or a player in third person, 25% of the time && groundEnt->client->playerTeam != ent->client->playerTeam ) //and not on the same team @@ -2316,38 +2316,38 @@ extern cvar_t *g_skippingcin; client->pers.lastCommand = *ucmd; // sanity check the command time to prevent speedup cheating - if ( ucmd->serverTime > level.time + 200 ) + if ( ucmd->serverTime > level.time + 200 ) { ucmd->serverTime = level.time + 200; } - if ( ucmd->serverTime < level.time - 1000 ) + if ( ucmd->serverTime < level.time - 1000 ) { ucmd->serverTime = level.time - 1000; - } + } msec = ucmd->serverTime - client->ps.commandTime; - if ( msec < 1 ) + if ( msec < 1 ) { msec = 1; } - if ( msec > 200 ) + if ( msec > 200 ) { msec = 200; } // check for inactivity timer, but never drop the local client of a non-dedicated server - if ( !ClientInactivityTimer( client ) ) + if ( !ClientInactivityTimer( client ) ) return; - if ( client->noclip ) + if ( client->noclip ) { client->ps.pm_type = PM_NOCLIP; - } - else if ( client->ps.stats[STAT_HEALTH] <= 0 ) + } + else if ( client->ps.stats[STAT_HEALTH] <= 0 ) { client->ps.pm_type = PM_DEAD; - } - else + } + else { client->ps.pm_type = PM_NORMAL; } @@ -2453,17 +2453,17 @@ extern cvar_t *g_skippingcin; else { //Slow down on turns - don't orbit!!! - float turndelta = 0; + float turndelta = 0; // if the NPC is locked into a Yaw, we want to check the lockedDesiredYaw...otherwise the NPC can't walk backwards, because it always thinks it trying to turn according to desiredYaw if( client->renderInfo.renderFlags & RF_LOCKEDANGLE ) // yeah I know the RF_ flag is a pretty ugly hack... - { + { turndelta = (180 - fabs( AngleDelta( ent->currentAngles[YAW], ent->NPC->lockedDesiredYaw ) ))/180; } else { turndelta = (180 - fabs( AngleDelta( ent->currentAngles[YAW], ent->NPC->desiredYaw ) ))/180; } - + if ( turndelta < 0.75f ) { client->ps.speed = 0; @@ -2477,7 +2477,7 @@ extern cvar_t *g_skippingcin; } } else - { + { ent->NPC->desiredSpeed = ( ucmd->buttons & BUTTON_WALKING ) ? NPC_GetWalkSpeed( ent ) : NPC_GetRunSpeed( ent ); client->ps.speed = ent->NPC->desiredSpeed; @@ -2769,7 +2769,7 @@ extern cvar_t *g_skippingcin; Pmove( &pm ); // save results of pmove - if ( ent->client->ps.eventSequence != oldEventSequence ) + if ( ent->client->ps.eventSequence != oldEventSequence ) { ent->eventTime = level.time; { @@ -2816,7 +2816,7 @@ extern cvar_t *g_skippingcin; // link entity now, after any personal teleporters have been used gi.linkentity( ent ); ent->client->hiddenDist = 0; - if ( !ent->client->noclip ) + if ( !ent->client->noclip ) { G_TouchTriggersLerped( ent ); } @@ -2830,18 +2830,18 @@ extern cvar_t *g_skippingcin; client->latched_buttons |= client->buttons & ~client->oldbuttons; // check for respawning - if ( client->ps.stats[STAT_HEALTH] <= 0 ) + if ( client->ps.stats[STAT_HEALTH] <= 0 ) { // wait for the attack button to be pressed - if ( ent->NPC == NULL && level.time > client->respawnTime ) + if ( ent->NPC == NULL && level.time > client->respawnTime ) { // don't allow respawn if they are still flying through the // air, unless 10 extra seconds have passed, meaning something // strange is going on, like the corpse is caught in a wind tunnel /* - if ( level.time < client->respawnTime + 10000 ) + if ( level.time < client->respawnTime + 10000 ) { - if ( client->ps.groundEntityNum == ENTITYNUM_NONE ) + if ( client->ps.groundEntityNum == ENTITYNUM_NONE ) { return; } @@ -2849,18 +2849,18 @@ extern cvar_t *g_skippingcin; */ // pressing attack or use is the normal respawn method - if ( ucmd->buttons & ( BUTTON_ATTACK ) ) + if ( ucmd->buttons & ( BUTTON_ATTACK ) ) { respawn( ent ); // gi.SendConsoleCommand( va("disconnect;wait;wait;wait;wait;wait;wait;devmap %s\n",level.mapname) ); } } - if ( ent - && !ent->s.number - && ent->enemy - && ent->enemy != ent - && ent->enemy->s.number < ENTITYNUM_WORLD - && ent->enemy->inuse + if ( ent + && !ent->s.number + && ent->enemy + && ent->enemy != ent + && ent->enemy->s.number < ENTITYNUM_WORLD + && ent->enemy->inuse && !(cg.overrides.active&CG_OVERRIDE_3RD_PERSON_ANG) ) {//keep facing enemy vec3_t deadDir; @@ -2923,7 +2923,7 @@ void ClientThink( int clientNum, usercmd_t *ucmd ) { {//you're controlling another NPC gentity_t *controlled = &g_entities[ent->client->ps.viewEntity]; qboolean freed = qfalse; - if ( controlled->NPC + if ( controlled->NPC && controlled->NPC->controlledTime && ent->client->ps.forcePowerLevel[FP_TELEPATHY] > FORCE_LEVEL_3 ) {//An NPC I'm controlling with mind trick @@ -2998,7 +2998,7 @@ void ClientThink( int clientNum, usercmd_t *ucmd ) { ent->client->usercmd = *ucmd; -// if ( !g_syncronousClients->integer ) +// if ( !g_syncronousClients->integer ) { ClientThink_real( ent, ucmd ); } @@ -3014,18 +3014,18 @@ void ClientThink( int clientNum, usercmd_t *ucmd ) { } } -void ClientEndPowerUps( gentity_t *ent ) +void ClientEndPowerUps( gentity_t *ent ) { int i; - if ( ent == NULL || ent->client == NULL ) + if ( ent == NULL || ent->client == NULL ) { return; } // turn off any expired powerups - for ( i = 0 ; i < MAX_POWERUPS ; i++ ) + for ( i = 0 ; i < MAX_POWERUPS ; i++ ) { - if ( ent->client->ps.powerups[ i ] < level.time ) + if ( ent->client->ps.powerups[ i ] < level.time ) { ent->client->ps.powerups[ i ] = 0; } @@ -3040,7 +3040,7 @@ A fast client will have multiple ClientThink for each ClientEdFrame, while a slow client may have multiple ClientEndFrame between ClientThink. ============== */ -void ClientEndFrame( gentity_t *ent ) +void ClientEndFrame( gentity_t *ent ) { // // If the end of unit layout is displayed, don't give diff --git a/codeJK2/game/g_breakable.cpp b/codeJK2/game/g_breakable.cpp index 3414928966..711ae7fca5 100644 --- a/codeJK2/game/g_breakable.cpp +++ b/codeJK2/game/g_breakable.cpp @@ -88,7 +88,7 @@ void funcBBrushDieGo (gentity_t *self) float scale; int numChunks, size = 0; material_t chunkType = self->material; - + // if a missile is stuck to us, blow it up so we don't look dumb for ( int i = 0; i < MAX_GENTITIES; i++ ) { @@ -102,7 +102,7 @@ void funcBBrushDieGo (gentity_t *self) self->s.solid = 0; self->contents = 0; self->clipmask = 0; - gi.linkentity(self); + gi.linkentity(self); VectorSet(up, 0, 0, 1); @@ -149,7 +149,7 @@ void funcBBrushDieGo (gentity_t *self) else { VectorCopy(up, dir); - } + } if ( !(self->spawnflags & 2048) ) // NO_EXPLOSION { @@ -249,7 +249,7 @@ void funcBBrushPain(gentity_t *self, gentity_t *inflictor, gentity_t *attacker, else { VectorSet( dir, 0, 0, 1 ); - } + } CG_Chunks( self->s.number, org, dir, self->mins, self->maxs, 300, Q_irand( 1, 3 ), self->material, 0, scale ); } @@ -262,23 +262,23 @@ void funcBBrushPain(gentity_t *self, gentity_t *inflictor, gentity_t *attacker, self->painDebounceTime = level.time + self->wait; } -static void InitBBrush ( gentity_t *ent ) +static void InitBBrush ( gentity_t *ent ) { float light; vec3_t color; qboolean lightSet, colorSet; VectorCopy( ent->s.origin, ent->pos1 ); - + gi.SetBrushModel( ent, ent->model ); ent->e_DieFunc = dieF_funcBBrushDie; - + ent->svFlags |= SVF_BBRUSH; // if the "model2" key is set, use a seperate model // for drawing, but clip against the brushes - if ( ent->model2 ) + if ( ent->model2 ) { ent->s.modelindex2 = G_ModelIndex( ent->model2 ); } @@ -286,7 +286,7 @@ static void InitBBrush ( gentity_t *ent ) // if the "color" or "light" keys are set, setup constantLight lightSet = G_SpawnFloat( "light", "100", &light ); colorSet = G_SpawnVector( "color", "1 1 1", color ); - if ( lightSet || colorSet ) + if ( lightSet || colorSet ) { int r, g, b, i; @@ -356,13 +356,13 @@ Damage: default is none "neutral" "enemy" -Don't know if these work: +Don't know if these work: "color" constantLight color "light" constantLight radius "material" - default is "0 - MAT_METAL" - choose from this list: 0 = MAT_METAL (basic blue-grey scorched-DEFAULT) -1 = MAT_GLASS +1 = MAT_GLASS 2 = MAT_ELECTRICAL (sparks only) 3 = MAT_ELEC_METAL (METAL2 chunks and sparks) 4 = MAT_DRK_STONE (brown stone chunks) @@ -379,7 +379,7 @@ Don't know if these work: 15 = MAT_WHITE_METAL (white angular chunks for Stu, NS_hideout ) */ -void SP_func_breakable( gentity_t *self ) +void SP_func_breakable( gentity_t *self ) { if(!(self->spawnflags & 1)) { @@ -398,7 +398,7 @@ void SP_func_breakable( gentity_t *self ) self->flags |= FL_DMG_BY_HEAVY_WEAP_ONLY; } - if (self->health) + if (self->health) { self->takedamage = qtrue; } @@ -448,7 +448,7 @@ void misc_model_breakable_pain ( gentity_t *self, gentity_t *inflictor, gentity_ } } -void misc_model_breakable_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath,int dFlags,int hitLoc ) +void misc_model_breakable_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath,int dFlags,int hitLoc ) { int numChunks; float size = 0, scale; @@ -458,7 +458,7 @@ void misc_model_breakable_die( gentity_t *self, gentity_t *inflictor, gentity_t //Turn off animation self->s.frame = self->startFrame = self->endFrame = 0; self->svFlags &= ~SVF_ANIMATING; - + self->health = 0; //Throw some chunks @@ -639,7 +639,7 @@ void misc_model_breakable_init( gentity_t *ent ) if (type == MDL_OTHER) { - ent->e_UseFunc = useF_misc_model_use; + ent->e_UseFunc = useF_misc_model_use; } else if ( type == MDL_ARMOR_HEALTH ) { @@ -662,7 +662,7 @@ void misc_model_breakable_init( gentity_t *ent ) ent->health = 60; } - if ( ent->health ) + if ( ent->health ) { G_SoundIndex("sound/weapons/explosions/cargoexplode.wav"); ent->max_health = ent->health; @@ -695,7 +695,7 @@ void TieFighterThink ( gentity_t *self ) fighterSpeed = VectorNormalize( fighterDir )*1000; AngleVectors( self->currentAngles, fwd, rt, NULL ); - if ( fighterSpeed ) + if ( fighterSpeed ) { float side; @@ -723,7 +723,7 @@ void TieFighterThink ( gentity_t *self ) gentity_t *bolt; bolt = G_Spawn(); - + bolt->classname = "tie_proj"; bolt->nextthink = level.time + 10000; bolt->e_ThinkFunc = thinkF_G_FreeEntity; @@ -866,7 +866,7 @@ Damage: default is none "material" - default is "8 - MAT_NONE" - choose from this list: 0 = MAT_METAL (grey metal) -1 = MAT_GLASS +1 = MAT_GLASS 2 = MAT_ELECTRICAL (sparks only) 3 = MAT_ELEC_METAL (METAL chunks and sparks) 4 = MAT_DRK_STONE (brown stone chunks) @@ -881,18 +881,18 @@ Damage: default is none 13 = MAT_ROPE (for yavin_trial, no chunks, just wispy bits ) 14 = MAT_CRATE2 (red multi-colored crate chunks) 15 = MAT_WHITE_METAL (white angular chunks for Stu, NS_hideout ) -FIXME/TODO: +FIXME/TODO: set size better? multiple damage models? custom explosion effect/sound? */ -void SP_misc_model_breakable( gentity_t *ent ) +void SP_misc_model_breakable( gentity_t *ent ) { char damageModel[MAX_QPATH]; char chunkModel[MAX_QPATH]; char useModel[MAX_QPATH]; int len; - + // Chris F. requested default for misc_model_breakable to be NONE...so don't arbitrarily change this. G_SpawnInt( "material", "8", (int*)&ent->material ); G_SpawnFloat( "radius", "1", &ent->radius ); // used to scale chunk code if desired by a designer @@ -905,14 +905,14 @@ void SP_misc_model_breakable( gentity_t *ent ) damageModel[len] = 0; //chop extension strncpy( chunkModel, damageModel, sizeof(chunkModel)); strncpy( useModel, damageModel, sizeof(useModel)); - + if (ent->takedamage) { //Dead/damaged model if( !(ent->spawnflags & 8) ) { //no dmodel strcat( damageModel, "_d1.md3" ); ent->s.modelindex2 = G_ModelIndex( damageModel ); } - + //Chunk model strcat( chunkModel, "_c1.md3" ); ent->s.modelindex3 = G_ModelIndex( chunkModel ); @@ -954,7 +954,7 @@ void SP_misc_model_breakable( gentity_t *ent ) G_Error("team name %s not recognized", ent->team); } } - + ent->team = NULL; //HACK @@ -991,7 +991,7 @@ void SP_misc_model_breakable( gentity_t *ent ) //---------------------------------- // Really naughty cheating. Put in an EVENT at some point... -extern void cgi_R_GetBModelVerts(int bmodelIndex, vec3_t *verts, vec3_t normal ); +extern void cgi_R_GetBModelVerts(int bmodelIndex, vec3_t *verts, vec3_t normal ); extern void CG_DoGlass( vec3_t verts[4], vec3_t normal, vec3_t dmgPt, vec3_t dmgDir, float dmgRadius ); extern cgs_t cgs; @@ -1021,7 +1021,7 @@ void funcGlassDie( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, i self->s.solid = 0; self->contents = 0; self->clipmask = 0; - gi.linkentity(self); + gi.linkentity(self); if ( self->target && attacker != NULL ) { @@ -1069,7 +1069,7 @@ INVINCIBLE - can only be broken by being used "health" default is 1 */ //----------------------------------------------------- -void SP_func_glass( gentity_t *self ) +void SP_func_glass( gentity_t *self ) { if ( !(self->spawnflags & 1 )) { @@ -1079,7 +1079,7 @@ void SP_func_glass( gentity_t *self ) } } - if ( self->health ) + if ( self->health ) { self->takedamage = qtrue; } @@ -1088,7 +1088,7 @@ void SP_func_glass( gentity_t *self ) self->e_DieFunc = dieF_funcGlassDie; VectorCopy( self->s.origin, self->pos1 ); - + gi.SetBrushModel( self, self->model ); self->svFlags |= (SVF_GLASS_BRUSH|SVF_BBRUSH); self->material = MAT_GLASS; diff --git a/codeJK2/game/g_camera.cpp b/codeJK2/game/g_camera.cpp index e52c6f93b8..67c61fb324 100644 --- a/codeJK2/game/g_camera.cpp +++ b/codeJK2/game/g_camera.cpp @@ -114,7 +114,7 @@ void misc_camera_track_think (gentity_t *self) self->enemy = NULL; } } - + if( !self->enemy) { if( self->target && self->target[0] ) @@ -212,7 +212,7 @@ void cam_point_link( gentity_t *ent ) } void cam_ctrl_point_link( gentity_t *ent ) -{ +{ /* gentity_t *target2 = NULL; target2 = G_Find( NULL, FOFS(targetname), ent->target2 ); @@ -227,7 +227,7 @@ void cam_ctrl_point_link( gentity_t *ent ) // Store the control point here VectorCopy( target2->s.origin, ent->pos1 ); - + //--------------------- if ( ent->target ) { diff --git a/codeJK2/game/g_cmds.cpp b/codeJK2/game/g_cmds.cpp index 7fbc3270d1..ff0ed59863 100644 --- a/codeJK2/game/g_cmds.cpp +++ b/codeJK2/game/g_cmds.cpp @@ -214,7 +214,7 @@ void G_Give( gentity_t *ent, const char *name, const char *args, int argc ) if ( !give_all ) return; } - + if ( !give_all && !Q_stricmp( name, "weaponnum" ) ) { ent->client->ps.stats[STAT_WEAPONS] |= (1 << atoi( args )); @@ -312,7 +312,7 @@ void Cmd_Fx( gentity_t *ent ) if ( gi.argc() == 3 ) { // I guess, only allow one active at a time - while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) + while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) { G_FreeEntity( fx_ent ); } @@ -336,7 +336,7 @@ extern void SP_fx_runner( gentity_t *ent ); } else if ( Q_stricmp( gi.argv(1), "stop" ) == 0 ) { - while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) + while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) { G_FreeEntity( fx_ent ); } @@ -345,7 +345,7 @@ extern void SP_fx_runner( gentity_t *ent ); } else if ( Q_stricmp( gi.argv(1), "delay" ) == 0 ) { - while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) + while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) { if ( gi.argc() == 3 ) { @@ -361,7 +361,7 @@ extern void SP_fx_runner( gentity_t *ent ); } else if ( Q_stricmp( gi.argv(1), "random" ) == 0 ) { - while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) + while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) { if ( gi.argc() == 3 ) { @@ -377,7 +377,7 @@ extern void SP_fx_runner( gentity_t *ent ); } else if ( Q_stricmp( gi.argv(1), "origin" ) == 0 ) { - while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) + while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) { if ( gi.argc() == 5 ) { @@ -389,7 +389,7 @@ extern void SP_fx_runner( gentity_t *ent ); } else { - gi.Printf( S_COLOR_GREEN"FX: current origin is: <%6.2f %6.2f %6.2f>\n", + gi.Printf( S_COLOR_GREEN"FX: current origin is: <%6.2f %6.2f %6.2f>\n", fx_ent->currentOrigin[0], fx_ent->currentOrigin[1], fx_ent->currentOrigin[2] ); } @@ -398,7 +398,7 @@ extern void SP_fx_runner( gentity_t *ent ); } else if ( Q_stricmp( gi.argv(1), "dir" ) == 0 ) { - while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) + while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) { if ( gi.argc() == 5 ) { @@ -414,7 +414,7 @@ extern void SP_fx_runner( gentity_t *ent ); } else { - gi.Printf( S_COLOR_GREEN"FX: current dir is: <%6.2f %6.2f %6.2f>\n", + gi.Printf( S_COLOR_GREEN"FX: current dir is: <%6.2f %6.2f %6.2f>\n", fx_ent->s.angles[0], fx_ent->s.angles[1], fx_ent->s.angles[2] ); } @@ -426,7 +426,7 @@ extern void SP_fx_runner( gentity_t *ent ); gi.Printf( S_COLOR_CYAN"commands: sample usage:\n" ); gi.Printf( S_COLOR_CYAN"----------------------------------------------------------\n" ); gi.Printf( S_COLOR_CYAN"fx play fx play sparks, fx play env/fire\n" ); - gi.Printf( S_COLOR_CYAN"fx stop fx stop\n" ); + gi.Printf( S_COLOR_CYAN"fx stop fx stop\n" ); gi.Printf( S_COLOR_CYAN"fx delay <#> fx delay 1000\n" ); gi.Printf( S_COLOR_CYAN"fx random <#> fx random 200\n" ); gi.Printf( S_COLOR_CYAN"fx origin <#><#><#> fx origin 10 20 30\n" ); @@ -472,7 +472,7 @@ void Cmd_Undying_f (gentity_t *ent) { const char *msg; - if ( !CheatsOk( ent ) ) + if ( !CheatsOk( ent ) ) { return; } @@ -605,7 +605,7 @@ void Cmd_Where_f( gentity_t *ent ) { const char *s = gi.argv(1); const int len = strlen(s); gentity_t *check; - + if ( gi.argc () < 2 ) { gi.Printf("usage: where classname\n"); return; @@ -639,7 +639,7 @@ void UserSpawn( gentity_t *ent, const char *name ) vec3_t vf; vec3_t angles; gentity_t *ent2; - + //Spawn the ent ent2 = G_Spawn(); ent2->classname = G_NewString( name ); //FIXME: This will leave floating memory... @@ -719,13 +719,13 @@ void Cmd_SetViewpos_f( gentity_t *ent ) { Cmd_SetObjective_f ================= */ -void Cmd_SetObjective_f( gentity_t *ent ) +void Cmd_SetObjective_f( gentity_t *ent ) { int objectiveI,status,displayStatus; if ( gi.argc() == 2 ) { objectiveI = atoi(gi.argv(1)); - gi.Printf("objective #%d display status=%d, status=%d\n",objectiveI, + gi.Printf("objective #%d display status=%d, status=%d\n",objectiveI, ent->client->sess.mission_objectives[objectiveI].display, ent->client->sess.mission_objectives[objectiveI].status ); @@ -736,7 +736,7 @@ void Cmd_SetObjective_f( gentity_t *ent ) return; } - if ( !CheatsOk( ent ) ) + if ( !CheatsOk( ent ) ) { return; } @@ -754,7 +754,7 @@ void Cmd_SetObjective_f( gentity_t *ent ) Cmd_ViewObjective_f ================= */ -void Cmd_ViewObjective_f( gentity_t *ent ) +void Cmd_ViewObjective_f( gentity_t *ent ) { int objectiveI; @@ -876,7 +876,7 @@ void Cmd_UseSeeker_f( gentity_t *ent ) if ( ent->client && ent->client->ps.inventory[INV_SEEKER] > 0 && level.time > ent->client->ps.powerups[PW_SEEKER] ) { gentity_t *tent = G_Spawn(); - + if ( tent ) { vec3_t fwd, right, spot; @@ -1024,7 +1024,7 @@ void ClientCommand( int clientNum ) { Cmd_Spawn( ent ); return; } - + if (Q_stricmp (cmd, "give") == 0) Cmd_Give_f (ent); else if (Q_stricmp (cmd, "god") == 0) diff --git a/codeJK2/game/g_functions.cpp b/codeJK2/game/g_functions.cpp index 5a95f8a263..dd35d8ebc2 100644 --- a/codeJK2/game/g_functions.cpp +++ b/codeJK2/game/g_functions.cpp @@ -38,43 +38,43 @@ void GEntity_ThinkFunc(gentity_t *self) switch (self->e_ThinkFunc) { - case thinkF_NULL: + case thinkF_NULL: break; - THINKCASE( funcBBrushDieGo ) - THINKCASE( ExplodeDeath ) - THINKCASE( RespawnItem ) - THINKCASE( G_FreeEntity ) - THINKCASE( FinishSpawningItem ) - THINKCASE( locateCamera ) - THINKCASE( G_RunObject ) - THINKCASE( ReturnToPos1 ) - THINKCASE( Use_BinaryMover_Go ) - THINKCASE( Think_MatchTeam ) - THINKCASE( Think_BeginMoving ) - THINKCASE( Think_SetupTrainTargets ) - THINKCASE( Think_SpawnNewDoorTrigger ) - THINKCASE( ref_link ) - THINKCASE( Think_Target_Delay ) - THINKCASE( target_laser_think ) - THINKCASE( target_laser_start ) - THINKCASE( target_location_linkup ) - THINKCASE( scriptrunner_run ) - THINKCASE( multi_wait ) - THINKCASE( multi_trigger_run ) - THINKCASE( trigger_always_think ) - THINKCASE( AimAtTarget ) - THINKCASE( func_timer_think ) - THINKCASE( NPC_RemoveBody ) - THINKCASE( Disappear ) - THINKCASE( NPC_Think ) - THINKCASE( NPC_Spawn_Go ) - THINKCASE( NPC_Begin ) + THINKCASE( funcBBrushDieGo ) + THINKCASE( ExplodeDeath ) + THINKCASE( RespawnItem ) + THINKCASE( G_FreeEntity ) + THINKCASE( FinishSpawningItem ) + THINKCASE( locateCamera ) + THINKCASE( G_RunObject ) + THINKCASE( ReturnToPos1 ) + THINKCASE( Use_BinaryMover_Go ) + THINKCASE( Think_MatchTeam ) + THINKCASE( Think_BeginMoving ) + THINKCASE( Think_SetupTrainTargets ) + THINKCASE( Think_SpawnNewDoorTrigger ) + THINKCASE( ref_link ) + THINKCASE( Think_Target_Delay ) + THINKCASE( target_laser_think ) + THINKCASE( target_laser_start ) + THINKCASE( target_location_linkup ) + THINKCASE( scriptrunner_run ) + THINKCASE( multi_wait ) + THINKCASE( multi_trigger_run ) + THINKCASE( trigger_always_think ) + THINKCASE( AimAtTarget ) + THINKCASE( func_timer_think ) + THINKCASE( NPC_RemoveBody ) + THINKCASE( Disappear ) + THINKCASE( NPC_Think ) + THINKCASE( NPC_Spawn_Go ) + THINKCASE( NPC_Begin ) THINKCASE( moverCallback ) THINKCASE( anglerCallback ) - THINKCASE( RemoveOwner ) - THINKCASE( MakeOwnerInvis ) - THINKCASE( MakeOwnerEnergy ) + THINKCASE( RemoveOwner ) + THINKCASE( MakeOwnerInvis ) + THINKCASE( MakeOwnerEnergy ) THINKCASE( func_usable_think ) THINKCASE( misc_dlight_think ) THINKCASE( health_think ) @@ -128,7 +128,7 @@ void GEntity_ThinkFunc(gentity_t *self) THINKCASE( panel_turret_think ) THINKCASE( welder_think ) THINKCASE( gas_random_jet ) - THINKCASE( poll_converter ) // dumb loop sound handling + THINKCASE( poll_converter ) // dumb loop sound handling THINKCASE( spawn_rack_goods ) // delay spawn of goods to help on ents default: @@ -161,12 +161,12 @@ void CEntity_ThinkFunc(centity_s *cent) void GEntity_ReachedFunc(gentity_t *self) -{ +{ //#define REACHEDCASE(blah) case reachedF_ ## blah: blah(self); OutputDebugString(va("%s\n",#blah));break; #define REACHEDCASE(blah) case reachedF_ ## blah: blah(self); break; switch (self->e_ReachedFunc) - { + { case reachedF_NULL: break; @@ -193,8 +193,8 @@ void GEntity_BlockedFunc(gentity_t *self, gentity_t *other) case blockedF_NULL: break; - BLOCKEDCASE( Blocked_Door ) - BLOCKEDCASE( Blocked_Mover ) + BLOCKEDCASE( Blocked_Door ) + BLOCKEDCASE( Blocked_Mover ) default: Com_Error(ERR_DROP, "GEntity_BlockedFunc: case %d not handled!\n",self->e_BlockedFunc); diff --git a/codeJK2/game/g_functions.h b/codeJK2/game/g_functions.h index 23e94d89df..d41cb92e99 100644 --- a/codeJK2/game/g_functions.h +++ b/codeJK2/game/g_functions.h @@ -36,7 +36,7 @@ along with this program; if not, see . #undef dieFunc_t // void (*think)(gentity_t *self); -typedef enum +typedef enum { thinkF_NULL = 0, // @@ -45,7 +45,7 @@ typedef enum thinkF_ExplodeDeath, thinkF_RespawnItem, thinkF_G_FreeEntity, - thinkF_FinishSpawningItem, + thinkF_FinishSpawningItem, thinkF_locateCamera, thinkF_G_RunObject, thinkF_ReturnToPos1, @@ -174,7 +174,7 @@ extern void RemoveOwner ( gentity_t *ent ); extern void MakeOwnerInvis ( gentity_t *ent ); extern void MakeOwnerEnergy ( gentity_t *ent ); extern void func_usable_think ( gentity_t *self ); -extern void misc_dlight_think ( gentity_t *ent ); +extern void misc_dlight_think ( gentity_t *ent ); extern void laser_link ( gentity_t *ent ); extern void blow_chunks_link ( gentity_t *ent ); extern void health_think ( gentity_t *ent ); @@ -234,7 +234,7 @@ extern void spawn_rack_goods ( gentity_t *self ); // void (*clThink)(centity_s *cent); //Think func for equivalent centity typedef enum { - clThinkF_NULL = 0, + clThinkF_NULL = 0, // clThinkF_CG_DLightThink, clThinkF_CG_MatrixEffect, @@ -274,7 +274,7 @@ typedef enum blockedF_NULL = 0, // blockedF_Blocked_Door, - blockedF_Blocked_Mover + blockedF_Blocked_Mover } blockedFunc_t; @@ -287,7 +287,7 @@ extern void Blocked_Mover (gentity_t *self, gentity_t *other); // void (*touch)(gentity_t *self, gentity_t *other, trace_t *trace); typedef enum -{ +{ touchF_NULL = 0, // touchF_Touch_Item, @@ -415,20 +415,20 @@ typedef enum extern void funcBBrushUse ( gentity_t *self, gentity_t *other, gentity_t *activator); extern void misc_model_use ( gentity_t *self, gentity_t *other, gentity_t *activator); extern void Use_Item ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void Use_Shooter ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void GoExplodeDeath ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void Use_BinaryMover ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void use_wall ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void Use_Target_Give ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void Use_Target_Delay ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void Use_Target_Score ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void Use_Target_Print ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void Use_Target_Speaker ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void Use_Shooter ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void GoExplodeDeath ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void Use_BinaryMover ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void use_wall ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void Use_Target_Give ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void Use_Target_Delay ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void Use_Target_Score ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void Use_Target_Print ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void Use_Target_Speaker ( gentity_t *self, gentity_t *other, gentity_t *activator); extern void target_laser_use ( gentity_t *self, gentity_t *other, gentity_t *activator); extern void target_relay_use ( gentity_t *self, gentity_t *other, gentity_t *activator); extern void target_kill_use ( gentity_t *self, gentity_t *other, gentity_t *activator); extern void target_counter_use ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void target_random_use ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void target_random_use ( gentity_t *self, gentity_t *other, gentity_t *activator); extern void target_scriptrunner_use ( gentity_t *self, gentity_t *other, gentity_t *activator); extern void target_gravity_change_use ( gentity_t *self, gentity_t *other, gentity_t *activator); extern void target_friction_change_use ( gentity_t *self, gentity_t *other, gentity_t *activator); diff --git a/codeJK2/game/g_items.h b/codeJK2/game/g_items.h index 742369afd3..608dbbd4b2 100644 --- a/codeJK2/game/g_items.h +++ b/codeJK2/game/g_items.h @@ -26,7 +26,7 @@ along with this program; if not, see . #define __ITEMS_H__ // Items enums -enum +enum { ITM_NONE, @@ -90,7 +90,7 @@ ITM_GOODIE_KEY_PICKUP, ITM_SECURITY_KEY_PICKUP, ITM_NUM_ITEMS -}; +}; // Inventory item enums enum //# item_e @@ -99,7 +99,7 @@ enum //# item_e INV_BACTA_CANISTER, INV_SEEKER, INV_LIGHTAMP_GOGGLES, - INV_SENTRY, + INV_SENTRY, //# #eol INV_GOODIE_KEY, // don't want to include keys in the icarus list INV_SECURITY_KEY, diff --git a/codeJK2/game/g_local.h b/codeJK2/game/g_local.h index 0c2bf4fdf7..40dbdbb544 100644 --- a/codeJK2/game/g_local.h +++ b/codeJK2/game/g_local.h @@ -42,7 +42,7 @@ along with this program; if not, see . #define BODY_QUEUE_SIZE 8 -#define Q3_INFINITE 16777216 +#define Q3_INFINITE 16777216 #define FRAMETIME 100 // msec #define EVENT_VALID_MSEC 300 @@ -88,7 +88,7 @@ along with this program; if not, see . #define MAX_INTEREST_POINTS 64 -typedef struct +typedef struct { vec3_t origin; char *target; @@ -98,7 +98,7 @@ typedef struct #define MAX_COMBAT_POINTS 512 -typedef struct +typedef struct { vec3_t origin; int flags; diff --git a/codeJK2/game/g_mem.cpp b/codeJK2/game/g_mem.cpp index 4e46abd212..bd8ff91efa 100644 --- a/codeJK2/game/g_mem.cpp +++ b/codeJK2/game/g_mem.cpp @@ -43,7 +43,7 @@ void *G_Alloc( int size ) { allocPoint += size; - + return gi.Malloc(size, TAG_G_ALLOC, qfalse); } diff --git a/codeJK2/game/g_missile.cpp b/codeJK2/game/g_missile.cpp index b340f302aa..aa8d6c789c 100644 --- a/codeJK2/game/g_missile.cpp +++ b/codeJK2/game/g_missile.cpp @@ -26,7 +26,7 @@ along with this program; if not, see . #include "g_local.h" #include "g_functions.h" #include "wp_saber.h" -#include "bg_local.h" +#include "bg_local.h" extern qboolean InFront( vec3_t spot, vec3_t from, vec3_t fromAngles, float threshHold = 0.0f ); qboolean LogAccuracyHit( gentity_t *target, gentity_t *attacker ); @@ -79,7 +79,7 @@ void G_MissileReflectEffect( gentity_t *ent, vec3_t org, vec3_t dir ) //------------------------------------------------------------------------- static void G_MissileStick( gentity_t *missile, gentity_t *other, trace_t *tr ) -{ +{ if ( other->NPC || !Q_stricmp( other->classname, "misc_model_breakable" )) { // we bounce off of NPC's and misc model breakables because sticking to them requires too much effort @@ -96,7 +96,7 @@ static void G_MissileStick( gentity_t *missile, gentity_t *other, trace_t *tr ) missile->s.pos.trTime = level.time - 10; // move a bit on the first frame // check for stop - if ( tr->entityNum >= 0 && tr->entityNum < ENTITYNUM_WORLD && + if ( tr->entityNum >= 0 && tr->entityNum < ENTITYNUM_WORLD && tr->plane.normal[2] > 0.7 && missile->s.pos.trDelta[2] < 40 ) //this can happen even on very slightly sloped walls, so changed it from > 0 to > 0.7 { missile->nextthink = level.time + 100; @@ -132,7 +132,7 @@ G_ReflectMissile ================ */ extern gentity_t *Jedi_FindEnemyInCone( gentity_t *self, gentity_t *fallback, float minDot ); -void G_ReflectMissile( gentity_t *ent, gentity_t *missile, vec3_t forward ) +void G_ReflectMissile( gentity_t *ent, gentity_t *missile, vec3_t forward ) { vec3_t bounce_dir; int i; @@ -148,7 +148,7 @@ void G_ReflectMissile( gentity_t *ent, gentity_t *missile, vec3_t forward ) //save the original speed speed = VectorNormalize( missile->s.pos.trDelta ); - if ( ent && owner && owner->client && !owner->client->ps.saberInFlight && + if ( ent && owner && owner->client && !owner->client->ps.saberInFlight && (owner->client->ps.forcePowerLevel[FP_SABER_DEFENSE] > FORCE_LEVEL_2 || (owner->client->ps.forcePowerLevel[FP_SABER_DEFENSE]>FORCE_LEVEL_1&&!Q_irand( 0, 3 )) ) ) {//if high enough defense skill and saber in-hand (100% at level 3, 25% at level 2, 0% at level 1), reflections are perfectly deflected toward an enemy gentity_t *enemy; @@ -169,8 +169,8 @@ void G_ReflectMissile( gentity_t *ent, gentity_t *missile, vec3_t forward ) bullseye[2] += Q_irand( -16, 4 ); VectorSubtract( bullseye, missile->currentOrigin, bounce_dir ); VectorNormalize( bounce_dir ); - if ( !PM_SaberInParry( owner->client->ps.saberMove ) - && !PM_SaberInReflect( owner->client->ps.saberMove ) + if ( !PM_SaberInParry( owner->client->ps.saberMove ) + && !PM_SaberInReflect( owner->client->ps.saberMove ) && !PM_SaberInIdle( owner->client->ps.saberMove ) ) {//a bit more wild if ( PM_SaberInAttack( owner->client->ps.saberMove ) @@ -233,8 +233,8 @@ void G_ReflectMissile( gentity_t *ent, gentity_t *missile, vec3_t forward ) bounce_dir[i] += Q_flrand( -0.2f, 0.2f ); } } - if ( !PM_SaberInParry( owner->client->ps.saberMove ) - && !PM_SaberInReflect( owner->client->ps.saberMove ) + if ( !PM_SaberInParry( owner->client->ps.saberMove ) + && !PM_SaberInReflect( owner->client->ps.saberMove ) && !PM_SaberInIdle( owner->client->ps.saberMove ) ) {//a bit more wild if ( PM_SaberInAttack( owner->client->ps.saberMove ) @@ -290,7 +290,7 @@ G_BounceRollMissile ================ */ -void G_BounceRollMissile( gentity_t *ent, trace_t *trace ) +void G_BounceRollMissile( gentity_t *ent, trace_t *trace ) { vec3_t velocity, normal; float dot, speedXY, velocityZ, normalZ; @@ -324,7 +324,7 @@ void G_BounceRollMissile( gentity_t *ent, trace_t *trace ) } // check for stop - if ( speedXY <= 0 ) + if ( speedXY <= 0 ) { G_SetOrigin( ent, trace->endpos ); VectorCopy( ent->currentAngles, ent->s.apos.trBase ); @@ -361,7 +361,7 @@ void G_BounceMissile( gentity_t *ent, trace_t *trace ) { dot = DotProduct( velocity, trace->plane.normal ); VectorMA( velocity, -2*dot, trace->plane.normal, ent->s.pos.trDelta ); - if ( ent->s.eFlags & EF_BOUNCE_SHRAPNEL ) + if ( ent->s.eFlags & EF_BOUNCE_SHRAPNEL ) { VectorScale( ent->s.pos.trDelta, 0.25f, ent->s.pos.trDelta ); ent->s.pos.trType = TR_GRAVITY; @@ -374,7 +374,7 @@ void G_BounceMissile( gentity_t *ent, trace_t *trace ) { return; } } - else if ( ent->s.eFlags & EF_BOUNCE_HALF ) + else if ( ent->s.eFlags & EF_BOUNCE_HALF ) { VectorScale( ent->s.pos.trDelta, 0.5, ent->s.pos.trDelta ); @@ -421,8 +421,8 @@ void G_BounceMissile( gentity_t *ent, trace_t *trace ) { VectorCopy( ent->currentOrigin, ent->s.pos.trBase ); VectorCopy( trace->plane.normal, ent->pos1 ); - if ( ent->s.weapon != WP_SABER - && ent->s.weapon != WP_THERMAL + if ( ent->s.weapon != WP_SABER + && ent->s.weapon != WP_THERMAL && ent->e_clThinkFunc != clThinkF_CG_Limb && ent->e_ThinkFunc != thinkF_LimbThink ) {//not a saber, bouncing thermal or limb @@ -430,7 +430,7 @@ void G_BounceMissile( gentity_t *ent, trace_t *trace ) { ent->owner = NULL; } } - + /* ================ G_MissileImpact @@ -444,15 +444,15 @@ extern qboolean W_AccuracyLoggableWeapon( int weapon, qboolean alt_fire, int mod void G_MissileImpacted( gentity_t *ent, gentity_t *other, vec3_t impactPos, vec3_t normal, int hitLoc=HL_NONE ) { // impact damage - if ( other->takedamage ) + if ( other->takedamage ) { // FIXME: wrong damage direction? - if ( ent->damage ) + if ( ent->damage ) { vec3_t velocity; EvaluateTrajectoryDelta( &ent->s.pos, level.time, velocity ); - if ( VectorLength( velocity ) == 0 ) + if ( VectorLength( velocity ) == 0 ) { velocity[2] = 1; // stepped on a grenade } @@ -481,7 +481,7 @@ void G_MissileImpacted( gentity_t *ent, gentity_t *other, vec3_t impactPos, vec3 } G_Damage( other, ent, ent->owner, velocity, - impactPos, damage, + impactPos, damage, ent->dflags, ent->methodOfDeath, hitLoc); } } @@ -489,13 +489,13 @@ void G_MissileImpacted( gentity_t *ent, gentity_t *other, vec3_t impactPos, vec3 // is it cheaper in bandwidth to just remove this ent and create a new // one, rather than changing the missile into the explosion? //G_FreeEntity(ent); - - if ( (other->takedamage && other->client ) || (ent->s.weapon == WP_FLECHETTE && other->contents&CONTENTS_LIGHTSABER) ) + + if ( (other->takedamage && other->client ) || (ent->s.weapon == WP_FLECHETTE && other->contents&CONTENTS_LIGHTSABER) ) { G_AddEvent( ent, EV_MISSILE_HIT, DirToByte( normal ) ); ent->s.otherEntityNum = other->s.number; - } - else + } + else { G_AddEvent( ent, EV_MISSILE_MISS, DirToByte( normal ) ); ent->s.otherEntityNum = other->s.number; @@ -521,9 +521,9 @@ void G_MissileImpacted( gentity_t *ent, gentity_t *other, vec3_t impactPos, vec3 G_SetOrigin( ent, impactPos ); // splash damage (doesn't apply to person directly hit) - if ( ent->splashDamage ) + if ( ent->splashDamage ) { - G_RadiusDamage( impactPos, ent->owner, ent->splashDamage, ent->splashRadius, + G_RadiusDamage( impactPos, ent->owner, ent->splashDamage, ent->splashRadius, other, ent->splashMethodOfDeath ); } @@ -547,7 +547,7 @@ static void G_MissileAddAlerts( gentity_t *ent ) } //------------------------------------------------------ -void G_MissileImpact( gentity_t *ent, trace_t *trace, int hitLoc=HL_NONE ) +void G_MissileImpact( gentity_t *ent, trace_t *trace, int hitLoc=HL_NONE ) { gentity_t *other; vec3_t diff; @@ -573,7 +573,7 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace, int hitLoc=HL_NONE ) { if ( !ent->lastEnemy || ent->lastEnemy == ent->owner ) {//a missile that was not reflected or, if so, still is owned by original owner - if( LogAccuracyHit( other, ent->owner ) ) + if( LogAccuracyHit( other, ent->owner ) ) { ent->owner->client->ps.persistant[PERS_ACCURACY_HITS]++; } @@ -630,10 +630,10 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace, int hitLoc=HL_NONE ) } } - if ( bounce ) + if ( bounce ) { // Check to see if there is a bounce count - if ( ent->bounceCount ) + if ( ent->bounceCount ) { // decrement number of bounces and then see if it should be done bouncing if ( !(--ent->bounceCount) ) { @@ -648,8 +648,8 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace, int hitLoc=HL_NONE ) } G_BounceMissile( ent, trace ); - - if ( ent->owner )//&& ent->owner->s.number == 0 ) + + if ( ent->owner )//&& ent->owner->s.number == 0 ) { G_MissileAddAlerts( ent ); } @@ -657,10 +657,10 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace, int hitLoc=HL_NONE ) return; } - + // I would glom onto the EF_BOUNCE code section above, but don't feel like risking breaking something else - if ( (!other->takedamage && ( ent->s.eFlags&(EF_BOUNCE_SHRAPNEL) ) ) - || ((trace->surfaceFlags&SURF_FORCEFIELD)&&!ent->splashDamage&&!ent->splashRadius) ) + if ( (!other->takedamage && ( ent->s.eFlags&(EF_BOUNCE_SHRAPNEL) ) ) + || ((trace->surfaceFlags&SURF_FORCEFIELD)&&!ent->splashDamage&&!ent->splashRadius) ) { if ( !(other->contents&CONTENTS_LIGHTSABER) || g_spskill->integer <= 0//on easy, it reflects all shots @@ -680,11 +680,11 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace, int hitLoc=HL_NONE ) } if ( (!other->takedamage || (other->client && other->health <= 0)) - && ent->s.weapon == WP_THERMAL + && ent->s.weapon == WP_THERMAL && !ent->alt_fire ) {//rolling thermal det - FIXME: make this an eFlag like bounce & stick!!! //G_BounceRollMissile( ent, trace ); - if ( ent->owner )//&& ent->owner->s.number == 0 ) + if ( ent->owner )//&& ent->owner->s.number == 0 ) { G_MissileAddAlerts( ent ); } @@ -693,9 +693,9 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace, int hitLoc=HL_NONE ) } // check for sticking - if ( ent->s.eFlags & EF_MISSILE_STICK ) + if ( ent->s.eFlags & EF_MISSILE_STICK ) { - if ( ent->owner )//&& ent->owner->s.number == 0 ) + if ( ent->owner )//&& ent->owner->s.number == 0 ) { //Add the event if ( ent->s.weapon == WP_TRIP_MINE ) @@ -730,9 +730,9 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace, int hitLoc=HL_NONE ) || (g_spskill->integer >= 2 && ent->s.weapon != WP_FLECHETTE && ent->s.weapon != WP_DEMP2 && ent->s.weapon != WP_BOWCASTER && ent->s.weapon != WP_REPEATER )//on hard it won't reflect flechette, demp, repeater or bowcaster shots ) && (!ent->splashDamage || !ent->splashRadius) )//this would be cool, though, to "bat" the thermal det away... - { + { //FIXME: take other's owner's FP_SABER_DEFENSE into account here somehow? - if ( !other->owner || !other->owner->client || other->owner->client->ps.saberInFlight || InFront( ent->currentOrigin, other->owner->currentOrigin, other->owner->client->ps.viewangles, SABER_REFLECT_MISSILE_CONE ) )//other->owner->s.number != 0 || + if ( !other->owner || !other->owner->client || other->owner->client->ps.saberInFlight || InFront( ent->currentOrigin, other->owner->currentOrigin, other->owner->client->ps.viewangles, SABER_REFLECT_MISSILE_CONE ) )//other->owner->s.number != 0 || {//Jedi cannot block shots from behind! if ( (other->owner->client->ps.forcePowerLevel[FP_SABER_DEFENSE] > FORCE_LEVEL_1 && Q_irand( 0, 3 )) ||(other->owner->client->ps.forcePowerLevel[FP_SABER_DEFENSE] > FORCE_LEVEL_0 && Q_irand( 0, 1 ))) @@ -770,7 +770,7 @@ G_ExplodeMissile Explode a missile without an impact ================ */ -void G_ExplodeMissile( gentity_t *ent ) +void G_ExplodeMissile( gentity_t *ent ) { vec3_t dir; vec3_t origin; @@ -795,7 +795,7 @@ void G_ExplodeMissile( gentity_t *ent ) ent->freeAfterEvent = qtrue;*/ // splash damage - if ( ent->splashDamage ) + if ( ent->splashDamage ) { G_RadiusDamage( ent->currentOrigin, ent->owner, ent->splashDamage, ent->splashRadius, NULL , ent->splashMethodOfDeath ); @@ -814,7 +814,7 @@ void G_RunStuckMissile( gentity_t *ent ) { gentity_t *other = &g_entities[ent->s.groundEntityNum]; - if ( (!VectorCompare( vec3_origin, other->s.pos.trDelta ) && other->s.pos.trType != TR_STATIONARY) || + if ( (!VectorCompare( vec3_origin, other->s.pos.trDelta ) && other->s.pos.trType != TR_STATIONARY) || (!VectorCompare( vec3_origin, other->s.apos.trDelta ) && other->s.apos.trType != TR_STATIONARY) ) {//thing I stuck to is moving or rotating now, kill me G_Damage( ent, other, other, NULL, NULL, 99999, 0, MOD_CRUSH ); @@ -846,7 +846,7 @@ int G_GroundTrace( gentity_t *ent, pml_t *pPml ) pPml->groundTrace = trace; // do something corrective if the trace starts in a solid... - if ( trace.allsolid ) + if ( trace.allsolid ) { pPml->groundPlane = qfalse; pPml->walking = qfalse; @@ -854,7 +854,7 @@ int G_GroundTrace( gentity_t *ent, pml_t *pPml ) } // if the trace didn't hit anything, we are in free fall - if ( trace.fraction == 1.0 ) + if ( trace.fraction == 1.0 ) { pPml->groundPlane = qfalse; pPml->walking = qfalse; @@ -862,15 +862,15 @@ int G_GroundTrace( gentity_t *ent, pml_t *pPml ) } // check if getting thrown off the ground - if ( ent->s.pos.trDelta[2] > 0 && DotProduct( ent->s.pos.trDelta, trace.plane.normal ) > 10 ) + if ( ent->s.pos.trDelta[2] > 0 && DotProduct( ent->s.pos.trDelta, trace.plane.normal ) > 10 ) { pPml->groundPlane = qfalse; pPml->walking = qfalse; return ENTITYNUM_NONE; } - + // slopes that are too steep will not be considered onground - if ( trace.plane.normal[2] < MIN_WALK_NORMAL ) + if ( trace.plane.normal[2] < MIN_WALK_NORMAL ) { pPml->groundPlane = qtrue; pPml->walking = qfalse; @@ -881,7 +881,7 @@ int G_GroundTrace( gentity_t *ent, pml_t *pPml ) pPml->walking = qtrue; /* - if ( ent->s.groundEntityNum == ENTITYNUM_NONE ) + if ( ent->s.groundEntityNum == ENTITYNUM_NONE ) { // just hit the ground } @@ -895,11 +895,11 @@ int G_GroundTrace( gentity_t *ent, pml_t *pPml ) G_RollMissile -reworking the rolling object code, -still needs to stop bobbling up & down, -need to get roll angles right, -and need to maybe make the transfer of velocity happen on impacts? -Also need bounce sound for bounces off a floor. +reworking the rolling object code, +still needs to stop bobbling up & down, +need to get roll angles right, +and need to maybe make the transfer of velocity happen on impacts? +Also need bounce sound for bounces off a floor. Also need to not bounce as much off of enemies Also gets stuck inside thrower if looking down when thrown @@ -928,11 +928,11 @@ void G_RollMissile( gentity_t *ent ) gentity_t *hitEnt = NULL; memset( &objPML, 0, sizeof( objPML ) ); - + G_GroundTrace( ent, &objPML ); objPML.frametime = (level.time - level.previousTime)*0.001; - + numbumps = 4; VectorCopy ( ent->s.pos.trDelta, primal_velocity ); @@ -941,7 +941,7 @@ void G_RollMissile( gentity_t *ent ) endVelocity[2] -= g_gravity->value * objPML.frametime; ent->s.pos.trDelta[2] = ( ent->s.pos.trDelta[2] + endVelocity[2] ) * 0.5; primal_velocity[2] = endVelocity[2]; - if ( objPML.groundPlane ) + if ( objPML.groundPlane ) {//FIXME: never happens! // slide along the ground plane PM_ClipVelocity( ent->s.pos.trDelta, objPML.groundTrace.plane.normal, ent->s.pos.trDelta, BUMPCLIP ); @@ -951,12 +951,12 @@ void G_RollMissile( gentity_t *ent ) time_left = objPML.frametime; // never turn against the ground plane - if ( objPML.groundPlane ) + if ( objPML.groundPlane ) { numplanes = 1; VectorCopy( objPML.groundTrace.plane.normal, planes[0] ); - } - else + } + else { numplanes = 0; } @@ -967,7 +967,7 @@ void G_RollMissile( gentity_t *ent ) numplanes++; */ - for ( bumpcount = 0; bumpcount < numbumps; bumpcount++ ) + for ( bumpcount = 0; bumpcount < numbumps; bumpcount++ ) { // calculate position we are trying to move to VectorMA( ent->currentOrigin, time_left, ent->s.pos.trDelta, end ); @@ -999,13 +999,13 @@ void G_RollMissile( gentity_t *ent ) return;// qtrue; } - if ( trace.fraction > 0 ) + if ( trace.fraction > 0 ) { // actually covered some distance VectorCopy( trace.endpos, ent->currentOrigin ); } - if ( trace.fraction == 1 ) + if ( trace.fraction == 1 ) { break; // moved the entire distance } @@ -1025,7 +1025,7 @@ void G_RollMissile( gentity_t *ent ) time_left -= time_left * trace.fraction; - if ( numplanes >= MAX_CLIP_PLANES ) + if ( numplanes >= MAX_CLIP_PLANES ) { // this shouldn't really happen VectorClear( ent->s.pos.trDelta ); @@ -1037,15 +1037,15 @@ void G_RollMissile( gentity_t *ent ) // out along it, which fixes some epsilon issues with // non-axial planes // - for ( i = 0 ; i < numplanes ; i++ ) + for ( i = 0 ; i < numplanes ; i++ ) { - if ( DotProduct( trace.plane.normal, planes[i] ) > 0.99 ) + if ( DotProduct( trace.plane.normal, planes[i] ) > 0.99 ) { VectorAdd( trace.plane.normal, ent->s.pos.trDelta, ent->s.pos.trDelta ); break; } } - if ( i < numplanes ) + if ( i < numplanes ) { continue; } @@ -1055,7 +1055,7 @@ void G_RollMissile( gentity_t *ent ) // // modify velocity so it parallels all of the clip planes // - if ( g_entities[trace.entityNum].inuse && g_entities[trace.entityNum].client ) + if ( g_entities[trace.entityNum].inuse && g_entities[trace.entityNum].client ) {//hit a person, bounce off much less bounceAmt = OVERCLIP; } @@ -1065,16 +1065,16 @@ void G_RollMissile( gentity_t *ent ) } // find a plane that it enters - for ( i = 0 ; i < numplanes ; i++ ) + for ( i = 0 ; i < numplanes ; i++ ) { into = DotProduct( ent->s.pos.trDelta, planes[i] ); - if ( into >= 0.1 ) + if ( into >= 0.1 ) { continue; // move doesn't interact with the plane } // see how hard we are hitting things - if ( -into > pml.impactSpeed ) + if ( -into > pml.impactSpeed ) { pml.impactSpeed = -into; } @@ -1086,13 +1086,13 @@ void G_RollMissile( gentity_t *ent ) PM_ClipVelocity( endVelocity, planes[i], endClipVelocity, bounceAmt ); // see if there is a second plane that the new move enters - for ( j = 0 ; j < numplanes ; j++ ) + for ( j = 0 ; j < numplanes ; j++ ) { - if ( j == i ) + if ( j == i ) { continue; } - if ( DotProduct( clipVelocity, planes[j] ) >= 0.1 ) + if ( DotProduct( clipVelocity, planes[j] ) >= 0.1 ) { continue; // move doesn't interact with the plane } @@ -1102,7 +1102,7 @@ void G_RollMissile( gentity_t *ent ) PM_ClipVelocity( endClipVelocity, planes[j], endClipVelocity, bounceAmt ); // see if it goes back into the first clip plane - if ( DotProduct( clipVelocity, planes[i] ) >= 0 ) + if ( DotProduct( clipVelocity, planes[i] ) >= 0 ) { continue; } @@ -1119,13 +1119,13 @@ void G_RollMissile( gentity_t *ent ) VectorScale( dir, d, endClipVelocity ); // see if there is a third plane the the new move enters - for ( k = 0 ; k < numplanes ; k++ ) + for ( k = 0 ; k < numplanes ; k++ ) { - if ( k == i || k == j ) + if ( k == i || k == j ) { continue; } - if ( DotProduct( clipVelocity, planes[k] ) >= 0.1 ) + if ( DotProduct( clipVelocity, planes[k] ) >= 0.1 ) { continue; // move doesn't interact with the plane } @@ -1148,7 +1148,7 @@ void G_RollMissile( gentity_t *ent ) // don't change velocity if in a timer (FIXME: is this correct?) /* - if ( pm->ps->pm_time ) + if ( pm->ps->pm_time ) { VectorCopy( primal_velocity, ent->s.pos.trDelta ); } @@ -1163,7 +1163,7 @@ G_RunMissile ================ */ void G_MoverTouchPushTriggers( gentity_t *ent, vec3_t oldOrg ); -void G_RunMissile( gentity_t *ent ) +void G_RunMissile( gentity_t *ent ) { vec3_t origin, oldOrg; trace_t tr; @@ -1190,7 +1190,7 @@ void G_RunMissile( gentity_t *ent ) { vec3_t ang, fwdDir, rtDir; float speed; - + ent->s.apos.trType = TR_INTERPOLATE; VectorSet( ang, 0, ent->s.apos.trBase[1], 0 ); AngleVectors( ang, fwdDir, rtDir, NULL ); @@ -1216,21 +1216,21 @@ void G_RunMissile( gentity_t *ent ) // trace a line from the previous position to the current position, // ignoring interactions with the missile owner /* - gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, + gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, ent->owner ? ent->owner->s.number : ENTITYNUM_NONE, ent->clipmask, G2_RETURNONHIT, 10 ); */ - gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, + gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, ent->owner ? ent->owner->s.number : ent->s.number, ent->clipmask, G2_COLLIDE, 10 ); /* if ( !VectorCompare( ent->mins, vec3_origin ) || !VectorCompare( ent->maxs, vec3_origin ) ) {//don't do ghoul trace if ent has size because g2 just ignores that anyway - gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, + gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, ent->owner ? ent->owner->s.number : ENTITYNUM_NONE, ent->clipmask, G2_NOCOLLIDE, 10 ); } else //Now we always do ghoul trace, regardless of bbox size of missile, this is presuming that non-point ghoul traces will be possible...? { - gi.trace( &tr, ent->currentOrigin, vec3_origin, vec3_origin, origin, + gi.trace( &tr, ent->currentOrigin, vec3_origin, vec3_origin, origin, ent->owner ? ent->owner->s.number : ENTITYNUM_NONE, ent->clipmask, G2_RETURNONHIT, 10 ); } */ @@ -1245,7 +1245,7 @@ void G_RunMissile( gentity_t *ent ) EvaluateTrajectory( &ent->s.pos, level.time, origin ); // trace a line from the previous position to the current position, // ignoring interactions with the missile owner - gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, + gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, ent->owner ? ent->owner->s.number : ENTITYNUM_NONE, ent->clipmask | CONTENTS_GHOUL2 ); if ( tr.fraction == 1.0f ) { @@ -1280,7 +1280,7 @@ void G_RunMissile( gentity_t *ent ) //FIXME: Rolling things hitting G2 polys is weird /////////////////////////////////////////////////////// -//? if ( tr.fraction != 1 ) +//? if ( tr.fraction != 1 ) { // did we hit or go near a Ghoul2 model? // qboolean hitModel = qfalse; @@ -1330,7 +1330,7 @@ void G_RunMissile( gentity_t *ent ) // now attach an effect to this new bolt // Bolting on this effect just looks dumb and adds lots of unnecessary effects to the scene -// +// // G_PlayEffect( G_EffectIndex( "blaster/smoke_bolton") , coll.mModelIndex, newBolt, hitEnt->s.number); // // @@ -1349,7 +1349,7 @@ void G_RunMissile( gentity_t *ent ) } ///////////////////////////////////////////////////////// - if ( tr.startsolid ) + if ( tr.startsolid ) { tr.fraction = 0; } @@ -1365,7 +1365,7 @@ void G_RunMissile( gentity_t *ent ) // check think function G_RunThink( ent ); - if ( ent->s.eType != ET_MISSILE ) + if ( ent->s.eType != ET_MISSILE ) { return; // exploded } @@ -1397,7 +1397,7 @@ void G_RunMissile( gentity_t *ent ) if ( ent->s.weapon == WP_TRIP_MINE ) {//??? } - else + else { if ( ent->s.weapon == WP_ROCKET_LAUNCHER && ent->e_ThinkFunc == thinkF_rocketThink ) {//homing rocket- run like hell! @@ -1416,13 +1416,13 @@ void G_RunMissile( gentity_t *ent ) } } - if ( tr.fraction == 1 ) + if ( tr.fraction == 1 ) { return; } // never explode or bounce on sky - if ( tr.surfaceFlags & SURF_NOIMPACT ) + if ( tr.surfaceFlags & SURF_NOIMPACT ) { G_FreeEntity( ent ); return; diff --git a/codeJK2/game/g_object.cpp b/codeJK2/game/g_object.cpp index 100c93965d..c4d35c7b26 100644 --- a/codeJK2/game/g_object.cpp +++ b/codeJK2/game/g_object.cpp @@ -34,7 +34,7 @@ G_BounceMissile ================ */ -void G_BounceObject( gentity_t *ent, trace_t *trace ) +void G_BounceObject( gentity_t *ent, trace_t *trace ) { vec3_t velocity; float dot; @@ -52,7 +52,7 @@ void G_BounceObject( gentity_t *ent, trace_t *trace ) VectorMA( velocity, -2*dot*bounceFactor, trace->plane.normal, ent->s.pos.trDelta ); //FIXME: customized or material-based impact/bounce sounds - if ( ent->s.eFlags & EF_BOUNCE_HALF ) + if ( ent->s.eFlags & EF_BOUNCE_HALF ) { VectorScale( ent->s.pos.trDelta, 0.5, ent->s.pos.trDelta ); @@ -90,14 +90,14 @@ G_RunObject */ extern void DoImpact( gentity_t *self, gentity_t *other, qboolean damageSelf ); extern void pitch_roll_for_slope( gentity_t *forwhom, vec3_t pass_slope ); -void G_RunObject( gentity_t *ent ) +void G_RunObject( gentity_t *ent ) { vec3_t origin, oldOrg; trace_t tr; gentity_t *traceEnt = NULL; //FIXME: floaters need to stop floating up after a while, even if gravity stays negative? - if ( ent->s.pos.trType == TR_STATIONARY )//g_gravity->value <= 0 && + if ( ent->s.pos.trType == TR_STATIONARY )//g_gravity->value <= 0 && { ent->s.pos.trType = TR_GRAVITY; VectorCopy( ent->currentOrigin, ent->s.pos.trBase ); @@ -122,16 +122,16 @@ void G_RunObject( gentity_t *ent ) } // trace a line from the previous position to the current position, // ignoring interactions with the missile owner - gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, + gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, ent->owner ? ent->owner->s.number : ent->s.number, ent->clipmask, G2_NOCOLLIDE, 0 ); - if ( !tr.startsolid && !tr.allsolid && tr.fraction ) + if ( !tr.startsolid && !tr.allsolid && tr.fraction ) { VectorCopy( tr.endpos, ent->currentOrigin ); gi.linkentity( ent ); } else - //if ( tr.startsolid ) + //if ( tr.startsolid ) { tr.fraction = 0; } @@ -152,7 +152,7 @@ void G_RunObject( gentity_t *ent ) } */ - if ( tr.fraction == 1 ) + if ( tr.fraction == 1 ) { if ( g_gravity->value <= 0 ) { @@ -208,7 +208,7 @@ void G_RunObject( gentity_t *ent ) } //do impact physics - if ( ent->s.pos.trType == TR_GRAVITY )//tr.fraction < 1.0 && + if ( ent->s.pos.trType == TR_GRAVITY )//tr.fraction < 1.0 && {//FIXME: only do this if no trDelta if ( g_gravity->value <= 0 || tr.plane.normal[2] < 0.7 ) { @@ -303,7 +303,7 @@ void G_StartObjectMoving( gentity_t *object, vec3_t dir, float speed, trType_t t } } -gentity_t *G_CreateObject ( gentity_t *owner, vec3_t origin, vec3_t angles, int modelIndex, int frame, trType_t trType ) +gentity_t *G_CreateObject ( gentity_t *owner, vec3_t origin, vec3_t angles, int modelIndex, int frame, trType_t trType ) { gentity_t *object; diff --git a/codeJK2/game/g_objectives.cpp b/codeJK2/game/g_objectives.cpp index c5291543c9..7aa6ef469e 100644 --- a/codeJK2/game/g_objectives.cpp +++ b/codeJK2/game/g_objectives.cpp @@ -47,7 +47,7 @@ void OBJ_SetPendingObjectives(gentity_t *ent) for (i=0;iclient->sess.mission_objectives[i].status == OBJECTIVE_STAT_PENDING) && + if ((ent->client->sess.mission_objectives[i].status == OBJECTIVE_STAT_PENDING) && (ent->client->sess.mission_objectives[i].display)) { ent->client->sess.mission_objectives[i].status = OBJECTIVE_STAT_FAILED; diff --git a/codeJK2/game/g_public.h b/codeJK2/game/g_public.h index 7186c4734e..b23c5c9e92 100644 --- a/codeJK2/game/g_public.h +++ b/codeJK2/game/g_public.h @@ -112,7 +112,7 @@ struct gentity_s { Ghoul2 Insert Start */ // this marker thing of Jake's is used for memcpy() length calcs, so don't put any ordinary fields (like above) - // below this point or they won't work, and will mess up all sorts of stuff. + // below this point or they won't work, and will mess up all sorts of stuff. // CGhoul2Info_v ghoul2; /* @@ -211,12 +211,12 @@ typedef struct { void (*SetBrushModel)( gentity_t *ent, const char *name ); // collision detection against all linked entities - void (*trace)( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, + void (*trace)( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, const int passEntityNum, const int contentmask , const EG2_Collision eG2TraceType , const int useLod ); // point contents against all linked entities int (*pointcontents)( const vec3_t point, int passEntityNum ); - // what contents are on the map? + // what contents are on the map? int (*totalMapContents)(); qboolean (*inPVS)( const vec3_t p1, const vec3_t p2 ); @@ -264,7 +264,7 @@ Ghoul2 Insert Start qboolean (*G2API_SetBoneAnglesMatrix)(CGhoul2Info *ghlInfo, const char *boneName, const mdxaBone_t &matrix, const int flags, qhandle_t *modelList, int blendTime , int currentTime ); void (*G2API_CopyGhoul2Instance)(CGhoul2Info_v &ghoul2From, CGhoul2Info_v &ghoul2To, int modelIndex ); - qboolean (*G2API_SetBoneAnimIndex)(CGhoul2Info *ghlInfo, const int index, const int startFrame, const int endFrame, const int flags, + qboolean (*G2API_SetBoneAnimIndex)(CGhoul2Info *ghlInfo, const int index, const int startFrame, const int endFrame, const int flags, const float animSpeed, const int currentTime, const float setFrame , const int blendTime ); qboolean (*G2API_SetLodBias)(CGhoul2Info *ghlInfo, int lodBias); @@ -295,7 +295,7 @@ Ghoul2 Insert Start qboolean (*G2API_AttachEnt)(int *boltInfo, CGhoul2Info *ghlInfoTo, int toBoltIndex, int entNum, int toModelNum); void (*G2API_DetachEnt)(int *boltInfo); - qboolean (*G2API_GetBoltMatrix)(CGhoul2Info_v &ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, + qboolean (*G2API_GetBoltMatrix)(CGhoul2Info_v &ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, const vec3_t position, const int frameNum, qhandle_t *modelList, const vec3_t scale); void (*G2API_ListSurfaces)(CGhoul2Info *ghlInfo); @@ -384,7 +384,7 @@ typedef struct { // init and shutdown will be called every single level // levelTime will be near zero, while globalTime will be a large number // that can be used to track spectator entry times across restarts - void (*Init)( const char *mapname, const char *spawntarget, int checkSum, const char *entstring, + void (*Init)( const char *mapname, const char *spawntarget, int checkSum, const char *entstring, int levelTime, int randomSeed, int globalTime, SavedGameJustLoaded_e eSavedGameJustLoaded, qboolean qbLoadTransition ); void (*Shutdown) (void); @@ -423,7 +423,7 @@ typedef struct { // The gentities array is allocated in the game dll so it // can vary in size from one game to another. - // + // // The size will be fixed when ge->Init() is called // the server can't just use pointer arithmetic on gentities, because the // server's sizeof(struct gentity_s) doesn't equal gentitySize diff --git a/codeJK2/game/g_roff.cpp b/codeJK2/game/g_roff.cpp index b1c9539e26..b035f57fb2 100644 --- a/codeJK2/game/g_roff.cpp +++ b/codeJK2/game/g_roff.cpp @@ -337,7 +337,7 @@ qboolean G_InitRoff( char *file, unsigned char *data ) count = LittleLong(hdr->mCount); roffs[num_roffs].frames = count; - roffs[num_roffs].data = (void *) G_Alloc( count * sizeof( move_rotate2_t )); + roffs[num_roffs].data = (void *) G_Alloc( count * sizeof( move_rotate2_t )); move_rotate2_t *mem = (move_rotate2_t *)roffs[num_roffs].data; if ( mem ) @@ -486,7 +486,7 @@ void G_Roff( gentity_t *ent ) { return; } - + if ( ent->next_roff_time > level.time ) {// either I don't think or it's just not time to have me think yet return; @@ -523,7 +523,7 @@ void G_Roff( gentity_t *ent ) #ifdef _DEBUG if ( g_developer->integer ) { - Com_Printf( S_COLOR_GREEN"ROFF dat: num: %d o:<%.2f %.2f %.2f> a:<%.2f %.2f %.2f>\n", + Com_Printf( S_COLOR_GREEN"ROFF dat: num: %d o:<%.2f %.2f %.2f> a:<%.2f %.2f %.2f>\n", ent->roff_ctr, org[0], org[1], org[2], ang[0], ang[1], ang[2] ); @@ -584,7 +584,7 @@ void G_Roff( gentity_t *ent ) //make it true linear... FIXME: sticks around after ROFF is done, but do we really care? ent->alt_fire = qtrue; - if ( !ent->e_ThinkFunc + if ( !ent->e_ThinkFunc && ent->s.eType != ET_MISSILE && ent->s.eType != ET_ITEM && ent->s.eType != ET_MOVER ) diff --git a/codeJK2/game/g_roff.h b/codeJK2/game/g_roff.h index 666adb6f49..239e2bc963 100644 --- a/codeJK2/game/g_roff.h +++ b/codeJK2/game/g_roff.h @@ -40,9 +40,9 @@ along with this program; if not, see . typedef struct roff_hdr_s { char mHeader[4]; // should be "ROFF" (Rotation, Origin File Format) - int mVersion; + int mVersion; float mCount; // There isn't any reason for this to be anything other than an int, sigh... - // + // // Move - Rotate data follows....vec3_t delta_origin, vec3_t delta_rotation // } roff_hdr_t; diff --git a/codeJK2/game/g_shared.h b/codeJK2/game/g_shared.h index 3bd444940c..2077d65be7 100644 --- a/codeJK2/game/g_shared.h +++ b/codeJK2/game/g_shared.h @@ -37,7 +37,7 @@ typedef struct centity_s centity_t; class CSequencer; class CTaskManager; -enum +enum { HL_NONE = 0, HL_FOOT_RT, @@ -202,7 +202,7 @@ class clientInfo_t //================================================================== -typedef enum +typedef enum { MOVER_POS1, MOVER_POS2, @@ -237,7 +237,7 @@ typedef struct modelInfo_s } } modelInfo_t; -typedef enum +typedef enum { MODEL_LEGS = 0, MODEL_TORSO, @@ -260,7 +260,7 @@ class renderInfo_t // Legs model, or full model on one piece entities union { - modelInfo_t legsModel; + modelInfo_t legsModel; modelInfo_t model; }; @@ -645,7 +645,7 @@ class clientSession_t class clientPersistant_t { public: - clientConnected_t connected; + clientConnected_t connected; usercmd_t lastCommand; qboolean localClient; // true if "ip" info key is "localhost" char netname[34]; @@ -753,7 +753,7 @@ class gclient_t // timeResidual is used to handle events that happen every second // like health / armor countdowns and regeneration int timeResidual; - + // Facial Expression Timers float facial_blink; // time before next blink. If a minus value, we are in blink mode @@ -996,7 +996,7 @@ struct gentity_s { Ghoul2 Insert Start */ // this marker thing of Jake's is used for memcpy() length calcs, so don't put any ordinary fields (like above) - // below this point or they won't work, and will mess up all sorts of stuff. + // below this point or they won't work, and will mess up all sorts of stuff. // CGhoul2Info_v ghoul2; /* @@ -1021,7 +1021,7 @@ Ghoul2 Insert End char *model2; // Torso model int freetime; // sv.time when the object was freed - + int eventTime; // events will be cleared EVENT_VALID_MSEC after set qboolean freeAfterEvent; qboolean unlinkAfterEvent; @@ -1060,7 +1060,7 @@ Ghoul2 Insert End int roff_ctr; // current roff frame we are playing - int next_roff_time; + int next_roff_time; int fx_time; // timer for beam in/out effects. //Think Functions @@ -1197,7 +1197,7 @@ Ghoul2 Insert End qhandle_t cinematicModel; //========================================================================================== - + //FIELDS USED EXCLUSIVELY BY SPECIFIC CLASSES OF ENTITIES //NPC/Player entity fields //FIXME: Make these client only? @@ -1233,7 +1233,7 @@ Ghoul2 Insert End //Variables used only by waypoints (for the most part) float radius; - + union { int wpIndex; @@ -1251,7 +1251,7 @@ Ghoul2 Insert End }; //FIXME: Are these being used anymore? - gitem_t *item; // for bonus items - + gitem_t *item; // for bonus items - char *message; //Used by triggers to print a message when activated float lightLevel; diff --git a/codeJK2/game/g_spawn.cpp b/codeJK2/game/g_spawn.cpp index 9e3672d21e..660e571aa3 100644 --- a/codeJK2/game/g_spawn.cpp +++ b/codeJK2/game/g_spawn.cpp @@ -100,9 +100,9 @@ qboolean G_SpawnVector4( const char *key, const char *defaultString, float *out qboolean G_SpawnFlag( const char *key, int flag, int *out ) { //find that key - for ( int i = 0 ; i < numSpawnVars ; i++ ) + for ( int i = 0 ; i < numSpawnVars ; i++ ) { - if ( !strcmp( key, spawnVars[i][0] ) ) + if ( !strcmp( key, spawnVars[i][0] ) ) { //found the key if ( atoi( spawnVars[i][1] ) != 0 ) @@ -147,7 +147,7 @@ stringID_table_t flagTable [] = // fields are needed for spawning from the entity string // typedef enum { - F_INT, + F_INT, F_FLOAT, F_LSTRING, // string on disk, pointer in memory, TAG_LEVEL F_GSTRING, // string on disk, pointer in memory, TAG_GAME @@ -578,7 +578,7 @@ spawn_t spawns[] = { {"misc_ion_cannon", SP_misc_ion_cannon}, {"misc_sentry_turret", SP_PAS}, {"misc_maglock", SP_misc_maglock}, - + {"misc_model_ghoul", SP_misc_model_ghoul}, {"misc_model_breakable", SP_misc_model_breakable}, {"misc_portal_surface", SP_misc_portal_surface}, @@ -609,7 +609,7 @@ spawn_t spawns[] = { {"misc_atst_drivable", SP_misc_atst_drivable}, {"misc_cubemap", SP_misc_cubemap}, - + {"shooter_rocket", SP_shooter_rocket}, {"shooter_grenade", SP_shooter_grenade}, {"shooter_plasma", SP_shooter_plasma}, @@ -677,7 +677,7 @@ spawn_t spawns[] = { {"waypoint_navgoal_4", SP_waypoint_navgoal_4}, {"waypoint_navgoal_2", SP_waypoint_navgoal_2}, {"waypoint_navgoal_1", SP_waypoint_navgoal_1}, - + {"fx_runner", SP_fx_runner}, {"fx_explosion_trail", SP_fx_explosion_trail}, {"fx_target_beam", SP_fx_target_beam}, @@ -768,7 +768,7 @@ char *G_NewString( const char *string ) { *new_p++ = string[i]; } } - + return newb; } @@ -1009,7 +1009,7 @@ qboolean G_ParseSpawnVars( const char **data ) { } // go through all the key / value pairs - while ( 1 ) { + while ( 1 ) { // parse key com_token = COM_Parse( data ); if ( com_token[0] == '}' ) { @@ -1021,8 +1021,8 @@ qboolean G_ParseSpawnVars( const char **data ) { } Q_strncpyz( keyname, com_token, sizeof(keyname) ); - - // parse value + + // parse value com_token = COM_Parse( data ); if ( com_token[0] == '}' ) { COM_EndParseSession(); @@ -1045,7 +1045,7 @@ qboolean G_ParseSpawnVars( const char **data ) { return qtrue; } -static char *defaultStyles[LS_NUM_STYLES][3] = +static char *defaultStyles[LS_NUM_STYLES][3] = { { // 0 normal "z", @@ -1233,7 +1233,7 @@ void SP_worldspawn( void ) { int i; gi.cvar_set( "region", "0" ); - for ( i = 0 ; i < numSpawnVars ; i++ ) + for ( i = 0 ; i < numSpawnVars ; i++ ) { if ( Q_stricmp( "spawnscript", spawnVars[i][0] ) == 0 ) {//ONly let them set spawnscript, we don't want them setting an angle or something on the world. @@ -1294,10 +1294,10 @@ void SP_worldspawn( void ) { if (lengthRed != lengthGreen || lengthGreen != lengthBlue) { - Com_Error(ERR_DROP, "Style %d has inconsistent lengths: R %d, G %d, B %d", + Com_Error(ERR_DROP, "Style %d has inconsistent lengths: R %d, G %d, B %d", i, lengthRed, lengthGreen, lengthBlue); } - } + } g_entities[ENTITYNUM_WORLD].s.number = ENTITYNUM_WORLD; g_entities[ENTITYNUM_WORLD].classname = "worldspawn"; @@ -1368,14 +1368,14 @@ void G_SpawnEntitiesFromString( const char *entityString ) { if ( !G_ParseSpawnVars( &entities ) ) { G_Error( "SpawnEntities: no entities" ); } - + SP_worldspawn(); // parse ents - while( G_ParseSpawnVars( &entities ) ) + while( G_ParseSpawnVars( &entities ) ) { G_SpawnGEntityFromSpawnVars(); - } + } //Search the entities for precache information G_ParsePrecaches(); diff --git a/codeJK2/game/g_svcmds.cpp b/codeJK2/game/g_svcmds.cpp index 40d45801dc..58ea2eab45 100644 --- a/codeJK2/game/g_svcmds.cpp +++ b/codeJK2/game/g_svcmds.cpp @@ -176,9 +176,9 @@ extern cvar_t *g_skippingcin; gentity_t *G_GetSelfForPlayerCmd( void ) { - if ( g_entities[0].client->ps.viewEntity > 0 - && g_entities[0].client->ps.viewEntity < ENTITYNUM_WORLD - && g_entities[g_entities[0].client->ps.viewEntity].client + if ( g_entities[0].client->ps.viewEntity > 0 + && g_entities[0].client->ps.viewEntity < ENTITYNUM_WORLD + && g_entities[g_entities[0].client->ps.viewEntity].client && g_entities[g_entities[0].client->ps.viewEntity].s.weapon == WP_SABER ) {//you're controlling another NPC return (&g_entities[g_entities[0].client->ps.viewEntity]); @@ -199,7 +199,7 @@ static void Svcmd_SaberColor_f() return; } - + gentity_t *self = G_GetSelfForPlayerCmd(); if ( !Q_stricmp( color, "red" )) @@ -259,7 +259,7 @@ static void Svcmd_ForceSetLevel_f( int forcePower ) { return; } - if ( !g_cheats->integer ) + if ( !g_cheats->integer ) { gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\""); return; @@ -563,7 +563,7 @@ static svcmd_t svcmds[] = { { "ICARUS", Svcmd_ICARUS_f, CMD_CHEAT }, { "saberColor", Svcmd_SaberColor_f, CMD_CHEAT }, - + { "setForceJump", Svcmd_ForceSetLevel_f, CMD_CHEAT }, { "setSaberThrow", Svcmd_ForceSetLevel_f, CMD_CHEAT }, { "setForceHeal", Svcmd_ForceSetLevel_f, CMD_CHEAT }, @@ -577,20 +577,20 @@ static svcmd_t svcmds[] = { { "setSaberOffense", Svcmd_ForceSetLevel_f, CMD_CHEAT }, { "setForceAll", Svcmd_SetForceAll_f, CMD_CHEAT }, { "setSaberAll", Svcmd_SetSaberAll_f, CMD_CHEAT }, - + { "saberAttackCycle", Svcmd_SaberAttackCycle_f, CMD_NONE }, - + { "runscript", Svcmd_RunScript_f, CMD_CHEAT }, - + { "playerTeam", Svcmd_PlayerTeam_f, CMD_CHEAT }, - + { "control", Svcmd_Control_f, CMD_CHEAT }, { "exitview", Svcmd_ExitView_f, CMD_NONE }, - + { "secrets", Svcmd_Secrets_f, CMD_NONE }, { "difficulty", Svcmd_Difficulty_f, CMD_NONE }, - + //{ "say", Svcmd_Say_f, qtrue }, //{ "toggleallowvote", Svcmd_ToggleAllowVote_f, qfalse }, //{ "toggleuserinfovalidation", Svcmd_ToggleUserinfoValidation_f, qfalse }, @@ -608,7 +608,7 @@ qboolean ConsoleCommand( void ) { if ( !command ) return qfalse; - + if ( (command->flags & CMD_CHEAT) && !g_cheats->integer ) { diff --git a/codeJK2/game/g_target.cpp b/codeJK2/game/g_target.cpp index 495a4f96b4..36566852d8 100644 --- a/codeJK2/game/g_target.cpp +++ b/codeJK2/game/g_target.cpp @@ -72,12 +72,12 @@ void SP_target_give( gentity_t *ent ) { "wait" seconds to pause before firing targets. "random" delay variance, total delay = delay +/- random seconds */ -void Think_Target_Delay( gentity_t *ent ) +void Think_Target_Delay( gentity_t *ent ) { G_UseTargets( ent, ent->activator ); } -void Use_Target_Delay( gentity_t *ent, gentity_t *other, gentity_t *activator ) +void Use_Target_Delay( gentity_t *ent, gentity_t *other, gentity_t *activator ) { G_ActivateBehavior(ent,BSET_USE); @@ -86,15 +86,15 @@ void Use_Target_Delay( gentity_t *ent, gentity_t *other, gentity_t *activator ) ent->activator = activator; } -void SP_target_delay( gentity_t *ent ) +void SP_target_delay( gentity_t *ent ) { // check delay for backwards compatability - if ( !G_SpawnFloat( "delay", "0", &ent->wait ) ) + if ( !G_SpawnFloat( "delay", "0", &ent->wait ) ) { G_SpawnFloat( "wait", "1", &ent->wait ); } - if ( !ent->wait ) + if ( !ent->wait ) { ent->wait = 1; } @@ -110,7 +110,7 @@ void SP_target_delay( gentity_t *ent ) The activator is given this many points. */ -void Use_Target_Score (gentity_t *ent, gentity_t *other, gentity_t *activator) +void Use_Target_Score (gentity_t *ent, gentity_t *other, gentity_t *activator) { G_ActivateBehavior(ent,BSET_USE); @@ -131,7 +131,7 @@ void SP_target_score( gentity_t *ent ) { "message" text to print If "private", only the activator gets the message. If no checks, all clients get the message. */ -void Use_Target_Print (gentity_t *ent, gentity_t *other, gentity_t *activator) +void Use_Target_Print (gentity_t *ent, gentity_t *other, gentity_t *activator) { G_ActivateBehavior(ent,BSET_USE); @@ -291,7 +291,7 @@ void target_laser_think (gentity_t *self) { if ( tr.entityNum ) { // hurt it if we can - G_Damage ( &g_entities[tr.entityNum], self, self->activator, self->movedir, + G_Damage ( &g_entities[tr.entityNum], self, self->activator, self->movedir, tr.endpos, self->damage, DAMAGE_NO_KNOCKBACK, MOD_ENERGY ); } @@ -404,18 +404,18 @@ INACTIVE Can't be used until activated "delay" - Will actually fire this many seconds after being used "wait" - Cannot be fired again until this many seconds after the last time it was used */ -void target_relay_use_go (gentity_t *self ) +void target_relay_use_go (gentity_t *self ) { G_ActivateBehavior( self, BSET_USE ); - - if ( self->spawnflags & 4 ) + + if ( self->spawnflags & 4 ) { gentity_t *ent; ent = G_PickTarget( self->target ); - if ( ent && (ent->e_UseFunc != useF_NULL) ) + if ( ent && (ent->e_UseFunc != useF_NULL) ) { // e_UseFunc check can be omitted - GEntity_UseFunc( ent, self, self->activator ); + GEntity_UseFunc( ent, self, self->activator ); } return; } @@ -423,14 +423,14 @@ void target_relay_use_go (gentity_t *self ) G_UseTargets( self, self->activator ); } -void target_relay_use (gentity_t *self, gentity_t *other, gentity_t *activator) +void target_relay_use (gentity_t *self, gentity_t *other, gentity_t *activator) { - if ( ( self->spawnflags & 1 ) && activator->client ) + if ( ( self->spawnflags & 1 ) && activator->client ) {//&& activator->client->ps.persistant[PERS_TEAM] != TEAM_RED ) { return; } - if ( ( self->spawnflags & 2 ) && activator->client ) + if ( ( self->spawnflags & 2 ) && activator->client ) {//&& activator->client->ps.persistant[PERS_TEAM] != TEAM_BLUE ) { return; } @@ -467,7 +467,7 @@ void target_relay_use (gentity_t *self, gentity_t *other, gentity_t *activator) } } -void SP_target_relay (gentity_t *self) +void SP_target_relay (gentity_t *self) { self->e_UseFunc = useF_target_relay_use; self->wait *= 1000; @@ -501,7 +501,7 @@ void target_kill_use( gentity_t *self, gentity_t *other, gentity_t *activator ) else if ( self->spawnflags & 2 ) // electrical { G_Damage ( activator, NULL, NULL, NULL, NULL, 100000, DAMAGE_NO_PROTECTION, MOD_ELECTROCUTE ); - + if ( activator->client ) { activator->s.powerups |= ( 1 << PW_SHOCKED ); @@ -514,7 +514,7 @@ void target_kill_use( gentity_t *self, gentity_t *other, gentity_t *activator ) } } -void SP_target_kill( gentity_t *self ) +void SP_target_kill( gentity_t *self ) { self->e_UseFunc = useF_target_kill_use; } @@ -532,7 +532,7 @@ void target_location_linkup(gentity_t *ent) { int i; - if (level.locationLinked) + if (level.locationLinked) return; level.locationLinked = qtrue; @@ -584,7 +584,7 @@ void target_counter_use( gentity_t *self, gentity_t *other, gentity_t *activator { return; } - + //gi.Printf("target_counter %s used by %s, entnum %d\n", self->targetname, activator->targetname, activator->s.number ); self->count--; @@ -602,7 +602,7 @@ void target_counter_use( gentity_t *self, gentity_t *other, gentity_t *activator } return; } - + G_ActivateBehavior( self,BSET_USE ); if ( self->spawnflags & 128 ) @@ -622,7 +622,7 @@ void target_counter_use( gentity_t *self, gentity_t *other, gentity_t *activator self->count = self->max_health; if ( self->bounceCount > 0 ) {//-1 means bounce back forever - self->bounceCount--; + self->bounceCount--; } } } @@ -693,7 +693,7 @@ void target_random_use(gentity_t *self, gentity_t *other, gentity_t *activator) { continue; } - + if (t == self) { // gi.Printf ("WARNING: Entity used itself.\n"); @@ -725,7 +725,7 @@ void scriptrunner_run (gentity_t *self) { /* if (self->behaviorSet[BSET_USE]) - { + { char newname[MAX_FILENAME_LENGTH]; sprintf((char *) &newname, "%s/%s", Q3_SCRIPT_DIR, self->behaviorSet[BSET_USE] ); @@ -1041,7 +1041,7 @@ extern cvar_t *com_buildScript; Q_strncpyz( buffer, s, sizeof(buffer) ); COM_DefaultExtension( buffer, sizeof(buffer), ".mp3"); - + gi.FS_FOpenFile(buffer, &hFile, FS_READ); if (hFile) { gi.FS_FCloseFile( hFile ); @@ -1070,7 +1070,7 @@ void SP_target_autosave( gentity_t *self ) } void target_secret_use(gentity_t *self, gentity_t *other, gentity_t *activator) -{ +{ //we'll assume that the activator is the player gclient_t* const client = &level.clients[0]; client->sess.missionStats.secretsFound++; @@ -1091,7 +1091,7 @@ You found a Secret! "count" - how many secrets on this level, if more than one on a level, be sure they all have the same count! */ -void SP_target_secret( gentity_t *self ) +void SP_target_secret( gentity_t *self ) { G_SetOrigin( self, self->s.origin ); self->e_UseFunc = useF_target_secret_use; diff --git a/codeJK2/game/g_trigger.cpp b/codeJK2/game/g_trigger.cpp index 6e6e7ac6af..68b9ea50a4 100644 --- a/codeJK2/game/g_trigger.cpp +++ b/codeJK2/game/g_trigger.cpp @@ -58,7 +58,7 @@ void multi_wait( gentity_t *ent ) { // the trigger was just activated // ent->activator should be set to the activator so it can be held through a delay // so wait for the delay time before firing -void multi_trigger_run( gentity_t *ent ) +void multi_trigger_run( gentity_t *ent ) { ent->e_ThinkFunc = thinkF_NULL; @@ -70,7 +70,7 @@ void multi_trigger_run( gentity_t *ent ) } G_UseTargets (ent, ent->activator); - if ( ent->noise_index ) + if ( ent->noise_index ) { G_Sound( ent->activator, ent->noise_index ); } @@ -80,7 +80,7 @@ void multi_trigger_run( gentity_t *ent ) ent->e_ThinkFunc = thinkF_trigger_cleared_fire; ent->nextthink = level.time + ent->speed; } - else if ( ent->wait > 0 ) + else if ( ent->wait > 0 ) { if ( ent->painDebounceTime != level.time ) {//first ent to touch it this frame @@ -88,7 +88,7 @@ void multi_trigger_run( gentity_t *ent ) ent->nextthink = level.time + ( ent->wait + ent->random * Q_flrand(-1.0f, 1.0f) ) * 1000; ent->painDebounceTime = level.time; } - } + } else if ( ent->wait < 0 ) { // we can't just remove (self) here, because this is a touch function @@ -107,14 +107,14 @@ void multi_trigger_run( gentity_t *ent ) } -void multi_trigger( gentity_t *ent, gentity_t *activator ) +void multi_trigger( gentity_t *ent, gentity_t *activator ) { if ( ent->e_ThinkFunc == thinkF_multi_trigger_run ) {//already triggered, just waiting to run return; } - if ( ent->nextthink > level.time ) + if ( ent->nextthink > level.time ) { if( ent->spawnflags & 2048 ) // MULTIPLE - allow multiple entities to touch this trigger in a single frame { @@ -133,7 +133,7 @@ void multi_trigger( gentity_t *ent, gentity_t *activator ) // if the player has already activated this trigger this frame if( activator && !activator->s.number && ent->aimDebounceTime == level.time ) { - return; + return; } if ( ent->svFlags & SVF_INACTIVE ) @@ -148,7 +148,7 @@ void multi_trigger( gentity_t *ent, gentity_t *activator ) ent->e_ThinkFunc = thinkF_multi_trigger_run; ent->nextthink = level.time + ent->delay; ent->painDebounceTime = level.time; - + } else { @@ -156,14 +156,14 @@ void multi_trigger( gentity_t *ent, gentity_t *activator ) } } -void Use_Multi( gentity_t *ent, gentity_t *other, gentity_t *activator ) +void Use_Multi( gentity_t *ent, gentity_t *other, gentity_t *activator ) { multi_trigger( ent, activator ); } -void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace ) +void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace ) { - if( !other->client ) + if( !other->client ) { return; } @@ -316,7 +316,7 @@ void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace ) */ //other->client->ps.weaponTime = other->client->ps.torsoAnimTimer; } - + if ( self->e_ThinkFunc == thinkF_trigger_cleared_fire ) {//We're waiting to fire our target2 first self->nextthink = level.time + self->speed; @@ -331,7 +331,7 @@ void trigger_cleared_fire (gentity_t *self) G_UseTargets2( self, self->activator, self->target2 ); self->e_ThinkFunc = thinkF_NULL; // should start the wait timer now, because the trigger's just been cleared, so we must "wait" from this point - if ( self->wait > 0 ) + if ( self->wait > 0 ) { self->nextthink = level.time + ( self->wait + self->random * Q_flrand(-1.0f, 1.0f) ) * 1000; } @@ -406,17 +406,17 @@ so, the basic time between firing is a random time between "soundSet" Ambient sound set to play when this trigger is activated */ team_t TranslateTeamName( const char *name ); -void SP_trigger_multiple( gentity_t *ent ) +void SP_trigger_multiple( gentity_t *ent ) { char buffer[MAX_QPATH]; char *s; - if ( G_SpawnString( "noise", "*NOSOUND*", &s ) ) + if ( G_SpawnString( "noise", "*NOSOUND*", &s ) ) { Q_strncpyz( buffer, s, sizeof(buffer) ); COM_DefaultExtension( buffer, sizeof(buffer), ".wav"); ent->noise_index = G_SoundIndex(buffer); } - + G_SpawnFloat( "wait", "0", &ent->wait );//was 0.5 ... but that means wait can never be zero... we should probably put it back to 0.5, though... G_SpawnFloat( "random", "0", &ent->random ); @@ -473,11 +473,11 @@ so, the basic time between firing is a random time between "soundSet" Ambient sound set to play when this trigger is activated */ -void SP_trigger_once( gentity_t *ent ) +void SP_trigger_once( gentity_t *ent ) { char buffer[MAX_QPATH]; char *s; - if ( G_SpawnString( "noise", "*NOSOUND*", &s ) ) + if ( G_SpawnString( "noise", "*NOSOUND*", &s ) ) { Q_strncpyz( buffer, s, sizeof(buffer) ); COM_DefaultExtension( buffer, sizeof(buffer), ".wav"); @@ -517,7 +517,7 @@ Fires "backwardstarget" when someone moves through it in the opposite direction TODO: count */ -void SP_trigger_bidirectional( gentity_t *ent ) +void SP_trigger_bidirectional( gentity_t *ent ) { G_FreeEntity(ent); //FIXME: Implement @@ -528,13 +528,13 @@ void SP_trigger_bidirectional( gentity_t *ent ) ent->touch = Touch_Multi; ent->use = Use_Multi; - + InitTrigger( ent ); gi.linkentity (ent); */ } -/*QUAKED trigger_location (.1 .5 .1) ? +/*QUAKED trigger_location (.1 .5 .1) ? When an ent is asked for it's location, it will return this ent's "message" field if it is in it. "message" - location name @@ -550,7 +550,7 @@ char *G_GetLocationForEnt( gentity_t *ent ) while( (found = G_Find(found, FOFS(classname), "trigger_location")) != NULL ) { - if ( gi.EntityContact( mins, maxs, found ) ) + if ( gi.EntityContact( mins, maxs, found ) ) { return found->message; } @@ -559,7 +559,7 @@ char *G_GetLocationForEnt( gentity_t *ent ) return NULL; } -void SP_trigger_location( gentity_t *ent ) +void SP_trigger_location( gentity_t *ent ) { if ( !ent->message || !ent->message[0] ) { @@ -604,7 +604,7 @@ trigger_push ============================================================================== */ -#define PUSH_CONVEYOR 32 +#define PUSH_CONVEYOR 32 void trigger_push_touch (gentity_t *self, gentity_t *other, trace_t *trace ) { if ( self->svFlags & SVF_INACTIVE ) {//set by target_deactivate @@ -629,10 +629,10 @@ void trigger_push_touch (gentity_t *self, gentity_t *other, trace_t *trace ) { // if the player has already activated this trigger this frame if( other && !other->s.number && self->aimDebounceTime == level.time ) { - return; + return; } - - + + if( self->spawnflags & PUSH_CONVEYOR ) { // only push player if he's on the ground if( other->s.groundEntityNum == ENTITYNUM_NONE ) @@ -672,7 +672,7 @@ void trigger_push_touch (gentity_t *self, gentity_t *other, trace_t *trace ) { if ( other->client->ps.pm_type != PM_NORMAL ) { return; } - + if ( (self->spawnflags&16) ) {//relative, dir to it * speed vec3_t dir; @@ -704,7 +704,7 @@ void trigger_push_touch (gentity_t *self, gentity_t *other, trace_t *trace ) { else if ( self->wait > 0 ) { self->painDebounceTime = level.time; - + } if( other && !other->s.number ) { // mark that the player has activated this trigger this frame @@ -721,7 +721,7 @@ AimAtTarget Calculate origin2 so the target apogee will be hit ================= */ -void AimAtTarget( gentity_t *self ) +void AimAtTarget( gentity_t *self ) { gentity_t *ent; vec3_t origin; @@ -732,7 +732,7 @@ void AimAtTarget( gentity_t *self ) VectorScale ( origin, 0.5, origin ); ent = G_PickTarget( self->target ); - if ( !ent ) + if ( !ent ) { G_FreeEntity( self ); return; @@ -901,8 +901,8 @@ CONSTANT will push activator in direction of 'target' at constant 'speed' NO_DAMAGE the activator won't take falling damage after being pushed */ void SP_target_push( gentity_t *self ) { - - + + if (!self->speed) { self->speed = 1000; } @@ -918,7 +918,7 @@ void SP_target_push( gentity_t *self ) { VectorCopy( self->s.origin, self->absmax ); self->e_ThinkFunc = thinkF_AimAtTarget; self->nextthink = level.time + START_TIME_LINK_ENTS; - + } self->e_UseFunc = useF_Use_target_push; } @@ -936,7 +936,7 @@ trigger_teleport #define TTSF_STASIS 8 #define TTSF_DEAD_OK 16 void TeleportMover( gentity_t *mover, vec3_t origin, vec3_t diffAngles, qboolean snapAngle ); -void trigger_teleporter_touch (gentity_t *self, gentity_t *other, trace_t *trace ) +void trigger_teleporter_touch (gentity_t *self, gentity_t *other, trace_t *trace ) { gentity_t *dest; @@ -944,17 +944,17 @@ void trigger_teleporter_touch (gentity_t *self, gentity_t *other, trace_t *trace {//set by target_deactivate return; } - + dest = G_PickTarget( self->target ); - if (!dest) + if (!dest) { gi.Printf ("Couldn't find teleporter destination\n"); return; } - if ( other->client ) + if ( other->client ) { - if ( other->client->ps.pm_type == PM_DEAD ) + if ( other->client->ps.pm_type == PM_DEAD ) { if ( !(self->spawnflags&TTSF_DEAD_OK) ) {//dead men can't teleport @@ -973,7 +973,7 @@ void trigger_teleporter_touch (gentity_t *self, gentity_t *other, trace_t *trace {//Don't go through if something blocking on the other side return; } - + TeleportPlayer( other, dest->s.origin, dest->s.angles ); } //FIXME: check for SVF_NO_TELEPORT @@ -1032,7 +1032,7 @@ NO_NPCS - NPCs cannot pass through STASIS - will play stasis teleport sound and fx instead of starfleet DEAD_OK - even if dead, you will teleport */ -void SP_trigger_teleport( gentity_t *self ) +void SP_trigger_teleport( gentity_t *self ) { InitTrigger (self); @@ -1096,7 +1096,7 @@ void trigger_hurt_reset (gentity_t *self) self->e_ThinkFunc = thinkF_NULL; } -void hurt_touch( gentity_t *self, gentity_t *other, trace_t *trace ) +void hurt_touch( gentity_t *self, gentity_t *other, trace_t *trace ) { int dflags; int actualDmg = self->damage; @@ -1105,12 +1105,12 @@ void hurt_touch( gentity_t *self, gentity_t *other, trace_t *trace ) {//set by target_deactivate return; } - - if ( !other->takedamage ) + + if ( !other->takedamage ) { return; } - + if( level.time < self->painDebounceTime + self->wait ) // normal 'wait' check { if( self->spawnflags & 2048 ) // MULTIPLE - allow multiple entities to touch this trigger in one frame @@ -1129,7 +1129,7 @@ void hurt_touch( gentity_t *self, gentity_t *other, trace_t *trace ) // if the player has already activated this trigger this frame if( other && !other->s.number && self->aimDebounceTime == level.time ) { - return; + return; } @@ -1157,7 +1157,7 @@ void hurt_touch( gentity_t *self, gentity_t *other, trace_t *trace ) } // play sound - if ( !(self->spawnflags & 4) ) + if ( !(self->spawnflags & 4) ) { G_Sound( other, self->noise_index ); } @@ -1170,7 +1170,7 @@ void hurt_touch( gentity_t *self, gentity_t *other, trace_t *trace ) { dflags = 0; } - + if ( self->delay ) {//Increase dmg over time if ( self->attackDebounceTime < self->delay ) @@ -1237,14 +1237,14 @@ void hurt_touch( gentity_t *self, gentity_t *other, trace_t *trace ) } } -void SP_trigger_hurt( gentity_t *self ) +void SP_trigger_hurt( gentity_t *self ) { char buffer[MAX_QPATH]; char *s; InitTrigger (self); - if ( !( self->spawnflags & 4 )) + if ( !( self->spawnflags & 4 )) { G_SpawnString( "noise", "sound/world/electro", &s ); @@ -1257,7 +1257,7 @@ void SP_trigger_hurt( gentity_t *self ) if ( !self->damage ) { self->damage = 5; } - + self->delay *= 1000; self->wait *= 1000; @@ -1362,7 +1362,7 @@ ownername - If any, who to calc the distance from- default is the trigger_entdis example: target "biessman telsia" will look for the biessman and telsia NPC if it finds either of these within distance it will fire. - todo - + todo - add delay, count add monster classnames????? add LOS to it??? @@ -1402,7 +1402,7 @@ void trigger_entdist_use( gentity_t *self, gentity_t *other, gentity_t *activato found = &g_entities[0]; if (found) - { + { VectorSubtract(owner->currentOrigin, found->currentOrigin, diff); if(VectorLength(diff) < self->count) { @@ -1425,7 +1425,7 @@ void trigger_entdist_use( gentity_t *self, gentity_t *other, gentity_t *activato found = G_Find(found, FOFS(targetname), token); // Look for the specified NPC if (found) //Found??? - { + { VectorSubtract(owner->currentOrigin, found->currentOrigin, diff); if(VectorLength(diff) < self->count) // Within distance { @@ -1444,12 +1444,12 @@ void trigger_entdist_use( gentity_t *self, gentity_t *other, gentity_t *activato { // This is the negative target G_UseTargets2 (self, self->activator, self->target2); - } + } } -void SP_trigger_entdist( gentity_t *self ) +void SP_trigger_entdist( gentity_t *self ) { G_SpawnInt( "distance", "0", &self->count); @@ -1539,7 +1539,7 @@ void SP_trigger_visible( gentity_t *self ) if ( self->spawnflags & 128 ) {// Make it inactive - self->svFlags |= SVF_INACTIVE; + self->svFlags |= SVF_INACTIVE; } G_SetOrigin( self, self->s.origin ); diff --git a/codeJK2/game/g_usable.cpp b/codeJK2/game/g_usable.cpp index 9b5fc7a77c..ebc57b19d1 100644 --- a/codeJK2/game/g_usable.cpp +++ b/codeJK2/game/g_usable.cpp @@ -125,12 +125,12 @@ void func_usable_use( gentity_t *self, gentity_t *other, gentity_t *activator ) self->svFlags &= ~SVF_PLAYER_USABLE; //also remove ability to call any use func at all! self->e_UseFunc = useF_NULL; - + if(self->target && self->target[0]) { G_UseTargets(self, activator); } - + if ( self->wait ) { self->e_ThinkFunc = thinkF_func_usable_think; @@ -180,7 +180,7 @@ void func_usable_die(gentity_t *self, gentity_t *inflictor, gentity_t *attacker, /*QUAKED func_usable (0 .5 .8) ? STARTOFF AUTOANIMATE ANIM_ONCE ALWAYS_ON BLOCKCHECK NPC_USE PLAYER_USE INACTIVE START_OFF - the wall will not be there -AUTOANIMATE - if a model is used it will animate +AUTOANIMATE - if a model is used it will animate ANIM_ONCE - When turned on, goes through anim once ALWAYS_ON - Doesn't toggle on and off when used, just runs usescript and fires target NPC_ONLY - Only NPCs can directly use this @@ -201,7 +201,7 @@ A bmodel that just sits there, doing nothing. Can be used for conditional walls "endframe" Will make it animate to next shader frame when used, not turn on/off... set this to number of frames in the shader, minus 1 */ -void SP_func_usable( gentity_t *self ) +void SP_func_usable( gentity_t *self ) { gi.SetBrushModel( self, self->model ); InitMover( self ); diff --git a/codeJK2/game/ghoul2_shared.h b/codeJK2/game/ghoul2_shared.h index 076e3d8834..c90978c4f1 100644 --- a/codeJK2/game/ghoul2_shared.h +++ b/codeJK2/game/ghoul2_shared.h @@ -54,7 +54,7 @@ int G2API_GetTime(int argTime); // this may or may not return arg depending on // G H O U L I I D E F I N E S // // we save the whole surfaceInfo_t struct -struct surfaceInfo_t +struct surfaceInfo_t { int offFlags; // what the flags are for this model int surface; // index into array held inside the model definition of pointers to the actual surface data loaded in - used by both client and game @@ -62,7 +62,7 @@ struct surfaceInfo_t float genBarycentricI; // point 1 barycentric coors - point 2 is 1 - point0 - point1 int genPolySurfaceIndex; // used to point back to the original surface and poly if this is a generated surface int genLod; // used to determine original lod of original surface and poly hit location - + surfaceInfo_t(): offFlags(0), surface(0), @@ -130,16 +130,16 @@ boneInfo_t(): boneBlendTime(0), boneBlendStart(0) { - matrix.matrix[0][0] = matrix.matrix[0][1] = matrix.matrix[0][2] = matrix.matrix[0][3] = - matrix.matrix[1][0] = matrix.matrix[1][1] = matrix.matrix[1][2] = matrix.matrix[1][3] = + matrix.matrix[0][0] = matrix.matrix[0][1] = matrix.matrix[0][2] = matrix.matrix[0][3] = + matrix.matrix[1][0] = matrix.matrix[1][1] = matrix.matrix[1][2] = matrix.matrix[1][3] = matrix.matrix[2][0] = matrix.matrix[2][1] = matrix.matrix[2][2] = matrix.matrix[2][3] = 0.0f; } }; //we save from top to boltUsed here. Don't bother saving the position, it gets rebuilt every frame anyway struct boltInfo_t{ - int boneNumber; // bone number bolt attaches to - int surfaceNumber; // surface number bolt attaches to + int boneNumber; // bone number bolt attaches to + int surfaceNumber; // surface number bolt attaches to int surfaceType; // if we attach to a surface, this tells us if it is an original surface or a generated one - doesn't go across the network int boltUsed; // nor does this boltInfo_t(): @@ -243,7 +243,7 @@ class CGhoul2Info { mFileName[0] = 0; } -}; +}; class CGhoul2Info_v; diff --git a/codeJK2/game/objectives.h b/codeJK2/game/objectives.h index 1e7e7cd4aa..827085c09b 100644 --- a/codeJK2/game/objectives.h +++ b/codeJK2/game/objectives.h @@ -66,7 +66,7 @@ typedef enum //# Objective_e BESPIN_PLATFORM_OBJ2, //# BESPIN PLATFORM CAIRN_BAY_OBJ1, //# CAIRN BAY CAIRN_BAY_OBJ2, //# CAIRN BAY - CAIRN_ASSEMBLY_OBJ1, //# CAIRN ASSEMBLY + CAIRN_ASSEMBLY_OBJ1, //# CAIRN ASSEMBLY CAIRN_REACTOR_OBJ1, //# CAIRN REACTOR CAIRN_REACTOR_OBJ2, //# CAIRN REACTOR CAIRN_DOCK1_OBJ1, //# CAIRN DOCK1 @@ -85,16 +85,16 @@ typedef enum //# Objective_e YAVIN_COURTYARD_OBJ1, //# YAVIN COURTYARD YAVIN_COURTYARD_OBJ2, //# YAVIN COURTYARD YAVIN_FINAL_OBJ1, //# YAVIN FINAL - KEJIM_POST_OBJ3, //# KEJIM POST - GRAPHICS IN IT. - KEJIM_POST_OBJ4, //# KEJIM POST - GRAPHICS IN IT. - KEJIM_POST_OBJ5, //# KEJIM POST - GRAPHICS IN IT. + KEJIM_POST_OBJ3, //# KEJIM POST - GRAPHICS IN IT. + KEJIM_POST_OBJ4, //# KEJIM POST - GRAPHICS IN IT. + KEJIM_POST_OBJ5, //# KEJIM POST - GRAPHICS IN IT. ARTUS_DETENTION_OBJ3, //# ARTUS DETENTION - DOOM_COMM_OBJ4, //# DOOM COMM - GRAPHICS IN IT. + DOOM_COMM_OBJ4, //# DOOM COMM - GRAPHICS IN IT. DOOM_SHIELDS_OBJ3, //# DOOM SHIELDS - DEMO_OBJ1, //# DEMO - DEMO_OBJ2, //# DEMO - DEMO_OBJ3, //# DEMO - DEMO_OBJ4, //# DEMO + DEMO_OBJ1, //# DEMO + DEMO_OBJ2, //# DEMO + DEMO_OBJ3, //# DEMO + DEMO_OBJ4, //# DEMO //# #eol MAX_OBJECTIVES, @@ -206,7 +206,7 @@ stringID_table_t objectiveTable [] = ENUM2STRING(BESPIN_PLATFORM_OBJ2), //# BESPIN PLATFORM ENUM2STRING(CAIRN_BAY_OBJ1), //# CAIRN BAY ENUM2STRING(CAIRN_BAY_OBJ2), //# CAIRN BAY - ENUM2STRING(CAIRN_ASSEMBLY_OBJ1), //# CAIRN ASSEMBLY + ENUM2STRING(CAIRN_ASSEMBLY_OBJ1), //# CAIRN ASSEMBLY ENUM2STRING(CAIRN_REACTOR_OBJ1), //# CAIRN REACTOR ENUM2STRING(CAIRN_REACTOR_OBJ2), //# CAIRN REACTOR ENUM2STRING(CAIRN_DOCK1_OBJ1), //# CAIRN DOCK1 @@ -225,16 +225,16 @@ stringID_table_t objectiveTable [] = ENUM2STRING(YAVIN_COURTYARD_OBJ1), //# YAVIN COURTYARD ENUM2STRING(YAVIN_COURTYARD_OBJ2), //# YAVIN COURTYARD ENUM2STRING(YAVIN_FINAL_OBJ1), //# YAVIN FINAL - ENUM2STRING(KEJIM_POST_OBJ3), //# KEJIM POST - GRAPHICS IN IT. - ENUM2STRING(KEJIM_POST_OBJ4), //# KEJIM POST - GRAPHICS IN IT. - ENUM2STRING(KEJIM_POST_OBJ5), //# KEJIM POST - GRAPHICS IN IT. + ENUM2STRING(KEJIM_POST_OBJ3), //# KEJIM POST - GRAPHICS IN IT. + ENUM2STRING(KEJIM_POST_OBJ4), //# KEJIM POST - GRAPHICS IN IT. + ENUM2STRING(KEJIM_POST_OBJ5), //# KEJIM POST - GRAPHICS IN IT. ENUM2STRING(ARTUS_DETENTION_OBJ3), //# ARTUS DETENTION ENUM2STRING(DOOM_COMM_OBJ4), //# DOOM COMM - GRAPHICS IN IT. IT MUST BE LAST IN THE LIST ENUM2STRING(DOOM_SHIELDS_OBJ3), //# DOOM SHIELDS - ENUM2STRING(DEMO_OBJ1), //# DEMO - ENUM2STRING(DEMO_OBJ2), //# DEMO - ENUM2STRING(DEMO_OBJ3), //# DEMO - ENUM2STRING(DEMO_OBJ4), //# DEMO + ENUM2STRING(DEMO_OBJ1), //# DEMO + ENUM2STRING(DEMO_OBJ2), //# DEMO + ENUM2STRING(DEMO_OBJ3), //# DEMO + ENUM2STRING(DEMO_OBJ4), //# DEMO //stringID_table_t Must end with a null entry {"", 0} @@ -250,7 +250,7 @@ stringID_table_t missionFailedTable [] = ENUM2STRING(MISSIONFAILED_PRISONERS), //# TOO MANY PRISONERS DIED ENUM2STRING(MISSIONFAILED_EMPLACEDGUNS),//# ALL EMPLACED GUNS GONE ENUM2STRING(MISSIONFAILED_LADYLUCK), //# LADY LUCK DISTROYED - ENUM2STRING(MISSIONFAILED_KYLECAPTURE), //# KYLE HAS BEEN CAPTURED + ENUM2STRING(MISSIONFAILED_KYLECAPTURE), //# KYLE HAS BEEN CAPTURED ENUM2STRING(MISSIONFAILED_TOOMANYALLIESDIED), //# TOO MANY ALLIES DIED //stringID_table_t Must end with a null entry diff --git a/codeJK2/game/statindex.h b/codeJK2/game/statindex.h index 481eef607b..d2c5c09957 100644 --- a/codeJK2/game/statindex.h +++ b/codeJK2/game/statindex.h @@ -32,11 +32,11 @@ typedef enum { STAT_HEALTH, STAT_ITEMS, STAT_WEAPONS, // 16 bit fields - STAT_ARMOR, + STAT_ARMOR, STAT_DEAD_YAW, // look this direction when dead (FIXME: get rid of?) STAT_CLIENTS_READY, // bit mask of clients wishing to exit the intermission (FIXME: configstring?) STAT_MAX_HEALTH // health / armor limit, changable by handicap -} statIndex_t; +} statIndex_t; #endif // #ifndef STATINDEX_H diff --git a/codeJK2/game/teams.h b/codeJK2/game/teams.h index a7981c60b6..b1b018854a 100644 --- a/codeJK2/game/teams.h +++ b/codeJK2/game/teams.h @@ -36,15 +36,15 @@ typedef enum //# team_e } team_t; // This list is made up from the model directories, this MUST be in the same order as the ClassNames array in NPC_stats.cpp -typedef enum +typedef enum { CLASS_NONE, // hopefully this will never be used by an npc, just covering all bases CLASS_ATST, // technically droid... CLASS_BARTENDER, - CLASS_BESPIN_COP, + CLASS_BESPIN_COP, CLASS_CLAW, CLASS_COMMANDO, - CLASS_DESANN, + CLASS_DESANN, CLASS_FISH, CLASS_FLIER2, CLASS_GALAK, @@ -54,18 +54,18 @@ typedef enum CLASS_HOWLER, CLASS_IMPERIAL, CLASS_IMPWORKER, - CLASS_INTERROGATOR, // droid - CLASS_JAN, - CLASS_JEDI, - CLASS_KYLE, - CLASS_LANDO, + CLASS_INTERROGATOR, // droid + CLASS_JAN, + CLASS_JEDI, + CLASS_KYLE, + CLASS_LANDO, CLASS_LIZARD, - CLASS_LUKE, + CLASS_LUKE, CLASS_MARK1, // droid CLASS_MARK2, // droid CLASS_GALAKMECH, // droid CLASS_MINEMONSTER, - CLASS_MONMOTHA, + CLASS_MONMOTHA, CLASS_MORGANKATARN, CLASS_MOUSE, // droid CLASS_MURJJ, @@ -89,7 +89,7 @@ typedef enum CLASS_TRANDOSHAN, CLASS_UGNAUGHT, CLASS_WEEQUAY, - + CLASS_NUM_CLASSES } class_t; diff --git a/codeJK2/game/w_local.h b/codeJK2/game/w_local.h index 5fd05a180f..1635bc4337 100644 --- a/codeJK2/game/w_local.h +++ b/codeJK2/game/w_local.h @@ -68,7 +68,7 @@ void WP_FireRocket( gentity_t *ent, qboolean alt_fire ); void WP_FireStunBaton( gentity_t *ent, qboolean alt_fire ); void thermalDetonatorExplode( gentity_t *ent ); void thermal_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod, int dFlags, int hitLoc ); -qboolean WP_LobFire( gentity_t *self, vec3_t start, vec3_t target, vec3_t mins, vec3_t maxs, int clipmask, +qboolean WP_LobFire( gentity_t *self, vec3_t start, vec3_t target, vec3_t mins, vec3_t maxs, int clipmask, vec3_t velocity, qboolean tracePath, int ignoreEntNum, int enemyNum, float minSpeed = 0, float maxSpeed = 0, float idealSpeed = 0, qboolean mustHit = qfalse ); void WP_ThermalThink( gentity_t *ent ); diff --git a/codeJK2/game/weapons.h b/codeJK2/game/weapons.h index f796fc6533..acb2d00acd 100644 --- a/codeJK2/game/weapons.h +++ b/codeJK2/game/weapons.h @@ -60,7 +60,7 @@ typedef enum //# weapon_e WP_BOT_LASER, // Probe droid - Laser blast - WP_TURRET, // turret guns + WP_TURRET, // turret guns WP_ATST_MAIN, WP_ATST_SIDE, @@ -122,7 +122,7 @@ typedef struct weaponData_s int energyPerShot; // Amount of energy used per shot int fireTime; // Amount of time between firings int range; // Range of weapon - + int altEnergyPerShot; // Amount of energy used for alt-fire int altFireTime; // Amount of time between alt-firings int altRange; // Range of alt-fire @@ -288,8 +288,8 @@ typedef struct ammoData_s // ATST Main Gun //-------------- -#define ATST_MAIN_VEL 4000 // -#define ATST_MAIN_DAMAGE 25 // +#define ATST_MAIN_VEL 4000 // +#define ATST_MAIN_DAMAGE 25 // #define ATST_MAIN_SIZE 3 // make it easier to hit things // ATST Side Gun diff --git a/codeJK2/game/wp_blaster_rifle.cpp b/codeJK2/game/wp_blaster_rifle.cpp index 21eaaac51a..bdd8093e88 100644 --- a/codeJK2/game/wp_blaster_rifle.cpp +++ b/codeJK2/game/wp_blaster_rifle.cpp @@ -43,7 +43,7 @@ static void WP_FireBlasterMissile( gentity_t *ent, vec3_t start, vec3_t dir, qbo if ( ent->client && ent->client->ps.clientNum != 0 ) { if ( g_spskill->integer < 2 ) - { + { velocity *= BLASTER_NPC_VEL_CUT; } else diff --git a/codeJK2/game/wp_bowcaster.cpp b/codeJK2/game/wp_bowcaster.cpp index c4072a0777..1048d0c67e 100644 --- a/codeJK2/game/wp_bowcaster.cpp +++ b/codeJK2/game/wp_bowcaster.cpp @@ -98,7 +98,7 @@ static void WP_BowcasterMainFire( gentity_t *ent ) angs[PITCH] += ( Q_flrand(-1.0f, 1.0f) * (BLASTER_NPC_SPREAD+(6-ent->NPC->currentAim)*0.25f) ); angs[YAW] += ( Q_flrand(-1.0f, 1.0f) * (BLASTER_NPC_SPREAD+(6-ent->NPC->currentAim)*0.25f) ); } - + AngleVectors( angs, dir, NULL, NULL ); missile = CreateMissile( start, dir, vel, 10000, ent ); diff --git a/codeJK2/game/wp_demp2.cpp b/codeJK2/game/wp_demp2.cpp index b7cca42dc2..c75549b51a 100644 --- a/codeJK2/game/wp_demp2.cpp +++ b/codeJK2/game/wp_demp2.cpp @@ -96,10 +96,10 @@ void DEMP2_AltRadiusDamage( gentity_t *ent ) vec3_t v, dir; frac *= frac * frac; // yes, this is completely ridiculous...but it causes the shell to grow slowly then "explode" at the end - + radius = frac * 200.0f; // 200 is max radius...the model is aprox. 100 units tall...the fx draw code mults. this by 2. - for ( i = 0 ; i < 3 ; i++ ) + for ( i = 0 ; i < 3 ; i++ ) { mins[i] = ent->currentOrigin[i] - radius; maxs[i] = ent->currentOrigin[i] + radius; @@ -107,7 +107,7 @@ void DEMP2_AltRadiusDamage( gentity_t *ent ) numListedEntities = gi.EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); - for ( e = 0 ; e < numListedEntities ; e++ ) + for ( e = 0 ; e < numListedEntities ; e++ ) { gent = entityList[ e ]; @@ -117,17 +117,17 @@ void DEMP2_AltRadiusDamage( gentity_t *ent ) } // find the distance from the edge of the bounding box - for ( i = 0 ; i < 3 ; i++ ) + for ( i = 0 ; i < 3 ; i++ ) { - if ( ent->currentOrigin[i] < gent->absmin[i] ) + if ( ent->currentOrigin[i] < gent->absmin[i] ) { v[i] = gent->absmin[i] - ent->currentOrigin[i]; - } - else if ( ent->currentOrigin[i] > gent->absmax[i] ) + } + else if ( ent->currentOrigin[i] > gent->absmax[i] ) { v[i] = ent->currentOrigin[i] - gent->absmax[i]; - } - else + } + else { v[i] = 0; } @@ -138,7 +138,7 @@ void DEMP2_AltRadiusDamage( gentity_t *ent ) dist = VectorLength( v ); - if ( dist >= radius ) + if ( dist >= radius ) { // shockwave hasn't hit them yet continue; @@ -157,7 +157,7 @@ void DEMP2_AltRadiusDamage( gentity_t *ent ) dir[2] += 12; G_Damage( gent, ent, ent->owner, dir, ent->currentOrigin, weaponData[WP_DEMP2].altDamage, DAMAGE_DEATH_KNOCKBACK, ent->splashMethodOfDeath ); - if ( gent->takedamage && gent->client ) + if ( gent->takedamage && gent->client ) { gent->s.powerups |= ( 1 << PW_SHOCKED ); gent->client->ps.powerups[PW_SHOCKED] = level.time + 2000; diff --git a/codeJK2/game/wp_disruptor.cpp b/codeJK2/game/wp_disruptor.cpp index 4cea823d87..d18d126341 100644 --- a/codeJK2/game/wp_disruptor.cpp +++ b/codeJK2/game/wp_disruptor.cpp @@ -99,7 +99,7 @@ static void WP_DisruptorMainFire( gentity_t *ent ) gi.trace( &tr, start, NULL, NULL, end, ignore, MASK_SHOT, G2_RETURNONHIT, 0 ); traceEnt = &g_entities[tr.entityNum]; - if ( traceEnt && traceEnt->s.weapon == WP_SABER )//&& traceEnt->NPC + if ( traceEnt && traceEnt->s.weapon == WP_SABER )//&& traceEnt->NPC {//FIXME: need a more reliable way to know we hit a jedi? if ( Jedi_DodgeEvasion( traceEnt, ent, &tr, HL_NONE ) ) {//act like we didn't even hit him @@ -113,7 +113,7 @@ static void WP_DisruptorMainFire( gentity_t *ent ) break; } - if ( tr.surfaceFlags & SURF_NOIMPACT ) + if ( tr.surfaceFlags & SURF_NOIMPACT ) { render_impact = qfalse; } @@ -130,10 +130,10 @@ static void WP_DisruptorMainFire( gentity_t *ent ) // Create a simple impact type mark that doesn't last long in the world G_PlayEffect( G_EffectIndex( "disruptor/flesh_impact" ), tr.endpos, tr.plane.normal ); - if ( traceEnt->client && LogAccuracyHit( traceEnt, ent )) + if ( traceEnt->client && LogAccuracyHit( traceEnt, ent )) { ent->client->ps.persistant[PERS_ACCURACY_HITS]++; - } + } int hitLoc = G_GetHitLocFromTrace( &tr, MOD_DISRUPTOR ); if ( traceEnt && traceEnt->client && traceEnt->client->NPC_class == CLASS_GALAKMECH ) @@ -145,9 +145,9 @@ static void WP_DisruptorMainFire( gentity_t *ent ) G_Damage( traceEnt, ent, ent, wpFwd, tr.endpos, damage, DAMAGE_DEATH_KNOCKBACK, MOD_DISRUPTOR, hitLoc ); } } - else + else { - G_PlayEffect( G_EffectIndex( "disruptor/wall_impact" ), tr.endpos, tr.plane.normal ); + G_PlayEffect( G_EffectIndex( "disruptor/wall_impact" ), tr.endpos, tr.plane.normal ); } } @@ -246,7 +246,7 @@ void WP_DisruptorAltFire( gentity_t *ent ) //alternately, if you end up hitting an emplaced_gun that has a sitter, just redo this one trace with the "G2_COLLIDE, 10" to see if we it the sitter gi.trace( &tr, start, NULL, NULL, end, skip, MASK_SHOT, G2_COLLIDE, 10 );//G2_RETURNONHIT, 0 ); - if ( tr.surfaceFlags & SURF_NOIMPACT ) + if ( tr.surfaceFlags & SURF_NOIMPACT ) { render_impact = qfalse; } @@ -259,7 +259,7 @@ void WP_DisruptorAltFire( gentity_t *ent ) VectorCopy( tr.endpos, start ); skip = tr.entityNum; #ifdef _DEBUG - gi.Printf( "BAD! Disruptor gun shot somehow traced back and hit the owner!\n" ); + gi.Printf( "BAD! Disruptor gun shot somehow traced back and hit the owner!\n" ); #endif continue; } @@ -279,7 +279,7 @@ void WP_DisruptorAltFire( gentity_t *ent ) traceEnt = &g_entities[tr.entityNum]; - if ( traceEnt && traceEnt->s.weapon == WP_SABER )//&& traceEnt->NPC + if ( traceEnt && traceEnt->s.weapon == WP_SABER )//&& traceEnt->NPC {//FIXME: need a more reliable way to know we hit a jedi? hitDodged = Jedi_DodgeEvasion( traceEnt, ent, &tr, HL_NONE ); //acts like we didn't even hit him @@ -288,26 +288,26 @@ void WP_DisruptorAltFire( gentity_t *ent ) { if ( render_impact ) { - if (( tr.entityNum < ENTITYNUM_WORLD && traceEnt->takedamage ) || !Q_stricmp( traceEnt->classname, "misc_model_breakable" ) + if (( tr.entityNum < ENTITYNUM_WORLD && traceEnt->takedamage ) || !Q_stricmp( traceEnt->classname, "misc_model_breakable" ) || traceEnt->s.eType == ET_MOVER ) { // Create a simple impact type mark that doesn't last long in the world G_PlayEffect( G_EffectIndex( "disruptor/alt_hit" ), tr.endpos, tr.plane.normal ); - if ( traceEnt->client && LogAccuracyHit( traceEnt, ent )) + if ( traceEnt->client && LogAccuracyHit( traceEnt, ent )) {//NOTE: hitting multiple ents can still get you over 100% accuracy ent->client->ps.persistant[PERS_ACCURACY_HITS]++; - } + } int hitLoc = G_GetHitLocFromTrace( &tr, MOD_DISRUPTOR ); if ( traceEnt && traceEnt->client && traceEnt->client->NPC_class == CLASS_GALAKMECH ) {//hehe - G_Damage( traceEnt, ent, ent, wpFwd, tr.endpos, 10, DAMAGE_NO_KNOCKBACK|DAMAGE_NO_HIT_LOC, fullCharge ? MOD_SNIPER : MOD_DISRUPTOR, hitLoc ); + G_Damage( traceEnt, ent, ent, wpFwd, tr.endpos, 10, DAMAGE_NO_KNOCKBACK|DAMAGE_NO_HIT_LOC, fullCharge ? MOD_SNIPER : MOD_DISRUPTOR, hitLoc ); break; } G_Damage( traceEnt, ent, ent, wpFwd, tr.endpos, damage, DAMAGE_NO_KNOCKBACK|DAMAGE_NO_HIT_LOC, fullCharge ? MOD_SNIPER : MOD_DISRUPTOR, hitLoc ); } - else + else { // we only make this mark on things that can't break or move tent = G_TempEntity( tr.endpos, EV_DISRUPTOR_SNIPER_MISS ); diff --git a/codeJK2/game/wp_emplaced_gun.cpp b/codeJK2/game/wp_emplaced_gun.cpp index 25758823d5..a18e42c780 100644 --- a/codeJK2/game/wp_emplaced_gun.cpp +++ b/codeJK2/game/wp_emplaced_gun.cpp @@ -41,7 +41,7 @@ void WP_EmplacedFire( gentity_t *ent ) missile->classname = "emplaced_proj"; missile->s.weapon = WP_EMPLACED_GUN; - missile->damage = damage; + missile->damage = damage; missile->dflags = DAMAGE_DEATH_KNOCKBACK | DAMAGE_HEAVY_WEAP_CLASS; missile->methodOfDeath = MOD_EMPLACED; missile->clipmask = MASK_SHOT | CONTENTS_LIGHTSABER; diff --git a/codeJK2/game/wp_flechette.cpp b/codeJK2/game/wp_flechette.cpp index 79130363a9..8f073d719e 100644 --- a/codeJK2/game/wp_flechette.cpp +++ b/codeJK2/game/wp_flechette.cpp @@ -86,9 +86,9 @@ static void WP_FlechetteMainFire( gentity_t *ent ) // { // missile->flags |= FL_OVERCHARGED; // } - + missile->dflags = (DAMAGE_DEATH_KNOCKBACK|DAMAGE_EXTRA_KNOCKBACK); - + missile->methodOfDeath = MOD_FLECHETTE; missile->clipmask = MASK_SHOT | CONTENTS_LIGHTSABER; @@ -162,7 +162,7 @@ void prox_mine_stick( gentity_t *self, gentity_t *other, trace_t *trace ) self->owner = NULL; WP_Stick( self, trace ); - + self->e_ThinkFunc = thinkF_prox_mine_think; self->nextthink = level.time + 450; @@ -198,7 +198,7 @@ static void WP_FlechetteProxMine( gentity_t *ent ) missile->clipmask = MASK_SHOT; // we don't want it to bounce forever - missile->bounceCount = 0; + missile->bounceCount = 0; } */ //---------------------------------------------- @@ -218,7 +218,7 @@ static void WP_CreateFlechetteBouncyThing( vec3_t start, vec3_t fwd, gentity_t * //------------------------------------------------------------------------------ { gentity_t *missile = CreateMissile( start, fwd, 950 + Q_flrand(0.0f, 1.0f) * 700, 1500 + Q_flrand(0.0f, 1.0f) * 2000, self, qtrue ); - + missile->e_ThinkFunc = thinkF_WP_flechette_alt_blow; missile->s.weapon = WP_FLECHETTE; diff --git a/codeJK2/game/wp_rocket_launcher.cpp b/codeJK2/game/wp_rocket_launcher.cpp index cf7c7b89d5..a3f5431ca7 100644 --- a/codeJK2/game/wp_rocket_launcher.cpp +++ b/codeJK2/game/wp_rocket_launcher.cpp @@ -36,13 +36,13 @@ along with this program; if not, see . void rocketThink( gentity_t *ent ) //--------------------------------------------------------- { - vec3_t newdir, targetdir, - wpUp={0,0,1}, right; + vec3_t newdir, targetdir, + wpUp={0,0,1}, right; vec3_t org; float dot, dot2; if ( ent->enemy && ent->enemy->inuse ) - { + { float vel = ROCKET_VELOCITY; VectorCopy( ent->enemy->currentOrigin, org ); @@ -74,18 +74,18 @@ void rocketThink( gentity_t *ent ) // a dot of 1.0 means right-on-target. if ( dot < 0.0f ) - { + { // Go in the direction opposite, start a 180. CrossProduct( ent->movedir, wpUp, right ); dot2 = DotProduct( targetdir, right ); if ( dot2 > 0 ) - { + { // Turn 45 degrees right. VectorMA( ent->movedir, 0.3f, right, newdir ); } else - { + { // Turn 45 degrees left. VectorMA(ent->movedir, -0.3f, right, newdir); } @@ -97,12 +97,12 @@ void rocketThink( gentity_t *ent ) // vel *= 0.5f; } else if ( dot < 0.70f ) - { + { // Still a bit off, so we turn a bit softer VectorMA( ent->movedir, 0.5f, targetdir, newdir ); } else - { + { // getting close, so turn a bit harder VectorMA( ent->movedir, 0.9f, targetdir, newdir ); } @@ -205,8 +205,8 @@ void WP_FireRocket( gentity_t *ent, qboolean alt_fire ) dif = 8; } - // if we are fully locked, always take on the enemy. - // Also give a slight advantage to higher, but not quite full charges. + // if we are fully locked, always take on the enemy. + // Also give a slight advantage to higher, but not quite full charges. // Finally, just give any amount of charge a very slight random chance of locking. if ( dif == 8 || Q_flrand(0.0f, 1.0f) * dif > 2 || Q_flrand(0.0f, 1.0f) > 0.97f ) { diff --git a/codeJK2/icarus/BlockStream.cpp b/codeJK2/icarus/BlockStream.cpp index af8976518d..bb6213dceb 100644 --- a/codeJK2/icarus/BlockStream.cpp +++ b/codeJK2/icarus/BlockStream.cpp @@ -75,7 +75,7 @@ GetInfo */ void CBlockMember::GetInfo( int *id, int *size, void **data ) -{ +{ *id = m_id; *size = m_size; *data = m_data; @@ -141,7 +141,7 @@ int CBlockMember::ReadMember( char **stream, int *streamPos ) #endif } *streamPos += m_size; - + return true; } @@ -267,7 +267,7 @@ int CBlock::Write( int member_id, const char *member_data ) CBlockMember *bMember = new CBlockMember; bMember->SetID( member_id ); - + bMember->SetData( member_data ); bMember->SetSize( strlen(member_data) + 1 ); @@ -278,7 +278,7 @@ int CBlock::Write( int member_id, const char *member_data ) int CBlock::Write( int member_id, vector_t member_data ) { - CBlockMember *bMember; + CBlockMember *bMember; bMember = new CBlockMember; @@ -321,7 +321,7 @@ int CBlock::Write( int member_id, int member_data ) int CBlock::Write( CBlockMember *bMember ) { // findme: this is wrong: bMember->SetSize( sizeof(bMember->GetData()) ); - + AddMember( bMember ); return true; @@ -571,12 +571,12 @@ int CBlockStream::WriteBlock( CBlock *block ) int numMembers = block->GetNumMembers(); unsigned char flags = block->GetFlags(); - fwrite ( &id, sizeof(id), 1, m_fileHandle ); + fwrite ( &id, sizeof(id), 1, m_fileHandle ); fwrite ( &numMembers, sizeof(numMembers), 1, m_fileHandle ); fwrite ( &flags, sizeof( flags ), 1, m_fileHandle ); for ( int i = 0; i < numMembers; i++ ) - { + { bMember = block->GetMember( i ); bMember->WriteMember( m_fileHandle ); } @@ -626,7 +626,7 @@ int CBlockStream::ReadBlock( CBlock *get ) get->SetFlags( flags ); while ( numMembers-- > 0) - { + { bMember = new CBlockMember; bMember->ReadMember( &m_stream, &m_streamPos ); get->AddMember( bMember ); @@ -645,7 +645,7 @@ int CBlockStream::Open( char *buffer, long size ) { char id_header[IBI_HEADER_ID_LENGTH]; float version; - + Init(); m_fileSize = size; diff --git a/codeJK2/icarus/Instance.cpp b/codeJK2/icarus/Instance.cpp index 7aec690b14..4ee1a44115 100644 --- a/codeJK2/icarus/Instance.cpp +++ b/codeJK2/icarus/Instance.cpp @@ -47,7 +47,7 @@ ICARUS_Instance::ICARUS_Instance( void ) m_DEBUG_NumSequenceFreed = 0; m_DEBUG_NumSequenceResidual = 0; -#endif +#endif } @@ -87,7 +87,7 @@ int ICARUS_Instance::Free( void ) STL_ITERATE( sri, m_sequencers ) { delete (*sri); - + #ifdef _DEBUG m_DEBUG_NumSequencerResidual++; @@ -191,7 +191,7 @@ void ICARUS_Instance::DeleteSequencer( CSequencer *sequencer ) delete taskManager; } - m_sequencers.remove( sequencer ); + m_sequencers.remove( sequencer ); sequencer->Free(); delete sequencer; @@ -224,7 +224,7 @@ CSequence *ICARUS_Instance::GetSequence( void ) m_DEBUG_NumSequenceAlloc++; -#endif +#endif return sequence; } @@ -255,7 +255,7 @@ DeleteSequence void ICARUS_Instance::DeleteSequence( CSequence *sequence ) { - m_sequences.remove( sequence ); + m_sequences.remove( sequence ); delete sequence; @@ -263,7 +263,7 @@ void ICARUS_Instance::DeleteSequence( CSequence *sequence ) m_DEBUG_NumSequenceFreed++; -#endif +#endif } /* @@ -407,7 +407,7 @@ int ICARUS_Instance::SaveSignals( void ) { //m_interface->I_WriteSaveData( INT_ID('I','S','I','G'), &numSignals, sizeof( numSignals ) ); const char *name = ((*si).first).c_str(); - + //Make sure this is a valid string assert( ( name != NULL ) && ( name[0] != '\0' ) ); @@ -435,7 +435,7 @@ Save */ int ICARUS_Instance::Save( void ) -{ +{ //Save out a ICARUS save block header with the ICARUS version double version = ICARUS_VERSION; @@ -597,7 +597,7 @@ int ICARUS_Instance::LoadSequencers( void ) saved_game.read_chunk( INT_ID('#', 'S', 'Q', 'R'), numSequencers); - + //Load all sequencers for ( int i = 0; i < numSequencers; i++ ) { diff --git a/codeJK2/icarus/Interface.cpp b/codeJK2/icarus/Interface.cpp index 106a6d8d36..22d7e01d65 100644 --- a/codeJK2/icarus/Interface.cpp +++ b/codeJK2/icarus/Interface.cpp @@ -1,6 +1,6 @@ // ICARUS Engine Interface File // -// This file is the only section of the ICARUS systems that +// This file is the only section of the ICARUS systems that // is not directly portable from engine to engine. // // -- jweier diff --git a/codeJK2/icarus/Interpreter.cpp b/codeJK2/icarus/Interpreter.cpp index 2fe1f01c78..b986f1f7f4 100644 --- a/codeJK2/icarus/Interpreter.cpp +++ b/codeJK2/icarus/Interpreter.cpp @@ -33,11 +33,11 @@ keywordArray_t CInterpreter::m_symbolKeywords[] = //Blocks "{", TK_BLOCK_START, "}", TK_BLOCK_END, - + //Vectors "<", TK_VECTOR_START, ">", TK_VECTOR_END, - + //Groups "(", TK_OPEN_PARENTHESIS, ")", TK_CLOSED_PARENTHESIS, @@ -160,7 +160,7 @@ int CInterpreter::Error( char *format, ... ) int error_line = m_iCurrentLine; // m_tokenizer->GetCurLine(); m_tokenizer->GetCurFilename( &error_file ); - if (!error_file) + if (!error_file) { // 99% of the time we'll get here now, because of pushed parse streams // @@ -189,7 +189,7 @@ int CInterpreter::Error( char *format, ... ) strcat(out_msg, "\n"); } -#ifdef __POP_UPS__ +#ifdef __POP_UPS__ MessageBox( NULL, out_msg, "Error", MB_OK ); @@ -516,7 +516,7 @@ int CInterpreter::Match( int token_id ) { //This may have been a check, so don't loose the token m_tokenizer->PutBackToken( token ); - + return false; } @@ -558,7 +558,7 @@ int CInterpreter::LookAhead( int token_id ) if ( token->GetType() != token_id ) { m_tokenizer->PutBackToken( token ); - + return false; } @@ -650,7 +650,7 @@ int CInterpreter::GetFloat( CBlock *block ) { return Error("syntax error : expected float; found %s", GetTokenName(type) ); } - + if (type == TK_FLOAT) { block->Write( TK_FLOAT, (float) token->GetFloatValue() ); @@ -734,7 +734,7 @@ int CInterpreter::GetString( CBlock *block ) else temp[i] = temptr[i]; } - + temp[ strlen( temptr ) ] = 0; //UGLY HACK END!!! @@ -742,7 +742,7 @@ int CInterpreter::GetString( CBlock *block ) block->Write( TK_STRING, (const char *) &temp ); token->Delete(); - + return true; } @@ -781,7 +781,7 @@ int CInterpreter::GetIdentifier( CBlock *block ) block->Write( TK_IDENTIFIER, (const char *) token->GetStringValue() ); token->Delete(); - + return true; } @@ -984,7 +984,7 @@ int CInterpreter::GetID( char *id_name ) switch (id) { - + //Affect takes control of an entity case ID_AFFECT: @@ -1018,7 +1018,7 @@ int CInterpreter::GetID( char *id_name ) case ID_FLUSH: return GetFlush(); break; - + case ID_RUN: return GetRun(); break; @@ -1563,7 +1563,7 @@ int CInterpreter::GetAffect( void ) if (!Match( TK_OPEN_PARENTHESIS )) return Error("syntax error : '(' not found"); - if ( GetString( &block ) == false ) + if ( GetString( &block ) == false ) return false; if (!LookAhead( TK_IDENTIFIER )) @@ -1581,7 +1581,7 @@ int CInterpreter::GetAffect( void ) { case TYPE_INSERT: case TYPE_FLUSH: - + block.Write( TK_FLOAT, (float) type ); break; @@ -1677,7 +1677,7 @@ int CInterpreter::GetSet( void ) switch( GetNextType() ) { case TK_INT: - + if ( GetInteger( &block ) == false ) return false; @@ -1691,7 +1691,7 @@ int CInterpreter::GetSet( void ) break; case TK_STRING: - + if ( GetString( &block ) == false ) return false; @@ -1703,7 +1703,7 @@ int CInterpreter::GetSet( void ) return false; break; - + default: if ( MatchTag() ) @@ -1711,7 +1711,7 @@ int CInterpreter::GetSet( void ) GetTag( &block ); break; } - + if ( MatchRandom() ) { GetRandom( &block ); @@ -1959,7 +1959,7 @@ int CInterpreter::GetRemove( void ) // this is just so people can put comments in scripts in BehavEd and not have them lost as normal comments would be. // int CInterpreter::GetRem( void ) -{ +{ CBlock block; block.Create( ID_REM ); @@ -1972,7 +1972,7 @@ int CInterpreter::GetRem( void ) if (Match( TK_CLOSED_PARENTHESIS )) return true; - GetString( &block ); + GetString( &block ); if (!Match( TK_CLOSED_PARENTHESIS )) return Error("rem : function only takes 1 optional parameter"); @@ -2025,17 +2025,17 @@ int CInterpreter::GetCamera( void ) break; case TYPE_ZOOM: //ZOOM ( FOV, DURATION ) - + block.Write( TK_FLOAT, (float) type ); if ( GetFloat( &block ) == false ) return false; - + if ( GetFloat( &block ) == false ) return false; break; - + case TYPE_MOVE: //MOVE ( ORIGIN, DURATION ) block.Write( TK_FLOAT, (float) type ); @@ -2047,9 +2047,9 @@ int CInterpreter::GetCamera( void ) return false; break; - + case TYPE_FADE: //FADE ( SOURCE(R,G,B,A), DEST(R,G,B,A), DURATION ) - + block.Write( TK_FLOAT, (float) type ); //Source color @@ -2357,15 +2357,15 @@ int CInterpreter::Interpret( CTokenizer *Tokenizer, CBlockStream *BlockStream, c int type, blockLevel = 0, parenthesisLevel = 0; m_sCurrentFile = filename; // used during error reporting because you can't ask tokenizer for pushed streams - + m_tokenizer = Tokenizer; m_blockStream = BlockStream; m_iCurrentLine = m_tokenizer->GetCurLine(); - token = m_tokenizer->GetToEndOfLine(TK_STRING); - m_sCurrentLine = token->GetStringValue(); + token = m_tokenizer->GetToEndOfLine(TK_STRING); + m_sCurrentLine = token->GetStringValue(); m_tokenizer->PutBackToken(token, false, NULL, true); - + m_iBadCBlockNumber = 0; while (m_tokenizer->GetRemainingSize() > 0) @@ -2389,11 +2389,11 @@ int CInterpreter::Interpret( CTokenizer *Tokenizer, CBlockStream *BlockStream, c // read the next line, then put it back token->Delete(); m_iCurrentLine = m_tokenizer->GetCurLine(); - token = m_tokenizer->GetToEndOfLine(TK_STRING); - m_sCurrentLine = token->GetStringValue(); + token = m_tokenizer->GetToEndOfLine(TK_STRING); + m_sCurrentLine = token->GetStringValue(); m_tokenizer->PutBackToken(token, false, NULL, true); break; - + case TK_CHAR: case TK_STRING: token->Delete(); @@ -2401,21 +2401,21 @@ int CInterpreter::Interpret( CTokenizer *Tokenizer, CBlockStream *BlockStream, c Error("syntax error : unexpected string"); return m_iBadCBlockNumber; break; - + case TK_INT: token->Delete(); - m_iBadCBlockNumber = -m_iBadCBlockNumber; + m_iBadCBlockNumber = -m_iBadCBlockNumber; Error("syntax error : unexpected integer"); return m_iBadCBlockNumber; break; - + case TK_FLOAT: token->Delete(); m_iBadCBlockNumber = -m_iBadCBlockNumber; Error("syntax error : unexpected float"); return m_iBadCBlockNumber; break; - + case TK_IDENTIFIER: m_iBadCBlockNumber++; if (!GetID( (char *) token->GetStringValue() )) @@ -2425,7 +2425,7 @@ int CInterpreter::Interpret( CTokenizer *Tokenizer, CBlockStream *BlockStream, c } token->Delete(); break; - + case TK_BLOCK_START: token->Delete(); if (parenthesisLevel) @@ -2446,7 +2446,7 @@ int CInterpreter::Interpret( CTokenizer *Tokenizer, CBlockStream *BlockStream, c Error("syntax error : brace inside parenthesis"); return m_iBadCBlockNumber; } - + block.Create( ID_BLOCK_END ); m_blockStream->WriteBlock( &block ); block.Free(); diff --git a/codeJK2/icarus/Sequence.cpp b/codeJK2/icarus/Sequence.cpp index f2ab7507e4..170c852184 100644 --- a/codeJK2/icarus/Sequence.cpp +++ b/codeJK2/icarus/Sequence.cpp @@ -131,7 +131,7 @@ void CSequence::RemoveChild( CSequence *child ) assert( child ); if ( child == NULL ) return; - + //Remove the child m_children.remove( child ); m_numChildren--; @@ -177,7 +177,7 @@ void CSequence::SetParent( CSequence *parent ) m_flags |= SQ_RETAIN; if ( parent->m_flags & SQ_PENDING ) - m_flags |= SQ_PENDING; + m_flags |= SQ_PENDING; } /* @@ -203,7 +203,7 @@ CBlock *CSequence::PopCommand( int type ) command = m_commands.front(); m_commands.pop_front(); m_numCommands--; - + return command; break; @@ -212,7 +212,7 @@ CBlock *CSequence::PopCommand( int type ) command = m_commands.back(); m_commands.pop_back(); m_numCommands--; - + return command; break; } @@ -236,7 +236,7 @@ int CSequence::PushCommand( CBlock *block, int type ) switch ( type ) { case PUSH_FRONT: - + m_commands.push_front( block ); m_numCommands++; @@ -377,14 +377,14 @@ int CSequence::SaveCommand( CBlock *block ) saved_game.write_chunk( INT_ID('B', 'M', 'I', 'D'), bID); - + //Save out the data size size = bm->GetSize(); saved_game.write_chunk( INT_ID('B', 'S', 'I', 'Z'), size); - + //Save out the raw data const uint8_t* raw_data = static_cast(bm->GetData()); @@ -425,7 +425,7 @@ int CSequence::Save( void ) saved_game.write_chunk( INT_ID('S', 'R', 'I', 'D'), id); - + //Save the number of children saved_game.write_chunk( INT_ID('S', 'N', 'C', 'H'), @@ -473,7 +473,7 @@ Load int CSequence::Load( void ) { - unsigned char flags = 0; + unsigned char flags = 0; CSequence *sequence; CBlock *block; int id = 0, numMembers = 0; @@ -491,7 +491,7 @@ int CSequence::Load( void ) id); m_parent = ( id != -1 ) ? m_owner->GetSequence( id ) : NULL; - + //Get the return sequence saved_game.read_chunk( INT_ID('S', 'R', 'I', 'D'), @@ -515,7 +515,7 @@ int CSequence::Load( void ) //Get the desired sequence if ( ( sequence = m_owner->GetSequence( id ) ) == NULL ) return false; - + //Insert this into the list STL_INSERT( m_children, sequence ); @@ -523,7 +523,7 @@ int CSequence::Load( void ) m_childrenMap[ i ] = sequence; } - + //Get the sequence flags saved_game.read_chunk( INT_ID('S', 'F', 'L', 'G'), @@ -550,9 +550,9 @@ int CSequence::Load( void ) id); block = new CBlock; - + block->Create( id ); - + //Read the block's flags saved_game.read_chunk( INT_ID('B', 'F', 'L', 'G'), @@ -566,7 +566,7 @@ int CSequence::Load( void ) saved_game.read_chunk( INT_ID('B', 'N', 'U', 'M'), numMembers); - + for ( int j = 0; j < numMembers; j++ ) { bID = 0; @@ -630,7 +630,7 @@ int CSequence::Load( void ) case ID_RANDOM: block->Write( ID_RANDOM, *(float *) bData );//(float) ID_RANDOM ); break; - + case TK_EQUALS: case TK_GREATER_THAN: case TK_LESS_THAN: @@ -643,7 +643,7 @@ int CSequence::Load( void ) return false; break; } - + //Get rid of the temp memory ICARUS_Free( bData ); } diff --git a/codeJK2/icarus/Sequencer.cpp b/codeJK2/icarus/Sequencer.cpp index fb6f3db1d9..89c8164e9e 100644 --- a/codeJK2/icarus/Sequencer.cpp +++ b/codeJK2/icarus/Sequencer.cpp @@ -32,7 +32,7 @@ along with this program; if not, see . #include "assert.h" #include "../code/qcommon/ojk_saved_game_helper.h" -// Sequencer +// Sequencer CSequencer::CSequencer( void ) { @@ -129,7 +129,7 @@ int CSequencer::Flush( CSequence *owner ) { if ( owner == NULL ) return SEQ_FAILED; - + Recall(); sequence_l::iterator sli; @@ -145,11 +145,11 @@ int CSequencer::Flush( CSequence *owner ) //Remove it from the map m_sequenceMap.erase( (*sli)->GetID() ); - + //Delete it, and remove all references RemoveSequence( (*sli) ); m_owner->DeleteSequence( (*sli) ); - + //Delete from the sequence list and move on sli = m_sequences.erase( sli ); } @@ -198,7 +198,7 @@ void CSequencer::DeleteStream( bstream_t *bstream ) } bstream->stream->Free(); - + delete bstream->stream; delete bstream; @@ -279,7 +279,7 @@ CSequence *CSequencer::AddSequence( CSequence *parent, CSequence *returnSeq, int sequence->SetFlags( flags ); sequence->SetParent( parent ); sequence->SetReturn( returnSeq ); - + return sequence; } @@ -294,12 +294,12 @@ Retrieves a sequence by its ID CSequence *CSequencer::GetSequence( int id ) { sequenceID_m::iterator mi; - + mi = m_sequenceMap.find( id ); if ( mi == m_sequenceMap.end() ) return NULL; - + return (*mi).second; } @@ -330,12 +330,12 @@ Runs a script int CSequencer::Run( char *buffer, long size ) { bstream_t *blockStream; - + Recall(); //Create a new stream blockStream = AddStream(); - + //Open the stream as an IBI stream if (!blockStream->stream->Open( buffer, size )) { @@ -345,7 +345,7 @@ int CSequencer::Run( char *buffer, long size ) CSequence *sequence = AddSequence( NULL, m_curSequence, SQ_COMMON ); - // Interpret the command blocks and route them properly + // Interpret the command blocks and route them properly if ( S_FAILED( Route( sequence, blockStream )) ) { //Error code is set inside of Route() @@ -402,7 +402,7 @@ int CSequencer::ParseRun( CBlock *block ) m_curSequence->AddChild( new_sequence ); - // Interpret the command blocks and route them properly + // Interpret the command blocks and route them properly if ( S_FAILED( Route( new_sequence, new_stream )) ) { //Error code is set inside of Route() @@ -432,10 +432,10 @@ Parses an if statement int CSequencer::ParseIf( CBlock *block, bstream_t *bstream ) { CSequence *sequence; - + //Create the container sequence sequence = AddSequence( m_curSequence, m_curSequence, SQ_CONDITIONAL ); - + assert( sequence ); if ( sequence == NULL ) { @@ -452,7 +452,7 @@ int CSequencer::ParseIf( CBlock *block, bstream_t *bstream ) //Push this onto the stack to mark the conditional entrance PushCommand( block, PUSH_FRONT ); - + //Recursively obtain the conditional body Route( sequence, bstream ); @@ -475,12 +475,12 @@ int CSequencer::ParseElse( CBlock *block, bstream_t *bstream ) //The else is not retained delete block; block = NULL; - + CSequence *sequence; - + //Create the container sequence sequence = AddSequence( m_curSequence, m_curSequence, SQ_CONDITIONAL ); - + assert( sequence ); if ( sequence == NULL ) { @@ -499,7 +499,7 @@ int CSequencer::ParseElse( CBlock *block, bstream_t *bstream ) } m_elseOwner->Write( TK_FLOAT, (float) sequence->GetID() ); - + m_elseOwner->SetFlag( BF_ELSE ); //Recursively obtain the conditional body @@ -526,23 +526,23 @@ int CSequencer::ParseLoop( CBlock *block, bstream_t *bstream ) float min, max; int rIter; int memberNum = 0; - + //Set the parent sequence = AddSequence( m_curSequence, m_curSequence, ( SQ_LOOP | SQ_RETAIN ) ); - + assert( sequence ); if ( sequence == NULL ) { m_ie->I_DPrintf( WL_ERROR, "ParseLoop : failed to allocate container sequence" ); delete block; - block = NULL; + block = NULL; return SEQ_FAILED; } m_curSequence->AddChild( sequence ); //Set the number of iterations of this sequence - + bm = block->GetMember( memberNum++ ); if ( bm->GetID() == ID_RANDOM ) @@ -550,7 +550,7 @@ int CSequencer::ParseLoop( CBlock *block, bstream_t *bstream ) //Parse out the random number min = *(float *) block->GetMemberData( memberNum++ ); max = *(float *) block->GetMemberData( memberNum++ ); - + rIter = (int) m_ie->I_Random( min, max ); sequence->SetIterations( rIter ); } @@ -558,13 +558,13 @@ int CSequencer::ParseLoop( CBlock *block, bstream_t *bstream ) { sequence->SetIterations ( (int) (*(float *) bm->GetData()) ); } - + //Add a unique loop identifier to the block for reference later block->Write( TK_FLOAT, (float) sequence->GetID() ); //Push this onto the stack to mark the loop entrance PushCommand( block, PUSH_FRONT ); - + //Recursively obtain the loop Route( sequence, bstream ); @@ -591,7 +591,7 @@ int CSequencer::AddAffect( bstream_t *bstream, int retain, int *id ) //This will be replaced once it's actually used, but this will restore the route state properly sequence->SetReturn( m_curSequence ); - + //We need this as a temp holder new_stream.last = m_curStream; new_stream.stream = bstream->stream; @@ -629,7 +629,7 @@ int CSequencer::ParseAffect( CBlock *block, bstream_t *bstream ) if( !ent ) // if there wasn't a valid entname in the affect, we need to check if it's a get command { //try to parse a 'get' command that is embeded in this 'affect' - + int id; char *p1 = NULL; char *name = 0; @@ -639,7 +639,7 @@ int CSequencer::ParseAffect( CBlock *block, bstream_t *bstream ) // bm = block->GetMember( 0 ); id = bm->GetID(); - + switch ( id ) { // these 3 cases probably aren't necessary @@ -649,9 +649,9 @@ int CSequencer::ParseAffect( CBlock *block, bstream_t *bstream ) p1 = (char *) bm->GetData(); break; - case ID_GET: + case ID_GET: { - int type; + int type; //get( TYPE, NAME ) type = (int) (*(float *) block->GetMemberData( 1 )); @@ -659,7 +659,7 @@ int CSequencer::ParseAffect( CBlock *block, bstream_t *bstream ) switch ( type ) // what type are they attempting to get { - + case TK_STRING: //only string is acceptable for affect, store result in p1 if ( m_ie->I_GetString( m_ownerID, type, name, &p1 ) == false) @@ -698,7 +698,7 @@ int CSequencer::ParseAffect( CBlock *block, bstream_t *bstream ) { // a valid entity name was not returned from the get command m_ie->I_DPrintf( WL_WARNING, "'%s' : invalid affect() target\n"); } - + } // end if(!ent) if( ent ) @@ -709,7 +709,7 @@ int CSequencer::ParseAffect( CBlock *block, bstream_t *bstream ) if (stream_sequencer == NULL) { m_ie->I_DPrintf( WL_WARNING, "'%s' : invalid affect() target\n", entname ); - + //Fast-forward out of this affect block onto the next valid code CSequence *backSeq = m_curSequence; @@ -734,12 +734,12 @@ int CSequencer::ParseAffect( CBlock *block, bstream_t *bstream ) //FIXME: If the target sequence is freed, what then? (!suspect!) block->Write( TK_FLOAT, (float) ret ); - + PushCommand( block, PUSH_FRONT ); /* //Don't actually do these right now, we're just pre-processing (parsing) the affect if( ent ) - { // ents need to update upon being affected + { // ents need to update upon being affected ent->taskManager->Update(); } */ @@ -780,7 +780,7 @@ int CSequencer::ParseTask( CBlock *block, bstream_t *bstream ) //The current group is set to this group, all subsequent commands (until a block end) will fall into this task group group->SetParent( m_curGroup ); m_curGroup = group; - + //Keep an association between this task and the container sequence AddTaskSequence( sequence, group ); @@ -831,10 +831,10 @@ int CSequencer::Route( CSequence *sequence, bstream_t *bstream ) { //Marks the end of a blocked section case ID_BLOCK_END: - + //Save this as a pre-process marker PushCommand( block, PUSH_FRONT ); - + if ( m_curSequence->HasFlag( SQ_RUN ) || m_curSequence->HasFlag( SQ_AFFECT ) ) { //Go back to the last stream @@ -847,7 +847,7 @@ int CSequencer::Route( CSequence *sequence, bstream_t *bstream ) m_curStream = bstream->last; m_curGroup = m_curGroup->GetParent(); } - + m_curSequence = m_curSequence->GetReturn(); return SEQ_OK; @@ -871,7 +871,7 @@ int CSequencer::Route( CSequence *sequence, bstream_t *bstream ) //Loop pre-processor case ID_LOOP: - + if S_FAILED( ParseLoop( block, bstream ) ) return SEQ_FAILED; @@ -900,7 +900,7 @@ int CSequencer::Route( CSequence *sequence, bstream_t *bstream ) break; case ID_TASK: - + if S_FAILED( ParseTask( block, bstream ) ) return SEQ_FAILED; @@ -931,9 +931,9 @@ int CSequencer::Route( CSequence *sequence, bstream_t *bstream ) //Error default: - + m_ie->I_DPrintf( WL_ERROR, "'%d' : invalid block ID", block->GetBlockID() ); - + return SEQ_FAILED; break; } @@ -957,7 +957,7 @@ int CSequencer::Route( CSequence *sequence, bstream_t *bstream ) //Check to start the communication if ( ( bstream->last == NULL ) && ( m_numCommands > 0 ) ) - { + { //Everything is routed, so get it all rolling Prime( m_taskManager, PopCommand( POP_BACK ) ); } @@ -966,7 +966,7 @@ int CSequencer::Route( CSequence *sequence, bstream_t *bstream ) //Free the stream DeleteStream( bstream ); - + return SEQ_OK; } @@ -1007,7 +1007,7 @@ void CSequencer::CheckRun( CBlock **command ) } m_curSequence = GetSequence( id ); - + //TODO: Emit warning assert( m_curSequence ); if ( m_curSequence == NULL ) @@ -1020,14 +1020,14 @@ void CSequencer::CheckRun( CBlock **command ) if ( m_curSequence->GetNumCommands() > 0 ) { *command = PopCommand( POP_BACK ); - + Prep( command ); //Account for any other pre-processes return; } return; } - + //Check for the end of a run if ( ( block->GetBlockID() == ID_BLOCK_END ) && ( m_curSequence->HasFlag( SQ_RUN ) ) ) { @@ -1047,10 +1047,10 @@ void CSequencer::CheckRun( CBlock **command ) if ( m_curSequence && m_curSequence->GetNumCommands() > 0 ) { *command = PopCommand( POP_BACK ); - + Prep( command ); //Account for any other pre-processes return; - } + } //FIXME: Check this... } @@ -1111,7 +1111,7 @@ int CSequencer::EvaluateConditional( CBlock *block ) p1 = (char *) bm->GetData(); break; - case ID_GET: + case ID_GET: { int type; char *name; @@ -1135,7 +1135,7 @@ int CSequencer::EvaluateConditional( CBlock *block ) Com_sprintf( tempString1, sizeof( tempString1 ), "%.3f", fVal ); p1 = (char *) tempString1; } - + break; case TK_INT: @@ -1154,7 +1154,7 @@ int CSequencer::EvaluateConditional( CBlock *block ) if ( m_ie->I_GetString( m_ownerID, type, name, &p1 ) == false) return false; - + break; case TK_VECTOR: @@ -1167,7 +1167,7 @@ int CSequencer::EvaluateConditional( CBlock *block ) Com_sprintf( tempString1, sizeof( tempString1 ), "%.3f %.3f %.3f", vVal[0], vVal[1], vVal[2] ); p1 = (char *) tempString1; } - + break; } @@ -1281,7 +1281,7 @@ int CSequencer::EvaluateConditional( CBlock *block ) p2 = (char *) bm->GetData(); break; - case ID_GET: + case ID_GET: { int type; char *name; @@ -1305,7 +1305,7 @@ int CSequencer::EvaluateConditional( CBlock *block ) Com_sprintf( tempString2, sizeof( tempString2 ), "%.3f", fVal ); p2 = (char *) tempString2; } - + break; case TK_INT: @@ -1324,7 +1324,7 @@ int CSequencer::EvaluateConditional( CBlock *block ) if ( m_ie->I_GetString( m_ownerID, type, name, &p2 ) == false) return false; - + break; case TK_VECTOR: @@ -1337,7 +1337,7 @@ int CSequencer::EvaluateConditional( CBlock *block ) Com_sprintf( tempString2, sizeof( tempString2 ), "%.3f %.3f %.3f", vVal[0], vVal[1], vVal[2] ); p2 = (char *) tempString2; } - + break; } @@ -1345,7 +1345,7 @@ int CSequencer::EvaluateConditional( CBlock *block ) } case ID_RANDOM: - + { float min, max; //FIXME: This will not account for nested Q_flrand(0.0f, 1.0f) statements @@ -1450,14 +1450,14 @@ void CSequencer::CheckIf( CBlock **command ) block = NULL; *command = NULL; } - + m_curSequence = successSeq; //Recursively work out any other pre-processors *command = PopCommand( POP_BACK ); Prep( command ); - - return; + + return; } if ( ( ret == false ) && ( block->HasFlag( BF_ELSE ) ) ) @@ -1485,14 +1485,14 @@ void CSequencer::CheckIf( CBlock **command ) block = NULL; *command = NULL; } - + m_curSequence = failureSeq; //Recursively work out any other pre-processors *command = PopCommand( POP_BACK ); Prep( command ); - - return; + + return; } //Only save the conditional statement if the calling sequence is retained @@ -1510,8 +1510,8 @@ void CSequencer::CheckIf( CBlock **command ) //Conditional failed, just move on to the next command *command = PopCommand( POP_BACK ); Prep( command ); - - return; + + return; } if ( ( block->GetBlockID() == ID_BLOCK_END ) && ( m_curSequence->HasFlag( SQ_CONDITIONAL ) ) ) @@ -1534,10 +1534,10 @@ void CSequencer::CheckIf( CBlock **command ) block = NULL; *command = NULL; } - + //Back out of the conditional and resume the previous sequence m_curSequence = ReturnSequence( m_curSequence ); - + //This can safely happen if ( m_curSequence == NULL ) { @@ -1566,7 +1566,7 @@ void CSequencer::CheckLoop( CBlock **command ) int iterations; int loopID; int memberNum = 0; - + if ( block == NULL ) return; @@ -1581,18 +1581,18 @@ void CSequencer::CheckLoop( CBlock **command ) //Parse out the random number min = *(float *) block->GetMemberData( memberNum++ ); max = *(float *) block->GetMemberData( memberNum++ ); - + iterations = (int) m_ie->I_Random( min, max ); } else { iterations = (int) (*(float *) bm->GetData()); } - + loopID = (int) (*(float *) block->GetMemberData( memberNum++ )); CSequence *loop = GetSequence( loopID ); - + //TODO: Emit warning assert( loop ); if ( loop == NULL ) @@ -1623,16 +1623,16 @@ void CSequencer::CheckLoop( CBlock **command ) block = NULL; *command = NULL; } - + m_curSequence = loop; //Recursively work out any other pre-processors *command = PopCommand( POP_BACK ); Prep( command ); - + return; } - + //Check for the end of the loop if ( ( block->GetBlockID() == ID_BLOCK_END ) && ( m_curSequence->HasFlag( SQ_LOOP ) ) ) { @@ -1645,10 +1645,10 @@ void CSequencer::CheckLoop( CBlock **command ) { //Another iteration is going to happen, so this will need to be considered again PushCommand( block, PUSH_FRONT ); - + *command = PopCommand( POP_BACK ); Prep( command ); - + return; } else @@ -1671,10 +1671,10 @@ void CSequencer::CheckLoop( CBlock **command ) block = NULL; *command = NULL; } - + //Back out of the loop and resume the previous sequence m_curSequence = ReturnSequence( m_curSequence ); - + //This can safely happen if ( m_curSequence == NULL ) { @@ -1753,11 +1753,11 @@ void CSequencer::CheckAffect( CBlock **command ) CSequencer *sequencer = NULL; entname = (char*) block->GetMemberData( memberNum++ ); ent = m_ie->I_GetEntityByName( entname ); - + if( !ent ) // if there wasn't a valid entname in the affect, we need to check if it's a get command { //try to parse a 'get' command that is embeded in this 'affect' - + int id; char *p1 = NULL; char *name = 0; @@ -1767,7 +1767,7 @@ void CSequencer::CheckAffect( CBlock **command ) // bm = block->GetMember( 0 ); id = bm->GetID(); - + switch ( id ) { // these 3 cases probably aren't necessary @@ -1777,9 +1777,9 @@ void CSequencer::CheckAffect( CBlock **command ) p1 = (char *) bm->GetData(); break; - case ID_GET: + case ID_GET: { - int type; + int type; //get( TYPE, NAME ) type = (int) (*(float *) block->GetMemberData( memberNum++ )); @@ -1787,7 +1787,7 @@ void CSequencer::CheckAffect( CBlock **command ) switch ( type ) // what type are they attempting to get { - + case TK_STRING: //only string is acceptable for affect, store result in p1 if ( m_ie->I_GetString( m_ownerID, type, name, &p1 ) == false) @@ -1820,7 +1820,7 @@ void CSequencer::CheckAffect( CBlock **command ) { // a valid entity name was not returned from the get command m_ie->I_DPrintf( WL_WARNING, "'%s' : invalid affect() target\n"); } - + } // end if(!ent) if( ent ) @@ -1831,9 +1831,9 @@ void CSequencer::CheckAffect( CBlock **command ) { //there was no get, increment manually before next step memberNum++; } - int type = (int) (*(float *) block->GetMemberData( memberNum )); + int type = (int) (*(float *) block->GetMemberData( memberNum )); int id = (int) (*(float *) block->GetMemberData( memberNum+1 )); - + if ( m_curSequence->HasFlag( SQ_RETAIN ) ) { PushCommand( block, PUSH_FRONT ); @@ -1844,7 +1844,7 @@ void CSequencer::CheckAffect( CBlock **command ) block = NULL; *command = NULL; } - + //NOTENOTE: If this isn't found, continue on to the next command if ( sequencer == NULL ) { @@ -1858,7 +1858,7 @@ void CSequencer::CheckAffect( CBlock **command ) *command = PopCommand( POP_BACK ); Prep( command ); if( ent ) - { // ents need to update upon being affected + { // ents need to update upon being affected ent->taskManager->Update(); } @@ -1877,7 +1877,7 @@ void CSequencer::CheckAffect( CBlock **command ) block = NULL; *command = NULL; } - + m_curSequence = ReturnSequence( m_curSequence ); if ( m_curSequence == NULL ) @@ -1889,7 +1889,7 @@ void CSequencer::CheckAffect( CBlock **command ) *command = PopCommand( POP_BACK ); Prep( command ); if( ent ) - { // ents need to update upon being affected + { // ents need to update upon being affected ent->taskManager->Update(); } @@ -1961,7 +1961,7 @@ void CSequencer::CheckDo( CBlock **command ) //Recursively work out any other pre-processors *command = PopCommand( POP_BACK ); Prep( command ); - + return; } @@ -1977,7 +1977,7 @@ void CSequencer::CheckDo( CBlock **command ) block = NULL; *command = NULL; } - + m_taskManager->MarkTask( m_curGroup->GetGUID(), TASK_END ); m_curGroup = m_curGroup->GetParent(); @@ -2142,22 +2142,22 @@ int CSequencer::Affect( int id, int type ) //Get rid of all old code Flush( sequence ); - sequence->RemoveFlag( SQ_PENDING, true ); - + sequence->RemoveFlag( SQ_PENDING, true ); + m_curSequence = sequence; Prime( m_taskManager, PopCommand( POP_BACK ) ); break; - + case TYPE_INSERT: Recall(); - + sequence->SetReturn( m_curSequence ); - + sequence->RemoveFlag( SQ_PENDING, true ); - + m_curSequence = sequence; Prime( m_taskManager, PopCommand( POP_BACK ) ); @@ -2190,7 +2190,7 @@ int CSequencer::PushCommand( CBlock *command, int flag ) m_curSequence->PushCommand( command, flag ); m_numCommands++; - + //Invalid flag return SEQ_OK; } @@ -2210,7 +2210,7 @@ CBlock *CSequencer::PopCommand( int flag ) if ( m_curSequence == NULL ) return NULL; - CBlock *block = m_curSequence->PopCommand( flag ); + CBlock *block = m_curSequence->PopCommand( flag ); if ( block != NULL ) m_numCommands--; @@ -2250,7 +2250,7 @@ int CSequencer::RemoveSequence( CSequence *sequence ) temp->SetReturn( NULL ); } - + return SEQ_OK; } @@ -2287,7 +2287,7 @@ int CSequencer::DestroySequence( CSequence *sequence ) } m_owner->DeleteSequence( sequence ); - + return SEQ_OK; } @@ -2364,7 +2364,7 @@ int CSequencer::Save( void ) numTasks); STL_ITERATE( ti, m_taskSequences ) - { + { //Save the task group's ID id = ((*ti).first)->GetGUID(); @@ -2408,7 +2408,7 @@ Load */ int CSequencer::Load( void ) -{ +{ int i; ojk::SavedGameHelper saved_game( @@ -2464,7 +2464,7 @@ int CSequencer::Load( void ) saved_game.read_chunk( INT_ID('S', 'T', 'I', 'D'), taskID); - + //Read in the sequence's ID saved_game.read_chunk( INT_ID('S', 'S', 'I', 'D'), diff --git a/codeJK2/icarus/TaskManager.cpp b/codeJK2/icarus/TaskManager.cpp index feb0014b33..d0cbf4b3a6 100644 --- a/codeJK2/icarus/TaskManager.cpp +++ b/codeJK2/icarus/TaskManager.cpp @@ -20,7 +20,7 @@ along with this program; if not, see . =========================================================================== */ -// Task Manager +// Task Manager // // -- jweier @@ -75,7 +75,7 @@ Free void CTask::Free( void ) { - //NOTENOTE: The block is not consumed by the task, it is the sequencer's job to clean blocks up + //NOTENOTE: The block is not consumed by the task, it is the sequencer's job to clean blocks up delete this; } @@ -134,7 +134,7 @@ Add int CTaskGroup::Add( CTask *task ) { m_completedTasks[ task->GetGUID() ] = false; - return TASK_OK; + return TASK_OK; } /* @@ -229,7 +229,7 @@ int CTaskManager::Free( void ) { delete (*gi); } - + m_taskGroups.clear(); m_taskGroupNameMap.clear(); m_taskGroupIDMap.clear(); @@ -244,9 +244,9 @@ Flush */ int CTaskManager::Flush( void ) -{ +{ //FIXME: Rewrite - + return true; } @@ -267,10 +267,10 @@ CTaskGroup *CTaskManager::AddTaskGroup( const char *name ) if ( tgni != m_taskGroupNameMap.end() ) { group = (*tgni).second; - + //Clear it and just move on group->Init(); - + return group; } @@ -403,7 +403,7 @@ int CTaskManager::GetFloat( int entID, CBlock *block, int &memberNum, float &val if ( type != TK_FLOAT ) { (m_owner->GetInterface())->I_DPrintf( WL_ERROR, "Get() call tried to return a non-FLOAT parameter!\n" ); - return false; + return false; } return (m_owner->GetInterface())->I_GetFloat( entID, type, name, &value ); @@ -432,7 +432,7 @@ int CTaskManager::GetFloat( int entID, CBlock *block, int &memberNum, float &val } CBlockMember *bm = block->GetMember( memberNum ); - + if ( bm->GetID() == TK_INT ) { value = (float) (*(int *) block->GetMemberData( memberNum++ )); @@ -514,7 +514,7 @@ int CTaskManager::GetVector( int entID, CBlock *block, int &memberNum, vector_t (m_owner->GetInterface())->I_DPrintf( WL_ERROR, "Unable to find tag \"%s\"!\n", tagName ); assert(0); return TASK_FAILED; - } + } return true; } @@ -574,7 +574,7 @@ int CTaskManager::Get( int entID, CBlock *block, int &memberNum, char **value ) (m_owner->GetInterface())->I_DPrintf( WL_ERROR, "Get() parameter \"%s\" could not be found!\n", name ); return false; } - + return true; break; @@ -584,14 +584,14 @@ int CTaskManager::Get( int entID, CBlock *block, int &memberNum, char **value ) if ( (m_owner->GetInterface())->I_GetFloat( entID, type, name, &temp ) == false ) { - (m_owner->GetInterface())->I_DPrintf( WL_ERROR, "Get() parameter \"%s\" could not be found!\n", name ); + (m_owner->GetInterface())->I_DPrintf( WL_ERROR, "Get() parameter \"%s\" could not be found!\n", name ); return false; } Com_sprintf( tempBuffer, sizeof( tempBuffer ), "%f", temp ); *value = (char *) tempBuffer; } - + return true; break; @@ -601,14 +601,14 @@ int CTaskManager::Get( int entID, CBlock *block, int &memberNum, char **value ) if ( (m_owner->GetInterface())->I_GetVector( entID, type, name, vval ) == false ) { - (m_owner->GetInterface())->I_DPrintf( WL_ERROR, "Get() parameter \"%s\" could not be found!\n", name ); + (m_owner->GetInterface())->I_DPrintf( WL_ERROR, "Get() parameter \"%s\" could not be found!\n", name ); return false; } Com_sprintf( tempBuffer, sizeof( tempBuffer ), "%f %f %f", vval[0], vval[1], vval[2] ); *value = (char *) tempBuffer; } - + return true; break; @@ -700,7 +700,7 @@ int CTaskManager::Get( int entID, CBlock *block, int &memberNum, char **value ) return true; } - + //TODO: Emit warning assert( 0 ); (m_owner->GetInterface())->I_DPrintf( WL_WARNING, "Unexpected value; expected type STRING\n" ); @@ -739,16 +739,16 @@ int CTaskManager::Go( void ) (m_owner->GetInterface())->I_DPrintf( WL_ERROR, "Invalid task found in Go()!\n" ); return TASK_FAILED; } - + //If this hasn't been stamped, do so if ( task->GetTimeStamp() == 0 ) task->SetTimeStamp( ( m_owner->GetInterface())->I_GetTime() ); - + //Switch and call the proper function switch( task->GetID() ) { case ID_WAIT: - + Wait( task, completed ); //Push it to consider it again on the next frame if not complete @@ -763,7 +763,7 @@ int CTaskManager::Go( void ) break; case ID_WAITSIGNAL: - + WaitSignal( task, completed ); //Push it to consider it again on the next frame if not complete @@ -776,7 +776,7 @@ int CTaskManager::Go( void ) Completed( task->GetGUID() ); break; - + case ID_PRINT: //print( STRING ) Print( task ); break; @@ -842,10 +842,10 @@ int CTaskManager::Go( void ) task->Free(); } - + //FIXME: A command surge limiter could be implemented at this point to be sure a script doesn't // execute too many commands in one cycle. This may, however, cause timing errors to surface. - + return TASK_OK; } @@ -1032,14 +1032,14 @@ CTask *CTaskManager::PopTask( int flag ) case POP_FRONT: task = m_tasks.front(); m_tasks.pop_front(); - + return task; break; case POP_BACK: task = m_tasks.back(); m_tasks.pop_back(); - + return task; break; } @@ -1079,7 +1079,7 @@ CBlock *CTaskManager::GetCurrentTask( void ) int CTaskManager::Wait( CTask *task, bool &completed ) { CBlockMember *bm; - CBlock *block = task->GetBlock(); + CBlock *block = task->GetBlock(); char *sVal; float dwtime; int memberNum = 0; @@ -1132,7 +1132,7 @@ int CTaskManager::Wait( CTask *task, bool &completed ) { ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, dwtime ) ); } - + if ( task->GetTimeStamp() == (m_owner->GetInterface())->I_GetTime() ) { //Print out the debug info @@ -1204,7 +1204,7 @@ int CTaskManager::Print( CTask *task ) (m_owner->GetInterface())->I_CenterPrint( sVal ); Completed( task->GetGUID() ); - + return TASK_OK; } @@ -1228,7 +1228,7 @@ int CTaskManager::Sound( CTask *task ) //Only instantly complete if the user has requested it if( (m_owner->GetInterface())->I_PlaySound( task->GetGUID(), m_ownerID, sVal2, sVal ) ) Completed( task->GetGUID() ); - + return TASK_OK; } @@ -1273,7 +1273,7 @@ int CTaskManager::Rotate( CTask *task ) (m_owner->GetInterface())->I_DPrintf( WL_DEBUG, "%4d rotate( <%f,%f,%f>, %d); [%d]", m_ownerID, vector[0], vector[1], vector[2], (int) duration, task->GetTimeStamp() ); (m_owner->GetInterface())->I_Lerp2Angles( task->GetGUID(), m_ownerID, vector, duration ); - + return TASK_OK; } @@ -1290,12 +1290,12 @@ int CTaskManager::Remove( CTask *task ) int memberNum = 0; ICARUS_VALIDATE( Get( m_ownerID, block, memberNum, &sVal ) ); - + (m_owner->GetInterface())->I_DPrintf( WL_DEBUG, "%4d remove(\"%s\"); [%d]", m_ownerID, sVal, task->GetTimeStamp() ); (m_owner->GetInterface())->I_Remove( m_ownerID, sVal ); Completed( task->GetGUID() ); - + return TASK_OK; } @@ -1320,7 +1320,7 @@ int CTaskManager::Camera( CTask *task ) switch ( (int) type ) { case TYPE_PAN: - + ICARUS_VALIDATE( GetVector( m_ownerID, block, memberNum, vector ) ); ICARUS_VALIDATE( GetVector( m_ownerID, block, memberNum, vector2 ) ); @@ -1331,7 +1331,7 @@ int CTaskManager::Camera( CTask *task ) break; case TYPE_ZOOM: - + ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal ) ); ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal2 ) ); @@ -1370,7 +1370,7 @@ int CTaskManager::Camera( CTask *task ) break; case TYPE_TRACK: - + ICARUS_VALIDATE( Get( m_ownerID, block, memberNum, &sVal ) ); ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal ) ); ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal2 ) ); @@ -1383,7 +1383,7 @@ int CTaskManager::Camera( CTask *task ) ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal ) ); ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal2 ) ); - + (m_owner->GetInterface())->I_DPrintf( WL_DEBUG, "%4d camera( DISTANCE, %f, %f); [%d]", m_ownerID, fVal, fVal2, task->GetTimeStamp() ); ie->I_CameraDistance( fVal, fVal2 ); break; @@ -1395,7 +1395,7 @@ int CTaskManager::Camera( CTask *task ) ICARUS_VALIDATE( GetVector( m_ownerID, block, memberNum, vector2 ) ); ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal2 ) ); - + ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal3 ) ); (m_owner->GetInterface())->I_DPrintf( WL_DEBUG, "%4d camera( FADE, <%f %f %f>, %f, <%f %f %f>, %f, %f); [%d]", m_ownerID, vector[0], vector[1], vector[2], fVal, vector2[0], vector2[1], vector2[2], fVal2, fVal3, task->GetTimeStamp() ); @@ -1418,7 +1418,7 @@ int CTaskManager::Camera( CTask *task ) (m_owner->GetInterface())->I_DPrintf( WL_DEBUG, "%4d camera( DISABLE ); [%d]", m_ownerID, task->GetTimeStamp() ); ie->I_CameraDisable(); break; - + case TYPE_SHAKE: ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal ) ); ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal2 ) ); @@ -1453,8 +1453,8 @@ int CTaskManager::Move( CTask *task ) if ( GetVector( m_ownerID, block, memberNum, vector2 ) == false ) { ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, duration ) ); - - + + (m_owner->GetInterface())->I_DPrintf( WL_DEBUG, "%4d move( <%f %f %f>, %f ); [%d]", m_ownerID, vector[0], vector[1], vector[2], duration, task->GetTimeStamp() ); (m_owner->GetInterface())->I_Lerp2Pos( task->GetGUID(), m_ownerID, vector, NULL, duration ); @@ -1463,10 +1463,10 @@ int CTaskManager::Move( CTask *task ) //Get the duration and make the call ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, duration ) ); - + (m_owner->GetInterface())->I_DPrintf( WL_DEBUG, "%4d move( <%f %f %f>, <%f %f %f>, %f ); [%d]", m_ownerID, vector[0], vector[1], vector[2], vector2[0], vector2[1], vector2[2], duration, task->GetTimeStamp() ); (m_owner->GetInterface())->I_Lerp2Pos( task->GetGUID(), m_ownerID, vector, vector2, duration ); - + return TASK_OK; } @@ -1674,14 +1674,14 @@ int CTaskManager::SaveCommand( CBlock *block ) saved_game.write_chunk( INT_ID('B', 'M', 'I', 'D'), bID); - + //Save out the data size size = bm->GetSize(); saved_game.write_chunk( INT_ID('B', 'S', 'I', 'Z'), size); - + //Save out the raw data const uint8_t* raw_data = static_cast(bm->GetData()); @@ -1727,7 +1727,7 @@ void CTaskManager::Save( void ) //Save out all the tasks tasks_l::iterator ti; - + STL_ITERATE( ti, m_tasks ) { //Save the GUID @@ -1791,7 +1791,7 @@ void CTaskManager::Save( void ) //Save out the command map CTaskGroup::taskCallback_m::iterator tci; - + STL_ITERATE( tci, (*tgi)->m_completedTasks ) { //Write out the ID @@ -1837,7 +1837,7 @@ void CTaskManager::Save( void ) STL_ITERATE( tmi, m_taskGroupNameMap ) { name = ((*tmi).first).c_str(); - + //Make sure this is a valid string assert( ( name != NULL ) && ( name[0] != '\0' ) ); @@ -1899,7 +1899,7 @@ void CTaskManager::Load( void ) saved_game.read_chunk( INT_ID('T', 'S', 'K', '#'), numTasks); - + //Reload all the tasks for ( i = 0; i < numTasks; i++ ) { @@ -1931,9 +1931,9 @@ void CTaskManager::Load( void ) id); block = new CBlock; - + block->Create( id ); - + //Read the block's flags saved_game.read_chunk( INT_ID('B', 'F', 'L', 'G'), @@ -1945,14 +1945,14 @@ void CTaskManager::Load( void ) saved_game.read_chunk( INT_ID('B', 'N', 'U', 'M'), numMembers); - + for ( int j = 0; j < numMembers; j++ ) { //Get the member ID saved_game.read_chunk( INT_ID('B', 'M', 'I', 'D'), bID); - + //Get the member size saved_game.read_chunk( INT_ID('B', 'S', 'I', 'Z'), @@ -2007,11 +2007,11 @@ void CTaskManager::Load( void ) assert( 0 ); break; } - + //Get rid of the temp memory ICARUS_Free( bData ); } - + task->SetBlock( block ); STL_INSERT( m_tasks, task ); @@ -2019,7 +2019,7 @@ void CTaskManager::Load( void ) //Load the task groups int numTaskGroups = 0; - + saved_game.read_chunk( INT_ID('T', 'G', '#', 'G'), numTaskGroups); @@ -2042,7 +2042,7 @@ void CTaskManager::Load( void ) taskIDs[i]); taskGroup->m_GUID = taskIDs[i]; - + m_taskGroupIDMap[ taskIDs[i] ] = taskGroup; STL_INSERT( m_taskGroups, taskGroup ); @@ -2058,7 +2058,7 @@ void CTaskManager::Load( void ) saved_game.read_chunk( INT_ID('T', 'K', 'G', 'P'), id); - + if ( id != -1 ) taskGroup->m_parent = ( GetTaskGroup( id ) != NULL ) ? GetTaskGroup( id ) : NULL; @@ -2102,7 +2102,7 @@ void CTaskManager::Load( void ) { char name[1024]; int length = 0; - + //Get the size of the string saved_game.read_chunk( INT_ID('T', 'G', 'N', 'L'), diff --git a/codeJK2/icarus/Tokenizer.cpp b/codeJK2/icarus/Tokenizer.cpp index 3324355931..d97b594715 100644 --- a/codeJK2/icarus/Tokenizer.cpp +++ b/codeJK2/icarus/Tokenizer.cpp @@ -1,7 +1,7 @@ // Tokenizer.cpp #ifndef NOT_USING_MODULES // !!! if you are not using modules, read BELOW !!! -#include "module.h" // if you are not using modules, +#include "module.h" // if you are not using modules, // create an empty Module.h in your // project -- use of modules allows // the error handler to be overridden @@ -226,7 +226,7 @@ void CSymbolTable::Delete() bool CSymbolTable::AddSymbol(CSymbol* theSymbol) { LPCTSTR name = theSymbol->GetName(); - + symbolmap_t::iterator iter = m_symbols.find(name); if (iter != m_symbols.end()) { @@ -377,7 +377,7 @@ void CParsePutBack::Init(byte theByte, int curLine, LPCTSTR filename) m_curFile = (char*)malloc(strlen(filename) + 1); strcpy(m_curFile, filename); } - else + else { m_curFile = NULL; } @@ -426,7 +426,7 @@ CParseFile::~CParseFile() CParseFile* CParseFile::Create() { CParseFile* theParseFile = new CParseFile(); - + if ( !theParseFile->Init() ) { delete theParseFile; @@ -439,7 +439,7 @@ CParseFile* CParseFile::Create() CParseFile* CParseFile::Create(LPCTSTR filename, CTokenizer* tokenizer) { CParseFile* theParseFile = new CParseFile(); - + if ( theParseFile->Init(filename, tokenizer) ) return theParseFile; @@ -1490,7 +1490,7 @@ void CTokenizer::Error(LPCTSTR errString, int theError) m_errorProc(errString); } #ifdef USES_MODULES - else + else { ReportError(theError, errString); } @@ -1656,7 +1656,7 @@ CToken* CTokenizer::GetToEndOfLine(int tokenType) // the default string size of only 128 chars... // if (tokenType == TK_STRING) - { + { #define iRETURN_STRING_SIZE 2048 char theString[iRETURN_STRING_SIZE]; theString[0] = ' '; @@ -1673,15 +1673,15 @@ CToken* CTokenizer::GetToEndOfLine(int tokenType) } theString[i] = '\0'; - return CStringToken::Create(theString); + return CStringToken::Create(theString); } // line would maks a string too big to fit in buffer... - // + // Error(TKERR_STRINGLENGTHEXCEEDED); } else - { + { char theString[MAX_IDENTIFIER_LENGTH]; theString[0] = ' '; while (theString[0] == ' ') @@ -1712,7 +1712,7 @@ CToken* CTokenizer::GetToEndOfLine(int tokenType) } } Error(TKERR_IDENTIFIERLENGTHEXCEEDED); - } + } return NULL; } diff --git a/codeJK2/icarus/blockstream.h b/codeJK2/icarus/blockstream.h index 1e5643dece..03cae5f485 100644 --- a/codeJK2/icarus/blockstream.h +++ b/codeJK2/icarus/blockstream.h @@ -40,7 +40,7 @@ const int MAX_FILENAME_LENGTH = 1024; typedef float vector_t[3]; -enum +enum { POP_FRONT, POP_BACK, @@ -56,7 +56,7 @@ class CBlockMember { public: - CBlockMember(); + CBlockMember(); ~CBlockMember(); void Free( void ); @@ -110,7 +110,7 @@ class CBlockMember int m_size; //Size of the data member variable void *m_data; //Data for this member }; - + //CBlock class CBlock @@ -149,7 +149,7 @@ class CBlock void SetFlags( unsigned char flags ) { m_flags = flags; } void SetFlag( unsigned char flag ) { m_flags |= flag; } - + int HasFlag( unsigned char flag ) const { return ( m_flags & flag ); } unsigned char GetFlags( void ) const { return m_flags; } @@ -180,19 +180,19 @@ class CBlockStream int WriteBlock( CBlock * ); //Write the block out int ReadBlock( CBlock * ); //Read the block in - + int Open( char *, long ); //Open a stream for reading / writing protected: unsigned GetUnsignedInteger( void ); int GetInteger( void ); - + char GetChar( void ); long GetLong( void ); float GetFloat( void ); - long m_fileSize; //Size of the file + long m_fileSize; //Size of the file FILE *m_fileHandle; //Global file handle of current I/O source char m_fileName[MAX_FILENAME_LENGTH]; //Name of the current file diff --git a/codeJK2/icarus/instance.h b/codeJK2/icarus/instance.h index 9d5667694c..9925114f13 100644 --- a/codeJK2/icarus/instance.h +++ b/codeJK2/icarus/instance.h @@ -55,7 +55,7 @@ class ICARUS_Instance interface_export_t *GetInterface( void ) const { return m_interface; } //These are overriddable for "worst-case" save / loads - virtual int Save( void /*FIXME*/ ); + virtual int Save( void /*FIXME*/ ); virtual int Load( void /*FIXME*/ ); void Signal( const char *identifier ); diff --git a/codeJK2/icarus/interface.h b/codeJK2/icarus/interface.h index 8b83fa00fe..cb3f1eba22 100644 --- a/codeJK2/icarus/interface.h +++ b/codeJK2/icarus/interface.h @@ -42,7 +42,7 @@ typedef struct interface_export_s gentity_t * (*I_GetEntityByName)( const char *name ); //Polls the engine for the sequencer of the entity matching the name passed unsigned int (*I_GetTime)( void ); //Gets the current time unsigned int (*I_GetTimeScale)(void ); - int (*I_PlaySound)( int taskID, int entID, const char *name, const char *channel ); + int (*I_PlaySound)( int taskID, int entID, const char *name, const char *channel ); void (*I_Lerp2Pos)( int taskID, int entID, vec3_t origin, vec3_t angles, float duration ); void (*I_Lerp2Origin)( int taskID, int entID, vec3_t origin, float duration ); void (*I_Lerp2Angles)( int taskID, int entID, vec3_t angles, float duration ); diff --git a/codeJK2/icarus/interpreter.h b/codeJK2/icarus/interpreter.h index e5e9ec0e61..94abce33e3 100644 --- a/codeJK2/icarus/interpreter.h +++ b/codeJK2/icarus/interpreter.h @@ -33,7 +33,7 @@ along with this program; if not, see . typedef float vector_t[3]; //Token defines -enum +enum { TK_BLOCK_START = TK_USERDEF, TK_BLOCK_END, @@ -101,9 +101,9 @@ enum TYPE_ORIGIN, //Affect types - TYPE_INSERT, - TYPE_FLUSH, - + TYPE_INSERT, + TYPE_FLUSH, + //Camera types TYPE_PAN, TYPE_ZOOM, @@ -117,7 +117,7 @@ enum TYPE_TRACK, TYPE_DISTANCE, TYPE_FOLLOW, - + //Variable type TYPE_VARIABLE, @@ -144,7 +144,7 @@ typedef std::vector < variable_t * > variable_v; //CInterpreter -class CInterpreter +class CInterpreter { public: @@ -152,7 +152,7 @@ class CInterpreter ~CInterpreter(); int Interpret( CTokenizer *, CBlockStream *, char *filename=NULL ); //Main interpretation function - + int Match( int ); //Looks ahead to the next token to try and match it to the passed token, consumes token on success int LookAhead( int ); //Looks ahead without consuming on success @@ -168,7 +168,7 @@ class CInterpreter int GetFlush( void ); //Handles the flush() function int GetRun( void ); //Handles the run() function int GetKill( void ); //Handles the kill() function - int GetRemove( void ); //Handles the remove() function + int GetRemove( void ); //Handles the remove() function int GetCamera( void ); //Handles the camera() function int GetIf( void ); //Handles the if() conditional statement int GetSound( void ); //Handles the sound() function @@ -184,7 +184,7 @@ class CInterpreter int GetSignal( void ); int GetWaitSignal( void ); int GetPlay( void ); - + int GetRandom( CBlock *block ); int GetGet( CBlock *block ); //Heh int GetTag( CBlock *block ); //Handles the tag() identifier @@ -203,7 +203,7 @@ class CInterpreter int GetVariable( int type ); int GetID ( char * ); //Attempts to match and interpret an identifier - + keywordArray_t *GetSymbols( void ) { return (keywordArray_t *) &m_symbolKeywords; } //Returns the interpreter's symbol table keywordArray_t *GetIDs( void ) { return (keywordArray_t *) &m_IDKeywords; } //Returns the interpreter's ID table keywordArray_t *GetTypes( void ) { return (keywordArray_t *) &m_typeKeywords; } //Returns the interpreter's type table @@ -212,13 +212,13 @@ class CInterpreter void InitVars( void ); void FreeVars( void ); - + variable_t *AddVar( const char *name, int type ); variable_t *FindVar( const char *name ); const char *GetTokenName( int ); //Returns the name of a token int Error( char *, ... ); //Prints an error message - + int MatchTag( void ); //Attempts to match to a tag identifier int MatchGet( void ); //Attempts to match to a get identifier int MatchRandom( void ); //Attempts to match to a random identifier diff --git a/codeJK2/icarus/sequencer.h b/codeJK2/icarus/sequencer.h index ec52d3f772..808d710352 100644 --- a/codeJK2/icarus/sequencer.h +++ b/codeJK2/icarus/sequencer.h @@ -40,7 +40,7 @@ along with this program; if not, see . #define SQ_COMMON 0x00000000 //Common one-pass sequence #define SQ_LOOP 0x00000001 //Looping sequence #define SQ_RETAIN 0x00000002 //Inside a looping sequence list, retain the information -#define SQ_AFFECT 0x00000004 //Affect sequence +#define SQ_AFFECT 0x00000004 //Affect sequence #define SQ_RUN 0x00000008 //A run block #define SQ_PENDING 0x00000010 //Pending use, don't free when flushing the sequences #define SQ_CONDITIONAL 0x00000020 //Conditional statement @@ -164,7 +164,7 @@ class CSequencer CSequence *GetTaskSequence( CTaskGroup *group ); //Member variables - + ICARUS_Instance *m_owner; int m_ownerID; diff --git a/codeJK2/icarus/taskmanager.h b/codeJK2/icarus/taskmanager.h index db9e24431d..c347409971 100644 --- a/codeJK2/icarus/taskmanager.h +++ b/codeJK2/icarus/taskmanager.h @@ -40,14 +40,14 @@ enum TASK_RETURN_FAILED, }; -enum +enum { TASK_OK, TASK_FAILED, TASK_START, TASK_END, }; - + // CTask class CTask @@ -91,7 +91,7 @@ class CTaskGroup void Init( void ); int Add( CTask *task ); - + void SetGUID( int GUID ); void SetParent( CTaskGroup *group ) { m_parent = group; } @@ -199,7 +199,7 @@ class CTaskManager int m_GUID; int m_count; - + taskGroupName_m m_taskGroupNameMap; taskGroupID_m m_taskGroupIDMap; diff --git a/codeJK2/icarus/tokenizer.h b/codeJK2/icarus/tokenizer.h index f792da3097..3ca0ae2321 100644 --- a/codeJK2/icarus/tokenizer.h +++ b/codeJK2/icarus/tokenizer.h @@ -185,7 +185,7 @@ class CIntToken : public CToken protected: void Init(long value); - + long m_value; }; @@ -437,7 +437,7 @@ class CTokenizer const char *LookupToken(int tokenID, keywordArray_t* theTable = NULL); protected: - void SetError(int theError, const char *errString); + void SetError(int theError, const char *errString); virtual void Init(unsigned dwFlags = 0); CToken* FetchToken(); bool AddDefineSymbol(CDirectiveSymbol* definesymbol); diff --git a/codeJK2/qcommon/safe/memory.h b/codeJK2/qcommon/safe/memory.h index 1299509102..5caec82d91 100644 --- a/codeJK2/qcommon/safe/memory.h +++ b/codeJK2/qcommon/safe/memory.h @@ -80,7 +80,7 @@ namespace Zone using other = Allocator< U, tag >; }; }; - + template< typename T > using UniquePtr = std::unique_ptr< T, Deleter >; diff --git a/codeJK2/win32/game.rc b/codeJK2/win32/game.rc index d8a95ca3aa..408dea4f48 100644 --- a/codeJK2/win32/game.rc +++ b/codeJK2/win32/game.rc @@ -27,18 +27,18 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // TEXTINCLUDE // -1 TEXTINCLUDE +1 TEXTINCLUDE BEGIN "resource.h\0" END -2 TEXTINCLUDE +2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END -3 TEXTINCLUDE +3 TEXTINCLUDE BEGIN "\r\n" "\0" diff --git a/codeJK2/win32/resource.h b/codeJK2/win32/resource.h index 2a145bf827..1a25b5a313 100644 --- a/codeJK2/win32/resource.h +++ b/codeJK2/win32/resource.h @@ -9,7 +9,7 @@ #define IDC_CURSOR1 129 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 diff --git a/codemp/CMakeLists.txt b/codemp/CMakeLists.txt index d170c1b2c9..1e424ffd51 100644 --- a/codemp/CMakeLists.txt +++ b/codemp/CMakeLists.txt @@ -140,7 +140,7 @@ if(BuildMPEngine OR BuildMPDed) "${MPDir}/qcommon/qcommon.h" "${MPDir}/qcommon/qfiles.h" "${MPDir}/qcommon/tags.h" - + ${SharedCommonFiles} ) source_group("common" FILES ${MPBotlibCommonFiles}) @@ -268,7 +268,7 @@ if(BuildMPEngine OR BuildMPDed) endif(WIN32) source_group("common" FILES ${MPEngineAndDedCommonFiles}) set(MPEngineAndDedFiles ${MPEngineAndDedFiles} ${MPEngineAndDedCommonFiles}) - + set(MPEngineAndDedCommonSafeFiles "${SharedDir}/qcommon/safe/files.cpp" "${SharedDir}/qcommon/safe/files.h" diff --git a/codemp/cgame/CMakeLists.txt b/codemp/cgame/CMakeLists.txt index 3bb751c74a..e9424d533d 100644 --- a/codemp/cgame/CMakeLists.txt +++ b/codemp/cgame/CMakeLists.txt @@ -106,7 +106,7 @@ set(MPCGameCommonFiles "${MPDir}/qcommon/q_shared.h" "${MPDir}/qcommon/qfiles.h" "${MPDir}/qcommon/tags.h" - + ${SharedCommonFiles} ) source_group("common" FILES ${MPCGameCommonFiles}) @@ -160,14 +160,12 @@ elseif(WIN32) RUNTIME DESTINATION "${JKAInstallDir}/OpenJK" COMPONENT ${JKAMPCoreComponent}) - if (WIN64) - # Don't do this on 32-bit Windows to avoid overwriting - # vanilla JKA's DLLs - install(TARGETS ${MPCGame} - RUNTIME - DESTINATION "${JKAInstallDir}/base" - COMPONENT ${JKAMPCoreComponent}) - endif() + + # Use OpenJK modules as default + install(TARGETS ${MPCGame} + RUNTIME + DESTINATION "${JKAInstallDir}/base" + COMPONENT ${JKAMPCoreComponent}) else() install(TARGETS ${MPCGame} LIBRARY diff --git a/codemp/cgame/cg_draw.c b/codemp/cgame/cg_draw.c index 8b793c1593..5be400800e 100644 --- a/codemp/cgame/cg_draw.c +++ b/codemp/cgame/cg_draw.c @@ -3064,7 +3064,7 @@ static float CG_DrawEnemyInfo ( float y ) clientNum = cgs.duelWinner; } - if ( clientNum >= MAX_CLIENTS || !(&cgs.clientinfo[ clientNum ]) ) + if ( clientNum < 0 || clientNum >= MAX_CLIENTS || !cgs.clientinfo[clientNum].infoValid ) { return y; } @@ -3978,7 +3978,7 @@ static float CG_DrawTeamOverlay( float y, qboolean right, qboolean upper ) { } else { xx = x + w - TINYCHAR_WIDTH; } - for (j = 0; j <= PW_NUM_POWERUPS; j++) { + for (j = 0; j < PW_NUM_POWERUPS; j++) { if (ci->powerups & (1 << j)) { item = BG_FindItemForPowerup( j ); diff --git a/codemp/cgame/cg_event.c b/codemp/cgame/cg_event.c index 98d3992a7c..45af332e4a 100644 --- a/codemp/cgame/cg_event.c +++ b/codemp/cgame/cg_event.c @@ -3341,7 +3341,6 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) { // // powerup events // -#ifdef BASE_COMPAT case EV_POWERUP_QUAD: DEBUGNAME("EV_POWERUP_QUAD"); if ( es->number == cg.snap->ps.clientNum ) { @@ -3358,7 +3357,6 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) { } //trap->S_StartSound (NULL, es->number, CHAN_ITEM, cgs.media.protectSound ); break; -#endif // BASE_COMPAT case EV_FORCE_DRAINED: DEBUGNAME("EV_FORCE_DRAINED"); diff --git a/codemp/cgame/cg_main.c b/codemp/cgame/cg_main.c index b9c926d787..12bbd470ec 100644 --- a/codemp/cgame/cg_main.c +++ b/codemp/cgame/cg_main.c @@ -1623,6 +1623,9 @@ CG_ConfigString ================= */ const char *CG_ConfigString( int index ) { + // FIXME: don't read configstrings before initialisation + // assert( cgs.gameState.dataCount != 0 ); + if ( index < 0 || index >= MAX_CONFIGSTRINGS ) { trap->Error( ERR_DROP, "CG_ConfigString: bad index: %i", index ); } @@ -2626,6 +2629,9 @@ Ghoul2 Insert End cg.distanceCull = trap->R_GetDistanceCull(); CG_ParseEntitiesFromString(); + + BG_FixSaberMoveData(); + BG_FixWeaponAttackAnim(); } //makes sure returned string is in localized format diff --git a/codemp/cgame/cg_newDraw.c b/codemp/cgame/cg_newDraw.c index 6fb6e93848..ab2b384284 100644 --- a/codemp/cgame/cg_newDraw.c +++ b/codemp/cgame/cg_newDraw.c @@ -367,7 +367,7 @@ void CG_DrawNewTeamInfo(rectDef_t *rect, float text_x, float text_y, float scale if ( ci->infoValid && ci->team == cg.snap->ps.persistant[PERS_TEAM]) { xx = rect->x + 1; - for (j = 0; j <= PW_NUM_POWERUPS; j++) { + for (j = 0; j < PW_NUM_POWERUPS; j++) { if (ci->powerups & (1 << j)) { item = BG_FindItemForPowerup( j ); diff --git a/codemp/cgame/cg_players.c b/codemp/cgame/cg_players.c index d9262deb87..300503a8d4 100644 --- a/codemp/cgame/cg_players.c +++ b/codemp/cgame/cg_players.c @@ -4499,11 +4499,9 @@ static void CG_PlayerPowerups( centity_t *cent, refEntity_t *torso ) { return; } - #ifdef BASE_COMPAT - // quad gives a dlight - if ( powerups & ( 1 << PW_QUAD ) ) - trap->R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 0.2f, 0.2f, 1 ); - #endif // BASE_COMPAT + // quad gives a dlight + if ( powerups & ( 1 << PW_QUAD ) ) + trap->R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 0.2f, 0.2f, 1 ); if (cent->currentState.eType == ET_NPC) assert(cent->npcClient); diff --git a/codemp/cgame/cg_servercmds.c b/codemp/cgame/cg_servercmds.c index 82f4e20254..91f0272944 100644 --- a/codemp/cgame/cg_servercmds.c +++ b/codemp/cgame/cg_servercmds.c @@ -27,6 +27,7 @@ along with this program; if not, see . // be a valid snapshot this frame #include "cg_local.h" +#include "game/bg_public.h" #include "ui/menudef.h" #include "ghoul2/G2.h" #include "ui/ui_public.h" @@ -909,6 +910,11 @@ static void CG_ConfigStringModified( void ) { else if ( num == CS_SHADERSTATE ) { CG_ShaderStateChanged(); } + else if ( num == CS_LEGACY_FIXES ) { + // LEGACYFIX_SABERMOVEDATA etc may have changed + BG_FixSaberMoveData(); + BG_FixWeaponAttackAnim(); + } else if ( num >= CS_LIGHT_STYLES && num < CS_LIGHT_STYLES + (MAX_LIGHT_STYLES * 3)) { CG_SetLightstyle(num - CS_LIGHT_STYLES); diff --git a/codemp/cgame/cg_view.c b/codemp/cgame/cg_view.c index 228024c2c5..022976026c 100644 --- a/codemp/cgame/cg_view.c +++ b/codemp/cgame/cg_view.c @@ -2648,7 +2648,6 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo if ( !cg.hyperspace ) { CG_AddPacketEntities(qfalse); // adter calcViewValues, so predicted player state is correct CG_AddMarks(); - CG_AddLocalEntities(); } CG_AddViewWeapon( &cg.predictedPlayerState ); @@ -2664,6 +2663,11 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo if ( cg.testModelEntity.hModel ) { CG_AddTestModel(); } + + if ( !cg.hyperspace ) { + CG_AddLocalEntities(); + } + cg.refdef.time = cg.time; memcpy( cg.refdef.areamask, cg.snap->areamask, sizeof( cg.refdef.areamask ) ); diff --git a/codemp/cgame/cg_weapons.c b/codemp/cgame/cg_weapons.c index f6f191e0e9..4bb3b55524 100644 --- a/codemp/cgame/cg_weapons.c +++ b/codemp/cgame/cg_weapons.c @@ -1910,12 +1910,10 @@ void CG_FireWeapon( centity_t *cent, qboolean altFire ) { } } - #ifdef BASE_COMPAT - // play quad sound if needed - if ( cent->currentState.powerups & ( 1 << PW_QUAD ) ) { - //trap->S_StartSound (NULL, cent->currentState.number, CHAN_ITEM, cgs.media.quadSound ); - } - #endif // BASE_COMPAT + // play quad sound if needed + if ( cent->currentState.powerups & ( 1 << PW_QUAD ) ) { + //trap->S_StartSound (NULL, cent->currentState.number, CHAN_ITEM, cgs.media.quadSound ); + } // play a sound diff --git a/codemp/client/cl_input.cpp b/codemp/client/cl_input.cpp index fbbf624281..647efee0f8 100644 --- a/codemp/client/cl_input.cpp +++ b/codemp/client/cl_input.cpp @@ -922,7 +922,9 @@ CL_MouseEvent ================= */ void CL_MouseEvent( int dx, int dy, int time ) { - if (g_clAutoMapMode && cls.cgameStarted) + if (cls.cursorActive) { + CL_UpdateCursorPosition( dx, dy ); + } else if (g_clAutoMapMode && cls.cgameStarted) { //automap input autoMapInput_t *data = (autoMapInput_t *)cl.mSharedMemory; diff --git a/codemp/client/cl_keys.cpp b/codemp/client/cl_keys.cpp index 294b9c3053..b64de77b0e 100644 --- a/codemp/client/cl_keys.cpp +++ b/codemp/client/cl_keys.cpp @@ -1361,25 +1361,28 @@ void CL_KeyDownEvent( int key, unsigned time ) return; } - UIVM_KeyEvent( key, qtrue ); + if ( !cls.cursorActive ) UIVM_KeyEvent( key, qtrue ); return; } // send the bound action - CL_ParseBinding( key, qtrue, time ); + if ( !cls.cursorActive ) CL_ParseBinding( key, qtrue, time ); // distribute the key down event to the appropriate handler // console if ( Key_GetCatcher() & KEYCATCH_CONSOLE ) Console_Key( key ); + else if ( cls.cursorActive ) { + CL_CursorButton( key ); + } // ui else if ( Key_GetCatcher() & KEYCATCH_UI ) { - if ( cls.uiStarted ) + if ( cls.uiStarted && !cls.cursorActive ) UIVM_KeyEvent( key, qtrue ); } // cgame else if ( Key_GetCatcher() & KEYCATCH_CGAME ) { - if ( cls.cgameStarted ) + if ( cls.cgameStarted && !cls.cursorActive ) CGVM_KeyEvent( key, qtrue ); } // chatbox diff --git a/codemp/client/cl_main.cpp b/codemp/client/cl_main.cpp index dca664073a..0a3ac54269 100644 --- a/codemp/client/cl_main.cpp +++ b/codemp/client/cl_main.cpp @@ -106,6 +106,10 @@ cvar_t *cl_lanForcePackets; cvar_t *cl_drawRecording; +cvar_t *cl_downloadName; +cvar_t *cl_downloadPrompt; +cvar_t *cl_downloadOverlay; + cvar_t *cl_filterGames; vec3_t cl_windVec; @@ -1331,6 +1335,7 @@ Called when all downloading has been completed ================= */ void CL_DownloadsComplete( void ) { + clc.downloadMenuActive = qfalse; // if we downloaded files we need to restart the file system if (clc.downloadRestart) { @@ -1340,6 +1345,7 @@ void CL_DownloadsComplete( void ) { // inform the server so we get new gamestate info CL_AddReliableCommand( "donedl", qfalse ); + clc.downloadFinished = qtrue; // by sending the donedl command we request a new gamestate // so we don't want to load stuff yet @@ -1388,13 +1394,29 @@ game directory. ================= */ -void CL_BeginDownload( const char *localName, const char *remoteName ) { +void CL_BeginDownloadConfirm( void ) { + clc.downloadWaitingOnUser = qfalse; + + if ( !cl_downloadOverlay->integer ) { + clc.downloadMenuActive = qfalse; + } Com_DPrintf("***** CL_BeginDownload *****\n" "Localname: %s\n" "Remotename: %s\n" - "****************************\n", localName, remoteName); + "****************************\n", clc.downloadName, cl_downloadName->string); + + clc.downloadBlock = 0; // Starting new file + clc.downloadCount = 0; + clc.downloadTime = cls.realtime; + // Set current time to make sure the module knows the real start time after the delay + Cvar_SetValue( "cl_downloadTime", (float) cls.realtime ); + + CL_AddReliableCommand( va("download %s", cl_downloadName->string), qfalse ); +} + +void CL_BeginDownload( const char *localName, const char *remoteName ) { Q_strncpyz ( clc.downloadName, localName, sizeof(clc.downloadName) ); Com_sprintf( clc.downloadTempName, sizeof(clc.downloadTempName), "%s.tmp", localName ); @@ -1404,10 +1426,13 @@ void CL_BeginDownload( const char *localName, const char *remoteName ) { Cvar_Set( "cl_downloadCount", "0" ); Cvar_SetValue( "cl_downloadTime", (float) cls.realtime ); - clc.downloadBlock = 0; // Starting new file - clc.downloadCount = 0; - - CL_AddReliableCommand( va("download %s", remoteName), qfalse ); + // Prompt the user (unless they disabled it) + if ( cl_downloadPrompt->integer ) { + clc.downloadMenuActive = qtrue; + clc.downloadWaitingOnUser = qtrue; + } else { + CL_BeginDownloadConfirm(); + } } /* @@ -1421,8 +1446,10 @@ void CL_NextDownload(void) { char *s; char *remoteName, *localName; + clc.downloadWaitingOnUser = qfalse; + // A download has finished, check whether this matches a referenced checksum - if(*clc.downloadName) + if(*clc.downloadName && clc.downloadSize) { char *zippath = FS_BuildOSPath(Cvar_VariableString("fs_homepath"), clc.downloadName, ""); zippath[strlen(zippath)-1] = '\0'; @@ -1487,6 +1514,18 @@ and determine if we need to download them void CL_InitDownloads(void) { char missingfiles[1024]; + if ( clc.downloadFinished ) { + // If we just finished a download with a "donedl" we are getting another gamestate and we would be asked to + // download skipped files again. To avoid this we just skip this one... + clc.downloadFinished = qfalse; + CL_DownloadsComplete(); + return; + } + + if ( cl_downloadOverlay->integer ) { + clc.downloadMenuActive = qtrue; + } + if ( !cl_allowDownload->integer ) { // autodownload is disabled on the client @@ -1501,10 +1540,15 @@ void CL_InitDownloads(void) { } } else if ( FS_ComparePaks( clc.downloadList, sizeof( clc.downloadList ) , qtrue ) ) { + const char *serverInfo = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SERVERINFO ]; + const char *serverAllowDownloads = Info_ValueForKey( serverInfo, "sv_allowDownload" ); Com_Printf("Need paks: %s\n", clc.downloadList ); - if ( *clc.downloadList ) { + if ( serverAllowDownloads[0] && !atoi(serverAllowDownloads) ) { + // The server has an "sv_allowDownload" value set, but it's 0 + Com_Printf("Skipping downloads, because the server does not allow downloads\n"); + } else if ( *clc.downloadList ) { // if autodownloading is not enabled on the server cls.state = CA_CONNECTED; @@ -2298,6 +2342,9 @@ void CL_InitRenderer( void ) { cls.consoleShader = re->RegisterShader( "console" ); g_console_field_width = cls.glconfig.vidWidth / SMALLCHAR_WIDTH - 2; g_consoleField.widthInChars = g_console_field_width; + + cls.cursorShader = re->RegisterShaderNoMip("cursor"); + cls.menuFont = re->RegisterFont( "ocr_a" ); } /* @@ -2736,7 +2783,7 @@ void CL_Init( void ) { cl_showMouseRate = Cvar_Get ("cl_showmouserate", "0", 0); cl_framerate = Cvar_Get ("cl_framerate", "0", CVAR_TEMP); - cl_allowDownload = Cvar_Get ("cl_allowDownload", "0", CVAR_ARCHIVE_ND, "Allow downloading custom paks from server"); + cl_allowDownload = Cvar_Get ("cl_allowDownload", "1", CVAR_ARCHIVE_ND, "Allow downloading custom paks from server"); cl_allowAltEnter = Cvar_Get ("cl_allowAltEnter", "1", CVAR_ARCHIVE_ND, "Enables use of ALT+ENTER keyboard combo to toggle fullscreen" ); cl_autolodscale = Cvar_Get( "cl_autolodscale", "1", CVAR_ARCHIVE_ND ); @@ -2781,6 +2828,10 @@ void CL_Init( void ) { cl_filterGames = Cvar_Get( "cl_filterGames", "MBII MBIIOpenBeta", CVAR_ARCHIVE_ND, "List of fs_game to filter (space separated)" ); + cl_downloadName = Cvar_Get( "cl_downloadName", "", CVAR_INTERNAL ); + cl_downloadPrompt = Cvar_Get( "cl_downloadPrompt", "1", CVAR_ARCHIVE, "Confirm pk3 downloads from the server" ); + cl_downloadOverlay = Cvar_Get( "cl_downloadOverlay", "1", CVAR_ARCHIVE, "Draw download info overlay" ); + // userinfo Cvar_Get ("name", "Padawan", CVAR_USERINFO | CVAR_ARCHIVE_ND, "Player name" ); Cvar_Get ("rate", "25000", CVAR_USERINFO | CVAR_ARCHIVE, "Data rate" ); @@ -3742,3 +3793,298 @@ void CL_ShowIP_f(void) { Sys_ShowIP(); } +/* +================== + Internal Menu +================== +*/ + +void CL_DrawMenuRect( float x, float y, float width, float height, float borderSize, vec4_t elementBackgroundColor, vec4_t elementBorderColor ) { + // Draw the background + if ( elementBackgroundColor ) { + re->SetColor( elementBackgroundColor ); + re->DrawStretchPic( x, y, width, height, 0, 0, 0, 0, cls.whiteShader ); + } + + // Draw the borders + if ( elementBorderColor ) { + re->SetColor( elementBorderColor ); + re->DrawStretchPic( x, y, width, borderSize, 0, 0, 0, 0, cls.whiteShader ); + re->DrawStretchPic( x, y + height - borderSize, width, borderSize, 0, 0, 0, 0, cls.whiteShader ); + re->DrawStretchPic( x, y, borderSize, height, 0, 0, 0, 0, cls.whiteShader ); + re->DrawStretchPic( x + width - borderSize, y, borderSize, height, 0, 0, 0, 0, cls.whiteShader ); + } + + // Prevent color from leaking + re->SetColor( NULL ); +} + +void CL_DrawCenterStringAt( int x, int y, const char *str, int font, float scale ) { + int lenX = re->Font_StrLenPixels( str, font, scale ); + int lenY = re->Font_HeightPixels( font, scale ); + re->Font_DrawString( x - (lenX/2), y - (lenY/2), str, colorWhite, font, -1, scale ); +} + +typedef struct menuButton_s { + int x; + int y; + float width; + float height; + const char *text; + int font; + float scale; + void (*action)( void ); +} menuButton_t; +static menuButton_t menuButtons[16]; // No need for dynamic lists. We currently got exactly one menu with max. 3 buttons +static int menuButtonsActive = 0; + +static menuButton_t *CL_RegisterMenuButtonArea( int x, int y, float width, float height, const char *text, int font, float scale, void (*action)(void) ) { + // Too many buttons? Silently discard it to avoid console spam + if ( menuButtonsActive >= (int)ARRAY_LEN(menuButtons) ) return NULL; + + // Set the values + menuButtons[menuButtonsActive].x = x; + menuButtons[menuButtonsActive].y = y; + menuButtons[menuButtonsActive].width = width; + menuButtons[menuButtonsActive].height = height; + menuButtons[menuButtonsActive].text = text; + menuButtons[menuButtonsActive].font = font; + menuButtons[menuButtonsActive].scale = scale; + menuButtons[menuButtonsActive].action = action; + + // Increment counter + return &menuButtons[menuButtonsActive++]; +} + +static qboolean CL_IsCursorOnMenuButton( menuButton_t *button ) { + if ( cls.cursorX >= button->x && cls.cursorX <= button->x+button->width && cls.cursorY >= button->y && cls.cursorY <= button->y+button->height ) + return qtrue; + return qfalse; +} + +static void CL_DrawMenuButton( menuButton_t *button, vec4_t buttonBackgroundColor, vec4_t buttonBorderColor ) { + if ( !button ) return; + CL_DrawMenuRect( button->x, button->y, button->width, button->height, 3, buttonBackgroundColor, buttonBorderColor ); + CL_DrawCenterStringAt( button->x + (button->width/2), button->y + 5, button->text, button->font, button->scale ); +} + +static const char *CL_ByteCountToHumanString( int byteCount ) +{ + #define GB_BYTES (1024 * 1024 * 1024) + #define MB_BYTES (1024 * 1024) + #define KB_BYTES (1024) + + if ( byteCount > GB_BYTES ) return va( "%.02f GB", (float)byteCount / GB_BYTES ); + else if ( byteCount > MB_BYTES ) return va( "%.02f MB", (float)byteCount / MB_BYTES ); + else if ( byteCount > KB_BYTES ) return va( "%.1f KB", (float)byteCount / KB_BYTES ); + else return va( "%i B", byteCount ); +} + +static const char *CL_DurationSecToString( int duration ) +{ // SkyMod: Duration seconds to string + #define TIME_YEAR (60 * 60 * 24 * 365) + #define TIME_WEEK (60 * 60 * 24 * 7) + #define TIME_DAY (60 * 60 * 24) + #define TIME_HOUR (60 * 60) + #define TIME_MINUTE (60) + + static int call; + static char bufs[2][128]; + char *durationStr = bufs[call&1]; + int years = 0, weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0; + call++; + + while ( duration ) + { + if ( duration >= TIME_YEAR ) + { + duration -= TIME_YEAR; + years++; + } + else if ( duration >= TIME_WEEK ) + { + duration -= TIME_WEEK; + weeks++; + } + else if ( duration >= TIME_DAY ) + { + duration -= TIME_DAY; + days++; + } + else if ( duration >= TIME_HOUR ) + { + duration -= TIME_HOUR; + hours++; + } + else if ( duration >= TIME_MINUTE ) + { + duration -= TIME_MINUTE; + minutes++; + } + else + { + seconds = duration; + duration = 0; + } + } + + *durationStr = 0; + if ( years ) Q_strcat( durationStr, sizeof(bufs[0]), va("%iy ", years) ); + if ( weeks ) Q_strcat( durationStr, sizeof(bufs[0]), va("%iw ", weeks) ); + if ( days ) Q_strcat( durationStr, sizeof(bufs[0]), va("%id ", days) ); + if ( hours ) Q_strcat( durationStr, sizeof(bufs[0]), va("%ih ", hours) ); + if ( minutes ) Q_strcat( durationStr, sizeof(bufs[0]), va("%im ", minutes) ); + if ( seconds ) Q_strcat( durationStr, sizeof(bufs[0]), va("%is ", seconds) ); + + if ( *durationStr ) + { // Strip tailing space + char *ptr = durationStr; + while ( *ptr ) ptr++; + if ( *(ptr-1) == ' ' ) *(ptr-1) = 0; + } + + return durationStr; +} + +void CL_DrawDownloadRequest( void ) { + // Menu values + static vec4_t backgroundColor = { 0.1f, 0.2f, 0.45f, 0.9f }; + static vec4_t borderColor = { 0.05f, 0.1f, 0.35f, 1.0f }; + static float width = SCREEN_WIDTH / 6; + static float height = SCREEN_HEIGHT / 4; + + static float centerX = SCREEN_WIDTH / 2; + static float centerY = SCREEN_HEIGHT / 2; + + static float scale = 1.0f; + + // Button values + static vec4_t buttonBackgroundColor = { 0.1f, 0.1f, 0.4f, 0.9f }; + static vec4_t buttonBorderColor = { 0.05f, 0.05f, 0.2f, 1.0f }; + menuButton_t *button; + + // Draw frame + CL_DrawMenuRect( width, height, width*4, height*2, 6, backgroundColor, borderColor ); + + // Header + CL_DrawCenterStringAt( centerX, height + 10, "^1[ ^7File Download ^1]", cls.menuFont, scale ); + + // File name + CL_DrawCenterStringAt( centerX, centerY - (height/2), cl_downloadName->string, cls.menuFont, scale ); + + if ( clc.downloadWaitingOnUser ) { + // Tell user that we're waiting on their decision + CL_DrawCenterStringAt( centerX, centerY-10, "Do you want to download this file?", cls.menuFont, scale ); + CL_DrawCenterStringAt( centerX, centerY+10, "Please select an option", cls.menuFont, scale ); + } else { + // Draw Progress Bar + static vec4_t barBackgroundColor = { 0.1f, 0.8f, 0.4f, 0.9f }; + static vec4_t barBorderColor = { 0.05f, 0.6f, 0.2f, 1.0f }; + float dlFrac = clc.downloadSize ? (float)clc.downloadCount / clc.downloadSize : 0.0f; + + // Download speed + int dlTime = (float)(cls.realtime - clc.downloadTime) / 1000.0f; + static int dlRate; + static int dlLastTime; + static int dlLastCount; + + // Bar with percentage + CL_DrawCenterStringAt( centerX, centerY - 10, "Progress:", cls.menuFont, scale ); + CL_DrawMenuRect( centerX - width*2 + 10, centerY+5, (width * 4 - 20 - 3) * dlFrac, 20, 3, barBackgroundColor, NULL ); + CL_DrawMenuRect( centerX - width*2 + 10, centerY+5, width * 4 - 20 - 3, 20, 3, NULL, barBorderColor ); + CL_DrawCenterStringAt( centerX, centerY+10, va("%.02f%%", dlFrac * 100), cls.menuFont, scale ); + + // Draw size info + re->Font_DrawString( width + 10, centerY+30, va("File Size: %s", CL_ByteCountToHumanString(clc.downloadSize)) , colorWhite, cls.menuFont, -1, scale ); + re->Font_DrawString( width + 10, centerY+50, va("Downloaded: %s", CL_ByteCountToHumanString(clc.downloadCount)) , colorWhite, cls.menuFont, -1, scale ); + + // Download Speed + if ( dlTime >= 1 ) { + if ( dlTime != dlLastTime ) { + // Second passed, update measured values + dlRate = clc.downloadCount - dlLastCount; + dlLastTime = dlTime; + dlLastCount = clc.downloadCount; + } + + // Draw info texts + re->Font_DrawString( width + 10, centerY+70, va("Transfer Rate: %s/sec", CL_ByteCountToHumanString(dlRate)) , colorWhite, cls.menuFont, -1, scale ); + re->Font_DrawString( width + 10, centerY+90, va("Estimated Time Left: %s", dlRate ? CL_DurationSecToString(clc.downloadSize/dlRate - dlLastCount/dlRate) : "unknown" ) , colorWhite, cls.menuFont, -1, scale ); + } else { + // Set defaults - if we somehow don't get here and start with dlTime >= 1 we get incorrect values for one second, but that's okay + dlLastCount = clc.downloadCount; + dlLastTime = 0; + dlRate = 0; + + re->Font_DrawString( width + 10, centerY+70, "Transfer Rate: estimating" , colorWhite, cls.menuFont, -1, scale ); + re->Font_DrawString( width + 10, centerY+90, "Estimated Time Left: estimating" , colorWhite, cls.menuFont, -1, scale ); + } + } + + // Draw Buttons + if ( clc.downloadWaitingOnUser ) { + // Only show yes/no if we're waiting on a user decision + button = CL_RegisterMenuButtonArea( width + 10, (height * 3) - 30, 40, 20, "Yes", cls.menuFont, scale, CL_BeginDownloadConfirm ); + CL_DrawMenuButton( button, buttonBackgroundColor, buttonBorderColor ); + + button = CL_RegisterMenuButtonArea( width + 60, (height * 3) - 30, 40, 20, "No", cls.menuFont, scale, CL_NextDownload ); + CL_DrawMenuButton( button, buttonBackgroundColor, buttonBorderColor ); + } + + // The user can always abort if they change their mind + button = CL_RegisterMenuButtonArea( SCREEN_WIDTH - width - 13 - 80, (height * 3) - 30, 80, 20, "Abort", cls.menuFont, scale, CL_Disconnect_f ); + CL_DrawMenuButton( button, buttonBackgroundColor, buttonBorderColor ); +} + +void CL_DrawEngineMenus( void ) { + if ( clc.downloadMenuActive ) { + // Accept cursor movement + cls.cursorActive = qtrue; + } else { + // Disable movement + cls.cursorActive = qfalse; + } + + // Reset all menu buttons, the menu set them if required + menuButtonsActive = 0; + + // Draw menus + if ( clc.downloadMenuActive ) { + CL_DrawDownloadRequest(); + } + + // Draw cursor + if ( cls.cursorActive ) { + int i; + + // Re-draw the buttons the user is hovering over, but use a different color + static vec4_t buttonHoverBackground = { 0.75f, 0.5f, 0.0f, 1.0f }; + static vec4_t buttonHoverFrame = { 0.50f, 0.25f, 0.0f, 1.0f }; + for ( i = 0; i < menuButtonsActive; i++ ) { + if ( CL_IsCursorOnMenuButton(&menuButtons[i]) ) { + CL_DrawMenuButton( &menuButtons[i], buttonHoverBackground, buttonHoverFrame ); + } + } + + // Draw the actual cursor + re->DrawStretchPic( cls.cursorX, cls.cursorY, 48, 48, 0, 0, 1, 1, cls.cursorShader ); + } +} + +void CL_UpdateCursorPosition( int dx, int dy ) { + if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) return; + + cls.cursorX = Com_Clampi( 0, SCREEN_WIDTH, cls.cursorX + dx ); + cls.cursorY = Com_Clampi( 0, SCREEN_HEIGHT, cls.cursorY + dy ); +} + +void CL_CursorButton( int key ) { + int i; + if ( key == A_MOUSE1 ) { + for ( i = 0; i < menuButtonsActive; i++ ) { + if ( CL_IsCursorOnMenuButton(&menuButtons[i]) ) { + menuButtons[i].action(); + } + } + } +} diff --git a/codemp/client/cl_scrn.cpp b/codemp/client/cl_scrn.cpp index fb1c18b884..c25fb6e966 100644 --- a/codemp/client/cl_scrn.cpp +++ b/codemp/client/cl_scrn.cpp @@ -472,6 +472,9 @@ void SCR_DrawScreenField( stereoFrame_t stereoFrame ) { UIVM_Refresh( cls.realtime ); } + // Engine internal menu + CL_DrawEngineMenus(); + // console draws next Con_DrawConsole (); diff --git a/codemp/client/cl_uiapi.cpp b/codemp/client/cl_uiapi.cpp index 29cf09b06a..4ed911798b 100644 --- a/codemp/client/cl_uiapi.cpp +++ b/codemp/client/cl_uiapi.cpp @@ -271,7 +271,7 @@ static qboolean CL_G2API_HaveWeGhoul2Models( void *ghoul2) { static qboolean CL_G2API_GetBoltMatrix( void *ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, const vec3_t position, const int frameNum, qhandle_t *modelList, vec3_t scale ) { if ( !ghoul2 ) { return qfalse; - + } return re->G2API_GetBoltMatrix( *((CGhoul2Info_v *)ghoul2), modelIndex, boltIndex, matrix, angles, position, frameNum, modelList, scale ); } diff --git a/codemp/client/client.h b/codemp/client/client.h index 59ac0c6c4e..ced59fcf44 100644 --- a/codemp/client/client.h +++ b/codemp/client/client.h @@ -223,6 +223,10 @@ typedef struct clientConnection_s { int downloadSize; // how many bytes we got char downloadList[MAX_INFO_STRING]; // list of paks we need to download qboolean downloadRestart; // if true, we need to do another FS_Restart because we downloaded a pak + qboolean downloadMenuActive; + qboolean downloadWaitingOnUser; + qboolean downloadFinished; + int downloadTime; // demo information char demoName[MAX_QPATH]; @@ -327,6 +331,15 @@ typedef struct clientStatic_s { qhandle_t whiteShader; qhandle_t consoleShader; int consoleFont; + + // Cursor + qboolean cursorActive; + qhandle_t cursorShader; + int cursorX; + int cursorY; + + // Engine menu + int menuFont; } clientStatic_t; #define CON_TEXTSIZE 0x30000 //was 32768 @@ -470,6 +483,10 @@ int CL_ServerStatus( const char *serverAddress, char *serverStatusString, int ma qboolean CL_CheckPaused(void); +void CL_DrawEngineMenus( void ); +void CL_UpdateCursorPosition( int dx, int dy ); +void CL_CursorButton( int key ); + // // cl_input // diff --git a/codemp/game/CMakeLists.txt b/codemp/game/CMakeLists.txt index c1d4ae39ba..4d653abc10 100644 --- a/codemp/game/CMakeLists.txt +++ b/codemp/game/CMakeLists.txt @@ -150,7 +150,7 @@ set(MPGameCommonFiles "${MPDir}/qcommon/disablewarnings.h" "${MPDir}/qcommon/q_shared.h" "${MPDir}/qcommon/tags.h" - + ${SharedCommonFiles} ) source_group("common" FILES ${MPGameCommonFiles}) @@ -229,14 +229,12 @@ elseif(WIN32) RUNTIME DESTINATION "${JKAInstallDir}/OpenJK" COMPONENT ${JKAMPCoreComponent}) - if (WIN64) - # Don't do this on 32-bit Windows to avoid overwriting - # vanilla JKA's DLLs - install(TARGETS ${MPGame} - RUNTIME - DESTINATION "${JKAInstallDir}/base" - COMPONENT ${JKAMPCoreComponent}) - endif() + + # Use OpenJK modules as default + install(TARGETS ${MPGame} + RUNTIME + DESTINATION "${JKAInstallDir}/base" + COMPONENT ${JKAMPCoreComponent}) else() install(TARGETS ${MPGame} LIBRARY diff --git a/codemp/game/NPC_AI_GalakMech.c b/codemp/game/NPC_AI_GalakMech.c index b8fd462f7c..b3bae38ca5 100644 --- a/codemp/game/NPC_AI_GalakMech.c +++ b/codemp/game/NPC_AI_GalakMech.c @@ -1181,9 +1181,7 @@ void NPC_BSGM_Attack( void ) //if ( NPC->client->ps.powerups[PW_GALAK_SHIELD] > 0 ) if (0) { - #ifdef BASE_COMPAT - NPCS.NPC->client->ps.powerups[PW_BATTLESUIT] = level.time + ARMOR_EFFECT_TIME; - #endif + NPCS.NPC->client->ps.powerups[PW_BATTLESUIT] = level.time + ARMOR_EFFECT_TIME; G_Damage( NPCS.NPC->enemy, NPCS.NPC, NPCS.NPC, NULL, NPCS.NPC->r.currentOrigin, 100, DAMAGE_NO_KNOCKBACK, MOD_UNKNOWN ); } else @@ -1208,9 +1206,7 @@ void NPC_BSGM_Attack( void ) //FIXME: debounce this? NPCS.NPCInfo->touchedByPlayer = NULL; //FIXME: some shield effect? - #ifdef BASE_COMPAT - NPCS.NPC->client->ps.powerups[PW_BATTLESUIT] = level.time + ARMOR_EFFECT_TIME; - #endif + NPCS.NPC->client->ps.powerups[PW_BATTLESUIT] = level.time + ARMOR_EFFECT_TIME; VectorSubtract( NPCS.NPC->enemy->r.currentOrigin, NPCS.NPC->r.currentOrigin, smackDir ); smackDir[2] += 30; diff --git a/codemp/game/NPC_AI_MineMonster.c b/codemp/game/NPC_AI_MineMonster.c index 3c801728d1..5342a640ed 100644 --- a/codemp/game/NPC_AI_MineMonster.c +++ b/codemp/game/NPC_AI_MineMonster.c @@ -90,7 +90,7 @@ void MineMonster_Patrol( void ) } //rwwFIXMEFIXME: Care about all clients, not just client 0 - //OJKFIXME: clietnum 0 + //OJKFIXME: clientnum 0 VectorSubtract( g_entities[0].r.currentOrigin, NPCS.NPC->r.currentOrigin, dif ); if ( VectorLengthSquared( dif ) < 256 * 256 ) diff --git a/codemp/game/NPC_combat.c b/codemp/game/NPC_combat.c index 7b855edc0c..67d169d1a1 100644 --- a/codemp/game/NPC_combat.c +++ b/codemp/game/NPC_combat.c @@ -1494,7 +1494,7 @@ gentity_t *NPC_PickEnemy( gentity_t *closestTo, int enemyTeam, qboolean checkVis minVis = VIS_360; } - //OJKFIXME: care about clients other than 0 + //OJKFIXME: clientnum 0 //OJKFIXME: choice[] is not size checked? if( findPlayersFirst ) {//try to find a player first @@ -2178,7 +2178,7 @@ qboolean NPC_EvaluateShot( int hit, qboolean glassOK ) return qfalse; } - if ( hit == NPCS.NPC->enemy->s.number || (&g_entities[hit] != NULL && (g_entities[hit].r.svFlags&SVF_GLASS_BRUSH)) ) + if ( hit == NPCS.NPC->enemy->s.number || (g_entities[hit].inuse && (g_entities[hit].r.svFlags&SVF_GLASS_BRUSH)) ) {//can hit enemy or will hit glass, so shoot anyway return qtrue; } @@ -2452,7 +2452,7 @@ float IdealDistance ( gentity_t *self ) case WP_THERMAL: ideal += 50; break; - + case WP_SABER: case WP_BRYAR_PISTOL: // case WP_BLASTER_PISTOL: diff --git a/codemp/game/NPC_stats.c b/codemp/game/NPC_stats.c index 4920ad8a68..3293411e58 100644 --- a/codemp/game/NPC_stats.c +++ b/codemp/game/NPC_stats.c @@ -2554,7 +2554,7 @@ qboolean NPC_ParseParms( const char *NPCName, gentity_t *NPC ) } //FIXME: need to precache the weapon, too? (in above func) weap = GetIDForString( WPTable, value ); - if ( weap >= WP_NONE && weap <= WP_NUM_WEAPONS )///*WP_BLASTER_PISTOL*/WP_SABER ) //?! + if ( weap >= WP_NONE && weap < WP_NUM_WEAPONS )///*WP_BLASTER_PISTOL*/WP_SABER ) //?! { NPC->client->ps.weapon = weap; NPC->client->ps.stats[STAT_WEAPONS] |= ( 1 << NPC->client->ps.weapon ); diff --git a/codemp/game/bg_g2_utils.c b/codemp/game/bg_g2_utils.c index f8e6739a95..e4ba4dda19 100644 --- a/codemp/game/bg_g2_utils.c +++ b/codemp/game/bg_g2_utils.c @@ -42,26 +42,14 @@ void BG_AttachToRancor( void *ghoul2, float rancYaw, vec3_t rancOrigin, int time // Getting the bolt here if ( inMouth ) {//in mouth - #if defined(_GAME) boltIndex = trap->G2API_AddBolt(ghoul2, 0, "jaw_bone"); - #elif defined(_CGAME) - boltIndex = trap->G2API_AddBolt(ghoul2, 0, "jaw_bone"); - #endif } else {//in right hand - #if defined(_GAME) - boltIndex = trap->G2API_AddBolt(ghoul2, 0, "*r_hand"); - #elif defined(_CGAME) boltIndex = trap->G2API_AddBolt(ghoul2, 0, "*r_hand"); - #endif } VectorSet( rancAngles, 0, rancYaw, 0 ); -#if defined(_GAME) trap->G2API_GetBoltMatrix( ghoul2, 0, boltIndex, &boltMatrix, rancAngles, rancOrigin, time, modelList, modelScale ); -#elif defined(_CGAME) - trap->G2API_GetBoltMatrix( ghoul2, 0, boltIndex, &boltMatrix, rancAngles, rancOrigin, time, modelList, modelScale ); -#endif // Storing ent position, bolt position, and bolt axis if ( out_origin ) { @@ -112,11 +100,7 @@ void BG_AttachToRancor( void *ghoul2, float rancYaw, vec3_t rancOrigin, int time #define MAX_VARIANTS 8 qboolean BG_GetRootSurfNameWithVariant( void *ghoul2, const char *rootSurfName, char *returnSurfName, int returnSize ) { -#if defined(_GAME) - if ( !ghoul2 || !trap->G2API_GetSurfaceRenderStatus( ghoul2, 0, rootSurfName ) ) -#elif defined(_CGAME) if ( !ghoul2 || !trap->G2API_GetSurfaceRenderStatus( ghoul2, 0, rootSurfName ) ) -#endif {//see if the basic name without variants is on Q_strncpyz( returnSurfName, rootSurfName, returnSize ); return qtrue; @@ -127,11 +111,7 @@ qboolean BG_GetRootSurfNameWithVariant( void *ghoul2, const char *rootSurfName, for ( i = 0; i < MAX_VARIANTS; i++ ) { Com_sprintf( returnSurfName, returnSize, "%s%c", rootSurfName, 'a'+i ); - #if defined(_GAME) - if ( !trap->G2API_GetSurfaceRenderStatus( ghoul2, 0, returnSurfName ) ) - #elif defined(_CGAME) if ( !trap->G2API_GetSurfaceRenderStatus( ghoul2, 0, returnSurfName ) ) - #endif { return qtrue; } diff --git a/codemp/game/bg_misc.c b/codemp/game/bg_misc.c index b7fc7ba955..b283dcc446 100644 --- a/codemp/game/bg_misc.c +++ b/codemp/game/bg_misc.c @@ -312,9 +312,7 @@ int WeaponAttackAnim[WP_NUM_WEAPONS] = BOTH_THERMAL_THROW,//WP_THERMAL, BOTH_ATTACK3,//BOTH_ATTACK11,//WP_TRIP_MINE, BOTH_ATTACK3,//BOTH_ATTACK12,//WP_DET_PACK, - #ifndef BASE_COMPAT - BOTH_ATTACK3,//WP_CONCUSSION, - #endif // BASE_COMPAT + BOTH_ATTACK3,//WP_CONCUSSION, BOTH_ATTACK2,//WP_BRYAR_OLD, //NOT VALID (e.g. should never really be used): @@ -322,6 +320,32 @@ int WeaponAttackAnim[WP_NUM_WEAPONS] = BOTH_ATTACK1//WP_TURRET, }; +void BG_FixWeaponAttackAnim(void) { +#if defined(_GAME) + const qboolean doFix = !!g_fixWeaponAttackAnim.integer; +#elif defined(_CGAME) + const char *cs = CG_ConfigString(CS_LEGACY_FIXES); + const uint32_t legacyFixes = strtoul(cs, NULL, 0); + const qboolean doFix = !!(legacyFixes & (1 << LEGACYFIX_WEAPONATTACKANIM)); +#elif defined(UI_BUILD) + const qboolean doFix = qtrue; // no chance of prediction error from UI code +#endif + int *move; + + for (move = WeaponAttackAnim; move - WeaponAttackAnim < ARRAY_LEN(WeaponAttackAnim); move++) { + const weapon_t wpIndex = (weapon_t)(move - WeaponAttackAnim); + if (wpIndex == WP_CONCUSSION) { + *move = doFix ? BOTH_ATTACK3 : BOTH_ATTACK2; + } else if (wpIndex == WP_BRYAR_OLD) { + *move = doFix ? BOTH_ATTACK2 : BOTH_STAND1; + } else if (wpIndex == WP_EMPLACED_GUN) { + *move = doFix ? BOTH_STAND1 : BOTH_ATTACK1; + } else if (wpIndex == WP_TURRET) { + *move = doFix ? BOTH_ATTACK1 : BOTH_ATTACK2; // better than UB? + } + } +} + qboolean BG_FileExists( const char *fileName ) { if ( fileName && fileName[0] ) { fileHandle_t f = NULL_FILE; @@ -2056,8 +2080,7 @@ qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const play {//force powers and saber only if ( item->giType != IT_TEAM //not a flag && item->giType != IT_ARMOR//not shields - && (item->giType != IT_WEAPON - || item->giTag != WP_SABER)//not a saber + && (item->giType != IT_WEAPON || item->giTag != WP_SABER)//not a saber && (item->giType != IT_HOLDABLE || item->giTag != HI_SEEKER)//not a seeker && (item->giType != IT_POWERUP || item->giTag == PW_YSALAMIRI) )//not a force pick-up { @@ -2440,10 +2463,8 @@ const char *eventnames[EV_NUM_ENTITY_EVENTS] = { "EV_DEATH3", "EV_OBITUARY", - #ifdef BASE_COMPAT - "EV_POWERUP_QUAD", - "EV_POWERUP_BATTLESUIT", - #endif // BASE_COMPAT + "EV_POWERUP_QUAD", + "EV_POWERUP_BATTLESUIT", //"EV_POWERUP_REGEN", "EV_FORCE_DRAINED", diff --git a/codemp/game/bg_pmove.c b/codemp/game/bg_pmove.c index 62ac9c8772..894867f1c4 100644 --- a/codemp/game/bg_pmove.c +++ b/codemp/game/bg_pmove.c @@ -5161,6 +5161,16 @@ int PM_LegsSlopeBackTransition(int desiredAnim) return resultingAnim; } +static qboolean BG_AreRunWalkAnimsFixed(void) { +#if defined(_GAME) + return !!g_fixRunWalkAnims.integer; +#elif defined(_CGAME) + const char *cs = CG_ConfigString(CS_LEGACY_FIXES); + const uint32_t legacyFixes = strtoul(cs, NULL, 0); + return !!(legacyFixes & (1 << LEGACYFIX_RUNWALKANIMS)); +#endif +} + /* =============== PM_Footsteps @@ -5430,116 +5440,106 @@ static void PM_Footsteps( void ) { #endif else if ( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) { -#ifndef BASE_COMPAT - if( pm->ps->weapon != WP_SABER ) - { + if ( BG_AreRunWalkAnimsFixed() && pm->ps->weapon != WP_SABER ) { desiredAnim = BOTH_RUNBACK1; } - else - { -#endif - switch (pm->ps->fd.saberAnimLevel) - { - case SS_STAFF: - if ( pm->ps->saberHolstered > 1 ) - {//saber off - desiredAnim = BOTH_RUNBACK1; - } - else - { - //desiredAnim = BOTH_RUNBACK_STAFF; - //hmm.. stuff runback anim is pretty messed up for some reason. - desiredAnim = BOTH_RUNBACK2; - } - break; - case SS_DUAL: - if ( pm->ps->saberHolstered > 1 ) - {//sabers off - desiredAnim = BOTH_RUNBACK1; - } - else - { - //desiredAnim = BOTH_RUNBACK_DUAL; - //and so is the dual - desiredAnim = BOTH_RUNBACK2; - } - break; - default: - if ( pm->ps->saberHolstered ) - {//saber off - desiredAnim = BOTH_RUNBACK1; - } - else + else { + switch (pm->ps->fd.saberAnimLevel) { - desiredAnim = BOTH_RUNBACK2; + case SS_STAFF: + if ( pm->ps->saberHolstered > 1 ) + {//saber off + desiredAnim = BOTH_RUNBACK1; + } + else + { + //desiredAnim = BOTH_RUNBACK_STAFF; + //hmm.. stuff runback anim is pretty messed up for some reason. + desiredAnim = BOTH_RUNBACK2; + } + break; + case SS_DUAL: + if ( pm->ps->saberHolstered > 1 ) + {//sabers off + desiredAnim = BOTH_RUNBACK1; + } + else + { + //desiredAnim = BOTH_RUNBACK_DUAL; + //and so is the dual + desiredAnim = BOTH_RUNBACK2; + } + break; + default: + if ( pm->ps->saberHolstered ) + {//saber off + desiredAnim = BOTH_RUNBACK1; + } + else + { + desiredAnim = BOTH_RUNBACK2; + } + break; } - break; - } -#ifndef BASE_COMPAT } -#endif } else { -#ifndef BASE_COMPAT // FIXME: this doesn't break base compatibility at all, remove #ifndef - if ( pm->ps->weapon != WP_SABER ) + if ( BG_AreRunWalkAnimsFixed() && pm->ps->weapon != WP_SABER ) { desiredAnim = BOTH_RUN1; } else { -#endif - switch (pm->ps->fd.saberAnimLevel) - { - case SS_STAFF: - if ( pm->ps->saberHolstered > 1 ) - {//blades off - desiredAnim = BOTH_RUN1; - } - else if ( pm->ps->saberHolstered == 1 ) - {//1 blade on - desiredAnim = BOTH_RUN2; - } - else + switch (pm->ps->fd.saberAnimLevel) { - if (pm->ps->fd.forcePowersActive & (1<ps->saberHolstered > 1 ) + {//blades off + desiredAnim = BOTH_RUN1; + } + else if ( pm->ps->saberHolstered == 1 ) + {//1 blade on + desiredAnim = BOTH_RUN2; + } + else { + if (pm->ps->fd.forcePowersActive & (1<ps->saberHolstered > 1 ) + {//blades off desiredAnim = BOTH_RUN1; } + else if ( pm->ps->saberHolstered == 1 ) + {//1 saber on + desiredAnim = BOTH_RUN2; + } else { - desiredAnim = BOTH_RUN_STAFF; + desiredAnim = BOTH_RUN_DUAL; } + break; + default: + if ( pm->ps->saberHolstered ) + {//saber off + desiredAnim = BOTH_RUN1; + } + else + { + desiredAnim = BOTH_RUN2; + } + break; } - break; - case SS_DUAL: - if ( pm->ps->saberHolstered > 1 ) - {//blades off - desiredAnim = BOTH_RUN1; - } - else if ( pm->ps->saberHolstered == 1 ) - {//1 saber on - desiredAnim = BOTH_RUN2; - } - else - { - desiredAnim = BOTH_RUN_DUAL; - } - break; - default: - if ( pm->ps->saberHolstered ) - {//saber off - desiredAnim = BOTH_RUN1; - } - else - { - desiredAnim = BOTH_RUN2; - } - break; } -#ifndef BASE_COMPAT - } -#endif } } else @@ -5547,58 +5547,54 @@ static void PM_Footsteps( void ) { bobmove = 0.2f; // walking bobs slow if ( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) { -#ifndef BASE_COMPAT // fixme, doesn't break base compat if enabled (I tested this to be sure) - if( pm->ps->weapon != WP_SABER ) + if ( BG_AreRunWalkAnimsFixed() && pm->ps->weapon != WP_SABER ) { desiredAnim = BOTH_WALKBACK1; } else { -#endif - switch (pm->ps->fd.saberAnimLevel) - { - case SS_STAFF: - if ( pm->ps->saberHolstered > 1 ) - { - desiredAnim = BOTH_WALKBACK1; - } - else if ( pm->ps->saberHolstered ) - { - desiredAnim = BOTH_WALKBACK2; - } - else - { - desiredAnim = BOTH_WALKBACK_STAFF; - } - break; - case SS_DUAL: - if ( pm->ps->saberHolstered > 1 ) - { - desiredAnim = BOTH_WALKBACK1; - } - else if ( pm->ps->saberHolstered ) - { - desiredAnim = BOTH_WALKBACK2; - } - else - { - desiredAnim = BOTH_WALKBACK_DUAL; - } - break; - default: - if ( pm->ps->saberHolstered ) - { - desiredAnim = BOTH_WALKBACK1; - } - else + switch (pm->ps->fd.saberAnimLevel) { - desiredAnim = BOTH_WALKBACK2; + case SS_STAFF: + if ( pm->ps->saberHolstered > 1 ) + { + desiredAnim = BOTH_WALKBACK1; + } + else if ( pm->ps->saberHolstered ) + { + desiredAnim = BOTH_WALKBACK2; + } + else + { + desiredAnim = BOTH_WALKBACK_STAFF; + } + break; + case SS_DUAL: + if ( pm->ps->saberHolstered > 1 ) + { + desiredAnim = BOTH_WALKBACK1; + } + else if ( pm->ps->saberHolstered ) + { + desiredAnim = BOTH_WALKBACK2; + } + else + { + desiredAnim = BOTH_WALKBACK_DUAL; + } + break; + default: + if ( pm->ps->saberHolstered ) + { + desiredAnim = BOTH_WALKBACK1; + } + else + { + desiredAnim = BOTH_WALKBACK2; + } + break; } - break; - } -#ifndef BASE_COMPAT } -#endif } else { @@ -5610,12 +5606,10 @@ static void PM_Footsteps( void ) { { desiredAnim = BOTH_WALK1; } -#ifndef BASE_COMPAT - else if ( pm->ps->weapon != WP_SABER ) + else if ( BG_AreRunWalkAnimsFixed() && pm->ps->weapon != WP_SABER ) { desiredAnim = BOTH_WALK1; } -#endif else { switch (pm->ps->fd.saberAnimLevel) diff --git a/codemp/game/bg_public.h b/codemp/game/bg_public.h index e3da414b2f..0326fb64f4 100644 --- a/codemp/game/bg_public.h +++ b/codemp/game/bg_public.h @@ -120,6 +120,8 @@ along with this program; if not, see . #define CS_CLIENT_DUELHEALTHS 31 // nmckenzie: DUEL_HEALTH. Hopefully adding this cs is safe and good? #define CS_GLOBAL_AMBIENT_SET 32 +#define CS_LEGACY_FIXES 36 + #define CS_AMBIENT_SET 37 #define CS_SIEGE_STATE (CS_AMBIENT_SET+MAX_AMBIENT_SETS) @@ -156,6 +158,24 @@ Ghoul2 Insert End #error overflow: (CS_MAX) > MAX_CONFIGSTRINGS #endif +typedef enum legacyFixes_e { + LEGACYFIX_SABERMOVEDATA = 0, + LEGACYFIX_WEAPONATTACKANIM, + LEGACYFIX_RUNWALKANIMS, + /* + m m ""# " m m + # # mmm m m # mmm mmm mm#mm mmm m mm # + #mmmm# #" # "m m" # # # " # #" # #" # # + # # #"""" #m# # # """m # #"""" # # " + # # "#mm" "# # "mm mm#mm "mmm" "mm "#mm" # # # + m" " + "" + Forks of OpenJK should NOT add to or modify the legacy fixes values + Removal, replacement or adding of new flags might lead to incompatibilities + Forks should define their own configstring or serverinfo cvar instead of modifying this + */ +} legacyFixes_t; + typedef enum { G2_MODELPART_HEAD = 10, G2_MODELPART_WAIST, @@ -698,10 +718,8 @@ typedef enum { typedef enum { PW_NONE, - #ifdef BASE_COMPAT - PW_QUAD, - PW_BATTLESUIT, - #endif // BASE_COMPAT + PW_QUAD, + PW_BATTLESUIT, PW_PULL, @@ -908,10 +926,8 @@ typedef enum { EV_DEATH3, EV_OBITUARY, - #ifdef BASE_COMPAT - EV_POWERUP_QUAD, - EV_POWERUP_BATTLESUIT, - #endif // BASE_COMPAT + EV_POWERUP_QUAD, + EV_POWERUP_BATTLESUIT, EV_FORCE_DRAINED, @@ -1717,6 +1733,9 @@ qboolean BG_InDeathAnim( int anim ); qboolean BG_InSaberLockOld( int anim ); qboolean BG_InSaberLock( int anim ); +void BG_FixSaberMoveData( void ); +void BG_FixWeaponAttackAnim( void ); + void BG_SaberStartTransAnim( int clientNum, int saberAnimLevel, int weapon, int anim, float *animSpeed, int broken ); void BG_ForcePowerDrain( playerState_t *ps, forcePowers_t forcePower, int overrideAmt ); diff --git a/codemp/game/bg_saber.c b/codemp/game/bg_saber.c index e59413515b..7abb1642fd 100644 --- a/codemp/game/bg_saber.c +++ b/codemp/game/bg_saber.c @@ -26,6 +26,12 @@ along with this program; if not, see . #include "bg_local.h" #include "w_saber.h" +#if defined(_GAME) + #include "g_local.h" // for cvars +#elif defined(_CGAME) + #include "cgame/cg_local.h" // for configstrings +#endif + extern qboolean BG_SabersOff( playerState_t *ps ); saberInfo_t *BG_MySaber( int clientNum, int saberNum ); @@ -316,30 +322,23 @@ saberMoveData_t saberMoveData[LS_MOVE_MAX] = {// NB:randomized {"BParry Top", BOTH_H1_S1_T_, Q_T, Q_B, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_UP, {"BParry UR", BOTH_H1_S1_TR, Q_TR, Q_BL, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_UR, {"BParry UL", BOTH_H1_S1_TL, Q_TL, Q_BR, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_UL, - {"BParry LR", BOTH_H1_S1_BR, Q_BL, Q_TR, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LR, + {"BParry LR", BOTH_H1_S1_BL, Q_BL, Q_TR, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LR, {"BParry Bot", BOTH_H1_S1_B_, Q_B, Q_T, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LR - {"BParry LL", BOTH_H1_S1_BL, Q_BR, Q_TL, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LL - //{"BParry LR", BOTH_H1_S1_BL, Q_BL, Q_TR, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LR, - //{"BParry Bot", BOTH_H1_S1_B_, Q_B, Q_T, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LL - //{"BParry LL", BOTH_H1_S1_BR, Q_BR, Q_TL, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LL + {"BParry LL", BOTH_H1_S1_BR, Q_BR, Q_TL, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LL // Knockaways {"Knock Top", BOTH_K1_S1_T_, Q_R, Q_T, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BL2TR, LS_T1_T__BR, 150 }, // LS_PARRY_UP, {"Knock UR", BOTH_K1_S1_TR, Q_R, Q_TR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BL2TR, LS_T1_TR__R, 150 }, // LS_PARRY_UR, {"Knock UL", BOTH_K1_S1_TL, Q_R, Q_TL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BR2TL, LS_T1_TL__L, 150 }, // LS_PARRY_UL, - {"Knock LR", BOTH_K1_S1_BR, Q_R, Q_BL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TL2BR, LS_T1_BL_TL, 150 }, // LS_PARRY_LR, - {"Knock LL", BOTH_K1_S1_BL, Q_R, Q_BR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TR2BL, LS_T1_BR_TR, 150 }, // LS_PARRY_LL - //{"Knock LR", BOTH_K1_S1_BL, Q_R, Q_BL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TL2BR, LS_T1_BL_TL, 150 }, // LS_PARRY_LR, - //{"Knock LL", BOTH_K1_S1_BR, Q_R, Q_BR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TR2BL, LS_T1_BR_TR, 150 }, // LS_PARRY_LL + {"Knock LR", BOTH_K1_S1_BL, Q_R, Q_BL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TL2BR, LS_T1_BL_TL, 150 }, // LS_PARRY_LR, + {"Knock LL", BOTH_K1_S1_BR, Q_R, Q_BR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TR2BL, LS_T1_BR_TR, 150 }, // LS_PARRY_LL // Parry {"Parry Top", BOTH_P1_S1_T_, Q_R, Q_T, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BL2TR, LS_A_T2B, 150 }, // LS_PARRY_UP, {"Parry UR", BOTH_P1_S1_TR, Q_R, Q_TL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BL2TR, LS_A_TR2BL, 150 }, // LS_PARRY_UR, {"Parry UL", BOTH_P1_S1_TL, Q_R, Q_TR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BR2TL, LS_A_TL2BR, 150 }, // LS_PARRY_UL, - {"Parry LR", BOTH_P1_S1_BR, Q_R, Q_BR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TL2BR, LS_A_BR2TL, 150 }, // LS_PARRY_LR, - {"Parry LL", BOTH_P1_S1_BL, Q_R, Q_BL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TR2BL, LS_A_BL2TR, 150 }, // LS_PARRY_LL - //{"Parry LR", BOTH_P1_S1_BL, Q_R, Q_BR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TL2BR, LS_A_BR2TL, 150 }, // LS_PARRY_LR, - //{"Parry LL", BOTH_P1_S1_BR, Q_R, Q_BL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TR2BL, LS_A_BL2TR, 150 }, // LS_PARRY_LL + {"Parry LR", BOTH_P1_S1_BL, Q_R, Q_BR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TL2BR, LS_A_BR2TL, 150 }, // LS_PARRY_LR, + {"Parry LL", BOTH_P1_S1_BR, Q_R, Q_BL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TR2BL, LS_A_BL2TR, 150 }, // LS_PARRY_LL // Reflecting a missile {"Reflect Top", BOTH_P1_S1_T_, Q_R, Q_T, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BL2TR, LS_A_T2B, 300 }, // LS_PARRY_UP, @@ -349,6 +348,38 @@ saberMoveData_t saberMoveData[LS_MOVE_MAX] = {// NB:randomized {"Reflect LL", BOTH_P1_S1_BL, Q_R, Q_BR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TL2BR, LS_A_BR2TL, 300 }, // LS_PARRY_LL, }; +void BG_FixSaberMoveData(void) { +#if defined(_GAME) + const qboolean doFix = !!g_fixSaberMoveData.integer; +#elif defined(_CGAME) + const char *cs = CG_ConfigString(CS_LEGACY_FIXES); + const uint32_t legacyFixes = strtoul(cs, NULL, 0); + const qboolean doFix = !!(legacyFixes & (1 << LEGACYFIX_SABERMOVEDATA)); +#endif + saberMoveData_t *move; + + for (move = saberMoveData; move - saberMoveData < ARRAY_LEN(saberMoveData); move++) { + if (!strcmp(move->name, "BParry LR")) { + move->animToUse = doFix ? BOTH_H1_S1_BR : BOTH_H1_S1_BL; + } + else if (!strcmp(move->name, "BParry LL")) { + move->animToUse = doFix ? BOTH_H1_S1_BL : BOTH_H1_S1_BR; + } + else if (!strcmp(move->name, "Knock LR")) { + move->animToUse = doFix ? BOTH_K1_S1_BR : BOTH_K1_S1_BL; + } + else if (!strcmp(move->name, "Knock LL")) { + move->animToUse = doFix ? BOTH_K1_S1_BL : BOTH_K1_S1_BR; + } + else if (!strcmp(move->name, "Parry LR")) { + move->animToUse = doFix ? BOTH_P1_S1_BR : BOTH_P1_S1_BL; + } + else if (!strcmp(move->name, "Parry LL")) { + move->animToUse = doFix ? BOTH_P1_S1_BL : BOTH_P1_S1_BR; + } + } +} + int transitionMove[Q_NUM_QUADS][Q_NUM_QUADS] = { { LS_NONE, LS_T1_BR__R, LS_T1_BR_TR, LS_T1_BR_T_, LS_T1_BR_TL, LS_T1_BR__L, LS_T1_BR_BL, LS_NONE }, diff --git a/codemp/game/bg_saberLoad.c b/codemp/game/bg_saberLoad.c index ae7460dc1c..a2d02cd2ab 100644 --- a/codemp/game/bg_saberLoad.c +++ b/codemp/game/bg_saberLoad.c @@ -532,7 +532,7 @@ static void Saber_ParseSaberType( saberInfo_t *saber, const char **p ) { if ( COM_ParseString( p, &value ) ) return; saberType = GetIDForString( saberTable, value ); - if ( saberType >= SABER_SINGLE && saberType <= NUM_SABERS ) + if ( saberType >= SABER_SINGLE && saberType < NUM_SABERS ) saber->type = (saberType_t)saberType; } static void Saber_ParseSaberModel( saberInfo_t *saber, const char **p ) { diff --git a/codemp/game/bg_saga.c b/codemp/game/bg_saga.c index d67e339d80..e1ab740c6a 100644 --- a/codemp/game/bg_saga.c +++ b/codemp/game/bg_saga.c @@ -157,10 +157,8 @@ stringID_table_t HoldableTable[] = stringID_table_t PowerupTable[] = { ENUM2STRING(PW_NONE), - #ifdef BASE_COMPAT - ENUM2STRING(PW_QUAD), - ENUM2STRING(PW_BATTLESUIT), - #endif // BASE_COMPAT + ENUM2STRING(PW_QUAD), + ENUM2STRING(PW_BATTLESUIT), ENUM2STRING(PW_PULL), ENUM2STRING(PW_REDFLAG), ENUM2STRING(PW_BLUEFLAG), diff --git a/codemp/game/g_active.c b/codemp/game/g_active.c index 8fd94adc50..5f1f90c44e 100644 --- a/codemp/game/g_active.c +++ b/codemp/game/g_active.c @@ -144,9 +144,7 @@ Check for lava / slime contents and drowning ============= */ void P_WorldEffects( gentity_t *ent ) { -#ifdef BASE_COMPAT qboolean envirosuit = qfalse; -#endif int waterlevel; if ( ent->client->noclip ) { @@ -156,19 +154,15 @@ void P_WorldEffects( gentity_t *ent ) { waterlevel = ent->waterlevel; - #ifdef BASE_COMPAT - envirosuit = ent->client->ps.powerups[PW_BATTLESUIT] > level.time; - #endif // BASE_COMPAT + envirosuit = ent->client->ps.powerups[PW_BATTLESUIT] > level.time; // // check for drowning // if ( waterlevel == 3 ) { - #ifdef BASE_COMPAT - // envirosuit give air - if ( envirosuit ) - ent->client->airOutTime = level.time + 10000; - #endif // BASE_COMPAT + // envirosuit give air + if ( envirosuit ) + ent->client->airOutTime = level.time + 10000; // if out of air, start drowning if ( ent->client->airOutTime < level.time) { @@ -208,11 +202,9 @@ void P_WorldEffects( gentity_t *ent ) { { if ( ent->health > 0 && ent->client->tempSpectate < level.time && ent->pain_debounce_time <= level.time ) { - #ifdef BASE_COMPAT if ( envirosuit ) G_AddEvent( ent, EV_POWERUP_BATTLESUIT, 0 ); else - #endif { if ( ent->watertype & CONTENTS_LAVA ) G_Damage( ent, NULL, NULL, NULL, NULL, 30*waterlevel, 0, MOD_LAVA ); diff --git a/codemp/game/g_bot.c b/codemp/game/g_bot.c index 474370b3cb..8d065d141d 100644 --- a/codemp/game/g_bot.c +++ b/codemp/game/g_bot.c @@ -139,6 +139,9 @@ int G_GetMapTypeBits(char *type) typeBits |= (1 << GT_TEAM); typeBits |= (1 << GT_JEDIMASTER); } + if( strstr( type, "team" ) ) { + typeBits |= (1 << GT_TEAM); + } if( strstr( type, "holocron" ) ) { typeBits |= (1 << GT_HOLOCRON); } diff --git a/codemp/game/g_cmds.c b/codemp/game/g_cmds.c index e5c7e24d29..8227f5ee3f 100644 --- a/codemp/game/g_cmds.c +++ b/codemp/game/g_cmds.c @@ -2358,6 +2358,12 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) { char arg1[MAX_CVAR_VALUE_STRING] = {0}; char arg2[MAX_CVAR_VALUE_STRING] = {0}; + if ( g_gametype.integer < GT_TEAM ) + { + trap->SendServerCommand( ent-g_entities, "print \"Cannot call a team vote in a non-team gametype!\n\"" ); + return; + } + if ( team == TEAM_RED ) cs_offset = 0; else if ( team == TEAM_BLUE ) diff --git a/codemp/game/g_combat.c b/codemp/game/g_combat.c index 3540974377..caed2fa430 100644 --- a/codemp/game/g_combat.c +++ b/codemp/game/g_combat.c @@ -4908,17 +4908,15 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, vec3_ } } - #ifdef BASE_COMPAT - // battlesuit protects from all radius damage (but takes knockback) - // and protects 50% against all damage - if ( client && client->ps.powerups[PW_BATTLESUIT] ) { - G_AddEvent( targ, EV_POWERUP_BATTLESUIT, 0 ); - if ( ( dflags & DAMAGE_RADIUS ) || ( mod == MOD_FALLING ) ) { - return; - } - damage *= 0.5; + // battlesuit protects from all radius damage (but takes knockback) + // and protects 50% against all damage + if ( client && client->ps.powerups[PW_BATTLESUIT] ) { + G_AddEvent( targ, EV_POWERUP_BATTLESUIT, 0 ); + if ( ( dflags & DAMAGE_RADIUS ) || ( mod == MOD_FALLING ) ) { + return; } - #endif + damage *= 0.5; + } // add to the attacker's hit counter (if the target isn't a general entity like a prox mine) if ( attacker->client && targ != attacker && targ->health > 0 diff --git a/codemp/game/g_cvar.c b/codemp/game/g_cvar.c index ea8f8d0468..e2c7600e0c 100644 --- a/codemp/game/g_cvar.c +++ b/codemp/game/g_cvar.c @@ -21,18 +21,42 @@ along with this program; if not, see . =========================================================================== */ +#include + +#include "bg_public.h" #include "g_local.h" +#include "game/bg_public.h" // // Cvar callbacks // -/* -static void CVU_Derpity( void ) { - // ... +static void UpdateLegacyFixesConfigstring( legacyFixes_t legacyFix, qboolean enabled ) { + char sLegacyFixes[32]; + trap->GetConfigstring(CS_LEGACY_FIXES, sLegacyFixes, sizeof(sLegacyFixes)); + + uint32_t legacyFixes = strtoul(sLegacyFixes, NULL, 0); + if (enabled) { + legacyFixes |= (1 << legacyFix); + } else { + legacyFixes &= ~(1 << legacyFix); + } + trap->SetConfigstring(CS_LEGACY_FIXES, va("%" PRIu32, legacyFixes)); } -*/ +static void CVU_FixSaberMoveData(void) { + BG_FixSaberMoveData(); + UpdateLegacyFixesConfigstring(LEGACYFIX_SABERMOVEDATA, g_fixSaberMoveData.integer); +} + +static void CVU_FixRunWalkAnims(void) { + UpdateLegacyFixesConfigstring(LEGACYFIX_RUNWALKANIMS, g_fixRunWalkAnims.integer); +} + +static void CVU_FixWeaponAttackAnim(void) { + BG_FixWeaponAttackAnim(); + UpdateLegacyFixesConfigstring(LEGACYFIX_WEAPONATTACKANIM, g_fixWeaponAttackAnim.integer); +} // // Cvar table diff --git a/codemp/game/g_main.c b/codemp/game/g_main.c index 31715742ad..a8d33959e1 100644 --- a/codemp/game/g_main.c +++ b/codemp/game/g_main.c @@ -28,6 +28,7 @@ along with this program; if not, see . #include "g_nav.h" #include "bg_saga.h" #include "b_local.h" +#include "game/bg_public.h" #include "qcommon/q_version.h" NORETURN_PTR void (*Com_Error)( int level, const char *error, ... ); @@ -202,6 +203,10 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) { trap->Print ("gamename: %s\n", GAMEVERSION); trap->Print ("gamedate: %s\n", SOURCE_DATE); + // init as zero, to be updated by the following cvar registration + // relevant cvars call their update func to modify CS_LEGACY_FIXES when necessary + trap->SetConfigstring(CS_LEGACY_FIXES, "0"); + G_RegisterCvars(); G_ProcessIPBans(); diff --git a/codemp/game/g_xcvar.h b/codemp/game/g_xcvar.h index dca8c3ccd8..df9ee8094a 100644 --- a/codemp/game/g_xcvar.h +++ b/codemp/game/g_xcvar.h @@ -23,159 +23,162 @@ along with this program; if not, see . #include "qcommon/q_version.h" -#ifdef XCVAR_PROTO +#if defined(XCVAR_PROTO) #define XCVAR_DEF( name, defVal, update, flags, announce ) extern vmCvar_t name; -#endif - -#ifdef XCVAR_DECL +#elif defined(XCVAR_DECL) #define XCVAR_DEF( name, defVal, update, flags, announce ) vmCvar_t name; -#endif - -#ifdef XCVAR_LIST +#elif defined(XCVAR_LIST) #define XCVAR_DEF( name, defVal, update, flags, announce ) { & name , #name , defVal , update , flags , announce }, +#else + #warning "missing XCVAR expansion def" + #define XCVAR_DEF( ... ) #endif -XCVAR_DEF( bg_fighterAltControl, "0", NULL, CVAR_SYSTEMINFO, qtrue ) -XCVAR_DEF( capturelimit, "8", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) -XCVAR_DEF( com_optvehtrace, "0", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( d_altRoutes, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_asynchronousGroupAI, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_break, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_JediAI, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_noGroupAI, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_noroam, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_npcai, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_npcaiming, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_npcfreeze, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_noIntermissionWait, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( d_patched, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_perPlayerGhoul2, "0", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( d_powerDuelPrint, "0", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( d_projectileGhoul2Collision, "1", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( d_saberAlwaysBoxTrace, "0", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( d_saberBoxTraceSize, "0", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( d_saberCombat, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_saberGhoul2Collision, "1", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( d_saberInterpolate, "0", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( d_saberKickTweak, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( d_saberSPStyleDamage, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( d_saberStanceDebug, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( d_siegeSeekerNPC, "0", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( dedicated, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( developer, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( dmflags, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( duel_fraglimit, "10", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) -XCVAR_DEF( fraglimit, "20", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) -XCVAR_DEF( g_adaptRespawn, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_allowDuelSuicide, "1", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_allowHighPingDuelist, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_allowNPC, "1", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( g_allowTeamVote, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_allowVote, "-1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_antiFakePlayer, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_armBreakage, "0", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_austrian, "0", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_autoMapCycle, "0", NULL, CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) -XCVAR_DEF( g_banIPs, "", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_charRestrictRGB, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_duelWeaponDisable, "1", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qtrue ) -XCVAR_DEF( g_debugAlloc, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_debugDamage, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_debugMelee, "0", NULL, CVAR_SERVERINFO, qtrue ) -XCVAR_DEF( g_debugMove, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_debugSaberLocks, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( g_debugServerSkel, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( bg_fighterAltControl, "0", NULL, CVAR_SYSTEMINFO, qtrue ) +XCVAR_DEF( capturelimit, "8", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) +XCVAR_DEF( com_optvehtrace, "0", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( d_altRoutes, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_asynchronousGroupAI, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_break, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_JediAI, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_noGroupAI, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_noroam, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_npcai, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_npcaiming, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_npcfreeze, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_noIntermissionWait, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( d_patched, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_perPlayerGhoul2, "0", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( d_powerDuelPrint, "0", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( d_projectileGhoul2Collision, "1", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( d_saberAlwaysBoxTrace, "0", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( d_saberBoxTraceSize, "0", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( d_saberCombat, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_saberGhoul2Collision, "1", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( d_saberInterpolate, "0", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( d_saberKickTweak, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( d_saberSPStyleDamage, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( d_saberStanceDebug, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( d_siegeSeekerNPC, "0", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( dedicated, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( developer, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( dmflags, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( duel_fraglimit, "10", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) +XCVAR_DEF( fraglimit, "20", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) +XCVAR_DEF( g_adaptRespawn, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_allowDuelSuicide, "1", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_allowHighPingDuelist, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_allowNPC, "1", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( g_allowTeamVote, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_allowVote, "-1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_antiFakePlayer, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_armBreakage, "0", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_austrian, "0", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_autoMapCycle, "0", NULL, CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) +XCVAR_DEF( g_banIPs, "", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_charRestrictRGB, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_duelWeaponDisable, "1", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qtrue ) +XCVAR_DEF( g_debugAlloc, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_debugDamage, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_debugMelee, "0", NULL, CVAR_SERVERINFO, qtrue ) +XCVAR_DEF( g_debugMove, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_debugSaberLocks, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( g_debugServerSkel, "0", NULL, CVAR_CHEAT, qfalse ) #ifdef _DEBUG -XCVAR_DEF( g_disableServerG2, "0", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_disableServerG2, "0", NULL, CVAR_NONE, qtrue ) #endif -XCVAR_DEF( g_dismember, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_doWarmup, "0", NULL, CVAR_NONE, qtrue ) -//XCVAR_DEF( g_engineModifications, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_ff_objectives, "0", NULL, CVAR_CHEAT|CVAR_NORESTART, qtrue ) -XCVAR_DEF( g_filterBan, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_forceBasedTeams, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qfalse ) -XCVAR_DEF( g_forceClientUpdateRate, "250", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_forceDodge, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_forcePowerDisable, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qtrue ) -XCVAR_DEF( g_forceRegenTime, "200", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_forceRespawn, "60", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_fraglimitVoteCorrection, "1", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_friendlyFire, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_friendlySaber, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_g2TraceLod, "3", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_gametype, "0", NULL, CVAR_SERVERINFO|CVAR_LATCH, qfalse ) -XCVAR_DEF( g_gravity, "800", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_inactivity, "0", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_jediVmerc, "0", NULL, CVAR_SERVERINFO|CVAR_LATCH|CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_knockback, "1000", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_locationBasedDamage, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_log, "games.log", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_logClientInfo, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_logSync, "0", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_maxConnPerIP, "3", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_maxForceRank, "7", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qfalse ) -XCVAR_DEF( g_maxGameClients, "0", NULL, CVAR_SERVERINFO|CVAR_LATCH|CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_maxHolocronCarry, "3", NULL, CVAR_LATCH, qfalse ) -XCVAR_DEF( g_motd, "", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_needpass, "0", NULL, CVAR_SERVERINFO|CVAR_ROM, qfalse ) -XCVAR_DEF( g_noSpecMove, "0", NULL, CVAR_SERVERINFO, qtrue ) -XCVAR_DEF( g_npcspskill, "0", NULL, CVAR_ARCHIVE|CVAR_INTERNAL, qfalse ) -XCVAR_DEF( g_password, "", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_powerDuelEndHealth, "90", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_powerDuelStartHealth, "150", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_privateDuel, "1", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_randFix, "1", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_restarted, "0", NULL, CVAR_ROM, qfalse ) -XCVAR_DEF( g_saberBladeFaces, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_saberDamageScale, "1", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_dismember, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_doWarmup, "0", NULL, CVAR_NONE, qtrue ) +//XCVAR_DEF( g_engineModifications, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_ff_objectives, "0", NULL, CVAR_CHEAT|CVAR_NORESTART, qtrue ) +XCVAR_DEF( g_filterBan, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_fixSaberDisarmBonus, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_fixSaberMoveData, "1", CVU_FixSaberMoveData, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_fixRunWalkAnims, "1", CVU_FixRunWalkAnims, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_fixWeaponAttackAnim, "1", CVU_FixWeaponAttackAnim, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_forceBasedTeams, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qfalse ) +XCVAR_DEF( g_forceClientUpdateRate, "250", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_forceDodge, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_forcePowerDisable, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qtrue ) +XCVAR_DEF( g_forceRegenTime, "200", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_forceRespawn, "60", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_fraglimitVoteCorrection, "1", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_friendlyFire, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_friendlySaber, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_g2TraceLod, "3", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_gametype, "0", NULL, CVAR_SERVERINFO|CVAR_LATCH, qfalse ) +XCVAR_DEF( g_gravity, "800", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_inactivity, "0", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_jediVmerc, "0", NULL, CVAR_SERVERINFO|CVAR_LATCH|CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_knockback, "1000", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_locationBasedDamage, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_log, "games.log", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_logClientInfo, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_logSync, "0", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_maxConnPerIP, "3", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_maxForceRank, "7", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qfalse ) +XCVAR_DEF( g_maxGameClients, "0", NULL, CVAR_SERVERINFO|CVAR_LATCH|CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_maxHolocronCarry, "3", NULL, CVAR_LATCH, qfalse ) +XCVAR_DEF( g_motd, "", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_needpass, "0", NULL, CVAR_SERVERINFO|CVAR_ROM, qfalse ) +XCVAR_DEF( g_noSpecMove, "0", NULL, CVAR_SERVERINFO, qtrue ) +XCVAR_DEF( g_npcspskill, "0", NULL, CVAR_ARCHIVE|CVAR_INTERNAL, qfalse ) +XCVAR_DEF( g_password, "", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_powerDuelEndHealth, "90", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_powerDuelStartHealth, "150", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_privateDuel, "1", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_randFix, "1", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_restarted, "0", NULL, CVAR_ROM, qfalse ) +XCVAR_DEF( g_saberBladeFaces, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_saberDamageScale, "1", NULL, CVAR_ARCHIVE, qtrue ) #ifdef DEBUG_SABER_BOX -XCVAR_DEF( g_saberDebugBox, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( g_saberDebugBox, "0", NULL, CVAR_CHEAT, qfalse ) #endif #ifndef FINAL_BUILD -XCVAR_DEF( g_saberDebugPrint, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( g_saberDebugPrint, "0", NULL, CVAR_CHEAT, qfalse ) #endif -XCVAR_DEF( g_saberDmgDelay_Idle, "350", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_saberDmgDelay_Wound, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_saberDmgVelocityScale, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_saberLockFactor, "2", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_saberLocking, "1", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_saberLockRandomNess, "2", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_saberRealisticCombat, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( g_saberRestrictForce, "0", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_saberTraceSaberFirst, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_saberWallDamageScale, "0.4", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_securityLog, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_showDuelHealths, "0", NULL, CVAR_SERVERINFO, qfalse ) -XCVAR_DEF( g_siegeRespawn, "20", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_siegeTeam1, "none", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO, qfalse ) -XCVAR_DEF( g_siegeTeam2, "none", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO, qfalse ) -XCVAR_DEF( g_siegeTeamSwitch, "1", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_slowmoDuelEnd, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_smoothClients, "1", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_spawnInvulnerability, "3000", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_speed, "250", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_statLog, "0", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_statLogFile, "statlog.log", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_stepSlideFix, "1", NULL, CVAR_SERVERINFO, qtrue ) -XCVAR_DEF( g_synchronousClients, "0", NULL, CVAR_SYSTEMINFO, qfalse ) -XCVAR_DEF( g_teamAutoJoin, "0", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_teamForceBalance, "0", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_timeouttospec, "70", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_userinfoValidate, "25165823", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_useWhileThrowing, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_voteDelay, "3000", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_warmup, "20", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_weaponDisable, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qtrue ) -XCVAR_DEF( g_weaponRespawn, "5", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( gamedate, SOURCE_DATE, NULL, CVAR_ROM, qfalse ) -XCVAR_DEF( gamename, GAMEVERSION, NULL, CVAR_SERVERINFO|CVAR_ROM, qfalse ) -XCVAR_DEF( pmove_fixed, "0", NULL, CVAR_SYSTEMINFO|CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( pmove_float, "0", NULL, CVAR_SYSTEMINFO|CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( pmove_msec, "8", NULL, CVAR_SYSTEMINFO|CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( RMG, "0", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( sv_cheats, "1", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( sv_fps, "40", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO, qtrue ) -XCVAR_DEF( sv_maxclients, "8", NULL, CVAR_SERVERINFO|CVAR_LATCH|CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( timelimit, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) +XCVAR_DEF( g_saberDmgDelay_Idle, "350", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_saberDmgDelay_Wound, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_saberDmgVelocityScale, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_saberLockFactor, "2", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_saberLocking, "1", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_saberLockRandomNess, "2", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_saberRealisticCombat, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( g_saberRestrictForce, "0", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_saberTraceSaberFirst, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_saberWallDamageScale, "0.4", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_securityLog, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_showDuelHealths, "0", NULL, CVAR_SERVERINFO, qfalse ) +XCVAR_DEF( g_siegeRespawn, "20", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_siegeTeam1, "none", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO, qfalse ) +XCVAR_DEF( g_siegeTeam2, "none", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO, qfalse ) +XCVAR_DEF( g_siegeTeamSwitch, "1", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_slowmoDuelEnd, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_smoothClients, "1", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_spawnInvulnerability, "3000", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_speed, "250", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_statLog, "0", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_statLogFile, "statlog.log", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_stepSlideFix, "1", NULL, CVAR_SERVERINFO, qtrue ) +XCVAR_DEF( g_synchronousClients, "0", NULL, CVAR_SYSTEMINFO, qfalse ) +XCVAR_DEF( g_teamAutoJoin, "0", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_teamForceBalance, "0", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_timeouttospec, "70", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_userinfoValidate, "25165823", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_useWhileThrowing, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_voteDelay, "3000", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_warmup, "20", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_weaponDisable, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qtrue ) +XCVAR_DEF( g_weaponRespawn, "5", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( gamedate, SOURCE_DATE, NULL, CVAR_ROM, qfalse ) +XCVAR_DEF( gamename, GAMEVERSION, NULL, CVAR_SERVERINFO|CVAR_ROM, qfalse ) +XCVAR_DEF( pmove_fixed, "0", NULL, CVAR_SYSTEMINFO|CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( pmove_float, "0", NULL, CVAR_SYSTEMINFO|CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( pmove_msec, "8", NULL, CVAR_SYSTEMINFO|CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( RMG, "0", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( sv_cheats, "1", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( sv_fps, "40", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO, qtrue ) +XCVAR_DEF( sv_maxclients, "8", NULL, CVAR_SERVERINFO|CVAR_LATCH|CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( timelimit, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) #undef XCVAR_DEF diff --git a/codemp/game/w_saber.c b/codemp/game/w_saber.c index 5561b3ed8d..b143eae0b8 100644 --- a/codemp/game/w_saber.c +++ b/codemp/game/w_saber.c @@ -109,6 +109,16 @@ qboolean G_CanBeEnemy( gentity_t *self, gentity_t *enemy ) if ( !self->inuse || !enemy->inuse || !self->client || !enemy->client ) return qfalse; + if (self->client->ps.duelInProgress && self->client->ps.duelIndex != enemy->s.number) + { //dueling but not with this person + return qfalse; + } + + if (enemy->client->ps.duelInProgress && enemy->client->ps.duelIndex != self->s.number) + { //other guy dueling but not with me + return qfalse; + } + if (level.gametype < GT_TEAM) return qtrue; @@ -6745,7 +6755,8 @@ qboolean saberCheckKnockdown_DuelLoss(gentity_t *saberent, gentity_t *saberOwner if ( other && other->client ) { disarmChance += other->client->saber[0].disarmBonus; - if ( other->client->saber[1].model[0] + if ( g_fixSaberDisarmBonus.integer + && other->client->saber[1].model[0] && !other->client->ps.saberHolstered ) { disarmChance += other->client->saber[1].disarmBonus; @@ -6829,7 +6840,8 @@ qboolean saberCheckKnockdown_BrokenParry(gentity_t *saberent, gentity_t *saberOw if ( other && other->client ) { disarmChance += other->client->saber[0].disarmBonus; - if ( other->client->saber[1].model[0] + if ( g_fixSaberDisarmBonus.integer + && other->client->saber[1].model[0] && !other->client->ps.saberHolstered ) { disarmChance += other->client->saber[1].disarmBonus; diff --git a/codemp/qcommon/common.cpp b/codemp/qcommon/common.cpp index 69061d16de..4b84c4d141 100644 --- a/codemp/qcommon/common.cpp +++ b/codemp/qcommon/common.cpp @@ -1196,6 +1196,9 @@ void Com_Init( char *commandLine ) { com_homepath = Cvar_Get("com_homepath", "", CVAR_INIT); + // Init network before filesystem + NET_Init(); + FS_InitFilesystem (); Com_InitJournaling(); diff --git a/codemp/qcommon/cvar.cpp b/codemp/qcommon/cvar.cpp index 157cddeb2e..a705e18623 100644 --- a/codemp/qcommon/cvar.cpp +++ b/codemp/qcommon/cvar.cpp @@ -503,11 +503,11 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, uint32_t flags, c return var; } -static void Cvar_QSortByName( cvar_t **a, int n ) +static void Cvar_QSortByName( cvar_t **a, int n ) { cvar_t *temp; cvar_t *m; - int i, j; + int i, j; i = 0; j = n; @@ -519,10 +519,10 @@ static void Cvar_QSortByName( cvar_t **a, int n ) while ( strcmp( a[j]->name, m->name ) < 0 ) j--; if ( i <= j ) { - temp = a[i]; - a[i] = a[j]; + temp = a[i]; + a[i] = a[j]; a[j] = temp; - i++; + i++; j--; } } while ( i <= j ); @@ -532,7 +532,7 @@ static void Cvar_QSortByName( cvar_t **a, int n ) } -static void Cvar_Sort( void ) +static void Cvar_Sort( void ) { cvar_t *list[ MAX_CVARS ], *var; int count; @@ -551,7 +551,7 @@ static void Cvar_Sort( void ) } Cvar_QSortByName( &list[0], count-1 ); - + cvar_vars = NULL; // relink cvars diff --git a/codemp/qcommon/files.cpp b/codemp/qcommon/files.cpp index 7077b2d4c3..9529217d75 100644 --- a/codemp/qcommon/files.cpp +++ b/codemp/qcommon/files.cpp @@ -210,6 +210,7 @@ typedef struct pack_s { int pure_checksum; // checksum for pure int numfiles; // number of files in pk3 int referenced; // referenced file flags + qboolean noref; // file is blacklisted for referencing int hashSize; // hash table size (power of 2) fileInPack_t* *hashTable; // hash table fileInPack_t* buildBuffer; // buffer with the filenames etc. @@ -243,6 +244,7 @@ static cvar_t *fs_cdpath; static cvar_t *fs_copyfiles; static cvar_t *fs_gamedirvar; static cvar_t *fs_dirbeforepak; //rww - when building search path, keep directories at top and insert pk3's under them +static cvar_t *fs_forcegame; static searchpath_t *fs_searchpaths; static int fs_readCount; // total bytes read static int fs_loadCount; // total files read @@ -312,6 +314,18 @@ FILE* missingFiles = NULL; # endif #endif +const char *get_filename(const char *path) { + const char *slash = strrchr(path, PATH_SEP); + if (!slash || slash == path) return ""; + return slash + 1; +} + +const char *get_filename_ext(const char *filename) { + const char *dot = strrchr(filename, '.'); + if (!dot || dot == filename) return ""; + return dot + 1; +} + /* ============== FS_Initialized @@ -1394,41 +1408,47 @@ long FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean unique // The x86.dll suffixes are needed in order for sv_pure to continue to // work on non-x86/windows systems... - l = strlen( filename ); - if ( !(pak->referenced & FS_GENERAL_REF)) { - if( !FS_IsExt(filename, ".shader", l) && - !FS_IsExt(filename, ".txt", l) && - !FS_IsExt(filename, ".str", l) && - !FS_IsExt(filename, ".cfg", l) && - !FS_IsExt(filename, ".config", l) && - !FS_IsExt(filename, ".bot", l) && - !FS_IsExt(filename, ".arena", l) && - !FS_IsExt(filename, ".menu", l) && - !FS_IsExt(filename, ".fcf", l) && - Q_stricmp(filename, "jampgamex86.dll") != 0 && - //Q_stricmp(filename, "vm/qagame.qvm") != 0 && - !strstr(filename, "levelshots")) - { + // reference lists + if ( !pak->noref ) { + // JK2MV automatically references pk3's in three cases: + // 1. A .bsp file is loaded from it (and thus it is expected to be a map) + // 2. cgame.qvm or ui.qvm is loaded from it (expected to be a clientside) + // 3. pk3 is located in fs_game != base (standard jk2 behavior) + // All others need to be referenced manually by the use of reflists. + + if (!Q_stricmp(get_filename_ext(filename), "bsp")) { pak->referenced |= FS_GENERAL_REF; } - } - if (!(pak->referenced & FS_CGAME_REF)) - { - if ( Q_stricmp( filename, "cgame.qvm" ) == 0 || - Q_stricmp( filename, "cgamex86.dll" ) == 0 ) - { + if (!Q_stricmp(filename, "vm/cgame.qvm") || !Q_stricmp( filename, "cgamex86.dll" )) { pak->referenced |= FS_CGAME_REF; } - } - if (!(pak->referenced & FS_UI_REF)) - { - if ( Q_stricmp( filename, "ui.qvm" ) == 0 || - Q_stricmp( filename, "uix86.dll" ) == 0 ) - { + if (!Q_stricmp(filename, "vm/ui.qvm") || !Q_stricmp( filename, "uix86.dll" )) { pak->referenced |= FS_UI_REF; } + + // OLD Ref: + /* + l = strlen( filename ); + if ( !(pak->referenced & FS_GENERAL_REF)) { + if( !FS_IsExt(filename, ".shader", l) && + !FS_IsExt(filename, ".txt", l) && + !FS_IsExt(filename, ".str", l) && + !FS_IsExt(filename, ".cfg", l) && + !FS_IsExt(filename, ".config", l) && + !FS_IsExt(filename, ".bot", l) && + !FS_IsExt(filename, ".arena", l) && + !FS_IsExt(filename, ".menu", l) && + !FS_IsExt(filename, ".fcf", l) && + Q_stricmp(filename, "jampgamex86.dll") != 0 && + //Q_stricmp(filename, "vm/qagame.qvm") != 0 && + !strstr(filename, "levelshots")) + { + pak->referenced |= FS_GENERAL_REF; + } + } + */ } if ( uniqueFILE ) { @@ -2977,6 +2997,29 @@ void FS_Which_f( void ) { Com_Printf( "File not found: \"%s\"\n", filename ); } +/* +============ +FS_Restart_f +============ +*/ +static qboolean FS_CanRestartInPlace( void ) { + int i; + for ( i = 1; i < MAX_FILE_HANDLES; i++ ) { + // If we have an active filehandle for a module that references a zip file we cannot restart. + if ( fsh[i].fileSize ) { + if ( fsh[i].zipFile ) return qfalse; + } + } + return qtrue; +} +static void FS_Restart_f( void ) { + if ( !FS_CanRestartInPlace() ) { + Com_Printf( "^3WARNING: Cannot restart file system due to active file handles for pk3 files inside of modules.\n" ); + return; + } + FS_Restart( fs_checksumFeed, qtrue ); +} + //=========================================================================== static int QDECL paksort( const void *a, const void *b ) { @@ -2985,7 +3028,15 @@ static int QDECL paksort( const void *a, const void *b ) { aa = *(char **)a; bb = *(char **)b; - return FS_PathCmp( aa, bb ); + // downloaded files have priority + // this is needed because otherwise even if a clientside was downloaded, there is no gurantee it is actually used. + if (!Q_stricmpn(aa, "dl_", 3) && Q_stricmpn(bb, "dl_", 3)) { + return 1; + } else if (Q_stricmpn(aa, "dl_", 3) && !Q_stricmpn(bb, "dl_", 3)) { + return -1; + } else { + return FS_PathCmp(aa, bb); + } } /* @@ -2996,7 +3047,6 @@ Sets fs_gamedir, adds the directory to the head of the path, then loads the zip headers ================ */ -#define MAX_PAKFILES 1024 static void FS_AddGameDirectory( const char *path, const char *dir ) { searchpath_t *sp; int i; @@ -3006,7 +3056,7 @@ static void FS_AddGameDirectory( const char *path, const char *dir ) { char curpath[MAX_OSPATH + 1], *pakfile; int numfiles; char **pakfiles; - char *sorted[MAX_PAKFILES]; + const char *filename; // this fixes the case where fs_basepath is the same as fs_cdpath // which happens on full installs @@ -3038,25 +3088,48 @@ static void FS_AddGameDirectory( const char *path, const char *dir ) { pakfiles = Sys_ListFiles( curpath, ".pk3", NULL, &numfiles, qfalse ); - // sort them so that later alphabetic matches override - // earlier ones. This makes pak1.pk3 override pak0.pk3 - if ( numfiles > MAX_PAKFILES ) { - numfiles = MAX_PAKFILES; + if ( numfiles > 1 ) { + qsort( pakfiles, numfiles, sizeof(char*), paksort ); } - for ( i = 0 ; i < numfiles ; i++ ) { - sorted[i] = pakfiles[i]; - } - - qsort( sorted, numfiles, sizeof(char*), paksort ); for ( i = 0 ; i < numfiles ; i++ ) { - pakfile = FS_BuildOSPath( path, dir, sorted[i] ); - if ( ( pak = FS_LoadZipFile( pakfile, sorted[i] ) ) == 0 ) + pakfile = FS_BuildOSPath( path, dir, pakfiles[i] ); + filename = get_filename(pakfile); + + if ( ( pak = FS_LoadZipFile( pakfile, pakfiles[i] ) ) == 0 ) continue; + + // files beginning with "dl_" are only loaded when referenced by the server + if (!Q_stricmpn(filename, "dl_", 3)) { + int j; + qboolean found = qfalse; + + for (j = 0; j < fs_numServerReferencedPaks; j++) { + if (pak->checksum == fs_serverReferencedPaks[j]) { + // server wants it! + found = qtrue; + break; + } + } + + if (!found) { + // server has no interest in the file + unzClose(pak->handle); + Z_Free(pak->buildBuffer); + Z_Free(pak); + continue; + } + } + Q_strncpyz(pak->pakPathname, curpath, sizeof(pak->pakPathname)); // store the game name for downloading Q_strncpyz(pak->pakGamename, dir, sizeof(pak->pakGamename)); + // if the pk3 is not in base, always reference it (standard jk2 behaviour) + if (Q_stricmpn(pak->pakGamename, BASEGAME, (int)strlen(BASEGAME))) { + pak->referenced |= FS_GENERAL_REF; + } + fs_packFiles += pak->numfiles; search = (searchpath_s *)Z_Malloc (sizeof(searchpath_t), TAG_FILESYS, qtrue); @@ -3148,9 +3221,12 @@ we are not interested in a download string format, we want something human-reada qboolean FS_ComparePaks( char *neededpaks, int len, qboolean dlstring ) { searchpath_t *sp; qboolean havepak; - char *origpos = neededpaks; int i; + char moddir[MAX_ZPATH], filename[MAX_ZPATH]; // If the sum of them exceed 255 characters the game won't accept them + qboolean badname = qfalse; + int read; + if ( !fs_numServerReferencedPaks ) { return qfalse; // Server didn't send any pack information along } @@ -3182,41 +3258,53 @@ qboolean FS_ComparePaks( char *neededpaks, int len, qboolean dlstring ) { if ( !havepak && fs_serverReferencedPakNames[i] && *fs_serverReferencedPakNames[i] ) { // Don't got it + read = sscanf(fs_serverReferencedPakNames[i], "%255[^'/']/%255s", moddir, filename); + + if ( read != 2 ) { + Com_Printf( "WARNING: Unable to parse pak name: %s\n", fs_serverReferencedPakNames[i] ); + badname = qtrue; + continue; + } if (dlstring) { - // We need this to make sure we won't hit the end of the buffer or the server could - // overwrite non-pk3 files on clients by writing so much crap into neededpaks that - // Q_strcat cuts off the .pk3 extension. + // To make sure we don't cut anything off we build the string for the current pak in a separate buffer, + // which must be able to hold fs_serverReferencedPakNames[i], the result of st and 6 more characters. As + // st is at least 8 characters longer than fs_serverReferencedPakNames[i] the doubled size of st should + // be enough. + char currentPak[MAX_ZPATH*2]; + + // Don't allow '@' in file names, because the download code splits by them + if ( strchr(fs_serverReferencedPakNames[i], '@') ) { + badname = qtrue; + continue; + } - origpos += strlen(origpos); + *currentPak = 0; // Remote name - Q_strcat( neededpaks, len, "@"); - Q_strcat( neededpaks, len, fs_serverReferencedPakNames[i] ); - Q_strcat( neededpaks, len, ".pk3" ); + Q_strcat( currentPak, sizeof(currentPak), "@"); + Q_strcat( currentPak, sizeof(currentPak), fs_serverReferencedPakNames[i] ); + Q_strcat( currentPak, sizeof(currentPak), ".pk3" ); // Local name - Q_strcat( neededpaks, len, "@"); + Q_strcat( currentPak, sizeof(currentPak), "@"); // Do we have one with the same name? - if ( FS_SV_FileExists( va( "%s.pk3", fs_serverReferencedPakNames[i] ) ) ) { - char st[MAX_ZPATH]; + if (FS_SV_FileExists(va("%s/dl_%s.pk3", moddir, filename))) { // We already have one called this, we need to download it to another name // Make something up with the checksum in it - Com_sprintf( st, sizeof( st ), "%s.%08x.pk3", fs_serverReferencedPakNames[i], fs_serverReferencedPaks[i] ); - Q_strcat( neededpaks, len, st ); + Q_strcat( currentPak, sizeof(currentPak), va("%s/dl_%s.%08x.pk3", moddir, filename, fs_serverReferencedPaks[i]) ); } else { - Q_strcat( neededpaks, len, fs_serverReferencedPakNames[i] ); - Q_strcat( neededpaks, len, ".pk3" ); + Q_strcat( currentPak, sizeof(currentPak), va("%s/dl_%s.pk3", moddir, filename) ); } - // Find out whether it might have overflowed the buffer and don't add this file to the - // list if that is the case. - if(strlen(origpos) + (origpos - neededpaks) >= (unsigned)(len - 1)) - { - *origpos = '\0'; + // If the currentPak doesn't fit the neededpaks buffer we are likely running into issues + if ( strlen(neededpaks) + strlen(currentPak) >= (size_t)len ) { + Com_Printf( S_COLOR_YELLOW "WARNING (FS_ComparePaks): referenced pk3 files cut off due to too long total length\n" ); break; } + + Q_strcat( neededpaks, len, currentPak ); } else { @@ -3231,7 +3319,7 @@ qboolean FS_ComparePaks( char *neededpaks, int len, qboolean dlstring ) { } } } - if ( *neededpaks ) { + if ( *neededpaks || badname ) { return qtrue; } @@ -3245,7 +3333,7 @@ FS_Shutdown Frees all resources and closes all files ================ */ -void FS_Shutdown( qboolean closemfp ) { +void FS_Shutdown( qboolean closemfp, qboolean keepModuleFiles ) { searchpath_t *p, *next; int i; @@ -3272,7 +3360,8 @@ void FS_Shutdown( qboolean closemfp ) { for(i = 0; i < MAX_FILE_HANDLES; i++) { if (fsh[i].fileSize) { - FS_FCloseFile(i); + if ( !keepModuleFiles ) FS_FCloseFile(i); + else if ( fsh[i].zipFile ) Com_Error(ERR_FATAL, "FS_Shutdown: tried to keep module files when at least one module file is inside of a pak"); } } @@ -3297,6 +3386,7 @@ void FS_Shutdown( qboolean closemfp ) { Cmd_RemoveCommand( "fdir" ); Cmd_RemoveCommand( "touchFile" ); Cmd_RemoveCommand( "which" ); + Cmd_RemoveCommand( "fs_restart" ); #ifdef FS_MISSING if (closemfp) { @@ -3324,6 +3414,22 @@ void FS_UpdateGamedir(void) FS_AddGameDirectory(fs_homepath->string, fs_gamedirvar->string); } } + + // forcegame allows users to override any fs_game settings + if ( fs_forcegame->string[0] && Q_stricmp(fs_forcegame->string, fs_gamedir) ) { + if ( !fs_basegame->string[0] || Q_stricmp(fs_forcegame->string, fs_basegame->string) ) { + if (fs_cdpath->string[0]) { + FS_AddGameDirectory(fs_cdpath->string, fs_forcegame->string); + } + if (fs_basepath->string[0]) { + FS_AddGameDirectory(fs_basepath->string, fs_forcegame->string); + } + if (fs_homepath->string[0] && Q_stricmp(fs_homepath->string,fs_basepath->string)) { + FS_AddGameDirectory(fs_homepath->string, fs_forcegame->string); + } + } + Q_strncpyz( fs_gamedir, fs_forcegame->string, sizeof( fs_gamedir ) ); + } } /* @@ -3384,6 +3490,77 @@ static void FS_ReorderPurePaks() @param gameName Name of the default folder (i.e. always BASEGAME = "base" in OpenJK) */ +void FS_LoadReflists( void ) { + char *mv_whitelist = NULL, *mv_blacklist = NULL, *mv_forcelist = NULL; + fileHandle_t f_w, f_b, f_f; + int f_wl, f_bl, f_fl; + int s; + searchpath_t *search; + + char packstr[MAX_OSPATH]; + + // reference lists + f_wl = FS_FOpenFileRead("ref_whitelist.txt", &f_w, qfalse); + f_bl = FS_FOpenFileRead("ref_blacklist.txt", &f_b, qfalse); + f_fl = FS_FOpenFileRead("ref_forcelist.txt", &f_f, qfalse); + + if (f_w) { + Com_Printf("using whitelist for referenced files...\n"); + + mv_whitelist = (char *)Hunk_AllocateTempMemory(1 + f_wl + 1); + mv_whitelist[0] = '\n'; + s = FS_Read(mv_whitelist + 1, f_wl, f_w); + mv_whitelist[s + 1] = 0; + } + + if (f_b) { + Com_Printf("using blacklist for referenced files...\n"); + + mv_blacklist = (char *)Hunk_AllocateTempMemory(1 + f_bl + 1); + mv_blacklist[0] = '\n'; + s = FS_Read(mv_blacklist + 1, f_bl, f_b); + mv_blacklist[s + 1] = 0; + } + + if (f_f) { + Com_Printf("using forcelist for referenced files...\n"); + + mv_forcelist = (char *)Hunk_AllocateTempMemory(1 + f_fl + 1); + mv_forcelist[0] = '\n'; + s = FS_Read(mv_forcelist + 1, f_fl, f_f); + mv_forcelist[s + 1] = 0; + } + + for (search = fs_searchpaths; search; search = search->next) { + if (search->pack) { + Com_sprintf(packstr, sizeof(packstr), "\n%s/%s.pk3", search->pack->pakGamename, search->pack->pakBasename); + + if (f_w && !Q_stristr(mv_whitelist, packstr)) { + search->pack->noref = qtrue; + search->pack->referenced = 0; + } else if (f_b && Q_stristr(mv_blacklist, packstr)) { + search->pack->noref = qtrue; + search->pack->referenced = 0; + } else if (f_f && Q_stristr(mv_forcelist, packstr)) { + search->pack->referenced |= FS_GENERAL_REF; + } + } + } + + if (f_w) { + FS_FCloseFile(f_w); + Hunk_FreeTempMemory(mv_whitelist); + } + if (f_b) { + FS_FCloseFile(f_b); + Hunk_FreeTempMemory(mv_blacklist); + } + if (f_f) { + FS_FCloseFile(f_f); + Hunk_FreeTempMemory(mv_forcelist); + } +} + void FS_Startup( const char *gameName ) { const char *homePath; @@ -3405,6 +3582,8 @@ void FS_Startup( const char *gameName ) { fs_dirbeforepak = Cvar_Get("fs_dirbeforepak", "0", CVAR_INIT|CVAR_PROTECTED, "Prioritize directories before paks if not pure" ); + fs_forcegame = Cvar_Get ("fs_forcegame", "", CVAR_INIT, "Folder to use for overriding of fs_game (can not be set by the server)." ); + // add search path elements in reverse priority order (lowest priority first) if (fs_cdpath->string[0]) { FS_AddGameDirectory( fs_cdpath->string, gameName ); @@ -3454,12 +3633,29 @@ void FS_Startup( const char *gameName ) { } } + // forcegame allows users to override any fs_game settings + if ( fs_forcegame->string[0] && Q_stricmp(fs_forcegame->string, fs_gamedir) ) { + if ( !fs_basegame->string[0] || Q_stricmp(fs_forcegame->string, fs_basegame->string) ) { + if (fs_cdpath->string[0]) { + FS_AddGameDirectory(fs_cdpath->string, fs_forcegame->string); + } + if (fs_basepath->string[0]) { + FS_AddGameDirectory(fs_basepath->string, fs_forcegame->string); + } + if (fs_homepath->string[0] && Q_stricmp(fs_homepath->string,fs_basepath->string)) { + FS_AddGameDirectory(fs_homepath->string, fs_forcegame->string); + } + } + Q_strncpyz( fs_gamedir, fs_forcegame->string, sizeof( fs_gamedir ) ); + } + // add our commands Cmd_AddCommand ("path", FS_Path_f, "Lists search paths" ); Cmd_AddCommand ("dir", FS_Dir_f, "Lists a folder" ); Cmd_AddCommand ("fdir", FS_NewDir_f, "Lists a folder with filters" ); Cmd_AddCommand ("touchFile", FS_TouchFile_f, "Touches a file" ); Cmd_AddCommand ("which", FS_Which_f, "Determines which search path a file was loaded from" ); + Cmd_AddCommand ("fs_restart", FS_Restart_f, "Restarts the filesystem if no module is currently using files from a pk3" ); // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=506 // reorder the pure pk3 files according to server order @@ -3470,6 +3666,8 @@ void FS_Startup( const char *gameName ) { fs_gamedirvar->modified = qfalse; // We just loaded, it's not modified + FS_LoadReflists(); + Com_Printf( "----------------------\n" ); #ifdef FS_MISSING @@ -3580,7 +3778,7 @@ const char *FS_ReferencedPakChecksums( void ) { for ( search = fs_searchpaths ; search ; search = search->next ) { // is the element a pak file? if ( search->pack ) { - if (search->pack->referenced || Q_stricmpn(search->pack->pakGamename, BASEGAME, strlen(BASEGAME))) { + if (search->pack->referenced) { Q_strcat( info, sizeof( info ), va("%i ", search->pack->checksum ) ); } } @@ -3659,7 +3857,7 @@ const char *FS_ReferencedPakNames( void ) { for ( search = fs_searchpaths ; search ; search = search->next ) { // is the element a pak file? if ( search->pack ) { - if (search->pack->referenced || Q_stricmpn(search->pack->pakGamename, BASEGAME, strlen(BASEGAME))) { + if (search->pack->referenced) { if (*info) { Q_strcat(info, sizeof( info ), " " ); } @@ -3827,6 +4025,7 @@ void FS_InitFilesystem( void ) { #ifdef MACOS_X Com_StartupVariable( "fs_apppath" ); #endif + Com_StartupVariable( "fs_forcegame" ); if(!FS_FilenameCompare(Cvar_VariableString("fs_game"), BASEGAME)) Cvar_Set("fs_game", ""); @@ -3857,10 +4056,10 @@ void FS_InitFilesystem( void ) { FS_Restart ================ */ -void FS_Restart( int checksumFeed ) { +void FS_Restart( int checksumFeed, qboolean inPlace ) { // free anything we currently have loaded - FS_Shutdown(qfalse); + FS_Shutdown(qfalse, inPlace); // set the checksum feed fs_checksumFeed = checksumFeed; @@ -3890,7 +4089,7 @@ void FS_Restart( int checksumFeed ) { Com_Error( ERR_FATAL, "Couldn't load mpdefault.cfg" ); } - if ( Q_stricmp(fs_gamedirvar->string, lastValidGame) ) { + if ( Q_stricmp(fs_gamedirvar->string, lastValidGame) && !fs_forcegame->string[0] ) { // skip the jampconfig.cfg if "safe" is on the command line if ( !Com_SafeMode() ) { Cbuf_AddText ("exec " Q3CONFIG_CFG "\n"); @@ -4233,3 +4432,42 @@ qboolean FS_WriteToTemporaryFile( const void *data, size_t dataLength, char **te return qfalse; } + +// only referenced pk3 files can be downloaded +// returns the path to the GameData directory of the requested file. +const char *FS_MV_VerifyDownloadPath(const char *pk3file) { + char path[MAX_OSPATH]; + searchpath_t *search; + + for (search = fs_searchpaths; search; search = search->next) { + if (!search->pack) + continue; + + Com_sprintf(path, sizeof(path), "%s/%s", search->pack->pakGamename, search->pack->pakBasename); + if (FS_idPak(path, BASEGAME)) + continue; + + Q_strcat(path, sizeof(path), ".pk3"); + + if (!Q_stricmp(path, pk3file)) { + if (search->pack->noref) + return NULL; + + if (search->pack->referenced) { + static char gameDataPath[MAX_OSPATH]; + Q_strncpyz(gameDataPath, search->pack->pakFilename, sizeof(gameDataPath)); + + char *sp = strrchr(gameDataPath, PATH_SEP); + if ( sp ) *sp = 0; + else return NULL; + sp = strrchr(gameDataPath, PATH_SEP); + if ( sp ) *sp = 0; + else return NULL; + + return gameDataPath; + } + } + } + + return NULL; +} diff --git a/codemp/qcommon/q_shared.h b/codemp/qcommon/q_shared.h index cea7b5c833..526ede7d25 100644 --- a/codemp/qcommon/q_shared.h +++ b/codemp/qcommon/q_shared.h @@ -44,10 +44,6 @@ along with this program; if not, see . #define MAX_TEAMNAME 32 #define MAX_MASTER_SERVERS 5 // number of supported master servers -#define BASE_COMPAT // some unused and leftover code has been stripped out, but this breaks compatibility - // between base<->modbase clients and servers (mismatching events, powerups, etc) - // leave this defined to ensure compatibility - #include "qcommon/q_math.h" #include "qcommon/q_color.h" #include "qcommon/q_string.h" diff --git a/codemp/qcommon/qcommon.h b/codemp/qcommon/qcommon.h index c4dbdacfb9..1b5c0324c9 100644 --- a/codemp/qcommon/qcommon.h +++ b/codemp/qcommon/qcommon.h @@ -577,10 +577,10 @@ issues. qboolean FS_Initialized(); void FS_InitFilesystem (void); -void FS_Shutdown( qboolean closemfp ); +void FS_Shutdown( qboolean closemfp, qboolean keepModuleFiles = qfalse ); qboolean FS_ConditionalRestart( int checksumFeed ); -void FS_Restart( int checksumFeed ); +void FS_Restart( int checksumFeed, qboolean inPlace = qfalse ); // shutdown and restart the filesystem so changes to fs_gamedir can take effect char **FS_ListFiles( const char *directory, const char *extension, int *numfiles ); @@ -706,6 +706,7 @@ qboolean FS_ComparePaks( char *neededpaks, int len, qboolean dlstring ); void FS_Rename( const char *from, const char *to ); qboolean FS_WriteToTemporaryFile( const void *data, size_t dataLength, char **tempFileName ); +const char *FS_MV_VerifyDownloadPath(const char *pk3file); /* diff --git a/codemp/rd-common/tr_font.cpp b/codemp/rd-common/tr_font.cpp index 956e182f75..20f3ce8894 100644 --- a/codemp/rd-common/tr_font.cpp +++ b/codemp/rd-common/tr_font.cpp @@ -882,6 +882,7 @@ CFontInfo::CFontInfo(const char *_fontName) m_iOriginalFontWhenSBCSOverriden = -1; m_fAltSBCSFontScaleFactor = -1; m_bIsFakeAlienLanguage = !strcmp(_fontName,"aurabesh"); // dont try and make SBCS or asian overrides for this + m_isVariant = qfalse; len = ri.FS_ReadFile(fontName, NULL); if (len == sizeof(dfontdat_t)) diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index b54fc4fa80..9924b1126c 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -289,7 +289,7 @@ qboolean G2API_OverrideServerWithClientData(CGhoul2Info_v& ghoul2, int modelInde static size_t GetSizeOfGhoul2Info ( const CGhoul2Info& g2Info ) { size_t size = 0; - + // This is pretty ugly, but we don't want to save everything in the CGhoul2Info object. size += offsetof (CGhoul2Info, mTransformedVertsArray) - offsetof (CGhoul2Info, mModelindex); @@ -312,7 +312,7 @@ static size_t SerializeGhoul2Info ( char *buffer, const CGhoul2Info& g2Info ) { char *base = buffer; size_t blockSize; - + // Oh the ugliness... blockSize = offsetof (CGhoul2Info, mTransformedVertsArray) - offsetof (CGhoul2Info, mModelindex); memcpy (buffer, &g2Info.mModelindex, blockSize); @@ -329,7 +329,7 @@ static size_t SerializeGhoul2Info ( char *buffer, const CGhoul2Info& g2Info ) // Bones vector + size *(int *)buffer = g2Info.mBlist.size(); buffer += sizeof (int); - + blockSize = g2Info.mBlist.size() * sizeof (boneInfo_t); memcpy (buffer, g2Info.mBlist.data(), g2Info.mBlist.size() * sizeof (boneInfo_t)); buffer += blockSize; @@ -337,7 +337,7 @@ static size_t SerializeGhoul2Info ( char *buffer, const CGhoul2Info& g2Info ) // Bolts vector + size *(int *)buffer = g2Info.mBltlist.size(); buffer += sizeof (int); - + blockSize = g2Info.mBltlist.size() * sizeof (boltInfo_t); memcpy (buffer, g2Info.mBltlist.data(), g2Info.mBltlist.size() * sizeof (boltInfo_t)); buffer += blockSize; @@ -420,7 +420,7 @@ class Ghoul2InfoArray : public IGhoul2InfoArray size_t GetSerializedSize() const { - size_t size = 0; + size_t size = 0; size += sizeof (int); // size of mFreeIndecies linked list size += mFreeIndecies.size() * sizeof (int); @@ -495,7 +495,7 @@ class Ghoul2InfoArray : public IGhoul2InfoArray buffer += sizeof (int); mInfos[i].resize (count); - + for ( size_t j = 0; j < count; j++ ) { buffer += DeserializeGhoul2Info (buffer, mInfos[i][j]); @@ -548,7 +548,7 @@ class Ghoul2InfoArray : public IGhoul2InfoArray Com_Error(ERR_FATAL, "Out of ghoul2 info slots"); } - // gonna pull from the front, doing a + // gonna pull from the front, doing a int idx=*mFreeIndecies.begin(); mFreeIndecies.erase(mFreeIndecies.begin()); return mIds[idx]; @@ -585,7 +585,7 @@ class Ghoul2InfoArray : public IGhoul2InfoArray assert((handle&G2_INDEX_MASK)>=0&&(handle&G2_INDEX_MASK)=MAX_G2_MODELS||mIds[handle&G2_INDEX_MASK]!=handle)); - + return mInfos[handle&G2_INDEX_MASK]; } const std::vector &Get(int handle) const @@ -747,7 +747,7 @@ void G2API_CleanGhoul2Models(CGhoul2Info_v **ghoul2Ptr) delete *ghoul2Ptr; *ghoul2Ptr = NULL; - } + } } qboolean G2_ShouldRegisterServer(void) @@ -822,7 +822,7 @@ int G2API_InitGhoul2Model(CGhoul2Info_v **ghoul2Ptr, const char *fileName, int m if (model==ghoul2.size()) { //init should not be used to create additional models, only the first one assert(ghoul2.size() < 4); //use G2API_CopySpecificG2Model to add models - ghoul2.push_back(CGhoul2Info()); + ghoul2.push_back(CGhoul2Info()); } strcpy(ghoul2[model].mFileName, fileName); @@ -1291,7 +1291,7 @@ qboolean G2API_SetBoneAnim(CGhoul2Info_v &ghoul2, const int modelIndex, const ch CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; qboolean setPtrs = qfalse; qboolean res = qfalse; - + //rww - RAGDOLL_BEGIN if (ghlInfo) { @@ -2274,7 +2274,7 @@ void G2API_SetGhoul2ModelIndexes( // broken into 3 lines for debugging, STL is a pain to view... // int iModelIndex = ghoul2[i].mModelindex; - qhandle_t mModel = modelList[iModelIndex]; + qhandle_t mModel = modelList[iModelIndex]; ghoul2[i].mModel = mModel; ghoul2[i].mSkin = skinList[ghoul2[i].mCustomSkin]; @@ -2600,7 +2600,7 @@ int G2API_CopyGhoul2Instance(CGhoul2Info_v &g2From, CGhoul2Info_v &g2To, int mod { assert(modelIndex==-1); // copy individual bolted parts is not used in jk2 and I didn't want to deal with it // if ya want it, we will add it back correctly - + //G2ERROR(ghoul2From.IsValid(),"Invalid ghlInfo"); if (g2From.IsValid()) { @@ -2709,7 +2709,7 @@ void G2API_DuplicateGhoul2Instance(CGhoul2Info_v &g2From, CGhoul2Info_v **g2To) CGhoul2Info_v &ghoul2 = *(*g2To); /*ignore = */G2API_CopyGhoul2Instance(g2From, ghoul2, -1); - + return; } @@ -2874,7 +2874,7 @@ qboolean G2API_SkinlessModel(CGhoul2Info_v& ghoul2, int modelIndex) surf = (mdxmSurfHierarchy_t *) ( (byte *)mdxm + mdxm->ofsSurfHierarchy ); - for (i = 0; i < mdxm->numSurfaces; i++) + for (i = 0; i < mdxm->numSurfaces; i++) { if (surf->shader[0]) { //found a surface with a shader name, ok. @@ -3071,7 +3071,7 @@ qboolean G2_SetupModelPointers(CGhoul2Info *ghlInfo) // returns true if the mode // RJ - experimental optimization! if (!ghlInfo->mModel || 1) - { + { if (ri.Cvar_VariableIntegerValue( "dedicated" ) || (G2_ShouldRegisterServer())) //supreme hackery! { diff --git a/codemp/rd-rend2/G2_bolts.cpp b/codemp/rd-rend2/G2_bolts.cpp index cddbc5a067..c0eceb3119 100644 --- a/codemp/rd-rend2/G2_bolts.cpp +++ b/codemp/rd-rend2/G2_bolts.cpp @@ -48,7 +48,7 @@ int G2_Find_Bolt_Surface_Num(boltInfo_v &bltlist, const int surfaceNum, const in // didn't find it return -1; } - + //========================================================================================= //// Public Bolt Routines int G2_Add_Bolt_Surf_Num(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, const int surfNum) @@ -74,7 +74,7 @@ int G2_Add_Bolt_Surf_Num(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_ } } - // we have a surface + // we have a surface // look through entire list - see if it's already there first for(size_t i=0; i #else #include -#endif +#endif #include "ghoul2/G2_gore.h" //#define RAG_TRACE_DEBUG_LINES @@ -20,7 +20,7 @@ //===================================================================================================================== // Bone List handling routines - so entities can override bone info on a bone by bone level, and also interrogate this info -// Given a bone name, see if that bone is already in our bone list - note the model_t pointer that gets passed in here MUST point at the +// Given a bone name, see if that bone is already in our bone list - note the model_t pointer that gets passed in here MUST point at the // gla file, not the glm file type. int G2_Find_Bone(const model_t *mod, boneInfo_v &blist, const char *boneName) { @@ -65,7 +65,7 @@ int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName) //rww - RAGDOLL_BEGIN memset(&tempBone, 0, sizeof(tempBone)); //rww - RAGDOLL_END - + offsets = (mdxaSkelOffsets_t *)((byte *)mdxa + sizeof(mdxaHeader_t)); // walk the entire list of bones in the gla file for this model and see if any match the name of the bone we want to find @@ -168,7 +168,7 @@ qboolean G2_Remove_Bone_Index ( boneInfo_v &blist, int index) // yes, so lets do it blist.resize(newSize); } - + return qtrue; } } @@ -308,7 +308,7 @@ void G2_Generate_Matrix(const model_t *mod, boneInfo_v &blist, int index, const Mat3x4_Multiply(&temp1, boneOverride,&skel->BasePoseMatInv); Mat3x4_Multiply(boneOverride,&skel->BasePoseMat, &temp1); - + } else { @@ -421,7 +421,7 @@ qboolean G2_Remove_Bone (CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *bo assert(ghlInfo->animModel); index = G2_Find_Bone(ghlInfo->animModel, blist, boneName); - + return G2_Remove_Bone_Index(blist, index); } @@ -457,7 +457,7 @@ qboolean G2_Set_Bone_Angles_Index( return qtrue; } } - + if (flags & (BONE_ANGLES_PREMULT | BONE_ANGLES_POSTMULT)) { // you CANNOT call this with an index with these kinds of bone @@ -501,7 +501,7 @@ qboolean G2_Set_Bone_Angles(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char mod_a = (model_t *)ghlInfo->animModel; int index = G2_Find_Bone(mod_a, blist, boneName); - + // did we find it? if (index != -1) { @@ -592,9 +592,9 @@ qboolean G2_Set_Bone_Angles_Matrix(const char *fileName, boneInfo_v &blist, cons { mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); } - model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->header->animIndex); + model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->header->animIndex); int index = G2_Find_Bone(mod_a, blist, boneName); - + if (index != -1) { if (blist[index].flags & BONE_ANGLES_RAGDOLL) @@ -639,19 +639,19 @@ qboolean G2_Set_Bone_Angles_Matrix(const char *fileName, boneInfo_v &blist, cons // given a model, bone name, a bonelist, a start/end frame number, a anim speed and some anim flags, set up or modify an existing bone entry for a new set of anims qboolean G2_Set_Bone_Anim_Index( - boneInfo_v &blist, - const int index, - const int startFrame, - const int endFrame, - const int flags, - const float animSpeed, - const int currentTime, - const float setFrame, + boneInfo_v &blist, + const int index, + const int startFrame, + const int endFrame, + const int flags, + const float animSpeed, + const int currentTime, + const float setFrame, const int blendTime, const int numFrames) { int modFlags = flags; - + if ((index >= (int)blist.size()) || (blist[index].boneNumber == -1)) { // we are attempting to set a bone override that doesn't exist @@ -676,7 +676,7 @@ qboolean G2_Set_Bone_Anim_Index( } if (flags & BONE_ANIM_BLEND) { - float currentFrame, animSpeed; + float currentFrame, animSpeed; int startFrame, endFrame, flags; // figure out where we are now if (G2_Get_Bone_Anim_Index(blist, index, currentTime, ¤tFrame, &startFrame, &endFrame, &flags, &animSpeed, NULL, numFrames)) @@ -697,11 +697,11 @@ qboolean G2_Set_Bone_Anim_Index( { blist[index].blendFrame = currentFrame; blist[index].blendLerpFrame = currentFrame+1; - + // cope with if the lerp frame is actually off the end of the anim if (blist[index].blendFrame >= endFrame ) { - // we only want to lerp with the first frame of the anim if we are looping + // we only want to lerp with the first frame of the anim if we are looping if (blist[index].flags & BONE_ANIM_OVERRIDE_LOOP) { blist[index].blendFrame = startFrame; @@ -720,11 +720,11 @@ qboolean G2_Set_Bone_Anim_Index( } } } - + // cope with if the lerp frame is actually off the end of the anim if (blist[index].blendLerpFrame >= endFrame ) { - // we only want to lerp with the first frame of the anim if we are looping + // we only want to lerp with the first frame of the anim if we are looping if (blist[index].flags & BONE_ANIM_OVERRIDE_LOOP) { blist[index].blendLerpFrame = startFrame; @@ -828,18 +828,18 @@ qboolean G2_Set_Bone_Anim_Index( } // given a model, bone name, a bonelist, a start/end frame number, a anim speed and some anim flags, set up or modify an existing bone entry for a new set of anims -qboolean G2_Set_Bone_Anim(CGhoul2Info *ghlInfo, - boneInfo_v &blist, - const char *boneName, - const int startFrame, - const int endFrame, - const int flags, - const float animSpeed, - const int currentTime, - const float setFrame, +qboolean G2_Set_Bone_Anim(CGhoul2Info *ghlInfo, + boneInfo_v &blist, + const char *boneName, + const int startFrame, + const int endFrame, + const int flags, + const float animSpeed, + const int currentTime, + const float setFrame, const int blendTime) { - model_t *mod_a = (model_t *)ghlInfo->animModel; + model_t *mod_a = (model_t *)ghlInfo->animModel; int index = G2_Find_Bone(mod_a, blist, boneName); if (index == -1) @@ -866,10 +866,10 @@ qboolean G2_Get_Bone_Anim_Range(CGhoul2Info *ghlInfo, boneInfo_v &blist, const c { model_t *mod_a = (model_t *)ghlInfo->animModel; int index = G2_Find_Bone(mod_a, blist, boneName); - + // did we find it? if (index != -1) - { + { // are we an animating bone? if (blist[index].flags & (BONE_ANIM_OVERRIDE_LOOP | BONE_ANIM_OVERRIDE)) { @@ -885,13 +885,13 @@ qboolean G2_Get_Bone_Anim_Range(CGhoul2Info *ghlInfo, boneInfo_v &blist, const c // NOTE if we aren't running an animation, then qfalse is returned void G2_TimingModel(boneInfo_t &bone,int currentTime,int numFramesInFile,int ¤tFrame,int &newFrame,float &lerp); -qboolean G2_Get_Bone_Anim_Index( boneInfo_v &blist, const int index, const int currentTime, +qboolean G2_Get_Bone_Anim_Index( boneInfo_v &blist, const int index, const int currentTime, float *currentFrame, int *startFrame, int *endFrame, int *flags, float *retAnimSpeed, qhandle_t *modelList, int numFrames) { - + // did we find it? if ((index>=0) && !((index >= (int)blist.size()) || (blist[index].boneNumber == -1))) - { + { // are we an animating bone? if (blist[index].flags & (BONE_ANIM_OVERRIDE_LOOP | BONE_ANIM_OVERRIDE)) @@ -918,13 +918,13 @@ qboolean G2_Get_Bone_Anim_Index( boneInfo_v &blist, const int index, const int c // given a model, bonelist and bonename, return the current frame, startframe and endframe of the current animation // NOTE if we aren't running an animation, then qfalse is returned -qboolean G2_Get_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName, const int currentTime, +qboolean G2_Get_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName, const int currentTime, float *currentFrame, int *startFrame, int *endFrame, int *flags, float *retAnimSpeed, qhandle_t *modelList, int modelIndex) { model_t *mod_a = (model_t *)ghlInfo->animModel; int index = G2_Find_Bone(mod_a, blist, boneName); - + if (index==-1) { index = G2_Add_Bone(mod_a, blist, boneName); @@ -934,7 +934,7 @@ qboolean G2_Get_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *b return qfalse; } } - + assert(ghlInfo->aHeader); if (G2_Get_Bone_Anim_Index(blist, index, currentTime, currentFrame, startFrame, endFrame, flags, retAnimSpeed, modelList, ghlInfo->aHeader->numFrames)) @@ -951,10 +951,10 @@ qboolean G2_Get_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *b // given a model, bonelist and bonename, lets pause an anim if it's playing. qboolean G2_Pause_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName, const int currentTime) { - model_t *mod_a = (model_t *)ghlInfo->animModel; + model_t *mod_a = (model_t *)ghlInfo->animModel; int index = G2_Find_Bone(mod_a, blist, boneName); - + // did we find it? if (index != -1) { @@ -976,7 +976,7 @@ qboolean G2_Pause_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char { blist[index].pauseTime = currentTime; } - + return qtrue; } assert(0); @@ -986,10 +986,10 @@ qboolean G2_Pause_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char qboolean G2_IsPaused(const char *fileName, boneInfo_v &blist, const char *boneName) { - model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); - model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->header->animIndex); + model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); + model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->header->animIndex); int index = G2_Find_Bone(mod_a, blist, boneName); - + // did we find it? if (index != -1) { @@ -1008,7 +1008,7 @@ qboolean G2_IsPaused(const char *fileName, boneInfo_v &blist, const char *boneNa // given a model, bonelist and bonename, lets stop an anim if it's playing. qboolean G2_Stop_Bone_Anim_Index(boneInfo_v &blist, const int index) { - + if ((index >= (int)blist.size()) || (blist[index].boneNumber == -1)) { // we are attempting to set a bone override that doesn't exist @@ -1024,10 +1024,10 @@ qboolean G2_Stop_Bone_Anim_Index(boneInfo_v &blist, const int index) // given a model, bonelist and bonename, lets stop an anim if it's playing. qboolean G2_Stop_Bone_Anim(const char *fileName, boneInfo_v &blist, const char *boneName) { - model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); - model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->header->animIndex); + model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); + model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->header->animIndex); int index = G2_Find_Bone(mod_a, blist, boneName); - + // did we find it? if (index != -1) { @@ -1043,13 +1043,13 @@ qboolean G2_Stop_Bone_Anim(const char *fileName, boneInfo_v &blist, const char * // given a model, bonelist and bonename, lets stop an anim if it's playing. qboolean G2_Stop_Bone_Angles_Index(boneInfo_v &blist, const int index) { - + if ((index >= (int)blist.size()) || (blist[index].boneNumber == -1)) { // we are attempting to set a bone override that doesn't exist assert(0); return qfalse; - } + } blist[index].flags &= ~(BONE_ANGLES_TOTAL); // try and remove this bone if we can @@ -1060,10 +1060,10 @@ qboolean G2_Stop_Bone_Angles_Index(boneInfo_v &blist, const int index) // given a model, bonelist and bonename, lets stop an anim if it's playing. qboolean G2_Stop_Bone_Angles(const char *fileName, boneInfo_v &blist, const char *boneName) { - model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); - model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->header->animIndex); + model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); + model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->header->animIndex); int index = G2_Find_Bone(mod_a, blist, boneName); - + // did we find it? if (index != -1) { @@ -1111,7 +1111,7 @@ void G2_Animate_Bone_List(CGhoul2Info_v &ghoul2, const int currentTime, const in if (animSize) { // did we run off the end? - if (((animSpeed > 0.0f) && (newFrame_g > endFrame-1 )) || + if (((animSpeed > 0.0f) && (newFrame_g > endFrame-1 )) || ((animSpeed < 0.0f) && (newFrame_g < endFrame+1 ))) { // yep - decide what to do @@ -1260,7 +1260,7 @@ static std::vector rag; // once we get the dependents precompute static void G2_Generate_MatrixRag( // caution this must not be called before the whole skeleton is "remembered" - boneInfo_v &blist, + boneInfo_v &blist, int index) { @@ -1326,13 +1326,13 @@ int G2_Find_Bone_Rag(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneNa } #if _DEBUG // G2_Bone_Not_Found(boneName,ghlInfo->mFileName); -#endif +#endif // didn't find it return -1; } static int G2_Set_Bone_Rag(const mdxaHeader_t *mod_a, - boneInfo_v &blist, + boneInfo_v &blist, const char *boneName, CGhoul2Info &ghoul2, const vec3_t scale, @@ -1365,7 +1365,7 @@ static int G2_Set_Bone_Rag(const mdxaHeader_t *mod_a, static int G2_Set_Bone_Angles_Rag( CGhoul2Info &ghoul2, const mdxaHeader_t *mod_a, - boneInfo_v &blist, + boneInfo_v &blist, const char *boneName, const int flags, const float radius, @@ -1436,8 +1436,8 @@ static int G2_Set_Bone_Angles_Rag( } if (!bone.lastTimeUpdated) { - static mdxaBone_t id = - { + static mdxaBone_t id = + { { { 1.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f }, @@ -1524,12 +1524,12 @@ static void G2_RagDollMatchPosition() VectorSubtract(desiredPos,e.currentOrigin,desiredPelvisOffset); // last arg is dest haveDesiredPelvisOffset=true; VectorCopy(e.currentOrigin,bone.lastPosition); // last arg is dest - continue; + continue; } if (!(bone.RagFlags & RAG_EFFECTOR)) { - continue; + continue; } VectorCopy(bone.originalOrigin,desiredPos); VectorSubtract(desiredPos,e.currentOrigin,e.desiredDirection); @@ -1564,7 +1564,7 @@ qboolean G2_Set_Bone_Anim_No_BS(CGhoul2Info &ghoul2, const mdxaHeader_t *mod,bon return qtrue; } - + index = G2_Add_Bone(ghoul2.animModel, blist, boneName); if (index != -1) @@ -1599,7 +1599,7 @@ void G2_ResetRagDoll(CGhoul2Info_v &ghoul2V) break; } } - + if (model == ghoul2V.size()) { return; @@ -2969,12 +2969,12 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve VectorSubtract(desiredPos,e.currentOrigin,desiredPelvisOffset); // last arg is dest haveDesiredPelvisOffset=true; VectorCopy(e.currentOrigin,bone.lastPosition); // last arg is dest - continue; + continue; } if (!(bone.RagFlags & RAG_EFFECTOR)) { - continue; + continue; } vec3_t testMins; vec3_t testMaxs; @@ -3008,12 +3008,12 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve // above the origin, so lets try lower if (e.currentOrigin[2] > groundSpot[2]) { - testStart[2]=groundSpot[2]+(e.radius-10.0f); + testStart[2]=groundSpot[2]+(e.radius-10.0f); } else { // lets try higher - testStart[2]=groundSpot[2]+8.0f; + testStart[2]=groundSpot[2]+8.0f; Rag_Trace(&tr,testStart,testMins,testMaxs,testEnd,ignoreNum,RAG_MASK,G2_NOCOLLIDE,0); if (tr.entityNum==0) { @@ -3053,7 +3053,7 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve else { vertEffectorTraceFraction=tr.fraction; - if (params && + if (params && vertEffectorTraceFraction < .95f && fabsf(tr.plane.normal[2]) < .707f) { @@ -3076,7 +3076,7 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve vec3_t effectorGroundSpot; VectorAdvance(testStart,vertEffectorTraceFraction,testEnd,effectorGroundSpot);// VA(a,t,b,c)-> c := (1-t)a+tb // trace from the quake origin horzontally to the effector - // gonna choose the maximum of the ground spot or the effector location + // gonna choose the maximum of the ground spot or the effector location // and clamp it to be roughly in the bbox VectorCopy(groundSpot,testStart); //last arg is dest if (iAmStartSolid) @@ -3111,7 +3111,7 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve } if (ztestvelocity, givenVelocity); vSpeed = VectorNormalize(givenVelocity); @@ -3310,7 +3310,7 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve static inline int G2_RagIndexForBoneNum(int boneNum) { for (int i = 0; i < numRags; i++) - { + { // these are used for affecting the end result if (ragBoneData[i].boneNum == boneNum) { @@ -3512,12 +3512,12 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve VectorSubtract(goalSpot, e.currentOrigin, desiredPelvisOffset); haveDesiredPelvisOffset = true; VectorCopy(e.currentOrigin, bone.lastPosition); - continue; + continue; } if (!(bone.RagFlags & RAG_EFFECTOR)) { - continue; + continue; } if (bone.hasOverGoal) @@ -3728,7 +3728,7 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve { if (hasBasePos) { - VectorSubtract(basePos, e.currentOrigin, velDir); + VectorSubtract(basePos, e.currentOrigin, velDir); } else { @@ -3955,7 +3955,7 @@ static void G2_RagDollSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int f // END this is the objective function thing for (i=0;i=0.0f); #if 0 - if (bone.RagFlags & RAG_PCJ_PELVIS) + if (bone.RagFlags & RAG_PCJ_PELVIS) { magicFactor9=.85f; // we don't want this swinging radically, make the whole thing kindof unstable } @@ -4233,16 +4233,16 @@ static void G2_IKReposition(const vec3_t currentOrg,CRagDollUpdateParams *params if (!(bone.RagFlags & RAG_EFFECTOR)) { - continue; + continue; } - + //Most effectors are not going to be PCJ, so this is not appplicable. //The actual desired angle of the PCJ is factored around the desired //directions of the effectors which are dependant on it. /* if (!(bone.RagFlags & RAG_PCJ_IK_CONTROLLED)) { - continue; + continue; } */ @@ -4280,7 +4280,7 @@ static void G2_IKSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int frameN // END this is the objective function thing for (i = 0; i < numRags; i++) - { + { // these are used for affecting the end result boneInfo_t &bone = *ragBoneData[i]; @@ -4295,7 +4295,7 @@ static void G2_IKSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int frameN } Inverse_Matrix(&ragBones[i], &N); // dest 2nd arg - + int k; vec3_t tAngles; VectorCopy(bone.currentAngles, tAngles); @@ -4371,7 +4371,7 @@ static void G2_IKSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int frameN { magicFactor1 = 0.40f; } - + recip = sqrt(4.0f/1.0f); float fac = (decay*recip*magicFactor1); @@ -4500,7 +4500,7 @@ void G2_Animate_Bone_List(CGhoul2Info_v &ghoul2, const int currentTime, const in static int G2_Set_Bone_Angles_IK( CGhoul2Info &ghoul2, const mdxaHeader_t *mod_a, - boneInfo_v &blist, + boneInfo_v &blist, const char *boneName, const int flags, const float radius, @@ -4536,8 +4536,8 @@ static int G2_Set_Bone_Angles_IK( } if (!bone.lastTimeUpdated) { - static mdxaBone_t id = - { + static mdxaBone_t id = + { { { 1.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f }, @@ -4657,7 +4657,7 @@ qboolean G2_SetBoneIKState(CGhoul2Info_v &ghoul2, int time, const char *boneName } int index = G2_Find_Bone(mod_a, blist, boneName); - + if (index == -1) { index = G2_Add_Bone(mod_a, blist, boneName); @@ -4753,7 +4753,7 @@ qboolean G2_IKMove(CGhoul2Info_v &ghoul2, int time, sharedIKMoveParams_t *params } int index = G2_Find_Bone(mod_a, blist, params->boneName); - + //don't add here if you can't find it.. ik bones should already be there, because they need to have special stuff done to them anyway. if (index == -1) { //couldn't find the bone.. @@ -4823,8 +4823,8 @@ void G2_RemoveRedundantBoneOverrides(boneInfo_v &blist, int *activeBones) int G2_Get_Bone_Index(CGhoul2Info *ghoul2, const char *boneName) { - model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(ghoul2->mFileName)); - model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->header->animIndex); + model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(ghoul2->mFileName)); + model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->header->animIndex); return (G2_Find_Bone(mod_a, ghoul2->mBlist, boneName)); } diff --git a/codemp/rd-rend2/G2_misc.cpp b/codemp/rd-rend2/G2_misc.cpp index ac64001c4e..d5cf343366 100644 --- a/codemp/rd-rend2/G2_misc.cpp +++ b/codemp/rd-rend2/G2_misc.cpp @@ -16,7 +16,7 @@ static int CurrentTag=GORE_TAG_UPPER+1; static int CurrentTagUpper=GORE_TAG_UPPER; static std::map GoreRecords; -static std::map,int> GoreTagsTemp; // this is a surface index to gore tag map used only +static std::map,int> GoreTagsTemp; // this is a surface index to gore tag map used only // temporarily during the generation phase so we reuse gore tags per LOD int goreModelIndex; @@ -218,11 +218,11 @@ class CTraceSurface #endif surfaceNum(initsurfaceNum), - rootSList(initrootSList), + rootSList(initrootSList), currentModel(initcurrentModel), - lod(initlod), - collRecMap(initcollRecMap), - entNum(initentNum), + lod(initlod), + collRecMap(initcollRecMap), + entNum(initentNum), modelIndex(initmodelIndex), skin(initskin), cust_shader(initcust_shader), @@ -243,7 +243,7 @@ class CTraceSurface VectorCopy(initrayStart, rayStart); VectorCopy(initrayEnd, rayEnd); hitOne = false; - } + } }; @@ -259,7 +259,7 @@ void G2_List_Model_Surfaces(const char *fileName) surf = (mdxmSurfHierarchy_t *) ( (byte *)mdxm + mdxm->ofsSurfHierarchy ); mdxmSurface_t *surface = (mdxmSurface_t *)((byte *)mdxm + mdxm->ofsLODs + sizeof(mdxmLOD_t)); - for ( x = 0 ; x < mdxm->numSurfaces ; x++) + for ( x = 0 ; x < mdxm->numSurfaces ; x++) { Com_Printf("Surface %i Name %s\n", x, surf->name); if ( r_verbose->integer ) @@ -283,7 +283,7 @@ void G2_List_Model_Bones(const char *fileName, int frame) int x, i; mdxaSkel_t *skel; mdxaSkelOffsets_t *offsets; - model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); + model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->header->animIndex); // mdxaFrame_t *aframe=0; // int frameSize; @@ -292,7 +292,7 @@ void G2_List_Model_Bones(const char *fileName, int frame) // figure out where the offset list is offsets = (mdxaSkelOffsets_t *)((byte *)header + sizeof(mdxaHeader_t)); -// frameSize = (size_t)( &((mdxaFrame_t *)0)->boneIndexes[ header->numBones ] ); +// frameSize = (size_t)( &((mdxaFrame_t *)0)->boneIndexes[ header->numBones ] ); // aframe = (mdxaFrame_t *)((byte *)header + header->ofsFrames + (frame * frameSize)); // walk each bone and list it's name @@ -321,7 +321,7 @@ void G2_List_Model_Bones(const char *fileName, int frame) * obtain the .gla filename for a model * * Input - * filename of model + * filename of model * * Output * true if we successfully obtained a filename, false otherwise @@ -346,7 +346,7 @@ qboolean G2_GetAnimFileName(const char *fileName, char **filename) ///////////////////////////////////////////////////////////////////// -// +// // Code for collision detection for models gameside // ///////////////////////////////////////////////////////////////////// @@ -361,7 +361,7 @@ int G2_DecideTraceLod(CGhoul2Info &ghoul2, int useLod) returnLod = ghoul2.mLodBias; } // assert(G2_MODEL_OK(&ghoul2)); - + mdxmHeader_t *mdxm = ghoul2.currentModel->data.glm->header; assert(ghoul2.currentModel); assert(mdxm); @@ -376,7 +376,7 @@ int G2_DecideTraceLod(CGhoul2Info &ghoul2, int useLod) return returnLod; } -void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, IHeapAllocator *G2VertSpace, size_t *TransformedVertsArray,CBoneCache *boneCache) +void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, IHeapAllocator *G2VertSpace, size_t *TransformedVertsArray,CBoneCache *boneCache) { int j, k; mdxmVertex_t *v; @@ -386,7 +386,7 @@ void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, IHeapAl // deform the vertexes by the lerped bones // int *piBoneReferences = (int*) ((byte*)surface + surface->ofsBoneReferences); - + // alloc some space for the transformed verts to get put in TransformedVerts = (float *)G2VertSpace->MiniHeapAlloc(surface->numVerts * 5 * 4); TransformedVertsArray[surface->thisSurfaceIndex] = (size_t)TransformedVerts; @@ -403,7 +403,7 @@ void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, IHeapAl // optimisation issue if ((scale[0] != 1.0) || (scale[1] != 1.0) || (scale[2] != 1.0)) { - for ( j = 0; j < numVerts; j++ ) + for ( j = 0; j < numVerts; j++ ) { vec3_t tempVert, tempNormal; // mdxmWeight_t *w; @@ -415,7 +415,7 @@ void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, IHeapAl const int iNumWeights = G2_GetVertWeights( v ); float fTotalWeight = 0.0f; - for ( k = 0 ; k < iNumWeights ; k++ ) + for ( k = 0 ; k < iNumWeights ; k++ ) { int iBoneIndex = G2_GetVertBoneIndex( v, k ); float fBoneWeight = G2_GetVertBoneWeight( v, k, fTotalWeight, iNumWeights ); @@ -446,7 +446,7 @@ void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, IHeapAl else { int pos = 0; - for ( j = 0; j < numVerts; j++ ) + for ( j = 0; j < numVerts; j++ ) { vec3_t tempVert, tempNormal; // const mdxmWeight_t *w; @@ -458,7 +458,7 @@ void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, IHeapAl const int iNumWeights = G2_GetVertWeights( v ); float fTotalWeight = 0.0f; - for ( k = 0 ; k < iNumWeights ; k++ ) + for ( k = 0 ; k < iNumWeights ; k++ ) { int iBoneIndex = G2_GetVertBoneIndex( v, k ); float fBoneWeight = G2_GetVertBoneWeight( v, k, fTotalWeight, iNumWeights ); @@ -487,7 +487,7 @@ void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, IHeapAl } } -void G2_TransformSurfaces(int surfaceNum, surfaceInfo_v &rootSList, +void G2_TransformSurfaces(int surfaceNum, surfaceInfo_v &rootSList, CBoneCache *boneCache, const model_t *currentModel, int lod, vec3_t scale, IHeapAllocator *G2VertSpace, size_t *TransformedVertArray, bool secondTimeAround) { int i; @@ -497,7 +497,7 @@ void G2_TransformSurfaces(int surfaceNum, surfaceInfo_v &rootSList, const mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void*)currentModel, surfaceNum, lod); const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->data.glm->header + sizeof(mdxmHeader_t)); const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); - + // see if we have an override surface in the surface list const surfaceInfo_t *surfOverride = G2_FindOverrideSurface(surfaceNum, rootSList); @@ -619,7 +619,7 @@ void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, } } - memset(g.mTransformedVertsArray, 0,mdxm->numSurfaces * sizeof (size_t)); + memset(g.mTransformedVertsArray, 0,mdxm->numSurfaces * sizeof (size_t)); G2_FindOverrideSurface(-1,g.mSlist); //reset the quick surface override lookup; // recursively call the model surface transform @@ -691,15 +691,15 @@ qboolean G2_SegmentTriangleTest( const vec3_t start, const vec3_t end, vec3_t edgeAC; VectorSubtract(C, A, edgeAC); - VectorSubtract(B, A, returnedNormalT); + VectorSubtract(B, A, returnedNormalT); CrossProduct(returnedNormalT, edgeAC, returnedNormal); - + vec3_t ray; VectorSubtract(end, start, ray); *denom=DotProduct(ray, returnedNormal); - + if (fabs(*denom)0)|| // not accepting back faces (!frontFaces && *denom<0)) //not accepting front faces @@ -709,16 +709,16 @@ qboolean G2_SegmentTriangleTest( const vec3_t start, const vec3_t end, vec3_t toPlane; VectorSubtract(A, start, toPlane); - + float t=DotProduct(toPlane, returnedNormal)/ *denom; - + if (t<0.0f||t>1.0f) { return qfalse; // off segment } - + VectorScale(ray, t, ray); - + VectorAdd(ray, start, returnedPoint); vec3_t edgePA; @@ -729,9 +729,9 @@ qboolean G2_SegmentTriangleTest( const vec3_t start, const vec3_t end, vec3_t edgePC; VectorSubtract(C, returnedPoint, edgePC); - + vec3_t temp; - + CrossProduct(edgePA, edgePB, temp); if (DotProduct(temp, returnedNormal)<0.0f) { @@ -743,12 +743,12 @@ qboolean G2_SegmentTriangleTest( const vec3_t start, const vec3_t end, { return qfalse; // off triangle } - + CrossProduct(edgePB, edgePC, temp); if (DotProduct(temp, returnedNormal)<0.0f) { return qfalse; // off triangle - } + } return qtrue; } @@ -775,7 +775,7 @@ int G2API_GetTime(int argTime); // now we at poly level, check each model space transformed poly against the model world transfomed ray void G2_GorePolys( const mdxmSurface_t *surface, CTraceSurface &TS, const mdxmSurfHierarchy_t *surfInfo) -{ +{ int j; vec3_t basis1; vec3_t basis2; @@ -817,7 +817,7 @@ void G2_GorePolys( const mdxmSurface_t *surface, CTraceSurface &TS, const mdxmSu int numVerts = surface->numVerts; int flags=15; assert(numVerts=0&&tris[j].indexes[0]=0&&tris[j].indexes[1]growDuration != 0); add.mGoreGrowFactor = ( 1.0f - TS.gore->goreScaleStartFraction) / (float)(TS.gore->growDuration); //curscale = (curtime-mGoreGrowStartTime)*mGoreGrowFactor; - add.mGoreGrowOffset = TS.gore->goreScaleStartFraction; + add.mGoreGrowOffset = TS.gore->goreScaleStartFraction; goreSet->mGoreRecords.insert(std::pair(TS.surfaceNum,add)); GoreTagsTemp[std::pair(goreModelIndex,TS.surfaceNum)]=newTag; @@ -1007,7 +1007,7 @@ void G2_GorePolys( const mdxmSurface_t *surface, CTraceSurface &TS, const mdxmSu mdxmVertex_t currentVert = v[GoreIndexCopy[j]]; VectorCopy(currentVert.vertCoords, goreSurface->verts[j].position); goreSurface->verts[j].normal = R_VboPackNormal(currentVert.normal); - + int numWeights = G2_GetVertWeights(¤tVert); float fTotalWeight = 0.0f; for (int w = 0; w < numWeights; w++) @@ -1050,12 +1050,12 @@ static SVertexTemp GoreVerts[MAX_GORE_VERTS]; static bool G2_TracePolys(const mdxmSurface_t *surface, const mdxmSurfHierarchy_t *surfInfo, CTraceSurface &TS) { int j, numTris; - + // whip through and actually transform each vertex const mdxmTriangle_t *tris = (mdxmTriangle_t *) ((byte *)surface + surface->ofsTriangles); const float *verts = (float *)TS.TransformedVertsArray[surface->thisSurfaceIndex]; numTris = surface->numTriangles; - for ( j = 0; j < numTris; j++ ) + for ( j = 0; j < numTris; j++ ) { float face; vec3_t hitPoint, normal; @@ -1074,7 +1074,7 @@ static bool G2_TracePolys(const mdxmSurface_t *surface, const mdxmSurfHierarchy_ CollisionRecord_t &newCol = TS.collRecMap[i]; vec3_t distVect; float x_pos = 0, y_pos = 0; - + newCol.mPolyIndex = j; newCol.mEntityNum = TS.entNum; newCol.mSurfaceIndex = surface->thisSurfaceIndex; @@ -1104,32 +1104,32 @@ static bool G2_TracePolys(const mdxmSurface_t *surface, const mdxmSurfHierarchy_ G2_BuildHitPointST(point1, point1[3], point1[4], point2, point2[3], point2[4], point3, point3[3], point3[4], - hitPoint, &x_pos, &y_pos,newCol.mBarycentricI,newCol.mBarycentricJ); - + hitPoint, &x_pos, &y_pos,newCol.mBarycentricI,newCol.mBarycentricJ); + /* const shader_t *shader = 0; // now, we know what surface this hit belongs to, we need to go get the shader handle so we can get the correct hit location and hit material info - if ( cust_shader ) + if ( cust_shader ) { shader = cust_shader; - } - else if ( skin ) + } + else if ( skin ) { int j; - + // match the surface name to something in the skin file shader = tr.defaultShader; for ( j = 0 ; j < skin->numSurfaces ; j++ ) { // the names have both been lowercased - if ( !strcmp( skin->surfaces[j]->name, surfInfo->name ) ) + if ( !strcmp( skin->surfaces[j]->name, surfInfo->name ) ) { shader = skin->surfaces[j]->shader; break; } } - } - else + } + else { shader = R_GetShaderByHandle( surfInfo->shaderIndex ); } @@ -1143,7 +1143,7 @@ static bool G2_TracePolys(const mdxmSurface_t *surface, const mdxmSurfHierarchy_ newCol.mLocation = *(hitMatReg[shader->hitLocation].loc + ((int)(y_pos * hitMatReg[shader->hitLocation].height) * hitMatReg[shader->hitLocation].width) + ((int)(x_pos * hitMatReg[shader->hitLocation].width))); - Com_Printf("G2_TracePolys hit location: %d\n", newCol.mLocation); + Com_Printf("G2_TracePolys hit location: %d\n", newCol.mLocation); } if (shader->hitMaterial) @@ -1178,7 +1178,7 @@ static bool G2_TracePolys(const mdxmSurface_t *surface, const mdxmSurfHierarchy_ // now we're at poly level, check each model space transformed poly against the model world transfomed ray static bool G2_RadiusTracePolys( - const mdxmSurface_t *surface, + const mdxmSurface_t *surface, CTraceSurface &TS ) { @@ -1224,15 +1224,15 @@ static bool G2_RadiusTracePolys( const float * const verts = (float *)TS.TransformedVertsArray[surface->thisSurfaceIndex]; const int numVerts = surface->numVerts; - + int flags=63; //rayDir/=lengthSquared(raydir); - const float f = VectorLengthSquared(v3RayDir); + const float f = VectorLengthSquared(v3RayDir); v3RayDir[0]/=f; v3RayDir[1]/=f; v3RayDir[2]/=f; - for ( j = 0; j < numVerts; j++ ) + for ( j = 0; j < numVerts; j++ ) { const int pos=j*5; vec3_t delta; @@ -1281,7 +1281,7 @@ static bool G2_RadiusTracePolys( const int numTris = surface->numTriangles; const mdxmTriangle_t * const tris = (mdxmTriangle_t *) ((byte *)surface + surface->ofsTriangles); - for ( j = 0; j < numTris; j++ ) + for ( j = 0; j < numTris; j++ ) { assert(tris[j].indexes[0]>=0&&tris[j].indexes[0]=0&&tris[j].indexes[1]thisSurfaceIndex; @@ -1318,7 +1318,7 @@ static bool G2_RadiusTracePolys( // newCol.mFlags = G2_BACKFACE; // } - //get normal from triangle + //get normal from triangle const float *A = &verts[(tris[j].indexes[0] * 5)]; const float *B = &verts[(tris[j].indexes[1] * 5)]; const float *C = &verts[(tris[j].indexes[2] * 5)]; @@ -1392,7 +1392,7 @@ static void G2_TraceSurfaces(CTraceSurface &TS) const mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface(TS.currentModel, TS.surfaceNum, TS.lod); const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)TS.currentModel->data.glm->header + sizeof(mdxmHeader_t)); const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); - + // see if we have an override surface in the surface list const surfaceInfo_t *surfOverride = G2_FindOverrideSurface(TS.surfaceNum, TS.rootSList); @@ -1422,7 +1422,7 @@ static void G2_TraceSurfaces(CTraceSurface &TS) { // .. then use radius check // - if (G2_RadiusTracePolys(surface, // const mdxmSurface_t *surface, + if (G2_RadiusTracePolys(surface, // const mdxmSurface_t *surface, TS ) && (TS.traceFlags == G2_RETURNONHIT) @@ -1511,11 +1511,11 @@ void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, Colli } // assert(G2_MODEL_OK(&ghoul2[i])); // do we really want to collide with this object? - if (ghoul2[i].mFlags & GHOUL2_NOCOLLIDE) + if (ghoul2[i].mFlags & GHOUL2_NOCOLLIDE) { continue; } - + if (ghoul2[i].mCustomShader && ghoul2[i].mCustomShader != -20) //rww - -20 is a server instance (hack) { cust_shader = (shader_t *)R_GetShaderByHandle( ghoul2[i].mCustomShader ); @@ -1526,7 +1526,7 @@ void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, Colli } // figure out the custom skin thing - if ( ghoul2[i].mSkin > 0 && ghoul2[i].mSkin < tr.numSkins ) + if ( ghoul2[i].mSkin > 0 && ghoul2[i].mSkin < tr.numSkins ) { skin = R_GetSkinByHandle( ghoul2[i].mSkin ); } @@ -1546,7 +1546,7 @@ void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, Colli } #endif //reset the quick surface override lookup - G2_FindOverrideSurface(-1, ghoul2[i].mSlist); + G2_FindOverrideSurface(-1, ghoul2[i].mSlist); #ifdef _G2_GORE CTraceSurface TS(ghoul2[i].mSurfaceRoot, ghoul2[i].mSlist, (model_t *)ghoul2[i].currentModel, lod, rayStart, rayEnd, collRecMap, entNum, i, skin, cust_shader, ghoul2[i].mTransformedVertsArray, eG2TraceType, fRadius, ssize, tsize, theta, shader, &ghoul2[i], gore); @@ -1698,20 +1698,20 @@ qboolean G2_SaveGhoul2Models(CGhoul2Info_v &ghoul2, char **buffer, int *size) int ghoul2BlockSize = (size_t)&ghoul2[0].mTransformedVertsArray - (size_t)&ghoul2[0].mModelindex; // add in count for number of ghoul2 models - *size += 4; + *size += 4; // start out working out the total size of the buffer we need to allocate int i; // Linux GCC is forcing new scoping rules for (i=0; idata.glm->header; surf = (mdxmSurfHierarchy_t *) ( (byte *)mdxm + mdxm->ofsSurfHierarchy ); - for ( int i = 0 ; i < mdxm->numSurfaces ; i++) + for ( int i = 0 ; i < mdxm->numSurfaces ; i++) { if (!Q_stricmp(surfaceName, surf->name)) { @@ -104,7 +104,7 @@ mdxmSurface_t *G2_FindSurface(CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const } return 0; } - + // first find if we already have this surface in the list for (i = slist.size() - 1; i >= 0; i--) { @@ -139,7 +139,7 @@ qboolean G2_SetSurfaceOnOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const c { int surfIndex = -1; surfaceInfo_t temp_slist_entry; - mdxmSurface_t *surf; + mdxmSurface_t *surf; // find the model we want model_t *mod = (model_t *)ghlInfo->currentModel; @@ -149,7 +149,7 @@ qboolean G2_SetSurfaceOnOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const c assert(0); return qfalse; } - + // first find if we already have this surface in the list surf = G2_FindSurface(ghlInfo, slist, surfaceName, &surfIndex); if (surf) @@ -179,7 +179,7 @@ qboolean G2_SetSurfaceOnOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const c { // insert here then because it changed, no need to add an override otherwise temp_slist_entry.offFlags = newflags; temp_slist_entry.surface = surfaceNum; - + slist.push_back(temp_slist_entry); } return qtrue; @@ -203,7 +203,7 @@ void G2_SetSurfaceOnOffFromSkin (CGhoul2Info *ghlInfo, qhandle_t renderSkin) if ( !strcmp( ((shader_t *)skin->surfaces[j]->shader)->name, "*off") ) { G2_SetSurfaceOnOff(ghlInfo, ghlInfo->mSlist, skin->surfaces[j]->name, G2SURFACEFLAG_OFF); } - else + else { int flags; int surfaceNum = G2_IsSurfaceLegal((void *)ghlInfo->currentModel, skin->surfaces[j]->name, &flags); @@ -228,7 +228,7 @@ int G2_IsSurfaceOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const char *sur { return 0; } - + // first find if we already have this surface in the list surf = G2_FindSurface(ghlInfo, slist, surfaceName, &surfIndex); if (surf) @@ -240,7 +240,7 @@ int G2_IsSurfaceOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const char *sur mdxmSurfHierarchy_t *surface = (mdxmSurfHierarchy_t *) ( (byte *)mdxm + mdxm->ofsSurfHierarchy ); - for ( int i = 0 ; i < mdxm->numSurfaces ; i++) + for ( int i = 0 ; i < mdxm->numSurfaces ; i++) { if (!Q_stricmp(surfaceName, surface->name)) { @@ -367,7 +367,7 @@ qboolean G2_SetRootSurface(CGhoul2Info_v &ghoul2, const int modelIndex, const ch G2_FindRecursiveSurface(mod_m, surf, ghoul2[modelIndex].mSlist, activeSurfaces); // now generate the used bone list - CConstructBoneList CBL(ghoul2[modelIndex].mSurfaceRoot, + CConstructBoneList CBL(ghoul2[modelIndex].mSurfaceRoot, activeBones, ghoul2[modelIndex].mSlist, mod_m, @@ -393,8 +393,8 @@ qboolean G2_SetRootSurface(CGhoul2Info_v &ghoul2, const int modelIndex, const ch int boltMod = (ghoul2[i].mModelBoltLink >> MODEL_SHIFT) & MODEL_AND; int boltNum = (ghoul2[i].mModelBoltLink >> BOLT_SHIFT) & BOLT_AND; // if either the bolt list is too small, or the bolt we are pointing at references nothing, remove this model - if (((int)ghoul2[boltMod].mBltlist.size() <= boltNum) || - ((ghoul2[boltMod].mBltlist[boltNum].boneNumber == -1) && + if (((int)ghoul2[boltMod].mBltlist.size() <= boltNum) || + ((ghoul2[boltMod].mBltlist[boltNum].boneNumber == -1) && (ghoul2[boltMod].mBltlist[boltNum].surfaceNumber == -1))) { CGhoul2Info_v *g2i = &ghoul2; @@ -415,7 +415,7 @@ qboolean G2_SetRootSurface(CGhoul2Info_v &ghoul2, const int modelIndex, const ch { CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)entstate->ghoul2); model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(ghoul2[modelIndex].mFileName)); - model_t *mod_a = R_GetModelByHandle(mod_m->mdxm->animIndex); + model_t *mod_a = R_GetModelByHandle(mod_m->mdxm->animIndex); int surf; int flags; int *activeSurfaces, *activeBones; @@ -451,7 +451,7 @@ qboolean G2_SetRootSurface(CGhoul2Info_v &ghoul2, const int modelIndex, const ch G2_FindRecursiveSurface(mod_m, surf, ghoul2[modelIndex].mSlist, activeSurfaces); // now generate the used bone list - CConstructBoneList CBL(ghoul2[modelIndex].mSurfaceRoot, + CConstructBoneList CBL(ghoul2[modelIndex].mSurfaceRoot, activeBones, ghoul2[modelIndex].mSlist, mod_m, @@ -477,8 +477,8 @@ qboolean G2_SetRootSurface(CGhoul2Info_v &ghoul2, const int modelIndex, const ch int boltMod = (ghoul2[i].mModelBoltLink >> MODEL_SHIFT) & MODEL_AND; int boltNum = (ghoul2[i].mModelBoltLink >> BOLT_SHIFT) & BOLT_AND; // if either the bolt list is too small, or the bolt we are pointing at references nothing, remove this model - if ((ghoul2[boltMod].mBltlist.size() <= boltNum) || - ((ghoul2[boltMod].mBltlist[boltNum].boneNumber == -1) && + if ((ghoul2[boltMod].mBltlist.size() <= boltNum) || + ((ghoul2[boltMod].mBltlist[boltNum].boneNumber == -1) && (ghoul2[boltMod].mBltlist[boltNum].surfaceNumber == -1))) { G2API_RemoveGhoul2Model(entstate, i); @@ -595,7 +595,7 @@ int G2_GetSurfaceIndex(CGhoul2Info *ghlInfo, const char *surfaceName) { model_t *mod = (model_t *)ghlInfo->currentModel; int flags; - + return G2_IsSurfaceLegal(mod, surfaceName, &flags); } @@ -632,7 +632,7 @@ int G2_IsSurfaceRendered(CGhoul2Info *ghlInfo, const char *surfaceName, surfaceI //G2 was bug, above comment was accurate, but we don't want the original flags, we want the parent flags G2_IsSurfaceLegal((model_t *)ghlInfo->currentModel, parentSurfInfo->name, &parentFlags); - // now see if we already have overriden this surface in the slist + // now see if we already have overriden this surface in the slist parentSurf = G2_FindSurface(ghlInfo, slist, parentSurfInfo->name, &surfIndex); if (parentSurf) { @@ -643,7 +643,7 @@ int G2_IsSurfaceRendered(CGhoul2Info *ghlInfo, const char *surfaceName, surfaceI if (parentFlags & G2SURFACEFLAG_NODESCENDANTS) { flags |= G2SURFACEFLAG_OFF; - break; + break; } // set up scan of next parent surfNum = parentSurfInfo->parentIndex; @@ -655,7 +655,7 @@ int G2_IsSurfaceRendered(CGhoul2Info *ghlInfo, const char *surfaceName, surfaceI } if ( flags == 0 ) {//it's not being overridden by a parent - // now see if we already have overriden this surface in the slist + // now see if we already have overriden this surface in the slist const mdxmSurface_t *surf = G2_FindSurface(ghlInfo, slist, surfaceName, &surfIndex); if (surf) { diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 87d92988cc..e7264e2abb 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -280,7 +280,7 @@ static void R_Splash() { const GLfloat black[] = { 0.0f, 0.0f, 0.0f, 1.0f }; - qglViewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); + GL_SetViewportAndScissor( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); qglClearBufferfv(GL_COLOR, 0, black); qglClear(GL_DEPTH_BUFFER_BIT); @@ -1204,6 +1204,7 @@ void GL_SetDefaultState( void ) qglEnable(GL_PROGRAM_POINT_SIZE); qglDisable( GL_CULL_FACE ); qglDisable( GL_BLEND ); + glState.blend = false; qglEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); diff --git a/codemp/rd-vanilla/CMakeLists.txt b/codemp/rd-vanilla/CMakeLists.txt index 288997556e..b7909a608a 100644 --- a/codemp/rd-vanilla/CMakeLists.txt +++ b/codemp/rd-vanilla/CMakeLists.txt @@ -99,7 +99,7 @@ set(MPVanillaRendererFiles ${MPVanillaRendererFiles} ${MPVanillaRendererRdCommon set(MPVanillaRendererCommonFiles "${MPDir}/qcommon/matcomp.cpp" "${MPDir}/qcommon/q_shared.cpp" - + ${SharedCommonFiles}) source_group("common" FILES ${MPVanillaRendererCommonFiles}) set(MPVanillaRendererFiles ${MPVanillaRendererFiles} ${MPVanillaRendererCommonFiles}) diff --git a/codemp/rd-vanilla/tr_image.cpp b/codemp/rd-vanilla/tr_image.cpp index 23de173e30..4665ae25d5 100644 --- a/codemp/rd-vanilla/tr_image.cpp +++ b/codemp/rd-vanilla/tr_image.cpp @@ -874,7 +874,7 @@ qboolean RE_RegisterImages_LevelLoadEnd(void) // int iNumImages = AllocatedImages.size(); // more for curiosity, really. - qboolean imageDeleted = qtrue; + qboolean imageDeleted = qfalse; for (AllocatedImages_t::iterator itImage = AllocatedImages.begin(); itImage != AllocatedImages.end(); /* blank */) { qboolean bEraseOccured = qfalse; diff --git a/codemp/rd-vanilla/tr_shader.cpp b/codemp/rd-vanilla/tr_shader.cpp index 5fdc4ea61e..8d1733e5ff 100644 --- a/codemp/rd-vanilla/tr_shader.cpp +++ b/codemp/rd-vanilla/tr_shader.cpp @@ -2373,7 +2373,7 @@ static qboolean ParseShader( const char **text ) // functioned because rgbGen identity doesn't work with setcolor. // // We match against retail version of gfx/menus/radar/arrow_w by calculating - // the hash value of the shader text, and comparing it against a + // the hash value of the shader text, and comparing it against a // precalculated value. if ( shaderHash == RETAIL_ARROW_W_SHADER_HASH && Q_stricmp( shader.name, "gfx/menus/radar/arrow_w" ) == 0 ) diff --git a/codemp/rd-vanilla/tr_shadows.cpp b/codemp/rd-vanilla/tr_shadows.cpp index d5480fc62c..334b5faa77 100644 --- a/codemp/rd-vanilla/tr_shadows.cpp +++ b/codemp/rd-vanilla/tr_shadows.cpp @@ -400,7 +400,7 @@ void RB_DoShadowTessEnd( vec3_t lightPos ) // reenable writing to the color buffer qglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); - + #ifdef _DEBUG_STENCIL_SHADOWS qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL); #endif diff --git a/codemp/server/sv_client.cpp b/codemp/server/sv_client.cpp index 073fbbe6a4..fb2d4418ca 100644 --- a/codemp/server/sv_client.cpp +++ b/codemp/server/sv_client.cpp @@ -716,80 +716,27 @@ void SV_WriteDownloadToClient(client_t *cl, msg_t *msg) int curindex; int rate; int blockspersnap; - int unreferenced = 1; char errorMessage[1024]; - char pakbuf[MAX_QPATH], *pakptr; - int numRefPaks; if (!*cl->downloadName) return; // Nothing being downloaded if(!cl->download) { - qboolean idPack = qfalse; - qboolean missionPack = qfalse; - - // Chop off filename extension. - Com_sprintf(pakbuf, sizeof(pakbuf), "%s", cl->downloadName); - pakptr = strrchr(pakbuf, '.'); - - if(pakptr) - { - *pakptr = '\0'; - - // Check for pk3 filename extension - if(!Q_stricmp(pakptr + 1, "pk3")) - { - const char *referencedPaks = FS_ReferencedPakNames(); - - // Check whether the file appears in the list of referenced - // paks to prevent downloading of arbitrary files. - Cmd_TokenizeStringIgnoreQuotes(referencedPaks); - numRefPaks = Cmd_Argc(); - - for(curindex = 0; curindex < numRefPaks; curindex++) - { - if(!FS_FilenameCompare(Cmd_Argv(curindex), pakbuf)) - { - unreferenced = 0; - - // now that we know the file is referenced, - // check whether it's legal to download it. - missionPack = FS_idPak(pakbuf, "missionpack"); - idPack = missionPack; - idPack = (qboolean)(idPack || FS_idPak(pakbuf, BASEGAME)); - - break; - } - } - } - } + qboolean allowDownload = FS_MV_VerifyDownloadPath( cl->downloadName ) ? qtrue : qfalse; cl->download = 0; // We open the file here if ( !sv_allowDownload->integer || - idPack || unreferenced || + !allowDownload || ( cl->downloadSize = FS_SV_FOpenFileRead( cl->downloadName, &cl->download ) ) < 0 ) { // cannot auto-download file - if(unreferenced) + if( !allowDownload ) { Com_Printf("clientDownload: %d : \"%s\" is not referenced and cannot be downloaded.\n", (int) (cl - svs.clients), cl->downloadName); Com_sprintf(errorMessage, sizeof(errorMessage), "File \"%s\" is not referenced and cannot be downloaded.", cl->downloadName); - } - else if (idPack) { - Com_Printf("clientDownload: %d : \"%s\" cannot download id pk3 files\n", (int) (cl - svs.clients), cl->downloadName); - if(missionPack) - { - Com_sprintf(errorMessage, sizeof(errorMessage), "Cannot autodownload Team Arena file \"%s\"\n" - "The Team Arena mission pack can be found in your local game store.", cl->downloadName); - } - else - { - Com_sprintf(errorMessage, sizeof(errorMessage), "Cannot autodownload id pk3 file \"%s\"", cl->downloadName); - } - } - else if ( !sv_allowDownload->integer ) { + } else if ( !sv_allowDownload->integer ) { Com_Printf("clientDownload: %d : \"%s\" download disabled\n", (int) (cl - svs.clients), cl->downloadName); if (sv_pure->integer) { Com_sprintf(errorMessage, sizeof(errorMessage), "Could not download \"%s\" because autodownloading is disabled on the server.\n\n" diff --git a/codemp/ui/CMakeLists.txt b/codemp/ui/CMakeLists.txt index f44d4fcf4e..1d321430d1 100644 --- a/codemp/ui/CMakeLists.txt +++ b/codemp/ui/CMakeLists.txt @@ -54,7 +54,7 @@ set(MPUICommonFiles "${MPDir}/qcommon/q_shared.h" "${MPDir}/qcommon/qfiles.h" "${MPDir}/qcommon/tags.h" - + ${SharedCommonFiles} ) source_group("common" FILES ${MPUICommonFiles}) @@ -113,14 +113,12 @@ elseif(WIN32) RUNTIME DESTINATION "${JKAInstallDir}/OpenJK" COMPONENT ${JKAMPCoreComponent}) - if (WIN64) - # Don't do this on 32-bit Windows to avoid overwriting - # vanilla JKA's DLLs - install(TARGETS ${MPUI} - RUNTIME - DESTINATION "${JKAInstallDir}/base" - COMPONENT ${JKAMPCoreComponent}) - endif() + + # Use OpenJK modules as default + install(TARGETS ${MPUI} + RUNTIME + DESTINATION "${JKAInstallDir}/base" + COMPONENT ${JKAMPCoreComponent}) else() install(TARGETS ${MPUI} LIBRARY diff --git a/codemp/ui/ui_main.c b/codemp/ui/ui_main.c index 45501d9479..3375301f79 100644 --- a/codemp/ui/ui_main.c +++ b/codemp/ui/ui_main.c @@ -6505,7 +6505,6 @@ static void UI_RunMenuScript(char **args) { UI_UpdateCharacterSkin(); } -#if 0 else if (Q_stricmp(name, "setui_dualforcepower") == 0) { int forcePowerDisable = trap->Cvar_VariableValue("g_forcePowerDisable"); @@ -6540,7 +6539,7 @@ static void UI_RunMenuScript(char **args) } else if (Q_stricmp(name, "dualForcePowers") == 0) { - int dualforcePower,i, forcePowerDisable; + int dualforcePower,i, forcePowerDisable=0; dualforcePower = trap->Cvar_VariableValue("ui_dualforcepower"); if (dualforcePower==0) // All force powers @@ -6598,8 +6597,8 @@ static void UI_RunMenuScript(char **args) int weaponDisable,i; const char *cvarString; - if (uiInfo.gameTypes[ui_netGameType.integer].gtEnum == GT_DUEL || - uiInfo.gameTypes[ui_netGameType.integer].gtEnum == GT_POWERDUEL) + if (uiInfo.gameTypes[ui_netGametype.integer].gtEnum == GT_DUEL || + uiInfo.gameTypes[ui_netGametype.integer].gtEnum == GT_POWERDUEL) { cvarString = "g_duelWeaponDisable"; } @@ -6624,7 +6623,6 @@ static void UI_RunMenuScript(char **args) trap->Cvar_Set(cvarString, va("%i",weaponDisable)); } } -#endif // If this is siege, change all the bots to humans, because we faked it earlier // swapping humans for bots on the menu else if (Q_stricmp(name, "setSiegeNoBots") == 0) @@ -7414,7 +7412,6 @@ static void UI_BuildServerDisplayList(int force) { int i, count, clients, maxClients, ping, game, len, passw/*, visible*/; char info[MAX_STRING_CHARS]; // qboolean startRefresh = qtrue; TTimo: unused - static int numinvisible; int lanSource; if (!(force || uiInfo.uiDC.realTime > uiInfo.serverStatus.nextDisplayRefresh)) { @@ -7440,7 +7437,6 @@ static void UI_BuildServerDisplayList(int force) { lanSource = UI_SourceForLAN(); if (force) { - numinvisible = 0; // clear number of displayed servers uiInfo.serverStatus.numDisplayServers = 0; uiInfo.serverStatus.numPlayersOnServers = 0; @@ -7535,7 +7531,6 @@ static void UI_BuildServerDisplayList(int force) { // done with this server if (ping > 0) { trap->LAN_MarkServerVisible(lanSource, i, qfalse); - numinvisible++; } } } @@ -7705,7 +7700,7 @@ UI_BuildFindPlayerList ================== */ static void UI_BuildFindPlayerList(qboolean force) { - static int numFound, numTimeOuts; + static int numFound; int i, j, resend; serverStatusInfo_t info; char name[MAX_NAME_LENGTH+2]; @@ -7745,7 +7740,6 @@ static void UI_BuildFindPlayerList(qboolean force) { // sizeof(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1]), // "searching %d...", uiInfo.pendingServerStatus.num); numFound = 0; - numTimeOuts++; } for (i = 0; i < MAX_SERVERSTATUSREQUESTS; i++) { // if this pending server is valid @@ -7796,7 +7790,7 @@ static void UI_BuildFindPlayerList(qboolean force) { if (!uiInfo.pendingServerStatus.server[i].valid || uiInfo.pendingServerStatus.server[i].startTime < uiInfo.uiDC.realTime - ui_serverStatusTimeOut.integer) { if (uiInfo.pendingServerStatus.server[i].valid) { - numTimeOuts++; + // timed out } // reset server status request for this address UI_GetServerStatusInfo( uiInfo.pendingServerStatus.server[i].adrstr, NULL ); diff --git a/codemp/ui/ui_shared.c b/codemp/ui/ui_shared.c index f2ed6d56f9..cda2bbc6e6 100644 --- a/codemp/ui/ui_shared.c +++ b/codemp/ui/ui_shared.c @@ -8488,7 +8488,7 @@ static void Item_ApplyHacks( itemDef_t *item ) { } } #endif - + // Fix length of favorite address in createfavorite.menu if ( item->type == ITEM_TYPE_EDITFIELD && item->cvar && !Q_stricmp( item->cvar, "ui_favoriteAddress" ) ) { editFieldDef_t *editField = item->typeData.edit; diff --git a/rv-readme.txt b/rv-readme.txt index 779675e6e3..8c5bfb3916 100644 --- a/rv-readme.txt +++ b/rv-readme.txt @@ -1,4 +1,4 @@ -Activision and Raven are releasing this code for people to learn from and play with. +Activision and Raven are releasing this code for people to learn from and play with. This code is copyright Activision 2003. This source is released under GNU GPLv2. diff --git a/scripts/docker/server.cfg b/scripts/docker/server.cfg index cfdd09e7e7..5bbdc5a213 100644 --- a/scripts/docker/server.cfg +++ b/scripts/docker/server.cfg @@ -1,9 +1,9 @@ // Server Config seta sv_hostname "Sample OpenJK server" -//seta g_motd "woot" +//seta g_motd "woot" //rconpassword "my secret password" -seta sv_maxclients 16 +seta sv_maxclients 16 set timelimit 20 // gametypes // 0 = FFA diff --git a/shared/qcommon/q_string.c b/shared/qcommon/q_string.c index 280de852ff..a4f581f659 100644 --- a/shared/qcommon/q_string.c +++ b/shared/qcommon/q_string.c @@ -109,7 +109,7 @@ void Q_strncpyz( char *dest, const char *src, int destsize ) { assert(src); assert(dest); assert(destsize); - + strncpy( dest, src, destsize-1 ); dest[destsize-1] = 0; } diff --git a/shared/qcommon/safe/files.h b/shared/qcommon/safe/files.h index e82d3964e7..c477ddea35 100644 --- a/shared/qcommon/safe/files.h +++ b/shared/qcommon/safe/files.h @@ -87,7 +87,7 @@ namespace FS { return static_cast< std::size_t >( _end - begin() ); } - + private: // TODO: this should really be const; it's a matter of making FS_ListFiles' result const. char** _begin = nullptr; diff --git a/shared/rd-rend2/MikkTSpace/mikktspace.c b/shared/rd-rend2/MikkTSpace/mikktspace.c index 0342ae0146..8a0b8c66f3 100644 --- a/shared/rd-rend2/MikkTSpace/mikktspace.c +++ b/shared/rd-rend2/MikkTSpace/mikktspace.c @@ -130,7 +130,7 @@ typedef struct { tbool bOrientPreservering; } SGroup; -// +// #define MARK_DEGENERATE 1 #define QUAD_ONE_DEGEN_TRI 2 #define GROUP_WITH_ANY 4 @@ -141,7 +141,7 @@ typedef struct { typedef struct { int FaceNeighbors[3]; SGroup * AssignedGroup[3]; - + // normalized first order face derivatives SVec3 vOs, vOt; float fMagS, fMagT; // original magnitudes @@ -301,13 +301,13 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre // put the degenerate triangles last. DegenPrologue(pTriInfos, piTriListIn, iNrTrianglesIn, iTotTris); - + // evaluate triangle level attributes and neighbor list //printf("gen neighbors list begin\n"); InitTriInfo(pTriInfos, piTriListIn, pContext, iNrTrianglesIn); //printf("gen neighbors list end\n"); - + // based on the 4 rules, identify groups based on connectivity iNrMaxGroups = iNrTrianglesIn*3; pGroups = (SGroup *) malloc(sizeof(SGroup)*iNrMaxGroups); @@ -349,7 +349,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre //printf("gen tspaces begin\n"); bRes = GenerateTSpaces(psTspace, pTriInfos, pGroups, iNrActiveGroups, piTriListIn, fThresCos, pContext); //printf("gen tspaces end\n"); - + // clean up free(pGroups); free(piGroupTrianglesBuffer); @@ -375,7 +375,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre { const int verts = pContext->m_pInterface->m_getNumVerticesOfFace(pContext, f); if (verts!=3 && verts!=4) continue; - + // I've decided to let degenerate triangles and group-with-anythings // vary between left/right hand coordinate systems at the vertices. @@ -415,7 +415,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre free(psTspace); - + return TTRUE; } @@ -544,7 +544,7 @@ static void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SM if (iMaxCountiNrFaces; j++) { @@ -1298,7 +1298,7 @@ static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], con bFound = CompareSubGroups(&tmp_group, &pUniSubGroups[l]); if (!bFound) ++l; } - + // assign tangent space index assert(bFound || l==iUniqueSubGroups); //piTempTangIndices[f*3+index] = iUniqueTspaces+l; @@ -1626,7 +1626,7 @@ static void BuildNeighborsSlow(STriInfo pTriInfos[], const int piTriListIn[], co ++j; } } - + if (!bFound) ++t; } @@ -1703,7 +1703,7 @@ static void QuickSortEdges(SEdge * pSortBuffer, int iLeft, int iRight, const int static void GetEdge(int * i0_out, int * i1_out, int * edgenum_out, const int indices[], const int i0_in, const int i1_in) { *edgenum_out = -1; - + // test if first index is on the edge if (indices[0]==i0_in || indices[0]==i1_in) { @@ -1851,7 +1851,7 @@ static void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriLis const int iSrcOffs=pTriInfos[iTri].iTSpacesOffs; const int iDstVert=pTriInfos[t].vert_num[i]; const int iDstOffs=pTriInfos[t].iTSpacesOffs; - + // copy tspace psTspace[iDstOffs+iDstVert] = psTspace[iSrcOffs+iSrcVert]; } diff --git a/shared/rd-rend2/glsl/bokeh.glsl b/shared/rd-rend2/glsl/bokeh.glsl index c2337c28be..5d53884d5e 100644 --- a/shared/rd-rend2/glsl/bokeh.glsl +++ b/shared/rd-rend2/glsl/bokeh.glsl @@ -56,7 +56,7 @@ void main() tc = var_TexCoords + u_InvTexRes * vec2( -c[3], -c[3]); color += texture(u_TextureMap, tc); tc = var_TexCoords + u_InvTexRes * vec2( -c[4], -c[2]); color += texture(u_TextureMap, tc); tc = var_TexCoords + u_InvTexRes * vec2( -c[5], -c[1]); color += texture(u_TextureMap, tc); - + out_Color = color * 0.04166667 * u_Color; #endif @@ -81,6 +81,6 @@ void main() tc = var_TexCoords + u_InvTexRes * vec2( -c[1], -c[3]); color += texture(u_TextureMap, tc); tc = var_TexCoords + u_InvTexRes * vec2( -c[2], -c[2]); color += texture(u_TextureMap, tc); tc = var_TexCoords + u_InvTexRes * vec2( -c[3], -c[1]); color += texture(u_TextureMap, tc); - + out_Color = color * 0.0625 * u_Color; } diff --git a/shared/rd-rend2/glsl/calclevels4x.glsl b/shared/rd-rend2/glsl/calclevels4x.glsl index 4c9252230e..da58eeea16 100644 --- a/shared/rd-rend2/glsl/calclevels4x.glsl +++ b/shared/rd-rend2/glsl/calclevels4x.glsl @@ -51,12 +51,12 @@ void main() current = GetValues(vec2(-0.5, -1.5), current); current = GetValues(vec2( 0.5, -1.5), current); current = GetValues(vec2( 1.5, -1.5), current); - + current = GetValues(vec2(-1.5, -0.5), current); current = GetValues(vec2(-0.5, -0.5), current); current = GetValues(vec2( 0.5, -0.5), current); current = GetValues(vec2( 1.5, -0.5), current); - + current = GetValues(vec2(-1.5, 0.5), current); current = GetValues(vec2(-0.5, 0.5), current); current = GetValues(vec2( 0.5, 0.5), current); diff --git a/shared/rd-rend2/glsl/depthblur.glsl b/shared/rd-rend2/glsl/depthblur.glsl index ab32f9c000..50fc22cb79 100644 --- a/shared/rd-rend2/glsl/depthblur.glsl +++ b/shared/rd-rend2/glsl/depthblur.glsl @@ -48,10 +48,10 @@ vec4 depthGaussian1D(sampler2D imageMap, sampler2D depthMap, vec2 tex, float zFa #else // if defined(USE_VERTICAL_BLUR) vec2 direction = vec2(0.0, 1.0) * scale; #endif - + float depthCenter = zFar * getLinearDepth(depthMap, tex, zFarDivZNear); vec2 centerSlope = vec2(dFdx(depthCenter), dFdy(depthCenter)) / vec2(dFdx(tex.x), dFdy(tex.y)); - + vec4 result = texture(imageMap, tex) * gauss[0]; float total = gauss[0]; @@ -69,14 +69,14 @@ vec4 depthGaussian1D(sampler2D imageMap, sampler2D depthMap, vec2 tex, float zFa total += gauss[j]; } } - + direction = -direction; - } - + } + return result / total; } void main() -{ +{ out_Color = depthGaussian1D(u_ScreenImageMap, u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y); } diff --git a/shared/rd-rend2/glsl/down4x.glsl b/shared/rd-rend2/glsl/down4x.glsl index 7034cb81e9..b89e7f0172 100644 --- a/shared/rd-rend2/glsl/down4x.glsl +++ b/shared/rd-rend2/glsl/down4x.glsl @@ -25,7 +25,7 @@ void main() { vec4 color; vec2 tc; - + tc = var_TexCoords + u_InvTexRes * vec2(-1.5, -1.5); color = texture(u_TextureMap, tc); tc = var_TexCoords + u_InvTexRes * vec2(-0.5, -1.5); color += texture(u_TextureMap, tc); tc = var_TexCoords + u_InvTexRes * vec2( 0.5, -1.5); color += texture(u_TextureMap, tc); @@ -45,8 +45,8 @@ void main() tc = var_TexCoords + u_InvTexRes * vec2(-0.5, 1.5); color += texture(u_TextureMap, tc); tc = var_TexCoords + u_InvTexRes * vec2( 0.5, 1.5); color += texture(u_TextureMap, tc); tc = var_TexCoords + u_InvTexRes * vec2( 1.5, 1.5); color += texture(u_TextureMap, tc); - + color *= 0.0625; - + out_Color = color; } diff --git a/shared/rd-rend2/glsl/fogpass.glsl b/shared/rd-rend2/glsl/fogpass.glsl index 519e4d9223..14cbd948b4 100644 --- a/shared/rd-rend2/glsl/fogpass.glsl +++ b/shared/rd-rend2/glsl/fogpass.glsl @@ -165,7 +165,7 @@ vec3 DeformNormal( const in vec3 position, const in vec3 normal ) vec3 outNormal = normal; const float scale = 0.98; - + outNormal.x += amplitude * GetNoiseValue( position.x * scale, position.y * scale, diff --git a/shared/rd-rend2/glsl/generic.glsl b/shared/rd-rend2/glsl/generic.glsl index 419eda295a..3a2dcc8165 100644 --- a/shared/rd-rend2/glsl/generic.glsl +++ b/shared/rd-rend2/glsl/generic.glsl @@ -235,7 +235,7 @@ vec3 DeformNormal( const in vec3 position, const in vec3 normal ) vec3 outNormal = normal; const float scale = 0.98; - + outNormal.x += amplitude * GetNoiseValue( position.x * scale, position.y * scale, @@ -283,7 +283,8 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 case TCGEN_ENVIRONMENT_MAPPED: { - vec3 viewer = normalize(u_ViewOrigin - position); + vec3 localOrigin = (inverse(u_ModelMatrix) * vec4(u_ViewOrigin, 1.0)).xyz; + vec3 viewer = normalize(localOrigin - position); vec2 ref = reflect(viewer, normal).yz; tex.s = ref.x * -0.5 + 0.5; tex.t = ref.y * 0.5 + 0.5; @@ -292,7 +293,8 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 case TCGEN_ENVIRONMENT_MAPPED_SP: { - vec3 viewer = normalize(u_ViewOrigin - position); + vec3 localOrigin = (inverse(u_ModelMatrix) * vec4(u_ViewOrigin, 1.0)).xyz; + vec3 viewer = normalize(localOrigin - position); vec2 ref = reflect(viewer, normal).xy; tex.s = ref.x * -0.5; tex.t = ref.y * -0.5; @@ -313,7 +315,7 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 } break; } - + return tex; } #endif @@ -328,10 +330,10 @@ vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) st2.y = st.x * texMatrix.y + (st.y * texMatrix.w + offTurb.y); vec2 offsetPos = vec2(position.x + position.z, position.y); - + vec2 texOffset = sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(phase)); - - return st2 + texOffset * amplitude; + + return st2 + texOffset * amplitude; } #endif @@ -339,7 +341,7 @@ vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) vec4 CalcColor(vec3 position, vec3 normal) { vec4 color = u_VertColor * attr_Color + u_BaseColor; - + if (u_ColorGen == CGEN_LIGHTING_DIFFUSE) { float incoming = clamp(dot(normal, u_ModelLightDir), 0.0, 1.0); @@ -379,14 +381,15 @@ vec4 CalcColor(vec3 position, vec3 normal) return color; } - vec3 viewer = u_ViewOrigin - position; + vec3 localOrigin = (inverse(u_ModelMatrix) * vec4(u_ViewOrigin, 1.0)).xyz; + vec3 viewer = localOrigin - position; if (u_AlphaGen == AGEN_LIGHTING_SPECULAR) { // TODO: Handle specular on player models and misc_model_statics correctly vec3 lightDir = normalize(vec3(-960.0, 1980.0, 96.0) - position); vec3 reflected = -reflect(lightDir, normal); - + color.a = clamp(dot(reflected, normalize(viewer)), 0.0, 1.0); color.a *= color.a; color.a *= color.a; @@ -395,7 +398,7 @@ vec4 CalcColor(vec3 position, vec3 normal) { color.a = clamp(length(viewer) / u_PortalRange, 0.0, 1.0); } - + return color; } #endif @@ -441,7 +444,7 @@ void main() gl_Position = u_viewProjectionMatrix * wsPosition; #if defined(USE_TCGEN) - vec2 tex = GenTexCoords(u_TCGen0, wsPosition.xyz, normal, u_TCGen0Vector0, u_TCGen0Vector1); + vec2 tex = GenTexCoords(u_TCGen0, position.xyz, normal, u_TCGen0Vector0, u_TCGen0Vector1); #else vec2 tex = attr_TexCoord0.st; #endif @@ -464,7 +467,7 @@ void main() else { #if defined(USE_RGBAGEN) - var_Color = CalcColor(wsPosition.xyz, normal); + var_Color = CalcColor(position.xyz, normal); #else var_Color = u_VertColor * attr_Color + u_BaseColor; #endif @@ -546,7 +549,7 @@ float CalcFog(in vec3 viewOrigin, in vec3 position, in Fog fog) // fogPlane is inverted in tr_bsp for some reason. float t = -(fog.plane.w + dot(viewOrigin, -fog.plane.xyz)) / dot(V, -fog.plane.xyz); - + bool intersects = (t > 0.0 && t < 0.995); if (inFog == intersects) return 0.0; diff --git a/shared/rd-rend2/glsl/lightall.glsl b/shared/rd-rend2/glsl/lightall.glsl index 8540284988..01d9163bb7 100644 --- a/shared/rd-rend2/glsl/lightall.glsl +++ b/shared/rd-rend2/glsl/lightall.glsl @@ -157,7 +157,8 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 case TCGEN_ENVIRONMENT_MAPPED: { - vec3 viewer = normalize(u_ViewOrigin - position); + vec3 localOrigin = (inverse(u_ModelMatrix) * vec4(u_ViewOrigin, 1.0)).xyz; + vec3 viewer = normalize(localOrigin - position); vec2 ref = reflect(viewer, normal).yz; tex.s = ref.x * -0.5 + 0.5; tex.t = ref.y * 0.5 + 0.5; @@ -166,7 +167,8 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 case TCGEN_ENVIRONMENT_MAPPED_SP: { - vec3 viewer = normalize(u_ViewOrigin - position); + vec3 localOrigin = (inverse(u_ModelMatrix) * vec4(u_ViewOrigin, 1.0)).xyz; + vec3 viewer = normalize(localOrigin - position); vec2 ref = reflect(viewer, normal).xy; tex.s = ref.x * -0.5; tex.t = ref.y * -0.5; @@ -205,7 +207,7 @@ vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) vec2 texOffset = sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(phase)); - return st2 + texOffset * amplitude; + return st2 + texOffset * amplitude; } #endif @@ -259,7 +261,7 @@ void main() vec4 wsPosition = u_ModelMatrix * vec4(position, 1.0); #if defined(USE_TCGEN) - vec2 texCoords = GenTexCoords(u_TCGen0, wsPosition.xyz, normal, u_TCGen0Vector0, u_TCGen0Vector1); + vec2 texCoords = GenTexCoords(u_TCGen0, position.xyz, normal, u_TCGen0Vector0, u_TCGen0Vector1); #else vec2 texCoords = attr_TexCoord0.st; #endif @@ -476,26 +478,26 @@ float random( const vec2 p ) 23.1406926327792690, // e^pi (Gelfond's constant) 2.6651441426902251); // 2^sqrt(2) (Gelfond-Schneider constant) //return fract( cos( mod( 123456789., 1e-7 + 256. * dot(p,r) ) ) ); - return mod( 123456789., 1e-7 + 256. * dot(p,r) ); + return mod( 123456789., 1e-7 + 256. * dot(p,r) ); } -const vec2 poissonDisk[16] = vec2[16]( - vec2( -0.94201624, -0.39906216 ), - vec2( 0.94558609, -0.76890725 ), - vec2( -0.094184101, -0.92938870 ), - vec2( 0.34495938, 0.29387760 ), - vec2( -0.91588581, 0.45771432 ), - vec2( -0.81544232, -0.87912464 ), - vec2( -0.38277543, 0.27676845 ), - vec2( 0.97484398, 0.75648379 ), - vec2( 0.44323325, -0.97511554 ), - vec2( 0.53742981, -0.47373420 ), - vec2( -0.26496911, -0.41893023 ), - vec2( 0.79197514, 0.19090188 ), - vec2( -0.24188840, 0.99706507 ), - vec2( -0.81409955, 0.91437590 ), - vec2( 0.19984126, 0.78641367 ), - vec2( 0.14383161, -0.14100790 ) +const vec2 poissonDisk[16] = vec2[16]( + vec2( -0.94201624, -0.39906216 ), + vec2( 0.94558609, -0.76890725 ), + vec2( -0.094184101, -0.92938870 ), + vec2( 0.34495938, 0.29387760 ), + vec2( -0.91588581, 0.45771432 ), + vec2( -0.81544232, -0.87912464 ), + vec2( -0.38277543, 0.27676845 ), + vec2( 0.97484398, 0.75648379 ), + vec2( 0.44323325, -0.97511554 ), + vec2( 0.53742981, -0.47373420 ), + vec2( -0.26496911, -0.41893023 ), + vec2( 0.79197514, 0.19090188 ), + vec2( -0.24188840, 0.99706507 ), + vec2( -0.81409955, 0.91437590 ), + vec2( 0.19984126, 0.78641367 ), + vec2( 0.14383161, -0.14100790 ) ); float PCF(const sampler2DArrayShadow shadowmap, const float layer, const vec2 st, const float dist, float PCFScale) @@ -538,7 +540,7 @@ float PCF(const sampler2DArrayShadow shadowmap, const float layer, const vec2 st } mult *= 1.0 / 17.0; #endif - + return mult; } @@ -595,7 +597,7 @@ float sunShadow(in vec3 viewOrigin, in vec3 viewDir, in vec3 biasOffset) } } } - + return result; } #endif @@ -624,10 +626,10 @@ float RayIntersectDisplaceMap(in vec2 inDp, in vec2 ds, in sampler2D normalMap, for(int i = 0; i < linearSearchSteps - 1; ++i) { depth += size; - + // height is flipped before uploaded to the gpu float t = textureGrad(normalMap, dp + ds * depth, dx, dy).r; - + if(depth >= t) { bestDepth = depth; // store best depth @@ -641,10 +643,10 @@ float RayIntersectDisplaceMap(in vec2 inDp, in vec2 ds, in sampler2D normalMap, for(int i = 0; i < binarySearchSteps; ++i) { size *= 0.5; - + // height is flipped before uploaded to the gpu float t = textureGrad(normalMap, dp + ds * depth, dx, dy).r; - + if(depth >= t) { bestDepth = depth; @@ -872,7 +874,7 @@ float pcfShadow(in sampler2DArrayShadow depthMap, in vec3 L, in float distance, { const int samples = 9; const float diskRadius = M_PI / 512.0; - + vec2 polarL = vec2(atan(L.z, L.x), acos(L.y)); float shadow = 0.0; @@ -926,7 +928,7 @@ vec3 CalcDynamicLightContribution( continue; } Light light = u_Lights[i]; - + vec3 L = light.origin.xyz - position; float sqrLightDist = dot(L, L); @@ -1080,7 +1082,7 @@ void main() float shadowValue = sunShadow(u_ViewOrigin, viewDir, normalBias) * NPL; // surfaces not facing the light are always shadowed - + //shadowValue = mix(0.0, shadowValue, dot(N, primaryLightDir) > 0.0); #if defined(SHADOWMAP_MODULATE) @@ -1127,7 +1129,7 @@ void main() specular.rgb = mix(vec3(0.08) * ORMS.w, diffuse.rgb, ORMS.z); diffuse.rgb *= vec3(1.0 - ORMS.z); - + roughness = mix(0.01, 1.0, ORMS.y); AO = min(ORMS.x, AO); #else @@ -1162,7 +1164,7 @@ void main() out_Color.rgb = lightColor * reflectance * (attenuation * NL); out_Color.rgb += ambientColor * diffuse.rgb; - + #if defined(USE_PRIMARY_LIGHT) vec3 L2 = normalize(u_PrimaryLightOrigin.xyz); vec3 H2 = normalize(L2 + E); @@ -1180,18 +1182,18 @@ void main() out_Color.rgb += lightColor * reflectance * NL2; #endif - + out_Color.rgb += CalcDynamicLightContribution(roughness, N, E, u_ViewOrigin, viewDir, NE, diffuse.rgb, specular.rgb, vertexNormal); out_Color.rgb += CalcIBLContribution(roughness, N, E, u_ViewOrigin, viewDir, NE, specular.rgb * AO); #else lightColor = var_Color.rgb; - #if defined(USE_LIGHTMAP) + #if defined(USE_LIGHTMAP) lightColor *= lightmapColor.rgb; #endif out_Color.rgb = diffuse.rgb * lightColor; #endif - + out_Color.a = diffuse.a; #if defined(USE_GLOW_BUFFER) diff --git a/shared/rd-rend2/glsl/prefilterEnvMap.glsl b/shared/rd-rend2/glsl/prefilterEnvMap.glsl index 6df85b582b..273ccf532a 100644 --- a/shared/rd-rend2/glsl/prefilterEnvMap.glsl +++ b/shared/rd-rend2/glsl/prefilterEnvMap.glsl @@ -99,12 +99,12 @@ vec3 PrefilterEnvMap( float Roughness, vec3 R ) float NH = max(dot ( N, H ), 0.0); float HV = max(dot ( H, V ), 0.0); float D = D_GGX(NH, Roughness); - float pdf = (D * NH / (4.0 * HV)) + 0.0001; + float pdf = (D * NH / (4.0 * HV)) + 0.0001; float saTexel = 4.0 * M_PI / (6.0 * CUBEMAP_RESOLUTION * CUBEMAP_RESOLUTION); float saSample = 1.0 / (float(NumSamples) * pdf + 0.0001); - float mipLevel = Roughness == 0.0 ? 0.0 : 0.5 * log2(saSample / saTexel); + float mipLevel = Roughness == 0.0 ? 0.0 : 0.5 * log2(saSample / saTexel); PrefilteredColor += textureLod(u_CubeMap, L, mipLevel).rgb * NoL; TotalWeight += NoL; @@ -119,7 +119,7 @@ void main() // from http://www.codinglabs.net/article_physically_based_rendering.aspx vec3 normal = normalize(vec3(-vector.x, -vector.y, -1.0)); - + if (cubeFace == 0) normal = normalize(vec3(1.0, -vector.y, -vector.x)); else if (cubeFace == 1) @@ -129,13 +129,13 @@ void main() else if (cubeFace == 3) normal = normalize(vec3(vector.x, -1.0, -vector.y)); else if (cubeFace == 4) - normal = normalize(vec3(vector.x, -vector.y, 1.0)); + normal = normalize(vec3(vector.x, -vector.y, 1.0)); float roughness = u_ViewInfo.w; vec3 result = PrefilterEnvMap(roughness, normal); if (roughness == 0.0) result = textureLod(u_CubeMap, normal, 0.0).rgb; - + out_Color = vec4(result, 1.0); } \ No newline at end of file diff --git a/shared/rd-rend2/glsl/refraction.glsl b/shared/rd-rend2/glsl/refraction.glsl index 36063c1513..eebfb51839 100644 --- a/shared/rd-rend2/glsl/refraction.glsl +++ b/shared/rd-rend2/glsl/refraction.glsl @@ -195,7 +195,7 @@ vec3 DeformNormal( const in vec3 position, const in vec3 normal ) vec3 outNormal = normal; const float scale = 0.98; - + outNormal.x += amplitude * GetNoiseValue( position.x * scale, position.y * scale, @@ -252,7 +252,7 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 { tex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1)); } - + return tex; } #endif @@ -267,10 +267,10 @@ vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) st2.y = st.x * texMatrix.y + (st.y * texMatrix.w + offTurb.y); vec2 offsetPos = vec2(position.x + position.z, position.y); - + vec2 texOffset = sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(phase)); - - return st2 + texOffset * amplitude; + + return st2 + texOffset * amplitude; } #endif @@ -278,7 +278,7 @@ vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) vec4 CalcColor(vec3 position, vec3 normal) { vec4 color = u_VertColor * attr_Color + u_BaseColor; - + if (u_ColorGen == CGEN_LIGHTING_DIFFUSE) { float incoming = clamp(dot(normal, u_ModelLightDir), 0.0, 1.0); @@ -292,7 +292,7 @@ vec4 CalcColor(vec3 position, vec3 normal) { vec3 lightDir = normalize(vec3(-960.0, 1980.0, 96.0) - position); vec3 reflected = -reflect(lightDir, normal); - + color.a = clamp(dot(reflected, normalize(viewer)), 0.0, 1.0); color.a *= color.a; color.a *= color.a; @@ -301,7 +301,7 @@ vec4 CalcColor(vec3 position, vec3 normal) { color.a = clamp(length(viewer) / u_PortalRange, 0.0, 1.0); } - + return color; } #endif @@ -396,12 +396,12 @@ void main() vec3 new_pos = (distance * refraction_vec) + wsPosition.xyz; var_RefractPosR = vec4(inverseModel * new_pos, 1.0); var_RefractPosR = MVP * var_RefractPosR; - + refraction_vec = normalize(refract(ws_ViewDir, ws_Normal, etaG)); new_pos = (distance * refraction_vec) + wsPosition.xyz; var_RefractPosG = vec4(inverseModel * new_pos, 1.0); var_RefractPosG = MVP * var_RefractPosG; - + refraction_vec = normalize(refract(ws_ViewDir, ws_Normal, etaB)); new_pos = (distance * refraction_vec) + wsPosition.xyz; var_RefractPosB = vec4(inverseModel * new_pos, 1.0); @@ -467,11 +467,11 @@ vec3 FilmicTonemap(vec3 x) const float TS = 0.20; // Toe Strength const float TAN = 0.01; // Toe Angle Numerator const float TAD = 0.30; // Toe Angle Denominator - + vec3 SSxx = SS * x * x; vec3 LSx = LS * x; vec3 LALSx = LSx * LA; - + return ((SSxx + LALSx + TS * TAN) / (SSxx + LSx + TS * TAD)) - TAN / TAD; } @@ -488,7 +488,7 @@ void main() color.a = var_Color.a; color.rgb *= var_Color.rgb; color.rgb *= u_Color.rgb; - + #if defined(USE_ALPHA_TEST) if (u_AlphaTestType == ALPHA_TEST_GT0) { @@ -516,7 +516,7 @@ void main() vec3 minAvgMax = texture(u_LevelsMap, texG).rgb; vec3 logMinAvgMaxLum = clamp(minAvgMax * 20.0 - 10.0, -u_AutoExposureMinMax.y, -u_AutoExposureMinMax.x); float avgLum = exp2(logMinAvgMaxLum.y); - + color.rgb *= u_ToneMinAvgMaxLinear.y / avgLum; color.rgb = max(vec3(0.0), color.rgb - vec3(u_ToneMinAvgMaxLinear.x)); diff --git a/shared/rd-rend2/glsl/shadowvolume.glsl b/shared/rd-rend2/glsl/shadowvolume.glsl index 58bd7de1aa..5d3d95bd3d 100644 --- a/shared/rd-rend2/glsl/shadowvolume.glsl +++ b/shared/rd-rend2/glsl/shadowvolume.glsl @@ -111,7 +111,7 @@ void main() gl_Position = positions[2]; EmitVertex(); EndPrimitive(); - + // sides gl_Position = positions[0]; EmitVertex(); diff --git a/shared/rd-rend2/glsl/ssao.glsl b/shared/rd-rend2/glsl/ssao.glsl index 53aeb67630..10dcedadad 100644 --- a/shared/rd-rend2/glsl/ssao.glsl +++ b/shared/rd-rend2/glsl/ssao.glsl @@ -49,7 +49,7 @@ float random( const vec2 p ) 23.1406926327792690, // e^pi (Gelfond's constant) 2.6651441426902251); // 2^sqrt(2) (Gelfond-Schneider constant) //return fract( cos( mod( 123456789., 1e-7 + 256. * dot(p,r) ) ) ); - return mod( 123456789., 1e-7 + 256. * dot(p,r) ); + return mod( 123456789., 1e-7 + 256. * dot(p,r) ); } mat2 randomRotation( const vec2 p ) @@ -73,14 +73,14 @@ float ambientOcclusion(sampler2D depthMap, const vec2 tex, const float zFarDivZN float sampleZ = zFar * getLinearDepth(depthMap, tex, zFarDivZNear); vec2 expectedSlope = vec2(dFdx(sampleZ), dFdy(sampleZ)) / vec2(dFdx(tex.x), dFdy(tex.y)); - + if (length(expectedSlope) > 5000.0) return 1.0; - + vec2 offsetScale = vec2(3.0 / sampleZ); - + mat2 rmat = randomRotation(tex); - + int i; for (i = 0; i < 9; i++) { @@ -95,15 +95,15 @@ float ambientOcclusion(sampler2D depthMap, const vec2 tex, const float zFarDivZN result += step(expectedZ - 1.0, sampleZ2); } } - + result *= 0.11111; - + return result; } void main() { float result = ambientOcclusion(u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y); - + out_Color = vec4(vec3(result), 1.0); } diff --git a/shared/rd-rend2/glsl/surface_sprites.glsl b/shared/rd-rend2/glsl/surface_sprites.glsl index 2b0ad2406f..653a7aec77 100644 --- a/shared/rd-rend2/glsl/surface_sprites.glsl +++ b/shared/rd-rend2/glsl/surface_sprites.glsl @@ -77,7 +77,7 @@ void main() vec3( halfWidth, halfWidth, 0.0), vec3(-halfWidth, halfWidth, 0.0), vec3(-halfWidth, -halfWidth, 0.0) -#else +#else vec3( halfWidth, 0.0, 0.0), vec3( halfWidth, 0.0, height), vec3(-halfWidth, 0.0, height), @@ -236,7 +236,7 @@ void main() #else const float alphaTestValue = 0.5; #endif - + out_Color = texture(u_DiffuseMap, var_TexCoords); out_Color.rgb *= var_Color; out_Color.a *= var_Alpha*(1.0 - alphaTestValue) + alphaTestValue; @@ -278,7 +278,7 @@ void main() discard; } #endif - + #if defined(USE_FOG) Fog fog = u_Fogs[u_FogIndex]; float fogFactor = CalcFog(u_ViewOrigin, var_WSPosition, fog); @@ -292,6 +292,6 @@ void main() #if defined(ADDITIVE_BLEND) out_Color.rgb *= out_Color.a; #endif - + out_Glow = vec4(0.0); } diff --git a/shared/rd-rend2/glsl/tonemap.glsl b/shared/rd-rend2/glsl/tonemap.glsl index 58162d7ed2..05b8ba2e63 100644 --- a/shared/rd-rend2/glsl/tonemap.glsl +++ b/shared/rd-rend2/glsl/tonemap.glsl @@ -39,11 +39,11 @@ vec3 FilmicTonemap(vec3 x) const float TS = 0.20; // Toe Strength const float TAN = 0.01; // Toe Angle Numerator const float TAD = 0.30; // Toe Angle Denominator - + vec3 SSxx = SS * x * x; vec3 LSx = LS * x; vec3 LALSx = LSx * LA; - + return ((SSxx + LALSx + TS * TAN) / (SSxx + LSx + TS * TAD)) - TAN / TAD; //return ((x*(SS*x+LA*LS)+TS*TAN)/(x*(SS*x+LS)+TS*TAD)) - TAN/TAD; @@ -96,7 +96,7 @@ void main() vec4 color = texture(u_TextureMap, var_TexCoords) * u_Color; vec3 minAvgMax = texture(u_LevelsMap, var_TexCoords).rgb; vec3 logMinAvgMaxLum = clamp(minAvgMax * 20.0 - 10.0, -u_AutoExposureMinMax.y, -u_AutoExposureMinMax.x); - + float avgLum = exp2(logMinAvgMaxLum.y); //float maxLum = exp2(logMinAvgMaxLum.z); diff --git a/shared/rd-rend2/stb_image.h b/shared/rd-rend2/stb_image.h index a184dddb43..e67c1805d0 100644 --- a/shared/rd-rend2/stb_image.h +++ b/shared/rd-rend2/stb_image.h @@ -6295,7 +6295,7 @@ static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) g->history[idx / 4] = 1; c = &g->color_table[g->codes[code].suffix * 4]; - if (c[3] > 128) { // don't render transparent pixels; + if (c[3] > 128) { // don't render transparent pixels; p[0] = c[2]; p[1] = c[1]; p[2] = c[0]; @@ -6423,9 +6423,9 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i g->history = (stbi_uc *)stbi__malloc(g->w * g->h); if (g->out == 0) return stbi__errpuc("outofmem", "Out of memory"); - // image is treated as "tranparent" at the start - ie, nothing overwrites the current background; + // image is treated as "tranparent" at the start - ie, nothing overwrites the current background; // background colour is only used for pixels that are not rendered first frame, after that "background" - // color refers to teh color that was there the previous frame. + // color refers to teh color that was there the previous frame. memset(g->out, 0x00, 4 * g->w * g->h); memset(g->background, 0x00, 4 * g->w * g->h); // state of the background (starts transparent) memset(g->history, 0x00, g->w * g->h); // pixels that were affected previous frame @@ -6448,7 +6448,7 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i } } else if (dispose == 2) { - // restore what was changed last frame to background before that frame; + // restore what was changed last frame to background before that frame; for (pi = 0; pi < pcount; ++pi) { if (g->history[pi]) { memcpy(&g->out[pi * 4], &g->background[pi * 4], 4); @@ -6456,17 +6456,17 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i } } else { - // This is a non-disposal case eithe way, so just + // This is a non-disposal case eithe way, so just // leave the pixels as is, and they will become the new background // 1: do not dispose // 0: not specified. } - // background is what out is after the undoing of the previou frame; + // background is what out is after the undoing of the previou frame; memcpy(g->background, g->out, 4 * g->w * g->h); } - // clear my history; + // clear my history; memset(g->history, 0x00, g->w * g->h); // pixels that were affected previous frame for (;;) { @@ -6516,13 +6516,13 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i o = stbi__process_gif_raster(s, g); if (o == NULL) return NULL; - // if this was the first frame, + // if this was the first frame, pcount = g->w * g->h; if (first_frame && (g->bgindex > 0)) { // if first frame, any pixel not drawn to gets the background color for (pi = 0; pi < pcount; ++pi) { if (g->history[pi] == 0) { - g->pal[g->bgindex][3] = 255; // just in case it was made transparent, undo that; It will be reset next frame if need be; + g->pal[g->bgindex][3] = 255; // just in case it was made transparent, undo that; It will be reset next frame if need be; memcpy(&g->out[pi * 4], &g->pal[g->bgindex], 4); } } @@ -6624,12 +6624,12 @@ static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, } } while (u != 0); - // free temp buffer; + // free temp buffer; STBI_FREE(g.out); STBI_FREE(g.history); STBI_FREE(g.background); - // do the final conversion after loading everything; + // do the final conversion after loading everything; if (req_comp && req_comp != 4) out = stbi__convert_format(out, 4, req_comp, layers * g.w, g.h); @@ -6654,12 +6654,12 @@ static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req *y = g.h; // moved conversion to after successful load so that the same - // can be done for multiple frames. + // can be done for multiple frames. if (req_comp && req_comp != 4) u = stbi__convert_format(u, 4, req_comp, g.w, g.h); } - // free buffers needed for multiple frame loading; + // free buffers needed for multiple frame loading; STBI_FREE(g.history); STBI_FREE(g.background); diff --git a/shared/rd-rend2/tr_animation.cpp b/shared/rd-rend2/tr_animation.cpp index 63af468f08..1946872f53 100644 --- a/shared/rd-rend2/tr_animation.cpp +++ b/shared/rd-rend2/tr_animation.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA All bones should be an identity orientation to display the mesh exactly as it is specified. -For all other frames, the bones represent the transformation from the +For all other frames, the bones represent the transformation from the orientation of the bone in the base frame to the orientation in this frame. @@ -48,7 +48,7 @@ static int R_MDRCullModel( mdrHeader_t *header, trRefEntity_t *ent ) { int i, frameSize; frameSize = (size_t)( &((mdrFrame_t *)0)->bones[ header->numBones ] ); - + // compute frame pointers newFrame = ( mdrFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.frame); oldFrame = ( mdrFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.oldframe); @@ -62,7 +62,7 @@ static int R_MDRCullModel( mdrHeader_t *header, trRefEntity_t *ent ) { { // Ummm... yeah yeah I know we don't really have an md3 here.. but we pretend // we do. After all, the purpose of mdrs are not that different, are they? - + case CULL_OUT: tr.pc.c_sphere_cull_md3_out++; return CULL_OUT; @@ -106,7 +106,7 @@ static int R_MDRCullModel( mdrHeader_t *header, trRefEntity_t *ent ) { } } } - + // calculate a bounding box in the current coordinate system for (i = 0 ; i < 3 ; i++) { bounds[0][i] = oldFrame->bounds[0][i] < newFrame->bounds[0][i] ? oldFrame->bounds[0][i] : newFrame->bounds[0][i]; @@ -136,7 +136,7 @@ R_MDRComputeFogNum */ int R_MDRComputeFogNum( mdrHeader_t *header, trRefEntity_t *ent ) { - int i, j; + int i; float frameRadius; fog_t *fog; mdrFrame_t *mdrFrame; @@ -146,7 +146,7 @@ int R_MDRComputeFogNum( mdrHeader_t *header, trRefEntity_t *ent ) { if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { return 0; } - + frameSize = (size_t)( &((mdrFrame_t *)0)->bones[ header->numBones ] ); // FIXME: non-normalized axis issues @@ -154,6 +154,7 @@ int R_MDRComputeFogNum( mdrHeader_t *header, trRefEntity_t *ent ) { VectorAdd( ent->e.origin, mdrFrame->localOrigin, localOrigin ); frameRadius = mdrFrame->radius; #ifndef REND2_SP + int j; for (i = 1; i < tr.world->numfogs; i++) { fog = &tr.world->fogs[i]; for (j = 0; j < 3; j++) { @@ -227,25 +228,25 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent, int entityNum ) { qboolean personalModel; header = (mdrHeader_t *)tr.currentModel->data.mdr; - + personalModel = (qboolean)( (ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal || (tr.viewParms.flags & VPF_DEPTHSHADOW))); - + if ( ent->e.renderfx & RF_WRAP_FRAMES ) { ent->e.frame %= header->numFrames; ent->e.oldframe %= header->numFrames; - } - + } + // // Validate the frames so there is no chance of a crash. // This will write directly into the entity structure, so // when the surfaces are rendered, they don't need to be // range checked again. // - if ((ent->e.frame >= header->numFrames) + if ((ent->e.frame >= header->numFrames) || (ent->e.frame < 0) || (ent->e.oldframe >= header->numFrames) || (ent->e.oldframe < 0) ) @@ -263,7 +264,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent, int entityNum ) { cull = R_MDRCullModel (header, ent); if ( cull == CULL_OUT ) { return; - } + } // figure out the current LOD of the model we're rendering, and set the lod pointer respectively. lodnum = R_ComputeLOD(ent); @@ -288,14 +289,14 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent, int entityNum ) { for ( i = 0 ; i < lod->numSurfaces ; i++ ) { - + if(ent->e.customShader) shader = R_GetShaderByHandle(ent->e.customShader); else if(ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins) { skin = R_GetSkinByHandle(ent->e.customSkin); shader = tr.defaultShader; - + for(j = 0; j < skin->numSurfaces; j++) { if (!strcmp(skin->surfaces[j]->name, surface->name)) @@ -361,12 +362,12 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface ) // don't lerp if lerping off, or this is the only frame, or the last frame... // - if (backEnd.currentEntity->e.oldframe == backEnd.currentEntity->e.frame) + if (backEnd.currentEntity->e.oldframe == backEnd.currentEntity->e.frame) { backlerp = 0; // if backlerp is 0, lerping is off and frontlerp is never used frontlerp = 1; - } - else + } + else { backlerp = backEnd.currentEntity->e.backlerp; frontlerp = 1.0f - backlerp; @@ -387,9 +388,9 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface ) indexes = surface->numTriangles * 3; baseIndex = tess.numIndexes; baseVertex = tess.numVertexes; - + // Set up all triangles. - for (j = 0 ; j < indexes ; j++) + for (j = 0 ; j < indexes ; j++) { tess.indexes[baseIndex + j] = baseVertex + triangles[j]; } @@ -398,16 +399,16 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface ) // // lerp all the needed bones // - if ( !backlerp ) + if ( !backlerp ) { // no lerping needed bonePtr = frame->bones; - } - else + } + else { bonePtr = bones; - - for ( i = 0 ; i < header->numBones*12 ; i++ ) + + for ( i = 0 ; i < header->numBones*12 ; i++ ) { ((float *)bonePtr)[i] = frontlerp * ((float *)frame->bones)[i] + backlerp * ((float *)oldFrame->bones)[i]; } @@ -418,7 +419,7 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface ) // numVerts = surface->numVerts; v = (mdrVertex_t *) ((byte *)surface + surface->ofsVerts); - for ( j = 0; j < numVerts; j++ ) + for ( j = 0; j < numVerts; j++ ) { vec3_t tempVert, tempNormal; mdrWeight_t *w; @@ -426,14 +427,14 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface ) VectorClear( tempVert ); VectorClear( tempNormal ); w = v->weights; - for ( k = 0 ; k < v->numWeights ; k++, w++ ) + for ( k = 0 ; k < v->numWeights ; k++, w++ ) { bone = bonePtr + w->boneIndex; - + tempVert[0] += w->boneWeight * ( DotProduct( bone->matrix[0], w->offset ) + bone->matrix[0][3] ); tempVert[1] += w->boneWeight * ( DotProduct( bone->matrix[1], w->offset ) + bone->matrix[1][3] ); tempVert[2] += w->boneWeight * ( DotProduct( bone->matrix[2], w->offset ) + bone->matrix[2][3] ); - + tempNormal[0] += w->boneWeight * DotProduct( bone->matrix[0], v->normal ); tempNormal[1] += w->boneWeight * DotProduct( bone->matrix[1], v->normal ); tempNormal[2] += w->boneWeight * DotProduct( bone->matrix[2], v->normal ); diff --git a/shared/rd-rend2/tr_backend.cpp b/shared/rd-rend2/tr_backend.cpp index 0009e72003..9a7cb50e70 100644 --- a/shared/rd-rend2/tr_backend.cpp +++ b/shared/rd-rend2/tr_backend.cpp @@ -130,15 +130,15 @@ void GL_Cull( int cullType ) { if ( backEnd.projection2D ) cullType = CT_TWO_SIDED; - if ( cullType == CT_TWO_SIDED ) + if ( cullType == CT_TWO_SIDED ) { if ( glState.faceCulling != CT_TWO_SIDED ) qglDisable( GL_CULL_FACE ); - } - else + } + else { qboolean cullFront = (qboolean)(cullType == CT_FRONT_SIDED); - + if ( glState.faceCulling == CT_TWO_SIDED ) qglEnable( GL_CULL_FACE ); @@ -272,12 +272,20 @@ void GL_State( uint32_t stateBits ) break; } - qglEnable( GL_BLEND ); + if (!glState.blend) + { + qglEnable(GL_BLEND); + glState.blend = true; + } qglBlendFunc( srcFactor, dstFactor ); } else { - qglDisable( GL_BLEND ); + if (glState.blend) + { + qglDisable(GL_BLEND); + glState.blend = false; + } } } @@ -476,16 +484,31 @@ void GL_Draw( GLenum primitiveType, int firstVertex, int numVertices, int numIns void GL_SetProjectionMatrix(matrix_t matrix) { Matrix16Copy(matrix, glState.projection); - Matrix16Multiply(glState.projection, glState.modelview, glState.modelviewProjection); + Matrix16Multiply(glState.projection, glState.modelview, glState.modelviewProjection); } - void GL_SetModelviewMatrix(matrix_t matrix) { Matrix16Copy(matrix, glState.modelview); - Matrix16Multiply(glState.projection, glState.modelview, glState.modelviewProjection); + Matrix16Multiply(glState.projection, glState.modelview, glState.modelviewProjection); } +void GL_SetViewportAndScissor(int viewportX, int viewportY, int viewportWidth, int viewportHeight) +{ + if (glState.viewportOrigin[0] == viewportX && + glState.viewportOrigin[1] == viewportY && + glState.viewportSize[0] == viewportWidth && + glState.viewportSize[1] == viewportHeight) + return; + + qglViewport(viewportX, viewportY, viewportWidth, viewportHeight); + qglScissor(viewportX, viewportY, viewportWidth, viewportHeight); + + glState.viewportOrigin[0] = viewportX; + glState.viewportOrigin[1] = viewportY; + glState.viewportSize[0] = viewportWidth; + glState.viewportSize[1] = viewportHeight; +} /* ================ @@ -505,20 +528,8 @@ static void SetViewportAndScissor( void ) { GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix ); // set the window clipping - qglViewport( backEnd.viewParms.viewportX, backEnd.viewParms.viewportY, - backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight ); - - if ( !backEnd.viewParms.scissorX && !backEnd.viewParms.scissorY && - !backEnd.viewParms.scissorWidth && !backEnd.viewParms.scissorHeight ) - { - qglScissor( backEnd.viewParms.viewportX, backEnd.viewParms.viewportY, - backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight ); - } - else - { - qglScissor( backEnd.viewParms.scissorX, backEnd.viewParms.scissorY, - backEnd.viewParms.scissorWidth, backEnd.viewParms.scissorHeight ); - } + GL_SetViewportAndScissor(backEnd.viewParms.viewportX, backEnd.viewParms.viewportY, + backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight); } /* @@ -591,7 +602,7 @@ void RB_BeginDrawingView (void) { (!(backEnd.refdef.rdflags & RDF_NOWORLDMODEL))) { if (tr.world && tr.world->globalFog) - { + { const fog_t *fog = tr.world->globalFog; clearBits |= GL_COLOR_BUFFER_BIT; @@ -1113,7 +1124,7 @@ static void RB_DrawItems( drawItem.draw.params.indexed.numIndices, drawItem.draw.params.indexed.indexType, drawItem.draw.params.indexed.firstIndex, - drawItem.draw.numInstances, + drawItem.draw.numInstances, drawItem.draw.params.indexed.baseVertex); break; } @@ -1521,8 +1532,7 @@ void RB_SetGL2D (void) { } // set 2D virtual screen size - qglViewport( 0, 0, width, height ); - qglScissor( 0, 0, width, height ); + GL_SetViewportAndScissor(0, 0, width, height); Matrix16Ortho(0, 640, 480, 0, 0, 1, matrix); GL_SetProjectionMatrix(matrix); @@ -1615,7 +1625,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte * VectorSet2(texCoords[3], 0.5f / cols, (rows - 0.5f) / rows); GLSL_BindProgram(&tr.textureColorShader); - + GLSL_SetUniformMatrix4x4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite); @@ -1634,7 +1644,7 @@ void RE_UploadCinematic (int cols, int rows, const byte *data, int client, qbool qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); - qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); + qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); } else { if (dirty) { // otherwise, just subimage upload it so that drivers can tell we are going to be changing @@ -1751,7 +1761,7 @@ static const void *RB_StretchPic ( const void *data ) { RB_DrawRotatePic ============= */ -static const void *RB_RotatePic ( const void *data ) +static const void *RB_RotatePic ( const void *data ) { const rotatePicCommand_t *cmd; shader_t *shader; @@ -1844,7 +1854,7 @@ static const void *RB_RotatePic ( const void *data ) RB_DrawRotatePic2 ============= */ -static const void *RB_RotatePic2 ( const void *data ) +static const void *RB_RotatePic2 ( const void *data ) { const rotatePicCommand_t *cmd; shader_t *shader; @@ -2015,8 +2025,7 @@ static const void *RB_PrefilterEnvMap(const void *data) { GL_BindToTMU(tr.renderCubeImage, TB_CUBEMAP); GLSL_BindProgram(&tr.prefilterEnvMapShader); - qglViewport(0, 0, width, height); - qglScissor(0, 0, width, height); + GL_SetViewportAndScissor(0, 0, width, height); vec4_t viewInfo; VectorSet4(viewInfo, 0, level, roughnessMips, level / roughnessMips); @@ -2038,8 +2047,7 @@ static void RB_RenderSSAO() FBO_Bind(tr.quarterFbo[0]); - qglViewport(0, 0, tr.quarterFbo[0]->width, tr.quarterFbo[0]->height); - qglScissor(0, 0, tr.quarterFbo[0]->width, tr.quarterFbo[0]->height); + GL_SetViewportAndScissor(0, 0, tr.quarterFbo[0]->width, tr.quarterFbo[0]->height); GL_State( GLS_DEPTHTEST_DISABLE ); @@ -2052,8 +2060,7 @@ static void RB_RenderSSAO() FBO_Bind(tr.quarterFbo[1]); - qglViewport(0, 0, tr.quarterFbo[1]->width, tr.quarterFbo[1]->height); - qglScissor(0, 0, tr.quarterFbo[1]->width, tr.quarterFbo[1]->height); + GL_SetViewportAndScissor(0, 0, tr.quarterFbo[1]->width, tr.quarterFbo[1]->height); GLSL_BindProgram(&tr.depthBlurShader[0]); @@ -2065,8 +2072,7 @@ static void RB_RenderSSAO() FBO_Bind(tr.screenSsaoFbo); - qglViewport(0, 0, tr.screenSsaoFbo->width, tr.screenSsaoFbo->height); - qglScissor(0, 0, tr.screenSsaoFbo->width, tr.screenSsaoFbo->height); + GL_SetViewportAndScissor(0, 0, tr.screenSsaoFbo->width, tr.screenSsaoFbo->height); GLSL_BindProgram(&tr.depthBlurShader[1]); @@ -2139,21 +2145,21 @@ static void RB_RenderMainPass( drawSurf_t *drawSurfs, int numDrawSurfs ) if (r_drawSun->integer) { - RB_DrawSun(0.1, tr.sunShader); + RB_DrawSun(0.1f, tr.sunShader); } if (r_drawSunRays->integer) { FBO_t *oldFbo = glState.currentFBO; FBO_Bind(tr.sunRaysFbo); - + qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); qglClear( GL_COLOR_BUFFER_BIT ); tr.sunFlareQueryActive[tr.sunFlareQueryIndex] = qtrue; qglBeginQuery(GL_SAMPLES_PASSED, tr.sunFlareQuery[tr.sunFlareQueryIndex]); - RB_DrawSun(0.3, tr.sunFlareShader); + RB_DrawSun(0.3f, tr.sunFlareShader); qglEndQuery(GL_SAMPLES_PASSED); @@ -2519,7 +2525,7 @@ void RB_AddShaderToShaderInstanceUBO(shader_t *shader) shader->ShaderInstanceUboOffset = -1; return; } - + ShaderInstanceBlock shaderInstanceBlock = {}; ComputeDeformValues( shader, @@ -2703,7 +2709,7 @@ static const void *RB_ColorMask(const void *data) backEnd.colorMask[3] = (qboolean)(!cmd->rgba[3]); qglColorMask(cmd->rgba[0], cmd->rgba[1], cmd->rgba[2], cmd->rgba[3]); - + return (const void *)(cmd + 1); } @@ -2716,7 +2722,7 @@ RB_ClearDepth static const void *RB_ClearDepth(const void *data) { const clearDepthCommand_t *cmd = (clearDepthCommand_t *)data; - + // finish any 2D drawing if needed if(tess.numIndexes) RB_EndSurface(); @@ -2743,7 +2749,7 @@ static const void *RB_ClearDepth(const void *data) qglClear(GL_DEPTH_BUFFER_BIT); } - + return (const void *)(cmd + 1); } diff --git a/shared/rd-rend2/tr_cache.cpp b/shared/rd-rend2/tr_cache.cpp index df62c616e6..a1d89de26f 100644 --- a/shared/rd-rend2/tr_cache.cpp +++ b/shared/rd-rend2/tr_cache.cpp @@ -38,7 +38,7 @@ CModelCacheManager::FileCache::iterator CModelCacheManager::FindFile( const char }); } -static const byte FakeGLAFile[] = +static const byte FakeGLAFile[] = { 0x32, 0x4C, 0x47, 0x41, 0x06, 0x00, 0x00, 0x00, 0x2A, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6C, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -86,7 +86,7 @@ qboolean CModelCacheManager::LoadFile( const char *pFileName, void **ppFileBuffe memcpy(pvFakeGLAFile, &FakeGLAFile[0], sizeof (FakeGLAFile)); *ppFileBuffer = pvFakeGLAFile; - return qtrue; + return qtrue; } int len = ri.FS_ReadFile(path, ppFileBuffer); @@ -185,6 +185,7 @@ void CModelCacheManager::DumpNonPure( void ) int iInPak = ri.FS_FileIsInPAK( it->path, &iChecksum ); #else int iInPak = ri.FS_FileIsInPAK(it->path); + iChecksum = it->iPAKChecksum; #endif if( iInPak == -1 || iChecksum != it->iPAKChecksum ) @@ -203,7 +204,7 @@ void CModelCacheManager::DumpNonPure( void ) } } - ri.Printf( PRINT_DEVELOPER, "CCacheManager::DumpNonPure(): Ok\n"); + ri.Printf( PRINT_DEVELOPER, "CCacheManager::DumpNonPure(): Ok\n"); } CModelCacheManager::AssetCache::iterator CModelCacheManager::FindAsset( const char *path ) @@ -270,7 +271,7 @@ qboolean CModelCacheManager::LevelLoadEnd( qboolean deleteUnusedByLevel ) } } - ri.Printf( PRINT_DEVELOPER, S_COLOR_GREEN "CModelCacheManager::LevelLoadEnd(): Ok\n"); + ri.Printf( PRINT_DEVELOPER, S_COLOR_GREEN "CModelCacheManager::LevelLoadEnd(): Ok\n"); return bAtLeastOneModelFreed; } @@ -310,7 +311,7 @@ void CModelCacheManager::StoreShaderRequest( const char *psModelFileName, const assert(0); return; } - + int iNameOffset = psShaderName - (char *)file->pDiskImage; int iPokeOffset = (char*) piShaderIndexPoke - (char *)file->pDiskImage; @@ -343,9 +344,9 @@ void CModelCacheManager::AllocateShaders( const char *psFileName ) int *piShaderPokePtr = (int *)((char*)file->pDiskImage + shader.pokeOffset); shader_t *sh = R_FindShader(psShaderName, lightmapsNone, stylesDefault, qtrue); - if ( sh->defaultShader ) + if ( sh->defaultShader ) *piShaderPokePtr = 0; - else + else *piShaderPokePtr = sh->index; } } diff --git a/shared/rd-rend2/tr_cmds.cpp b/shared/rd-rend2/tr_cmds.cpp index b58eeb5063..0de9658db6 100644 --- a/shared/rd-rend2/tr_cmds.cpp +++ b/shared/rd-rend2/tr_cmds.cpp @@ -41,32 +41,32 @@ void R_PerformanceCounters( void ) { if (r_speeds->integer == 1) { ri.Printf (PRINT_ALL, "%i/%i/%i shaders/batches/surfs %i leafs %i verts %i/%i tris %.2f mtex %.2f dc\n", - backEnd.pc.c_shaders, backEnd.pc.c_surfBatches, backEnd.pc.c_surfaces, tr.pc.c_leafs, backEnd.pc.c_vertexes, - backEnd.pc.c_indexes/3, backEnd.pc.c_totalIndexes/3, - R_SumOfUsedImages()/(1000000.0f), backEnd.pc.c_overDraw / (float)(glConfig.vidWidth * glConfig.vidHeight) ); + backEnd.pc.c_shaders, backEnd.pc.c_surfBatches, backEnd.pc.c_surfaces, tr.pc.c_leafs, backEnd.pc.c_vertexes, + backEnd.pc.c_indexes/3, backEnd.pc.c_totalIndexes/3, + R_SumOfUsedImages()/(1000000.0f), backEnd.pc.c_overDraw / (float)(glConfig.vidWidth * glConfig.vidHeight) ); } else if (r_speeds->integer == 2) { ri.Printf (PRINT_ALL, "(patch) %i sin %i sclip %i sout %i bin %i bclip %i bout\n", - tr.pc.c_sphere_cull_patch_in, tr.pc.c_sphere_cull_patch_clip, tr.pc.c_sphere_cull_patch_out, + tr.pc.c_sphere_cull_patch_in, tr.pc.c_sphere_cull_patch_clip, tr.pc.c_sphere_cull_patch_out, tr.pc.c_box_cull_patch_in, tr.pc.c_box_cull_patch_clip, tr.pc.c_box_cull_patch_out ); ri.Printf (PRINT_ALL, "(md3) %i sin %i sclip %i sout %i bin %i bclip %i bout\n", - tr.pc.c_sphere_cull_md3_in, tr.pc.c_sphere_cull_md3_clip, tr.pc.c_sphere_cull_md3_out, + tr.pc.c_sphere_cull_md3_in, tr.pc.c_sphere_cull_md3_clip, tr.pc.c_sphere_cull_md3_out, tr.pc.c_box_cull_md3_in, tr.pc.c_box_cull_md3_clip, tr.pc.c_box_cull_md3_out ); } else if (r_speeds->integer == 3) { ri.Printf (PRINT_ALL, "viewcluster: %i\n", tr.viewCluster ); } else if (r_speeds->integer == 4) { if ( backEnd.pc.c_dlightVertexes ) { - ri.Printf (PRINT_ALL, "dlight srf:%i culled:%i verts:%i tris:%i\n", + ri.Printf (PRINT_ALL, "dlight srf:%i culled:%i verts:%i tris:%i\n", tr.pc.c_dlightSurfaces, tr.pc.c_dlightSurfacesCulled, backEnd.pc.c_dlightVertexes, backEnd.pc.c_dlightIndexes / 3 ); } - } + } else if (r_speeds->integer == 5 ) { ri.Printf( PRINT_ALL, "zFar: %.0f\n", tr.viewParms.zFar ); } else if (r_speeds->integer == 6 ) { - ri.Printf( PRINT_ALL, "flare adds:%i tests:%i renders:%i\n", + ri.Printf( PRINT_ALL, "flare adds:%i tests:%i renders:%i\n", backEnd.pc.c_flareAdds, backEnd.pc.c_flareTests, backEnd.pc.c_flareRenders ); } else if (r_speeds->integer == 7 ) @@ -245,7 +245,7 @@ R_AddConvolveCubemapsCmd */ void R_AddConvolveCubemapCmd( cubemap_t *cubemap , int cubemapId ) { convolveCubemapCommand_t *cmd; - + if (!tr.registered) { return; } @@ -254,7 +254,7 @@ void R_AddConvolveCubemapCmd( cubemap_t *cubemap , int cubemapId ) { return; } cmd->commandId = RC_CONVOLVECUBEMAP; - + cmd->cubemap = cubemap; cmd->cubemapId = cubemapId; } @@ -363,7 +363,7 @@ void RE_SetColor( const float *rgba ) { RE_RotatePic ============= */ -void RE_RotatePic ( float x, float y, float w, float h, +void RE_RotatePic ( float x, float y, float w, float h, float s1, float t1, float s2, float t2,float a, qhandle_t hShader ) { rotatePicCommand_t *cmd; @@ -392,7 +392,7 @@ void RE_RotatePic ( float x, float y, float w, float h, RE_RotatePic2 ============= */ -void RE_RotatePic2 ( float x, float y, float w, float h, +void RE_RotatePic2 ( float x, float y, float w, float h, float s1, float t1, float s2, float t2,float a, qhandle_t hShader ) { rotatePicCommand_t *cmd; @@ -421,7 +421,7 @@ void RE_RotatePic2 ( float x, float y, float w, float h, RE_StretchPic ============= */ -void RE_StretchPic ( float x, float y, float w, float h, +void RE_StretchPic ( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ) { stretchPicCommand_t *cmd; @@ -453,17 +453,17 @@ void RE_StretchPic ( float x, float y, float w, float h, void R_SetColorMode(GLboolean *rgba, stereoFrame_t stereoFrame, int colormode) { rgba[0] = rgba[1] = rgba[2] = rgba[3] = GL_TRUE; - + if(colormode > MODE_MAX) { if(stereoFrame == STEREO_LEFT) stereoFrame = STEREO_RIGHT; else if(stereoFrame == STEREO_RIGHT) stereoFrame = STEREO_LEFT; - + colormode -= MODE_MAX; } - + if(colormode == MODE_GREEN_MAGENTA) { if(stereoFrame == STEREO_LEFT) @@ -478,7 +478,7 @@ void R_SetColorMode(GLboolean *rgba, stereoFrame_t stereoFrame, int colormode) else if(stereoFrame == STEREO_RIGHT) { rgba[0] = GL_FALSE; - + if(colormode == MODE_RED_BLUE) rgba[1] = GL_FALSE; else if(colormode == MODE_RED_GREEN) @@ -667,9 +667,9 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { if (glConfig.stereoEnabled) { if( !(cmd = (drawBufferCommand_t *)R_GetCommandBuffer(sizeof(*cmd))) ) return; - + cmd->commandId = RC_DRAW_BUFFER; - + if ( stereoFrame == STEREO_LEFT ) { cmd->buffer = (int)GL_BACK_LEFT; } else if ( stereoFrame == STEREO_RIGHT ) { @@ -691,7 +691,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { backEnd.colorMask[2] = qfalse; backEnd.colorMask[3] = qfalse; qglClearColor(0.0f, 0.0f, 0.0f, 1.0f); - + // clear all framebuffers if (tr.msaaResolveFbo) { @@ -714,19 +714,19 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { r_anaglyphMode->modified = qfalse; } - + if(stereoFrame == STEREO_LEFT) { if( !(cmd = (drawBufferCommand_t *)R_GetCommandBuffer(sizeof(*cmd))) ) return; - + if( !(colcmd = (colorMaskCommand_t *)R_GetCommandBuffer(sizeof(*colcmd))) ) return; } else if(stereoFrame == STEREO_RIGHT) { clearDepthCommand_t *cldcmd; - + if( !(cldcmd = (clearDepthCommand_t *)R_GetCommandBuffer(sizeof(*cldcmd))) ) return; @@ -770,7 +770,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { cmd->buffer = (int)GL_BACK; } } - + tr.refdef.stereoFrame = stereoFrame; } diff --git a/shared/rd-rend2/tr_decals.cpp b/shared/rd-rend2/tr_decals.cpp index fe6a7d7f99..87fd5e3097 100644 --- a/shared/rd-rend2/tr_decals.cpp +++ b/shared/rd-rend2/tr_decals.cpp @@ -3,7 +3,7 @@ #define MAX_VERTS_ON_DECAL_POLY 10 #define MAX_DECAL_POLYS 500 -typedef struct decalPoly_s +typedef struct decalPoly_s { int time; int fadetime; @@ -49,7 +49,7 @@ void R_InitDecals( void ) { void RE_FreeDecal( int type, int index ) { if ( !re_decalPolys[type][index].time ) return; - + if ( type == DECALPOLY_TYPE_NORMAL ) { decalPoly_t* fade; @@ -75,7 +75,7 @@ Will allways succeed, even if it requires freeing an old active mark */ decalPoly_t* RE_AllocDecal( int type ) { decalPoly_t *le; - + // See if the cvar changed if ( re_decalPolyTotal[type] > r_markcount->integer ) RE_ClearDecals(); @@ -85,9 +85,9 @@ decalPoly_t* RE_AllocDecal( int type ) { // If it has no time its the first occasion its been used if ( le->time ) { if ( le->time != tr.refdef.time ) { - int i = re_decalPolyHead[type]; + int i = re_decalPolyHead[type]; - // since we are killing one that existed before, make sure we + // since we are killing one that existed before, make sure we // kill all the other marks that belong to the group do { i++; @@ -99,7 +99,7 @@ decalPoly_t* RE_AllocDecal( int type ) { break; RE_FreeDecal ( type, i ); - } while ( i != re_decalPolyHead[type] ); + } while ( i != re_decalPolyHead[type] ); RE_FreeDecal( type, re_decalPolyHead[type] ); } @@ -151,7 +151,7 @@ void RE_AddDecalToScene( qhandle_t decalShader, const vec3_t origin, const vec3_ if ( r_markcount->integer <= 0 && !temporary ) return; - if ( radius <= 0 ) + if ( radius <= 0 ) Com_Error( ERR_FATAL, "RE_AddDecalToScene: called with <= 0 radius" ); // create the texture axis @@ -163,7 +163,7 @@ void RE_AddDecalToScene( qhandle_t decalShader, const vec3_t origin, const vec3_ texCoordScale = 0.5 * 1.0 / radius; // create the full polygon - for ( i = 0 ; i < 3 ; i++ ) + for ( i = 0 ; i < 3 ; i++ ) { originalPoints[0][i] = origin[i] - radius * axis[1][i] - radius * axis[2][i]; originalPoints[1][i] = origin[i] + radius * axis[1][i] - radius * axis[2][i]; @@ -182,7 +182,7 @@ void RE_AddDecalToScene( qhandle_t decalShader, const vec3_t origin, const vec3_ colors[2] = blue * 255; colors[3] = alpha * 255; - for ( i = 0, mf = markFragments ; i < numFragments ; i++, mf++ ) + for ( i = 0, mf = markFragments ; i < numFragments ; i++, mf++ ) { polyVert_t *v; polyVert_t verts[MAX_VERTS_ON_DECAL_POLY]; @@ -193,7 +193,7 @@ void RE_AddDecalToScene( qhandle_t decalShader, const vec3_t origin, const vec3_ if ( mf->numPoints > MAX_VERTS_ON_DECAL_POLY ) mf->numPoints = MAX_VERTS_ON_DECAL_POLY; - for ( j = 0, v = verts ; j < mf->numPoints ; j++, v++ ) + for ( j = 0, v = verts ; j < mf->numPoints ; j++, v++ ) { vec3_t delta; @@ -207,7 +207,7 @@ void RE_AddDecalToScene( qhandle_t decalShader, const vec3_t origin, const vec3_ } // if it is a temporary (shadow) mark, add it immediately and forget about it - if ( temporary ) + if ( temporary ) { RE_AddPolyToScene( decalShader, mf->numPoints, verts ); continue; @@ -231,7 +231,7 @@ void RE_AddDecalToScene( qhandle_t decalShader, const vec3_t origin, const vec3_ R_AddDecals =============== */ -void R_AddDecals( void ) +void R_AddDecals( void ) { int decalPoly; int type; @@ -256,21 +256,21 @@ void R_AddDecals( void ) decalPoly_t* p = &re_decalPolys[type][decalPoly]; if ( p->time ) - { + { if ( p->fadetime ) { int t; // fade all marks out with time t = tr.refdef.time - p->time; - if ( t < DECAL_FADE_TIME ) + if ( t < DECAL_FADE_TIME ) { float fade; int j; fade = 255.0f * (1.0f - ((float)t / DECAL_FADE_TIME)); - - for ( j = 0 ; j < p->poly.numVerts ; j++ ) + + for ( j = 0 ; j < p->poly.numVerts ; j++ ) { p->verts[j].modulate[3] = fade; } diff --git a/shared/rd-rend2/tr_extensions.cpp b/shared/rd-rend2/tr_extensions.cpp index 55bf6c9ffe..83190a3425 100644 --- a/shared/rd-rend2/tr_extensions.cpp +++ b/shared/rd-rend2/tr_extensions.cpp @@ -337,7 +337,7 @@ void GLimp_InitCoreFunctions() GetGLFunction (qglVertexAttrib2f, "glVertexAttrib2f", qtrue); GetGLFunction (qglVertexAttrib3f, "glVertexAttrib3f", qtrue); GetGLFunction (qglVertexAttrib4f, "glVertexAttrib4f", qtrue); - + // Buffer objects qglGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &glRefConfig.uniformBufferOffsetAlignment); qglGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &glRefConfig.maxUniformBlockSize); @@ -518,7 +518,7 @@ void GLimp_InitCoreFunctions() GetGLFunction (qglDeleteSync, "glDeleteSync", qtrue); GetGLFunction (qglClientWaitSync, "glClientWaitSync", qtrue); GetGLFunction (qglWaitSync, "glWaitSync", qtrue); - + } void GLW_InitTextureCompression( void ); @@ -606,7 +606,7 @@ void GLimp_InitExtensions() if( GLimp_HaveExtension( extension ) ) { qboolean loaded = qtrue; - + loaded = (qboolean)(loaded && GetGLFunction (qglTexStorage3D, "glTexStorage3D", qfalse)); loaded = (qboolean)(loaded && GetGLFunction (qglTexStorage1D, "glTexStorage1D", qfalse)); loaded = (qboolean)(loaded && GetGLFunction (qglTexStorage2D, "glTexStorage2D", qfalse)); @@ -626,7 +626,7 @@ void GLimp_InitExtensions() if( GLimp_HaveExtension( extension ) ) { qboolean loaded = qtrue; - + if ( r_arb_buffer_storage->integer ) { loaded = (qboolean)(loaded && GetGLFunction (qglBufferStorage, "glBufferStorage", qfalse)); diff --git a/shared/rd-rend2/tr_extramath.cpp b/shared/rd-rend2/tr_extramath.cpp index 76cf7c5cb5..09b8015d45 100644 --- a/shared/rd-rend2/tr_extramath.cpp +++ b/shared/rd-rend2/tr_extramath.cpp @@ -44,10 +44,10 @@ void Matrix16Identity( matrix_t out ) void Matrix16Copy( const matrix_t in, matrix_t out ) { - out[ 0] = in[ 0]; out[ 4] = in[ 4]; out[ 8] = in[ 8]; out[12] = in[12]; - out[ 1] = in[ 1]; out[ 5] = in[ 5]; out[ 9] = in[ 9]; out[13] = in[13]; - out[ 2] = in[ 2]; out[ 6] = in[ 6]; out[10] = in[10]; out[14] = in[14]; - out[ 3] = in[ 3]; out[ 7] = in[ 7]; out[11] = in[11]; out[15] = in[15]; + out[ 0] = in[ 0]; out[ 4] = in[ 4]; out[ 8] = in[ 8]; out[12] = in[12]; + out[ 1] = in[ 1]; out[ 5] = in[ 5]; out[ 9] = in[ 9]; out[13] = in[13]; + out[ 2] = in[ 2]; out[ 6] = in[ 6]; out[10] = in[10]; out[14] = in[14]; + out[ 3] = in[ 3]; out[ 7] = in[ 7]; out[11] = in[11]; out[15] = in[15]; } void Matrix16Multiply( const matrix_t in1, const matrix_t in2, matrix_t out ) @@ -140,7 +140,7 @@ void Matrix16SimpleInverse( const matrix_t in, matrix_t out) { vec3_t v; float invSqrLen; - + VectorCopy(in + 0, v); invSqrLen = 1.0f / DotProduct(v, v); VectorScale(v, invSqrLen, v); out[ 0] = v[0]; out[ 4] = v[1]; out[ 8] = v[2]; out[12] = -DotProduct(v, &in[12]); @@ -167,7 +167,7 @@ qboolean SpheresIntersect(vec3_t origin1, float radius1, vec3_t origin2, float r { float radiusSum = radius1 + radius2; vec3_t diff; - + VectorSubtract(origin1, origin2, diff); if (DotProduct(diff, diff) <= radiusSum * radiusSum) @@ -202,7 +202,7 @@ int NextPowerOfTwo(int in) unsigned short FloatToHalf(float in) { unsigned short out; - + union { float f; diff --git a/shared/rd-rend2/tr_fbo.cpp b/shared/rd-rend2/tr_fbo.cpp index 80a395ed49..0b5a95f7be 100644 --- a/shared/rd-rend2/tr_fbo.cpp +++ b/shared/rd-rend2/tr_fbo.cpp @@ -344,7 +344,7 @@ void FBO_Bind(FBO_t * fbo) { if (glState.currentFBO == fbo) return; - + if (r_logFile->integer) { // don't just call LogComment, or we will get a call to va() every frame! @@ -415,7 +415,7 @@ void FBO_Init(void) { ri.Cvar_SetValue("r_ext_framebuffer_multisample", (float)multisample); } - + // only create a render FBO if we need to resolve MSAA or do HDR // otherwise just render straight to the screen (tr.renderFbo = NULL) if (multisample) @@ -819,8 +819,7 @@ void FBO_BlitFromTexture(struct image_s *src, vec4i_t inSrcBox, vec2_t inSrcTexS height = glConfig.vidHeight; } - qglViewport( 0, 0, width, height ); - qglScissor( 0, 0, width, height ); + GL_SetViewportAndScissor(0, 0, width, height); Matrix16Ortho(0, width, height, 0, 0, 1, projection); @@ -844,7 +843,7 @@ void FBO_BlitFromTexture(struct image_s *src, vec4i_t inSrcBox, vec2_t inSrcTexS GL_State( blend ); GLSL_BindProgram(shaderProgram); - + GLSL_SetUniformMatrix4x4(shaderProgram, UNIFORM_MODELVIEWPROJECTIONMATRIX, projection); GLSL_SetUniformVec4(shaderProgram, UNIFORM_COLOR, color); GLSL_SetUniformVec2(shaderProgram, UNIFORM_INVTEXRES, invTexRes); diff --git a/shared/rd-rend2/tr_flares.cpp b/shared/rd-rend2/tr_flares.cpp index be6d4120e1..3a4637d81a 100644 --- a/shared/rd-rend2/tr_flares.cpp +++ b/shared/rd-rend2/tr_flares.cpp @@ -185,7 +185,7 @@ void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t // fade the intensity of the flare down as the // light surface turns away from the viewer - VectorScale( f->color, d, f->color ); + VectorScale( f->color, d, f->color ); // save info needed to test f->windowX = backEnd.viewParms.viewportX + window[0]; @@ -217,7 +217,7 @@ void RB_AddDlightFlares( void ) { if(fog) { - // find which fog volume the light is in + // find which fog volume the light is in for ( j = 1 ; j < tr.world->numfogs ; j++ ) { fog = &tr.world->fogs[j]; for ( k = 0 ; k < 3 ; k++ ) { @@ -279,7 +279,7 @@ void RB_TestFlare( flare_t *f ) { FBO_Bind(oldFbo); } - screenZ = backEnd.viewParms.projectionMatrix[14] / + screenZ = backEnd.viewParms.projectionMatrix[14] / ( ( 2*depth - 1 ) * backEnd.viewParms.projectionMatrix[11] - backEnd.viewParms.projectionMatrix[10] ); visible = (qboolean)(( -f->eyeZ - -screenZ ) < 24); @@ -291,7 +291,7 @@ void RB_TestFlare( flare_t *f ) { } fade = ( ( backEnd.refdef.time - f->fadeTime ) / 500.0f ); } else { - // Dont fade out when flare is occluded. Will result in the ability to see + // Dont fade out when flare is occluded. Will result in the ability to see // flares through surfaces on high movement speeds /*if ( f->visible ) { f->visible = qfalse; diff --git a/shared/rd-rend2/tr_ghoul2.cpp b/shared/rd-rend2/tr_ghoul2.cpp index 409dc613f6..f730b2dafd 100644 --- a/shared/rd-rend2/tr_ghoul2.cpp +++ b/shared/rd-rend2/tr_ghoul2.cpp @@ -1,4 +1,4 @@ -#include "client/client.h" //FIXME!! EVIL - just include the definitions needed +#include "client/client.h" //FIXME!! EVIL - just include the definitions needed #include "tr_local.h" #include "qcommon/matcomp.h" #include "qcommon/qcommon.h" @@ -121,8 +121,8 @@ qboolean G2_SetupModelPointers(CGhoul2Info_v &ghoul2); extern cvar_t *r_Ghoul2AnimSmooth; extern cvar_t *r_Ghoul2UnSqashAfterSmooth; -static const mdxaBone_t identityMatrix = -{ +static const mdxaBone_t identityMatrix = +{ { { 0.0f, -1.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f, 0.0f }, @@ -170,7 +170,7 @@ void Mat3x4_Multiply(mdxaBone_t *out, const mdxaBone_t *in2, const mdxaBone_t *i const float m21 = in->matrix[2][1]; const float m22 = in->matrix[2][2]; const float m23 = in->matrix[2][3]; - + // first row of out out->matrix[0][0] = (n00 * m00) + (n01 * m10) + (n02 * m20); out->matrix[0][1] = (n00 * m01) + (n01 * m11) + (n02 * m21); @@ -275,7 +275,7 @@ class CConstructBoneList int *boneUsedList; surfaceInfo_v &rootSList; model_t *currentModel; - boneInfo_v &boneList; + boneInfo_v &boneList; CConstructBoneList( int initsurfaceNum, @@ -398,9 +398,9 @@ class CBoneCache } public: - int frameSize; - const mdxaHeader_t *header; - const model_t *mod; + int frameSize; + const mdxaHeader_t *header; + const model_t *mod; // these are split for better cpu cache behavior std::vector mBones; @@ -413,7 +413,7 @@ class CBoneCache int mCurrentTouch; int mCurrentTouchRender; - int mLastTouch; + int mLastTouch; int mLastLastTouch; // for render smoothing @@ -443,7 +443,7 @@ class CBoneCache { assert(amod); assert(aheader); - + Com_Memset(boneMatrices, 0, sizeof(boneMatrices)); int numBones = header->numBones; @@ -868,7 +868,7 @@ class CRenderSurface All bones should be an identity orientation to display the mesh exactly as it is specified. -For all other frames, the bones represent the transformation from the +For all other frames, the bones represent the transformation from the orientation of the bone in the base frame to the orientation in this frame. @@ -898,7 +898,7 @@ static int R_GCullModel( trRefEntity_t *ent ) { largestScale = 1; } - // cull bounding sphere + // cull bounding sphere switch ( R_CullLocalPointAndRadius( vec3_origin, ent->e.radius * largestScale) ) { case CULL_OUT: @@ -925,7 +925,7 @@ R_AComputeFogNum */ static int R_GComputeFogNum( trRefEntity_t *ent ) { - int i, j; + int i; float frameRadius; fog_t *fog; vec3_t localOrigin; @@ -937,6 +937,7 @@ static int R_GComputeFogNum( trRefEntity_t *ent ) { VectorCopy(ent->e.origin, localOrigin); frameRadius = ent->e.radius; #ifndef REND2_SP + int j; for ( i = 1 ; i < tr.world->numfogs ; i++ ) { fog = &tr.world->fogs[i]; for ( j = 0 ; j < 3 ; j++ ) { @@ -988,7 +989,7 @@ static int R_GComputeFogNum( trRefEntity_t *ent ) { } // work out lod for this entity. -static int G2_ComputeLOD( trRefEntity_t *ent, const model_t *currentModel, int lodBias ) +static int G2_ComputeLOD( trRefEntity_t *ent, const model_t *currentModel, int lodBias ) { float flod, lodscale; float projectedRadius; @@ -999,7 +1000,7 @@ static int G2_ComputeLOD( trRefEntity_t *ent, const model_t *currentModel, int l return(0); } - if ( r_lodbias->integer > lodBias ) + if ( r_lodbias->integer > lodBias ) { lodBias = r_lodbias->integer; } @@ -1024,12 +1025,12 @@ static int G2_ComputeLOD( trRefEntity_t *ent, const model_t *currentModel, int l // we reduce the radius to make the LOD match other model types which use // the actual bound box size - if ( projectedRadius != 0 ) + if ( projectedRadius != 0 ) { lodscale = (r_lodscale->value+r_autolodscalevalue->value); - if ( lodscale > 20 ) + if ( lodscale > 20 ) { - lodscale = 20; + lodscale = 20; } else if ( lodscale < 0 ) { @@ -1056,7 +1057,7 @@ static int G2_ComputeLOD( trRefEntity_t *ent, const model_t *currentModel, int l lod += lodBias; - + if ( lod >= currentModel->numLods ) lod = currentModel->numLods - 1; if ( lod < 0 ) @@ -1095,15 +1096,15 @@ void G2_CreateQuaterion(mdxaBone_t *mat, vec4_t quat) // Depending on this, calculate the following: if ( mat->matrix[0][0] > mat->matrix[1][1] && mat->matrix[0][0] > mat->matrix[2][2] ) { - // Column 0: + // Column 0: s = sqrt( 1.0 + mat->matrix[0][0] - mat->matrix[1][1] - mat->matrix[2][2])* 2; quat[0] = 0.25 * s; quat[1] = (mat->matrix[0][1] + mat->matrix[1][0] ) / s; quat[2] = (mat->matrix[2][0] + mat->matrix[0][2] ) / s; quat[3] = (mat->matrix[1][2] - mat->matrix[2][1] ) / s; - + } else if ( mat->matrix[1][1] > mat->matrix[2][2] ) { - // Column 1: + // Column 1: s = sqrt( 1.0 + mat->matrix[1][1] - mat->matrix[0][0] - mat->matrix[2][2] ) * 2; quat[0] = (mat->matrix[0][1] + mat->matrix[1][0] ) / s; quat[1] = 0.25 * s; @@ -1195,7 +1196,7 @@ void G2_TimingModel( time = (bone.pauseTime - bone.startTime) / 50.0f; } else - { + { time = (currentTime - bone.startTime) / 50.0f; } @@ -1209,7 +1210,7 @@ void G2_TimingModel( if ( numFramesInAnim != 0 ) { // did we run off the end? - if ( (animSpeed > 0.0f && newLerpFrame > (endFrame - 1)) || + if ( (animSpeed > 0.0f && newLerpFrame > (endFrame - 1)) || (animSpeed < 0.0f && newLerpFrame < (endFrame + 1)) ) { // yep - decide what to do @@ -1348,7 +1349,7 @@ void G2_TimingModel( if (newFrame >= (int)endFrame) { // we only want to lerp with the first frame of the anim if - // we are looping + // we are looping if (bone.flags & BONE_ANIM_OVERRIDE_LOOP) { newFrame = bone.startFrame; @@ -1381,7 +1382,7 @@ void G2_TimingModel( if (newFrame < endFrame+1) { // we only want to lerp with the first frame of the - // anim if we are looping + // anim if we are looping if (bone.flags & BONE_ANIM_OVERRIDE_LOOP) { newFrame = bone.startFrame; @@ -1510,7 +1511,7 @@ void G2_RagGetAnimMatrix( boneInfo_t &pbone = ghoul2.mBlist[parentBlistIndex]; // this should have been calc'd in the recursive call - assert(pbone.hasAnimFrameMatrix == frame); + assert(pbone.hasAnimFrameMatrix == frame); Mat3x4_Multiply(&bone.animFrameMatrix, &pbone.animFrameMatrix, &animMatrix); @@ -1572,7 +1573,7 @@ static void G2_TransformBone( int child, CBoneCache& BC ) // we found a bone in the list - we need to override something here. boneInfo_t& bone = boneList[boneListIndex]; int boneFlags = bone.flags; - + // do we override the rotational angles? if ( boneFlags & BONE_ANGLES_TOTAL ) { @@ -1721,7 +1722,7 @@ static void G2_TransformBone( int child, CBoneCache& BC ) assert(child >=0 && child < BC.header->numBones); // decide where the transformed bone is going - + // lerp this bone - use the temp space on the ref entity to put the bone // transforms into if ( !TB.backlerp ) @@ -1733,7 +1734,7 @@ static void G2_TransformBone( int child, CBoneCache& BC ) mdxaBone_t newFrameBone; mdxaBone_t currentFrameBone; UnCompressBone(newFrameBone.matrix, child, BC.header, TB.newFrame); - UnCompressBone(currentFrameBone.matrix, child, BC.header, TB.currentFrame); + UnCompressBone(currentFrameBone.matrix, child, BC.header, TB.currentFrame); Mat3x4_Lerp(¤tBone, &newFrameBone, ¤tFrameBone, TB.backlerp); } @@ -1785,8 +1786,8 @@ static void G2_TransformBone( int child, CBoneCache& BC ) // are doing post mults to compensate. mdxaBone_t temp = firstPass * skel->BasePoseMat; const float matrixScale = VectorLength((float*)&temp); - mdxaBone_t toMatrix = - { + mdxaBone_t toMatrix = + { { { 1.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f }, @@ -1975,7 +1976,7 @@ static void G2_TransformGhoulBones( #endif } ghoul2.mBoneCache->mod=currentModel; - ghoul2.mBoneCache->header=aHeader; + ghoul2.mBoneCache->header=aHeader; assert(ghoul2.mBoneCache->mBones.size()==(unsigned)aHeader->numBones); ghoul2.mBoneCache->mSmoothingActive=false; @@ -2074,7 +2075,7 @@ static void G2_TransformGhoulBones( //====================================================================== // -// Surface Manipulation code +// Surface Manipulation code #ifndef REND2_SP // We've come across a surface that's designated as a bolt surface, process it and put it in the appropriate bolt place @@ -2409,27 +2410,27 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum // if this surface is not off, add it to the shader render list if (!offFlags) { - if ( RS.cust_shader ) + if ( RS.cust_shader ) { shader = RS.cust_shader; - } - else if ( RS.skin ) + } + else if ( RS.skin ) { int j; - + // match the surface name to something in the skin file shader = R_GetShaderByHandle(surfInfo->shaderIndex); for ( j = 0 ; j < RS.skin->numSurfaces ; j++ ) { // the names have both been lowercased - if ( !strcmp( RS.skin->surfaces[j]->name, surfInfo->name ) ) + if ( !strcmp( RS.skin->surfaces[j]->name, surfInfo->name ) ) { shader = (shader_t*)RS.skin->surfaces[j]->shader; break; } } - } - else + } + else { shader = R_GetShaderByHandle( surfInfo->shaderIndex ); } @@ -2443,7 +2444,7 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum int cubemapIndex = R_CubemapForPoint(ent->e.origin); // don't add third_person objects if not viewing through a portal - if ( !RS.personalModel ) + if ( !RS.personalModel ) { // set the surface info to point at the where the transformed bone // list is going to be for when the surface gets rendered out @@ -2575,7 +2576,7 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum R_AddDrawSurf((surfaceType_t *)newSurf, entityNum, tr.projectionShadowShader, 0, qfalse, qfalse, 0); } } - + // if we are turning off all descendants, then stop this recursion now if (offFlags & G2SURFACEFLAG_NODESCENDANTS) { @@ -2642,7 +2643,7 @@ void ProcessModelBoltSurfaces( G2_ProcessSurfaceBolt(bonePtr, surface, boltNum, boltList, surfOverride, currentModel); } } - + // if we are turning off all descendants, then stop this recursion now if (offFlags & G2SURFACEFLAG_NODESCENDANTS) { @@ -2722,14 +2723,14 @@ void G2_ConstructUsedBoneList(CConstructBoneList &CBL) } // now we need to ensure that the parents of this bone are actually active... - // + // int iParentBone = skel->parent; while (iParentBone != -1) - { + { if (CBL.boneUsedList[iParentBone]) // no need to go higher break; CBL.boneUsedList[iParentBone] = 1; - skel = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[iParentBone]); + skel = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[iParentBone]); iParentBone = skel->parent; } } @@ -2897,13 +2898,13 @@ void G2_ProcessSurfaceBolt2( const mdxmTriangle_t *originalTriangleIndexes = (mdxmTriangle_t *)((byte*)originalSurf + originalSurf->ofsTriangles); - // get the original polys indexes + // get the original polys indexes const int index0 = originalTriangleIndexes[polyNumber].indexes[0]; const int index1 = originalTriangleIndexes[polyNumber].indexes[1]; const int index2 = originalTriangleIndexes[polyNumber].indexes[2]; // decide where the original verts are - const mdxmVertex_t *surfVerts = + const mdxmVertex_t *surfVerts = (mdxmVertex_t *)((byte *)originalSurf + originalSurf->ofsVerts); const mdxmVertex_t *verts[3] = { surfVerts + index0, @@ -2924,7 +2925,7 @@ void G2_ProcessSurfaceBolt2( // was hit originally const int iNumWeights = G2_GetVertWeights(verts[i]); float fTotalWeight = 0.0f; - for ( int k = 0 ; k < iNumWeights ; k++ ) + for ( int k = 0 ; k < iNumWeights ; k++ ) { const int iBoneIndex = G2_GetVertBoneIndex(verts[i], k); const float fBoneWeight = G2_GetVertBoneWeight( @@ -2999,13 +3000,13 @@ void G2_ProcessSurfaceBolt2( (const mdxmVertex_t *)((byte *)surface + surface->ofsVerts); const int *piBoneReferences = (const int*)((byte *)surface + surface->ofsBoneReferences); - for ( int j = 0; j < 3; j++ ) + for ( int j = 0; j < 3; j++ ) { VectorClear(pTri[j]); const int iNumWeights = G2_GetVertWeights( v ); float fTotalWeight = 0.0f; - for ( int k = 0 ; k < iNumWeights ; k++) + for ( int k = 0 ; k < iNumWeights ; k++) { const int iBoneIndex = G2_GetVertBoneIndex(v, k); const float fBoneWeight = @@ -3019,7 +3020,7 @@ void G2_ProcessSurfaceBolt2( pTri[j][2] += fBoneWeight * (DotProduct(bone.matrix[2], v->vertCoords) + bone.matrix[2][3]); } - + v++; } @@ -3168,7 +3169,7 @@ static void RootMatrix( mdxaBone_t bolt; mdxaBone_t tempMatrix; - G2_ConstructGhoulSkeleton(ghoul2, time, false, scale); + G2_ConstructGhoulSkeleton(ghoul2, time, false, scale); G2_GetBoltMatrixLow(ghoul2[i], ghoul2[i].mNewOrigin, scale, bolt); tempMatrix.matrix[0][0] = 1.0f; @@ -3230,7 +3231,7 @@ void R_AddGhoulSurfaces( trRefEntity_t *ent, int entityNum ) // cull the entire model if merged bounding box of both frames is outside // the view frustum. int cull = R_GCullModel(ent); - if ( cull == CULL_OUT ) + if ( cull == CULL_OUT ) { return; } @@ -3271,7 +3272,7 @@ void R_AddGhoulSurfaces( trRefEntity_t *ent, int entityNum ) { continue; } - + if ( (g2Info.mFlags & (GHOUL2_NOMODEL | GHOUL2_NORENDER)) != 0 ) { continue; @@ -3462,7 +3463,7 @@ void G2_ConstructGhoulSkeleton( #ifdef G2_PERFORMANCE_ANALYSIS G2Time_G2_ConstructGhoulSkeleton += G2PerformanceTimer_G2_ConstructGhoulSkeleton.End(); #endif -} +} static inline float G2_GetVertBoneWeightNotSlow( const mdxmVertex_t *pVert, const int iWeightNum) { @@ -3601,7 +3602,7 @@ void RB_FillBoneBlock(CRenderableSurface *surf, mat3x4_t *outMatrices) sizeof(surf->boneCache->boneMatrices)); } -void RB_SurfaceGhoul( CRenderableSurface *surf ) +void RB_SurfaceGhoul( CRenderableSurface *surf ) { mdxmVBOMesh_t *surface = surf->vboMesh; @@ -3656,8 +3657,8 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) lFade = Q_ftol(254.4f*(surf->fade - 2.0f)); if (lFade < tess.svars.colors[tess.firstIndex][0]) { //don't set it unless the fade is less than the current r value (to avoid brightening suddenly before we start fading) - tess.svars.colors[tess.firstIndex][0] = - tess.svars.colors[tess.firstIndex][1] = + tess.svars.colors[tess.firstIndex][0] = + tess.svars.colors[tess.firstIndex][1] = tess.svars.colors[tess.firstIndex][2] = lFade; } tess.svars.colors[tess.firstIndex][3] = lFade; @@ -3762,7 +3763,7 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) glState.skeletalAnimation = qtrue; } - + /* ================= R_LoadMDXM - load a Ghoul 2 Mesh file @@ -4133,11 +4134,11 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & int version; int size; mdxmSurfHierarchy_t *surfInfo; - + pinmodel= (mdxmHeader_t *)buffer; // // read some fields from the binary, but only LittleLong() them when we know this wasn't an already-cached model... - // + // version = (pinmodel->version); size = (pinmodel->ofsEnd); @@ -4154,8 +4155,8 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & } mod->type = MOD_MDXM; - mod->dataSize += size; - + mod->dataSize += size; + qboolean bAlreadyFound = qfalse; mdxm = (mdxmHeader_t*)CModelCache->Allocate(size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM); mod->data.glm = (mdxmData_t *)Hunk_Alloc(sizeof (mdxmData_t), h_low); @@ -4185,7 +4186,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & LL(mdxm->ofsSurfHierarchy); LL(mdxm->ofsEnd); } - + // first up, go load in the animation file we need that has the skeletal // animation info for this model mdxm->animIndex = RE_RegisterModel(va("%s.gla", mdxm->animName)); @@ -4217,7 +4218,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & #endif - if (!mdxm->animIndex) + if (!mdxm->animIndex) { Com_Printf (S_COLOR_YELLOW "R_LoadMDXM: missing animation file %s for mesh %s\n", mdxm->animName, mdxm->name); return qfalse; @@ -4233,7 +4234,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & } #endif surfInfo = (mdxmSurfHierarchy_t *)( (byte *)mdxm + mdxm->ofsSurfHierarchy); - for ( i = 0 ; i < mdxm->numSurfaces ; i++) + for ( i = 0 ; i < mdxm->numSurfaces ; i++) { LL(surfInfo->numChildren); LL(surfInfo->parentIndex); @@ -4260,7 +4261,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & // get the shader name sh = R_FindShader( surfInfo->shader, lightmapsNone, stylesDefault, qtrue ); // insert it in the surface list - if ( sh->defaultShader ) + if ( sh->defaultShader ) { surfInfo->shaderIndex = 0; } @@ -4269,12 +4270,12 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & surfInfo->shaderIndex = sh->index; } - CModelCache->StoreShaderRequest(mod_name, &surfInfo->shader[0], &surfInfo->shaderIndex); + CModelCache->StoreShaderRequest(mod_name, &surfInfo->shader[0], &surfInfo->shaderIndex); // find the next surface surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfInfo + offsetof(mdxmSurfHierarchy_t, childIndexes) + sizeof(int) * surfInfo->numChildren); } - + // swap all the LOD's (we need to do the middle part of this even for intel, because of shader reg and err-check) lod = (mdxmLOD_t *) ( (byte *)mdxm + mdxm->ofsLODs ); for ( l = 0 ; l < mdxm->numLODs ; l++) @@ -4284,7 +4285,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & LL(lod->ofsEnd); // swap all the surfaces surf = (mdxmSurface_t *) ( (byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof(mdxmLODSurfOffset_t)) ); - for ( i = 0 ; i < mdxm->numSurfaces ; i++) + for ( i = 0 ; i < mdxm->numSurfaces ; i++) { LL(surf->numTriangles); LL(surf->ofsTriangles); @@ -4297,7 +4298,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & // LL(surf->maxVertBoneWeights); triCount += surf->numTriangles; - + if ( surf->numVerts > SHADER_MAX_VERTEXES ) { Com_Error( ERR_DROP, @@ -4314,7 +4315,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & SHADER_MAX_INDEXES / 3, surf->numTriangles); } - + // change to surface identifier surf->ident = SF_MDX; // register the shaders @@ -4322,7 +4323,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & if (isAnOldModelFile) { int *boneRef = (int *) ( (byte *)surf + surf->ofsBoneReferences ); - for ( j = 0 ; j < surf->numBoneReferences ; j++ ) + for ( j = 0 ; j < surf->numBoneReferences ; j++ ) { if (boneRef[j] >= 0 && boneRef[j] < 72) { @@ -4871,7 +4872,7 @@ qboolean R_LoadMDXA(model_t *mod, void *buffer, const char *mod_name, qboolean & int childNumber = (NUM_ROOTPARENTS + NUM_OTHERPARENTS); // Allocate us some extra space so we can shift memory down. - size += (childNumber * (CHILD_PADDING * 8)); + size += (childNumber * (CHILD_PADDING * 8)); #endif // CREATE_LIMB_HIERARCHY mdxa = (mdxaHeader_t *)CModelCache->Allocate( @@ -4879,7 +4880,7 @@ qboolean R_LoadMDXA(model_t *mod, void *buffer, const char *mod_name, qboolean & mod->data.gla = mdxa; // I should probably eliminate 'bAlreadyFound', but wtf? - assert(bAlreadyCached == bAlreadyFound); + assert(bAlreadyCached == bAlreadyFound); if (!bAlreadyFound) { @@ -4951,7 +4952,7 @@ qboolean R_LoadMDXA(model_t *mod, void *buffer, const char *mod_name, qboolean & ShiftMemoryDown(offsets, mdxa, i, &sizeMarker); boneInfo = (mdxaSkel_t *) - ((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[i]); + ((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[i]); int newChild = BoneParentChildIndex(mdxa, offsets, boneInfo, qtrue); if (newChild != -1) diff --git a/shared/rd-rend2/tr_glsl.cpp b/shared/rd-rend2/tr_glsl.cpp index 36b0ca4ee8..44ba6d03db 100644 --- a/shared/rd-rend2/tr_glsl.cpp +++ b/shared/rd-rend2/tr_glsl.cpp @@ -339,7 +339,7 @@ static size_t GLSL_GetShaderHeader( Q_strcat(dest, size, va("#define ALPHA_TEST_GT0 %d\n" - "#define ALPHA_TEST_LT128 %d\n" + "#define ALPHA_TEST_LT128 %d\n" "#define ALPHA_TEST_GE128 %d\n" "#define ALPHA_TEST_GE192 %d\n", ALPHA_TEST_GT0, @@ -510,7 +510,7 @@ static size_t GLSL_LoadGPUShaderSource( { ri.FS_FreeFile(buffer); } - + return result; } @@ -730,7 +730,7 @@ bool ShaderProgramBuilder::AddShader( const GPUShaderDesc& shaderDesc, const cha { shaderSource.resize(shaderSource.size() * 2); } - + ++attempts; } @@ -830,7 +830,7 @@ void GLSL_InitUniforms(shaderProgram_t *program) uniforms[i] = qglGetUniformLocation(program->program, uniformsInfo[i].name); if (uniforms[i] == -1) continue; - + program->uniformBufferOffsets[i] = size; switch(uniformsInfo[i].type) { @@ -1099,7 +1099,7 @@ void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat valu } *compare = value; - + qglUniform1f(uniforms[uniformNum], value); } @@ -1407,7 +1407,7 @@ static const GPUProgramDesc *LoadProgramSource( const char *programName, Allocator& allocator, const GPUProgramDesc& fallback ) { const GPUProgramDesc *result = &fallback; - + if ( r_externalGLSL->integer ) { char *buffer; @@ -1557,7 +1557,7 @@ static int GLSL_LoadGPUProgramFogPass( qglUseProgram(0); GLSL_FinishGPUShader(&tr.fogShader[i]); - + ++numPrograms; } @@ -1797,7 +1797,7 @@ static int GLSL_LoadGPUProgramLightAll( qglUseProgram(0); GLSL_FinishGPUShader(&tr.lightallShader[i]); - + ++numPrograms; } @@ -1897,7 +1897,7 @@ static int GLSL_LoadGPUProgramPShadow( qglUseProgram(0); GLSL_FinishGPUShader(&tr.pshadowShader); - + return 1; } @@ -1945,7 +1945,7 @@ static int GLSL_LoadGPUProgramDownscale4x( qglUseProgram(0); GLSL_FinishGPUShader(&tr.down4xShader); - + return 1; } @@ -1967,7 +1967,7 @@ static int GLSL_LoadGPUProgramBokeh( qglUseProgram(0); GLSL_FinishGPUShader(&tr.bokehShader); - + return 1; } @@ -2038,7 +2038,7 @@ static int GLSL_LoadGPUProgramCalcLuminanceLevel( qglUseProgram(0); GLSL_FinishGPUShader(&tr.calclevels4xShader[i]); - + ++numPrograms; } @@ -2245,7 +2245,7 @@ static int GLSL_LoadGPUProgramSurfaceSprites( if (i & SSDEF_ADDITIVE) Q_strcat(extradefines, sizeof(extradefines), "#define ADDITIVE_BLEND\n"); - + shaderProgram_t *program = tr.spriteShader + i; if (!GLSL_LoadGPUShader(builder, program, "surface_sprites", attribs, NO_XFB_VARS, extradefines, *programDesc)) @@ -2357,7 +2357,7 @@ void GLSL_LoadGPUShaders() Allocator allocator(512 * 1024); ShaderProgramBuilder builder; - + int numGenShaders = 0; int numLightShaders = 0; int numEtcShaders = 0; @@ -2382,8 +2382,8 @@ void GLSL_LoadGPUShaders() numEtcShaders += GLSL_LoadGPUProgramSurfaceSprites(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramWeather(builder, allocator); - ri.Printf(PRINT_ALL, "loaded %i GLSL shaders (%i gen %i light %i etc) in %5.2f seconds\n", - numGenShaders + numLightShaders + numEtcShaders, numGenShaders, numLightShaders, + ri.Printf(PRINT_ALL, "loaded %i GLSL shaders (%i gen %i light %i etc) in %5.2f seconds\n", + numGenShaders + numLightShaders + numEtcShaders, numGenShaders, numLightShaders, numEtcShaders, (ri.Milliseconds() - startTime) / 1000.0); } @@ -2612,7 +2612,7 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) break; } - if (tess.fogNum && + if (tess.fogNum && pStage->adjustColorsForFog != ACFF_NONE && r_drawfog->integer) shaderAttribs |= GENERICDEF_USE_FOG; diff --git a/shared/rd-rend2/tr_image.cpp b/shared/rd-rend2/tr_image.cpp index 418a25ac34..8919c40563 100644 --- a/shared/rd-rend2/tr_image.cpp +++ b/shared/rd-rend2/tr_image.cpp @@ -132,7 +132,7 @@ void GL_TextureMode( const char *string ) { gl_filter_min = modes[i].minimize; gl_filter_max = modes[i].maximize; - + if ( r_ext_texture_filter_anisotropic->value > glConfig.maxTextureFilterAnisotropy ) { ri.Cvar_SetValue ("r_ext_texture_filter_anisotropic", glConfig.maxTextureFilterAnisotropy); @@ -145,7 +145,7 @@ void GL_TextureMode( const char *string ) { GL_Bind (glt); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); - + if ( r_ext_texture_filter_anisotropic->value > 0.0f ) { if ( glConfig.maxTextureFilterAnisotropy > 1.0f ) @@ -299,7 +299,7 @@ void R_ImageList_f( void ) { if (image->flags & IMGFLAG_MIPMAP) estSize += estSize / 2; - float printSize = GetReadableSize(estSize, &sizeSuffix); + float printSize = GetReadableSize(estSize, &sizeSuffix); ri.Printf(PRINT_ALL, "%4i: %4ix%4i %s %7.2f%s %s\n", i, image->uploadWidth, image->uploadHeight, format, printSize, sizeSuffix, image->imgName); estTotalSize += estSize; @@ -323,11 +323,11 @@ Used to resample images in a more general than quartering fashion. This will only be filtered properly if the resampled size is greater than half the original size. -If a larger shrinking is needed, use the mipmap function +If a larger shrinking is needed, use the mipmap function before or after. ================ */ -static void ResampleTexture( byte *in, int inwidth, int inheight, byte *out, +static void ResampleTexture( byte *in, int inwidth, int inheight, byte *out, int outwidth, int outheight ) { int i, j; byte *inrow, *inrow2; @@ -337,7 +337,7 @@ static void ResampleTexture( byte *in, int inwidth, int inheight, byte *out, if (outwidth>2048) ri.Error(ERR_DROP, "ResampleTexture: max width"); - + fracstep = inwidth*0x10000/outwidth; frac = fracstep>>2; @@ -557,7 +557,7 @@ static void DoFCBI(byte *in, byte *out, int width, int height, int component) inbyte += 8; } } - + for (y = 3; y < height - 3; y += 2) { // diagonals @@ -707,7 +707,7 @@ static void DoFCBI(byte *in, byte *out, int width, int height, int component) inbyte += 8; } } - + for (y = 2; y < height - 3; y++) { // horizontal & vertical @@ -747,7 +747,7 @@ static void DoFCBI(byte *in, byte *out, int width, int height, int component) //x = (y + 1) % 2; x = (y + 1) % 2 + 2; - + // optimization one // SAMPLE2(sa, x-1, y-2); //SAMPLE2(sc, x-2, y-1); SAMPLE2(sd, x, y-1); @@ -804,7 +804,7 @@ static void DoFCBI(byte *in, byte *out, int width, int height, int component) sj = *line4; line4 += 8; sl = *line5; line5 += 8; - hp = sf + sg; + hp = sf + sg; vp = sd + si; hd = abs(sf - sg); vd = abs(sd - si); @@ -828,7 +828,7 @@ static void DoFCBI(byte *in, byte *out, int width, int height, int component) if (hdd > vdd) *outbyte = hp >> 1; - else + else *outbyte = vp >> 1; } @@ -920,7 +920,7 @@ static void DoFCBIQuick(byte *in, byte *out, int width, int height, int componen inbyte += 8; } } - + for (y = 2; y < height - 3; y++) { byte sd, sf, sg, si; @@ -943,8 +943,8 @@ static void DoFCBIQuick(byte *in, byte *out, int width, int height, int componen sd = *line2; line2 += 8; sg = *line3; line3 += 8; si = *line4; line4 += 8; - - hp = sf + sg; + + hp = sf + sg; vp = sd + si; hd = abs(sf - sg); vd = abs(sd - si); @@ -1005,7 +1005,7 @@ static void DoLinear(byte *in, byte *out, int width, int height) COPYSAMPLE(si, line3); line3 += 8; for (i = 0; i < 4; i++) - { + { *outbyte++ = (sd[i] + si[i] + se[i] + sh[i]) >> 2; } @@ -1031,7 +1031,7 @@ static void DoLinear(byte *in, byte *out, int width, int height) inbyte += 8; } } - + for (y = 1; y < height - 1; y++) { byte sd[4], sf[4], sg[4], si[4]; @@ -1169,7 +1169,7 @@ static void FCBIByBlock(byte *data, int width, int height, qboolean clampToEdge, } outbyte = workdata + y2 * fullworkwidth * 4; - inbyte = data + srcy * width * 4; + inbyte = data + srcy * width * 4; for (x2 = 0; x2 < fullworkwidth; x2 += 2) { @@ -1328,7 +1328,7 @@ static void R_MipMap2( byte *in, int inWidth, int inHeight ) { for ( j = 0 ; j < outWidth ; j++ ) { outpix = (byte *) ( temp + i * outWidth + j ); for ( k = 0 ; k < 4 ; k++ ) { - total = + total = 1 * (&in[ 4*(((i*2-1)&inHeightMask)*inWidth + ((j*2-1)&inWidthMask)) ])[k] + 2 * (&in[ 4*(((i*2-1)&inHeightMask)*inWidth + ((j*2 )&inWidthMask)) ])[k] + 2 * (&in[ 4*(((i*2-1)&inHeightMask)*inWidth + ((j*2+1)&inWidthMask)) ])[k] + @@ -1435,8 +1435,8 @@ static void R_MipMapLuminanceAlpha (const byte *in, byte *out, int width, int he if ( width == 0 || height == 0 ) { width += height; // get largest for (i=0 ; i> 1; out[3] = (in[3] + in[7]) >> 1; } @@ -1445,8 +1445,8 @@ static void R_MipMapLuminanceAlpha (const byte *in, byte *out, int width, int he for (i=0 ; i> 2; out[3] = (in[3] + in[7] + in[row+3] + in[row+7]) >> 2; } @@ -1472,7 +1472,7 @@ static void R_MipMapNormalHeight (const byte *in, byte *out, int width, int heig row = width * 4; width >>= 1; height >>= 1; - + for (i=0 ; iinteger && scaled_height > height ) scaled_height >>= 1; - if ( picmip && data && resampledBuffer && r_imageUpsample->integer && + if ( picmip && data && resampledBuffer && r_imageUpsample->integer && scaled_width < r_imageUpsampleMaxSize->integer && scaled_height < r_imageUpsampleMaxSize->integer) { int finalwidth, finalheight; @@ -1730,7 +1730,7 @@ static qboolean RawImage_HasAlpha(const byte *scan, int numPixels) for ( i = 0; i < numPixels; i++ ) { - if ( scan[i*4 + 3] != 255 ) + if ( scan[i*4 + 3] != 255 ) { return qtrue; } @@ -2017,7 +2017,7 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei // the data is NULL. All levels have already been allocated by glTexStorage2D. int miplevel = 0; - + while (width > 1 || height > 1) { if (data) @@ -2042,7 +2042,7 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei R_MipMap( data, width, height ); } } - + width >>= 1; height >>= 1; if (width < 1) @@ -2110,7 +2110,7 @@ static void Upload32( byte *data, int width, int height, imgType_t type, int fla // c = width*height; scan = data; - + if( r_greyscale->integer ) { for ( i = 0; i < c; i++ ) @@ -2152,7 +2152,7 @@ static void Upload32( byte *data, int width, int height, imgType_t type, int fla } // copy or resample data as appropriate for first MIP level - if ( ( scaled_width == width ) && + if ( ( scaled_width == width ) && ( scaled_height == height ) ) { if (!(flags & IMGFLAG_MIPMAP)) { @@ -2488,7 +2488,7 @@ R_Create2DImageArray This is the only way any 2d array sampler image_t are created ================ */ -image_t *R_Create2DImageArray(const char *name, byte *pic, int width, int height, int layers, imgType_t type, int flags, int internalFormat) +image_t *R_Create2DImageArray(const char *name, byte *pic, int width, int height, int layers, imgType_t type, int flags, int internalFormat) { image_t *image; long hash; @@ -2543,7 +2543,7 @@ image_t *R_Create2DImageArray(const char *name, byte *pic, int width, int height case GL_DEPTH_COMPONENT16: case GL_DEPTH_COMPONENT24: case GL_DEPTH_COMPONENT32: - + qglTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); qglTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); if (flags & IMGLFAG_SHADOWCOMP) @@ -2609,10 +2609,10 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h scaledBuffer = (byte *)Hunk_AllocateTempMemory( sizeof( unsigned ) * scaled_width * scaled_height ); GL_SelectTexture( image->TMU ); - GL_Bind(image); + GL_Bind(image); // copy or resample data as appropriate for first MIP level - if ( ( scaled_width == width ) && + if ( ( scaled_width == width ) && ( scaled_height == height ) ) { if (!(image->flags & IMGFLAG_MIPMAP)) { @@ -2666,7 +2666,7 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h RawImage_UploadTexture( (byte *)data, scaled_x, scaled_y, scaled_width, scaled_height, image->internalFormat, image->type, image->flags, qtrue ); done: - + GL_SelectTexture( 0 ); GL_CheckErrors(); @@ -2729,7 +2729,7 @@ void R_LoadPackedMaterialImage(shaderStage_t *stage, const char *packedImageName image = R_GetLoadedImage(packedName, flags); if (image != NULL) { - // Don't scale occlusion, roughness and metalness + // Don't scale occlusion, roughness and metalness stage->specularScale[0] = stage->specularScale[2] = stage->specularScale[3] = 1.0f; @@ -2744,12 +2744,12 @@ void R_LoadPackedMaterialImage(shaderStage_t *stage, const char *packedImageName return; } - // Don't scale occlusion, roughness and metalness + // Don't scale occlusion, roughness and metalness stage->specularScale[0] = stage->specularScale[2] = stage->specularScale[3] = 1.0f; stage->specularScale[1] = baseSpecularScale; - + GLint swizzle[4] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }; switch (stage->specularType) @@ -2822,7 +2822,7 @@ image_t *R_BuildSDRSpecGlossImage(shaderStage_t *stage, const char *specImageNam currentColor[1] = ByteToFloat(specPic[i + 1]); currentColor[2] = ByteToFloat(specPic[i + 2]); - float ratio = + float ratio = (sRGBtoRGB(currentColor[0]) + sRGBtoRGB(currentColor[1]) + sRGBtoRGB(currentColor[1])) / (currentColor[0] + currentColor[1] + currentColor[2]); @@ -2842,26 +2842,26 @@ static void R_CreateNormalMap ( const char *name, byte *pic, int width, int heig image_t *normalImage; int normalWidth, normalHeight; int normalFlags; - + normalFlags = (flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_SRGB)) | IMGFLAG_NOLIGHTSCALE; - + COM_StripExtension(name, normalName, sizeof(normalName)); Q_strcat(normalName, sizeof(normalName), "_n"); - + // find normalmap in case it's there normalImage = R_FindImageFile(normalName, IMGTYPE_NORMAL, normalFlags); - + // if not, generate it if (normalImage == NULL) { byte *normalPic; int x, y; - + normalWidth = width; normalHeight = height; normalPic = (byte *)R_Malloc(width * height * 4, TAG_GENERAL); RGBAtoNormal(pic, normalPic, width, height, (qboolean)(flags & IMGFLAG_CLAMPTOEDGE)); - + #if 1 // Brighten up the original image to work with the normal map RGBAtoYCoCgA(pic, pic, width, height); @@ -2882,44 +2882,44 @@ static void R_CreateNormalMap ( const char *name, byte *pic, int width, int heig // Blur original image's luma to work with the normal map { byte *blurPic; - + RGBAtoYCoCgA(pic, pic, width, height); blurPic = ri.Malloc(width * height); - + for (y = 1; y < height - 1; y++) { byte *picbyte = pic + y * width * 4; byte *blurbyte = blurPic + y * width; - + picbyte += 4; blurbyte += 1; - + for (x = 1; x < width - 1; x++) { int result; - + result = *(picbyte - (width + 1) * 4) + *(picbyte - width * 4) + *(picbyte - (width - 1) * 4) + *(picbyte - 1 * 4) + *(picbyte ) + *(picbyte + 1 * 4) + *(picbyte + (width - 1) * 4) + *(picbyte + width * 4) + *(picbyte + (width + 1) * 4); - + result /= 9; - + *blurbyte = result; picbyte += 4; blurbyte += 1; } } - + // FIXME: do borders - + for (y = 1; y < height - 1; y++) { byte *picbyte = pic + y * width * 4; byte *blurbyte = blurPic + y * width; - + picbyte += 4; blurbyte += 1; - + for (x = 1; x < width - 1; x++) { picbyte[0] = *blurbyte; @@ -2927,13 +2927,13 @@ static void R_CreateNormalMap ( const char *name, byte *pic, int width, int heig blurbyte += 1; } } - + ri.Free(blurPic); - + YCoCgAtoRGBA(pic, pic, width, height); } #endif - + R_CreateImage( normalName, normalPic, normalWidth, normalHeight, IMGTYPE_NORMAL, normalFlags, 0 ); Z_Free( normalPic ); } @@ -2975,7 +2975,7 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) { R_LoadImage(name, &pic, &width, &height); } - else + else { float *floatBuffer = (float*)pic; for (int i = 0; i < width*height; i++) @@ -3016,7 +3016,7 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) image = R_CreateImage( name, pic, width, height, type, loadFlags, internalFormat); Z_Free( pic ); - + return image; } @@ -3056,10 +3056,10 @@ static void R_CreateDlightImage( void ) { } else if ( b < 75 ) { b = 0; } - data[y][x][0] = - data[y][x][1] = + data[y][x][0] = + data[y][x][1] = data[y][x][2] = b; - data[y][x][3] = 255; + data[y][x][3] = 255; } } tr.dlightImage = R_CreateImage("*dlight", (byte *)data, DLIGHT_SIZE, DLIGHT_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, 0 ); @@ -3076,7 +3076,7 @@ void R_InitFogTable( void ) { int i; float d; float exp; - + exp = 0.5; for ( i = 0 ; i < FOG_TABLE_SIZE ; i++ ) { @@ -3141,8 +3141,8 @@ static void R_CreateFogImage( void ) { for (y=0 ; yinteger == 4) { tr.pshadowArrayImage = R_Create2DImageArray( - va("*pshadowmapArray"), - NULL, + va("*pshadowmapArray"), + NULL, + PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, - PSHADOW_MAP_SIZE, - MAX_DRAWN_PSHADOWS, + MAX_DRAWN_PSHADOWS, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGLFAG_SHADOWCOMP | IMGFLAG_MUTABLE, GL_DEPTH_COMPONENT16); @@ -3511,10 +3511,10 @@ void R_CreateBuiltinImages( void ) { hdrFormat); tr.renderCubeDepthImage = R_CreateImage( - "*renderdepth", NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, + "*renderdepth", NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, - IMGFLAG_NO_COMPRESSION | - IMGFLAG_CLAMPTOEDGE, + IMGFLAG_NO_COMPRESSION | + IMGFLAG_CLAMPTOEDGE, GL_DEPTH24_STENCIL8); } diff --git a/shared/rd-rend2/tr_light.cpp b/shared/rd-rend2/tr_light.cpp index 6c4b481106..242fe9d190 100644 --- a/shared/rd-rend2/tr_light.cpp +++ b/shared/rd-rend2/tr_light.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define DLIGHT_AT_RADIUS 16 // at the edge of a dlight's influence, this amount of light will be added -#define DLIGHT_MINIMUM_RADIUS 16 +#define DLIGHT_MINIMUM_RADIUS 16 // never calculate a range less than this to prevent huge light numbers @@ -212,7 +212,7 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) { } data = world->lightGridData + *(world->lightGridArray+gridPos); - if ( data->styles[0] == LS_LSNONE ) + if ( data->styles[0] == LS_LSNONE ) { continue; // ignore samples in walls } @@ -336,7 +336,7 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { vec3_t lightDir; vec3_t lightOrigin; - // lighting calculations + // lighting calculations if ( ent->lightingCalculated ) { return; } @@ -355,13 +355,13 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { } // if NOWORLDMODEL, only use dynamic lights (menu system, etc) - if ( !(refdef->rdflags & RDF_NOWORLDMODEL ) + if ( !(refdef->rdflags & RDF_NOWORLDMODEL ) && tr.world->lightGridData ) { R_SetupEntityLightingGrid( ent, tr.world ); } else { - ent->ambientLight[0] = ent->ambientLight[1] = + ent->ambientLight[0] = ent->ambientLight[1] = ent->ambientLight[2] = tr.identityLight * 150; - ent->directedLight[0] = ent->directedLight[1] = + ent->directedLight[0] = ent->directedLight[1] = ent->directedLight[2] = tr.identityLight * 150; VectorCopy( tr.sunDirection, ent->lightDir ); } @@ -422,7 +422,7 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { ((byte *)&ent->ambientLightInt)[1] = Q_ftol(ent->ambientLight[1]); ((byte *)&ent->ambientLightInt)[2] = Q_ftol(ent->ambientLight[2]); ((byte *)&ent->ambientLightInt)[3] = 0xff; - + // transform the direction to local space VectorNormalize( lightDir ); VectorCopy(lightDir, ent->lightDir); @@ -440,7 +440,7 @@ R_LightForPoint int R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir ) { trRefEntity_t ent; - + if ( tr.world->lightGridData == NULL ) return qfalse; @@ -458,7 +458,7 @@ int R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, ve int R_LightDirForPoint( vec3_t point, vec3_t lightDir, vec3_t normal, world_t *world ) { trRefEntity_t ent; - + if ( world->lightGridData == NULL ) { VectorCopy(normal, lightDir); @@ -487,7 +487,7 @@ int R_DLightsForPoint(const vec3_t point, const float radius) for (int i = 0; i < tr.refdef.num_dlights; i++) { currentDlight = tr.refdef.dlights[i]; - + VectorSubtract(point, currentDlight.origin, delta); distance = VectorLength(delta); radiusSum = radius + currentDlight.radius; diff --git a/shared/rd-rend2/tr_local.h b/shared/rd-rend2/tr_local.h index 4c519efe16..5e1a3e7553 100644 --- a/shared/rd-rend2/tr_local.h +++ b/shared/rd-rend2/tr_local.h @@ -1583,7 +1583,6 @@ typedef struct { int frameCount; // copied from tr.frameCount cplane_t portalPlane; // clip anything behind this if mirroring int viewportX, viewportY, viewportWidth, viewportHeight; - int scissorX, scissorY, scissorWidth, scissorHeight; FBO_t *targetFbo; int targetFboLayer; float fovX, fovY; @@ -2256,8 +2255,11 @@ typedef struct glstate_s { int currenttmu; int texEnv[2]; int faceCulling; + bool blend; float minDepth; float maxDepth; + ivec2_t viewportOrigin; + ivec2_t viewportSize; uint32_t glStateBits; uint32_t vertexAttribsState; vertexAttribute_t currentVaoAttribs[ATTR_INDEX_MAX]; @@ -2921,6 +2923,7 @@ void GL_CheckErrs( const char *file, int line ); void GL_State( uint32_t stateVector ); void GL_SetProjectionMatrix(matrix_t matrix); void GL_SetModelviewMatrix(matrix_t matrix); +void GL_SetViewportAndScissor(int viewportX, int viewportY, int viewportWidth, int viewportHeight); void GL_Cull( int cullType ); void GL_DepthRange( float min, float max ); void GL_VertexAttribPointers(size_t numAttributes, diff --git a/shared/rd-rend2/tr_main.cpp b/shared/rd-rend2/tr_main.cpp index 4c4ed5ae71..81f70776ed 100644 --- a/shared/rd-rend2/tr_main.cpp +++ b/shared/rd-rend2/tr_main.cpp @@ -559,7 +559,7 @@ int R_CullPointAndRadiusEx( const vec3_t pt, float radius, const cplane_t* frust } // check against frustum planes - for (i = 0 ; i < numPlanes ; i++) + for (i = 0 ; i < numPlanes ; i++) { frust = &frustum[i]; @@ -568,7 +568,7 @@ int R_CullPointAndRadiusEx( const vec3_t pt, float radius, const cplane_t* frust { return CULL_OUT; } - else if ( dist <= radius ) + else if ( dist <= radius ) { mightBeClipped = qtrue; } @@ -637,7 +637,7 @@ void R_TransformModelToClip( const vec3_t src, const float *modelViewMatrix, con int i; for ( i = 0 ; i < 4 ; i++ ) { - eye[i] = + eye[i] = src[0] * modelViewMatrix[ i + 0 * 4 ] + src[1] * modelViewMatrix[ i + 1 * 4 ] + src[2] * modelViewMatrix[ i + 2 * 4 ] + @@ -645,7 +645,7 @@ void R_TransformModelToClip( const vec3_t src, const float *modelViewMatrix, con } for ( i = 0 ; i < 4 ; i++ ) { - dst[i] = + dst[i] = eye[0] * projectionMatrix[ i + 0 * 4 ] + eye[1] * projectionMatrix[ i + 1 * 4 ] + eye[2] * projectionMatrix[ i + 2 * 4 ] + @@ -703,7 +703,7 @@ Called by both the front end and the back end ================= */ void R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms, - orientationr_t *ori ) + orientationr_t *ori ) { vec3_t delta; float axisLength; @@ -767,7 +767,7 @@ R_RotateForViewer Sets up the modelview matrix for a given viewParm ================= */ -static void R_RotateForViewer(orientationr_t *ori, viewParms_t *viewParms) +static void R_RotateForViewer(orientationr_t *ori, viewParms_t *viewParms) { float viewerMatrix[16]; vec3_t origin; @@ -830,7 +830,7 @@ static void R_SetFarClip( viewParms_t *viewParms, const trRefdef_t *refdef ) return; } } - + // // set far clipping planes dynamically // @@ -893,7 +893,7 @@ void R_SetupFrustum (viewParms_t *dest, float xmin, float xmax, float ymax, floa vec3_t ofsorigin; float oppleg, adjleg, length; int i; - + if(stereoSep == 0 && xmin == -xmax) { // symmetric case can be simplified @@ -914,7 +914,7 @@ void R_SetupFrustum (viewParms_t *dest, float xmin, float xmax, float ymax, floa // In stereo rendering, due to the modification of the projection matrix, dest->ori.origin is not the // actual origin that we're rendering so offset the tip of the view pyramid. VectorMA(dest->ori.origin, stereoSep, dest->ori.axis[1], ofsorigin); - + oppleg = xmax + stereoSep; length = sqrt(oppleg * oppleg + zProj * zProj); VectorScale(dest->ori.axis[0], oppleg / length, dest->frustum[0].normal); @@ -935,7 +935,7 @@ void R_SetupFrustum (viewParms_t *dest, float xmin, float xmax, float ymax, floa VectorScale(dest->ori.axis[0], oppleg, dest->frustum[3].normal); VectorMA(dest->frustum[3].normal, -adjleg, dest->ori.axis[2], dest->frustum[3].normal); - + for (i=0 ; i<4 ; i++) { dest->frustum[i].type = PLANE_NON_AXIAL; dest->frustum[i].dist = DotProduct (ofsorigin, dest->frustum[i].normal); @@ -967,7 +967,7 @@ void R_SetupProjection(viewParms_t *dest, float zProj, float zFar, qboolean comp float width, height, stereoSep = r_stereoSeparation->value; /* - * offset the view origin of the viewer for stereo rendering + * offset the view origin of the viewer for stereo rendering * by setting the projection matrix appropriately. */ @@ -989,7 +989,7 @@ void R_SetupProjection(viewParms_t *dest, float zProj, float zFar, qboolean comp width = xmax - xmin; height = ymax - ymin; - + dest->projectionMatrix[0] = 2 * zProj / width; dest->projectionMatrix[4] = 0; dest->projectionMatrix[8] = (xmax + xmin + 2 * stereoSep) / width; @@ -1004,7 +1004,7 @@ void R_SetupProjection(viewParms_t *dest, float zProj, float zFar, qboolean comp dest->projectionMatrix[7] = 0; dest->projectionMatrix[11] = -1; dest->projectionMatrix[15] = 0; - + // Now that we have all the data for the projection matrix we can also setup the view frustum. if(computeFrustum) R_SetupFrustum(dest, xmin, xmax, ymax, zProj, zFar, stereoSep); @@ -1020,7 +1020,7 @@ Sets the z-component transformation part in the projection matrix void R_SetupProjectionZ(viewParms_t *dest) { float zNear, zFar, depth; - + zNear = dest->zNear; zFar = dest->zFar; @@ -1129,7 +1129,7 @@ void R_SetupProjectionOrtho(viewParms_t *dest, const vec3_t viewBounds[2]) VectorScale(dest->ori.axis[0], -1.0f, dest->frustum[4].normal); VectorMA(dest->ori.origin, -viewBounds[1][0], dest->frustum[4].normal, pop); dest->frustum[4].dist = DotProduct(pop, dest->frustum[4].normal); - + for (i = 0; i < 5; i++) { dest->frustum[i].type = PLANE_NON_AXIAL; @@ -1199,13 +1199,13 @@ void R_PlaneForSurface (surfaceType_t *surfType, cplane_t *plane) { v2 = tri->verts + tri->indexes[1]; v3 = tri->verts + tri->indexes[2]; PlaneFromPoints( plane4, v1->xyz, v2->xyz, v3->xyz ); - VectorCopy( plane4, plane->normal ); + VectorCopy( plane4, plane->normal ); plane->dist = plane4[3]; return; case SF_POLY: poly = (srfPoly_t *)surfType; PlaneFromPoints( plane4, poly->verts[0].xyz, poly->verts[1].xyz, poly->verts[2].xyz ); - VectorCopy( plane4, plane->normal ); + VectorCopy( plane4, plane->normal ); plane->dist = plane4[3]; return; default: @@ -1277,8 +1277,8 @@ qboolean R_GetPortalOrientations(const msurface_t *surf, int entityNum, VectorCopy( e->e.oldorigin, pvsOrigin ); // if the entity is just a mirror, don't use as a camera point - if ( e->e.oldorigin[0] == e->e.origin[0] && - e->e.oldorigin[1] == e->e.origin[1] && + if ( e->e.oldorigin[0] == e->e.origin[0] && + e->e.oldorigin[1] == e->e.origin[1] && e->e.oldorigin[2] == e->e.origin[2] ) { VectorScale( plane.normal, plane.dist, surface->origin ); VectorCopy( surface->origin, camera->origin ); @@ -1294,7 +1294,7 @@ qboolean R_GetPortalOrientations(const msurface_t *surf, int entityNum, // an origin point we can rotate around d = DotProduct( e->e.origin, plane.normal ) - plane.dist; VectorMA( e->e.origin, -d, surface->axis[0], surface->origin ); - + // now get the camera origin and orientation VectorCopy( e->e.oldorigin, camera->origin ); AxisCopy( e->e.axis, camera->axis ); @@ -1354,7 +1354,7 @@ static qboolean IsMirror( const msurface_t *surface, int entityNum ) R_PlaneForSurface( surface->data, &originalPlane ); // rotate the plane if necessary - if ( entityNum != REFENTITYNUM_WORLD ) + if ( entityNum != REFENTITYNUM_WORLD ) { const trRefEntity_t *currentEntity = &tr.refdef.entities[entityNum]; @@ -1368,12 +1368,12 @@ static qboolean IsMirror( const msurface_t *surface, int entityNum ) // translate the original plane originalPlane.dist = originalPlane.dist + DotProduct( originalPlane.normal, tr.ori.origin ); - } + } // locate the portal entity closest to this plane. // origin will be the origin of the portal, origin2 will be // the origin of the camera - for ( i = 0 ; i < tr.refdef.num_entities ; i++ ) + for ( i = 0 ; i < tr.refdef.num_entities ; i++ ) { e = &tr.refdef.entities[i]; if ( e->e.reType != RT_PORTALSURFACE ) { @@ -1386,9 +1386,9 @@ static qboolean IsMirror( const msurface_t *surface, int entityNum ) } // if the entity is just a mirror, don't use as a camera point - if ( e->e.oldorigin[0] == e->e.origin[0] && - e->e.oldorigin[1] == e->e.origin[1] && - e->e.oldorigin[2] == e->e.origin[2] ) + if ( e->e.oldorigin[0] == e->e.origin[0] && + e->e.oldorigin[1] == e->e.origin[1] && + e->e.oldorigin[2] == e->e.origin[2] ) { return qtrue; } @@ -1613,7 +1613,7 @@ qboolean R_MirrorViewBySurface (msurface_t *surface, int entityNum) { VectorSubtract( vec3_origin, camera.axis[0], newParms.portalPlane.normal ); newParms.portalPlane.dist = DotProduct( camera.origin, newParms.portalPlane.normal ); - + R_MirrorVector (oldParms.ori.axis[0], &surfaceOri, &camera, newParms.ori.axis[0]); R_MirrorVector (oldParms.ori.axis[1], &surfaceOri, &camera, newParms.ori.axis[1]); R_MirrorVector (oldParms.ori.axis[2], &surfaceOri, &camera, newParms.ori.axis[2]); @@ -1654,7 +1654,7 @@ See if a sprite is inside a fog volume ================= */ int R_SpriteFogNum( trRefEntity_t *ent ) { - int i, j; + int i; float frameRadius; fog_t *fog; vec3_t localOrigin; @@ -1666,6 +1666,7 @@ int R_SpriteFogNum( trRefEntity_t *ent ) { VectorCopy(ent->e.origin, localOrigin); frameRadius = ent->e.radius; #ifndef REND2_SP + int j; for (i = 1; i < tr.world->numfogs; i++) { fog = &tr.world->fogs[i]; for (j = 0; j < 3; j++) { @@ -1868,7 +1869,7 @@ void R_AddDrawSurf( surf->dlightBits = dlightMap; surf->fogIndex = fogIndex; } - + tr.refdef.numDrawSurfs++; } @@ -1901,7 +1902,7 @@ static void R_AddEntitySurface(const trRefdef_t *refdef, trRefEntity_t *ent, int // // the weapon model must be handled special -- - // we don't want the hacked weapon position showing in + // we don't want the hacked weapon position showing in // mirrors, because the true body position will already be drawn // if ( (ent->e.renderfx & RF_FIRST_PERSON) && (tr.viewParms.flags & VPF_NOVIEWMODEL)) { @@ -1983,7 +1984,7 @@ static void R_AddEntitySurface(const trRefdef_t *refdef, trRefEntity_t *ent, int break; } - // FIX ME: always draw null axis model instead of rejecting the drawcall + // FIX ME: always draw null axis model instead of rejecting the drawcall if (tr.currentModel->dataSize > 0) R_AddDrawSurf( &entitySurface, @@ -2202,19 +2203,19 @@ void R_RenderDlightCubemaps(const refdef_t *fd) VectorSet( shadowParms.ori.axis[1], 0, 0, -1); VectorSet( shadowParms.ori.axis[2], 0, 1, 0); break; - case 1: + case 1: // +X VectorSet( shadowParms.ori.axis[0], 1, 0, 0); VectorSet( shadowParms.ori.axis[1], 0, 0, 1); VectorSet( shadowParms.ori.axis[2], 0, 1, 0); break; - case 2: + case 2: // -Y VectorSet( shadowParms.ori.axis[0], 0, -1, 0); VectorSet( shadowParms.ori.axis[1], 1, 0, 0); VectorSet( shadowParms.ori.axis[2], 0, 0, -1); break; - case 3: + case 3: // +Y VectorSet( shadowParms.ori.axis[0], 0, 1, 0); VectorSet( shadowParms.ori.axis[1], 1, 0, 0); @@ -2300,7 +2301,6 @@ void R_SetupViewParmsForOrthoRendering( void R_SetupPshadowMaps(trRefdef_t *refdef) { - viewParms_t shadowParms; int i; // first, make a list of shadows @@ -2912,7 +2912,7 @@ void R_GatherFrameViews(trRefdef_t *refdef) tr.numCachedViewParms++; } } - + } // sun shadowmaps @@ -2984,7 +2984,7 @@ void R_GatherFrameViews(trRefdef_t *refdef) VectorMA(point, ly, refdef->viewaxis[2], point); VectorCopy(point, frustrumPoint0); VectorAdd(point, splitCenter, splitCenter); - + VectorMA(base, -lx, refdef->viewaxis[1], point); VectorMA(point, ly, refdef->viewaxis[2], point); VectorAdd(point, splitCenter, splitCenter); @@ -3041,7 +3041,7 @@ void R_GatherFrameViews(trRefdef_t *refdef) VPF_DEPTHSHADOW | VPF_DEPTHCLAMP | VPF_ORTHOGRAPHIC | VPF_NOVIEWMODEL | VPF_SHADOWCASCADES, orientation, lightviewBounds); - + // Moving the Light in Texel-Sized Increments // from http://msdn.microsoft.com/en-us/library/windows/desktop/ee416324%28v=vs.85%29.aspx static float worldUnitsPerTexel = 2.0f * lightviewBounds[1][0] / (float)tr.sunShadowFbo[level]->width; diff --git a/shared/rd-rend2/tr_marks.cpp b/shared/rd-rend2/tr_marks.cpp index 6e12616d13..aa2e761a1b 100644 --- a/shared/rd-rend2/tr_marks.cpp +++ b/shared/rd-rend2/tr_marks.cpp @@ -39,7 +39,7 @@ Out must have space for two more vertexes than in #define SIDE_BACK 1 #define SIDE_ON 2 static void R_ChopPolyBehindPlane( int numInPoints, vec3_t inPoints[MAX_VERTS_ON_POLY], - int *numOutPoints, vec3_t outPoints[MAX_VERTS_ON_POLY], + int *numOutPoints, vec3_t outPoints[MAX_VERTS_ON_POLY], vec3_t normal, float dist, float epsilon) { float dists[MAX_VERTS_ON_POLY+4] = { 0 }; int sides[MAX_VERTS_ON_POLY+4] = { 0 }; @@ -88,13 +88,13 @@ static void R_ChopPolyBehindPlane( int numInPoints, vec3_t inPoints[MAX_VERTS_ON for ( i = 0 ; i < numInPoints ; i++ ) { p1 = inPoints[i]; clip = outPoints[ *numOutPoints ]; - + if ( sides[i] == SIDE_ON ) { VectorCopy( p1, clip ); (*numOutPoints)++; continue; } - + if ( sides[i] == SIDE_FRONT ) { VectorCopy( p1, clip ); (*numOutPoints)++; @@ -104,7 +104,7 @@ static void R_ChopPolyBehindPlane( int numInPoints, vec3_t inPoints[MAX_VERTS_ON if ( sides[i+1] == SIDE_ON || sides[i+1] == sides[i] ) { continue; } - + // generate a split point p2 = inPoints[ (i+1) % numInPoints ]; diff --git a/shared/rd-rend2/tr_mesh.cpp b/shared/rd-rend2/tr_mesh.cpp index a2e4d1ac43..d68082088e 100644 --- a/shared/rd-rend2/tr_mesh.cpp +++ b/shared/rd-rend2/tr_mesh.cpp @@ -41,22 +41,22 @@ float ProjectRadius( float r, vec3_t location ) p[1] = fabs( r ); p[2] = -dist; - projected[0] = p[0] * tr.viewParms.projectionMatrix[0] + + projected[0] = p[0] * tr.viewParms.projectionMatrix[0] + p[1] * tr.viewParms.projectionMatrix[4] + p[2] * tr.viewParms.projectionMatrix[8] + tr.viewParms.projectionMatrix[12]; - projected[1] = p[0] * tr.viewParms.projectionMatrix[1] + + projected[1] = p[0] * tr.viewParms.projectionMatrix[1] + p[1] * tr.viewParms.projectionMatrix[5] + p[2] * tr.viewParms.projectionMatrix[9] + tr.viewParms.projectionMatrix[13]; - projected[2] = p[0] * tr.viewParms.projectionMatrix[2] + + projected[2] = p[0] * tr.viewParms.projectionMatrix[2] + p[1] * tr.viewParms.projectionMatrix[6] + p[2] * tr.viewParms.projectionMatrix[10] + tr.viewParms.projectionMatrix[14]; - projected[3] = p[0] * tr.viewParms.projectionMatrix[3] + + projected[3] = p[0] * tr.viewParms.projectionMatrix[3] + p[1] * tr.viewParms.projectionMatrix[7] + p[2] * tr.viewParms.projectionMatrix[11] + tr.viewParms.projectionMatrix[15]; @@ -134,7 +134,7 @@ static int R_CullModel( mdvModel_t *model, trRefEntity_t *ent ) { } } } - + // calculate a bounding box in the current coordinate system for (i = 0 ; i < 3 ; i++) { bounds[0][i] = oldFrame->bounds[0][i] < newFrame->bounds[0][i] ? oldFrame->bounds[0][i] : newFrame->bounds[0][i]; @@ -168,7 +168,6 @@ RE_GetModelBounds void RE_GetModelBounds(refEntity_t *refEnt, vec3_t bounds1, vec3_t bounds2) { mdvFrame_t *frame; - md3Header_t *header; model_t *model; assert(refEnt); @@ -212,9 +211,9 @@ int R_ComputeLOD( trRefEntity_t *ent ) { int frameSize; mdr = tr.currentModel->data.mdr; frameSize = (size_t) (&((mdrFrame_t *)0)->bones[mdr->numBones]); - + mdrframe = (mdrFrame_t *) ((byte *) mdr + mdr->ofsFrames + frameSize * ent->e.frame); - + radius = RadiusFromBounds(mdrframe->bounds[0], mdrframe->bounds[1]); } else @@ -253,7 +252,7 @@ int R_ComputeLOD( trRefEntity_t *ent ) { } lod += r_lodbias->integer; - + if ( lod >= tr.currentModel->numLods ) lod = tr.currentModel->numLods - 1; if ( lod < 0 ) @@ -269,7 +268,7 @@ R_ComputeFogNum ================= */ int R_ComputeFogNum( mdvModel_t *model, trRefEntity_t *ent ) { - int i, j; + int i; float frameRadius; fog_t *fog; mdvFrame_t *mdvFrame; @@ -284,6 +283,7 @@ int R_ComputeFogNum( mdvModel_t *model, trRefEntity_t *ent ) { VectorAdd( ent->e.origin, mdvFrame->localOrigin, localOrigin ); frameRadius = mdvFrame->radius; #ifndef REND2_SP + int j; for ( i = 1 ; i < tr.world->numfogs ; i++ ) { fog = &tr.world->fogs[i]; for ( j = 0 ; j < 3 ; j++ ) { @@ -352,7 +352,7 @@ void R_AddMD3Surfaces( trRefEntity_t *ent, int entityNum ) { qboolean personalModel; // don't add third_person objects if not in a portal - personalModel = (qboolean)((ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal + personalModel = (qboolean)((ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal || (tr.viewParms.flags & VPF_DEPTHSHADOW))); if ( ent->e.renderfx & RF_WRAP_FRAMES ) { @@ -366,7 +366,7 @@ void R_AddMD3Surfaces( trRefEntity_t *ent, int entityNum ) { // when the surfaces are rendered, they don't need to be // range checked again. // - if ( (ent->e.frame >= tr.currentModel->data.mdv[0]->numFrames) + if ( (ent->e.frame >= tr.currentModel->data.mdv[0]->numFrames) || (ent->e.frame < 0) || (ent->e.oldframe >= tr.currentModel->data.mdv[0]->numFrames) || (ent->e.oldframe < 0) ) { diff --git a/shared/rd-rend2/tr_model.cpp b/shared/rd-rend2/tr_model.cpp index 4fb300680e..1bacf55519 100644 --- a/shared/rd-rend2/tr_model.cpp +++ b/shared/rd-rend2/tr_model.cpp @@ -74,7 +74,7 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) ident = *(unsigned *)buf; if( !bAlreadyCached ) LL(ident); - + switch(ident) { case MD3_IDENT: @@ -142,20 +142,20 @@ qhandle_t R_RegisterMDR(const char *name, model_t *mod) mod->type = MOD_BAD; return 0; } - + ident = LittleLong(*(unsigned *)buf.u); if(ident == MDR_IDENT) loaded = R_LoadMDR(mod, buf.u, filesize, name); ri.FS_FreeFile (buf.v); - + if(!loaded) { ri.Printf(PRINT_WARNING,"R_RegisterMDR: couldn't load mdr file %s\n", name); mod->type = MOD_BAD; return 0; } - + return mod->index; } @@ -179,18 +179,18 @@ qhandle_t R_RegisterIQM(const char *name, model_t *mod) mod->type = MOD_BAD; return 0; } - + loaded = R_LoadIQM(mod, buf.u, filesize, name); ri.FS_FreeFile (buf.v); - + if(!loaded) { ri.Printf(PRINT_WARNING,"R_RegisterIQM: couldn't load iqm file %s\n", name); mod->type = MOD_BAD; return 0; } - + return mod->index; } @@ -208,7 +208,7 @@ static modelExtToLoaderMap_t modelLoaders[ ] = { "iqm", R_RegisterIQM }, { "mdr", R_RegisterMDR }, { "md3", R_RegisterMD3 }, - /* + /* Ghoul 2 Insert Start */ { "glm", R_RegisterMD3 }, @@ -433,7 +433,7 @@ qboolean R_LoadMDXA_Server( model_t *mod, void *buffer, const char *mod_name, qb pinmodel = (mdxaHeader_t *)buffer; // // read some fields from the binary, but only LittleLong() them when we know this wasn't an already-cached model... - // + // version = (pinmodel->version); size = (pinmodel->ofsEnd); @@ -442,7 +442,7 @@ qboolean R_LoadMDXA_Server( model_t *mod, void *buffer, const char *mod_name, qb LL(version); LL(size); } - + if (version != MDXA_VERSION) { return qfalse; } @@ -458,7 +458,7 @@ qboolean R_LoadMDXA_Server( model_t *mod, void *buffer, const char *mod_name, qb if (!bAlreadyFound) { - // horrible new hackery, if !bAlreadyFound then we've just done a tag-morph, so we need to set the + // horrible new hackery, if !bAlreadyFound then we've just done a tag-morph, so we need to set the // bool reference passed into this function to true, to tell the caller NOT to do an ri.FS_Freefile since // we've hijacked that memory block... // @@ -502,11 +502,11 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb int size; //shader_t *sh; mdxmSurfHierarchy_t *surfInfo; - + pinmodel= (mdxmHeader_t *)buffer; // // read some fields from the binary, but only LittleLong() them when we know this wasn't an already-cached model... - // + // version = (pinmodel->version); size = (pinmodel->ofsEnd); @@ -521,8 +521,8 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb } mod->type = MOD_MDXM; - mod->dataSize += size; - + mod->dataSize += size; + qboolean bAlreadyFound = qfalse; mdxm = (mdxmHeader_t*)CModelCache->Allocate( size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM ); mod->data.glm = (mdxmData_t *)Hunk_Alloc (sizeof (mdxmData_t), h_low); @@ -532,7 +532,7 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb if (!bAlreadyFound) { - // horrible new hackery, if !bAlreadyFound then we've just done a tag-morph, so we need to set the + // horrible new hackery, if !bAlreadyFound then we've just done a tag-morph, so we need to set the // bool reference passed into this function to true, to tell the caller NOT to do an ri.FS_Freefile since // we've hijacked that memory block... // @@ -550,10 +550,10 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb LL(mdxm->ofsSurfHierarchy); LL(mdxm->ofsEnd); } - + // first up, go load in the animation file we need that has the skeletal animation info for this model mdxm->animIndex = RE_RegisterServerModel(va ("%s.gla",mdxm->animName)); - if (!mdxm->animIndex) + if (!mdxm->animIndex) { return qfalse; } @@ -566,7 +566,7 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb } surfInfo = (mdxmSurfHierarchy_t *)( (byte *)mdxm + mdxm->ofsSurfHierarchy); - for ( i = 0 ; i < mdxm->numSurfaces ; i++) + for ( i = 0 ; i < mdxm->numSurfaces ; i++) { LL(surfInfo->numChildren); LL(surfInfo->parentIndex); @@ -580,7 +580,7 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb // We will not be using shaders on the server. //sh = 0; // insert it in the surface list - + surfInfo->shaderIndex = 0; CModelCache->StoreShaderRequest(mod_name, &surfInfo->shader[0], &surfInfo->shaderIndex); @@ -588,7 +588,7 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb // find the next surface surfInfo = (mdxmSurfHierarchy_t *)( (byte *)surfInfo + (intptr_t)( &((mdxmSurfHierarchy_t *)0)->childIndexes[ surfInfo->numChildren ] )); } - + // swap all the LOD's (we need to do the middle part of this even for intel, because of shader reg and err-check) lod = (mdxmLOD_t *) ( (byte *)mdxm + mdxm->ofsLODs ); for ( l = 0 ; l < mdxm->numLODs ; l++) @@ -598,7 +598,7 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb LL(lod->ofsEnd); // swap all the surfaces surf = (mdxmSurface_t *) ( (byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof(mdxmLODSurfOffset_t)) ); - for ( i = 0 ; i < mdxm->numSurfaces ; i++) + for ( i = 0 ; i < mdxm->numSurfaces ; i++) { LL(surf->numTriangles); LL(surf->ofsTriangles); @@ -611,14 +611,14 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb // LL(surf->maxVertBoneWeights); triCount += surf->numTriangles; - + if ( surf->numVerts > SHADER_MAX_VERTEXES ) { return qfalse; } if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) { return qfalse; } - + // change to surface identifier surf->ident = SF_MDX; @@ -677,7 +677,7 @@ qhandle_t R_RegisterMDX_Server(const char *name, model_t *mod) ident = *(unsigned *)buf; if( !bAlreadyCached ) LL(ident); - + switch(ident) { case MDXA_IDENT: @@ -725,7 +725,7 @@ qhandle_t R_RegisterMDX_Server(const char *name, model_t *mod) // when there are multiple models of different formats available static modelExtToLoaderMap_t serverModelLoaders[ ] = { - /* + /* Ghoul 2 Insert Start */ { "glm", R_RegisterMDX_Server }, @@ -1224,7 +1224,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN R_LoadMDR ================= */ -static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char *mod_name ) +static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char *mod_name ) { int i, j, k, l; mdrHeader_t *pinmodel, *mdr; @@ -1241,20 +1241,20 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char pinmodel = (mdrHeader_t *)buffer; pinmodel->version = LittleLong(pinmodel->version); - if (pinmodel->version != MDR_VERSION) + if (pinmodel->version != MDR_VERSION) { ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has wrong version (%i should be %i)\n", mod_name, pinmodel->version, MDR_VERSION); return qfalse; } size = LittleLong(pinmodel->ofsEnd); - + if(size > filesize) { ri.Printf(PRINT_WARNING, "R_LoadMDR: Header of %s is broken. Wrong filesize declared!\n", mod_name); return qfalse; } - + mod->type = MOD_MDR; LL(pinmodel->numFrames); @@ -1270,7 +1270,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // now add enough space for the uncompressed bones. size += pinmodel->numFrames * pinmodel->numBones * ((sizeof(mdrBone_t) - sizeof(mdrCompBone_t))); } - + // simple bounds check if(pinmodel->numBones < 0 || sizeof(*mdr) + pinmodel->numFrames * (sizeof(*frame) + (pinmodel->numBones - 1) * sizeof(*frame->bones)) > size) @@ -1283,7 +1283,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char mod->data.mdr = mdr = (mdrHeader_t*)Hunk_Alloc( size, h_low ); // Copy all the values over from the file and fix endian issues in the process, if necessary. - + mdr->ident = LittleLong(pinmodel->ident); mdr->version = pinmodel->version; // Don't need to swap byte order on this one, we already did above. Q_strncpyz(mdr->name, pinmodel->name, sizeof(mdr->name)); @@ -1295,7 +1295,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char mod->numLods = mdr->numLODs; - if ( mdr->numFrames < 1 ) + if ( mdr->numFrames < 1 ) { ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has no frames\n", mod_name); return qfalse; @@ -1304,14 +1304,14 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char /* The first frame will be put into the first free space after the header */ frame = (mdrFrame_t *)(mdr + 1); mdr->ofsFrames = (int)((byte *) frame - (byte *) mdr); - + if (pinmodel->ofsFrames < 0) { mdrCompFrame_t *cframe; - - // compressed model... + + // compressed model... cframe = (mdrCompFrame_t *)((byte *) pinmodel - pinmodel->ofsFrames); - + for(i = 0; i < mdr->numFrames; i++) { for(j = 0; j < 3; j++) @@ -1323,7 +1323,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char frame->radius = LittleFloat(cframe->radius); frame->name[0] = '\0'; // No name supplied in the compressed version. - + for(j = 0; j < mdr->numBones; j++) { for(k = 0; k < (sizeof(cframe->bones[j].Comp) / 2); k++) @@ -1331,15 +1331,15 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // Do swapping for the uncompressing functions. They seem to use shorts // values only, so I assume this will work. Never tested it on other // platforms, though. - + ((unsigned short *)(cframe->bones[j].Comp))[k] = LittleShort( ((unsigned short *)(cframe->bones[j].Comp))[k] ); } - + /* Now do the actual uncompressing */ MC_UnCompress(frame->bones[j].matrix, cframe->bones[j].Comp); } - + // Next Frame... cframe = (mdrCompFrame_t *) &cframe->bones[j]; frame = (mdrFrame_t *) &frame->bones[j]; @@ -1348,14 +1348,14 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char else { mdrFrame_t *curframe; - + // uncompressed model... // - + curframe = (mdrFrame_t *)((byte *) pinmodel + pinmodel->ofsFrames); - + // swap all the frames - for ( i = 0 ; i < mdr->numFrames ; i++) + for ( i = 0 ; i < mdr->numFrames ; i++) { for(j = 0; j < 3; j++) { @@ -1363,26 +1363,26 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char frame->bounds[1][j] = LittleFloat(curframe->bounds[1][j]); frame->localOrigin[j] = LittleFloat(curframe->localOrigin[j]); } - + frame->radius = LittleFloat(curframe->radius); Q_strncpyz(frame->name, curframe->name, sizeof(frame->name)); - - for (j = 0; j < (int) (mdr->numBones * sizeof(mdrBone_t) / 4); j++) + + for (j = 0; j < (int) (mdr->numBones * sizeof(mdrBone_t) / 4); j++) { ((float *)frame->bones)[j] = LittleFloat( ((float *)curframe->bones)[j] ); } - + curframe = (mdrFrame_t *) &curframe->bones[mdr->numBones]; frame = (mdrFrame_t *) &frame->bones[mdr->numBones]; } } - + // frame should now point to the first free address after all frames. lod = (mdrLOD_t *) frame; mdr->ofsLODs = (int) ((byte *) lod - (byte *)mdr); - + curlod = (mdrLOD_t *)((byte *) pinmodel + LittleLong(pinmodel->ofsLODs)); - + // swap all the LOD's for ( l = 0 ; l < mdr->numLODs ; l++) { @@ -1394,12 +1394,12 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char } lod->numSurfaces = LittleLong(curlod->numSurfaces); - + // swap all the surfaces surf = (mdrSurface_t *) (lod + 1); lod->ofsSurfaces = (int)((byte *) surf - (byte *) lod); cursurf = (mdrSurface_t *) ((byte *)curlod + LittleLong(curlod->ofsSurfaces)); - + for ( i = 0 ; i < lod->numSurfaces ; i++) { // simple bounds check @@ -1410,26 +1410,26 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char } // first do some copying stuff - + surf->ident = SF_MDR; Q_strncpyz(surf->name, cursurf->name, sizeof(surf->name)); Q_strncpyz(surf->shader, cursurf->shader, sizeof(surf->shader)); - + surf->ofsHeader = (byte *) mdr - (byte *) surf; - + surf->numVerts = LittleLong(cursurf->numVerts); surf->numTriangles = LittleLong(cursurf->numTriangles); // numBoneReferences and BoneReferences generally seem to be unused - + // now do the checks that may fail. - if ( surf->numVerts >= SHADER_MAX_VERTEXES ) + if ( surf->numVerts >= SHADER_MAX_VERTEXES ) { ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i verts on %s (%i).\n", mod_name, SHADER_MAX_VERTEXES-1, surf->name[0] ? surf->name : "a surface", surf->numVerts ); return qfalse; } - if ( surf->numTriangles*3 >= SHADER_MAX_INDEXES ) + if ( surf->numTriangles*3 >= SHADER_MAX_INDEXES ) { ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i triangles on %s (%i).\n", mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, surf->name[0] ? surf->name : "a surface", @@ -1446,16 +1446,16 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char } else { surf->shaderIndex = sh->index; } - + // now copy the vertexes. v = (mdrVertex_t *) (surf + 1); surf->ofsVerts = (int)((byte *) v - (byte *) surf); curv = (mdrVertex_t *) ((byte *)cursurf + LittleLong(cursurf->ofsVerts)); - + for(j = 0; j < surf->numVerts; j++) { LL(curv->numWeights); - + // simple bounds check if(curv->numWeights < 0 || (byte *) (v + 1) + (curv->numWeights - 1) * sizeof(*weight) > (byte *) mdr + size) { @@ -1466,37 +1466,37 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char v->normal[0] = LittleFloat(curv->normal[0]); v->normal[1] = LittleFloat(curv->normal[1]); v->normal[2] = LittleFloat(curv->normal[2]); - + v->texCoords[0] = LittleFloat(curv->texCoords[0]); v->texCoords[1] = LittleFloat(curv->texCoords[1]); - + v->numWeights = curv->numWeights; weight = &v->weights[0]; curweight = &curv->weights[0]; - + // Now copy all the weights for(k = 0; k < v->numWeights; k++) { weight->boneIndex = LittleLong(curweight->boneIndex); weight->boneWeight = LittleFloat(curweight->boneWeight); - + weight->offset[0] = LittleFloat(curweight->offset[0]); weight->offset[1] = LittleFloat(curweight->offset[1]); weight->offset[2] = LittleFloat(curweight->offset[2]); - + weight++; curweight++; } - + v = (mdrVertex_t *) weight; curv = (mdrVertex_t *) curweight; } - + // we know the offset to the triangles now: tri = (mdrTriangle_t *) v; surf->ofsTriangles = (int)((byte *) tri - (byte *) surf); curtri = (mdrTriangle_t *)((byte *) cursurf + LittleLong(cursurf->ofsTriangles)); - + // simple bounds check if(surf->numTriangles < 0 || (byte *) (tri + surf->numTriangles) > (byte *) mdr + size) { @@ -1509,11 +1509,11 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char tri->indexes[0] = LittleLong(curtri->indexes[0]); tri->indexes[1] = LittleLong(curtri->indexes[1]); tri->indexes[2] = LittleLong(curtri->indexes[2]); - + tri++; curtri++; } - + // tri now points to the end of the surface. surf->ofsEnd = (byte *) tri - (byte *) surf; surf = (mdrSurface_t *) tri; @@ -1529,7 +1529,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // find the next LOD. curlod = (mdrLOD_t *)((byte *) curlod + LittleLong(curlod->ofsEnd)); } - + // lod points to the first tag now, so update the offset too. tag = (mdrTag_t *) lod; mdr->ofsTags = (int)((byte *) tag - (byte *) mdr); @@ -1541,21 +1541,21 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); return qfalse; } - + for (i = 0 ; i < mdr->numTags ; i++) { tag->boneIndex = LittleLong(curtag->boneIndex); Q_strncpyz(tag->name, curtag->name, sizeof(tag->name)); - + tag++; curtag++; } - + // And finally we know the real offset to the end. mdr->ofsEnd = (int)((byte *) tag - (byte *) mdr); // phew! we're done. - + return qtrue; } @@ -1706,7 +1706,7 @@ void R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, mdvTag_t mdrFrame_t *frame; mdrTag_t *tag; - if ( framenum >= mod->numFrames ) + if ( framenum >= mod->numFrames ) { // it is possible to have a bad frame while changing models, so don't error framenum = mod->numFrames - 1; @@ -1730,7 +1730,7 @@ void R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, mdvTag_t dest->origin[0]=frame->bones[tag->boneIndex].matrix[0][3]; dest->origin[1]=frame->bones[tag->boneIndex].matrix[1][3]; - dest->origin[2]=frame->bones[tag->boneIndex].matrix[2][3]; + dest->origin[2]=frame->bones[tag->boneIndex].matrix[2][3]; return; } @@ -1745,7 +1745,7 @@ void R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, mdvTag_t R_LerpTag ================ */ -int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFrame, +int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFrame, float frac, const char *tagName ) { mdvTag_t *start, *end; mdvTag_t start_space, end_space; @@ -1785,7 +1785,7 @@ int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFram return qfalse; } } - + frontLerp = frac; backLerp = 1.0f - frac; @@ -1815,7 +1815,7 @@ void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ) { if(model->type == MOD_BRUSH) { VectorCopy( model->data.bmodel->bounds[0], mins ); VectorCopy( model->data.bmodel->bounds[1], maxs ); - + return; } else if (model->type == MOD_MESH) { mdvModel_t *header; @@ -1826,7 +1826,7 @@ void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ) { VectorCopy( frame->bounds[0], mins ); VectorCopy( frame->bounds[1], maxs ); - + return; } else if (model->type == MOD_MDR) { mdrHeader_t *header; @@ -1837,11 +1837,11 @@ void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ) { VectorCopy( frame->bounds[0], mins ); VectorCopy( frame->bounds[1], maxs ); - + return; } else if(model->type == MOD_IQM) { iqmData_t *iqmData; - + iqmData = model->data.iqm; if(iqmData->bounds) diff --git a/shared/rd-rend2/tr_model_iqm.cpp b/shared/rd-rend2/tr_model_iqm.cpp index eff2e47e35..6af9a6a562 100644 --- a/shared/rd-rend2/tr_model_iqm.cpp +++ b/shared/rd-rend2/tr_model_iqm.cpp @@ -108,7 +108,7 @@ static void Matrix34Invert( float *inMat, float *outMat ) { vec3_t trans; float invSqrLen, *v; - + outMat[ 0] = inMat[ 0]; outMat[ 1] = inMat[ 4]; outMat[ 2] = inMat[ 8]; outMat[ 4] = inMat[ 1]; outMat[ 5] = inMat[ 5]; outMat[ 6] = inMat[ 9]; outMat[ 8] = inMat[ 2]; outMat[ 9] = inMat[ 6]; outMat[10] = inMat[10]; @@ -308,7 +308,7 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na LL( triangle->vertex[0] ); LL( triangle->vertex[1] ); LL( triangle->vertex[2] ); - + if( triangle->vertex[0] > header->num_vertexes || triangle->vertex[1] > header->num_vertexes || triangle->vertex[2] > header->num_vertexes ) { @@ -337,14 +337,14 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na } // check ioq3 limits - if ( mesh->num_vertexes >= SHADER_MAX_VERTEXES ) + if ( mesh->num_vertexes >= SHADER_MAX_VERTEXES ) { ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i verts on %s (%i).\n", mod_name, SHADER_MAX_VERTEXES-1, meshName[0] ? meshName : "a surface", mesh->num_vertexes ); return qfalse; } - if ( mesh->num_triangles*3 >= SHADER_MAX_INDEXES ) + if ( mesh->num_triangles*3 >= SHADER_MAX_INDEXES ) { ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i triangles on %s (%i).\n", mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, meshName[0] ? meshName : "a surface", @@ -534,10 +534,10 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na joint = (iqmJoint_t *)((byte *)header + header->ofs_joints); for( i = 0; i < header->num_joints; i++, joint++ ) { float baseFrame[12], invBaseFrame[12]; - + JointToMatrix( joint->rotate, joint->scale, joint->translate, baseFrame ); Matrix34Invert( baseFrame, invBaseFrame ); - + if ( joint->parent >= 0 ) { Matrix34Multiply( iqmData->jointMats + 12 * joint->parent, baseFrame, mat ); @@ -600,14 +600,14 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na // construct transformation matrix JointToMatrix( rotate, scale, translate, mat1 ); - + if( pose->parent >= 0 ) { Matrix34Multiply( iqmData->jointMats + 12 * pose->parent, mat1, mat2 ); } else { Com_Memcpy( mat2, mat1, sizeof(mat1) ); } - + Matrix34Multiply( mat2, jointInvMats + 12 * j, mat ); mat += 12; } @@ -862,7 +862,7 @@ void R_AddIQMSurfaces( trRefEntity_t *ent, int entityNum ) { // when the surfaces are rendered, they don't need to be // range checked again. // - if ( (ent->e.frame >= data->num_frames) + if ( (ent->e.frame >= data->num_frames) || (ent->e.frame < 0) || (ent->e.oldframe >= data->num_frames) || (ent->e.oldframe < 0) ) { @@ -913,9 +913,9 @@ void R_AddIQMSurfaces( trRefEntity_t *ent, int entityNum ) { // stencil shadows can't do personal models unless I polyhedron clip if ( !personalModel - && r_shadows->integer == 2 + && r_shadows->integer == 2 && fogNum == 0 - && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) + && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) && shader->sort == SS_OPAQUE ) { R_AddDrawSurf( (surfaceType_t *)surface, entityNum, tr.shadowShader, 0, 0, R_IsPostRenderEntity(ent), 0 ); } @@ -968,7 +968,7 @@ static void ComputePoseMats( iqmData_t *data, int frame, int oldframe, } else { mat1 = data->poseMats + 12 * data->num_poses * frame; mat2 = data->poseMats + 12 * data->num_poses * oldframe; - + for( i = 0; i < data->num_poses; i++, joint++ ) { if( *joint >= 0 ) { float tmpMat[12]; @@ -976,7 +976,7 @@ static void ComputePoseMats( iqmData_t *data, int frame, int oldframe, backlerp, tmpMat ); Matrix34Multiply( mat + 12 * *joint, tmpMat, mat + 12*i ); - + } else { InterpolateMatrix( mat1 + 12*i, mat2 + 12*i, backlerp, mat ); @@ -1150,7 +1150,7 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) { } int R_IQMLerpTag( orientation_t *tag, iqmData_t *data, - int startFrame, int endFrame, + int startFrame, int endFrame, float frac, const char *tagName ) { float jointMats[IQM_MAX_JOINTS * 12]; int joint; diff --git a/shared/rd-rend2/tr_postprocess.cpp b/shared/rd-rend2/tr_postprocess.cpp index 9502cb50e7..b4c2784ca9 100644 --- a/shared/rd-rend2/tr_postprocess.cpp +++ b/shared/rd-rend2/tr_postprocess.cpp @@ -66,7 +66,7 @@ void RB_ToneMap(FBO_t *hdrFbo, vec4i_t hdrBox, FBO_t *ldrFbo, vec4i_t ldrBox, in // blend with old log luminance for gradual change VectorSet4(srcBox, 0, 0, 0, 0); - color[0] = + color[0] = color[1] = color[2] = 1.0f; @@ -97,14 +97,14 @@ RB_BokehBlur Blurs a part of one framebuffer to another. -Framebuffers can be identical. +Framebuffers can be identical. ============= */ void RB_BokehBlur(FBO_t *src, vec4i_t srcBox, FBO_t *dst, vec4i_t dstBox, float blur) { // vec4i_t srcBox, dstBox; vec4_t color; - + blur *= 10.0f; if (blur < 0.004f) @@ -229,7 +229,7 @@ static void RB_RadialBlur(FBO_t *srcFbo, FBO_t *dstFbo, int passes, float stretc { vec2_t texScale; - texScale[0] = + texScale[0] = texScale[1] = 1.0f; alpha *= inc; @@ -263,7 +263,7 @@ static void RB_RadialBlur(FBO_t *srcFbo, FBO_t *dstFbo, int passes, float stretc srcBox[2] = (s1 - s0) * glConfig.vidWidth; srcBox[3] = (t1 - t0) * glConfig.vidHeight; } - + FBO_Blit(srcFbo, srcBox, texScale, dstFbo, dstBox, &tr.textureColorShader, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); scale *= mul; @@ -295,7 +295,7 @@ static qboolean RB_UpdateSunFlareVis(void) ri.Printf(PRINT_DEVELOPER, "Waited %d iterations\n", iter); } - + qglGetQueryObjectuiv(tr.sunFlareQuery[tr.sunFlareQueryIndex], GL_QUERY_RESULT, &sampleCount); return (qboolean)(sampleCount > 0); } @@ -348,7 +348,7 @@ void RB_SunRays(FBO_t *srcFbo, vec4i_t srcBox, FBO_t *dstFbo, vec4i_t dstBox) vec2_t texScale; vec4i_t rayBox, quarterBox; - texScale[0] = + texScale[0] = texScale[1] = 1.0f; VectorSet4(color, mul, mul, mul, 1); @@ -396,13 +396,13 @@ void RB_SunRays(FBO_t *srcFbo, vec4i_t srcBox, FBO_t *dstFbo, vec4i_t dstBox) stretch += stretch_add; } } - + // add result back on top of the main buffer { float mul = 1.f; vec2_t texScale; - texScale[0] = + texScale[0] = texScale[1] = 1.0f; VectorSet4(color, mul, mul, mul, 1); @@ -437,7 +437,7 @@ static void RB_BlurAxis(FBO_t *srcFbo, FBO_t *dstFbo, float strength, qboolean h vec4_t color; vec2_t texScale; - texScale[0] = + texScale[0] = texScale[1] = 1.0f; VectorSet4(color, weights[0], weights[0], weights[0], 1.0f); @@ -491,8 +491,7 @@ void RB_BloomDownscale(image_t *sourceImage, FBO_t *destFBO) FBO_Bind(destFBO); GL_State(GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); - - qglViewport(0, 0, destFBO->width, destFBO->height); + GL_SetViewportAndScissor(0, 0, destFBO->width, destFBO->height); qglClearBufferfv(GL_COLOR, 0, colorBlack); GLSL_BindProgram(&tr.dglowDownsample); @@ -515,8 +514,7 @@ void RB_BloomUpscale(FBO_t *sourceFBO, FBO_t *destFBO) FBO_Bind(destFBO); GL_State(GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); - - glViewport(0, 0, destFBO->width, destFBO->height); + GL_SetViewportAndScissor(0, 0, destFBO->width, destFBO->height); qglClearBufferfv(GL_COLOR, 0, colorBlack); GLSL_BindProgram(&tr.dglowUpsample); diff --git a/shared/rd-rend2/tr_scene.cpp b/shared/rd-rend2/tr_scene.cpp index 51a212203a..3c417d6f51 100644 --- a/shared/rd-rend2/tr_scene.cpp +++ b/shared/rd-rend2/tr_scene.cpp @@ -143,7 +143,7 @@ void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts poly->hShader = hShader; poly->numVerts = numVerts; poly->verts = &backEndData->polyVerts[r_numpolyverts]; - + Com_Memcpy( poly->verts, &verts[numVerts*j], numVerts * sizeof( *verts ) ); // done. @@ -165,7 +165,7 @@ void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts AddPointToBounds( poly->verts[i].xyz, bounds[0], bounds[1] ); } for ( fogIndex = 1 ; fogIndex < tr.world->numfogs ; fogIndex++ ) { - fog = &tr.world->fogs[fogIndex]; + fog = &tr.world->fogs[fogIndex]; if ( bounds[1][0] >= fog->bounds[0][0] && bounds[1][1] >= fog->bounds[0][1] && bounds[1][2] >= fog->bounds[0][2] @@ -275,7 +275,7 @@ void RE_AddDynamicLightToScene( const vec3_t org, float intensity, float r, floa dl->color[1] = g; dl->color[2] = b; - if (r_hdr->integer) + if (r_hdr->integer) { float maxValue = MAX(r, MAX(g, b)); if (maxValue > 1.0f) @@ -287,7 +287,7 @@ void RE_AddDynamicLightToScene( const vec3_t org, float intensity, float r, floa } dl->radius = MIN(dl->radius, 65535.0f); } - + dl->additive = additive; } @@ -445,7 +445,7 @@ void RE_BeginScene(const refdef_t *fd) VectorCopy(extra->sunCol, tr.refdef.sunCol); VectorCopy(extra->sunAmbCol, tr.refdef.sunAmbCol); } - } + } else { tr.refdef.blurFactor = 0.0f; @@ -535,7 +535,7 @@ Rendering a scene may require multiple views to be rendered to handle mirrors, @@@@@@@@@@@@@@@@@@@@@ */ -void RE_RenderScene( const refdef_t *fd ) +void RE_RenderScene( const refdef_t *fd ) { int startTime; diff --git a/shared/rd-rend2/tr_shade.cpp b/shared/rd-rend2/tr_shade.cpp index f5805113a4..c9942ad999 100644 --- a/shared/rd-rend2/tr_shade.cpp +++ b/shared/rd-rend2/tr_shade.cpp @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // tr_shade.c -#include "tr_local.h" +#include "tr_local.h" #include "tr_allocator.h" /* @@ -52,7 +52,7 @@ void R_DrawElementsVBO( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex } -static void R_DrawMultiElementsVBO( int multiDrawPrimitives, glIndex_t *multiDrawMinIndex, glIndex_t *multiDrawMaxIndex, +static void R_DrawMultiElementsVBO( int multiDrawPrimitives, glIndex_t *multiDrawMinIndex, glIndex_t *multiDrawMaxIndex, GLsizei *multiDrawNumIndexes, glIndex_t **multiDrawFirstIndex) { GL_MultiDrawIndexed( @@ -195,7 +195,7 @@ static void ComputeTexMods( shaderStage_t *pStage, int bundleNum, float *outMatr for ( tm = 0; tm < bundle->numTexMods ; tm++ ) { switch ( bundle->texMods[tm].type ) { - + case TMOD_NONE: tm = TR_MAX_TEXMODS; // break out of for loop break; @@ -217,9 +217,9 @@ static void ComputeTexMods( shaderStage_t *pStage, int bundleNum, float *outMatr RB_CalcScaleTexMatrix( bundle->texMods[tm].scale, matrix ); break; - + case TMOD_STRETCH: - RB_CalcStretchTexMatrix( &bundle->texMods[tm].wave, + RB_CalcStretchTexMatrix( &bundle->texMods[tm].wave, matrix ); break; @@ -239,7 +239,7 @@ static void ComputeTexMods( shaderStage_t *pStage, int bundleNum, float *outMatr } switch ( bundle->texMods[tm].type ) - { + { case TMOD_NONE: case TMOD_TURBULENT: default: @@ -276,14 +276,14 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t colorGen_t rgbGen = pStage->rgbGen; alphaGen_t alphaGen = pStage->alphaGen; - baseColor[0] = - baseColor[1] = - baseColor[2] = - baseColor[3] = 1.0f; - - vertColor[0] = - vertColor[1] = - vertColor[2] = + baseColor[0] = + baseColor[1] = + baseColor[2] = + baseColor[3] = 1.0f; + + vertColor[0] = + vertColor[1] = + vertColor[2] = vertColor[3] = 0.0f; if ( forceRGBGen != NULL && *forceRGBGen != CGEN_BAD ) @@ -299,20 +299,20 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t switch ( rgbGen ) { case CGEN_IDENTITY_LIGHTING: - baseColor[0] = + baseColor[0] = baseColor[1] = baseColor[2] = tr.identityLight; break; case CGEN_EXACT_VERTEX: case CGEN_EXACT_VERTEX_LIT: - baseColor[0] = + baseColor[0] = baseColor[1] = - baseColor[2] = + baseColor[2] = baseColor[3] = 0.0f; vertColor[0] = vertColor[1] = - vertColor[2] = + vertColor[2] = vertColor[3] = 1.0f; break; case CGEN_CONST: @@ -322,7 +322,7 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t baseColor[3] = pStage->constantColor[3]; break; case CGEN_VERTEX: - baseColor[0] = + baseColor[0] = baseColor[1] = baseColor[2] = baseColor[3] = 0.0f; @@ -333,18 +333,18 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor[3] = 1.0f; break; case CGEN_VERTEX_LIT: - baseColor[0] = + baseColor[0] = baseColor[1] = - baseColor[2] = + baseColor[2] = baseColor[3] = 0.0f; vertColor[0] = vertColor[1] = - vertColor[2] = + vertColor[2] = vertColor[3] = tr.identityLight; break; case CGEN_ONE_MINUS_VERTEX: - baseColor[0] = + baseColor[0] = baseColor[1] = baseColor[2] = tr.identityLight; @@ -359,8 +359,8 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t } break; case CGEN_WAVEFORM: - baseColor[0] = - baseColor[1] = + baseColor[0] = + baseColor[1] = baseColor[2] = RB_CalcWaveColorSingle( &pStage->rgbWave ); break; case CGEN_ENTITY: @@ -460,9 +460,9 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t { *forceRGBGen = rgbGen; } - + // multiply color by overbrightbits if this isn't a blend - if (tr.overbrightBits + if (tr.overbrightBits && !((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_DST_COLOR) && !((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_ONE_MINUS_DST_COLOR) && !((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_SRC_COLOR) @@ -484,7 +484,7 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t if(r_greyscale->integer) { int scale; - + for(i = 0; i < tess.numVertexes; i++) { scale = (tess.svars.colors[i][0] + tess.svars.colors[i][1] + tess.svars.colors[i][2]) / 3; @@ -1046,7 +1046,7 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v if (glState.skeletalAnimation) shaderBits |= FOGDEF_USE_SKELETAL_ANIMATION; - if (tr.world && tr.world->globalFog && + if (tr.world && tr.world->globalFog && input->fogNum != tr.world->globalFogIndex && input->shader->sort != SS_FOG) shaderBits |= FOGDEF_USE_FALLBACK_GLOBAL_FOG; @@ -1054,7 +1054,7 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v if (input->numPasses > 0) if (input->xstages[0]->alphaTestType != ALPHA_TEST_NONE) shaderBits |= FOGDEF_USE_ALPHA_TEST; - + shaderProgram_t *sp = tr.fogShader + shaderBits; backEnd.pc.c_fogDraws++; @@ -1064,7 +1064,7 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v uniformDataWriter.SetUniformInt(UNIFORM_FOGINDEX, input->fogNum - 1); if (input->numPasses > 0) uniformDataWriter.SetUniformInt(UNIFORM_ALPHA_TEST_TYPE, input->xstages[0]->alphaTestType); - + uint32_t stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; if ( tess.shader->fogPass == FP_EQUAL ) stateBits |= GLS_DEPTHFUNC_EQUAL; @@ -1249,6 +1249,11 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag { index |= LIGHTDEF_USE_ALPHA_TEST; } + + // TODO: remove light vertex def and fix parallax usage on unlit stages like glow stages + if (stage->glslShaderIndex & LIGHTDEF_USE_PARALLAXMAP && + stage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) + index |= LIGHTDEF_USE_PARALLAXMAP | LIGHTDEF_USE_LIGHT_VERTEX; result = &stage->glslShaderGroup[index]; backEnd.pc.c_lightallDraws++; @@ -1314,7 +1319,7 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag if (glState.skeletalAnimation) { index |= LIGHTDEF_USE_SKELETAL_ANIMATION; - } + } } if ( !useAlphaTestGE192 ) @@ -1498,7 +1503,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays assert(sp); uniformDataWriter.Start(sp); - + if ( input->fogNum ) { vec4_t fogColorMask; ComputeFogColorMask(pStage, fogColorMask); @@ -1537,7 +1542,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays if (backEnd.currentEntity->e.renderfx & RF_FORCE_ENT_ALPHA) { - baseColor[3] = backEnd.currentEntity->e.shaderRGBA[3] / 255.0f; + baseColor[3] = backEnd.currentEntity->e.shaderRGBA[3] / 255.0f; vertColor[3] = 0.0f; } @@ -1602,7 +1607,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays texMatrix[0] = texMatrix[3] = input->texCoords[input->firstIndex][0][0]; else #endif - ComputeTexMods(pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb); + ComputeTexMods(pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb); uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXMATRIX, texMatrix); uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXOFFTURB, texOffTurb); @@ -1676,6 +1681,23 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays samplerBindingsWriter.AddStaticImage(tr.whiteImage, 0); else if ( pStage->bundle[TB_COLORMAP].image[0] != 0 ) samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[TB_COLORMAP], TB_COLORMAP); + + // TODO: remove light requirement + if (pStage->glslShaderIndex & LIGHTDEF_USE_PARALLAXMAP && + pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) + { + vec4_t enableTextures = {}; + if (pStage->bundle[TB_NORMALMAP].image[0]) + { + samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[TB_NORMALMAP], TB_NORMALMAP); + enableTextures[0] = 1.0f; + } + else if (r_normalMapping->integer) + { + samplerBindingsWriter.AddStaticImage(tr.whiteImage, TB_NORMALMAP); + } + uniformDataWriter.SetUniformVec4(UNIFORM_ENABLETEXTURES, enableTextures); + } } else if ( pStage->glslShaderGroup == tr.lightallShader ) { @@ -1786,7 +1808,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[0], 0); samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[1], 1); } - else + else { // // set state @@ -1812,7 +1834,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformVec4(UNIFORM_CUBEMAPINFO, vec); } - + if (enableDLights) { uniformDataWriter.SetUniformInt(UNIFORM_LIGHTMASK, tess.dlightBits); @@ -1881,7 +1903,7 @@ void RB_StageIteratorGeneric( void ) // // log this call // - if ( r_logFile->integer ) + if ( r_logFile->integer ) { // don't just call LogComment, or we will get // a call to va() every frame! @@ -1890,7 +1912,7 @@ void RB_StageIteratorGeneric( void ) // // update vertex buffer data - // + // uint32_t vertexAttribs = RB_CalcShaderVertexAttribs( input->shader ); if (tess.useInternalVBO) { @@ -2009,7 +2031,7 @@ void RB_EndSurface( void ) { if (input->indexes[SHADER_MAX_INDEXES-1] != 0) { ri.Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_INDEXES hit"); - } + } if (input->xyz[SHADER_MAX_VERTEXES-1][0] != 0) { ri.Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_VERTEXES hit"); } diff --git a/shared/rd-rend2/tr_shade_calc.cpp b/shared/rd-rend2/tr_shade_calc.cpp index 0af7479f3d..cca523af5d 100644 --- a/shared/rd-rend2/tr_shade_calc.cpp +++ b/shared/rd-rend2/tr_shade_calc.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define WAVEVALUE( table, base, amplitude, phase, freq ) ((base) + table[ Q_ftol( ( ( (phase) + tess.shaderTime * (freq) ) * FUNCTABLE_SIZE ) ) & FUNCTABLE_MASK ] * (amplitude)) -static float *TableForFunc( genFunc_t func ) +static float *TableForFunc( genFunc_t func ) { switch ( func ) { @@ -54,7 +54,7 @@ static float *TableForFunc( genFunc_t func ) ** ** Evaluates a given waveForm_t, referencing backEnd.refdef.time directly */ -static float EvalWaveForm( const waveForm_t *wf ) +static float EvalWaveForm( const waveForm_t *wf ) { float *table; @@ -133,7 +133,7 @@ void RB_CalcDeformVertexes( deformStage_t *ds ) for ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal++ ) { R_VboUnpackNormal(offset, *normal); - + xyz[0] += offset[0] * scale; xyz[1] += offset[1] * scale; xyz[2] += offset[2] * scale; @@ -147,7 +147,7 @@ void RB_CalcDeformVertexes( deformStage_t *ds ) { float off = ( xyz[0] + xyz[1] + xyz[2] ) * ds->deformationSpread; - scale = WAVEVALUE( table, ds->deformationWave.base, + scale = WAVEVALUE( table, ds->deformationWave.base, ds->deformationWave.amplitude, ds->deformationWave.phase + off, ds->deformationWave.frequency ); @@ -225,7 +225,7 @@ void RB_CalcBulgeVertexes( deformStage_t *ds ) { off = (float)( FUNCTABLE_SIZE / (M_PI*2) ) * ( st[0] * ds->bulgeWidth + now ); scale = tr.sinTable[ off & FUNCTABLE_MASK ] * ds->bulgeHeight; - + xyz[0] += fNormal[0] * scale; xyz[1] += fNormal[1] * scale; xyz[2] += fNormal[2] * scale; @@ -249,7 +249,7 @@ void RB_CalcMoveVertexes( deformStage_t *ds ) { table = TableForFunc( ds->deformationWave.func ); - scale = WAVEVALUE( table, ds->deformationWave.base, + scale = WAVEVALUE( table, ds->deformationWave.base, ds->deformationWave.amplitude, ds->deformationWave.phase, ds->deformationWave.frequency ); @@ -477,7 +477,7 @@ static void Autosprite2Deform( void ) { v2 = xyz + 4 * edgeVerts[j][1]; VectorSubtract( v1, v2, temp ); - + l = DotProduct( temp, temp ); if ( l < lengths[0] ) { nums[1] = nums[0]; @@ -505,7 +505,7 @@ static void Autosprite2Deform( void ) { // cross this with the view direction to get minor axis CrossProduct( major, forward, minor ); VectorNormalize( minor ); - + // re-project the points for ( j = 0 ; j < 2 ; j++ ) { float l; @@ -514,7 +514,7 @@ static void Autosprite2Deform( void ) { v2 = xyz + 4 * edgeVerts[nums[j]][1]; l = 0.5 * sqrt( lengths[j] ); - + // we need to see which direction this edge // is used to determine direction of projection for ( k = 0 ; k < 5 ; k++ ) { @@ -614,7 +614,7 @@ float RB_CalcWaveColorSingle( const waveForm_t *wf ) } else { glow = EvalWaveForm( wf ) * tr.identityLight; } - + if ( glow < 0 ) { glow = 0; } @@ -697,11 +697,11 @@ void RB_CalcFogTexCoords( float *st ) { // rotate the gradient vector for this orientation if ( fog->hasSurface ) { - fogDepthVector[0] = fog->surface[0] * backEnd.ori.axis[0][0] + + fogDepthVector[0] = fog->surface[0] * backEnd.ori.axis[0][0] + fog->surface[1] * backEnd.ori.axis[0][1] + fog->surface[2] * backEnd.ori.axis[0][2]; - fogDepthVector[1] = fog->surface[0] * backEnd.ori.axis[1][0] + + fogDepthVector[1] = fog->surface[0] * backEnd.ori.axis[1][0] + fog->surface[1] * backEnd.ori.axis[1][1] + fog->surface[2] * backEnd.ori.axis[1][2]; - fogDepthVector[2] = fog->surface[0] * backEnd.ori.axis[2][0] + + fogDepthVector[2] = fog->surface[0] * backEnd.ori.axis[2][0] + fog->surface[1] * backEnd.ori.axis[2][1] + fog->surface[2] * backEnd.ori.axis[2][2]; fogDepthVector[3] = -fog->surface[3] + DotProduct( backEnd.ori.origin, fog->surface ); @@ -727,7 +727,7 @@ void RB_CalcFogTexCoords( float *st ) { s = DotProduct( v, fogDistanceVector ) + fogDistanceVector[3]; t = DotProduct( v, fogDepthVector ) + fogDepthVector[3]; - // partially clipped fogs use the T axis + // partially clipped fogs use the T axis if ( eyeOutside ) { if ( t < 1.0 ) { t = 1.0/32; // point is outside, so no fogging diff --git a/shared/rd-rend2/tr_shader.cpp b/shared/rd-rend2/tr_shader.cpp index 0679552d6a..309312fe6b 100644 --- a/shared/rd-rend2/tr_shader.cpp +++ b/shared/rd-rend2/tr_shader.cpp @@ -27,7 +27,7 @@ static char *s_shaderText; // the shader is parsed into these global variables, then copied into // dynamically allocated memory if it is valid. -static shaderStage_t stages[MAX_SHADER_STAGES]; +static shaderStage_t stages[MAX_SHADER_STAGES]; static shader_t shader; static texModInfo_t texMods[MAX_SHADER_STAGES][TR_MAX_TEXMODS]; @@ -51,31 +51,31 @@ static shader_t* hashTable[FILE_HASH_SIZE]; #define MAX_SHADERTEXT_HASH 2048 static char **shaderTextHashTable[MAX_SHADERTEXT_HASH] = { 0 }; -const int lightmapsNone[MAXLIGHTMAPS] = -{ +const int lightmapsNone[MAXLIGHTMAPS] = +{ LIGHTMAP_NONE, LIGHTMAP_NONE, LIGHTMAP_NONE, - LIGHTMAP_NONE + LIGHTMAP_NONE }; -const int lightmaps2d[MAXLIGHTMAPS] = -{ +const int lightmaps2d[MAXLIGHTMAPS] = +{ LIGHTMAP_2D, LIGHTMAP_2D, LIGHTMAP_2D, - LIGHTMAP_2D + LIGHTMAP_2D }; -const int lightmapsVertex[MAXLIGHTMAPS] = -{ +const int lightmapsVertex[MAXLIGHTMAPS] = +{ LIGHTMAP_BY_VERTEX, LIGHTMAP_BY_VERTEX, LIGHTMAP_BY_VERTEX, - LIGHTMAP_BY_VERTEX + LIGHTMAP_BY_VERTEX }; -const int lightmapsFullBright[MAXLIGHTMAPS] = +const int lightmapsFullBright[MAXLIGHTMAPS] = { LIGHTMAP_WHITEIMAGE, LIGHTMAP_WHITEIMAGE, @@ -83,7 +83,7 @@ const int lightmapsFullBright[MAXLIGHTMAPS] = LIGHTMAP_WHITEIMAGE }; -const byte stylesDefault[MAXLIGHTMAPS] = +const byte stylesDefault[MAXLIGHTMAPS] = { LS_NORMAL, LS_LSNONE, @@ -253,7 +253,7 @@ ParseAlphaTestFunc =============== */ static void ParseAlphaTestFunc( shaderStage_t *stage, const char *funcname ) -{ +{ stage->alphaTestType = ALPHA_TEST_NONE; if ( !Q_stricmp( funcname, "GT0" ) ) @@ -620,7 +620,7 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) return; } tmi->wave.frequency = atof( token ); - + tmi->type = TMOD_STRETCH; } // @@ -1232,7 +1232,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) else if ( !Q_stricmp( token, "map" ) || (!Q_stricmp(token, "clampmap"))) { int flags = !Q_stricmp(token, "clampmap") ? IMGFLAG_CLAMPTOEDGE : IMGFLAG_NONE; - + token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { @@ -1385,7 +1385,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) ri.Printf(PRINT_WARNING, "WARNING: R_FindImageFile could not find specMap '%s' in shader '%s'\n", token, shader.name); return qfalse; } - + } // // rmoMap || rmosMap @@ -1619,8 +1619,8 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) ri.Printf( PRINT_WARNING, "WARNING: missing parameter for specular reflectance in shader '%s'\n", shader.name ); continue; } - stage->specularScale[0] = - stage->specularScale[1] = + stage->specularScale[0] = + stage->specularScale[1] = stage->specularScale[2] = Com_Clamp( 0.0f, 1.0f, atof( token ) ); } // @@ -1638,13 +1638,13 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } exponent = atof( token ); - // Change shininess to gloss - // FIXME: assumes max exponent of 8192 and min of 1, must change here if altered in lightall_fp.glsl - exponent = CLAMP(exponent, 1.0, 8192.0); + // Change shininess to gloss + // FIXME: assumes max exponent of 8192 and min of 1, must change here if altered in lightall_fp.glsl + exponent = CLAMP(exponent, 1.0, 8192.0); stage->specularScale[3] = 1.0f - (log(exponent) / log(8192.0)); } // - // gloss + // gloss // else if ( !Q_stricmp( token, "gloss" ) ) { @@ -1876,7 +1876,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } } // - // alphaGen + // alphaGen // else if ( !Q_stricmp( token, "alphaGen" ) ) { @@ -1953,7 +1953,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // // tcGen // - else if ( !Q_stricmp(token, "texgen") || !Q_stricmp( token, "tcGen" ) ) + else if ( !Q_stricmp(token, "texgen") || !Q_stricmp( token, "tcGen" ) ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) @@ -1985,7 +1985,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) stage->bundle[0].tcGen = TCGEN_VECTOR; } - else + else { ri.Printf( PRINT_WARNING, "WARNING: unknown texgen parm in shader '%s'\n", shader.name ); } @@ -2154,7 +2154,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // if ( stage->rgbGen == CGEN_BAD ) { if ( blendSrcBits == 0 || - blendSrcBits == GLS_SRCBLEND_ONE || + blendSrcBits == GLS_SRCBLEND_ONE || blendSrcBits == GLS_SRCBLEND_SRC_ALPHA ) { stage->rgbGen = CGEN_IDENTITY_LIGHTING; } else { @@ -2166,7 +2166,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // // implicitly assume that a GL_ONE GL_ZERO blend mask disables blending // - if ( ( blendSrcBits == GLS_SRCBLEND_ONE ) && + if ( ( blendSrcBits == GLS_SRCBLEND_ONE ) && ( blendDstBits == GLS_DSTBLEND_ZERO ) ) { blendDstBits = blendSrcBits = 0; @@ -2184,8 +2184,8 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // // compute state bits // - stage->stateBits = depthMaskBits | - blendSrcBits | blendDstBits | + stage->stateBits = depthMaskBits | + blendSrcBits | blendDstBits | depthFuncBits; return qtrue; @@ -2241,7 +2241,7 @@ static void ParseDeform( const char **text ) { if ( !Q_stricmpn( token, "text", 4 ) ) { int n; - + n = token[4] - '0'; if ( n < 0 || n > 7 ) { n = 0; @@ -2450,7 +2450,7 @@ void ParseSort( const char **text ) { shader.sort = SS_MID_OUTSIDE; } else if ( !Q_stricmp( token, "outside" ) ) { shader.sort = SS_OUTSIDE; - } + } else { shader.sort = atof( token ); } @@ -2466,20 +2466,20 @@ const char *materialNames[MATERIAL_LAST] = MATERIALS }; -void ParseMaterial( const char **text ) +void ParseMaterial( const char **text ) { char *token; int i; token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) + if ( token[0] == 0 ) { Com_Printf (S_COLOR_YELLOW "WARNING: missing material in shader '%s'\n", shader.name ); return; } for(i = 0; i < MATERIAL_LAST; i++) { - if ( !Q_stricmp( token, materialNames[i] ) ) + if ( !Q_stricmp( token, materialNames[i] ) ) { shader.surfaceFlags |= i; break; @@ -2501,13 +2501,13 @@ infoParm_t infoParms[] = { { "nonopaque", ~CONTENTS_OPAQUE, SURF_NONE, CONTENTS_NONE }, // special hack to clear opaque flag { "lava", ~CONTENTS_SOLID, SURF_NONE, CONTENTS_LAVA }, // very damaging { "slime", ~CONTENTS_SOLID, SURF_NONE, CONTENTS_SLIME }, // mildly damaging - { "water", ~CONTENTS_SOLID, SURF_NONE, CONTENTS_WATER }, // + { "water", ~CONTENTS_SOLID, SURF_NONE, CONTENTS_WATER }, // { "fog", ~CONTENTS_SOLID, SURF_NONE, CONTENTS_FOG}, // carves surfaces entering { "shotclip", ~CONTENTS_SOLID, SURF_NONE, CONTENTS_SHOTCLIP }, // block shots, but not people { "playerclip", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_PLAYERCLIP }, // block only the player - { "monsterclip", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_MONSTERCLIP }, // + { "monsterclip", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_MONSTERCLIP }, // { "botclip", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_BOTCLIP }, // for bots - { "trigger", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_TRIGGER }, // + { "trigger", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_TRIGGER }, // { "nodrop", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_NODROP }, // don't drop items or leave bodies (death fog, lava, etc) { "terrain", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_TERRAIN }, // use special terrain collsion { "ladder", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_LADDER }, // climb up in it like water @@ -2520,17 +2520,17 @@ infoParm_t infoParms[] = { /* Game surface flags */ { "sky", CONTENTS_ALL, SURF_SKY, CONTENTS_NONE }, // emit light from an environment map - { "slick", CONTENTS_ALL, SURF_SLICK, CONTENTS_NONE }, // + { "slick", CONTENTS_ALL, SURF_SLICK, CONTENTS_NONE }, // - { "nodamage", CONTENTS_ALL, SURF_NODAMAGE, CONTENTS_NONE }, // + { "nodamage", CONTENTS_ALL, SURF_NODAMAGE, CONTENTS_NONE }, // { "noimpact", CONTENTS_ALL, SURF_NOIMPACT, CONTENTS_NONE }, // don't make impact explosions or marks { "nomarks", CONTENTS_ALL, SURF_NOMARKS, CONTENTS_NONE }, // don't make impact marks, but still explode { "nodraw", CONTENTS_ALL, SURF_NODRAW, CONTENTS_NONE }, // don't generate a drawsurface (or a lightmap) - { "nosteps", CONTENTS_ALL, SURF_NOSTEPS, CONTENTS_NONE }, // + { "nosteps", CONTENTS_ALL, SURF_NOSTEPS, CONTENTS_NONE }, // { "nodlight", CONTENTS_ALL, SURF_NODLIGHT, CONTENTS_NONE }, // don't ever add dynamic lights - { "metalsteps", CONTENTS_ALL, SURF_METALSTEPS, CONTENTS_NONE }, // + { "metalsteps", CONTENTS_ALL, SURF_METALSTEPS, CONTENTS_NONE }, // { "nomiscents", CONTENTS_ALL, SURF_NOMISCENTS, CONTENTS_NONE }, // No misc ents on this surface - { "forcefield", CONTENTS_ALL, SURF_FORCEFIELD, CONTENTS_NONE }, // + { "forcefield", CONTENTS_ALL, SURF_FORCEFIELD, CONTENTS_NONE }, // { "forcesight", CONTENTS_ALL, SURF_FORCESIGHT, CONTENTS_NONE }, // only visible with force sight }; @@ -2623,7 +2623,7 @@ static qboolean ParseShader( const char **text ) else if ( !Q_stricmp( token, "material" ) || !Q_stricmp( token, "q3map_material" ) ) { ParseMaterial( text ); - } + } // sun parms else if ( !Q_stricmp( token, "sun" ) || !Q_stricmp( token, "q3map_sun" ) || !Q_stricmp( token, "q3map_sunExt" ) || !Q_stricmp( token, "q3gl2_sun" ) ) { float a, b; @@ -2641,7 +2641,7 @@ static qboolean ParseShader( const char **text ) tr.sunLight[1] = atof( token ); token = COM_ParseExt( text, qfalse ); tr.sunLight[2] = atof( token ); - + VectorNormalize( tr.sunLight ); token = COM_ParseExt( text, qfalse ); @@ -2780,7 +2780,7 @@ static qboolean ParseShader( const char **text ) continue; } // fogParms - else if ( !Q_stricmp( token, "fogParms" ) ) + else if ( !Q_stricmp( token, "fogParms" ) ) { if ( !ParseVector( text, 3, shader.fogParms.color ) ) { return qfalse; @@ -2794,7 +2794,7 @@ static qboolean ParseShader( const char **text ) } token = COM_ParseExt( text, qfalse ); - if ( !token[0] ) + if ( !token[0] ) { ri.Printf( PRINT_WARNING, "WARNING: missing parm for 'fogParms' keyword in shader '%s'\n", shader.name ); continue; @@ -2819,13 +2819,13 @@ static qboolean ParseShader( const char **text ) continue; } // light determines flaring in q3map, not needed here - else if ( !Q_stricmp(token, "light") ) + else if ( !Q_stricmp(token, "light") ) { COM_ParseExt( text, qfalse ); continue; } // cull - else if ( !Q_stricmp( token, "cull") ) + else if ( !Q_stricmp( token, "cull") ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) @@ -3000,7 +3000,7 @@ static void ComputeVertexAttribs(void) { shaderStage_t *pStage = &stages[stage]; - if ( !pStage->active ) + if ( !pStage->active ) { break; } @@ -3129,8 +3129,8 @@ static void CollapseStagesToLightall(shaderStage_t *stage, shaderStage_t *lightm image_t *diffuseImg; if (stage->bundle[TB_NORMALMAP].image[0]) { - if (stage->bundle[TB_NORMALMAP].image[0]->type == IMGTYPE_NORMALHEIGHT && - r_parallaxMapping->integer && + if (stage->bundle[TB_NORMALMAP].image[0]->type == IMGTYPE_NORMALHEIGHT && + r_parallaxMapping->integer && defs & LIGHTDEF_LIGHTTYPE_MASK) defs |= LIGHTDEF_USE_PARALLAXMAP; //ri.Printf(PRINT_ALL, ", normalmap %s", stage->bundle[TB_NORMALMAP].image[0]->imgName); @@ -3211,7 +3211,7 @@ static void CollapseStagesToLightall(shaderStage_t *stage, shaderStage_t *lightm Q_strcat(imageName, MAX_QPATH, "_rmo"); stage->specularType = SPEC_RMO; R_LoadPackedMaterialImage(stage, imageName, specularFlags); - + if (!stage->bundle[TB_ORMSMAP].image[0]) { COM_StripExtension(diffuseImg->imgName, imageName, MAX_QPATH); @@ -3299,7 +3299,7 @@ static qboolean CollapseStagesToGLSL(void) pStage->bundle[0].tcGen <= TCGEN_LIGHTMAP3) { int blendBits = pStage->stateBits & ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); - + if (blendBits != (GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO) && blendBits != (GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR) && blendBits != (GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE)) //lightstyle lightmap stages @@ -3520,7 +3520,7 @@ static qboolean CollapseStagesToGLSL(void) if (pStage->adjustColorsForFog) continue; - if (pStage->bundle[TB_DIFFUSEMAP].tcGen >= TCGEN_LIGHTMAP + if (pStage->bundle[TB_DIFFUSEMAP].tcGen >= TCGEN_LIGHTMAP && pStage->bundle[TB_DIFFUSEMAP].tcGen <= TCGEN_LIGHTMAP3 && pStage->rgbGen != CGEN_LIGHTMAPSTYLE) //don't convert lightstyled lightmap stages { @@ -3706,7 +3706,7 @@ static void SortNewShader( void ) { { break; } - + tr.sortedShaders[i+1] = shader; tr.sortedShaders[i+1]->sortedIndex++; } @@ -3779,7 +3779,7 @@ static shader_t *GeneratePermanentShader( void ) { tr.shaders[ tr.numShaders ] = newShader; newShader->index = tr.numShaders; - + tr.sortedShaders[ tr.numShaders ] = newShader; newShader->sortedIndex = tr.numShaders; @@ -3868,7 +3868,7 @@ static void VertexLightingCollapse( void ) { } else { stages[0].rgbGen = CGEN_EXACT_VERTEX; } - stages[0].alphaGen = AGEN_SKIP; + stages[0].alphaGen = AGEN_SKIP; } else { // don't use a lightmap (tesla coils) if ( stages[0].bundle[0].isLightmap ) { @@ -4089,23 +4089,23 @@ static shader_t *FinishShader( void ) { if ( pStage->isDetail && !r_detailTextures->integer ) { int index; - + for(index = stage + 1; index < MAX_SHADER_STAGES; index++) { if(!stages[index].active) break; } - + if(index < MAX_SHADER_STAGES) memmove(pStage, pStage + 1, sizeof(*pStage) * (index - stage)); else { if(stage + 1 < MAX_SHADER_STAGES) memmove(pStage, pStage + 1, sizeof(*pStage) * (index - stage - 1)); - + Com_Memset(&stages[index - 1], 0, sizeof(*stages)); } - + continue; } @@ -4180,7 +4180,7 @@ static shader_t *FinishShader( void ) { } } } - + stage++; } @@ -4275,7 +4275,7 @@ static const char *FindShaderInShaderText( const char *shadername ) { { p = shaderTextHashTable[hash][i]; token = COM_ParseExt(&p, qtrue); - + if(!Q_stricmp(token, shadername)) return p; } @@ -4595,7 +4595,7 @@ shader_t *R_FindShader( const char *name, const int *lightmapIndexes, const byte return FinishShader(); } -shader_t *R_FindServerShader( const char *name, const int *lightmapIndexes, const byte *styles, qboolean mipRawImage ) +shader_t *R_FindServerShader( const char *name, const int *lightmapIndexes, const byte *styles, qboolean mipRawImage ) { char strippedName[MAX_QPATH]; int hash; @@ -4627,7 +4627,7 @@ shader_t *R_FindServerShader( const char *name, const int *lightmapIndexes, cons ClearGlobalShader(); Q_strncpyz(shader.name, strippedName, sizeof(shader.name)); Com_Memcpy (shader.lightmapIndex, lightmapIndexes, sizeof (shader.lightmapIndex)); - + shader.defaultShader = qtrue; return FinishShader(); } @@ -4721,11 +4721,11 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, const int *lightmapIndexe } sh = FinishShader(); - return sh->index; + return sh->index; } -/* +/* ==================== RE_RegisterShader @@ -4759,7 +4759,7 @@ qhandle_t RE_RegisterShaderLightMap( const char *name, const int *lightmapIndexe } -/* +/* ==================== RE_RegisterShader @@ -4959,13 +4959,13 @@ static void ScanAndLoadShaderFiles( void ) Com_sprintf( filename, sizeof( filename ), "shaders/%s", shaderFiles[i] ); } } - + ri.Printf( PRINT_DEVELOPER, "...loading '%s'\n", filename ); summand = ri.FS_ReadFile( filename, (void **)&buffers[i] ); - + if ( !buffers[i] ) ri.Error( ERR_DROP, "Couldn't load %s", filename ); - + // Do a simple check on the shader structure in that file to make sure one bad shader file cannot fuck up all other shaders. p = buffers[i]; #ifndef REND2_SP @@ -4976,7 +4976,7 @@ static void ScanAndLoadShaderFiles( void ) while(1) { token = COM_ParseExt(&p, qtrue); - + if(!*token) break; @@ -5015,8 +5015,8 @@ static void ScanAndLoadShaderFiles( void ) break; } } - - + + if (buffers[i]) sum += summand; @@ -5029,7 +5029,7 @@ static void ScanAndLoadShaderFiles( void ) s_shaderText = (char *)Hunk_Alloc( sum + numShaderFiles*2, h_low ); s_shaderText[ 0 ] = '\0'; textEnd = s_shaderText; - + // free in reverse order, so the temp files are all dumped for ( i = numShaderFiles - 1; i >= 0 ; i-- ) { diff --git a/shared/rd-rend2/tr_shadows.cpp b/shared/rd-rend2/tr_shadows.cpp index eb0b472dfc..50a1475272 100644 --- a/shared/rd-rend2/tr_shadows.cpp +++ b/shared/rd-rend2/tr_shadows.cpp @@ -39,15 +39,12 @@ void RB_ShadowFinish(void) { return; } - GL_Cull(CT_TWO_SIDED); - GL_BindToTMU(tr.whiteImage, TB_COLORMAP); GL_State(GLS_STENCILTEST_ENABLE | GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO); qglStencilFunc(GL_NOTEQUAL, 0, 0xff); - qglViewport(0, 0, glConfig.vidWidth, glConfig.vidHeight); - qglScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight); + GL_SetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight); matrix_t projection; Matrix16Ortho(0, glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1, projection); diff --git a/shared/rd-rend2/tr_skin.cpp b/shared/rd-rend2/tr_skin.cpp index 6924083004..b5ba142159 100644 --- a/shared/rd-rend2/tr_skin.cpp +++ b/shared/rd-rend2/tr_skin.cpp @@ -49,9 +49,9 @@ bool RE_SplitSkins(const char *INname, char *skinhead, char *skintorso, char *sk strcpy (skinlower, name); //now get the the individual files - + //advance to second - char *p2 = strchr(p, '|'); + char *p2 = strchr(p, '|'); assert(p2); if (!p2) { @@ -77,14 +77,14 @@ bool RE_SplitSkins(const char *INname, char *skinhead, char *skintorso, char *sk strcat (skinlower,p); strcat (skinlower, ".skin"); - + return true; } return false; } // given a name, go get the skin we want and return -qhandle_t RE_RegisterIndividualSkin( const char *name , qhandle_t hSkin) +qhandle_t RE_RegisterIndividualSkin( const char *name , qhandle_t hSkin) { skin_t *skin; skinSurface_t *surf; @@ -124,7 +124,7 @@ qhandle_t RE_RegisterIndividualSkin( const char *name , qhandle_t hSkin) if ( !strncmp( token, "tag_", 4 ) ) { //these aren't in there, but just in case you load an id style one... continue; } - + // parse the shader name token = CommaParse( &text_p ); @@ -279,13 +279,13 @@ static char *CommaParse( char **data_p ) { data++; } // skip /* */ comments - else if ( c=='/' && data[1] == '*' ) + else if ( c=='/' && data[1] == '*' ) { - while ( *data && ( *data != '*' || data[1] != '/' ) ) + while ( *data && ( *data != '*' || data[1] != '/' ) ) { data++; } - if ( *data ) + if ( *data ) { data += 2; } @@ -475,7 +475,7 @@ void R_SkinList_f( void ) { Com_Printf ("%3i:%s\n", i, skin->name ); for ( j = 0 ; j < skin->numSurfaces ; j++ ) { - Com_Printf (" %s = %s\n", + Com_Printf (" %s = %s\n", skin->surfaces[j]->name, ((shader_t* )skin->surfaces[j]->shader)->name ); } } diff --git a/shared/rd-rend2/tr_sky.cpp b/shared/rd-rend2/tr_sky.cpp index 98a60c6058..9f9d8eb148 100644 --- a/shared/rd-rend2/tr_sky.cpp +++ b/shared/rd-rend2/tr_sky.cpp @@ -36,14 +36,14 @@ POLYGON TO BOX SIDE PROJECTION =================================================================================== */ -static vec3_t sky_clip[6] = +static vec3_t sky_clip[6] = { {1,1,0}, {1,-1,0}, {0,-1,1}, {0,1,1}, {1,0,1}, - {-1,0,1} + {-1,0,1} }; static float sky_mins[2][6], sky_maxs[2][6]; @@ -54,7 +54,7 @@ static float sky_min, sky_max; AddSkyPolygon ================ */ -static void AddSkyPolygon (int nump, vec3_t vecs) +static void AddSkyPolygon (int nump, vec3_t vecs) { int i,j; vec3_t v, av; @@ -147,7 +147,7 @@ static void AddSkyPolygon (int nump, vec3_t vecs) ClipSkyPolygon ================ */ -static void ClipSkyPolygon (int nump, vec3_t vecs, int stage) +static void ClipSkyPolygon (int nump, vec3_t vecs, int stage) { float *norm; float *v; @@ -266,10 +266,10 @@ void RB_ClipSkyPolygons( shaderCommands_t *input ) for ( i = 0; i < input->numIndexes; i += 3 ) { - for (j = 0 ; j < 3 ; j++) + for (j = 0 ; j < 3 ; j++) { VectorSubtract( input->xyz[input->indexes[i+j]], - backEnd.viewParms.ori.origin, + backEnd.viewParms.ori.origin, p[j] ); } ClipSkyPolygon( 3, p[0], 0 ); @@ -369,7 +369,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max int maxIndex = tess.maxIndex; tess.firstIndex = tess.numIndexes; - + for ( t = mins[1]+HALF_SKY_SUBDIVISIONS; t <= maxs[1]+HALF_SKY_SUBDIVISIONS; t++ ) { @@ -482,7 +482,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max RB_AddDrawItem(backEndData->currentPass, key, item); RB_CommitInternalBufferData(); - + tess.useInternalVBO = qfalse; tess.numIndexes = tess.firstIndex; tess.numVertexes = firstVertex; @@ -521,22 +521,22 @@ static void DrawSkyBox( shader_t *shader ) sky_maxs_subd[0] = sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS; sky_maxs_subd[1] = sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS; - if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) + if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS; - else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS ) + else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS ) sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS; if ( sky_mins_subd[1] < -HALF_SKY_SUBDIVISIONS ) sky_mins_subd[1] = -HALF_SKY_SUBDIVISIONS; - else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS ) + else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS ) sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS; - if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS ) + if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS; - else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS ) + else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS; - if ( sky_maxs_subd[1] < -HALF_SKY_SUBDIVISIONS ) + if ( sky_maxs_subd[1] < -HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[1] = -HALF_SKY_SUBDIVISIONS; - else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS ) + else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS; // @@ -548,10 +548,10 @@ static void DrawSkyBox( shader_t *shader ) for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ ) { - MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, - ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, - i, - s_skyTexCoords[t][s], + MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, + ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, + i, + s_skyTexCoords[t][s], s_skyPoints[t][s] ); } } @@ -593,7 +593,7 @@ static void FillCloudySkySide( const int mins[2], const int maxs[2], qboolean ad // only add indexes for one pass, otherwise it would draw multiple times for each pass if ( addIndexes ) { for ( t = 0; t < tHeight-1; t++ ) - { + { for ( s = 0; s < sWidth-1; s++ ) { tess.indexes[tess.numIndexes] = vertexStart + s + t * ( sWidth ); @@ -641,22 +641,22 @@ static void FillCloudBox( const shader_t *shader, int stage ) sky_maxs_subd[0] = Q_ftol(sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS); sky_maxs_subd[1] = Q_ftol(sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS); - if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) + if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS; - else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS ) + else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS ) sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS; if ( sky_mins_subd[1] < MIN_T ) sky_mins_subd[1] = MIN_T; - else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS ) + else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS ) sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS; - if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS ) + if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS; - else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS ) + else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS; if ( sky_maxs_subd[1] < MIN_T ) sky_maxs_subd[1] = MIN_T; - else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS ) + else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS; // @@ -668,9 +668,9 @@ static void FillCloudBox( const shader_t *shader, int stage ) for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ ) { - MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, - ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, - i, + MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, + ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, + i, NULL, s_skyPoints[t][s] ); @@ -743,20 +743,20 @@ void R_InitSkyTexCoords( float heightCloud ) for ( s = 0; s <= SKY_SUBDIVISIONS; s++ ) { // compute vector from view origin to sky side integral point - MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, - ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, - i, + MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, + ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, + i, NULL, skyVec ); // compute parametric value 'p' that intersects with cloud layer p = ( 1.0f / ( 2 * DotProduct( skyVec, skyVec ) ) ) * - ( -2 * skyVec[2] * radiusWorld + - 2 * sqrt( SQR( skyVec[2] ) * SQR( radiusWorld ) + + ( -2 * skyVec[2] * radiusWorld + + 2 * sqrt( SQR( skyVec[2] ) * SQR( radiusWorld ) + 2 * SQR( skyVec[0] ) * radiusWorld * heightCloud + - SQR( skyVec[0] ) * SQR( heightCloud ) + + SQR( skyVec[0] ) * SQR( heightCloud ) + 2 * SQR( skyVec[1] ) * radiusWorld * heightCloud + - SQR( skyVec[1] ) * SQR( heightCloud ) + + SQR( skyVec[1] ) * SQR( heightCloud ) + 2 * SQR( skyVec[2] ) * radiusWorld * heightCloud + SQR( skyVec[2] ) * SQR( heightCloud ) ) ); diff --git a/shared/rd-rend2/tr_surface.cpp b/shared/rd-rend2/tr_surface.cpp index 5ca4ae638e..2276cc48c6 100644 --- a/shared/rd-rend2/tr_surface.cpp +++ b/shared/rd-rend2/tr_surface.cpp @@ -240,14 +240,14 @@ void RB_InstantQuad(vec4_t quadVerts[4]) VectorSet2(texCoords[3], 0.0f, 1.0f); GLSL_BindProgram(&tr.textureColorShader); - + GLSL_SetUniformMatrix4x4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite); RB_InstantQuad2(quadVerts, texCoords); } -void RB_InstantTriangle() +void RB_InstantTriangle() { qglDrawArrays(GL_TRIANGLES, 0, 3); } @@ -273,7 +273,7 @@ static void RB_SurfaceSprite( void ) { } else { float s, c; float ang; - + ang = M_PI * ent->e.rotation / 180; s = sin( ang ); c = cos( ang ); @@ -310,17 +310,17 @@ static void RB_SurfaceOrientedQuad( void ) VectorCopy( backEnd.currentEntity->e.axis[1], left ); VectorCopy( backEnd.currentEntity->e.axis[2], up ); - if ( backEnd.currentEntity->e.rotation == 0 ) + if ( backEnd.currentEntity->e.rotation == 0 ) { VectorScale( left, radius, left ); VectorScale( up, radius, up ); - } - else + } + else { vec3_t tempLeft, tempUp; float s, c; float ang; - + ang = M_PI * backEnd.currentEntity->e.rotation / 180; s = sin( ang ); c = cos( ang ); @@ -336,7 +336,7 @@ static void RB_SurfaceOrientedQuad( void ) VectorCopy( tempLeft, left ); } - if ( backEnd.viewParms.isMirror ) + if ( backEnd.viewParms.isMirror ) { VectorSubtract( vec3_origin, left, left ); } @@ -679,12 +679,12 @@ static void RB_SurfaceBeam( void ) // FIXME: A lot of this can probably be removed for speed, and refactored into a more convenient function RB_UpdateVBOs(ATTR_POSITION); - + GLSL_VertexAttribsState(ATTR_POSITION, NULL); GLSL_BindProgram(sp); - + GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - + GLSL_SetUniformVec4(sp, UNIFORM_COLOR, colorRed); R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); @@ -702,13 +702,13 @@ static void RB_SurfaceBeam( void ) //------------------ // DoSprite //------------------ -static void DoSprite( vec3_t origin, float radius, float rotation ) +static void DoSprite( vec3_t origin, float radius, float rotation ) { float s, c; float ang; vec3_t left, up; float color[4]; - + ang = M_PI * rotation / 180.0f; s = sin( ang ); c = cos( ang ); @@ -719,7 +719,7 @@ static void DoSprite( vec3_t origin, float radius, float rotation ) VectorScale( backEnd.viewParms.ori.axis[2], c * radius, up ); VectorMA( up, s * radius, backEnd.viewParms.ori.axis[1], up ); - if ( backEnd.viewParms.isMirror ) + if ( backEnd.viewParms.isMirror ) { VectorSubtract( vec3_origin, left, left ); } @@ -733,7 +733,7 @@ static void DoSprite( vec3_t origin, float radius, float rotation ) // RB_SurfaceSaber //------------------ static void RB_SurfaceSaberGlow() -{ +{ vec3_t end; refEntity_t *e; @@ -765,13 +765,13 @@ RB_SurfaceLine // STScale (how many times to loop a texture) // alpha // RGB -// +// // Values for proper line object... // lifetime // dscale // startalpha, endalpha // startRGB, endRGB -// +// static void DoLine( const vec3_t start, const vec3_t end, const vec3_t up, float spanWidth ) { @@ -924,7 +924,7 @@ static void RB_SurfaceOrientedLine(void) //----------------- // RB_SurfaceLine //----------------- -static void RB_SurfaceLine( void ) +static void RB_SurfaceLine( void ) { refEntity_t *e; vec3_t right; @@ -971,7 +971,7 @@ static void DoCylinderPart(polyVert_t *verts) VectorScale4 (verts->modulate, 1.0f / 255.0f, tess.vertexColors[tess.numVertexes]); tess.numVertexes++; verts++; - } + } tess.indexes[tess.numIndexes++] = vbase; tess.indexes[tess.numIndexes++] = vbase + 1; @@ -1036,12 +1036,12 @@ static void RB_SurfaceCylinder( void ) //Upper ring RotatePointAroundVector( upper_points[i].xyz, e->axis[0], vu, detail * i ); VectorAdd( upper_points[i].xyz, e->origin, upper_points[i].xyz ); - + //Lower ring RotatePointAroundVector( lower_points[i].xyz, e->axis[0], v1, detail * i ); VectorAdd( lower_points[i].xyz, e->oldorigin, lower_points[i].xyz ); } - + // Calculate the texture coords so the texture can wrap around the whole cylinder detail = 1.0f / (float)segments; @@ -1147,7 +1147,7 @@ static void ApplyShape( vec3_t start, vec3_t end, vec3_t right, float sradius, f DoLine2( start, end, right, sradius, eradius, startPerc, endPerc); return; } - + CreateShape(); VectorSubtract( end, start, fwd ); @@ -1180,7 +1180,7 @@ static void ApplyShape( vec3_t start, vec3_t end, vec3_t right, float sradius, f VectorMA( point2, 1.0f - perc, end, point2 ); VectorMA( point2, dis * sh2[1], rt, point2 ); VectorMA( point2, dis * sh2[2], up, point2 ); - + // recursion #ifndef REND2_SP ApplyShape( point2, point1, right, rads1, rads2, count - 1 ); @@ -1275,7 +1275,7 @@ static void DoBoltSeg( vec3_t start, vec3_t end, vec3_t right, float radius ) #else ApplyShape(cur, old, right, newRadius, oldRadius, 2 - r_lodbias->integer, 0, 1); #endif - + // randomly split off to create little tendrils, but don't do it too close to the end and especially if we are not even of the forked variety if ( ( e->renderfx & RF_FORKED ) && f_count > 0 && Q_random(&e->frame) > 0.94f && radius * (1.0f - perc) > 0.2f ) { @@ -1365,13 +1365,13 @@ static void RB_SurfaceElectricity() static void VectorArrayNormalize(vec4_t *normals, unsigned int count) { // assert(count); - + #if idppc { register float half = 0.5; register float one = 1.0; float *components = (float *)normals; - + // Vanilla PPC code, but since PPC has a reciprocal square root estimate instruction, // runs *much* faster than calling sqrt(). We'll use a single Newton-Raphson // refinement step to get a little more precision. This seems to yeild results @@ -1380,14 +1380,14 @@ static void VectorArrayNormalize(vec4_t *normals, unsigned int count) do { float x, y, z; float B, y0, y1; - + x = components[0]; y = components[1]; z = components[2]; components += 4; B = x*x + y*y + z*z; -#ifdef __GNUC__ +#ifdef __GNUC__ asm("frsqrte %0,%1" : "=f" (y0) : "f" (B)); #else y0 = __frsqrte(B); @@ -1453,11 +1453,11 @@ static void LerpMeshVertexes_altivec(md3Surface_t *surf, float backlerp) vector unsigned char newNormalsLoadPermute; vector unsigned char newNormalsStorePermute; vector float zero; - + newNormalsStorePermute = vec_lvsl(0,(float *)&newXyzScaleVec); newXyzScaleVec = *(vector float *)&newXyzScale; newXyzScaleVec = vec_perm(newXyzScaleVec,newXyzScaleVec,newNormalsStorePermute); - newXyzScaleVec = vec_splat(newXyzScaleVec,0); + newXyzScaleVec = vec_splat(newXyzScaleVec,0); newNormalsLoadPermute = vec_lvsl(0,newXyz); newNormalsStorePermute = vec_lvsr(0,outXyz); zero = (vector float)vec_splat_s8(0); @@ -1466,7 +1466,7 @@ static void LerpMeshVertexes_altivec(md3Surface_t *surf, float backlerp) // for (vertNum=0 ; vertNum < numVerts ; vertNum++, newXyz += 4, newNormals += 4, - outXyz += 4, outNormal += 4) + outXyz += 4, outNormal += 4) { newNormalsLoadPermute = vec_lvsl(0,newXyz); newNormalsStorePermute = vec_lvsr(0,outXyz); @@ -1511,7 +1511,7 @@ static void LerpMeshVertexes_altivec(md3Surface_t *surf, float backlerp) for (vertNum=0 ; vertNum < numVerts ; vertNum++, oldXyz += 4, newXyz += 4, oldNormals += 4, newNormals += 4, - outXyz += 4, outNormal += 4) + outXyz += 4, outNormal += 4) { vec3_t uncompressedOldNormal, uncompressedNewNormal; @@ -1579,7 +1579,7 @@ static void LerpMeshVertexes_scalar(mdvSurface_t *surf, float backlerp) // for (vertNum=0 ; vertNum < numVerts ; vertNum++, newXyz += 4, newNormals += 4, - outXyz += 4, outNormal += 4) + outXyz += 4, outNormal += 4) { outXyz[0] = newXyz[0] * newXyzScale; @@ -1612,7 +1612,7 @@ static void LerpMeshVertexes_scalar(mdvSurface_t *surf, float backlerp) for (vertNum=0 ; vertNum < numVerts ; vertNum++, oldXyz += 4, newXyz += 4, oldNormals += 4, newNormals += 4, - outXyz += 4, outNormal += 4) + outXyz += 4, outNormal += 4) { vec3_t uncompressedOldNormal, uncompressedNewNormal; @@ -1791,11 +1791,11 @@ static float LodErrorForVolume( vec3_t local, float radius ) { return 0; } - world[0] = local[0] * backEnd.ori.axis[0][0] + local[1] * backEnd.ori.axis[1][0] + + world[0] = local[0] * backEnd.ori.axis[0][0] + local[1] * backEnd.ori.axis[1][0] + local[2] * backEnd.ori.axis[2][0] + backEnd.ori.origin[0]; - world[1] = local[0] * backEnd.ori.axis[0][1] + local[1] * backEnd.ori.axis[1][1] + + world[1] = local[0] * backEnd.ori.axis[0][1] + local[1] * backEnd.ori.axis[1][1] + local[2] * backEnd.ori.axis[2][1] + backEnd.ori.origin[1]; - world[2] = local[0] * backEnd.ori.axis[0][2] + local[1] * backEnd.ori.axis[1][2] + + world[2] = local[0] * backEnd.ori.axis[0][2] + local[1] * backEnd.ori.axis[1][2] + local[2] * backEnd.ori.axis[2][2] + backEnd.ori.origin[2]; VectorSubtract( world, backEnd.viewParms.ori.origin, world ); @@ -1897,7 +1897,7 @@ static void RB_SurfaceBSPGrid( srfBspSurface_t *srf ) { break; } } while ( 1 ); - + rows = irows; if ( vrows < irows + 1 ) { rows = vrows - 1; @@ -1981,7 +1981,7 @@ static void RB_SurfaceBSPGrid( srfBspSurface_t *srf ) { for (i = 0 ; i < h ; i++) { for (j = 0 ; j < w ; j++) { int v1, v2, v3, v4; - + // vertex order to be reckognized as tristrips v1 = numVertexes + i*lodWidth + j + 1; v2 = v1 - 1; @@ -1991,7 +1991,7 @@ static void RB_SurfaceBSPGrid( srfBspSurface_t *srf ) { tess.indexes[numIndexes] = v2; tess.indexes[numIndexes+1] = v3; tess.indexes[numIndexes+2] = v1; - + tess.indexes[numIndexes+3] = v1; tess.indexes[numIndexes+4] = v3; tess.indexes[numIndexes+5] = v4; @@ -2417,7 +2417,7 @@ static void RB_SurfaceEntity( surfaceType_t *surfType ) { const int count = backEnd.currentEntity->e.uRefEnt.uMini.miniCount; assert(count > 0); backEnd.currentEntity = &tempEnt; - + assert(backEnd.currentEntity->e.renderfx >= 0); for (int i = 0, j = start; i < count; i++, j++) @@ -2582,7 +2582,7 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) // TODO: Do we want a 2-level lod system where far away sprites are // just flat surfaces? - + // TODO: Check which pass (z-prepass/shadow/forward) we're rendering for? shader_t *shader = surf->shader; shaderStage_t *firstStage = shader->stages[0]; @@ -2616,7 +2616,7 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) UniformDataWriter uniformDataWriter; uniformDataWriter.Start(program); - + // FIXME: Use entity block for this uniformDataWriter.SetUniformMatrix4x4( UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); @@ -2689,8 +2689,8 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) } void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = { - (void(*)(void*))RB_SurfaceBad, // SF_BAD, - (void(*)(void*))RB_SurfaceSkip, // SF_SKIP, + (void(*)(void*))RB_SurfaceBad, // SF_BAD, + (void(*)(void*))RB_SurfaceSkip, // SF_SKIP, (void(*)(void*))RB_SurfaceBSPFace, // SF_FACE, (void(*)(void*))RB_SurfaceBSPGrid, // SF_GRID, (void(*)(void*))RB_SurfaceBSPTriangles, // SF_TRIANGLES, diff --git a/shared/rd-rend2/tr_weather.cpp b/shared/rd-rend2/tr_weather.cpp index f7a7c0e17a..854251ec58 100644 --- a/shared/rd-rend2/tr_weather.cpp +++ b/shared/rd-rend2/tr_weather.cpp @@ -58,7 +58,7 @@ namespace } return; } - + wo->targetVelocityTimeRemaining--; vec3_t deltaVelocity; VectorSubtract(wo->targetVelocity, wo->currentVelocity, deltaVelocity); @@ -134,7 +134,7 @@ namespace vec3_t mapSize; vec3_t halfMapSize; VectorSubtract( - tr.world->bmodels[0].bounds[0], + tr.world->bmodels[0].bounds[0], tr.world->bmodels[0].bounds[1], mapSize); VectorScale(mapSize, -0.5f, halfMapSize); @@ -150,7 +150,7 @@ namespace orientationr_t orientation; R_SetOrientationOriginAndAxis(orientation, viewOrigin, forward, left, up); - + const vec3_t viewBounds[2] = { { 0.0f, -halfMapSize[1], -halfMapSize[0] }, { halfMapSize[2] * 2.0f, halfMapSize[1], halfMapSize[0] } @@ -172,9 +172,8 @@ namespace { FBO_Bind(tr.weatherDepthFbo); - qglViewport(0, 0, tr.weatherDepthFbo->width, tr.weatherDepthFbo->height); - qglScissor(0, 0, tr.weatherDepthFbo->width, tr.weatherDepthFbo->height); - + GL_SetViewportAndScissor(0, 0, tr.weatherDepthFbo->width, tr.weatherDepthFbo->height); + if (tr.weatherSystem->weatherBrushType == WEATHER_BRUSHES_OUTSIDE) // used outside brushes { qglClearDepth(0.0f); @@ -299,8 +298,8 @@ namespace continue; // Just draw it when batch is full - if (tess.numVertexes + 4 >= SHADER_MAX_VERTEXES || tess.numIndexes + 6 >= SHADER_MAX_INDEXES) - { + if (tess.numVertexes + 4 >= SHADER_MAX_VERTEXES || tess.numIndexes + 6 >= SHADER_MAX_INDEXES) + { RB_UpdateVBOs(ATTR_POSITION); GLSL_VertexAttribsState(ATTR_POSITION, NULL); GLSL_BindProgram(&tr.textureColorShader); @@ -318,7 +317,7 @@ namespace tess.multiDrawPrimitives = 0; tess.externalIBO = nullptr; } - + RB_AddQuadStamp(rayPos, left, up, color); } } @@ -385,7 +384,7 @@ namespace void RB_SimulateWeather(weatherObject_t *ws, vec2_t *zoneOffsets, int zoneIndex) { - if (ws->vboLastUpdateFrame == backEndData->realFrameNumber || + if (ws->vboLastUpdateFrame == backEndData->realFrameNumber || tr.weatherSystem->frozen) { // Already simulated for this frame @@ -663,8 +662,8 @@ void RE_WorldEffectCommand(const char *command) else VectorMA( tr.weatherSystem->constWindDirection, - 0.001f, - parsedWind, + 0.001f, + parsedWind, tr.weatherSystem->constWindDirection); } @@ -897,8 +896,8 @@ void RE_WorldEffectCommand(const char *command) VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].color, 0.75f, 0.75f, 0.75f, 0.75f); VectorScale( - tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].color, - 0.75f, + tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].color, + 0.75f, tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].color); } @@ -997,7 +996,7 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_FOG].particleCount = 70; tr.weatherSystem->weatherSlots[WEATHER_FOG].active = true; - tr.weatherSystem->weatherSlots[WEATHER_FOG].gravity = 0.0f; + tr.weatherSystem->weatherSlots[WEATHER_FOG].gravity = 0.0f; tr.weatherSystem->weatherSlots[WEATHER_FOG].fadeDistance = 2400.f; tr.weatherSystem->weatherSlots[WEATHER_FOG].size[0] = 300.f; diff --git a/shared/rd-rend2/tr_world.cpp b/shared/rd-rend2/tr_world.cpp index e08527efb4..f07a0e6ddd 100644 --- a/shared/rd-rend2/tr_world.cpp +++ b/shared/rd-rend2/tr_world.cpp @@ -97,7 +97,7 @@ static qboolean R_CullSurface( msurface_t *surf, int entityNum ) { // don't cull exactly on the plane, because there are levels of rounding // through the BSP, ICD, and hardware that may cause pixel gaps if an - // epsilon isn't allowed here + // epsilon isn't allowed here if ( ct == CT_FRONT_SIDED ) { if ( d < surf->cullinfo.plane.dist - 8 ) { return qtrue; @@ -160,7 +160,7 @@ static int R_DlightSurface( msurface_t *surf, int dlightBits ) { float d; int i; dlight_t *dl; - + if ( surf->cullinfo.type & CULLINFO_PLANE ) { for ( i = 0 ; i < tr.refdef.num_dlights ; i++ ) { @@ -175,7 +175,7 @@ static int R_DlightSurface( msurface_t *surf, int dlightBits ) { } } } - + if ( surf->cullinfo.type & CULLINFO_BOX ) { for ( i = 0 ; i < tr.refdef.num_dlights ; i++ ) { @@ -244,7 +244,7 @@ static int R_PshadowSurface( msurface_t *surf, int pshadowBits ) { float d; int i; pshadow_t *ps; - + if ( surf->cullinfo.type & CULLINFO_PLANE ) { for ( i = 0 ; i < tr.refdef.num_pshadows ; i++ ) { @@ -259,7 +259,7 @@ static int R_PshadowSurface( msurface_t *surf, int pshadowBits ) { } } } - + if ( surf->cullinfo.type & CULLINFO_BOX ) { for ( i = 0 ; i < tr.refdef.num_pshadows ; i++ ) { @@ -272,7 +272,7 @@ static int R_PshadowSurface( msurface_t *surf, int pshadowBits ) { || ps->lightOrigin[1] - ps->lightRadius > surf->cullinfo.bounds[1][1] || ps->lightOrigin[1] + ps->lightRadius < surf->cullinfo.bounds[0][1] || ps->lightOrigin[2] - ps->lightRadius > surf->cullinfo.bounds[1][2] - || ps->lightOrigin[2] + ps->lightRadius < surf->cullinfo.bounds[0][2] + || ps->lightOrigin[2] + ps->lightRadius < surf->cullinfo.bounds[0][2] || BoxOnPlaneSide(surf->cullinfo.bounds[0], surf->cullinfo.bounds[1], &ps->cullPlane) == 2 ) { // pshadow doesn't reach the bounds pshadowBits &= ~( 1 << i ); @@ -361,7 +361,7 @@ static void R_AddWorldSurface( R_AddDrawSurf( surf->data, entityNum, surf->shader, surf->fogIndex, dlightBits, isPostRenderEntity, surf->cubemapIndex ); - for ( int i = 0, numSprites = surf->numSurfaceSprites; + for ( int i = 0, numSprites = surf->numSurfaceSprites; i < numSprites; ++i ) { srfSprites_t *sprites = surf->surfaceSprites + i; @@ -390,14 +390,14 @@ void R_AddBrushModelSurfaces ( trRefEntity_t *ent, int entityNum ) { if ( clip == CULL_OUT ) { return; } - + if (!(tr.viewParms.flags & VPF_DEPTHSHADOW)) R_DlightBmodel( bmodel, ent ); world_t *world = R_GetWorld(bmodel->worldIndex); for ( int i = 0 ; i < bmodel->numSurfaces ; i++ ) { int surf = bmodel->firstSurface + i; - + if (world->surfacesViewCount[surf] != tr.viewCount) { world->surfacesViewCount[surf] = tr.viewCount; @@ -608,7 +608,7 @@ void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, int psh dlight_t *dl = &tr.refdef.dlights[i]; float dist = DotProduct(dl->origin, node->plane->normal) - node->plane->dist; - + if ( dist > -dl->radius ) { newDlights[0] |= ( 1 << i ); } @@ -628,7 +628,7 @@ void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, int psh pshadow_t *shadow = &tr.refdef.pshadows[i]; float dist = DotProduct(shadow->lightOrigin, node->plane->normal) - node->plane->dist; - + if ( dist > -shadow->lightRadius ) { newPShadows[0] |= ( 1 << i ); } @@ -717,7 +717,7 @@ static mnode_t *R_PointInLeaf( const vec3_t p ) { mnode_t *node; float d; cplane_t *plane; - + if ( !tr.world ) { ri.Error (ERR_DROP, "R_PointInLeaf: bad model"); } @@ -735,7 +735,7 @@ static mnode_t *R_PointInLeaf( const vec3_t p ) { node = node->children[1]; } } - + return node; } @@ -831,7 +831,7 @@ void R_MarkLeaves( void ) } const byte *vis = R_ClusterPVS(tr.visClusters[tr.visIndex]); - + int i; for (i = 0, leaf = tr.world->nodes; i < tr.world->numnodes; i++, leaf++) { cluster = leaf->cluster; diff --git a/shared/sdl/sdl_input.cpp b/shared/sdl/sdl_input.cpp index 59e940613b..74dce1db0b 100644 --- a/shared/sdl/sdl_input.cpp +++ b/shared/sdl/sdl_input.cpp @@ -1160,7 +1160,7 @@ void IN_Frame (void) { // Console is down in windowed mode IN_DeactivateMouse( ); } - else if( !cls.glconfig.isFullscreen && loading ) + else if( !cls.glconfig.isFullscreen && loading && !cls.cursorActive ) { // Loading in windowed mode IN_DeactivateMouse( ); diff --git a/shared/sys/sys_local.h b/shared/sys/sys_local.h index 815adc5eff..2a404f4c05 100644 --- a/shared/sys/sys_local.h +++ b/shared/sys/sys_local.h @@ -28,7 +28,7 @@ void IN_Frame( void ); void IN_Shutdown( void ); void IN_Restart( void ); -void Sys_PlatformInit( void ); +void Sys_PlatformInit( int argc, char *argv[] ); void Sys_PlatformExit( void ); qboolean Sys_GetPacket( netadr_t *net_from, msg_t *net_message ); char *Sys_ConsoleInput( void ); diff --git a/shared/sys/sys_main.cpp b/shared/sys/sys_main.cpp index fd103e713f..7c8dcf9127 100644 --- a/shared/sys/sys_main.cpp +++ b/shared/sys/sys_main.cpp @@ -40,6 +40,7 @@ cvar_t *com_unfocused; cvar_t *com_maxfps; cvar_t *com_maxfpsMinimized; cvar_t *com_maxfpsUnfocused; +cvar_t *com_unpackLibraries; /* ================= @@ -164,6 +165,8 @@ void Sys_Init( void ) { #endif com_maxfpsUnfocused = Cvar_Get( "com_maxfpsUnfocused", "0", CVAR_ARCHIVE_ND ); com_maxfpsMinimized = Cvar_Get( "com_maxfpsMinimized", "50", CVAR_ARCHIVE_ND ); + + com_unpackLibraries = Cvar_Get( "com_unpackLibraries", "0", CVAR_INIT|CVAR_PROTECTED ); } static void NORETURN Sys_Exit( int ex ) { @@ -473,22 +476,24 @@ void *Sys_LoadLegacyGameDll( const char *name, VMMainProc **vmMain, SystemCallPr if ( !libHandle ) #endif { - UnpackDLLResult unpackResult = Sys_UnpackDLL(filename); - if ( !unpackResult.succeeded ) - { - if ( Sys_DLLNeedsUnpacking() ) + if ( com_unpackLibraries->integer ) { + UnpackDLLResult unpackResult = Sys_UnpackDLL(filename); + if ( !unpackResult.succeeded ) { - FreeUnpackDLLResult(&unpackResult); - Com_DPrintf( "Sys_LoadLegacyGameDll: Failed to unpack %s from PK3.\n", filename ); - return NULL; + if ( Sys_DLLNeedsUnpacking() ) + { + FreeUnpackDLLResult(&unpackResult); + Com_DPrintf( "Sys_LoadLegacyGameDll: Failed to unpack %s from PK3.\n", filename ); + return NULL; + } + } + else + { + libHandle = Sys_LoadLibrary(unpackResult.tempDLLPath); } - } - else - { - libHandle = Sys_LoadLibrary(unpackResult.tempDLLPath); - } - FreeUnpackDLLResult(&unpackResult); + FreeUnpackDLLResult(&unpackResult); + } if ( !libHandle ) { @@ -604,22 +609,24 @@ void *Sys_LoadGameDll( const char *name, GetModuleAPIProc **moduleAPI ) if ( !libHandle ) #endif { - UnpackDLLResult unpackResult = Sys_UnpackDLL(filename); - if ( !unpackResult.succeeded ) - { - if ( Sys_DLLNeedsUnpacking() ) + if ( com_unpackLibraries->integer ) { + UnpackDLLResult unpackResult = Sys_UnpackDLL(filename); + if ( !unpackResult.succeeded ) { - FreeUnpackDLLResult(&unpackResult); - Com_DPrintf( "Sys_LoadLegacyGameDll: Failed to unpack %s from PK3.\n", filename ); - return NULL; + if ( Sys_DLLNeedsUnpacking() ) + { + FreeUnpackDLLResult(&unpackResult); + Com_DPrintf( "Sys_LoadLegacyGameDll: Failed to unpack %s from PK3.\n", filename ); + return NULL; + } + } + else + { + libHandle = Sys_LoadLibrary(unpackResult.tempDLLPath); } - } - else - { - libHandle = Sys_LoadLibrary(unpackResult.tempDLLPath); - } - FreeUnpackDLLResult(&unpackResult); + FreeUnpackDLLResult(&unpackResult); + } if ( !libHandle ) { @@ -738,7 +745,7 @@ int main ( int argc, char* argv[] ) int i; char commandLine[ MAX_STRING_CHARS ] = { 0 }; - Sys_PlatformInit(); + Sys_PlatformInit( argc, argv ); CON_Init(); // get the initial time base @@ -781,8 +788,6 @@ int main ( int argc, char* argv[] ) Com_Printf( "SDL Version Linked: %d.%d.%d\n", linked.major, linked.minor, linked.patch ); #endif - NET_Init(); - // main game loop while (1) { diff --git a/shared/sys/sys_unix.cpp b/shared/sys/sys_unix.cpp index e3149819fc..849d11b219 100644 --- a/shared/sys/sys_unix.cpp +++ b/shared/sys/sys_unix.cpp @@ -32,6 +32,7 @@ along with this program; if not, see . #include #include #include +#include #include "qcommon/qcommon.h" #include "qcommon/q_shared.h" @@ -42,7 +43,11 @@ qboolean stdinIsATTY = qfalse; // Used to determine where to store user-specific files static char homePath[ MAX_OSPATH ] = { 0 }; -void Sys_PlatformInit( void ) +// Max open file descriptors. Mostly used by pk3 files with +// MAX_SEARCH_PATHS limit. +#define MAX_OPEN_FILES 4096 + +void Sys_PlatformInit( int argc, char *argv[] ) { const char* term = getenv( "TERM" ); @@ -56,6 +61,25 @@ void Sys_PlatformInit( void ) stdinIsATTY = qtrue; else stdinIsATTY = qfalse; + + // raise open file limit to allow more pk3 files + int retval; + struct rlimit rlim; + rlim_t maxfds = MAX_OPEN_FILES; + + for (int i = 1; i + 1 < argc; i++) { + if (!Q_stricmp(argv[i], "-maxfds")) { + maxfds = atoi(argv[i + 1]); + } + } + + getrlimit(RLIMIT_NOFILE, &rlim); + rlim.rlim_cur = Q_min(maxfds, rlim.rlim_max); + retval = setrlimit(RLIMIT_NOFILE, &rlim); + + if (retval == -1) { + Com_Printf("Warning: Failed to raise open file limit. %s\n", strerror(errno)); + } } void Sys_PlatformExit( void ) diff --git a/shared/sys/sys_win32.cpp b/shared/sys/sys_win32.cpp index 4a8768130f..226c71e530 100644 --- a/shared/sys/sys_win32.cpp +++ b/shared/sys/sys_win32.cpp @@ -542,7 +542,12 @@ Sys_PlatformInit Platform-specific initialization ================ */ -void Sys_PlatformInit( void ) { + +// Max open file descriptors. Mostly used by pk3 files with +// MAX_SEARCH_PATHS limit. +#define MAX_OPEN_FILES 4096 + +void Sys_PlatformInit( int argc, char *argv[] ) { TIMECAPS ptc; if ( timeGetDevCaps( &ptc, sizeof( ptc ) ) == MMSYSERR_NOERROR ) { @@ -558,6 +563,21 @@ void Sys_PlatformInit( void ) { } else timerResolution = 0; + + // raise open file limit to allow more pk3 files + int maxfds = MAX_OPEN_FILES; + + for (int i = 1; i + 1 < argc; i++) { + if (!Q_stricmp(argv[i], "-maxfds")) { + maxfds = atoi(argv[i + 1]); + } + } + + maxfds = _setmaxstdio(maxfds); + + if (maxfds == -1) { + Com_Printf("Warning: Failed to increase open file limit. %s\n", strerror(errno)); + } } /* diff --git a/ui/menudef.h b/ui/menudef.h index 203a95dff9..df27d11f45 100644 --- a/ui/menudef.h +++ b/ui/menudef.h @@ -7,12 +7,12 @@ #define CT_DKCYAN 0 0.25 0.25 #define ITEM_TYPE_TEXT 0 // simple text -#define ITEM_TYPE_BUTTON 1 // button, basically text with a border -#define ITEM_TYPE_RADIOBUTTON 2 // toggle button, may be grouped +#define ITEM_TYPE_BUTTON 1 // button, basically text with a border +#define ITEM_TYPE_RADIOBUTTON 2 // toggle button, may be grouped #define ITEM_TYPE_CHECKBOX 3 // check box #define ITEM_TYPE_EDITFIELD 4 // editable text, associated with a cvar #define ITEM_TYPE_COMBO 5 // drop down list -#define ITEM_TYPE_LISTBOX 6 // scrollable list +#define ITEM_TYPE_LISTBOX 6 // scrollable list #define ITEM_TYPE_MODEL 7 // model #define ITEM_TYPE_OWNERDRAW 8 // owner draw, name specs what it is #define ITEM_TYPE_NUMERICFIELD 9 // editable text, associated with a cvar @@ -21,7 +21,7 @@ #define ITEM_TYPE_MULTI 12 // multiple list setting, enumerated #define ITEM_TYPE_BIND 13 // multiple list setting, enumerated #define ITEM_TYPE_TEXTSCROLL 14 // scrolls text - + #define ITEM_ALIGN_LEFT 0 // left alignment #define ITEM_ALIGN_CENTER 1 // center alignment #define ITEM_ALIGN_RIGHT 2 // right alignment @@ -33,17 +33,17 @@ #define ITEM_TEXTSTYLE_OUTLINED 4 // drop shadow ( need a color for this ) #define ITEM_TEXTSTYLE_OUTLINESHADOWED 5 // drop shadow ( need a color for this ) #define ITEM_TEXTSTYLE_SHADOWEDMORE 6 // drop shadow ( need a color for this ) - + #define WINDOW_BORDER_NONE 0 // no border #define WINDOW_BORDER_FULL 1 // full border based on border color ( single pixel ) #define WINDOW_BORDER_HORZ 2 // horizontal borders only -#define WINDOW_BORDER_VERT 3 // vertical borders only +#define WINDOW_BORDER_VERT 3 // vertical borders only #define WINDOW_BORDER_KCGRADIENT 4 // horizontal border using the gradient bars - + #define WINDOW_STYLE_EMPTY 0 // no background #define WINDOW_STYLE_FILLED 1 // filled with background color -#define WINDOW_STYLE_GRADIENT 2 // gradient bar based on background color -#define WINDOW_STYLE_SHADER 3 // gradient bar based on background color +#define WINDOW_STYLE_GRADIENT 2 // gradient bar based on background color +#define WINDOW_STYLE_SHADER 3 // gradient bar based on background color #define WINDOW_STYLE_TEAMCOLOR 4 // team color #define WINDOW_STYLE_CINEMATIC 5 // cinematic @@ -166,10 +166,10 @@ // owner draw types // ideally these should be done outside of this file but -// this makes it much easier for the macro expansion to +// this makes it much easier for the macro expansion to // convert them for the designers ( from the .menu files ) #define CG_OWNERDRAW_BASE 1 -#define CG_PLAYER_ARMOR_ICON 1 +#define CG_PLAYER_ARMOR_ICON 1 #define CG_PLAYER_ARMOR_VALUE 2 #define CG_PLAYER_HEAD 3 #define CG_PLAYER_HEALTH 4 @@ -208,13 +208,13 @@ #define CG_PLAYER_LOCATION 33 #define CG_TEAM_COLOR 34 #define CG_CTF_POWERUP 35 - + #define CG_AREA_POWERUP 36 #define CG_AREA_LAGOMETER 37 // painted with old system -#define CG_PLAYER_HASFLAG 38 +#define CG_PLAYER_HASFLAG 38 #define CG_GAME_TYPE 39 // not done -#define CG_SELECTEDPLAYER_ARMOR 40 +#define CG_SELECTEDPLAYER_ARMOR 40 #define CG_SELECTEDPLAYER_HEALTH 41 #define CG_PLAYER_STATUS 42 #define CG_FRAGGED_MSG 43 // painted with old system @@ -225,7 +225,7 @@ #define CG_AREA_CHAT 48 // painted with old system #define CG_GAME_STATUS 49 #define CG_KILLER 50 -#define CG_PLAYER_ARMOR_ICON2D 51 +#define CG_PLAYER_ARMOR_ICON2D 51 #define CG_PLAYER_AMMO_ICON2D 52 #define CG_ACCURACY 53 #define CG_ASSISTS 54 @@ -238,9 +238,9 @@ #define CG_TEAMINFO 61 #define CG_VOICE_HEAD 62 #define CG_VOICE_NAME 63 -#define CG_PLAYER_HASFLAG2D 64 +#define CG_PLAYER_HASFLAG2D 64 #define CG_HARVESTER_SKULLS2D 65 // only shows in harvester -#define CG_CAPFRAGLIMIT 66 +#define CG_CAPFRAGLIMIT 66 #define CG_1STPLACE 67 #define CG_2NDPLACE 68 #define CG_CAPTURES 69 @@ -391,7 +391,7 @@ #define UI_PLAYERKICK_DESC 194 #define UI_VOTE_LISTENER 195 #define UI_VOTE_DESC 196 -#define UI_SOFT_KEYBOARD_ACCEPT 197 -#define UI_SOFT_KEYBOARD_DELETE 198 -#define UI_SOFT_KEYBOARD 199 +#define UI_SOFT_KEYBOARD_ACCEPT 197 +#define UI_SOFT_KEYBOARD_DELETE 198 +#define UI_SOFT_KEYBOARD 199