From 28f266302fbeea2d75d5a62de651d464ab380798 Mon Sep 17 00:00:00 2001 From: Adrian Graber Date: Sun, 4 Jul 2021 18:52:48 +0200 Subject: Add Nintendo Switch initial support --- .github/workflows/build-switch.yml | 28 +++++++ .vscode/c_cpp_properties.json | 19 +++++ .vscode/settings.json | 10 ++- CMakeLists.txt | 6 ++ cmake/nx/NXFunctions.cmake | 7 ++ logo_switch.jpg | Bin 0 -> 18096 bytes src/CMakeLists.txt | 40 +++++++++- src/core/common.h | 4 + src/core/config.h | 9 ++- src/core/re3.cpp | 2 - src/skel/crossplatform.cpp | 146 ++++++++++++++++++++++++++++++++++++- src/skel/events.cpp | 2 + src/skel/glfw/glfw.cpp | 12 ++- 13 files changed, 273 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/build-switch.yml create mode 100644 cmake/nx/NXFunctions.cmake create mode 100644 logo_switch.jpg diff --git a/.github/workflows/build-switch.yml b/.github/workflows/build-switch.yml new file mode 100644 index 00000000..46e1d501 --- /dev/null +++ b/.github/workflows/build-switch.yml @@ -0,0 +1,28 @@ +name: re3 cmake devkitA64 (Nintendo Switch) +on: + pull_request: + push: + release: + types: published +jobs: + build-nintendo-switch: + runs-on: ubuntu-latest + container: devkitpro/devkita64:latest + steps: + - uses: actions/checkout@v2 + with: + submodules: 'true' + - name: "Build files" + run: | + /opt/devkitpro/portlibs/switch/bin/aarch64-none-elf-cmake -S. -Bbuild -DRE3_AUDIO=OAL -DLIBRW_PLATFORM=GL3 -DLIBRW_GL3_GFXLIB=GLFW -DRE3_WITH_OPUS=False -DRE3_VENDORED_LIBRW=True -DRE3_INSTALL=True + cmake --build build --parallel + - name: "Create binary package (cpack)" + working-directory: ./build + run: | + cpack + - name: "Archive binary package (github artifacts)" + uses: actions/upload-artifact@v2 + with: + name: "switch-gl3" + path: build/*.zip + if-no-files-found: error diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 327d8cc7..a214042a 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -26,6 +26,25 @@ "compilerArgs": ["-ggdb"], "cStandard": "gnu11", "cppStandard": "gnu++14" + }, + { + "name": "devkitPro aarch64 (Nintendo Switch)", + "compilerPath": "${env:DEVKITPRO}/devkitA64/bin/aarch64-none-elf-g++", + "includePath": [ + "${default}", + "${env:DEVKITPRO}/portlibs/switch/include", + "${env:DEVKITPRO}/libnx/include" + ], + "intelliSenseMode": "gcc-arm64", + "cStandard": "gnu11", + "cppStandard": "gnu++11", + "defines": [ + "__SWITCH__", + "GTA_SWITCH", + "LIBRW", + "RW_GL3", + "AUDIO_OAL" + ] } ], "version": 4 diff --git a/.vscode/settings.json b/.vscode/settings.json index 10cb5627..ee8362c1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,8 +2,13 @@ "C_Cpp.default.cStandard": "gnu11", "C_Cpp.default.cppStandard": "gnu++14", "C_Cpp.default.includePath": [ + "src", "src/animation", "src/audio", + "src/audio/eax", + "src/audio/oal", + "src/buildings", + "src/collision", "src/control", "src/core", "src/entities", @@ -15,8 +20,9 @@ "src/peds", "src/render", "src/rw", - "src/save", - "src/skel", + "src/save/", + "src/skel/", + "src/skel/glfw", "src/text", "src/vehicles", "src/weapons", diff --git a/CMakeLists.txt b/CMakeLists.txt index 5396d3b4..b687124a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,10 @@ message(STATUS "Building ${CMAKE_PROJECT_NAME} GIT SHA1: ${GIT_SHA1}") if(WIN32) set(${PROJECT}_AUDIOS "OAL" "MSS") +elseif(NINTENDO_SWITCH) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/nx") + include(NXFunctions) + set(${PROJECT}_AUDIOS "OAL") else() set(${PROJECT}_AUDIOS "OAL") endif() @@ -66,6 +70,8 @@ if(${PROJECT}_INSTALL) set(os "-apple") elseif(UNIX) set(os "-linux") + elseif(NINTENDO_SWITCH) + set(os "-switch") else() set(compiler "-UNK") message(WARNING "Unknown os. Created cpack package will be wrong. (override using cpack -P)") diff --git a/cmake/nx/NXFunctions.cmake b/cmake/nx/NXFunctions.cmake new file mode 100644 index 00000000..8fa23fae --- /dev/null +++ b/cmake/nx/NXFunctions.cmake @@ -0,0 +1,7 @@ +if(NOT COMMAND nx_generate_nacp) + message(FATAL_ERROR "The `nx_generate_nacp` cmake command is not available. Please use an appropriate Nintendo Switch toolchain.") +endif() + +if(NOT COMMAND nx_create_nro) + message(FATAL_ERROR "The `nx_create_nro` cmake command is not available. Please use an appropriate Nintendo Switch toolchain.") +endif() diff --git a/logo_switch.jpg b/logo_switch.jpg new file mode 100644 index 00000000..595d2c3b Binary files /dev/null and b/logo_switch.jpg differ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 28090d7e..67dfb325 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -120,13 +120,19 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") ) endif() +if(NINTENDO_SWITCH) + set(${PROJECT}_C_CXX_EXTENSIONS ON) +else() + set(${PROJECT}_C_CXX_EXTENSIONS OFF) +endif() + set_target_properties(${EXECUTABLE} PROPERTIES C_STANDARD 11 - C_EXTENSIONS OFF + C_EXTENSIONS ${${PROJECT}_C_CXX_EXTENSIONS} C_STANDARD_REQUIRED ON CXX_STANDARD 11 - CXX_EXTENSIONS OFF + CXX_EXTENSIONS ${${PROJECT}_C_CXX_EXTENSIONS} CXX_STANDARD_REQUIRED ON ) @@ -140,3 +146,33 @@ if(${PROJECT}_INSTALL) install(FILES $ DESTINATION "." OPTIONAL) endif() endif() + +# Build Nintendo Switch binaries +if(NINTENDO_SWITCH) + target_compile_definitions(${EXECUTABLE} PRIVATE + GTA_SWITCH + ) + + # Needed for OpenAL-Soft + target_link_libraries(${EXECUTABLE} PRIVATE + openal # HACK - something broke with latest cmake + SDL2 + ) + + nx_generate_nacp (${EXECUTABLE}.nacp + NAME "${EXECUTABLE}" + AUTHOR "${EXECUTABLE} Team" + VERSION "1.0.0-${GIT_SHA1}" + ) + + nx_create_nro(${EXECUTABLE} + NACP ${EXECUTABLE}.nacp + ICON "${PROJECT_SOURCE_DIR}/logo_switch.jpg" + ) + + if(${PROJECT}_INSTALL) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE}.nro" + DESTINATION "." + ) + endif() +endif() diff --git a/src/core/common.h b/src/core/common.h index da162762..99aafc5a 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -11,6 +11,10 @@ #define __STDC_LIMIT_MACROS // so we get UINT32_MAX etc #endif +#ifdef GTA_SWITCH +#include +#endif + #include #include #include diff --git a/src/core/config.h b/src/core/config.h index 885f98b8..edb5fb5a 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -319,7 +319,7 @@ enum Config { #if !defined(RW_GL3) && defined(_WIN32) #define XINPUT #endif -#if defined XINPUT || (defined RW_GL3 && !defined LIBRW_SDL2 && !defined __SWITCH__) +#if defined XINPUT || (defined RW_GL3 && !defined LIBRW_SDL2 && !defined GTA_SWITCH) #define DETECT_JOYSTICK_MENU // Then we'll expect user to enter Controller->Detect joysticks if his joystick isn't detected at the start. #endif #define DETECT_PAD_INPUT_SWITCH // Adds automatic switch of pad related stuff between controller and kb/m @@ -439,7 +439,7 @@ enum Config { #endif // Streaming -#if !defined(_WIN32) && !defined(__SWITCH__) +#if !defined(_WIN32) && !defined(GTA_SWITCH) //#define ONE_THREAD_PER_CHANNEL // Don't use if you're not on SSD/Flash - also not utilized too much right now(see commented LoadAllRequestedModels in Streaming.cpp) #define FLUSHABLE_STREAMING // Make it possible to interrupt reading when processing file isn't needed anymore. #endif @@ -461,4 +461,9 @@ enum Config { #undef PEDS_REPORT_CRIMES_ON_PHONE #endif +#ifdef GTA_SWITCH + #define IGNORE_MOUSE_KEYBOARD // ignore mouse & keyboard input + #define USE_UNNAMED_SEM // named semaphores are unsupported on the switch +#endif + #endif // VANILLA_DEFINES diff --git a/src/core/re3.cpp b/src/core/re3.cpp index b7d89363..40be153a 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -45,9 +45,7 @@ #include "Population.h" #include "IniFile.h" -#ifdef DETECT_JOYSTICK_MENU #include "crossplatform.h" -#endif #ifndef _WIN32 #include "assert.h" diff --git a/src/skel/crossplatform.cpp b/src/skel/crossplatform.cpp index 577983b6..758125e9 100644 --- a/src/skel/crossplatform.cpp +++ b/src/skel/crossplatform.cpp @@ -198,6 +198,20 @@ char* casepath(char const* path, bool checkPathFirst) size_t rl = 0; DIR* d; + char* c; + + #if defined(GTA_SWITCH) || defined(GTA_VITA) + if( (c = strstr(p, ":/")) != NULL) // scheme used by some environments, eg. switch, vita + { + size_t deviceNameOffset = c - p + 3; + char* deviceNamePath = (char*)alloca(deviceNameOffset + 1); + strlcpy(deviceNamePath, p, deviceNameOffset); + deviceNamePath[deviceNameOffset] = 0; + d = opendir(deviceNamePath); + p = c + 1; + } + else + #endif if (p[0] == '/' || p[0] == '\\') { d = opendir("/"); @@ -212,7 +226,7 @@ char* casepath(char const* path, bool checkPathFirst) bool cantProceed = false; // just convert slashes in what's left in string, don't correct case of letters(because we can't) bool mayBeTrailingSlash = false; - char* c; + while (c = strsep(&p, "/\\")) { // May be trailing slash(allow), slash at the start(avoid), or multiple slashes(avoid) @@ -279,3 +293,133 @@ char* casepath(char const* path, bool checkPathFirst) return out; } #endif + +#ifdef GTA_SWITCH +/* Taken from glibc */ +char *realpath(const char *name, char *resolved) +{ + char *rpath, *dest = NULL; + const char *start, *end, *rpath_limit; + long int path_max; + + /* As per Single Unix Specification V2 we must return an error if + either parameter is a null pointer. We extend this to allow + the RESOLVED parameter to be NULL in case the we are expected to + allocate the room for the return value. */ + if (!name) + return NULL; + + /* As per Single Unix Specification V2 we must return an error if + the name argument points to an empty string. */ + if (name[0] == '\0') + return NULL; + +#ifdef PATH_MAX + path_max = PATH_MAX; +#else + path_max = pathconf(name, _PC_PATH_MAX); + if (path_max <= 0) + path_max = 1024; +#endif + + if (!resolved) + { + rpath = (char*)malloc(path_max); + if (!rpath) + return NULL; + } + else + rpath = resolved; + rpath_limit = rpath + path_max; + + if (name[0] != '/') + { + if (!getcwd(rpath, path_max)) + { + rpath[0] = '\0'; + goto error; + } + dest = (char*)memchr(rpath, '\0', path_max); + } + else + { + rpath[0] = '/'; + dest = rpath + 1; + } + + for (start = end = name; *start; start = end) + { + /* Skip sequence of multiple path-separators. */ + while (*start == '/') + ++start; + + /* Find end of path component. */ + for (end = start; *end && *end != '/'; ++end) + /* Nothing. */; + + if (end - start == 0) + break; + else if (end - start == 1 && start[0] == '.') + /* nothing */; + else if (end - start == 2 && start[0] == '.' && start[1] == '.') + { + /* Back up to previous component, ignore if at root already. */ + if (dest > rpath + 1) + while ((--dest)[-1] != '/') + ; + } + else + { + size_t new_size; + + if (dest[-1] != '/') + *dest++ = '/'; + + if (dest + (end - start) >= rpath_limit) + { + ptrdiff_t dest_offset = dest - rpath; + char *new_rpath; + + if (resolved) + { + if (dest > rpath + 1) + dest--; + *dest = '\0'; + goto error; + } + new_size = rpath_limit - rpath; + if (end - start + 1 > path_max) + new_size += end - start + 1; + else + new_size += path_max; + new_rpath = (char *)realloc(rpath, new_size); + if (!new_rpath) + goto error; + rpath = new_rpath; + rpath_limit = rpath + new_size; + + dest = rpath + dest_offset; + } + + dest = (char*)memcpy(dest, start, end - start); + *dest = '\0'; + } + } + if (dest > rpath + 1 && dest[-1] == '/') + --dest; + *dest = '\0'; + + return rpath; + +error: + if (!resolved) + free(rpath); + return NULL; +} + +ssize_t readlink (const char * __path, char * __buf, size_t __buflen) +{ + errno = ENOSYS; + return -1; +} +#endif diff --git a/src/skel/events.cpp b/src/skel/events.cpp index 3e1e95b3..87447819 100644 --- a/src/skel/events.cpp +++ b/src/skel/events.cpp @@ -821,7 +821,9 @@ PadHandler(RsEvent event, void *param) RwBool AttachInputDevices(void) { +#ifndef IGNORE_MOUSE_KEYBOARD RsInputDeviceAttach(rsKEYBOARD, KeyboardHandler); +#endif RsInputDeviceAttach(rsPAD, PadHandler); diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 8d3fc7d7..c7f92d34 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -12,12 +12,14 @@ DWORD _dwOperatingSystemVersion; #include "resource.h" #else long _dwOperatingSystemVersion; +#ifndef GTA_SWITCH #ifndef __APPLE__ #include #else #include #include #endif +#endif #include #include #include @@ -51,7 +53,7 @@ long _dwOperatingSystemVersion; #include "MemoryMgr.h" // We found out that GLFW's keyboard input handling is still pretty delayed/not stable, so now we fetch input from X11 directly on Linux. -#if !defined _WIN32 && !defined __APPLE__ && !defined __SWITCH__ // && !defined WAYLAND +#if !defined _WIN32 && !defined __APPLE__ && !defined GTA_SWITCH // && !defined WAYLAND #define GET_KEYBOARD_INPUT_FROM_X11 #endif @@ -485,11 +487,13 @@ psInitialize(void) debug("Physical memory size %llu\n", _dwMemAvailPhys); debug("Available physical memory %llu\n", size); #else +#ifndef GTA_SWITCH struct sysinfo systemInfo; sysinfo(&systemInfo); _dwMemAvailPhys = systemInfo.freeram; debug("Physical memory size %u\n", systemInfo.totalram); debug("Available physical memory %u\n", systemInfo.freeram); +#endif #endif TheText.Unload(); @@ -949,13 +953,15 @@ void psPostRWinit(void) RwVideoMode vm; RwEngineGetVideoModeInfo(&vm, GcurSelVM); + glfwSetFramebufferSizeCallback(PSGLOBAL(window), resizeCB); +#ifndef IGNORE_MOUSE_KEYBOARD #ifndef GET_KEYBOARD_INPUT_FROM_X11 glfwSetKeyCallback(PSGLOBAL(window), keypressCB); #endif - glfwSetFramebufferSizeCallback(PSGLOBAL(window), resizeCB); glfwSetScrollCallback(PSGLOBAL(window), scrollCB); glfwSetCursorPosCallback(PSGLOBAL(window), cursorCB); glfwSetCursorEnterCallback(PSGLOBAL(window), cursorEnterCB); +#endif glfwSetWindowIconifyCallback(PSGLOBAL(window), windowIconifyCB); glfwSetWindowFocusCallback(PSGLOBAL(window), windowFocusCB); glfwSetJoystickCallback(joysChangeCB); @@ -1791,7 +1797,7 @@ main(int argc, char *argv[]) InitMemoryMgr(); #endif -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(GTA_SWITCH) struct sigaction act; act.sa_sigaction = terminateHandler; act.sa_flags = SA_SIGINFO; -- cgit v1.2.3 From 6da20aa7232e92b19af28d1bcd2dacacc3898789 Mon Sep 17 00:00:00 2001 From: Adrian Graber Date: Sun, 4 Jul 2021 19:15:23 +0200 Subject: Enable Gamepad Menu on Switch --- src/core/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/config.h b/src/core/config.h index edb5fb5a..462dd713 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -345,7 +345,7 @@ enum Config { //# define PS2_MENU_USEALLPAGEICONS #else -# ifdef XINPUT +# if defined(XINPUT) || defined(GTA_SWITCH) # define GAMEPAD_MENU // Add gamepad menu # endif -- cgit v1.2.3 From 02ec56e8f70ab0fda5092d3455f76dcbb8825cff Mon Sep 17 00:00:00 2001 From: Adrian Graber Date: Sun, 4 Jul 2021 20:51:16 +0200 Subject: Add platform specific functions for glfw vibration With implementation for Switch vibration through libnx hid/pad API --- src/skel/glfw/glfw.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index c7f92d34..754c43be 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -326,6 +326,78 @@ psNativeTextureSupport(void) #define CMDSTR LPSTR #endif +/* + ***************************************************************************** + */ + +#ifdef GTA_SWITCH + +static HidVibrationValue SwitchVibrationValues[2]; +static HidVibrationDeviceHandle SwitchVibrationDeviceHandles[2][2]; +static HidVibrationDeviceHandle SwitchVibrationDeviceGC; + +static PadState SwitchPad; + +Result HidInitializationResult[2]; +Result HidInitializationGCResult; + +void _psInitializeVibration() +{ + HidInitializationResult[0] = hidInitializeVibrationDevices(SwitchVibrationDeviceHandles[0], 2, HidNpadIdType_Handheld, HidNpadStyleTag_NpadHandheld); + if(R_FAILED(HidInitializationResult[0])) { + printf("Failed to initialize VibrationDevice for Handheld Mode\n"); + } + HidInitializationResult[1] = hidInitializeVibrationDevices(SwitchVibrationDeviceHandles[1], 2, HidNpadIdType_No1, HidNpadStyleSet_NpadFullCtrl); + if(R_FAILED(HidInitializationResult[1])) { + printf("Failed to initialize VibrationDevice for Detached Mode\n"); + } + HidInitializationGCResult = hidInitializeVibrationDevices(&SwitchVibrationDeviceGC, 1, HidNpadIdType_No1, HidNpadStyleTag_NpadGc); + if(R_FAILED(HidInitializationResult[1])) { + printf("Failed to initialize VibrationDevice for GC Mode\n"); + } + + SwitchVibrationValues[0].freq_low = 160.0f; + SwitchVibrationValues[0].freq_high = 320.0f; + + padConfigureInput(1, HidNpadStyleSet_NpadFullCtrl); + padInitializeDefault(&SwitchPad); +} + +void _psHandleVibration() +{ + padUpdate(&SwitchPad); + + uint8 target_device = padIsHandheld(&SwitchPad) ? 0 : 1; + + if(R_SUCCEEDED(HidInitializationResult[target_device])) { + CPad* pad = CPad::GetPad(0); + + // value conversion based on SDL2 switch port + SwitchVibrationValues[0].amp_high = SwitchVibrationValues[0].amp_low = pad->ShakeFreq == 0 ? 0.0f : 320.0f; + SwitchVibrationValues[0].freq_low = pad->ShakeFreq == 0.0 ? 160.0f : (float)pad->ShakeFreq * 1.26f; + SwitchVibrationValues[0].freq_high = pad->ShakeFreq == 0.0 ? 320.0f : (float)pad->ShakeFreq * 1.26f; + + if (pad->ShakeDur < CTimer::GetTimeStepInMilliseconds()) + pad->ShakeDur = 0; + else + pad->ShakeDur -= CTimer::GetTimeStepInMilliseconds(); + if (pad->ShakeDur == 0) pad->ShakeFreq = 0; + + + if(target_device == 1 && R_SUCCEEDED(HidInitializationGCResult)) { + // gamecube rumble + hidSendVibrationGcErmCommand(SwitchVibrationDeviceGC, pad->ShakeFreq > 0 ? HidVibrationGcErmCommand_Start : HidVibrationGcErmCommand_Stop); + } + + memcpy(&SwitchVibrationValues[1], &SwitchVibrationValues[0], sizeof(HidVibrationValue)); + hidSendVibrationValues(SwitchVibrationDeviceHandles[target_device], SwitchVibrationValues, 2); + } +} +#else +void _psInitializeVibration() {} +void _psHandleVibration() {} +#endif + /* ***************************************************************************** */ @@ -409,6 +481,8 @@ psInitialize(void) #endif #endif + + _psInitializeVibration(); gGameState = GS_START_UP; TRACE("gGameState = GS_START_UP"); @@ -2459,6 +2533,8 @@ void CapturePad(RwInt32 padID) if ( Abs(rightStickPos.y) > 0.3f ) pad->PCTempJoyState.RightStickY = (int32)(rightStickPos.y * 128.0f); } + + _psHandleVibration(); return; } -- cgit v1.2.3 From ca5d3c881133d1fb3c2d9af16de81b63304bc88f Mon Sep 17 00:00:00 2001 From: Adrian Graber Date: Mon, 5 Jul 2021 20:02:44 +0200 Subject: Replace GTA_SWITCH macro and use GAMEPAD_MENU * Replace GTA_SWITCH macro with __SWITCH__ for platform specific stuff and GTA_HANDHELD for the rest (which could be used by other ports) * Use GAMEPAD_MENU on GTA_HANDHELD, which will replace the usual controller setup (which contains some useless features for handhelds) * Fix some identation inconsistencies * Disable PC_PLAYER_CONTROLS on GTA_HANDHELD builds --- .vscode/c_cpp_properties.json | 1 - src/CMakeLists.txt | 4 ---- src/core/MenuScreensCustom.cpp | 12 +++++++++--- src/core/common.h | 2 +- src/core/config.h | 20 +++++++++++++++----- src/skel/crossplatform.cpp | 4 ++-- src/skel/glfw/glfw.cpp | 24 ++++++++++++------------ 7 files changed, 39 insertions(+), 28 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index a214042a..2ce82727 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -40,7 +40,6 @@ "cppStandard": "gnu++11", "defines": [ "__SWITCH__", - "GTA_SWITCH", "LIBRW", "RW_GL3", "AUDIO_OAL" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 67dfb325..2989c145 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -149,10 +149,6 @@ endif() # Build Nintendo Switch binaries if(NINTENDO_SWITCH) - target_compile_definitions(${EXECUTABLE} PRIVATE - GTA_SWITCH - ) - # Needed for OpenAL-Soft target_link_libraries(${EXECUTABLE} PRIVATE openal # HACK - something broke with latest cmake diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index 033ed9b9..5b0fd60c 100644 --- a/src/core/MenuScreensCustom.cpp +++ b/src/core/MenuScreensCustom.cpp @@ -36,7 +36,7 @@ #ifdef CUSTOM_FRONTEND_OPTIONS -#ifdef IMPROVED_VIDEOMODE +#if defined(IMPROVED_VIDEOMODE) && !defined(GTA_HANDHELD) #define VIDEOMODE_SELECTOR MENUACTION_CFO_SELECT, "FEM_SCF", { new CCFOSelect((int8*)&FrontEndMenuManager.m_nPrefsWindowed, "VideoMode", "Windowed", screenModes, 2, true, ScreenModeAfterChange, true) }, #else #define VIDEOMODE_SELECTOR @@ -418,10 +418,10 @@ CMenuScreenCustom aScreens[MENUPAGES] = { }, // MENUPAGE_CONTROLLER_SETTINGS = 4 -#ifdef GAMEPAD_MENU +#if defined(GAMEPAD_MENU) && !defined(GTA_HANDHELD) { "FET_AGS", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, nil, nil, #else - { "FET_CON", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, nil, nil, + { "FET_AGS", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, nil, nil, #endif MENUACTION_CTRLCONFIG, "FEC_CCF", { nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS }, MENUACTION_CTRLDISPLAY, "FEC_CDP", { nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS }, @@ -751,7 +751,11 @@ CMenuScreenCustom aScreens[MENUPAGES] = { // MENUPAGE_OPTIONS = 41 { "FET_OPT", MENUPAGE_NONE, MENUPAGE_NONE, nil, nil, +#ifdef GTA_HANDHELD + MENUACTION_CHANGEMENU, "FET_CTL", { nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS }, +#else MENUACTION_CHANGEMENU, "FET_CTL", { nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC }, +#endif MENUACTION_LOADRADIO, "FET_AUD", { nil, SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS }, MENUACTION_CHANGEMENU, "FET_DIS", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS }, #ifdef GRAPHICS_MENU_OPTIONS @@ -885,7 +889,9 @@ CMenuScreenCustom aScreens[MENUPAGES] = { { "FET_GFX", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, new CCustomScreenLayout({MENUSPRITE_MAINMENU, 50, 0, 20, FONT_HEADING, FESCREEN_LEFT_ALIGN, true, MEDIUMTEXT_X_SCALE, MEDIUMTEXT_Y_SCALE}), GraphicsGoBack, +#ifdef GTA_HANDHELD MENUACTION_SCREENRES, "FED_RES", { nil, SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS }, +#endif MENUACTION_WIDESCREEN, "FED_WIS", { nil, SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS }, VIDEOMODE_SELECTOR MENUACTION_FRAMESYNC, "FEM_VSC", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS }, diff --git a/src/core/common.h b/src/core/common.h index 99aafc5a..31aab2b3 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -11,7 +11,7 @@ #define __STDC_LIMIT_MACROS // so we get UINT32_MAX etc #endif -#ifdef GTA_SWITCH +#ifdef __SWITCH__ #include #endif diff --git a/src/core/config.h b/src/core/config.h index 462dd713..8171f987 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -158,6 +158,11 @@ enum Config { #define GTA_VERSION GTA3_PC_11 +// Enable configuration for handheld console ports +#if defined(__SWITCH__) || defined(PSP2) + #define GTA_HANDHELD +#endif + #if defined GTA_PS2 # define GTA_PS2_STUFF # define RANDOMSPLASH @@ -166,7 +171,9 @@ enum Config { # define ANIM_COMPRESSION # define PS2_MENU #elif defined GTA_PC -# define PC_PLAYER_CONTROLS // mouse player/cam mode +# ifndef GTA_HANDHELD +# define PC_PLAYER_CONTROLS // mouse player/cam mode +# endif # define GTA_REPLAY # define GTA_SCENE_EDIT # define PC_MENU @@ -319,7 +326,7 @@ enum Config { #if !defined(RW_GL3) && defined(_WIN32) #define XINPUT #endif -#if defined XINPUT || (defined RW_GL3 && !defined LIBRW_SDL2 && !defined GTA_SWITCH) +#if defined XINPUT || (defined RW_GL3 && !defined LIBRW_SDL2 && !defined GTA_HANDHELD) #define DETECT_JOYSTICK_MENU // Then we'll expect user to enter Controller->Detect joysticks if his joystick isn't detected at the start. #endif #define DETECT_PAD_INPUT_SWITCH // Adds automatic switch of pad related stuff between controller and kb/m @@ -345,7 +352,7 @@ enum Config { //# define PS2_MENU_USEALLPAGEICONS #else -# if defined(XINPUT) || defined(GTA_SWITCH) +# if defined(XINPUT) || defined(GTA_HANDHELD) # define GAMEPAD_MENU // Add gamepad menu # endif @@ -439,7 +446,7 @@ enum Config { #endif // Streaming -#if !defined(_WIN32) && !defined(GTA_SWITCH) +#if !defined(_WIN32) && !defined(__SWITCH__) //#define ONE_THREAD_PER_CHANNEL // Don't use if you're not on SSD/Flash - also not utilized too much right now(see commented LoadAllRequestedModels in Streaming.cpp) #define FLUSHABLE_STREAMING // Make it possible to interrupt reading when processing file isn't needed anymore. #endif @@ -461,8 +468,11 @@ enum Config { #undef PEDS_REPORT_CRIMES_ON_PHONE #endif -#ifdef GTA_SWITCH +#ifdef GTA_HANDHELD #define IGNORE_MOUSE_KEYBOARD // ignore mouse & keyboard input +#endif + +#ifdef __SWITCH__ #define USE_UNNAMED_SEM // named semaphores are unsupported on the switch #endif diff --git a/src/skel/crossplatform.cpp b/src/skel/crossplatform.cpp index 758125e9..e69c22e1 100644 --- a/src/skel/crossplatform.cpp +++ b/src/skel/crossplatform.cpp @@ -200,7 +200,7 @@ char* casepath(char const* path, bool checkPathFirst) DIR* d; char* c; - #if defined(GTA_SWITCH) || defined(GTA_VITA) + #if defined(__SWITCH__) || defined(PSP2) if( (c = strstr(p, ":/")) != NULL) // scheme used by some environments, eg. switch, vita { size_t deviceNameOffset = c - p + 3; @@ -294,7 +294,7 @@ char* casepath(char const* path, bool checkPathFirst) } #endif -#ifdef GTA_SWITCH +#ifdef __SWITCH__ /* Taken from glibc */ char *realpath(const char *name, char *resolved) { diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 754c43be..767d1bbd 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -12,7 +12,7 @@ DWORD _dwOperatingSystemVersion; #include "resource.h" #else long _dwOperatingSystemVersion; -#ifndef GTA_SWITCH +#ifndef __SWITCH__ #ifndef __APPLE__ #include #else @@ -53,7 +53,7 @@ long _dwOperatingSystemVersion; #include "MemoryMgr.h" // We found out that GLFW's keyboard input handling is still pretty delayed/not stable, so now we fetch input from X11 directly on Linux. -#if !defined _WIN32 && !defined __APPLE__ && !defined GTA_SWITCH // && !defined WAYLAND +#if !defined _WIN32 && !defined __APPLE__ && !defined GTA_HANDHELD // && !defined WAYLAND #define GET_KEYBOARD_INPUT_FROM_X11 #endif @@ -330,7 +330,7 @@ psNativeTextureSupport(void) ***************************************************************************** */ -#ifdef GTA_SWITCH +#ifdef __SWITCH__ static HidVibrationValue SwitchVibrationValues[2]; static HidVibrationDeviceHandle SwitchVibrationDeviceHandles[2][2]; @@ -338,10 +338,10 @@ static HidVibrationDeviceHandle SwitchVibrationDeviceGC; static PadState SwitchPad; -Result HidInitializationResult[2]; -Result HidInitializationGCResult; +static Result HidInitializationResult[2]; +static Result HidInitializationGCResult; -void _psInitializeVibration() +static void _psInitializeVibration() { HidInitializationResult[0] = hidInitializeVibrationDevices(SwitchVibrationDeviceHandles[0], 2, HidNpadIdType_Handheld, HidNpadStyleTag_NpadHandheld); if(R_FAILED(HidInitializationResult[0])) { @@ -360,10 +360,10 @@ void _psInitializeVibration() SwitchVibrationValues[0].freq_high = 320.0f; padConfigureInput(1, HidNpadStyleSet_NpadFullCtrl); - padInitializeDefault(&SwitchPad); + padInitializeDefault(&SwitchPad); } -void _psHandleVibration() +static void _psHandleVibration() { padUpdate(&SwitchPad); @@ -394,8 +394,8 @@ void _psHandleVibration() } } #else -void _psInitializeVibration() {} -void _psHandleVibration() {} +static void _psInitializeVibration() {} +static void _psHandleVibration() {} #endif /* @@ -561,7 +561,7 @@ psInitialize(void) debug("Physical memory size %llu\n", _dwMemAvailPhys); debug("Available physical memory %llu\n", size); #else -#ifndef GTA_SWITCH +#ifndef __SWITCH__ struct sysinfo systemInfo; sysinfo(&systemInfo); _dwMemAvailPhys = systemInfo.freeram; @@ -1871,7 +1871,7 @@ main(int argc, char *argv[]) InitMemoryMgr(); #endif -#if !defined(_WIN32) && !defined(GTA_SWITCH) +#if !defined(_WIN32) && !defined(__SWITCH__) struct sigaction act; act.sa_sigaction = terminateHandler; act.sa_flags = SA_SIGINFO; -- cgit v1.2.3 From a247d533675a3ffa3b5f3722bef4d55e5a912d03 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Mon, 5 Jul 2021 16:02:10 +0200 Subject: cmake: fix OpenAL on Switch + using X11 on Linux --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b687124a..8bfe3656 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.14) set(EXECUTABLE re3) set(PROJECT RE3) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2989c145..4de36572 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,9 +54,13 @@ target_compile_definitions(${EXECUTABLE} PRIVATE USE_OUR_VERSIONING) if(${PROJECT}_AUDIO STREQUAL "OAL") find_package(OpenAL REQUIRED) - target_include_directories(${EXECUTABLE} PRIVATE ${OPENAL_INCLUDE_DIR}) - target_link_libraries(${EXECUTABLE} PRIVATE ${OPENAL_LIBRARY}) - target_compile_definitions(${EXECUTABLE} PRIVATE ${OPENAL_DEFINITIONS}) + if(TARGET OpenAL::OpenAL) + target_link_libraries(${EXECUTABLE} PRIVATE OpenAL::OpenAL) + else() + target_include_directories(${EXECUTABLE} PRIVATE ${OPENAL_INCLUDE_DIR}) + target_link_libraries(${EXECUTABLE} PRIVATE ${OPENAL_LIBRARY}) + target_compile_definitions(${EXECUTABLE} PRIVATE ${OPENAL_DEFINITIONS}) + endif() target_compile_definitions(${EXECUTABLE} PRIVATE AUDIO_OAL) elseif(${PROJECT}_AUDIO STREQUAL "MSS") find_package(MilesSDK REQUIRED) @@ -126,6 +130,11 @@ else() set(${PROJECT}_C_CXX_EXTENSIONS OFF) endif() +if(NOT (WINDOWS OR APPLE OR NINTENDO_SWITCH)) + find_package(X11 REQUIRED) + target_link_libraries(${EXECUTABLE} PRIVATE X11::X11) +endif() + set_target_properties(${EXECUTABLE} PROPERTIES C_STANDARD 11 @@ -151,7 +160,6 @@ endif() if(NINTENDO_SWITCH) # Needed for OpenAL-Soft target_link_libraries(${EXECUTABLE} PRIVATE - openal # HACK - something broke with latest cmake SDL2 ) -- cgit v1.2.3 From b09b489ae7b15feb85b71a18f1b8e320f56d0ce8 Mon Sep 17 00:00:00 2001 From: Adrian Graber Date: Mon, 5 Jul 2021 20:52:00 +0200 Subject: Fix WINDOWS -> WIN32 on cmake --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4de36572..1cf10d0f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -130,7 +130,7 @@ else() set(${PROJECT}_C_CXX_EXTENSIONS OFF) endif() -if(NOT (WINDOWS OR APPLE OR NINTENDO_SWITCH)) +if(NOT (WIN32 OR APPLE OR NINTENDO_SWITCH)) find_package(X11 REQUIRED) target_link_libraries(${EXECUTABLE} PRIVATE X11::X11) endif() -- cgit v1.2.3 From a99a04ed49fe5cea1eb8292d9ffeefb40d10ac82 Mon Sep 17 00:00:00 2001 From: Adrian Graber Date: Tue, 6 Jul 2021 18:05:21 +0200 Subject: Add Switch controller asset and configuration * Add GXT string for the Nintendo Switch Controller * Add frontend and button textures for Nintendo Switch controllers * Fix wrong #ifndef when hiding screen resolution option on GTA_HANDHELD --- gamefiles/TEXT/american.gxt | Bin 220642 -> 220708 bytes gamefiles/TEXT/french.gxt | Bin 246616 -> 246682 bytes gamefiles/TEXT/german.gxt | Bin 242680 -> 242746 bytes gamefiles/TEXT/italian.gxt | Bin 242050 -> 242116 bytes gamefiles/TEXT/polish.gxt | Bin 241682 -> 241748 bytes gamefiles/TEXT/russian.gxt | Bin 222468 -> 222534 bytes gamefiles/TEXT/spanish.gxt | Bin 235614 -> 235676 bytes gamefiles/models/frontend_nsw.txd | Bin 0 -> 2360104 bytes gamefiles/models/nswbtns.txd | Bin 0 -> 528424 bytes src/core/ControllerConfig.cpp | 14 ++++++++++++++ src/core/Frontend.cpp | 20 ++++++++++++++++++++ src/core/Frontend.h | 1 + src/core/MenuScreensCustom.cpp | 4 ++-- utils/gxt/american.txt | 3 +++ utils/gxt/french.txt | 3 +++ utils/gxt/german.txt | 3 +++ utils/gxt/italian.txt | 3 +++ utils/gxt/polish.txt | 3 +++ utils/gxt/russian.txt | 3 +++ utils/gxt/spanish.txt | 3 +++ 20 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 gamefiles/models/frontend_nsw.txd create mode 100644 gamefiles/models/nswbtns.txd diff --git a/gamefiles/TEXT/american.gxt b/gamefiles/TEXT/american.gxt index d4034411..d7b7c956 100644 Binary files a/gamefiles/TEXT/american.gxt and b/gamefiles/TEXT/american.gxt differ diff --git a/gamefiles/TEXT/french.gxt b/gamefiles/TEXT/french.gxt index 16c7a716..3dece994 100644 Binary files a/gamefiles/TEXT/french.gxt and b/gamefiles/TEXT/french.gxt differ diff --git a/gamefiles/TEXT/german.gxt b/gamefiles/TEXT/german.gxt index c3309d61..7f25bd05 100644 Binary files a/gamefiles/TEXT/german.gxt and b/gamefiles/TEXT/german.gxt differ diff --git a/gamefiles/TEXT/italian.gxt b/gamefiles/TEXT/italian.gxt index b30b74f4..5a060a9a 100644 Binary files a/gamefiles/TEXT/italian.gxt and b/gamefiles/TEXT/italian.gxt differ diff --git a/gamefiles/TEXT/polish.gxt b/gamefiles/TEXT/polish.gxt index d771427b..782f656d 100755 Binary files a/gamefiles/TEXT/polish.gxt and b/gamefiles/TEXT/polish.gxt differ diff --git a/gamefiles/TEXT/russian.gxt b/gamefiles/TEXT/russian.gxt index 0075c691..914f5b52 100644 Binary files a/gamefiles/TEXT/russian.gxt and b/gamefiles/TEXT/russian.gxt differ diff --git a/gamefiles/TEXT/spanish.gxt b/gamefiles/TEXT/spanish.gxt index 8980eb4d..cb884689 100644 Binary files a/gamefiles/TEXT/spanish.gxt and b/gamefiles/TEXT/spanish.gxt differ diff --git a/gamefiles/models/frontend_nsw.txd b/gamefiles/models/frontend_nsw.txd new file mode 100644 index 00000000..1379a1a7 Binary files /dev/null and b/gamefiles/models/frontend_nsw.txd differ diff --git a/gamefiles/models/nswbtns.txd b/gamefiles/models/nswbtns.txd new file mode 100644 index 00000000..0b1756ee Binary files /dev/null and b/gamefiles/models/nswbtns.txd differ diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index e72af7e4..8775792f 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -2644,6 +2644,14 @@ const char *PlayStationButtons[][MAX_CONTROLLERACTIONS] = #undef PS2_CROSS #undef PS2_SQUARE +const char *NintendoSwitchButtons_noIcons[][MAX_CONTROLLERACTIONS] = + CONTROLLER_BUTTONS("Y", "A", "B", "X", "L", "ZL", "LS", "R", "ZR", "RS", "BACK"); + +#ifdef BUTTON_ICONS +const char *NintendoSwitchButtons[][MAX_CONTROLLERACTIONS] = + CONTROLLER_BUTTONS("~T~", "~O~", "~X~", "~Q~", "~K~", "~M~", "~A~", "~J~", "~V~", "~C~", "BACK"); +#endif + #undef CONTROLLER_BUTTONS #undef VFB @@ -2664,6 +2672,9 @@ void CControllerConfigManager::GetWideStringOfCommandKeys(uint16 action, wchar * case CMenuManager::CONTROLLER_DUALSHOCK4: Buttons = CFont::ButtonsSlot != -1 ? PlayStationButtons : PlayStationButtons_noIcons; break; + case CMenuManager::CONTROLLER_NINTENDO_SWITCH: + Buttons = CFont::ButtonsSlot != -1 ? NintendoSwitchButtons : NintendoSwitchButtons_noIcons; + break; default: #endif Buttons = CFont::ButtonsSlot != -1 ? XboxButtons : XboxButtons_noIcons; @@ -2679,6 +2690,9 @@ void CControllerConfigManager::GetWideStringOfCommandKeys(uint16 action, wchar * case CMenuManager::CONTROLLER_DUALSHOCK4: Buttons = PlayStationButtons_noIcons; break; + case CMenuManager::CONTROLLER_NINTENDO_SWITCH: + Buttons = NintendoSwitchButtons_noIcons; + break; default: Buttons = XboxButtons_noIcons; break; diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index ecb893b4..0f4218a4 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -142,8 +142,12 @@ int8 CMenuManager::m_PrefsIslandLoading = ISLAND_LOADING_LOW; #endif #ifdef GAMEPAD_MENU +#ifdef __SWITCH__ +int8 CMenuManager::m_PrefsControllerType = CONTROLLER_NINTENDO_SWITCH; +#else int8 CMenuManager::m_PrefsControllerType = CONTROLLER_XBOXONE; #endif +#endif int32 CMenuManager::OS_Language = LANG_ENGLISH; int8 CMenuManager::m_PrefsUseVibration; @@ -3674,6 +3678,7 @@ const char* controllerTypesPaths[] = { "MODELS/FRONTEND_DS4.TXD", "MODELS/FRONTEND_X360.TXD", "MODELS/FRONTEND_XONE.TXD", + "MODELS/FRONTEND_NSW.TXD", }; void @@ -3686,6 +3691,9 @@ CMenuManager::LoadController(int8 type) case CONTROLLER_DUALSHOCK4: CFont::LoadButtons("MODELS/PS3BTNS.TXD"); break; + case CONTROLLER_NINTENDO_SWITCH: + CFont::LoadButtons("MODELS/NSWBTNS.TXD"); + break; default: CFont::LoadButtons("MODELS/X360BTNS.TXD"); break; @@ -5928,6 +5936,18 @@ CMenuManager::PrintController(void) TEXT_L2R2_Y += 5.0f; TEXT_SELECT_X += 3.0f; break; + case CONTROLLER_NINTENDO_SWITCH: + TEXT_L1_Y += 5.0f; + TEXT_L1_Y_VEH = TEXT_L1_Y; + TEXT_R1_Y += 5.0f; + TEXT_TRIANGLE_Y += 3.0f; + TEXT_CIRCLE_Y += 3.0f; + TEXT_CROSS_Y += 3.0f; + TEXT_LSTICK_Y -= 23.0f; + TEXT_DPAD_Y += 25.0; + TEXT_RSTICK_Y += 1.0f; + TEXT_R3_Y += 1.0f; + break; }; if (m_DisplayControllerOnFoot) { diff --git a/src/core/Frontend.h b/src/core/Frontend.h index 32e5ef9d..6e6c40f7 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -760,6 +760,7 @@ public: CONTROLLER_DUALSHOCK4, CONTROLLER_XBOX360, CONTROLLER_XBOXONE, + CONTROLLER_NINTENDO_SWITCH, }; static int8 m_PrefsControllerType; diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index 5b0fd60c..586b51fa 100644 --- a/src/core/MenuScreensCustom.cpp +++ b/src/core/MenuScreensCustom.cpp @@ -388,7 +388,7 @@ void DetectJoystickGoBack() { #endif #ifdef GAMEPAD_MENU -const char* controllerTypes[] = { "FEC_DS2", "FEC_DS3", "FEC_DS4", "FEC_360", "FEC_ONE" }; +const char* controllerTypes[] = { "FEC_DS2", "FEC_DS3", "FEC_DS4", "FEC_360", "FEC_ONE", "FEC_NSW" }; void ControllerTypeAfterChange(int8 before, int8 after) { FrontEndMenuManager.LoadController(after); @@ -889,7 +889,7 @@ CMenuScreenCustom aScreens[MENUPAGES] = { { "FET_GFX", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, new CCustomScreenLayout({MENUSPRITE_MAINMENU, 50, 0, 20, FONT_HEADING, FESCREEN_LEFT_ALIGN, true, MEDIUMTEXT_X_SCALE, MEDIUMTEXT_Y_SCALE}), GraphicsGoBack, -#ifdef GTA_HANDHELD +#ifndef GTA_HANDHELD MENUACTION_SCREENRES, "FED_RES", { nil, SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS }, #endif MENUACTION_WIDESCREEN, "FED_WIS", { nil, SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS }, diff --git a/utils/gxt/american.txt b/utils/gxt/american.txt index d8f79f05..57ec4d74 100644 --- a/utils/gxt/american.txt +++ b/utils/gxt/american.txt @@ -8061,6 +8061,9 @@ XBOX 360 CONTROLLER [FEC_ONE] XBOX ONE CONTROLLER +[FEC_NSW] +NINTENDO SWITCH CONTROLLER + [FEC_TYP] GAMEPAD TYPE diff --git a/utils/gxt/french.txt b/utils/gxt/french.txt index bd4acf96..bdb12c7b 100644 --- a/utils/gxt/french.txt +++ b/utils/gxt/french.txt @@ -8329,6 +8329,9 @@ XBOX 360 CONTROLLER [FEC_ONE] XBOX ONE CONTROLLER +[FEC_NSW] +NINTENDO SWITCH CONTROLLER + [FEC_TYP] GAMEPAD TYPE diff --git a/utils/gxt/german.txt b/utils/gxt/german.txt index 5f5c53c4..b77cb17c 100644 --- a/utils/gxt/german.txt +++ b/utils/gxt/german.txt @@ -8146,6 +8146,9 @@ XBOX 360 CONTROLLER [FEC_ONE] XBOX ONE CONTROLLER +[FEC_NSW] +NINTENDO SWITCH CONTROLLER + [FEC_TYP] GAMEPAD-TYP diff --git a/utils/gxt/italian.txt b/utils/gxt/italian.txt index 803b7fbf..9dfee85c 100644 --- a/utils/gxt/italian.txt +++ b/utils/gxt/italian.txt @@ -8158,6 +8158,9 @@ XBOX 360 CONTROLLER [FEC_ONE] XBOX ONE CONTROLLER +[FEC_NSW] +NINTENDO SWITCH CONTROLLER + [FEC_TYP] GAMEPAD TYPE diff --git a/utils/gxt/polish.txt b/utils/gxt/polish.txt index 33716291..98d373ef 100755 --- a/utils/gxt/polish.txt +++ b/utils/gxt/polish.txt @@ -8067,6 +8067,9 @@ XBOX 360 CONTROLLER [FEC_ONE] XBOX ONE CONTROLLER +[FEC_NSW] +NINTENDO SWITCH CONTROLLER + [FEC_TYP] GAMEPAD TYPE diff --git a/utils/gxt/russian.txt b/utils/gxt/russian.txt index 221e59f5..3b42bb21 100644 --- a/utils/gxt/russian.txt +++ b/utils/gxt/russian.txt @@ -8069,6 +8069,9 @@ DUALSHOCK 4 [FEC_ONE] КОНТРОЛЛЕР XBOX ONE +[FEC_NSW] +КОНТРОЛЛЕР NINTENDO SWITCH + [FEC_TYP] ГЕЙМПАД diff --git a/utils/gxt/spanish.txt b/utils/gxt/spanish.txt index 5f108d3b..2775d342 100644 --- a/utils/gxt/spanish.txt +++ b/utils/gxt/spanish.txt @@ -8128,6 +8128,9 @@ MANDO DE XBOX 360 [FEC_ONE] MANDO DE XBOX ONE +[FEC_NSW] +MANDO DE NINTENDO SWITCH + [FEC_TYP] TIPO DE MANDO -- cgit v1.2.3 From 3bde84f6c8480217b2fcd7ec29c28f62672a3279 Mon Sep 17 00:00:00 2001 From: Adrian Graber Date: Mon, 12 Jul 2021 01:26:11 +0200 Subject: Move assets to dedicated folder and redefine GLFW mappings for Switch --- README.md | 2 +- logo.png | Bin 24295 -> 0 bytes logo.svg | 88 ----------------------------------------------- logo_switch.jpg | Bin 18096 -> 0 bytes res/images/logo.svg | 88 +++++++++++++++++++++++++++++++++++++++++++++++ res/images/logo_1024.png | Bin 0 -> 24295 bytes res/images/logo_256.jpg | Bin 0 -> 18096 bytes src/CMakeLists.txt | 2 +- src/skel/crossplatform.h | 25 ++++++++++++++ 9 files changed, 115 insertions(+), 90 deletions(-) delete mode 100644 logo.png delete mode 100644 logo.svg delete mode 100644 logo_switch.jpg create mode 100644 res/images/logo.svg create mode 100644 res/images/logo_1024.png create mode 100644 res/images/logo_256.jpg diff --git a/README.md b/README.md index 9ccabf1e..bcbecaba 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -re3 logo +re3 logo [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2FGTAmodding%2Fre3%2Fbadge%3Fref%3Dmaster&style=flat)](https://actions-badge.atrox.dev/GTAmodding/re3/goto?ref=master) diff --git a/logo.png b/logo.png deleted file mode 100644 index 50ae8690..00000000 Binary files a/logo.png and /dev/null differ diff --git a/logo.svg b/logo.svg deleted file mode 100644 index 9db8447c..00000000 --- a/logo.svg +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - - - diff --git a/logo_switch.jpg b/logo_switch.jpg deleted file mode 100644 index 595d2c3b..00000000 Binary files a/logo_switch.jpg and /dev/null differ diff --git a/res/images/logo.svg b/res/images/logo.svg new file mode 100644 index 00000000..9db8447c --- /dev/null +++ b/res/images/logo.svg @@ -0,0 +1,88 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/res/images/logo_1024.png b/res/images/logo_1024.png new file mode 100644 index 00000000..50ae8690 Binary files /dev/null and b/res/images/logo_1024.png differ diff --git a/res/images/logo_256.jpg b/res/images/logo_256.jpg new file mode 100644 index 00000000..595d2c3b Binary files /dev/null and b/res/images/logo_256.jpg differ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1cf10d0f..425f2315 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -171,7 +171,7 @@ if(NINTENDO_SWITCH) nx_create_nro(${EXECUTABLE} NACP ${EXECUTABLE}.nacp - ICON "${PROJECT_SOURCE_DIR}/logo_switch.jpg" + ICON "${PROJECT_SOURCE_DIR}/res/images/logo_256.jpg" ) if(${PROJECT}_INSTALL) diff --git a/src/skel/crossplatform.h b/src/skel/crossplatform.h index aa90ce5a..67bb4282 100644 --- a/src/skel/crossplatform.h +++ b/src/skel/crossplatform.h @@ -157,3 +157,28 @@ bool FindNextFile(HANDLE, WIN32_FIND_DATA*); void FileTimeToSystemTime(time_t*, SYSTEMTIME*); void GetDateFormat(int, int, SYSTEMTIME*, int, char*, int); #endif + +#ifdef __SWITCH__ + +// tweak glfw values for switch to match expected pc bindings +#ifdef GLFW_GAMEPAD_BUTTON_A + #undef GLFW_GAMEPAD_BUTTON_A +#endif +#define GLFW_GAMEPAD_BUTTON_A 1 + +#ifdef GLFW_GAMEPAD_BUTTON_B + #undef GLFW_GAMEPAD_BUTTON_B +#endif +#define GLFW_GAMEPAD_BUTTON_B 0 + +#ifdef GLFW_GAMEPAD_BUTTON_X + #undef GLFW_GAMEPAD_BUTTON_X +#endif +#define GLFW_GAMEPAD_BUTTON_X 3 + +#ifdef GLFW_GAMEPAD_BUTTON_Y + #undef GLFW_GAMEPAD_BUTTON_Y +#endif +#define GLFW_GAMEPAD_BUTTON_Y 2 + +#endif -- cgit v1.2.3 From 5cab196718d94c1ddfe1ddda0490a639cac7fde0 Mon Sep 17 00:00:00 2001 From: Adrian Graber Date: Mon, 12 Jul 2021 02:27:45 +0200 Subject: Finish cmake stuff for Switch build * SDL2 for OpenAL not needed anymore * Add re3_platform_target function and use that instead of manually building NRO --- CMakeLists.txt | 15 +++++++++++---- cmake/nx/NXFunctions.cmake | 31 +++++++++++++++++++++++++++++++ src/CMakeLists.txt | 25 +------------------------ 3 files changed, 43 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bfe3656..adf3c29f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,18 +4,25 @@ set(EXECUTABLE re3) set(PROJECT RE3) project(${EXECUTABLE} C CXX) +set(${PROJECT}_AUTHOR "${PROJECT} Team") list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") include(GetGitRevisionDescription) get_git_head_revision(GIT_REFSPEC GIT_SHA1 "ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR") message(STATUS "Building ${CMAKE_PROJECT_NAME} GIT SHA1: ${GIT_SHA1}") -if(WIN32) - set(${PROJECT}_AUDIOS "OAL" "MSS") -elseif(NINTENDO_SWITCH) +if(NINTENDO_SWITCH) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/nx") include(NXFunctions) - set(${PROJECT}_AUDIOS "OAL") +endif() + +if(NOT COMMAND re3_platform_target) + function(re3_platform_target) + endfunction() +endif() + +if(WIN32) + set(${PROJECT}_AUDIOS "OAL" "MSS") else() set(${PROJECT}_AUDIOS "OAL") endif() diff --git a/cmake/nx/NXFunctions.cmake b/cmake/nx/NXFunctions.cmake index 8fa23fae..cf3f974b 100644 --- a/cmake/nx/NXFunctions.cmake +++ b/cmake/nx/NXFunctions.cmake @@ -5,3 +5,34 @@ endif() if(NOT COMMAND nx_create_nro) message(FATAL_ERROR "The `nx_create_nro` cmake command is not available. Please use an appropriate Nintendo Switch toolchain.") endif() + +set(CMAKE_EXECUTABLE_SUFFIX ".elf") + +function(re3_platform_target TARGET) + cmake_parse_arguments(RPT "INSTALL" "" "" ${ARGN}) + + get_target_property(TARGET_TYPE "${TARGET}" TYPE) + if(TARGET_TYPE STREQUAL "EXECUTABLE") + nx_generate_nacp(${TARGET}.nacp + NAME "${TARGET}" + AUTHOR "${${PROJECT}_AUTHOR}" + VERSION "1.0.0-${GIT_SHA1}" + ) + + nx_create_nro(${TARGET} + NACP ${TARGET}.nacp + ICON "${PROJECT_SOURCE_DIR}/res/images/logo_256.jpg" + ) + + if(${PROJECT}_INSTALL AND RPT_INSTALL) + get_target_property(TARGET_OUTPUT_NAME ${TARGET} OUTPUT_NAME) + if(NOT TARGET_OUTPUT_NAME) + set(TARGET_OUTPUT_NAME "${TARGET}") + endif() + + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_OUTPUT_NAME}.nro" + DESTINATION "." + ) + endif() + endif() +endfunction() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 425f2315..8dac5a3a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -156,27 +156,4 @@ if(${PROJECT}_INSTALL) endif() endif() -# Build Nintendo Switch binaries -if(NINTENDO_SWITCH) - # Needed for OpenAL-Soft - target_link_libraries(${EXECUTABLE} PRIVATE - SDL2 - ) - - nx_generate_nacp (${EXECUTABLE}.nacp - NAME "${EXECUTABLE}" - AUTHOR "${EXECUTABLE} Team" - VERSION "1.0.0-${GIT_SHA1}" - ) - - nx_create_nro(${EXECUTABLE} - NACP ${EXECUTABLE}.nacp - ICON "${PROJECT_SOURCE_DIR}/res/images/logo_256.jpg" - ) - - if(${PROJECT}_INSTALL) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE}.nro" - DESTINATION "." - ) - endif() -endif() +re3_platform_target(${EXECUTABLE} INSTALL) -- cgit v1.2.3 From a7b38e1b34210c9c78c16a32140ba40e47152fa8 Mon Sep 17 00:00:00 2001 From: Adrian Graber Date: Mon, 12 Jul 2021 20:58:34 +0200 Subject: Save current usable memory for Switch application --- src/skel/glfw/glfw.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 767d1bbd..6d4cade9 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -560,14 +560,15 @@ psInitialize(void) _dwMemAvailPhys = (uint64_t)(vm_stat.free_count * page_size); debug("Physical memory size %llu\n", _dwMemAvailPhys); debug("Available physical memory %llu\n", size); +#elif defined (__SWITCH__) + svcGetInfo(&_dwMemAvailPhys, 7, 0xffff8001, 0); + debug("Physical memory size %llu\n", _dwMemAvailPhys); #else -#ifndef __SWITCH__ struct sysinfo systemInfo; sysinfo(&systemInfo); _dwMemAvailPhys = systemInfo.freeram; debug("Physical memory size %u\n", systemInfo.totalram); debug("Available physical memory %u\n", systemInfo.freeram); -#endif #endif TheText.Unload(); -- cgit v1.2.3 From 207378c94716f8c97600f39f63dff526de293a50 Mon Sep 17 00:00:00 2001 From: Adrian Graber Date: Tue, 13 Jul 2021 00:41:56 +0200 Subject: Use svcGetInfo definitions from libnx Co-authored-by: Anonymous Maarten --- src/skel/glfw/glfw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 6d4cade9..2282a040 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -561,7 +561,7 @@ psInitialize(void) debug("Physical memory size %llu\n", _dwMemAvailPhys); debug("Available physical memory %llu\n", size); #elif defined (__SWITCH__) - svcGetInfo(&_dwMemAvailPhys, 7, 0xffff8001, 0); + svcGetInfo(&_dwMemAvailPhys, InfoType_UsedMemorySize, CUR_PROCESS_HANDLE, 0); debug("Physical memory size %llu\n", _dwMemAvailPhys); #else struct sysinfo systemInfo; -- cgit v1.2.3 From 79856dac2567d0950679d6961c0e540797d132db Mon Sep 17 00:00:00 2001 From: erorcun Date: Mon, 16 Aug 2021 21:06:06 +0300 Subject: Fix impossible bullets & turn speed on heavy guns --- src/peds/Ped.cpp | 8 ++++-- src/peds/PedFight.cpp | 14 ++++++++++ src/peds/PlayerPed.cpp | 41 +++++++++++++++++++++------- src/peds/PlayerPed.h | 6 +++++ src/weapons/Weapon.cpp | 72 +++++++++++++++++++++++++++++++++++++++++--------- 5 files changed, 117 insertions(+), 24 deletions(-) diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 96c1d094..6b28dcb0 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -1120,8 +1120,12 @@ CPed::ClearAimFlag(void) #endif } - if (IsPlayer()) + if (IsPlayer()) { ((CPlayerPed*)this)->m_fFPSMoveHeading = 0.0f; +#ifdef FREE_CAM + ((CPlayerPed*)this)->m_bFreeAimActive = false; +#endif + } } void @@ -1361,7 +1365,7 @@ CPed::CalculateNewVelocity(void) } #ifdef FREE_CAM - if (!TheCamera.Cams[0].Using3rdPersonMouseCam()) + if (!CCamera::bFreeCam || !TheCamera.Cams[0].Using3rdPersonMouseCam()) #endif if (IsPlayer() && m_nPedState == PED_ATTACK) headAmount /= 4.0f; diff --git a/src/peds/PedFight.cpp b/src/peds/PedFight.cpp index 13d3930c..03d5c755 100644 --- a/src/peds/PedFight.cpp +++ b/src/peds/PedFight.cpp @@ -311,9 +311,14 @@ CPed::SetAttack(CEntity *victim) m_pLookTarget->RegisterReference((CEntity **) &m_pLookTarget); m_pSeekTarget->RegisterReference((CEntity **) &m_pSeekTarget); } + if (m_pLookTarget) { SetAimFlag(m_pLookTarget); +#ifdef FREE_CAM + } else if (this != FindPlayerPed() || !((CPlayerPed*)this)->m_bFreeAimActive) { +#else } else { +#endif SetAimFlag(m_fRotationCur); if (FindPlayerPed() == this && TheCamera.Cams[0].Using3rdPersonMouseCam()) @@ -736,6 +741,15 @@ CPed::Attack(void) weaponAnimAssoc->SetCurrentTime(ourWeapon->m_fAnimLoopEnd); weaponAnimAssoc->flags &= ~ASSOC_RUNNING; SetPointGunAt(m_pPointGunAt); +#endif +#ifdef FREE_CAM + } else if (IsPlayer() && ((CPlayerPed*)this)->m_bFreeAimActive && GetWeapon()->m_eWeaponState != WEAPONSTATE_RELOADING) { + float limitedCam = CGeneral::LimitRadianAngle(-TheCamera.Orientation); + SetLookFlag(limitedCam, true); + SetAimFlag(limitedCam); + SetLookTimer(INT32_MAX); + SetPointGunAt(nil); + ((CPlayerPed*)this)->m_fFPSMoveHeading = TheCamera.Find3rdPersonQuickAimPitch(); #endif } else { ClearAimFlag(); diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index 416fb949..deb409b5 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -504,7 +504,7 @@ CPlayerPed::DoWeaponSmoothSpray(void) if (m_nPedState == PED_ATTACK && !m_pPointGunAt) { eWeaponType weapon = GetWeapon()->m_eWeaponType; #ifdef FREE_CAM - if(TheCamera.Cams[0].Using3rdPersonMouseCam() && (weapon == WEAPONTYPE_COLT45 || weapon == WEAPONTYPE_UZI)) + if(CCamera::bFreeCam && TheCamera.Cams[0].Using3rdPersonMouseCam() && (weapon == WEAPONTYPE_COLT45 || weapon == WEAPONTYPE_UZI)) return false; #endif if (weapon == WEAPONTYPE_FLAMETHROWER || weapon == WEAPONTYPE_COLT45 || weapon == WEAPONTYPE_UZI || weapon == WEAPONTYPE_SHOTGUN || @@ -1060,7 +1060,9 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed) #ifdef FREE_CAM static int8 changedHeadingRate = 0; + static int8 pointedGun = 0; if (changedHeadingRate == 2) changedHeadingRate = 1; + if (pointedGun == 2) pointedGun = 1; // Rotate player/arm when shooting. We don't have auto-rotation anymore if (CCamera::m_bUseMouse3rdPerson && CCamera::bFreeCam && @@ -1071,22 +1073,28 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed) if ((padUsed->GetTarget() && weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM)) || padUsed->GetWeapon()) { float limitedCam = CGeneral::LimitRadianAngle(-TheCamera.Orientation); + m_cachedCamSource = TheCamera.Cams[TheCamera.ActiveCam].Source; + m_cachedCamFront = TheCamera.Cams[TheCamera.ActiveCam].Front; + m_cachedCamUp = TheCamera.Cams[TheCamera.ActiveCam].Up; + // On this one we can rotate arm. if (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM)) { - if (!padUsed->GetWeapon()) { // making this State != ATTACK still stops it after attack. Re-start it immediately! - SetPointGunAt(nil); - bIsPointingGunAt = false; // to not stop after attack - } - + pointedGun = 2; + m_bFreeAimActive = true; SetLookFlag(limitedCam, true); SetAimFlag(limitedCam); #ifdef VC_PED_PORTS SetLookTimer(INT32_MAX); // removing this makes head move for real, but I experinced some bugs. #endif + ((CPlayerPed*)this)->m_fFPSMoveHeading = TheCamera.Find3rdPersonQuickAimPitch(); + if (m_nPedState != PED_ATTACK && m_nPedState != PED_AIM_GUN) { + // This is a seperate ped state just for pointing gun. Used for target button + SetPointGunAt(nil); + } } else { m_fRotationDest = limitedCam; changedHeadingRate = 2; - m_headingRate = 50.0f; + m_headingRate = 12.5f; // Anim. fix for shotgun, ak47 and m16 (we must finish rot. it quickly) if (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM) && padUsed->WeaponJustDown()) { @@ -1102,14 +1110,27 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed) m_fRotationCur += (limitedRotDest - m_fRotationCur) / 2; } } - } else if (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM) && m_nPedState != PED_ATTACK) - ClearPointGunAt(); + } } } if (changedHeadingRate == 1) { changedHeadingRate = 0; RestoreHeadingRate(); } + if (pointedGun == 1) { + if (m_nPedState == PED_ATTACK) { + if (!padUsed->GetWeapon() && (m_pedIK.m_flags & CPedIK::GUN_POINTED_SUCCESSFULLY) == 0) { + float limitedCam = CGeneral::LimitRadianAngle(-TheCamera.Orientation); + + SetAimFlag(limitedCam); + ((CPlayerPed*)this)->m_fFPSMoveHeading = TheCamera.Find3rdPersonQuickAimPitch(); + m_bFreeAimActive = true; + } + } else { + pointedGun = 0; + ClearPointGunAt(); + } + } #endif if (padUsed->GetTarget() && m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT) { @@ -1188,7 +1209,7 @@ CPlayerPed::PlayerControlZelda(CPad *padUsed) } #ifdef FREE_CAM - if(TheCamera.Cams[0].Using3rdPersonMouseCam() && doSmoothSpray) { + if(CCamera::bFreeCam && TheCamera.Cams[0].Using3rdPersonMouseCam() && doSmoothSpray) { padMoveInGameUnit = 0.0f; smoothSprayWithoutMove = false; } diff --git a/src/peds/PlayerPed.h b/src/peds/PlayerPed.h index e8173c8c..796a6ca0 100644 --- a/src/peds/PlayerPed.h +++ b/src/peds/PlayerPed.h @@ -34,6 +34,12 @@ public: CPed *m_pPedAtSafePos[6]; float m_fWalkAngle; float m_fFPSMoveHeading; +#ifdef FREE_CAM + bool m_bFreeAimActive; + CVector m_cachedCamSource; + CVector m_cachedCamFront; + CVector m_cachedCamUp; +#endif CPlayerPed(); ~CPlayerPed(); diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp index 6eab1a65..d6af8202 100644 --- a/src/weapons/Weapon.cpp +++ b/src/weapons/Weapon.cpp @@ -50,6 +50,29 @@ uint16 gReloadSampleTime[WEAPONTYPE_LAST_WEAPONTYPE] = 0 // HELICANNON }; +#ifdef FREE_CAM +static bool +Find3rdPersonCamTargetVectorFromCachedVectors(float dist, CVector pos, CVector& source, CVector& target, CVector camSource, CVector camFront, CVector camUp) +{ + if (CPad::GetPad(0)->GetLookBehindForPed()) { + source = pos; + target = dist * FindPlayerPed()->GetForward() + source; + return false; + } else { + float angleX = DEGTORAD((TheCamera.m_f3rdPersonCHairMultX - 0.5f) * 1.8f * 0.5f * TheCamera.Cams[TheCamera.ActiveCam].FOV * CDraw::GetAspectRatio()); + float angleY = DEGTORAD((0.5f - TheCamera.m_f3rdPersonCHairMultY) * 1.8f * 0.5f * TheCamera.Cams[TheCamera.ActiveCam].FOV); + source = camSource; + target = camFront; + target += camUp * Tan(angleY); + target += CrossProduct(camFront, camUp) * Tan(angleX); + target.Normalise(); + source += DotProduct(pos - source, target) * target; + target = dist * target + source; + return true; + } +} +#endif + CWeaponInfo * CWeapon::GetInfo() { @@ -591,17 +614,22 @@ CWeapon::FireInstantHit(CEntity *shooter, CVector *fireSource) else if ( shooter == FindPlayerPed() && TheCamera.Cams[0].Using3rdPersonMouseCam() ) { CVector src, trgt; - TheCamera.Find3rdPersonCamTargetVector(info->m_fRange, *fireSource, src, trgt); #ifdef FREE_CAM - CPed *shooterPed = (CPed *)shooter; - if((shooterPed->m_pedIK.m_flags & CPedIK::GUN_POINTED_SUCCESSFULLY) == 0) { - trgt.x = info->m_fRange; - trgt.y = 0.0f; - trgt.z = 0.0f; - - shooterPed->TransformToNode(trgt, PED_HANDR); - } + if (CCamera::bFreeCam) { + CPlayerPed *shooterPed = (CPlayerPed*)shooter; + Find3rdPersonCamTargetVectorFromCachedVectors(info->m_fRange, *fireSource, src, trgt, shooterPed->m_cachedCamSource, shooterPed->m_cachedCamFront, shooterPed->m_cachedCamUp); + if ((shooterPed->m_pedIK.m_flags & CPedIK::GUN_POINTED_SUCCESSFULLY) == 0) { + trgt.x = info->m_fRange; + trgt.y = 0.0f; + trgt.z = 0.0f; + + shooterPed->TransformToNode(trgt, PED_HANDR); + } + } else #endif + { + TheCamera.Find3rdPersonCamTargetVector(info->m_fRange, *fireSource, src, trgt); + } #ifdef FIX_BUGS // fix muzzleflash rotation @@ -1209,8 +1237,19 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource) if ( shooter == FindPlayerPed() && TheCamera.Cams[0].Using3rdPersonMouseCam() ) { - TheCamera.Find3rdPersonCamTargetVector(1.0f, *fireSource, source, target); - CVector Left = CrossProduct(TheCamera.Cams[TheCamera.ActiveCam].Front, TheCamera.Cams[TheCamera.ActiveCam].Up); + CVector Left; +#ifdef FREE_CAM + if (CCamera::bFreeCam) { + CPlayerPed* shooterPed = (CPlayerPed*)shooter; + Find3rdPersonCamTargetVectorFromCachedVectors(1.0f, *fireSource, source, target, shooterPed->m_cachedCamSource, shooterPed->m_cachedCamFront, shooterPed->m_cachedCamUp); + Left = CrossProduct(shooterPed->m_cachedCamFront, shooterPed->m_cachedCamUp); + } + else +#endif + { + TheCamera.Find3rdPersonCamTargetVector(1.0f, *fireSource, source, target); + Left = CrossProduct(TheCamera.Cams[TheCamera.ActiveCam].Front, TheCamera.Cams[TheCamera.ActiveCam].Up); + } float f = float(i - 2) * (DEGTORAD(7.5f) / 2); target = f * Left + target - source; @@ -1525,7 +1564,16 @@ CWeapon::FireAreaEffect(CEntity *shooter, CVector *fireSource) if ( shooter == FindPlayerPed() && TheCamera.Cams[0].Using3rdPersonMouseCam() ) { - TheCamera.Find3rdPersonCamTargetVector(info->m_fRange, *fireSource, source, target); +#ifdef FREE_CAM + if (CCamera::bFreeCam) { + CPlayerPed *shooterPed = (CPlayerPed*)shooter; + Find3rdPersonCamTargetVectorFromCachedVectors(info->m_fRange, *fireSource, source, target, shooterPed->m_cachedCamSource, shooterPed->m_cachedCamFront, shooterPed->m_cachedCamUp); + } + else +#endif + { + TheCamera.Find3rdPersonCamTargetVector(info->m_fRange, *fireSource, source, target); + } float norm = (1.0f / info->m_fRange); dir = (target - source) * norm; } -- cgit v1.2.3 From e0ecbeee39e605cf2ee06e3632f4931d03606ce7 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 15 Aug 2021 21:24:20 +0300 Subject: Auto-detect X11 dependency --- autoconf/LICENSE.txt | 27 +++++ autoconf/api.lua | 305 +++++++++++++++++++++++++++++++++++++++++++++++++ autoconf/autoconf.lua | 18 +++ autoconf/clang.lua | 27 +++++ autoconf/gcc.lua | 27 +++++ autoconf/msc.lua | 62 ++++++++++ premake5.lua | 21 +++- src/CMakeLists.txt | 16 +++ src/skel/glfw/glfw.cpp | 6 +- 9 files changed, 501 insertions(+), 8 deletions(-) create mode 100644 autoconf/LICENSE.txt create mode 100644 autoconf/api.lua create mode 100644 autoconf/autoconf.lua create mode 100644 autoconf/clang.lua create mode 100644 autoconf/gcc.lua create mode 100644 autoconf/msc.lua diff --git a/autoconf/LICENSE.txt b/autoconf/LICENSE.txt new file mode 100644 index 00000000..eb1b1720 --- /dev/null +++ b/autoconf/LICENSE.txt @@ -0,0 +1,27 @@ +Copyright (c) 2016 Blizzard Entertainment and individual contributors. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of Premake nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/autoconf/api.lua b/autoconf/api.lua new file mode 100644 index 00000000..064ea795 --- /dev/null +++ b/autoconf/api.lua @@ -0,0 +1,305 @@ +--- +-- Autoconfiguration. +-- Copyright (c) 2016 Blizzard Entertainment +-- Enhanced by re3 +--- +local p = premake +local autoconf = p.modules.autoconf +autoconf.cache = {} +autoconf.parameters = "" + + +--- +-- register autoconfigure api. +--- +p.api.register { + name = "autoconfigure", + scope = "config", + kind = "table" +} + +--- +-- Check for a particular include file. +-- +-- @cfg : Current config. +-- @variable : The variable to store the result, such as 'HAVE_STDINT_H'. +-- @filename : The header file to check for. +--- +function check_include(cfg, variable, filename) + local res = autoconf.cache_compile(cfg, variable, function () + p.outln('#include <' .. filename .. '>') + p.outln('int main(void) { return 0; }') + end) + + if res.value then + autoconf.set_value(cfg, variable, 1) + end +end + + +--- +-- Check for size of a particular type. +-- +-- @cfg : Current config. +-- @variable : The variable to use, such as 'SIZEOF_SIZE_T', this method will also add "'HAVE_' .. variable". +-- @type : The type to check. +-- @headers : An optional array of header files to include. +-- @defines : An optional array of defines to define. +--- +function check_type_size(cfg, variable, type, headers, defines) + check_include(cfg, 'HAVE_SYS_TYPES_H', 'sys/types.h') + check_include(cfg, 'HAVE_STDINT_H', 'stdint.h') + check_include(cfg, 'HAVE_STDDEF_H', 'stddef.h') + + local res = autoconf.cache_compile(cfg, variable .. cfg.platform, + function () + if cfg.autoconf['HAVE_SYS_TYPES_H'] then + p.outln('#include ') + end + + if cfg.autoconf['HAVE_STDINT_H'] then + p.outln('#include ') + end + + if cfg.autoconf['HAVE_STDDEF_H'] then + p.outln('#include ') + end + + autoconf.include_defines(defines) + autoconf.include_headers(headers) + p.outln("") + p.outln("#define SIZE (sizeof(" .. type .. "))") + p.outln("char info_size[] = {'I', 'N', 'F', 'O', ':', 's','i','z','e','[',") + p.outln(" ('0' + ((SIZE / 10000)%10)),") + p.outln(" ('0' + ((SIZE / 1000)%10)),") + p.outln(" ('0' + ((SIZE / 100)%10)),") + p.outln(" ('0' + ((SIZE / 10)%10)),") + p.outln(" ('0' + (SIZE %10)),") + p.outln(" ']', '\\0'};") + p.outln("") + p.outln("int main(int argc, char *argv[]) {") + p.outln(" int require = 0;") + p.outln(" require += info_size[argc];") + p.outln(" (void)argv;") + p.outln(" return require;") + p.outln("}") + end, + function (e) + -- if the compile step succeeded, we should have a binary with 'INFO:size[*****]' + -- somewhere in there. + local content = io.readfile(e.binary) + if content then + local size = string.find(content, 'INFO:size') + if size then + e.size = tonumber(string.sub(content, size+10, size+14)) + end + end + end + ) + + if res.size then + autoconf.set_value(cfg, 'HAVE_' .. variable, 1) + autoconf.set_value(cfg, variable, res.size) + end +end + + +--- +-- Check if the given struct or class has the specified member variable +-- +-- @cfg : current config. +-- @variable : variable to store the result. +-- @type : the name of the struct or class you are interested in +-- @member : the member which existence you want to check +-- @headers : an optional array of header files to include. +-- @defines : An optional array of defines to define. +--- +function check_struct_has_member(cfg, variable, type, member, headers, defines) + local res = autoconf.cache_compile(cfg, variable, function () + autoconf.include_defines(defines) + autoconf.include_headers(headers) + p.outln('int main(void) {') + p.outln(' (void)sizeof(((' .. type .. '*)0)->' .. member ..');') + p.outln(' return 0;') + p.outln('}') + end) + + if res.value then + autoconf.set_value(cfg, variable, 1) + end +end + + +--- +-- Check if a symbol exists as a function, variable, or macro +-- +-- @cfg : current config. +-- @variable : variable to store the result. +-- @symbol : The symbol to check for. +-- @headers : an optional array of header files to include. +-- @defines : An optional array of defines to define. +--- +function check_symbol_exists(cfg, variable, symbol, headers, defines) + local h = headers + local res = autoconf.cache_compile(cfg, variable, function () + autoconf.include_defines(defines) + autoconf.include_headers(headers) + p.outln('int main(int argc, char** argv) {') + p.outln(' (void)argv;') + p.outln('#ifndef ' .. symbol) + p.outln(' return ((int*)(&' .. symbol .. '))[argc];') + p.outln('#else') + p.outln(' (void)argc;') + p.outln(' return 0;') + p.outln('#endif') + p.outln('}') + end) + + if res.value then + autoconf.set_value(cfg, variable, 1) + end +end + + +--- +-- try compiling a piece of c/c++ +--- +function autoconf.try_compile(cfg, cpp) + local ts = autoconf.toolset(cfg) + if ts then + return ts.try_compile(cfg, cpp, autoconf.parameters) + else + p.warnOnce('autoconf', 'no toolset found, autoconf always failing.') + end +end + + +function autoconf.cache_compile(cfg, entry, func, post) + if not autoconf.cache[entry] then + local cpp = p.capture(func) + local res = autoconf.try_compile(cfg, cpp) + if res then + local e = { binary = res, value = true } + if post then + post(e) + end + autoconf.cache[entry] = e + else + autoconf.cache[entry] = { } + end + end + return autoconf.cache[entry] +end + + +--- +-- get the current configured toolset, or the default. +--- +function autoconf.toolset(cfg) + local ts = p.config.toolset(cfg) + if not ts then + local tools = { + -- Actually we always return nil on msc. see msc.lua + ['vs2010'] = p.tools.msc, + ['vs2012'] = p.tools.msc, + ['vs2013'] = p.tools.msc, + ['vs2015'] = p.tools.msc, + ['vs2017'] = p.tools.msc, + ['vs2019'] = p.tools.msc, + ['gmake'] = premake.tools.gcc, + ['gmake2'] = premake.tools.gcc, + ['codelite'] = premake.tools.gcc, + ['xcode4'] = premake.tools.clang, + } + ts = tools[_ACTION] + end + return ts +end + + +--- +-- store the value of the variable in the configuration +--- +function autoconf.set_value(cfg, variable, value) + cfg.autoconf[variable] = value +end + + +--- +-- write the cfg.autoconf table to the file +--- +function autoconf.writefile(cfg, filename) + if cfg.autoconf then + local file = io.open(filename, "w+") + for variable, value in pairs(cfg.autoconf) do + file:write('#define ' .. variable .. ' ' .. tostring(value) .. (_eol or '\n')) + end + file:close() + end +end + + +--- +-- Utility method to add a table of headers. +--- +function autoconf.include_headers(headers) + if headers ~= nil then + if type(headers) == "table" then + for _, v in ipairs(headers) do + p.outln('#include <' .. v .. '>') + end + else + p.outln('#include <' .. headers .. '>') + end + end +end + +function autoconf.include_defines(defines) + if defines ~= nil then + if type(defines) == "table" then + for _, v in ipairs(defines) do + p.outln('#define ' .. v) + end + else + p.outln('#define ' .. defines) + end + end +end + +--- +-- attach ourselfs to the running action. +--- +p.override(p.action, 'call', function (base, name) + local a = p.action.get(name) + + -- store the old callback. + local onBaseProject = a.onProject or a.onproject + + -- override it with our own. + a.onProject = function(prj) + -- go through each configuration, and call the setup configuration methods. + for cfg in p.project.eachconfig(prj) do + cfg.autoconf = {} + if cfg.autoconfigure then + verbosef('Running auto config steps for "%s/%s".', prj.name, cfg.name) + for file, func in pairs(cfg.autoconfigure) do + func(cfg) + + if not (file ~= "dontWrite") then + os.mkdir(cfg.objdir) + local filename = path.join(cfg.objdir, file) + autoconf.writefile(cfg, filename) + end + end + end + end + + -- then call the old onProject. + if onBaseProject then + onBaseProject(prj) + end + end + + -- now call the original action.call methods + base(name) +end) diff --git a/autoconf/autoconf.lua b/autoconf/autoconf.lua new file mode 100644 index 00000000..6c99f9da --- /dev/null +++ b/autoconf/autoconf.lua @@ -0,0 +1,18 @@ +--- +-- Autoconfiguration. +-- Copyright (c) 2016 Blizzard Entertainment +--- + local p = premake + + if not premake.modules.autoconf then + p.modules.autoconf = {} + p.modules.autoconf._VERSION = p._VERSION + + verbosef('Loading autoconf module...') + include('api.lua') + include('msc.lua') + include('clang.lua') + include('gcc.lua') + end + + return p.modules.autoconf diff --git a/autoconf/clang.lua b/autoconf/clang.lua new file mode 100644 index 00000000..fdb5f405 --- /dev/null +++ b/autoconf/clang.lua @@ -0,0 +1,27 @@ +--- +-- Autoconfiguration. +-- Copyright (c) 2016 Blizzard Entertainment +--- +local p = premake +local clang = p.tools.clang + +function clang.try_compile(cfg, text, parameters) + -- write the text to a temporary file. + local cppFile = path.join(cfg.objdir, "temp.cpp") + if not io.writefile(cppFile, text) then + return nil + end + + if parameters == nil then + parameters = "" + end + + local outFile = path.join(cfg.objdir, "temp.out") + + -- compile that text file. + if os.execute('clang "' .. cppFile .. '" ' .. parameters .. ' -o "' .. outFile ..'" &> /dev/null') then + return outFile + else + return nil + end +end diff --git a/autoconf/gcc.lua b/autoconf/gcc.lua new file mode 100644 index 00000000..34520139 --- /dev/null +++ b/autoconf/gcc.lua @@ -0,0 +1,27 @@ +--- +-- Autoconfiguration. +-- Copyright (c) 2016 Blizzard Entertainment +--- +local p = premake +local gcc = p.tools.gcc + +function gcc.try_compile(cfg, text, parameters) + -- write the text to a temporary file. + local cppFile = path.join(cfg.objdir, "temp.cpp") + if not io.writefile(cppFile, text) then + return nil + end + + if parameters == nil then + parameters = "" + end + + local outFile = path.join(cfg.objdir, "temp.out") + + -- compile that text file. + if os.execute('gcc "' .. cppFile .. '" ' .. parameters .. ' -o "' .. outFile ..'" &> /dev/null') then + return outFile + else + return nil + end +end diff --git a/autoconf/msc.lua b/autoconf/msc.lua new file mode 100644 index 00000000..b96a82ec --- /dev/null +++ b/autoconf/msc.lua @@ -0,0 +1,62 @@ +--- +-- Autoconfiguration. +-- Copyright (c) 2016 Blizzard Entertainment +--- +local p = premake +local msc = p.tools.msc + +-- "parameters" is unused, matter of fact this file is unused - re3 +function msc.try_compile(cfg, text, parameters) + + return nil +--[[ + -- write the text to a temporary file. + local cppFile = path.join(cfg.objdir, "temp.cpp") + if not io.writefile(cppFile, text) then + return nil + end + + -- write out a batch file. + local batch = p.capture(function () + p.outln('@echo off') + p.outln('SET mypath=%~dp0') + p.outln('pushd %mypath%') + + local map = { + vs2010 = 'VS100COMNTOOLS', + vs2012 = 'VS110COMNTOOLS', + vs2013 = 'VS120COMNTOOLS', + vs2015 = 'VS140COMNTOOLS', + vs2017 = 'VS141COMNTOOLS', + vs2019 = 'VS142COMNTOOLS', + } + + local a = map[_ACTION] + if a then + a = path.translate(os.getenv(a), '/') + a = path.join(a, '../../VC/vcvarsall.bat') + + if cfg.platform == 'x86' then + p.outln('call "' .. a .. '" > NUL') + else + p.outln('call "' .. a .. '" amd64 > NUL') + end + + p.outln('cl.exe /nologo temp.cpp > NUL') + else + error('Unsupported Visual Studio version: ' .. _ACTION) + end + end) + + local batchFile = path.join(cfg.objdir, "compile.bat") + if not io.writefile(batchFile, batch) then + return nil + end + + if os.execute(batchFile) then + return path.join(cfg.objdir, "temp.exe") + else + return nil + end +--]] +end diff --git a/premake5.lua b/premake5.lua index 25090dc6..a33623fc 100644 --- a/premake5.lua +++ b/premake5.lua @@ -42,6 +42,8 @@ newoption { description = "Don't print full paths into binary" } +require("autoconf") + if(_OPTIONS["with-librw"]) then Librw = "vendor/librw" else @@ -364,6 +366,19 @@ project "re3" filter "platforms:win*glfw*" staticruntime "off" + + filter "platforms:*glfw*" + premake.modules.autoconf.parameters = "-lglfw -lX11" + autoconfigure { + -- iterates all configs and runs on them + ["dontWrite"] = function (cfg) + check_symbol_exists(cfg, "haveX11", "glfwGetX11Display", { "X11/Xlib.h", "X11/XKBlib.h", "GLFW/glfw3.h", "GLFW/glfw3native.h" }, "GLFW_EXPOSE_NATIVE_X11") + if cfg.autoconf["haveX11"] then + table.insert(cfg.links, "X11") + table.insert(cfg.defines, "GET_KEYBOARD_INPUT_FROM_X11") + end + end + } filter "platforms:win*oal" includedirs { "vendor/openal-soft/include" } @@ -381,10 +396,10 @@ project "re3" libdirs { "vendor/openal-soft/libs/Win64" } filter "platforms:linux*oal" - links { "openal", "mpg123", "sndfile", "pthread", "X11" } - + links { "openal", "mpg123", "sndfile", "pthread" } + filter "platforms:bsd*oal" - links { "openal", "mpg123", "sndfile", "pthread", "X11" } + links { "openal", "mpg123", "sndfile", "pthread" } filter "platforms:macosx*oal" links { "openal", "mpg123", "sndfile", "pthread" } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9cbd87a0..818d180f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -130,6 +130,22 @@ else() set(${PROJECT}_C_CXX_EXTENSIONS OFF) endif() +if(LIBRW_PLATFORM_GL3 AND LIBRW_GL3_GFXLIB STREQUAL "GLFW") + include(CheckSymbolExists) + + set(CMAKE_REQUIRED_LIBRARIES glfw) + set(CMAKE_REQUIRED_DEFINITIONS -DGLFW_EXPOSE_NATIVE_X11) + check_symbol_exists(glfwGetX11Display "GLFW/glfw3.h;GLFW/glfw3native.h" GLFW_HAS_X11) + unset(CMAKE_REQUIRED_DEFINITIONS) + unset(CMAKE_REQUIRED_LIBRARIES) + + if (GLFW_HAS_X11) + find_package(X11 REQUIRED) + target_link_libraries(${EXECUTABLE} PRIVATE X11::X11) + target_compile_definitions(${EXECUTABLE} PRIVATE GET_KEYBOARD_INPUT_FROM_X11) + endif (GLFW_HAS_X11) +endif() + set_target_properties(${EXECUTABLE} PROPERTIES C_STANDARD 11 diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 92574953..92a5a93f 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -52,11 +52,7 @@ long _dwOperatingSystemVersion; #include "Font.h" #include "MemoryMgr.h" -// We found out that GLFW's keyboard input handling is still pretty delayed/not stable, so now we fetch input from X11 directly on Linux. -#if !defined _WIN32 && !defined __APPLE__ && !defined GTA_HANDHELD // && !defined WAYLAND -#define GET_KEYBOARD_INPUT_FROM_X11 -#endif - +// This is defined on project-level, via premake5 or cmake #ifdef GET_KEYBOARD_INPUT_FROM_X11 #include #include -- cgit v1.2.3 From 2526503743e71af6a93b033cf23d8d50e2abf926 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Tue, 17 Aug 2021 10:50:53 +0300 Subject: Remove FIX_BUGS that wasn't needed --- src/audio/AudioLogic.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index d3f38345..3ce3c3cf 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -883,11 +883,7 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams& params) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 3; -#ifdef FIX_BUGS multiplier = (m_sQueueSample.m_fDistance / SOUND_INTENSITY) * 0.5f; -#else - multiplier = (m_sQueueSample.m_fDistance / 3.0f) * 0.5f; -#endif freq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE); m_sQueueSample.m_nFrequency = freq + freq * multiplier; m_sQueueSample.m_nLoopCount = 0; -- cgit v1.2.3 From 16ff379ebeca2092e9609eb3163a6bd2ffd68060 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Tue, 17 Aug 2021 13:58:48 +0300 Subject: Add AUDIO_REFLECTIONS define, fix a bunch of types, fix heli chatter intensity --- src/audio/AudioCollision.cpp | 8 +- src/audio/AudioLogic.cpp | 392 +++++++++++++++++++++++------------------ src/audio/AudioManager.cpp | 46 +++-- src/audio/AudioManager.h | 37 ++-- src/audio/DMAudio.cpp | 2 + src/audio/PolRadio.cpp | 2 +- src/audio/sampman_miles.cpp | 14 +- src/audio/sampman_oal.cpp | 14 +- src/core/MenuScreens.cpp | 2 + src/core/MenuScreensCustom.cpp | 2 + src/core/config.h | 5 + 11 files changed, 313 insertions(+), 211 deletions(-) diff --git a/src/audio/AudioCollision.cpp b/src/audio/AudioCollision.cpp index 1b72764e..02231773 100644 --- a/src/audio/AudioCollision.cpp +++ b/src/audio/AudioCollision.cpp @@ -203,7 +203,7 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col) m_sQueueSample.m_fDistance = Sqrt(col.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance); - if(m_sQueueSample.m_nVolume) { + if(m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = gOneShotCol[s1]; switch(m_sQueueSample.m_nSampleIndex) { case SFX_COL_TARMAC_1: @@ -269,7 +269,7 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col) m_sQueueSample.m_SoundIntensity = CollisionSoundIntensity; m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -285,7 +285,7 @@ cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 coun m_sQueueSample.m_fDistance = Sqrt(col.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance); - if(m_sQueueSample.m_nVolume) { + if(m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = counter; m_sQueueSample.m_vecPos = col.m_vecPosition; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -299,7 +299,7 @@ cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 coun m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 5; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 3ce3c3cf..7ccd7134 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -676,7 +676,7 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams& params) CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); float emittingVol = 30.f * CWeather::Rain; m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, rainOnVehicleIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = veh->m_bRainSamplesCounter++; if (veh->m_bRainSamplesCounter > 4) veh->m_bRainSamplesCounter = 68; @@ -692,7 +692,7 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams& params) m_sQueueSample.m_SoundIntensity = rainOnVehicleIntensity; m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_bReverbFlag = FALSE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -725,7 +725,7 @@ cAudioManager::ProcessReverseGear(cVehicleParams& params) modificator = Abs(modificator); emittingVol = (24.f * modificator); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, reverseGearIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { if (params.m_pVehicle->m_fGasPedal >= 0.0f) { m_sQueueSample.m_nCounter = 62; m_sQueueSample.m_nSampleIndex = SFX_REVERSE_GEAR_2; @@ -745,7 +745,7 @@ cAudioManager::ProcessReverseGear(cVehicleParams& params) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 5; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -780,7 +780,7 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams& params) if (emittingVol) { CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, 30.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nSampleIndex = SFX_REMOTE_CONTROLLED_CAR; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -795,7 +795,7 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams& params) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -824,7 +824,7 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams& params) CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); emittingVol = 30.f * Min(1.f, velocity / (0.5f * params.m_pTransmission->fMaxVelocity)); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; @@ -847,7 +847,7 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams& params) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 4; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -877,7 +877,7 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams& params) relativeVelocity = Min(1.0f, velChange / (0.5f * params.m_pTransmission->fMaxVelocity)); emittingVol = 23.0f * relativeVelocity * CWeather::WetRoads; m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -894,7 +894,7 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams& params) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 4; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -1006,7 +1006,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams& params) volume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); } m_sQueueSample.m_nVolume = volume; - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { if (automobile->GetStatus() == STATUS_SIMPLE) { if (modificator < 0.02f) { m_sQueueSample.m_nSampleIndex = aVehicleSettings[params.m_nIndex].m_nBank - CAR_SFX_BANKS_OFFSET + SFX_CAR_IDLE_1; @@ -1040,7 +1040,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams& params) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 8; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -1078,7 +1078,7 @@ void cAudioManager::AddPlayerCarSample(uint8 emittingVolume, uint32 freq, uint32 sample, uint8 bank, uint8 counter, bool8 notLooping) { m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, 50.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = counter; m_sQueueSample.m_nSampleIndex = sample; #ifdef GTA_PS2 @@ -1101,7 +1101,7 @@ cAudioManager::AddPlayerCarSample(uint8 emittingVolume, uint32 freq, uint32 samp m_sQueueSample.m_SoundIntensity = 50.0f; m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -1129,7 +1129,7 @@ cAudioManager::ProcessCesna(cVehicleParams& params) } else if (params.m_fDistance < SQR(200)) { CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(80, 200.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 52; m_sQueueSample.m_nSampleIndex = SFX_CESNA_IDLE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -1144,12 +1144,12 @@ cAudioManager::ProcessCesna(cVehicleParams& params) m_sQueueSample.m_SoundIntensity = 200.0f; m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } if (params.m_fDistance < SQR(90)) { m_sQueueSample.m_nVolume = ComputeVolume(80, 90.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nSampleIndex = SFX_CESNA_REV; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -1164,7 +1164,7 @@ cAudioManager::ProcessCesna(cVehicleParams& params) m_sQueueSample.m_SoundIntensity = 90.0f; m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -1453,7 +1453,7 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams& params) if (skidVal > 0.0f) { emittingVol = 50.f * skidVal; m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 3; switch (params.m_pVehicle->m_nSurfaceTouched) { case SURFACE_GRASS: @@ -1490,7 +1490,7 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams& params) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -1565,7 +1565,7 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams& params) CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(80, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 4; m_sQueueSample.m_nSampleIndex = aVehicleSettings[params.m_nIndex].m_nHornSample; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -1580,7 +1580,7 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams& params) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -1630,7 +1630,7 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams& params) CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(80, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 5; if (UsesSiren(params.m_nIndex)) { if (params.m_pVehicle->GetStatus() == STATUS_ABANDONED) @@ -1661,7 +1661,7 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams& params) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 5; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); return TRUE; } else @@ -1689,7 +1689,7 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams& params) if (veh->bEngineOn && veh->m_fGasPedal < 0.0f) { CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(60, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 12; m_sQueueSample.m_nSampleIndex = SFX_REVERSE_WARNING; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -1704,7 +1704,7 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams& params) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -1734,7 +1734,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams& params) if (velocity > 0.0035f) { emittingVol = (100.f * velocity * 10.f / 3.f); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = i + 6; m_sQueueSample.m_nSampleIndex = m_anRandomTable[1] % 6 + SFX_COL_CAR_PANEL_1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex) + RandomDisplacement(1000); @@ -1748,7 +1748,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams& params) m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); AddSampleToRequestedQueue(); } } @@ -1777,7 +1777,7 @@ cAudioManager::ProcessAirBrakes(cVehicleParams& params) CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); rand = m_anRandomTable[0] % 10 + 70; m_sQueueSample.m_nVolume = ComputeVolume(rand, 30.0f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 13; m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_AIR_BRAKES); @@ -1792,7 +1792,7 @@ cAudioManager::ProcessAirBrakes(cVehicleParams& params) m_sQueueSample.m_SoundIntensity = 30.0f; m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -1834,7 +1834,7 @@ cAudioManager::ProcessEngineDamage(cVehicleParams& params) } CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, engineDamageIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 28; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; @@ -1846,7 +1846,7 @@ cAudioManager::ProcessEngineDamage(cVehicleParams& params) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -1864,7 +1864,7 @@ cAudioManager::ProcessCarBombTick(cVehicleParams& params) if (automobile->bEngineOn && automobile->m_bombType == CARBOMB_TIMEDACTIVE) { CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(60, 40.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 35; m_sQueueSample.m_nSampleIndex = SFX_COUNTDOWN; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -1879,7 +1879,7 @@ cAudioManager::ProcessCarBombTick(cVehicleParams& params) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -1903,7 +1903,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) for (uint16 i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; i++) { noReflections = FALSE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); event = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i]; switch (event) { case SOUND_CAR_DOOR_CLOSE_BONNET: @@ -1943,7 +1943,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); break; } case SOUND_CAR_DOOR_OPEN_BONNET: @@ -1981,7 +1981,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); break; } case SOUND_CAR_WINDSHIELD_CRACK: { @@ -2027,7 +2027,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); break; } case SOUND_CAR_LIGHT_BREAK: { @@ -2167,7 +2167,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; maxDist = SQR(SOUND_INTENSITY); - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); emittingVol = 60; break; } @@ -2227,7 +2227,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); emittingVol = 50; maxDist = SQR(SOUND_INTENSITY); break; @@ -2258,7 +2258,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; maxDist = SQR(SOUND_INTENSITY); - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); emittingVol = m_anRandomTable[4] % 20 + 90; break; } @@ -2275,7 +2275,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) maxDist = SQR(SOUND_INTENSITY); emittingVol = m_anRandomTable[4] % 20 + 55; CrunchOffset %= 2; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); break; } case SOUND_CAR_PED_COLLISION: { @@ -2301,7 +2301,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) if (params.m_fDistance < maxDist) { CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { if (noReflections) { m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -2338,7 +2338,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams& params) emittingVol = (75.f * speedMultipler); if (train->m_fWagonPosition == 0.0f) { m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 32; m_sQueueSample.m_nSampleIndex = SFX_TRAIN_FAR; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -2353,14 +2353,14 @@ cAudioManager::ProcessTrainNoise(cVehicleParams& params) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } const float SOUND_INTENSITY = 70.0f; if (params.m_fDistance < SQR(SOUND_INTENSITY)) { m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 33; m_sQueueSample.m_nSampleIndex = SFX_TRAIN_NEAR; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -2375,7 +2375,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams& params) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -2403,7 +2403,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) if (params.m_nIndex == REEFER) { CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(80, intensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 39; m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE; m_sQueueSample.m_nFrequency = 10386; @@ -2419,7 +2419,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 7; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } if (FindPlayerVehicle() == params.m_pVehicle) { @@ -2442,23 +2442,24 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) } } m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, intensity, m_sQueueSample.m_fDistance); - if (!m_sQueueSample.m_nVolume) - return TRUE; - m_sQueueSample.m_nCounter = 40; - m_sQueueSample.m_nSampleIndex = SFX_POLICE_BOAT_ACCEL; - m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nLoopCount = 0; - SET_EMITTING_VOLUME(emittingVol); - SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) - m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_SoundIntensity = intensity; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 7; - m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + if (m_sQueueSample.m_nVolume > 0) { + m_sQueueSample.m_nCounter = 40; + m_sQueueSample.m_nSampleIndex = SFX_POLICE_BOAT_ACCEL; + m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nLoopCount = 0; + SET_EMITTING_VOLUME(emittingVol); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) + m_sQueueSample.m_fSpeedMultiplier = 2.0f; + m_sQueueSample.m_SoundIntensity = intensity; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; + m_sQueueSample.m_nReleasingVolumeDivider = 7; + m_sQueueSample.m_bReverbFlag = TRUE; + SET_SOUND_REFLECTION(FALSE); + AddSampleToRequestedQueue(); + } } else { if (FindPlayerVehicle() == params.m_pVehicle) { padAccelerate = Max(Pads[0].GetAccelerate(), Pads[0].GetBrake()); @@ -2499,23 +2500,23 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) } CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, intensity, m_sQueueSample.m_fDistance); - if (!m_sQueueSample.m_nVolume) - return TRUE; - m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nLoopCount = 0; - SET_EMITTING_VOLUME(emittingVol); - SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) - m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_SoundIntensity = intensity; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 7; - m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + if (m_sQueueSample.m_nVolume > 0) { + m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nLoopCount = 0; + SET_EMITTING_VOLUME(emittingVol); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) + m_sQueueSample.m_fSpeedMultiplier = 2.0f; + m_sQueueSample.m_SoundIntensity = intensity; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; + m_sQueueSample.m_nReleasingVolumeDivider = 7; + m_sQueueSample.m_bReverbFlag = TRUE; + SET_SOUND_REFLECTION(FALSE); + AddSampleToRequestedQueue(); + } } - AddSampleToRequestedQueue(); return TRUE; } return FALSE; @@ -2540,7 +2541,7 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams& params) CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); vol = (30.f * multiplier); m_sQueueSample.m_nVolume = ComputeVolume(vol, 50.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 38; m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -2555,7 +2556,7 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams& params) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -2595,7 +2596,7 @@ cAudioManager::ProcessHelicopter(cVehicleParams& params) emittingVol = gHeliSfxRanges[i].m_bBaseVolume; m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, gHeliSfxRanges[i].m_fMaxDistance, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = i + 65; m_sQueueSample.m_nSampleIndex = i + SFX_HELI_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -2610,7 +2611,7 @@ cAudioManager::ProcessHelicopter(cVehicleParams& params) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -2769,7 +2770,7 @@ cAudioManager::SetupJumboTaxiSound(uint8 vol) emittingVol -= emittingVol * gJumboVolOffsetPercentage / 100; m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -2784,7 +2785,7 @@ cAudioManager::SetupJumboTaxiSound(uint8 vol) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 4; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } return TRUE; @@ -2800,7 +2801,7 @@ cAudioManager::SetupJumboWhineSound(uint8 emittingVol, uint32 freq) m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_WHINE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -2815,7 +2816,7 @@ cAudioManager::SetupJumboWhineSound(uint8 emittingVol, uint32 freq) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 4; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } return TRUE; @@ -2830,7 +2831,7 @@ cAudioManager::SetupJumboEngineSound(uint8 vol, uint32 freq) uint8 emittingVol = vol - gJumboVolOffsetPercentage / 100; m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 3; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_ENGINE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -2845,7 +2846,7 @@ cAudioManager::SetupJumboEngineSound(uint8 vol, uint32 freq) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 4; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } return TRUE; @@ -2860,7 +2861,7 @@ cAudioManager::SetupJumboFlySound(uint8 emittingVol) int32 vol = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); m_sQueueSample.m_nVolume = vol; - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_DIST_FLY; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -2875,7 +2876,7 @@ cAudioManager::SetupJumboFlySound(uint8 emittingVol) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 5; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } return TRUE; @@ -2890,7 +2891,7 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 5; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_RUMBLE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -2906,7 +2907,7 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) m_sQueueSample.m_nReleasingVolumeDivider = 12; m_sQueueSample.m_nOffset = 0; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); m_sQueueSample.m_nCounter = 6; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_RUMBLE; @@ -2970,7 +2971,7 @@ cAudioManager::ProcessPedHeadphones(cPedParams ¶ms) } m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, 7.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 64; m_sQueueSample.m_nSampleIndex = SFX_HEADPHONES; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -2985,7 +2986,7 @@ cAudioManager::ProcessPedHeadphones(cPedParams ¶ms) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 5; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } return; @@ -3013,7 +3014,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) for (uint32 i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; i++) { stereo = FALSE; narrowSoundRange = FALSE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); sound = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i]; switch (sound) { case SOUND_STEP_START: @@ -3091,7 +3092,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); break; case SOUND_FALL_LAND: case SOUND_FALL_COLLAPSE: @@ -3118,7 +3119,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); break; case SOUND_FIGHT_PUNCH_33: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1; @@ -3182,7 +3183,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); break; case SOUND_WEAPON_BAT_ATTACK: m_sQueueSample.m_nSampleIndex = SFX_BAT_HIT_LEFT; @@ -3200,9 +3201,11 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; +#ifdef AUDIO_REFLECTIONS if (m_bDynamicAcousticModelingStatus) m_sQueueSample.m_bRequireReflection = TRUE; else +#endif stereo = TRUE; break; case SOUND_WEAPON_SHOT_FIRED: @@ -3225,9 +3228,11 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; +#ifdef AUDIO_REFLECTIONS if (m_bDynamicAcousticModelingStatus) m_sQueueSample.m_bRequireReflection = TRUE; else +#endif stereo = TRUE; break; case WEAPONTYPE_UZI: @@ -3265,9 +3270,11 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; +#ifdef AUDIO_REFLECTIONS if (m_bDynamicAcousticModelingStatus) m_sQueueSample.m_bRequireReflection = TRUE; else +#endif stereo = TRUE; break; case WEAPONTYPE_AK47: @@ -3323,9 +3330,11 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; +#ifdef AUDIO_REFLECTIONS if (m_bDynamicAcousticModelingStatus) m_sQueueSample.m_bRequireReflection = TRUE; else +#endif stereo = TRUE; break; case WEAPONTYPE_ROCKETLAUNCHER: @@ -3345,9 +3354,11 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; +#ifdef AUDIO_REFLECTIONS if (m_bDynamicAcousticModelingStatus) m_sQueueSample.m_bRequireReflection = TRUE; else +#endif stereo = TRUE; break; case WEAPONTYPE_FLAMETHROWER: @@ -3366,9 +3377,11 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 6; +#ifdef AUDIO_REFLECTIONS if (m_bDynamicAcousticModelingStatus) m_sQueueSample.m_bRequireReflection = TRUE; else +#endif stereo = TRUE; break; default: @@ -3424,7 +3437,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) SET_EMITTING_VOLUME(75); m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); break; case SOUND_WEAPON_AK47_BULLET_ECHO: case SOUND_WEAPON_UZI_BULLET_ECHO: @@ -3445,9 +3458,11 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; +#ifdef AUDIO_REFLECTIONS if (m_bDynamicAcousticModelingStatus) m_sQueueSample.m_bRequireReflection = TRUE; else +#endif stereo = TRUE; break; case SOUND_WEAPON_FLAMETHROWER_FIRE: @@ -3501,7 +3516,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); break; default: SetupPedComments(params, sound); @@ -3513,7 +3528,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) if (params.m_fDistance < maxDist) { CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { if (stereo) { if (m_sQueueSample.m_fDistance < 0.2f * m_sQueueSample.m_SoundIntensity) { m_sQueueSample.m_bIs2D = TRUE; @@ -3614,7 +3629,7 @@ cAudioManager::SetupPedComments(cPedParams ¶ms, uint16 sound) } m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, soundIntensity, m_sQueueSample.m_fDistance); pedComment.m_nProcess = 10; - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { pedComment.m_nEntityIndex = m_sQueueSample.m_nEntityIndex; pedComment.m_vecPos = m_sQueueSample.m_vecPos; pedComment.m_fDistance = m_sQueueSample.m_fDistance; @@ -6070,6 +6085,34 @@ cPedComments::Process() case SFX_POLICE_HELI_1: case SFX_POLICE_HELI_2: case SFX_POLICE_HELI_3: +#ifdef FIX_BUGS + case SFX_POLICE_HELI_4: + case SFX_POLICE_HELI_5: + case SFX_POLICE_HELI_6: + case SFX_POLICE_HELI_7: + case SFX_POLICE_HELI_8: + case SFX_POLICE_HELI_9: + case SFX_POLICE_HELI_10: + case SFX_POLICE_HELI_11: + case SFX_POLICE_HELI_12: + case SFX_POLICE_HELI_13: + case SFX_POLICE_HELI_14: + case SFX_POLICE_HELI_15: + case SFX_POLICE_HELI_16: + case SFX_POLICE_HELI_17: + case SFX_POLICE_HELI_18: + case SFX_POLICE_HELI_19: + case SFX_POLICE_HELI_20: + case SFX_POLICE_HELI_21: + case SFX_POLICE_HELI_22: + case SFX_POLICE_HELI_23: + case SFX_POLICE_HELI_24: + case SFX_POLICE_HELI_25: + case SFX_POLICE_HELI_26: + case SFX_POLICE_HELI_27: + case SFX_POLICE_HELI_28: + case SFX_POLICE_HELI_29: +#endif AudioManager.m_sQueueSample.m_SoundIntensity = 400.0f; break; default: @@ -6081,10 +6124,21 @@ cPedComments::Process() if (sampleIndex >= SFX_AMMU_D && sampleIndex <= SFX_AMMU_F) { AudioManager.m_sQueueSample.m_bReverbFlag = FALSE; +#ifdef AUDIO_REFLECTIONS + AudioManager.m_sQueueSample.m_bRequireReflection = FALSE; +#endif +#ifdef FIX_BUGS + } else if (sampleIndex >= SFX_POLICE_HELI_1 && sampleIndex <= SFX_POLICE_HELI_29) { + AudioManager.m_sQueueSample.m_bReverbFlag = TRUE; +#ifdef AUDIO_REFLECTIONS AudioManager.m_sQueueSample.m_bRequireReflection = FALSE; +#endif // AUDIO_REFLECTIONS +#endif // FIX_BUGS } else { AudioManager.m_sQueueSample.m_bReverbFlag = TRUE; +#ifdef AUDIO_REFLECTIONS AudioManager.m_sQueueSample.m_bRequireReflection = TRUE; +#endif } AudioManager.m_sQueueSample.m_bIs2D = FALSE; @@ -6175,7 +6229,7 @@ cAudioManager::ProcessExplosions(int32 explosion) if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(MAX_VOLUME, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = i; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_bIs2D = FALSE; @@ -6185,7 +6239,7 @@ cAudioManager::ProcessExplosions(int32 explosion) SET_EMITTING_VOLUME(MAX_VOLUME); RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); AddSampleToRequestedQueue(); } } @@ -6242,7 +6296,7 @@ cAudioManager::ProcessFires(int32) if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = i; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_fSpeedMultiplier = 2.0f; @@ -6253,7 +6307,7 @@ cAudioManager::ProcessFires(int32) SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -6277,7 +6331,7 @@ cAudioManager::ProcessWaterCannon(int32) #else m_sQueueSample.m_nVolume = ComputeVolume(50, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); #endif - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { #ifdef FIX_BUGS m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; #else @@ -6296,7 +6350,7 @@ cAudioManager::ProcessWaterCannon(int32) SET_EMITTING_VOLUME(50); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -6359,7 +6413,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); emittingVolume = RandomDisplacement(10) + 50; break; case SCRIPT_SOUND_BULLET_HIT_GROUND_1: @@ -6397,7 +6451,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); break; case SCRIPT_SOUND_GLASS_BREAK_L: m_sQueueSample.m_SoundIntensity = 60.0f; @@ -6428,7 +6482,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); break; case SCRIPT_SOUND_GLASS_LIGHT_BREAK: m_sQueueSample.m_SoundIntensity = 55.0f; @@ -6448,7 +6502,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); emittingVolume = m_anRandomTable[2] % 20 + 80; break; case SCRIPT_SOUND_BOX_DESTROYED_2: @@ -6459,7 +6513,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); emittingVolume = m_anRandomTable[2] % 20 + 80; break; case SCRIPT_SOUND_METAL_COLLISION: @@ -6471,7 +6525,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); emittingVolume = m_anRandomTable[2] % 30 + 70; break; case SCRIPT_SOUND_TIRE_COLLISION: @@ -6483,7 +6537,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); emittingVolume = m_anRandomTable[2] % 30 + 60; break; case SCRIPT_SOUND_GUNSHELL_DROP: @@ -6539,7 +6593,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_bReleasingSoundFlag = TRUE; @@ -7144,7 +7198,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; @@ -7152,7 +7206,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_bReverbFlag = TRUE; SET_EMITTING_VOLUME(emittingVolume); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -7214,7 +7268,7 @@ cAudioManager::ProcessPornCinema(uint8 sound) m_sQueueSample.m_fDistance = Sqrt(distSquared); if (sound != SCRIPT_SOUND_MISTY_SEX_S && sound != SCRIPT_SOUND_MISTY_SEX_L) { m_sQueueSample.m_nVolume = ComputeVolume(MAX_VOLUME, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = FALSE; @@ -7225,7 +7279,7 @@ cAudioManager::ProcessPornCinema(uint8 sound) SET_EMITTING_VOLUME(MAX_VOLUME); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -7233,7 +7287,7 @@ cAudioManager::ProcessPornCinema(uint8 sound) time = CTimer::GetTimeInMilliseconds(); if (time > gPornNextTime) { m_sQueueSample.m_nVolume = ComputeVolume(90, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { rand = m_anRandomTable[1] & 1; m_sQueueSample.m_nSampleIndex = rand + sample; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); @@ -7249,7 +7303,7 @@ cAudioManager::ProcessPornCinema(uint8 sound) #endif RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); gPornNextTime = time + 2000 + m_anRandomTable[3] % 6000; } @@ -7274,7 +7328,7 @@ cAudioManager::ProcessWorkShopScriptObject(uint8 sound) if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = SFX_WORKSHOP_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_WORKSHOP; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_WORKSHOP_1); @@ -7287,7 +7341,7 @@ cAudioManager::ProcessWorkShopScriptObject(uint8 sound) SET_EMITTING_VOLUME(30); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -7312,7 +7366,7 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = SFX_SAWMILL_LOOP; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_SAWMILL; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SAWMILL_LOOP); @@ -7325,13 +7379,13 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) SET_EMITTING_VOLUME(30); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } time = CTimer::GetTimeInMilliseconds(); if (time > gSawMillNextTime) { m_sQueueSample.m_nVolume = ComputeVolume(70, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = SFX_SAWMILL_CUT_WOOD; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_SAWMILL; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); @@ -7346,7 +7400,7 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) #endif RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); gSawMillNextTime = time + 2000 + m_anRandomTable[3] % 4000; } @@ -7369,7 +7423,7 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(45, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = SFX_LAUNDERETTE_LOOP; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_LAUNDERETTE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_LAUNDERETTE_LOOP); @@ -7382,11 +7436,11 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) SET_EMITTING_VOLUME(45); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } m_sQueueSample.m_nVolume = ComputeVolume(110, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = SFX_LAUNDERETTE_SONG_LOOP; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_LAUNDERETTE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_LAUNDERETTE_SONG_LOOP); @@ -7399,7 +7453,7 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) SET_EMITTING_VOLUME(110); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -7424,7 +7478,7 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = SFX_SHOP_LOOP; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_SHOP; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SHOP_LOOP); @@ -7437,13 +7491,13 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) SET_EMITTING_VOLUME(30); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } time = CTimer::GetTimeInMilliseconds(); if (time > gShopNextTime) { m_sQueueSample.m_nVolume = ComputeVolume(70, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { rand = m_anRandomTable[1] & 1; m_sQueueSample.m_nSampleIndex = rand + SFX_SHOP_TILL_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_SHOP; @@ -7457,7 +7511,7 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) SET_EMITTING_VOLUME(70); RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); gShopNextTime = time + 3000 + m_anRandomTable[3] % 7000; } @@ -7486,7 +7540,7 @@ cAudioManager::ProcessAirportScriptObject(uint8 sound) if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(110, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = (m_anRandomTable[1] & 3) + SFX_AIRPORT_ANNOUNCEMENT_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_AIRPORT; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); @@ -7499,7 +7553,7 @@ cAudioManager::ProcessAirportScriptObject(uint8 sound) SET_EMITTING_VOLUME(110); RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); gAirportNextTime = time + 10000 + m_anRandomTable[3] % 20000; } @@ -7531,7 +7585,7 @@ cAudioManager::ProcessCinemaScriptObject(uint8 sound) m_sQueueSample.m_fDistance = Sqrt(distSquared); rand = m_anRandomTable[0] % 90 + 30; m_sQueueSample.m_nVolume = ComputeVolume(rand, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = iSound % 3 + SFX_CINEMA_BASS_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CINEMA; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); @@ -7545,7 +7599,7 @@ cAudioManager::ProcessCinemaScriptObject(uint8 sound) SET_EMITTING_VOLUME(rand); RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); gCinemaNextTime = time + 1000 + m_anRandomTable[3] % 4000; } @@ -7579,7 +7633,7 @@ cAudioManager::ProcessDocksScriptObject(uint8 sound) m_sQueueSample.m_fDistance = Sqrt(distSquared); rand = m_anRandomTable[0] % 60 + 40; m_sQueueSample.m_nVolume = ComputeVolume(rand, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = SFX_DOCKS_FOGHORN; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_DOCKS; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_DOCKS_FOGHORN); @@ -7593,7 +7647,7 @@ cAudioManager::ProcessDocksScriptObject(uint8 sound) SET_EMITTING_VOLUME(rand); RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); gDocksNextTime = time + 10000 + m_anRandomTable[3] % 40000; } @@ -7626,7 +7680,7 @@ cAudioManager::ProcessHomeScriptObject(uint8 sound) m_sQueueSample.m_fDistance = Sqrt(dist); rand = m_anRandomTable[0] % 30 + 40; m_sQueueSample.m_nVolume = ComputeVolume(rand, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = m_anRandomTable[0] % 5 + SFX_HOME_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_HOME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); @@ -7640,7 +7694,7 @@ cAudioManager::ProcessHomeScriptObject(uint8 sound) SET_EMITTING_VOLUME(rand); RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); AddSampleToRequestedQueue(); gHomeNextTime = time + 1000 + m_anRandomTable[3] % 4000; } @@ -7678,7 +7732,7 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound) m_sQueueSample.m_nSampleIndex = sampleIndex; emittingVol = m_anRandomTable[0] % 50 + 55; m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); @@ -7691,7 +7745,7 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound) SET_EMITTING_VOLUME(emittingVol); RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); cPedParams params; params.m_bDistanceCalculated = TRUE; @@ -7738,7 +7792,7 @@ cAudioManager::ProcessWeather(int32 id) SET_EMITTING_VOLUME(m_sQueueSample.m_nVolume); RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = FALSE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } if (CWeather::Rain > 0.0f && (!CCullZones::CamNoRain() || !CCullZones::PlayerNoRain())) { @@ -7756,7 +7810,7 @@ cAudioManager::ProcessWeather(int32 id) m_sQueueSample.m_bReverbFlag = FALSE; SET_EMITTING_VOLUME(m_sQueueSample.m_nVolume); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -7935,7 +7989,7 @@ cAudioManager::ProcessFrontEnd() else m_sQueueSample.m_nOffset = 63; m_sQueueSample.m_bReverbFlag = FALSE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); if (stereo) { ++m_sQueueSample.m_nSampleIndex; @@ -7962,7 +8016,7 @@ cAudioManager::ProcessCrane() if (distSquared < SQR(intensity)) { CalculateDistance(distCalculated, distSquared); m_sQueueSample.m_nVolume = ComputeVolume(100, 80.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_CRANE_MAGNET; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -7977,7 +8031,7 @@ cAudioManager::ProcessCrane() m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } if (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents > 0) { @@ -7987,7 +8041,7 @@ cAudioManager::ProcessCrane() m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); AddSampleToRequestedQueue(); } } @@ -8033,7 +8087,7 @@ cAudioManager::ProcessProjectiles() if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = i; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; @@ -8041,7 +8095,7 @@ cAudioManager::ProcessProjectiles() SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -8078,7 +8132,7 @@ cAudioManager::ProcessGarages() while (state == GS_OPENING || state == GS_CLOSING || state == GS_AFTERDROPOFF) { CalculateDistance(distCalculated, distSquared); m_sQueueSample.m_nVolume = ComputeVolume(90, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { if (CGarages::aGarages[i].m_eGarageType == GARAGE_CRUSHER) { if (CGarages::aGarages[i].m_eGarageState == GS_AFTERDROPOFF) { if (m_FrameCounter & 1) { @@ -8122,7 +8176,7 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } break; @@ -8135,7 +8189,7 @@ cAudioManager::ProcessGarages() if (distSquared < SQR(SOUND_INTENSITY)) { CalculateDistance(distCalculated, distSquared); m_sQueueSample.m_nVolume = ComputeVolume(60, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { if (CGarages::aGarages[i].m_eGarageType == GARAGE_CRUSHER) { m_sQueueSample.m_nSampleIndex = SFX_COL_CAR_PANEL_2; m_sQueueSample.m_nFrequency = 6735; @@ -8159,7 +8213,7 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_nCounter = iSound++; if (iSound < 32) iSound = 32; - m_sQueueSample.m_bRequireReflection = TRUE; + SET_SOUND_REFLECTION(TRUE); AddSampleToRequestedQueue(); } } @@ -8183,7 +8237,7 @@ cAudioManager::ProcessFireHydrant() if (distSquared < SQR(intensity)) { CalculateDistance(distCalculated, distSquared); m_sQueueSample.m_nVolume = ComputeVolume(40, 35.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -8198,7 +8252,7 @@ cAudioManager::ProcessFireHydrant() m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -8242,7 +8296,7 @@ cAudioManager::ProcessBridgeWarning() { if (CStats::CommercialPassed && m_sQueueSample.m_fDistance < 450.f) { m_sQueueSample.m_nVolume = ComputeVolume(100, 450.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_BRIDGE_OPEN_WARNING; m_sQueueSample.m_nBankIndex = SFX_BANK_GENERIC_EXTRA; @@ -8257,7 +8311,7 @@ cAudioManager::ProcessBridgeWarning() m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 8; m_sQueueSample.m_bReverbFlag = FALSE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } @@ -8268,7 +8322,7 @@ cAudioManager::ProcessBridgeMotor() { if (m_sQueueSample.m_fDistance < bridgeIntensity) { m_sQueueSample.m_nVolume = ComputeVolume(MAX_VOLUME, bridgeIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE; // todo check sfx name m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -8303,7 +8357,7 @@ cAudioManager::ProcessBridgeOneShots() if (m_sQueueSample.m_fDistance < bridgeIntensity) { m_sQueueSample.m_nVolume = ComputeVolume(MAX_VOLUME, bridgeIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { + if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; @@ -8316,7 +8370,7 @@ cAudioManager::ProcessBridgeOneShots() m_sQueueSample.m_SoundIntensity = bridgeIntensity; m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_bReverbFlag = FALSE; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } } diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 9b1337c9..15c8c00e 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -30,7 +30,9 @@ cAudioManager::cAudioManager() ClearActiveSamples(); GenerateIntegerRandomNumberTable(); m_bDoubleVolume = FALSE; +#ifdef AUDIO_REFLECTIONS m_bDynamicAcousticModelingStatus = TRUE; +#endif for (int i = 0; i < NUM_AUDIOENTITIES; i++) { m_asAudioEntities[i].m_bIsUsed = FALSE; @@ -114,7 +116,7 @@ cAudioManager::Service() if (m_bIsInitialised) { m_nPreviousUserPause = m_nUserPause; m_nUserPause = CTimer::GetIsUserPaused(); -#if GTA_VERSION >= GTA3_PC_10 +#ifdef AUDIO_REFLECTIONS UpdateReflections(); #endif ServiceSoundEffects(); @@ -434,11 +436,13 @@ cAudioManager::ReacquireDigitalHandle() } } +#ifdef AUDIO_REFLECTIONS void cAudioManager::SetDynamicAcousticModelingStatus(bool8 status) { m_bDynamicAcousticModelingStatus = status; } +#endif bool8 cAudioManager::CheckForAnAudioFileOnCD() @@ -601,9 +605,11 @@ cAudioManager::InterrogateAudioEntities() void cAudioManager::AddSampleToRequestedQueue() { - int32 calculatedVolume; + uint32 calculatedVolume; uint8 sampleIndex; +#ifdef AUDIO_REFLECTIONS bool8 bReflections; +#endif if (m_sQueueSample.m_nSampleIndex < TOTAL_AUDIO_SAMPLES) { calculatedVolume = m_sQueueSample.m_nReleasingVolumeModificator * (MAX_VOLUME - m_sQueueSample.m_nVolume); @@ -617,11 +623,12 @@ cAudioManager::AddSampleToRequestedQueue() } m_sQueueSample.m_nCalculatedVolume = calculatedVolume; m_sQueueSample.m_bLoopEnded = FALSE; +#ifdef AUDIO_REFLECTIONS if (m_sQueueSample.m_bIs2D) { m_sQueueSample.m_bRequireReflection = FALSE; m_sQueueSample.m_nLoopsRemaining = 0; } - if (m_bDynamicAcousticModelingStatus && m_sQueueSample.m_nLoopCount) { + if (m_bDynamicAcousticModelingStatus && m_sQueueSample.m_nLoopCount > 0) { bReflections = m_sQueueSample.m_bRequireReflection; } else { bReflections = FALSE; @@ -631,12 +638,15 @@ cAudioManager::AddSampleToRequestedQueue() if (!m_bDynamicAcousticModelingStatus) m_sQueueSample.m_bReverbFlag = FALSE; +#endif m_asSamples[m_nActiveSampleQueue][sampleIndex] = m_sQueueSample; AddDetailsToRequestedOrderList(sampleIndex); +#ifdef AUDIO_REFLECTIONS if (bReflections) AddReflectionsToRequestedQueue(); +#endif } } @@ -657,7 +667,7 @@ cAudioManager::AddDetailsToRequestedOrderList(uint8 sample) m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = sample; } -#if GTA_VERSION >= GTA3_PC_10 +#ifdef AUDIO_REFLECTIONS void cAudioManager::AddReflectionsToRequestedQueue() { @@ -675,12 +685,12 @@ cAudioManager::AddReflectionsToRequestedQueue() m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > emittingVolume / 16) { m_sQueueSample.m_nCounter += (i + 1) * 256; - if (m_sQueueSample.m_nLoopCount) { + if (m_sQueueSample.m_nLoopCount > 0) { noise = RandomDisplacement(m_sQueueSample.m_nFrequency / 32); - if (noise <= 0) - m_sQueueSample.m_nFrequency += noise; - else + if (noise > 0) m_sQueueSample.m_nFrequency -= noise; + else + m_sQueueSample.m_nFrequency += noise; } m_sQueueSample.m_nReleasingVolumeModificator += 20; m_sQueueSample.m_vecPos = m_avecReflectionsPos[i]; @@ -740,7 +750,7 @@ cAudioManager::UpdateReflections() m_afReflectionsDistances[4] = 50.0f; } } -#endif // GTA_VERSION >= GTA3_PC_10 +#endif // AUDIO_REFLECTIONS void cAudioManager::AddReleasingSounds() @@ -768,7 +778,10 @@ cAudioManager::AddReleasingSounds() } } if (!toProcess[i]) { - if (sample.m_nCounter <= 255 || sample.m_nLoopsRemaining == 0) { +#ifdef AUDIO_REFLECTIONS + if (sample.m_nCounter <= 255 || sample.m_nLoopsRemaining == 0) // check if not reflection +#endif + { if (sample.m_nReleasingVolumeDivider == 0) continue; if (sample.m_nLoopCount == 0) { @@ -831,7 +844,7 @@ cAudioManager::ProcessActiveQueues() for (int32 j = 0; j < m_nActiveSamples; j++) { if (sample.m_nEntityIndex == m_asActiveSamples[j].m_nEntityIndex && sample.m_nCounter == m_asActiveSamples[j].m_nCounter && sample.m_nSampleIndex == m_asActiveSamples[j].m_nSampleIndex) { - if (sample.m_nLoopCount) { + if (sample.m_nLoopCount > 0) { if (m_FrameCounter & 1) flag = !!(j & 1); else @@ -914,13 +927,16 @@ cAudioManager::ProcessActiveQueues() for (uint8 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) { tSound &sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]]; if (!sample.m_bIsProcessed && !sample.m_bLoopEnded && m_asAudioEntities[sample.m_nEntityIndex].m_bIsUsed && sample.m_nSampleIndex < NO_SAMPLE) { - if (sample.m_nCounter > 255 && sample.m_nLoopCount != 0 && sample.m_nLoopsRemaining != 0) { +#ifdef AUDIO_REFLECTIONS + if (sample.m_nCounter > 255 && sample.m_nLoopCount > 0 && sample.m_nLoopsRemaining > 0) { // check if reflection sample.m_nLoopsRemaining--; sample.m_nReleasingVolumeDivider = 1; - } else { + } else +#endif + { for (uint8 j = 0; j < m_nActiveSamples; j++) { if (!m_asActiveSamples[j].m_bIsProcessed) { - if (sample.m_nLoopCount != 0) { + if (sample.m_nLoopCount > 0) { samplesPerFrame = sample.m_nFrequency / m_nTimeSpent; samplesToPlay = sample.m_nLoopCount * SampleManager.GetSampleLength(sample.m_nSampleIndex); if (samplesPerFrame == 0) @@ -1028,7 +1044,7 @@ cAudioManager::ClearActiveSamples() m_asActiveSamples[i].m_nVolumeChange = -1; m_asActiveSamples[i].m_vecPos = CVector(0.0f, 0.0f, 0.0f); m_asActiveSamples[i].m_bReverbFlag = FALSE; -#if GTA_VERSION >= GTA3_PC_10 +#ifdef AUDIO_REFLECTIONS m_asActiveSamples[i].m_nLoopsRemaining = 0; m_asActiveSamples[i].m_bRequireReflection = FALSE; #endif diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 7934996e..3b413965 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -9,20 +9,20 @@ class tSound public: int32 m_nEntityIndex; #if GTA_VERSION >= GTA3_PC_10 - int32 m_nCounter; + uint32 m_nCounter; #else uint8 m_nCounter; #endif - int32 m_nSampleIndex; + uint32 m_nSampleIndex; uint8 m_nBankIndex; bool8 m_bIs2D; - int32 m_nReleasingVolumeModificator; + uint32 m_nReleasingVolumeModificator; uint32 m_nFrequency; uint8 m_nVolume; float m_fDistance; - int32 m_nLoopCount; + uint32 m_nLoopCount; #ifndef GTA_PS2 - int32 m_nLoopStart; + uint32 m_nLoopStart; int32 m_nLoopEnd; #endif #ifdef EXTERNAL_3D_SOUND @@ -37,18 +37,18 @@ public: bool8 m_bReleasingSoundFlag; CVector m_vecPos; bool8 m_bReverbFlag; -#if GTA_VERSION >= GTA3_PC_10 +#ifdef AUDIO_REFLECTIONS uint8 m_nLoopsRemaining; bool8 m_bRequireReflection; // Used for oneshots #endif uint8 m_nOffset; - int32 m_nReleasingVolumeDivider; + uint32 m_nReleasingVolumeDivider; bool8 m_bIsProcessed; bool8 m_bLoopEnded; #if GTA_VERSION < GTA3_PC_10 int32 unk; // only on PS2, seems unused #endif - int32 m_nCalculatedVolume; + uint32 m_nCalculatedVolume; int8 m_nVolumeChange; }; @@ -74,7 +74,7 @@ VALIDATE_SIZE(tAudioEntity, 40); class tPedComment { public: - int32 m_nSampleIndex; + uint32 m_nSampleIndex; int32 m_nEntityIndex; CVector m_vecPos; float m_fDistance; @@ -120,7 +120,7 @@ class cMissionAudio public: CVector m_vecPos; bool8 m_bPredefinedProperties; - int32 m_nSampleIndex; + uint32 m_nSampleIndex; uint8 m_nLoadingStatus; uint8 m_nPlayStatus; bool8 m_bIsPlaying; @@ -168,7 +168,7 @@ public: float m_fDistance; CVehicle *m_pVehicle; cTransmission *m_pTransmission; - int32 m_nIndex; + uint32 m_nIndex; float m_fVelocityChange; cVehicleParams() @@ -211,8 +211,10 @@ public: bool8 m_bReverb; // unused bool8 m_bFifthFrameFlag; uint8 m_nActiveSamples; - uint8 m_bDoubleVolume; // unused + bool8 m_bDoubleVolume; // unused +#if GTA_VERSION >= GTA3_PC_10 bool8 m_bDynamicAcousticModelingStatus; +#endif float m_fSpeedOfSound; bool8 m_bTimerJustReset; int32 m_nTimer; @@ -225,7 +227,7 @@ public: tAudioEntity m_asAudioEntities[NUM_AUDIOENTITIES]; int32 m_anAudioEntityIndices[NUM_AUDIOENTITIES]; int32 m_nAudioEntitiesTotal; -#if GTA_VERSION >= GTA3_PC_10 +#ifdef AUDIO_REFLECTIONS CVector m_avecReflectionsPos[MAX_REFLECTIONS]; float m_afReflectionsDistances[MAX_REFLECTIONS]; #endif @@ -276,7 +278,9 @@ public: bool8 IsMP3RadioChannelAvailable(); void ReleaseDigitalHandle(); void ReacquireDigitalHandle(); +#ifdef AUDIO_REFLECTIONS void SetDynamicAcousticModelingStatus(bool8 status); +#endif bool8 CheckForAnAudioFileOnCD(); char GetCDAudioDriveLetter(); bool8 IsAudioInitialised(); @@ -292,7 +296,7 @@ public: void InterrogateAudioEntities(); // inlined on PS2 void AddSampleToRequestedQueue(); void AddDetailsToRequestedOrderList(uint8 sample); // inlined on PS2 -#if GTA_VERSION >= GTA3_PC_10 +#ifdef AUDIO_REFLECTIONS void AddReflectionsToRequestedQueue(); void UpdateReflections(); #endif @@ -548,6 +552,11 @@ public: #else #define SET_EMITTING_VOLUME(vol) #endif +#ifdef AUDIO_REFLECTIONS +#define SET_SOUND_REFLECTION(b) m_sQueueSample.m_bRequireReflection = b +#else +#define SET_SOUND_REFLECTION(b) +#endif #if defined(AUDIO_MSS) && !defined(PS2_AUDIO_CHANNELS) static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index 688da201..d88bfddd 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -155,7 +155,9 @@ cDMAudio::ReacquireDigitalHandle(void) void cDMAudio::SetDynamicAcousticModelingStatus(bool8 status) { +#ifdef AUDIO_REFLECTIONS AudioManager.SetDynamicAcousticModelingStatus(status); +#endif } bool8 diff --git a/src/audio/PolRadio.cpp b/src/audio/PolRadio.cpp index 742e5ea5..4c84829a 100644 --- a/src/audio/PolRadio.cpp +++ b/src/audio/PolRadio.cpp @@ -139,7 +139,7 @@ cAudioManager::DoPoliceRadioCrackle() m_sQueueSample.m_bReverbFlag = FALSE; m_sQueueSample.m_nOffset = 63; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bRequireReflection = FALSE; + SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index 0ba6b544..71ff00ee 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -1652,10 +1652,16 @@ cSampleManager::UpdateReverb(void) if ( AudioManager.m_FrameCounter & 15 ) return FALSE; - + +#ifdef AUDIO_REFLECTIONS float y = AudioManager.m_afReflectionsDistances[REFLECTION_TOP] + AudioManager.m_afReflectionsDistances[REFLECTION_BOTTOM]; float x = AudioManager.m_afReflectionsDistances[REFLECTION_LEFT] + AudioManager.m_afReflectionsDistances[REFLECTION_RIGHT]; float z = AudioManager.m_afReflectionsDistances[REFLECTION_UP]; +#else + float x = 0.0f; + float y = 0.0f; + float z = 0.0f; +#endif float normy = norm(y, 5.0f, 40.0f); float normx = norm(x, 5.0f, 40.0f); @@ -2169,7 +2175,7 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream) bool8 cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) { - int i = 0; + uint32 i = 0; uint32 position = nPos; char filename[MAX_PATH]; @@ -2250,7 +2256,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) if ( !_pMP3List ) { nFile = 0; - _bIsMp3Active = 0; + _bIsMp3Active = FALSE; #ifdef PS2_AUDIO_PATHS strcpy(filename, m_szCDRomRootPath); strcat(filename, PS2StreamedNameTable[nFile]); @@ -2295,7 +2301,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) } } - _bIsMp3Active = 0; + _bIsMp3Active = FALSE; } while ( ++i < nNumMP3s ); position = 0; diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 17776347..b8a3ed3d 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -1362,10 +1362,16 @@ bool8 cSampleManager::UpdateReverb(void) if ( AudioManager.m_FrameCounter & 15 ) return FALSE; - + +#ifdef AUDIO_REFLECTIONS float y = AudioManager.m_afReflectionsDistances[REFLECTION_TOP] + AudioManager.m_afReflectionsDistances[REFLECTION_BOTTOM]; float x = AudioManager.m_afReflectionsDistances[REFLECTION_LEFT] + AudioManager.m_afReflectionsDistances[REFLECTION_RIGHT]; float z = AudioManager.m_afReflectionsDistances[REFLECTION_UP]; +#else + float x = 0.0f; + float y = 0.0f; + float z = 0.0f; +#endif float normy = norm(y, 5.0f, 40.0f); float normx = norm(x, 5.0f, 40.0f); @@ -1653,7 +1659,7 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream) bool8 cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) { - int i = 0; + uint32 i = 0; uint32 position = nPos; char filename[MAX_PATH]; @@ -1728,7 +1734,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) if ( !_pMP3List ) { nFile = 0; - _bIsMp3Active = 0; + _bIsMp3Active = FALSE; CStream *stream = aStream[nStream]; #ifdef PS2_AUDIO_PATHS if(!stream->Open(PS2StreamedNameTable[nFile], IsThisTrackAt16KHz(nFile) ? 16000 : 32000)) @@ -1767,7 +1773,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) } } - _bIsMp3Active = 0; + _bIsMp3Active = FALSE; } while ( ++i < nNumMP3s ); position = 0; diff --git a/src/core/MenuScreens.cpp b/src/core/MenuScreens.cpp index 0a149f27..247de98a 100644 --- a/src/core/MenuScreens.cpp +++ b/src/core/MenuScreens.cpp @@ -44,7 +44,9 @@ CMenuScreen aScreens[MENUPAGES] = { MENUACTION_AUDIOHW, "FEA_3DH", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, MENUACTION_SPEAKERCONF, "FEA_SPK", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, #endif +#ifdef AUDIO_REFLECTIONS MENUACTION_DYNAMICACOUSTIC, "FET_DAM", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, +#endif MENUACTION_RADIO, "FEA_RSS", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index 5eecd841..d33650f8 100644 --- a/src/core/MenuScreensCustom.cpp +++ b/src/core/MenuScreensCustom.cpp @@ -439,7 +439,9 @@ CMenuScreenCustom aScreens[MENUPAGES] = { MENUACTION_AUDIOHW, "FEA_3DH", { nil, SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS }, MENUACTION_SPEAKERCONF, "FEA_SPK", { nil, SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS }, #endif +#ifdef AUDIO_REFLECTIONS MENUACTION_DYNAMICACOUSTIC, "FET_DAM", { nil, SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS }, +#endif MENUACTION_RADIO, "FEA_RSS", { nil, SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS }, MENUACTION_RESTOREDEF, "FET_DEF", { nil, SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS }, MENUACTION_CHANGEMENU, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE }, diff --git a/src/core/config.h b/src/core/config.h index d26f9546..5ec6f3ee 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -171,6 +171,7 @@ enum Config { # define PS2_MENU #elif defined GTA_PC # define EXTERNAL_3D_SOUND +# define AUDIO_REFLECTIONS # ifndef GTA_HANDHELD # define PC_PLAYER_CONTROLS // mouse player/cam mode # endif @@ -429,6 +430,7 @@ enum Config { // Audio #define EXTERNAL_3D_SOUND // use external engine to simulate 3d audio spatialization. OpenAL would not work without it (because it works in a 3d space // originally and making it work in 2d only requires more resource). Will not work on PS2 +#define AUDIO_REFLECTIONS // Enable audio reflections. Disabled on mobile, didn't exist yet on PS2. #define RADIO_SCROLL_TO_PREV_STATION #define AUDIO_CACHE #define PS2_AUDIO_CHANNELS // increases the maximum number of audio channels to PS2 value of 44 (PC has 28 originally) @@ -490,3 +492,6 @@ enum Config { #if defined(GTA_PS2) && defined(EXTERNAL_3D_SOUND) #error EXTERNAL_3D_SOUND cannot work on PS2 #endif +#if defined(AUDIO_REFLECTIONS) && GTA_VERSION < GTA3_PC_10 +#error AUDIO_REFLECTIONS cannot work with versions below GTA3_PC_10 +#endif \ No newline at end of file -- cgit v1.2.3 From 6b4b11d80e3b89b179a77d79ae77d0f1ad901b7c Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 17 Aug 2021 12:59:13 +0200 Subject: fix opengl; update librw --- src/extras/screendroplets.cpp | 4 ++-- vendor/librw | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/extras/screendroplets.cpp b/src/extras/screendroplets.cpp index 2485386b..cc86808f 100644 --- a/src/extras/screendroplets.cpp +++ b/src/extras/screendroplets.cpp @@ -741,7 +741,7 @@ uint32 im2D_UV2_Vao; void openim2d_uv2(void) { - u_xform = rw::gl3::registerUniform("u_xform"); // this doesn't add a new one, so it's safe + u_xform = rw::gl3::registerUniform("u_xform", rw::gl3::UNIFORM_VEC4); // this doesn't add a new one, so it's safe glGenBuffers(1, &im2D_UV2_Ibo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, im2D_UV2_Ibo); @@ -803,7 +803,7 @@ RenderIndexedPrimitive_UV2(RwPrimitiveType primType, Im2DVertexUV2 *vertices, Rw setAttribPointers(im2d_UV2_attribDesc, 4); #endif - glUniform4fv(currentShader->uniformLocations[u_xform], 1, xform); + setUniform(u_xform, xform); flushCache(); glDrawElements(primTypeMap[primType], numIndices, diff --git a/vendor/librw b/vendor/librw index a5bc9723..4c4b1990 160000 --- a/vendor/librw +++ b/vendor/librw @@ -1 +1 @@ -Subproject commit a5bc97232293250ae1bbd6ef6642532a541034ca +Subproject commit 4c4b199057e9570557cdf108d21795236a076755 -- cgit v1.2.3 From d4175c5315439a6afa77d0b11d463b2135a33222 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 17 Aug 2021 23:21:27 +0200 Subject: update librw --- vendor/librw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/librw b/vendor/librw index 4c4b1990..8f1321f1 160000 --- a/vendor/librw +++ b/vendor/librw @@ -1 +1 @@ -Subproject commit 4c4b199057e9570557cdf108d21795236a076755 +Subproject commit 8f1321f194c33b573d3e45e383bb95c41ac3477b -- cgit v1.2.3 From 5c562c3adc06044a17cabb9c4785795b0d2d7fa7 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 18 Aug 2021 15:31:58 +0300 Subject: More type fixes in audio --- src/audio/AudioLogic.cpp | 2 +- src/audio/AudioManager.h | 4 ++-- src/audio/MusicManager.cpp | 4 ++-- src/audio/PolRadio.cpp | 36 ++++++++++++++++++------------------ 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 7ccd7134..04df506d 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -6054,7 +6054,7 @@ cPedComments::Process() uint8 actualUsedBank; tPedComment *comment; - if (AudioManager.m_nUserPause != 0) return; + if (AudioManager.m_nUserPause) return; if (m_nCommentsInBank[m_nActiveBank]) { sampleIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nSampleIndex; diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 3b413965..ed920cab 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -245,8 +245,8 @@ public: cMissionAudio m_sMissionAudio; int32 m_anRandomTable[5]; uint8 m_nTimeSpent; - uint8 m_nUserPause; - uint8 m_nPreviousUserPause; + bool8 m_nUserPause; + bool8 m_nPreviousUserPause; uint32 m_FrameCounter; cAudioManager(); diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 9872589a..0752a5d8 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -363,14 +363,14 @@ cMusicManager::GetRadioInCar(void) CVehicle *veh = FindPlayerVehicle(); if (veh != nil){ if (UsesPoliceRadio(veh)) { - if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && AudioManager.m_nUserPause == 0)) + if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && !AudioManager.m_nUserPause)) return POLICE_RADIO; return m_nRadioInCar; } else return veh->m_nRadioStation; } } - if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && AudioManager.m_nUserPause == 0)) + if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && !AudioManager.m_nUserPause)) return RADIO_OFF; return m_nRadioInCar; } diff --git a/src/audio/PolRadio.cpp b/src/audio/PolRadio.cpp index 4c84829a..6b663d0d 100644 --- a/src/audio/PolRadio.cpp +++ b/src/audio/PolRadio.cpp @@ -26,7 +26,7 @@ char SubZo2Label[8]; char SubZo3Label[8]; uint32 g_nMissionAudioSfx = TOTAL_AUDIO_SAMPLES; -int8 g_nMissionAudioPlayingStatus = 2; +int8 g_nMissionAudioPlayingStatus = PLAY_STATUS_FINISHED; uint8 gSpecialSuspectLastSeenReport; uint32 gMinTimeToNextReport[NUM_CRIME_TYPES]; @@ -109,8 +109,8 @@ void cAudioManager::SetMissionScriptPoliceAudio(uint32 sfx) { if (!m_bIsInitialised) return; - if (g_nMissionAudioPlayingStatus != 1) { - g_nMissionAudioPlayingStatus = 0; + if (g_nMissionAudioPlayingStatus != PLAY_STATUS_PLAYING) { + g_nMissionAudioPlayingStatus = PLAY_STATUS_STOPPED; g_nMissionAudioSfx = sfx; } } @@ -151,7 +151,7 @@ cAudioManager::ServicePoliceRadio() if(!m_bIsInitialised) return; - if(m_nUserPause == 0) { + if(!m_nUserPause) { bool8 crimeReport = SetupCrimeReport(); #ifdef FIX_BUGS // Crash at 0x5fe6ef if(CReplay::IsPlayingBack() || !FindPlayerPed() || !FindPlayerPed()->m_pWanted) @@ -185,20 +185,20 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) static int cWait = 0; static bool8 bChannelOpen = FALSE; - static uint8 bMissionAudioPhysicalPlayingStatus = 0; + static uint8 bMissionAudioPhysicalPlayingStatus = PLAY_STATUS_STOPPED; static int32 PoliceChannelFreq = 5500; if (!m_bIsInitialised) return; - if (m_nUserPause != 0) { + if (m_nUserPause) { if (SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO)) SampleManager.StopChannel(CHANNEL_POLICE_RADIO); - if (g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && bMissionAudioPhysicalPlayingStatus == 1 && + if (g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING && SampleManager.IsStreamPlaying(1)) { SampleManager.PauseStream(TRUE, 1); } } else { if (m_nPreviousUserPause && g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && - bMissionAudioPhysicalPlayingStatus == 1) { + bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING) { SampleManager.PauseStream(FALSE, 1); } if (m_sPoliceRadioQueue.policeChannelTimer == 0) bChannelOpen = FALSE; @@ -211,17 +211,17 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) return; } if (g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && !bChannelOpen) { - if (g_nMissionAudioPlayingStatus) { - if (g_nMissionAudioPlayingStatus == 1 && !bMissionAudioPhysicalPlayingStatus && + if (g_nMissionAudioPlayingStatus != PLAY_STATUS_STOPPED) { + if (g_nMissionAudioPlayingStatus == PLAY_STATUS_PLAYING && bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_STOPPED && SampleManager.IsStreamPlaying(1)) { - bMissionAudioPhysicalPlayingStatus = 1; + bMissionAudioPhysicalPlayingStatus = PLAY_STATUS_PLAYING; } - if (bMissionAudioPhysicalPlayingStatus == 1) { + if (bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING) { if (SampleManager.IsStreamPlaying(1)) { DoPoliceRadioCrackle(); } else { - bMissionAudioPhysicalPlayingStatus = 2; - g_nMissionAudioPlayingStatus = 2; + bMissionAudioPhysicalPlayingStatus = PLAY_STATUS_FINISHED; + g_nMissionAudioPlayingStatus = PLAY_STATUS_FINISHED; g_nMissionAudioSfx = TOTAL_AUDIO_SAMPLES; cWait = 30; } @@ -231,13 +231,13 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) SampleManager.PreloadStreamedFile(g_nMissionAudioSfx, 1); SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, TRUE, 1); SampleManager.StartPreloadedStreamedFile(1); - g_nMissionAudioPlayingStatus = 1; - bMissionAudioPhysicalPlayingStatus = 0; + g_nMissionAudioPlayingStatus = PLAY_STATUS_PLAYING; + bMissionAudioPhysicalPlayingStatus = PLAY_STATUS_STOPPED; return; } } if (bChannelOpen) DoPoliceRadioCrackle(); - if ((g_nMissionAudioSfx == TOTAL_AUDIO_SAMPLES || g_nMissionAudioPlayingStatus != 1) && + if ((g_nMissionAudioSfx == TOTAL_AUDIO_SAMPLES || g_nMissionAudioPlayingStatus != PLAY_STATUS_PLAYING) && !SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO) && m_sPoliceRadioQueue.policeChannelTimer) { if (m_sPoliceRadioQueue.policeChannelTimer) { sample = m_sPoliceRadioQueue.crimesSamples[m_sPoliceRadioQueue.policeChannelCounterSeconds]; @@ -292,7 +292,7 @@ cAudioManager::SetupCrimeReport() float quarterX; float quarterY; int i; - int32 sampleIndex; + uint32 sampleIndex; bool8 processed = FALSE; if (MusicManager.m_nMusicMode == MUSICMODE_CUTSCENE) return FALSE; -- cgit v1.2.3 From 597802ff2ed096ca72ba3cc6bee095b54180d927 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 18 Aug 2021 15:37:31 +0300 Subject: One more type fix --- src/audio/PolRadio.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/PolRadio.cpp b/src/audio/PolRadio.cpp index 6b663d0d..b5df5c14 100644 --- a/src/audio/PolRadio.cpp +++ b/src/audio/PolRadio.cpp @@ -27,7 +27,7 @@ char SubZo3Label[8]; uint32 g_nMissionAudioSfx = TOTAL_AUDIO_SAMPLES; int8 g_nMissionAudioPlayingStatus = PLAY_STATUS_FINISHED; -uint8 gSpecialSuspectLastSeenReport; +bool8 gSpecialSuspectLastSeenReport; uint32 gMinTimeToNextReport[NUM_CRIME_TYPES]; void @@ -248,7 +248,7 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) } if (wantedLevel == 0) { if (gSpecialSuspectLastSeenReport) { - gSpecialSuspectLastSeenReport = 0; + gSpecialSuspectLastSeenReport = FALSE; } else if (((sample >= SFX_POLICE_RADIO_MESSAGE_NOISE_1) && (sample <= SFX_POLICE_RADIO_MESSAGE_NOISE_3)) || sample == TOTAL_AUDIO_SAMPLES) { bChannelOpen = FALSE; processed = TRUE; -- cgit v1.2.3 From 01c70dfb76558baded969964e4a57f4f27f2337b Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 18 Aug 2021 18:37:10 +0300 Subject: Fix acceleration sound playing when exiting the vehicle --- src/audio/AudioLogic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 04df506d..9b8e278b 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -282,7 +282,7 @@ cAudioManager::ProcessSpecial() } CPlayerPed *playerPed = FindPlayerPed(); if (playerPed) { - if(playerPed->EnteringCar() && !playerPed->bInVehicle) + if(!playerPed->EnteringCar() && !playerPed->bInVehicle) SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE); } } -- cgit v1.2.3 From eda2c054489e83a03a14976747cd19e3ac60d7a4 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 18 Aug 2021 21:07:33 +0300 Subject: Audio: ifdef more things that aren't on ps2 --- src/audio/AudioLogic.cpp | 20 ++++++++++++++++++-- src/audio/AudioManager.cpp | 7 +++++++ src/audio/PolRadio.cpp | 2 ++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 9b8e278b..6756925d 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -246,6 +246,12 @@ cAudioManager::ProcessReverb() } #else // TODO: PS2 code + + static uint8 OldVolL = 0; + static uint8 OldVolR = 0; + + // SoundDistUp, SoundDistLeft, SoundDistRight used in here from TheCamera + SampleManager.UpdateReverb(); #endif } @@ -1197,6 +1203,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * uint8 currentGear; float gasPedalAudio; CVector pos; + bool8 slowingDown; static int16 LastAccel = 0; static int16 LastBrake = 0; @@ -1223,6 +1230,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * else accelerateState = Pads[0].GetAccelerate(); + slowingDown = params.m_fVelocityChange < -0.001f; channelUsed = SampleManager.GetChannelUsedFlag(CHANNEL_PLAYER_VEHICLE_ENGINE); transmission = params.m_pTransmission; velocityChange = params.m_fVelocityChange; @@ -1260,7 +1268,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * freqModifier = -(Min(0.2f, time) * 3000.0f * 5.0f); else freqModifier = -(Max(-0.2f, time) * 3000.0f * 5.0f); - if (params.m_fVelocityChange < -0.001f) + if (slowingDown) freqModifier = -freqModifier; } else freqModifier = 0; @@ -1268,7 +1276,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * engineSoundType = aVehicleSettings[params.m_nIndex].m_nBank; soundOffset = 3 * (engineSoundType - CAR_SFX_BANKS_OFFSET); if (accelerateState <= 0) { - if (params.m_fVelocityChange < -0.001f) { + if (slowingDown) { if (channelUsed) { SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE); bAccelSampleStopped = TRUE; @@ -1356,10 +1364,14 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * } } +#ifdef GTA_PS2 + SampleManager.InitialiseChannel(CHANNEL_PLAYER_VEHICLE_ENGINE, soundOffset + SFX_CAR_ACCEL_1, SFX_BANK_0); +#else if (!SampleManager.InitialiseChannel(CHANNEL_PLAYER_VEHICLE_ENGINE, soundOffset + SFX_CAR_ACCEL_1, SFX_BANK_0)) return; SampleManager.SetChannelLoopCount(CHANNEL_PLAYER_VEHICLE_ENGINE, 1); SampleManager.SetChannelLoopPoints(CHANNEL_PLAYER_VEHICLE_ENGINE, 0, -1); +#endif } #ifdef EXTERNAL_3D_SOUND @@ -1376,7 +1388,11 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * freq /= 2; SampleManager.SetChannelFrequency(CHANNEL_PLAYER_VEHICLE_ENGINE, freq); if (!channelUsed) { +#if GTA_VERSION >= GTA3_PC_10 SampleManager.SetChannelReverbFlag(CHANNEL_PLAYER_VEHICLE_ENGINE, m_bDynamicAcousticModelingStatus != FALSE); +#else + SampleManager.SetChannelReverbFlag(CHANNEL_PLAYER_VEHICLE_ENGINE, TRUE); +#endif SampleManager.StartChannel(CHANNEL_PLAYER_VEHICLE_ENGINE); } } diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 15c8c00e..a288ac12 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -955,7 +955,12 @@ cAudioManager::ProcessActiveQueues() #else emittingVol = m_bDoubleVolume ? 2 * Min(63, m_asActiveSamples[j].m_nVolume) : m_asActiveSamples[j].m_nVolume; #endif +#ifdef GTA_PS2 + { + SampleManager.InitialiseChannel(j, m_asActiveSamples[j].m_nSampleIndex, m_asActiveSamples[j].m_nBankIndex); +#else if (SampleManager.InitialiseChannel(j, m_asActiveSamples[j].m_nSampleIndex, m_asActiveSamples[j].m_nBankIndex)) { +#endif SampleManager.SetChannelFrequency(j, m_asActiveSamples[j].m_nFrequency); #ifdef EXTERNAL_3D_SOUND SampleManager.SetChannelEmittingVolume(j, emittingVol); @@ -963,8 +968,10 @@ cAudioManager::ProcessActiveQueues() SampleManager.SetChannelVolume(j, emittingVol); SampleManager.SetChannelPan(j, m_asActiveSamples[j].m_nOffset); #endif +#ifndef GTA_PS2 SampleManager.SetChannelLoopPoints(j, m_asActiveSamples[j].m_nLoopStart, m_asActiveSamples[j].m_nLoopEnd); SampleManager.SetChannelLoopCount(j, m_asActiveSamples[j].m_nLoopCount); +#endif SampleManager.SetChannelReverbFlag(j, m_asActiveSamples[j].m_bReverbFlag); #ifdef EXTERNAL_3D_SOUND if (m_asActiveSamples[j].m_bIs2D) { diff --git a/src/audio/PolRadio.cpp b/src/audio/PolRadio.cpp index b5df5c14..b1460b3c 100644 --- a/src/audio/PolRadio.cpp +++ b/src/audio/PolRadio.cpp @@ -271,8 +271,10 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) SampleManager.SetChannelFrequency(CHANNEL_POLICE_RADIO, freq); SampleManager.SetChannelVolume(CHANNEL_POLICE_RADIO, 100); SampleManager.SetChannelPan(CHANNEL_POLICE_RADIO, 63); +#ifndef GTA_PS2 SampleManager.SetChannelLoopCount(CHANNEL_POLICE_RADIO, 1); SampleManager.SetChannelLoopPoints(CHANNEL_POLICE_RADIO, 0, -1); +#endif SampleManager.StartChannel(CHANNEL_POLICE_RADIO); } if (processed) ResetPoliceRadio(); -- cgit v1.2.3 From d3e7ab933de880cd287243e5aec66bf62564372a Mon Sep 17 00:00:00 2001 From: withmorten Date: Thu, 19 Aug 2021 17:02:26 +0200 Subject: update librw --- vendor/librw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/librw b/vendor/librw index 8f1321f1..22ce63a1 160000 --- a/vendor/librw +++ b/vendor/librw @@ -1 +1 @@ -Subproject commit 8f1321f194c33b573d3e45e383bb95c41ac3477b +Subproject commit 22ce63a114be1b84357dea0ba597c8926d465d37 -- cgit v1.2.3 From 0e5ffb8c34982c5bb3f9d67b2cd353ab1c274e34 Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 20 Aug 2021 10:29:33 +0200 Subject: CAutomobile fixes --- src/vehicles/Automobile.cpp | 47 +++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index 7b3a8921..417dd140 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -1363,7 +1363,7 @@ CAutomobile::PreRender(void) break; default: - if(Abs(fwdSpeed) > 0.5f) + if(Abs(fwdSpeed) > 5.0f) AddWheelDirtAndWater(&m_aWheelColPoints[i], drawParticles); if(m_aWheelSkidmarkBloody[i] && m_aWheelTimer[i] > 0.0f) CSkidmarks::RegisterOne((uintptr)this + i, m_aWheelColPoints[i].point, @@ -1388,7 +1388,7 @@ CAutomobile::PreRender(void) CVector(0.0f, 0.0f, 0.0f)); if(m_aWheelTimer[CARWHEEL_REAR_LEFT] > 0.0f) - CSkidmarks::RegisterOne((uintptr)this + CARWHEEL_REAR_LEFT, + CSkidmarks::RegisterOne((uintptr)this + 5, m_aWheelColPoints[CARWHEEL_REAR_LEFT].point + offset, GetForward().x, GetForward().y, &m_aWheelSkidmarkMuddy[CARWHEEL_REAR_LEFT], &m_aWheelSkidmarkBloody[CARWHEEL_REAR_LEFT]); @@ -1406,12 +1406,12 @@ CAutomobile::PreRender(void) CVector(0.0f, 0.0f, 0.0f)); if(m_aWheelTimer[CARWHEEL_REAR_RIGHT] > 0.0f) - CSkidmarks::RegisterOne((uintptr)this + CARWHEEL_REAR_RIGHT, + CSkidmarks::RegisterOne((uintptr)this + 6, m_aWheelColPoints[CARWHEEL_REAR_RIGHT].point + offset, GetForward().x, GetForward().y, &m_aWheelSkidmarkMuddy[CARWHEEL_REAR_RIGHT], &m_aWheelSkidmarkBloody[CARWHEEL_REAR_RIGHT]); break; - default: break; + default: break; } } @@ -1539,7 +1539,7 @@ CAutomobile::PreRender(void) r *= f; g *= f; b *= f; - }else if(t > 412){ + }else if(t > (512-100)){ float f = (512-t)/100.0f; r *= f; g *= f; @@ -1770,20 +1770,20 @@ CAutomobile::PreRender(void) // Taillight coronas if(behindness > 0.0f){ // Behind car - float intensity = 0.4f*behindness + 0.4f; - float size = (behindness + 1.0f)/2.0f; + float intensity = (behindness + 1.0f)*0.4f; + float size = (behindness + 1.0f)*0.5f; if(m_fGasPedal < 0.0f){ // reversing intensity += 0.4f; size += 0.3f; if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK) - CCoronas::RegisterCorona((uintptr)this + 2, 128*intensity, 128*intensity, 128*intensity, 255, + CCoronas::RegisterCorona((uintptr)this + 14, 128*intensity, 128*intensity, 128*intensity, 255, lightL, size, 50.0f*TheCamera.LODDistMultiplier, CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle); if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK) - CCoronas::RegisterCorona((uintptr)this + 3, 128*intensity, 128*intensity, 128*intensity, 255, + CCoronas::RegisterCorona((uintptr)this + 15, 128*intensity, 128*intensity, 128*intensity, 255, lightR, size, 50.0f*TheCamera.LODDistMultiplier, CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle); @@ -1795,23 +1795,23 @@ CAutomobile::PreRender(void) if(alarmOff){ if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK) - CCoronas::RegisterCorona((uintptr)this + 2, 0, 0, 0, 0, + CCoronas::RegisterCorona((uintptr)this + 14, 0, 0, 0, 0, lightL, size, 0.0f, CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle); if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK) - CCoronas::RegisterCorona((uintptr)this + 3, 0, 0, 0, 0, + CCoronas::RegisterCorona((uintptr)this + 15, 0, 0, 0, 0, lightR, size, 0.0f, CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle); }else{ if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK) - CCoronas::RegisterCorona((uintptr)this + 2, 128*intensity, 0, 0, 255, + CCoronas::RegisterCorona((uintptr)this + 14, 128*intensity, 0, 0, 255, lightL, size, 50.0f*TheCamera.LODDistMultiplier, CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle); if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK) - CCoronas::RegisterCorona((uintptr)this + 3, 128*intensity, 0, 0, 255, + CCoronas::RegisterCorona((uintptr)this + 15, 128*intensity, 0, 0, 255, lightR, size, 50.0f*TheCamera.LODDistMultiplier, CCoronas::TYPE_STREAK, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, angle); @@ -1819,10 +1819,11 @@ CAutomobile::PreRender(void) } }else{ // In front of car + // missing LODDistMultiplier probably a BUG if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK) - CCoronas::UpdateCoronaCoors((uintptr)this + 2, lightL, 50.0f*TheCamera.LODDistMultiplier, angle); + CCoronas::UpdateCoronaCoors((uintptr)this + 14, lightL, 50.0f, angle); if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK) - CCoronas::UpdateCoronaCoors((uintptr)this + 3, lightR, 50.0f*TheCamera.LODDistMultiplier, angle); + CCoronas::UpdateCoronaCoors((uintptr)this + 15, lightR, 50.0f, angle); } // bright lights @@ -1888,12 +1889,12 @@ CAutomobile::PreRender(void) if(m_fGasPedal < 0.0f){ // reversing if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK) - CCoronas::RegisterCorona((uintptr)this + 2, 120, 120, 120, 255, + CCoronas::RegisterCorona((uintptr)this + 14, 120, 120, 120, 255, lightL, 1.2f, 50.0f*TheCamera.LODDistMultiplier, CCoronas::TYPE_STAR, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, 0.0f); if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK) - CCoronas::RegisterCorona((uintptr)this + 3, 120, 120, 120, 255, + CCoronas::RegisterCorona((uintptr)this + 15, 120, 120, 120, 255, lightR, 1.2f, 50.0f*TheCamera.LODDistMultiplier, CCoronas::TYPE_STAR, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, 0.0f); @@ -1904,12 +1905,12 @@ CAutomobile::PreRender(void) }else{ // braking if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK) - CCoronas::RegisterCorona((uintptr)this + 2, 120, 0, 0, 255, + CCoronas::RegisterCorona((uintptr)this + 14, 120, 0, 0, 255, lightL, 1.2f, 50.0f*TheCamera.LODDistMultiplier, CCoronas::TYPE_STAR, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, 0.0f); if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK) - CCoronas::RegisterCorona((uintptr)this + 3, 120, 0, 0, 255, + CCoronas::RegisterCorona((uintptr)this + 15, 120, 0, 0, 255, lightR, 1.2f, 50.0f*TheCamera.LODDistMultiplier, CCoronas::TYPE_STAR, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, 0.0f); @@ -1920,15 +1921,15 @@ CAutomobile::PreRender(void) } }else{ if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK) - CCoronas::UpdateCoronaCoors((uintptr)this + 2, lightL, 50.0f*TheCamera.LODDistMultiplier, 0.0f); + CCoronas::UpdateCoronaCoors((uintptr)this + 14, lightL, 50.0f*TheCamera.LODDistMultiplier, 0.0f); if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK) - CCoronas::UpdateCoronaCoors((uintptr)this + 3, lightR, 50.0f*TheCamera.LODDistMultiplier, 0.0f); + CCoronas::UpdateCoronaCoors((uintptr)this + 15, lightR, 50.0f*TheCamera.LODDistMultiplier, 0.0f); } }else{ if(Damage.GetLightStatus(VEHLIGHT_REAR_LEFT) == LIGHT_STATUS_OK) - CCoronas::UpdateCoronaCoors((uintptr)this + 2, lightL, 50.0f*TheCamera.LODDistMultiplier, 0.0f); + CCoronas::UpdateCoronaCoors((uintptr)this + 14, lightL, 50.0f*TheCamera.LODDistMultiplier, 0.0f); if(Damage.GetLightStatus(VEHLIGHT_REAR_RIGHT) == LIGHT_STATUS_OK) - CCoronas::UpdateCoronaCoors((uintptr)this + 3, lightR, 50.0f*TheCamera.LODDistMultiplier, 0.0f); + CCoronas::UpdateCoronaCoors((uintptr)this + 15, lightR, 50.0f*TheCamera.LODDistMultiplier, 0.0f); } } // end of lights -- cgit v1.2.3 From c168786b421a18f66202faa481a2570ef33f9708 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 20 Aug 2021 13:02:58 +0300 Subject: Audio refactoring: * renamed tSound fields, added descriptions for each field * getting rid of term 'intensity' in favour of 'max distance' * renamed two cAudioManager fields * fix volume not being reduced for stopping sounds that are looped * reverse a few PS2 bits --- src/audio/AudioCollision.cpp | 18 +- src/audio/AudioLogic.cpp | 1331 +++++++++++++++++++++--------------------- src/audio/AudioManager.cpp | 185 +++--- src/audio/AudioManager.h | 72 ++- src/audio/PolRadio.cpp | 10 +- 5 files changed, 828 insertions(+), 788 deletions(-) diff --git a/src/audio/AudioCollision.cpp b/src/audio/AudioCollision.cpp index 02231773..5af762f9 100644 --- a/src/audio/AudioCollision.cpp +++ b/src/audio/AudioCollision.cpp @@ -261,14 +261,14 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col) m_sQueueSample.m_vecPos = col.m_vecPosition; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 11; + m_sQueueSample.m_nPriority = 11; m_sQueueSample.m_nLoopCount = 1; SET_EMITTING_VOLUME(emittingVol); RESET_LOOP_OFFSETS m_sQueueSample.m_fSpeedMultiplier = 4.0f; - m_sQueueSample.m_SoundIntensity = CollisionSoundIntensity; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = CollisionSoundIntensity; + m_sQueueSample.m_bStatic = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -290,15 +290,15 @@ cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 coun m_sQueueSample.m_vecPos = col.m_vecPosition; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 7; + m_sQueueSample.m_nPriority = 7; m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 4.0f; - m_sQueueSample.m_SoundIntensity = CollisionSoundIntensity; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = CollisionSoundIntensity; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 5; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 6756925d..b1f269ec 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -38,6 +38,9 @@ #include "ZoneCull.h" #include "sampman.h" +// TODO: Get rid of *intensity* consts (and get rid of term 'intensity' in general) +// Make them defines, not floats because they were not floats on PS2 + #ifndef GTA_PS2 #define CHANNEL_PLAYER_VEHICLE_ENGINE m_nActiveSamples #endif @@ -239,7 +242,7 @@ cAudioManager::ProcessReverb() #endif ; i++) { - if (m_asActiveSamples[i].m_bReverbFlag) + if (m_asActiveSamples[i].m_bReverb) SampleManager.SetChannelReverbFlag(i, TRUE); } #endif @@ -302,53 +305,53 @@ cAudioManager::ProcessEntity(int32 id) switch (m_asAudioEntities[id].m_nType) { case AUDIOTYPE_PHYSICAL: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; ProcessPhysical(id); } break; case AUDIOTYPE_EXPLOSION: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; ProcessExplosions(id); } break; case AUDIOTYPE_FIRE: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; ProcessFires(id); } break; case AUDIOTYPE_WEATHER: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; ProcessWeather(id); } break; case AUDIOTYPE_CRANE: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; ProcessCrane(); } break; case AUDIOTYPE_SCRIPTOBJECT: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; ProcessScriptObject(id); } break; case AUDIOTYPE_BRIDGE: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; ProcessBridge(); } break; case AUDIOTYPE_FRONTEND: - m_sQueueSample.m_bReverbFlag = FALSE; + m_sQueueSample.m_bReverb = FALSE; ProcessFrontEnd(); break; case AUDIOTYPE_PROJECTILE: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; ProcessProjectiles(); } break; @@ -358,13 +361,13 @@ cAudioManager::ProcessEntity(int32 id) break; case AUDIOTYPE_FIREHYDRANT: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; ProcessFireHydrant(); } break; case AUDIOTYPE_WATERCANNON: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; ProcessWaterCannon(id); } break; @@ -689,15 +692,15 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams& params) m_sQueueSample.m_nSampleIndex = (m_anRandomTable[1] & 3) + SFX_CAR_RAIN_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 9; + m_sQueueSample.m_nPriority = 9; m_sQueueSample.m_nFrequency = m_anRandomTable[1] % 4000 + 28000; m_sQueueSample.m_nLoopCount = 1; SET_EMITTING_VOLUME((uint8)emittingVol); RESET_LOOP_OFFSETS m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = rainOnVehicleIntensity; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_bReverbFlag = FALSE; + m_sQueueSample.m_MaxDistance = rainOnVehicleIntensity; + m_sQueueSample.m_bStatic = TRUE; + m_sQueueSample.m_bReverb = FALSE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -741,16 +744,16 @@ cAudioManager::ProcessReverseGear(cVehicleParams& params) } m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_nFrequency = (6000.f * modificator) + 7000; m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 3.0f; - m_sQueueSample.m_SoundIntensity = reverseGearIntensity; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = reverseGearIntensity; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 5; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -791,16 +794,16 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams& params) m_sQueueSample.m_nSampleIndex = SFX_REMOTE_CONTROLLED_CAR; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_nFrequency = (11025.f * velocityChange / params.m_pTransmission->fMaxVelocity + 11025.f); m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 3.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 3; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -834,7 +837,7 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams& params) m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; if (params.m_pVehicle->m_nSurfaceTouched == SURFACE_WATER) { m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; freq = 6050 * emittingVol / 30 + 16000; @@ -849,10 +852,10 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams& params) SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 4; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 4; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -888,7 +891,7 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams& params) m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; multiplier = (m_sQueueSample.m_fDistance / SOUND_INTENSITY) * 0.5f; freq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE); m_sQueueSample.m_nFrequency = freq + freq * multiplier; @@ -896,10 +899,10 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams& params) SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 4; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 4; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -1034,7 +1037,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams& params) } m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_nFrequency = freq + 100 * m_sQueueSample.m_nEntityIndex % 1000; if (m_sQueueSample.m_nSampleIndex == SFX_CAR_IDLE_6 || m_sQueueSample.m_nSampleIndex == SFX_CAR_REV_6) m_sQueueSample.m_nFrequency /= 2; @@ -1042,10 +1045,10 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams& params) SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 8; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 8; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -1093,20 +1096,20 @@ cAudioManager::AddPlayerCarSample(uint8 emittingVolume, uint32 freq, uint32 samp m_sQueueSample.m_nBankIndex = SFX_BANK_0; #endif // GTA_PS2 m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 0; + m_sQueueSample.m_nPriority = 0; m_sQueueSample.m_nFrequency = freq; if (notLooping) { m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nReleasingVolumeDivider = 8; + m_sQueueSample.m_nFramesToPlay = 8; } else { m_sQueueSample.m_nLoopCount = 1; } SET_EMITTING_VOLUME(emittingVolume); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_SoundIntensity = 50.0f; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = 50.0f; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -1140,16 +1143,16 @@ cAudioManager::ProcessCesna(cVehicleParams& params) m_sQueueSample.m_nSampleIndex = SFX_CESNA_IDLE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 0; + m_sQueueSample.m_nPriority = 0; m_sQueueSample.m_nFrequency = 12500; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nReleasingVolumeDivider = 8; + m_sQueueSample.m_nFramesToPlay = 8; SET_EMITTING_VOLUME(80); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 8.0f; - m_sQueueSample.m_SoundIntensity = 200.0f; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = 200.0f; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -1160,16 +1163,16 @@ cAudioManager::ProcessCesna(cVehicleParams& params) m_sQueueSample.m_nSampleIndex = SFX_CESNA_REV; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 0; + m_sQueueSample.m_nPriority = 0; m_sQueueSample.m_nFrequency = 25000; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nReleasingVolumeDivider = 4; + m_sQueueSample.m_nFramesToPlay = 4; SET_EMITTING_VOLUME(80); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 8.0f; - m_sQueueSample.m_SoundIntensity = 90.0f; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = 90.0f; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -1341,7 +1344,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * } else { TranslateEntity(&m_sQueueSample.m_vecPos, &pos); #ifndef EXTERNAL_3D_SOUND - m_sQueueSample.m_nOffset = ComputePan(m_sQueueSample.m_fDistance, &pos); + m_sQueueSample.m_nPan = ComputePan(m_sQueueSample.m_fDistance, &pos); #endif if (bAccelSampleStopped) { if (CurrentPretendGear != 1 || currentGear != 2) { @@ -1381,7 +1384,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * #else SampleManager.SetChannelVolume(CHANNEL_PLAYER_VEHICLE_ENGINE, ComputeVolume(85, 50.0f, m_sQueueSample.m_fDistance)); - SampleManager.SetChannelPan(CHANNEL_PLAYER_VEHICLE_ENGINE, m_sQueueSample.m_nOffset); + SampleManager.SetChannelPan(CHANNEL_PLAYER_VEHICLE_ENGINE, m_sQueueSample.m_nPan); #endif freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050; if (engineSoundType == SFX_BANK_TRUCK) @@ -1497,15 +1500,15 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams& params) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 8; + m_sQueueSample.m_nPriority = 8; m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 3.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 3; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -1586,16 +1589,16 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams& params) m_sQueueSample.m_nSampleIndex = aVehicleSettings[params.m_nIndex].m_nHornSample; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_nPriority = 2; m_sQueueSample.m_nFrequency = aVehicleSettings[params.m_nIndex].m_nHornFrequency; m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(80); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 5.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 3; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -1668,15 +1671,15 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams& params) } m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(80); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 7.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 5; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); return TRUE; @@ -1710,16 +1713,16 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams& params) m_sQueueSample.m_nSampleIndex = SFX_REVERSE_WARNING; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_nPriority = 2; m_sQueueSample.m_nFrequency = (100 * m_sQueueSample.m_nEntityIndex & 1023) + SampleManager.GetSampleBaseFrequency(SFX_REVERSE_WARNING); m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(60); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 3.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 3; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -1756,14 +1759,14 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams& params) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex) + RandomDisplacement(1000); m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 10; + m_sQueueSample.m_nPriority = 10; m_sQueueSample.m_nLoopCount = 1; SET_EMITTING_VOLUME(emittingVol); RESET_LOOP_OFFSETS m_sQueueSample.m_fSpeedMultiplier = 1.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_bStatic = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(TRUE); AddSampleToRequestedQueue(); } @@ -1800,14 +1803,14 @@ cAudioManager::ProcessAirBrakes(cVehicleParams& params) m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 10; + m_sQueueSample.m_nPriority = 10; m_sQueueSample.m_nLoopCount = 1; SET_EMITTING_VOLUME(rand); RESET_LOOP_OFFSETS m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = 30.0f; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = 30.0f; + m_sQueueSample.m_bStatic = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -1840,12 +1843,12 @@ cAudioManager::ProcessEngineDamage(cVehicleParams& params) if (engineStatus < 225) { m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; emittingVolume = 6; - m_sQueueSample.m_nReleasingVolumeModificator = 7; + m_sQueueSample.m_nPriority = 7; m_sQueueSample.m_nFrequency = 40000; } else { emittingVolume = 60; m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE; - m_sQueueSample.m_nReleasingVolumeModificator = 7; + m_sQueueSample.m_nPriority = 7; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE); } CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); @@ -1858,10 +1861,10 @@ cAudioManager::ProcessEngineDamage(cVehicleParams& params) SET_EMITTING_VOLUME(emittingVolume); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_SoundIntensity = engineDamageIntensity; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = engineDamageIntensity; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 3; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -1885,16 +1888,16 @@ cAudioManager::ProcessCarBombTick(cVehicleParams& params) m_sQueueSample.m_nSampleIndex = SFX_COUNTDOWN; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 0; + m_sQueueSample.m_nPriority = 0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COUNTDOWN); m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(60); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_SoundIntensity = 40.0f; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = 40.0f; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 3; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -1956,9 +1959,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) #endif m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; SET_SOUND_REFLECTION(TRUE); break; } @@ -1994,9 +1997,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) #endif m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; SET_SOUND_REFLECTION(TRUE); break; } @@ -2008,9 +2011,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nCounter = 68; emittingVol = m_anRandomTable[1] % 30 + 60; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_CRACK); - m_sQueueSample.m_nReleasingVolumeModificator = 5; + m_sQueueSample.m_nPriority = 5; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; } break; case SOUND_CAR_JUMP: { const float SOUND_INTENSITY = 35.0f; @@ -2027,9 +2030,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nFrequency *= 2; emittingVol /= 2; } - m_sQueueSample.m_nReleasingVolumeModificator = 6; + m_sQueueSample.m_nPriority = 6; m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; break; } case SOUND_CAR_ENGINE_START: { @@ -2040,9 +2043,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 33; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_STARTER); - m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; SET_SOUND_REFLECTION(TRUE); break; } @@ -2053,9 +2056,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nCounter = 37; m_sQueueSample.m_nFrequency = 9 * SampleManager.GetSampleBaseFrequency(SFX_GLASS_SHARD_1) / 10; m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 8); - m_sQueueSample.m_nReleasingVolumeModificator = 5; + m_sQueueSample.m_nPriority = 5; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; maxDist = SQR(SOUND_INTENSITY); emittingVol = m_anRandomTable[4] % 10 + 30; break; @@ -2071,9 +2074,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 51; m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 8); - m_sQueueSample.m_nReleasingVolumeModificator = 5; + m_sQueueSample.m_nPriority = 5; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; maxDist = SQR(SOUND_INTENSITY); emittingVol = m_anRandomTable[0] % 15 + 55; break; @@ -2084,10 +2087,10 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 86; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SUSPENSION_SLOW_MOVE_LOOP); - m_sQueueSample.m_nReleasingVolumeModificator = 5; + m_sQueueSample.m_nPriority = 5; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_nReleasingVolumeDivider = 7; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_nFramesToPlay = 7; noReflections = TRUE; maxDist = SQR(SOUND_INTENSITY); emittingVol = m_anRandomTable[0] % 15 + 55; @@ -2100,9 +2103,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nCounter = 87; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SHAG_SUSPENSION); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 8); - m_sQueueSample.m_nReleasingVolumeModificator = 5; + m_sQueueSample.m_nPriority = 5; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; maxDist = SQR(SOUND_INTENSITY); emittingVol = m_anRandomTable[1] % 15 + 55; break; @@ -2121,9 +2124,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) if (WaveIndex > 46) WaveIndex = 41; m_sQueueSample.m_nFrequency = (7000.f * relVol) + 6000; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; emittingVol = (55.f * relVol); maxDist = SQR(SOUND_INTENSITY); break; @@ -2134,9 +2137,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 47; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_POLICE_BOAT_THUMB_OFF) + RandomDisplacement(600); - m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_nPriority = 2; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; emittingVol = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i]; maxDist = SQR(SOUND_INTENSITY); break; @@ -2148,9 +2151,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 59; m_sQueueSample.m_nFrequency = RandomDisplacement(1000) + 11025; - m_sQueueSample.m_nReleasingVolumeModificator = 5; + m_sQueueSample.m_nPriority = 5; m_sQueueSample.m_fSpeedMultiplier = 5.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; maxDist = SQR(SOUND_INTENSITY); emittingVol = m_anRandomTable[1] % 20 + 70; break; @@ -2164,10 +2167,10 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 79; m_sQueueSample.m_nFrequency = (3000.f * vol * 2500.0f / 96.0f) + 9000; - m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_nPriority = 2; m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_nFramesToPlay = 3; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; emittingVol = (37.f * vol * 2500.0f / 96.0f) + 90; maxDist = SQR(SOUND_INTENSITY); noReflections = TRUE; @@ -2179,9 +2182,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 80; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BOMB_BEEP); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; maxDist = SQR(SOUND_INTENSITY); SET_SOUND_REFLECTION(TRUE); emittingVol = 60; @@ -2193,9 +2196,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 81; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_JUMBO_LAND_WHEELS); - m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_nPriority = 2; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; maxDist = SQR(SOUND_INTENSITY); emittingVol = m_anRandomTable[4] % 25 + 75; break; @@ -2212,9 +2215,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) GunIndex = 53; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_UZI_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; break; } case SOUND_WEAPON_HIT_VEHICLE: { @@ -2224,9 +2227,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nCounter = 34; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); - m_sQueueSample.m_nReleasingVolumeModificator = 7; + m_sQueueSample.m_nPriority = 7; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; maxDist = SQR(SOUND_INTENSITY); emittingVol = m_anRandomTable[3] % 20 + 90; break; @@ -2240,9 +2243,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 36; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ARM_BOMB); - m_sQueueSample.m_nReleasingVolumeModificator = 0; + m_sQueueSample.m_nPriority = 0; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; SET_SOUND_REFLECTION(TRUE); emittingVol = 50; maxDist = SQR(SOUND_INTENSITY); @@ -2270,9 +2273,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 15; m_sQueueSample.m_nFrequency = RandomDisplacement(1000) + 16000; - m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; maxDist = SQR(SOUND_INTENSITY); SET_SOUND_REFLECTION(TRUE); emittingVol = m_anRandomTable[4] % 20 + 90; @@ -2284,9 +2287,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 48; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_PED_CRUNCH_1) + RandomDisplacement(600); - m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = 40.0f; + m_sQueueSample.m_MaxDistance = 40.0f; ++CrunchOffset; maxDist = SQR(SOUND_INTENSITY); emittingVol = m_anRandomTable[4] % 20 + 55; @@ -2305,9 +2308,9 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 50; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex) / 2; - m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; maxDist = SQR(SOUND_INTENSITY); break; } @@ -2316,18 +2319,18 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) } if (params.m_fDistance < maxDist) { CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); - m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { if (noReflections) { m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; + m_sQueueSample.m_bStatic = FALSE; } else { m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; } SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) SET_EMITTING_VOLUME(emittingVol); - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; m_sQueueSample.m_bIs2D = FALSE; AddSampleToRequestedQueue(); } @@ -2359,16 +2362,16 @@ cAudioManager::ProcessTrainNoise(cVehicleParams& params) m_sQueueSample.m_nSampleIndex = SFX_TRAIN_FAR; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_nPriority = 2; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TRAIN_FAR); m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 3.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 3; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -2381,16 +2384,16 @@ cAudioManager::ProcessTrainNoise(cVehicleParams& params) m_sQueueSample.m_nSampleIndex = SFX_TRAIN_NEAR; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 5; + m_sQueueSample.m_nPriority = 5; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TRAIN_NEAR) + 100 * m_sQueueSample.m_nEntityIndex % 987; m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 3; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -2426,15 +2429,15 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(80); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_SoundIntensity = intensity; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 7; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = intensity; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 7; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -2464,15 +2467,15 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_SoundIntensity = intensity; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 7; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = intensity; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 7; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -2520,15 +2523,15 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_SoundIntensity = intensity; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 7; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = intensity; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 7; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -2562,16 +2565,16 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams& params) m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_nFrequency = (6050.f * multiplier) + 16000; m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(vol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_SoundIntensity = 50.0f; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = 50.0f; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 3; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -2617,16 +2620,16 @@ cAudioManager::ProcessHelicopter(cVehicleParams& params) m_sQueueSample.m_nSampleIndex = i + SFX_HELI_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 0; + m_sQueueSample.m_nPriority = 0; m_sQueueSample.m_nFrequency = 1200 * heli->m_nHeliId + SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_SoundIntensity = gHeliSfxRanges[i].m_fMaxDistance; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = gHeliSfxRanges[i].m_fMaxDistance; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 3; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -2791,16 +2794,16 @@ cAudioManager::SetupJumboTaxiSound(uint8 vol) m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_nFrequency = GetJumboTaxiFreq(); m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 4.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 4; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 4; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -2822,16 +2825,16 @@ cAudioManager::SetupJumboWhineSound(uint8 emittingVol, uint32 freq) m_sQueueSample.m_nSampleIndex = SFX_JUMBO_WHINE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_nFrequency = freq; m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 4.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 4; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 4; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -2852,16 +2855,16 @@ cAudioManager::SetupJumboEngineSound(uint8 vol, uint32 freq) m_sQueueSample.m_nSampleIndex = SFX_JUMBO_ENGINE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_nFrequency = freq; m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 4.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 4; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 4; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -2882,16 +2885,16 @@ cAudioManager::SetupJumboFlySound(uint8 emittingVol) m_sQueueSample.m_nSampleIndex = SFX_JUMBO_DIST_FLY; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_JUMBO_DIST_FLY); m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 4.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 5; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -2912,23 +2915,23 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) m_sQueueSample.m_nSampleIndex = SFX_JUMBO_RUMBLE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = TRUE; - m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_JUMBO_RUMBLE); m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 4.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 12; - m_sQueueSample.m_nOffset = 0; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 12; + m_sQueueSample.m_nPan = 0; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); m_sQueueSample.m_nCounter = 6; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_RUMBLE; m_sQueueSample.m_nFrequency += 200; - m_sQueueSample.m_nOffset = 127; + m_sQueueSample.m_nPan = 127; AddSampleToRequestedQueue(); } return TRUE; @@ -2992,16 +2995,16 @@ cAudioManager::ProcessPedHeadphones(cPedParams ¶ms) m_sQueueSample.m_nSampleIndex = SFX_HEADPHONES; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 5; + m_sQueueSample.m_nPriority = 5; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_HEADPHONES); m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 4.0f; - m_sQueueSample.m_SoundIntensity = 7.0f; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = 7.0f; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 5; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -3100,14 +3103,14 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) default: break; } - m_sQueueSample.m_nReleasingVolumeModificator = 5; + m_sQueueSample.m_nPriority = 5; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = 20.0f; + m_sQueueSample.m_MaxDistance = 20.0f; m_sQueueSample.m_nLoopCount = 1; RESET_LOOP_OFFSETS SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; SET_SOUND_REFLECTION(TRUE); break; case SOUND_FALL_LAND: @@ -3127,14 +3130,14 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 17); - m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_nPriority = 2; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = 30.0f; + m_sQueueSample.m_MaxDistance = 30.0f; m_sQueueSample.m_nLoopCount = 1; RESET_LOOP_OFFSETS SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; SET_SOUND_REFLECTION(TRUE); break; case SOUND_FIGHT_PUNCH_33: @@ -3189,16 +3192,16 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nCounter = iSound; narrowSoundRange = TRUE; ++iSound; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = 30.0f; + m_sQueueSample.m_MaxDistance = 30.0f; maxDist = SQR(30); m_sQueueSample.m_nLoopCount = 1; RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[3] % 26 + 100; SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; SET_SOUND_REFLECTION(TRUE); break; case SOUND_WEAPON_BAT_ATTACK: @@ -3207,19 +3210,19 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nCounter = iSound++; narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = RandomDisplacement(2000) + 22000; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = 30.0f; + m_sQueueSample.m_MaxDistance = 30.0f; maxDist = SQR(30); m_sQueueSample.m_nLoopCount = 1; RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[2] % 20 + 100; SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; #ifdef AUDIO_REFLECTIONS if (m_bDynamicAcousticModelingStatus) - m_sQueueSample.m_bRequireReflection = TRUE; + m_sQueueSample.m_bReflections = TRUE; else #endif stereo = TRUE; @@ -3234,19 +3237,19 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COLT45_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = 50.0f; + m_sQueueSample.m_MaxDistance = 50.0f; maxDist = SQR(50); m_sQueueSample.m_nLoopCount = 1; RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[1] % 10 + 90; SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; #ifdef AUDIO_REFLECTIONS if (m_bDynamicAcousticModelingStatus) - m_sQueueSample.m_bRequireReflection = TRUE; + m_sQueueSample.m_bReflections = TRUE; else #endif stereo = TRUE; @@ -3258,16 +3261,16 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_UZI_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = 80.0f; + m_sQueueSample.m_MaxDistance = 80.0f; maxDist = SQR(80); m_sQueueSample.m_nLoopCount = 1; RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[3] % 15 + 70; SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; break; case WEAPONTYPE_SHOTGUN: m_sQueueSample.m_nSampleIndex = SFX_SHOTGUN_LEFT; @@ -3276,19 +3279,19 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SHOTGUN_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = 60.0f; + m_sQueueSample.m_MaxDistance = 60.0f; maxDist = SQR(60); m_sQueueSample.m_nLoopCount = 1; RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[2] % 10 + 100; SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; #ifdef AUDIO_REFLECTIONS if (m_bDynamicAcousticModelingStatus) - m_sQueueSample.m_bRequireReflection = TRUE; + m_sQueueSample.m_bReflections = TRUE; else #endif stereo = TRUE; @@ -3300,16 +3303,16 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_AK47_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = 80.0f; + m_sQueueSample.m_MaxDistance = 80.0f; maxDist = SQR(80); m_sQueueSample.m_nLoopCount = 1; RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[1] % 15 + 70; SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; break; case WEAPONTYPE_M16: m_sQueueSample.m_nSampleIndex = SFX_M16_LEFT; @@ -3318,16 +3321,16 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_M16_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = 80.0f; + m_sQueueSample.m_MaxDistance = 80.0f; maxDist = SQR(80); m_sQueueSample.m_nLoopCount = 1; RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[4] % 15 + 70; SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; break; case WEAPONTYPE_SNIPERRIFLE: m_sQueueSample.m_nSampleIndex = SFX_SNIPER_LEFT; @@ -3336,19 +3339,19 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SNIPER_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = 60.0f; + m_sQueueSample.m_MaxDistance = 60.0f; maxDist = SQR(60); m_sQueueSample.m_nLoopCount = 1; RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[4] % 10 + 110; SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; #ifdef AUDIO_REFLECTIONS if (m_bDynamicAcousticModelingStatus) - m_sQueueSample.m_bRequireReflection = TRUE; + m_sQueueSample.m_bReflections = TRUE; else #endif stereo = TRUE; @@ -3360,19 +3363,19 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ROCKET_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); - m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = 90.0f; + m_sQueueSample.m_MaxDistance = 90.0f; maxDist = SQR(90); m_sQueueSample.m_nLoopCount = 1; RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[0] % 20 + 80; SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; #ifdef AUDIO_REFLECTIONS if (m_bDynamicAcousticModelingStatus) - m_sQueueSample.m_bRequireReflection = TRUE; + m_sQueueSample.m_bReflections = TRUE; else #endif stereo = TRUE; @@ -3383,19 +3386,19 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nCounter = 9; emittingVol = 90; m_sQueueSample.m_nFrequency = (10 * m_sQueueSample.m_nEntityIndex & 2047) + SampleManager.GetSampleBaseFrequency(SFX_FLAMETHROWER_LEFT); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 4.0f; - m_sQueueSample.m_SoundIntensity = 60.0f; + m_sQueueSample.m_MaxDistance = 60.0f; maxDist = SQR(60); m_sQueueSample.m_nLoopCount = 0; SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) SET_EMITTING_VOLUME(90); m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 6; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 6; #ifdef AUDIO_REFLECTIONS if (m_bDynamicAcousticModelingStatus) - m_sQueueSample.m_bRequireReflection = TRUE; + m_sQueueSample.m_bReflections = TRUE; else #endif stereo = TRUE; @@ -3444,15 +3447,15 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency += RandomDisplacement(300); m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nReleasingVolumeModificator = 5; + m_sQueueSample.m_nPriority = 5; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = 30.0f; + m_sQueueSample.m_MaxDistance = 30.0f; maxDist = SQR(30); m_sQueueSample.m_nLoopCount = 1; RESET_LOOP_OFFSETS SET_EMITTING_VOLUME(75); m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; SET_SOUND_REFLECTION(TRUE); break; case SOUND_WEAPON_AK47_BULLET_ECHO: @@ -3464,19 +3467,19 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_UZI_END_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = 80.0f; + m_sQueueSample.m_MaxDistance = 80.0f; maxDist = SQR(80); m_sQueueSample.m_nLoopCount = 1; RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[4] % 10 + 40; SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; #ifdef AUDIO_REFLECTIONS if (m_bDynamicAcousticModelingStatus) - m_sQueueSample.m_bRequireReflection = TRUE; + m_sQueueSample.m_bReflections = TRUE; else #endif stereo = TRUE; @@ -3487,16 +3490,16 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_FLAMETHROWER_START_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 4.0f; - m_sQueueSample.m_SoundIntensity = 60.0f; + m_sQueueSample.m_MaxDistance = 60.0f; maxDist = SQR(60); m_sQueueSample.m_nLoopCount = 1; RESET_LOOP_OFFSETS emittingVol = 70; SET_EMITTING_VOLUME(70); m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; break; case SOUND_WEAPON_HIT_PED: m_sQueueSample.m_nSampleIndex = SFX_BULLET_PED; @@ -3505,16 +3508,16 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BULLET_PED); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 8); - m_sQueueSample.m_nReleasingVolumeModificator = 7; + m_sQueueSample.m_nPriority = 7; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = 30.0f; + m_sQueueSample.m_MaxDistance = 30.0f; maxDist = SQR(30); m_sQueueSample.m_nLoopCount = 1; RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[0] % 20 + 90; SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; break; case SOUND_SPLASH: m_sQueueSample.m_nSampleIndex = SFX_SPLASH_1; @@ -3522,16 +3525,16 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nCounter = iSound++; narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = RandomDisplacement(1400) + 20000; - m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = 40.0f; + m_sQueueSample.m_MaxDistance = 40.0f; maxDist = SQR(40); m_sQueueSample.m_nLoopCount = 1; RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[2] % 30 + 70; SET_EMITTING_VOLUME(emittingVol); m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; SET_SOUND_REFLECTION(TRUE); break; default: @@ -3543,20 +3546,20 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) iSound = 21; if (params.m_fDistance < maxDist) { CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); - m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { if (stereo) { - if (m_sQueueSample.m_fDistance < 0.2f * m_sQueueSample.m_SoundIntensity) { + if (m_sQueueSample.m_fDistance < 0.2f * m_sQueueSample.m_MaxDistance) { m_sQueueSample.m_bIs2D = TRUE; - m_sQueueSample.m_nOffset = 0; + m_sQueueSample.m_nPan = 0; } else { stereo = FALSE; } } - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; AddSampleToRequestedQueue(); if (stereo) { - m_sQueueSample.m_nOffset = 127; + m_sQueueSample.m_nPan = 127; ++m_sQueueSample.m_nSampleIndex; if (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] != SOUND_WEAPON_SHOT_FIRED || weapon->m_eWeaponType != WEAPONTYPE_FLAMETHROWER) { @@ -6081,7 +6084,7 @@ cPedComments::Process() AudioManager.m_sQueueSample.m_nCounter = 0; AudioManager.m_sQueueSample.m_nSampleIndex = sampleIndex; AudioManager.m_sQueueSample.m_nBankIndex = SFX_BANK_PED_COMMENTS; - AudioManager.m_sQueueSample.m_nReleasingVolumeModificator = 3; + AudioManager.m_sQueueSample.m_nPriority = 3; AudioManager.m_sQueueSample.m_nVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nVolume; AudioManager.m_sQueueSample.m_fDistance = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_fDistance; AudioManager.m_sQueueSample.m_nLoopCount = 1; @@ -6129,31 +6132,31 @@ cPedComments::Process() case SFX_POLICE_HELI_28: case SFX_POLICE_HELI_29: #endif - AudioManager.m_sQueueSample.m_SoundIntensity = 400.0f; + AudioManager.m_sQueueSample.m_MaxDistance = 400.0f; break; default: - AudioManager.m_sQueueSample.m_SoundIntensity = 50.0f; + AudioManager.m_sQueueSample.m_MaxDistance = 50.0f; break; } - AudioManager.m_sQueueSample.m_bReleasingSoundFlag = TRUE; + AudioManager.m_sQueueSample.m_bStatic = TRUE; AudioManager.m_sQueueSample.m_vecPos = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_vecPos; if (sampleIndex >= SFX_AMMU_D && sampleIndex <= SFX_AMMU_F) { - AudioManager.m_sQueueSample.m_bReverbFlag = FALSE; + AudioManager.m_sQueueSample.m_bReverb = FALSE; #ifdef AUDIO_REFLECTIONS - AudioManager.m_sQueueSample.m_bRequireReflection = FALSE; + AudioManager.m_sQueueSample.m_bReflections = FALSE; #endif #ifdef FIX_BUGS } else if (sampleIndex >= SFX_POLICE_HELI_1 && sampleIndex <= SFX_POLICE_HELI_29) { - AudioManager.m_sQueueSample.m_bReverbFlag = TRUE; + AudioManager.m_sQueueSample.m_bReverb = TRUE; #ifdef AUDIO_REFLECTIONS - AudioManager.m_sQueueSample.m_bRequireReflection = FALSE; + AudioManager.m_sQueueSample.m_bReflections = FALSE; #endif // AUDIO_REFLECTIONS #endif // FIX_BUGS } else { - AudioManager.m_sQueueSample.m_bReverbFlag = TRUE; + AudioManager.m_sQueueSample.m_bReverb = TRUE; #ifdef AUDIO_REFLECTIONS - AudioManager.m_sQueueSample.m_bRequireReflection = TRUE; + AudioManager.m_sQueueSample.m_bReflections = TRUE; #endif } @@ -6208,53 +6211,53 @@ cAudioManager::ProcessExplosions(int32 explosion) case EXPLOSION_ROCKET: case EXPLOSION_BARREL: case EXPLOSION_TANK_GRENADE: - m_sQueueSample.m_SoundIntensity = 400.0f; + m_sQueueSample.m_MaxDistance = 400.0f; m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_2; m_sQueueSample.m_nFrequency = RandomDisplacement(2000) + 38000; - m_sQueueSample.m_nReleasingVolumeModificator = 0; + m_sQueueSample.m_nPriority = 0; m_sQueueSample.m_nBankIndex = SFX_BANK_0; break; case EXPLOSION_MOLOTOV: - m_sQueueSample.m_SoundIntensity = 200.0f; + m_sQueueSample.m_MaxDistance = 200.0f; m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_3; m_sQueueSample.m_nFrequency = RandomDisplacement(1000) + 19000; - m_sQueueSample.m_nReleasingVolumeModificator = 0; + m_sQueueSample.m_nPriority = 0; m_sQueueSample.m_nBankIndex = SFX_BANK_0; break; case EXPLOSION_MINE: case EXPLOSION_HELI_BOMB: - m_sQueueSample.m_SoundIntensity = 300.0f; + m_sQueueSample.m_MaxDistance = 300.0f; m_sQueueSample.m_nSampleIndex = SFX_ROCKET_LEFT; m_sQueueSample.m_nFrequency = RandomDisplacement(1000) + 12347; - m_sQueueSample.m_nReleasingVolumeModificator = 0; + m_sQueueSample.m_nPriority = 0; m_sQueueSample.m_nBankIndex = SFX_BANK_0; break; default: - m_sQueueSample.m_SoundIntensity = 400.0f; + m_sQueueSample.m_MaxDistance = 400.0f; m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_1; m_sQueueSample.m_nFrequency = RandomDisplacement(2000) + 38000; if (type == EXPLOSION_HELI) m_sQueueSample.m_nFrequency = 8 * m_sQueueSample.m_nFrequency / 10; - m_sQueueSample.m_nReleasingVolumeModificator = 0; + m_sQueueSample.m_nPriority = 0; m_sQueueSample.m_nBankIndex = SFX_BANK_GENERIC_EXTRA; break; } pos = CExplosion::GetExplosionPosition(i); m_sQueueSample.m_vecPos = *pos; distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { + if (distSquared < SQR(m_sQueueSample.m_MaxDistance)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); - m_sQueueSample.m_nVolume = ComputeVolume(MAX_VOLUME, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(MAX_VOLUME, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = i; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_EMITTING_VOLUME(MAX_VOLUME); RESET_LOOP_OFFSETS - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(TRUE); AddSampleToRequestedQueue(); } @@ -6276,53 +6279,53 @@ cAudioManager::ProcessFires(int32) if (entity) { switch (entity->GetType()) { case ENTITY_TYPE_BUILDING: - m_sQueueSample.m_SoundIntensity = 50.0f; + m_sQueueSample.m_MaxDistance = 50.0f; m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE; emittingVol = 100; m_sQueueSample.m_nFrequency = 8 * SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE) / 10; m_sQueueSample.m_nFrequency += i * (m_sQueueSample.m_nFrequency / 64); - m_sQueueSample.m_nReleasingVolumeModificator = 6; + m_sQueueSample.m_nPriority = 6; break; case ENTITY_TYPE_PED: - m_sQueueSample.m_SoundIntensity = 25.0f; + m_sQueueSample.m_MaxDistance = 25.0f; m_sQueueSample.m_nSampleIndex = SFX_PED_ON_FIRE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_PED_ON_FIRE); emittingVol = 60; m_sQueueSample.m_nFrequency += i * (m_sQueueSample.m_nFrequency / 64); - m_sQueueSample.m_nReleasingVolumeModificator = 10; + m_sQueueSample.m_nPriority = 10; break; default: - m_sQueueSample.m_SoundIntensity = 50.0f; + m_sQueueSample.m_MaxDistance = 50.0f; m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE); m_sQueueSample.m_nFrequency += i * (m_sQueueSample.m_nFrequency / 64); emittingVol = 80; - m_sQueueSample.m_nReleasingVolumeModificator = 8; + m_sQueueSample.m_nPriority = 8; } } else { - m_sQueueSample.m_SoundIntensity = 50.0f; + m_sQueueSample.m_MaxDistance = 50.0f; m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE); m_sQueueSample.m_nFrequency += i * (m_sQueueSample.m_nFrequency / 64); emittingVol = 80; - m_sQueueSample.m_nReleasingVolumeModificator = 8; + m_sQueueSample.m_nPriority = 8; } m_sQueueSample.m_vecPos = gFireManager.m_aFires[i].m_vecPos; distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { + if (distSquared < SQR(m_sQueueSample.m_MaxDistance)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); - m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = i; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_nReleasingVolumeDivider = 10; + m_sQueueSample.m_nFramesToPlay = 10; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; + m_sQueueSample.m_bStatic = FALSE; SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -6345,27 +6348,27 @@ cAudioManager::ProcessWaterCannon(int32) #ifdef FIX_BUGS m_sQueueSample.m_nVolume = ComputeVolume(50, SOUND_INTENSITY, m_sQueueSample.m_fDistance); #else - m_sQueueSample.m_nVolume = ComputeVolume(50, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(50, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); #endif if (m_sQueueSample.m_nVolume > 0) { #ifdef FIX_BUGS - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; #else - m_sQueueSample.m_SoundIntensity = SQR(SOUND_INTENSITY); + m_sQueueSample.m_MaxDistance = SQR(SOUND_INTENSITY); #endif m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = 15591; - m_sQueueSample.m_nReleasingVolumeModificator = 5; + m_sQueueSample.m_nPriority = 5; m_sQueueSample.m_nCounter = i; m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_nReleasingVolumeDivider = 8; + m_sQueueSample.m_nFramesToPlay = 8; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; + m_sQueueSample.m_bStatic = FALSE; SET_EMITTING_VOLUME(50); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -6419,14 +6422,14 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) } case SCRIPT_SOUND_GATE_START_CLUNK: case SCRIPT_SOUND_GATE_STOP_CLUNK: - m_sQueueSample.m_SoundIntensity = 40.0f; + m_sQueueSample.m_MaxDistance = 40.0f; m_sQueueSample.m_nSampleIndex = SFX_COL_GATE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; if (sound == SCRIPT_SOUND_GATE_START_CLUNK) m_sQueueSample.m_nFrequency = 10600; else m_sQueueSample.m_nFrequency = 9000; - m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = FALSE; SET_SOUND_REFLECTION(TRUE); @@ -6435,12 +6438,12 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_BULLET_HIT_GROUND_1: case SCRIPT_SOUND_BULLET_HIT_GROUND_2: case SCRIPT_SOUND_BULLET_HIT_GROUND_3: - m_sQueueSample.m_SoundIntensity = 50.0f; + m_sQueueSample.m_MaxDistance = 50.0f; m_sQueueSample.m_nSampleIndex = m_anRandomTable[iSound % 5] % 3 + SFX_BULLET_WALL_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); - m_sQueueSample.m_nReleasingVolumeModificator = 9; + m_sQueueSample.m_nPriority = 9; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = FALSE; emittingVolume = m_anRandomTable[2] % 20 + 90; @@ -6449,108 +6452,108 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_TRAIN_ANNOUNCEMENT_2: if (!SampleManager.IsSampleBankLoaded(SFX_BANK_TRAIN)) return; - m_sQueueSample.m_SoundIntensity = 80.0f; + m_sQueueSample.m_MaxDistance = 80.0f; m_sQueueSample.m_nSampleIndex = SFX_TRAIN_STATION_ANNOUNCE; m_sQueueSample.m_nBankIndex = SFX_BANK_TRAIN; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TRAIN_STATION_ANNOUNCE); - m_sQueueSample.m_nReleasingVolumeModificator = 0; + m_sQueueSample.m_nPriority = 0; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_bIs2D = FALSE; break; case SCRIPT_SOUND_PAYPHONE_RINGING: - m_sQueueSample.m_SoundIntensity = 80.0f; + m_sQueueSample.m_MaxDistance = 80.0f; m_sQueueSample.m_nSampleIndex = SFX_PHONE_RING; m_sQueueSample.m_nBankIndex = SFX_BANK_0; emittingVolume = 80; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_PHONE_RING); - m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_bIs2D = FALSE; SET_SOUND_REFLECTION(FALSE); break; case SCRIPT_SOUND_GLASS_BREAK_L: - m_sQueueSample.m_SoundIntensity = 60.0f; + m_sQueueSample.m_MaxDistance = 60.0f; m_sQueueSample.m_nSampleIndex = SFX_GLASS_SMASH; m_sQueueSample.m_nBankIndex = SFX_BANK_0; emittingVolume = 70; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_SMASH); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = FALSE; break; case SCRIPT_SOUND_GLASS_BREAK_S: - m_sQueueSample.m_SoundIntensity = 60.0f; + m_sQueueSample.m_MaxDistance = 60.0f; m_sQueueSample.m_nSampleIndex = SFX_GLASS_SMASH; m_sQueueSample.m_nBankIndex = SFX_BANK_0; emittingVolume = 60; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_SMASH); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = FALSE; break; case SCRIPT_SOUND_GLASS_CRACK: - m_sQueueSample.m_SoundIntensity = 60.0f; + m_sQueueSample.m_MaxDistance = 60.0f; m_sQueueSample.m_nSampleIndex = SFX_GLASS_CRACK; m_sQueueSample.m_nBankIndex = SFX_BANK_0; emittingVolume = 70; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_CRACK); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = FALSE; SET_SOUND_REFLECTION(TRUE); break; case SCRIPT_SOUND_GLASS_LIGHT_BREAK: - m_sQueueSample.m_SoundIntensity = 55.0f; + m_sQueueSample.m_MaxDistance = 55.0f; m_sQueueSample.m_nSampleIndex = (m_anRandomTable[4] & 3) + SFX_GLASS_SHARD_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = RandomDisplacement(2000) + 19000; - m_sQueueSample.m_nReleasingVolumeModificator = 9; + m_sQueueSample.m_nPriority = 9; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = FALSE; emittingVolume = RandomDisplacement(11) + 25; break; case SCRIPT_SOUND_BOX_DESTROYED_1: - m_sQueueSample.m_SoundIntensity = 60.0f; + m_sQueueSample.m_MaxDistance = 60.0f; m_sQueueSample.m_nSampleIndex = SFX_WOODEN_BOX_SMASH; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = RandomDisplacement(1500) + 18600; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = FALSE; SET_SOUND_REFLECTION(TRUE); emittingVolume = m_anRandomTable[2] % 20 + 80; break; case SCRIPT_SOUND_BOX_DESTROYED_2: - m_sQueueSample.m_SoundIntensity = 60.0f; + m_sQueueSample.m_MaxDistance = 60.0f; m_sQueueSample.m_nSampleIndex = SFX_CARDBOARD_BOX_SMASH; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = RandomDisplacement(1500) + 18600; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = FALSE; SET_SOUND_REFLECTION(TRUE); emittingVolume = m_anRandomTable[2] % 20 + 80; break; case SCRIPT_SOUND_METAL_COLLISION: - m_sQueueSample.m_SoundIntensity = 60.0f; + m_sQueueSample.m_MaxDistance = 60.0f; m_sQueueSample.m_nSampleIndex = m_anRandomTable[3] % 5 + SFX_COL_CAR_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = FALSE; SET_SOUND_REFLECTION(TRUE); emittingVolume = m_anRandomTable[2] % 30 + 70; break; case SCRIPT_SOUND_TIRE_COLLISION: - m_sQueueSample.m_SoundIntensity = 60.0f; + m_sQueueSample.m_MaxDistance = 60.0f; m_sQueueSample.m_nSampleIndex = SFX_TYRE_BUMP; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = FALSE; SET_SOUND_REFLECTION(TRUE); @@ -6570,22 +6573,22 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SURFACE_HEDGE: m_sQueueSample.m_nSampleIndex = SFX_BULLET_SHELL_HIT_GROUND_2; m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 11000; - m_sQueueSample.m_nReleasingVolumeModificator = 18; + m_sQueueSample.m_nPriority = 18; break; case SURFACE_WATER: return; default: m_sQueueSample.m_nSampleIndex = SFX_BULLET_SHELL_HIT_GROUND_1; m_sQueueSample.m_nFrequency = RandomDisplacement(750) + 18000; - m_sQueueSample.m_nReleasingVolumeModificator = 15; + m_sQueueSample.m_nPriority = 15; break; } } else { m_sQueueSample.m_nSampleIndex = SFX_BULLET_SHELL_HIT_GROUND_1; m_sQueueSample.m_nFrequency = RandomDisplacement(750) + 18000; - m_sQueueSample.m_nReleasingVolumeModificator = 15; + m_sQueueSample.m_nPriority = 15; } - m_sQueueSample.m_SoundIntensity = 20.0f; + m_sQueueSample.m_MaxDistance = 20.0f; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = FALSE; @@ -6594,8 +6597,8 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_GUNSHELL_DROP_SOFT: m_sQueueSample.m_nSampleIndex = SFX_BULLET_SHELL_HIT_GROUND_2; m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 11000; - m_sQueueSample.m_nReleasingVolumeModificator = 18; - m_sQueueSample.m_SoundIntensity = 20.0f; + m_sQueueSample.m_nPriority = 18; + m_sQueueSample.m_MaxDistance = 20.0f; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = FALSE; @@ -6606,16 +6609,16 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) } distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { + if (distSquared < SQR(m_sQueueSample.m_MaxDistance)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); - m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; SET_EMITTING_VOLUME(emittingVolume); RESET_LOOP_OFFSETS - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; AddSampleToRequestedQueue(); } } @@ -6629,303 +6632,303 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) switch (sound) { case SCRIPT_SOUND_PARTY_1_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_1; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_1); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_1_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_1; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_1); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_2_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_2; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_2; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_2); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_2_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_2; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_2; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_2); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_3_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_3; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_3; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_3); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_3_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_3; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_3; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_3); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_4_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_4; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_4; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_4); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_4_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_4; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_4; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_4); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_5_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_5; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_5; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_5); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_5_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_5; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_5; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_5); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_6_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_6; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_6; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_6); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_6_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_6; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_6; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_6); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_7_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_7; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_7; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_7); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_7_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_7; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_7; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_7); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_8_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_8; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_8; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_8); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_8_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_8; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_8; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_8); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_9_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_9; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_9; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_9); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_9_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_9; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_9; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_9); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_10_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_10; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_10; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_10); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_10_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_10; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_10; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_10); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_11_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_11; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_11; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_11); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_11_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_11; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_11; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_11); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_12_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_12; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_12; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_12); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_12_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_12; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_12; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_12); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_13_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_RAGGA; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_RAGGA; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_RAGGA); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_13_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_RAGGA; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_RAGGA; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_RAGGA); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_STRIP_CLUB_LOOP_1_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_STRIP_CLUB_1; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_STRIP_CLUB_1); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_STRIP_CLUB_LOOP_1_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_STRIP_CLUB_1; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_STRIP_CLUB_1); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_STRIP_CLUB_LOOP_2_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_2; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_STRIP_CLUB_2; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_STRIP_CLUB_2); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_STRIP_CLUB_LOOP_2_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_2; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_STRIP_CLUB_2; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_STRIP_CLUB_2); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_WORK_SHOP_LOOP_S: @@ -6937,23 +6940,23 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) ProcessSawMillScriptObject(sound); return; case SCRIPT_SOUND_38: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_DOG_FOOD_FACTORY; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_DOG_FOOD_FACTORY; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_DOG_FOOD_FACTORY); - m_sQueueSample.m_nReleasingVolumeModificator = 6; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 6; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_39: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_DOG_FOOD_FACTORY; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_DOG_FOOD_FACTORY; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_DOG_FOOD_FACTORY); - m_sQueueSample.m_nReleasingVolumeModificator = 6; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 6; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_LAUNDERETTE_LOOP_S: @@ -6961,83 +6964,83 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) ProcessLaunderetteScriptObject(sound); return; case SCRIPT_SOUND_CHINATOWN_RESTAURANT_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_CHINATOWN; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_RESTAURANT_CHINATOWN; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_CHINATOWN); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_CHINATOWN_RESTAURANT_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_CHINATOWN; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_RESTAURANT_CHINATOWN; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_CHINATOWN); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_CIPRIANI_RESAURANT_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_ITALY; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_RESTAURANT_ITALY; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_ITALY); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_CIPRIANI_RESAURANT_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_ITALY; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_RESTAURANT_ITALY; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_ITALY); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_46_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_RESTAURANT_GENERIC_1; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_GENERIC_1); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_47_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_RESTAURANT_GENERIC_1; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_GENERIC_1); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_MARCO_BISTRO_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_2; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_RESTAURANT_GENERIC_2; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_GENERIC_2); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_MARCO_BISTRO_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_2; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_RESTAURANT_GENERIC_2; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_GENERIC_2); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_AIRPORT_LOOP_S: @@ -7061,23 +7064,23 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) ProcessHomeScriptObject(sound); return; case SCRIPT_SOUND_FRANKIE_PIANO: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_PIANO_BAR_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_PIANO_BAR; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_PIANO_BAR_1); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PARTY_1_LOOP: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CLUB_1; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_1); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PORN_CINEMA_1_S: @@ -7091,63 +7094,63 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) ProcessPornCinema(sound); return; case SCRIPT_SOUND_BANK_ALARM_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_BANK_ALARM_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_BANK_ALARM; emittingVolume = 90; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BANK_ALARM_1); - m_sQueueSample.m_nReleasingVolumeModificator = 2; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 2; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_BANK_ALARM_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_BANK_ALARM_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_BANK_ALARM; emittingVolume = 90; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BANK_ALARM_1); - m_sQueueSample.m_nReleasingVolumeModificator = 2; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 2; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_POLICE_BALL_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_POLICE_BALL_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_POLICE_BALL; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_POLICE_BALL_1); - m_sQueueSample.m_nReleasingVolumeModificator = 2; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 2; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_POLICE_BALL_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_POLICE_BALL_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_POLICE_BALL; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_POLICE_BALL_1); - m_sQueueSample.m_nReleasingVolumeModificator = 2; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 2; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_RAVE_LOOP_INDUSTRIAL_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RAVE_INDUSTRIAL; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_RAVE_INDUSTRIAL; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RAVE_INDUSTRIAL); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_RAVE_LOOP_INDUSTRIAL_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RAVE_INDUSTRIAL; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_RAVE_INDUSTRIAL; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RAVE_INDUSTRIAL); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_POLICE_CELL_BEATING_LOOP_S: @@ -7156,54 +7159,54 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) return; case SCRIPT_SOUND_RAVE_1_LOOP_S: case SCRIPT_SOUND_RAVE_2_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RAVE_COMMERCIAL; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_RAVE_COMMERCIAL; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_RAVE_1_LOOP_L: case SCRIPT_SOUND_RAVE_2_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RAVE_COMMERCIAL; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_RAVE_COMMERCIAL; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_RAVE_3_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RAVE_SUBURBAN; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_RAVE_SUBURBAN; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RAVE_SUBURBAN); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_RAVE_3_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RAVE_SUBURBAN; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_RAVE_SUBURBAN; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RAVE_SUBURBAN); - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nPriority = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; case SCRIPT_SOUND_PRETEND_FIRE_LOOP: - m_sQueueSample.m_SoundIntensity = 50.0f; + m_sQueueSample.m_MaxDistance = 50.0f; m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; emittingVolume = 80; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE); - m_sQueueSample.m_nReleasingVolumeModificator = 8; - m_sQueueSample.m_nReleasingVolumeDivider = 10; + m_sQueueSample.m_nPriority = 8; + m_sQueueSample.m_nFramesToPlay = 10; m_sQueueSample.m_fSpeedMultiplier = 2.0f; break; default: @@ -7211,15 +7214,15 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) } distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { + if (distSquared < SQR(m_sQueueSample.m_MaxDistance)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); - m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_bReverb = TRUE; SET_EMITTING_VOLUME(emittingVolume); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) SET_SOUND_REFLECTION(FALSE); @@ -7243,58 +7246,58 @@ cAudioManager::ProcessPornCinema(uint8 sound) m_sQueueSample.m_nSampleIndex = SFX_PORN_1_LOOP; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_PORN_1; sample = SFX_PORN_1_GROAN_1; - m_sQueueSample.m_SoundIntensity = 20.0f; + m_sQueueSample.m_MaxDistance = 20.0f; break; case SCRIPT_SOUND_PORN_CINEMA_1_L: case SCRIPT_SOUND_MISTY_SEX_L: m_sQueueSample.m_nSampleIndex = SFX_PORN_1_LOOP; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_PORN_1; sample = SFX_PORN_1_GROAN_1; - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; break; case SCRIPT_SOUND_PORN_CINEMA_2_S: m_sQueueSample.m_nSampleIndex = SFX_PORN_2_LOOP; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_PORN_2; sample = SFX_PORN_2_GROAN_1; - m_sQueueSample.m_SoundIntensity = 20.0f; + m_sQueueSample.m_MaxDistance = 20.0f; break; case SCRIPT_SOUND_PORN_CINEMA_2_L: m_sQueueSample.m_nSampleIndex = SFX_PORN_2_LOOP; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_PORN_2; sample = SFX_PORN_2_GROAN_1; - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; break; case SCRIPT_SOUND_PORN_CINEMA_3_S: m_sQueueSample.m_nSampleIndex = SFX_PORN_3_LOOP; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_PORN_3; - m_sQueueSample.m_SoundIntensity = 20.0f; + m_sQueueSample.m_MaxDistance = 20.0f; sample = SFX_PORN_3_GROAN_1; break; case SCRIPT_SOUND_PORN_CINEMA_3_L: m_sQueueSample.m_nSampleIndex = SFX_PORN_3_LOOP; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_PORN_3; - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; sample = SFX_PORN_3_GROAN_1; break; default: return; } distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { + if (distSquared < SQR(m_sQueueSample.m_MaxDistance)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); if (sound != SCRIPT_SOUND_MISTY_SEX_S && sound != SCRIPT_SOUND_MISTY_SEX_L) { - m_sQueueSample.m_nVolume = ComputeVolume(MAX_VOLUME, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(MAX_VOLUME, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; SET_EMITTING_VOLUME(MAX_VOLUME); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -7302,7 +7305,7 @@ cAudioManager::ProcessPornCinema(uint8 sound) time = CTimer::GetTimeInMilliseconds(); if (time > gPornNextTime) { - m_sQueueSample.m_nVolume = ComputeVolume(90, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(90, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { rand = m_anRandomTable[1] & 1; m_sQueueSample.m_nSampleIndex = rand + sample; @@ -7311,14 +7314,14 @@ cAudioManager::ProcessPornCinema(uint8 sound) m_sQueueSample.m_nCounter = rand + 1; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_nReleasingVolumeModificator = 6; + m_sQueueSample.m_bStatic = TRUE; + m_sQueueSample.m_nPriority = 6; m_sQueueSample.m_fSpeedMultiplier = 0.0f; #ifdef FIX_BUGS SET_EMITTING_VOLUME(90); #endif RESET_LOOP_OFFSETS - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); gPornNextTime = time + 2000 + m_anRandomTable[3] % 6000; @@ -7335,15 +7338,15 @@ cAudioManager::ProcessWorkShopScriptObject(uint8 sound) switch (sound) { case SCRIPT_SOUND_WORK_SHOP_LOOP_S: case SCRIPT_SOUND_WORK_SHOP_LOOP_L: - m_sQueueSample.m_SoundIntensity = 20.0f; + m_sQueueSample.m_MaxDistance = 20.0f; break; default: return; } distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { + if (distSquared < SQR(m_sQueueSample.m_MaxDistance)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); - m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = SFX_WORKSHOP_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_WORKSHOP; @@ -7351,12 +7354,12 @@ cAudioManager::ProcessWorkShopScriptObject(uint8 sound) m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 5; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nPriority = 5; m_sQueueSample.m_fSpeedMultiplier = 2.0f; SET_EMITTING_VOLUME(30); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -7373,15 +7376,15 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) switch (sound) { case SCRIPT_SOUND_SAWMILL_LOOP_S: case SCRIPT_SOUND_SAWMILL_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; break; default: return; } distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { + if (distSquared < SQR(m_sQueueSample.m_MaxDistance)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); - m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = SFX_SAWMILL_LOOP; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_SAWMILL; @@ -7389,18 +7392,18 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 5; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nPriority = 5; m_sQueueSample.m_fSpeedMultiplier = 2.0f; SET_EMITTING_VOLUME(30); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } time = CTimer::GetTimeInMilliseconds(); if (time > gSawMillNextTime) { - m_sQueueSample.m_nVolume = ComputeVolume(70, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(70, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = SFX_SAWMILL_CUT_WOOD; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_SAWMILL; @@ -7408,14 +7411,14 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_bStatic = TRUE; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; #ifdef FIX_BUGS SET_EMITTING_VOLUME(70); #endif RESET_LOOP_OFFSETS - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); gSawMillNextTime = time + 2000 + m_anRandomTable[3] % 4000; @@ -7430,15 +7433,15 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) switch (sound) { case SCRIPT_SOUND_LAUNDERETTE_LOOP_S: case SCRIPT_SOUND_LAUNDERETTE_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; break; default: return; } float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { + if (distSquared < SQR(m_sQueueSample.m_MaxDistance)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); - m_sQueueSample.m_nVolume = ComputeVolume(45, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(45, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = SFX_LAUNDERETTE_LOOP; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_LAUNDERETTE; @@ -7446,16 +7449,16 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 5; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nPriority = 5; m_sQueueSample.m_fSpeedMultiplier = 2.0f; SET_EMITTING_VOLUME(45); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } - m_sQueueSample.m_nVolume = ComputeVolume(110, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(110, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = SFX_LAUNDERETTE_SONG_LOOP; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_LAUNDERETTE; @@ -7463,12 +7466,12 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; SET_EMITTING_VOLUME(110); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -7485,15 +7488,15 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) switch (sound) { case SCRIPT_SOUND_SHOP_LOOP_S: case SCRIPT_SOUND_SHOP_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; break; default: return; } distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { + if (distSquared < SQR(m_sQueueSample.m_MaxDistance)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); - m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = SFX_SHOP_LOOP; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_SHOP; @@ -7501,18 +7504,18 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 5; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nPriority = 5; m_sQueueSample.m_fSpeedMultiplier = 2.0f; SET_EMITTING_VOLUME(30); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } time = CTimer::GetTimeInMilliseconds(); if (time > gShopNextTime) { - m_sQueueSample.m_nVolume = ComputeVolume(70, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(70, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { rand = m_anRandomTable[1] & 1; m_sQueueSample.m_nSampleIndex = rand + SFX_SHOP_TILL_1; @@ -7521,12 +7524,12 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) m_sQueueSample.m_nCounter = rand + 1; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_bStatic = TRUE; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; SET_EMITTING_VOLUME(70); RESET_LOOP_OFFSETS - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); gShopNextTime = time + 3000 + m_anRandomTable[3] % 7000; @@ -7544,18 +7547,18 @@ cAudioManager::ProcessAirportScriptObject(uint8 sound) if (time > gAirportNextTime) { switch (sound) { case SCRIPT_SOUND_AIRPORT_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; break; case SCRIPT_SOUND_AIRPORT_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; break; default: return; } float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { + if (distSquared < SQR(m_sQueueSample.m_MaxDistance)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); - m_sQueueSample.m_nVolume = ComputeVolume(110, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(110, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = (m_anRandomTable[1] & 3) + SFX_AIRPORT_ANNOUNCEMENT_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_AIRPORT; @@ -7563,12 +7566,12 @@ cAudioManager::ProcessAirportScriptObject(uint8 sound) m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_bStatic = TRUE; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; SET_EMITTING_VOLUME(110); RESET_LOOP_OFFSETS - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); gAirportNextTime = time + 10000 + m_anRandomTable[3] % 20000; @@ -7588,19 +7591,19 @@ cAudioManager::ProcessCinemaScriptObject(uint8 sound) if (time > gCinemaNextTime) { switch (sound) { case SCRIPT_SOUND_CINEMA_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; break; case SCRIPT_SOUND_CINEMA_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; break; default: return; } float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { + if (distSquared < SQR(m_sQueueSample.m_MaxDistance)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); rand = m_anRandomTable[0] % 90 + 30; - m_sQueueSample.m_nVolume = ComputeVolume(rand, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(rand, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = iSound % 3 + SFX_CINEMA_BASS_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CINEMA; @@ -7609,12 +7612,12 @@ cAudioManager::ProcessCinemaScriptObject(uint8 sound) m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_bStatic = TRUE; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; SET_EMITTING_VOLUME(rand); RESET_LOOP_OFFSETS - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); gCinemaNextTime = time + 1000 + m_anRandomTable[3] % 4000; @@ -7636,19 +7639,19 @@ cAudioManager::ProcessDocksScriptObject(uint8 sound) if (time > gDocksNextTime) { switch (sound) { case SCRIPT_SOUND_DOCKS_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; break; case SCRIPT_SOUND_DOCKS_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; break; default: return; } distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { + if (distSquared < SQR(m_sQueueSample.m_MaxDistance)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); rand = m_anRandomTable[0] % 60 + 40; - m_sQueueSample.m_nVolume = ComputeVolume(rand, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(rand, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = SFX_DOCKS_FOGHORN; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_DOCKS; @@ -7657,12 +7660,12 @@ cAudioManager::ProcessDocksScriptObject(uint8 sound) m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_bStatic = TRUE; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; SET_EMITTING_VOLUME(rand); RESET_LOOP_OFFSETS - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); gDocksNextTime = time + 10000 + m_anRandomTable[3] % 40000; @@ -7683,19 +7686,19 @@ cAudioManager::ProcessHomeScriptObject(uint8 sound) if (time > gHomeNextTime) { switch (sound) { case SCRIPT_SOUND_HOME_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; break; case SCRIPT_SOUND_HOME_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; break; default: return; } dist = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (dist < SQR(m_sQueueSample.m_SoundIntensity)) { + if (dist < SQR(m_sQueueSample.m_MaxDistance)) { m_sQueueSample.m_fDistance = Sqrt(dist); rand = m_anRandomTable[0] % 30 + 40; - m_sQueueSample.m_nVolume = ComputeVolume(rand, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(rand, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nSampleIndex = m_anRandomTable[0] % 5 + SFX_HOME_1; m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_HOME; @@ -7704,12 +7707,12 @@ cAudioManager::ProcessHomeScriptObject(uint8 sound) m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_bStatic = TRUE; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; SET_EMITTING_VOLUME(rand); RESET_LOOP_OFFSETS - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(TRUE); AddSampleToRequestedQueue(); gHomeNextTime = time + 1000 + m_anRandomTable[3] % 4000; @@ -7730,16 +7733,16 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound) if (time > gCellNextTime) { switch (sound) { case SCRIPT_SOUND_POLICE_CELL_BEATING_LOOP_S: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_S; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_S; break; case SCRIPT_SOUND_POLICE_CELL_BEATING_LOOP_L: - m_sQueueSample.m_SoundIntensity = SCRIPT_OBJECT_INTENSITY_L; + m_sQueueSample.m_MaxDistance = SCRIPT_OBJECT_INTENSITY_L; break; default: return; } distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { + if (distSquared < SQR(m_sQueueSample.m_MaxDistance)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); if (m_FrameCounter & 1) sampleIndex = (m_anRandomTable[1] & 3) + SFX_FIGHT_1; @@ -7747,7 +7750,7 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound) sampleIndex = (m_anRandomTable[3] & 1) + SFX_BAT_HIT_LEFT; m_sQueueSample.m_nSampleIndex = sampleIndex; emittingVol = m_anRandomTable[0] % 50 + 55; - m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); @@ -7755,12 +7758,12 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound) m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_bStatic = TRUE; + m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; SET_EMITTING_VOLUME(emittingVol); RESET_LOOP_OFFSETS - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); cPedParams params; @@ -7800,14 +7803,14 @@ cAudioManager::ProcessWeather(int32 id) if (iSound == 4) iSound = 0; m_sQueueSample.m_nCounter = iSound++; - m_sQueueSample.m_nReleasingVolumeModificator = 0; - m_sQueueSample.m_nOffset = (m_anRandomTable[2] & 15) + 55; + m_sQueueSample.m_nPriority = 0; + m_sQueueSample.m_nPan = (m_anRandomTable[2] & 15) + 55; m_sQueueSample.m_bIs2D = TRUE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; SET_EMITTING_VOLUME(m_sQueueSample.m_nVolume); RESET_LOOP_OFFSETS - m_sQueueSample.m_bReverbFlag = FALSE; + m_sQueueSample.m_bReverb = FALSE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -7817,13 +7820,13 @@ cAudioManager::ProcessWeather(int32 id) m_sQueueSample.m_nVolume = (uint8)(25.0f * CWeather::Rain); m_sQueueSample.m_nCounter = 4; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nReleasingVolumeModificator = 0; - m_sQueueSample.m_nOffset = 63; + m_sQueueSample.m_nPriority = 0; + m_sQueueSample.m_nPan = 63; m_sQueueSample.m_bIs2D = TRUE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 30; - m_sQueueSample.m_bReverbFlag = FALSE; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 30; + m_sQueueSample.m_bReverb = FALSE; SET_EMITTING_VOLUME(m_sQueueSample.m_nVolume); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) SET_SOUND_REFLECTION(FALSE); @@ -7994,23 +7997,23 @@ cAudioManager::ProcessFrontEnd() m_sQueueSample.m_nVolume = 110; m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; m_sQueueSample.m_nBankIndex = frontendBank ? SFX_BANK_FRONT_END_MENU : SFX_BANK_0; - m_sQueueSample.m_nReleasingVolumeModificator = 0; + m_sQueueSample.m_nPriority = 0; m_sQueueSample.m_bIs2D = TRUE; SET_EMITTING_VOLUME(m_sQueueSample.m_nVolume); RESET_LOOP_OFFSETS if (stereo) - m_sQueueSample.m_nOffset = m_anRandomTable[0] & 31; + m_sQueueSample.m_nPan = m_anRandomTable[0] & 31; else - m_sQueueSample.m_nOffset = 63; - m_sQueueSample.m_bReverbFlag = FALSE; + m_sQueueSample.m_nPan = 63; + m_sQueueSample.m_bReverb = FALSE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); if (stereo) { ++m_sQueueSample.m_nSampleIndex; m_sQueueSample.m_nCounter = iSound++; - m_sQueueSample.m_nOffset = 127 - m_sQueueSample.m_nOffset; + m_sQueueSample.m_nPan = 127 - m_sQueueSample.m_nPan; AddSampleToRequestedQueue(); } } @@ -8037,16 +8040,16 @@ cAudioManager::ProcessCrane() m_sQueueSample.m_nSampleIndex = SFX_CRANE_MAGNET; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_nPriority = 2; m_sQueueSample.m_nFrequency = 6000; m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(100); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 4.0f; - m_sQueueSample.m_SoundIntensity = intensity; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = intensity; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 3; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -8055,8 +8058,8 @@ cAudioManager::ProcessCrane() m_sQueueSample.m_nSampleIndex = SFX_COL_CAR_2; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COL_CAR_2); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(TRUE); AddSampleToRequestedQueue(); } @@ -8079,38 +8082,38 @@ cAudioManager::ProcessProjectiles() switch (CProjectileInfo::GetProjectileInfo(i)->m_eWeaponType) { case WEAPONTYPE_ROCKETLAUNCHER: emittingVol = MAX_VOLUME; - m_sQueueSample.m_SoundIntensity = rocketLauncherIntensity; + m_sQueueSample.m_MaxDistance = rocketLauncherIntensity; m_sQueueSample.m_nSampleIndex = SFX_ROCKET_FLY; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ROCKET_FLY); - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; break; case WEAPONTYPE_MOLOTOV: emittingVol = molotovVolume; - m_sQueueSample.m_SoundIntensity = molotovIntensity; + m_sQueueSample.m_MaxDistance = molotovIntensity; m_sQueueSample.m_nSampleIndex = SFX_PED_ON_FIRE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = 32 * SampleManager.GetSampleBaseFrequency(SFX_PED_ON_FIRE) / 25; - m_sQueueSample.m_nReleasingVolumeModificator = 7; + m_sQueueSample.m_nPriority = 7; break; default: return; } m_sQueueSample.m_fSpeedMultiplier = 4.0f; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nFramesToPlay = 3; m_sQueueSample.m_vecPos = CProjectileInfo::ms_apProjectile[i]->GetPosition(); float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distSquared < SQR(m_sQueueSample.m_SoundIntensity)) { + if (distSquared < SQR(m_sQueueSample.m_MaxDistance)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); - m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = i; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(emittingVol); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -8160,7 +8163,7 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex) / 2; m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; m_sQueueSample.m_nCounter = iSound++; if (iSound < 32) iSound = 32; @@ -8171,8 +8174,8 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_nCounter = i; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; + m_sQueueSample.m_nFramesToPlay = 3; + m_sQueueSample.m_bStatic = FALSE; } } else { m_sQueueSample.m_nSampleIndex = SFX_GARAGE_DOOR_LOOP; @@ -8180,18 +8183,18 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_nCounter = i; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; + m_sQueueSample.m_nFramesToPlay = 3; + m_sQueueSample.m_bStatic = FALSE; } m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nPriority = 3; SET_EMITTING_VOLUME(90); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -8217,13 +8220,13 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_nFrequency = 18000; } m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nReleasingVolumeModificator = 4; + m_sQueueSample.m_nPriority = 4; SET_EMITTING_VOLUME(60); m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_SoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = SOUND_INTENSITY; + m_sQueueSample.m_bReverb = TRUE; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bStatic = TRUE; m_sQueueSample.m_nLoopCount = 1; RESET_LOOP_OFFSETS m_sQueueSample.m_nCounter = iSound++; @@ -8258,16 +8261,16 @@ cAudioManager::ProcessFireHydrant() m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 4; + m_sQueueSample.m_nPriority = 4; m_sQueueSample.m_nFrequency = 15591; m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(40); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_SoundIntensity = intensity; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_MaxDistance = intensity; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 3; + m_sQueueSample.m_bReverb = TRUE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -8317,16 +8320,16 @@ cAudioManager::ProcessBridgeWarning() m_sQueueSample.m_nSampleIndex = SFX_BRIDGE_OPEN_WARNING; m_sQueueSample.m_nBankIndex = SFX_BANK_GENERIC_EXTRA; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BRIDGE_OPEN_WARNING); m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(100); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_SoundIntensity = 450.0f; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 8; - m_sQueueSample.m_bReverbFlag = FALSE; + m_sQueueSample.m_MaxDistance = 450.0f; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 8; + m_sQueueSample.m_bReverb = FALSE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -8343,16 +8346,16 @@ cAudioManager::ProcessBridgeMotor() m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE; // todo check sfx name m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_nFrequency = 5500; m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(MAX_VOLUME); SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_SoundIntensity = bridgeIntensity; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = FALSE; + m_sQueueSample.m_MaxDistance = bridgeIntensity; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_nFramesToPlay = 3; + m_sQueueSample.m_bReverb = FALSE; AddSampleToRequestedQueue(); } } @@ -8377,15 +8380,15 @@ cAudioManager::ProcessBridgeOneShots() m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopCount = 1; SET_EMITTING_VOLUME(MAX_VOLUME); RESET_LOOP_OFFSETS m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_SoundIntensity = bridgeIntensity; - m_sQueueSample.m_bReleasingSoundFlag = TRUE; - m_sQueueSample.m_bReverbFlag = FALSE; + m_sQueueSample.m_MaxDistance = bridgeIntensity; + m_sQueueSample.m_bStatic = TRUE; + m_sQueueSample.m_bReverb = FALSE; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index a288ac12..1df4681c 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -19,7 +19,7 @@ cAudioManager AudioManager; cAudioManager::cAudioManager() { m_bIsInitialised = FALSE; - m_bReverb = TRUE; + m_bIsSurround = TRUE; m_fSpeedOfSound = SPEED_OF_SOUND / TIME_SPENT; m_nTimeSpent = TIME_SPENT; m_nActiveSamples = NUM_CHANNELS_GENERIC; @@ -40,7 +40,7 @@ cAudioManager::cAudioManager() } m_nAudioEntitiesTotal = 0; m_FrameCounter = 0; - m_bFifthFrameFlag = FALSE; + m_bReduceReleasingPriority = FALSE; m_bTimerJustReset = FALSE; m_nTimer = 0; } @@ -473,7 +473,7 @@ cAudioManager::ServiceSoundEffects() #ifdef FIX_BUGS if(CTimer::GetLogicalFramesPassed() != 0) #endif - m_bFifthFrameFlag = (m_FrameCounter++ % 5) == 0; + m_bReduceReleasingPriority = (m_FrameCounter++ % 5) == 0; if (m_nUserPause && !m_nPreviousUserPause) { for (int32 i = 0; i < NUM_CHANNELS; i++) SampleManager.StopChannel(i); @@ -523,14 +523,14 @@ cAudioManager::FL(float f) } uint8 -cAudioManager::ComputeVolume(uint8 emittingVolume, float soundIntensity, float distance) +cAudioManager::ComputeVolume(uint8 emittingVolume, float maxDistance, float distance) { - float newSoundIntensity; - if (soundIntensity <= 0.0f) + float minDistance; + if (maxDistance <= 0.0f) return 0; - newSoundIntensity = soundIntensity / 5.0f; - if (newSoundIntensity <= distance) - emittingVolume = sq((soundIntensity - newSoundIntensity - (distance - newSoundIntensity)) / (soundIntensity - newSoundIntensity)) * emittingVolume; + minDistance = maxDistance / 5.0f; + if (minDistance <= distance) + emittingVolume = sq((maxDistance - minDistance - (distance - minDistance)) / (maxDistance - minDistance)) * emittingVolume; return emittingVolume; } @@ -605,39 +605,47 @@ cAudioManager::InterrogateAudioEntities() void cAudioManager::AddSampleToRequestedQueue() { - uint32 calculatedVolume; + uint32 finalPriority; uint8 sampleIndex; #ifdef AUDIO_REFLECTIONS bool8 bReflections; #endif if (m_sQueueSample.m_nSampleIndex < TOTAL_AUDIO_SAMPLES) { - calculatedVolume = m_sQueueSample.m_nReleasingVolumeModificator * (MAX_VOLUME - m_sQueueSample.m_nVolume); + finalPriority = m_sQueueSample.m_nPriority * (MAX_VOLUME - m_sQueueSample.m_nVolume); sampleIndex = m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; if (sampleIndex >= m_nActiveSamples) { sampleIndex = m_abSampleQueueIndexTable[m_nActiveSampleQueue][m_nActiveSamples - 1]; - if (m_asSamples[m_nActiveSampleQueue][sampleIndex].m_nCalculatedVolume <= calculatedVolume) + if (m_asSamples[m_nActiveSampleQueue][sampleIndex].m_nFinalPriority <= finalPriority) return; } else { ++m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; } - m_sQueueSample.m_nCalculatedVolume = calculatedVolume; - m_sQueueSample.m_bLoopEnded = FALSE; +#if GTA_VERSION < GTA3_PC_10 + if (m_sQueueSample.m_bStatic) { + if (m_sQueueSample.m_nLoopCount > 0) + m_sQueueSample.unk = m_nTimeSpent * SampleManager.GetSampleLength(m_sQueueSample.m_nSampleIndex) / m_sQueueSample.m_nFrequency; + else + m_sQueueSample.unk = -3; + } +#endif + m_sQueueSample.m_nFinalPriority = finalPriority; + m_sQueueSample.m_bIsPlayingFinished = FALSE; #ifdef AUDIO_REFLECTIONS if (m_sQueueSample.m_bIs2D) { - m_sQueueSample.m_bRequireReflection = FALSE; - m_sQueueSample.m_nLoopsRemaining = 0; + m_sQueueSample.m_bReflections = FALSE; + m_sQueueSample.m_nReflectionDelay = 0; } if (m_bDynamicAcousticModelingStatus && m_sQueueSample.m_nLoopCount > 0) { - bReflections = m_sQueueSample.m_bRequireReflection; + bReflections = m_sQueueSample.m_bReflections; } else { bReflections = FALSE; - m_sQueueSample.m_nLoopsRemaining = 0; + m_sQueueSample.m_nReflectionDelay = 0; } - m_sQueueSample.m_bRequireReflection = FALSE; + m_sQueueSample.m_bReflections = FALSE; if (!m_bDynamicAcousticModelingStatus) - m_sQueueSample.m_bReverbFlag = FALSE; + m_sQueueSample.m_bReverb = FALSE; #endif m_asSamples[m_nActiveSampleQueue][sampleIndex] = m_sQueueSample; @@ -656,8 +664,8 @@ cAudioManager::AddDetailsToRequestedOrderList(uint8 sample) uint32 i = 0; if (sample != 0) { for (; i < sample; i++) { - if (m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]].m_nCalculatedVolume > - m_asSamples[m_nActiveSampleQueue][sample].m_nCalculatedVolume) + if (m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]].m_nFinalPriority > + m_asSamples[m_nActiveSampleQueue][sample].m_nFinalPriority) break; } if (i < sample) { @@ -677,12 +685,12 @@ cAudioManager::AddReflectionsToRequestedQueue() for (uint32 i = 0; i < ARRAY_SIZE(m_afReflectionsDistances); i++) { reflectionDistance = m_afReflectionsDistances[i]; - if (reflectionDistance > 0.0f && reflectionDistance < 100.f && reflectionDistance < m_sQueueSample.m_SoundIntensity) { - m_sQueueSample.m_nLoopsRemaining = (reflectionDistance * 500.f / 1029.f); - if (m_sQueueSample.m_nLoopsRemaining > 5) { + if (reflectionDistance > 0.0f && reflectionDistance < 100.f && reflectionDistance < m_sQueueSample.m_MaxDistance) { + m_sQueueSample.m_nReflectionDelay = (reflectionDistance * 500.f / 1029.f); + if (m_sQueueSample.m_nReflectionDelay > 5) { m_sQueueSample.m_fDistance = m_afReflectionsDistances[i]; SET_EMITTING_VOLUME(emittingVolume); - m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume > emittingVolume / 16) { m_sQueueSample.m_nCounter += (i + 1) * 256; if (m_sQueueSample.m_nLoopCount > 0) { @@ -692,7 +700,7 @@ cAudioManager::AddReflectionsToRequestedQueue() else m_sQueueSample.m_nFrequency += noise; } - m_sQueueSample.m_nReleasingVolumeModificator += 20; + m_sQueueSample.m_nPriority += 20; m_sQueueSample.m_vecPos = m_avecReflectionsPos[i]; AddSampleToRequestedQueue(); } @@ -766,7 +774,7 @@ cAudioManager::AddReleasingSounds() for (int32 i = 0; i < m_SampleRequestQueuesStatus[queue]; i++) { tSound &sample = m_asSamples[queue][m_abSampleQueueIndexTable[queue][i]]; - if (sample.m_bLoopEnded) + if (sample.m_bIsPlayingFinished) continue; toProcess[i] = FALSE; @@ -779,32 +787,44 @@ cAudioManager::AddReleasingSounds() } if (!toProcess[i]) { #ifdef AUDIO_REFLECTIONS - if (sample.m_nCounter <= 255 || sample.m_nLoopsRemaining == 0) // check if not reflection + if (sample.m_nCounter <= 255 || sample.m_nReflectionDelay == 0) // check if not delayed reflection #endif { - if (sample.m_nReleasingVolumeDivider == 0) + if (sample.m_nFramesToPlay == 0) continue; if (sample.m_nLoopCount == 0) { if (sample.m_nVolumeChange == -1) { - sample.m_nVolumeChange = sample.m_nVolume / sample.m_nReleasingVolumeDivider; +#if defined(FIX_BUGS) && defined(EXTERNAL_3D_SOUND) + sample.m_nVolumeChange = sample.m_nEmittingVolume / sample.m_nFramesToPlay; +#else + sample.m_nVolumeChange = sample.m_nVolume / sample.m_nFramesToPlay; +#endif if (sample.m_nVolumeChange <= 0) sample.m_nVolumeChange = 1; } +#if defined(FIX_BUGS) && defined(EXTERNAL_3D_SOUND) + if (sample.m_nEmittingVolume <= sample.m_nVolumeChange) { +#else if (sample.m_nVolume <= sample.m_nVolumeChange) { - sample.m_nReleasingVolumeDivider = 0; +#endif + sample.m_nFramesToPlay = 0; continue; } +#if defined(FIX_BUGS) && defined(EXTERNAL_3D_SOUND) + sample.m_nEmittingVolume -= sample.m_nVolumeChange; +#else sample.m_nVolume -= sample.m_nVolumeChange; +#endif } #ifdef FIX_BUGS if(CTimer::GetLogicalFramesPassed() != 0) #endif - --sample.m_nReleasingVolumeDivider; - if (m_bFifthFrameFlag) { - if (sample.m_nReleasingVolumeModificator < 20) - ++sample.m_nReleasingVolumeModificator; + --sample.m_nFramesToPlay; + if (m_bReduceReleasingPriority) { + if (sample.m_nPriority < 20) + ++sample.m_nPriority; } - sample.m_bReleasingSoundFlag = 0; + sample.m_bStatic = FALSE; } memcpy(&m_sQueueSample, &sample, sizeof(tSound)); AddSampleToRequestedQueue(); @@ -834,8 +854,8 @@ cAudioManager::ProcessActiveQueues() CVector position; for (int32 i = 0; i < m_nActiveSamples; i++) { - m_asSamples[m_nActiveSampleQueue][i].m_bIsProcessed = FALSE; - m_asActiveSamples[i].m_bIsProcessed = FALSE; + m_asSamples[m_nActiveSampleQueue][i].m_bIsBeingPlayed = FALSE; + m_asActiveSamples[i].m_bIsBeingPlayed = FALSE; } for (int32 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) { @@ -845,23 +865,30 @@ cAudioManager::ProcessActiveQueues() if (sample.m_nEntityIndex == m_asActiveSamples[j].m_nEntityIndex && sample.m_nCounter == m_asActiveSamples[j].m_nCounter && sample.m_nSampleIndex == m_asActiveSamples[j].m_nSampleIndex) { if (sample.m_nLoopCount > 0) { +#if GTA_VERSION >= GTA3_PC_10 if (m_FrameCounter & 1) flag = !!(j & 1); else flag = !(j & 1); - if (flag && !SampleManager.GetChannelUsedFlag(j)) { - sample.m_bLoopEnded = TRUE; - m_asActiveSamples[j].m_bLoopEnded = TRUE; +#else + if (m_asActiveSamples[j].unk != 0) + m_asActiveSamples[j].unk--; + else if (SampleManager.GetChannelUsedFlag(j)) + m_asActiveSamples[j].unk = m_nTimeSpent * SampleManager.GetSampleLength(m_asActiveSamples[j].m_nSampleIndex) / m_asActiveSamples[j].m_nFrequency; + else { +#endif + sample.m_bIsPlayingFinished = TRUE; + m_asActiveSamples[j].m_bIsPlayingFinished = TRUE; m_asActiveSamples[j].m_nSampleIndex = NO_SAMPLE; m_asActiveSamples[j].m_nEntityIndex = AEHANDLE_NONE; continue; } } - sample.m_bIsProcessed = TRUE; - m_asActiveSamples[j].m_bIsProcessed = TRUE; + sample.m_bIsBeingPlayed = TRUE; + m_asActiveSamples[j].m_bIsBeingPlayed = TRUE; sample.m_nVolumeChange = -1; - if (!sample.m_bReleasingSoundFlag) { + if (!sample.m_bStatic) { if (sample.m_bIs2D) { #ifdef EXTERNAL_3D_SOUND emittingVol = m_bDoubleVolume ? 2 * Min(63, sample.m_nEmittingVolume) : sample.m_nEmittingVolume; @@ -872,7 +899,7 @@ cAudioManager::ProcessActiveQueues() #ifdef EXTERNAL_3D_SOUND SampleManager.SetChannelEmittingVolume(j, emittingVol); #else - SampleManager.SetChannelPan(j, sample.m_nOffset); + SampleManager.SetChannelPan(j, sample.m_nPan); SampleManager.SetChannelVolume(j, sample.m_nVolume); #endif } else { @@ -902,23 +929,23 @@ cAudioManager::ProcessActiveQueues() TranslateEntity(&sample.m_vecPos, &position); #ifdef EXTERNAL_3D_SOUND SampleManager.SetChannel3DPosition(j, position.x, position.y, position.z); - SampleManager.SetChannel3DDistances(j, sample.m_SoundIntensity, 0.25f * sample.m_SoundIntensity); + SampleManager.SetChannel3DDistances(j, sample.m_MaxDistance, 0.25f * sample.m_MaxDistance); #else - sample.m_nOffset = ComputePan(sample.m_fDistance, &position); - SampleManager.SetChannelPan(j, sample.m_nOffset); + sample.m_nPan = ComputePan(sample.m_fDistance, &position); + SampleManager.SetChannelPan(j, sample.m_nPan); #endif } - SampleManager.SetChannelReverbFlag(j, sample.m_bReverbFlag); + SampleManager.SetChannelReverbFlag(j, sample.m_bReverb); break; } - sample.m_bIsProcessed = FALSE; - m_asActiveSamples[j].m_bIsProcessed = FALSE; + sample.m_bIsBeingPlayed = FALSE; + m_asActiveSamples[j].m_bIsBeingPlayed = FALSE; } } } } for (int32 i = 0; i < m_nActiveSamples; i++) { - if (m_asActiveSamples[i].m_nSampleIndex != NO_SAMPLE && !m_asActiveSamples[i].m_bIsProcessed) { + if (m_asActiveSamples[i].m_nSampleIndex != NO_SAMPLE && !m_asActiveSamples[i].m_bIsBeingPlayed) { SampleManager.StopChannel(i); m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE; m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE; @@ -926,28 +953,28 @@ cAudioManager::ProcessActiveQueues() } for (uint8 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) { tSound &sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]]; - if (!sample.m_bIsProcessed && !sample.m_bLoopEnded && m_asAudioEntities[sample.m_nEntityIndex].m_bIsUsed && sample.m_nSampleIndex < NO_SAMPLE) { + if (!sample.m_bIsBeingPlayed && !sample.m_bIsPlayingFinished && m_asAudioEntities[sample.m_nEntityIndex].m_bIsUsed && sample.m_nSampleIndex < NO_SAMPLE) { #ifdef AUDIO_REFLECTIONS - if (sample.m_nCounter > 255 && sample.m_nLoopCount > 0 && sample.m_nLoopsRemaining > 0) { // check if reflection - sample.m_nLoopsRemaining--; - sample.m_nReleasingVolumeDivider = 1; + if (sample.m_nCounter > 255 && sample.m_nLoopCount > 0 && sample.m_nReflectionDelay > 0) { // check if reflection + sample.m_nReflectionDelay--; + sample.m_nFramesToPlay = 1; } else #endif { for (uint8 j = 0; j < m_nActiveSamples; j++) { - if (!m_asActiveSamples[j].m_bIsProcessed) { + if (!m_asActiveSamples[j].m_bIsBeingPlayed) { if (sample.m_nLoopCount > 0) { samplesPerFrame = sample.m_nFrequency / m_nTimeSpent; samplesToPlay = sample.m_nLoopCount * SampleManager.GetSampleLength(sample.m_nSampleIndex); if (samplesPerFrame == 0) continue; - sample.m_nReleasingVolumeDivider = samplesToPlay / samplesPerFrame + 1; + sample.m_nFramesToPlay = samplesToPlay / samplesPerFrame + 1; } memcpy(&m_asActiveSamples[j], &sample, sizeof(tSound)); if (!m_asActiveSamples[j].m_bIs2D) { TranslateEntity(&m_asActiveSamples[j].m_vecPos, &position); #ifndef EXTERNAL_3D_SOUND - m_asActiveSamples[j].m_nOffset = ComputePan(m_asActiveSamples[j].m_fDistance, &position); + m_asActiveSamples[j].m_nPan = ComputePan(m_asActiveSamples[j].m_fDistance, &position); #endif } #ifdef EXTERNAL_3D_SOUND @@ -966,16 +993,16 @@ cAudioManager::ProcessActiveQueues() SampleManager.SetChannelEmittingVolume(j, emittingVol); #else SampleManager.SetChannelVolume(j, emittingVol); - SampleManager.SetChannelPan(j, m_asActiveSamples[j].m_nOffset); + SampleManager.SetChannelPan(j, m_asActiveSamples[j].m_nPan); #endif #ifndef GTA_PS2 SampleManager.SetChannelLoopPoints(j, m_asActiveSamples[j].m_nLoopStart, m_asActiveSamples[j].m_nLoopEnd); SampleManager.SetChannelLoopCount(j, m_asActiveSamples[j].m_nLoopCount); #endif - SampleManager.SetChannelReverbFlag(j, m_asActiveSamples[j].m_bReverbFlag); + SampleManager.SetChannelReverbFlag(j, m_asActiveSamples[j].m_bReverb); #ifdef EXTERNAL_3D_SOUND if (m_asActiveSamples[j].m_bIs2D) { - uint8 offset = m_asActiveSamples[j].m_nOffset; + uint8 offset = m_asActiveSamples[j].m_nPan; if (offset == 63) x = 0.f; else if (offset >= 63) @@ -985,19 +1012,19 @@ cAudioManager::ProcessActiveQueues() usedX = x; usedY = 0.0f; usedZ = 0.0f; - m_asActiveSamples[j].m_SoundIntensity = 100000.0f; + m_asActiveSamples[j].m_MaxDistance = 100000.0f; } else { usedX = position.x; usedY = position.y; usedZ = position.z; } SampleManager.SetChannel3DPosition(j, usedX, usedY, usedZ); - SampleManager.SetChannel3DDistances(j, m_asActiveSamples[j].m_SoundIntensity, 0.25f * m_asActiveSamples[j].m_SoundIntensity); + SampleManager.SetChannel3DDistances(j, m_asActiveSamples[j].m_MaxDistance, 0.25f * m_asActiveSamples[j].m_MaxDistance); #endif SampleManager.StartChannel(j); } - m_asActiveSamples[j].m_bIsProcessed = TRUE; - sample.m_bIsProcessed = TRUE; + m_asActiveSamples[j].m_bIsBeingPlayed = TRUE; + sample.m_bIsBeingPlayed = TRUE; sample.m_nVolumeChange = -1; break; } @@ -1025,35 +1052,35 @@ cAudioManager::ClearActiveSamples() m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE; m_asActiveSamples[i].m_nBankIndex = INVALID_SFX_BANK; m_asActiveSamples[i].m_bIs2D = FALSE; - m_asActiveSamples[i].m_nReleasingVolumeModificator = 5; + m_asActiveSamples[i].m_nPriority = 5; m_asActiveSamples[i].m_nFrequency = 0; m_asActiveSamples[i].m_nVolume = 0; #ifdef EXTERNAL_3D_SOUND m_asActiveSamples[i].m_nEmittingVolume = 0; #endif m_asActiveSamples[i].m_fDistance = 0.0f; - m_asActiveSamples[i].m_bIsProcessed = FALSE; - m_asActiveSamples[i].m_bLoopEnded = FALSE; + m_asActiveSamples[i].m_bIsBeingPlayed = FALSE; + m_asActiveSamples[i].m_bIsPlayingFinished = FALSE; m_asActiveSamples[i].m_nLoopCount = 1; #ifndef GTA_PS2 m_asActiveSamples[i].m_nLoopStart = 0; m_asActiveSamples[i].m_nLoopEnd = -1; #endif m_asActiveSamples[i].m_fSpeedMultiplier = 0.0f; - m_asActiveSamples[i].m_SoundIntensity = 200.0f; - m_asActiveSamples[i].m_nOffset = 63; - m_asActiveSamples[i].m_bReleasingSoundFlag = FALSE; + m_asActiveSamples[i].m_MaxDistance = 200.0f; + m_asActiveSamples[i].m_nPan = 63; + m_asActiveSamples[i].m_bStatic = FALSE; #if GTA_VERSION < GTA3_PC_10 m_asActiveSamples[i].unk = -3; #endif - m_asActiveSamples[i].m_nCalculatedVolume = 0; - m_asActiveSamples[i].m_nReleasingVolumeDivider = 0; + m_asActiveSamples[i].m_nFinalPriority = 0; + m_asActiveSamples[i].m_nFramesToPlay = 0; m_asActiveSamples[i].m_nVolumeChange = -1; m_asActiveSamples[i].m_vecPos = CVector(0.0f, 0.0f, 0.0f); - m_asActiveSamples[i].m_bReverbFlag = FALSE; + m_asActiveSamples[i].m_bReverb = FALSE; #ifdef AUDIO_REFLECTIONS - m_asActiveSamples[i].m_nLoopsRemaining = 0; - m_asActiveSamples[i].m_bRequireReflection = FALSE; + m_asActiveSamples[i].m_nReflectionDelay = 0; + m_asActiveSamples[i].m_bReflections = FALSE; #endif } } @@ -1081,7 +1108,7 @@ cAudioManager::AdjustSamplesVolume() tSound *pSample = &m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]]; if (!pSample->m_bIs2D) - pSample->m_nEmittingVolume = ComputeEmittingVolume(pSample->m_nEmittingVolume, pSample->m_SoundIntensity, pSample->m_fDistance); + pSample->m_nEmittingVolume = ComputeEmittingVolume(pSample->m_nEmittingVolume, pSample->m_MaxDistance, pSample->m_fDistance); } } diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index ed920cab..662e929e 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -7,49 +7,59 @@ class tSound { public: - int32 m_nEntityIndex; + int32 m_nEntityIndex; // audio entity index #if GTA_VERSION >= GTA3_PC_10 - uint32 m_nCounter; + uint32 m_nCounter; // I'm not sure what this is but it looks like a virtual counter to determine the same sound in queue + // Values higher than 255 are used by reflections #else uint8 m_nCounter; #endif - uint32 m_nSampleIndex; - uint8 m_nBankIndex; - bool8 m_bIs2D; - uint32 m_nReleasingVolumeModificator; - uint32 m_nFrequency; - uint8 m_nVolume; - float m_fDistance; - uint32 m_nLoopCount; + uint32 m_nSampleIndex; // An index of sample from AudioSamples.h + uint8 m_nBankIndex; // A sound bank index. IDK what's the point of it here since samples are hardcoded anyway + bool8 m_bIs2D; // If TRUE then sound is played in 2D space (such as frontend or police radio) + uint32 m_nPriority; // The multiplier for the sound priority (see m_nFinalPriority below). Lesser value means higher priority + uint32 m_nFrequency; // Sound frequency, plain and simple + uint8 m_nVolume; // Sound volume (0..127), only used as an actual volume without EXTERNAL_3D_SOUND (see m_nEmittingVolume) + float m_fDistance; // Distance to camera (useless if m_bIs2D == TRUE) + uint32 m_nLoopCount; // 0 - always loop, 1 - don't loop, other values never seen #ifndef GTA_PS2 + // Loop offsets uint32 m_nLoopStart; int32 m_nLoopEnd; #endif #ifdef EXTERNAL_3D_SOUND - uint8 m_nEmittingVolume; + uint8 m_nEmittingVolume; // The volume in 3D space, provided to 3D audio engine #endif - float m_fSpeedMultiplier; + float m_fSpeedMultiplier; // Used for doppler effect. 0.0f - unaffected by doppler #if GTA_VERSION >= GTA3_PC_10 - float m_SoundIntensity; + float m_MaxDistance; // The maximum distance at which sound could be heard. Minimum distance = MaxDistance / 5 or MaxDistance / 4 in case of emitting volume (useless if m_bIs2D == TRUE) #else - uint32 m_SoundIntensity; + uint32 m_MaxDistance; #endif - bool8 m_bReleasingSoundFlag; - CVector m_vecPos; - bool8 m_bReverbFlag; + bool8 m_bStatic; // If TRUE then sound parameters cannot be changed during playback (frequency, position, etc.) + CVector m_vecPos; // Position of sound in 3D space. Unused if m_bIs2D == TRUE + bool8 m_bReverb; // Toggles reverb effect #ifdef AUDIO_REFLECTIONS - uint8 m_nLoopsRemaining; - bool8 m_bRequireReflection; // Used for oneshots + uint8 m_nReflectionDelay; // Number of frames before reflection could be played. This is calculated internally by AudioManager and shouldn't be set by queued sample + bool8 m_bReflections; // Add sound reflections #endif - uint8 m_nOffset; - uint32 m_nReleasingVolumeDivider; - bool8 m_bIsProcessed; - bool8 m_bLoopEnded; + uint8 m_nPan; // Sound panning (0-127). Controls the volume of the playback coming from left and right speaker. Calculated internally unless m_bIs2D==TRUE. + // 0 = L 100% R 0% + // 63 = L 100% R 100% + // 127 = L 0% R 100% + uint32 m_nFramesToPlay; // Number of frames the sound would be played (if it stops being queued). + // This one is being set by queued sample for looping sounds, otherwise calculated inside AudioManager + + // all fields below are internal to AudioManager calculations and aren't set by queued sample + bool8 m_bIsBeingPlayed; // Set to TRUE when the sound was added or changed on current frame to avoid it being overwritten + bool8 m_bIsPlayingFinished; // Not sure about the name. Set to TRUE when sampman channel becomes free #if GTA_VERSION < GTA3_PC_10 - int32 unk; // only on PS2, seems unused + int32 unk; // Only on PS2, used by static non-looped sounds (AFAIK) + // Looks like it's keeping a number of frames left to play with the purpose of setting m_bIsPlayingFinished=TRUE once value reaches 0 + // Default value is -3 for whatever reason #endif - uint32 m_nCalculatedVolume; - int8 m_nVolumeChange; + uint32 m_nFinalPriority; // Actual value used to compare priority, calculated using volume and m_nPriority. Lesser value means higher priority + int8 m_nVolumeChange; // How much m_nVolume should reduce per each frame. Has no effect with EXTERNAL_3D_SOUND }; VALIDATE_SIZE(tSound, 92); @@ -208,8 +218,8 @@ class cAudioManager { public: bool8 m_bIsInitialised; - bool8 m_bReverb; // unused - bool8 m_bFifthFrameFlag; + bool8 m_bIsSurround; // unused until VC + bool8 m_bReduceReleasingPriority; uint8 m_nActiveSamples; bool8 m_bDoubleVolume; // unused #if GTA_VERSION >= GTA3_PC_10 @@ -288,7 +298,7 @@ public: void ServiceSoundEffects(); uint32 FL(float f); // not used - uint8 ComputeVolume(uint8 emittingVolume, float soundIntensity, float distance); + uint8 ComputeVolume(uint8 emittingVolume, float maxDistance, float distance); void TranslateEntity(Const CVector *v1, CVector *v2); int32 ComputePan(float, CVector *); uint32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, float speedMultiplier); // inlined on PS2 @@ -309,7 +319,7 @@ public: #ifdef EXTERNAL_3D_SOUND // actually must have been && AUDIO_MSS as well void AdjustSamplesVolume(); - uint8 ComputeEmittingVolume(uint8 emittingVolume, float intensity, float dist); + uint8 ComputeEmittingVolume(uint8 emittingVolume, float maxDistance, float dist); #endif // audio logic @@ -553,7 +563,7 @@ public: #define SET_EMITTING_VOLUME(vol) #endif #ifdef AUDIO_REFLECTIONS -#define SET_SOUND_REFLECTION(b) m_sQueueSample.m_bRequireReflection = b +#define SET_SOUND_REFLECTION(b) m_sQueueSample.m_bReflections = b #else #define SET_SOUND_REFLECTION(b) #endif diff --git a/src/audio/PolRadio.cpp b/src/audio/PolRadio.cpp index b1460b3c..76a87137 100644 --- a/src/audio/PolRadio.cpp +++ b/src/audio/PolRadio.cpp @@ -129,16 +129,16 @@ cAudioManager::DoPoliceRadioCrackle() m_sQueueSample.m_nSampleIndex = SFX_POLICE_RADIO_CRACKLE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = TRUE; - m_sQueueSample.m_nReleasingVolumeModificator = 10; + m_sQueueSample.m_nPriority = 10; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_POLICE_RADIO_CRACKLE); m_sQueueSample.m_nVolume = m_anRandomTable[2] % 20 + 15; m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(m_sQueueSample.m_nVolume); SET_LOOP_OFFSETS(SFX_POLICE_RADIO_CRACKLE) - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_bReverbFlag = FALSE; - m_sQueueSample.m_nOffset = 63; - m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_bStatic = FALSE; + m_sQueueSample.m_bReverb = FALSE; + m_sQueueSample.m_nPan = 63; + m_sQueueSample.m_nFramesToPlay = 3; SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } -- cgit v1.2.3 From ef0b5f857db7b58a9bea62c68e89e17f45c0a0de Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 20 Aug 2021 14:28:18 +0300 Subject: A few small audio changes --- src/audio/AudioManager.cpp | 10 +++++----- src/audio/AudioManager.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 1df4681c..425a897d 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -1113,12 +1113,12 @@ cAudioManager::AdjustSamplesVolume() } uint8 -cAudioManager::ComputeEmittingVolume(uint8 emittingVolume, float intensity, float dist) +cAudioManager::ComputeEmittingVolume(uint8 emittingVolume, float maxDistance, float distance) { - float quatIntensity = intensity / 4.0f; - float diffIntensity = intensity - quatIntensity; - if (dist > diffIntensity) - return (quatIntensity - (dist - diffIntensity)) * (float)emittingVolume / quatIntensity; + float minDistance = maxDistance / 4.0f; + float diffDistance = maxDistance - minDistance; + if (distance > diffDistance) + return (minDistance - (distance - diffDistance)) * (float)emittingVolume / minDistance; return emittingVolume; } #endif diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 662e929e..efff4f39 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -59,7 +59,7 @@ public: // Default value is -3 for whatever reason #endif uint32 m_nFinalPriority; // Actual value used to compare priority, calculated using volume and m_nPriority. Lesser value means higher priority - int8 m_nVolumeChange; // How much m_nVolume should reduce per each frame. Has no effect with EXTERNAL_3D_SOUND + int8 m_nVolumeChange; // How much m_nVolume should reduce per each frame. }; VALIDATE_SIZE(tSound, 92); @@ -319,7 +319,7 @@ public: #ifdef EXTERNAL_3D_SOUND // actually must have been && AUDIO_MSS as well void AdjustSamplesVolume(); - uint8 ComputeEmittingVolume(uint8 emittingVolume, float maxDistance, float dist); + uint8 ComputeEmittingVolume(uint8 emittingVolume, float maxDistance, float distance); #endif // audio logic -- cgit v1.2.3 From aa104bb0aa3ede08e24358ec80ce1b97baf950e9 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Fri, 20 Aug 2021 17:49:51 +0300 Subject: small refactoring --- src/control/CarCtrl.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index ca83603f..fe776a38 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -773,14 +773,16 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle) delete pVehicle; return; } - if (pVehicle->GetStatus() != STATUS_WRECKED || pVehicle->m_nTimeOfDeath == 0) - return; - if (CTimer::GetTimeInMilliseconds() > pVehicle->m_nTimeOfDeath + 60000 && - !(pVehicle->GetIsOnScreen() && CRenderer::IsEntityCullZoneVisible(pVehicle)) ){ - if ((pVehicle->GetPosition() - vecPlayerPos).MagnitudeSqr() > SQR(7.5f)){ - if (!CGarages::IsPointWithinHideOutGarage(pVehicle->GetPosition())){ - CWorld::Remove(pVehicle); - delete pVehicle; + if (pVehicle->GetStatus() == STATUS_WRECKED) { + if (pVehicle->m_nTimeOfDeath != 0) { + if (CTimer::GetTimeInMilliseconds() > pVehicle->m_nTimeOfDeath + 60000 && + !(pVehicle->GetIsOnScreen() && CRenderer::IsEntityCullZoneVisible(pVehicle))) { + if ((pVehicle->GetPosition() - vecPlayerPos).MagnitudeSqr() > SQR(7.5f)) { + if (!CGarages::IsPointWithinHideOutGarage(pVehicle->GetPosition())) { + CWorld::Remove(pVehicle); + delete pVehicle; + } + } } } } -- cgit v1.2.3 From 7d5b1e6c2e19fb88f2adc57e9b4736886b0c299a Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Fri, 20 Aug 2021 20:38:24 +0300 Subject: fix --- src/control/CarCtrl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index fe776a38..2085681a 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -810,8 +810,8 @@ CCarCtrl::UpdateCarOnRails(CVehicle* pVehicle) pVehicle->AutoPilot.ModifySpeed(0.0f); if (CTimer::GetTimeInMilliseconds() > pVehicle->AutoPilot.m_nTempAction){ pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE; - pVehicle->AutoPilot.m_nAntiReverseTimer = 0; - pVehicle->AutoPilot.m_nTimeToStartMission = 0; + pVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds(); + pVehicle->AutoPilot.m_nTimeToStartMission = CTimer::GetTimeInMilliseconds(); } return; } -- cgit v1.2.3 From b683c047dc879ad313070397e28b77b3dcd4b44d Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 21 Aug 2021 12:18:11 +0300 Subject: Remove cMissionAudio, move cAMCrime array outside of cPoliceRadioQueue (R* vision) --- src/audio/AudioLogic.cpp | 110 +++++++++++++++++++++++------------------------ src/audio/AudioManager.h | 32 ++++++-------- src/audio/PolRadio.cpp | 84 ++++++++++++++++-------------------- src/audio/PolRadio.h | 48 +++++++++++++++------ 4 files changed, 141 insertions(+), 133 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index b1f269ec..d09352be 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -154,13 +154,13 @@ cAudioManager::PostInitialiseGameSpecificSetup() if (m_nBridgeEntity >= 0) SetEntityStatus(m_nBridgeEntity, TRUE); - m_sMissionAudio.m_nSampleIndex = NO_SAMPLE; - m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_NOT_LOADED; - m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_STOPPED; - m_sMissionAudio.m_bIsPlaying = FALSE; - m_sMissionAudio.m_bIsPlayed = FALSE; - m_sMissionAudio.m_bPredefinedProperties = TRUE; - m_sMissionAudio.m_nMissionAudioCounter = 0; + m_nMissionAudioSampleIndex = NO_SAMPLE; + m_nMissionAudioLoadingStatus = LOADING_STATUS_NOT_LOADED; + m_nMissionAudioPlayStatus = PLAY_STATUS_STOPPED; + m_bIsMissionAudioPlaying = FALSE; + m_bIsMissionAudioAllowedToPlay = FALSE; + m_bIsMissionAudio2D = TRUE; + m_nMissionAudioFramesToPlay = 0; ResetAudioLogicTimers(CTimer::GetTimeInMilliseconds()); } @@ -8479,14 +8479,14 @@ cAudioManager::PreloadMissionAudio(Const char *name) if (m_bIsInitialised) { int32 missionAudioSfx = FindMissionAudioSfx(name); if (missionAudioSfx != NO_SAMPLE) { - m_sMissionAudio.m_nSampleIndex = missionAudioSfx; - m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_NOT_LOADED; - m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_STOPPED; - m_sMissionAudio.m_bIsPlaying = FALSE; - m_sMissionAudio.m_nMissionAudioCounter = m_nTimeSpent * SampleManager.GetStreamedFileLength(missionAudioSfx) / 1000; - m_sMissionAudio.m_nMissionAudioCounter *= 4; - m_sMissionAudio.m_bIsPlayed = FALSE; - m_sMissionAudio.m_bPredefinedProperties = TRUE; + m_nMissionAudioSampleIndex = missionAudioSfx; + m_nMissionAudioLoadingStatus = LOADING_STATUS_NOT_LOADED; + m_nMissionAudioPlayStatus = PLAY_STATUS_STOPPED; + m_bIsMissionAudioPlaying = FALSE; + m_nMissionAudioFramesToPlay = m_nTimeSpent * SampleManager.GetStreamedFileLength(missionAudioSfx) / 1000; + m_nMissionAudioFramesToPlay *= 4; + m_bIsMissionAudioAllowedToPlay = FALSE; + m_bIsMissionAudio2D = TRUE; g_bMissionAudioLoadFailed = FALSE; } } @@ -8496,7 +8496,7 @@ uint8 cAudioManager::GetMissionAudioLoadingStatus() { if (m_bIsInitialised) - return m_sMissionAudio.m_nLoadingStatus; + return m_nMissionAudioLoadingStatus; return LOADING_STATUS_LOADED; } @@ -8505,24 +8505,24 @@ void cAudioManager::SetMissionAudioLocation(float x, float y, float z) { if (m_bIsInitialised) { - m_sMissionAudio.m_bPredefinedProperties = FALSE; - m_sMissionAudio.m_vecPos = CVector(x, y, z); + m_bIsMissionAudio2D = FALSE; + m_vecMissionAudioPosition = CVector(x, y, z); } } void cAudioManager::PlayLoadedMissionAudio() { - if (m_bIsInitialised && m_sMissionAudio.m_nSampleIndex != NO_SAMPLE && m_sMissionAudio.m_nLoadingStatus == LOADING_STATUS_LOADED && - m_sMissionAudio.m_nPlayStatus == PLAY_STATUS_STOPPED) - m_sMissionAudio.m_bIsPlayed = TRUE; + if (m_bIsInitialised && m_nMissionAudioSampleIndex != NO_SAMPLE && m_nMissionAudioLoadingStatus == LOADING_STATUS_LOADED && + m_nMissionAudioPlayStatus == PLAY_STATUS_STOPPED) + m_bIsMissionAudioAllowedToPlay = TRUE; } bool8 cAudioManager::IsMissionAudioSampleFinished() { if (m_bIsInitialised) - return m_sMissionAudio.m_nPlayStatus == PLAY_STATUS_FINISHED; + return m_nMissionAudioPlayStatus == PLAY_STATUS_FINISHED; static int32 cPretendFrame = 1; @@ -8533,13 +8533,13 @@ void cAudioManager::ClearMissionAudio() { if (m_bIsInitialised) { - m_sMissionAudio.m_nSampleIndex = NO_SAMPLE; - m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_NOT_LOADED; - m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_STOPPED; - m_sMissionAudio.m_bIsPlaying = FALSE; - m_sMissionAudio.m_bIsPlayed = FALSE; - m_sMissionAudio.m_bPredefinedProperties = TRUE; - m_sMissionAudio.m_nMissionAudioCounter = 0; + m_nMissionAudioSampleIndex = NO_SAMPLE; + m_nMissionAudioLoadingStatus = LOADING_STATUS_NOT_LOADED; + m_nMissionAudioPlayStatus = PLAY_STATUS_STOPPED; + m_bIsMissionAudioPlaying = FALSE; + m_bIsMissionAudioAllowedToPlay = FALSE; + m_bIsMissionAudio2D = TRUE; + m_nMissionAudioFramesToPlay = 0; } } @@ -8557,16 +8557,16 @@ cAudioManager::ProcessMissionAudio() static uint8 nFramesForPretendPlaying = 0; if (!m_bIsInitialised) return; - if (m_sMissionAudio.m_nSampleIndex == NO_SAMPLE) return; + if (m_nMissionAudioSampleIndex == NO_SAMPLE) return; - switch (m_sMissionAudio.m_nLoadingStatus) { + switch (m_nMissionAudioLoadingStatus) { case LOADING_STATUS_NOT_LOADED: - SampleManager.PreloadStreamedFile(m_sMissionAudio.m_nSampleIndex, 1); - m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_LOADED; + SampleManager.PreloadStreamedFile(m_nMissionAudioSampleIndex, 1); + m_nMissionAudioLoadingStatus = LOADING_STATUS_LOADED; nFramesUntilFailedLoad = 0; break; case LOADING_STATUS_LOADED: - if (!m_sMissionAudio.m_bIsPlayed) + if (!m_bIsMissionAudioAllowedToPlay) return; if (g_bMissionAudioLoadFailed) { if (m_bTimerJustReset) { @@ -8577,39 +8577,39 @@ cAudioManager::ProcessMissionAudio() nFramesUntilFailedLoad = 0; } else if (!m_nUserPause) { if (++nFramesForPretendPlaying < 120) { - m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_PLAYING; + m_nMissionAudioPlayStatus = PLAY_STATUS_PLAYING; } else { - m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_FINISHED; - m_sMissionAudio.m_nSampleIndex = NO_SAMPLE; + m_nMissionAudioPlayStatus = PLAY_STATUS_FINISHED; + m_nMissionAudioSampleIndex = NO_SAMPLE; } } break; } - switch (m_sMissionAudio.m_nPlayStatus) { + switch (m_nMissionAudioPlayStatus) { case PLAY_STATUS_STOPPED: - if (MissionScriptAudioUsesPoliceChannel(m_sMissionAudio.m_nSampleIndex)) { - SetMissionScriptPoliceAudio(m_sMissionAudio.m_nSampleIndex); + if (MissionScriptAudioUsesPoliceChannel(m_nMissionAudioSampleIndex)) { + SetMissionScriptPoliceAudio(m_nMissionAudioSampleIndex); } else { if (m_nUserPause) SampleManager.PauseStream(TRUE, 1); - if (m_sMissionAudio.m_bPredefinedProperties) { + if (m_bIsMissionAudio2D) { SampleManager.SetStreamedVolumeAndPan(80, 63, TRUE, 1); } else { - distSquared = GetDistanceSquared(m_sMissionAudio.m_vecPos); + distSquared = GetDistanceSquared(m_vecMissionAudioPosition); if (distSquared >= SQR(50.0f)) { emittingVol = 0; pan = 63; } else { dist = Sqrt(distSquared); emittingVol = ComputeVolume(80, 50.0f, dist); - TranslateEntity(&m_sMissionAudio.m_vecPos, &vec); + TranslateEntity(&m_vecMissionAudioPosition, &vec); pan = ComputePan(50.f, &vec); } SampleManager.SetStreamedVolumeAndPan(emittingVol, pan, TRUE, 1); } SampleManager.StartPreloadedStreamedFile(1); } - m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_PLAYING; + m_nMissionAudioPlayStatus = PLAY_STATUS_PLAYING; nCheckPlayingDelay = 30; break; case PLAY_STATUS_PLAYING: @@ -8618,28 +8618,28 @@ cAudioManager::ProcessMissionAudio() SampleManager.StopStreamedFile(1); break; } - if (MissionScriptAudioUsesPoliceChannel(m_sMissionAudio.m_nSampleIndex)) { + if (MissionScriptAudioUsesPoliceChannel(m_nMissionAudioSampleIndex)) { if (!m_nUserPause) { if (nCheckPlayingDelay) { --nCheckPlayingDelay; - } else if (GetMissionScriptPoliceAudioPlayingStatus() == PLAY_STATUS_FINISHED || m_sMissionAudio.m_nMissionAudioCounter-- == 0) { - m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_FINISHED; - m_sMissionAudio.m_nSampleIndex = NO_SAMPLE; + } else if (GetMissionScriptPoliceAudioPlayingStatus() == PLAY_STATUS_FINISHED || m_nMissionAudioFramesToPlay-- == 0) { + m_nMissionAudioPlayStatus = PLAY_STATUS_FINISHED; + m_nMissionAudioSampleIndex = NO_SAMPLE; SampleManager.StopStreamedFile(1); - m_sMissionAudio.m_nMissionAudioCounter = 0; + m_nMissionAudioFramesToPlay = 0; } } - } else if (m_sMissionAudio.m_bIsPlaying) { + } else if (m_bIsMissionAudioPlaying) { if (SampleManager.IsStreamPlaying(1) || m_nUserPause || m_nPreviousUserPause) { if (m_nUserPause) SampleManager.PauseStream(TRUE, 1); else SampleManager.PauseStream(FALSE, 1); } else { - m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_FINISHED; - m_sMissionAudio.m_nSampleIndex = NO_SAMPLE; + m_nMissionAudioPlayStatus = PLAY_STATUS_FINISHED; + m_nMissionAudioSampleIndex = NO_SAMPLE; SampleManager.StopStreamedFile(1); - m_sMissionAudio.m_nMissionAudioCounter = 0; + m_nMissionAudioFramesToPlay = 0; } } else { if (m_nUserPause) @@ -8649,7 +8649,7 @@ cAudioManager::ProcessMissionAudio() break; nCheckPlayingDelay = 0; } - m_sMissionAudio.m_bIsPlaying = TRUE; + m_bIsMissionAudioPlaying = TRUE; } break; default: @@ -8661,7 +8661,7 @@ cAudioManager::ProcessMissionAudio() nFramesForPretendPlaying = 0; g_bMissionAudioLoadFailed = TRUE; nFramesUntilFailedLoad = 0; - m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_LOADED; + m_nMissionAudioLoadingStatus = LOADING_STATUS_LOADED; } break; default: diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index efff4f39..39fa9288 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -123,22 +123,6 @@ public: VALIDATE_SIZE(cPedComments, 1164); -class CEntity; - -class cMissionAudio -{ -public: - CVector m_vecPos; - bool8 m_bPredefinedProperties; - uint32 m_nSampleIndex; - uint8 m_nLoadingStatus; - uint8 m_nPlayStatus; - bool8 m_bIsPlaying; - int32 m_nMissionAudioCounter; - bool8 m_bIsPlayed; -}; -VALIDATE_SIZE(cMissionAudio, 32); - // name made up class cAudioScriptObjectManager { @@ -152,6 +136,7 @@ public: class cTransmission; +class CEntity; class CPlane; class CVehicle; class CPed; @@ -247,12 +232,23 @@ public: int32 m_nWaterCannonEntity; int32 m_nPoliceChannelEntity; cPoliceRadioQueue m_sPoliceRadioQueue; + cAMCrime m_aCrimes[10]; int32 m_nFrontEndEntity; int32 m_nCollisionEntity; cAudioCollisionManager m_sCollisionManager; int32 m_nProjectileEntity; int32 m_nBridgeEntity; - cMissionAudio m_sMissionAudio; + + // Mission audio stuff + CVector m_vecMissionAudioPosition; + bool8 m_bIsMissionAudio2D; + uint32 m_nMissionAudioSampleIndex; + uint8 m_nMissionAudioLoadingStatus; + uint8 m_nMissionAudioPlayStatus; + bool8 m_bIsMissionAudioPlaying; + int32 m_nMissionAudioFramesToPlay; + bool8 m_bIsMissionAudioAllowedToPlay; + int32 m_anRandomTable[5]; uint8 m_nTimeSpent; bool8 m_nUserPause; @@ -510,7 +506,7 @@ public: void SetMissionAudioLocation(float x, float y, float z); void PlayLoadedMissionAudio(); bool8 IsMissionAudioSampleFinished(); - bool8 IsMissionAudioSamplePlaying() { return m_sMissionAudio.m_nPlayStatus == PLAY_STATUS_PLAYING; } + bool8 IsMissionAudioSamplePlaying() { return m_nMissionAudioPlayStatus == PLAY_STATUS_PLAYING; } bool8 ShouldDuckMissionAudio() { return IsMissionAudioSamplePlaying(); } void ClearMissionAudio(); void ProcessMissionAudio(); diff --git a/src/audio/PolRadio.cpp b/src/audio/PolRadio.cpp index 76a87137..553cf287 100644 --- a/src/audio/PolRadio.cpp +++ b/src/audio/PolRadio.cpp @@ -85,11 +85,9 @@ cAudioManager::InitialisePoliceRadioZones() void cAudioManager::InitialisePoliceRadio() { - m_sPoliceRadioQueue.policeChannelTimer = 0; - m_sPoliceRadioQueue.policeChannelTimerSeconds = 0; - m_sPoliceRadioQueue.policeChannelCounterSeconds = 0; - for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) - m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE; + m_sPoliceRadioQueue.Reset(); + for (int32 i = 0; i < ARRAY_SIZE(m_aCrimes); i++) + m_aCrimes[i].type = CRIME_NONE; SampleManager.SetChannelReverbFlag(CHANNEL_POLICE_RADIO, FALSE); gSpecialSuspectLastSeenReport = FALSE; @@ -201,7 +199,7 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING) { SampleManager.PauseStream(FALSE, 1); } - if (m_sPoliceRadioQueue.policeChannelTimer == 0) bChannelOpen = FALSE; + if (m_sPoliceRadioQueue.m_nSamplesInQueue == 0) bChannelOpen = FALSE; if (cWait) { #ifdef FIX_BUGS cWait -= CTimer::GetLogicalFramesPassed(); @@ -238,14 +236,8 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) } if (bChannelOpen) DoPoliceRadioCrackle(); if ((g_nMissionAudioSfx == TOTAL_AUDIO_SAMPLES || g_nMissionAudioPlayingStatus != PLAY_STATUS_PLAYING) && - !SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO) && m_sPoliceRadioQueue.policeChannelTimer) { - if (m_sPoliceRadioQueue.policeChannelTimer) { - sample = m_sPoliceRadioQueue.crimesSamples[m_sPoliceRadioQueue.policeChannelCounterSeconds]; - m_sPoliceRadioQueue.policeChannelTimer--; - m_sPoliceRadioQueue.policeChannelCounterSeconds = (m_sPoliceRadioQueue.policeChannelCounterSeconds + 1) % 60; - } else { - sample = TOTAL_AUDIO_SAMPLES; - } + !SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO) && m_sPoliceRadioQueue.m_nSamplesInQueue != 0) { + sample = m_sPoliceRadioQueue.Remove(); if (wantedLevel == 0) { if (gSpecialSuspectLastSeenReport) { gSpecialSuspectLastSeenReport = FALSE; @@ -299,18 +291,18 @@ cAudioManager::SetupCrimeReport() if (MusicManager.m_nMusicMode == MUSICMODE_CUTSCENE) return FALSE; - if (60 - m_sPoliceRadioQueue.policeChannelTimer <= 9) { + if (POLICE_RADIO_QUEUE_MAX_SAMPLES - m_sPoliceRadioQueue.m_nSamplesInQueue <= 9) { AgeCrimes(); return TRUE; } - for (i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) { - if (m_sPoliceRadioQueue.crimes[i].type != CRIME_NONE) + for (i = 0; i < ARRAY_SIZE(m_aCrimes); i++) { + if (m_aCrimes[i].type != CRIME_NONE) break; } - if (i == ARRAY_SIZE(m_sPoliceRadioQueue.crimes)) return FALSE; - audioZoneId = CTheZones::FindAudioZone(&m_sPoliceRadioQueue.crimes[i].position); + if (i == ARRAY_SIZE(m_aCrimes)) return FALSE; + audioZoneId = CTheZones::FindAudioZone(&m_aCrimes[i].position); if (audioZoneId >= 0 && audioZoneId < NUMAUDIOZONES) { zone = CTheZones::GetAudioZone(audioZoneId); for (int j = 0; j < NUMAUDIOZONES; j++) { @@ -319,14 +311,14 @@ cAudioManager::SetupCrimeReport() m_sPoliceRadioQueue.Add(m_anRandomTable[4] % 3 + SFX_POLICE_RADIO_MESSAGE_NOISE_1); m_sPoliceRadioQueue.Add(m_anRandomTable[0] % 3 + SFX_WEVE_GOT); m_sPoliceRadioQueue.Add(m_anRandomTable[1] % 2 + SFX_A_10_1); - switch (m_sPoliceRadioQueue.crimes[i].type) { - case CRIME_PED_BURNED: m_sPoliceRadioQueue.crimes[i].type = CRIME_HIT_PED; break; - case CRIME_COP_BURNED: m_sPoliceRadioQueue.crimes[i].type = CRIME_HIT_COP; break; - case CRIME_VEHICLE_BURNED: m_sPoliceRadioQueue.crimes[i].type = CRIME_STEAL_CAR; break; - case CRIME_DESTROYED_CESSNA: m_sPoliceRadioQueue.crimes[i].type = CRIME_SHOOT_HELI; break; + switch (m_aCrimes[i].type) { + case CRIME_PED_BURNED: m_aCrimes[i].type = CRIME_HIT_PED; break; + case CRIME_COP_BURNED: m_aCrimes[i].type = CRIME_HIT_COP; break; + case CRIME_VEHICLE_BURNED: m_aCrimes[i].type = CRIME_STEAL_CAR; break; + case CRIME_DESTROYED_CESSNA: m_aCrimes[i].type = CRIME_SHOOT_HELI; break; default: break; } - m_sPoliceRadioQueue.Add(m_sPoliceRadioQueue.crimes[i].type + SFX_CRIME_1 - 1); + m_sPoliceRadioQueue.Add(m_aCrimes[i].type + SFX_CRIME_1 - 1); m_sPoliceRadioQueue.Add(SFX_IN); if (sampleIndex == SFX_POLICE_RADIO_SHORESIDE_VALE && (strcmp(zone->name, SubZo2Label) == 0 || strcmp(zone->name, SubZo3Label) == 0)) { @@ -340,17 +332,17 @@ cAudioManager::SetupCrimeReport() quarterX = 0.25f * rangeX; quarterY = 0.25f * rangeY; - if (m_sPoliceRadioQueue.crimes[i].position.y > halfY + quarterY) { + if (m_aCrimes[i].position.y > halfY + quarterY) { m_sPoliceRadioQueue.Add(SFX_NORTH); processed = TRUE; - } else if (m_sPoliceRadioQueue.crimes[i].position.y < halfY - quarterY) { + } else if (m_aCrimes[i].position.y < halfY - quarterY) { m_sPoliceRadioQueue.Add(SFX_SOUTH); processed = TRUE; } - if (m_sPoliceRadioQueue.crimes[i].position.x > halfX + quarterX) + if (m_aCrimes[i].position.x > halfX + quarterX) m_sPoliceRadioQueue.Add(SFX_EAST); - else if (m_sPoliceRadioQueue.crimes[i].position.x < halfX - quarterX) + else if (m_aCrimes[i].position.x < halfX - quarterX) m_sPoliceRadioQueue.Add(SFX_WEST); else if (!processed) m_sPoliceRadioQueue.Add(SFX_CENTRAL); @@ -363,7 +355,7 @@ cAudioManager::SetupCrimeReport() } } } - m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE; + m_aCrimes[i].type = CRIME_NONE; AgeCrimes(); return TRUE; } @@ -536,7 +528,7 @@ cAudioManager::SetupSuspectLastSeenReport() if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE) { veh = FindPlayerVehicle(); if (veh != nil) { - if (60 - m_sPoliceRadioQueue.policeChannelTimer > 9) { + if (POLICE_RADIO_QUEUE_MAX_SAMPLES - m_sPoliceRadioQueue.m_nSamplesInQueue > 9) { color1 = veh->m_currentColour1; if (color1 >= ARRAY_SIZE(gCarColourTable)) { debug("\n *** UNKNOWN CAR COLOUR %d *** ", color1); @@ -669,7 +661,7 @@ cAudioManager::SetupSuspectLastSeenReport() m_sPoliceRadioQueue.Add(TOTAL_AUDIO_SAMPLES); } } - } else if (60 - m_sPoliceRadioQueue.policeChannelTimer > 4) { + } else if (POLICE_RADIO_QUEUE_MAX_SAMPLES - m_sPoliceRadioQueue.m_nSamplesInQueue > 4) { m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_MESSAGE_NOISE_1); m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_SUSPECT); m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_ON_FOOT); @@ -682,14 +674,14 @@ cAudioManager::SetupSuspectLastSeenReport() void cAudioManager::ReportCrime(eCrimeType type, const CVector &pos) { - int32 lastCrime = ARRAY_SIZE(m_sPoliceRadioQueue.crimes); + int32 lastCrime = ARRAY_SIZE(m_aCrimes); if (m_bIsInitialised && MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && FindPlayerPed()->m_pWanted->GetWantedLevel() > 0 && (type > CRIME_NONE || type < NUM_CRIME_TYPES) && m_FrameCounter >= gMinTimeToNextReport[type]) { - for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) { - if (m_sPoliceRadioQueue.crimes[i].type) { - if (m_sPoliceRadioQueue.crimes[i].type == type) { - m_sPoliceRadioQueue.crimes[i].position = pos; - m_sPoliceRadioQueue.crimes[i].timer = 0; + for (int32 i = 0; i < ARRAY_SIZE(m_aCrimes); i++) { + if (m_aCrimes[i].type != CRIME_NONE) { + if (m_aCrimes[i].type == type) { + m_aCrimes[i].position = pos; + m_aCrimes[i].timer = 0; return; } } else { @@ -697,10 +689,10 @@ cAudioManager::ReportCrime(eCrimeType type, const CVector &pos) } } - if (lastCrime < ARRAY_SIZE(m_sPoliceRadioQueue.crimes)) { - m_sPoliceRadioQueue.crimes[lastCrime].type = type; - m_sPoliceRadioQueue.crimes[lastCrime].position = pos; - m_sPoliceRadioQueue.crimes[lastCrime].timer = 0; + if (lastCrime < ARRAY_SIZE(m_aCrimes)) { + m_aCrimes[lastCrime].type = type; + m_aCrimes[lastCrime].position = pos; + m_aCrimes[lastCrime].timer = 0; gMinTimeToNextReport[type] = m_FrameCounter + 500; } } @@ -723,7 +715,7 @@ cAudioManager::PlaySuspectLastSeen(float x, float y, float z) if (!m_bIsInitialised) return; - if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && 60 - m_sPoliceRadioQueue.policeChannelTimer > 9) { + if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && POLICE_RADIO_QUEUE_MAX_SAMPLES - m_sPoliceRadioQueue.m_nSamplesInQueue > 9) { audioZone = CTheZones::FindAudioZone(&vec); if (audioZone >= 0 && audioZone < NUMAUDIOZONES) { zone = CTheZones::GetAudioZone(audioZone); @@ -776,9 +768,9 @@ cAudioManager::PlaySuspectLastSeen(float x, float y, float z) void cAudioManager::AgeCrimes() { - for (uint8 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) { - if (m_sPoliceRadioQueue.crimes[i].type != CRIME_NONE) { - if (++m_sPoliceRadioQueue.crimes[i].timer > 1500) m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE; + for (uint8 i = 0; i < ARRAY_SIZE(m_aCrimes); i++) { + if (m_aCrimes[i].type != CRIME_NONE) { + if (++m_aCrimes[i].timer > 1500) m_aCrimes[i].type = CRIME_NONE; } } } diff --git a/src/audio/PolRadio.h b/src/audio/PolRadio.h index 368708b6..f402c200 100644 --- a/src/audio/PolRadio.h +++ b/src/audio/PolRadio.h @@ -1,6 +1,7 @@ #pragma once #include "Crime.h" +#include "AudioSamples.h" struct cAMCrime { int32 type; @@ -17,30 +18,49 @@ struct cAMCrime { VALIDATE_SIZE(cAMCrime, 20); +#define POLICE_RADIO_QUEUE_MAX_SAMPLES 60 + class cPoliceRadioQueue { public: - int32 crimesSamples[60]; - uint8 policeChannelTimer; - uint8 policeChannelTimerSeconds; - uint8 policeChannelCounterSeconds; - cAMCrime crimes[10]; + int32 m_aSamples[POLICE_RADIO_QUEUE_MAX_SAMPLES]; + uint8 m_nSamplesInQueue; + uint8 m_nAddOffset; + uint8 m_nRemoveOffset; cPoliceRadioQueue() { - policeChannelTimerSeconds = 0; - policeChannelCounterSeconds = 0; - policeChannelTimer = 0; + Reset(); + } + + void Reset() + { + m_nAddOffset = 0; + m_nRemoveOffset = 0; + m_nSamplesInQueue = 0; + } + + bool8 Add(uint32 sample) + { + if (m_nSamplesInQueue != POLICE_RADIO_QUEUE_MAX_SAMPLES) { + m_aSamples[m_nAddOffset] = sample; + m_nSamplesInQueue++; + m_nAddOffset = (m_nAddOffset + 1) % POLICE_RADIO_QUEUE_MAX_SAMPLES; + return TRUE; + } + return FALSE; } - void Add(uint32 sample) + uint32 Remove() { - if (policeChannelTimer != 60) { - crimesSamples[policeChannelTimerSeconds] = sample; - policeChannelTimer++; - policeChannelTimerSeconds = (policeChannelTimerSeconds + 1) % 60; + if (m_nSamplesInQueue != 0) { + uint32 sample = m_aSamples[m_nRemoveOffset]; + m_nSamplesInQueue--; + m_nRemoveOffset = (m_nRemoveOffset + 1) % POLICE_RADIO_QUEUE_MAX_SAMPLES; + return sample; } + return TOTAL_AUDIO_SAMPLES; } }; -VALIDATE_SIZE(cPoliceRadioQueue, 444); +VALIDATE_SIZE(cPoliceRadioQueue, 244); -- cgit v1.2.3 From e33b56b49af7b9ba1b848e38e4aff3f88bc2e362 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 21 Aug 2021 15:13:23 +0300 Subject: VC bits --- src/peds/PlayerPed.cpp | 29 +++++++++++++++++++++++++++++ src/peds/PlayerPed.h | 3 +++ 2 files changed, 32 insertions(+) diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index deb409b5..ef877965 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -20,6 +20,10 @@ #define PAD_MOVE_TO_GAME_WORLD_MOVE 60.0f +#ifdef VC_PED_PORTS +bool CPlayerPed::bDontAllowWeaponChange; +#endif + const uint32 CPlayerPed::nSaveStructSize = #ifdef COMPATIBLE_SAVES 1520; @@ -603,7 +607,11 @@ CPlayerPed::ProcessWeaponSwitch(CPad *padUsed) if (CDarkel::FrenzyOnGoing()) goto switchDetectDone; +#ifdef VC_PED_PORTS + if (padUsed->CycleWeaponRightJustDown() && !m_pPointGunAt && !bDontAllowWeaponChange) { +#else if (padUsed->CycleWeaponRightJustDown() && !m_pPointGunAt) { +#endif if (TheCamera.PlayerWeaponMode.Mode != CCam::MODE_M16_1STPERSON && TheCamera.PlayerWeaponMode.Mode != CCam::MODE_M16_1STPERSON_RUNABOUT @@ -619,7 +627,11 @@ CPlayerPed::ProcessWeaponSwitch(CPad *padUsed) } m_nSelectedWepSlot = WEAPONTYPE_UNARMED; } +#ifdef VC_PED_PORTS + } else if (padUsed->CycleWeaponLeftJustDown() && !m_pPointGunAt && !bDontAllowWeaponChange) { +#else } else if (padUsed->CycleWeaponLeftJustDown() && !m_pPointGunAt) { +#endif if (TheCamera.PlayerWeaponMode.Mode != CCam::MODE_M16_1STPERSON && TheCamera.PlayerWeaponMode.Mode != CCam::MODE_SNIPER && TheCamera.PlayerWeaponMode.Mode != CCam::MODE_ROCKETLAUNCHER) { @@ -857,7 +869,11 @@ CPlayerPed::FindNextWeaponLockOnTarget(CEntity *previousTarget, bool lookToLeft) // nextTarget = nil; // duplicate float lastCloseness = -10000.0f; // CGeneral::GetATanOfXY(GetForward().x, GetForward().y); // unused +#ifdef VC_PED_PORTS + CVector distVec = previousTarget->GetPosition() - TheCamera.GetPosition(); +#else CVector distVec = previousTarget->GetPosition() - GetPosition(); +#endif float referenceBeta = CGeneral::GetATanOfXY(distVec.x, distVec.y); for (int h = CPools::GetPedPool()->GetSize() - 1; h >= 0; h--) { @@ -882,6 +898,9 @@ CPlayerPed::FindNextWeaponLockOnTarget(CEntity *previousTarget, bool lookToLeft) return false; SetWeaponLockOnTarget(nextTarget); +#ifdef VC_PED_PORTS + bDontAllowWeaponChange = true; +#endif SetPointGunAt(nextTarget); return true; } @@ -927,6 +946,9 @@ CPlayerPed::FindWeaponLockOnTarget(void) return false; SetWeaponLockOnTarget(nextTarget); +#ifdef VC_PED_PORTS + bDontAllowWeaponChange = true; +#endif SetPointGunAt(nextTarget); return true; } @@ -1511,6 +1533,13 @@ CPlayerPed::ProcessControl(void) m_bSpeedTimerFlag = false; } +#ifdef VC_PED_PORTS + if (bDontAllowWeaponChange && FindPlayerPed() == this) { + if (!CPad::GetPad(0)->GetTarget()) + bDontAllowWeaponChange = false; + } +#endif + #ifdef PED_SKIN if (!bIsVisible && IsClumpSkinned(GetClump())) UpdateRpHAnim(); diff --git a/src/peds/PlayerPed.h b/src/peds/PlayerPed.h index 796a6ca0..2e9f7989 100644 --- a/src/peds/PlayerPed.h +++ b/src/peds/PlayerPed.h @@ -40,6 +40,9 @@ public: CVector m_cachedCamFront; CVector m_cachedCamUp; #endif +#ifdef VC_PED_PORTS + static bool bDontAllowWeaponChange; +#endif CPlayerPed(); ~CPlayerPed(); -- cgit v1.2.3 From f86bdb2cdb2256a9348001e230c9c8eb6fe76e8e Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 21 Aug 2021 17:15:30 +0300 Subject: Fix map teleport Z coordinate --- src/core/Radar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index d74ce007..b29c19eb 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -1550,7 +1550,7 @@ CRadar::ToggleTargetMarker(float x, float y) ms_RadarTrace[nextBlip].m_bDim = 0; ms_RadarTrace[nextBlip].m_bInUse = 1; ms_RadarTrace[nextBlip].m_Radius = 1.0f; - CVector pos(x, y, 0.0f/*CWorld::FindGroundZForCoord(x,y)*/); + CVector pos(x, y, CWorld::FindGroundZForCoord(x,y)); TargetMarkerPos = pos; ms_RadarTrace[nextBlip].m_vec2DPos = pos; ms_RadarTrace[nextBlip].m_vecPos = pos; -- cgit v1.2.3 From c52aebe8e7561c428c610e17827eb1347197369f Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 21 Aug 2021 19:07:26 +0300 Subject: Fix an original bug about entering boat sometimes takes 2 key press --- src/peds/PedAI.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/peds/PedAI.cpp b/src/peds/PedAI.cpp index f1c753ec..8bd6791c 100644 --- a/src/peds/PedAI.cpp +++ b/src/peds/PedAI.cpp @@ -3531,23 +3531,17 @@ CPed::SetEnterCar_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag) m_vecOffsetSeek = doorOpenPos - GetPosition(); m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + 600; if (car->IsBoat()) { -#ifdef VC_PED_PORTS - // VC checks for handling flag, but we can't do that - if(car->GetModelIndex() == MI_SPEEDER) - m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_STD_CAR_SIT, 100.0f); - else - m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_STD_BOAT_DRIVE, 100.0f); - - PedSetInCarCB(nil, this); - bVehExitWillBeInstant = true; -#else - #ifndef FIX_BUGS m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_STD_BOAT_DRIVE, 100.0f); #else m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, car->GetDriverAnim(), 100.0f); #endif + // Otherwise boat enter key sometimes processed multiple times, so you enter/exit instantly +#if defined VC_PED_PORTS || defined FIX_BUGS + PedSetInCarCB(nil, this); + bVehExitWillBeInstant = true; +#else m_pVehicleAnim->SetFinishCallback(PedSetInCarCB, this); #endif if (IsPlayer()) @@ -5194,8 +5188,10 @@ CPed::SeekBoatPosition(void) enterOffset = boatModel->GetFrontSeatPosn(); enterOffset.x = 0.0f; CMatrix boatMat(m_carInObjective->GetMatrix()); + CVector boatEnterPos = Multiply3x3(boatMat, enterOffset); + boatEnterPos += m_carInObjective->GetPosition(); SetMoveState(PEDMOVE_WALK); - m_vecSeekPos = boatMat * enterOffset; + m_vecSeekPos = boatEnterPos; if (Seek()) { // We arrived to the boat m_vehDoor = 0; -- cgit v1.2.3 From 6110f74ad66fea524b0983695f6f6f2b5dd2002f Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 22 Aug 2021 01:57:01 +0300 Subject: Add forgotten bit from X11 detection --- premake5.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/premake5.lua b/premake5.lua index a33623fc..ebbcf4a5 100644 --- a/premake5.lua +++ b/premake5.lua @@ -373,7 +373,7 @@ project "re3" -- iterates all configs and runs on them ["dontWrite"] = function (cfg) check_symbol_exists(cfg, "haveX11", "glfwGetX11Display", { "X11/Xlib.h", "X11/XKBlib.h", "GLFW/glfw3.h", "GLFW/glfw3native.h" }, "GLFW_EXPOSE_NATIVE_X11") - if cfg.autoconf["haveX11"] then + if cfg.autoconf["haveX11"] ~= nil and cfg.autoconf["haveX11"] == 1 then table.insert(cfg.links, "X11") table.insert(cfg.defines, "GET_KEYBOARD_INPUT_FROM_X11") end -- cgit v1.2.3 From ceb65eafa5374bbde2e39efed27bb2f87fb31901 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 23 Aug 2021 11:15:03 +0300 Subject: Make ped comments update position and volume --- src/audio/AudioLogic.cpp | 160 ++++++++++++++++++++++++--------------------- src/audio/AudioManager.cpp | 19 ++++++ src/audio/PolRadio.h | 2 +- src/core/config.h | 1 + 4 files changed, 108 insertions(+), 74 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index d09352be..0ba2190d 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -6077,96 +6077,110 @@ cPedComments::Process() if (m_nCommentsInBank[m_nActiveBank]) { sampleIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nSampleIndex; - if (!SampleManager.IsPedCommentLoaded(sampleIndex)) + switch (SampleManager.IsPedCommentLoaded(sampleIndex)) // yes, this was a switch + { + case FALSE: SampleManager.LoadPedComment(sampleIndex); - - AudioManager.m_sQueueSample.m_nEntityIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEntityIndex; - AudioManager.m_sQueueSample.m_nCounter = 0; - AudioManager.m_sQueueSample.m_nSampleIndex = sampleIndex; - AudioManager.m_sQueueSample.m_nBankIndex = SFX_BANK_PED_COMMENTS; - AudioManager.m_sQueueSample.m_nPriority = 3; - AudioManager.m_sQueueSample.m_nVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nVolume; - AudioManager.m_sQueueSample.m_fDistance = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_fDistance; - AudioManager.m_sQueueSample.m_nLoopCount = 1; + // BUG? no break, VC has break in here + case TRUE: + AudioManager.m_sQueueSample.m_nEntityIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEntityIndex; + AudioManager.m_sQueueSample.m_nCounter = 0; + AudioManager.m_sQueueSample.m_nSampleIndex = sampleIndex; + AudioManager.m_sQueueSample.m_nBankIndex = SFX_BANK_PED_COMMENTS; + AudioManager.m_sQueueSample.m_nPriority = 3; + AudioManager.m_sQueueSample.m_nVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nVolume; + AudioManager.m_sQueueSample.m_fDistance = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_fDistance; + AudioManager.m_sQueueSample.m_nLoopCount = 1; #ifndef GTA_PS2 - AudioManager.m_sQueueSample.m_nLoopStart = 0; - AudioManager.m_sQueueSample.m_nLoopEnd = -1; + AudioManager.m_sQueueSample.m_nLoopStart = 0; + AudioManager.m_sQueueSample.m_nLoopEnd = -1; #endif // !GTA_PS2 #ifdef EXTERNAL_3D_SOUND - #ifdef FIX_BUGS - AudioManager.m_sQueueSample.m_nEmittingVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEmittingVolume; - #else - AudioManager.m_sQueueSample.m_nEmittingVolume = MAX_VOLUME; - #endif // FIX_BUGS +#ifdef FIX_BUGS + AudioManager.m_sQueueSample.m_nEmittingVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEmittingVolume; +#else + AudioManager.m_sQueueSample.m_nEmittingVolume = MAX_VOLUME; +#endif // FIX_BUGS #endif // EXTERNAL_3D_SOUND - AudioManager.m_sQueueSample.m_fSpeedMultiplier = 3.0f; - switch (sampleIndex) { - case SFX_POLICE_HELI_1: - case SFX_POLICE_HELI_2: - case SFX_POLICE_HELI_3: +#ifdef ATTACH_PED_COMMENTS_TO_ENTITIES + // let's disable doppler because if sounds funny as the sound moves + // originally position of ped comment doesn't change so this has no effect anyway + AudioManager.m_sQueueSample.m_fSpeedMultiplier = 0.0f; +#else + AudioManager.m_sQueueSample.m_fSpeedMultiplier = 3.0f; +#endif + switch (sampleIndex) { + case SFX_POLICE_HELI_1: + case SFX_POLICE_HELI_2: + case SFX_POLICE_HELI_3: #ifdef FIX_BUGS - case SFX_POLICE_HELI_4: - case SFX_POLICE_HELI_5: - case SFX_POLICE_HELI_6: - case SFX_POLICE_HELI_7: - case SFX_POLICE_HELI_8: - case SFX_POLICE_HELI_9: - case SFX_POLICE_HELI_10: - case SFX_POLICE_HELI_11: - case SFX_POLICE_HELI_12: - case SFX_POLICE_HELI_13: - case SFX_POLICE_HELI_14: - case SFX_POLICE_HELI_15: - case SFX_POLICE_HELI_16: - case SFX_POLICE_HELI_17: - case SFX_POLICE_HELI_18: - case SFX_POLICE_HELI_19: - case SFX_POLICE_HELI_20: - case SFX_POLICE_HELI_21: - case SFX_POLICE_HELI_22: - case SFX_POLICE_HELI_23: - case SFX_POLICE_HELI_24: - case SFX_POLICE_HELI_25: - case SFX_POLICE_HELI_26: - case SFX_POLICE_HELI_27: - case SFX_POLICE_HELI_28: - case SFX_POLICE_HELI_29: + case SFX_POLICE_HELI_4: + case SFX_POLICE_HELI_5: + case SFX_POLICE_HELI_6: + case SFX_POLICE_HELI_7: + case SFX_POLICE_HELI_8: + case SFX_POLICE_HELI_9: + case SFX_POLICE_HELI_10: + case SFX_POLICE_HELI_11: + case SFX_POLICE_HELI_12: + case SFX_POLICE_HELI_13: + case SFX_POLICE_HELI_14: + case SFX_POLICE_HELI_15: + case SFX_POLICE_HELI_16: + case SFX_POLICE_HELI_17: + case SFX_POLICE_HELI_18: + case SFX_POLICE_HELI_19: + case SFX_POLICE_HELI_20: + case SFX_POLICE_HELI_21: + case SFX_POLICE_HELI_22: + case SFX_POLICE_HELI_23: + case SFX_POLICE_HELI_24: + case SFX_POLICE_HELI_25: + case SFX_POLICE_HELI_26: + case SFX_POLICE_HELI_27: + case SFX_POLICE_HELI_28: + case SFX_POLICE_HELI_29: #endif - AudioManager.m_sQueueSample.m_MaxDistance = 400.0f; - break; - default: - AudioManager.m_sQueueSample.m_MaxDistance = 50.0f; - break; - } - AudioManager.m_sQueueSample.m_bStatic = TRUE; - AudioManager.m_sQueueSample.m_vecPos = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_vecPos; + AudioManager.m_sQueueSample.m_MaxDistance = 400.0f; + break; + default: + AudioManager.m_sQueueSample.m_MaxDistance = 50.0f; + break; + } + AudioManager.m_sQueueSample.m_bStatic = TRUE; + AudioManager.m_sQueueSample.m_vecPos = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_vecPos; - if (sampleIndex >= SFX_AMMU_D && sampleIndex <= SFX_AMMU_F) { - AudioManager.m_sQueueSample.m_bReverb = FALSE; + if (sampleIndex >= SFX_AMMU_D && sampleIndex <= SFX_AMMU_F) { + AudioManager.m_sQueueSample.m_bReverb = FALSE; #ifdef AUDIO_REFLECTIONS - AudioManager.m_sQueueSample.m_bReflections = FALSE; + AudioManager.m_sQueueSample.m_bReflections = FALSE; #endif #ifdef FIX_BUGS - } else if (sampleIndex >= SFX_POLICE_HELI_1 && sampleIndex <= SFX_POLICE_HELI_29) { - AudioManager.m_sQueueSample.m_bReverb = TRUE; + } + else if (sampleIndex >= SFX_POLICE_HELI_1 && sampleIndex <= SFX_POLICE_HELI_29) { + AudioManager.m_sQueueSample.m_bReverb = TRUE; #ifdef AUDIO_REFLECTIONS - AudioManager.m_sQueueSample.m_bReflections = FALSE; + AudioManager.m_sQueueSample.m_bReflections = FALSE; #endif // AUDIO_REFLECTIONS #endif // FIX_BUGS - } else { - AudioManager.m_sQueueSample.m_bReverb = TRUE; + } + else { + AudioManager.m_sQueueSample.m_bReverb = TRUE; #ifdef AUDIO_REFLECTIONS - AudioManager.m_sQueueSample.m_bReflections = TRUE; + AudioManager.m_sQueueSample.m_bReflections = TRUE; #endif - } + } - AudioManager.m_sQueueSample.m_bIs2D = FALSE; - AudioManager.m_sQueueSample.m_nFrequency = - SampleManager.GetSampleBaseFrequency(AudioManager.m_sQueueSample.m_nSampleIndex) + AudioManager.RandomDisplacement(750); - if (CTimer::GetIsSlowMotionActive()) - AudioManager.m_sQueueSample.m_nFrequency /= 2; - m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nProcess = -1; - AudioManager.AddSampleToRequestedQueue(); + AudioManager.m_sQueueSample.m_bIs2D = FALSE; + AudioManager.m_sQueueSample.m_nFrequency = + SampleManager.GetSampleBaseFrequency(AudioManager.m_sQueueSample.m_nSampleIndex) + AudioManager.RandomDisplacement(750); + if (CTimer::GetIsSlowMotionActive()) + AudioManager.m_sQueueSample.m_nFrequency /= 2; + m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nProcess = -1; + AudioManager.AddSampleToRequestedQueue(); + default: + break; + } } // Switch bank diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 425a897d..eeebcebb 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -10,6 +10,7 @@ #include "sampman.h" #include "Camera.h" #include "World.h" +#include "Entity.h" cAudioManager AudioManager; @@ -903,6 +904,24 @@ cAudioManager::ProcessActiveQueues() SampleManager.SetChannelVolume(j, sample.m_nVolume); #endif } else { +#ifdef ATTACH_PED_COMMENTS_TO_ENTITIES + if (sample.m_nCounter <= 255 && sample.m_nSampleIndex >= SAMPLEBANK_PED_START && sample.m_nSampleIndex <= SAMPLEBANK_PED_END) { + CEntity* entity = (CEntity*)GetEntityPointer(sample.m_nEntityIndex); + if (entity && m_asAudioEntities[sample.m_nEntityIndex].m_nType == AUDIOTYPE_PHYSICAL) { + sample.m_vecPos = entity->GetPosition(); + sample.m_fDistance = Sqrt(GetDistanceSquared(sample.m_vecPos)); + uint8 vol; + if (CWorld::GetIsLineOfSightClear(TheCamera.GetPosition(), sample.m_vecPos, true, false, false, false, false, false)) + vol = MAX_VOLUME; + else + vol = 31; +#ifdef EXTERNAL_3D_SOUND + sample.m_nEmittingVolume = vol; +#endif + sample.m_nVolume = ComputeVolume(vol, sample.m_MaxDistance, sample.m_fDistance); + } + } +#endif position2 = sample.m_fDistance; position1 = m_asActiveSamples[j].m_fDistance; m_asActiveSamples[j].m_fDistance = sample.m_fDistance; diff --git a/src/audio/PolRadio.h b/src/audio/PolRadio.h index f402c200..c7b0bcc8 100644 --- a/src/audio/PolRadio.h +++ b/src/audio/PolRadio.h @@ -23,7 +23,7 @@ VALIDATE_SIZE(cAMCrime, 20); class cPoliceRadioQueue { public: - int32 m_aSamples[POLICE_RADIO_QUEUE_MAX_SAMPLES]; + uint32 m_aSamples[POLICE_RADIO_QUEUE_MAX_SAMPLES]; uint8 m_nSamplesInQueue; uint8 m_nAddOffset; uint8 m_nRemoveOffset; diff --git a/src/core/config.h b/src/core/config.h index 5ec6f3ee..c04dfdf1 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -438,6 +438,7 @@ enum Config { //#define AUDIO_OAL_USE_SNDFILE // use libsndfile to decode WAVs instead of our internal decoder #define AUDIO_OAL_USE_MPG123 // use mpg123 to support mp3 files #define PAUSE_RADIO_IN_FRONTEND // pause radio when game is paused +#define ATTACH_PED_COMMENTS_TO_ENTITIES // ped comments coordinates would update following ped entity #define MULTITHREADED_AUDIO // for streams. requires C++11 or later #ifdef AUDIO_OPUS -- cgit v1.2.3 From e9a61ca38cd88a9c8b15b00a1ada73dd7d85c46f Mon Sep 17 00:00:00 2001 From: erorcun Date: Mon, 23 Aug 2021 21:56:22 +0300 Subject: Adjust plane free cam values for sparks to be visible in Dodo --- src/core/Cam.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index ecfade74..d4be8585 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -4816,7 +4816,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, {1.3f, 1.0f, 0.4f, 10.0f, 15.0f, 0.5f, 1.0f, 1.0f, 0.85f, 0.2f, 0.075f, 0.05f, 0.8f, DEGTORAD(45.0f), DEGTORAD(89.0f)}, // cars {1.1f, 1.0f, 0.1f, 10.0f, 11.0f, 0.5f, 1.0f, 1.0f, 0.85f, 0.2f, 0.075f, 0.05f, 0.75f, DEGTORAD(45.0f), DEGTORAD(89.0f)}, // bike {1.1f, 1.0f, 0.2f, 10.0f, 15.0f, 0.05f, 0.05f, 0.0f, 0.9f, 0.05f, 0.01f, 0.05f, 1.0f, DEGTORAD(10.0f), DEGTORAD(70.0f)}, // heli (SA values) - {1.1f, 3.5f, 0.2f, 10.0f, 25.0f, 0.5f, 1.0f, 1.0f, 0.75f, 0.1f, 0.005f, 0.2f, 1.0f, DEGTORAD(89.0f), DEGTORAD(89.0f)}, // plane (SA values) + {1.1f, 1.0f, 0.2f, 10.0f, 15.0f, 0.5f, 1.0f, 1.0f, 0.75f, 0.1f, 0.005f, 0.2f, 1.0f, DEGTORAD(89.0f), DEGTORAD(89.0f)}, // plane (SA values) {0.9f, 1.0f, 0.1f, 10.0f, 15.0f, 0.5f, 1.0f, 0.0f, 0.9f, 0.05f, 0.005f, 0.05f, 1.0f, -0.2f, DEGTORAD(70.0f)}, // boat {1.1f, 1.0f, 0.2f, 10.0f, 5.0f, 0.5f, 1.0f, 1.0f, 0.75f, 0.1f, 0.005f, 0.2f, 1.0f, DEGTORAD(45.0f), DEGTORAD(89.0f)}, // rc cars {1.1f, 1.0f, 0.2f, 10.0f, 5.0f, 0.5f, 1.0f, 1.0f, 0.75f, 0.1f, 0.005f, 0.2f, 1.0f, DEGTORAD(20.0f), DEGTORAD(70.0f)}, // rc heli/planes -- cgit v1.2.3 From 38f4ea7aa3773e5fa9ff99fa131b7db223117009 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Tue, 24 Aug 2021 13:11:36 +0300 Subject: Audio enhancements: * redo high fps fix * make releasing vehicle sounds attach to entities * fix bug with reusing audio entity that is still being used * use time scale to modify sound speed --- src/audio/AudioLogic.cpp | 10 ++- src/audio/AudioManager.cpp | 188 ++++++++++++++++++++++++++++++++++----------- src/audio/AudioManager.h | 7 ++ src/audio/PolRadio.cpp | 4 + src/core/config.h | 3 +- 5 files changed, 164 insertions(+), 48 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 0ba2190d..da46d0d7 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -1389,7 +1389,11 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050; if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; +#ifdef USE_TIME_SCALE_FOR_AUDIO + SampleManager.SetChannelFrequency(CHANNEL_PLAYER_VEHICLE_ENGINE, freq * CTimer::GetTimeScale()); +#else SampleManager.SetChannelFrequency(CHANNEL_PLAYER_VEHICLE_ENGINE, freq); +#endif if (!channelUsed) { #if GTA_VERSION >= GTA3_PC_10 SampleManager.SetChannelReverbFlag(CHANNEL_PLAYER_VEHICLE_ENGINE, m_bDynamicAcousticModelingStatus != FALSE); @@ -6102,7 +6106,7 @@ cPedComments::Process() AudioManager.m_sQueueSample.m_nEmittingVolume = MAX_VOLUME; #endif // FIX_BUGS #endif // EXTERNAL_3D_SOUND -#ifdef ATTACH_PED_COMMENTS_TO_ENTITIES +#ifdef ATTACH_RELEASING_SOUNDS_TO_ENTITIES // let's disable doppler because if sounds funny as the sound moves // originally position of ped comment doesn't change so this has no effect anyway AudioManager.m_sQueueSample.m_fSpeedMultiplier = 0.0f; @@ -6174,8 +6178,10 @@ cPedComments::Process() AudioManager.m_sQueueSample.m_bIs2D = FALSE; AudioManager.m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AudioManager.m_sQueueSample.m_nSampleIndex) + AudioManager.RandomDisplacement(750); +#ifndef USE_TIME_SCALE_FOR_AUDIO if (CTimer::GetIsSlowMotionActive()) - AudioManager.m_sQueueSample.m_nFrequency /= 2; + AudioManager.m_sQueueSample.m_nFrequency >>= 1; +#endif m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nProcess = -1; AudioManager.AddSampleToRequestedQueue(); default: diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index eeebcebb..c13b8cca 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -134,8 +134,47 @@ cAudioManager::CreateEntity(eAudioType type, void *entity) return AEHANDLE_ERROR_NOENTITY; if (type >= TOTAL_AUDIO_TYPES) return AEHANDLE_ERROR_BADAUDIOTYPE; + +#ifdef FIX_BUGS + // since sound could still play after entity deletion let's make sure we don't override one that is in use + // find all the free entity IDs that are being used by queued samples + int32 stillUsedEntities[NUM_CHANNELS_GENERIC * NUM_SOUNDS_SAMPLES_BANKS]; + uint32 stillUsedEntitiesCount = 0; + + for (uint8 i = 0; i < NUM_SOUNDS_SAMPLES_BANKS; i++) + for (uint8 j = 0; j < m_SampleRequestQueuesStatus[i]; j++) { + tSound &sound = m_asSamples[i][m_abSampleQueueIndexTable[i][j]]; + if (sound.m_nEntityIndex < 0) continue; + if (!m_asAudioEntities[sound.m_nEntityIndex].m_bIsUsed) { + bool found = false; + for (uint8 k = 0; k < stillUsedEntitiesCount; k++) { + if (stillUsedEntities[k] == sound.m_nEntityIndex) { + found = true; + break; + } + } + if (!found) + stillUsedEntities[stillUsedEntitiesCount++] = sound.m_nEntityIndex; + } + } +#endif + for (uint32 i = 0; i < ARRAY_SIZE(m_asAudioEntities); i++) { if (!m_asAudioEntities[i].m_bIsUsed) { +#ifdef FIX_BUGS + // skip if ID is still used by queued sample + bool skip = false; + for (uint8 j = 0; j < stillUsedEntitiesCount; j++) { + if (stillUsedEntities[j] == i) { + //debug("audio entity %i still used, skipping\n", i); + skip = true; + break; + } + } + if (skip) + continue; +#endif + m_asAudioEntities[i].m_bIsUsed = TRUE; m_asAudioEntities[i].m_bStatus = FALSE; m_asAudioEntities[i].m_nType = type; @@ -791,39 +830,93 @@ cAudioManager::AddReleasingSounds() if (sample.m_nCounter <= 255 || sample.m_nReflectionDelay == 0) // check if not delayed reflection #endif { - if (sample.m_nFramesToPlay == 0) +#ifdef ATTACH_RELEASING_SOUNDS_TO_ENTITIES + if (sample.m_nCounter <= 255 && !sample.m_bIs2D) { // check if not reflection and is a 3D sound + CEntity* entity = (CEntity*)GetEntityPointer(sample.m_nEntityIndex); + if (entity && m_asAudioEntities[sample.m_nEntityIndex].m_nType == AUDIOTYPE_PHYSICAL) { + sample.m_vecPos = entity->GetPosition(); + float oldDistance = sample.m_fDistance; + sample.m_fDistance = Sqrt(GetDistanceSquared(sample.m_vecPos)); + if (sample.m_nSampleIndex >= SAMPLEBANK_PED_START && sample.m_nSampleIndex <= SAMPLEBANK_PED_END) { // check if it's ped comment + uint8 vol; + if (CWorld::GetIsLineOfSightClear(TheCamera.GetPosition(), sample.m_vecPos, true, false, false, false, false, false)) + vol = MAX_VOLUME; + else + vol = 31; +#ifdef EXTERNAL_3D_SOUND + sample.m_nEmittingVolume = vol; +#endif + sample.m_nVolume = ComputeVolume(vol, sample.m_MaxDistance, sample.m_fDistance); + } else { + // calculate new volume with changed distance + float volumeDiff = sq((sample.m_MaxDistance - sample.m_fDistance) / (sample.m_MaxDistance - oldDistance)); + if (volumeDiff > 0.0f) { + uint8 newVolume = volumeDiff * sample.m_nVolume; + if (sample.m_nVolumeChange > 0) + sample.m_nVolumeChange = volumeDiff * sample.m_nVolumeChange; +#if defined(FIX_BUGS) && defined(EXTERNAL_3D_SOUND) + if (sample.m_nEmittingVolumeChange > 0) + sample.m_nEmittingVolumeChange = volumeDiff * sample.m_nEmittingVolumeChange; +#endif + sample.m_nVolume = Min(127, newVolume); + } + } + if (sample.m_nVolume == 0) + sample.m_nFramesToPlay = 0; + } + } +#endif +#ifdef FIX_BUGS + // fixing emitting volume not being lowered and high fps bugs + if (sample.m_nFramesToPlay <= 0) continue; if (sample.m_nLoopCount == 0) { if (sample.m_nVolumeChange == -1) { -#if defined(FIX_BUGS) && defined(EXTERNAL_3D_SOUND) - sample.m_nVolumeChange = sample.m_nEmittingVolume / sample.m_nFramesToPlay; -#else sample.m_nVolumeChange = sample.m_nVolume / sample.m_nFramesToPlay; -#endif if (sample.m_nVolumeChange <= 0) sample.m_nVolumeChange = 1; +#ifdef EXTERNAL_3D_SOUND + sample.m_nEmittingVolumeChange = sample.m_nEmittingVolume / sample.m_nFramesToPlay; + if (sample.m_nEmittingVolumeChange <= 0) + sample.m_nEmittingVolumeChange = 1; +#endif } -#if defined(FIX_BUGS) && defined(EXTERNAL_3D_SOUND) - if (sample.m_nEmittingVolume <= sample.m_nVolumeChange) { + if (sample.m_nVolume <= sample.m_nVolumeChange * CTimer::GetTimeStepFix()) { + sample.m_nFramesToPlay = 0; + continue; + } + sample.m_nVolume -= sample.m_nVolumeChange * CTimer::GetTimeStepFix(); +#ifdef EXTERNAL_3D_SOUND + if (sample.m_nEmittingVolume <= sample.m_nEmittingVolumeChange * CTimer::GetTimeStepFix()) { + sample.m_nFramesToPlay = 0; + continue; + } + sample.m_nEmittingVolume -= sample.m_nEmittingVolumeChange * CTimer::GetTimeStepFix(); +#endif + } + sample.m_nFramesToPlay -= CTimer::GetTimeStepFix(); + if (sample.m_nFramesToPlay < 0) + sample.m_nFramesToPlay = 0; #else + if (sample.m_nFramesToPlay == 0) + continue; + if (sample.m_nLoopCount == 0) { + if (sample.m_nVolumeChange == -1) { + sample.m_nVolumeChange = sample.m_nVolume / sample.m_nFramesToPlay; + if (sample.m_nVolumeChange <= 0) + sample.m_nVolumeChange = 1; + } if (sample.m_nVolume <= sample.m_nVolumeChange) { -#endif sample.m_nFramesToPlay = 0; continue; } -#if defined(FIX_BUGS) && defined(EXTERNAL_3D_SOUND) - sample.m_nEmittingVolume -= sample.m_nVolumeChange; -#else sample.m_nVolume -= sample.m_nVolumeChange; -#endif } -#ifdef FIX_BUGS - if(CTimer::GetLogicalFramesPassed() != 0) + sample.m_nFramesToPlay--; #endif - --sample.m_nFramesToPlay; if (m_bReduceReleasingPriority) { if (sample.m_nPriority < 20) - ++sample.m_nPriority; + sample.m_nPriority++; } sample.m_bStatic = FALSE; } @@ -854,6 +947,16 @@ cAudioManager::ProcessActiveQueues() uint8 emittingVol; CVector position; +#ifdef EXTERNAL_3D_SOUND + #define WORKING_VOLUME_FIELD m_nEmittingVolume +#else + #define WORKING_VOLUME_FIELD m_nVolume +#endif + +#ifdef USE_TIME_SCALE_FOR_AUDIO + float timeScale = m_nUserPause ? 1.0f : CTimer::GetTimeScale(); +#endif + for (int32 i = 0; i < m_nActiveSamples; i++) { m_asSamples[m_nActiveSampleQueue][i].m_bIsBeingPlayed = FALSE; m_asActiveSamples[i].m_bIsBeingPlayed = FALSE; @@ -891,12 +994,12 @@ cAudioManager::ProcessActiveQueues() sample.m_nVolumeChange = -1; if (!sample.m_bStatic) { if (sample.m_bIs2D) { -#ifdef EXTERNAL_3D_SOUND - emittingVol = m_bDoubleVolume ? 2 * Min(63, sample.m_nEmittingVolume) : sample.m_nEmittingVolume; + emittingVol = m_bDoubleVolume ? 2 * Min(63, sample.WORKING_VOLUME_FIELD) : sample.WORKING_VOLUME_FIELD; +#ifdef USE_TIME_SCALE_FOR_AUDIO + SampleManager.SetChannelFrequency(j, sample.m_nFrequency * timeScale); #else - emittingVol = m_bDoubleVolume ? 2 * Min(63, sample.m_nVolume) : sample.m_nVolume; -#endif SampleManager.SetChannelFrequency(j, sample.m_nFrequency); +#endif #ifdef EXTERNAL_3D_SOUND SampleManager.SetChannelEmittingVolume(j, emittingVol); #else @@ -904,24 +1007,6 @@ cAudioManager::ProcessActiveQueues() SampleManager.SetChannelVolume(j, sample.m_nVolume); #endif } else { -#ifdef ATTACH_PED_COMMENTS_TO_ENTITIES - if (sample.m_nCounter <= 255 && sample.m_nSampleIndex >= SAMPLEBANK_PED_START && sample.m_nSampleIndex <= SAMPLEBANK_PED_END) { - CEntity* entity = (CEntity*)GetEntityPointer(sample.m_nEntityIndex); - if (entity && m_asAudioEntities[sample.m_nEntityIndex].m_nType == AUDIOTYPE_PHYSICAL) { - sample.m_vecPos = entity->GetPosition(); - sample.m_fDistance = Sqrt(GetDistanceSquared(sample.m_vecPos)); - uint8 vol; - if (CWorld::GetIsLineOfSightClear(TheCamera.GetPosition(), sample.m_vecPos, true, false, false, false, false, false)) - vol = MAX_VOLUME; - else - vol = 31; -#ifdef EXTERNAL_3D_SOUND - sample.m_nEmittingVolume = vol; -#endif - sample.m_nVolume = ComputeVolume(vol, sample.m_MaxDistance, sample.m_fDistance); - } - } -#endif position2 = sample.m_fDistance; position1 = m_asActiveSamples[j].m_fDistance; m_asActiveSamples[j].m_fDistance = sample.m_fDistance; @@ -929,7 +1014,11 @@ cAudioManager::ProcessActiveQueues() if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) { uint32 freq = Clamp2((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency, 6000); m_asActiveSamples[j].m_nFrequency = freq; +#ifdef USE_TIME_SCALE_FOR_AUDIO + SampleManager.SetChannelFrequency(j, freq * timeScale); +#else SampleManager.SetChannelFrequency(j, freq); +#endif } #ifdef EXTERNAL_3D_SOUND @@ -942,8 +1031,8 @@ cAudioManager::ProcessActiveQueues() if (sample.m_nVolume != m_asActiveSamples[j].m_nVolume) { vol = Clamp2((int8)sample.m_nVolume, (int8)m_asActiveSamples[j].m_nVolume, 10); m_asActiveSamples[j].m_nVolume = vol; - SampleManager.SetChannelVolume(j, m_bDoubleVolume ? 2 * Min(63, vol) : vol); } + SampleManager.SetChannelVolume(j, m_bDoubleVolume ? 2 * Min(63, vol) : vol); #endif TranslateEntity(&sample.m_vecPos, &position); #ifdef EXTERNAL_3D_SOUND @@ -996,18 +1085,18 @@ cAudioManager::ProcessActiveQueues() m_asActiveSamples[j].m_nPan = ComputePan(m_asActiveSamples[j].m_fDistance, &position); #endif } -#ifdef EXTERNAL_3D_SOUND - emittingVol = m_bDoubleVolume ? 2 * Min(63, m_asActiveSamples[j].m_nEmittingVolume) : m_asActiveSamples[j].m_nEmittingVolume; -#else - emittingVol = m_bDoubleVolume ? 2 * Min(63, m_asActiveSamples[j].m_nVolume) : m_asActiveSamples[j].m_nVolume; -#endif + emittingVol = m_bDoubleVolume ? 2 * Min(63, m_asActiveSamples[j].WORKING_VOLUME_FIELD) : m_asActiveSamples[j].WORKING_VOLUME_FIELD; #ifdef GTA_PS2 { SampleManager.InitialiseChannel(j, m_asActiveSamples[j].m_nSampleIndex, m_asActiveSamples[j].m_nBankIndex); #else if (SampleManager.InitialiseChannel(j, m_asActiveSamples[j].m_nSampleIndex, m_asActiveSamples[j].m_nBankIndex)) { #endif +#ifdef USE_TIME_SCALE_FOR_AUDIO + SampleManager.SetChannelFrequency(j, m_asActiveSamples[j].m_nFrequency * timeScale); +#else SampleManager.SetChannelFrequency(j, m_asActiveSamples[j].m_nFrequency); +#endif #ifdef EXTERNAL_3D_SOUND SampleManager.SetChannelEmittingVolume(j, emittingVol); #else @@ -1016,8 +1105,8 @@ cAudioManager::ProcessActiveQueues() #endif #ifndef GTA_PS2 SampleManager.SetChannelLoopPoints(j, m_asActiveSamples[j].m_nLoopStart, m_asActiveSamples[j].m_nLoopEnd); - SampleManager.SetChannelLoopCount(j, m_asActiveSamples[j].m_nLoopCount); #endif + SampleManager.SetChannelLoopCount(j, m_asActiveSamples[j].m_nLoopCount); SampleManager.SetChannelReverbFlag(j, m_asActiveSamples[j].m_bReverb); #ifdef EXTERNAL_3D_SOUND if (m_asActiveSamples[j].m_bIs2D) { @@ -1051,6 +1140,15 @@ cAudioManager::ProcessActiveQueues() } } } + +#ifdef USE_TIME_SCALE_FOR_AUDIO + for (uint8 i = 0; i < m_nActiveSamples; i++) { + if (m_asActiveSamples[i].m_nSampleIndex != NO_SAMPLE && m_asActiveSamples[i].m_bIsBeingPlayed) + SampleManager.SetChannelFrequency(i, m_asActiveSamples[i].m_nFrequency * timeScale); + } +#endif + + #undef WORKING_VOLUME_FIELD } void diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 39fa9288..a76ef67b 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -47,8 +47,12 @@ public: // 0 = L 100% R 0% // 63 = L 100% R 100% // 127 = L 0% R 100% +#ifndef FIX_BUGS uint32 m_nFramesToPlay; // Number of frames the sound would be played (if it stops being queued). // This one is being set by queued sample for looping sounds, otherwise calculated inside AudioManager +#else + float m_nFramesToPlay; // Made into float for high fps fix +#endif // all fields below are internal to AudioManager calculations and aren't set by queued sample bool8 m_bIsBeingPlayed; // Set to TRUE when the sound was added or changed on current frame to avoid it being overwritten @@ -60,6 +64,9 @@ public: #endif uint32 m_nFinalPriority; // Actual value used to compare priority, calculated using volume and m_nPriority. Lesser value means higher priority int8 m_nVolumeChange; // How much m_nVolume should reduce per each frame. +#if defined(FIX_BUGS) && defined(EXTERNAL_3D_SOUND) + int8 m_nEmittingVolumeChange; // same as above but for m_nEmittingVolume +#endif }; VALIDATE_SIZE(tSound, 92); diff --git a/src/audio/PolRadio.cpp b/src/audio/PolRadio.cpp index 553cf287..7688566b 100644 --- a/src/audio/PolRadio.cpp +++ b/src/audio/PolRadio.cpp @@ -260,7 +260,11 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) default: freq = SampleManager.GetSampleBaseFrequency(sample); break; } PoliceChannelFreq = freq; +#ifdef USE_TIME_SCALE_FOR_AUDIO + SampleManager.SetChannelFrequency(CHANNEL_POLICE_RADIO, freq * CTimer::GetTimeScale()); +#else SampleManager.SetChannelFrequency(CHANNEL_POLICE_RADIO, freq); +#endif SampleManager.SetChannelVolume(CHANNEL_POLICE_RADIO, 100); SampleManager.SetChannelPan(CHANNEL_POLICE_RADIO, 63); #ifndef GTA_PS2 diff --git a/src/core/config.h b/src/core/config.h index c04dfdf1..625075c5 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -438,7 +438,8 @@ enum Config { //#define AUDIO_OAL_USE_SNDFILE // use libsndfile to decode WAVs instead of our internal decoder #define AUDIO_OAL_USE_MPG123 // use mpg123 to support mp3 files #define PAUSE_RADIO_IN_FRONTEND // pause radio when game is paused -#define ATTACH_PED_COMMENTS_TO_ENTITIES // ped comments coordinates would update following ped entity +#define ATTACH_RELEASING_SOUNDS_TO_ENTITIES // sounds would follow ped and vehicles coordinates if not being queued otherwise +#define USE_TIME_SCALE_FOR_AUDIO // slow down/speed up sounds according to the speed of the game #define MULTITHREADED_AUDIO // for streams. requires C++11 or later #ifdef AUDIO_OPUS -- cgit v1.2.3