From be638a497387e417b3b825cb2e6fde4fa5f72fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Wed, 19 Aug 2020 20:30:57 +0300 Subject: Revert "remove CFO" This reverts commit 0418ba597bc53d08d0244188f4623ebadfdd2876. --- src/core/Frontend.cpp | 150 +++++++++++++++++++++++++++++++++++- src/core/Frontend.h | 5 +- src/core/Game.cpp | 5 ++ src/core/MenuScreens.cpp | 21 +---- src/core/config.h | 1 + src/core/re3.cpp | 112 +++++++++++++++++++++++++++ src/extras/frontendoption.cpp | 173 ++++++++++++++++++++++++++++++++++++++++++ src/extras/frontendoption.h | 87 +++++++++++++++++++++ 8 files changed, 533 insertions(+), 21 deletions(-) create mode 100644 src/extras/frontendoption.cpp create mode 100644 src/extras/frontendoption.h diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index d82c5df4..0c813cbb 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -36,6 +36,7 @@ #include "Stats.h" #include "Messages.h" #include "FileLoader.h" +#include "frontendoption.h" #define TIDY_UP_PBP // ProcessButtonPresses #define MAX_VISIBLE_LIST_ROW 30 @@ -431,12 +432,46 @@ CMenuManager::ThingsToDoBeforeGoingBack() if ((m_nCurrScreen == MENUPAGE_SKIN_SELECT) || (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS)) { m_nTotalListRow = 0; } + +#ifdef CUSTOM_FRONTEND_OPTIONS + for (int i = 0; i < numCustomFrontendOptions; i++) { + FrontendOption &option = customFrontendOptions[i]; + if (option.type != FEOPTION_REDIRECT && option.type != FEOPTION_GOBACK && m_nCurrScreen == option.screen) { + if (option.returnPrevPageFunc) + option.returnPrevPageFunc(); + + if (m_nCurrOption == option.screenOptionOrder && option.type == FEOPTION_DYNAMIC) + option.buttonPressFunc(FEOPTION_ACTION_FOCUSLOSS); + + if (option.onlyApplyOnEnter) + option.displayedValue = *option.value; + } + } +#endif } int8 CMenuManager::GetPreviousPageOption() { +#ifndef CUSTOM_FRONTEND_OPTIONS + return !m_bGameNotLoaded ? aScreens[m_nCurrScreen].m_ParentEntry[1] : aScreens[m_nCurrScreen].m_ParentEntry[0]; +#else + int8 prevPage = !m_bGameNotLoaded ? aScreens[m_nCurrScreen].m_PreviousPage[1] : aScreens[m_nCurrScreen].m_PreviousPage[0]; + + if (prevPage == -1) // Game also does same + return 0; + + prevPage = prevPage == MENUPAGE_NONE ? (!m_bGameNotLoaded ? MENUPAGE_PAUSE_MENU : MENUPAGE_START_MENU) : prevPage; + + for (int i = 0; i < NUM_MENUROWS; i++) { + if (aScreens[prevPage].m_aEntries[i].m_TargetMenu == m_nCurrScreen) { + return i; + } + } + + // Couldn't find current screen option on previous page, use default behaviour (maybe save-related screen?) return !m_bGameNotLoaded ? aScreens[m_nCurrScreen].m_ParentEntry[1] : aScreens[m_nCurrScreen].m_ParentEntry[0]; +#endif } // ------ Functions not in the game/inlined ends @@ -955,7 +990,14 @@ CMenuManager::Draw() } #endif +#ifdef CUSTOM_FRONTEND_OPTIONS + static int lastOption = m_nCurrOption; +#endif + for (int i = 0; i < NUM_MENUROWS; ++i) { +#ifdef CUSTOM_FRONTEND_OPTIONS + bool isOptionDisabled = false; +#endif if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action != MENUACTION_LABEL && aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName[0] != '\0') { wchar *rightText = nil; wchar *leftText; @@ -1232,6 +1274,29 @@ CMenuManager::Draw() rightText = TheText.Get(gPS2alphaTest ? "FEM_ON" : "FEM_OFF"); break; #endif +#ifdef CUSTOM_FRONTEND_OPTIONS + case MENUACTION_TRIGGERFUNC: + FrontendOption& option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[i].m_TargetMenu]; + if (m_nCurrScreen == option.screen && i == option.screenOptionOrder) { + leftText = (wchar*)option.leftText; + if (option.type == FEOPTION_SELECT) { + if (option.displayedValue >= option.numRightTexts || option.displayedValue < 0) + option.displayedValue = 0; + + rightText = (wchar*)option.rightTexts[option.displayedValue]; + + } else if (option.type == FEOPTION_DYNAMIC) { + if (option.drawFunc) { + rightText = option.drawFunc(&isOptionDisabled); + } + } + } else { + debug("A- screen:%d option:%d - totalCo: %d, coId: %d, coScreen:%d, coOption:%d\n", m_nCurrScreen, i, numCustomFrontendOptions, aScreens[m_nCurrScreen].m_aEntries[i].m_TargetMenu, option.screen, option.screenOptionOrder); + assert(0 && "Custom frontend options is borked"); + } + + break; +#endif } float nextItemY = headerHeight + nextYToUse; @@ -1318,7 +1383,11 @@ CMenuManager::Draw() || !strcmp(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName, "FED_AAS") #endif ) - && !m_bGameNotLoaded) + && !m_bGameNotLoaded +#ifdef CUSTOM_FRONTEND_OPTIONS + || isOptionDisabled +#endif + ) CFont::SetColor(CRGBA(155, 117, 6, FadeIn(255))); CFont::PrintString(MENU_X_RIGHT_ALIGNED(columnWidth - textLayer), itemY, rightText); @@ -1428,6 +1497,20 @@ CMenuManager::Draw() } #endif +#ifdef CUSTOM_FRONTEND_OPTIONS + if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action == MENUACTION_TRIGGERFUNC) { + FrontendOption &option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[i].m_TargetMenu]; + if (option.onlyApplyOnEnter && m_nCurrOption != i) + option.displayedValue = *option.value; + + if (m_nCurrOption != lastOption && lastOption == i) { + FrontendOption &oldOption = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[lastOption].m_TargetMenu]; + if (oldOption.type == FEOPTION_DYNAMIC) + oldOption.buttonPressFunc(FEOPTION_ACTION_FOCUSLOSS); + } + } +#endif + // Sliders int lastActiveBarX; switch (aScreens[m_nCurrScreen].m_aEntries[i].m_Action) { @@ -1471,6 +1554,10 @@ CMenuManager::Draw() } } +#ifdef CUSTOM_FRONTEND_OPTIONS + lastOption = m_nCurrOption; +#endif + switch (m_nCurrScreen) { case MENUPAGE_CONTROLLER_SETTINGS: case MENUPAGE_SOUND_SETTINGS: @@ -3128,6 +3215,10 @@ CMenuManager::InitialiseChangedLanguageSettings() default: break; } + +#ifdef CUSTOM_FRONTEND_OPTIONS + CustomFrontendOptionsPopulate(); +#endif } } @@ -5005,6 +5096,33 @@ CMenuManager::ProcessButtonPresses(void) RequestFrontEndShutDown(); RetryMission(2, 0); return; +#endif +#ifdef CUSTOM_FRONTEND_OPTIONS + case MENUACTION_TRIGGERFUNC: + FrontendOption& option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu]; + if (m_nCurrScreen == option.screen && m_nCurrOption == option.screenOptionOrder) { + if (option.type == FEOPTION_SELECT) { + if (!option.onlyApplyOnEnter) { + option.displayedValue++; + if (option.displayedValue >= option.numRightTexts || option.displayedValue < 0) + option.displayedValue = 0; + } + option.changeFunc(option.displayedValue); + *option.value = option.displayedValue; + + } else if (option.type == FEOPTION_DYNAMIC) { + option.buttonPressFunc(FEOPTION_ACTION_SELECT); + } else if (option.type == FEOPTION_REDIRECT) { + ChangeScreen(option.to, option.option, true, option.fadeIn); + } else if (option.type == FEOPTION_GOBACK) { + goBack = true; + } + } else { + debug("B- screen:%d option:%d - totalCo: %d, coId: %d, coScreen:%d, coOption:%d\n", m_nCurrScreen, m_nCurrOption, numCustomFrontendOptions, aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu, option.screen, option.screenOptionOrder); + assert(0 && "Custom frontend options are borked"); + } + + break; #endif } } @@ -5236,6 +5354,36 @@ CMenuManager::ProcessButtonPresses(void) DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); SaveSettings(); break; +#ifdef CUSTOM_FRONTEND_OPTIONS + case MENUACTION_TRIGGERFUNC: + FrontendOption& option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu]; + if (m_nCurrScreen == option.screen && m_nCurrOption == option.screenOptionOrder) { + if (option.type == FEOPTION_SELECT) { + if (changeValueBy > 0) { + option.displayedValue++; + if (option.displayedValue >= option.numRightTexts) + option.displayedValue = 0; + } else { + option.displayedValue--; + if (option.displayedValue < 0) + option.displayedValue = option.numRightTexts - 1; + } + if (!option.onlyApplyOnEnter) { + option.changeFunc(option.displayedValue); + *option.value = option.displayedValue; + } + } else if (option.type == FEOPTION_DYNAMIC) { + option.buttonPressFunc(changeValueBy > 0 ? FEOPTION_ACTION_RIGHT : FEOPTION_ACTION_LEFT); + } + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); + } + else { + debug("C- screen:%d option:%d - totalCo: %d, coId: %d, coScreen:%d, coOption:%d\n", m_nCurrScreen, m_nCurrOption, numCustomFrontendOptions, aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu, option.screen, option.screenOptionOrder); + assert(0 && "Custom frontend options are borked"); + } + + break; +#endif } ProcessOnOffMenuOptions(); if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { diff --git a/src/core/Frontend.h b/src/core/Frontend.h index cf112b3d..fa3652a1 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -381,6 +381,9 @@ enum eMenuAction #ifdef CUTSCENE_BORDERS_SWITCH MENUACTION_CUTSCENEBORDERS, #endif +#ifdef CUSTOM_FRONTEND_OPTIONS + MENUACTION_TRIGGERFUNC +#endif }; enum eCheckHover @@ -475,7 +478,7 @@ struct CMenuScreen int32 m_Action; // eMenuAction char m_EntryName[8]; int32 m_SaveSlot; // eSaveSlot - int32 m_TargetMenu; // eMenuScreen + int32 m_TargetMenu; // eMenuScreen // FrontendOption ID if it's a custom option } m_aEntries[NUM_MENUROWS]; }; diff --git a/src/core/Game.cpp b/src/core/Game.cpp index a95c479a..c0530709 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -86,6 +86,7 @@ #include "ZoneCull.h" #include "Zones.h" #include "debugmenu.h" +#include "frontendoption.h" #include "postfx.h" #include "custompipes.h" @@ -292,6 +293,10 @@ bool CGame::InitialiseOnceAfterRW(void) DMAudio.SetEffectsFadeVol(127); DMAudio.SetMusicFadeVol(127); CWorld::Players[0].SetPlayerSkin(CMenuManager::m_PrefsSkinFile); + +#ifdef CUSTOM_FRONTEND_OPTIONS + CustomFrontendOptionsPopulate(); +#endif return true; } diff --git a/src/core/MenuScreens.cpp b/src/core/MenuScreens.cpp index 5dfcc8fe..02c004b3 100644 --- a/src/core/MenuScreens.cpp +++ b/src/core/MenuScreens.cpp @@ -2,6 +2,8 @@ #include "Frontend.h" #ifdef PC_MENU +// If you want to add new options, please don't do that here and see CustomFrontendOptionsPopulate in re3.cpp. + #ifdef CUTSCENE_BORDERS_SWITCH #define MENU_CUTSCENE_BORDERS_SWITCH(screen) MENUACTION_CUTSCENEBORDERS, "FEM_CSB", SAVESLOT_NONE, screen, #else @@ -45,11 +47,7 @@ CMenuScreen aScreens[] = { { "", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_STATS = 1 -#ifdef MENU_MAP - { "FET_STA", 1, MENUPAGE_NONE, MENUPAGE_NONE, 5, 3, -#else { "FET_STA", 1, MENUPAGE_NONE, MENUPAGE_NONE, 5, 2, -#endif MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, @@ -62,11 +60,7 @@ CMenuScreen aScreens[] = { }, // MENUPAGE_BRIEFS = 3 -#ifdef MENU_MAP - { "FET_BRE", 1, MENUPAGE_NONE, MENUPAGE_NONE, 6, 4, -#else { "FET_BRE", 1, MENUPAGE_NONE, MENUPAGE_NONE, 6, 3, -#endif MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, @@ -381,11 +375,7 @@ CMenuScreen aScreens[] = { }, // MENUPAGE_OPTIONS = 41 -#ifdef MENU_MAP - { "FET_OPT", 1, MENUPAGE_NONE, MENUPAGE_NONE, 1, 5, -#else { "FET_OPT", 1, MENUPAGE_NONE, MENUPAGE_NONE, 1, 4, -#endif MENUACTION_CHANGEMENU, "FET_CTL", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, MENUACTION_LOADRADIO, "FET_AUD", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, MENUACTION_CHANGEMENU, "FET_DIS", SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS, @@ -398,11 +388,7 @@ CMenuScreen aScreens[] = { }, // MENUPAGE_EXIT = 42 -#ifdef MENU_MAP - { "FET_QG", 1, MENUPAGE_NONE, MENUPAGE_NONE, 2, 6, -#else { "FET_QG", 1, MENUPAGE_NONE, MENUPAGE_NONE, 2, 5, -#endif MENUACTION_LABEL, "FEQ_SRE", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_DONTCANCEL, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CANCELGAME, "FEM_YES", SAVESLOT_NONE, MENUPAGE_NONE, @@ -463,9 +449,6 @@ CMenuScreen aScreens[] = { { "FET_PAU", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_RESUME, "FEM_RES", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEN_STA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, -#ifdef MENU_MAP - MENUACTION_CHANGEMENU, "FEG_MAP", SAVESLOT_NONE, MENUPAGE_MAP, -#endif MENUACTION_CHANGEMENU, "FEP_STA", SAVESLOT_NONE, MENUPAGE_STATS, MENUACTION_CHANGEMENU, "FEP_BRI", SAVESLOT_NONE, MENUPAGE_BRIEFS, MENUACTION_CHANGEMENU, "FET_OPT", SAVESLOT_NONE, MENUPAGE_OPTIONS, diff --git a/src/core/config.h b/src/core/config.h index 8e91853d..ac3ba109 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -248,6 +248,7 @@ enum Config { # define SCROLLABLE_STATS_PAGE // only draggable by mouse atm # define TRIANGLE_BACK_BUTTON //# define CIRCLE_BACK_BUTTON +# define CUSTOM_FRONTEND_OPTIONS # define GRAPHICS_MENU_OPTIONS #endif diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 27ec336d..dd116e27 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -71,6 +71,115 @@ mysrand(unsigned int seed) myrand_seed = seed; } +#ifdef CUSTOM_FRONTEND_OPTIONS +#include "frontendoption.h" +#include "platform.h" + +void ReloadFrontendOptions(void) +{ + CustomFrontendOptionsPopulate(); +} + +#ifdef MORE_LANGUAGES +void LangPolSelect(int8 action) +{ + if (action == FEOPTION_ACTION_SELECT) { + FrontEndMenuManager.m_PrefsLanguage = CMenuManager::LANGUAGE_POLISH; + FrontEndMenuManager.m_bFrontEnd_ReloadObrTxtGxt = true; + FrontEndMenuManager.InitialiseChangedLanguageSettings(); + FrontEndMenuManager.SaveSettings(); + } +} + +void LangRusSelect(int8 action) +{ + if (action == FEOPTION_ACTION_SELECT) { + FrontEndMenuManager.m_PrefsLanguage = CMenuManager::LANGUAGE_RUSSIAN; + FrontEndMenuManager.m_bFrontEnd_ReloadObrTxtGxt = true; + FrontEndMenuManager.InitialiseChangedLanguageSettings(); + FrontEndMenuManager.SaveSettings(); + } +} + +void LangJapSelect(int8 action) +{ + if (action == FEOPTION_ACTION_SELECT) { + FrontEndMenuManager.m_PrefsLanguage = CMenuManager::LANGUAGE_JAPANESE; + FrontEndMenuManager.m_bFrontEnd_ReloadObrTxtGxt = true; + FrontEndMenuManager.InitialiseChangedLanguageSettings(); + FrontEndMenuManager.SaveSettings(); + } +} +#endif + +/*#ifdef IMPROVED_VIDEOMODE +void ScreenModeChange(int8 displayedValue) +{ + if (displayedValue != FrontEndMenuManager.m_nPrefsWindowed) { + FrontEndMenuManager.m_nPrefsWindowed = displayedValue; + _psSelectScreenVM(FrontEndMenuManager.m_nPrefsVideoMode); // apply same resolution + FrontEndMenuManager.SetHelperText(0); + FrontEndMenuManager.SaveSettings(); + } +} +#endif*/ + +#ifdef FREE_CAM +void ToggleFreeCam(int8 action) +{ + if (action == FEOPTION_ACTION_SELECT) { + TheCamera.bFreeCam = !TheCamera.bFreeCam; + FrontEndMenuManager.SaveSettings(); + } +} +#endif + +//#ifdef CUTSCENE_BORDERS_SWITCH +//void BorderModeChange(int8 displayedValue) +//{ +// CMenuManager::m_PrefsCutsceneBorders = !!displayedValue; +// FrontEndMenuManager.SaveSettings(); +//} +//#endif + +// Reloaded on language change, so you can use hardcoded wchar* and TheText.Get with peace of mind +void +CustomFrontendOptionsPopulate(void) +{ + RemoveCustomFrontendOptions(); // if exist + +#ifdef MORE_LANGUAGES + FrontendOptionSetPosition(MENUPAGE_LANGUAGE_SETTINGS); + FrontendOptionAddDynamic(TheText.Get("FEL_POL"), nil, LangPolSelect, nil); + FrontendOptionAddDynamic(TheText.Get("FEL_RUS"), nil, LangRusSelect, nil); + FrontendOptionAddDynamic(TheText.Get("FEL_JAP"), nil, LangJapSelect, nil); +#endif + +/*#ifdef IMPROVED_VIDEOMODE + static const wchar *screenModes[] = { (wchar*)L"FULLSCREEN", (wchar*)L"WINDOWED" }; + FrontendOptionSetPosition(MENUPAGE_GRAPHICS_SETTINGS, 8); + FrontendOptionAddSelect(TheText.Get("SCRFOR"), screenModes, 2, (int8*)&FrontEndMenuManager.m_nPrefsWindowed, true, ScreenModeChange, nil); +#endif*/ + +#ifdef MENU_MAP + FrontendOptionSetPosition(MENUPAGE_PAUSE_MENU, 2); + FrontendOptionAddRedirect(TheText.Get("FEG_MAP"), MENUPAGE_MAP); +#endif + +#ifdef FREE_CAM + static const wchar *text = (wchar*)L"TOGGLE FREE CAM"; + FrontendOptionSetPosition(MENUPAGE_CONTROLLER_PC, 1); + FrontendOptionAddDynamic(text, nil, ToggleFreeCam, nil); +#endif + +/*#ifdef CUTSCENE_BORDERS_SWITCH + static const wchar *off_on[] = { TheText.Get("FEM_OFF"), TheText.Get("FEM_ON") }; + FrontendOptionSetPosition(MENUPAGE_DISPLAY_SETTINGS, 3); + FrontendOptionAddSelect((const wchar *)L"CUTSCENE BORDERS", off_on, 2, (int8 *)&CMenuManager::m_PrefsCutsceneBorders, false, BorderModeChange, nil); +#endif*/ +} +#endif + #ifdef DEBUGMENU void WeaponCheat(); void HealthCheat(); @@ -405,6 +514,9 @@ DebugMenuPopulate(void) DebugMenuAddCmd("Debug", "Catalina Fly Away", CHeli::MakeCatalinaHeliFlyAway); DebugMenuAddVarBool8("Debug", "Script Heli On", &CHeli::ScriptHeliOn, nil); +#ifdef CUSTOM_FRONTEND_OPTIONS + DebugMenuAddCmd("Debug", "Reload custom frontend options", ReloadFrontendOptions); +#endif DebugMenuAddVarBool8("Debug", "Toggle popping heads on headshot", &CPed::bPopHeadsOnHeadshot, nil); DebugMenuAddCmd("Debug", "Start Credits", CCredits::Start); DebugMenuAddCmd("Debug", "Stop Credits", CCredits::Stop); diff --git a/src/extras/frontendoption.cpp b/src/extras/frontendoption.cpp new file mode 100644 index 00000000..51814f35 --- /dev/null +++ b/src/extras/frontendoption.cpp @@ -0,0 +1,173 @@ +#include "common.h" + +#ifdef CUSTOM_FRONTEND_OPTIONS +#include "frontendoption.h" + +int numCustomFrontendOptions = 0; +FrontendOption *customFrontendOptions; + +int optionCursor = -1; +eMenuScreen currentMenu; + +void ChangeScreen(eMenuScreen screen, int option, bool fadeIn) +{ + FrontEndMenuManager.m_nPrevScreen = FrontEndMenuManager.m_nCurrScreen; + FrontEndMenuManager.m_nCurrScreen = screen; + FrontEndMenuManager.m_nCurrOption = option; + if (fadeIn) + FrontEndMenuManager.m_nMenuFadeAlpha = 0; +} + +void GoBack(bool fadeIn) +{ + int screen = !FrontEndMenuManager.m_bGameNotLoaded ? + aScreens[FrontEndMenuManager.m_nCurrScreen].m_PreviousPage[1] : aScreens[FrontEndMenuManager.m_nCurrScreen].m_PreviousPage[0]; + int option = !FrontEndMenuManager.m_bGameNotLoaded ? + aScreens[FrontEndMenuManager.m_nCurrScreen].m_ParentEntry[1] : aScreens[FrontEndMenuManager.m_nCurrScreen].m_ParentEntry[0]; + + FrontEndMenuManager.ThingsToDoBeforeGoingBack(); + + ChangeScreen((eMenuScreen)screen, option, fadeIn); +} + +uint8 +GetNumberOfMenuOptions(int screen) +{ + uint8 Rows = 0; + for (int i = 0; i < NUM_MENUROWS; i++) { + if (aScreens[screen].m_aEntries[i].m_Action == MENUACTION_NOTHING) + break; + + ++Rows; + } + return Rows; +} + +// Used before populating options, but effective in InitialiseChangedLanguageSettings and debugmenu +void +RemoveCustomFrontendOptions() +{ + if (numCustomFrontendOptions == 0) + return; + + for (int i = 0; i < MENUPAGES; i++) { + for (int j = 0; j < NUM_MENUROWS; j++) { + if (aScreens[i].m_aEntries[j].m_Action == MENUACTION_TRIGGERFUNC) { + int k; + for (k = j; k < NUM_MENUROWS-1; k++) { + memcpy(&aScreens[i].m_aEntries[k], &aScreens[i].m_aEntries[k+1], sizeof(CMenuScreen::CMenuEntry)); + } + aScreens[i].m_aEntries[k].m_Action = MENUACTION_NOTHING; + aScreens[i].m_aEntries[k].m_EntryName[0] = '\0'; + j--; + } + } + } + free(customFrontendOptions); + numCustomFrontendOptions = 0; +} + +int8 RegisterNewOption(int screen) +{ + numCustomFrontendOptions++; + if (numCustomFrontendOptions == 1) + customFrontendOptions = (FrontendOption*)malloc(5 * sizeof(FrontendOption)); + else if (numCustomFrontendOptions % 5 == 1) + customFrontendOptions = (FrontendOption*)realloc(customFrontendOptions, (numCustomFrontendOptions + 4) * sizeof(FrontendOption)); + + assert(customFrontendOptions != nil && "Custom frontend options can't be allocated"); + + uint8 nth = GetNumberOfMenuOptions(screen); + if (optionCursor < 0) { + if (optionCursor == -1) { + if (!strcmp(aScreens[screen].m_aEntries[nth - 1].m_EntryName, "FEDS_TB") || !strcmp(aScreens[screen].m_aEntries[nth - 1].m_EntryName, "FESZ_CA")) { + // Move back button one below + memcpy(&aScreens[screen].m_aEntries[nth], &aScreens[screen].m_aEntries[nth - 1], sizeof(CMenuScreen::CMenuEntry)); + nth--; + } + } + } else { + if (aScreens[screen].m_aEntries[optionCursor].m_Action != MENUACTION_NOTHING) { + for (int i = nth - 1; i >= optionCursor; i--) { + memcpy(&aScreens[screen].m_aEntries[i + 1], &aScreens[screen].m_aEntries[i], sizeof(CMenuScreen::CMenuEntry)); + } + } + nth = optionCursor; + optionCursor++; + } + + aScreens[screen].m_aEntries[nth].m_Action = MENUACTION_TRIGGERFUNC; + aScreens[screen].m_aEntries[nth].m_TargetMenu = numCustomFrontendOptions - 1; + aScreens[screen].m_aEntries[nth].m_EntryName[0] = 1; // just something to fool it + return nth; +} + +void FrontendOptionSetPosition(eMenuScreen screen, int8 option) +{ + currentMenu = screen; + optionCursor = option; +} + +void FrontendOptionAddSelect(const wchar* leftText, const wchar** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, ReturnPrevPageFunc returnPrevPageFunc) +{ + int8 screenOptionOrder = RegisterNewOption(currentMenu); + + FrontendOption& option = customFrontendOptions[numCustomFrontendOptions - 1]; + option.screen = currentMenu; + option.type = FEOPTION_SELECT; + option.leftText = leftText; + option.rightTexts = rightTexts; + option.numRightTexts = numRightTexts; + option.value = var; + option.displayedValue = *var; + option.onlyApplyOnEnter = onlyApplyOnEnter; + option.changeFunc = changeFunc; + option.screenOptionOrder = screenOptionOrder; + option.returnPrevPageFunc = returnPrevPageFunc; +} + +void FrontendOptionAddDynamic(const wchar* leftText, DrawFunc drawFunc, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc) +{ + int8 screenOptionOrder = RegisterNewOption(currentMenu); + + FrontendOption& option = customFrontendOptions[numCustomFrontendOptions - 1]; + option.screen = currentMenu; + option.type = FEOPTION_DYNAMIC; + option.drawFunc = drawFunc; + option.buttonPressFunc = buttonPressFunc; + option.leftText = leftText; + option.onlyApplyOnEnter = false; + option.screenOptionOrder = screenOptionOrder; + option.returnPrevPageFunc = returnPrevPageFunc; +} + +void FrontendOptionAddRedirect(const wchar* text, eMenuScreen to, int8 selectedOption, bool fadeIn) +{ + int8 screenOptionOrder = RegisterNewOption(currentMenu); + + FrontendOption &option = customFrontendOptions[numCustomFrontendOptions - 1]; + option.screen = currentMenu; + option.type = FEOPTION_REDIRECT; + option.to = to; + option.option = selectedOption; + option.fadeIn = fadeIn; + option.leftText = text; + option.onlyApplyOnEnter = false; + option.screenOptionOrder = screenOptionOrder; + option.returnPrevPageFunc = nil; +} + +void FrontendOptionAddBackButton(const wchar* text, bool fadeIn) +{ + int8 screenOptionOrder = RegisterNewOption(currentMenu); + + FrontendOption& option = customFrontendOptions[numCustomFrontendOptions - 1]; + option.screen = currentMenu; + option.type = FEOPTION_GOBACK; + option.fadeIn = fadeIn; + option.leftText = text; + option.onlyApplyOnEnter = false; + option.screenOptionOrder = screenOptionOrder; + option.returnPrevPageFunc = nil; +} +#endif \ No newline at end of file diff --git a/src/extras/frontendoption.h b/src/extras/frontendoption.h new file mode 100644 index 00000000..7cfc09a7 --- /dev/null +++ b/src/extras/frontendoption.h @@ -0,0 +1,87 @@ +#pragma once +#include "common.h" + +#ifdef CUSTOM_FRONTEND_OPTIONS +#include "Frontend.h" + +// Warning: All of the code relies on that you won't use more then NUM_MENUROWS(18) options on one page. Also congrats if you can make 18 options visible at once. + + +// Static/select: User allocates variable, passes it to function and it's set automatically from input among the strings given to function, +// then you can handle ChangeFunc and ReturnPrevPageFunc if needed. +// +// Dynamic: Function doesn't accept value pointer, user should do operations with handling ButtonPressFunc. +// Right-side text can be set via DrawFunc, which is called on every draw. ReturnPrevPageFunc is also here if needed. + +#define FEOPTION_SELECT 0 +#define FEOPTION_DYNAMIC 1 +#define FEOPTION_REDIRECT 2 +#define FEOPTION_GOBACK 3 + +#define FEOPTION_ACTION_LEFT 0 +#define FEOPTION_ACTION_RIGHT 1 +#define FEOPTION_ACTION_SELECT 2 +#define FEOPTION_ACTION_FOCUSLOSS 3 + +void RemoveCustomFrontendOptions(); +void CustomFrontendOptionsPopulate(); + +// for static and dynamic options +typedef void (*ReturnPrevPageFunc)(); + +// for static options +typedef void (*ChangeFunc)(int8 displayedValue); // called before updating the value + +// for dynamic options +typedef wchar* (*DrawFunc)(bool* disabled); // should return pointer to right text. *disabled = true will make it dark yellow +typedef void (*ButtonPressFunc)(int8 action); // see FEOPTION_ACTIONs above + +struct FrontendOption +{ + int8 type; + int8 screenOptionOrder; + eMenuScreen screen; + const wchar* leftText; + ReturnPrevPageFunc returnPrevPageFunc; + + union { + // Only for dynamic + struct { + DrawFunc drawFunc; + ButtonPressFunc buttonPressFunc; + }; + + // Only for static/select + struct { + const wchar** rightTexts; + int8 numRightTexts; + int8 *value; + int8 displayedValue; // if onlyApplyOnEnter enabled + bool onlyApplyOnEnter; + ChangeFunc changeFunc; + }; + + // Only for redirect + struct { + eMenuScreen to; + int8 option; + bool fadeIn; + }; + }; +}; + +extern int numCustomFrontendOptions; +extern FrontendOption* customFrontendOptions; + +// To be used in ButtonPressFunc / ChangeFunc(but that would be weird): +void ChangeScreen(eMenuScreen screen, int option = 0, bool fadeIn = true); +void GoBack(bool fadeIn = true); + +// If option is positive number, all calls will increase it before using it (you can think it as cursor). -1 means before the back button, -2 is end of page +void FrontendOptionSetPosition(eMenuScreen screen, int8 option = -1); + +void FrontendOptionAddSelect(const wchar* leftText, const wchar** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, ReturnPrevPageFunc returnPrevPageFunc); +void FrontendOptionAddDynamic(const wchar* leftText, DrawFunc rightTextDrawFunc, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc); +void FrontendOptionAddRedirect(const wchar* text, eMenuScreen to, int8 selectedOption = 0, bool fadeIn = true); +void FrontendOptionAddBackButton(const wchar* text, bool fadeIn = true); +#endif \ No newline at end of file -- cgit v1.2.3 From 082c4caecfb542e93f5a9a942e51b555e0035279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Mon, 24 Aug 2020 22:42:26 +0300 Subject: new frontend customization --- src/core/Cam.cpp | 2 +- src/core/Frontend.cpp | 716 ++++++++++++++++++------------------------ src/core/Frontend.h | 48 ++- src/core/MenuScreens.cpp | 92 +----- src/core/config.h | 2 +- src/core/re3.cpp | 274 ++++++++++++++-- src/extras/frontendoption.cpp | 233 ++++++++++---- src/extras/frontendoption.h | 121 +++++-- 8 files changed, 851 insertions(+), 637 deletions(-) diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index fcffce9b..3e016667 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -30,7 +30,7 @@ bool PrintDebugCode = false; int16 DebugCamMode; #ifdef FREE_CAM -bool CCamera::bFreeCam; +bool CCamera::bFreeCam = false; int nPreviousMode = -1; #endif diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index d1196042..fbefe354 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -116,7 +116,6 @@ int32 CMenuManager::m_PrefsSfxVolume = 102; bool CMenuManager::m_PrefsCutsceneBorders = true; #endif - #ifdef MULTISAMPLING int8 CMenuManager::m_nPrefsMSAALevel = 0; int8 CMenuManager::m_nDisplayMSAALevel = 0; @@ -160,10 +159,6 @@ int32 MouseButtonJustClicked; int32 JoyButtonJustClicked; //int32 *pControlTemp = 0; -#ifdef PS2_ALPHA_TEST -extern bool gPS2alphaTest; -#endif - #ifndef MASTER bool CMenuManager::m_PrefsMarketing = false; bool CMenuManager::m_PrefsDisableTutorials = false; @@ -402,27 +397,40 @@ CMenuManager::PageDownList(bool playSoundOnSuccess) } } +#ifdef CUSTOM_FRONTEND_OPTIONS +bool ScreenHasOption(int screen, const char* gxtKey) +{ + for (int i = 0; i < NUM_MENUROWS; i++) { + if (strcmp(gxtKey, aScreens[screen].m_aEntries[i].m_EntryName) == 0) + return true; + } + return false; +} +#endif + void CMenuManager::ThingsToDoBeforeGoingBack() { if ((m_nCurrScreen == MENUPAGE_SKIN_SELECT) && strcmp(m_aSkinName, m_PrefsSkinFile) != 0) { CWorld::Players[0].SetPlayerSkin(m_PrefsSkinFile); +#ifdef CUSTOM_FRONTEND_OPTIONS + } else if (ScreenHasOption(m_nCurrScreen, "FEA_3DH")) { +#else } else if (m_nCurrScreen == MENUPAGE_SOUND_SETTINGS) { +#endif if (m_nPrefsAudio3DProviderIndex != -1) m_nPrefsAudio3DProviderIndex = DMAudio.GetCurrent3DProviderIndex(); #ifdef TIDY_UP_PBP DMAudio.StopFrontEndTrack(); OutputDebugString("FRONTEND AUDIO TRACK STOPPED"); #endif -#ifdef GRAPHICS_MENU_OPTIONS - } else if (m_nCurrScreen == MENUPAGE_GRAPHICS_SETTINGS) { + +#ifdef CUSTOM_FRONTEND_OPTIONS + } else if (ScreenHasOption(m_nCurrScreen, "FED_RES")) { #else } else if (m_nCurrScreen == MENUPAGE_DISPLAY_SETTINGS) { #endif m_nDisplayVideoMode = m_nPrefsVideoMode; -#ifdef MULTISAMPLING - m_nDisplayMSAALevel = m_nPrefsMSAALevel; -#endif } if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { @@ -440,11 +448,22 @@ CMenuManager::ThingsToDoBeforeGoingBack() if (option.returnPrevPageFunc) option.returnPrevPageFunc(); - if (m_nCurrOption == option.screenOptionOrder && option.type == FEOPTION_DYNAMIC) - option.buttonPressFunc(FEOPTION_ACTION_FOCUSLOSS); + if (m_nCurrOption == option.screenOptionOrder && (option.type == FEOPTION_DYNAMIC || option.type == FEOPTION_BUILTIN_ACTION)) + if(option.buttonPressFunc) + option.buttonPressFunc(FEOPTION_ACTION_FOCUSLOSS); - if (option.onlyApplyOnEnter) - option.displayedValue = *option.value; + if (option.type == FEOPTION_SELECT && option.onlyApplyOnEnter && option.lastSavedValue != option.displayedValue) + option.displayedValue = *option.value = option.lastSavedValue; + } + } + + if (m_nCurrScreen > lastOgScreen) { + for (int i = 0; i < numCustomFrontendScreens; i++) { + FrontendScreen& screen = customFrontendScreens[i]; + if (m_nCurrScreen == screen.id && screen.returnPrevPageFunc) { + screen.returnPrevPageFunc(); + break; + } } } #endif @@ -464,7 +483,12 @@ CMenuManager::GetPreviousPageOption() prevPage = prevPage == MENUPAGE_NONE ? (!m_bGameNotLoaded ? MENUPAGE_PAUSE_MENU : MENUPAGE_START_MENU) : prevPage; for (int i = 0; i < NUM_MENUROWS; i++) { - if (aScreens[prevPage].m_aEntries[i].m_TargetMenu == m_nCurrScreen) { + if (aScreens[prevPage].m_aEntries[i].m_SaveSlot == SAVESLOT_CFO) { + FrontendOption &option = customFrontendOptions[aScreens[prevPage].m_aEntries[i].m_TargetMenu]; + if(option.type == FEOPTION_REDIRECT && option.to == m_nCurrScreen) { + return i; + } + } else if (aScreens[prevPage].m_aEntries[i].m_TargetMenu == m_nCurrScreen) { return i; } } @@ -879,9 +903,6 @@ CMenuManager::Draw() case MENUPAGE_CONTROLLER_PC_OLD4: case MENUPAGE_CONTROLLER_DEBUG: case MENUPAGE_MOUSE_CONTROLS: -#ifdef GRAPHICS_MENU_OPTIONS - case MENUPAGE_GRAPHICS_SETTINGS: -#endif columnWidth = 50; headerHeight = 0; lineHeight = 20; @@ -937,12 +958,43 @@ CMenuManager::Draw() break; #endif default: - columnWidth = 320; - headerHeight = 40; - lineHeight = 24; - CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING)); - CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE)); - CFont::SetCentreOn(); +#ifdef CUSTOM_FRONTEND_OPTIONS + bool custom = m_nCurrScreen > lastOgScreen; + if (custom) { + for (int i = 0; i < numCustomFrontendScreens; i++) { + FrontendScreen& screen = customFrontendScreens[i]; + if (m_nCurrScreen == screen.id) { + columnWidth = screen.columnWidth; + headerHeight = screen.headerHeight; + lineHeight = screen.lineHeight; + CFont::SetFontStyle(FONT_LOCALE(screen.font)); + CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = screen.fontScaleX), MENU_Y(MENU_TEXT_SIZE_Y = screen.fontScaleY)); + if (screen.alignment == FESCREEN_LEFT_ALIGN) { + CFont::SetCentreOff(); + CFont::SetRightJustifyOff(); + } else if (screen.alignment == FESCREEN_RIGHT_ALIGN) { + CFont::SetCentreOff(); + CFont::SetRightJustifyOn(); + } else { + CFont::SetRightJustifyOff(); + CFont::SetCentreOn(); + } + break; + } + if (i == numCustomFrontendScreens - 1) + custom = false; + } + } + if (!custom) +#endif + { + columnWidth = 320; + headerHeight = 40; + lineHeight = 24; + CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING)); + CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE)); + CFont::SetCentreOn(); + } break; } @@ -1014,6 +1066,12 @@ CMenuManager::Draw() leftText = TheText.Get(gString); } } else { +#ifdef CUSTOM_FRONTEND_OPTIONS + if (aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot == SAVESLOT_CFO){ + FrontendOption& option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[i].m_TargetMenu]; + leftText = (wchar*)option.leftText; + } else +#endif leftText = TheText.Get(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName); } @@ -1180,40 +1238,21 @@ CMenuManager::Draw() AsciiToUnicode(_psGetVideoModeList()[m_nDisplayVideoMode], unicodeTemp); rightText = unicodeTemp; break; -#ifdef IMPROVED_VIDEOMODE - case MENUACTION_SCREENFORMAT: - rightText = TheText.Get(FrontEndMenuManager.m_nSelectedScreenMode ? "FED_WND" : "FED_FLS"); - break; -#endif -#ifdef MULTISAMPLING - case MENUACTION_MULTISAMPLING: - switch (m_nDisplayMSAALevel) { - case 0: - rightText = TheText.Get("FEM_OFF"); - break; - default: - sprintf(gString, "%iX", 1 << (m_nDisplayMSAALevel)); - AsciiToUnicode(gString, unicodeTemp); - rightText = unicodeTemp; - break; - } - break; -#endif -#ifdef NO_ISLAND_LOADING - case MENUACTION_ISLANDLOADING: - switch (m_DisplayIslandLoading) { - case ISLAND_LOADING_LOW: - rightText = TheText.Get("FEM_LOW"); - break; - case ISLAND_LOADING_MEDIUM: - rightText = TheText.Get("FEM_MED"); - break; - case ISLAND_LOADING_HIGH: - rightText = TheText.Get("FEM_HIG"); - break; - } - break; -#endif +//#ifdef NO_ISLAND_LOADING +// case MENUACTION_ISLANDLOADING: +// switch (m_DisplayIslandLoading) { +// case ISLAND_LOADING_LOW: +// rightText = TheText.Get("FEM_LOW"); +// break; +// case ISLAND_LOADING_MEDIUM: +// rightText = TheText.Get("FEM_MED"); +// break; +// case ISLAND_LOADING_HIGH: +// rightText = TheText.Get("FEM_HIG"); +// break; +// } +// break; +//#endif case MENUACTION_AUDIOHW: if (m_nPrefsAudio3DProviderIndex == -1) rightText = TheText.Get("FEA_NAH"); @@ -1264,22 +1303,15 @@ CMenuManager::Draw() case MENUACTION_MOUSESTEER: rightText = TheText.Get(CVehicle::m_bDisableMouseSteering ? "FEM_OFF" : "FEM_ON"); break; -#ifdef CUTSCENE_BORDERS_SWITCH - case MENUACTION_CUTSCENEBORDERS: - rightText = TheText.Get(m_PrefsCutsceneBorders ? "FEM_ON" : "FEM_OFF"); - break; -#endif -#ifdef PS2_ALPHA_TEST - case MENUACTION_PS2_ALPHA_TEST: - rightText = TheText.Get(gPS2alphaTest ? "FEM_ON" : "FEM_OFF"); - break; -#endif #ifdef CUSTOM_FRONTEND_OPTIONS case MENUACTION_TRIGGERFUNC: FrontendOption& option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[i].m_TargetMenu]; if (m_nCurrScreen == option.screen && i == option.screenOptionOrder) { - leftText = (wchar*)option.leftText; if (option.type == FEOPTION_SELECT) { + // To whom manipulate option.value of static options externally (like RestoreDef functions) + if (*option.value != option.lastSavedValue) + option.displayedValue = option.lastSavedValue = *option.value; + if (option.displayedValue >= option.numRightTexts || option.displayedValue < 0) option.displayedValue = 0; @@ -1287,7 +1319,7 @@ CMenuManager::Draw() } else if (option.type == FEOPTION_DYNAMIC) { if (option.drawFunc) { - rightText = option.drawFunc(&isOptionDisabled); + rightText = option.drawFunc(&isOptionDisabled, m_nCurrOption == i); } } } else { @@ -1375,15 +1407,7 @@ CMenuManager::Draw() CFont::SetRightJustifyOn(); if(textLayer == 1) - if((!strcmp(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName, "FED_RES") -#ifdef IMPROVED_VIDEOMODE - || !strcmp(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName, "FEM_SCF") -#endif -#ifdef MULTISAMPLING - || !strcmp(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName, "FED_AAS") -#endif - ) - && !m_bGameNotLoaded + if (!strcmp(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName, "FED_RES") && !m_bGameNotLoaded #ifdef CUSTOM_FRONTEND_OPTIONS || isOptionDisabled #endif @@ -1407,24 +1431,12 @@ CMenuManager::Draw() if (!strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FED_RES") && m_nHelperTextMsgId == 1) ResetHelperText(); } -#ifdef IMPROVED_VIDEOMODE - if (m_nSelectedScreenMode == m_nPrefsWindowed) { - if (!strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEM_SCF") && m_nHelperTextMsgId == 1) - ResetHelperText(); - } -#endif -#ifdef MULTISAMPLING - if (m_nDisplayMSAALevel == m_nPrefsMSAALevel) { - if (!strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FED_AAS") && m_nHelperTextMsgId == 1) - ResetHelperText(); - } -#endif -#ifdef NO_ISLAND_LOADING - if (m_DisplayIslandLoading == m_PrefsIslandLoading) { - if (!strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEM_ISL") && m_nHelperTextMsgId == 1) - ResetHelperText(); - } -#endif +//#ifdef NO_ISLAND_LOADING +// if (m_DisplayIslandLoading == m_PrefsIslandLoading) { +// if (!strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEM_ISL") && m_nHelperTextMsgId == 1) +// ResetHelperText(); +// } +//#endif if (m_nPrefsAudio3DProviderIndex != DMAudio.GetCurrent3DProviderIndex()) { if (!strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEA_3DH")) SetHelperText(1); @@ -1433,27 +1445,19 @@ CMenuManager::Draw() if (!strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FED_RES")) SetHelperText(1); } -#ifdef IMPROVED_VIDEOMODE - if (m_nSelectedScreenMode != m_nPrefsWindowed) { - if (!strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEM_SCF")) - SetHelperText(1); - } -#endif -#ifdef MULTISAMPLING - if (m_nDisplayMSAALevel != m_nPrefsMSAALevel) { - if (!strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FED_AAS")) - SetHelperText(1); - } -#endif -#ifdef NO_ISLAND_LOADING - if (m_DisplayIslandLoading != m_PrefsIslandLoading) { - if (!strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEM_ISL")) - SetHelperText(1); - } -#endif +//#ifdef NO_ISLAND_LOADING +// if (m_DisplayIslandLoading != m_PrefsIslandLoading) { +// if (!strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEM_ISL")) +// SetHelperText(1); +// } +//#endif if (m_nPrefsAudio3DProviderIndex != DMAudio.GetCurrent3DProviderIndex()) { if (strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEA_3DH") != 0 - && m_nCurrScreen == MENUPAGE_SOUND_SETTINGS && m_nPrefsAudio3DProviderIndex != -1) { + // To make assigning built-in actions to new custom options possible. +#ifndef CUSTOM_FRONTEND_OPTIONS + && m_nCurrScreen == MENUPAGE_SOUND_SETTINGS +#endif + && m_nPrefsAudio3DProviderIndex != -1) { m_nPrefsAudio3DProviderIndex = DMAudio.GetCurrent3DProviderIndex(); SetHelperText(3); @@ -1461,52 +1465,46 @@ CMenuManager::Draw() } if (m_nDisplayVideoMode != m_nPrefsVideoMode) { if (strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FED_RES") != 0 -#ifdef GRAPHICS_MENU_OPTIONS - && m_nCurrScreen == MENUPAGE_GRAPHICS_SETTINGS) { + // To make assigning built-in actions to new custom options possible. +#ifdef CUSTOM_FRONTEND_OPTIONS + && ScreenHasOption(m_nCurrScreen, "FED_RES") #else - && m_nCurrScreen == MENUPAGE_DISPLAY_SETTINGS) { + && m_nCurrScreen == MENUPAGE_DISPLAY_SETTINGS #endif + ){ m_nDisplayVideoMode = m_nPrefsVideoMode; SetHelperText(3); } } -#ifdef IMPROVED_VIDEOMODE - if (m_nSelectedScreenMode != m_nPrefsWindowed) { - if (strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEM_SCF") != 0 -#ifdef GRAPHICS_MENU_OPTIONS - && m_nCurrScreen == MENUPAGE_GRAPHICS_SETTINGS) { -#else - && m_nCurrScreen == MENUPAGE_DISPLAY_SETTINGS) { -#endif - m_nSelectedScreenMode = m_nPrefsWindowed; - SetHelperText(3); - } - } -#endif -#ifdef MULTISAMPLING - if (m_nSelectedScreenMode != m_nPrefsWindowed) { - if (strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FED_AAS") != 0 -#ifdef GRAPHICS_MENU_OPTIONS - && m_nCurrScreen == MENUPAGE_GRAPHICS_SETTINGS) { -#else - && m_nCurrScreen == MENUPAGE_DISPLAY_SETTINGS) { -#endif - m_nDisplayMSAALevel = m_nPrefsMSAALevel; - SetHelperText(3); - } - } -#endif #ifdef CUSTOM_FRONTEND_OPTIONS - if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action == MENUACTION_TRIGGERFUNC) { + if (aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot == SAVESLOT_CFO) { FrontendOption &option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[i].m_TargetMenu]; - if (option.onlyApplyOnEnter && m_nCurrOption != i) - option.displayedValue = *option.value; + if (option.type == FEOPTION_SELECT) { + if (option.onlyApplyOnEnter){ + if (m_nCurrOption != i) { + if (option.displayedValue != option.lastSavedValue) + SetHelperText(3); // Restored original value + +// option.displayedValue = option.lastSavedValue = *option.value; + + } else { + if (option.displayedValue != *option.value) + SetHelperText(1); // Enter to apply + else if (m_nHelperTextMsgId == 1) + ResetHelperText(); // Applied + } + } + } if (m_nCurrOption != lastOption && lastOption == i) { FrontendOption &oldOption = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[lastOption].m_TargetMenu]; - if (oldOption.type == FEOPTION_DYNAMIC) - oldOption.buttonPressFunc(FEOPTION_ACTION_FOCUSLOSS); + if (oldOption.type == FEOPTION_DYNAMIC || oldOption.type == FEOPTION_BUILTIN_ACTION) + if(oldOption.buttonPressFunc) + oldOption.buttonPressFunc(FEOPTION_ACTION_FOCUSLOSS); + + if (oldOption.onlyApplyOnEnter && oldOption.type == FEOPTION_SELECT) + oldOption.displayedValue = oldOption.lastSavedValue = *oldOption.value; } } #endif @@ -1565,11 +1563,21 @@ CMenuManager::Draw() case MENUPAGE_SKIN_SELECT: case MENUPAGE_CONTROLLER_PC: case MENUPAGE_MOUSE_CONTROLS: -#ifdef GRAPHICS_MENU_OPTIONS - case MENUPAGE_GRAPHICS_SETTINGS: -#endif DisplayHelperText(); break; +#ifdef CUSTOM_FRONTEND_OPTIONS + default: + if (m_nCurrScreen > lastOgScreen) { + for (int i = 0; i < numCustomFrontendScreens; i++) { + FrontendScreen& screen = customFrontendScreens[i]; + if (m_nCurrScreen == screen.id && screen.showLeftRightHelper) { + DisplayHelperText(); + break; + } + } + } + break; +#endif } if (m_nCurrScreen == MENUPAGE_CONTROLLER_SETTINGS) @@ -2558,7 +2566,22 @@ CMenuManager::DrawFrontEndNormal() previousSprite = MENUSPRITE_PLAYERSET; break; default: - previousSprite = MENUSPRITE_MAINMENU; +#ifdef CUSTOM_FRONTEND_OPTIONS + bool custom = m_nPrevScreen > lastOgScreen; + if (custom) { + for (int i = 0; i < numCustomFrontendScreens; i++) { + FrontendScreen& screen = customFrontendScreens[i]; + if (m_nPrevScreen == screen.id) { + previousSprite = screen.sprite; + break; + } + if (i == numCustomFrontendScreens - 1) + custom = false; + } + } + if (!custom) +#endif + previousSprite = MENUSPRITE_MAINMENU; break; } @@ -2608,6 +2631,20 @@ CMenuManager::DrawFrontEndNormal() case MENUPAGE_OPTIONS: currentSprite = MENUSPRITE_PLAYERSET; break; +#ifdef CUSTOM_FRONTEND_OPTIONS + default: + bool custom = m_nCurrScreen > lastOgScreen; + if (custom) { + for (int i = 0; i < numCustomFrontendScreens; i++) { + FrontendScreen& screen = customFrontendScreens[i]; + if (m_nCurrScreen == screen.id) { + currentSprite = screen.sprite; + break; + } + } + } + break; +#endif } if (m_nMenuFadeAlpha < 255) { @@ -3368,23 +3405,19 @@ CMenuManager::LoadSettings() CFileMgr::Read(fileHandle, m_PrefsSkinFile, 256); CFileMgr::Read(fileHandle, (char*)&m_ControlMethod, 1); CFileMgr::Read(fileHandle, (char*)&m_PrefsLanguage, 1); -#ifdef FREE_CAM - CFileMgr::Read(fileHandle, (char*)&TheCamera.bFreeCam, 1); -#endif -#ifdef CUTSCENE_BORDERS_SWITCH - CFileMgr::Read(fileHandle, (char *)&CMenuManager::m_PrefsCutsceneBorders, 1); -#endif -#ifdef MULTISAMPLING - CFileMgr::Read(fileHandle, (char *)&m_nPrefsMSAALevel, 1); - m_nDisplayMSAALevel = m_nPrefsMSAALevel; +#ifdef CUSTOM_FRONTEND_OPTIONS + for (int i = 0; i < numCustomFrontendOptions; i++) { + FrontendOption& option = customFrontendOptions[i]; + if (option.save) { + CFileMgr::Read(fileHandle, (char*)option.value, 1); + option.lastSavedValue = option.displayedValue = *option.value; + } + } #endif #ifdef NO_ISLAND_LOADING CFileMgr::Read(fileHandle, (char *)&CMenuManager::m_PrefsIslandLoading, 1); CMenuManager::m_DisplayIslandLoading = CMenuManager::m_PrefsIslandLoading; #endif -#ifdef PS2_ALPHA_TEST - CFileMgr::Read(fileHandle, (char *)&gPS2alphaTest, 1); -#endif // PS2_ALPHA_TEST } } @@ -3475,21 +3508,17 @@ CMenuManager::SaveSettings() CFileMgr::Write(fileHandle, m_PrefsSkinFile, 256); CFileMgr::Write(fileHandle, (char*)&m_ControlMethod, 1); CFileMgr::Write(fileHandle, (char*)&m_PrefsLanguage, 1); -#ifdef FREE_CAM - CFileMgr::Write(fileHandle, (char*)&TheCamera.bFreeCam, 1); -#endif -#ifdef CUTSCENE_BORDERS_SWITCH - CFileMgr::Write(fileHandle, (char *)&CMenuManager::m_PrefsCutsceneBorders, 1); -#endif -#ifdef MULTISAMPLING - CFileMgr::Write(fileHandle, (char *)&CMenuManager::m_nPrefsMSAALevel, 1); +#ifdef CUSTOM_FRONTEND_OPTIONS + for (int i = 0; i < numCustomFrontendOptions; i++) { + FrontendOption &option = customFrontendOptions[i]; + if (option.save) { + CFileMgr::Write(fileHandle, (char*)option.value, 1); + } + } #endif #ifdef NO_ISLAND_LOADING CFileMgr::Write(fileHandle, (char *)&CMenuManager::m_PrefsIslandLoading, 1); #endif -#ifdef PS2_ALPHA_TEST - CFileMgr::Write(fileHandle, (char *)&gPS2alphaTest, 1); -#endif // PS2_ALPHA_TEST } CFileMgr::CloseFile(fileHandle); @@ -4808,65 +4837,45 @@ CMenuManager::ProcessButtonPresses(void) SaveSettings(); } break; -#ifdef IMPROVED_VIDEOMODE - case MENUACTION_SCREENFORMAT: - if (m_nSelectedScreenMode != m_nPrefsWindowed) { - m_nPrefsWindowed = m_nSelectedScreenMode; - _psSelectScreenVM(m_nPrefsVideoMode); - SetHelperText(0); - SaveSettings(); - } - break; -#endif -#ifdef MULTISAMPLING - case MENUACTION_MULTISAMPLING: - if (m_nDisplayMSAALevel != m_nPrefsMSAALevel) { - m_nPrefsMSAALevel = m_nDisplayMSAALevel; - _psSelectScreenVM(m_nPrefsVideoMode); - SetHelperText(0); - SaveSettings(); - } - break; -#endif -#ifdef NO_ISLAND_LOADING - case MENUACTION_ISLANDLOADING: - if (m_DisplayIslandLoading != m_PrefsIslandLoading) { - if (!m_bGameNotLoaded) { - if (m_DisplayIslandLoading > ISLAND_LOADING_LOW) { - if (m_DisplayIslandLoading == ISLAND_LOADING_HIGH) - CStreaming::RemoveIslandsNotUsed(LEVEL_GENERIC); - if (m_PrefsIslandLoading == ISLAND_LOADING_LOW) { - if (CGame::currLevel != LEVEL_INDUSTRIAL) - CFileLoader::LoadCollisionFromDatFile(LEVEL_INDUSTRIAL); - if (CGame::currLevel != LEVEL_COMMERCIAL) - CFileLoader::LoadCollisionFromDatFile(LEVEL_COMMERCIAL); - if (CGame::currLevel != LEVEL_SUBURBAN) - CFileLoader::LoadCollisionFromDatFile(LEVEL_SUBURBAN); - CCollision::bAlreadyLoaded = true; - m_PrefsIslandLoading = m_DisplayIslandLoading; - CStreaming::RequestBigBuildings(CGame::currLevel); - } else if (m_PrefsIslandLoading == ISLAND_LOADING_HIGH) { - m_PrefsIslandLoading = m_DisplayIslandLoading; - CStreaming::RequestIslands(CGame::currLevel); - } else - m_PrefsIslandLoading = m_DisplayIslandLoading; - } else { // low - m_PrefsIslandLoading = m_DisplayIslandLoading; - CCollision::bAlreadyLoaded = false; - CModelInfo::RemoveColModelsFromOtherLevels(CGame::currLevel); - CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); - CStreaming::RemoveUnusedBuildings(CGame::currLevel); - CStreaming::RequestIslands(CGame::currLevel); - } - - CStreaming::LoadAllRequestedModels(true); - } else - m_PrefsIslandLoading = m_DisplayIslandLoading; - SetHelperText(0); - SaveSettings(); - } - break; -#endif +//#ifdef NO_ISLAND_LOADING +// case MENUACTION_ISLANDLOADING: +// if (m_DisplayIslandLoading != m_PrefsIslandLoading) { +// if (!m_bGameNotLoaded) { +// if (m_DisplayIslandLoading > ISLAND_LOADING_LOW) { +// if (m_DisplayIslandLoading == ISLAND_LOADING_HIGH) +// CStreaming::RemoveIslandsNotUsed(LEVEL_GENERIC); +// if (m_PrefsIslandLoading == ISLAND_LOADING_LOW) { +// if (CGame::currLevel != LEVEL_INDUSTRIAL) +// CFileLoader::LoadCollisionFromDatFile(LEVEL_INDUSTRIAL); +// if (CGame::currLevel != LEVEL_COMMERCIAL) +// CFileLoader::LoadCollisionFromDatFile(LEVEL_COMMERCIAL); +// if (CGame::currLevel != LEVEL_SUBURBAN) +// CFileLoader::LoadCollisionFromDatFile(LEVEL_SUBURBAN); +// CCollision::bAlreadyLoaded = true; +// m_PrefsIslandLoading = m_DisplayIslandLoading; +// CStreaming::RequestBigBuildings(CGame::currLevel); +// } else if (m_PrefsIslandLoading == ISLAND_LOADING_HIGH) { +// m_PrefsIslandLoading = m_DisplayIslandLoading; +// CStreaming::RequestIslands(CGame::currLevel); +// } else +// m_PrefsIslandLoading = m_DisplayIslandLoading; +// } else { // low +// m_PrefsIslandLoading = m_DisplayIslandLoading; +// CCollision::bAlreadyLoaded = false; +// CModelInfo::RemoveColModelsFromOtherLevels(CGame::currLevel); +// CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); +// CStreaming::RemoveUnusedBuildings(CGame::currLevel); +// CStreaming::RequestIslands(CGame::currLevel); +// } +// +// CStreaming::LoadAllRequestedModels(true); +// } else +// m_PrefsIslandLoading = m_DisplayIslandLoading; +// SetHelperText(0); +// SaveSettings(); +// } +// break; +//#endif case MENUACTION_AUDIOHW: { int selectedProvider = m_nPrefsAudio3DProviderIndex; @@ -4913,7 +4922,6 @@ CMenuManager::ProcessButtonPresses(void) DMAudio.SetRadioInCar(m_PrefsRadioStation); DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); SaveSettings(); -#ifndef GRAPHICS_MENU_OPTIONS } else if (m_nCurrScreen == MENUPAGE_DISPLAY_SETTINGS) { m_PrefsFrameLimiter = true; m_PrefsBrightness = 256; @@ -4928,121 +4936,55 @@ CMenuManager::ProcessButtonPresses(void) if (_dwOperatingSystemVersion == OS_WIN98) { CMBlur::BlurOn = false; CMBlur::MotionBlurClose(); - } - else { + } else { CMBlur::BlurOn = true; CMBlur::MotionBlurOpen(Scene.camera); } #else CMBlur::BlurOn = true; #endif -#ifdef CUTSCENE_BORDERS_SWITCH - m_PrefsCutsceneBorders = true; -#endif -#ifdef NO_ISLAND_LOADING - m_DisplayIslandLoading = ISLAND_LOADING_LOW; - if (!m_bGameNotLoaded) { - if (m_DisplayIslandLoading > ISLAND_LOADING_LOW) { - if (m_DisplayIslandLoading == ISLAND_LOADING_HIGH) - CStreaming::RemoveIslandsNotUsed(LEVEL_GENERIC); - if (m_PrefsIslandLoading == ISLAND_LOADING_LOW) { - if (CGame::currLevel != LEVEL_INDUSTRIAL) - CFileLoader::LoadCollisionFromDatFile(LEVEL_INDUSTRIAL); - if (CGame::currLevel != LEVEL_COMMERCIAL) - CFileLoader::LoadCollisionFromDatFile(LEVEL_COMMERCIAL); - if (CGame::currLevel != LEVEL_SUBURBAN) - CFileLoader::LoadCollisionFromDatFile(LEVEL_SUBURBAN); - CCollision::bAlreadyLoaded = true; - m_PrefsIslandLoading = m_DisplayIslandLoading; - CStreaming::RequestBigBuildings(CGame::currLevel); - } else if (m_PrefsIslandLoading == ISLAND_LOADING_HIGH) { - m_PrefsIslandLoading = m_DisplayIslandLoading; - CStreaming::RequestIslands(CGame::currLevel); - } else - m_PrefsIslandLoading = m_DisplayIslandLoading; - } else { // low - m_PrefsIslandLoading = m_DisplayIslandLoading; - CCollision::bAlreadyLoaded = false; - CModelInfo::RemoveColModelsFromOtherLevels(CGame::currLevel); - CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); - CStreaming::RemoveUnusedBuildings(CGame::currLevel); - CStreaming::RequestIslands(CGame::currLevel); - } - - CStreaming::LoadAllRequestedModels(true); - } else - m_PrefsIslandLoading = m_DisplayIslandLoading; -#endif // NO_ISLAND_LOADING -#ifdef PS2_ALPHA_TEST - gPS2alphaTest = false; -#endif // PS2_ALPHA_TEST +#ifdef CUSTOM_FRONTEND_OPTIONS + extern void RestoreDefGraphics(int8); + extern void RestoreDefDisplay(int8); + + RestoreDefGraphics(FEOPTION_ACTION_SELECT); + RestoreDefDisplay(FEOPTION_ACTION_SELECT); +#endif +//#ifdef NO_ISLAND_LOADING +// m_DisplayIslandLoading = ISLAND_LOADING_LOW; +// if (!m_bGameNotLoaded) { +// if (m_DisplayIslandLoading > ISLAND_LOADING_LOW) { +// if (m_DisplayIslandLoading == ISLAND_LOADING_HIGH) +// CStreaming::RemoveIslandsNotUsed(LEVEL_GENERIC); +// if (m_PrefsIslandLoading == ISLAND_LOADING_LOW) { +// if (CGame::currLevel != LEVEL_INDUSTRIAL) +// CFileLoader::LoadCollisionFromDatFile(LEVEL_INDUSTRIAL); +// if (CGame::currLevel != LEVEL_COMMERCIAL) +// CFileLoader::LoadCollisionFromDatFile(LEVEL_COMMERCIAL); +// if (CGame::currLevel != LEVEL_SUBURBAN) +// CFileLoader::LoadCollisionFromDatFile(LEVEL_SUBURBAN); +// CCollision::bAlreadyLoaded = true; +// m_PrefsIslandLoading = m_DisplayIslandLoading; +// CStreaming::RequestBigBuildings(CGame::currLevel); +// } else if (m_PrefsIslandLoading == ISLAND_LOADING_HIGH) { +// m_PrefsIslandLoading = m_DisplayIslandLoading; +// CStreaming::RequestIslands(CGame::currLevel); +// } else +// m_PrefsIslandLoading = m_DisplayIslandLoading; +// } else { // low +// m_PrefsIslandLoading = m_DisplayIslandLoading; +// CCollision::bAlreadyLoaded = false; +// CModelInfo::RemoveColModelsFromOtherLevels(CGame::currLevel); +// CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); +// CStreaming::RemoveUnusedBuildings(CGame::currLevel); +// CStreaming::RequestIslands(CGame::currLevel); +// } +// +// CStreaming::LoadAllRequestedModels(true); +// } else +// m_PrefsIslandLoading = m_DisplayIslandLoading; +//#endif // NO_ISLAND_LOADING SaveSettings(); -#else - } else if (m_nCurrScreen == MENUPAGE_DISPLAY_SETTINGS) { - m_PrefsBrightness = 256; - m_PrefsShowSubtitles = true; -#ifdef CUTSCENE_BORDERS_SWITCH - m_PrefsCutsceneBorders = true; -#endif - SaveSettings(); - } else if (m_nCurrScreen == MENUPAGE_GRAPHICS_SETTINGS) { - m_PrefsFrameLimiter = true; - m_PrefsUseWideScreen = false; - m_PrefsVsyncDisp = true; - m_PrefsLOD = 1.2f; - m_PrefsVsync = true; - CRenderer::ms_lodDistScale = 1.2f; - m_nDisplayVideoMode = m_nPrefsVideoMode; -#ifdef GTA3_1_1_PATCH - if (_dwOperatingSystemVersion == OS_WIN98) { - CMBlur::BlurOn = false; - CMBlur::MotionBlurClose(); - } else { - CMBlur::BlurOn = true; - CMBlur::MotionBlurOpen(Scene.camera); - } -#else - CMBlur::BlurOn = true; -#endif // GTA3_1_1_PATCH -#ifdef NO_ISLAND_LOADING - m_DisplayIslandLoading = ISLAND_LOADING_LOW; - if (!m_bGameNotLoaded) { - if (m_DisplayIslandLoading > ISLAND_LOADING_LOW) { - if (m_DisplayIslandLoading == ISLAND_LOADING_HIGH) - CStreaming::RemoveIslandsNotUsed(LEVEL_GENERIC); - if (m_PrefsIslandLoading == ISLAND_LOADING_LOW) { - if (CGame::currLevel != LEVEL_INDUSTRIAL) - CFileLoader::LoadCollisionFromDatFile(LEVEL_INDUSTRIAL); - if (CGame::currLevel != LEVEL_COMMERCIAL) - CFileLoader::LoadCollisionFromDatFile(LEVEL_COMMERCIAL); - if (CGame::currLevel != LEVEL_SUBURBAN) - CFileLoader::LoadCollisionFromDatFile(LEVEL_SUBURBAN); - CCollision::bAlreadyLoaded = true; - m_PrefsIslandLoading = m_DisplayIslandLoading; - CStreaming::RequestBigBuildings(CGame::currLevel); - } else if (m_PrefsIslandLoading == ISLAND_LOADING_HIGH) { - m_PrefsIslandLoading = m_DisplayIslandLoading; - CStreaming::RequestIslands(CGame::currLevel); - } else - m_PrefsIslandLoading = m_DisplayIslandLoading; - } else { // low - m_PrefsIslandLoading = m_DisplayIslandLoading; - CCollision::bAlreadyLoaded = false; - CModelInfo::RemoveColModelsFromOtherLevels(CGame::currLevel); - CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); - CStreaming::RemoveUnusedBuildings(CGame::currLevel); - CStreaming::RequestIslands(CGame::currLevel); - } - - CStreaming::LoadAllRequestedModels(true); - } else - m_PrefsIslandLoading = m_DisplayIslandLoading; -#endif // NO_ISLAND_LOADING -#ifdef PS2_ALPHA_TEST - gPS2alphaTest = false; -#endif // PS2_ALPHA_TEST - SaveSettings(); -#endif // GRAPHICS_MENU_OPTIONS } else if ((m_nCurrScreen != MENUPAGE_SKIN_SELECT_OLD) && (m_nCurrScreen == MENUPAGE_CONTROLLER_PC)) { ControlsManager.MakeControllerActionsBlank(); ControlsManager.InitDefaultControlConfiguration(); @@ -5112,7 +5054,7 @@ CMenuManager::ProcessButtonPresses(void) option.displayedValue = 0; } option.changeFunc(option.displayedValue); - *option.value = option.displayedValue; + *option.value = option.lastSavedValue = option.displayedValue; } else if (option.type == FEOPTION_DYNAMIC) { option.buttonPressFunc(FEOPTION_ACTION_SELECT); @@ -5131,6 +5073,14 @@ CMenuManager::ProcessButtonPresses(void) } } ProcessOnOffMenuOptions(); +#ifdef CUSTOM_FRONTEND_OPTIONS + if (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot == SAVESLOT_CFO) { + FrontendOption& option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu]; + if (option.type == FEOPTION_BUILTIN_ACTION && option.buttonPressFunc) { + option.buttonPressFunc(FEOPTION_ACTION_SELECT); + } + } +#endif } if (goBack) { @@ -5301,41 +5251,15 @@ CMenuManager::ProcessButtonPresses(void) } } break; -#ifdef IMPROVED_VIDEOMODE - case MENUACTION_SCREENFORMAT: - if (m_bGameNotLoaded) { - FrontEndMenuManager.m_nSelectedScreenMode = !FrontEndMenuManager.m_nSelectedScreenMode; - } - break; -#endif -#ifdef MULTISAMPLING - case MENUACTION_MULTISAMPLING: - if (m_bGameNotLoaded) { - m_nDisplayMSAALevel += changeValueBy; - - int i = 0; - int maxAA = RwD3D8EngineGetMaxMultiSamplingLevels(); - while (maxAA != 1) { - i++; - maxAA >>= 1; - } - - if (m_nDisplayMSAALevel < 0) - m_nDisplayMSAALevel = i; - else if (m_nDisplayMSAALevel > i) - m_nDisplayMSAALevel = 0; - } - break; -#endif -#ifdef NO_ISLAND_LOADING - case MENUACTION_ISLANDLOADING: - m_DisplayIslandLoading += changeValueBy; - if (m_DisplayIslandLoading > ISLAND_LOADING_HIGH) - m_DisplayIslandLoading = ISLAND_LOADING_LOW; - else if (m_DisplayIslandLoading < ISLAND_LOADING_LOW) - m_DisplayIslandLoading = ISLAND_LOADING_HIGH; - break; -#endif +//#ifdef NO_ISLAND_LOADING +// case MENUACTION_ISLANDLOADING: +// m_DisplayIslandLoading += changeValueBy; +// if (m_DisplayIslandLoading > ISLAND_LOADING_HIGH) +// m_DisplayIslandLoading = ISLAND_LOADING_LOW; +// else if (m_DisplayIslandLoading < ISLAND_LOADING_LOW) +// m_DisplayIslandLoading = ISLAND_LOADING_HIGH; +// break; +//#endif case MENUACTION_AUDIOHW: if (m_nPrefsAudio3DProviderIndex != -1) { m_nPrefsAudio3DProviderIndex += changeValueBy; @@ -5374,7 +5298,7 @@ CMenuManager::ProcessButtonPresses(void) } if (!option.onlyApplyOnEnter) { option.changeFunc(option.displayedValue); - *option.value = option.displayedValue; + *option.value = option.lastSavedValue = option.displayedValue; } } else if (option.type == FEOPTION_DYNAMIC) { option.buttonPressFunc(changeValueBy > 0 ? FEOPTION_ACTION_RIGHT : FEOPTION_ACTION_LEFT); @@ -5501,20 +5425,6 @@ CMenuManager::ProcessOnOffMenuOptions() DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); SaveSettings(); break; -#ifdef CUTSCENE_BORDERS_SWITCH - case MENUACTION_CUTSCENEBORDERS: - m_PrefsCutsceneBorders = !m_PrefsCutsceneBorders; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); - SaveSettings(); - break; -#endif -#ifdef PS2_ALPHA_TEST - case MENUACTION_PS2_ALPHA_TEST: - gPS2alphaTest = !gPS2alphaTest; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); - SaveSettings(); - break; -#endif } } @@ -6354,20 +6264,6 @@ CMenuManager::ConstructStatLine(int rowIdx) #undef STAT_LINE } -#if 0 -uint8 CMenuManager::GetNumberOfMenuOptions() -{ - uint8 Rows = -1; - for (int i = 0; i < NUM_MENUROWS; i++) { - if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action == MENUACTION_NOTHING) - break; - - ++Rows; - } - return Rows; -} -#endif - #undef GetBackJustUp #undef GetBackJustDown #undef ChangeScreen diff --git a/src/core/Frontend.h b/src/core/Frontend.h index fa3652a1..848148e7 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -155,7 +155,10 @@ enum eSaveSlot SAVESLOT_6, SAVESLOT_7, SAVESLOT_8, - SAVESLOT_LABEL = 36 + SAVESLOT_LABEL = 36, +#ifdef CUSTOM_FRONTEND_OPTIONS + SAVESLOT_CFO +#endif }; #ifdef MENU_MAP @@ -235,14 +238,15 @@ enum eMenuScreen MENUPAGE_KEYBOARD_CONTROLS = 55, MENUPAGE_MOUSE_CONTROLS = 56, MENUPAGE_MISSION_RETRY = 57, - MENUPAGE_58 = 58, #ifdef MENU_MAP - MENUPAGE_MAP = 59, -#endif -#ifdef GRAPHICS_MENU_OPTIONS - MENUPAGE_GRAPHICS_SETTINGS, + MENUPAGE_MAP, #endif + MENUPAGE_UNK, // 58 in game. Map page is added above, because last screen in CMenuScreens should always be empty to make CFO work +#ifdef CUSTOM_FRONTEND_OPTIONS + MENUPAGES = 65 // for some room to add more screen +#else MENUPAGES +#endif }; enum eMenuAction @@ -362,25 +366,13 @@ enum eMenuAction MENUACTION_UNK112, MENUACTION_REJECT_RETRY, MENUACTION_UNK114, -#ifdef IMPROVED_VIDEOMODE - MENUACTION_SCREENFORMAT, -#endif -#ifdef ANISOTROPIC_FILTERING - MENUACTION_MIPMAPS, - MENUACTION_TEXTURE_FILTERING, -#endif -#ifdef MULTISAMPLING - MENUACTION_MULTISAMPLING, -#endif -#ifdef NO_ISLAND_LOADING - MENUACTION_ISLANDLOADING, -#endif -#ifdef PS2_ALPHA_TEST - MENUACTION_PS2_ALPHA_TEST, -#endif -#ifdef CUTSCENE_BORDERS_SWITCH - MENUACTION_CUTSCENEBORDERS, -#endif +//#ifdef ANISOTROPIC_FILTERING +// MENUACTION_MIPMAPS, +// MENUACTION_TEXTURE_FILTERING, +//#endif +//#ifdef NO_ISLAND_LOADING +// MENUACTION_ISLANDLOADING, +//#endif #ifdef CUSTOM_FRONTEND_OPTIONS MENUACTION_TRIGGERFUNC #endif @@ -469,7 +461,7 @@ struct BottomBarOption struct CMenuScreen { char m_ScreenName[8]; - int32 unk; // 2 on MENUPAGE_MULTIPLAYER_START, 1 on everywhere else + int32 unk; // 2 on MENUPAGE_MULTIPLAYER_START, 1 on everywhere else, 0 on unused. int32 m_PreviousPage[2]; // eMenuScreen int32 m_ParentEntry[2]; // row @@ -704,8 +696,6 @@ public: void PageUpList(bool); void PageDownList(bool); int8 GetPreviousPageOption(); - - // uint8 GetNumberOfMenuOptions(); }; #ifndef IMPROVED_VIDEOMODE @@ -713,6 +703,6 @@ VALIDATE_SIZE(CMenuManager, 0x564); #endif extern CMenuManager FrontEndMenuManager; -extern CMenuScreen aScreens[]; +extern CMenuScreen aScreens[MENUPAGES]; #endif \ No newline at end of file diff --git a/src/core/MenuScreens.cpp b/src/core/MenuScreens.cpp index 02c004b3..533fc755 100644 --- a/src/core/MenuScreens.cpp +++ b/src/core/MenuScreens.cpp @@ -4,45 +4,7 @@ // If you want to add new options, please don't do that here and see CustomFrontendOptionsPopulate in re3.cpp. -#ifdef CUTSCENE_BORDERS_SWITCH -#define MENU_CUTSCENE_BORDERS_SWITCH(screen) MENUACTION_CUTSCENEBORDERS, "FEM_CSB", SAVESLOT_NONE, screen, -#else -#define MENU_CUTSCENE_BORDERS_SWITCH(screen) -#endif - -#ifdef IMPROVED_VIDEOMODE -#define MENU_IMPROVED_VIDEOMODE(screen) MENUACTION_SCREENFORMAT, "FEM_SCF", SAVESLOT_NONE, screen, -#else -#define MENU_IMPROVED_VIDEOMODE(screen) -#endif - -#ifdef ANISOTROPIC_FILTERING -#define MENU_MIPMAPS(screen) MENUACTION_MIPMAPS, "FED_MIP", SAVESLOT_NONE, screen, -#define MENU_TEXTURE_FILTERING(screen) MENUACTION_TEXTURE_FILTERING, "FED_FIL", SAVESLOT_NONE, screen, -#else -#define MENU_MIPMAPS(screen) -#define MENU_TEXTURE_FILTERING(screen) -#endif - -#ifdef MULTISAMPLING -#define MENU_MULTISAMPLING(screen) MENUACTION_MULTISAMPLING, "FED_AAS", SAVESLOT_NONE, screen, -#else -#define MENU_MULTISAMPLING(screen) -#endif - -#ifdef NO_ISLAND_LOADING -#define MENU_ISLAND_LOADING(screen) MENUACTION_ISLANDLOADING, "FEM_ISL", SAVESLOT_NONE, screen, -#else -#define MENU_ISLAND_LOADING(screen) -#endif - -#ifdef PS2_ALPHA_TEST -#define MENU_PS2_ALPHA_TEST(screen) MENUACTION_PS2_ALPHA_TEST, "FEM_2PR", SAVESLOT_NONE, screen, -#else -#define MENU_PS2_ALPHA_TEST(screen) -#endif - -CMenuScreen aScreens[] = { +CMenuScreen aScreens[MENUPAGES] = { // MENUPAGE_NONE = 0 { "", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, @@ -85,7 +47,6 @@ CMenuScreen aScreens[] = { }, // MENUPAGE_DISPLAY_SETTINGS = 6 -#ifndef GRAPHICS_MENU_OPTIONS { "FET_DIS", 1, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 2, 2, MENUACTION_BRIGHTNESS, "FED_BRI", SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS, MENUACTION_DRAWDIST, "FEM_LOD", SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS, @@ -93,28 +54,11 @@ CMenuScreen aScreens[] = { MENUACTION_FRAMELIMIT, "FEM_FRM", SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS, MENUACTION_TRAILS, "FED_TRA", SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS, MENUACTION_SUBTITLES, "FED_SUB", SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS, - MENU_CUTSCENE_BORDERS_SWITCH(MENUPAGE_DISPLAY_SETTINGS) - MENU_MIPMAPS(MENUPAGE_DISPLAY_SETTINGS) - MENU_TEXTURE_FILTERING(MENUPAGE_DISPLAY_SETTINGS) - MENU_ISLAND_LOADING(MENUPAGE_DISPLAY_SETTINGS) - MENU_PS2_ALPHA_TEST(MENUPAGE_DISPLAY_SETTINGS) - MENU_MULTISAMPLING(MENUPAGE_DISPLAY_SETTINGS) MENUACTION_WIDESCREEN, "FED_WIS", SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS, - MENU_IMPROVED_VIDEOMODE(MENUPAGE_DISPLAY_SETTINGS) MENUACTION_SCREENRES, "FED_RES", SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS, MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, -#else - { "FET_DIS", 1, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 2, 2, - MENUACTION_BRIGHTNESS, "FED_BRI", SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS, - MENUACTION_SUBTITLES, "FED_SUB", SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS, - MENU_CUTSCENE_BORDERS_SWITCH(MENUPAGE_DISPLAY_SETTINGS) - MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS, - MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, - }, -#endif // GRAPHICS_MENU_OPTIONS - // MENUPAGE_LANGUAGE_SETTINGS = 7 { "FET_LAN", 1, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 3, 3, @@ -379,9 +323,6 @@ CMenuScreen aScreens[] = { MENUACTION_CHANGEMENU, "FET_CTL", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, MENUACTION_LOADRADIO, "FET_AUD", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, MENUACTION_CHANGEMENU, "FET_DIS", SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS, -#ifdef GRAPHICS_MENU_OPTIONS - MENUACTION_CHANGEMENU, "FET_GRA", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, -#endif MENUACTION_CHANGEMENU, "FET_LAN", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, MENUACTION_PLAYERSETUP, "FET_PSU", SAVESLOT_NONE, MENUPAGE_SKIN_SELECT, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, @@ -493,38 +434,19 @@ CMenuScreen aScreens[] = { }, #endif - // MENUPAGE_58 = 58 - { "", 0, MENUPAGE_NONE, MENUPAGE_NONE, 0, 0, - - }, - #ifdef MENU_MAP - // MENUPAGE_MAP = 59 + // MENUPAGE_MAP { "FEG_MAP", 1, MENUPAGE_NONE, MENUPAGE_NONE, 5, 2, MENUACTION_UNK110, "", SAVESLOT_NONE, MENUPAGE_NONE, // to prevent cross/enter to go back MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, #endif -#ifdef GRAPHICS_MENU_OPTIONS - // MENUPAGE_GRAPHICS_SETTINGS = 60 - { "FET_GRA", 1, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 2, 2, - MENUACTION_DRAWDIST, "FEM_LOD", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, - MENUACTION_FRAMESYNC, "FEM_VSC", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, - MENUACTION_FRAMELIMIT, "FEM_FRM", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, - MENUACTION_TRAILS, "FED_TRA", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, - MENUACTION_WIDESCREEN, "FED_WIS", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, - MENU_MIPMAPS(MENUPAGE_GRAPHICS_SETTINGS) - MENU_TEXTURE_FILTERING(MENUPAGE_GRAPHICS_SETTINGS) - MENU_ISLAND_LOADING(MENUPAGE_GRAPHICS_SETTINGS) - MENU_PS2_ALPHA_TEST(MENUPAGE_GRAPHICS_SETTINGS) - MENU_MULTISAMPLING(MENUPAGE_GRAPHICS_SETTINGS) - MENU_IMPROVED_VIDEOMODE(MENUPAGE_GRAPHICS_SETTINGS) - MENUACTION_SCREENRES, "FED_RES", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, - MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, - MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, - }, -#endif + // MENUPAGE_UNK + { "", 0, MENUPAGE_NONE, MENUPAGE_NONE, 0, 0, + + }, + }; #endif \ No newline at end of file diff --git a/src/core/config.h b/src/core/config.h index b0d89fac..498be8f3 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -250,7 +250,7 @@ enum Config { # define TRIANGLE_BACK_BUTTON //# define CIRCLE_BACK_BUTTON # define CUSTOM_FRONTEND_OPTIONS -# define GRAPHICS_MENU_OPTIONS +# define GRAPHICS_MENU_OPTIONS // otherwise Advanced Options menu will appear if Display is full #endif // Script diff --git a/src/core/re3.cpp b/src/core/re3.cpp index dd116e27..2922f73e 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -74,12 +74,124 @@ mysrand(unsigned int seed) #ifdef CUSTOM_FRONTEND_OPTIONS #include "frontendoption.h" #include "platform.h" +#include "Font.h" void ReloadFrontendOptions(void) { CustomFrontendOptionsPopulate(); } +void RestoreDefGraphics(int8 action) { + if (action != FEOPTION_ACTION_SELECT) + return; + + #ifdef PS2_ALPHA_TEST + gPS2alphaTest = false; + #endif + #ifdef MULTISAMPLING + FrontEndMenuManager.m_nPrefsMSAALevel = FrontEndMenuManager.m_nDisplayMSAALevel = 0; + #endif + #ifdef GRAPHICS_MENU_OPTIONS // otherwise Frontend will handle those + CMenuManager::m_PrefsFrameLimiter = true; + CMenuManager::m_PrefsVsyncDisp = true; + CMenuManager::m_PrefsVsync = true; + CMenuManager::m_PrefsUseWideScreen = false; + FrontEndMenuManager.m_nDisplayVideoMode = FrontEndMenuManager.m_nPrefsVideoMode; + #ifdef GTA3_1_1_PATCH + if (_dwOperatingSystemVersion == OS_WIN98) { + CMBlur::BlurOn = false; + CMBlur::MotionBlurClose(); + } else { + CMBlur::BlurOn = true; + CMBlur::MotionBlurOpen(Scene.camera); + } + #else + CMBlur::BlurOn = true; + #endif + FrontEndMenuManager.SaveSettings(); + #endif +} + +void RestoreDefDisplay(int8 action) { + if (action != FEOPTION_ACTION_SELECT) + return; + + #ifdef CUTSCENE_BORDERS_SWITCH + CMenuManager::m_PrefsCutsceneBorders = true; + #endif + #ifdef FREE_CAM + TheCamera.bFreeCam = false; + #endif + #ifdef GRAPHICS_MENU_OPTIONS // otherwise Frontend will handle those + CMenuManager::m_PrefsBrightness = 256; + CMenuManager::m_PrefsLOD = 1.2f; + CRenderer::ms_lodDistScale = 1.2f; + CMenuManager::m_PrefsShowSubtitles = true; + FrontEndMenuManager.SaveSettings(); + #endif +} + +#ifdef MULTISAMPLING +void MultiSamplingGoBack() { + FrontEndMenuManager.m_nDisplayMSAALevel = FrontEndMenuManager.m_nPrefsMSAALevel; +} + +void MultiSamplingButtonPress(int8 action) { + if (action == FEOPTION_ACTION_SELECT) { + if (FrontEndMenuManager.m_nDisplayMSAALevel != FrontEndMenuManager.m_nPrefsMSAALevel) { + FrontEndMenuManager.m_nPrefsMSAALevel = FrontEndMenuManager.m_nDisplayMSAALevel; + _psSelectScreenVM(FrontEndMenuManager.m_nPrefsVideoMode); + FrontEndMenuManager.SetHelperText(0); + FrontEndMenuManager.SaveSettings(); + } + } else if (action == FEOPTION_ACTION_LEFT || action == FEOPTION_ACTION_RIGHT) { + if (FrontEndMenuManager.m_bGameNotLoaded) { + FrontEndMenuManager.m_nDisplayMSAALevel += (action == FEOPTION_ACTION_RIGHT ? 1 : -1); + + int i = 0; + int maxAA = RwD3D8EngineGetMaxMultiSamplingLevels(); + while (maxAA != 1) { + i++; + maxAA >>= 1; + } + + if (FrontEndMenuManager.m_nDisplayMSAALevel < 0) + FrontEndMenuManager.m_nDisplayMSAALevel = i; + else if (FrontEndMenuManager.m_nDisplayMSAALevel > i) + FrontEndMenuManager.m_nDisplayMSAALevel = 0; + } + } else if (action == FEOPTION_ACTION_FOCUSLOSS) { + if (FrontEndMenuManager.m_nDisplayMSAALevel != FrontEndMenuManager.m_nPrefsMSAALevel) { + FrontEndMenuManager.m_nDisplayMSAALevel = FrontEndMenuManager.m_nPrefsMSAALevel; + FrontEndMenuManager.SetHelperText(3); + } + } +} + +wchar* MultiSamplingDraw(bool *disabled, bool userHovering) { + static wchar unicodeTemp[64]; + if (userHovering) { + if (FrontEndMenuManager.m_nDisplayMSAALevel == FrontEndMenuManager.m_nPrefsMSAALevel) { + if (FrontEndMenuManager.m_nHelperTextMsgId == 1) // Press enter to apply + FrontEndMenuManager.ResetHelperText(); + } else { + FrontEndMenuManager.SetHelperText(1); + } + } + if (!FrontEndMenuManager.m_bGameNotLoaded) + *disabled = true; + + switch (FrontEndMenuManager.m_nDisplayMSAALevel) { + case 0: + return TheText.Get("FEM_OFF"); + default: + sprintf(gString, "%iX", 1 << (FrontEndMenuManager.m_nDisplayMSAALevel)); + AsciiToUnicode(gString, unicodeTemp); + return unicodeTemp; + } +} +#endif + #ifdef MORE_LANGUAGES void LangPolSelect(int8 action) { @@ -112,7 +224,7 @@ void LangJapSelect(int8 action) } #endif -/*#ifdef IMPROVED_VIDEOMODE +#ifdef IMPROVED_VIDEOMODE void ScreenModeChange(int8 displayedValue) { if (displayedValue != FrontEndMenuManager.m_nPrefsWindowed) { @@ -122,61 +234,155 @@ void ScreenModeChange(int8 displayedValue) FrontEndMenuManager.SaveSettings(); } } -#endif*/ +#endif #ifdef FREE_CAM -void ToggleFreeCam(int8 action) +void FreeCamChange(int8 displayedValue) { - if (action == FEOPTION_ACTION_SELECT) { - TheCamera.bFreeCam = !TheCamera.bFreeCam; - FrontEndMenuManager.SaveSettings(); - } + TheCamera.bFreeCam = !!displayedValue; + FrontEndMenuManager.SaveSettings(); +} +#endif + +#ifdef CUTSCENE_BORDERS_SWITCH +void BorderModeChange(int8 displayedValue) +{ + CMenuManager::m_PrefsCutsceneBorders = !!displayedValue; + FrontEndMenuManager.SaveSettings(); +} +#endif + +#ifdef PS2_ALPHA_TEST +void PS2AlphaTestChange(int8 displayedValue) +{ + gPS2alphaTest = !!displayedValue; + FrontEndMenuManager.SaveSettings(); } #endif -//#ifdef CUTSCENE_BORDERS_SWITCH -//void BorderModeChange(int8 displayedValue) -//{ -// CMenuManager::m_PrefsCutsceneBorders = !!displayedValue; -// FrontEndMenuManager.SaveSettings(); -//} -//#endif -// Reloaded on language change, so you can use hardcoded wchar* and TheText.Get with peace of mind +// Important: Make sure to read the warnings/informations in frontendoption.h!! void CustomFrontendOptionsPopulate(void) { RemoveCustomFrontendOptions(); // if exist -#ifdef MORE_LANGUAGES - FrontendOptionSetPosition(MENUPAGE_LANGUAGE_SETTINGS); - FrontendOptionAddDynamic(TheText.Get("FEL_POL"), nil, LangPolSelect, nil); - FrontendOptionAddDynamic(TheText.Get("FEL_RUS"), nil, LangRusSelect, nil); - FrontendOptionAddDynamic(TheText.Get("FEL_JAP"), nil, LangJapSelect, nil); + // -- Graphics/display seperation preperation starts - don't add options in here! +#ifdef GRAPHICS_MENU_OPTIONS + int graphicsMenu = FrontendScreenAdd("FET_GRA", MENUSPRITE_MAINMENU, MENUPAGE_OPTIONS, 50, 0, 20, + FONT_HEADING, MEDIUMTEXT_X_SCALE, MEDIUMTEXT_Y_SCALE, FESCREEN_LEFT_ALIGN, true); + + int newDisplayMenu = FrontendScreenAdd("FET_DIS", MENUSPRITE_MAINMENU, MENUPAGE_OPTIONS, 50, 0, 20, + FONT_HEADING, MEDIUMTEXT_X_SCALE, MEDIUMTEXT_Y_SCALE, FESCREEN_LEFT_ALIGN, true); + + FrontendOptionSetCursor(MENUPAGE_OPTIONS, 2, true); + FrontendOptionAddRedirect(TheText.Get("FET_DIS"), newDisplayMenu, 0); + FrontendOptionSetCursor(MENUPAGE_OPTIONS, 3); + FrontendOptionAddRedirect(TheText.Get("FET_GRA"), graphicsMenu, 0); + +#define SWITCH_TO_GRAPHICS_MENU FrontendOptionSetCursor(graphicsMenu, -1); +#define SWITCH_TO_DISPLAY_MENU FrontendOptionSetCursor(newDisplayMenu, -1); +#define CLONE_OPTION(a, b, c, d) FrontendOptionAddBuiltinAction(a, b, c, d); +#define ADD_BACK FrontendOptionAddBackButton(TheText.Get("FEDS_TB")); +#define ADD_RESTORE_DEFAULTS(a) FrontendOptionAddDynamic(TheText.Get("FET_DEF"), nil, nil, a, nil); +#else + int advancedDisplayMenu = FrontendScreenAdd("FET_ADV", MENUSPRITE_MAINMENU, MENUPAGE_DISPLAY_SETTINGS, 50, 0, 20, + FONT_HEADING, MEDIUMTEXT_X_SCALE, MEDIUMTEXT_Y_SCALE, FESCREEN_LEFT_ALIGN, true); + bool movedToAdvMenu = false; + +#define SWITCH_TO_GRAPHICS_MENU \ + if (GetNumberOfMenuOptions(MENUPAGE_DISPLAY_SETTINGS) >= 12) { \ + FrontendOptionSetCursor(advancedDisplayMenu, -1); \ + movedToAdvMenu = true; \ + } else { \ + FrontendOptionSetCursor(MENUPAGE_DISPLAY_SETTINGS, -3); \ + } + +#define SWITCH_TO_DISPLAY_MENU SWITCH_TO_GRAPHICS_MENU +#define CLONE_OPTION(a, b, c, d) +#define ADD_BACK +#define ADD_RESTORE_DEFAULTS(a) #endif + // -- Graphics/display seperation preperation end + + static const wchar* off_on[] = { TheText.Get("FEM_OFF"), TheText.Get("FEM_ON") }; -/*#ifdef IMPROVED_VIDEOMODE - static const wchar *screenModes[] = { (wchar*)L"FULLSCREEN", (wchar*)L"WINDOWED" }; - FrontendOptionSetPosition(MENUPAGE_GRAPHICS_SETTINGS, 8); - FrontendOptionAddSelect(TheText.Get("SCRFOR"), screenModes, 2, (int8*)&FrontEndMenuManager.m_nPrefsWindowed, true, ScreenModeChange, nil); -#endif*/ +#ifdef MORE_LANGUAGES + FrontendOptionSetCursor(MENUPAGE_LANGUAGE_SETTINGS, -2); + FrontendOptionAddDynamic(TheText.Get("FEL_POL"), nil, nil, LangPolSelect, nil); + FrontendOptionAddDynamic(TheText.Get("FEL_RUS"), nil, nil, LangRusSelect, nil); + FrontendOptionAddDynamic(TheText.Get("FEL_JAP"), nil, nil, LangJapSelect, nil); +#endif #ifdef MENU_MAP - FrontendOptionSetPosition(MENUPAGE_PAUSE_MENU, 2); + FrontendOptionSetCursor(MENUPAGE_PAUSE_MENU, 2); FrontendOptionAddRedirect(TheText.Get("FEG_MAP"), MENUPAGE_MAP); #endif + // -- Start of graphics menu - add options in display order! + + SWITCH_TO_GRAPHICS_MENU + CLONE_OPTION(TheText.Get("FED_RES"), MENUACTION_SCREENRES, nil, nil); + CLONE_OPTION(TheText.Get("FED_WIS"), MENUACTION_WIDESCREEN, nil, nil) + +#ifdef IMPROVED_VIDEOMODE + static const wchar* screenModes[] = { (wchar*)L"FULLSCREEN", (wchar*)L"WINDOWED" }; + // Storing isn't enabled because it's handled in Frontend + FrontendOptionAddSelect(TheText.Get("FEM_SCF"), screenModes, 2, (int8*)&FrontEndMenuManager.m_nPrefsWindowed, true, ScreenModeChange, nil); +#endif + + CLONE_OPTION(TheText.Get("FEM_VSC"), MENUACTION_FRAMESYNC, nil, nil); + CLONE_OPTION(TheText.Get("FEM_FRM"), MENUACTION_FRAMELIMIT, nil, nil); + +#ifdef MULTISAMPLING + SWITCH_TO_GRAPHICS_MENU + FrontendOptionAddDynamic(TheText.Get("FED_AAS"), MultiSamplingDraw, (int8*)&FrontEndMenuManager.m_nPrefsMSAALevel, MultiSamplingButtonPress, MultiSamplingGoBack, true); +#endif + + CLONE_OPTION(TheText.Get("FED_TRA"), MENUACTION_TRAILS, nil, nil); + +#ifdef PS2_ALPHA_TEST + SWITCH_TO_GRAPHICS_MENU + FrontendOptionAddSelect(TheText.Get("FEM_2PR"), off_on, 2, (int8*)&gPS2alphaTest, false, PS2AlphaTestChange, nil, true); +#endif + + ADD_RESTORE_DEFAULTS(RestoreDefGraphics) + ADD_BACK + + // ---- End of Graphics Menu ---- + + // -- Start of Display menu - add options in display order! + + SWITCH_TO_DISPLAY_MENU + CLONE_OPTION(TheText.Get("FED_BRI"), MENUACTION_BRIGHTNESS, nil, nil); + CLONE_OPTION(TheText.Get("FEM_LOD"), MENUACTION_DRAWDIST, nil, nil); + +#ifdef CUTSCENE_BORDERS_SWITCH + SWITCH_TO_DISPLAY_MENU + FrontendOptionAddSelect(TheText.Get("FEM_CSB"), off_on, 2, (int8 *)&CMenuManager::m_PrefsCutsceneBorders, false, BorderModeChange, nil, true); +#endif + #ifdef FREE_CAM - static const wchar *text = (wchar*)L"TOGGLE FREE CAM"; - FrontendOptionSetPosition(MENUPAGE_CONTROLLER_PC, 1); - FrontendOptionAddDynamic(text, nil, ToggleFreeCam, nil); + SWITCH_TO_DISPLAY_MENU + static const wchar* text = (wchar*)L"FREE CAM"; + FrontendOptionAddSelect(text, off_on, 2, (int8*)&TheCamera.bFreeCam, false, FreeCamChange, nil, true); +#endif + + CLONE_OPTION(TheText.Get("FED_SUB"), MENUACTION_SUBTITLES, nil, nil); + + // Add link to advanced graphics menu if it's filled. +#ifndef GRAPHICS_MENU_OPTIONS + if (movedToAdvMenu) { + FrontendOptionSetCursor(MENUPAGE_DISPLAY_SETTINGS, -3); + FrontendOptionAddRedirect(TheText.Get("FET_ADV"), advancedDisplayMenu, 0); + + FrontendOptionSetCursor(advancedDisplayMenu, -1); + FrontendOptionAddBackButton(TheText.Get("FEDS_TB")); + } #endif -/*#ifdef CUTSCENE_BORDERS_SWITCH - static const wchar *off_on[] = { TheText.Get("FEM_OFF"), TheText.Get("FEM_ON") }; - FrontendOptionSetPosition(MENUPAGE_DISPLAY_SETTINGS, 3); - FrontendOptionAddSelect((const wchar *)L"CUTSCENE BORDERS", off_on, 2, (int8 *)&CMenuManager::m_PrefsCutsceneBorders, false, BorderModeChange, nil); -#endif*/ + ADD_RESTORE_DEFAULTS(RestoreDefDisplay) + ADD_BACK } #endif diff --git a/src/extras/frontendoption.cpp b/src/extras/frontendoption.cpp index 51814f35..3214bbfd 100644 --- a/src/extras/frontendoption.cpp +++ b/src/extras/frontendoption.cpp @@ -2,14 +2,24 @@ #ifdef CUSTOM_FRONTEND_OPTIONS #include "frontendoption.h" +#include "Text.h" int numCustomFrontendOptions = 0; FrontendOption *customFrontendOptions; -int optionCursor = -1; -eMenuScreen currentMenu; +int numCustomFrontendScreens = 0; +FrontendScreen* customFrontendScreens; -void ChangeScreen(eMenuScreen screen, int option, bool fadeIn) +int numFrontendOptionReplacements = 0; +CMenuScreen::CMenuEntry* frontendOptionReplacements; + +int lastOgScreen = MENUPAGES; // means no new pages + +int optionCursor = -2; +int currentMenu; +bool optionOverwrite = false; + +void ChangeScreen(int screen, int option, bool fadeIn) { FrontEndMenuManager.m_nPrevScreen = FrontEndMenuManager.m_nCurrScreen; FrontEndMenuManager.m_nCurrScreen = screen; @@ -27,7 +37,7 @@ void GoBack(bool fadeIn) FrontEndMenuManager.ThingsToDoBeforeGoingBack(); - ChangeScreen((eMenuScreen)screen, option, fadeIn); + ChangeScreen(screen, option, fadeIn); } uint8 @@ -43,31 +53,89 @@ GetNumberOfMenuOptions(int screen) return Rows; } +uint8 +GetLastMenuScreen() +{ + uint8 page = -1; + for (int i = 0; i < MENUPAGES; i++) { + if (strcmp(aScreens[i].m_ScreenName, "") == 0 && aScreens[i].unk == 0) + break; + + ++page; + } + return page; +} + // Used before populating options, but effective in InitialiseChangedLanguageSettings and debugmenu void RemoveCustomFrontendOptions() { - if (numCustomFrontendOptions == 0) - return; + if (numCustomFrontendOptions != 0) { - for (int i = 0; i < MENUPAGES; i++) { - for (int j = 0; j < NUM_MENUROWS; j++) { - if (aScreens[i].m_aEntries[j].m_Action == MENUACTION_TRIGGERFUNC) { - int k; - for (k = j; k < NUM_MENUROWS-1; k++) { - memcpy(&aScreens[i].m_aEntries[k], &aScreens[i].m_aEntries[k+1], sizeof(CMenuScreen::CMenuEntry)); + for (int i = 0; i < MENUPAGES; i++) { + for (int j = 0; j < NUM_MENUROWS; j++) { + if (aScreens[i].m_aEntries[j].m_SaveSlot == SAVESLOT_CFO) { + int ogOptionId = customFrontendOptions[aScreens[i].m_aEntries[j].m_TargetMenu].ogOptionId; + if (ogOptionId == -1) { + int k; + for (k = j; k < NUM_MENUROWS - 1; k++) { + memcpy(&aScreens[i].m_aEntries[k], &aScreens[i].m_aEntries[k + 1], sizeof(CMenuScreen::CMenuEntry)); + } + aScreens[i].m_aEntries[k].m_Action = MENUACTION_NOTHING; + aScreens[i].m_aEntries[k].m_SaveSlot = SAVESLOT_NONE; + aScreens[i].m_aEntries[k].m_EntryName[0] = '\0'; + j--; + } else { + memcpy(&aScreens[i].m_aEntries[j], &frontendOptionReplacements[ogOptionId], sizeof(CMenuScreen::CMenuEntry)); + } } - aScreens[i].m_aEntries[k].m_Action = MENUACTION_NOTHING; - aScreens[i].m_aEntries[k].m_EntryName[0] = '\0'; - j--; } } + free(customFrontendOptions); + numCustomFrontendOptions = 0; + + if (numFrontendOptionReplacements != 0) { + free(frontendOptionReplacements); + numFrontendOptionReplacements = 0; + } + } + + if (numCustomFrontendScreens == 0) + return; + + for (int i = 0; i < MENUPAGES; i++) { + if (i > lastOgScreen) { + aScreens[i].m_ScreenName[0] = '\0'; + aScreens[i].unk = 0; + } } - free(customFrontendOptions); - numCustomFrontendOptions = 0; + free(customFrontendScreens); + numCustomFrontendScreens = 0; + lastOgScreen = MENUPAGES; +} + +int8 RegisterNewScreen(char *name, int prevPage) +{ + if (lastOgScreen == MENUPAGES) + lastOgScreen = GetLastMenuScreen(); + + numCustomFrontendScreens++; + if (numCustomFrontendScreens == 1) + customFrontendScreens = (FrontendScreen*)malloc(5 * sizeof(FrontendScreen)); + else if (numCustomFrontendScreens % 5 == 1) + customFrontendScreens = (FrontendScreen*)realloc(customFrontendScreens, (numCustomFrontendScreens + 4) * sizeof(FrontendScreen)); + + assert(customFrontendScreens != nil && "Custom frontend screens can't be allocated"); + + int id = lastOgScreen + numCustomFrontendScreens; + assert(id < MENUPAGES && "No room for new custom frontend screens! Increase MENUPAGES"); + strncpy(aScreens[id].m_ScreenName, name, 8); + aScreens[id].m_PreviousPage[0] = aScreens[id].m_PreviousPage[1] = prevPage; + aScreens[id].unk = 1; + return id; } -int8 RegisterNewOption(int screen) +int8 RegisterNewOption() { numCustomFrontendOptions++; if (numCustomFrontendOptions == 1) @@ -77,97 +145,154 @@ int8 RegisterNewOption(int screen) assert(customFrontendOptions != nil && "Custom frontend options can't be allocated"); - uint8 nth = GetNumberOfMenuOptions(screen); + uint8 numOptions = GetNumberOfMenuOptions(currentMenu); + uint8 curIdx; if (optionCursor < 0) { - if (optionCursor == -1) { - if (!strcmp(aScreens[screen].m_aEntries[nth - 1].m_EntryName, "FEDS_TB") || !strcmp(aScreens[screen].m_aEntries[nth - 1].m_EntryName, "FESZ_CA")) { - // Move back button one below - memcpy(&aScreens[screen].m_aEntries[nth], &aScreens[screen].m_aEntries[nth - 1], sizeof(CMenuScreen::CMenuEntry)); - nth--; + optionCursor = curIdx = numOptions + optionCursor + 1; + } else + curIdx = optionCursor; + + if (!optionOverwrite) { + if (aScreens[currentMenu].m_aEntries[curIdx].m_Action != MENUACTION_NOTHING) { + for (int i = numOptions - 1; i >= curIdx; i--) { + memcpy(&aScreens[currentMenu].m_aEntries[i + 1], &aScreens[currentMenu].m_aEntries[i], sizeof(CMenuScreen::CMenuEntry)); } } + } + optionCursor++; + + if (optionOverwrite) { + numFrontendOptionReplacements++; + if (numFrontendOptionReplacements == 1) + frontendOptionReplacements = (CMenuScreen::CMenuEntry*)malloc(5 * sizeof(CMenuScreen::CMenuEntry)); + else if (numFrontendOptionReplacements % 5 == 1) + frontendOptionReplacements = (CMenuScreen::CMenuEntry*)realloc(frontendOptionReplacements, (numFrontendOptionReplacements + 4) * sizeof(CMenuScreen::CMenuEntry)); + + memcpy(&frontendOptionReplacements[numFrontendOptionReplacements - 1], &aScreens[currentMenu].m_aEntries[curIdx], sizeof(CMenuScreen::CMenuEntry)); + customFrontendOptions[numCustomFrontendOptions - 1].ogOptionId = numFrontendOptionReplacements - 1; } else { - if (aScreens[screen].m_aEntries[optionCursor].m_Action != MENUACTION_NOTHING) { - for (int i = nth - 1; i >= optionCursor; i--) { - memcpy(&aScreens[screen].m_aEntries[i + 1], &aScreens[screen].m_aEntries[i], sizeof(CMenuScreen::CMenuEntry)); - } - } - nth = optionCursor; - optionCursor++; + customFrontendOptions[numCustomFrontendOptions - 1].ogOptionId = -1; } + customFrontendOptions[numCustomFrontendOptions - 1].screen = currentMenu; - aScreens[screen].m_aEntries[nth].m_Action = MENUACTION_TRIGGERFUNC; - aScreens[screen].m_aEntries[nth].m_TargetMenu = numCustomFrontendOptions - 1; - aScreens[screen].m_aEntries[nth].m_EntryName[0] = 1; // just something to fool it - return nth; + aScreens[currentMenu].m_aEntries[curIdx].m_Action = MENUACTION_TRIGGERFUNC; + aScreens[currentMenu].m_aEntries[curIdx].m_SaveSlot = SAVESLOT_CFO; + aScreens[currentMenu].m_aEntries[curIdx].m_TargetMenu = numCustomFrontendOptions - 1; + aScreens[currentMenu].m_aEntries[curIdx].m_EntryName[0] = 1; // just something to fool it + return curIdx; } -void FrontendOptionSetPosition(eMenuScreen screen, int8 option) +void FrontendOptionSetCursor(int screen, int8 option, bool overwrite) { currentMenu = screen; optionCursor = option; + optionOverwrite = overwrite; } -void FrontendOptionAddSelect(const wchar* leftText, const wchar** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, ReturnPrevPageFunc returnPrevPageFunc) +void FrontendOptionAddBuiltinAction(const wchar* leftText, int action, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc) { + int8 screenOptionOrder = RegisterNewOption(); + + FrontendOption& option = customFrontendOptions[numCustomFrontendOptions - 1]; + + // To fool the Frontend, we will still display the text passed via first param. + switch (action) { + case MENUACTION_SCREENRES: + strcpy(aScreens[currentMenu].m_aEntries[screenOptionOrder].m_EntryName, "FED_RES"); + break; + case MENUACTION_AUDIOHW: + strcpy(aScreens[currentMenu].m_aEntries[screenOptionOrder].m_EntryName, "FEA_3DH"); + break; + } + aScreens[currentMenu].m_aEntries[screenOptionOrder].m_Action = action; + option.type = FEOPTION_BUILTIN_ACTION; + option.buttonPressFunc = buttonPressFunc; + TextCopy(option.leftText, leftText); + option.screenOptionOrder = screenOptionOrder; + option.returnPrevPageFunc = returnPrevPageFunc; + option.save = false; +} + +void FrontendOptionAddSelect(const wchar* leftText, const wchar** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, ReturnPrevPageFunc returnPrevPageFunc, bool save) { - int8 screenOptionOrder = RegisterNewOption(currentMenu); + int8 screenOptionOrder = RegisterNewOption(); FrontendOption& option = customFrontendOptions[numCustomFrontendOptions - 1]; - option.screen = currentMenu; option.type = FEOPTION_SELECT; - option.leftText = leftText; + TextCopy(option.leftText, leftText); option.rightTexts = rightTexts; option.numRightTexts = numRightTexts; option.value = var; option.displayedValue = *var; + option.lastSavedValue = *var; + option.save = save; option.onlyApplyOnEnter = onlyApplyOnEnter; option.changeFunc = changeFunc; option.screenOptionOrder = screenOptionOrder; option.returnPrevPageFunc = returnPrevPageFunc; } -void FrontendOptionAddDynamic(const wchar* leftText, DrawFunc drawFunc, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc) +void FrontendOptionAddDynamic(const wchar* leftText, DrawFunc drawFunc, int8 *var, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc, bool save) { - int8 screenOptionOrder = RegisterNewOption(currentMenu); + int8 screenOptionOrder = RegisterNewOption(); FrontendOption& option = customFrontendOptions[numCustomFrontendOptions - 1]; - option.screen = currentMenu; option.type = FEOPTION_DYNAMIC; option.drawFunc = drawFunc; option.buttonPressFunc = buttonPressFunc; - option.leftText = leftText; - option.onlyApplyOnEnter = false; + TextCopy(option.leftText, leftText); + option.value = var; + option.save = save; option.screenOptionOrder = screenOptionOrder; option.returnPrevPageFunc = returnPrevPageFunc; } -void FrontendOptionAddRedirect(const wchar* text, eMenuScreen to, int8 selectedOption, bool fadeIn) +void FrontendOptionAddRedirect(const wchar* text, int to, int8 selectedOption, bool fadeIn) { - int8 screenOptionOrder = RegisterNewOption(currentMenu); + int8 screenOptionOrder = RegisterNewOption(); FrontendOption &option = customFrontendOptions[numCustomFrontendOptions - 1]; - option.screen = currentMenu; option.type = FEOPTION_REDIRECT; option.to = to; option.option = selectedOption; option.fadeIn = fadeIn; - option.leftText = text; - option.onlyApplyOnEnter = false; + TextCopy(option.leftText, text); option.screenOptionOrder = screenOptionOrder; option.returnPrevPageFunc = nil; + option.save = false; } void FrontendOptionAddBackButton(const wchar* text, bool fadeIn) { - int8 screenOptionOrder = RegisterNewOption(currentMenu); + int8 screenOptionOrder = RegisterNewOption(); FrontendOption& option = customFrontendOptions[numCustomFrontendOptions - 1]; - option.screen = currentMenu; option.type = FEOPTION_GOBACK; option.fadeIn = fadeIn; - option.leftText = text; - option.onlyApplyOnEnter = false; + TextCopy(option.leftText, text); option.screenOptionOrder = screenOptionOrder; option.returnPrevPageFunc = nil; + option.save = false; +} + +uint8 FrontendScreenAdd(char* gxtKey, eMenuSprites sprite, int prevPage, int columnWidth, int headerHeight, int lineHeight, + int8 font, float fontScaleX, float fontScaleY, int8 alignment, bool showLeftRightHelper, ReturnPrevPageFunc returnPrevPageFunc) { + + uint8 screenOrder = RegisterNewScreen(gxtKey, prevPage); + + FrontendScreen &screen = customFrontendScreens[numCustomFrontendScreens - 1]; + screen.id = screenOrder; + screen.sprite = sprite; + screen.prevPage = prevPage; + strncpy(screen.name, gxtKey, 8); + screen.columnWidth = columnWidth; + screen.headerHeight = headerHeight; + screen.lineHeight = lineHeight; + screen.font = font; + screen.fontScaleX = fontScaleX; + screen.fontScaleY = fontScaleY; + screen.alignment = alignment; + screen.returnPrevPageFunc = returnPrevPageFunc; + + return screenOrder; } #endif \ No newline at end of file diff --git a/src/extras/frontendoption.h b/src/extras/frontendoption.h index 7cfc09a7..9608870b 100644 --- a/src/extras/frontendoption.h +++ b/src/extras/frontendoption.h @@ -4,48 +4,102 @@ #ifdef CUSTOM_FRONTEND_OPTIONS #include "Frontend.h" -// Warning: All of the code relies on that you won't use more then NUM_MENUROWS(18) options on one page. Also congrats if you can make 18 options visible at once. +// Warning: +// All of the code relies on that you won't use more then NUM_MENUROWS(18) options on one page. +// Also congrats if you can make 18 options visible at once. +// About texts: +// All text parameters accept wchar(including hardcoded wchar* and TheText.Get) +// except FrontendScreenAdd(it's char[8] by the design of Frontend). +// All texts reload if custom options reloaded too, which includes language changes and via live reload feature in debug menu! -// Static/select: User allocates variable, passes it to function and it's set automatically from input among the strings given to function, -// then you can handle ChangeFunc and ReturnPrevPageFunc if needed. +// Execute direction: +// All of the calls below eventually manipulate the aScreens array, so keep in mind to add/replace options in order, +// i.e. don't set cursor to 8 first and then 3. + +// Live reload: +// You can add/change/undo the new options in-game if you use VS. Change what you want, build the changed bits via "Edit and Continue", +// and hit the "Reload custom frontend options" from debug menu. Or call CustomFrontendOptionsPopulate() from somewhere else. + + +// -- Option types +// +// Static/select: You allocate the variable, pass it to function and game sets it from user input among the strings given to function, +// then you can handle ChangeFunc(only called on enter if onlyApplyOnEnter set, or set immediately) +// and ReturnPrevPageFunc optionally. You can store the option in gta3.set if you pass true to corresponding parameter. +// +// Dynamic: Passing variable to function is only needed if you want to store it, otherwise you should do +// all the operations with ButtonPressFunc, this includes allocating the variable. +// Left-side text is passed while creating and static, but ofc right-side text is dynamic - +// you should return it in DrawFunc, which is called on every draw. ReturnPrevPageFunc is also here if needed. // -// Dynamic: Function doesn't accept value pointer, user should do operations with handling ButtonPressFunc. -// Right-side text can be set via DrawFunc, which is called on every draw. ReturnPrevPageFunc is also here if needed. +// Redirect: Redirection to another screen. selectedOption parameter is the highlighted option user will see after the redirection. +// +// Built-in action: As the name suggests, any action that game has built-in. But as an extra you can set the option text, +// and can be informed on button press/focus loss via buttonPressFunc. ReturnPrevPageFunc is also here. #define FEOPTION_SELECT 0 #define FEOPTION_DYNAMIC 1 #define FEOPTION_REDIRECT 2 #define FEOPTION_GOBACK 3 +#define FEOPTION_BUILTIN_ACTION 4 +// -- Returned via ButtonPressFunc() action param. #define FEOPTION_ACTION_LEFT 0 #define FEOPTION_ACTION_RIGHT 1 #define FEOPTION_ACTION_SELECT 2 #define FEOPTION_ACTION_FOCUSLOSS 3 -void RemoveCustomFrontendOptions(); -void CustomFrontendOptionsPopulate(); +// -- Passed via FrontendScreenAdd() +#define FESCREEN_CENTER 0 +#define FESCREEN_LEFT_ALIGN 1 +#define FESCREEN_RIGHT_ALIGN 2 -// for static and dynamic options +// -- Callbacks + +// pretty much in everything I guess, and optional in all of them typedef void (*ReturnPrevPageFunc)(); // for static options -typedef void (*ChangeFunc)(int8 displayedValue); // called before updating the value +typedef void (*ChangeFunc)(int8 displayedValue); // called before updating the value. + // only called on enter if onlyApplyOnEnter set, otherwise called on every value change // for dynamic options -typedef wchar* (*DrawFunc)(bool* disabled); // should return pointer to right text. *disabled = true will make it dark yellow +typedef wchar* (*DrawFunc)(bool* disabled, bool userHovering); // you must return a pointer for right text. + // you can also set *disabled if you want to gray it out. typedef void (*ButtonPressFunc)(int8 action); // see FEOPTION_ACTIONs above +struct FrontendScreen +{ + int id; + char name[8]; + eMenuSprites sprite; + int prevPage; + int columnWidth; + int headerHeight; + int lineHeight; + int8 font; + float fontScaleX; + float fontScaleY; + int8 alignment; + bool showLeftRightHelper; + ReturnPrevPageFunc returnPrevPageFunc; +}; + struct FrontendOption { int8 type; int8 screenOptionOrder; - eMenuScreen screen; - const wchar* leftText; + int32 screen; + wchar leftText[64]; ReturnPrevPageFunc returnPrevPageFunc; + int8* value; + int8 displayedValue; // only if onlyApplyOnEnter enabled for now + bool save; + int32 ogOptionId; // for replacements, see overwrite parameter of SetCursor union { - // Only for dynamic + // Only for dynamic / built-in action struct { DrawFunc drawFunc; ButtonPressFunc buttonPressFunc; @@ -55,33 +109,54 @@ struct FrontendOption struct { const wchar** rightTexts; int8 numRightTexts; - int8 *value; - int8 displayedValue; // if onlyApplyOnEnter enabled bool onlyApplyOnEnter; ChangeFunc changeFunc; + int8 lastSavedValue; // only if onlyApplyOnEnter enabled }; // Only for redirect struct { - eMenuScreen to; + int to; int8 option; bool fadeIn; }; }; }; +// -- Internal things +void RemoveCustomFrontendOptions(); +void CustomFrontendOptionsPopulate(); + +extern int lastOgScreen; // for reloading + extern int numCustomFrontendOptions; extern FrontendOption* customFrontendOptions; -// To be used in ButtonPressFunc / ChangeFunc(but that would be weird): -void ChangeScreen(eMenuScreen screen, int option = 0, bool fadeIn = true); +extern int numCustomFrontendScreens; +extern FrontendScreen* customFrontendScreens; + +// -- To be used in ButtonPressFunc / ChangeFunc(this one would be weird): +void ChangeScreen(int screen, int option = 0, bool fadeIn = true); void GoBack(bool fadeIn = true); -// If option is positive number, all calls will increase it before using it (you can think it as cursor). -1 means before the back button, -2 is end of page -void FrontendOptionSetPosition(eMenuScreen screen, int8 option = -1); +uint8 GetNumberOfMenuOptions(int screen); -void FrontendOptionAddSelect(const wchar* leftText, const wchar** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, ReturnPrevPageFunc returnPrevPageFunc); -void FrontendOptionAddDynamic(const wchar* leftText, DrawFunc rightTextDrawFunc, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc); -void FrontendOptionAddRedirect(const wchar* text, eMenuScreen to, int8 selectedOption = 0, bool fadeIn = true); +// -- Placing the cursor to append/overwrite option +// +// Done via FrontendOptionSetCursor(screen, position, overwrite = false), parameters explained below: +// Screen: as the name suggests. Also accepts the screen IDs returned from FrontendScreenAdd. +// Option: if positive, next AddOption call will put the option to there and progress the cursor. +// if negative, cursor will be placed on bottom-(pos+1), so -1 means the very bottom, -2 means before the back button etc. +// Overwrite: Use to overwrite the options, not appending a new one. AddOption calls will still progress the cursor. + +void FrontendOptionSetCursor(int screen, int8 option, bool overwrite = false); + +// var is optional in AddDynamic, you can enable save parameter if you pass one, otherwise pass nil/0 +void FrontendOptionAddBuiltinAction(const wchar* leftText, int action, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc); +void FrontendOptionAddSelect(const wchar* leftText, const wchar** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, ReturnPrevPageFunc returnPrevPageFunc, bool save = false); +void FrontendOptionAddDynamic(const wchar* leftText, DrawFunc rightTextDrawFunc, int8 *var, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc, bool save = false); +void FrontendOptionAddRedirect(const wchar* text, int to, int8 selectedOption = 0, bool fadeIn = true); void FrontendOptionAddBackButton(const wchar* text, bool fadeIn = true); + +uint8 FrontendScreenAdd(char* gxtKey, eMenuSprites sprite, int prevPage, int columnWidth, int headerHeight, int lineHeight, int8 font, float fontScaleX, float fontScaleY, int8 alignment, bool showLeftRightHelper, ReturnPrevPageFunc returnPrevPageFunc = nil); #endif \ No newline at end of file -- cgit v1.2.3 From 700967dd2d931368a8aff614cf07b6654973d54a Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 25 Aug 2020 00:04:01 +0200 Subject: update librw --- vendor/librw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/librw b/vendor/librw index fbb2d35f..30b77b0b 160000 --- a/vendor/librw +++ b/vendor/librw @@ -1 +1 @@ -Subproject commit fbb2d35fc4b5eb1a1f0b9a74fb77d5d9b218dbb6 +Subproject commit 30b77b0b32b4113b5dce2b67813ce9b85d1e1e57 -- cgit v1.2.3 From 290faa5e4bea56460ff7638a66fac15bd09c7205 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Tue, 25 Aug 2020 02:06:27 +0300 Subject: update lib --- vendor/opus | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/opus b/vendor/opus index 6bae366f..034c1b61 160000 --- a/vendor/opus +++ b/vendor/opus @@ -1 +1 @@ -Subproject commit 6bae366f9fef25191fc812c430e8abd40a13a233 +Subproject commit 034c1b61a250457649d788bbf983b3f0fb63f02e -- cgit v1.2.3 From 76585772607a7fbbed9e19ee0b4556b9140cde16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Tue, 25 Aug 2020 03:27:38 +0300 Subject: CFO fixes --- src/core/Frontend.cpp | 64 +++++++++++++++++++++---------------------- src/core/Game.cpp | 5 +++- src/core/re3.cpp | 9 ++++-- src/extras/frontendoption.cpp | 7 ++++- src/extras/frontendoption.h | 2 +- 5 files changed, 50 insertions(+), 37 deletions(-) diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index fbefe354..0e358fc5 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -1075,6 +1075,38 @@ CMenuManager::Draw() leftText = TheText.Get(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName); } +#ifdef CUSTOM_FRONTEND_OPTIONS + if (aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot == SAVESLOT_CFO) { + FrontendOption &option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[i].m_TargetMenu]; + if (option.type == FEOPTION_SELECT) { + if (option.onlyApplyOnEnter){ + if (m_nCurrOption != i) { + if (option.displayedValue != option.lastSavedValue) + SetHelperText(3); // Restored original value + +// option.displayedValue = option.lastSavedValue = *option.value; + + } else { + if (option.displayedValue != *option.value) + SetHelperText(1); // Enter to apply + else if (m_nHelperTextMsgId == 1) + ResetHelperText(); // Applied + } + } + } + + if (m_nCurrOption != lastOption && lastOption == i) { + FrontendOption &oldOption = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[lastOption].m_TargetMenu]; + if (oldOption.type == FEOPTION_DYNAMIC || oldOption.type == FEOPTION_BUILTIN_ACTION) + if(oldOption.buttonPressFunc) + oldOption.buttonPressFunc(FEOPTION_ACTION_FOCUSLOSS); + + if (oldOption.onlyApplyOnEnter && oldOption.type == FEOPTION_SELECT) + oldOption.displayedValue = oldOption.lastSavedValue = *oldOption.value; + } + } +#endif + switch (aScreens[m_nCurrScreen].m_aEntries[i].m_Action) { case MENUACTION_CHANGEMENU: { switch (aScreens[m_nCurrScreen].m_aEntries[i].m_TargetMenu) { @@ -1477,38 +1509,6 @@ CMenuManager::Draw() } } -#ifdef CUSTOM_FRONTEND_OPTIONS - if (aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot == SAVESLOT_CFO) { - FrontendOption &option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[i].m_TargetMenu]; - if (option.type == FEOPTION_SELECT) { - if (option.onlyApplyOnEnter){ - if (m_nCurrOption != i) { - if (option.displayedValue != option.lastSavedValue) - SetHelperText(3); // Restored original value - -// option.displayedValue = option.lastSavedValue = *option.value; - - } else { - if (option.displayedValue != *option.value) - SetHelperText(1); // Enter to apply - else if (m_nHelperTextMsgId == 1) - ResetHelperText(); // Applied - } - } - } - - if (m_nCurrOption != lastOption && lastOption == i) { - FrontendOption &oldOption = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[lastOption].m_TargetMenu]; - if (oldOption.type == FEOPTION_DYNAMIC || oldOption.type == FEOPTION_BUILTIN_ACTION) - if(oldOption.buttonPressFunc) - oldOption.buttonPressFunc(FEOPTION_ACTION_FOCUSLOSS); - - if (oldOption.onlyApplyOnEnter && oldOption.type == FEOPTION_SELECT) - oldOption.displayedValue = oldOption.lastSavedValue = *oldOption.value; - } - } -#endif - // Sliders int lastActiveBarX; switch (aScreens[m_nCurrScreen].m_aEntries[i].m_Action) { diff --git a/src/core/Game.cpp b/src/core/Game.cpp index c0530709..e944512a 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -295,7 +295,10 @@ bool CGame::InitialiseOnceAfterRW(void) CWorld::Players[0].SetPlayerSkin(CMenuManager::m_PrefsSkinFile); #ifdef CUSTOM_FRONTEND_OPTIONS - CustomFrontendOptionsPopulate(); + if (numCustomFrontendOptions == 0 && numCustomFrontendScreens == 0) { + CustomFrontendOptionsPopulate(); + FrontEndMenuManager.LoadSettings(); + } #endif return true; } diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 2922f73e..a7a0d7f1 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -177,7 +177,12 @@ wchar* MultiSamplingDraw(bool *disabled, bool userHovering) { } else { FrontEndMenuManager.SetHelperText(1); } + } else { + if (FrontEndMenuManager.m_nDisplayMSAALevel != FrontEndMenuManager.m_nPrefsMSAALevel) { + FrontEndMenuManager.m_nDisplayMSAALevel = FrontEndMenuManager.m_nPrefsMSAALevel; + } } + if (!FrontEndMenuManager.m_bGameNotLoaded) *disabled = true; @@ -305,7 +310,7 @@ CustomFrontendOptionsPopulate(void) #endif // -- Graphics/display seperation preperation end - static const wchar* off_on[] = { TheText.Get("FEM_OFF"), TheText.Get("FEM_ON") }; + const wchar* off_on[] = { TheText.Get("FEM_OFF"), TheText.Get("FEM_ON") }; #ifdef MORE_LANGUAGES FrontendOptionSetCursor(MENUPAGE_LANGUAGE_SETTINGS, -2); @@ -326,7 +331,7 @@ CustomFrontendOptionsPopulate(void) CLONE_OPTION(TheText.Get("FED_WIS"), MENUACTION_WIDESCREEN, nil, nil) #ifdef IMPROVED_VIDEOMODE - static const wchar* screenModes[] = { (wchar*)L"FULLSCREEN", (wchar*)L"WINDOWED" }; + const wchar* screenModes[] = { TheText.Get("FED_FLS"), TheText.Get("FED_WND") }; // Storing isn't enabled because it's handled in Frontend FrontendOptionAddSelect(TheText.Get("FEM_SCF"), screenModes, 2, (int8*)&FrontEndMenuManager.m_nPrefsWindowed, true, ScreenModeChange, nil); #endif diff --git a/src/extras/frontendoption.cpp b/src/extras/frontendoption.cpp index 3214bbfd..f8d9f81e 100644 --- a/src/extras/frontendoption.cpp +++ b/src/extras/frontendoption.cpp @@ -76,6 +76,10 @@ RemoveCustomFrontendOptions() for (int j = 0; j < NUM_MENUROWS; j++) { if (aScreens[i].m_aEntries[j].m_SaveSlot == SAVESLOT_CFO) { int ogOptionId = customFrontendOptions[aScreens[i].m_aEntries[j].m_TargetMenu].ogOptionId; + + if (customFrontendOptions[aScreens[i].m_aEntries[j].m_TargetMenu].type == FEOPTION_SELECT) + free(customFrontendOptions[aScreens[i].m_aEntries[j].m_TargetMenu].rightTexts); + if (ogOptionId == -1) { int k; for (k = j; k < NUM_MENUROWS - 1; k++) { @@ -219,7 +223,8 @@ void FrontendOptionAddSelect(const wchar* leftText, const wchar** rightTexts, in FrontendOption& option = customFrontendOptions[numCustomFrontendOptions - 1]; option.type = FEOPTION_SELECT; TextCopy(option.leftText, leftText); - option.rightTexts = rightTexts; + option.rightTexts = (wchar**)malloc(numRightTexts * sizeof(wchar*)); + memcpy(option.rightTexts, rightTexts, numRightTexts * sizeof(wchar*)); option.numRightTexts = numRightTexts; option.value = var; option.displayedValue = *var; diff --git a/src/extras/frontendoption.h b/src/extras/frontendoption.h index 9608870b..8e2dd668 100644 --- a/src/extras/frontendoption.h +++ b/src/extras/frontendoption.h @@ -107,7 +107,7 @@ struct FrontendOption // Only for static/select struct { - const wchar** rightTexts; + wchar** rightTexts; int8 numRightTexts; bool onlyApplyOnEnter; ChangeFunc changeFunc; -- cgit v1.2.3 From 93d77f340df1305fd8a802034b878f69f2cb1285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Thu, 10 Sep 2020 03:14:50 +0300 Subject: Fixes from miami --- src/audio/sampman_oal.cpp | 2 +- src/control/PathFind.cpp | 2 +- src/control/Script.cpp | 6 +-- src/peds/Ped.cpp | 129 ++++++++++++++++++++++------------------------ src/peds/Ped.h | 1 + 5 files changed, 69 insertions(+), 71 deletions(-) diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 5e4b5aba..a8056c03 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -450,9 +450,9 @@ int8 cSampleManager::GetCurrent3DProviderIndex(void) int8 cSampleManager::SetCurrent3DProvider(uint8 nProvider) { - ASSERT( nProvider < m_nNumberOfProviders ); if (nProvider >= m_nNumberOfProviders) nProvider = 0; + ASSERT( nProvider < m_nNumberOfProviders ); int savedprovider = curprovider; if ( nProvider < m_nNumberOfProviders ) diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp index 46895678..fb60250c 100644 --- a/src/control/PathFind.cpp +++ b/src/control/PathFind.cpp @@ -1682,7 +1682,7 @@ CPathFind::Load(uint8 *buf, uint32 size) void CPathFind::DisplayPathData(void) { - // Not the function from mobm_carPathLinksile but my own! + // Not the function from mobile but my own! int i, j, k; // Draw 50 units around camera diff --git a/src/control/Script.cpp b/src/control/Script.cpp index e9808643..793b61c3 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -4994,7 +4994,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); // Useless call CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - int handle = CRadar::SetCoordBlip(BLIP_COORD, pos, 2, BLIP_DISPLAY_BOTH); + int handle = CRadar::SetCoordBlip(BLIP_CONTACT_POINT, pos, 2, BLIP_DISPLAY_BOTH); CRadar::ChangeBlipScale(handle, 3); ScriptParams[0] = handle; StoreParameters(&m_nIp, 1); @@ -9319,7 +9319,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) CVector pos = *(CVector*)&ScriptParams[0]; if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - C3dMarkers::PlaceMarkerSet((uintptr)this + m_nIp, 4, pos, *(float*)&ScriptParams[3], + C3dMarkers::PlaceMarkerSet((uintptr)this + m_nIp, MARKERTYPE_CYLINDER, pos, *(float*)&ScriptParams[3], SPHERE_MARKER_R, SPHERE_MARKER_G, SPHERE_MARKER_B, SPHERE_MARKER_A, SPHERE_MARKER_PULSE_PERIOD, SPHERE_MARKER_PULSE_FRACTION, 0); return 0; @@ -11254,7 +11254,7 @@ void CTheScripts::DrawScriptSpheres() { for (int i = 0; i < MAX_NUM_SCRIPT_SPHERES; i++) { if (ScriptSphereArray[i].m_bInUse) - C3dMarkers::PlaceMarkerSet(ScriptSphereArray[i].m_Id, 4, ScriptSphereArray[i].m_vecCenter, ScriptSphereArray[i].m_fRadius, + C3dMarkers::PlaceMarkerSet(ScriptSphereArray[i].m_Id, MARKERTYPE_CYLINDER, ScriptSphereArray[i].m_vecCenter, ScriptSphereArray[i].m_fRadius, SPHERE_MARKER_R, SPHERE_MARKER_G, SPHERE_MARKER_B, SPHERE_MARKER_A, SPHERE_MARKER_PULSE_PERIOD, SPHERE_MARKER_PULSE_FRACTION, 0); } } diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index bfcb52e4..0c469942 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -202,8 +202,8 @@ CPed::CPed(uint32 pedType) : m_pedIK(this) m_pedFormation = FORMATION_UNDEFINED; m_collidingThingTimer = 0; m_nPedStateTimer = 0; - m_actionX = 0; - m_actionY = 0; + m_actionX = 0.0f; + m_actionY = 0.0f; m_phoneTalkTimer = 0; m_stateUnused = 0; m_leaveCarTimer = 0; @@ -295,7 +295,6 @@ CPed::CPed(uint32 pedType) : m_pedIK(this) bIsShooting = false; bFindNewNodeAfterStateRestore = false; - bHasACamera = false; bGonnaInvestigateEvent = false; bPedIsBleeding = false; bStopAndShoot = false; @@ -352,7 +351,9 @@ CPed::CPed(uint32 pedType) : m_pedIK(this) bSomeVCflag1 = false; #endif - if ((CGeneral::GetRandomNumber() & 3) == 0) + if (CGeneral::GetRandomNumber() & 3) + bHasACamera = false; + else bHasACamera = true; m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, this); @@ -766,10 +767,10 @@ CPed::OurPedCanSeeThisOne(CEntity *target) CColPoint colpoint; CEntity *ent; - CVector2D dist = CVector2D(target->GetPosition()) - CVector2D(this->GetPosition()); + CVector2D dist = CVector2D(target->GetPosition()) - CVector2D(GetPosition()); // Check if target is behind ped - if (DotProduct2D(dist, CVector2D(this->GetForward())) < 0.0f) + if (DotProduct2D(dist, CVector2D(GetForward())) < 0.0f) return false; // Check if target is too far away @@ -798,7 +799,7 @@ CPed::Avoid(void) if (nearestPed && nearestPed->m_nPedState != PED_DEAD && nearestPed != m_pSeekTarget && nearestPed != m_pedInObjective) { // Check if this ped wants to avoid the nearest one - if (CPedType::GetAvoid(this->m_nPedType) & CPedType::GetFlag(nearestPed->m_nPedType)) { + if (CPedType::GetAvoid(m_nPedType) & CPedType::GetFlag(nearestPed->m_nPedType)) { // Further codes checks whether the distance between us and ped will be equal or below 1.0, if we walk up to him by 1.25 meters. // If so, we want to avoid it, so we turn our body 45 degree and look to somewhere else. @@ -1761,7 +1762,6 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) if (seatPosMult > 0.2f || vehIsUpsideDown) { SetPosition(neededPos); - SetHeading(m_fRotationCur); } else { CMatrix vehDoorMat(veh->GetMatrix()); @@ -2925,7 +2925,7 @@ CPed::ReactToAttack(CEntity *attacker) return; } } else if (bCrouchWhenShooting || bKindaStayInSamePlace) { - SetDuck(CGeneral::GetRandomNumberInRange(1000,3000)); + SetDuck(CGeneral::GetRandomNumberInRange(1000, 3000)); return; } @@ -8130,7 +8130,7 @@ CPed::InvestigateEvent(void) animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_IDLE_STANCE); if (animAssoc && animAssoc->animId == ANIM_IDLE_CAM) { - CAnimManager::BlendAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE, 14.0f); + CAnimManager::BlendAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE, 4.0f); SetLookTimer(CGeneral::GetRandomNumberInRange(1000, 2500)); } else if (CGeneral::GetRandomNumber() & 3) { @@ -8157,7 +8157,7 @@ CPed::InvestigateEvent(void) animToPlay = ANIM_XPRESS_SCRATCH; CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, animToPlay, 4.0f); - SetLookTimer(CGeneral::GetRandomNumberInRange(1000, 2500)); + SetLookTimer(CGeneral::GetRandomNumberInRange(1500, 4000)); } else if (animAssoc && animAssoc->animId == ANIM_IDLE_HBHB) { animAssoc->blendDelta = -8.0f; @@ -8247,7 +8247,7 @@ CPed::InvestigateEvent(void) SetMoveState(PEDMOVE_WALK); return; } - if (distSqr > 1.44f) { + if (distSqr > sq(1.2f)) { SetMoveState(PEDMOVE_WALK); return; } @@ -8555,7 +8555,6 @@ CPed::LookForInterestingNodes(void) { CBaseModelInfo *model; CPtrNode *ptrNode; - CVector effectPos; CVector effectDist; C2dEffect *effect; CMatrix *objMat; @@ -8596,7 +8595,7 @@ CPed::LookForInterestingNodes(void) effect = model->Get2dEffect(e); if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) { objMat = &veh->GetMatrix(); - effectPos = veh->GetMatrix() * effect->pos; + CVector effectPos = veh->GetMatrix() * effect->pos; effectDist = effectPos - GetPosition(); if (effectDist.MagnitudeSqr() < sq(8.0f)) { found = true; @@ -8614,7 +8613,7 @@ CPed::LookForInterestingNodes(void) effect = model->Get2dEffect(e); if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) { objMat = &obj->GetMatrix(); - effectPos = obj->GetMatrix() * effect->pos; + CVector effectPos = obj->GetMatrix() * effect->pos; effectDist = effectPos - GetPosition(); if (effectDist.MagnitudeSqr() < sq(8.0f)) { found = true; @@ -8632,7 +8631,7 @@ CPed::LookForInterestingNodes(void) effect = model->Get2dEffect(e); if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) { objMat = &building->GetMatrix(); - effectPos = building->GetMatrix() * effect->pos; + CVector effectPos = building->GetMatrix() * effect->pos; effectDist = effectPos - GetPosition(); if (effectDist.MagnitudeSqr() < sq(8.0f)) { found = true; @@ -8650,7 +8649,7 @@ CPed::LookForInterestingNodes(void) effect = model->Get2dEffect(e); if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) { objMat = &building->GetMatrix(); - effectPos = building->GetMatrix() * effect->pos; + CVector effectPos = building->GetMatrix() * effect->pos; effectDist = effectPos - GetPosition(); if (effectDist.MagnitudeSqr() < sq(8.0f)) { found = true; @@ -8676,12 +8675,13 @@ CPed::LookForInterestingNodes(void) return false; } + CVector2D effectPos = *objMat * effect->pos; switch (effect->attractor.type) { case ATTRACTORTYPE_ICECREAM: - SetInvestigateEvent(EVENT_ICECREAM, CVector2D(effectPos), 0.1f, 15000, angleToFace); + SetInvestigateEvent(EVENT_ICECREAM, effectPos, 0.1f, 15000, angleToFace); break; case ATTRACTORTYPE_STARE: - SetInvestigateEvent(EVENT_SHOPSTALL, CVector2D(effectPos), 1.0f, + SetInvestigateEvent(EVENT_SHOPSTALL, effectPos, 1.0f, CGeneral::GetRandomNumberInRange(8000, 10 * effect->attractor.probability + 8500), angleToFace); break; @@ -11732,7 +11732,7 @@ CPed::RegisterThreatWithGangPeds(CEntity *attacker) if (!attackerPed->m_pMyVehicle || attackerPed->m_pMyVehicle->GetModelIndex() != MI_TOYZ) { int16 lastVehicle; CEntity *vehicles[8]; - CWorld::FindObjectsInRange(GetPosition(), 30.0f, true, &lastVehicle, 6, vehicles, false, true, false, false, false); + CWorld::FindObjectsInRange(GetPosition(), ENTER_CAR_MAX_DIST, true, &lastVehicle, 6, vehicles, false, true, false, false, false); if (lastVehicle > 8) lastVehicle = 8; @@ -12539,7 +12539,8 @@ CPed::ProcessObjective(void) SetObjective(OBJECTIVE_LEAVE_CAR, m_pMyVehicle); bFleeAfterExitingCar = true; } else if (m_nPedState != PED_FLEE_POS) { - SetFlee(GetPosition(), 10000); + CVector2D fleePos = GetPosition(); + SetFlee(fleePos, 10000); bUsePedNodeSeek = true; m_pNextPathNode = nil; } @@ -12585,7 +12586,7 @@ CPed::ProcessObjective(void) { if (m_pedInObjective) { if (m_pedInObjective->IsPlayer() && CharCreatedBy != MISSION_CHAR - && m_nPedType != PEDTYPE_COP && FindPlayerPed()->m_pWanted->m_CurrentCops + && m_nPedType != PEDTYPE_COP && FindPlayerPed()->m_pWanted->m_CurrentCops != 0 && !bKindaStayInSamePlace) { SetObjective(OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE); @@ -12693,7 +12694,6 @@ CPed::ProcessObjective(void) SetObjective(OBJECTIVE_LEAVE_CAR, m_pMyVehicle); break; } - if (!m_pedInObjective || m_pedInObjective->DyingOrDead()) { ClearLookFlag(); bObjectiveCompleted = true; @@ -13249,7 +13249,7 @@ CPed::ProcessObjective(void) if (m_carInObjective && m_carInObjective->m_fHealth > 0.0f) { distWithTarget = m_carInObjective->GetPosition() - GetPosition(); if (!bInVehicle) { - if (nEnterCarRangeMultiplier * 30.0f < distWithTarget.Magnitude()) { + if (nEnterCarRangeMultiplier * ENTER_CAR_MAX_DIST < distWithTarget.Magnitude()) { if (!m_carInObjective->pDriver && !m_carInObjective->GetIsOnScreen() && !GetIsOnScreen()) WarpPedToNearEntityOffScreen(m_carInObjective); @@ -13534,11 +13534,12 @@ CPed::ProcessObjective(void) RestorePreviousObjective(); } else if (m_hitRecoverTimer < CTimer::GetTimeInMilliseconds()) { CVehicle *carToSteal = nil; - float closestCarDist = 30.0f; + float closestCarDist = ENTER_CAR_MAX_DIST; CVector pos = GetPosition(); int16 lastVehicle; CEntity *vehicles[8]; + // NB: This should've been ENTER_CAR_MAX_DIST actually, and is fixed in VC. CWorld::FindObjectsInRange(pos, CHECK_NEARBY_THINGS_MAX_DIST, true, &lastVehicle, 6, vehicles, false, true, false, false, false); for(int i = 0; i < lastVehicle; i++) { CVehicle *nearVeh = (CVehicle*)vehicles[i]; @@ -14545,48 +14546,44 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints) upperSpeedLimit *= 2.0f; lowerSpeedLimit *= 1.5f; } - if (!bWasStanding) { - if ((speed <= upperSpeedLimit /* || (bfFlagsL >> 5) & 1 */) && m_vecMoveSpeed.z >= lowerSpeedLimit - || m_pCollidingEntity == collidingEnt) { - - if (RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FALL_FALL) && -0.016f * CTimer::GetTimeStep() > m_vecMoveSpeed.z) { - InflictDamage(collidingEnt, WEAPONTYPE_FALL, 15.0f, PEDPIECE_TORSO, 2); - } - } else { - float damage = 100.0f * Max(speed - 0.25f, 0.0f); - float damage2 = damage; - if (m_vecMoveSpeed.z < -0.25f) - damage += (-0.25f - m_vecMoveSpeed.z) * 150.0f; - - uint8 dir = 2; // from backward - if (m_vecMoveSpeed.x > 0.01f || m_vecMoveSpeed.x < -0.01f || m_vecMoveSpeed.y > 0.01f || m_vecMoveSpeed.y < -0.01f) { - CVector2D offset = -m_vecMoveSpeed; - dir = GetLocalDirection(offset); - } - InflictDamage(collidingEnt, WEAPONTYPE_FALL, damage, PEDPIECE_TORSO, dir); - if (IsPlayer() && damage2 > 5.0f) - Say(SOUND_PED_LAND); + CAnimBlendAssociation *fallAnim = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FALL_FALL); + if (!bWasStanding && speed > upperSpeedLimit && (/*!bPushedAlongByCar ||*/ m_vecMoveSpeed.z < lowerSpeedLimit) + && m_pCollidingEntity != collidingEnt) { + + float damage = 100.0f * Max(speed - 0.25f, 0.0f); + float damage2 = damage; + if (m_vecMoveSpeed.z < -0.25f) + damage += (-0.25f - m_vecMoveSpeed.z) * 150.0f; + + uint8 dir = 2; // from backward + if (m_vecMoveSpeed.x > 0.01f || m_vecMoveSpeed.x < -0.01f || m_vecMoveSpeed.y > 0.01f || m_vecMoveSpeed.y < -0.01f) { + CVector2D offset = -m_vecMoveSpeed; + dir = GetLocalDirection(offset); } + + InflictDamage(collidingEnt, WEAPONTYPE_FALL, damage, PEDPIECE_TORSO, dir); + if (IsPlayer() && damage2 > 5.0f) + Say(SOUND_PED_LAND); + + } else if (!bWasStanding && fallAnim && -0.016f * CTimer::GetTimeStep() > m_vecMoveSpeed.z) { + InflictDamage(collidingEnt, WEAPONTYPE_FALL, 15.0f, PEDPIECE_TORSO, 2); } #else float speedSqr = 0.0f; - if (!bWasStanding) { - if (m_vecMoveSpeed.z >= -0.25f && (speedSqr = m_vecMoveSpeed.MagnitudeSqr()) <= sq(0.5f)) { - - if (RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FALL_FALL) && -0.016f * CTimer::GetTimeStep() > m_vecMoveSpeed.z) { - InflictDamage(collidingEnt, WEAPONTYPE_FALL, 15.0f, PEDPIECE_TORSO, 2); - } - } else { - if (speedSqr == 0.0f) - speedSqr = sq(m_vecMoveSpeed.z); - - uint8 dir = 2; // from backward - if (m_vecMoveSpeed.x > 0.01f || m_vecMoveSpeed.x < -0.01f || m_vecMoveSpeed.y > 0.01f || m_vecMoveSpeed.y < -0.01f) { - CVector2D offset = -m_vecMoveSpeed; - dir = GetLocalDirection(offset); - } - InflictDamage(collidingEnt, WEAPONTYPE_FALL, 350.0f * sq(speedSqr), PEDPIECE_TORSO, dir); + CAnimBlendAssociation *fallAnim = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FALL_FALL); + if (!bWasStanding && (m_vecMoveSpeed.z < -0.25f || (speedSqr = m_vecMoveSpeed.MagnitudeSqr()) > sq(0.5f))) { + if (speedSqr == 0.0f) + speedSqr = sq(m_vecMoveSpeed.z); + + uint8 dir = 2; // from backward + if (m_vecMoveSpeed.x > 0.01f || m_vecMoveSpeed.x < -0.01f || m_vecMoveSpeed.y > 0.01f || m_vecMoveSpeed.y < -0.01f) { + CVector2D offset = -m_vecMoveSpeed; + dir = GetLocalDirection(offset); } + InflictDamage(collidingEnt, WEAPONTYPE_FALL, 350.0f * sq(speedSqr), PEDPIECE_TORSO, dir); + + } else if (!bWasStanding && fallAnim && -0.016f * CTimer::GetTimeStep() > m_vecMoveSpeed.z) { + InflictDamage(collidingEnt, WEAPONTYPE_FALL, 15.0f, PEDPIECE_TORSO, 2); } #endif m_vecMoveSpeed.z = 0.0f; @@ -14613,7 +14610,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints) bHasHitWall = true; } } - if (collidingEnt->IsBuilding() || collidingEnt->IsStatic()) { + if (collidingEnt->IsBuilding() || collidingEnt->IsStatic()) { if (bWasStanding) { CVector sphereNormal; @@ -15008,7 +15005,7 @@ CPed::ProcessBuoyancy(void) ApplyMoveForce(buoyancyImpulse); if (!DyingOrDead()) { if (bTryingToReachDryLand) { - if (buoyancyImpulse.z / m_fMass > 0.0032f * CTimer::GetTimeStep()) { + if (buoyancyImpulse.z / m_fMass > GRAVITY * 0.4f * CTimer::GetTimeStep()) { bTryingToReachDryLand = false; CVector pos = GetPosition(); if (PlacePedOnDryLand()) { @@ -15032,7 +15029,7 @@ CPed::ProcessBuoyancy(void) } } float speedMult = 0.0f; - if (buoyancyImpulse.z / m_fMass > 0.006f * CTimer::GetTimeStep() + if (buoyancyImpulse.z / m_fMass > GRAVITY * 0.75f * CTimer::GetTimeStep() || mod_Buoyancy.m_waterlevel > GetPosition().z) { speedMult = pow(0.9f, CTimer::GetTimeStep()); m_vecMoveSpeed.x *= speedMult; @@ -15041,7 +15038,7 @@ CPed::ProcessBuoyancy(void) bIsStanding = false; InflictDamage(nil, WEAPONTYPE_DROWNING, 3.0f * CTimer::GetTimeStep(), PEDPIECE_TORSO, 0); } - if (buoyancyImpulse.z / m_fMass > 0.002f * CTimer::GetTimeStep()) { + if (buoyancyImpulse.z / m_fMass > GRAVITY * 0.25f * CTimer::GetTimeStep()) { if (speedMult == 0.0f) { speedMult = pow(0.9f, CTimer::GetTimeStep()); } diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 63d8e598..dbe61572 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -12,6 +12,7 @@ #define FEET_OFFSET 1.04f #define CHECK_NEARBY_THINGS_MAX_DIST 15.0f +#define ENTER_CAR_MAX_DIST 30.0f struct CPathNode; class CAccident; -- cgit v1.2.3 From 38ec1bd50de234faf476daa15ea41778a860ca0b Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 14 Sep 2020 20:48:49 +0300 Subject: Move a bunch of math to cpp files + small fixes --- src/control/CarCtrl.cpp | 14 +- src/math/Matrix.cpp | 552 +++++++++++++++++++++++++++++++++++++++++++++ src/math/Matrix.h | 257 +++------------------ src/math/Quaternion.cpp | 177 +++++++++++++++ src/math/Quaternion.h | 18 +- src/math/Rect.cpp | 17 ++ src/math/Rect.h | 14 +- src/math/Vector.cpp | 46 ++++ src/math/Vector.h | 36 +-- src/math/Vector2D.h | 10 +- src/math/math.cpp | 233 ------------------- src/render/Glass.cpp | 2 +- src/render/Skidmarks.cpp | 7 +- src/render/WaterCannon.cpp | 3 +- 14 files changed, 857 insertions(+), 529 deletions(-) create mode 100644 src/math/Matrix.cpp create mode 100644 src/math/Quaternion.cpp create mode 100644 src/math/Rect.cpp create mode 100644 src/math/Vector.cpp diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index c6d90dd9..5a2def05 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -1080,11 +1080,11 @@ void CCarCtrl::SlowCarDownForCarsSectorList(CPtrList& lst, CVehicle* pVehicle, f void CCarCtrl::SlowCarDownForOtherCar(CEntity* pOtherEntity, CVehicle* pVehicle, float* pSpeed, float curSpeed) { CVector forwardA = pVehicle->GetForward(); - ((CVector2D)forwardA).Normalise(); + ((CVector2D)forwardA).NormaliseSafe(); if (DotProduct2D(pOtherEntity->GetPosition() - pVehicle->GetPosition(), forwardA) < 0.0f) return; CVector forwardB = pOtherEntity->GetForward(); - ((CVector2D)forwardB).Normalise(); + ((CVector2D)forwardB).NormaliseSafe(); forwardA.z = forwardB.z = 0.0f; CVehicle* pOtherVehicle = (CVehicle*)pOtherEntity; /* why is the argument CEntity if it's always CVehicle anyway and is casted? */ @@ -1337,7 +1337,7 @@ void CCarCtrl::WeaveForOtherCar(CEntity* pOtherEntity, CVehicle* pVehicle, float pVehicle->GetModelInfo()->GetColModel()->boundingSphere.radius < distance) return; CVector2D forward = pVehicle->GetForward(); - forward.Normalise(); + forward.NormaliseSafe(); float forwardAngle = CGeneral::GetATanOfXY(forward.x, forward.y); float angleDiff = angleBetweenVehicles - forwardAngle; float lenProjection = ABS(pOtherCar->GetColModel()->boundingBox.max.y * sin(angleDiff)); @@ -2276,7 +2276,7 @@ float CCarCtrl::FindMaxSteerAngle(CVehicle* pVehicle) void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerve, float* pAccel, float* pBrake, bool* pHandbrake) { CVector2D forward = pVehicle->GetForward(); - forward.Normalise(); + forward.NormaliseSafe(); CCarPathLink* pCurrentLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo]; CCarPathLink* pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo]; CVector2D currentPathLinkForward(pCurrentLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection, @@ -2410,7 +2410,7 @@ void CCarCtrl::SteerAICarWithPhysicsHeadingForTarget(CVehicle* pVehicle, CPhysic { *pHandbrake = false; CVector2D forward = pVehicle->GetForward(); - forward.Normalise(); + forward.NormaliseSafe(); float angleToTarget = CGeneral::GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y); float angleForward = CGeneral::GetATanOfXY(forward.x, forward.y); if (pVehicle->AutoPilot.m_nDrivingStyle == DRIVINGSTYLE_AVOID_CARS) @@ -2497,7 +2497,7 @@ void CCarCtrl::SteerAICarWithPhysicsTryingToBlockTarget_Stop(CVehicle* pVehicle, void CCarCtrl::SteerAIBoatWithPhysicsHeadingForTarget(CBoat* pBoat, float targetX, float targetY, float* pSwerve, float* pAccel, float* pBrake) { CVector2D forward(pBoat->GetForward()); - forward.Normalise(); + forward.NormaliseSafe(); CVector2D distanceToTarget = CVector2D(targetX, targetY) - pBoat->GetPosition(); float angleToTarget = CGeneral::GetATanOfXY(distanceToTarget.x, distanceToTarget.y); float angleForward = CGeneral::GetATanOfXY(forward.x, forward.y); @@ -2733,7 +2733,7 @@ bool CCarCtrl::GenerateOneEmergencyServicesCar(uint32 mi, CVector vecPos) pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE; pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS; CVector2D direction = vecPos - spawnPos; - direction.Normalise(); + direction.NormaliseSafe(); pVehicle->GetForward() = CVector(direction.x, direction.y, 0.0f); pVehicle->GetRight() = CVector(direction.y, -direction.x, 0.0f); pVehicle->GetUp() = CVector(0.0f, 0.0f, 1.0f); diff --git a/src/math/Matrix.cpp b/src/math/Matrix.cpp new file mode 100644 index 00000000..3e77548d --- /dev/null +++ b/src/math/Matrix.cpp @@ -0,0 +1,552 @@ +#include "common.h" + +CMatrix::CMatrix(void) +{ + m_attachment = nil; + m_hasRwMatrix = false; +} + +CMatrix::CMatrix(CMatrix const &m) +{ + m_attachment = nil; + m_hasRwMatrix = false; + *this = m; +} + +CMatrix::CMatrix(RwMatrix *matrix, bool owner) +{ + m_attachment = nil; + Attach(matrix, owner); +} + +CMatrix::~CMatrix(void) +{ + if (m_hasRwMatrix && m_attachment) + RwMatrixDestroy(m_attachment); +} + +void +CMatrix::Attach(RwMatrix *matrix, bool owner) +{ +#ifdef FIX_BUGS + if (m_attachment && m_hasRwMatrix) +#else + if (m_hasRwMatrix && m_attachment) +#endif + RwMatrixDestroy(m_attachment); + m_attachment = matrix; + m_hasRwMatrix = owner; + Update(); +} + +void +CMatrix::AttachRW(RwMatrix *matrix, bool owner) +{ + if (m_hasRwMatrix && m_attachment) + RwMatrixDestroy(m_attachment); + m_attachment = matrix; + m_hasRwMatrix = owner; + UpdateRW(); +} + +void +CMatrix::Detach(void) +{ + if (m_hasRwMatrix && m_attachment) + RwMatrixDestroy(m_attachment); + m_attachment = nil; +} + +void +CMatrix::Update(void) +{ + m_matrix = *m_attachment; +} + +void +CMatrix::UpdateRW(void) +{ + if (m_attachment) { + *m_attachment = m_matrix; + RwMatrixUpdate(m_attachment); + } +} + +void +CMatrix::operator=(CMatrix const &rhs) +{ + m_matrix = rhs.m_matrix; + if (m_attachment) + UpdateRW(); +} + +void +CMatrix::CopyOnlyMatrix(CMatrix *other) +{ + m_matrix = other->m_matrix; +} + +CMatrix & +CMatrix::operator+=(CMatrix const &rhs) +{ + m_matrix.right.x += rhs.m_matrix.right.x; + m_matrix.up.x += rhs.m_matrix.up.x; + m_matrix.at.x += rhs.m_matrix.at.x; + m_matrix.right.y += rhs.m_matrix.right.y; + m_matrix.up.y += rhs.m_matrix.up.y; + m_matrix.at.y += rhs.m_matrix.at.y; + m_matrix.right.z += rhs.m_matrix.right.z; + m_matrix.up.z += rhs.m_matrix.up.z; + m_matrix.at.z += rhs.m_matrix.at.z; + m_matrix.pos.x += rhs.m_matrix.pos.x; + m_matrix.pos.y += rhs.m_matrix.pos.y; + m_matrix.pos.z += rhs.m_matrix.pos.z; + return *this; +} + +void +CMatrix::SetUnity(void) +{ + m_matrix.right.x = 1.0f; + m_matrix.right.y = 0.0f; + m_matrix.right.z = 0.0f; + m_matrix.up.x = 0.0f; + m_matrix.up.y = 1.0f; + m_matrix.up.z = 0.0f; + m_matrix.at.x = 0.0f; + m_matrix.at.y = 0.0f; + m_matrix.at.z = 1.0f; + m_matrix.pos.x = 0.0f; + m_matrix.pos.y = 0.0f; + m_matrix.pos.z = 0.0f; +} + +void +CMatrix::ResetOrientation(void) +{ + m_matrix.right.x = 1.0f; + m_matrix.right.y = 0.0f; + m_matrix.right.z = 0.0f; + m_matrix.up.x = 0.0f; + m_matrix.up.y = 1.0f; + m_matrix.up.z = 0.0f; + m_matrix.at.x = 0.0f; + m_matrix.at.y = 0.0f; + m_matrix.at.z = 1.0f; +} + +void +CMatrix::SetScale(float s) +{ + m_matrix.right.x = s; + m_matrix.right.y = 0.0f; + m_matrix.right.z = 0.0f; + + m_matrix.up.x = 0.0f; + m_matrix.up.y = s; + m_matrix.up.z = 0.0f; + + m_matrix.at.x = 0.0f; + m_matrix.at.y = 0.0f; + m_matrix.at.z = s; + + m_matrix.pos.x = 0.0f; + m_matrix.pos.y = 0.0f; + m_matrix.pos.z = 0.0f; +} + +void +CMatrix::SetTranslate(float x, float y, float z) +{ + m_matrix.right.x = 1.0f; + m_matrix.right.y = 0.0f; + m_matrix.right.z = 0.0f; + + m_matrix.up.x = 0.0f; + m_matrix.up.y = 1.0f; + m_matrix.up.z = 0.0f; + + m_matrix.at.x = 0.0f; + m_matrix.at.y = 0.0f; + m_matrix.at.z = 1.0f; + + m_matrix.pos.x = x; + m_matrix.pos.y = y; + m_matrix.pos.z = z; +} + +void +CMatrix::SetRotateXOnly(float angle) +{ + float c = Cos(angle); + float s = Sin(angle); + + m_matrix.right.x = 1.0f; + m_matrix.right.y = 0.0f; + m_matrix.right.z = 0.0f; + + m_matrix.up.x = 0.0f; + m_matrix.up.y = c; + m_matrix.up.z = s; + + m_matrix.at.x = 0.0f; + m_matrix.at.y = -s; + m_matrix.at.z = c; +} + +void +CMatrix::SetRotateYOnly(float angle) +{ + float c = Cos(angle); + float s = Sin(angle); + + m_matrix.right.x = c; + m_matrix.right.y = 0.0f; + m_matrix.right.z = -s; + + m_matrix.up.x = 0.0f; + m_matrix.up.y = 1.0f; + m_matrix.up.z = 0.0f; + + m_matrix.at.x = s; + m_matrix.at.y = 0.0f; + m_matrix.at.z = c; +} + +void +CMatrix::SetRotateZOnly(float angle) +{ + float c = Cos(angle); + float s = Sin(angle); + + m_matrix.right.x = c; + m_matrix.right.y = s; + m_matrix.right.z = 0.0f; + + m_matrix.up.x = -s; + m_matrix.up.y = c; + m_matrix.up.z = 0.0f; + + m_matrix.at.x = 0.0f; + m_matrix.at.y = 0.0f; + m_matrix.at.z = 1.0f; +} + +void +CMatrix::SetRotateX(float angle) +{ + SetRotateXOnly(angle); + m_matrix.pos.x = 0.0f; + m_matrix.pos.y = 0.0f; + m_matrix.pos.z = 0.0f; +} + + +void +CMatrix::SetRotateY(float angle) +{ + SetRotateYOnly(angle); + m_matrix.pos.x = 0.0f; + m_matrix.pos.y = 0.0f; + m_matrix.pos.z = 0.0f; +} + +void +CMatrix::SetRotateZ(float angle) +{ + SetRotateZOnly(angle); + m_matrix.pos.x = 0.0f; + m_matrix.pos.y = 0.0f; + m_matrix.pos.z = 0.0f; +} + +void +CMatrix::SetRotate(float xAngle, float yAngle, float zAngle) +{ + float cX = Cos(xAngle); + float sX = Sin(xAngle); + float cY = Cos(yAngle); + float sY = Sin(yAngle); + float cZ = Cos(zAngle); + float sZ = Sin(zAngle); + + m_matrix.right.x = cZ * cY - (sZ * sX) * sY; + m_matrix.right.y = (cZ * sX) * sY + sZ * cY; + m_matrix.right.z = -cX * sY; + + m_matrix.up.x = -sZ * cX; + m_matrix.up.y = cZ * cX; + m_matrix.up.z = sX; + + m_matrix.at.x = (sZ * sX) * cY + cZ * sY; + m_matrix.at.y = sZ * sY - (cZ * sX) * cY; + m_matrix.at.z = cX * cY; + + m_matrix.pos.x = 0.0f; + m_matrix.pos.y = 0.0f; + m_matrix.pos.z = 0.0f; +} + +void +CMatrix::RotateX(float x) +{ + float c = Cos(x); + float s = Sin(x); + + float ry = m_matrix.right.y; + float rz = m_matrix.right.z; + float uy = m_matrix.up.y; + float uz = m_matrix.up.z; + float ay = m_matrix.at.y; + float az = m_matrix.at.z; + float py = m_matrix.pos.y; + float pz = m_matrix.pos.z; + + m_matrix.right.y = c * ry - s * rz; + m_matrix.right.z = c * rz + s * ry; + m_matrix.up.y = c * uy - s * uz; + m_matrix.up.z = c * uz + s * uy; + m_matrix.at.y = c * ay - s * az; + m_matrix.at.z = c * az + s * ay; + m_matrix.pos.y = c * py - s * pz; + m_matrix.pos.z = c * pz + s * py; +} + +void +CMatrix::RotateY(float y) +{ + float c = Cos(y); + float s = Sin(y); + + float rx = m_matrix.right.x; + float rz = m_matrix.right.z; + float ux = m_matrix.up.x; + float uz = m_matrix.up.z; + float ax = m_matrix.at.x; + float az = m_matrix.at.z; + float px = m_matrix.pos.x; + float pz = m_matrix.pos.z; + + m_matrix.right.x = c * rx - s * rz; + m_matrix.right.z = c * rz + s * rx; + m_matrix.up.x = c * ux - s * uz; + m_matrix.up.z = c * uz + s * ux; + m_matrix.at.x = c * ax - s * az; + m_matrix.at.z = c * az + s * ax; + m_matrix.pos.x = c * px - s * pz; + m_matrix.pos.z = c * pz + s * px; +} + +void +CMatrix::RotateZ(float z) +{ + float c = Cos(z); + float s = Sin(z); + + float ry = m_matrix.right.y; + float rx = m_matrix.right.x; + float uy = m_matrix.up.y; + float ux = m_matrix.up.x; + float ay = m_matrix.at.y; + float ax = m_matrix.at.x; + float py = m_matrix.pos.y; + float px = m_matrix.pos.x; + + m_matrix.right.x = c * rx - s * ry; + m_matrix.right.y = c * ry + s * rx; + m_matrix.up.x = c * ux - s * uy; + m_matrix.up.y = c * uy + s * ux; + m_matrix.at.x = c * ax - s * ay; + m_matrix.at.y = c * ay + s * ax; + m_matrix.pos.x = c * px - s * py; + m_matrix.pos.y = c * py + s * px; + +} + +void +CMatrix::Rotate(float x, float y, float z) +{ + float cX = Cos(x); + float sX = Sin(x); + float cY = Cos(y); + float sY = Sin(y); + float cZ = Cos(z); + float sZ = Sin(z); + + float rx = m_matrix.right.x; + float ry = m_matrix.right.y; + float rz = m_matrix.right.z; + float ux = m_matrix.up.x; + float uy = m_matrix.up.y; + float uz = m_matrix.up.z; + float ax = m_matrix.at.x; + float ay = m_matrix.at.y; + float az = m_matrix.at.z; + float px = m_matrix.pos.x; + float py = m_matrix.pos.y; + float pz = m_matrix.pos.z; + + float x1 = cZ * cY - (sZ * sX) * sY; + float x2 = (cZ * sX) * sY + sZ * cY; + float x3 = -cX * sY; + float y1 = -sZ * cX; + float y2 = cZ * cX; + float y3 = sX; + float z1 = (sZ * sX) * cY + cZ * sY; + float z2 = sZ * sY - (cZ * sX) * cY; + float z3 = cX * cY; + + m_matrix.right.x = x1 * rx + y1 * ry + z1 * rz; + m_matrix.right.y = x2 * rx + y2 * ry + z2 * rz; + m_matrix.right.z = x3 * rx + y3 * ry + z3 * rz; + m_matrix.up.x = x1 * ux + y1 * uy + z1 * uz; + m_matrix.up.y = x2 * ux + y2 * uy + z2 * uz; + m_matrix.up.z = x3 * ux + y3 * uy + z3 * uz; + m_matrix.at.x = x1 * ax + y1 * ay + z1 * az; + m_matrix.at.y = x2 * ax + y2 * ay + z2 * az; + m_matrix.at.z = x3 * ax + y3 * ay + z3 * az; + m_matrix.pos.x = x1 * px + y1 * py + z1 * pz; + m_matrix.pos.y = x2 * px + y2 * py + z2 * pz; + m_matrix.pos.z = x3 * px + y3 * py + z3 * pz; +} + +CMatrix & +CMatrix::operator*=(CMatrix const &rhs) +{ + // TODO: VU0 code + *this = *this * rhs; + return *this; +} + +void +CMatrix::Reorthogonalise(void) +{ + CVector &r = GetRight(); + CVector &f = GetForward(); + CVector &u = GetUp(); + u = CrossProduct(r, f); + u.Normalise(); + r = CrossProduct(f, u); + r.Normalise(); + f = CrossProduct(u, r); +} + +CMatrix +operator*(const CMatrix &m1, const CMatrix &m2) +{ + // TODO: VU0 code + CMatrix out; + RwMatrix *dst = &out.m_matrix; + const RwMatrix *src1 = &m1.m_matrix; + const RwMatrix *src2 = &m2.m_matrix; + dst->right.x = src1->right.x * src2->right.x + src1->up.x * src2->right.y + src1->at.x * src2->right.z; + dst->right.y = src1->right.y * src2->right.x + src1->up.y * src2->right.y + src1->at.y * src2->right.z; + dst->right.z = src1->right.z * src2->right.x + src1->up.z * src2->right.y + src1->at.z * src2->right.z; + dst->up.x = src1->right.x * src2->up.x + src1->up.x * src2->up.y + src1->at.x * src2->up.z; + dst->up.y = src1->right.y * src2->up.x + src1->up.y * src2->up.y + src1->at.y * src2->up.z; + dst->up.z = src1->right.z * src2->up.x + src1->up.z * src2->up.y + src1->at.z * src2->up.z; + dst->at.x = src1->right.x * src2->at.x + src1->up.x * src2->at.y + src1->at.x * src2->at.z; + dst->at.y = src1->right.y * src2->at.x + src1->up.y * src2->at.y + src1->at.y * src2->at.z; + dst->at.z = src1->right.z * src2->at.x + src1->up.z * src2->at.y + src1->at.z * src2->at.z; + dst->pos.x = src1->right.x * src2->pos.x + src1->up.x * src2->pos.y + src1->at.x * src2->pos.z + src1->pos.x; + dst->pos.y = src1->right.y * src2->pos.x + src1->up.y * src2->pos.y + src1->at.y * src2->pos.z + src1->pos.y; + dst->pos.z = src1->right.z * src2->pos.x + src1->up.z * src2->pos.y + src1->at.z * src2->pos.z + src1->pos.z; + return out; +} + +CMatrix & +Invert(const CMatrix &src, CMatrix &dst) +{ + // TODO: VU0 code + // GTA handles this as a raw 4x4 orthonormal matrix + // and trashes the RW flags, let's not do that + float (*scr_fm)[4] = (float (*)[4])&src.m_matrix; + float (*dst_fm)[4] = (float (*)[4])&dst.m_matrix; + + dst_fm[3][0] = dst_fm[3][1] = dst_fm[3][2] = 0.0f; +#ifndef FIX_BUGS + dst_fm[3][3] = scr_fm[3][3]; +#endif + + dst_fm[0][0] = scr_fm[0][0]; + dst_fm[0][1] = scr_fm[1][0]; + dst_fm[0][2] = scr_fm[2][0]; +#ifndef FIX_BUGS + dst_fm[0][3] = scr_fm[3][0]; +#endif + dst_fm[1][0] = scr_fm[0][1]; + dst_fm[1][1] = scr_fm[1][1]; + dst_fm[1][2] = scr_fm[2][1]; +#ifndef FIX_BUGS + dst_fm[1][3] = scr_fm[3][1]; +#endif + dst_fm[2][0] = scr_fm[0][2]; + dst_fm[2][1] = scr_fm[1][2]; + dst_fm[2][2] = scr_fm[2][2]; +#ifndef FIX_BUGS + dst_fm[2][3] = scr_fm[3][2]; +#endif + + dst_fm[3][0] += dst_fm[0][0] * scr_fm[3][0]; + dst_fm[3][1] += dst_fm[0][1] * scr_fm[3][0]; + dst_fm[3][2] += dst_fm[0][2] * scr_fm[3][0]; +#ifndef FIX_BUGS + dst_fm[3][3] += dst_fm[0][3] * scr_fm[3][0]; +#endif + + dst_fm[3][0] += dst_fm[1][0] * scr_fm[3][1]; + dst_fm[3][1] += dst_fm[1][1] * scr_fm[3][1]; + dst_fm[3][2] += dst_fm[1][2] * scr_fm[3][1]; +#ifndef FIX_BUGS + dst_fm[3][3] += dst_fm[1][3] * scr_fm[3][1]; +#endif + + dst_fm[3][0] += dst_fm[2][0] * scr_fm[3][2]; + dst_fm[3][1] += dst_fm[2][1] * scr_fm[3][2]; + dst_fm[3][2] += dst_fm[2][2] * scr_fm[3][2]; +#ifndef FIX_BUGS + dst_fm[3][3] += dst_fm[2][3] * scr_fm[3][2]; +#endif + + dst_fm[3][0] = -dst_fm[3][0]; + dst_fm[3][1] = -dst_fm[3][1]; + dst_fm[3][2] = -dst_fm[3][2]; +#ifndef FIX_BUGS + dst_fm[3][3] = scr_fm[3][3] - dst_fm[3][3]; +#endif + + return dst; +} + +CMatrix +Invert(const CMatrix &matrix) +{ + CMatrix inv; + return Invert(matrix, inv); +} + +void +CCompressedMatrixNotAligned::CompressFromFullMatrix(CMatrix &other) +{ + m_rightX = 127.0f * other.GetRight().x; + m_rightY = 127.0f * other.GetRight().y; + m_rightZ = 127.0f * other.GetRight().z; + m_upX = 127.0f * other.GetForward().x; + m_upY = 127.0f * other.GetForward().y; + m_upZ = 127.0f * other.GetForward().z; + m_vecPos = other.GetPosition(); +} + +void +CCompressedMatrixNotAligned::DecompressIntoFullMatrix(CMatrix &other) +{ + other.GetRight().x = m_rightX / 127.0f; + other.GetRight().y = m_rightY / 127.0f; + other.GetRight().z = m_rightZ / 127.0f; + other.GetForward().x = m_upX / 127.0f; + other.GetForward().y = m_upY / 127.0f; + other.GetForward().z = m_upZ / 127.0f; + other.GetUp() = CrossProduct(other.GetRight(), other.GetForward()); + other.GetPosition() = m_vecPos; + other.Reorthogonalise(); +} \ No newline at end of file diff --git a/src/math/Matrix.h b/src/math/Matrix.h index e2d6b0e0..d8f6388d 100644 --- a/src/math/Matrix.h +++ b/src/math/Matrix.h @@ -7,104 +7,30 @@ public: RwMatrix *m_attachment; bool m_hasRwMatrix; // are we the owner? - CMatrix(void){ - m_attachment = nil; - m_hasRwMatrix = false; - } - CMatrix(CMatrix const &m){ - m_attachment = nil; - m_hasRwMatrix = false; - *this = m; - } - CMatrix(RwMatrix *matrix, bool owner = false){ - m_attachment = nil; - Attach(matrix, owner); - } + CMatrix(void); + CMatrix(CMatrix const &m); + CMatrix(RwMatrix *matrix, bool owner = false); CMatrix(float scale){ m_attachment = nil; m_hasRwMatrix = false; SetScale(scale); } - ~CMatrix(void){ - if(m_hasRwMatrix && m_attachment) - RwMatrixDestroy(m_attachment); - } - void Attach(RwMatrix *matrix, bool owner = false){ -#ifdef FIX_BUGS - if(m_attachment && m_hasRwMatrix) -#else - if(m_hasRwMatrix && m_attachment) -#endif - RwMatrixDestroy(m_attachment); - m_attachment = matrix; - m_hasRwMatrix = owner; - Update(); - } - void AttachRW(RwMatrix *matrix, bool owner = false){ - if(m_hasRwMatrix && m_attachment) - RwMatrixDestroy(m_attachment); - m_attachment = matrix; - m_hasRwMatrix = owner; - UpdateRW(); - } - void Detach(void){ - if(m_hasRwMatrix && m_attachment) - RwMatrixDestroy(m_attachment); - m_attachment = nil; - } - void Update(void){ - m_matrix = *m_attachment; - } - void UpdateRW(void){ - if(m_attachment){ - *m_attachment = m_matrix; - RwMatrixUpdate(m_attachment); - } - } - void operator=(CMatrix const &rhs){ - m_matrix = rhs.m_matrix; - if(m_attachment) - UpdateRW(); - } - CMatrix& operator+=(CMatrix const &rhs){ - m_matrix.right.x += rhs.m_matrix.right.x; - m_matrix.up.x += rhs.m_matrix.up.x; - m_matrix.at.x += rhs.m_matrix.at.x; - m_matrix.right.y += rhs.m_matrix.right.y; - m_matrix.up.y += rhs.m_matrix.up.y; - m_matrix.at.y += rhs.m_matrix.at.y; - m_matrix.right.z += rhs.m_matrix.right.z; - m_matrix.up.z += rhs.m_matrix.up.z; - m_matrix.at.z += rhs.m_matrix.at.z; - m_matrix.pos.x += rhs.m_matrix.pos.x; - m_matrix.pos.y += rhs.m_matrix.pos.y; - m_matrix.pos.z += rhs.m_matrix.pos.z; - return *this; - } - CMatrix& operator*=(CMatrix const &rhs); + ~CMatrix(void); + void Attach(RwMatrix *matrix, bool owner = false); + void AttachRW(RwMatrix *matrix, bool owner = false); + void Detach(void); + void Update(void); + void UpdateRW(void); + void operator=(CMatrix const &rhs); + CMatrix &operator+=(CMatrix const &rhs); + CMatrix &operator*=(CMatrix const &rhs); CVector &GetPosition(void){ return *(CVector*)&m_matrix.pos; } CVector &GetRight(void) { return *(CVector*)&m_matrix.right; } CVector &GetForward(void) { return *(CVector*)&m_matrix.up; } CVector &GetUp(void) { return *(CVector*)&m_matrix.at; } - void SetTranslate(float x, float y, float z){ - m_matrix.right.x = 1.0f; - m_matrix.right.y = 0.0f; - m_matrix.right.z = 0.0f; - - m_matrix.up.x = 0.0f; - m_matrix.up.y = 1.0f; - m_matrix.up.z = 0.0f; - - m_matrix.at.x = 0.0f; - m_matrix.at.y = 0.0f; - m_matrix.at.z = 1.0f; - - m_matrix.pos.x = x; - m_matrix.pos.y = y; - m_matrix.pos.z = z; - } + void SetTranslate(float x, float y, float z); void SetTranslate(const CVector &trans){ SetTranslate(trans.x, trans.y, trans.z); } void Translate(float x, float y, float z){ m_matrix.pos.x += x; @@ -113,23 +39,7 @@ public: } void Translate(const CVector &trans){ Translate(trans.x, trans.y, trans.z); } - void SetScale(float s){ - m_matrix.right.x = s; - m_matrix.right.y = 0.0f; - m_matrix.right.z = 0.0f; - - m_matrix.up.x = 0.0f; - m_matrix.up.y = s; - m_matrix.up.z = 0.0f; - - m_matrix.at.x = 0.0f; - m_matrix.at.y = 0.0f; - m_matrix.at.z = s; - - m_matrix.pos.x = 0.0f; - m_matrix.pos.y = 0.0f; - m_matrix.pos.z = 0.0f; - } + void SetScale(float s); void Scale(float scale) { float *pFloatMatrix = (float*)&m_matrix; @@ -143,66 +53,9 @@ public: } - void SetRotateXOnly(float angle){ - float c = Cos(angle); - float s = Sin(angle); - - m_matrix.right.x = 1.0f; - m_matrix.right.y = 0.0f; - m_matrix.right.z = 0.0f; - - m_matrix.up.x = 0.0f; - m_matrix.up.y = c; - m_matrix.up.z = s; - - m_matrix.at.x = 0.0f; - m_matrix.at.y = -s; - m_matrix.at.z = c; - } - void SetRotateX(float angle){ - SetRotateXOnly(angle); - m_matrix.pos.x = 0.0f; - m_matrix.pos.y = 0.0f; - m_matrix.pos.z = 0.0f; - } - void SetRotateYOnly(float angle){ - float c = Cos(angle); - float s = Sin(angle); - - m_matrix.right.x = c; - m_matrix.right.y = 0.0f; - m_matrix.right.z = -s; - - m_matrix.up.x = 0.0f; - m_matrix.up.y = 1.0f; - m_matrix.up.z = 0.0f; - - m_matrix.at.x = s; - m_matrix.at.y = 0.0f; - m_matrix.at.z = c; - } - void SetRotateY(float angle){ - SetRotateYOnly(angle); - m_matrix.pos.x = 0.0f; - m_matrix.pos.y = 0.0f; - m_matrix.pos.z = 0.0f; - } - void SetRotateZOnly(float angle){ - float c = Cos(angle); - float s = Sin(angle); - - m_matrix.right.x = c; - m_matrix.right.y = s; - m_matrix.right.z = 0.0f; - - m_matrix.up.x = -s; - m_matrix.up.y = c; - m_matrix.up.z = 0.0f; - - m_matrix.at.x = 0.0f; - m_matrix.at.y = 0.0f; - m_matrix.at.z = 1.0f; - } + void SetRotateXOnly(float angle); + void SetRotateYOnly(float angle); + void SetRotateZOnly(float angle); void SetRotateZOnlyScaled(float angle, float scale) { float c = Cos(angle); float s = Sin(angle); @@ -219,12 +72,9 @@ public: m_matrix.at.y = 0.0f; m_matrix.at.z = scale; } - void SetRotateZ(float angle){ - SetRotateZOnly(angle); - m_matrix.pos.x = 0.0f; - m_matrix.pos.y = 0.0f; - m_matrix.pos.z = 0.0f; - } + void SetRotateX(float angle); + void SetRotateY(float angle); + void SetRotateZ(float angle); void SetRotate(float xAngle, float yAngle, float zAngle); void Rotate(float x, float y, float z); void RotateX(float x); @@ -232,34 +82,9 @@ public: void RotateZ(float z); void Reorthogonalise(void); - void CopyOnlyMatrix(CMatrix *other){ - m_matrix = other->m_matrix; - } - void SetUnity(void) { - m_matrix.right.x = 1.0f; - m_matrix.right.y = 0.0f; - m_matrix.right.z = 0.0f; - m_matrix.up.x = 0.0f; - m_matrix.up.y = 1.0f; - m_matrix.up.z = 0.0f; - m_matrix.at.x = 0.0f; - m_matrix.at.y = 0.0f; - m_matrix.at.z = 1.0f; - m_matrix.pos.x = 0.0f; - m_matrix.pos.y = 0.0f; - m_matrix.pos.z = 0.0f; - } - void ResetOrientation(void) { - m_matrix.right.x = 1.0f; - m_matrix.right.y = 0.0f; - m_matrix.right.z = 0.0f; - m_matrix.up.x = 0.0f; - m_matrix.up.y = 1.0f; - m_matrix.up.z = 0.0f; - m_matrix.at.x = 0.0f; - m_matrix.at.y = 0.0f; - m_matrix.at.z = 1.0f; - } + void CopyOnlyMatrix(CMatrix *other); + void SetUnity(void); + void ResetOrientation(void); void SetTranslateOnly(float x, float y, float z) { m_matrix.pos.x = x; m_matrix.pos.y = y; @@ -268,11 +93,12 @@ public: void SetTranslateOnly(const CVector& pos) { SetTranslateOnly(pos.x, pos.y, pos.z); } + void CheckIntegrity(){} }; CMatrix &Invert(const CMatrix &src, CMatrix &dst); -CVector operator*(const CMatrix &mat, const CVector &vec); +CMatrix Invert(const CMatrix &matrix); CMatrix operator*(const CMatrix &m1, const CMatrix &m2); inline CVector MultiplyInverse(const CMatrix &mat, const CVector &vec) { @@ -283,15 +109,6 @@ inline CVector MultiplyInverse(const CMatrix &mat, const CVector &vec) mat.m_matrix.at.x * v.x + mat.m_matrix.at.y * v.y + mat.m_matrix.at.z * v.z); } -const CVector Multiply3x3(const CMatrix &mat, const CVector &vec); -const CVector Multiply3x3(const CVector &vec, const CMatrix &mat); - -inline CMatrix -Invert(const CMatrix &matrix) -{ - CMatrix inv; - return Invert(matrix, inv); -} class CCompressedMatrixNotAligned @@ -304,28 +121,8 @@ class CCompressedMatrixNotAligned int8 m_upY; int8 m_upZ; public: - void CompressFromFullMatrix(CMatrix &other) - { - m_rightX = 127.0f * other.GetRight().x; - m_rightY = 127.0f * other.GetRight().y; - m_rightZ = 127.0f * other.GetRight().z; - m_upX = 127.0f * other.GetForward().x; - m_upY = 127.0f * other.GetForward().y; - m_upZ = 127.0f * other.GetForward().z; - m_vecPos = other.GetPosition(); - } - void DecompressIntoFullMatrix(CMatrix &other) - { - other.GetRight().x = m_rightX / 127.0f; - other.GetRight().y = m_rightY / 127.0f; - other.GetRight().z = m_rightZ / 127.0f; - other.GetForward().x = m_upX / 127.0f; - other.GetForward().y = m_upY / 127.0f; - other.GetForward().z = m_upZ / 127.0f; - other.GetUp() = CrossProduct(other.GetRight(), other.GetForward()); - other.GetPosition() = m_vecPos; - other.Reorthogonalise(); - } + void CompressFromFullMatrix(CMatrix &other); + void DecompressIntoFullMatrix(CMatrix &other); }; class CCompressedMatrix : public CCompressedMatrixNotAligned diff --git a/src/math/Quaternion.cpp b/src/math/Quaternion.cpp new file mode 100644 index 00000000..b0e782e2 --- /dev/null +++ b/src/math/Quaternion.cpp @@ -0,0 +1,177 @@ +#include "common.h" +#include "Quaternion.h" + +void +CQuaternion::Normalise(void) +{ + float sq = MagnitudeSqr(); + if (sq == 0.0f) + w = 1.0f; + else { + float invsqrt = RecipSqrt(sq); + x *= invsqrt; + y *= invsqrt; + z *= invsqrt; + w *= invsqrt; + } +} + +void +CQuaternion::Slerp(const CQuaternion &q1, const CQuaternion &q2, float theta, float invSin, float t) +{ + if (theta == 0.0f) + *this = q2; + else { + float w1, w2; + if (theta > PI / 2) { + theta = PI - theta; + w1 = Sin((1.0f - t) * theta) * invSin; + w2 = -Sin(t * theta) * invSin; + } else { + w1 = Sin((1.0f - t) * theta) * invSin; + w2 = Sin(t * theta) * invSin; + } + // TODO: VU0 code + *this = w1 * q1 + w2 * q2; + } +} + +void +CQuaternion::Multiply(const CQuaternion &q1, const CQuaternion &q2) +{ + x = (q2.z * q1.y) - (q1.z * q2.y) + (q1.x * q2.w) + (q2.x * q1.w); + y = (q2.x * q1.z) - (q1.x * q2.z) + (q1.y * q2.w) + (q2.y * q1.w); + z = (q2.y * q1.x) - (q1.y * q2.x) + (q1.z * q2.w) + (q2.z * q1.w); + w = (q2.w * q1.w) - (q2.x * q1.x) - (q2.y * q1.y) - (q2.z * q1.z); +} + +void +CQuaternion::Get(RwV3d *axis, float *angle) +{ + *angle = Acos(w); + float s = Sin(*angle); + + axis->x = x * (1.0f / s); + axis->y = y * (1.0f / s); + axis->z = z * (1.0f / s); +} + +void +CQuaternion::Set(RwV3d *axis, float angle) +{ + float halfCos = Cos(angle * 0.5f); + float halfSin = Sin(angle * 0.5f); + x = axis->x * halfSin; + y = axis->y * halfSin; + z = axis->z * halfSin; + w = halfCos; +} + +void +CQuaternion::Get(RwMatrix *matrix) +{ + float x2 = x + x; + float y2 = y + y; + float z2 = z + z; + + float x_2x = x * x2; + float x_2y = x * y2; + float x_2z = x * z2; + float y_2y = y * y2; + float y_2z = y * z2; + float z_2z = z * z2; + float w_2x = w * x2; + float w_2y = w * y2; + float w_2z = w * z2; + + matrix->right.x = 1.0f - (y_2y + z_2z); + matrix->up.x = x_2y - w_2z; + matrix->at.x = x_2z + w_2y; + matrix->right.y = x_2y + w_2z; + matrix->up.y = 1.0f - (x_2x + z_2z); + matrix->at.y = y_2z - w_2x; + matrix->right.z = x_2z - w_2y; + matrix->up.z = y_2z + w_2x; + matrix->at.z = 1.0f - (x_2x + y_2y); +} + +void +CQuaternion::Set(const RwMatrix &matrix) +{ + float f, s, m; + + f = matrix.up.y + matrix.right.x + matrix.at.z; + if (f >= 0.0f) { + s = Sqrt(f + 1.0f); + w = 0.5f * s; + m = 0.5f / s; + x = (matrix.up.z - matrix.at.y) * m; + y = (matrix.at.x - matrix.right.z) * m; + z = (matrix.right.y - matrix.up.x) * m; + return; + } + + f = matrix.right.x - matrix.up.y - matrix.at.z; + if (f >= 0.0f) { + s = Sqrt(f + 1.0f); + x = 0.5f * s; + m = 0.5f / s; + y = (matrix.up.x + matrix.right.y) * m; + z = (matrix.at.x + matrix.right.z) * m; + w = (matrix.up.z - matrix.at.y) * m; + return; + } + + f = matrix.up.y - matrix.right.x - matrix.at.z; + if (f >= 0.0f) { + s = Sqrt(f + 1.0f); + y = 0.5f * s; + m = 0.5f / s; + w = (matrix.at.x - matrix.right.z) * m; + x = (matrix.up.x - matrix.right.y) * m; + z = (matrix.at.y + matrix.up.z) * m; + return; + } + + f = matrix.at.z - (matrix.up.y + matrix.right.x); + s = Sqrt(f + 1.0f); + z = 0.5f * s; + m = 0.5f / s; + w = (matrix.right.y - matrix.up.x) * m; + x = (matrix.at.x + matrix.right.z) * m; + y = (matrix.at.y + matrix.up.z) * m; +} + +void +CQuaternion::Get(float *f1, float *f2, float *f3) +{ + RwMatrix matrix; + + Get(&matrix); + *f3 = Atan2(matrix.right.y, matrix.up.y); + if (*f3 < 0.0f) + *f3 += TWOPI; + float s = Sin(*f3); + float c = Cos(*f3); + *f1 = Atan2(-matrix.at.y, s * matrix.right.y + c * matrix.up.y); + if (*f1 < 0.0f) + *f1 += TWOPI; + *f2 = Atan2(-(matrix.right.z * c - matrix.up.z * s), matrix.right.x * c - matrix.up.x * s); + if (*f2 < 0.0f) + *f2 += TWOPI; +} + +void +CQuaternion::Set(float f1, float f2, float f3) +{ + float c1 = Cos(f1 * 0.5f); + float c2 = Cos(f2 * 0.5f); + float c3 = Cos(f3 * 0.5f); + float s1 = Sin(f1 * 0.5f); + float s2 = Sin(f2 * 0.5f); + float s3 = Sin(f3 * 0.5f); + x = ((c2 * c1) * s3) - ((s2 * s1) * c3); + y = ((s1 * c2) * c3) + ((s2 * c1) * s3); + z = ((s2 * c1) * c3) - ((s1 * c2) * s3); + w = ((c2 * c1) * c3) + ((s2 * s1) * s3); +} \ No newline at end of file diff --git a/src/math/Quaternion.h b/src/math/Quaternion.h index dac49362..a5a34626 100644 --- a/src/math/Quaternion.h +++ b/src/math/Quaternion.h @@ -10,18 +10,8 @@ public: float Magnitude(void) const { return Sqrt(x*x + y*y + z*z + w*w); } float MagnitudeSqr(void) const { return x*x + y*y + z*z + w*w; } - void Normalise(void) { - float sq = MagnitudeSqr(); - if(sq == 0.0f) - w = 1.0f; - else{ - float invsqrt = RecipSqrt(sq); - x *= invsqrt; - y *= invsqrt; - z *= invsqrt; - w *= invsqrt; - } - } + void Normalise(void); + void Multiply(const CQuaternion &q1, const CQuaternion &q2); const CQuaternion &operator+=(CQuaternion const &right) { x += right.x; @@ -60,8 +50,12 @@ public: } void Slerp(const CQuaternion &q1, const CQuaternion &q2, float theta, float invSin, float t); + void Get(RwV3d *axis, float *angle); void Set(RwV3d *axis, float angle); void Get(RwMatrix *matrix); + void Set(const RwMatrix &matrix); + void Set(float f1, float f2, float f3); + void Get(float *f1, float *f2, float *f3); }; inline float diff --git a/src/math/Rect.cpp b/src/math/Rect.cpp new file mode 100644 index 00000000..de6320ad --- /dev/null +++ b/src/math/Rect.cpp @@ -0,0 +1,17 @@ +#include "common.h" + +CRect::CRect(void) +{ + left = 1000000.0f; + top = 1000000.0f; + right = -1000000.0f; + bottom = -1000000.0f; +} + +CRect::CRect(float l, float t, float r, float b) +{ + left = l; + top = t; + right = r; + bottom = b; +} \ No newline at end of file diff --git a/src/math/Rect.h b/src/math/Rect.h index 326bb479..fa8d8de4 100644 --- a/src/math/Rect.h +++ b/src/math/Rect.h @@ -8,18 +8,8 @@ public: float right; // x max float top; // y min - CRect(void){ - left = 1000000.0f; - top = 1000000.0f; - right = -1000000.0f; - bottom = -1000000.0f; - } - CRect(float l, float t, float r, float b){ - left = l; - top = t; - right = r; - bottom = b; - } + CRect(void); + CRect(float l, float t, float r, float b); void ContainPoint(CVector const &v){ if(v.x < left) left = v.x; if(v.x > right) right = v.x; diff --git a/src/math/Vector.cpp b/src/math/Vector.cpp new file mode 100644 index 00000000..42e1828e --- /dev/null +++ b/src/math/Vector.cpp @@ -0,0 +1,46 @@ +#include "common.h" + +void +CVector::Normalise(void) +{ + float sq = MagnitudeSqr(); + if (sq > 0.0f) { + float invsqrt = RecipSqrt(sq); + x *= invsqrt; + y *= invsqrt; + z *= invsqrt; + } else + x = 1.0f; +} + +CVector +CrossProduct(const CVector &v1, const CVector &v2) +{ + return CVector(v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x); +} + +CVector +Multiply3x3(const CMatrix &mat, const CVector &vec) +{ + // TODO: VU0 code + return CVector(mat.m_matrix.right.x * vec.x + mat.m_matrix.up.x * vec.y + mat.m_matrix.at.x * vec.z, + mat.m_matrix.right.y * vec.x + mat.m_matrix.up.y * vec.y + mat.m_matrix.at.y * vec.z, + mat.m_matrix.right.z * vec.x + mat.m_matrix.up.z * vec.y + mat.m_matrix.at.z * vec.z); +} + +CVector +Multiply3x3(const CVector &vec, const CMatrix &mat) +{ + return CVector(mat.m_matrix.right.x * vec.x + mat.m_matrix.right.y * vec.y + mat.m_matrix.right.z * vec.z, + mat.m_matrix.up.x * vec.x + mat.m_matrix.up.y * vec.y + mat.m_matrix.up.z * vec.z, + mat.m_matrix.at.x * vec.x + mat.m_matrix.at.y * vec.y + mat.m_matrix.at.z * vec.z); +} + +CVector +operator*(const CMatrix &mat, const CVector &vec) +{ + // TODO: VU0 code + return CVector(mat.m_matrix.right.x * vec.x + mat.m_matrix.up.x * vec.y + mat.m_matrix.at.x * vec.z + mat.m_matrix.pos.x, + mat.m_matrix.right.y * vec.x + mat.m_matrix.up.y * vec.y + mat.m_matrix.at.y * vec.z + mat.m_matrix.pos.y, + mat.m_matrix.right.z * vec.x + mat.m_matrix.up.z * vec.y + mat.m_matrix.at.z * vec.z + mat.m_matrix.pos.z); +} diff --git a/src/math/Vector.h b/src/math/Vector.h index 5918a5d1..7ee01149 100644 --- a/src/math/Vector.h +++ b/src/math/Vector.h @@ -24,24 +24,7 @@ public: float MagnitudeSqr(void) const { return x*x + y*y + z*z; } float Magnitude2D(void) const { return Sqrt(x*x + y*y); } float MagnitudeSqr2D(void) const { return x*x + y*y; } - void Normalise(void) { - float sq = MagnitudeSqr(); - if(sq > 0.0f){ - float invsqrt = RecipSqrt(sq); - x *= invsqrt; - y *= invsqrt; - z *= invsqrt; - }else - x = 1.0f; - } - - void Normalise(float norm) { - float sq = MagnitudeSqr(); - float invsqrt = RecipSqrt(norm, sq); - x *= invsqrt; - y *= invsqrt; - z *= invsqrt; - } + void Normalise(void); void Normalise2D(void) { float sq = MagnitudeSqr2D(); @@ -124,17 +107,16 @@ DotProduct(const CVector &v1, const CVector &v2) return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z; } -inline const CVector -CrossProduct(const CVector &v1, const CVector &v2) -{ - return CVector( - v1.y*v2.z - v1.z*v2.y, - v1.z*v2.x - v1.x*v2.z, - v1.x*v2.y - v1.y*v2.x); -} +CVector CrossProduct(const CVector &v1, const CVector &v2); inline float Distance(const CVector &v1, const CVector &v2) { return (v2 - v1).Magnitude(); -} \ No newline at end of file +} + +class CMatrix; + +CVector Multiply3x3(const CMatrix &mat, const CVector &vec); +CVector Multiply3x3(const CVector &vec, const CMatrix &mat); +CVector operator*(const CMatrix &mat, const CVector &vec); \ No newline at end of file diff --git a/src/math/Vector2D.h b/src/math/Vector2D.h index 0885a5d2..0235dbe5 100644 --- a/src/math/Vector2D.h +++ b/src/math/Vector2D.h @@ -11,7 +11,13 @@ public: float Magnitude(void) const { return Sqrt(x*x + y*y); } float MagnitudeSqr(void) const { return x*x + y*y; } - void Normalise(void); + void Normalise(void) { + float sq = MagnitudeSqr(); + // assert(sq != 0.0f); // just be safe here + float invsqrt = RecipSqrt(sq); + x *= invsqrt; + y *= invsqrt; + } void NormaliseSafe(void) { float sq = MagnitudeSqr(); @@ -20,7 +26,7 @@ public: x *= invsqrt; y *= invsqrt; }else - y = 1.0f; + x = 1.0f; } const CVector2D &operator+=(CVector2D const &right) { diff --git a/src/math/math.cpp b/src/math/math.cpp index 4792fdd0..8cb56dab 100644 --- a/src/math/math.cpp +++ b/src/math/math.cpp @@ -1,6 +1,5 @@ #include "common.h" -#include "Quaternion.h" #include "VuVector.h" // TODO: move more stuff into here @@ -117,235 +116,3 @@ void TransformPoints(CVuVector *out, int n, const CMatrix &mat, const CVuVector } #endif } - - -void -CVector2D::Normalise(void) -{ - float sq = MagnitudeSqr(); - assert(sq != 0.0f); // just be safe here - //if(sq > 0.0f){ - float invsqrt = RecipSqrt(sq); - x *= invsqrt; - y *= invsqrt; - //}else - // x = 1.0f; -} - -void -CMatrix::SetRotate(float xAngle, float yAngle, float zAngle) -{ - float cX = Cos(xAngle); - float sX = Sin(xAngle); - float cY = Cos(yAngle); - float sY = Sin(yAngle); - float cZ = Cos(zAngle); - float sZ = Sin(zAngle); - - m_matrix.right.x = cZ * cY - (sZ * sX) * sY; - m_matrix.right.y = (cZ * sX) * sY + sZ * cY; - m_matrix.right.z = -cX * sY; - - m_matrix.up.x = -sZ * cX; - m_matrix.up.y = cZ * cX; - m_matrix.up.z = sX; - - m_matrix.at.x = (sZ * sX) * cY + cZ * sY; - m_matrix.at.y = sZ * sY - (cZ * sX) * cY; - m_matrix.at.z = cX * cY; - - m_matrix.pos.x = 0.0f; - m_matrix.pos.y = 0.0f; - m_matrix.pos.z = 0.0f; -} - -void -CMatrix::Rotate(float x, float y, float z) -{ - // TODO? do this directly without creating another matrix - CMatrix rot; - rot.SetRotate(x, y, z); - *this = rot * *this; -} - -void -CMatrix::RotateX(float x) -{ - Rotate(x, 0.0f, 0.0f); -} - -void -CMatrix::RotateY(float y) -{ - Rotate(0.0f, y, 0.0f); -} - -void -CMatrix::RotateZ(float z) -{ - Rotate(0.0f, 0.0f, z); -} - -void -CMatrix::Reorthogonalise(void) -{ - CVector &r = GetRight(); - CVector &f = GetForward(); - CVector &u = GetUp(); - u = CrossProduct(r, f); - u.Normalise(); - r = CrossProduct(f, u); - r.Normalise(); - f = CrossProduct(u, r); -} - -CMatrix& -Invert(const CMatrix &src, CMatrix &dst) -{ - // TODO: VU0 code - // GTA handles this as a raw 4x4 orthonormal matrix - // and trashes the RW flags, let's not do that - // actual copy of librw code: - RwMatrix *d = &dst.m_matrix; - const RwMatrix *s = &src.m_matrix; - d->right.x = s->right.x; - d->right.y = s->up.x; - d->right.z = s->at.x; - d->up.x = s->right.y; - d->up.y = s->up.y; - d->up.z = s->at.y; - d->at.x = s->right.z; - d->at.y = s->up.z; - d->at.z = s->at.z; - d->pos.x = -(s->pos.x*s->right.x + - s->pos.y*s->right.y + - s->pos.z*s->right.z); - d->pos.y = -(s->pos.x*s->up.x + - s->pos.y*s->up.y + - s->pos.z*s->up.z); - d->pos.z = -(s->pos.x*s->at.x + - s->pos.y*s->at.y + - s->pos.z*s->at.z); - d->flags = rwMATRIXTYPEORTHONORMAL; - return dst; -} - -CVector -operator*(const CMatrix &mat, const CVector &vec) -{ - // TODO: VU0 code - return CVector( - mat.m_matrix.right.x * vec.x + mat.m_matrix.up.x * vec.y + mat.m_matrix.at.x * vec.z + mat.m_matrix.pos.x, - mat.m_matrix.right.y * vec.x + mat.m_matrix.up.y * vec.y + mat.m_matrix.at.y * vec.z + mat.m_matrix.pos.y, - mat.m_matrix.right.z * vec.x + mat.m_matrix.up.z * vec.y + mat.m_matrix.at.z * vec.z + mat.m_matrix.pos.z); -} - -CMatrix -operator*(const CMatrix &m1, const CMatrix &m2) -{ - // TODO: VU0 code - CMatrix out; - RwMatrix *dst = &out.m_matrix; - const RwMatrix *src1 = &m1.m_matrix; - const RwMatrix *src2 = &m2.m_matrix; - dst->right.x = src1->right.x*src2->right.x + src1->up.x*src2->right.y + src1->at.x*src2->right.z; - dst->right.y = src1->right.y*src2->right.x + src1->up.y*src2->right.y + src1->at.y*src2->right.z; - dst->right.z = src1->right.z*src2->right.x + src1->up.z*src2->right.y + src1->at.z*src2->right.z; - dst->up.x = src1->right.x*src2->up.x + src1->up.x*src2->up.y + src1->at.x*src2->up.z; - dst->up.y = src1->right.y*src2->up.x + src1->up.y*src2->up.y + src1->at.y*src2->up.z; - dst->up.z = src1->right.z*src2->up.x + src1->up.z*src2->up.y + src1->at.z*src2->up.z; - dst->at.x = src1->right.x*src2->at.x + src1->up.x*src2->at.y + src1->at.x*src2->at.z; - dst->at.y = src1->right.y*src2->at.x + src1->up.y*src2->at.y + src1->at.y*src2->at.z; - dst->at.z = src1->right.z*src2->at.x + src1->up.z*src2->at.y + src1->at.z*src2->at.z; - dst->pos.x = src1->right.x*src2->pos.x + src1->up.x*src2->pos.y + src1->at.x*src2->pos.z + src1->pos.x; - dst->pos.y = src1->right.y*src2->pos.x + src1->up.y*src2->pos.y + src1->at.y*src2->pos.z + src1->pos.y; - dst->pos.z = src1->right.z*src2->pos.x + src1->up.z*src2->pos.y + src1->at.z*src2->pos.z + src1->pos.z; - return out; -} - -CMatrix& -CMatrix::operator*=(CMatrix const &rhs) -{ - // TODO: VU0 code - *this = *this * rhs; - return *this; -} - -const CVector -Multiply3x3(const CMatrix &mat, const CVector &vec) -{ - // TODO: VU0 code - return CVector( - mat.m_matrix.right.x * vec.x + mat.m_matrix.up.x * vec.y + mat.m_matrix.at.x * vec.z, - mat.m_matrix.right.y * vec.x + mat.m_matrix.up.y * vec.y + mat.m_matrix.at.y * vec.z, - mat.m_matrix.right.z * vec.x + mat.m_matrix.up.z * vec.y + mat.m_matrix.at.z * vec.z); -} - -const CVector -Multiply3x3(const CVector &vec, const CMatrix &mat) -{ - return CVector( - mat.m_matrix.right.x * vec.x + mat.m_matrix.right.y * vec.y + mat.m_matrix.right.z * vec.z, - mat.m_matrix.up.x * vec.x + mat.m_matrix.up.y * vec.y + mat.m_matrix.up.z * vec.z, - mat.m_matrix.at.x * vec.x + mat.m_matrix.at.y * vec.y + mat.m_matrix.at.z * vec.z); -} - - -void -CQuaternion::Slerp(const CQuaternion &q1, const CQuaternion &q2, float theta, float invSin, float t) -{ - if(theta == 0.0f) - *this = q2; - else{ - float w1, w2; - if(theta > PI/2){ - theta = PI - theta; - w1 = Sin((1.0f - t) * theta) * invSin; - w2 = -Sin(t * theta) * invSin; - }else{ - w1 = Sin((1.0f - t) * theta) * invSin; - w2 = Sin(t * theta) * invSin; - } - // TODO: VU0 code - *this = w1*q1 + w2*q2; - } -} - -void -CQuaternion::Set(RwV3d *axis, float angle) -{ - float halfCos = Cos(angle*0.5f); - float halfSin = Sin(angle*0.5f); - x = axis->x*halfSin; - y = axis->y*halfSin; - z = axis->z*halfSin; - w = halfCos; -} - -void -CQuaternion::Get(RwMatrix *matrix) -{ - float x2 = x+x; - float y2 = y+y; - float z2 = z+z; - - float x_2x = x * x2; - float x_2y = x * y2; - float x_2z = x * z2; - float y_2y = y * y2; - float y_2z = y * z2; - float z_2z = z * z2; - float w_2x = w * x2; - float w_2y = w * y2; - float w_2z = w * z2; - - matrix->right.x = 1.0f - (y_2y + z_2z); - matrix->up.x = x_2y - w_2z; - matrix->at.x = x_2z + w_2y; - matrix->right.y = x_2y + w_2z; - matrix->up.y = 1.0f - (x_2x + z_2z); - matrix->at.y = y_2z - w_2x; - matrix->right.z = x_2z - w_2y; - matrix->up.z = y_2z + w_2x; - matrix->at.z = 1.0f - (x_2x + y_2y); -} diff --git a/src/render/Glass.cpp b/src/render/Glass.cpp index ee36bad3..c52d49bd 100644 --- a/src/render/Glass.cpp +++ b/src/render/Glass.cpp @@ -700,7 +700,7 @@ CGlass::WindowRespondsToExplosion(CEntity *entity, CVector point) if ( fDistToGlass < 10.0f ) { - distToGlass.Normalise(0.3f); + distToGlass *= (0.3f / fDistToGlass); // normalise WindowRespondsToCollision(object, 10000.0f, distToGlass, object->GetPosition(), true); } else diff --git a/src/render/Skidmarks.cpp b/src/render/Skidmarks.cpp index 5d521041..ad036d58 100644 --- a/src/render/Skidmarks.cpp +++ b/src/render/Skidmarks.cpp @@ -222,10 +222,11 @@ CSkidmarks::RegisterOne(uintptr id, CVector pos, float fwdX, float fwdY, bool *i aSkidmarks[i].m_pos[aSkidmarks[i].m_last] = pos; - CVector2D dist = aSkidmarks[i].m_pos[aSkidmarks[i].m_last] - aSkidmarks[i].m_pos[aSkidmarks[i].m_last-1]; - dist.NormaliseSafe(); + CVector2D right(aSkidmarks[i].m_pos[aSkidmarks[i].m_last].y - aSkidmarks[i].m_pos[aSkidmarks[i].m_last - 1].y, + aSkidmarks[i].m_pos[aSkidmarks[i].m_last - 1].x - aSkidmarks[i].m_pos[aSkidmarks[i].m_last].x); + + right.NormaliseSafe(); fwd.NormaliseSafe(); - CVector2D right(dist.y, -dist.x); float turn = DotProduct2D(fwd, right); turn = Abs(turn) + 1.0f; aSkidmarks[i].m_side[aSkidmarks[i].m_last] = CVector(right.x, right.y, 0.0f) * turn * 0.125f; diff --git a/src/render/WaterCannon.cpp b/src/render/WaterCannon.cpp index 2ef10d77..2b34db37 100644 --- a/src/render/WaterCannon.cpp +++ b/src/render/WaterCannon.cpp @@ -140,8 +140,7 @@ void CWaterCannon::Render(void) if ( !bInit ) { CVector cp = CrossProduct(m_avecPos[pointB] - m_avecPos[pointA], TheCamera.GetForward()); - cp.Normalise(0.05f); - norm = cp; + norm = cp * (0.05f / cp.Magnitude()); bInit = true; } -- cgit v1.2.3 From 9c2e9fcf886533ea2a1fdd415b31c659ca733286 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Tue, 15 Sep 2020 00:31:32 +0300 Subject: Fix RotateY --- src/math/Matrix.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/math/Matrix.cpp b/src/math/Matrix.cpp index 3e77548d..a8b1b182 100644 --- a/src/math/Matrix.cpp +++ b/src/math/Matrix.cpp @@ -327,14 +327,14 @@ CMatrix::RotateY(float y) float px = m_matrix.pos.x; float pz = m_matrix.pos.z; - m_matrix.right.x = c * rx - s * rz; - m_matrix.right.z = c * rz + s * rx; - m_matrix.up.x = c * ux - s * uz; - m_matrix.up.z = c * uz + s * ux; - m_matrix.at.x = c * ax - s * az; - m_matrix.at.z = c * az + s * ax; - m_matrix.pos.x = c * px - s * pz; - m_matrix.pos.z = c * pz + s * px; + m_matrix.right.x = c * rx + s * rz; + m_matrix.right.z = c * rz - s * rx; + m_matrix.up.x = c * ux + s * uz; + m_matrix.up.z = c * uz - s * ux; + m_matrix.at.x = c * ax + s * az; + m_matrix.at.z = c * az - s * ax; + m_matrix.pos.x = c * px + s * pz; + m_matrix.pos.z = c * pz - s * px; } void -- cgit v1.2.3 From 7efc153dc9c452e63a6010226d7eba0f13358d41 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 19 Sep 2020 15:55:27 +0300 Subject: Renaming audio enum entries to something more like original --- src/audio/AudioCollision.cpp | 4 +- src/audio/AudioLogic.cpp | 694 +++++++++++++++++++++---------------------- src/audio/AudioManager.cpp | 4 +- src/audio/MusicManager.cpp | 60 ++-- src/audio/PoliceRadio.cpp | 2 +- src/audio/audio_enums.h | 2 +- src/audio/sampman.h | 132 ++++---- src/audio/sampman_miles.cpp | 58 ++-- src/audio/sampman_null.cpp | 10 +- src/audio/sampman_oal.cpp | 70 ++--- 10 files changed, 518 insertions(+), 518 deletions(-) diff --git a/src/audio/AudioCollision.cpp b/src/audio/AudioCollision.cpp index 55d64714..6ce7bbac 100644 --- a/src/audio/AudioCollision.cpp +++ b/src/audio/AudioCollision.cpp @@ -165,7 +165,7 @@ cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 coun if(m_sQueueSample.m_nVolume) { m_sQueueSample.m_nCounter = counter; m_sQueueSample.m_vecPos = col.m_vecPosition; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 7; m_sQueueSample.m_nLoopCount = 0; @@ -306,7 +306,7 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col) m_sQueueSample.m_nCounter = counter++; if(counter >= 255) counter = 28; m_sQueueSample.m_vecPos = col.m_vecPosition; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 11; m_sQueueSample.m_nLoopCount = 1; diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 8546f255..5ea03aff 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -58,69 +58,69 @@ enum LOADING_STATUS : uint8 { LOADING_STATUS_NOT_LOADED = 0, LOADING_STATUS_LOAD void cAudioManager::PreInitialiseGameSpecificSetup() const { - BankStartOffset[SAMPLEBANK_MAIN] = SAMPLEBANK_START; + BankStartOffset[SFX_BANK_0] = SAMPLEBANK_START; #ifdef GTA_PS2 - BankStartOffset[SAMPLEBANK_CAR_PACARD] = SFX_CAR_ACCEL_1; - BankStartOffset[SAMPLEBANK_CAR_PATHFINDER] = SFX_CAR_ACCEL_2; - BankStartOffset[SAMPLEBANK_CAR_PORSCHE] = SFX_CAR_ACCEL_3; - BankStartOffset[SAMPLEBANK_CAR_SPIDER] = SFX_CAR_ACCEL_4; - BankStartOffset[SAMPLEBANK_CAR_MERC] = SFX_CAR_ACCEL_5; - BankStartOffset[SAMPLEBANK_CAR_MACKTRUCK] = SFX_CAR_ACCEL_6; - BankStartOffset[SAMPLEBANK_CAR_HOTROD] = SFX_CAR_ACCEL_7; - BankStartOffset[SAMPLEBANK_CAR_COBRA] = SFX_CAR_ACCEL_8; - BankStartOffset[SAMPLEBANK_CAR_NONE] = SFX_CAR_ACCEL_9; - BankStartOffset[SAMPLEBANK_FRONTEND] = SFX_PAGE_CHANGE_AND_BACK_LEFT; - BankStartOffset[SAMPLEBANK_TRAIN] = SFX_TRAIN_STATION_AMBIENCE_LOOP; - BankStartOffset[SAMPLEBANK_BUILDING_CLUB_1] = SFX_CLUB_1; - BankStartOffset[SAMPLEBANK_BUILDING_CLUB_2] = SFX_CLUB_2; - BankStartOffset[SAMPLEBANK_BUILDING_CLUB_3] = SFX_CLUB_3; - BankStartOffset[SAMPLEBANK_BUILDING_CLUB_4] = SFX_CLUB_4; - BankStartOffset[SAMPLEBANK_BUILDING_CLUB_5] = SFX_CLUB_5; - BankStartOffset[SAMPLEBANK_BUILDING_CLUB_6] = SFX_CLUB_6; - BankStartOffset[SAMPLEBANK_BUILDING_CLUB_7] = SFX_CLUB_7; - BankStartOffset[SAMPLEBANK_BUILDING_CLUB_8] = SFX_CLUB_8; - BankStartOffset[SAMPLEBANK_BUILDING_CLUB_9] = SFX_CLUB_9; - BankStartOffset[SAMPLEBANK_BUILDING_CLUB_10] = SFX_CLUB_10; - BankStartOffset[SAMPLEBANK_BUILDING_CLUB_11] = SFX_CLUB_11; - BankStartOffset[SAMPLEBANK_BUILDING_CLUB_12] = SFX_CLUB_12; - BankStartOffset[SAMPLEBANK_BUILDING_CLUB_RAGGA] = SFX_CLUB_RAGGA; - BankStartOffset[SAMPLEBANK_BUILDING_STRIP_CLUB_1] = SFX_STRIP_CLUB_1; - BankStartOffset[SAMPLEBANK_BUILDING_STRIP_CLUB_2] = SFX_STRIP_CLUB_2; - BankStartOffset[SAMPLEBANK_BUILDING_WORKSHOP] = SFX_WORKSHOP_1; - BankStartOffset[SAMPLEBANK_BUILDING_PIANO_BAR] = SFX_PIANO_BAR_1; - BankStartOffset[SAMPLEBANK_BUILDING_SAWMILL] = SFX_SAWMILL_LOOP; - BankStartOffset[SAMPLEBANK_BUILDING_DOG_FOOD_FACTORY] = SFX_DOG_FOOD_FACTORY; - BankStartOffset[SAMPLEBANK_BUILDING_LAUNDERETTE] = SFX_LAUNDERETTE_LOOP; - BankStartOffset[SAMPLEBANK_BUILDING_RESTAURANT_CHINATOWN] = SFX_RESTAURANT_CHINATOWN; - BankStartOffset[SAMPLEBANK_BUILDING_RESTAURANT_ITALY] = SFX_RESTAURANT_ITALY; - BankStartOffset[SAMPLEBANK_BUILDING_RESTAURANT_GENERIC_1] = SFX_RESTAURANT_GENERIC_1; - BankStartOffset[SAMPLEBANK_BUILDING_RESTAURANT_GENERIC_2] = SFX_RESTAURANT_GENERIC_2; - BankStartOffset[SAMPLEBANK_BUILDING_AIRPORT] = SFX_AIRPORT_ANNOUNCEMENT_1; - BankStartOffset[SAMPLEBANK_BUILDING_SHOP] = SFX_SHOP_LOOP; - BankStartOffset[SAMPLEBANK_BUILDING_CINEMA] = SFX_CINEMA_BASS_1; - BankStartOffset[SAMPLEBANK_BUILDING_DOCKS] = SFX_DOCKS_FOGHORN; - BankStartOffset[SAMPLEBANK_BUILDING_HOME] = SFX_HOME_1; - BankStartOffset[SAMPLEBANK_BUILDING_PORN_1] = SFX_PORN_1_LOOP; - BankStartOffset[SAMPLEBANK_BUILDING_PORN_2] = SFX_PORN_2_LOOP; - BankStartOffset[SAMPLEBANK_BUILDING_PORN_3] = SFX_PORN_3_LOOP; - BankStartOffset[SAMPLEBANK_BUILDING_POLICE_BALL] = SFX_POLICE_BALL_1; - BankStartOffset[SAMPLEBANK_BUILDING_BANK_ALARM] = SFX_BANK_ALARM_1; - BankStartOffset[SAMPLEBANK_BUILDING_RAVE_INDUSTRIAL] = SFX_RAVE_INDUSTRIAL; - BankStartOffset[SAMPLEBANK_BUILDING_RAVE_COMMERCIAL] = SFX_RAVE_COMMERCIAL; - BankStartOffset[SAMPLEBANK_BUILDING_RAVE_SUBURBAN] = SFX_RAVE_SUBURBAN; - BankStartOffset[SAMPLEBANK_BUILDING_RAVE_COMMERCIAL_2] = SFX_RAVE_COMMERCIAL_2; - BankStartOffset[SAMPLEBANK_BUILDING_39] = SFX_CLUB_1_1; - BankStartOffset[SAMPLEBANK_BUILDING_40] = SFX_CLUB_1_2; - BankStartOffset[SAMPLEBANK_BUILDING_41] = SFX_CLUB_1_3; - BankStartOffset[SAMPLEBANK_BUILDING_42] = SFX_CLUB_1_4; - BankStartOffset[SAMPLEBANK_BUILDING_43] = SFX_CLUB_1_5; - BankStartOffset[SAMPLEBANK_BUILDING_44] = SFX_CLUB_1_6; - BankStartOffset[SAMPLEBANK_BUILDING_45] = SFX_CLUB_1_7; - BankStartOffset[SAMPLEBANK_BUILDING_46] = SFX_CLUB_1_8; - BankStartOffset[SAMPLEBANK_BUILDING_47] = SFX_CLUB_1_9; - BankStartOffset[SAMPLEBANK_EXTRAS] = SFX_EXPLOSION_1; + BankStartOffset[SFX_BANK_PACARD] = SFX_CAR_ACCEL_1; + BankStartOffset[SFX_BANK_PATHFINDER] = SFX_CAR_ACCEL_2; + BankStartOffset[SFX_BANK_PORSCHE] = SFX_CAR_ACCEL_3; + BankStartOffset[SFX_BANK_SPIDER] = SFX_CAR_ACCEL_4; + BankStartOffset[SFX_BANK_MERC] = SFX_CAR_ACCEL_5; + BankStartOffset[SFX_BANK_TRUCK] = SFX_CAR_ACCEL_6; + BankStartOffset[SFX_BANK_HOTROD] = SFX_CAR_ACCEL_7; + BankStartOffset[SFX_BANK_COBRA] = SFX_CAR_ACCEL_8; + BankStartOffset[SFX_BANK_NONE] = SFX_CAR_ACCEL_9; + BankStartOffset[SFX_BANK_FRONT_END_MENU] = SFX_PAGE_CHANGE_AND_BACK_LEFT; + BankStartOffset[SFX_BANK_TRAIN] = SFX_TRAIN_STATION_AMBIENCE_LOOP; + BankStartOffset[SFX_BANK_BUILDING_CLUB_1] = SFX_CLUB_1; + BankStartOffset[SFX_BANK_BUILDING_CLUB_2] = SFX_CLUB_2; + BankStartOffset[SFX_BANK_BUILDING_CLUB_3] = SFX_CLUB_3; + BankStartOffset[SFX_BANK_BUILDING_CLUB_4] = SFX_CLUB_4; + BankStartOffset[SFX_BANK_BUILDING_CLUB_5] = SFX_CLUB_5; + BankStartOffset[SFX_BANK_BUILDING_CLUB_6] = SFX_CLUB_6; + BankStartOffset[SFX_BANK_BUILDING_CLUB_7] = SFX_CLUB_7; + BankStartOffset[SFX_BANK_BUILDING_CLUB_8] = SFX_CLUB_8; + BankStartOffset[SFX_BANK_BUILDING_CLUB_9] = SFX_CLUB_9; + BankStartOffset[SFX_BANK_BUILDING_CLUB_10] = SFX_CLUB_10; + BankStartOffset[SFX_BANK_BUILDING_CLUB_11] = SFX_CLUB_11; + BankStartOffset[SFX_BANK_BUILDING_CLUB_12] = SFX_CLUB_12; + BankStartOffset[SFX_BANK_BUILDING_CLUB_RAGGA] = SFX_CLUB_RAGGA; + BankStartOffset[SFX_BANK_BUILDING_STRIP_CLUB_1] = SFX_STRIP_CLUB_1; + BankStartOffset[SFX_BANK_BUILDING_STRIP_CLUB_2] = SFX_STRIP_CLUB_2; + BankStartOffset[SFX_BANK_BUILDING_WORKSHOP] = SFX_WORKSHOP_1; + BankStartOffset[SFX_BANK_BUILDING_PIANO_BAR] = SFX_PIANO_BAR_1; + BankStartOffset[SFX_BANK_BUILDING_SAWMILL] = SFX_SAWMILL_LOOP; + BankStartOffset[SFX_BANK_BUILDING_DOG_FOOD_FACTORY] = SFX_DOG_FOOD_FACTORY; + BankStartOffset[SFX_BANK_BUILDING_LAUNDERETTE] = SFX_LAUNDERETTE_LOOP; + BankStartOffset[SFX_BANK_BUILDING_RESTAURANT_CHINATOWN] = SFX_RESTAURANT_CHINATOWN; + BankStartOffset[SFX_BANK_BUILDING_RESTAURANT_ITALY] = SFX_RESTAURANT_ITALY; + BankStartOffset[SFX_BANK_BUILDING_RESTAURANT_GENERIC_1] = SFX_RESTAURANT_GENERIC_1; + BankStartOffset[SFX_BANK_BUILDING_RESTAURANT_GENERIC_2] = SFX_RESTAURANT_GENERIC_2; + BankStartOffset[SFX_BANK_BUILDING_AIRPORT] = SFX_AIRPORT_ANNOUNCEMENT_1; + BankStartOffset[SFX_BANK_BUILDING_SHOP] = SFX_SHOP_LOOP; + BankStartOffset[SFX_BANK_BUILDING_CINEMA] = SFX_CINEMA_BASS_1; + BankStartOffset[SFX_BANK_BUILDING_DOCKS] = SFX_DOCKS_FOGHORN; + BankStartOffset[SFX_BANK_BUILDING_HOME] = SFX_HOME_1; + BankStartOffset[SFX_BANK_BUILDING_PORN_1] = SFX_PORN_1_LOOP; + BankStartOffset[SFX_BANK_BUILDING_PORN_2] = SFX_PORN_2_LOOP; + BankStartOffset[SFX_BANK_BUILDING_PORN_3] = SFX_PORN_3_LOOP; + BankStartOffset[SFX_BANK_BUILDING_POLICE_BALL] = SFX_POLICE_BALL_1; + BankStartOffset[SFX_BANK_BUILDING_BANK_ALARM] = SFX_BANK_ALARM_1; + BankStartOffset[SFX_BANK_BUILDING_RAVE_INDUSTRIAL] = SFX_RAVE_INDUSTRIAL; + BankStartOffset[SFX_BANK_BUILDING_RAVE_COMMERCIAL] = SFX_RAVE_COMMERCIAL; + BankStartOffset[SFX_BANK_BUILDING_RAVE_SUBURBAN] = SFX_RAVE_SUBURBAN; + BankStartOffset[SFX_BANK_BUILDING_RAVE_COMMERCIAL_2] = SFX_RAVE_COMMERCIAL_2; + BankStartOffset[SFX_BANK_BUILDING_39] = SFX_CLUB_1_1; + BankStartOffset[SFX_BANK_BUILDING_40] = SFX_CLUB_1_2; + BankStartOffset[SFX_BANK_BUILDING_41] = SFX_CLUB_1_3; + BankStartOffset[SFX_BANK_BUILDING_42] = SFX_CLUB_1_4; + BankStartOffset[SFX_BANK_BUILDING_43] = SFX_CLUB_1_5; + BankStartOffset[SFX_BANK_BUILDING_44] = SFX_CLUB_1_6; + BankStartOffset[SFX_BANK_BUILDING_45] = SFX_CLUB_1_7; + BankStartOffset[SFX_BANK_BUILDING_46] = SFX_CLUB_1_8; + BankStartOffset[SFX_BANK_BUILDING_47] = SFX_CLUB_1_9; + BankStartOffset[SFX_BANK_GENERIC_EXTRA] = SFX_EXPLOSION_1; #endif // GTA_PS2 - BankStartOffset[SAMPLEBANK_PED] = SAMPLEBANK_PED_START; + BankStartOffset[SFX_BANK_PED_COMMENTS] = SAMPLEBANK_PED_START; } void @@ -459,10 +459,10 @@ enum eVehicleModel { enum { - DOOR_TYPE_OLD = 0, - DOOR_TYPE_NEW, - DOOR_TYPE_TRUCK, - DOOR_TYPE_AIRBREAK, + OLD_DOOR = 0, + NEW_DOOR, + TRUCK_DOOR, + BUS_DOOR, }; @@ -477,76 +477,76 @@ struct tVehicleSampleData { }; const tVehicleSampleData aVehicleSettings[MAX_CARS] = { - {SFX_CAR_REV_2, SAMPLEBANK_CAR_PATHFINDER, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_56CHEV, 11487, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_8, SAMPLEBANK_CAR_COBRA, SFX_CAR_HORN_PORSCHE, 11025, SFX_CAR_ALARM_1, 10928, DOOR_TYPE_NEW}, - {SFX_CAR_REV_6, SAMPLEBANK_CAR_MACKTRUCK, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_56CHEV, 12893, SFX_CAR_ALARM_1, 8941, DOOR_TYPE_OLD}, - {SFX_CAR_REV_5, SAMPLEBANK_CAR_MERC, SFX_CAR_HORN_BMW328, 10706, SFX_CAR_ALARM_1, 11922, DOOR_TYPE_NEW}, - {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 7948, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_6, SAMPLEBANK_CAR_MACKTRUCK, SFX_CAR_HORN_TRUCK, 29711, SFX_POLICE_SIREN_SLOW, 11556, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_6, SAMPLEBANK_CAR_MACKTRUCK, SFX_CAR_HORN_TRUCK, 31478, SFX_CAR_ALARM_1, 8941, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_BMW328, 9538, SFX_CAR_ALARM_1, 12220, DOOR_TYPE_NEW}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_3, SAMPLEBANK_CAR_PORSCHE, SFX_CAR_HORN_BMW328, 12017, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, - {SFX_CAR_REV_2, SAMPLEBANK_CAR_PATHFINDER, SFX_CAR_HORN_JEEP, 22295, SFX_CAR_ALARM_1, 12200, DOOR_TYPE_NEW}, - {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_BUS2, 18000, SFX_CAR_ALARM_1, 13400, DOOR_TYPE_NEW}, - {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_BUS, 18286, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_3, SAMPLEBANK_CAR_PORSCHE, SFX_CAR_HORN_PORSCHE, 11025, SFX_CAR_ALARM_1, 13600, DOOR_TYPE_NEW}, - {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_JEEP, 22295, SFX_AMBULANCE_SIREN_SLOW, 8795, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_5, SAMPLEBANK_CAR_MERC, SFX_CAR_HORN_PORSCHE, 9271, SFX_POLICE_SIREN_SLOW, 16168, DOOR_TYPE_NEW}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_56CHEV, 12170, SFX_CAR_ALARM_1, 8000, DOOR_TYPE_NEW}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_BUS2, 12345, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_2, SAMPLEBANK_CAR_PATHFINDER, SFX_CAR_HORN_BMW328, 10796, SFX_CAR_ALARM_1, 8543, DOOR_TYPE_NEW}, - {SFX_CAR_REV_5, SAMPLEBANK_CAR_MERC, SFX_CAR_HORN_PORSCHE, 9271, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, - {SFX_CAR_REV_2, SAMPLEBANK_CAR_PATHFINDER, SFX_CAR_HORN_PICKUP, 10924, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_PICKUP, 11025, SFX_ICE_CREAM_TUNE, 11025, DOOR_TYPE_OLD}, - {SFX_CAR_REV_7, SAMPLEBANK_CAR_HOTROD, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 10000, DOOR_TYPE_OLD}, - {SFX_CAR_REV_5, SAMPLEBANK_CAR_MERC, SFX_CAR_HORN_BMW328, 10706, SFX_POLICE_SIREN_SLOW, 13596, DOOR_TYPE_NEW}, - {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_BUS, 17260, SFX_POLICE_SIREN_SLOW, 13000, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_PICKUP, 8670, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_8, SAMPLEBANK_CAR_COBRA, SFX_CAR_HORN_PORSCHE, 10400, SFX_CAR_ALARM_1, 10123, DOOR_TYPE_NEW}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 26513, SFX_POLICE_SIREN_SLOW, 13596, DOOR_TYPE_OLD}, - {SFX_CAR_REV_6, SAMPLEBANK_CAR_MACKTRUCK, SFX_CAR_HORN_BUS2, 11652, SFX_CAR_ALARM_1, 10554, DOOR_TYPE_AIRBREAK}, - {SFX_CAR_REV_6, SAMPLEBANK_CAR_MACKTRUCK, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 8000, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_6, SAMPLEBANK_CAR_MACKTRUCK, SFX_CAR_HORN_TRUCK, 28043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_1, SAMPLEBANK_MAIN, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_AIRBREAK}, - {SFX_CAR_REV_1, SAMPLEBANK_MAIN, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CESNA_IDLE, SAMPLEBANK_MAIN, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_6, SAMPLEBANK_CAR_MACKTRUCK, SFX_CAR_HORN_BUS, 16291, SFX_CAR_ALARM_1, 7500, DOOR_TYPE_AIRBREAK}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_56CHEV, 10233, SFX_CAR_ALARM_1, 8935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_PICKUP, 8670, SFX_CAR_ALARM_1, 8935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, SAMPLEBANK_MAIN, SFX_CAR_HORN_PICKUP, 2000, SFX_CAR_ALARM_1, 17000, DOOR_TYPE_OLD}, - {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_5, SAMPLEBANK_CAR_MERC, SFX_CAR_HORN_BMW328, 9003, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, - {SFX_CAR_REV_2, SAMPLEBANK_CAR_PATHFINDER, SFX_CAR_HORN_PORSCHE, 12375, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, - {SFX_CAR_REV_5, SAMPLEBANK_CAR_MERC, SFX_CAR_HORN_BUS2, 15554, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, - {SFX_CAR_REV_7, SAMPLEBANK_CAR_HOTROD, SFX_CAR_HORN_BUS2, 13857, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_7, SAMPLEBANK_CAR_HOTROD, SFX_CAR_HORN_PICKUP, 10924, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_1, SAMPLEBANK_MAIN, SFX_CAR_HORN_JEEP, 20143, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, SAMPLEBANK_MAIN, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9000, DOOR_TYPE_OLD}, - {SFX_CAR_REV_6, SAMPLEBANK_CAR_MACKTRUCK, SFX_CAR_HORN_TRUCK, 28043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_BUS, 18286, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_BUS2, 18000, SFX_CAR_ALARM_1, 13400, DOOR_TYPE_NEW}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}}; + {SFX_CAR_REV_2, SFX_BANK_PATHFINDER, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, NEW_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_56CHEV, 11487, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_8, SFX_BANK_COBRA, SFX_CAR_HORN_PORSCHE, 11025, SFX_CAR_ALARM_1, 10928, NEW_DOOR}, + {SFX_CAR_REV_6, SFX_BANK_TRUCK, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 9935, TRUCK_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_56CHEV, 12893, SFX_CAR_ALARM_1, 8941, OLD_DOOR}, + {SFX_CAR_REV_5, SFX_BANK_MERC, SFX_CAR_HORN_BMW328, 10706, SFX_CAR_ALARM_1, 11922, NEW_DOOR}, + {SFX_CAR_REV_4, SFX_BANK_SPIDER, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 7948, TRUCK_DOOR}, + {SFX_CAR_REV_6, SFX_BANK_TRUCK, SFX_CAR_HORN_TRUCK, 29711, SFX_POLICE_SIREN_SLOW, 11556, TRUCK_DOOR}, + {SFX_CAR_REV_6, SFX_BANK_TRUCK, SFX_CAR_HORN_TRUCK, 31478, SFX_CAR_ALARM_1, 8941, TRUCK_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_BMW328, 9538, SFX_CAR_ALARM_1, 12220, NEW_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_3, SFX_BANK_PORSCHE, SFX_CAR_HORN_BMW328, 12017, SFX_CAR_ALARM_1, 9935, NEW_DOOR}, + {SFX_CAR_REV_2, SFX_BANK_PATHFINDER, SFX_CAR_HORN_JEEP, 22295, SFX_CAR_ALARM_1, 12200, NEW_DOOR}, + {SFX_CAR_REV_4, SFX_BANK_SPIDER, SFX_CAR_HORN_BUS2, 18000, SFX_CAR_ALARM_1, 13400, NEW_DOOR}, + {SFX_CAR_REV_4, SFX_BANK_SPIDER, SFX_CAR_HORN_BUS, 18286, SFX_CAR_ALARM_1, 9935, TRUCK_DOOR}, + {SFX_CAR_REV_3, SFX_BANK_PORSCHE, SFX_CAR_HORN_PORSCHE, 11025, SFX_CAR_ALARM_1, 13600, NEW_DOOR}, + {SFX_CAR_REV_4, SFX_BANK_SPIDER, SFX_CAR_HORN_JEEP, 22295, SFX_AMBULANCE_SIREN_SLOW, 8795, TRUCK_DOOR}, + {SFX_CAR_REV_5, SFX_BANK_MERC, SFX_CAR_HORN_PORSCHE, 9271, SFX_POLICE_SIREN_SLOW, 16168, NEW_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_56CHEV, 12170, SFX_CAR_ALARM_1, 8000, NEW_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_BUS2, 12345, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_2, SFX_BANK_PATHFINDER, SFX_CAR_HORN_BMW328, 10796, SFX_CAR_ALARM_1, 8543, NEW_DOOR}, + {SFX_CAR_REV_5, SFX_BANK_MERC, SFX_CAR_HORN_PORSCHE, 9271, SFX_CAR_ALARM_1, 9935, NEW_DOOR}, + {SFX_CAR_REV_2, SFX_BANK_PATHFINDER, SFX_CAR_HORN_PICKUP, 10924, SFX_CAR_ALARM_1, 9935, NEW_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_PICKUP, 11025, SFX_ICE_CREAM_TUNE, 11025, OLD_DOOR}, + {SFX_CAR_REV_7, SFX_BANK_HOTROD, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, NEW_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 10000, OLD_DOOR}, + {SFX_CAR_REV_5, SFX_BANK_MERC, SFX_CAR_HORN_BMW328, 10706, SFX_POLICE_SIREN_SLOW, 13596, NEW_DOOR}, + {SFX_CAR_REV_4, SFX_BANK_SPIDER, SFX_CAR_HORN_BUS, 17260, SFX_POLICE_SIREN_SLOW, 13000, TRUCK_DOOR}, + {SFX_CAR_REV_4, SFX_BANK_SPIDER, SFX_CAR_HORN_PICKUP, 8670, SFX_CAR_ALARM_1, 9935, TRUCK_DOOR}, + {SFX_CAR_REV_8, SFX_BANK_COBRA, SFX_CAR_HORN_PORSCHE, 10400, SFX_CAR_ALARM_1, 10123, NEW_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_JEEP, 26513, SFX_POLICE_SIREN_SLOW, 13596, OLD_DOOR}, + {SFX_CAR_REV_6, SFX_BANK_TRUCK, SFX_CAR_HORN_BUS2, 11652, SFX_CAR_ALARM_1, 10554, BUS_DOOR}, + {SFX_CAR_REV_6, SFX_BANK_TRUCK, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 8000, TRUCK_DOOR}, + {SFX_CAR_REV_6, SFX_BANK_TRUCK, SFX_CAR_HORN_TRUCK, 28043, SFX_CAR_ALARM_1, 9935, TRUCK_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_0, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 9935, BUS_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CESNA_IDLE, SFX_BANK_0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_6, SFX_BANK_TRUCK, SFX_CAR_HORN_BUS, 16291, SFX_CAR_ALARM_1, 7500, BUS_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_56CHEV, 10233, SFX_CAR_ALARM_1, 8935, OLD_DOOR}, + {SFX_CAR_REV_4, SFX_BANK_SPIDER, SFX_CAR_HORN_PICKUP, 8670, SFX_CAR_ALARM_1, 8935, OLD_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_0, SFX_CAR_HORN_PICKUP, 2000, SFX_CAR_ALARM_1, 17000, OLD_DOOR}, + {SFX_CAR_REV_4, SFX_BANK_SPIDER, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_4, SFX_BANK_SPIDER, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_5, SFX_BANK_MERC, SFX_CAR_HORN_BMW328, 9003, SFX_CAR_ALARM_1, 9935, NEW_DOOR}, + {SFX_CAR_REV_2, SFX_BANK_PATHFINDER, SFX_CAR_HORN_PORSCHE, 12375, SFX_CAR_ALARM_1, 9935, NEW_DOOR}, + {SFX_CAR_REV_5, SFX_BANK_MERC, SFX_CAR_HORN_BUS2, 15554, SFX_CAR_ALARM_1, 9935, NEW_DOOR}, + {SFX_CAR_REV_7, SFX_BANK_HOTROD, SFX_CAR_HORN_BUS2, 13857, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_7, SFX_BANK_HOTROD, SFX_CAR_HORN_PICKUP, 10924, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_4, SFX_BANK_SPIDER, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, TRUCK_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_0, SFX_CAR_HORN_JEEP, 20143, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_0, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_4, SFX_BANK_SPIDER, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9000, OLD_DOOR}, + {SFX_CAR_REV_6, SFX_BANK_TRUCK, SFX_CAR_HORN_TRUCK, 28043, SFX_CAR_ALARM_1, 9935, TRUCK_DOOR}, + {SFX_CAR_REV_4, SFX_BANK_SPIDER, SFX_CAR_HORN_BUS, 18286, SFX_CAR_ALARM_1, 9935, TRUCK_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_4, SFX_BANK_SPIDER, SFX_CAR_HORN_BUS2, 18000, SFX_CAR_ALARM_1, 13400, NEW_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, OLD_DOOR}, + {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, OLD_DOOR}}; bool bPlayerJustEnteredCar; @@ -678,7 +678,7 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams *params) if (veh->m_bRainSamplesCounter > 4) veh->m_bRainSamplesCounter = 68; m_sQueueSample.m_nSampleIndex = (m_anRandomTable[1] & 3) + SFX_CAR_RAIN_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 9; m_sQueueSample.m_nFrequency = m_anRandomTable[1] % 4000 + 28000; @@ -731,7 +731,7 @@ cAudioManager::ProcessReverseGear(cVehicleParams *params) m_sQueueSample.m_nCounter = 61; m_sQueueSample.m_nSampleIndex = SFX_REVERSE_GEAR; } - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nFrequency = (6000.f * modificator) + 7000; @@ -782,7 +782,7 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nSampleIndex = SFX_REMOTE_CONTROLLED_CAR; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = (11025.f * velocityChange / params->m_pTransmission->fMaxVelocity + 11025.f); @@ -828,7 +828,7 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 0; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; if (params->m_pVehicle->m_nSurfaceTouched == SURFACE_WATER) { @@ -883,7 +883,7 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; modificator = m_sQueueSample.m_fDistance / 6.f; @@ -1013,7 +1013,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params) 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_SAMPLEBANKS_OFFSET + SFX_CAR_IDLE_1; + m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nBank - CAR_SFX_BANKS_OFFSET + SFX_CAR_IDLE_1; freq = modificator * 10000 + 22050; m_sQueueSample.m_nCounter = 52; } else { @@ -1022,7 +1022,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params) } } else { if (automobile->m_fGasPedal < 0.05f) { - m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nBank - CAR_SAMPLEBANKS_OFFSET + SFX_CAR_IDLE_1; + m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nBank - CAR_SFX_BANKS_OFFSET + SFX_CAR_IDLE_1; freq = modificator * 10000 + 22050; m_sQueueSample.m_nCounter = 52; } else { @@ -1030,7 +1030,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params) m_sQueueSample.m_nCounter = 2; } } - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nFrequency = freq + 100 * m_sQueueSample.m_nEntityIndex % 1000; @@ -1087,7 +1087,7 @@ cAudioManager::AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sampl #ifdef GTA_PS2 m_sQueueSample.m_nBankIndex = bank; #else - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; #endif // GTA_PS2 m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 0; @@ -1125,18 +1125,18 @@ cAudioManager::ProcessCesna(cVehicleParams *params) } else if (nAccel < 60) { ++nAccel; } - AddPlayerCarSample(85 * (60 - nAccel) / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_IDLE, SAMPLEBANK_MAIN, 52, true); - AddPlayerCarSample(85 * nAccel / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_REV, SAMPLEBANK_MAIN, 2, true); + AddPlayerCarSample(85 * (60 - nAccel) / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_IDLE, SFX_BANK_0, 52, true); + AddPlayerCarSample(85 * nAccel / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_REV, SFX_BANK_0, 2, true); } } else if (params->m_nIndex == DODO) { - AddPlayerCarSample(105, 17000, SFX_CESNA_IDLE, SAMPLEBANK_MAIN, 52, true); + AddPlayerCarSample(105, 17000, SFX_CESNA_IDLE, SFX_BANK_0, 52, true); } 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) { m_sQueueSample.m_nCounter = 52; m_sQueueSample.m_nSampleIndex = SFX_CESNA_IDLE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nFrequency = 12500; @@ -1157,7 +1157,7 @@ cAudioManager::ProcessCesna(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nSampleIndex = SFX_CESNA_REV; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nFrequency = 25000; @@ -1272,7 +1272,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * freqModifier = 0; engineSoundType = aVehicleSettings[params->m_nIndex].m_nBank; - soundOffset = 3 * (engineSoundType - CAR_SAMPLEBANKS_OFFSET); + soundOffset = 3 * (engineSoundType - CAR_SFX_BANKS_OFFSET); if (accelerateState <= 0) { if (params->m_fVelocityChange < -0.001f) { if (channelUsed) { @@ -1299,16 +1299,16 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * } if (gasPedalAudio > 0.05f) { freq = (5000.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 19000; - if (engineSoundType == SAMPLEBANK_CAR_MACKTRUCK) + if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; AddPlayerCarSample((25.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 40, freq, (soundOffset + SFX_CAR_FINGER_OFF_ACCEL_1), engineSoundType, 63, false); } } freq = (10000.f * gasPedalAudio) + 22050; - if (engineSoundType == SAMPLEBANK_CAR_MACKTRUCK) + if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; - AddPlayerCarSample(110 - (40.f * gasPedalAudio), freq, (engineSoundType - CAR_SAMPLEBANKS_OFFSET + SFX_CAR_IDLE_1), SAMPLEBANK_MAIN, 52, true); + AddPlayerCarSample(110 - (40.f * gasPedalAudio), freq, (engineSoundType - CAR_SFX_BANKS_OFFSET + SFX_CAR_IDLE_1), SFX_BANK_0, 52, true); CurrentPretendGear = Max(1, currentGear); } else { @@ -1329,13 +1329,13 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * automobile->m_fGasPedalAudio = accelerationMultipler; } freq = freqModifier + baseFreq; - if (engineSoundType == SAMPLEBANK_CAR_MACKTRUCK) + if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; if (channelUsed) { SampleManager.StopChannel(m_nActiveSamples); bAccelSampleStopped = true; } - AddPlayerCarSample(vol, freq, (engineSoundType - CAR_SAMPLEBANKS_OFFSET + SFX_CAR_REV_1), SAMPLEBANK_MAIN, 2, true); + AddPlayerCarSample(vol, freq, (engineSoundType - CAR_SFX_BANKS_OFFSET + SFX_CAR_REV_1), SFX_BANK_0, 2, true); } else { TranslateEntity(&m_sQueueSample.m_vecPos, &pos); if (bAccelSampleStopped) { @@ -1359,7 +1359,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * } } - if (!SampleManager.InitialiseChannel(m_nActiveSamples, soundOffset + SFX_CAR_ACCEL_1, SAMPLEBANK_MAIN)) + if (!SampleManager.InitialiseChannel(m_nActiveSamples, soundOffset + SFX_CAR_ACCEL_1, SFX_BANK_0)) return; SampleManager.SetChannelLoopCount(m_nActiveSamples, 1); SampleManager.SetChannelLoopPoints(m_nActiveSamples, 0, -1); @@ -1369,7 +1369,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z); SampleManager.SetChannel3DDistances(m_nActiveSamples, 50.f, 12.5f); freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050; - if (engineSoundType == SAMPLEBANK_CAR_MACKTRUCK) + if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; SampleManager.SetChannelFrequency(m_nActiveSamples, freq); if (!channelUsed) { @@ -1392,7 +1392,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * --nCruising; } freq = 27 * nCruising + freqModifier + 22050; - if (engineSoundType == SAMPLEBANK_CAR_MACKTRUCK) + if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; AddPlayerCarSample(85, freq, (soundOffset + SFX_CAR_AFTER_ACCEL_1), engineSoundType, 64, true); } @@ -1476,7 +1476,7 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params) break; } - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 8; m_sQueueSample.m_nLoopCount = 0; @@ -1566,7 +1566,7 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams *params) 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 = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 2; m_sQueueSample.m_nFrequency = aVehicleSettings[params->m_nIndex].m_nHornFrequency; @@ -1649,7 +1649,7 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams *params) m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nSirenOrAlarmSample; m_sQueueSample.m_nFrequency = aVehicleSettings[params->m_nIndex].m_nSirenOrAlarmFrequency; } - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; @@ -1692,7 +1692,7 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 12; m_sQueueSample.m_nSampleIndex = SFX_REVERSE_WARNING; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 2; m_sQueueSample.m_nFrequency = (100 * m_sQueueSample.m_nEntityIndex & 1023) + SampleManager.GetSampleBaseFrequency(SFX_REVERSE_WARNING); @@ -1739,7 +1739,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams *params) 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); - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 10; m_sQueueSample.m_nLoopCount = 1; @@ -1784,7 +1784,7 @@ cAudioManager::ProcessAirBrakes(cVehicleParams *params) m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_AIR_BRAKES); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 10; m_sQueueSample.m_nLoopCount = 1; @@ -1839,7 +1839,7 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params) m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, engineDamageIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 28; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVolume; @@ -1871,7 +1871,7 @@ cAudioManager::ProcessCarBombTick(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 35; m_sQueueSample.m_nSampleIndex = SFX_COUNTDOWN; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COUNTDOWN); @@ -1922,21 +1922,21 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) maxDist = SQR(SOUND_INTENSITY); emittingVol = m_anRandomTable[2] % 5 + 122; switch (aVehicleSettings[params->m_nIndex].m_bDoorType) { - case DOOR_TYPE_OLD: + case OLD_DOOR: m_sQueueSample.m_nSampleIndex = SFX_OLD_CAR_DOOR_CLOSE; break; - case DOOR_TYPE_NEW: + case NEW_DOOR: default: m_sQueueSample.m_nSampleIndex = SFX_NEW_CAR_DOOR_CLOSE; break; - case DOOR_TYPE_TRUCK: + case TRUCK_DOOR: m_sQueueSample.m_nSampleIndex = SFX_TRUCK_DOOR_CLOSE; break; - case DOOR_TYPE_AIRBREAK: + case BUS_DOOR: m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES; break; } - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] + 22; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); @@ -1956,21 +1956,21 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) maxDist = SQR(SOUND_INTENSITY); emittingVol = m_anRandomTable[1] % 10 + 117; switch (aVehicleSettings[params->m_nIndex].m_bDoorType) { - case DOOR_TYPE_OLD: + case OLD_DOOR: m_sQueueSample.m_nSampleIndex = SFX_OLD_CAR_DOOR_OPEN; break; - case DOOR_TYPE_NEW: + case NEW_DOOR: default: m_sQueueSample.m_nSampleIndex = SFX_NEW_CAR_DOOR_OPEN; break; - case DOOR_TYPE_TRUCK: + case TRUCK_DOOR: m_sQueueSample.m_nSampleIndex = SFX_TRUCK_DOOR_OPEN; break; - case DOOR_TYPE_AIRBREAK: + case BUS_DOOR: m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES; break; } - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] + 10; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); @@ -1984,7 +1984,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) const float SOUND_INTENSITY = 30.0f; maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_GLASS_CRACK; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 68; emittingVol = m_anRandomTable[1] % 30 + 60; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_CRACK); @@ -1997,7 +1997,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) emittingVol = Max(80.f, 2 * (100.f * m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i])); maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_TYRE_BUMP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iWheelIndex++; if (iWheelIndex > 85) iWheelIndex = 82; @@ -2017,7 +2017,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) emittingVol = 60; maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_CAR_STARTER; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + 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; @@ -2029,7 +2029,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_CAR_LIGHT_BREAK: { const float SOUND_INTENSITY = 30.0f; m_sQueueSample.m_nSampleIndex = SFX_GLASS_SHARD_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; 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); @@ -2048,7 +2048,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) else m_sQueueSample.m_nFrequency = 13118; m_sQueueSample.m_nSampleIndex = SFX_SUSPENSION_FAST_MOVE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + 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; @@ -2061,7 +2061,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_CAR_HYDRAULIC_3: { const float SOUND_INTENSITY = 35.0f; m_sQueueSample.m_nSampleIndex = SFX_SUSPENSION_SLOW_MOVE_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + 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; @@ -2076,7 +2076,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_CAR_JERK: { const float SOUND_INTENSITY = 35.0f; m_sQueueSample.m_nSampleIndex = SFX_SHAG_SUSPENSION; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 87; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SHAG_SUSPENSION); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 8); @@ -2096,7 +2096,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i] = 1200.0f; relVol = (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i] - 300.f) / 900.f; m_sQueueSample.m_nSampleIndex = (m_anRandomTable[0] & 1) + SFX_BOAT_SPLASH_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = WaveIndex++; if (WaveIndex > 46) WaveIndex = 41; @@ -2111,7 +2111,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_BOAT_SLOWDOWN: { const float SOUND_INTENSITY = 50.0f; m_sQueueSample.m_nSampleIndex = SFX_POLICE_BOAT_THUMB_OFF; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + 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; @@ -2125,7 +2125,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_TRAIN_DOOR_OPEN: { const float SOUND_INTENSITY = 35.0f; m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 59; m_sQueueSample.m_nFrequency = RandomDisplacement(1000) + 11025; m_sQueueSample.m_nReleasingVolumeModificator = 5; @@ -2141,7 +2141,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) if (vol > 96.0f / 2500.0f) vol = 96.0f / 2500.0f; m_sQueueSample.m_nSampleIndex = SFX_TANK_TURRET; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + 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; @@ -2156,7 +2156,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_CAR_BOMB_TICK: { const float SOUND_INTENSITY = 30.0f; m_sQueueSample.m_nSampleIndex = SFX_BOMB_BEEP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + 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; @@ -2170,7 +2170,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_PLANE_ON_GROUND: { const float SOUND_INTENSITY = 180.0f; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_LAND_WHEELS; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + 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; @@ -2185,7 +2185,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) emittingVol = m_anRandomTable[2]; maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_UZI_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = GunIndex++; emittingVol = emittingVol % 15 + 65; if (GunIndex > 58) @@ -2200,7 +2200,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_WEAPON_HIT_VEHICLE: { const float SOUND_INTENSITY = 40.0f; m_sQueueSample.m_nSampleIndex = m_anRandomTable[m_sQueueSample.m_nEntityIndex % ARRAY_SIZE(m_anRandomTable)] % 6 + SFX_BULLET_CAR_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; 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); @@ -2217,7 +2217,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_BOMB_TICK: { const float SOUND_INTENSITY = 50.0f; m_sQueueSample.m_nSampleIndex = SFX_ARM_BOMB; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + 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; @@ -2247,7 +2247,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_WATER_FALL: { const float SOUND_INTENSITY = 40.0f; m_sQueueSample.m_nSampleIndex = SFX_SPLASH_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 15; m_sQueueSample.m_nFrequency = RandomDisplacement(1000) + 16000; m_sQueueSample.m_nReleasingVolumeModificator = 1; @@ -2261,7 +2261,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_SPLATTER: { const float SOUND_INTENSITY = 40.0f; m_sQueueSample.m_nSampleIndex = CrunchOffset + SFX_PED_CRUNCH_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + 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; @@ -2282,7 +2282,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) continue; m_sQueueSample.m_nSampleIndex = (m_anRandomTable[2] & 3) + SFX_FIGHT_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + 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; @@ -2338,7 +2338,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 32; m_sQueueSample.m_nSampleIndex = SFX_TRAIN_FAR; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 2; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TRAIN_FAR); @@ -2361,7 +2361,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 33; m_sQueueSample.m_nSampleIndex = SFX_TRAIN_NEAR; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TRAIN_NEAR) + 100 * m_sQueueSample.m_nEntityIndex % 987; @@ -2407,7 +2407,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE; m_sQueueSample.m_nFrequency = 10386; m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nLoopCount = 0; @@ -2447,7 +2447,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) 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 = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nLoopCount = 0; @@ -2503,7 +2503,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) if (!m_sQueueSample.m_nVolume) return true; m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nLoopCount = 0; @@ -2545,7 +2545,7 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 38; m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nFrequency = (6050.f * multiplier) + 16000; @@ -2601,7 +2601,7 @@ cAudioManager::ProcessHelicopter(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = i + 65; m_sQueueSample.m_nSampleIndex = i + SFX_HELI_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nFrequency = 1200 * heli->m_nHeliId + SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); @@ -2776,7 +2776,7 @@ cAudioManager::SetupJumboTaxiSound(uint8 vol) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = GetJumboTaxiFreq(); @@ -2808,7 +2808,7 @@ cAudioManager::SetupJumboWhineSound(uint8 emittingVol, int32 freq) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_WHINE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = freq; @@ -2839,7 +2839,7 @@ cAudioManager::SetupJumboEngineSound(uint8 vol, int32 freq) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 3; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_ENGINE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = freq; @@ -2870,7 +2870,7 @@ cAudioManager::SetupJumboFlySound(uint8 emittingVol) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = SFX_JUMBO_DIST_FLY; m_sQueueSample.m_nCounter = 0; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nEmittingVolume = emittingVol; @@ -2900,7 +2900,7 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 5; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_RUMBLE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = true; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_JUMBO_RUMBLE); @@ -2985,7 +2985,7 @@ cAudioManager::ProcessPedHeadphones(cPedParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 64; m_sQueueSample.m_nSampleIndex = SFX_HEADPHONES; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_HEADPHONES); @@ -3076,7 +3076,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; } m_sQueueSample.m_nSampleIndex = sampleIndex; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] - 28; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 17); @@ -3119,7 +3119,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) } else { m_sQueueSample.m_nSampleIndex = SFX_BODY_LAND_AND_FALL; } - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; 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); @@ -3138,7 +3138,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_PUNCH_33: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1; m_sQueueSample.m_nFrequency = 18000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3158,7 +3158,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_KICK_34: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1; m_sQueueSample.m_nFrequency = 16500; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3178,7 +3178,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_HEADBUTT_35: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1; m_sQueueSample.m_nFrequency = 20000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3198,7 +3198,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_PUNCH_36: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_2; m_sQueueSample.m_nFrequency = 18000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3218,7 +3218,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_PUNCH_37: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_2; m_sQueueSample.m_nFrequency = 16500; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3238,7 +3238,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_CLOSE_PUNCH_38: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_2; m_sQueueSample.m_nFrequency = 20000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3258,7 +3258,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_PUNCH_39: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_4; m_sQueueSample.m_nFrequency = 18000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3278,7 +3278,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_PUNCH_OR_KICK_BELOW_40: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_4; m_sQueueSample.m_nFrequency = 16500; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3298,7 +3298,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_PUNCH_41: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_4; m_sQueueSample.m_nFrequency = 20000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3318,7 +3318,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_PUNCH_FROM_BEHIND_42: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_5; m_sQueueSample.m_nFrequency = 18000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3338,7 +3338,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_KNEE_OR_KICK_43: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_5; m_sQueueSample.m_nFrequency = 16500; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3358,7 +3358,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_KICK_44: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_5; m_sQueueSample.m_nFrequency = 20000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3377,7 +3377,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case SOUND_WEAPON_BAT_ATTACK: m_sQueueSample.m_nSampleIndex = SFX_BAT_HIT_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = RandomDisplacement(2000) + 22000; @@ -3402,7 +3402,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) switch (weapon->m_eWeaponType) { case WEAPONTYPE_COLT45: m_sQueueSample.m_nSampleIndex = SFX_COLT45_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COLT45_LEFT); @@ -3425,7 +3425,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case WEAPONTYPE_UZI: m_sQueueSample.m_nSampleIndex = SFX_UZI_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_UZI_LEFT); @@ -3444,7 +3444,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case WEAPONTYPE_SHOTGUN: m_sQueueSample.m_nSampleIndex = SFX_SHOTGUN_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SHOTGUN_LEFT); @@ -3467,7 +3467,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case WEAPONTYPE_AK47: m_sQueueSample.m_nSampleIndex = SFX_AK47_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_AK47_LEFT); @@ -3486,7 +3486,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case WEAPONTYPE_M16: m_sQueueSample.m_nSampleIndex = SFX_M16_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_M16_LEFT); @@ -3505,7 +3505,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case WEAPONTYPE_SNIPERRIFLE: m_sQueueSample.m_nSampleIndex = SFX_SNIPER_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SNIPER_LEFT); @@ -3528,7 +3528,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case WEAPONTYPE_ROCKETLAUNCHER: m_sQueueSample.m_nSampleIndex = SFX_ROCKET_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ROCKET_LEFT); @@ -3551,7 +3551,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case WEAPONTYPE_FLAMETHROWER: m_sQueueSample.m_nSampleIndex = SFX_FLAMETHROWER_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 9; emittingVol = 90; m_sQueueSample.m_nFrequency = (10 * m_sQueueSample.m_nEntityIndex & 2047) + SampleManager.GetSampleBaseFrequency(SFX_FLAMETHROWER_LEFT); @@ -3614,7 +3614,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency += RandomDisplacement(300); - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = 30.0f; @@ -3631,7 +3631,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_WEAPON_UZI_BULLET_ECHO: case SOUND_WEAPON_M16_BULLET_ECHO: m_sQueueSample.m_nSampleIndex = SFX_UZI_END_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_UZI_END_LEFT); @@ -3654,7 +3654,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case SOUND_WEAPON_FLAMETHROWER_FIRE: m_sQueueSample.m_nSampleIndex = SFX_FLAMETHROWER_START_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; 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); @@ -3672,7 +3672,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case SOUND_WEAPON_HIT_PED: m_sQueueSample.m_nSampleIndex = SFX_BULLET_PED; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BULLET_PED); @@ -3691,7 +3691,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case SOUND_SPLASH: m_sQueueSample.m_nSampleIndex = SFX_SPLASH_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = RandomDisplacement(1400) + 20000; @@ -6279,7 +6279,7 @@ cPedComments::Process() 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 = SAMPLEBANK_PED; + AudioManager.m_sQueueSample.m_nBankIndex = SFX_BANK_PED_COMMENTS; AudioManager.m_sQueueSample.m_nReleasingVolumeModificator = 3; AudioManager.m_sQueueSample.m_nVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_bVolume; AudioManager.m_sQueueSample.m_fDistance = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_fDistance; @@ -6320,11 +6320,11 @@ cPedComments::Process() // Switch bank if (m_nActiveBank) { - actualUsedBank = SAMPLEBANK_PED; - m_nActiveBank = SAMPLEBANK_MAIN; + actualUsedBank = SFX_BANK_PED_COMMENTS; + m_nActiveBank = SFX_BANK_0; } else { - actualUsedBank = SAMPLEBANK_MAIN; - m_nActiveBank = SAMPLEBANK_PED; + actualUsedBank = SFX_BANK_0; + m_nActiveBank = SFX_BANK_PED_COMMENTS; } comment = m_asPedComments[actualUsedBank]; for (uint32 i = 0; i < m_nCommentsInBank[actualUsedBank]; i++) { @@ -6364,14 +6364,14 @@ cAudioManager::ProcessExplosions(int32 explosion) m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_2; m_sQueueSample.m_nFrequency = RandomDisplacement(2000) + 38000; m_sQueueSample.m_nReleasingVolumeModificator = 0; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; break; case EXPLOSION_MOLOTOV: m_sQueueSample.m_fSoundIntensity = 200.0f; m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_3; m_sQueueSample.m_nFrequency = RandomDisplacement(1000) + 19000; m_sQueueSample.m_nReleasingVolumeModificator = 0; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; break; case EXPLOSION_MINE: case EXPLOSION_HELI_BOMB: @@ -6379,7 +6379,7 @@ cAudioManager::ProcessExplosions(int32 explosion) m_sQueueSample.m_nSampleIndex = SFX_ROCKET_LEFT; m_sQueueSample.m_nFrequency = RandomDisplacement(1000) + 12347; m_sQueueSample.m_nReleasingVolumeModificator = 0; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; break; default: m_sQueueSample.m_fSoundIntensity = 400.0f; @@ -6388,7 +6388,7 @@ cAudioManager::ProcessExplosions(int32 explosion) if (type == EXPLOSION_HELI) m_sQueueSample.m_nFrequency = 8 * m_sQueueSample.m_nFrequency / 10; m_sQueueSample.m_nReleasingVolumeModificator = 0; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_EXTRAS; + m_sQueueSample.m_nBankIndex = SFX_BANK_GENERIC_EXTRA; break; } pos = CExplosion::GetExplosionPosition(i); @@ -6467,7 +6467,7 @@ cAudioManager::ProcessFires(int32) m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = i; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nReleasingVolumeDivider = 10; m_sQueueSample.m_bIs2D = false; @@ -6500,7 +6500,7 @@ cAudioManager::ProcessWaterCannon(int32) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = 15591; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_nCounter = i; @@ -6569,7 +6569,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_GATE_STOP_CLUNK: m_sQueueSample.m_fSoundIntensity = 40.0f; m_sQueueSample.m_nSampleIndex = SFX_COL_GATE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; if (sound == SCRIPT_SOUND_GATE_START_CLUNK) m_sQueueSample.m_nFrequency = 10600; else @@ -6585,7 +6585,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_BULLET_HIT_GROUND_3: m_sQueueSample.m_fSoundIntensity = 50.0f; m_sQueueSample.m_nSampleIndex = m_anRandomTable[iSound % 5] % 3 + SFX_BULLET_WALL_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + 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; @@ -6595,11 +6595,11 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) break; case SCRIPT_SOUND_TRAIN_ANNOUNCEMENT_1: case SCRIPT_SOUND_TRAIN_ANNOUNCEMENT_2: - if (!SampleManager.IsSampleBankLoaded(SAMPLEBANK_TRAIN)) + if (!SampleManager.IsSampleBankLoaded(SFX_BANK_TRAIN)) return; m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = SFX_TRAIN_STATION_ANNOUNCE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_TRAIN; + 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; @@ -6609,7 +6609,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_PAYPHONE_RINGING: m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = SFX_PHONE_RING; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; emittingVolume = 80; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_PHONE_RING); m_sQueueSample.m_nReleasingVolumeModificator = 1; @@ -6620,7 +6620,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_GLASS_BREAK_L: m_sQueueSample.m_fSoundIntensity = 60.0f; m_sQueueSample.m_nSampleIndex = SFX_GLASS_SMASH; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; emittingVolume = 70; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_SMASH); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6630,7 +6630,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_GLASS_BREAK_S: m_sQueueSample.m_fSoundIntensity = 60.0f; m_sQueueSample.m_nSampleIndex = SFX_GLASS_SMASH; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; emittingVolume = 60; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_SMASH); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6640,7 +6640,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_GLASS_CRACK: m_sQueueSample.m_fSoundIntensity = 60.0f; m_sQueueSample.m_nSampleIndex = SFX_GLASS_CRACK; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; emittingVolume = 70; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_CRACK); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6651,7 +6651,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_GLASS_LIGHT_BREAK: m_sQueueSample.m_fSoundIntensity = 55.0f; m_sQueueSample.m_nSampleIndex = (m_anRandomTable[4] & 3) + SFX_GLASS_SHARD_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = RandomDisplacement(2000) + 19000; m_sQueueSample.m_nReleasingVolumeModificator = 9; m_sQueueSample.m_fSpeedMultiplier = 0.0f; @@ -6661,7 +6661,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_BOX_DESTROYED_1: m_sQueueSample.m_fSoundIntensity = 60.0f; m_sQueueSample.m_nSampleIndex = SFX_WOODEN_BOX_SMASH; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = RandomDisplacement(1500) + 18600; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; @@ -6672,7 +6672,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_BOX_DESTROYED_2: m_sQueueSample.m_fSoundIntensity = 60.0f; m_sQueueSample.m_nSampleIndex = SFX_CARDBOARD_BOX_SMASH; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = RandomDisplacement(1500) + 18600; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; @@ -6683,7 +6683,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_METAL_COLLISION: m_sQueueSample.m_fSoundIntensity = 60.0f; m_sQueueSample.m_nSampleIndex = m_anRandomTable[3] % 5 + SFX_COL_CAR_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + 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; @@ -6695,7 +6695,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_TIRE_COLLISION: m_sQueueSample.m_fSoundIntensity = 60.0f; m_sQueueSample.m_nSampleIndex = SFX_TYRE_BUMP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + 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; @@ -6720,7 +6720,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 11000; m_sQueueSample.m_nReleasingVolumeModificator = 18; m_sQueueSample.m_fSoundIntensity = 20.0f; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = false; emittingVolume = m_anRandomTable[2] % 20 + 30; @@ -6750,7 +6750,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = RandomDisplacement(750) + 18000; m_sQueueSample.m_nReleasingVolumeModificator = 15; m_sQueueSample.m_fSoundIntensity = 20.0f; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = false; emittingVolume = m_anRandomTable[2] % 20 + 30; @@ -6760,7 +6760,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 11000; m_sQueueSample.m_nReleasingVolumeModificator = 18; m_sQueueSample.m_fSoundIntensity = 20.0f; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = false; emittingVolume = m_anRandomTable[2] % 20 + 30; @@ -6796,7 +6796,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_1_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6806,7 +6806,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_1_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6816,7 +6816,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_2_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_2; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6826,7 +6826,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_2_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_2; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6836,7 +6836,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_3_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_3; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6846,7 +6846,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_3_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_3; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6856,7 +6856,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_4_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_4; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6866,7 +6866,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_4_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_4; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6876,7 +6876,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_5_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_5; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6886,7 +6886,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_5_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_5; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6896,7 +6896,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_6_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_6; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6906,7 +6906,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_6_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_6; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6916,7 +6916,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_7_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_7; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6926,7 +6926,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_7_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_7; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6936,7 +6936,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_8_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_8; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6946,7 +6946,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_8_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_8; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6956,7 +6956,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_9_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_9; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6966,7 +6966,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_9_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_9; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6976,7 +6976,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_10_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_10; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6986,7 +6986,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_10_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_10; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -6996,7 +6996,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_11_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_11; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7006,7 +7006,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_11_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_11; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7016,7 +7016,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_12_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_12; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7026,7 +7026,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_12_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_12; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7036,7 +7036,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_13_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_RAGGA; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7046,7 +7046,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_13_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_RAGGA; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7056,7 +7056,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_STRIP_CLUB_LOOP_1_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7066,7 +7066,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_STRIP_CLUB_LOOP_1_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7076,7 +7076,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_STRIP_CLUB_LOOP_2_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_2; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7086,7 +7086,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_STRIP_CLUB_LOOP_2_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_2; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7104,7 +7104,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_38: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_DOG_FOOD_FACTORY; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7114,7 +7114,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_39: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_DOG_FOOD_FACTORY; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7128,7 +7128,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_CHINATOWN_RESTAURANT_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_CHINATOWN; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7138,7 +7138,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_CHINATOWN_RESTAURANT_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_CHINATOWN; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7148,7 +7148,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_CIPRIANI_RESAURANT_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_ITALY; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7158,7 +7158,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_CIPRIANI_RESAURANT_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_ITALY; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7168,7 +7168,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_46_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7178,7 +7178,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_47_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7188,7 +7188,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_MARCO_BISTRO_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_2; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7198,7 +7198,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_MARCO_BISTRO_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_2; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7228,7 +7228,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_FRANKIE_PIANO: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_PIANO_BAR_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_PIANO_BAR; + 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; @@ -7238,7 +7238,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_1_LOOP: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7258,7 +7258,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_BANK_ALARM_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_BANK_ALARM_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_BANK_ALARM; + 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; @@ -7268,7 +7268,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_BANK_ALARM_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_BANK_ALARM_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_BANK_ALARM; + 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; @@ -7278,7 +7278,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_POLICE_BALL_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_POLICE_BALL_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_POLICE_BALL; + 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; @@ -7288,7 +7288,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_POLICE_BALL_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_POLICE_BALL_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_POLICE_BALL; + 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; @@ -7298,7 +7298,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_RAVE_LOOP_INDUSTRIAL_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RAVE_INDUSTRIAL; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7308,7 +7308,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_RAVE_LOOP_INDUSTRIAL_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RAVE_INDUSTRIAL; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7323,7 +7323,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_RAVE_2_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RAVE_COMMERCIAL; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7334,7 +7334,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_RAVE_2_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RAVE_COMMERCIAL; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7344,7 +7344,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_RAVE_3_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RAVE_SUBURBAN; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7354,7 +7354,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_RAVE_3_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RAVE_SUBURBAN; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_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; @@ -7364,7 +7364,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PRETEND_FIRE_LOOP: m_sQueueSample.m_fSoundIntensity = 50.0f; m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; emittingVolume = 80; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE); m_sQueueSample.m_nReleasingVolumeModificator = 8; @@ -7407,38 +7407,38 @@ cAudioManager::ProcessPornCinema(uint8 sound) case SCRIPT_SOUND_PORN_CINEMA_1_S: case SCRIPT_SOUND_MISTY_SEX_S: m_sQueueSample.m_nSampleIndex = SFX_PORN_1_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_PORN_1; + m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_PORN_1; sample = SFX_PORN_1_GROAN_1; m_sQueueSample.m_fSoundIntensity = 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 = SAMPLEBANK_BUILDING_PORN_1; + m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_PORN_1; sample = SFX_PORN_1_GROAN_1; m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; break; case SCRIPT_SOUND_PORN_CINEMA_2_S: m_sQueueSample.m_nSampleIndex = SFX_PORN_2_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_PORN_2; + m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_PORN_2; sample = SFX_PORN_2_GROAN_1; m_sQueueSample.m_fSoundIntensity = 20.0f; break; case SCRIPT_SOUND_PORN_CINEMA_2_L: m_sQueueSample.m_nSampleIndex = SFX_PORN_2_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_PORN_2; + m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_PORN_2; sample = SFX_PORN_2_GROAN_1; m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; break; case SCRIPT_SOUND_PORN_CINEMA_3_S: m_sQueueSample.m_nSampleIndex = SFX_PORN_3_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_PORN_3; + m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_PORN_3; m_sQueueSample.m_fSoundIntensity = 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 = SAMPLEBANK_BUILDING_PORN_3; + m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_PORN_3; m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; sample = SFX_PORN_3_GROAN_1; break; @@ -7511,7 +7511,7 @@ cAudioManager::ProcessWorkShopScriptObject(uint8 sound) m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = SFX_WORKSHOP_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_WORKSHOP; + m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_WORKSHOP; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_WORKSHOP_1); m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = false; @@ -7550,7 +7550,7 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = SFX_SAWMILL_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_SAWMILL; + m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_SAWMILL; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SAWMILL_LOOP); m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = false; @@ -7570,7 +7570,7 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) m_sQueueSample.m_nVolume = ComputeVolume(70, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = SFX_SAWMILL_CUT_WOOD; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_SAWMILL; + m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_SAWMILL; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_bIs2D = false; @@ -7606,7 +7606,7 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) m_sQueueSample.m_nVolume = ComputeVolume(45, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = SFX_LAUNDERETTE_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_LAUNDERETTE; + m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_LAUNDERETTE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_LAUNDERETTE_LOOP); m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = false; @@ -7624,7 +7624,7 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) m_sQueueSample.m_nVolume = ComputeVolume(110, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = SFX_LAUNDERETTE_SONG_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_LAUNDERETTE; + m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_LAUNDERETTE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_LAUNDERETTE_SONG_LOOP); m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_bIs2D = false; @@ -7663,7 +7663,7 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = SFX_SHOP_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_SHOP; + m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_SHOP; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SHOP_LOOP); m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = false; @@ -7684,7 +7684,7 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) if (m_sQueueSample.m_nVolume != 0) { rand = m_anRandomTable[1] & 1; m_sQueueSample.m_nSampleIndex = rand + SFX_SHOP_TILL_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_SHOP; + m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_SHOP; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nCounter = rand + 1; m_sQueueSample.m_bIs2D = false; @@ -7727,7 +7727,7 @@ cAudioManager::ProcessAirportScriptObject(uint8 sound) m_sQueueSample.m_nVolume = ComputeVolume(110, m_sQueueSample.m_fSoundIntensity, 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 = SAMPLEBANK_BUILDING_AIRPORT; + m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_AIRPORT; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_bIs2D = false; @@ -7773,7 +7773,7 @@ cAudioManager::ProcessCinemaScriptObject(uint8 sound) m_sQueueSample.m_nVolume = ComputeVolume(rand, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = iSound % 3 + SFX_CINEMA_BASS_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CINEMA; + m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_CINEMA; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 4); m_sQueueSample.m_nCounter = iSound++; @@ -7822,7 +7822,7 @@ cAudioManager::ProcessDocksScriptObject(uint8 sound) m_sQueueSample.m_nVolume = ComputeVolume(rand, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = SFX_DOCKS_FOGHORN; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_DOCKS; + m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_DOCKS; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_DOCKS_FOGHORN); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 8); m_sQueueSample.m_nCounter = iSound++; @@ -7870,7 +7870,7 @@ cAudioManager::ProcessHomeScriptObject(uint8 sound) m_sQueueSample.m_nVolume = ComputeVolume(rand, m_sQueueSample.m_fSoundIntensity, 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 = SAMPLEBANK_BUILDING_HOME; + m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_HOME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); m_sQueueSample.m_nCounter = iSound++; @@ -7923,7 +7923,7 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound) emittingVol = m_anRandomTable[0] % 50 + 55; m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + 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_nCounter = iSound++; @@ -7958,12 +7958,12 @@ cAudioManager::ProcessWeather(int32 id) if (m_asAudioEntities[id].m_AudioEvents && m_asAudioEntities[id].m_awAudioEvent[0] == SOUND_LIGHTNING) { if (m_asAudioEntities[id].m_afVolume[0] >= 10.f) { m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_EXTRAS; + m_sQueueSample.m_nBankIndex = SFX_BANK_GENERIC_EXTRA; m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 4000; vol = (m_asAudioEntities[id].m_afVolume[0] - 10.f) + 40; } else { m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_2; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 4000; vol = (m_asAudioEntities[id].m_afVolume[0]) + 35; } @@ -7990,7 +7990,7 @@ cAudioManager::ProcessWeather(int32 id) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RAIN); m_sQueueSample.m_nVolume = (int32)(25.f * CWeather::Rain); m_sQueueSample.m_nCounter = 4; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nOffset = 63; m_sQueueSample.m_bIs2D = true; @@ -8170,7 +8170,7 @@ cAudioManager::ProcessFrontEnd() m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_nBankIndex = frontendBank ? SAMPLEBANK_FRONTEND : SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = frontendBank ? SFX_BANK_FRONT_END_MENU : SFX_BANK_0; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_bIs2D = true; m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume; @@ -8211,7 +8211,7 @@ cAudioManager::ProcessCrane() if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_CRANE_MAGNET; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 2; m_sQueueSample.m_nFrequency = 6000; @@ -8258,7 +8258,7 @@ cAudioManager::ProcessProjectiles() emittingVol = MAX_VOLUME; m_sQueueSample.m_fSoundIntensity = rocketLauncherIntensity; m_sQueueSample.m_nSampleIndex = SFX_ROCKET_FLY; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ROCKET_FLY); m_sQueueSample.m_nReleasingVolumeModificator = 3; break; @@ -8266,7 +8266,7 @@ cAudioManager::ProcessProjectiles() emittingVol = molotovVolume; m_sQueueSample.m_fSoundIntensity = molotovIntensity; m_sQueueSample.m_nSampleIndex = SFX_PED_ON_FIRE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = 32 * SampleManager.GetSampleBaseFrequency(SFX_PED_ON_FIRE) / 25; m_sQueueSample.m_nReleasingVolumeModificator = 7; break; @@ -8362,7 +8362,7 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_bReleasingSoundFlag = false; } - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nEmittingVolume = 90; @@ -8395,7 +8395,7 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_nSampleIndex = SFX_COL_GARAGE_DOOR_1; m_sQueueSample.m_nFrequency = 18000; } - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nReleasingVolumeModificator = 4; m_sQueueSample.m_nEmittingVolume = 60; m_sQueueSample.m_fSpeedMultiplier = 0.0f; @@ -8436,7 +8436,7 @@ cAudioManager::ProcessFireHydrant() if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 4; m_sQueueSample.m_nFrequency = 15591; @@ -8496,7 +8496,7 @@ cAudioManager::ProcessBridgeWarning() if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_BRIDGE_OPEN_WARNING; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_EXTRAS; + m_sQueueSample.m_nBankIndex = SFX_BANK_GENERIC_EXTRA; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BRIDGE_OPEN_WARNING); @@ -8523,7 +8523,7 @@ cAudioManager::ProcessBridgeMotor() 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 = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = 5500; @@ -8558,7 +8558,7 @@ cAudioManager::ProcessBridgeOneShots() m_sQueueSample.m_nVolume = ComputeVolume(MAX_VOLUME, bridgeIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 2; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 58483602..028df85e 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -86,7 +86,7 @@ cAudioManager::Terminate() m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal = 0; PreTerminateGameSpecificShutdown(); - for (uint32 i = 0; i < MAX_SAMPLEBANKS; i++) { + for (uint32 i = 0; i < MAX_SFX_BANKS; i++) { if (SampleManager.IsSampleBankLoaded(i)) SampleManager.UnloadSampleBank(i); } @@ -917,7 +917,7 @@ cAudioManager::ClearActiveSamples() m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE; m_asActiveSamples[i].m_nCounter = 0; m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE; - m_asActiveSamples[i].m_nBankIndex = SAMPLEBANK_INVALID; + m_asActiveSamples[i].m_nBankIndex = INVALID_SFX_BANK; m_asActiveSamples[i].m_bIs2D = false; m_asActiveSamples[i].m_nReleasingVolumeModificator = 5; m_asActiveSamples[i].m_nFrequency = 0; diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 9f648d07..e4392aa9 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -26,12 +26,12 @@ cMusicManager::cMusicManager() m_bIsInitialised = false; m_bDisabled = false; m_nMusicMode = MUSICMODE_DISABLED; - m_nCurrentStreamedSound = NO_STREAMED_SOUND; - m_nPreviousStreamedSound = NO_STREAMED_SOUND; + m_nCurrentStreamedSound = NO_TRACK; + m_nPreviousStreamedSound = NO_TRACK; m_bFrontendTrackFinished = false; m_bPlayInFrontend = false; m_bSetNextStation = false; - m_nAnnouncement = NO_STREAMED_SOUND; + m_nAnnouncement = NO_TRACK; m_bPreviousPlayerInCar = false; m_bPlayerInCar = false; m_bAnnouncementInProgress = false; @@ -224,7 +224,7 @@ cMusicManager::Initialise() m_bRadioSetByScript = false; m_nRadioStation = HEAD_RADIO; m_nRadioPosition = -1; - m_nRadioInCar = NO_STREAMED_SOUND; + m_nRadioInCar = NO_TRACK; gNumRetunePresses = 0; gRetuneCounter = 0; m_bIsInitialised = true; @@ -239,8 +239,8 @@ cMusicManager::Terminate() if (SampleManager.IsStreamPlaying(0)) { SampleManager.StopStreamedFile(0); - m_nCurrentStreamedSound = NO_STREAMED_SOUND; - m_nPreviousStreamedSound = NO_STREAMED_SOUND; + m_nCurrentStreamedSound = NO_TRACK; + m_nPreviousStreamedSound = NO_TRACK; } m_bIsInitialised = false; } @@ -274,8 +274,8 @@ cMusicManager::ChangeMusicMode(uint8 mode) } SampleManager.StopStreamedFile(0); } - m_nCurrentStreamedSound = NO_STREAMED_SOUND; - m_nPreviousStreamedSound = NO_STREAMED_SOUND; + m_nCurrentStreamedSound = NO_TRACK; + m_nPreviousStreamedSound = NO_TRACK; m_bFrontendTrackFinished = false; m_bPlayInFrontend = false; m_bSetNextStation = false; @@ -301,14 +301,14 @@ cMusicManager::GetRadioInCar(void) CVehicle *veh = FindPlayerVehicle(); if (veh != nil){ if (UsesPoliceRadio(veh)) { - if (m_nRadioInCar == NO_STREAMED_SOUND || (CReplay::IsPlayingBack() && AudioManager.m_nUserPause == 0)) + if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && AudioManager.m_nUserPause == 0)) return POLICE_RADIO; return m_nRadioInCar; } else return veh->m_nRadioStation; } } - if (m_nRadioInCar == NO_STREAMED_SOUND || (CReplay::IsPlayingBack() && AudioManager.m_nUserPause == 0)) + if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && AudioManager.m_nUserPause == 0)) return RADIO_OFF; return m_nRadioInCar; } @@ -347,7 +347,7 @@ cMusicManager::ResetMusicAfterReload() m_bRadioSetByScript = false; m_nRadioStation = 0; m_nRadioPosition = -1; - m_nAnnouncement = NO_STREAMED_SOUND; + m_nAnnouncement = NO_TRACK; m_bAnnouncementInProgress = false; m_bSetNextStation = false; gRetuneCounter = 0; @@ -384,7 +384,7 @@ cMusicManager::Service() m_nLastTrackServiceTime = m_nTimer; } else m_bDoTrackService = false; - if (m_nCurrentStreamedSound == NO_STREAMED_SOUND && SampleManager.IsStreamPlaying(0)) + if (m_nCurrentStreamedSound == NO_TRACK && SampleManager.IsStreamPlaying(0)) SampleManager.StopStreamedFile(0); else switch (m_nMusicMode) { case MUSICMODE_FRONTEND: ServiceFrontEndMode(); break; @@ -410,8 +410,8 @@ cMusicManager::ServiceFrontEndMode() default: break; } - m_nCurrentStreamedSound = NO_STREAMED_SOUND; - m_nPreviousStreamedSound = NO_STREAMED_SOUND; + m_nCurrentStreamedSound = NO_TRACK; + m_nPreviousStreamedSound = NO_TRACK; } } else if (bHasStarted) { if (!SampleManager.IsStreamPlaying(0)) @@ -516,7 +516,7 @@ cMusicManager::ServiceGameMode() m_bPlayerInCar = false; if (FindPlayerVehicle()) FindPlayerVehicle()->m_nRadioStation = m_nCurrentStreamedSound; - m_nCurrentStreamedSound = NO_STREAMED_SOUND; + m_nCurrentStreamedSound = NO_TRACK; } if (CTimer::GetIsSlowMotionActive()) { if (TheCamera.pTargetEntity != nil) { @@ -585,7 +585,7 @@ cMusicManager::ServiceGameMode() } else { m_nCurrentStreamedSound = m_nRadioStation; if (FindPlayerVehicle()->m_nRadioStation == m_nCurrentStreamedSound) { - m_nPreviousStreamedSound = NO_STREAMED_SOUND; + m_nPreviousStreamedSound = NO_TRACK; SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0); SampleManager.StopStreamedFile(0); } @@ -608,19 +608,19 @@ cMusicManager::ServiceGameMode() } } else { m_bPlayerInCar = false; - m_nCurrentStreamedSound = NO_STREAMED_SOUND; + m_nCurrentStreamedSound = NO_TRACK; } } void cMusicManager::StopFrontEndTrack() { - if (IsInitialised() && !m_bDisabled && m_nMusicMode == MUSICMODE_FRONTEND && m_nCurrentStreamedSound != NO_STREAMED_SOUND) { + if (IsInitialised() && !m_bDisabled && m_nMusicMode == MUSICMODE_FRONTEND && m_nCurrentStreamedSound != NO_TRACK) { m_aTracks[m_nCurrentStreamedSound].m_nPosition = SampleManager.GetStreamedFilePosition(0); m_aTracks[m_nCurrentStreamedSound].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); SampleManager.StopStreamedFile(0); - m_nPreviousStreamedSound = NO_STREAMED_SOUND; - m_nCurrentStreamedSound = NO_STREAMED_SOUND; + m_nPreviousStreamedSound = NO_TRACK; + m_nCurrentStreamedSound = NO_TRACK; } } @@ -636,9 +636,9 @@ cMusicManager::PlayFrontEndTrack(uint8 track, uint8 bPlayInFrontend) { if (IsInitialised() && !m_bDisabled && track < TOTAL_STREAMED_SOUNDS) { if (m_nMusicMode == MUSICMODE_GAME) { - if (m_nCurrentStreamedSound != NO_STREAMED_SOUND) { + if (m_nCurrentStreamedSound != NO_TRACK) { if (m_bAnnouncementInProgress) { - m_nAnnouncement = NO_STREAMED_SOUND; + m_nAnnouncement = NO_TRACK; m_bAnnouncementInProgress = false; } m_aTracks[m_nCurrentStreamedSound].m_nPosition = SampleManager.GetStreamedFilePosition(0); @@ -646,7 +646,7 @@ cMusicManager::PlayFrontEndTrack(uint8 track, uint8 bPlayInFrontend) } SampleManager.StopStreamedFile(0); } else if (m_nMusicMode == MUSICMODE_FRONTEND) { - if (m_nCurrentStreamedSound != NO_STREAMED_SOUND) { + if (m_nCurrentStreamedSound != NO_TRACK) { m_aTracks[m_nCurrentStreamedSound].m_nPosition = SampleManager.GetStreamedFilePosition(0); m_aTracks[m_nCurrentStreamedSound].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); } @@ -691,7 +691,7 @@ cMusicManager::StopCutSceneMusic(void) { if (IsInitialised() && !m_bDisabled && m_nMusicMode == MUSICMODE_CUTSCENE) { SampleManager.StopStreamedFile(0); - m_nCurrentStreamedSound = NO_STREAMED_SOUND; + m_nCurrentStreamedSound = NO_TRACK; } } @@ -733,7 +733,7 @@ cMusicManager::ServiceAmbience() uint8 volume; if (m_bAnnouncementInProgress) { - m_nAnnouncement = NO_STREAMED_SOUND; + m_nAnnouncement = NO_TRACK; m_bAnnouncementInProgress = false; } if (m_nCurrentStreamedSound < STREAMED_SOUND_CITY_AMBIENT) { @@ -741,13 +741,13 @@ cMusicManager::ServiceAmbience() m_aTracks[m_nCurrentStreamedSound].m_nPosition = SampleManager.GetStreamedFilePosition(0); m_aTracks[m_nCurrentStreamedSound].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); SampleManager.StopStreamedFile(0); - m_nCurrentStreamedSound = NO_STREAMED_SOUND; + m_nCurrentStreamedSound = NO_TRACK; return; } m_nCurrentStreamedSound = STREAMED_SOUND_CITY_AMBIENT; } if (CWorld::Players[CWorld::PlayerInFocus].m_WBState != WBSTATE_PLAYING && !SampleManager.IsStreamPlaying(0)) { - m_nCurrentStreamedSound = NO_STREAMED_SOUND; + m_nCurrentStreamedSound = NO_TRACK; return; } @@ -774,7 +774,7 @@ cMusicManager::ServiceAmbience() SampleManager.SetStreamedVolumeAndPan(volume, 63, 1, 0); m_bDontServiceAmbienceTrack = true; } else - m_nCurrentStreamedSound = NO_STREAMED_SOUND; + m_nCurrentStreamedSound = NO_TRACK; } } @@ -813,7 +813,7 @@ cMusicManager::ServiceAnnouncement() static int8 cCheck = 0; if (m_bAnnouncementInProgress) { if (!SampleManager.IsStreamPlaying(0)) { - m_nAnnouncement = NO_STREAMED_SOUND; + m_nAnnouncement = NO_TRACK; m_bAnnouncementInProgress = false; } return true; @@ -823,7 +823,7 @@ cMusicManager::ServiceAnnouncement() cCheck = 0; int pos = SampleManager.GetStreamedFilePosition(0); if (SampleManager.IsStreamPlaying(0)) { - if (m_nCurrentStreamedSound != NO_STREAMED_SOUND) { + if (m_nCurrentStreamedSound != NO_TRACK) { m_aTracks[m_nCurrentStreamedSound].m_nPosition = pos; m_aTracks[m_nCurrentStreamedSound].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); SampleManager.StopStreamedFile(0); diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PoliceRadio.cpp index af346479..4d0f8909 100644 --- a/src/audio/PoliceRadio.cpp +++ b/src/audio/PoliceRadio.cpp @@ -129,7 +129,7 @@ cAudioManager::DoPoliceRadioCrackle() m_sQueueSample.m_nEntityIndex = m_nPoliceChannelEntity; m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_POLICE_RADIO_CRACKLE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = true; m_sQueueSample.m_nReleasingVolumeModificator = 10; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_POLICE_RADIO_CRACKLE); diff --git a/src/audio/audio_enums.h b/src/audio/audio_enums.h index 3b996205..20760859 100644 --- a/src/audio/audio_enums.h +++ b/src/audio/audio_enums.h @@ -224,7 +224,7 @@ enum eStreamedSounds STREAMED_SOUND_MISSION_K1_B, STREAMED_SOUND_MISSION_CAT1, TOTAL_STREAMED_SOUNDS, - NO_STREAMED_SOUND, + NO_TRACK, }; enum AudioEntityHandle { diff --git a/src/audio/sampman.h b/src/audio/sampman.h index 9a94e16f..d4b2621a 100644 --- a/src/audio/sampman.h +++ b/src/audio/sampman.h @@ -16,83 +16,83 @@ struct tSample { #ifdef GTA_PS2 #define PS2BANK(e) e #else -#define PS2BANK(e) e = SAMPLEBANK_MAIN +#define PS2BANK(e) e = SFX_BANK_0 #endif // GTA_PS2 enum { - SAMPLEBANK_MAIN, + SFX_BANK_0, - CAR_SAMPLEBANKS_OFFSET, - SAMPLEBANK_CAR_PACARD = CAR_SAMPLEBANKS_OFFSET, - SAMPLEBANK_CAR_PATHFINDER, - SAMPLEBANK_CAR_PORSCHE, - SAMPLEBANK_CAR_SPIDER, - SAMPLEBANK_CAR_MERC, - SAMPLEBANK_CAR_MACKTRUCK, - SAMPLEBANK_CAR_HOTROD, - SAMPLEBANK_CAR_COBRA, - SAMPLEBANK_CAR_NONE, + CAR_SFX_BANKS_OFFSET, + SFX_BANK_PACARD = CAR_SFX_BANKS_OFFSET, + SFX_BANK_PATHFINDER, + SFX_BANK_PORSCHE, + SFX_BANK_SPIDER, + SFX_BANK_MERC, + SFX_BANK_TRUCK, + SFX_BANK_HOTROD, + SFX_BANK_COBRA, + SFX_BANK_NONE, - PS2BANK(SAMPLEBANK_FRONTEND), + PS2BANK(SFX_BANK_FRONT_END_MENU), - PS2BANK(SAMPLEBANK_TRAIN), + PS2BANK(SFX_BANK_TRAIN), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_1), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_2), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_3), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_4), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_5), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_6), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_7), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_8), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_9), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_10), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_11), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_12), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_RAGGA), - PS2BANK(SAMPLEBANK_BUILDING_STRIP_CLUB_1), - PS2BANK(SAMPLEBANK_BUILDING_STRIP_CLUB_2), - PS2BANK(SAMPLEBANK_BUILDING_WORKSHOP), - PS2BANK(SAMPLEBANK_BUILDING_PIANO_BAR), - PS2BANK(SAMPLEBANK_BUILDING_SAWMILL), - PS2BANK(SAMPLEBANK_BUILDING_DOG_FOOD_FACTORY), - PS2BANK(SAMPLEBANK_BUILDING_LAUNDERETTE), - PS2BANK(SAMPLEBANK_BUILDING_RESTAURANT_CHINATOWN), - PS2BANK(SAMPLEBANK_BUILDING_RESTAURANT_ITALY), - PS2BANK(SAMPLEBANK_BUILDING_RESTAURANT_GENERIC_1), - PS2BANK(SAMPLEBANK_BUILDING_RESTAURANT_GENERIC_2), - PS2BANK(SAMPLEBANK_BUILDING_AIRPORT), - PS2BANK(SAMPLEBANK_BUILDING_SHOP), - PS2BANK(SAMPLEBANK_BUILDING_CINEMA), - PS2BANK(SAMPLEBANK_BUILDING_DOCKS), - PS2BANK(SAMPLEBANK_BUILDING_HOME), - PS2BANK(SAMPLEBANK_BUILDING_PORN_1), - PS2BANK(SAMPLEBANK_BUILDING_PORN_2), - PS2BANK(SAMPLEBANK_BUILDING_PORN_3), - PS2BANK(SAMPLEBANK_BUILDING_POLICE_BALL), - PS2BANK(SAMPLEBANK_BUILDING_BANK_ALARM), - PS2BANK(SAMPLEBANK_BUILDING_RAVE_INDUSTRIAL), - PS2BANK(SAMPLEBANK_BUILDING_RAVE_COMMERCIAL), - PS2BANK(SAMPLEBANK_BUILDING_RAVE_SUBURBAN), - PS2BANK(SAMPLEBANK_BUILDING_RAVE_COMMERCIAL_2), + PS2BANK(SFX_BANK_BUILDING_CLUB_1), + PS2BANK(SFX_BANK_BUILDING_CLUB_2), + PS2BANK(SFX_BANK_BUILDING_CLUB_3), + PS2BANK(SFX_BANK_BUILDING_CLUB_4), + PS2BANK(SFX_BANK_BUILDING_CLUB_5), + PS2BANK(SFX_BANK_BUILDING_CLUB_6), + PS2BANK(SFX_BANK_BUILDING_CLUB_7), + PS2BANK(SFX_BANK_BUILDING_CLUB_8), + PS2BANK(SFX_BANK_BUILDING_CLUB_9), + PS2BANK(SFX_BANK_BUILDING_CLUB_10), + PS2BANK(SFX_BANK_BUILDING_CLUB_11), + PS2BANK(SFX_BANK_BUILDING_CLUB_12), + PS2BANK(SFX_BANK_BUILDING_CLUB_RAGGA), + PS2BANK(SFX_BANK_BUILDING_STRIP_CLUB_1), + PS2BANK(SFX_BANK_BUILDING_STRIP_CLUB_2), + PS2BANK(SFX_BANK_BUILDING_WORKSHOP), + PS2BANK(SFX_BANK_BUILDING_PIANO_BAR), + PS2BANK(SFX_BANK_BUILDING_SAWMILL), + PS2BANK(SFX_BANK_BUILDING_DOG_FOOD_FACTORY), + PS2BANK(SFX_BANK_BUILDING_LAUNDERETTE), + PS2BANK(SFX_BANK_BUILDING_RESTAURANT_CHINATOWN), + PS2BANK(SFX_BANK_BUILDING_RESTAURANT_ITALY), + PS2BANK(SFX_BANK_BUILDING_RESTAURANT_GENERIC_1), + PS2BANK(SFX_BANK_BUILDING_RESTAURANT_GENERIC_2), + PS2BANK(SFX_BANK_BUILDING_AIRPORT), + PS2BANK(SFX_BANK_BUILDING_SHOP), + PS2BANK(SFX_BANK_BUILDING_CINEMA), + PS2BANK(SFX_BANK_BUILDING_DOCKS), + PS2BANK(SFX_BANK_BUILDING_HOME), + PS2BANK(SFX_BANK_BUILDING_PORN_1), + PS2BANK(SFX_BANK_BUILDING_PORN_2), + PS2BANK(SFX_BANK_BUILDING_PORN_3), + PS2BANK(SFX_BANK_BUILDING_POLICE_BALL), + PS2BANK(SFX_BANK_BUILDING_BANK_ALARM), + PS2BANK(SFX_BANK_BUILDING_RAVE_INDUSTRIAL), + PS2BANK(SFX_BANK_BUILDING_RAVE_COMMERCIAL), + PS2BANK(SFX_BANK_BUILDING_RAVE_SUBURBAN), + PS2BANK(SFX_BANK_BUILDING_RAVE_COMMERCIAL_2), - PS2BANK(SAMPLEBANK_BUILDING_39), - PS2BANK(SAMPLEBANK_BUILDING_40), - PS2BANK(SAMPLEBANK_BUILDING_41), - PS2BANK(SAMPLEBANK_BUILDING_42), - PS2BANK(SAMPLEBANK_BUILDING_43), - PS2BANK(SAMPLEBANK_BUILDING_44), - PS2BANK(SAMPLEBANK_BUILDING_45), - PS2BANK(SAMPLEBANK_BUILDING_46), - PS2BANK(SAMPLEBANK_BUILDING_47), + PS2BANK(SFX_BANK_BUILDING_39), + PS2BANK(SFX_BANK_BUILDING_40), + PS2BANK(SFX_BANK_BUILDING_41), + PS2BANK(SFX_BANK_BUILDING_42), + PS2BANK(SFX_BANK_BUILDING_43), + PS2BANK(SFX_BANK_BUILDING_44), + PS2BANK(SFX_BANK_BUILDING_45), + PS2BANK(SFX_BANK_BUILDING_46), + PS2BANK(SFX_BANK_BUILDING_47), - PS2BANK(SAMPLEBANK_EXTRAS), + PS2BANK(SFX_BANK_GENERIC_EXTRA), - SAMPLEBANK_PED, - MAX_SAMPLEBANKS, - SAMPLEBANK_INVALID + SFX_BANK_PED_COMMENTS, + MAX_SFX_BANKS, + INVALID_SFX_BANK }; #define MAX_PEDSFX 7 @@ -216,7 +216,7 @@ public: }; extern cSampleManager SampleManager; -extern uint32 BankStartOffset[MAX_SAMPLEBANKS]; +extern uint32 BankStartOffset[MAX_SFX_BANKS]; #ifdef AUDIO_OPUS static char StreamedNameTable[][25] = { diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index 098b6efa..70ea942e 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -21,7 +21,7 @@ #pragma comment( lib, "mss32.lib" ) cSampleManager SampleManager; -uint32 BankStartOffset[MAX_SAMPLEBANKS]; +uint32 BankStartOffset[MAX_SFX_BANKS]; /////////////////////////////////////////////////////////////// char SampleBankDescFilename[] = "AUDIO\\SFX.SDT"; @@ -29,10 +29,10 @@ char SampleBankDataFilename[] = "AUDIO\\SFX.RAW"; FILE *fpSampleDescHandle; FILE *fpSampleDataHandle; -bool bSampleBankLoaded [MAX_SAMPLEBANKS]; -int32 nSampleBankDiscStartOffset [MAX_SAMPLEBANKS]; -int32 nSampleBankSize [MAX_SAMPLEBANKS]; -int32 nSampleBankMemoryStartAddress[MAX_SAMPLEBANKS]; +bool bSampleBankLoaded [MAX_SFX_BANKS]; +int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS]; +int32 nSampleBankSize [MAX_SFX_BANKS]; +int32 nSampleBankMemoryStartAddress[MAX_SFX_BANKS]; int32 _nSampleDataEndOffset; int32 nPedSlotSfx [MAX_PEDSFX]; @@ -896,7 +896,7 @@ cSampleManager::Initialise(void) _nSampleDataEndOffset = 0; - for ( int32 i = 0; i < MAX_SAMPLEBANKS; i++ ) + for ( int32 i = 0; i < MAX_SFX_BANKS; i++ ) { bSampleBankLoaded[i] = false; nSampleBankDiscStartOffset[i] = 0; @@ -948,14 +948,14 @@ cSampleManager::Initialise(void) return false; } - nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = (int32)AIL_mem_alloc_lock(nSampleBankSize[SAMPLEBANK_MAIN]); - if ( !nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] ) + nSampleBankMemoryStartAddress[SFX_BANK_0] = (int32)AIL_mem_alloc_lock(nSampleBankSize[SFX_BANK_0]); + if ( !nSampleBankMemoryStartAddress[SFX_BANK_0] ) { Terminate(); return false; } - nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = (int32)AIL_mem_alloc_lock(PED_BLOCKSIZE*MAX_PEDSFX); + nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (int32)AIL_mem_alloc_lock(PED_BLOCKSIZE*MAX_PEDSFX); } @@ -1176,7 +1176,7 @@ cSampleManager::Initialise(void) TRACE("bank"); - LoadSampleBank(SAMPLEBANK_MAIN); + LoadSampleBank(SFX_BANK_0); // mp3 TRACE("mp3"); @@ -1271,16 +1271,16 @@ cSampleManager::Terminate(void) _DeleteMP3Entries(); - if ( nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] != 0 ) + if ( nSampleBankMemoryStartAddress[SFX_BANK_0] != 0 ) { - AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN]); - nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = 0; + AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SFX_BANK_0]); + nSampleBankMemoryStartAddress[SFX_BANK_0] = 0; } - if ( nSampleBankMemoryStartAddress[SAMPLEBANK_PED] != 0 ) + if ( nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0 ) { - AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SAMPLEBANK_PED]); - nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = 0; + AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]); + nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0; } if ( DIG ) @@ -1429,7 +1429,7 @@ cSampleManager::LoadSampleBank(uint8 nBank) if ( MusicManager.IsInitialised() && MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE - && nBank != SAMPLEBANK_MAIN ) + && nBank != SFX_BANK_0 ) { return false; } @@ -1526,10 +1526,10 @@ cSampleManager::LoadPedComment(uint32 nComment) if ( fseek(fpSampleDataHandle, m_aSamples[nComment].nOffset, SEEK_SET) != 0 ) return false; - if ( fread((void *)(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) + if ( fread((void *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) return false; - nPedSlotSfxAddr[nCurrentPedSlot] = nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE*nCurrentPedSlot; + nPedSlotSfxAddr[nCurrentPedSlot] = nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot; nPedSlotSfx [nCurrentPedSlot] = nComment; if ( ++nCurrentPedSlot >= MAX_PEDSFX ) @@ -1541,13 +1541,13 @@ cSampleManager::LoadPedComment(uint32 nComment) int32 cSampleManager::GetBankContainingSound(uint32 offset) { - if ( offset >= BankStartOffset[SAMPLEBANK_PED] ) - return SAMPLEBANK_PED; + if ( offset >= BankStartOffset[SFX_BANK_PED_COMMENTS] ) + return SFX_BANK_PED_COMMENTS; - if ( offset >= BankStartOffset[SAMPLEBANK_MAIN] ) - return SAMPLEBANK_MAIN; + if ( offset >= BankStartOffset[SFX_BANK_0] ) + return SFX_BANK_0; - return SAMPLEBANK_INVALID; + return INVALID_SFX_BANK; } int32 @@ -2289,7 +2289,7 @@ cSampleManager::IsStreamPlaying(uint8 nStream) bool cSampleManager::InitialiseSampleBanks(void) { - int32 nBank = SAMPLEBANK_MAIN; + int32 nBank = SFX_BANK_0; fpSampleDescHandle = fopen(SampleBankDescFilename, "rb"); if ( fpSampleDescHandle == NULL ) @@ -2316,17 +2316,17 @@ cSampleManager::InitialiseSampleBanks(void) for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) { #ifdef FIX_BUGS - if (nBank >= MAX_SAMPLEBANKS) break; + if (nBank >= MAX_SFX_BANKS) break; #endif - if ( BankStartOffset[nBank] == BankStartOffset[SAMPLEBANK_MAIN] + i ) + if ( BankStartOffset[nBank] == BankStartOffset[SFX_BANK_0] + i ) { nSampleBankDiscStartOffset[nBank] = m_aSamples[i].nOffset; nBank++; } } - nSampleBankSize[SAMPLEBANK_MAIN] = nSampleBankDiscStartOffset[SAMPLEBANK_PED] - nSampleBankDiscStartOffset[SAMPLEBANK_MAIN]; - nSampleBankSize[SAMPLEBANK_PED] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SAMPLEBANK_PED]; + nSampleBankSize[SFX_BANK_0] = nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - nSampleBankDiscStartOffset[SFX_BANK_0]; + nSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS]; return true; } diff --git a/src/audio/sampman_null.cpp b/src/audio/sampman_null.cpp index 6ec8a521..e44e5b57 100644 --- a/src/audio/sampman_null.cpp +++ b/src/audio/sampman_null.cpp @@ -6,7 +6,7 @@ cSampleManager SampleManager; bool _bSampmanInitialised = false; -uint32 BankStartOffset[MAX_SAMPLEBANKS]; +uint32 BankStartOffset[MAX_SFX_BANKS]; uint32 nNumMP3s; cSampleManager::cSampleManager(void) @@ -131,20 +131,20 @@ cSampleManager::SetMonoMode(uint8 nMode) bool cSampleManager::LoadSampleBank(uint8 nBank) { - ASSERT( nBank < MAX_SAMPLEBANKS ); + ASSERT( nBank < MAX_SFX_BANKS ); return false; } void cSampleManager::UnloadSampleBank(uint8 nBank) { - ASSERT( nBank < MAX_SAMPLEBANKS ); + ASSERT( nBank < MAX_SFX_BANKS ); } bool cSampleManager::IsSampleBankLoaded(uint8 nBank) { - ASSERT( nBank < MAX_SAMPLEBANKS ); + ASSERT( nBank < MAX_SFX_BANKS ); return false; } @@ -174,7 +174,7 @@ cSampleManager::LoadPedComment(uint32 nComment) int32 cSampleManager::GetBankContainingSound(uint32 offset) { - return SAMPLEBANK_INVALID; + return INVALID_SFX_BANK; } int32 diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index a8056c03..b10aa1ff 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -43,7 +43,7 @@ cSampleManager SampleManager; bool _bSampmanInitialised = false; -uint32 BankStartOffset[MAX_SAMPLEBANKS]; +uint32 BankStartOffset[MAX_SFX_BANKS]; int prevprovider=-1; int curprovider=-1; @@ -77,10 +77,10 @@ OggOpusFile *fpSampleDataHandle; #else FILE *fpSampleDataHandle; #endif -bool bSampleBankLoaded [MAX_SAMPLEBANKS]; -int32 nSampleBankDiscStartOffset [MAX_SAMPLEBANKS]; -int32 nSampleBankSize [MAX_SAMPLEBANKS]; -uintptr nSampleBankMemoryStartAddress[MAX_SAMPLEBANKS]; +bool bSampleBankLoaded [MAX_SFX_BANKS]; +int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS]; +int32 nSampleBankSize [MAX_SFX_BANKS]; +uintptr nSampleBankMemoryStartAddress[MAX_SFX_BANKS]; int32 _nSampleDataEndOffset; int32 nPedSlotSfx [MAX_PEDSFX]; @@ -541,7 +541,7 @@ cSampleManager::Initialise(void) fpSampleDescHandle = NULL; fpSampleDataHandle = NULL; - for ( int32 i = 0; i < MAX_SAMPLEBANKS; i++ ) + for ( int32 i = 0; i < MAX_SFX_BANKS; i++ ) { bSampleBankLoaded[i] = false; nSampleBankDiscStartOffset[i] = 0; @@ -586,17 +586,17 @@ cSampleManager::Initialise(void) return false; } - nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = (uintptr)malloc(nSampleBankSize[SAMPLEBANK_MAIN]); - ASSERT(nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] != 0); + nSampleBankMemoryStartAddress[SFX_BANK_0] = (uintptr)malloc(nSampleBankSize[SFX_BANK_0]); + ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_0] != 0); - if ( nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] == 0 ) + if ( nSampleBankMemoryStartAddress[SFX_BANK_0] == 0 ) { Terminate(); return false; } - nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX); - ASSERT(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] != 0); + nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX); + ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0); } @@ -644,7 +644,7 @@ cSampleManager::Initialise(void) #endif } - LoadSampleBank(SAMPLEBANK_MAIN); + LoadSampleBank(SFX_BANK_0); return true; } @@ -666,16 +666,16 @@ cSampleManager::Terminate(void) CStream::Terminate(); - if ( nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] != 0 ) + if ( nSampleBankMemoryStartAddress[SFX_BANK_0] != 0 ) { - free((void *)nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN]); - nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = 0; + free((void *)nSampleBankMemoryStartAddress[SFX_BANK_0]); + nSampleBankMemoryStartAddress[SFX_BANK_0] = 0; } - if ( nSampleBankMemoryStartAddress[SAMPLEBANK_PED] != 0 ) + if ( nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0 ) { - free((void *)nSampleBankMemoryStartAddress[SAMPLEBANK_PED]); - nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = 0; + free((void *)nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]); + nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0; } _bSampmanInitialised = false; @@ -751,14 +751,14 @@ cSampleManager::SetMonoMode(uint8 nMode) bool cSampleManager::LoadSampleBank(uint8 nBank) { - ASSERT( nBank < MAX_SAMPLEBANKS ); + ASSERT( nBank < MAX_SFX_BANKS ); if ( CTimer::GetIsCodePaused() ) return false; if ( MusicManager.IsInitialised() && MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE - && nBank != SAMPLEBANK_MAIN ) + && nBank != SFX_BANK_0 ) { return false; } @@ -792,7 +792,7 @@ cSampleManager::LoadSampleBank(uint8 nBank) void cSampleManager::UnloadSampleBank(uint8 nBank) { - ASSERT( nBank < MAX_SAMPLEBANKS ); + ASSERT( nBank < MAX_SFX_BANKS ); bSampleBankLoaded[nBank] = false; } @@ -800,7 +800,7 @@ cSampleManager::UnloadSampleBank(uint8 nBank) bool cSampleManager::IsSampleBankLoaded(uint8 nBank) { - ASSERT( nBank < MAX_SAMPLEBANKS ); + ASSERT( nBank < MAX_SFX_BANKS ); return bSampleBankLoaded[nBank]; } @@ -881,7 +881,7 @@ cSampleManager::LoadPedComment(uint32 nComment) int samplesSize = m_aSamples[nComment].nSize / 2; op_pcm_seek(fpSampleDataHandle, m_aSamples[nComment].nOffset / 2); while (samplesSize > 0) { - int size = op_read(fpSampleDataHandle, (opus_int16 *)(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE * nCurrentPedSlot + samplesRead), + int size = op_read(fpSampleDataHandle, (opus_int16 *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE * nCurrentPedSlot + samplesRead), samplesSize, NULL); if (size <= 0) { return false; @@ -893,7 +893,7 @@ cSampleManager::LoadPedComment(uint32 nComment) if ( fseek(fpSampleDataHandle, m_aSamples[nComment].nOffset, SEEK_SET) != 0 ) return false; - if ( fread((void *)(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) + if ( fread((void *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) return false; #endif @@ -901,7 +901,7 @@ cSampleManager::LoadPedComment(uint32 nComment) alBufferData(pedBuffers[nCurrentPedSlot], AL_FORMAT_MONO16, - (void *)(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE*nCurrentPedSlot), + (void *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot), m_aSamples[nComment].nSize, m_aSamples[nComment].nFrequency); @@ -914,13 +914,13 @@ cSampleManager::LoadPedComment(uint32 nComment) int32 cSampleManager::GetBankContainingSound(uint32 offset) { - if ( offset >= BankStartOffset[SAMPLEBANK_PED] ) - return SAMPLEBANK_PED; + if ( offset >= BankStartOffset[SFX_BANK_PED_COMMENTS] ) + return SFX_BANK_PED_COMMENTS; - if ( offset >= BankStartOffset[SAMPLEBANK_MAIN] ) - return SAMPLEBANK_MAIN; + if ( offset >= BankStartOffset[SFX_BANK_0] ) + return SFX_BANK_0; - return SAMPLEBANK_INVALID; + return INVALID_SFX_BANK; } int32 @@ -1421,7 +1421,7 @@ cSampleManager::Service(void) bool cSampleManager::InitialiseSampleBanks(void) { - int32 nBank = SAMPLEBANK_MAIN; + int32 nBank = SFX_BANK_0; fpSampleDescHandle = fopen(SampleBankDescFilename, "rb"); if ( fpSampleDescHandle == NULL ) @@ -1453,17 +1453,17 @@ cSampleManager::InitialiseSampleBanks(void) for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) { #ifdef FIX_BUGS - if (nBank >= MAX_SAMPLEBANKS) break; + if (nBank >= MAX_SFX_BANKS) break; #endif - if ( BankStartOffset[nBank] == BankStartOffset[SAMPLEBANK_MAIN] + i ) + if ( BankStartOffset[nBank] == BankStartOffset[SFX_BANK_0] + i ) { nSampleBankDiscStartOffset[nBank] = m_aSamples[i].nOffset; nBank++; } } - nSampleBankSize[SAMPLEBANK_MAIN] = nSampleBankDiscStartOffset[SAMPLEBANK_PED] - nSampleBankDiscStartOffset[SAMPLEBANK_MAIN]; - nSampleBankSize[SAMPLEBANK_PED] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SAMPLEBANK_PED]; + nSampleBankSize[SFX_BANK_0] = nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - nSampleBankDiscStartOffset[SFX_BANK_0]; + nSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS]; return true; } -- cgit v1.2.3 From db2c34923dba92012f023b2453a35aba4bd6846e Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 19 Sep 2020 16:39:31 +0300 Subject: Fixes to MusicManager --- src/audio/AudioManager.h | 2 +- src/audio/MusicManager.cpp | 64 ++++++++++++++++++++++------------------------ 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 363031b7..b6bbef8f 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -213,7 +213,7 @@ public: float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; } int32 GetRandomNumber(int32 idx) const { return m_anRandomTable[idx]; } int32 GetRandomNumberInRange(int32 idx, int32 low, int32 high) const { return (m_anRandomTable[idx] % (high - low + 1)) + low; } - bool IsMissionAudioSamplePlaying() const { return m_sMissionAudio.m_nPlayStatus == 1; } + bool ShouldDuckMissionAudio() const { return m_sMissionAudio.m_nPlayStatus == 1; } // "Should" be in alphabetic order, except "getXTalkSfx" void AddDetailsToRequestedOrderList(uint8 sample); diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index e4392aa9..febd0ca1 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -434,6 +434,7 @@ cMusicManager::ServiceGameMode() { bool bRadioOff = false; static int8 nFramesSinceCutsceneEnded = -1; + uint8 volume; m_bPreviousPlayerInCar = m_bPlayerInCar; m_bPlayerInCar = PlayerInCar(); @@ -520,25 +521,25 @@ cMusicManager::ServiceGameMode() } if (CTimer::GetIsSlowMotionActive()) { if (TheCamera.pTargetEntity != nil) { - float dist = (TheCamera.pTargetEntity->GetPosition() - TheCamera.GetPosition()).MagnitudeSqr(); - if (dist >= 3025.0f) { + float DistToTargetSq = (TheCamera.pTargetEntity->GetPosition() - TheCamera.GetPosition()).MagnitudeSqr(); + if (DistToTargetSq >= SQR(55.0f)) { SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0); - } else if (dist >= 100.0f) { - int8 volume = ((45.0f - (Sqrt(dist) - 10.0f)) / 45.0f * 100.0f); - int8 pan; - if (AudioManager.IsMissionAudioSamplePlaying()) + } else if (DistToTargetSq >= SQR(10.0f)) { + volume = ((45.0f - (Sqrt(DistToTargetSq) - 10.0f)) / 45.0f * 100.0f); + uint8 pan; + if (AudioManager.ShouldDuckMissionAudio()) volume /= 4; - if (volume != 0) { - CVector trVec; - AudioManager.TranslateEntity(&TheCamera.pTargetEntity->GetPosition(), &trVec); - pan = AudioManager.ComputePan(55.0f, &trVec); + if (volume > 0) { + CVector panVec; + AudioManager.TranslateEntity(&TheCamera.pTargetEntity->GetPosition(), &panVec); + pan = AudioManager.ComputePan(55.0f, &panVec); } else { pan = 0; } if (gRetuneCounter) volume /= 4; SampleManager.SetStreamedVolumeAndPan(volume, pan, 0, 0); - } else if (AudioManager.IsMissionAudioSamplePlaying()) { + } else if (AudioManager.ShouldDuckMissionAudio()) { SampleManager.SetStreamedVolumeAndPan(25, 63, 0, 0); } else if (gRetuneCounter) { SampleManager.SetStreamedVolumeAndPan(25, 63, 0, 0); @@ -546,26 +547,24 @@ cMusicManager::ServiceGameMode() SampleManager.SetStreamedVolumeAndPan(100, 63, 0, 0); } } - } else if (AudioManager.IsMissionAudioSamplePlaying()) { + } else if (AudioManager.ShouldDuckMissionAudio()) { SampleManager.SetStreamedVolumeAndPan(25, 63, 0, 0); nFramesSinceCutsceneEnded = 0; } else { - int8 volume; if (nFramesSinceCutsceneEnded == -1) { volume = 100; - } else if (nFramesSinceCutsceneEnded >= 20) { - if (nFramesSinceCutsceneEnded >= 40) { - nFramesSinceCutsceneEnded = -1; - volume = 100; - } else { - volume = 3 * (nFramesSinceCutsceneEnded - 20) + 25; - nFramesSinceCutsceneEnded++; - } - } else { + } else if (nFramesSinceCutsceneEnded < 20) { nFramesSinceCutsceneEnded++; volume = 25; + } else if (nFramesSinceCutsceneEnded < 40) { + volume = 3 * (nFramesSinceCutsceneEnded - 20) + 25; + nFramesSinceCutsceneEnded++; + } else { + nFramesSinceCutsceneEnded = -1; + volume = 100; } - if (gRetuneCounter) volume /= 4; + if (gRetuneCounter != 0) + volume /= 4; SampleManager.SetStreamedVolumeAndPan(volume, 63, 0, 0); } return; @@ -698,16 +697,15 @@ cMusicManager::StopCutSceneMusic(void) uint32 cMusicManager::GetTrackStartPos(uint8 track) { - uint32 result; - uint32 timer = m_aTracks[track].m_nLastPosCheckTimer; - if (CTimer::GetTimeInMillisecondsPauseMode() <= timer) { - result = m_aTracks[track].m_nPosition; + uint32 pos = m_aTracks[track].m_nPosition; + if (CTimer::GetTimeInMillisecondsPauseMode() > m_aTracks[track].m_nLastPosCheckTimer) + pos += Min(CTimer::GetTimeInMillisecondsPauseMode() - m_aTracks[track].m_nLastPosCheckTimer, 90000); + else m_aTracks[track].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); - } else - result = Min(CTimer::GetTimeInMillisecondsPauseMode() - timer, 90000) + m_aTracks[track].m_nPosition; - if (result > m_aTracks[track].m_nLength) result %= m_aTracks[track].m_nLength; - return result; + if (pos > m_aTracks[track].m_nLength) + pos %= m_aTracks[track].m_nLength; + return pos; } @@ -832,7 +830,7 @@ cMusicManager::ServiceAnnouncement() SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0); if (SampleManager.StartStreamedFile(m_nAnnouncement, 0, 0)) { - SampleManager.SetStreamedVolumeAndPan(AudioManager.IsMissionAudioSamplePlaying() ? 25 : 100, 63, 0, 0); + SampleManager.SetStreamedVolumeAndPan(AudioManager.ShouldDuckMissionAudio() ? 25 : 100, 63, 0, 0); m_bAnnouncementInProgress = true; m_nPreviousStreamedSound = m_nCurrentStreamedSound; m_nCurrentStreamedSound = m_nAnnouncement; @@ -905,7 +903,7 @@ cMusicManager::ChangeRadioChannel() return false; if (!SampleManager.StartStreamedFile(m_nCurrentStreamedSound, GetTrackStartPos(m_nCurrentStreamedSound), 0)) return false; - SampleManager.SetStreamedVolumeAndPan(AudioManager.IsMissionAudioSamplePlaying() ? 25 : 100, 63, 0, 0); + SampleManager.SetStreamedVolumeAndPan(AudioManager.ShouldDuckMissionAudio() ? 25 : 100, 63, 0, 0); } return true; } -- cgit v1.2.3 From a9c3fdd63fd4ef985b708318a0e28353a11bba90 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Tue, 22 Sep 2020 03:28:14 +0300 Subject: rewisited: ProcessReverseGear ProcessWeather ProcessScriptObject ProcessExtraSounds ProcessEntity and so, more info in my repo --- src/audio/AudioLogic.cpp | 157 ++++++++++++++++++++++++++++++++++------------- src/audio/AudioManager.h | 2 + 2 files changed, 117 insertions(+), 42 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index e76bb99d..cf2fd140 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -38,6 +38,7 @@ #include "ZoneCull.h" #include "sampman.h" #include "Bike.h" +#include "WindModifiers.h" const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); @@ -292,7 +293,6 @@ cAudioManager::CalculateDistance(bool &distCalculated, float dist) if (!distCalculated) { if (dist > 0.0f) m_sQueueSample.m_fDistance = Sqrt(dist); - else m_sQueueSample.m_fDistance = 0.0f; distCalculated = true; @@ -337,7 +337,7 @@ cAudioManager::ProcessSpecial() void cAudioManager::ProcessEntity(int32 id) { - if (m_asAudioEntities[id].m_nStatus) { + if (m_asAudioEntities[id].m_nStatus != STATUS_PLAYER) { m_sQueueSample.m_nEntityIndex = id; switch (m_asAudioEntities[id].m_nType) { case AUDIOTYPE_PHYSICAL: @@ -361,29 +361,16 @@ cAudioManager::ProcessEntity(int32 id) case AUDIOTYPE_WEATHER: if (!m_nUserPause) { m_sQueueSample.m_bReverbFlag = true; - ProcessWeather(id); + if(CGame::currArea == AREA_MAIN_MAP || CGame::currArea == AREA_EVERYWHERE) + ProcessWeather(id); } break; -/* case AUDIOTYPE_CRANE: - if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = true; - ProcessCrane(); - } - break;*/ case AUDIOTYPE_SCRIPTOBJECT: if (!m_nUserPause) { m_sQueueSample.m_bReverbFlag = true; ProcessScriptObject(id); } break; -#ifdef GTA_BRIDGE - case AUDIOTYPE_BRIDGE: - if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = true; - ProcessBridge(); - } - break; -#endif case AUDIOTYPE_FRONTEND: m_sQueueSample.m_bReverbFlag = false; ProcessFrontEnd(); @@ -410,6 +397,18 @@ cAudioManager::ProcessEntity(int32 id) ProcessWaterCannon(id); } break; + case AUDIOTYPE_ESCALATOR: + if (!m_nUserPause) { + m_sQueueSample.m_bReverbFlag = true; + //ProcessEscalators(); //TODO + } + break; + case AUDIOTYPE_EXTRA_SOUNDS: + if (!m_nUserPause) { + m_sQueueSample.m_bReverbFlag = true; + ProcessExtraSounds(); + } + break; default: return; } @@ -869,27 +868,28 @@ cAudioManager::ProcessReverseGear(cVehicleParams *params) { const int reverseGearIntensity = 30; - CVehicle *veh; - CAutomobile *automobile; - int32 emittingVol; + CAutomobile* automobile; float modificator; + uint8 emittingVolume; if (params->m_fDistance >= SQR(reverseGearIntensity)) return false; - veh = params->m_pVehicle; - if (veh->bEngineOn && (veh->m_fGasPedal < 0.0f || veh->m_nCurrentGear == 0)) { + automobile = (CAutomobile*)params->m_pVehicle; + if (automobile->m_modelIndex == MI_CADDY) + return true; + if (automobile->bEngineOn && (automobile->m_fGasPedal < 0.0f || automobile->m_nCurrentGear == 0)) { CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - automobile = (CAutomobile *)params->m_pVehicle; - if (automobile->m_nWheelsOnGround != 0) { + if (automobile->m_nDriveWheelsOnGround != 0) { modificator = params->m_fVelocityChange / params->m_pTransmission->fMaxReverseVelocity; } else { - if (automobile->m_nDriveWheelsOnGround != 0) + if (automobile->m_nDriveWheelsOnGroundPrev != 0) automobile->m_fGasPedalAudio *= 0.4f; modificator = automobile->m_fGasPedalAudio; } modificator = Abs(modificator); - emittingVol = (24.f * modificator); - m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, reverseGearIntensity, m_sQueueSample.m_fDistance); + emittingVolume = modificator * 24.0f; + m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, reverseGearIntensity, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { if (params->m_pVehicle->m_fGasPedal >= 0.0f) { m_sQueueSample.m_nCounter = 62; @@ -901,9 +901,9 @@ cAudioManager::ProcessReverseGear(cVehicleParams *params) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nFrequency = (6000.f * modificator) + 7000; + m_sQueueSample.m_nFrequency = (6000.0f * modificator) + 7000; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = emittingVol; + m_sQueueSample.m_nEmittingVolume = emittingVolume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 3.0f; @@ -1197,7 +1197,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams* params) break; } } - } else if (0.0f == params->m_fVelocityChange) { + } else if (params->m_fVelocityChange == 0.0f) { traction = 0.9f; } if (transmission->fMaxVelocity <= 0.0) { @@ -4186,7 +4186,6 @@ cAudioManager::SetupPedComments(cPedParams *params, uint32 sound) return; break; } - soundIntensity = 50.0f; } else { switch (sound) { @@ -4558,6 +4557,47 @@ cAudioManager::ProcessWaterCannon(int32) } } +CVector aVecExtraSoundPosition[] = { {-1042.546, 88.793999, 11.324}, {-1004.476, 181.69701, 11.324} }; + +void +cAudioManager::ProcessExtraSounds() +{ + const float extraSoundIntensity = 18; + + float distance; + + for (int i = 0; i < ARRAY_SIZE(aVecExtraSoundPosition); i++) { + m_sQueueSample.m_vecPos = aVecExtraSoundPosition[i]; + distance = GetDistanceSquared(m_sQueueSample.m_vecPos); + if (distance < SQR(extraSoundIntensity)) { + if (distance > 0.0) + m_sQueueSample.m_fDistance = Sqrt(distance); + else + m_sQueueSample.m_fDistance = 0.0f; + m_sQueueSample.m_nVolume = ComputeVolume(50, 18.0f, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + this->m_sQueueSample.m_nCounter = i; + this->m_sQueueSample.m_nSampleIndex = SFX_ARCADE; + this->m_sQueueSample.m_nBankIndex = 0; + this->m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ARCADE); + this->m_sQueueSample.m_bIs2D = false; + this->m_sQueueSample.m_nLoopCount = 0; + this->m_sQueueSample.m_bReleasingSoundFlag = false; + this->m_sQueueSample.m_nReleasingVolumeModificator = 4; + this->m_sQueueSample.m_fSpeedMultiplier = 3.0; + this->m_sQueueSample.m_nEmittingVolume = 50; + this->m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_ARCADE); + this->m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_ARCADE); + this->m_sQueueSample.m_bReverbFlag = true; + this->m_sQueueSample.m_fSoundIntensity = 18.0f; + this->m_sQueueSample.m_bRequireReflection = false; + this->m_sQueueSample.m_nReleasingVolumeDivider = 3; + AddSampleToRequestedQueue(); + } + } + } +} + #pragma region SCRIPT_OBJECTS const int SCRIPT_OBJECT_INTENSITY_S = 30; const int SCRIPT_OBJECT_INTENSITY_L = 80; @@ -4565,13 +4605,15 @@ const int SCRIPT_OBJECT_INTENSITY_L = 80; void cAudioManager::ProcessScriptObject(int32 id) { - cAudioScriptObject *entity = (cAudioScriptObject *)m_asAudioEntities[id].m_pEntity; - if (entity != nil) { - m_sQueueSample.m_vecPos = entity->Posn; - if (m_asAudioEntities[id].m_AudioEvents == 1) - ProcessOneShotScriptObject(m_asAudioEntities[id].m_awAudioEvent[0]); - else - ProcessLoopingScriptObject(entity->AudioId); + if (MusicManager.m_nMusicMode == MUSICMODE_GAME) { + cAudioScriptObject* entity = (cAudioScriptObject*)m_asAudioEntities[id].m_pEntity; + if (entity != nil) { + m_sQueueSample.m_vecPos = entity->Posn; + if (m_asAudioEntities[id].m_AudioEvents == 1) + ProcessOneShotScriptObject(m_asAudioEntities[id].m_awAudioEvent[0]); + else + ProcessLoopingScriptObject(entity->AudioId); + } } } @@ -4959,14 +5001,19 @@ void cAudioManager::ProcessWeather(int32 id) { uint8 vol; + float x; + float y; + float modifier; + float wind; + static uint8 iSound = 0; - if (m_asAudioEntities[id].m_AudioEvents && m_asAudioEntities[id].m_awAudioEvent[0] == SOUND_LIGHTNING) { + if (m_asAudioEntities[id].m_AudioEvents != 0 && m_asAudioEntities[id].m_awAudioEvent[0] == SOUND_LIGHTNING) { if (m_asAudioEntities[id].m_afVolume[0] >= 10.f) { m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_1; m_sQueueSample.m_nBankIndex = SFX_BANK_GENERIC_EXTRA; m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 4000; - vol = (m_asAudioEntities[id].m_afVolume[0] - 10.f) + 40; + vol = (m_asAudioEntities[id].m_afVolume[0] - 10.0f) + 40; } else { m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -4974,7 +5021,7 @@ cAudioManager::ProcessWeather(int32 id) vol = (m_asAudioEntities[id].m_afVolume[0]) + 35; } m_sQueueSample.m_nVolume = vol; - if (TheCamera.SoundDistUp < 20.f) + if (TheCamera.SoundDistUp < 20.0f) m_sQueueSample.m_nVolume /= 2; if (iSound == 4) iSound = 0; @@ -4994,7 +5041,7 @@ cAudioManager::ProcessWeather(int32 id) if (CWeather::Rain > 0.0f && (!CCullZones::CamNoRain() || !CCullZones::PlayerNoRain())) { m_sQueueSample.m_nSampleIndex = SFX_RAIN; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RAIN); - m_sQueueSample.m_nVolume = (int32)(25.f * CWeather::Rain); + 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; @@ -5010,6 +5057,32 @@ cAudioManager::ProcessWeather(int32 id) m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); } + x = 0.0f; + y = 0.0f; + CWindModifiers::FindWindModifier(TheCamera.GetPosition(), &x, &y); + modifier = Max(Abs(x), Abs(y)) * 10.0f; + modifier = Min(1.0f, modifier); + wind = Max(CWeather::Wind, modifier); + if (wind > 0.0f && CObject::fDistToNearestTree < 75.0) { + m_sQueueSample.m_nSampleIndex = SFX_PALM_TREE_LO; + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_PALM_TREE_LO); + m_sQueueSample.m_nVolume = (m_anRandomTable[1] % 10 + 45.0f) * (75.0f - CObject::fDistToNearestTree) * (4.0f / 300.0f) * wind; + m_sQueueSample.m_nCounter = 5; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nOffset = 63; + m_sQueueSample.m_bIs2D = true; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 7; + m_sQueueSample.m_bReverbFlag = false; + m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + CObject::fDistToNearestTree = 999999.9f; + } } void diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index a93aa6f7..a598b698 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -370,6 +370,8 @@ public: void ProcessWaterCannon(int32); void ProcessWeather(int32 id); bool ProcessWetRoadNoise(cVehicleParams *params); + void ProcessEscalators(); + void ProcessExtraSounds(); int32 RandomDisplacement(uint32 seed) const; void ReacquireDigitalHandle() const; -- cgit v1.2.3 From b2e3d90734b46b36dce0a0fe3b4dd278168b6de2 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Tue, 22 Sep 2020 19:32:05 +0300 Subject: ProcessEscalators + some fixes --- src/audio/AudioLogic.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++------ src/render/Fluff.h | 6 ++--- 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index cf2fd140..1f6c4a53 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -39,6 +39,7 @@ #include "sampman.h" #include "Bike.h" #include "WindModifiers.h" +#include "Fluff.h" const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); @@ -400,7 +401,7 @@ cAudioManager::ProcessEntity(int32 id) case AUDIOTYPE_ESCALATOR: if (!m_nUserPause) { m_sQueueSample.m_bReverbFlag = true; - //ProcessEscalators(); //TODO + ProcessEscalators(); } break; case AUDIOTYPE_EXTRA_SOUNDS: @@ -3072,6 +3073,7 @@ cAudioManager::ProcessHelicopter(cVehicleParams *params) return true; } +//TODO use it in ProcessVehicle void cAudioManager::ProcessPlane(cVehicleParams *params) { @@ -4557,12 +4559,14 @@ cAudioManager::ProcessWaterCannon(int32) } } +//positon of arcade machines CVector aVecExtraSoundPosition[] = { {-1042.546, 88.793999, 11.324}, {-1004.476, 181.69701, 11.324} }; void cAudioManager::ProcessExtraSounds() { - const float extraSoundIntensity = 18; + const float extraSoundIntensity = 18.0f; + const uint8 extraSoundVolume = 50; float distance; @@ -4574,22 +4578,22 @@ cAudioManager::ProcessExtraSounds() m_sQueueSample.m_fDistance = Sqrt(distance); else m_sQueueSample.m_fDistance = 0.0f; - m_sQueueSample.m_nVolume = ComputeVolume(50, 18.0f, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(extraSoundVolume, extraSoundIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { this->m_sQueueSample.m_nCounter = i; this->m_sQueueSample.m_nSampleIndex = SFX_ARCADE; - this->m_sQueueSample.m_nBankIndex = 0; + this->m_sQueueSample.m_nBankIndex = SFX_BANK_0; this->m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ARCADE); this->m_sQueueSample.m_bIs2D = false; this->m_sQueueSample.m_nLoopCount = 0; this->m_sQueueSample.m_bReleasingSoundFlag = false; this->m_sQueueSample.m_nReleasingVolumeModificator = 4; - this->m_sQueueSample.m_fSpeedMultiplier = 3.0; - this->m_sQueueSample.m_nEmittingVolume = 50; + this->m_sQueueSample.m_fSpeedMultiplier = 3.0f; + this->m_sQueueSample.m_nEmittingVolume = extraSoundVolume; this->m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_ARCADE); this->m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_ARCADE); this->m_sQueueSample.m_bReverbFlag = true; - this->m_sQueueSample.m_fSoundIntensity = 18.0f; + this->m_sQueueSample.m_fSoundIntensity = extraSoundIntensity; this->m_sQueueSample.m_bRequireReflection = false; this->m_sQueueSample.m_nReleasingVolumeDivider = 3; AddSampleToRequestedQueue(); @@ -4598,6 +4602,48 @@ cAudioManager::ProcessExtraSounds() } } +void +cAudioManager::ProcessEscalators() +{ + const float escalatorsSoundIntensity = 30.0f; + const uint8 escalatorsSoundVolume = 26; + + float distance; + + for (int i = 0; i < CEscalators::NumEscalators; i++) { + if (!CEscalators::aEscalators[i].m_bIsActive) + continue; + m_sQueueSample.m_vecPos = CEscalators::aEscalators[i].m_midPoint; + distance = GetDistanceSquared(m_sQueueSample.m_vecPos); + if (distance < SQR(escalatorsSoundIntensity)) { + if (distance > 0.0) + m_sQueueSample.m_fDistance = Sqrt(distance); + else + m_sQueueSample.m_fDistance = 0.0f; + m_sQueueSample.m_nVolume = ComputeVolume(escalatorsSoundVolume, escalatorsSoundIntensity, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + this->m_sQueueSample.m_nSampleIndex = SFX_BOAT_V12_LOOP; + this->m_sQueueSample.m_nBankIndex = SFX_BANK_0; + this->m_sQueueSample.m_nFrequency = i * 50 % 250 + 3973; + this->m_sQueueSample.m_nReleasingVolumeModificator = 3; + this->m_sQueueSample.m_fSpeedMultiplier = 3.0f; + this->m_sQueueSample.m_nReleasingVolumeDivider = 5; + this->m_sQueueSample.m_fSoundIntensity = escalatorsSoundIntensity; + this->m_sQueueSample.m_nCounter = i; + this->m_sQueueSample.m_bIs2D = false; + this->m_sQueueSample.m_nLoopCount = 0; + this->m_sQueueSample.m_nEmittingVolume = escalatorsSoundVolume; + this->m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_BOAT_V12_LOOP); + this->m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_BOAT_V12_LOOP); + this->m_sQueueSample.m_bReverbFlag = true; + this->m_sQueueSample.m_bReleasingSoundFlag = false; + this->m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } + } + } +} + #pragma region SCRIPT_OBJECTS const int SCRIPT_OBJECT_INTENSITY_S = 30; const int SCRIPT_OBJECT_INTENSITY_L = 80; diff --git a/src/render/Fluff.h b/src/render/Fluff.h index 0fc57c73..5a4458a8 100644 --- a/src/render/Fluff.h +++ b/src/render/Fluff.h @@ -90,15 +90,15 @@ class CEscalator CVector m_pos2; CVector m_pos3; CMatrix m_matrix; - bool m_bIsActive; bool m_bIsMovingDown; int32 m_stepsCount; float m_lowerEnd; float m_upperEnd; - CVector m_midPoint; float m_radius; CObject *m_pSteps[24]; public: + bool m_bIsActive;//TODO also recheck! + CVector m_midPoint; CEscalator(); void Update(void); void SwitchOff(void); @@ -107,8 +107,8 @@ public: class CEscalators { - static CEscalator aEscalators[NUM_ESCALATORS]; public: + static CEscalator aEscalators[NUM_ESCALATORS];//TODO need recheck this! static int32 NumEscalators; static void Init(void); static void Update(void); -- cgit v1.2.3 From c6cf16447bfe5b7d8130588e53a65c9a99658603 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 23 Sep 2020 15:57:13 +0300 Subject: Add .gitattributes for better language stats --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..9261b404 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +sdk/* linguist-vendored +vendor/* linguist-vendored \ No newline at end of file -- cgit v1.2.3 From 1d22c78f9fa9bcfcbca663a78b1e92b4b52478cc Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 25 Sep 2020 01:43:19 +0300 Subject: processCarHeli half done --- src/audio/AudioLogic.cpp | 407 +++++++++++++++++++++++++++++++++++++++++++++-- src/audio/AudioManager.h | 1 + 2 files changed, 394 insertions(+), 14 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 1f6c4a53..9da2c1a6 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -747,7 +747,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) } else { switch (veh->GetVehicleAppearance()) { case VEHICLE_APPEARANCE_HELI: - ProcessHelicopter(¶ms); + ProcessCarHeli(¶ms); //ProcessVehicleFlatTyre(¶ms); ProcessEngineDamage(¶ms); break; @@ -780,27 +780,18 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) break; case VEHICLE_TYPE_BOAT: if (veh->m_modelIndex == MI_SKIMMER) - ProcessHelicopter(¶ms); + ProcessCarHeli(¶ms); else ProcessBoatEngine(¶ms); ProcessBoatMovingOverWater(¶ms); ProcessVehicleOneShots(¶ms); break; case VEHICLE_TYPE_HELI: - ProcessHelicopter(¶ms); + ProcessCarHeli(¶ms); ProcessVehicleOneShots(¶ms); break; case VEHICLE_TYPE_PLANE: - switch (params.m_nIndex) { - case AIRTRAIN: - ProcessJumbo(¶ms); - break; - case DEADDODO: - ProcessCesna(¶ms); - break; - default: - break; - } + ProcessPlane(¶ms); ProcessVehicleOneShots(¶ms); //ProcessVehicleFlatType(¶ms); break; @@ -3073,6 +3064,394 @@ cAudioManager::ProcessHelicopter(cVehicleParams *params) return true; } +void cAudioManager::ProcessCarHeli(cVehicleParams* params) +{ + CVehicle* playerVeh; // eax + CVehicle* veh; // ecx + CAutomobile* automobile; // [esp+10h] [ebp-CCh] + CBoat* boat; // [esp+1Ch] [ebp-C0h] + + signed int volume; // ebx + float volumeTmp; // st5 + unsigned int freqModifier; // eax + signed int v30; // ebx + uint32 freq_6; // eax + signed int volume_3; // ebx + + signed int volume_2; // ebx + char distCalcBool; // [esp+Ch] [ebp-D0h] + signed int freqModifier_2; // [esp+14h] [ebp-C8h] + char hunterBool; // [esp+18h] [ebp-C4h] + signed int brake; // [esp+20h] [ebp-BCh] + signed int accelerate; // [esp+24h] [ebp-B8h] + signed int volume_4; // [esp+28h] [ebp-B4h] + signed int volume_1; // [esp+2Ch] [ebp-B0h] + float vehAtYAbs; // [esp+34h] [ebp-A8h] + float vehCameraDot; // [esp+38h] [ebp-A4h] + float speedMultiplied; // [esp+3Ch] [ebp-A0h] + float volumeModifier; // [esp+40h] [ebp-9Ch] + float distance_3; // [esp+44h] [ebp-98h] + CVector posBackup; // [esp+48h] [ebp-94h] + + CMatrix cameraMatrix; // [esp+60h] [ebp-7Ch] + CVector pos; // [esp+A8h] [ebp-34h] + //CVector multipliedVector; // [esp+B4h] [ebp-28h] + //CVector MatrixMultiplier; // [esp+C0h] [ebp-1Ch] + + static uint32 freqPrev = 14287; + static uint32 freqPrev_1 = 7143; + static uint32 freqPrev_0 = 14287; + + const float CarHeliDistance = 250.0f; + + boat = 0; + hunterBool = 0; + automobile = 0; + cameraMatrix.m_attachment = 0; + cameraMatrix.m_hasRwMatrix = 0; + + if (params->m_fDistance < SQR(CarHeliDistance)) {//!! + playerVeh = FindPlayerVehicle(); + veh = params->m_pVehicle; + if (playerVeh == veh) { + accelerate = Pads[0].GetAccelerate(); + brake = Pads[0].GetBrake(); + } else { + accelerate = veh->m_fGasPedal * 255.0f; + brake = veh->m_fBrakePedal * 255.0f; + } + cameraMatrix = TheCamera.m_matrix; + vehAtYAbs = Abs(veh->m_matrix.GetUp().y); + vehCameraDot = (DotProduct(veh->m_matrix.GetForward(), cameraMatrix.GetForward()) + 1.0f) / 2.0f; + + //123-139 + if (veh->m_modelIndex == MI_SKIMMER) {//!! + boat = (CBoat*)params->m_pVehicle; + speedMultiplied = boat->m_fMovingSpeed * 50.0f / 11.0f; + } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) {//!! + speedMultiplied = 1.0; + } else { + automobile = (CAutomobile*)params->m_pVehicle; + speedMultiplied = automobile->m_aWheelSpeed[1] * 50.0f / 11.0f; + } + //140-162 + if (0.0 == speedMultiplied) {//?? + cameraMatrix.~CMatrix(); + return; + } + speedMultiplied = Min(1.0f, speedMultiplied); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + //163- + if (m_sQueueSample.m_fDistance >= 40.0f) {//?? + volumeTmp = speedMultiplied * 75.0f; + } else { + if (m_sQueueSample.m_fDistance >= 25.0f) {//!! + volume = 0; + LABEL_34: + //173-243 + if (volume != 0) {//!! + m_sQueueSample.m_nVolume = cAudioManager::ComputeVolume(volume, 250.0f, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { //!! + m_sQueueSample.m_nCounter = 88; + if (boat != nil) { //!! + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO3; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + if (accelerate <= 0 && brake <= 0) { //!! + freqModifier = Min(1.0f, vehAtYAbs) * 949;//??? + m_sQueueSample.m_nFrequency = 3651 + freqModifier; + } else { + freqModifier = Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 563; + m_sQueueSample.m_nFrequency = 4600 + freqModifier; + } + } else { + m_sQueueSample.m_nSampleIndex = SFX_HELI_1; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); + } + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 250.0f; + m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + //244- + if (automobile) { //!! + automobile->GetComponentWorldPosition(CAR_BOOT, pos); + } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) { //!! + //MatrixMultiplier.z = 0.0; + //MatrixMultiplier.x = 0.0; + //MatrixMultiplier.y = -10.0; + //multipliedVector = params->m_pVehicle->m_matrix * MatrixMultiplier; + } else { + pos = m_sQueueSample.m_vecPos; + } + //263-270 + if (params->m_fDistance >= 19600.0f) //?? + goto LABEL_EXIT; + if (speedMultiplied >= 0.4f) //?? + volumeModifier = (speedMultiplied - 0.4f) * 5.0f / 3.0f; + else + volumeModifier = 0.0f; + //270-286 + if (!boat) { //!! + freqModifier_2 = Min(1300, 7000.0f * vehAtYAbs); + if (playerVeh == veh && (accelerate > 0 || brake > 0) && freqModifier_2 < 1300) //!! + freqModifier_2 = 1300; + if (veh->m_modelIndex == MI_HUNTER) //!! + hunterBool = true; + } + + volume_1 = (1.0f - vehCameraDot) * volumeModifier * 127.0f; + //288-339 + if (boat) { //!! + if (accelerate <= 0 && brake <= 0) { //!! + //freqModifier_4 = 3713.0 * vehAtYAbs; + //if (freqModifier_4 > 3713)//!! + // freqModifier_4 = 3713; + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; //??? + } else { + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, vehAtYAbs * (Max(accelerate, brake) / 255)) * 2204; + } + + if (speedMultiplied < 1.0) { //?? + //v27 = (double)(this_1->m_sQueueSample.m_nFrequency >> 1); + //this_1->m_sQueueSample.m_nFrequency = (signed __int64)(v27 * speedMultiplied + v27); + m_sQueueSample.m_nFrequency = (speedMultiplied + 1.0f) * m_sQueueSample.m_nFrequency / 2.0f; + } + + m_sQueueSample.m_nFrequency = m_sQueueSample.m_nFrequency < freqPrev ? + Max(m_sQueueSample.m_nFrequency, freqPrev - 197) : Min(m_sQueueSample.m_nFrequency, freqPrev + 197); + freqPrev = m_sQueueSample.m_nFrequency; + //TODO maybe clamp!!! + } + + + + m_sQueueSample.m_nVolume = ComputeVolume(volume_1, 140.0f, m_sQueueSample.m_fDistance); + if (!m_sQueueSample.m_nVolume) { //!! + LABEL_105: + if (!boat && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance >= 30.0) { //!! + if (automobile->bEngineOn) { + if (speedMultiplied >= 1.0) { + v30 = (signed int)((1.0 - 0.5 * speedMultiplied) * 70.0f); + m_sQueueSample.m_nVolume = ComputeVolume(v30, 30.0, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) { + if (hunterBool) { + m_sQueueSample.m_nSampleIndex = 456; + m_sQueueSample.m_nBankIndex = 0; + freq_6 = 3000.0 * speedMultiplied + 30000; + } else { + m_sQueueSample.m_nSampleIndex = 11; + m_sQueueSample.m_nBankIndex = 0; + freq_6 = 3000.0 * speedMultiplied + 6000; + } + m_sQueueSample.m_nFrequency = freq_6; + m_sQueueSample.m_nCounter = 12; + m_sQueueSample.m_bIs2D = 0; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = v30; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0; + m_sQueueSample.m_fSoundIntensity = 30.0; + m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_nReleasingVolumeDivider = 30; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + } + } + volume_4 = ((0.5 * vehCameraDot + 0.5) * volumeModifier * 127.0); + if (boat) { + if (accelerate <= 0 && brake <= 0) //!! + m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857; + else + m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102; + + if (speedMultiplied < 1.0) //?? + m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); + + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98); + freqPrev_1 = m_sQueueSample.m_nFrequency; + } + m_sQueueSample.m_nVolume = ComputeVolume(volume_4, 140.0, m_sQueueSample.m_fDistance); + if (!m_sQueueSample.m_nVolume) + goto LABEL_147; + m_sQueueSample.m_nCounter = 1; + if (hunterBool) { //488 andro + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_2; + } else { + if (boat) { + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + LABEL_146: + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_4; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + LABEL_147: + if (boat) { + //489-568 + if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0 && speedMultiplied > 0.0) { //?? 525 andro + volume_3 = speedMultiplied * 100.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); + if (accelerate <= 0 && brake <= 0)//!! + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; + else + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 2204; + if (speedMultiplied < 1.0) //?? + m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); + freqPrev_0 = m_sQueueSample.m_nFrequency; + if (m_sQueueSample.m_nVolume) { + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nCounter = 12; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_3; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(464); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(464); + m_sQueueSample.m_fSpeedMultiplier = 5.0f; + m_sQueueSample.m_fSoundIntensity = 20.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 7; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } + } + } else { + //573-645 + posBackup = m_sQueueSample.m_vecPos; + distCalcBool = params->m_bDistanceCalculated; + distance_3 = params->m_fDistance; + + m_sQueueSample.m_vecPos = pos; + params->m_bDistanceCalculated = false; + params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);//580-589 + if (params->m_fDistance < 729.0f) { //!! + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);//593-605 + volume_2 = 25.0f * volumeModifier; + m_sQueueSample.m_nVolume = ComputeVolume(volume_2, 27.0f, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) {//!! + m_sQueueSample.m_nCounter = 2; + if (hunterBool)//!! + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_3; + else + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_REA; + m_sQueueSample.m_nBankIndex = 0; + m_sQueueSample.m_bIs2D = 0; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nFrequency = 16000.0f * volumeModifier + 16000; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_2; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 27.0f; + m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + + m_sQueueSample.m_vecPos = posBackup; + params->m_bDistanceCalculated = distCalcBool; + params->m_fDistance = distance_3; + } + LABEL_EXIT: + cameraMatrix.~CMatrix(); + return; + } + m_sQueueSample.m_nSampleIndex = 9; + } + m_sQueueSample.m_nBankIndex = 0; + m_sQueueSample.m_nFrequency = (unsigned __int64)(signed __int64)(16000.0 * volumeModifier) + + 16000; + m_sQueueSample.m_nFrequency += freqModifier_2; + goto LABEL_146; + } + + + + + m_sQueueSample.m_nCounter = 3; //347 andro + if (hunterBool) { //!! + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_1; + } else { + if (boat) { //!! + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + //LABEL_104: + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + goto LABEL_105; + } + m_sQueueSample.m_nSampleIndex = 8; + } + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = (16000.0 * volumeModifier) + 16000; + m_sQueueSample.m_nFrequency += freqModifier_2; + //goto LABEL_104; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + goto LABEL_105; + } + volumeTmp = (m_sQueueSample.m_fDistance - 25.0) * 0.06666667 * (75.0 * speedMultiplied); + } + volume = (signed int)volumeTmp; + goto LABEL_34; + } + cameraMatrix.~CMatrix(); +} + //TODO use it in ProcessVehicle void cAudioManager::ProcessPlane(cVehicleParams *params) @@ -4560,7 +4939,7 @@ cAudioManager::ProcessWaterCannon(int32) } //positon of arcade machines -CVector aVecExtraSoundPosition[] = { {-1042.546, 88.793999, 11.324}, {-1004.476, 181.69701, 11.324} }; +CVector aVecExtraSoundPosition[] = { {-1042.546f, 88.793999f, 11.324f}, {-1004.476f, 181.69701f, 11.324f} }; void cAudioManager::ProcessExtraSounds() diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index a598b698..cae606fd 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -331,6 +331,7 @@ public: void ProcessFrontEnd(); void ProcessGarages(); bool ProcessHelicopter(cVehicleParams *params); + void ProcessCarHeli(cVehicleParams* params); void ProcessJumbo(cVehicleParams *); void ProcessJumboAccel(CPlane *plane); void ProcessJumboDecel(CPlane *plane); -- cgit v1.2.3 From b3cbe3d33886ff665ed08805e122f1853144fbbd Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 25 Sep 2020 02:17:58 +0300 Subject: removed some goto --- src/audio/AudioLogic.cpp | 609 +++++++++++++++++++++++------------------------ 1 file changed, 304 insertions(+), 305 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 9da2c1a6..f553bef6 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -3072,9 +3072,8 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) CBoat* boat; // [esp+1Ch] [ebp-C0h] signed int volume; // ebx - float volumeTmp; // st5 unsigned int freqModifier; // eax - signed int v30; // ebx + signed int volume; // ebx uint32 freq_6; // eax signed int volume_3; // ebx @@ -3104,335 +3103,212 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) const float CarHeliDistance = 250.0f; - boat = 0; - hunterBool = 0; - automobile = 0; + boat = nil; + hunterBool = false; + automobile = nil; cameraMatrix.m_attachment = 0; cameraMatrix.m_hasRwMatrix = 0; - if (params->m_fDistance < SQR(CarHeliDistance)) {//!! - playerVeh = FindPlayerVehicle(); - veh = params->m_pVehicle; - if (playerVeh == veh) { - accelerate = Pads[0].GetAccelerate(); - brake = Pads[0].GetBrake(); - } else { - accelerate = veh->m_fGasPedal * 255.0f; - brake = veh->m_fBrakePedal * 255.0f; - } - cameraMatrix = TheCamera.m_matrix; - vehAtYAbs = Abs(veh->m_matrix.GetUp().y); - vehCameraDot = (DotProduct(veh->m_matrix.GetForward(), cameraMatrix.GetForward()) + 1.0f) / 2.0f; - - //123-139 - if (veh->m_modelIndex == MI_SKIMMER) {//!! - boat = (CBoat*)params->m_pVehicle; - speedMultiplied = boat->m_fMovingSpeed * 50.0f / 11.0f; - } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) {//!! - speedMultiplied = 1.0; - } else { - automobile = (CAutomobile*)params->m_pVehicle; - speedMultiplied = automobile->m_aWheelSpeed[1] * 50.0f / 11.0f; - } - //140-162 - if (0.0 == speedMultiplied) {//?? - cameraMatrix.~CMatrix(); - return; - } - speedMultiplied = Min(1.0f, speedMultiplied); - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - //163- - if (m_sQueueSample.m_fDistance >= 40.0f) {//?? - volumeTmp = speedMultiplied * 75.0f; - } else { - if (m_sQueueSample.m_fDistance >= 25.0f) {//!! - volume = 0; - LABEL_34: - //173-243 - if (volume != 0) {//!! - m_sQueueSample.m_nVolume = cAudioManager::ComputeVolume(volume, 250.0f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { //!! - m_sQueueSample.m_nCounter = 88; - if (boat != nil) { //!! - m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO3; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerate <= 0 && brake <= 0) { //!! - freqModifier = Min(1.0f, vehAtYAbs) * 949;//??? - m_sQueueSample.m_nFrequency = 3651 + freqModifier; - } else { - freqModifier = Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 563; - m_sQueueSample.m_nFrequency = 4600 + freqModifier; - } - } else { - m_sQueueSample.m_nSampleIndex = SFX_HELI_1; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); - } - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 2; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 250.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; - AddSampleToRequestedQueue(); - } - } - //244- - if (automobile) { //!! - automobile->GetComponentWorldPosition(CAR_BOOT, pos); - } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) { //!! - //MatrixMultiplier.z = 0.0; - //MatrixMultiplier.x = 0.0; - //MatrixMultiplier.y = -10.0; - //multipliedVector = params->m_pVehicle->m_matrix * MatrixMultiplier; - } else { - pos = m_sQueueSample.m_vecPos; - } - //263-270 - if (params->m_fDistance >= 19600.0f) //?? - goto LABEL_EXIT; - if (speedMultiplied >= 0.4f) //?? - volumeModifier = (speedMultiplied - 0.4f) * 5.0f / 3.0f; - else - volumeModifier = 0.0f; - //270-286 - if (!boat) { //!! - freqModifier_2 = Min(1300, 7000.0f * vehAtYAbs); - if (playerVeh == veh && (accelerate > 0 || brake > 0) && freqModifier_2 < 1300) //!! - freqModifier_2 = 1300; - if (veh->m_modelIndex == MI_HUNTER) //!! - hunterBool = true; - } + if (params->m_fDistance >= SQR(CarHeliDistance)) {//!! + cameraMatrix.~CMatrix(); + return; + } + playerVeh = FindPlayerVehicle(); + veh = params->m_pVehicle; + if (playerVeh == veh) { + accelerate = Pads[0].GetAccelerate(); + brake = Pads[0].GetBrake(); + } else { + accelerate = veh->m_fGasPedal * 255.0f; + brake = veh->m_fBrakePedal * 255.0f; + } + cameraMatrix = TheCamera.m_matrix; + vehAtYAbs = Abs(veh->m_matrix.GetUp().y); + vehCameraDot = (DotProduct(veh->m_matrix.GetForward(), cameraMatrix.GetForward()) + 1.0f) / 2.0f; + if (veh->m_modelIndex == MI_SKIMMER) {//!! + boat = (CBoat*)params->m_pVehicle; + speedMultiplied = boat->m_fMovingSpeed * 50.0f / 11.0f; + } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) {//!! + speedMultiplied = 1.0f; + } else { + automobile = (CAutomobile*)params->m_pVehicle; + speedMultiplied = automobile->m_aWheelSpeed[1] * 50.0f / 11.0f; + } + if (speedMultiplied == 0.0f) {//?? + cameraMatrix.~CMatrix(); + return; + } + speedMultiplied = Min(1.0f, speedMultiplied); + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - volume_1 = (1.0f - vehCameraDot) * volumeModifier * 127.0f; - //288-339 - if (boat) { //!! - if (accelerate <= 0 && brake <= 0) { //!! - //freqModifier_4 = 3713.0 * vehAtYAbs; - //if (freqModifier_4 > 3713)//!! - // freqModifier_4 = 3713; - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; //??? - } else { - m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, vehAtYAbs * (Max(accelerate, brake) / 255)) * 2204; - } - if (speedMultiplied < 1.0) { //?? - //v27 = (double)(this_1->m_sQueueSample.m_nFrequency >> 1); - //this_1->m_sQueueSample.m_nFrequency = (signed __int64)(v27 * speedMultiplied + v27); - m_sQueueSample.m_nFrequency = (speedMultiplied + 1.0f) * m_sQueueSample.m_nFrequency / 2.0f; - } + if (m_sQueueSample.m_fDistance >= 40.0f) + volume = speedMultiplied * 75.0f; + else if (m_sQueueSample.m_fDistance >= 25.0f) + volume = 0; + else + volume = (m_sQueueSample.m_fDistance - 25.0f) * 0.06666667f * (75.0f * speedMultiplied); - m_sQueueSample.m_nFrequency = m_sQueueSample.m_nFrequency < freqPrev ? - Max(m_sQueueSample.m_nFrequency, freqPrev - 197) : Min(m_sQueueSample.m_nFrequency, freqPrev + 197); - freqPrev = m_sQueueSample.m_nFrequency; - //TODO maybe clamp!!! - } - m_sQueueSample.m_nVolume = ComputeVolume(volume_1, 140.0f, m_sQueueSample.m_fDistance); - if (!m_sQueueSample.m_nVolume) { //!! - LABEL_105: - if (!boat && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance >= 30.0) { //!! - if (automobile->bEngineOn) { - if (speedMultiplied >= 1.0) { - v30 = (signed int)((1.0 - 0.5 * speedMultiplied) * 70.0f); - m_sQueueSample.m_nVolume = ComputeVolume(v30, 30.0, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { - if (hunterBool) { - m_sQueueSample.m_nSampleIndex = 456; - m_sQueueSample.m_nBankIndex = 0; - freq_6 = 3000.0 * speedMultiplied + 30000; - } else { - m_sQueueSample.m_nSampleIndex = 11; - m_sQueueSample.m_nBankIndex = 0; - freq_6 = 3000.0 * speedMultiplied + 6000; - } - m_sQueueSample.m_nFrequency = freq_6; - m_sQueueSample.m_nCounter = 12; - m_sQueueSample.m_bIs2D = 0; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = v30; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0; - m_sQueueSample.m_fSoundIntensity = 30.0; - m_sQueueSample.m_bReleasingSoundFlag = 0; - m_sQueueSample.m_nReleasingVolumeDivider = 30; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; - AddSampleToRequestedQueue(); - } - } - } - } - volume_4 = ((0.5 * vehCameraDot + 0.5) * volumeModifier * 127.0); - if (boat) { - if (accelerate <= 0 && brake <= 0) //!! - m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857; - else - m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102; + //173-243 + if (volume != 0) {//!! + m_sQueueSample.m_nVolume = cAudioManager::ComputeVolume(volume, 250.0f, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { //!! + m_sQueueSample.m_nCounter = 88; + if (boat != nil) { //!! + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO3; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + if (accelerate <= 0 && brake <= 0) { //!! + freqModifier = Min(1.0f, vehAtYAbs) * 949;//??? + m_sQueueSample.m_nFrequency = 3651 + freqModifier; + } else { + freqModifier = Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 563; + m_sQueueSample.m_nFrequency = 4600 + freqModifier; + } + } else { + m_sQueueSample.m_nSampleIndex = SFX_HELI_1; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); + } + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 250.0f; + m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + //244- + if (automobile) { //!! + automobile->GetComponentWorldPosition(CAR_BOOT, pos); + } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) { //!! + //MatrixMultiplier.z = 0.0; + //MatrixMultiplier.x = 0.0; + //MatrixMultiplier.y = -10.0; + //multipliedVector = params->m_pVehicle->m_matrix * MatrixMultiplier; + } else { + pos = m_sQueueSample.m_vecPos; + } - if (speedMultiplied < 1.0) //?? - m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98); - freqPrev_1 = m_sQueueSample.m_nFrequency; - } - m_sQueueSample.m_nVolume = ComputeVolume(volume_4, 140.0, m_sQueueSample.m_fDistance); - if (!m_sQueueSample.m_nVolume) - goto LABEL_147; - m_sQueueSample.m_nCounter = 1; - if (hunterBool) { //488 andro - m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_2; - } else { - if (boat) { - m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - LABEL_146: - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_4; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 140.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - LABEL_147: - if (boat) { - //489-568 - if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0 && speedMultiplied > 0.0) { //?? 525 andro - volume_3 = speedMultiplied * 100.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); - if (accelerate <= 0 && brake <= 0)//!! - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; - else - m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 2204; - if (speedMultiplied < 1.0) //?? - m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); - freqPrev_0 = m_sQueueSample.m_nFrequency; - if (m_sQueueSample.m_nVolume) { - m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nCounter = 12; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_3; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(464); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(464); - m_sQueueSample.m_fSpeedMultiplier = 5.0f; - m_sQueueSample.m_fSoundIntensity = 20.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 7; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - } - } - } else { - //573-645 - posBackup = m_sQueueSample.m_vecPos; - distCalcBool = params->m_bDistanceCalculated; - distance_3 = params->m_fDistance; - - m_sQueueSample.m_vecPos = pos; - params->m_bDistanceCalculated = false; - params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);//580-589 - if (params->m_fDistance < 729.0f) { //!! - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);//593-605 - volume_2 = 25.0f * volumeModifier; - m_sQueueSample.m_nVolume = ComputeVolume(volume_2, 27.0f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) {//!! - m_sQueueSample.m_nCounter = 2; - if (hunterBool)//!! - m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_3; - else - m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_REA; - m_sQueueSample.m_nBankIndex = 0; - m_sQueueSample.m_bIs2D = 0; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nFrequency = 16000.0f * volumeModifier + 16000; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_2; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 27.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; - AddSampleToRequestedQueue(); - } - } + //263-270 + if (params->m_fDistance >= 19600.0f) { //?? + cameraMatrix.~CMatrix(); + return; + } - m_sQueueSample.m_vecPos = posBackup; - params->m_bDistanceCalculated = distCalcBool; - params->m_fDistance = distance_3; - } - LABEL_EXIT: - cameraMatrix.~CMatrix(); - return; - } - m_sQueueSample.m_nSampleIndex = 9; - } - m_sQueueSample.m_nBankIndex = 0; - m_sQueueSample.m_nFrequency = (unsigned __int64)(signed __int64)(16000.0 * volumeModifier) - + 16000; - m_sQueueSample.m_nFrequency += freqModifier_2; - goto LABEL_146; - } - + if (speedMultiplied >= 0.4f) //?? + volumeModifier = (speedMultiplied - 0.4f) * 5.0f / 3.0f; + else + volumeModifier = 0.0f; + //270-286 + if (!boat) { //!! + freqModifier_2 = Min(1300, 7000.0f * vehAtYAbs); + if (playerVeh == veh && (accelerate > 0 || brake > 0) && freqModifier_2 < 1300) //!! + freqModifier_2 = 1300; + if (veh->m_modelIndex == MI_HUNTER) //!! + hunterBool = true; + } + volume_1 = (1.0f - vehCameraDot) * volumeModifier * 127.0f; + //288-339 + if (boat) { //!! + if (accelerate <= 0 && brake <= 0) { //!! + //freqModifier_4 = 3713.0 * vehAtYAbs; + //if (freqModifier_4 > 3713)//!! + // freqModifier_4 = 3713; + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; //??? + } else { + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, vehAtYAbs * (Max(accelerate, brake) / 255)) * 2204; + } + if (speedMultiplied < 1.0) { //?? + //v27 = (double)(this_1->m_sQueueSample.m_nFrequency >> 1); + //this_1->m_sQueueSample.m_nFrequency = (signed __int64)(v27 * speedMultiplied + v27); + m_sQueueSample.m_nFrequency = (speedMultiplied + 1.0f) * m_sQueueSample.m_nFrequency / 2.0f; + } + m_sQueueSample.m_nFrequency = m_sQueueSample.m_nFrequency < freqPrev ? + Max(m_sQueueSample.m_nFrequency, freqPrev - 197) : Min(m_sQueueSample.m_nFrequency, freqPrev + 197); + freqPrev = m_sQueueSample.m_nFrequency; + //TODO maybe clamp!!! + } - m_sQueueSample.m_nCounter = 3; //347 andro - if (hunterBool) { //!! - m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_1; - } else { - if (boat) { //!! - m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - //LABEL_104: + + + m_sQueueSample.m_nVolume = ComputeVolume(volume_1, 140.0f, m_sQueueSample.m_fDistance); + if (!m_sQueueSample.m_nVolume) { //!! + LABEL_105: + if (!boat && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance >= 30.0f) { //!! + if (automobile->bEngineOn) { + if (speedMultiplied >= 1.0f) { + volume = (1.0f - 0.5f * speedMultiplied) * 70.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume, 30.0, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) { + if (hunterBool) { + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_4; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + freq_6 = 3000.0f * speedMultiplied + 30000; + } else { + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_STA; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + freq_6 = 3000.0f * speedMultiplied + 6000; + } + m_sQueueSample.m_nFrequency = freq_6; + m_sQueueSample.m_nCounter = 12; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nEmittingVolume = volume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_nReleasingVolumeDivider = 30; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); - goto LABEL_105; } - m_sQueueSample.m_nSampleIndex = 8; } + } + } + volume_4 = ((0.5 * vehCameraDot + 0.5) * volumeModifier * 127.0); + if (boat) { + if (accelerate <= 0 && brake <= 0) //!! + m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857; + else + m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102; + + if (speedMultiplied < 1.0) //?? + m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); + + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98); + freqPrev_1 = m_sQueueSample.m_nFrequency; + } + m_sQueueSample.m_nVolume = ComputeVolume(volume_4, 140.0, m_sQueueSample.m_fDistance); + if (!m_sQueueSample.m_nVolume) + goto LABEL_147; + m_sQueueSample.m_nCounter = 1; + if (hunterBool) { //488 andro + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_2; + } else { + if (boat) { + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = (16000.0 * volumeModifier) + 16000; - m_sQueueSample.m_nFrequency += freqModifier_2; - //goto LABEL_104; + LABEL_146: m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nEmittingVolume = volume_4; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3442,14 +3318,137 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); - goto LABEL_105; + LABEL_147: + if (boat) { + //489-568 + if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0 && speedMultiplied > 0.0) { //?? 525 andro + volume_3 = speedMultiplied * 100.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); + if (accelerate <= 0 && brake <= 0)//!! + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; + else + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 2204; + if (speedMultiplied < 1.0) //?? + m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); + freqPrev_0 = m_sQueueSample.m_nFrequency; + if (m_sQueueSample.m_nVolume) { + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nCounter = 12; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_3; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(464); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(464); + m_sQueueSample.m_fSpeedMultiplier = 5.0f; + m_sQueueSample.m_fSoundIntensity = 20.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 7; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } + } + } else { + //573-645 + posBackup = m_sQueueSample.m_vecPos; + distCalcBool = params->m_bDistanceCalculated; + distance_3 = params->m_fDistance; + + m_sQueueSample.m_vecPos = pos; + params->m_bDistanceCalculated = false; + params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);//580-589 + if (params->m_fDistance < 729.0f) { //!! + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);//593-605 + volume_2 = 25.0f * volumeModifier; + m_sQueueSample.m_nVolume = ComputeVolume(volume_2, 27.0f, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) {//!! + m_sQueueSample.m_nCounter = 2; + if (hunterBool)//!! + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_3; + else + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_REA; + m_sQueueSample.m_nBankIndex = 0; + m_sQueueSample.m_bIs2D = 0; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nFrequency = 16000.0f * volumeModifier + 16000; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_2; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 27.0f; + m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + + m_sQueueSample.m_vecPos = posBackup; + params->m_bDistanceCalculated = distCalcBool; + params->m_fDistance = distance_3; + } + cameraMatrix.~CMatrix(); + return; } - volumeTmp = (m_sQueueSample.m_fDistance - 25.0) * 0.06666667 * (75.0 * speedMultiplied); + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI2; } - volume = (signed int)volumeTmp; - goto LABEL_34; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; + goto LABEL_146; } - cameraMatrix.~CMatrix(); + + + + + m_sQueueSample.m_nCounter = 3; //347 andro + if (hunterBool) { //!! + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_1; + } else { + if (boat) { //!! + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + //LABEL_104: + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + goto LABEL_105; + } + m_sQueueSample.m_nSampleIndex = 8; + } + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; + //goto LABEL_104; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + goto LABEL_105; + + } //TODO use it in ProcessVehicle -- cgit v1.2.3 From 4414288b86f1f9630ad124cda6df8b30b43e7f36 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 25 Sep 2020 02:30:51 +0300 Subject: remove anther goto --- src/audio/AudioLogic.cpp | 204 ++++++++++++++++++++++++----------------------- 1 file changed, 105 insertions(+), 99 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index f553bef6..4d97ba20 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -3298,108 +3298,116 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) if (!m_sQueueSample.m_nVolume) goto LABEL_147; m_sQueueSample.m_nCounter = 1; - if (hunterBool) { //488 andro + + + + + + + + + if (hunterBool) { m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_2; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; + } else if (boat) { + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; } else { - if (boat) { - m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - LABEL_146: - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_4; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 140.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - LABEL_147: - if (boat) { - //489-568 - if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0 && speedMultiplied > 0.0) { //?? 525 andro - volume_3 = speedMultiplied * 100.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); - if (accelerate <= 0 && brake <= 0)//!! - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; - else - m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 2204; - if (speedMultiplied < 1.0) //?? - m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); - freqPrev_0 = m_sQueueSample.m_nFrequency; - if (m_sQueueSample.m_nVolume) { - m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nCounter = 12; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_3; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(464); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(464); - m_sQueueSample.m_fSpeedMultiplier = 5.0f; - m_sQueueSample.m_fSoundIntensity = 20.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 7; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - } - } - } else { - //573-645 - posBackup = m_sQueueSample.m_vecPos; - distCalcBool = params->m_bDistanceCalculated; - distance_3 = params->m_fDistance; - - m_sQueueSample.m_vecPos = pos; - params->m_bDistanceCalculated = false; - params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);//580-589 - if (params->m_fDistance < 729.0f) { //!! - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);//593-605 - volume_2 = 25.0f * volumeModifier; - m_sQueueSample.m_nVolume = ComputeVolume(volume_2, 27.0f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) {//!! - m_sQueueSample.m_nCounter = 2; - if (hunterBool)//!! - m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_3; - else - m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_REA; - m_sQueueSample.m_nBankIndex = 0; - m_sQueueSample.m_bIs2D = 0; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nFrequency = 16000.0f * volumeModifier + 16000; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_2; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 27.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; - AddSampleToRequestedQueue(); - } - } - - m_sQueueSample.m_vecPos = posBackup; - params->m_bDistanceCalculated = distCalcBool; - params->m_fDistance = distance_3; + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI2; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; + } + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_4; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + LABEL_147: + if (boat) { + //489-568 + if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0 && speedMultiplied > 0.0) { //?? 525 andro + volume_3 = speedMultiplied * 100.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); + if (accelerate <= 0 && brake <= 0)//!! + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; + else + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 2204; + if (speedMultiplied < 1.0) //?? + m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); + freqPrev_0 = m_sQueueSample.m_nFrequency; + if (m_sQueueSample.m_nVolume) { + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nCounter = 12; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_3; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(464); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(464); + m_sQueueSample.m_fSpeedMultiplier = 5.0f; + m_sQueueSample.m_fSoundIntensity = 20.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 7; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); } - cameraMatrix.~CMatrix(); - return; } - m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI2; + } else { + //573-645 + posBackup = m_sQueueSample.m_vecPos; + distCalcBool = params->m_bDistanceCalculated; + distance_3 = params->m_fDistance; + + m_sQueueSample.m_vecPos = pos; + params->m_bDistanceCalculated = false; + params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);//580-589 + if (params->m_fDistance < 729.0f) { //!! + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);//593-605 + volume_2 = 25.0f * volumeModifier; + m_sQueueSample.m_nVolume = ComputeVolume(volume_2, 27.0f, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) {//!! + m_sQueueSample.m_nCounter = 2; + if (hunterBool)//!! + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_3; + else + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_REA; + m_sQueueSample.m_nBankIndex = 0; + m_sQueueSample.m_bIs2D = 0; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nFrequency = 16000.0f * volumeModifier + 16000; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_2; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 27.0f; + m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + + m_sQueueSample.m_vecPos = posBackup; + params->m_bDistanceCalculated = distCalcBool; + params->m_fDistance = distance_3; } - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; - goto LABEL_146; + cameraMatrix.~CMatrix(); + return; + } @@ -3412,7 +3420,6 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) if (boat) { //!! m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - //LABEL_104: m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; @@ -3432,7 +3439,6 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) } m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; - //goto LABEL_104; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; -- cgit v1.2.3 From f097b9c972c541445ed1fe8f80dbc90ebcf7b92a Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 25 Sep 2020 03:10:11 +0300 Subject: fix deaddodo --- src/audio/AudioLogic.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 4d97ba20..1df7e773 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -3071,7 +3071,7 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) CAutomobile* automobile; // [esp+10h] [ebp-CCh] CBoat* boat; // [esp+1Ch] [ebp-C0h] - signed int volume; // ebx + signed int volume_5; // ebx unsigned int freqModifier; // eax signed int volume; // ebx uint32 freq_6; // eax @@ -3142,13 +3142,12 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - if (m_sQueueSample.m_fDistance >= 40.0f) + if (m_sQueueSample.m_fDistance >= 40.0f) //!! volume = speedMultiplied * 75.0f; - else if (m_sQueueSample.m_fDistance >= 25.0f) - volume = 0; - else + else if (m_sQueueSample.m_fDistance >= 25.0f) //!! volume = (m_sQueueSample.m_fDistance - 25.0f) * 0.06666667f * (75.0f * speedMultiplied); - + else + volume = 0; @@ -3250,8 +3249,8 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) if (!boat && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance >= 30.0f) { //!! if (automobile->bEngineOn) { if (speedMultiplied >= 1.0f) { - volume = (1.0f - 0.5f * speedMultiplied) * 70.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume, 30.0, m_sQueueSample.m_fDistance); + volume_5 = (1.0f - 0.5f * speedMultiplied) * 70.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume_5, 30.0, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume) { if (hunterBool) { m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_4; @@ -3267,7 +3266,7 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nEmittingVolume = volume_5; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; -- cgit v1.2.3 From 4d1023ca3015cd62fc1147b472f94c206115966d Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 25 Sep 2020 04:57:11 +0300 Subject: safe before clean up --- src/audio/AudioLogic.cpp | 347 ++++++++++++++++++++++++----------------------- 1 file changed, 176 insertions(+), 171 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 1df7e773..7089497d 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -3151,9 +3151,9 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) - //173-243 + //on height distance if (volume != 0) {//!! - m_sQueueSample.m_nVolume = cAudioManager::ComputeVolume(volume, 250.0f, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(volume, 250.0f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { //!! m_sQueueSample.m_nCounter = 88; if (boat != nil) { //!! @@ -3242,69 +3242,118 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) } - + //sound from front of helicopter m_sQueueSample.m_nVolume = ComputeVolume(volume_1, 140.0f, m_sQueueSample.m_fDistance); - if (!m_sQueueSample.m_nVolume) { //!! - LABEL_105: - if (!boat && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance >= 30.0f) { //!! - if (automobile->bEngineOn) { - if (speedMultiplied >= 1.0f) { - volume_5 = (1.0f - 0.5f * speedMultiplied) * 70.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume_5, 30.0, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { - if (hunterBool) { - m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_4; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - freq_6 = 3000.0f * speedMultiplied + 30000; - } else { - m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_STA; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - freq_6 = 3000.0f * speedMultiplied + 6000; - } - m_sQueueSample.m_nFrequency = freq_6; - m_sQueueSample.m_nCounter = 12; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_5; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 30.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 30; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); + if (m_sQueueSample.m_nVolume != 0) { + m_sQueueSample.m_nCounter = 3; //347 andro + if (hunterBool) { //!! + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_1; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } else if (boat) { //!! + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } else { + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 140.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } + } + + if (!boat && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance < 30.0f) { //!! + //engine starting sound + if (automobile->bEngineOn) { + if (speedMultiplied < 1.0f) { + volume_5 = (1.0f - 0.5f * speedMultiplied) * 70.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume_5, 30.0, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) { + if (hunterBool) { + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_4; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + freq_6 = 3000.0f * speedMultiplied + 30000; + } else { + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_STA; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + freq_6 = 3000.0f * speedMultiplied + 6000; } + m_sQueueSample.m_nFrequency = freq_6; + m_sQueueSample.m_nCounter = 12; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_5; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 30; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); } } } - volume_4 = ((0.5 * vehCameraDot + 0.5) * volumeModifier * 127.0); - if (boat) { - if (accelerate <= 0 && brake <= 0) //!! - m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857; - else - m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102; - - if (speedMultiplied < 1.0) //?? - m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); - - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98); - freqPrev_1 = m_sQueueSample.m_nFrequency; - } - m_sQueueSample.m_nVolume = ComputeVolume(volume_4, 140.0, m_sQueueSample.m_fDistance); - if (!m_sQueueSample.m_nVolume) - goto LABEL_147; - m_sQueueSample.m_nCounter = 1; - - - + } + if (boat) { + if (accelerate <= 0 && brake <= 0) //!! + m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857; + else + m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102; + if (speedMultiplied < 1.0) //?? + m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98); + freqPrev_1 = m_sQueueSample.m_nFrequency; + } + //after accel rotor sound + volume_4 = ((0.5 * vehCameraDot + 0.5) * volumeModifier * 127.0); + m_sQueueSample.m_nVolume = ComputeVolume(volume_4, 140.0, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + m_sQueueSample.m_nCounter = 1; if (hunterBool) { m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -3330,130 +3379,86 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); - LABEL_147: - if (boat) { - //489-568 - if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0 && speedMultiplied > 0.0) { //?? 525 andro - volume_3 = speedMultiplied * 100.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); - if (accelerate <= 0 && brake <= 0)//!! - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; - else - m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 2204; - if (speedMultiplied < 1.0) //?? - m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); - freqPrev_0 = m_sQueueSample.m_nFrequency; - if (m_sQueueSample.m_nVolume) { - m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nCounter = 12; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_3; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(464); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(464); - m_sQueueSample.m_fSpeedMultiplier = 5.0f; - m_sQueueSample.m_fSoundIntensity = 20.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 7; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - } - } - } else { - //573-645 - posBackup = m_sQueueSample.m_vecPos; - distCalcBool = params->m_bDistanceCalculated; - distance_3 = params->m_fDistance; - - m_sQueueSample.m_vecPos = pos; - params->m_bDistanceCalculated = false; - params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);//580-589 - if (params->m_fDistance < 729.0f) { //!! - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);//593-605 - volume_2 = 25.0f * volumeModifier; - m_sQueueSample.m_nVolume = ComputeVolume(volume_2, 27.0f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) {//!! - m_sQueueSample.m_nCounter = 2; - if (hunterBool)//!! - m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_3; - else - m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_REA; - m_sQueueSample.m_nBankIndex = 0; - m_sQueueSample.m_bIs2D = 0; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nFrequency = 16000.0f * volumeModifier + 16000; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_2; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 27.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; - AddSampleToRequestedQueue(); - } - } - - m_sQueueSample.m_vecPos = posBackup; - params->m_bDistanceCalculated = distCalcBool; - params->m_fDistance = distance_3; - } - cameraMatrix.~CMatrix(); - return; - } - m_sQueueSample.m_nCounter = 3; //347 andro - if (hunterBool) { //!! - m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_1; + if (boat) { + //489-568 + if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0f && speedMultiplied > 0.0f) { //?? 525 andro + volume_3 = speedMultiplied * 100.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); + if (accelerate <= 0 && brake <= 0)//!! + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; + else + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 2204; + if (speedMultiplied < 1.0) //?? + m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); + freqPrev_0 = m_sQueueSample.m_nFrequency; + if (m_sQueueSample.m_nVolume) { + m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nCounter = 12; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_3; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(464); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(464); + m_sQueueSample.m_fSpeedMultiplier = 5.0f; + m_sQueueSample.m_fSoundIntensity = 20.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 7; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } + } } else { - if (boat) { //!! - m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_1; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 140.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - goto LABEL_105; + //vacuum cleaner sound + posBackup = m_sQueueSample.m_vecPos; + distCalcBool = params->m_bDistanceCalculated; + distance_3 = params->m_fDistance; + + m_sQueueSample.m_vecPos = pos; + params->m_bDistanceCalculated = false; + params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);//580-589 + if (params->m_fDistance < 729.0f) { //!! + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);//593-605 + volume_2 = 25.0f * volumeModifier; + m_sQueueSample.m_nVolume = ComputeVolume(volume_2, 27.0f, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) {//!! + m_sQueueSample.m_nCounter = 2; + if (hunterBool)//!! + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_3; + else + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_REA; + m_sQueueSample.m_nBankIndex = 0; + m_sQueueSample.m_bIs2D = 0; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nFrequency = 16000.0f * volumeModifier + 16000; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume_2; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 27.0f; + m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } } - m_sQueueSample.m_nSampleIndex = 8; + + m_sQueueSample.m_vecPos = posBackup; + params->m_bDistanceCalculated = distCalcBool; + params->m_fDistance = distance_3; } - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_1; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 140.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - goto LABEL_105; - - + cameraMatrix.~CMatrix(); + return; } //TODO use it in ProcessVehicle -- cgit v1.2.3 From 6dfb32d285f40bbae86322689e24775343dfd626 Mon Sep 17 00:00:00 2001 From: shfil Date: Fri, 25 Sep 2020 13:56:15 +0200 Subject: Add link to steam store --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d336435..8d5b4c0c 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ such that we have a working game at all times. ## How can I try it? -- re3 requires game assets to work, so you **must** own a copy of GTA III. +- re3 requires game assets to work, so you **must** own [a copy of GTA III](https://store.steampowered.com/app/12100/Grand_Theft_Auto_III/). - Build re3 or download it from one of the above links (Debug or Release). - (Optional) If you want to use optional features like Russian language or menu map, copy the files in /gamefiles folder to your game root folder. - Move re3.exe to GTA 3 directory and run it. -- cgit v1.2.3 From 6e3523d59452a970d8d1ef88bcc1b998857fcd38 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 25 Sep 2020 23:27:28 +0300 Subject: flat tyre and minimal refractoring --- src/audio/AudioLogic.cpp | 187 ++++++++++++++++++++++++++++++++++------------- src/audio/AudioManager.h | 1 + 2 files changed, 138 insertions(+), 50 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 7089497d..3bc7f279 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -748,7 +748,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) switch (veh->GetVehicleAppearance()) { case VEHICLE_APPEARANCE_HELI: ProcessCarHeli(¶ms); - //ProcessVehicleFlatTyre(¶ms); + ProcessVehicleFlatTyre(¶ms); ProcessEngineDamage(¶ms); break; case VEHICLE_APPEARANCE_BOAT: @@ -760,7 +760,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) if (CWeather::WetRoads > 0.0) ProcessWetRoadNoise(¶ms); ProcessVehicleSkidding(¶ms); - //ProcessVehicleFlatTyre(params); + ProcessVehicleFlatTyre(¶ms); ProcessVehicleHorn(¶ms); ProcessVehicleSirenOrAlarm(¶ms); if (UsesReverseWarning(params.m_nIndex)) @@ -793,7 +793,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) case VEHICLE_TYPE_PLANE: ProcessPlane(¶ms); ProcessVehicleOneShots(¶ms); - //ProcessVehicleFlatType(¶ms); + ProcessVehicleFlatTyre(¶ms); break; case VEHICLE_TYPE_BIKE: bike = (CBike*)veh; @@ -807,7 +807,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) ProcessCarBombTick(¶ms); ProcessEngineDamage(¶ms); ProcessVehicleEngine(¶ms); - //ProcessVehicleFlatTyre(); + ProcessVehicleFlatTyre(¶ms); } ProcessVehicleOneShots(¶ms); bike->m_fVelocityChangeForAudio = params.m_fVelocityChange; @@ -3071,27 +3071,28 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) CAutomobile* automobile; // [esp+10h] [ebp-CCh] CBoat* boat; // [esp+1Ch] [ebp-C0h] - signed int volume_5; // ebx - unsigned int freqModifier; // eax signed int volume; // ebx - uint32 freq_6; // eax + signed int volume_5; // ebx signed int volume_3; // ebx - signed int volume_2; // ebx - char distCalcBool; // [esp+Ch] [ebp-D0h] + signed int volume_4; // [esp+28h] [ebp-B4h] + signed int volume_1; // [esp+2Ch] [ebp-B0h] + float volumeModifier; // [esp+40h] [ebp-9Ch] + + uint32 freq_6; // eax + unsigned int freqModifier; // eax signed int freqModifier_2; // [esp+14h] [ebp-C8h] + + bool distCalcBool; // [esp+Ch] [ebp-D0h] char hunterBool; // [esp+18h] [ebp-C4h] signed int brake; // [esp+20h] [ebp-BCh] signed int accelerate; // [esp+24h] [ebp-B8h] - signed int volume_4; // [esp+28h] [ebp-B4h] - signed int volume_1; // [esp+2Ch] [ebp-B0h] float vehAtYAbs; // [esp+34h] [ebp-A8h] float vehCameraDot; // [esp+38h] [ebp-A4h] float speedMultiplied; // [esp+3Ch] [ebp-A0h] - float volumeModifier; // [esp+40h] [ebp-9Ch] float distance_3; // [esp+44h] [ebp-98h] - CVector posBackup; // [esp+48h] [ebp-94h] + CVector posBackup; // [esp+48h] [ebp-94h] CMatrix cameraMatrix; // [esp+60h] [ebp-7Ch] CVector pos; // [esp+A8h] [ebp-34h] //CVector multipliedVector; // [esp+B4h] [ebp-28h] @@ -3186,6 +3187,9 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) AddSampleToRequestedQueue(); } } + + + //244- if (automobile) { //!! automobile->GetComponentWorldPosition(CAR_BOOT, pos); @@ -3194,6 +3198,7 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) //MatrixMultiplier.x = 0.0; //MatrixMultiplier.y = -10.0; //multipliedVector = params->m_pVehicle->m_matrix * MatrixMultiplier; + pos = { 0.0f, -10.0f, 0.0f }; } else { pos = m_sQueueSample.m_vecPos; } @@ -3217,32 +3222,10 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) if (veh->m_modelIndex == MI_HUNTER) //!! hunterBool = true; } - volume_1 = (1.0f - vehCameraDot) * volumeModifier * 127.0f; - //288-339 - if (boat) { //!! - if (accelerate <= 0 && brake <= 0) { //!! - //freqModifier_4 = 3713.0 * vehAtYAbs; - //if (freqModifier_4 > 3713)//!! - // freqModifier_4 = 3713; - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; //??? - } else { - m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, vehAtYAbs * (Max(accelerate, brake) / 255)) * 2204; - } - - if (speedMultiplied < 1.0) { //?? - //v27 = (double)(this_1->m_sQueueSample.m_nFrequency >> 1); - //this_1->m_sQueueSample.m_nFrequency = (signed __int64)(v27 * speedMultiplied + v27); - m_sQueueSample.m_nFrequency = (speedMultiplied + 1.0f) * m_sQueueSample.m_nFrequency / 2.0f; - } - - m_sQueueSample.m_nFrequency = m_sQueueSample.m_nFrequency < freqPrev ? - Max(m_sQueueSample.m_nFrequency, freqPrev - 197) : Min(m_sQueueSample.m_nFrequency, freqPrev + 197); - freqPrev = m_sQueueSample.m_nFrequency; - //TODO maybe clamp!!! - } //sound from front of helicopter + volume_1 = (1.0f - vehCameraDot) * volumeModifier * 127.0f; m_sQueueSample.m_nVolume = ComputeVolume(volume_1, 140.0f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 3; //347 andro @@ -3266,6 +3249,27 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) } else if (boat) { //!! m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; + + if (accelerate <= 0 && brake <= 0) { //!! + //freqModifier_4 = 3713.0 * vehAtYAbs; + //if (freqModifier_4 > 3713)//!! + // freqModifier_4 = 3713; + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; //??? + } else { + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, vehAtYAbs * (Max(accelerate, brake) / 255)) * 2204; + } + + if (speedMultiplied < 1.0) { //?? + //v27 = (double)(this_1->m_sQueueSample.m_nFrequency >> 1); + //this_1->m_sQueueSample.m_nFrequency = (signed __int64)(v27 * speedMultiplied + v27); + m_sQueueSample.m_nFrequency = (speedMultiplied + 1.0f) * m_sQueueSample.m_nFrequency / 2.0f; + } + + m_sQueueSample.m_nFrequency = m_sQueueSample.m_nFrequency < freqPrev ? + Max(m_sQueueSample.m_nFrequency, freqPrev - 197) : Min(m_sQueueSample.m_nFrequency, freqPrev + 197); + freqPrev = m_sQueueSample.m_nFrequency; + //TODO maybe clamp!!! + m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; @@ -3299,6 +3303,8 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) } } + + if (!boat && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance < 30.0f) { //!! //engine starting sound if (automobile->bEngineOn) { @@ -3337,20 +3343,8 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) - if (boat) { - if (accelerate <= 0 && brake <= 0) //!! - m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857; - else - m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102; - - if (speedMultiplied < 1.0) //?? - m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); - - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98); - freqPrev_1 = m_sQueueSample.m_nFrequency; - } //after accel rotor sound - volume_4 = ((0.5 * vehCameraDot + 0.5) * volumeModifier * 127.0); + volume_4 = ((vehCameraDot + 1) * volumeModifier * 127.0f) / 2; m_sQueueSample.m_nVolume = ComputeVolume(volume_4, 140.0, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 1; @@ -3361,6 +3355,17 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) } else if (boat) { m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; + + if (accelerate <= 0 && brake <= 0) //!! + m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857; + else + m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102; + + if (speedMultiplied < 1.0) //?? + m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); + + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98); + freqPrev_1 = m_sQueueSample.m_nFrequency; } else { m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -3383,12 +3388,12 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) - if (boat) { //489-568 if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0f && speedMultiplied > 0.0f) { //?? 525 andro volume_3 = speedMultiplied * 100.0f; m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); + if (accelerate <= 0 && brake <= 0)//!! m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; else @@ -3397,6 +3402,7 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); freqPrev_0 = m_sQueueSample.m_nFrequency; + if (m_sQueueSample.m_nVolume) { m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -3461,6 +3467,87 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) return; } +void +cAudioManager::ProcessVehicleFlatTyre(cVehicleParams* params) +{ + CAutomobile* automobile; + CBike* bike; + + + cAudioManager* this_1; // ebp + int vehType; // edx + unsigned __int8 j; // dl + float tmp_2; // ST1C_4 + double tmp_4; // st6 + float tmp_3; + signed int volume; // ebx + bool someBool; // [esp+4h] [ebp-20h] + float modifier; // [esp+Ch] [ebp-18h] + + this_1 = this; + someBool = 0; + if (params->m_fDistance >= 3600.0) + return; + + vehType = params->m_VehicleType; + switch (params->m_VehicleType) { + case 0: + automobile = (CAutomobile*)params->m_pVehicle; + someBool = false; + for (int i = 0; i < 4; i++) + if (automobile->Damage.GetWheelStatus(i) == 1 && automobile->m_aWheelTimer[i] > 0.0) + someBool = true; + if (!someBool) + //return; + break; + case 5: + bike = (CBike*)params->m_pVehicle; + someBool = false; + for(int i = 0; i < 2; i++) + if (bike->m_wheelStatus[i] == 1 && bike->m_aWheelTimer[i] > 0.0) + someBool = true; + if (!someBool) + return; + break; + default: + return; + } + + tmp_2 = fabs(params->m_fVelocityChange); + if (tmp_2 / (0.3 * params->m_pTransmission->fMaxVelocity) <= 1.0) { //!! + tmp_3 = fabs(params->m_fVelocityChange); + tmp_4 = tmp_3 / (0.3 * params->m_pTransmission->fMaxVelocity); + } else { + tmp_4 = 1.0; + } + modifier = tmp_4+0.5f; + if (modifier > 0.01) { //!! + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + volume = (100.0 * modifier); + this_1->m_sQueueSample.m_nVolume = ComputeVolume(volume, 60.0, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) { + m_sQueueSample.m_nCounter = 95; + m_sQueueSample.m_nBankIndex = 0; + m_sQueueSample.m_bIs2D = 0; + m_sQueueSample.m_nReleasingVolumeModificator = 5; + m_sQueueSample.m_nSampleIndex = SFX_TYRE_BURST_L; + m_sQueueSample.m_nFrequency = (5500.0f * modifier) + + 8000; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_TYRE_BURST_L); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_TYRE_BURST_L); + m_sQueueSample.m_fSpeedMultiplier = 2.0; + m_sQueueSample.m_fSoundIntensity = 60.0; + m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } +} + //TODO use it in ProcessVehicle void cAudioManager::ProcessPlane(cVehicleParams *params) diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index cae606fd..aa7c80ec 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -332,6 +332,7 @@ public: void ProcessGarages(); bool ProcessHelicopter(cVehicleParams *params); void ProcessCarHeli(cVehicleParams* params); + void ProcessVehicleFlatTyre(cVehicleParams* params); void ProcessJumbo(cVehicleParams *); void ProcessJumboAccel(CPlane *plane); void ProcessJumboDecel(CPlane *plane); -- cgit v1.2.3 From 0ce8082bdaac94f127f6783023b99d6d4cf8e297 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 26 Sep 2020 00:24:30 +0300 Subject: Fix OpenGL Z-write --- src/core/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/main.cpp b/src/core/main.cpp index 99868dbd..5fea9c4b 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -757,12 +757,13 @@ DisplayGameDebugText() { static bool bDisplayPosn = false; static bool bDisplayRate = false; - +#ifndef FINAL { SETTWEAKPATH("GameDebugText"); TWEAKBOOL(bDisplayPosn); TWEAKBOOL(bDisplayRate); } +#endif char str[200]; @@ -1111,6 +1112,7 @@ Idle(void *arg) #endif #ifdef FIX_BUGS + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE); // TODO: temp? this fixes OpenGL render but there should be a better place for this // This has to be done BEFORE RwCameraBeginUpdate RwCameraSetFarClipPlane(Scene.camera, CTimeCycle::GetFarClip()); RwCameraSetFogDistance(Scene.camera, CTimeCycle::GetFogStart()); -- cgit v1.2.3 From a75ddd0d0ca4465f9b10305045b18dbecc76e504 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sat, 26 Sep 2020 04:10:00 +0300 Subject: processVehicleOneShots for heli, and heli blade fix --- src/audio/AudioLogic.cpp | 23 ++++++++++++++++++++++- src/vehicles/Automobile.cpp | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 3bc7f279..10e0c78b 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -2349,6 +2349,8 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) static uint8 GunIndex = 53; static uint8 iWheelIndex = 82; static uint8 CrunchOffset = 0; + static uint8 heliIndex = 0; + for (int i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; i++) { noReflections = 0; @@ -2623,6 +2625,25 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) emittingVol = m_anRandomTable[4] % 25 + 75; break; } + case SOUND_31:{ + const float SOUND_INTENSITY = 35.0f; + relVol = ((CAutomobile*)params->m_pVehicle)->m_aWheelSpeed[1] * 50.0f / 11.0f; + if (relVol < 0.2 || 1.0 == relVol) + continue; + relVol /= 20; + emittingVol = (1.0f - relVol) * 70.0f; + maxDist = SQR(SOUND_INTENSITY); + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_ROT; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nCounter = heliIndex + 89; + heliIndex = heliIndex != 1 ? heliIndex + 1 : 0; + m_sQueueSample.m_nFrequency = (8000.0f * relVol) + 16000; + m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); + m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_fSpeedMultiplier = 0.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + break; + } case SOUND_WEAPON_SHOT_FIRED: { const float SOUND_INTENSITY = 120.0f; emittingVol = m_anRandomTable[2]; @@ -3498,7 +3519,7 @@ cAudioManager::ProcessVehicleFlatTyre(cVehicleParams* params) if (automobile->Damage.GetWheelStatus(i) == 1 && automobile->m_aWheelTimer[i] > 0.0) someBool = true; if (!someBool) - //return; + return; break; case 5: bike = (CBike*)params->m_pVehicle; diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index eec44c35..0154ae05 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -1486,7 +1486,7 @@ CAutomobile::ProcessControl(void) CMatrix mat; mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_BONNET])); CVector blade = mat.GetRight(); - blade = GetMatrix() * blade; + blade = Multiply3x3(blade, GetMatrix()); camDist /= Max(Sqrt(distSq), 0.01f); if(Abs(DotProduct(camDist, blade)) > 0.95f){ DMAudio.PlayOneShot(m_audioEntityId, SOUND_31, 0.0f); -- cgit v1.2.3 From 3f0a80f7c75e62a868362a0ab95b0497b41768c9 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 26 Sep 2020 05:10:22 +0300 Subject: Fix MASTER build with glfw --- src/skel/glfw/glfw.cpp | 86 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 920bb8a9..f5fd4474 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1,5 +1,15 @@ #if defined RW_GL3 && !defined LIBRW_SDL2 +#ifdef _WIN32 +#include +#include +#include +#include +#include +#include +#include +#endif + #define WITHWINDOWS #include "common.h" @@ -1180,7 +1190,11 @@ void resizeCB(GLFWwindow* window, int width, int height) { * memory things don't work. */ /* redraw window */ - if (RwInitialised && (gGameState == GS_PLAYING_GAME || gGameState == GS_ANIMVIEWER)) + if (RwInitialised && (gGameState == GS_PLAYING_GAME +#ifndef MASTER + || gGameState == GS_ANIMVIEWER +#endif + )) { RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void*)TRUE); } @@ -1610,6 +1624,72 @@ main(int argc, char *argv[]) break; } + case GS_INIT_LOGO_MPEG: + { + //if (!startupDeactivate) + // PlayMovieInWindow(cmdShow, "movies\\Logo.mpg"); + gGameState = GS_LOGO_MPEG; + TRACE("gGameState = GS_LOGO_MPEG;"); + break; + } + + case GS_LOGO_MPEG: + { +// CPad::UpdatePads(); + +// if (startupDeactivate || ControlsManager.GetJoyButtonJustDown() != 0) + ++gGameState; +// else if (CPad::GetPad(0)->GetLeftMouseJustDown()) +// ++gGameState; +// else if (CPad::GetPad(0)->GetEnterJustDown()) +// ++gGameState; +// else if (CPad::GetPad(0)->GetCharJustDown(' ')) +// ++gGameState; +// else if (CPad::GetPad(0)->GetAltJustDown()) +// ++gGameState; +// else if (CPad::GetPad(0)->GetTabJustDown()) +// ++gGameState; + + break; + } + + case GS_INIT_INTRO_MPEG: + { +//#ifndef NO_MOVIES +// CloseClip(); +// CoUninitialize(); +//#endif +// +// if (CMenuManager::OS_Language == LANG_FRENCH || CMenuManager::OS_Language == LANG_GERMAN) +// PlayMovieInWindow(cmdShow, "movies\\GTAtitlesGER.mpg"); +// else +// PlayMovieInWindow(cmdShow, "movies\\GTAtitles.mpg"); + + gGameState = GS_INTRO_MPEG; + TRACE("gGameState = GS_INTRO_MPEG;"); + break; + } + + case GS_INTRO_MPEG: + { +// CPad::UpdatePads(); +// +// if (startupDeactivate || ControlsManager.GetJoyButtonJustDown() != 0) + ++gGameState; +// else if (CPad::GetPad(0)->GetLeftMouseJustDown()) +// ++gGameState; +// else if (CPad::GetPad(0)->GetEnterJustDown()) +// ++gGameState; +// else if (CPad::GetPad(0)->GetCharJustDown(' ')) +// ++gGameState; +// else if (CPad::GetPad(0)->GetAltJustDown()) +// ++gGameState; +// else if (CPad::GetPad(0)->GetTabJustDown()) +// ++gGameState; + + break; + } + case GS_INIT_ONCE: { //CoUninitialize(); @@ -1818,8 +1898,10 @@ main(int argc, char *argv[]) { if ( gGameState == GS_PLAYING_GAME ) CGame::ShutDown(); +#ifndef MASTER else if ( gGameState == GS_ANIMVIEWER ) CAnimViewer::Shutdown(); +#endif CTimer::Stop(); @@ -1843,8 +1925,10 @@ main(int argc, char *argv[]) if ( gGameState == GS_PLAYING_GAME ) CGame::ShutDown(); +#ifndef MASTER else if ( gGameState == GS_ANIMVIEWER ) CAnimViewer::Shutdown(); +#endif DMAudio.Terminate(); -- cgit v1.2.3 From e256eaf0149d9851c87ac236772f9a57a6b39010 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sat, 26 Sep 2020 05:41:10 +0300 Subject: cleanup carHeli --- src/audio/AudioLogic.cpp | 235 +++++++++++++++++++---------------------------- 1 file changed, 92 insertions(+), 143 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 10e0c78b..3b7f55ec 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -2628,9 +2628,8 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_31:{ const float SOUND_INTENSITY = 35.0f; relVol = ((CAutomobile*)params->m_pVehicle)->m_aWheelSpeed[1] * 50.0f / 11.0f; - if (relVol < 0.2 || 1.0 == relVol) + if (relVol < 0.2f || 1.0f == relVol) continue; - relVol /= 20; emittingVol = (1.0f - relVol) * 70.0f; maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_ROT; @@ -3085,19 +3084,19 @@ cAudioManager::ProcessHelicopter(cVehicleParams *params) return true; } -void cAudioManager::ProcessCarHeli(cVehicleParams* params) +void +cAudioManager::ProcessCarHeli(cVehicleParams* params) { + const float SOUND_INTENSITY = 250.0f; + CVehicle* playerVeh; // eax CVehicle* veh; // ecx CAutomobile* automobile; // [esp+10h] [ebp-CCh] CBoat* boat; // [esp+1Ch] [ebp-C0h] signed int volume; // ebx - signed int volume_5; // ebx signed int volume_3; // ebx signed int volume_2; // ebx - signed int volume_4; // [esp+28h] [ebp-B4h] - signed int volume_1; // [esp+2Ch] [ebp-B0h] float volumeModifier; // [esp+40h] [ebp-9Ch] uint32 freq_6; // eax @@ -3114,7 +3113,6 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) float distance_3; // [esp+44h] [ebp-98h] CVector posBackup; // [esp+48h] [ebp-94h] - CMatrix cameraMatrix; // [esp+60h] [ebp-7Ch] CVector pos; // [esp+A8h] [ebp-34h] //CVector multipliedVector; // [esp+B4h] [ebp-28h] //CVector MatrixMultiplier; // [esp+C0h] [ebp-1Ch] @@ -3123,18 +3121,13 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) static uint32 freqPrev_1 = 7143; static uint32 freqPrev_0 = 14287; - const float CarHeliDistance = 250.0f; - boat = nil; - hunterBool = false; automobile = nil; - cameraMatrix.m_attachment = 0; - cameraMatrix.m_hasRwMatrix = 0; + hunterBool = false; - if (params->m_fDistance >= SQR(CarHeliDistance)) {//!! - cameraMatrix.~CMatrix(); + if (params->m_fDistance >= SQR(SOUND_INTENSITY)) return; - } + playerVeh = FindPlayerVehicle(); veh = params->m_pVehicle; if (playerVeh == veh) { @@ -3144,50 +3137,43 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) accelerate = veh->m_fGasPedal * 255.0f; brake = veh->m_fBrakePedal * 255.0f; } - cameraMatrix = TheCamera.m_matrix; vehAtYAbs = Abs(veh->m_matrix.GetUp().y); - vehCameraDot = (DotProduct(veh->m_matrix.GetForward(), cameraMatrix.GetForward()) + 1.0f) / 2.0f; - if (veh->m_modelIndex == MI_SKIMMER) {//!! - boat = (CBoat*)params->m_pVehicle; + vehCameraDot = (DotProduct(veh->m_matrix.GetForward(), TheCamera.GetForward()) + 1.0f) / 2.0f; + if (veh->m_modelIndex == MI_SKIMMER) { + boat = (CBoat*)veh; speedMultiplied = boat->m_fMovingSpeed * 50.0f / 11.0f; - } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) {//!! + } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) { speedMultiplied = 1.0f; } else { - automobile = (CAutomobile*)params->m_pVehicle; + automobile = (CAutomobile*)veh; speedMultiplied = automobile->m_aWheelSpeed[1] * 50.0f / 11.0f; } - if (speedMultiplied == 0.0f) {//?? - cameraMatrix.~CMatrix(); + + if (speedMultiplied == 0.0f) return; - } + speedMultiplied = Min(1.0f, speedMultiplied); CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - if (m_sQueueSample.m_fDistance >= 40.0f) //!! + //sound on long distances + if (m_sQueueSample.m_fDistance >= 40.0f) volume = speedMultiplied * 75.0f; - else if (m_sQueueSample.m_fDistance >= 25.0f) //!! + else if (m_sQueueSample.m_fDistance >= 25.0f) volume = (m_sQueueSample.m_fDistance - 25.0f) * 0.06666667f * (75.0f * speedMultiplied); else volume = 0; - - - - //on height distance - if (volume != 0) {//!! - m_sQueueSample.m_nVolume = ComputeVolume(volume, 250.0f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume != 0) { //!! + if (volume != 0) { + m_sQueueSample.m_nVolume = ComputeVolume(volume, SOUND_INTENSITY, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 88; - if (boat != nil) { //!! + if (boat != nil) { m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO3; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerate <= 0 && brake <= 0) { //!! - freqModifier = Min(1.0f, vehAtYAbs) * 949;//??? - m_sQueueSample.m_nFrequency = 3651 + freqModifier; - } else { - freqModifier = Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 563; - m_sQueueSample.m_nFrequency = 4600 + freqModifier; - } + if (accelerate <= 0 && brake <= 0) + m_sQueueSample.m_nFrequency = 3651 + Min(1.0f, vehAtYAbs) * 949; + else + m_sQueueSample.m_nFrequency = 4600 + Min(1.0f, (Max(accelerate, brake) / 255.0f) * vehAtYAbs) * 563; } else { m_sQueueSample.m_nSampleIndex = SFX_HELI_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -3200,64 +3186,44 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 250.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); } } - - - //244- - if (automobile) { //!! - automobile->GetComponentWorldPosition(CAR_BOOT, pos); - } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) { //!! - //MatrixMultiplier.z = 0.0; - //MatrixMultiplier.x = 0.0; - //MatrixMultiplier.y = -10.0; - //multipliedVector = params->m_pVehicle->m_matrix * MatrixMultiplier; - pos = { 0.0f, -10.0f, 0.0f }; - } else { - pos = m_sQueueSample.m_vecPos; - } - - - //263-270 - if (params->m_fDistance >= 19600.0f) { //?? - cameraMatrix.~CMatrix(); + if (params->m_fDistance >= 19600.0f) return; - } - if (speedMultiplied >= 0.4f) //?? + if (speedMultiplied >= 0.4f) volumeModifier = (speedMultiplied - 0.4f) * 5.0f / 3.0f; else volumeModifier = 0.0f; - //270-286 - if (!boat) { //!! + if (!boat) { freqModifier_2 = Min(1300, 7000.0f * vehAtYAbs); - if (playerVeh == veh && (accelerate > 0 || brake > 0) && freqModifier_2 < 1300) //!! + if (playerVeh == veh && (accelerate > 0 || brake > 0) && freqModifier_2 < 1300)//unnesesary freqModifier alredy <= 1300 freqModifier_2 = 1300; - if (veh->m_modelIndex == MI_HUNTER) //!! + if (veh->m_modelIndex == MI_HUNTER) hunterBool = true; } //sound from front of helicopter - volume_1 = (1.0f - vehCameraDot) * volumeModifier * 127.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume_1, 140.0f, m_sQueueSample.m_fDistance); + volume = (1.0f - vehCameraDot) * volumeModifier * 127.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume, 140.0f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { - m_sQueueSample.m_nCounter = 3; //347 andro - if (hunterBool) { //!! + m_sQueueSample.m_nCounter = 3; + if (hunterBool) { m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; + m_sQueueSample.m_nFrequency = (volumeModifier + 1.0f) * 16000 + freqModifier_2; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nEmittingVolume = volume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3267,34 +3233,22 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); - } else if (boat) { //!! + } else if (boat != nil) { m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerate <= 0 && brake <= 0) { //!! - //freqModifier_4 = 3713.0 * vehAtYAbs; - //if (freqModifier_4 > 3713)//!! - // freqModifier_4 = 3713; - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; //??? - } else { - m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, vehAtYAbs * (Max(accelerate, brake) / 255)) * 2204; - } - - if (speedMultiplied < 1.0) { //?? - //v27 = (double)(this_1->m_sQueueSample.m_nFrequency >> 1); - //this_1->m_sQueueSample.m_nFrequency = (signed __int64)(v27 * speedMultiplied + v27); - m_sQueueSample.m_nFrequency = (speedMultiplied + 1.0f) * m_sQueueSample.m_nFrequency / 2.0f; - } - - m_sQueueSample.m_nFrequency = m_sQueueSample.m_nFrequency < freqPrev ? - Max(m_sQueueSample.m_nFrequency, freqPrev - 197) : Min(m_sQueueSample.m_nFrequency, freqPrev + 197); - freqPrev = m_sQueueSample.m_nFrequency; - //TODO maybe clamp!!! + if (accelerate <= 0 && brake <= 0) + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; + else + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, vehAtYAbs * (Max(accelerate, brake) / 255.0f)) * 2204; + if (speedMultiplied < 1.0f) + m_sQueueSample.m_nFrequency = (speedMultiplied + 1.0f) * (m_sQueueSample.m_nFrequency / 2.0f); + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev - 197, freqPrev + 197); m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nEmittingVolume = volume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3311,7 +3265,7 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_1; + m_sQueueSample.m_nEmittingVolume = volume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3325,13 +3279,12 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) } - - if (!boat && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance < 30.0f) { //!! - //engine starting sound + //engine starting sound + if (boat == nil && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance < 30.0f) { //strange way to check if automobile != nil if (automobile->bEngineOn) { if (speedMultiplied < 1.0f) { - volume_5 = (1.0f - 0.5f * speedMultiplied) * 70.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume_5, 30.0, m_sQueueSample.m_fDistance); + volume = (1.0f - speedMultiplied / 2.0f) * 70.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume, 30.0, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume) { if (hunterBool) { m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_4; @@ -3347,7 +3300,7 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_5; + m_sQueueSample.m_nEmittingVolume = volume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3365,8 +3318,8 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) //after accel rotor sound - volume_4 = ((vehCameraDot + 1) * volumeModifier * 127.0f) / 2; - m_sQueueSample.m_nVolume = ComputeVolume(volume_4, 140.0, m_sQueueSample.m_fDistance); + volume = ((vehCameraDot + 1.0f) * volumeModifier * 127.0f) / 2.0f; + m_sQueueSample.m_nVolume = ComputeVolume(volume, 140.0, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 1; if (hunterBool) { @@ -3377,12 +3330,12 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerate <= 0 && brake <= 0) //!! + if (accelerate <= 0 && brake <= 0) m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857; else m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102; - if (speedMultiplied < 1.0) //?? + if (speedMultiplied < 1.0f) m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98); @@ -3395,7 +3348,7 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_4; + m_sQueueSample.m_nEmittingVolume = volume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3410,30 +3363,28 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) if (boat) { - //489-568 - if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0f && speedMultiplied > 0.0f) { //?? 525 andro - volume_3 = speedMultiplied * 100.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); + if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FIXED && m_sQueueSample.m_fDistance < 20.0f && speedMultiplied > 0.0f) { + m_sQueueSample.m_nVolume = ComputeVolume(speedMultiplied * 100.0f, 20.0f, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) { - if (accelerate <= 0 && brake <= 0)//!! - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; - else - m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 2204; - if (speedMultiplied < 1.0) //?? - m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); - freqPrev_0 = m_sQueueSample.m_nFrequency; + if (accelerate <= 0 && brake <= 0) + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; + else + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255.0f) * vehAtYAbs) * 2204; + if (speedMultiplied < 1.0) + m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2.0f); + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); + freqPrev_0 = m_sQueueSample.m_nFrequency; - if (m_sQueueSample.m_nVolume) { m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 12; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_3; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(464); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(464); + m_sQueueSample.m_nEmittingVolume = speedMultiplied * 100.0f; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_SEAPLANE_PRO4); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_SEAPLANE_PRO4); m_sQueueSample.m_fSpeedMultiplier = 5.0f; m_sQueueSample.m_fSoundIntensity = 20.0f; m_sQueueSample.m_bReleasingSoundFlag = false; @@ -3449,33 +3400,33 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) distCalcBool = params->m_bDistanceCalculated; distance_3 = params->m_fDistance; - m_sQueueSample.m_vecPos = pos; + if (automobile != nil) + automobile->GetComponentWorldPosition(CAR_BOOT, m_sQueueSample.m_vecPos); + else if (params->m_VehicleType == VEHICLE_TYPE_HELI) + m_sQueueSample.m_vecPos = { 0.0f, -10.0f, 0.0f }; //this is from android, but for real it's not used + params->m_bDistanceCalculated = false; - params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);//580-589 - if (params->m_fDistance < 729.0f) { //!! - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);//593-605 - volume_2 = 25.0f * volumeModifier; - m_sQueueSample.m_nVolume = ComputeVolume(volume_2, 27.0f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) {//!! + params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); + if (params->m_fDistance < 729.0f) { + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(volumeModifier * 25.0f, 27.0f, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) { m_sQueueSample.m_nCounter = 2; - if (hunterBool)//!! - m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_3; - else - m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_REA; + m_sQueueSample.m_nSampleIndex = hunterBool ? SFX_HELI_APACHE_3 : SFX_CAR_HELI_REA; m_sQueueSample.m_nBankIndex = 0; m_sQueueSample.m_bIs2D = 0; m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nFrequency = 16000.0f * volumeModifier + 16000; + m_sQueueSample.m_nFrequency = (volumeModifier + 1.0f) * 16000; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume_2; + m_sQueueSample.m_nEmittingVolume = volumeModifier * 25.0f; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = 27.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); } } @@ -3484,8 +3435,6 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params) params->m_bDistanceCalculated = distCalcBool; params->m_fDistance = distance_3; } - cameraMatrix.~CMatrix(); - return; } void -- cgit v1.2.3 From b42d9e3e7c1caf6ad06ad81eb34cc27e09bd9bb9 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 26 Sep 2020 13:30:22 +0300 Subject: silentpatch fixes --- src/control/Garages.cpp | 6 ++++++ src/core/Camera.cpp | 8 ++++---- src/core/CdStream.cpp | 4 +++- src/core/Radar.cpp | 12 ++++++++++++ src/skel/win/win.cpp | 17 ++++++++++++++++- src/vehicles/DamageManager.cpp | 2 ++ src/weapons/Weapon.cpp | 3 +++ vendor/opusfile | 2 +- 8 files changed, 47 insertions(+), 7 deletions(-) diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index c9112f81..e1f06c97 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -1886,7 +1886,13 @@ CVehicle* CStoredCar::RestoreCar() #ifdef FIX_BUGS if (pVehicle->IsCar()) #endif + { ((CAutomobile*)pVehicle)->m_bombType = m_nCarBombType; +#ifdef FIX_BUGS + if (m_nCarBombType != CARBOMB_NONE) + ((CAutomobile*)pVehicle)->m_pBombRigger = FindPlayerPed(); +#endif + } pVehicle->bHasBeenOwnedByPlayer = true; pVehicle->m_nDoorLock = CARLOCK_UNLOCKED; pVehicle->bBulletProof = m_bBulletproof; diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index abe0833e..8f6fb3eb 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -74,7 +74,7 @@ bool bDidWeProcessAnyCinemaCam; CCamera::CCamera(void) { -#ifdef GTA3_1_1_PATCH +#if defined(GTA3_1_1_PATCH) || defined(FIX_BUGS) m_fMouseAccelHorzntl = 0.0025f; m_fMouseAccelVertical = 0.003f; #endif @@ -88,7 +88,7 @@ CCamera::CCamera(float) void CCamera::Init(void) { -#ifdef GTA3_1_1_PATCH +#if defined(GTA3_1_1_PATCH) || defined(FIX_BUGS) float fMouseAccelHorzntl = m_fMouseAccelHorzntl; float fMouseAccelVertical = m_fMouseAccelVertical; #endif @@ -104,7 +104,7 @@ CCamera::Init(void) memset(this, 0, sizeof(CCamera)); // getting rid of vtable, eh? #endif - #ifdef GTA3_1_1_PATCH + #if defined(GTA3_1_1_PATCH) || defined(FIX_BUGS) m_fMouseAccelHorzntl = fMouseAccelHorzntl; m_fMouseAccelVertical = fMouseAccelVertical; #endif @@ -237,7 +237,7 @@ CCamera::Init(void) m_uiTransitionState = 0; m_uiTimeTransitionStart = 0; m_bLookingAtPlayer = true; -#ifndef GTA3_1_1_PATCH +#if !defined(GTA3_1_1_PATCH) && !defined(FIX_BUGS) m_fMouseAccelHorzntl = 0.0025f; m_fMouseAccelVertical = 0.003f; #endif diff --git a/src/core/CdStream.cpp b/src/core/CdStream.cpp index d9978040..c11fb72a 100644 --- a/src/core/CdStream.cpp +++ b/src/core/CdStream.cpp @@ -106,12 +106,14 @@ CdStreamInit(int32 numChannels) GetDiskFreeSpace(nil, &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters); _gdwCdStreamFlags = 0; - + +#ifndef FIX_BUGS // this just slows down streaming if ( BytesPerSector <= CDSTREAM_SECTOR_SIZE ) { _gdwCdStreamFlags |= FILE_FLAG_NO_BUFFERING; debug("Using no buffered loading for streaming\n"); } +#endif _gbCdStreamOverlapped = TRUE; diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 05002a3f..af28aae7 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -1100,6 +1100,10 @@ int CRadar::SetCoordBlip(eBlipType type, CVector pos, int32 color, eBlipDisplay if (!ms_RadarTrace[nextBlip].m_bInUse) break; } +#ifdef FIX_BUGS + if (nextBlip == NUMRADARBLIPS) + return -1; +#endif ms_RadarTrace[nextBlip].m_eBlipType = type; ms_RadarTrace[nextBlip].m_nColor = color; ms_RadarTrace[nextBlip].m_bDim = 1; @@ -1121,6 +1125,10 @@ int CRadar::SetEntityBlip(eBlipType type, int32 handle, int32 color, eBlipDispla if (!ms_RadarTrace[nextBlip].m_bInUse) break; } +#ifdef FIX_BUGS + if (nextBlip == NUMRADARBLIPS) + return -1; +#endif ms_RadarTrace[nextBlip].m_eBlipType = type; ms_RadarTrace[nextBlip].m_nColor = color; ms_RadarTrace[nextBlip].m_bDim = 1; @@ -1452,6 +1460,10 @@ CRadar::ToggleTargetMarker(float x, float y) if (!ms_RadarTrace[nextBlip].m_bInUse) break; } +#ifdef FIX_BUGS + if (nextBlip == NUMRADARBLIPS) + return; +#endif ms_RadarTrace[nextBlip].m_eBlipType = BLIP_COORD; ms_RadarTrace[nextBlip].m_nColor = 0x333333FF; ms_RadarTrace[nextBlip].m_bDim = 1; diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index e79a8150..03eb0d09 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -1095,8 +1095,11 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) if ( wParam == VK_SHIFT ) _InputTranslateShiftKeyUpDown(&ks); - +#ifdef FIX_BUGS + break; +#else return 0L; +#endif } case WM_KEYUP: @@ -1109,7 +1112,11 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) if ( wParam == VK_SHIFT ) _InputTranslateShiftKeyUpDown(&ks); +#ifdef FIX_BUGS + break; +#else return 0L; +#endif } case WM_SYSKEYDOWN: @@ -1122,7 +1129,11 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) if ( wParam == VK_SHIFT ) _InputTranslateShiftKeyUpDown(&ks); +#ifdef FIX_BUGS + break; +#else return 0L; +#endif } case WM_SYSKEYUP: @@ -1135,7 +1146,11 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) if ( wParam == VK_SHIFT ) _InputTranslateShiftKeyUpDown(&ks); +#ifdef FIX_BUGS + break; +#else return 0L; +#endif } case WM_ACTIVATEAPP: diff --git a/src/vehicles/DamageManager.cpp b/src/vehicles/DamageManager.cpp index c625a4e7..56034dee 100644 --- a/src/vehicles/DamageManager.cpp +++ b/src/vehicles/DamageManager.cpp @@ -42,8 +42,10 @@ CDamageManager::FuckCarCompletely(void) #endif } // Why set to no damage? +#ifndef FIX_BUGS m_lightStatus = 0; m_panelStatus = 0; +#endif SetEngineStatus(250); } diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp index aea14f6a..37f59c95 100644 --- a/src/weapons/Weapon.cpp +++ b/src/weapons/Weapon.cpp @@ -1608,6 +1608,9 @@ CWeapon::FireM16_1stPerson(CEntity *shooter) if ( shooter == FindPlayerPed() ) { +#ifdef FIX_BUGS + CStats::InstantHitsFiredByPlayer++; +#endif CPad::GetPad(0)->StartShake_Distance(240, 128, FindPlayerPed()->GetPosition().x, FindPlayerPed()->GetPosition().y, FindPlayerPed()->GetPosition().z); if ( m_eWeaponType == WEAPONTYPE_M16 ) diff --git a/vendor/opusfile b/vendor/opusfile index 6452e838..f94a1764 160000 --- a/vendor/opusfile +++ b/vendor/opusfile @@ -1 +1 @@ -Subproject commit 6452e838e68e8f4fc0b3599523c760ac6276ce89 +Subproject commit f94a1764b0dcdd84ee8c13c040de9f4c1a67e4df -- cgit v1.2.3 From 2eb2e9ac12e66d3520d88547037217b53997b1fb Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 26 Sep 2020 14:12:42 +0300 Subject: fixed tab --- src/core/Camera.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 8f6fb3eb..13d03213 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -104,7 +104,7 @@ CCamera::Init(void) memset(this, 0, sizeof(CCamera)); // getting rid of vtable, eh? #endif - #if defined(GTA3_1_1_PATCH) || defined(FIX_BUGS) + #if defined(GTA3_1_1_PATCH) || defined(FIX_BUGS) m_fMouseAccelHorzntl = fMouseAccelHorzntl; m_fMouseAccelVertical = fMouseAccelVertical; #endif -- cgit v1.2.3 From 05e65baabe3e941cbbb546f546bae8719974b00f Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 26 Sep 2020 14:21:51 +0300 Subject: Fix coronas reflections --- src/render/Coronas.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/render/Coronas.cpp b/src/render/Coronas.cpp index d2d229f9..33c3f4bf 100644 --- a/src/render/Coronas.cpp +++ b/src/render/Coronas.cpp @@ -476,7 +476,11 @@ CCoronas::RenderReflections(void) int intensity = distanceFade*heightFade * 230.0 * CWeather::WetRoads; CSprite::RenderBufferedOneXLUSprite( +#ifdef FIX_BUGS + spriteCoors.x, spriteCoors.y, spriteCoors.z, +#else spriteCoors.x, spriteCoors.y, RwIm2DGetNearScreenZ(), +#endif spritew * aCoronas[i].size * 0.75f, spriteh * aCoronas[i].size * 2.0f, (intensity * CCoronas::aCoronas[i].red)>>8, -- cgit v1.2.3 From 1bd497effcceeecf2873c3b2e33f3006cf986cf8 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sat, 26 Sep 2020 06:52:15 +0300 Subject: complete cleanup heli and flatTyre --- src/audio/AudioLogic.cpp | 385 +++++++++++++++++++---------------------------- src/audio/AudioManager.h | 1 - 2 files changed, 154 insertions(+), 232 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 3b7f55ec..45f9b81b 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -3034,92 +3034,33 @@ struct tHelicopterSampleData { uint8 m_bBaseVolume; }; -bool -cAudioManager::ProcessHelicopter(cVehicleParams *params) -{ - CHeli *heli; - float MaxDist; - float dist; - float baseDist; - int32 emittingVol; - static const tHelicopterSampleData gHeliSfxRanges[3] = {{400.f, 380.f, 100}, {100.f, 70.f, MAX_VOLUME}, {60.f, 30.f, MAX_VOLUME}}; - - if (SQR(gHeliSfxRanges[0].m_fMaxDistance) <= params->m_fDistance) - return false; - - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - heli = (CHeli *)params->m_pVehicle; - for (uint32 i = 0; i < ARRAY_SIZE(gHeliSfxRanges); i++) { - MaxDist = gHeliSfxRanges[i].m_fMaxDistance; - dist = m_sQueueSample.m_fDistance; - if (dist >= MaxDist) - return true; - baseDist = gHeliSfxRanges[i].m_fBaseDistance; - if (dist < baseDist) - emittingVol = (gHeliSfxRanges[i].m_bBaseVolume * ((MaxDist - dist) / (MaxDist - baseDist))); - else - 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) { - m_sQueueSample.m_nCounter = i + 65; - 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_nFrequency = 1200 * heli->m_nHeliId + SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = gHeliSfxRanges[i].m_fMaxDistance; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - } - } - return true; -} - void cAudioManager::ProcessCarHeli(cVehicleParams* params) { const float SOUND_INTENSITY = 250.0f; - CVehicle* playerVeh; // eax - CVehicle* veh; // ecx - CAutomobile* automobile; // [esp+10h] [ebp-CCh] - CBoat* boat; // [esp+1Ch] [ebp-C0h] - - signed int volume; // ebx - signed int volume_3; // ebx - signed int volume_2; // ebx - float volumeModifier; // [esp+40h] [ebp-9Ch] - - uint32 freq_6; // eax - unsigned int freqModifier; // eax - signed int freqModifier_2; // [esp+14h] [ebp-C8h] - - bool distCalcBool; // [esp+Ch] [ebp-D0h] - char hunterBool; // [esp+18h] [ebp-C4h] - signed int brake; // [esp+20h] [ebp-BCh] - signed int accelerate; // [esp+24h] [ebp-B8h] - float vehAtYAbs; // [esp+34h] [ebp-A8h] - float vehCameraDot; // [esp+38h] [ebp-A4h] - float speedMultiplied; // [esp+3Ch] [ebp-A0h] - float distance_3; // [esp+44h] [ebp-98h] - - CVector posBackup; // [esp+48h] [ebp-94h] - CVector pos; // [esp+A8h] [ebp-34h] - //CVector multipliedVector; // [esp+B4h] [ebp-28h] - //CVector MatrixMultiplier; // [esp+C0h] [ebp-1Ch] - - static uint32 freqPrev = 14287; - static uint32 freqPrev_1 = 7143; - static uint32 freqPrev_0 = 14287; + CVehicle* playerVeh; + CVehicle* veh; + CAutomobile* automobile; + CBoat* boat; + + uint8 emittingVol; + int16 brakeState; + int16 accelerateState; + uint32 freq; + float propellerSpeed; + float freqModifier; //may be hieght + float cameraAngle; + bool distanceCalculatedOld; + float distanceOld; + CVector vecPosOld; + + float volumeModifier; + bool hunterBool; + + static uint32 freqFrontPrev = 14287; + static uint32 freqPropellerPrev = 7143; + static uint32 freqSkimmerPrev = 14287; boat = nil; automobile = nil; @@ -3131,49 +3072,49 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) playerVeh = FindPlayerVehicle(); veh = params->m_pVehicle; if (playerVeh == veh) { - accelerate = Pads[0].GetAccelerate(); - brake = Pads[0].GetBrake(); + accelerateState = Pads[0].GetAccelerate(); + brakeState = Pads[0].GetBrake(); } else { - accelerate = veh->m_fGasPedal * 255.0f; - brake = veh->m_fBrakePedal * 255.0f; + accelerateState = veh->m_fGasPedal * 255.0f; + brakeState = veh->m_fBrakePedal * 255.0f; } - vehAtYAbs = Abs(veh->m_matrix.GetUp().y); - vehCameraDot = (DotProduct(veh->m_matrix.GetForward(), TheCamera.GetForward()) + 1.0f) / 2.0f; + freqModifier = Abs(veh->GetUp().y); + cameraAngle = (DotProduct(veh->m_matrix.GetForward(), TheCamera.GetForward()) + 1.0f) / 2.0f; if (veh->m_modelIndex == MI_SKIMMER) { boat = (CBoat*)veh; - speedMultiplied = boat->m_fMovingSpeed * 50.0f / 11.0f; + propellerSpeed = boat->m_fMovingSpeed * 50.0f / 11.0f; } else if (params->m_VehicleType == VEHICLE_TYPE_HELI) { - speedMultiplied = 1.0f; + propellerSpeed = 1.0f; } else { automobile = (CAutomobile*)veh; - speedMultiplied = automobile->m_aWheelSpeed[1] * 50.0f / 11.0f; + propellerSpeed = automobile->m_aWheelSpeed[1] * 50.0f / 11.0f; } - if (speedMultiplied == 0.0f) + if (propellerSpeed == 0.0f) return; - speedMultiplied = Min(1.0f, speedMultiplied); + propellerSpeed = Min(1.0f, propellerSpeed); CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); //sound on long distances if (m_sQueueSample.m_fDistance >= 40.0f) - volume = speedMultiplied * 75.0f; + emittingVol = propellerSpeed * 75.0f; else if (m_sQueueSample.m_fDistance >= 25.0f) - volume = (m_sQueueSample.m_fDistance - 25.0f) * 0.06666667f * (75.0f * speedMultiplied); + emittingVol = (m_sQueueSample.m_fDistance - 25.0f) * 0.06666667f * (75.0f * propellerSpeed); else - volume = 0; - if (volume != 0) { - m_sQueueSample.m_nVolume = ComputeVolume(volume, SOUND_INTENSITY, m_sQueueSample.m_fDistance); + emittingVol = 0; + if (emittingVol != 0) { + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 88; if (boat != nil) { m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO3; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerate <= 0 && brake <= 0) - m_sQueueSample.m_nFrequency = 3651 + Min(1.0f, vehAtYAbs) * 949; + if (accelerateState <= 0 && brakeState <= 0) + m_sQueueSample.m_nFrequency = 3651 + Min(1.0f, freqModifier) * 949; else - m_sQueueSample.m_nFrequency = 4600 + Min(1.0f, (Max(accelerate, brake) / 255.0f) * vehAtYAbs) * 563; + m_sQueueSample.m_nFrequency = 4600 + Min(1.0f, (Max(accelerateState, brakeState) / 255.0f) * freqModifier) * 563; } else { m_sQueueSample.m_nSampleIndex = SFX_HELI_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -3182,7 +3123,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 2; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3198,32 +3139,32 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) if (params->m_fDistance >= 19600.0f) return; - if (speedMultiplied >= 0.4f) - volumeModifier = (speedMultiplied - 0.4f) * 5.0f / 3.0f; + if (propellerSpeed >= 0.4f) + volumeModifier = (propellerSpeed - 0.4f) * 5.0f / 3.0f; else volumeModifier = 0.0f; if (!boat) { - freqModifier_2 = Min(1300, 7000.0f * vehAtYAbs); - if (playerVeh == veh && (accelerate > 0 || brake > 0) && freqModifier_2 < 1300)//unnesesary freqModifier alredy <= 1300 - freqModifier_2 = 1300; + freq = Min(1300, 7000.0f * freqModifier); + if (playerVeh == veh && (accelerateState > 0 || brakeState > 0) && freq < 1300)//unnesesary freqModifier alredy <= 1300 + freq = 1300; if (veh->m_modelIndex == MI_HUNTER) hunterBool = true; } //sound from front of helicopter - volume = (1.0f - vehCameraDot) * volumeModifier * 127.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume, 140.0f, m_sQueueSample.m_fDistance); + emittingVol = (1.0f - cameraAngle) * volumeModifier * 127.0f; + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, 140.0f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 3; if (hunterBool) { m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = (volumeModifier + 1.0f) * 16000 + freqModifier_2; + m_sQueueSample.m_nFrequency = (volumeModifier + 1.0f) * 16000 + freq; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3237,18 +3178,19 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerate <= 0 && brake <= 0) - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; + if (accelerateState <= 0 && brakeState <= 0) + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713; else - m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, vehAtYAbs * (Max(accelerate, brake) / 255.0f)) * 2204; - if (speedMultiplied < 1.0f) - m_sQueueSample.m_nFrequency = (speedMultiplied + 1.0f) * (m_sQueueSample.m_nFrequency / 2.0f); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev - 197, freqPrev + 197); + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, freqModifier * (Max(accelerateState, brakeState) / 255.0f)) * 2204; + if (propellerSpeed < 1.0f) + m_sQueueSample.m_nFrequency = (propellerSpeed + 1.0f) * (m_sQueueSample.m_nFrequency / 2.0f); + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqFrontPrev - 197, freqFrontPrev + 197); + freqFrontPrev = m_sQueueSample.m_nFrequency; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3261,11 +3203,11 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) } else { m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; + m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freq; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3279,76 +3221,38 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) } - //engine starting sound - if (boat == nil && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance < 30.0f) { //strange way to check if automobile != nil - if (automobile->bEngineOn) { - if (speedMultiplied < 1.0f) { - volume = (1.0f - speedMultiplied / 2.0f) * 70.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume, 30.0, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { - if (hunterBool) { - m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_4; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - freq_6 = 3000.0f * speedMultiplied + 30000; - } else { - m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_STA; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - freq_6 = 3000.0f * speedMultiplied + 6000; - } - m_sQueueSample.m_nFrequency = freq_6; - m_sQueueSample.m_nCounter = 12; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = 30.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 30; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - } - } - } - } - - - //after accel rotor sound - volume = ((vehCameraDot + 1.0f) * volumeModifier * 127.0f) / 2.0f; - m_sQueueSample.m_nVolume = ComputeVolume(volume, 140.0, m_sQueueSample.m_fDistance); + emittingVol = ((cameraAngle + 1.0f) * volumeModifier * 127.0f) / 2.0f; + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, 140.0, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 1; if (hunterBool) { m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; + m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freq; } else if (boat) { m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerate <= 0 && brake <= 0) - m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857; + if (accelerateState <= 0 && brakeState <= 0) + m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, freqModifier) * 1857; else - m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102; + m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerateState, brakeState) / 255) * freqModifier) * 1102; - if (speedMultiplied < 1.0f) - m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); + if (propellerSpeed < 1.0f) + m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98); - freqPrev_1 = m_sQueueSample.m_nFrequency; + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPropellerPrev - 98, freqPropellerPrev + 98); + freqPropellerPrev = m_sQueueSample.m_nFrequency; } else { m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freqModifier_2; + m_sQueueSample.m_nFrequency = (volumeModifier + 1) * 16000 + freq; } m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; @@ -3361,20 +3265,56 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) } + //engine starting sound + if (boat == nil && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance < 30.0f) { //strange way to check if automobile != nil + if (automobile->bEngineOn) { + if (propellerSpeed < 1.0f) { + emittingVol = (1.0f - propellerSpeed / 2.0f) * 70.0f; + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, 30.0, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume) { + if (hunterBool) { + m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_4; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + freq = 3000.0f * propellerSpeed + 30000; + } else { + m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_STA; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + freq = 3000.0f * propellerSpeed + 6000; + } + m_sQueueSample.m_nFrequency = freq; + m_sQueueSample.m_nCounter = 12; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 30; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } + } + } + } + if (boat) { - if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FIXED && m_sQueueSample.m_fDistance < 20.0f && speedMultiplied > 0.0f) { - m_sQueueSample.m_nVolume = ComputeVolume(speedMultiplied * 100.0f, 20.0f, m_sQueueSample.m_fDistance); + if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FIXED && m_sQueueSample.m_fDistance < 20.0f && propellerSpeed > 0.0f) { + m_sQueueSample.m_nVolume = ComputeVolume(propellerSpeed * 100.0f, 20.0f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume) { - if (accelerate <= 0 && brake <= 0) - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; + if (accelerateState <= 0 && brakeState <= 0) + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713; else - m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerate, brake) / 255.0f) * vehAtYAbs) * 2204; - if (speedMultiplied < 1.0) - m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2.0f); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); - freqPrev_0 = m_sQueueSample.m_nFrequency; + m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerateState, brakeState) / 255.0f) * freqModifier) * 2204; + if (propellerSpeed < 1.0) + m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2.0f); + m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqSkimmerPrev - 197, freqSkimmerPrev + 197); + freqSkimmerPrev = m_sQueueSample.m_nFrequency; m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -3382,7 +3322,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = speedMultiplied * 100.0f; + m_sQueueSample.m_nEmittingVolume = propellerSpeed * 100.0f; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_SEAPLANE_PRO4); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_SEAPLANE_PRO4); m_sQueueSample.m_fSpeedMultiplier = 5.0f; @@ -3396,9 +3336,9 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) } } else { //vacuum cleaner sound - posBackup = m_sQueueSample.m_vecPos; - distCalcBool = params->m_bDistanceCalculated; - distance_3 = params->m_fDistance; + vecPosOld = m_sQueueSample.m_vecPos; + distanceCalculatedOld = params->m_bDistanceCalculated; + distanceOld = params->m_fDistance; if (automobile != nil) automobile->GetComponentWorldPosition(CAR_BOOT, m_sQueueSample.m_vecPos); @@ -3431,88 +3371,71 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) } } - m_sQueueSample.m_vecPos = posBackup; - params->m_bDistanceCalculated = distCalcBool; - params->m_fDistance = distance_3; + m_sQueueSample.m_vecPos = vecPosOld; + params->m_bDistanceCalculated = distanceCalculatedOld; + params->m_fDistance = distanceOld; } } void cAudioManager::ProcessVehicleFlatTyre(cVehicleParams* params) { + const float SOUND_INTENSITY = 60.0f; + CAutomobile* automobile; CBike* bike; + bool wheelBurst; + uint8 emittingVol; + float modifier; - cAudioManager* this_1; // ebp - int vehType; // edx - unsigned __int8 j; // dl - float tmp_2; // ST1C_4 - double tmp_4; // st6 - float tmp_3; - signed int volume; // ebx - bool someBool; // [esp+4h] [ebp-20h] - float modifier; // [esp+Ch] [ebp-18h] - - this_1 = this; - someBool = 0; - if (params->m_fDistance >= 3600.0) + if (params->m_fDistance >= SQR(SOUND_INTENSITY)) return; - vehType = params->m_VehicleType; switch (params->m_VehicleType) { - case 0: + case VEHICLE_TYPE_CAR: automobile = (CAutomobile*)params->m_pVehicle; - someBool = false; + wheelBurst = false; for (int i = 0; i < 4; i++) - if (automobile->Damage.GetWheelStatus(i) == 1 && automobile->m_aWheelTimer[i] > 0.0) - someBool = true; - if (!someBool) + if (automobile->Damage.GetWheelStatus(i) == WHEEL_STATUS_BURST && automobile->m_aWheelTimer[i] > 0.0f) + wheelBurst = true; + if (!wheelBurst) return; break; - case 5: + case VEHICLE_TYPE_BIKE: bike = (CBike*)params->m_pVehicle; - someBool = false; + wheelBurst = false; for(int i = 0; i < 2; i++) - if (bike->m_wheelStatus[i] == 1 && bike->m_aWheelTimer[i] > 0.0) - someBool = true; - if (!someBool) + if (bike->m_wheelStatus[i] == WHEEL_STATUS_BURST && bike->m_aWheelTimer[i] > 0.0f) + wheelBurst = true; + if (!wheelBurst) return; break; default: return; } - - tmp_2 = fabs(params->m_fVelocityChange); - if (tmp_2 / (0.3 * params->m_pTransmission->fMaxVelocity) <= 1.0) { //!! - tmp_3 = fabs(params->m_fVelocityChange); - tmp_4 = tmp_3 / (0.3 * params->m_pTransmission->fMaxVelocity); - } else { - tmp_4 = 1.0; - } - modifier = tmp_4+0.5f; - if (modifier > 0.01) { //!! + modifier = Min(1.0f, Abs(params->m_fVelocityChange) / (0.3f * params->m_pTransmission->fMaxVelocity)); + if (modifier > 0.01) { //mb can be replaced by (emittingVol > 1) + emittingVol = (100.0 * modifier); CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - volume = (100.0 * modifier); - this_1->m_sQueueSample.m_nVolume = ComputeVolume(volume, 60.0, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume) { m_sQueueSample.m_nCounter = 95; - m_sQueueSample.m_nBankIndex = 0; - m_sQueueSample.m_bIs2D = 0; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_nSampleIndex = SFX_TYRE_BURST_L; - m_sQueueSample.m_nFrequency = (5500.0f * modifier) - + 8000; + m_sQueueSample.m_nFrequency = (5500.0f * modifier) + 8000; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = volume; + m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_TYRE_BURST_L); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_TYRE_BURST_L); - m_sQueueSample.m_fSpeedMultiplier = 2.0; - m_sQueueSample.m_fSoundIntensity = 60.0; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_fSpeedMultiplier = 2.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); } } diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index aa7c80ec..a11d8619 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -330,7 +330,6 @@ public: void ProcessFires(int32 entity); void ProcessFrontEnd(); void ProcessGarages(); - bool ProcessHelicopter(cVehicleParams *params); void ProcessCarHeli(cVehicleParams* params); void ProcessVehicleFlatTyre(cVehicleParams* params); void ProcessJumbo(cVehicleParams *); -- cgit v1.2.3 From c61160fee351f898e36e9db505787fac31ecdf9b Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sat, 26 Sep 2020 20:24:25 +0300 Subject: small fixes and cleanup --- src/audio/AudioLogic.cpp | 96 +++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 51 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 45f9b81b..b04030dc 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -2628,14 +2628,14 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_31:{ const float SOUND_INTENSITY = 35.0f; relVol = ((CAutomobile*)params->m_pVehicle)->m_aWheelSpeed[1] * 50.0f / 11.0f; - if (relVol < 0.2f || 1.0f == relVol) + if (relVol < 0.2f || relVol == 1.0f) continue; emittingVol = (1.0f - relVol) * 70.0f; maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_ROT; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = heliIndex + 89; - heliIndex = heliIndex != 1 ? heliIndex + 1 : 0; + heliIndex = heliIndex != 1 ? heliIndex + 1 : 0; //maybe better use 1 and 0, to avoid extreme values m_sQueueSample.m_nFrequency = (8000.0f * relVol) + 16000; m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); m_sQueueSample.m_nReleasingVolumeModificator = 2; @@ -3028,12 +3028,6 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams *params) return true; } -struct tHelicopterSampleData { - float m_fMaxDistance; - float m_fBaseDistance; - uint8 m_bBaseVolume; -}; - void cAudioManager::ProcessCarHeli(cVehicleParams* params) { @@ -3049,13 +3043,13 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) int16 accelerateState; uint32 freq; float propellerSpeed; - float freqModifier; //may be hieght + float freqModifier; //may be relate to angle with horison float cameraAngle; bool distanceCalculatedOld; float distanceOld; CVector vecPosOld; - float volumeModifier; + float volumeModifier;//TODO find better name bool hunterBool; static uint32 freqFrontPrev = 14287; @@ -4933,37 +4927,37 @@ CVector aVecExtraSoundPosition[] = { {-1042.546f, 88.793999f, 11.324f}, {-1004.4 void cAudioManager::ProcessExtraSounds() { - const float extraSoundIntensity = 18.0f; - const uint8 extraSoundVolume = 50; + const float SOUND_INTENSITY = 18.0f; + const uint8 EMITTING_VOLUME = 50; float distance; for (int i = 0; i < ARRAY_SIZE(aVecExtraSoundPosition); i++) { m_sQueueSample.m_vecPos = aVecExtraSoundPosition[i]; distance = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distance < SQR(extraSoundIntensity)) { + if (distance < SQR(SOUND_INTENSITY)) { if (distance > 0.0) m_sQueueSample.m_fDistance = Sqrt(distance); else m_sQueueSample.m_fDistance = 0.0f; - m_sQueueSample.m_nVolume = ComputeVolume(extraSoundVolume, extraSoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(EMITTING_VOLUME, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { - this->m_sQueueSample.m_nCounter = i; - this->m_sQueueSample.m_nSampleIndex = SFX_ARCADE; - this->m_sQueueSample.m_nBankIndex = SFX_BANK_0; - this->m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ARCADE); - this->m_sQueueSample.m_bIs2D = false; - this->m_sQueueSample.m_nLoopCount = 0; - this->m_sQueueSample.m_bReleasingSoundFlag = false; - this->m_sQueueSample.m_nReleasingVolumeModificator = 4; - this->m_sQueueSample.m_fSpeedMultiplier = 3.0f; - this->m_sQueueSample.m_nEmittingVolume = extraSoundVolume; - this->m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_ARCADE); - this->m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_ARCADE); - this->m_sQueueSample.m_bReverbFlag = true; - this->m_sQueueSample.m_fSoundIntensity = extraSoundIntensity; - this->m_sQueueSample.m_bRequireReflection = false; - this->m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_nCounter = i; + m_sQueueSample.m_nSampleIndex = SFX_ARCADE; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ARCADE); + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeModificator = 4; + m_sQueueSample.m_fSpeedMultiplier = 3.0f; + m_sQueueSample.m_nEmittingVolume = EMITTING_VOLUME; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_ARCADE); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_ARCADE); + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_nReleasingVolumeDivider = 3; AddSampleToRequestedQueue(); } } @@ -4973,8 +4967,8 @@ cAudioManager::ProcessExtraSounds() void cAudioManager::ProcessEscalators() { - const float escalatorsSoundIntensity = 30.0f; - const uint8 escalatorsSoundVolume = 26; + const float SOUND_INTENSITY = 30.0f; + const uint8 EMITTING_VOLUME = 26; float distance; @@ -4983,29 +4977,29 @@ cAudioManager::ProcessEscalators() continue; m_sQueueSample.m_vecPos = CEscalators::aEscalators[i].m_midPoint; distance = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distance < SQR(escalatorsSoundIntensity)) { - if (distance > 0.0) + if (distance < SQR(SOUND_INTENSITY)) { + if (distance > 0.0f) m_sQueueSample.m_fDistance = Sqrt(distance); else m_sQueueSample.m_fDistance = 0.0f; - m_sQueueSample.m_nVolume = ComputeVolume(escalatorsSoundVolume, escalatorsSoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(EMITTING_VOLUME, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { - this->m_sQueueSample.m_nSampleIndex = SFX_BOAT_V12_LOOP; - this->m_sQueueSample.m_nBankIndex = SFX_BANK_0; - this->m_sQueueSample.m_nFrequency = i * 50 % 250 + 3973; - this->m_sQueueSample.m_nReleasingVolumeModificator = 3; - this->m_sQueueSample.m_fSpeedMultiplier = 3.0f; - this->m_sQueueSample.m_nReleasingVolumeDivider = 5; - this->m_sQueueSample.m_fSoundIntensity = escalatorsSoundIntensity; - this->m_sQueueSample.m_nCounter = i; - this->m_sQueueSample.m_bIs2D = false; - this->m_sQueueSample.m_nLoopCount = 0; - this->m_sQueueSample.m_nEmittingVolume = escalatorsSoundVolume; - this->m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_BOAT_V12_LOOP); - this->m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_BOAT_V12_LOOP); - this->m_sQueueSample.m_bReverbFlag = true; - this->m_sQueueSample.m_bReleasingSoundFlag = false; - this->m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_nSampleIndex = SFX_BOAT_V12_LOOP; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nFrequency = i * 50 % 250 + 3973; + m_sQueueSample.m_nReleasingVolumeModificator = 3; + m_sQueueSample.m_fSpeedMultiplier = 3.0f; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_nCounter = i; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = EMITTING_VOLUME; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_BOAT_V12_LOOP); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_BOAT_V12_LOOP); + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); } } -- cgit v1.2.3 From ec8ac117ed061abbd72215e4efef18e7f48294cf Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sat, 26 Sep 2020 20:36:07 +0300 Subject: Improve dodo cheat to allow fly on cars --- src/vehicles/Vehicle.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 378a4c0a..795219ba 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -351,6 +351,11 @@ CVehicle::FlyingControl(eFlightModel flightModel) fSteerUD *= -fSteerMult; // thrust +#ifdef ALT_DODO_CHEAT //allow fly on cars + float dooCompinsator = ((CPad::GetPad(0)->GetAccelerate() - CPad::GetPad(0)->GetBrake()) / 255.0f) * 2; + if (bAltDodoCheat) + ApplyMoveForce(GetForward() * CTimer::GetTimeStep() * dooCompinsator); +#endif float fForwSpeed = DotProduct(GetMoveSpeed(), GetForward()); CVector vecTail = GetColModel()->boundingBox.min.y * GetForward(); float fThrust = (CPad::GetPad(0)->GetAccelerate() - CPad::GetPad(0)->GetBrake()) / 255.0f; -- cgit v1.2.3 From 356c50ec1e6097eaf57bb8135f5308899bd8263c Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sat, 26 Sep 2020 20:50:51 +0300 Subject: mark completed functions in audioManager.h --- src/audio/AudioManager.h | 50 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index a11d8619..0cd86219 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -241,13 +241,13 @@ public: // "Should" be in alphabetic order, except "getXTalkSfx" void AddDetailsToRequestedOrderList(uint8 sample); void AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 bank, - uint8 counter, bool notLooping); + uint8 counter, bool notLooping); //done void AddReflectionsToRequestedQueue(); void AddReleasingSounds(); void AddSampleToRequestedQueue(); void AgeCrimes(); - void CalculateDistance(bool &condition, float dist); + void CalculateDistance(bool &condition, float dist); //done bool CheckForAnAudioFileOnCD() const; void ClearActiveSamples(); void ClearMissionAudio(uint8 slot); @@ -275,7 +275,7 @@ public: float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used float GetCollisionOneShotRatio(int32 a, float b) const; float GetCollisionRatio(float a, float b, float c, float d) const; - float GetDistanceSquared(const CVector &v) const; + float GetDistanceSquared(const CVector &v) const; //done int32 GetJumboTaxiFreq() const; uint8 GetMissionAudioLoadingStatus(uint8 slot) const; int8 GetMissionScriptPoliceAudioPlayingStatus() const; @@ -287,7 +287,7 @@ public: float GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange); - bool HasAirBrakes(int32 model) const; + bool HasAirBrakes(int32 model) const; //done void Initialise(); void InitialisePoliceRadio(); @@ -302,13 +302,13 @@ public: void PlayLoadedMissionAudio(uint8 slot); void PlayOneShot(int32 index, int16 sound, float vol); void PlaySuspectLastSeen(float x, float y, float z); - void PlayerJustGotInCar() const; - void PlayerJustLeftCar() const; + void PlayerJustGotInCar() const; //done + void PlayerJustLeftCar() const; //done void PostInitialiseGameSpecificSetup(); - void PostTerminateGameSpecificShutdown(); - void PreInitialiseGameSpecificSetup() const; + void PostTerminateGameSpecificShutdown(); //done + void PreInitialiseGameSpecificSetup() const; //done void PreloadMissionAudio(uint8 slot, Const char *name); - void PreTerminateGameSpecificShutdown(); + void PreTerminateGameSpecificShutdown(); //done /// processX - main logic of adding new sounds void ProcessActiveQueues(); bool ProcessAirBrakes(cVehicleParams *params); @@ -324,14 +324,14 @@ public: void ProcessCesna(cVehicleParams *params); //void ProcessCrane(); bool ProcessEngineDamage(cVehicleParams *params); - void ProcessEntity(int32 sound); + void ProcessEntity(int32 sound); //done void ProcessExplosions(int32 explosion); void ProcessFireHydrant(); void ProcessFires(int32 entity); void ProcessFrontEnd(); void ProcessGarages(); - void ProcessCarHeli(cVehicleParams* params); - void ProcessVehicleFlatTyre(cVehicleParams* params); + void ProcessCarHeli(cVehicleParams* params); //done + void ProcessVehicleFlatTyre(cVehicleParams* params); //done void ProcessJumbo(cVehicleParams *); void ProcessJumboAccel(CPlane *plane); void ProcessJumboDecel(CPlane *plane); @@ -346,22 +346,22 @@ public: void ProcessOneShotScriptObject(uint8 sound); void ProcessPed(CPhysical *ped); void ProcessPedOneShots(cPedParams *params); - void ProcessPhysical(int32 id); - void ProcessPlane(cVehicleParams *params); - void ProcessPlayersVehicleEngine(cVehicleParams *params, CVehicle* veh); + void ProcessPhysical(int32 id); //done + void ProcessPlane(cVehicleParams *params); //done + void ProcessPlayersVehicleEngine(cVehicleParams *params, CVehicle* veh); //done void ProcessProjectiles(); void ProcessRainOnVehicle(cVehicleParams *params); void ProcessReverb() const; - bool ProcessReverseGear(cVehicleParams *params); - void ProcessScriptObject(int32 id); + bool ProcessReverseGear(cVehicleParams *params); //done + void ProcessScriptObject(int32 id); //done void ProcessSpecial(); #ifdef GTA_TRAIN bool ProcessTrainNoise(cVehicleParams *params); #endif - void ProcessVehicle(CVehicle *vehicle); + void ProcessVehicle(CVehicle *vehicle); //done, but need add model functions bool ProcessVehicleDoors(cVehicleParams *params); - void ProcessVehicleEngine(cVehicleParams *params); - void UpdateGasPedalAudio(CVehicle* veh, int vehType); + void ProcessVehicleEngine(cVehicleParams *params); //done + void UpdateGasPedalAudio(CVehicle* veh, int vehType); //done void ProcessVehicleHorn(cVehicleParams *params); void ProcessVehicleOneShots(cVehicleParams *params); bool ProcessVehicleReverseWarning(cVehicleParams *params); @@ -369,10 +369,10 @@ public: bool ProcessVehicleSirenOrAlarm(cVehicleParams *params); bool ProcessVehicleSkidding(cVehicleParams *params); void ProcessWaterCannon(int32); - void ProcessWeather(int32 id); + void ProcessWeather(int32 id); //done bool ProcessWetRoadNoise(cVehicleParams *params); - void ProcessEscalators(); - void ProcessExtraSounds(); + void ProcessEscalators(); //done + void ProcessExtraSounds(); //done int32 RandomDisplacement(uint32 seed) const; void ReacquireDigitalHandle() const; @@ -417,11 +417,11 @@ public: void TranslateEntity(Const CVector *v1, CVector *v2) const; void UpdateReflections(); - bool UsesReverseWarning(int32 model) const; + bool UsesReverseWarning(int32 model) const; //done bool UsesSiren(int32 model) const; bool UsesSirenSwitching(int32 model) const; - CVehicle *FindVehicleOfPlayer(); + CVehicle *FindVehicleOfPlayer(); //done void SetPedTalkingStatus(CPed *ped, uint8 status); void SetPlayersMood(uint8 mood, int32 time); -- cgit v1.2.3 From 4c220b1f9583e2db3cdbb99fcdecd82ae4fe9e0d Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sat, 26 Sep 2020 21:07:51 +0300 Subject: return bridge, crane and fix structures in fluff.h --- src/audio/AudioLogic.cpp | 18 ++++++++++++++++-- src/render/Fluff.h | 9 ++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index b04030dc..60989aba 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -366,12 +366,26 @@ cAudioManager::ProcessEntity(int32 id) ProcessWeather(id); } break; +/* case AUDIOTYPE_CRANE: + if (!m_nUserPause) { + m_sQueueSample.m_bReverbFlag = true; + ProcessCrane(); + } + break;*/ case AUDIOTYPE_SCRIPTOBJECT: if (!m_nUserPause) { m_sQueueSample.m_bReverbFlag = true; ProcessScriptObject(id); } break; +#ifdef GTA_BRIDGE + case AUDIOTYPE_BRIDGE: + if (!m_nUserPause) { + m_sQueueSample.m_bReverbFlag = true; + ProcessBridge(); + } + break; +#endif case AUDIOTYPE_FRONTEND: m_sQueueSample.m_bReverbFlag = false; ProcessFrontEnd(); @@ -4973,9 +4987,9 @@ cAudioManager::ProcessEscalators() float distance; for (int i = 0; i < CEscalators::NumEscalators; i++) { - if (!CEscalators::aEscalators[i].m_bIsActive) + if (!CEscalators::GetEscalator(i).IsActive()) continue; - m_sQueueSample.m_vecPos = CEscalators::aEscalators[i].m_midPoint; + m_sQueueSample.m_vecPos = CEscalators::GetEscalator(i).GetPosition(); distance = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distance < SQR(SOUND_INTENSITY)) { if (distance > 0.0f) diff --git a/src/render/Fluff.h b/src/render/Fluff.h index 5a4458a8..460c12a8 100644 --- a/src/render/Fluff.h +++ b/src/render/Fluff.h @@ -90,30 +90,33 @@ class CEscalator CVector m_pos2; CVector m_pos3; CMatrix m_matrix; + bool m_bIsActive; bool m_bIsMovingDown; int32 m_stepsCount; float m_lowerEnd; float m_upperEnd; + CVector m_midPoint; float m_radius; CObject *m_pSteps[24]; public: - bool m_bIsActive;//TODO also recheck! - CVector m_midPoint; CEscalator(); void Update(void); void SwitchOff(void); void AddThisOne(CVector pos0, CVector pos1, CVector pos2, CVector pos3, bool b_isMovingDown); + bool IsActive() { return m_bIsActive; }; + CVector GetPosition() { return m_midPoint; }; }; class CEscalators { + static CEscalator aEscalators[NUM_ESCALATORS]; public: - static CEscalator aEscalators[NUM_ESCALATORS];//TODO need recheck this! static int32 NumEscalators; static void Init(void); static void Update(void); static void AddOne(CVector pos0, CVector pos1, CVector pos2, CVector pos3, bool b_isMovingDown); static void Shutdown(void); + static CEscalator GetEscalator(int ind) { return aEscalators[ind]; }; }; class CMovingThing -- cgit v1.2.3 From 796ad66d722cfde7e9152e52f914e1d9605cbf0b Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 26 Sep 2020 21:12:47 +0300 Subject: fixed replay bug --- src/control/Replay.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp index 8276f94a..f21703ac 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -744,7 +744,7 @@ void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressI car->Damage.SetDoorStatus(DOOR_FRONT_LEFT, DOOR_STATUS_SWINGING); if (vp->door_angles[1]) car->Damage.SetDoorStatus(DOOR_FRONT_RIGHT, DOOR_STATUS_SWINGING); - if (vp->door_status & 1 && car->Damage.GetDoorStatus(DOOR_BONNET) != DOOR_STATUS_MISSING){ + if (vp->door_status & 1 && car->Damage.GetDoorStatus(DOOR_BONNET) != DOOR_STATUS_MISSING) { car->Damage.SetDoorStatus(DOOR_BONNET, DOOR_STATUS_MISSING); car->SetDoorDamage(CAR_BONNET, DOOR_BONNET, true); } @@ -768,14 +768,14 @@ void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressI car->Damage.SetDoorStatus(DOOR_REAR_RIGHT, DOOR_STATUS_MISSING); car->SetDoorDamage(CAR_DOOR_RR, DOOR_REAR_RIGHT, true); } - vehicle->bEngineOn = true; - if (vehicle->IsCar()) - ((CAutomobile*)vehicle)->m_nDriveWheelsOnGround = 4; - CWorld::Remove(vehicle); - CWorld::Add(vehicle); - if (vehicle->IsBoat()) - ((CBoat*)vehicle)->m_bIsAnchored = false; } + vehicle->bEngineOn = true; + if (vehicle->IsCar()) + ((CAutomobile*)vehicle)->m_nDriveWheelsOnGround = 4; + CWorld::Remove(vehicle); + CWorld::Add(vehicle); + if (vehicle->IsBoat()) + ((CBoat*)vehicle)->m_bIsAnchored = false; } bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, float interpolation, uint32 *pTimer){ -- cgit v1.2.3 From 48a10de41fac345aae6140835191e699be1bea4f Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 26 Sep 2020 21:25:40 +0300 Subject: bug fixed --- src/control/Script.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 793b61c3..ceecbeb3 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -9614,7 +9614,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) CBaseModelInfo* pInfo = CModelInfo::GetModelInfo(model); script_assert(pInfo->GetModelType() == MITYPE_VEHICLE); CVehicleModelInfo* pVehicleInfo = (CVehicleModelInfo*)pInfo; - if (pVehicleInfo->m_vehicleType != VEHICLE_TYPE_CAR) { + if (pVehicleInfo->m_vehicleType == VEHICLE_TYPE_CAR) { switch (model) { case MI_LANDSTAL: case MI_LINERUN: -- cgit v1.2.3 From 6cfac662a1ebf3137b4d5e14315f14d341839cf9 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sun, 27 Sep 2020 00:32:14 +0200 Subject: Add target arm64 --- premake5.lua | 655 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 329 insertions(+), 326 deletions(-) diff --git a/premake5.lua b/premake5.lua index 4ebb735c..881035ef 100644 --- a/premake5.lua +++ b/premake5.lua @@ -1,328 +1,331 @@ -newoption { - trigger = "glewdir", - value = "PATH", - description = "Directory of GLEW", - default = "vendor/glew-2.1.0" -} - -newoption { - trigger = "glfwdir64", - value = "PATH", - description = "Directory of glfw", - default = "vendor/glfw-3.3.2.bin.WIN64", -} - -newoption { - trigger = "glfwdir32", - value = "PATH", - description = "Directory of glfw", - default = "vendor/glfw-3.3.2.bin.WIN32", -} - -newoption { - trigger = "with-librw", - description = "Build and use librw from this solution" -} - -newoption { - trigger = "with-opus", - description = "Build with opus" -} - -if(_OPTIONS["with-librw"]) then - Librw = "vendor/librw" -else - Librw = os.getenv("LIBRW") or "vendor/librw" -end - -function getsys(a) - if a == 'windows' then - return 'win' - end - return a -end - -function getarch(a) - if a == 'x86_64' then - return 'amd64' - elseif a == 'ARM' then - return 'arm' - end - return a -end - -workspace "re3" - language "C++" - configurations { "Debug", "Release" } - location "build" - symbols "Full" - staticruntime "off" - - filter { "system:windows" } - platforms { - "win-x86-RW33_d3d8-mss", - "win-x86-librw_d3d9-mss", - "win-x86-librw_gl3_glfw-mss", - "win-x86-RW33_d3d8-oal", - "win-x86-librw_d3d9-oal", - "win-x86-librw_gl3_glfw-oal", - "win-amd64-librw_d3d9-oal", - "win-amd64-librw_gl3_glfw-oal", - } - - filter { "system:linux" } - platforms { - "linux-x86-librw_gl3_glfw-oal", - "linux-amd64-librw_gl3_glfw-oal", - "linux-arm-librw_gl3_glfw-oal", - } - - filter { "system:bsd" } - platforms { - "bsd-amd64-librw_gl3_glfw-oal" - } - - filter "configurations:Debug" - defines { "DEBUG" } - - filter "configurations:Release" - defines { "NDEBUG" } - optimize "On" - - filter { "platforms:win*" } - system "windows" - - filter { "platforms:linux*" } - system "linux" - - filter { "platforms:bsd*" } - system "bsd" - - filter { "platforms:*x86*" } - architecture "x86" - - filter { "platforms:*amd64*" } - architecture "amd64" - - filter { "platforms:*arm*" } - architecture "ARM" - - filter { "platforms:*librw_d3d9*" } - defines { "RW_D3D9" } - if(not _OPTIONS["with-librw"]) then - libdirs { path.join(Librw, "lib/win-%{getarch(cfg.architecture)}-d3d9/%{cfg.buildcfg}") } - end - - filter "platforms:*librw_gl3_glfw*" - defines { "RW_GL3" } - includedirs { path.join(_OPTIONS["glewdir"], "include") } - if(not _OPTIONS["with-librw"]) then - libdirs { path.join(Librw, "lib/%{getsys(cfg.system)}-%{getarch(cfg.architecture)}-gl3/%{cfg.buildcfg}") } - end - - filter "platforms:*x86-librw_gl3_glfw*" - includedirs { path.join(_OPTIONS["glfwdir32"], "include") } - - filter "platforms:*amd64-librw_gl3_glfw*" - includedirs { path.join(_OPTIONS["glfwdir64"], "include") } - - filter "platforms:win*librw_gl3_glfw*" - defines { "GLEW_STATIC" } - - filter {} - - function setpaths (gamepath, exepath, scriptspath) - scriptspath = scriptspath or "" - if (gamepath) then - postbuildcommands { - '{COPY} "%{cfg.buildtarget.abspath}" "' .. gamepath .. scriptspath .. '%{cfg.buildtarget.name}"' - } - debugdir (gamepath) - if (exepath) then - -- Used VS variable $(TargetFileName) because it doesn't accept premake tokens. Does debugcommand even work outside VS?? - debugcommand (gamepath .. "$(TargetFileName)") - dir, file = exepath:match'(.*/)(.*)' - debugdir (gamepath .. (dir or "")) - end - end - --targetdir ("bin/%{prj.name}/" .. scriptspath) - end - -if(_OPTIONS["with-librw"]) then -project "librw" - kind "StaticLib" - targetname "rw" - targetdir(path.join(Librw, "lib/%{cfg.platform}/%{cfg.buildcfg}")) - files { path.join(Librw, "src/*.*") } - files { path.join(Librw, "src/*/*.*") } - - filter "platforms:bsd*" - includedirs { "/usr/local/include" } - libdirs { "/usr/local/lib" } - - filter "platforms:*RW33*" - flags { "ExcludeFromBuild" } - filter {} -end - -local function addSrcFiles( prefix ) - return prefix .. "/*cpp", prefix .. "/*.h", prefix .. "/*.c", prefix .. "/*.ico", prefix .. "/*.rc" -end - -project "re3" - kind "WindowedApp" - targetname "re3" - targetdir "bin/%{cfg.platform}/%{cfg.buildcfg}" - - files { addSrcFiles("src") } - files { addSrcFiles("src/animation") } +newoption { + trigger = "glewdir", + value = "PATH", + description = "Directory of GLEW", + default = "vendor/glew-2.1.0" +} + +newoption { + trigger = "glfwdir64", + value = "PATH", + description = "Directory of glfw", + default = "vendor/glfw-3.3.2.bin.WIN64", +} + +newoption { + trigger = "glfwdir32", + value = "PATH", + description = "Directory of glfw", + default = "vendor/glfw-3.3.2.bin.WIN32", +} + +newoption { + trigger = "with-librw", + description = "Build and use librw from this solution" +} + +newoption { + trigger = "with-opus", + description = "Build with opus" +} + +if(_OPTIONS["with-librw"]) then + Librw = "vendor/librw" +else + Librw = os.getenv("LIBRW") or "vendor/librw" +end + +function getsys(a) + if a == 'windows' then + return 'win' + end + return a +end + +function getarch(a) + if a == 'x86_64' then + return 'amd64' + elseif a == 'ARM' then + return 'arm' + elseif a == 'ARM64' then + return 'arm64' + end + return a +end + +workspace "re3" + language "C++" + configurations { "Debug", "Release" } + location "build" + symbols "Full" + staticruntime "off" + + filter { "system:windows" } + platforms { + "win-x86-RW33_d3d8-mss", + "win-x86-librw_d3d9-mss", + "win-x86-librw_gl3_glfw-mss", + "win-x86-RW33_d3d8-oal", + "win-x86-librw_d3d9-oal", + "win-x86-librw_gl3_glfw-oal", + "win-amd64-librw_d3d9-oal", + "win-amd64-librw_gl3_glfw-oal", + } + + filter { "system:linux" } + platforms { + "linux-x86-librw_gl3_glfw-oal", + "linux-amd64-librw_gl3_glfw-oal", + "linux-arm-librw_gl3_glfw-oal", + "linux-arm64-librw_gl3_glfw-oal", + } + + filter { "system:bsd" } + platforms { + "bsd-amd64-librw_gl3_glfw-oal" + } + + filter "configurations:Debug" + defines { "DEBUG" } + + filter "configurations:Release" + defines { "NDEBUG" } + optimize "On" + + filter { "platforms:win*" } + system "windows" + + filter { "platforms:linux*" } + system "linux" + + filter { "platforms:bsd*" } + system "bsd" + + filter { "platforms:*x86*" } + architecture "x86" + + filter { "platforms:*amd64*" } + architecture "amd64" + + filter { "platforms:*arm*" } + architecture "ARM" + + filter { "platforms:*librw_d3d9*" } + defines { "RW_D3D9" } + if(not _OPTIONS["with-librw"]) then + libdirs { path.join(Librw, "lib/win-%{getarch(cfg.architecture)}-d3d9/%{cfg.buildcfg}") } + end + + filter "platforms:*librw_gl3_glfw*" + defines { "RW_GL3" } + includedirs { path.join(_OPTIONS["glewdir"], "include") } + if(not _OPTIONS["with-librw"]) then + libdirs { path.join(Librw, "lib/%{getsys(cfg.system)}-%{getarch(cfg.architecture)}-gl3/%{cfg.buildcfg}") } + end + + filter "platforms:*x86-librw_gl3_glfw*" + includedirs { path.join(_OPTIONS["glfwdir32"], "include") } + + filter "platforms:*amd64-librw_gl3_glfw*" + includedirs { path.join(_OPTIONS["glfwdir64"], "include") } + + filter "platforms:win*librw_gl3_glfw*" + defines { "GLEW_STATIC" } + + filter {} + + function setpaths (gamepath, exepath, scriptspath) + scriptspath = scriptspath or "" + if (gamepath) then + postbuildcommands { + '{COPY} "%{cfg.buildtarget.abspath}" "' .. gamepath .. scriptspath .. '%{cfg.buildtarget.name}"' + } + debugdir (gamepath) + if (exepath) then + -- Used VS variable $(TargetFileName) because it doesn't accept premake tokens. Does debugcommand even work outside VS?? + debugcommand (gamepath .. "$(TargetFileName)") + dir, file = exepath:match'(.*/)(.*)' + debugdir (gamepath .. (dir or "")) + end + end + --targetdir ("bin/%{prj.name}/" .. scriptspath) + end + +if(_OPTIONS["with-librw"]) then +project "librw" + kind "StaticLib" + targetname "rw" + targetdir(path.join(Librw, "lib/%{cfg.platform}/%{cfg.buildcfg}")) + files { path.join(Librw, "src/*.*") } + files { path.join(Librw, "src/*/*.*") } + + filter "platforms:bsd*" + includedirs { "/usr/local/include" } + libdirs { "/usr/local/lib" } + + filter "platforms:*RW33*" + flags { "ExcludeFromBuild" } + filter {} +end + +local function addSrcFiles( prefix ) + return prefix .. "/*cpp", prefix .. "/*.h", prefix .. "/*.c", prefix .. "/*.ico", prefix .. "/*.rc" +end + +project "re3" + kind "WindowedApp" + targetname "re3" + targetdir "bin/%{cfg.platform}/%{cfg.buildcfg}" + + files { addSrcFiles("src") } + files { addSrcFiles("src/animation") } files { addSrcFiles("src/audio") } - files { addSrcFiles("src/audio/eax") } - files { addSrcFiles("src/audio/oal") } - files { addSrcFiles("src/control") } - files { addSrcFiles("src/core") } - files { addSrcFiles("src/entities") } - files { addSrcFiles("src/math") } - files { addSrcFiles("src/modelinfo") } - files { addSrcFiles("src/objects") } - files { addSrcFiles("src/peds") } - files { addSrcFiles("src/render") } - files { addSrcFiles("src/rw") } - files { addSrcFiles("src/save") } - files { addSrcFiles("src/skel") } - files { addSrcFiles("src/skel/glfw") } - files { addSrcFiles("src/text") } - files { addSrcFiles("src/vehicles") } - files { addSrcFiles("src/weapons") } - files { addSrcFiles("src/extras") } - - includedirs { "src" } - includedirs { "src/animation" } + files { addSrcFiles("src/audio/eax") } + files { addSrcFiles("src/audio/oal") } + files { addSrcFiles("src/control") } + files { addSrcFiles("src/core") } + files { addSrcFiles("src/entities") } + files { addSrcFiles("src/math") } + files { addSrcFiles("src/modelinfo") } + files { addSrcFiles("src/objects") } + files { addSrcFiles("src/peds") } + files { addSrcFiles("src/render") } + files { addSrcFiles("src/rw") } + files { addSrcFiles("src/save") } + files { addSrcFiles("src/skel") } + files { addSrcFiles("src/skel/glfw") } + files { addSrcFiles("src/text") } + files { addSrcFiles("src/vehicles") } + files { addSrcFiles("src/weapons") } + files { addSrcFiles("src/extras") } + + includedirs { "src" } + includedirs { "src/animation" } includedirs { "src/audio" } - includedirs { "src/audio/eax" } - includedirs { "src/audio/oal" } - includedirs { "src/control" } - includedirs { "src/core" } - includedirs { "src/entities" } - includedirs { "src/math" } - includedirs { "src/modelinfo" } - includedirs { "src/objects" } - includedirs { "src/peds" } - includedirs { "src/render" } - includedirs { "src/rw" } - includedirs { "src/save/" } - includedirs { "src/skel/" } - includedirs { "src/skel/glfw" } - includedirs { "src/text" } - includedirs { "src/vehicles" } - includedirs { "src/weapons" } - includedirs { "src/extras" } - - if _OPTIONS["with-opus"] then - includedirs { "vendor/ogg/include" } - includedirs { "vendor/opus/include" } - includedirs { "vendor/opusfile/include" } - end - - filter "platforms:*mss" - defines { "AUDIO_MSS" } - includedirs { "sdk/milessdk/include" } - libdirs { "sdk/milessdk/lib" } - - if _OPTIONS["with-opus"] then - filter "platforms:win*" - libdirs { "vendor/ogg/win32/VS2015/Win32/%{cfg.buildcfg}" } - libdirs { "vendor/opus/win32/VS2015/Win32/%{cfg.buildcfg}" } - libdirs { "vendor/opusfile/win32/VS2015/Win32/Release-NoHTTP" } - filter {} - defines { "AUDIO_OPUS" } - end - - filter "platforms:*oal" - defines { "AUDIO_OAL" } - - filter {} - if(os.getenv("GTA_III_RE_DIR")) then - setpaths("$(GTA_III_RE_DIR)/", "%(cfg.buildtarget.name)", "") - end - - filter "platforms:win*" - files { addSrcFiles("src/skel/win") } - includedirs { "src/skel/win" } - linkoptions "/SAFESEH:NO" - characterset ("MBCS") - targetextension ".exe" - - filter "platforms:win*oal" - includedirs { "vendor/openal-soft/include" } - includedirs { "vendor/libsndfile/include" } - includedirs { "vendor/mpg123/include" } - - filter "platforms:win-x86*oal" - libdirs { "vendor/mpg123/lib/Win32" } - libdirs { "vendor/libsndfile/lib/Win32" } - libdirs { "vendor/openal-soft/libs/Win32" } - - filter "platforms:win-amd64*oal" - libdirs { "vendor/mpg123/lib/Win64" } - libdirs { "vendor/libsndfile/lib/Win64" } - libdirs { "vendor/openal-soft/libs/Win64" } - - filter "platforms:linux*oal" - links { "openal", "mpg123", "sndfile", "pthread" } - - filter "platforms:bsd*oal" - links { "openal", "mpg123", "sndfile", "pthread" } - - if _OPTIONS["with-opus"] then - filter {} - links { "libogg" } - links { "opus" } - links { "opusfile" } - end - - filter "platforms:*RW33*" - staticruntime "on" - includedirs { "sdk/rwsdk/include/d3d8" } - libdirs { "sdk/rwsdk/lib/d3d8/release" } - links { "rwcore", "rpworld", "rpmatfx", "rpskin", "rphanim", "rtbmp", "rtquat", "rtcharse" } - defines { "RWLIBS" } - linkoptions "/SECTION:_rwcseg,ER!W /MERGE:_rwcseg=.text" - - filter "platforms:*librw*" - defines { "LIBRW" } - files { addSrcFiles("src/fakerw") } - includedirs { "src/fakerw" } - includedirs { Librw } - if(_OPTIONS["with-librw"]) then - libdirs { "vendor/librw/lib/%{cfg.platform}/%{cfg.buildcfg}" } - end - links { "rw" } - - filter "platforms:*d3d9*" - links { "d3d9" } - - filter "platforms:*x86*d3d*" - includedirs { "sdk/dx8sdk/include" } - libdirs { "sdk/dx8sdk/lib" } - - filter "platforms:*amd64*d3d9*" - defines { "USE_D3D9" } - - filter "platforms:win-x86*gl3_glfw*" - libdirs { path.join(_OPTIONS["glewdir"], "lib/Release/Win32") } - libdirs { path.join(_OPTIONS["glfwdir32"], "lib-" .. string.gsub(_ACTION or '', "vs", "vc")) } - links { "opengl32", "glew32s", "glfw3" } - - filter "platforms:win-amd64*gl3_glfw*" - libdirs { path.join(_OPTIONS["glewdir"], "lib/Release/x64") } - libdirs { path.join(_OPTIONS["glfwdir64"], "lib-" .. string.gsub(_ACTION or '', "vs", "vc")) } - links { "opengl32", "glew32s", "glfw3" } - - filter "platforms:linux*gl3_glfw*" - links { "GL", "GLEW", "glfw" } - - filter "platforms:bsd*gl3_glfw*" - links { "GL", "GLEW", "glfw", "sysinfo" } - includedirs { "/usr/local/include" } - libdirs { "/usr/local/lib" } + includedirs { "src/audio/eax" } + includedirs { "src/audio/oal" } + includedirs { "src/control" } + includedirs { "src/core" } + includedirs { "src/entities" } + includedirs { "src/math" } + includedirs { "src/modelinfo" } + includedirs { "src/objects" } + includedirs { "src/peds" } + includedirs { "src/render" } + includedirs { "src/rw" } + includedirs { "src/save/" } + includedirs { "src/skel/" } + includedirs { "src/skel/glfw" } + includedirs { "src/text" } + includedirs { "src/vehicles" } + includedirs { "src/weapons" } + includedirs { "src/extras" } + + if _OPTIONS["with-opus"] then + includedirs { "vendor/ogg/include" } + includedirs { "vendor/opus/include" } + includedirs { "vendor/opusfile/include" } + end + + filter "platforms:*mss" + defines { "AUDIO_MSS" } + includedirs { "sdk/milessdk/include" } + libdirs { "sdk/milessdk/lib" } + + if _OPTIONS["with-opus"] then + filter "platforms:win*" + libdirs { "vendor/ogg/win32/VS2015/Win32/%{cfg.buildcfg}" } + libdirs { "vendor/opus/win32/VS2015/Win32/%{cfg.buildcfg}" } + libdirs { "vendor/opusfile/win32/VS2015/Win32/Release-NoHTTP" } + filter {} + defines { "AUDIO_OPUS" } + end + + filter "platforms:*oal" + defines { "AUDIO_OAL" } + + filter {} + if(os.getenv("GTA_III_RE_DIR")) then + setpaths("$(GTA_III_RE_DIR)/", "%(cfg.buildtarget.name)", "") + end + + filter "platforms:win*" + files { addSrcFiles("src/skel/win") } + includedirs { "src/skel/win" } + linkoptions "/SAFESEH:NO" + characterset ("MBCS") + targetextension ".exe" + + filter "platforms:win*oal" + includedirs { "vendor/openal-soft/include" } + includedirs { "vendor/libsndfile/include" } + includedirs { "vendor/mpg123/include" } + + filter "platforms:win-x86*oal" + libdirs { "vendor/mpg123/lib/Win32" } + libdirs { "vendor/libsndfile/lib/Win32" } + libdirs { "vendor/openal-soft/libs/Win32" } + + filter "platforms:win-amd64*oal" + libdirs { "vendor/mpg123/lib/Win64" } + libdirs { "vendor/libsndfile/lib/Win64" } + libdirs { "vendor/openal-soft/libs/Win64" } + + filter "platforms:linux*oal" + links { "openal", "mpg123", "sndfile", "pthread" } + + filter "platforms:bsd*oal" + links { "openal", "mpg123", "sndfile", "pthread" } + + if _OPTIONS["with-opus"] then + filter {} + links { "libogg" } + links { "opus" } + links { "opusfile" } + end + + filter "platforms:*RW33*" + staticruntime "on" + includedirs { "sdk/rwsdk/include/d3d8" } + libdirs { "sdk/rwsdk/lib/d3d8/release" } + links { "rwcore", "rpworld", "rpmatfx", "rpskin", "rphanim", "rtbmp", "rtquat", "rtcharse" } + defines { "RWLIBS" } + linkoptions "/SECTION:_rwcseg,ER!W /MERGE:_rwcseg=.text" + + filter "platforms:*librw*" + defines { "LIBRW" } + files { addSrcFiles("src/fakerw") } + includedirs { "src/fakerw" } + includedirs { Librw } + if(_OPTIONS["with-librw"]) then + libdirs { "vendor/librw/lib/%{cfg.platform}/%{cfg.buildcfg}" } + end + links { "rw" } + + filter "platforms:*d3d9*" + links { "d3d9" } + + filter "platforms:*x86*d3d*" + includedirs { "sdk/dx8sdk/include" } + libdirs { "sdk/dx8sdk/lib" } + + filter "platforms:*amd64*d3d9*" + defines { "USE_D3D9" } + + filter "platforms:win-x86*gl3_glfw*" + libdirs { path.join(_OPTIONS["glewdir"], "lib/Release/Win32") } + libdirs { path.join(_OPTIONS["glfwdir32"], "lib-" .. string.gsub(_ACTION or '', "vs", "vc")) } + links { "opengl32", "glew32s", "glfw3" } + + filter "platforms:win-amd64*gl3_glfw*" + libdirs { path.join(_OPTIONS["glewdir"], "lib/Release/x64") } + libdirs { path.join(_OPTIONS["glfwdir64"], "lib-" .. string.gsub(_ACTION or '', "vs", "vc")) } + links { "opengl32", "glew32s", "glfw3" } + + filter "platforms:linux*gl3_glfw*" + links { "GL", "GLEW", "glfw" } + + filter "platforms:bsd*gl3_glfw*" + links { "GL", "GLEW", "glfw", "sysinfo" } + includedirs { "/usr/local/include" } + libdirs { "/usr/local/lib" } -- cgit v1.2.3 From c403df08611c857f43ebf708799974f06b4e8a8a Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sun, 27 Sep 2020 02:03:36 +0300 Subject: processEngineDamage --- src/audio/AudioLogic.cpp | 33 +++++++++++++++++---------------- src/audio/AudioManager.h | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 60989aba..b174a924 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -2265,34 +2265,36 @@ cAudioManager::HasAirBrakes(int32 model) const || model == COACH || model == PACKER || model == FLATBED; } -bool +void cAudioManager::ProcessEngineDamage(cVehicleParams *params) { const int engineDamageIntensity = 40; - CAutomobile *veh; - uint8 engineStatus; + float health; uint8 emittingVolume; if (params->m_fDistance >= SQR(engineDamageIntensity)) - return false; - veh = (CAutomobile *)params->m_pVehicle; - if (veh->bEngineOn) { - engineStatus = veh->Damage.GetEngineStatus(); - if (engineStatus > 250 || engineStatus < 100) - return true; - if (engineStatus < 225) { - m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; - emittingVolume = 6; - m_sQueueSample.m_nReleasingVolumeModificator = 7; - m_sQueueSample.m_nFrequency = 40000; - } else { + return; + if (params->m_pVehicle->m_modelIndex == MI_CADDY) + return; + if (params->m_pVehicle->GetStatus() == STATUS_WRECKED) + return; + health = params->m_pVehicle->m_fHealth; + if (health < 390.0f) { + if (health < 250.0f) { emittingVolume = 60; m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE; m_sQueueSample.m_nReleasingVolumeModificator = 7; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE); + } else { + emittingVolume = 30; + m_sQueueSample.m_nSampleIndex = SFX_PALM_TREE_LO; + m_sQueueSample.m_nReleasingVolumeModificator = 7; + m_sQueueSample.m_nFrequency = 27000; } CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + if (params->m_pVehicle->bIsDrowning) + emittingVolume /= 2; m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, engineDamageIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 28; @@ -2311,7 +2313,6 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params) AddSampleToRequestedQueue(); } } - return true; } bool diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 0cd86219..c3462291 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -323,7 +323,7 @@ public: bool ProcessCarBombTick(cVehicleParams *params); void ProcessCesna(cVehicleParams *params); //void ProcessCrane(); - bool ProcessEngineDamage(cVehicleParams *params); + void ProcessEngineDamage(cVehicleParams *params); //done void ProcessEntity(int32 sound); //done void ProcessExplosions(int32 explosion); void ProcessFireHydrant(); -- cgit v1.2.3 From f67275be138d087106ad05c241a3cda9ca2d0373 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sun, 27 Sep 2020 03:35:15 +0300 Subject: correction of defects and another two audio functions --- src/audio/AudioLogic.cpp | 109 +++++++++++++++++++++++++++-------------------- src/audio/AudioManager.h | 6 +-- src/render/Fluff.h | 4 +- 3 files changed, 68 insertions(+), 51 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index b174a924..28fa9343 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -2189,7 +2189,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams *params) if (doorState == DOORST_OPEN || doorState == DOORST_CLOSED) { velocity = Min(0.3f, Abs(automobile->Doors[i].m_fAngVel)); if (velocity > 0.0035f) { - emittingVol = (100.f * velocity * 10.f / 3.f); + emittingVol = (100.0f * velocity * 10.0f / 3.0f); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = i + 6; @@ -2265,20 +2265,20 @@ cAudioManager::HasAirBrakes(int32 model) const || model == COACH || model == PACKER || model == FLATBED; } -void +bool cAudioManager::ProcessEngineDamage(cVehicleParams *params) { - const int engineDamageIntensity = 40; + const float SOUND_INTENSITY = 40.0f; float health; uint8 emittingVolume; - if (params->m_fDistance >= SQR(engineDamageIntensity)) - return; + if (params->m_fDistance >= SQR(SOUND_INTENSITY)) + return false; if (params->m_pVehicle->m_modelIndex == MI_CADDY) - return; + return true; if (params->m_pVehicle->GetStatus() == STATUS_WRECKED) - return; + return true; health = params->m_pVehicle->m_fHealth; if (health < 390.0f) { if (health < 250.0f) { @@ -2295,7 +2295,7 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params) CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); if (params->m_pVehicle->bIsDrowning) emittingVolume /= 2; - m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, engineDamageIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 28; m_sQueueSample.m_nBankIndex = SFX_BANK_0; @@ -2305,7 +2305,7 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params) m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_fSoundIntensity = engineDamageIntensity; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = true; @@ -2313,37 +2313,54 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params) AddSampleToRequestedQueue(); } } + return true; } bool cAudioManager::ProcessCarBombTick(cVehicleParams *params) { - CAutomobile *automobile; + const float SOUND_INTENSITY = 40.0f; + const uint8 EMITTING_VOLUME = 60; + + uint8 bombType; - if (params->m_fDistance >= SQR(40.f)) + if (params->m_fDistance >= SQR(SOUND_INTENSITY)) return false; - automobile = (CAutomobile *)params->m_pVehicle; - 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) { - m_sQueueSample.m_nCounter = 35; - 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_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COUNTDOWN); - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = 60; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_fSoundIntensity = 40.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); + if (params->m_pVehicle->bEngineOn) { + switch (params->m_VehicleType) { + case VEHICLE_TYPE_CAR: + bombType = params->m_pVehicle->m_bombType; + break; + case VEHICLE_TYPE_BIKE: + bombType = params->m_pVehicle->m_bombType; + break; + default: + debug("\n * AUDIOLOG: ProcessCarBombTick() Unsupported vehicle type %d * \n", params->m_VehicleType); + return true; + break; + } + if (bombType == CARBOMB_TIMEDACTIVE) { + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(EMITTING_VOLUME, SOUND_INTENSITY, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + m_sQueueSample.m_nCounter = 35; + 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_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COUNTDOWN); + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = EMITTING_VOLUME; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 2.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } } } return true; @@ -3110,7 +3127,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) if (m_sQueueSample.m_fDistance >= 40.0f) emittingVol = propellerSpeed * 75.0f; else if (m_sQueueSample.m_fDistance >= 25.0f) - emittingVol = (m_sQueueSample.m_fDistance - 25.0f) * 0.06666667f * (75.0f * propellerSpeed); + emittingVol = (m_sQueueSample.m_fDistance - 25.0f) * (75.0f * propellerSpeed) / 15.0f; else emittingVol = 0; if (emittingVol != 0) { @@ -3145,7 +3162,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) } } - if (params->m_fDistance >= 19600.0f) + if (params->m_fDistance >= SQR(140.0f)) return; if (propellerSpeed >= 0.4f) @@ -3187,10 +3204,10 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerateState <= 0 && brakeState <= 0) - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713; - else + if (accelerateState > 0 || brakeState > 0) m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, freqModifier * (Max(accelerateState, brakeState) / 255.0f)) * 2204; + else + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713; if (propellerSpeed < 1.0f) m_sQueueSample.m_nFrequency = (propellerSpeed + 1.0f) * (m_sQueueSample.m_nFrequency / 2.0f); m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqFrontPrev - 197, freqFrontPrev + 197); @@ -3243,10 +3260,10 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerateState <= 0 && brakeState <= 0) - m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, freqModifier) * 1857; - else + if (accelerateState > 0 || brakeState > 0) m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerateState, brakeState) / 255) * freqModifier) * 1102; + else + m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, freqModifier) * 1857; if (propellerSpeed < 1.0f) m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2); @@ -3316,10 +3333,10 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_nVolume = ComputeVolume(propellerSpeed * 100.0f, 20.0f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume) { - if (accelerateState <= 0 && brakeState <= 0) - m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713; - else + if (accelerateState > 0 || brakeState > 0) m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, (Max(accelerateState, brakeState) / 255.0f) * freqModifier) * 2204; + else + m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713; if (propellerSpeed < 1.0) m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2.0f); m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqSkimmerPrev - 197, freqSkimmerPrev + 197); @@ -3356,7 +3373,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) params->m_bDistanceCalculated = false; params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (params->m_fDistance < 729.0f) { + if (params->m_fDistance < SQR(27.0f)) { CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(volumeModifier * 25.0f, 27.0f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume) { @@ -4937,7 +4954,7 @@ cAudioManager::ProcessWaterCannon(int32) } //positon of arcade machines -CVector aVecExtraSoundPosition[] = { {-1042.546f, 88.793999f, 11.324f}, {-1004.476f, 181.69701f, 11.324f} }; +CVector aVecExtraSoundPosition[] = { {-1042.546f, 88.794f, 11.324f}, {-1004.476f, 181.697f, 11.324f} }; void cAudioManager::ProcessExtraSounds() diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index c3462291..949de7d1 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -320,10 +320,10 @@ public: void ProcessBridgeOneShots(); void ProcessBridgeWarning(); #endif - bool ProcessCarBombTick(cVehicleParams *params); + bool ProcessCarBombTick(cVehicleParams *params); //done void ProcessCesna(cVehicleParams *params); //void ProcessCrane(); - void ProcessEngineDamage(cVehicleParams *params); //done + bool ProcessEngineDamage(cVehicleParams *params); //done void ProcessEntity(int32 sound); //done void ProcessExplosions(int32 explosion); void ProcessFireHydrant(); @@ -359,7 +359,7 @@ public: bool ProcessTrainNoise(cVehicleParams *params); #endif void ProcessVehicle(CVehicle *vehicle); //done, but need add model functions - bool ProcessVehicleDoors(cVehicleParams *params); + bool ProcessVehicleDoors(cVehicleParams *params); //done void ProcessVehicleEngine(cVehicleParams *params); //done void UpdateGasPedalAudio(CVehicle* veh, int vehType); //done void ProcessVehicleHorn(cVehicleParams *params); diff --git a/src/render/Fluff.h b/src/render/Fluff.h index 460c12a8..d600def7 100644 --- a/src/render/Fluff.h +++ b/src/render/Fluff.h @@ -104,7 +104,7 @@ public: void SwitchOff(void); void AddThisOne(CVector pos0, CVector pos1, CVector pos2, CVector pos3, bool b_isMovingDown); bool IsActive() { return m_bIsActive; }; - CVector GetPosition() { return m_midPoint; }; + const CVector& GetPosition() const { return m_midPoint; }; }; class CEscalators @@ -116,7 +116,7 @@ public: static void Update(void); static void AddOne(CVector pos0, CVector pos1, CVector pos2, CVector pos3, bool b_isMovingDown); static void Shutdown(void); - static CEscalator GetEscalator(int ind) { return aEscalators[ind]; }; + static CEscalator& GetEscalator(int ind) { return aEscalators[ind]; }; }; class CMovingThing -- cgit v1.2.3 From b956be0f44930fe1d764c07e680f7cee47c1587a Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sun, 27 Sep 2020 04:22:59 +0300 Subject: another clamp --- src/audio/AudioLogic.cpp | 12 ++++++------ src/core/common.h | 2 ++ src/render/Fluff.h | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 28fa9343..9154e6a6 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -3210,7 +3210,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713; if (propellerSpeed < 1.0f) m_sQueueSample.m_nFrequency = (propellerSpeed + 1.0f) * (m_sQueueSample.m_nFrequency / 2.0f); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqFrontPrev - 197, freqFrontPrev + 197); + m_sQueueSample.m_nFrequency = clamp2(m_sQueueSample.m_nFrequency, freqFrontPrev, 197); freqFrontPrev = m_sQueueSample.m_nFrequency; m_sQueueSample.m_bIs2D = false; @@ -3268,7 +3268,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) if (propellerSpeed < 1.0f) m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPropellerPrev - 98, freqPropellerPrev + 98); + m_sQueueSample.m_nFrequency = clamp2(m_sQueueSample.m_nFrequency, freqPropellerPrev, 98); freqPropellerPrev = m_sQueueSample.m_nFrequency; } else { m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI2; @@ -3339,7 +3339,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713; if (propellerSpeed < 1.0) m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2.0f); - m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqSkimmerPrev - 197, freqSkimmerPrev + 197); + m_sQueueSample.m_nFrequency = clamp2(m_sQueueSample.m_nFrequency, freqSkimmerPrev, 197); freqSkimmerPrev = m_sQueueSample.m_nFrequency; m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; @@ -3441,8 +3441,8 @@ cAudioManager::ProcessVehicleFlatTyre(cVehicleParams* params) return; } modifier = Min(1.0f, Abs(params->m_fVelocityChange) / (0.3f * params->m_pTransmission->fMaxVelocity)); - if (modifier > 0.01) { //mb can be replaced by (emittingVol > 1) - emittingVol = (100.0 * modifier); + if (modifier > 0.01f) { //mb can be replaced by (emittingVol > 1) + emittingVol = (100.0f * modifier); CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume) { @@ -4968,7 +4968,7 @@ cAudioManager::ProcessExtraSounds() m_sQueueSample.m_vecPos = aVecExtraSoundPosition[i]; distance = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distance < SQR(SOUND_INTENSITY)) { - if (distance > 0.0) + if (distance > 0.0f) m_sQueueSample.m_fDistance = Sqrt(distance); else m_sQueueSample.m_fDistance = 0.0f; diff --git a/src/core/common.h b/src/core/common.h index ba1d24ef..0a2a236e 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -219,6 +219,8 @@ extern int strncasecmp(const char *str1, const char *str2, size_t len); #define clamp(v, low, high) ((v)<(low) ? (low) : (v)>(high) ? (high) : (v)) +#define clamp2(v, center, radius) ((v) < (center) ? Max(v, center - radius) : Min(v, center + radius)) + inline float sq(float x) { return x*x; } #define SQR(x) ((x) * (x)) diff --git a/src/render/Fluff.h b/src/render/Fluff.h index d600def7..a6a28cb7 100644 --- a/src/render/Fluff.h +++ b/src/render/Fluff.h @@ -103,7 +103,7 @@ public: void Update(void); void SwitchOff(void); void AddThisOne(CVector pos0, CVector pos1, CVector pos2, CVector pos3, bool b_isMovingDown); - bool IsActive() { return m_bIsActive; }; + bool IsActive() const { return m_bIsActive; }; const CVector& GetPosition() const { return m_midPoint; }; }; @@ -116,7 +116,7 @@ public: static void Update(void); static void AddOne(CVector pos0, CVector pos1, CVector pos2, CVector pos3, bool b_isMovingDown); static void Shutdown(void); - static CEscalator& GetEscalator(int ind) { return aEscalators[ind]; }; + static const CEscalator& GetEscalator(int ind) { return aEscalators[ind]; }; }; class CMovingThing -- cgit v1.2.3 From 9b7642454006f4c6b93d57297f88b2899e3f0077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sun, 27 Sep 2020 04:39:25 +0300 Subject: Fixes --- src/core/Frontend.cpp | 34 ++++++++++++++++++++++++++-------- src/core/config.h | 4 ++-- src/core/re3.cpp | 3 ++- src/render/Credits.cpp | 19 ++++++++++++++----- src/skel/glfw/glfw.cpp | 28 ++++++++++++++++++++++------ 5 files changed, 66 insertions(+), 22 deletions(-) diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 0e358fc5..256cf0d4 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -261,6 +261,12 @@ ScaleAndCenterX(float x) #define MENU_Y(y) StretchY(y) #endif +#ifdef PS2_LIKE_MENU +#define PAGE_NAME_X MENU_X_RIGHT_ALIGNED +#else +#define PAGE_NAME_X SCREEN_SCALE_FROM_RIGHT +#endif + #ifdef PS2_LIKE_MENU #define ChangeScreen(screen, option, updateDelay, withReverseAlpha) \ do { \ @@ -272,7 +278,7 @@ ScaleAndCenterX(float x) if (updateDelay) \ m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); \ } \ - if (withReverseAlpha) { \ + if (withReverseAlpha && !m_bRenderGameInMenu) { \ pendingOption = option; \ pendingScreen = screen; \ reverseAlpha = true; \ @@ -827,7 +833,7 @@ CMenuManager::Draw() if (aScreens[m_nCurrScreen].m_ScreenName[0] != '\0') { PREPARE_MENU_HEADER - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName)); + CFont::PrintString(PAGE_NAME_X(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName)); // Weird place to put that. nextYToUse += 24.0f + 10.0f; @@ -1418,10 +1424,17 @@ CMenuManager::Draw() if (!m_bRenderGameInMenu) #endif if (i == m_nCurrOption && itemsAreSelectable) { +#ifdef PS2_LIKE_MENU // We keep stretching, because we also stretch background image and we want that bar to be aligned with borders of background - CSprite2d::DrawRect(CRect(StretchX(10.0f), MENU_Y(bitAboveNextItemY), - SCREEN_STRETCH_FROM_RIGHT(11.0f), MENU_Y(usableLineHeight + nextItemY)), + CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(29.0f), MENU_Y(bitAboveNextItemY), + MENU_X_RIGHT_ALIGNED(29.0f), MENU_Y(usableLineHeight + nextItemY)), CRGBA(100, 200, 50, FadeIn(50))); +#else + // We keep stretching, because we also stretch background image and we want that bar to be aligned with borders of background + CSprite2d::DrawRect(CRect(StretchX(10.0f), MENU_Y(bitAboveNextItemY), + SCREEN_STRETCH_FROM_RIGHT(11.0f), MENU_Y(usableLineHeight + nextItemY)), + CRGBA(100, 200, 50, FadeIn(50))); +#endif } CFont::SetColor(CRGBA(0, 0, 0, FadeIn(90))); @@ -2047,11 +2060,11 @@ CMenuManager::DrawControllerSetupScreen() switch (m_ControlMethod) { case CONTROL_STANDARD: - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), + CFont::PrintString(PAGE_NAME_X(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName)); break; case CONTROL_CLASSIC: - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), + CFont::PrintString(PAGE_NAME_X(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get("FET_CTI")); break; default: @@ -2753,7 +2766,7 @@ CMenuManager::DrawPlayerSetupScreen() PREPARE_MENU_HEADER - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get("FET_PS")); + CFont::PrintString(PAGE_NAME_X(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get("FET_PS")); // lstrcpy's changed with strcpy @@ -3737,7 +3750,7 @@ CMenuManager::PrintStats() // ::Draw already does that. /* PREPARE_MENU_HEADER - CFont::PrintString(MENU_X_RIGHT_ALIGNED(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName)); + CFont::PrintString(PAGE_NAME_X(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName)); */ CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X), MENU_Y(MENU_TEXT_SIZE_Y)); } @@ -4513,12 +4526,17 @@ CMenuManager::ProcessButtonPresses(void) bottomBarActive = false; curBottomBarOption = hoveredBottomBarOption; ChangeScreen(bbNames[curBottomBarOption].screenId, 0, true, false); + if (bbNames[curBottomBarOption].screenId == MENUPAGE_SOUND_SETTINGS) + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); return; } else if (bottomBarActive) { if (CPad::GetPad(0)->GetEnterJustDown() || CPad::GetPad(0)->GetCrossJustDown()) { DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); bottomBarActive = false; + if (bbNames[curBottomBarOption].screenId == MENUPAGE_SOUND_SETTINGS) + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); + // If there's a menu change with fade ongoing, finish it now if (reverseAlpha) m_nMenuFadeAlpha = 0; diff --git a/src/core/config.h b/src/core/config.h index 498be8f3..13a0c099 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -242,13 +242,13 @@ enum Config { #ifndef PC_MENU # define PS2_MENU //# define PS2_MENU_USEALLPAGEICONS -# define PS2_SAVE_DIALOG // PS2 style save dialog with transparent black box -//# define PS2_LIKE_MENU // An effort to recreate PS2 menu, cycling through tabs, different bg etc. #else # define MENU_MAP // VC-like menu map. Make sure you have new menu.txd # define SCROLLABLE_STATS_PAGE // only draggable by mouse atm # define TRIANGLE_BACK_BUTTON //# define CIRCLE_BACK_BUTTON +//# define PS2_LIKE_MENU // An effort to recreate PS2 menu, cycling through tabs, different bg etc. +//# define PS2_SAVE_DIALOG // PS2 style save dialog with transparent black box # define CUSTOM_FRONTEND_OPTIONS # define GRAPHICS_MENU_OPTIONS // otherwise Advanced Options menu will appear if Display is full #endif diff --git a/src/core/re3.cpp b/src/core/re3.cpp index a7a0d7f1..13cb6283 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -267,6 +267,7 @@ void PS2AlphaTestChange(int8 displayedValue) // Important: Make sure to read the warnings/informations in frontendoption.h!! +// For texts: Either use TheText.Get, or use wcsdup(wchar version of strdup) void CustomFrontendOptionsPopulate(void) { @@ -369,7 +370,7 @@ CustomFrontendOptionsPopulate(void) #ifdef FREE_CAM SWITCH_TO_DISPLAY_MENU - static const wchar* text = (wchar*)L"FREE CAM"; + static const wchar* text = (wchar*)wcsdup(L"FREE CAM"); FrontendOptionAddSelect(text, off_on, 2, (int8*)&TheCamera.bFreeCam, false, FreeCamChange, nil, true); #endif diff --git a/src/render/Credits.cpp b/src/render/Credits.cpp index 2cfdba90..2d33ce40 100644 --- a/src/render/Credits.cpp +++ b/src/render/Credits.cpp @@ -11,6 +11,13 @@ bool CCredits::bCreditsGoing; uint32 CCredits::CreditsStartTime; +#ifdef ASPECT_RATIO_SCALE +#define SCALE_AND_CENTER(x) ScaleAndCenterX(x) +extern float ScaleAndCenterX(float x); +#else +#define SCALE_AND_CENTER(x) SCREEN_STRETCH_X(x) +#endif + void CCredits::Init(void) { @@ -39,11 +46,11 @@ CCredits::PrintCreditSpace(float space, uint32 &line) void CCredits::PrintCreditText(float scaleX, float scaleY, wchar *text, uint32 &lineoffset, float scrolloffset) { - float start = SCREEN_HEIGHT + 50.0f; + float start = DEFAULT_SCREEN_HEIGHT + 50.0f; float y = lineoffset + start - scrolloffset; if(y > -50.0f && y < start){ - CFont::SetScale(scaleX, scaleY); - CFont::PrintString(SCREEN_WIDTH/2.0f, y, (uint16*)text); + CFont::SetScale(SCREEN_SCALE_X(scaleX), SCREEN_SCALE_Y(scaleY)); + CFont::PrintString(SCREEN_WIDTH/2.0f, SCREEN_SCALE_Y(y), (uint16*)text); } lineoffset += scaleY*25.0f; } @@ -62,7 +69,7 @@ CCredits::Render(void) scrolloffset = (CTimer::GetTimeInMilliseconds() - CreditsStartTime) / 24.0f; CFont::SetJustifyOff(); CFont::SetBackgroundOff(); - CFont::SetCentreSize(SCREEN_WIDTH - 20); + CFont::SetCentreSize(SCALE_AND_CENTER(DEFAULT_SCREEN_WIDTH - 20)); CFont::SetCentreOn(); CFont::SetPropOn(); CFont::SetColor(CRGBA(220, 220, 220, 220)); @@ -489,7 +496,7 @@ CCredits::Render(void) if(TheCamera.m_WideScreenOn) TheCamera.DrawBordersForWideScreen(); - if(lineoffset + SCREEN_HEIGHT - scrolloffset < -10.0f) + if(lineoffset + DEFAULT_SCREEN_HEIGHT - scrolloffset < -10.0f) bCreditsGoing = false; } @@ -497,3 +504,5 @@ bool CCredits::AreCreditsDone(void) { return !bCreditsGoing; } + +#undef SCALE_AND_CENTER \ No newline at end of file diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index f5fd4474..d7feb885 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -822,12 +822,28 @@ void joysChangeCB(int jid, int event); bool IsThisJoystickBlacklisted(int i) { - const char *joyname = glfwGetJoystickName(i); + if (glfwJoystickIsGamepad(i)) + return false; + + const char* joyname = glfwGetJoystickName(i); // this is just a keyboard and mouse // Microsoft Microsoft® 2.4GHz Transceiver v8.0 Consumer Control // Microsoft Microsoft® 2.4GHz Transceiver v8.0 System Control - if(strstr(joyname, "2.4GHz Transceiver")) + if (strstr(joyname, "2.4GHz Transceiver")) + return true; + // COMPANY USB Device System Control + // COMPANY USB Device Consumer Control + if (strstr(joyname, "COMPANY USB")) + return true; + // i.e. Synaptics TM2438-005 + if (strstr(joyname, "Synaptics ")) + return true; + // i.e. ELAN Touchscreen + if (strstr(joyname, "ELAN ")) + return true; + // i.e. Primax Electronics, Ltd HP Wireless Keyboard Mouse Kit Consumer Control + if (strstr(joyname, "Keyboard")) return true; return false; @@ -2016,11 +2032,11 @@ void CapturePad(RwInt32 padID) // Gamepad axes are guaranteed to return 0.0f if that particular gamepad doesn't have that axis. if ( glfwPad != -1 ) { - leftStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[0] : numAxes >= 0 ? axes[0] : 0.0f; - leftStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[1] : numAxes >= 1 ? axes[1] : 0.0f; + leftStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[0] : numAxes >= 1 ? axes[0] : 0.0f; + leftStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[1] : numAxes >= 2 ? axes[1] : 0.0f; - rightStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[2] : numAxes >= 2 ? axes[2] : 0.0f; - rightStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[3] : numAxes >= 3 ? axes[3] : 0.0f; + rightStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[2] : numAxes >= 3 ? axes[2] : 0.0f; + rightStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[3] : numAxes >= 4 ? axes[3] : 0.0f; } { -- cgit v1.2.3 From 70aac0f460a9e57956de00ae5d84d8bb4bf4643c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sun, 27 Sep 2020 19:21:16 +0300 Subject: Fixes: PS2/PS2-like menu, Hud, new sliding text found --- src/audio/MusicManager.cpp | 2 +- src/core/Frontend.cpp | 89 +++++++++++++++++++++++++++++++--------------- src/core/Frontend_PS2.cpp | 13 +++++++ src/core/Frontend_PS2.h | 23 ++++++++++++ src/core/common.h | 3 ++ src/core/config.h | 2 +- src/render/Credits.cpp | 13 ++----- src/render/Draw.cpp | 11 ++++++ src/render/Font.cpp | 4 +-- src/render/Hud.cpp | 47 ++++++++++++++---------- src/skel/glfw/glfw.cpp | 3 +- src/skel/win/win.cpp | 4 +++ 12 files changed, 150 insertions(+), 64 deletions(-) diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index febd0ca1..9cf092b3 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -161,7 +161,7 @@ cMusicManager::DisplayRadioStationName() CFont::SetPropOn(); CFont::SetFontStyle(FONT_HEADING); CFont::SetCentreOn(); - CFont::SetCentreSize(SCREEN_SCALE_X(640.0f)); + CFont::SetCentreSize(SCREEN_STRETCH_X(640.0f)); CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(22.0f) + SCREEN_SCALE_Y(2.0f), pCurrentStation); diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 256cf0d4..9ead2a0a 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -235,28 +235,15 @@ const char* MenuFilenames[][2] = { { nil, nil } }; +#define MENU_X_RIGHT_ALIGNED(x) SCALE_AND_CENTER_X(DEFAULT_SCREEN_WIDTH - (x)) + #ifdef ASPECT_RATIO_SCALE // All of the defines below replace the StretchX function. Otherwise use SCREEN_SCALE_X. -#define MENU_X_LEFT_ALIGNED(x) ScaleAndCenterX(x) -#define MENU_X_RIGHT_ALIGNED(x) ScaleAndCenterX(DEFAULT_SCREEN_WIDTH - (x)) +#define MENU_X_LEFT_ALIGNED(x) SCALE_AND_CENTER_X(x) #define MENU_X(x) SCREEN_SCALE_X(x) #define MENU_Y(y) SCREEN_SCALE_Y(y) -float -ScaleAndCenterX(float x) -{ - if (SCREEN_WIDTH == DEFAULT_SCREEN_WIDTH) - return x; - else { - if (x > DEFAULT_SCREEN_WIDTH / 2) { - return SCREEN_WIDTH / 2 + SCREEN_SCALE_X(x - DEFAULT_SCREEN_WIDTH / 2); - } else { - return SCREEN_WIDTH / 2 - SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH / 2 - x); - } - } -} #else #define MENU_X_LEFT_ALIGNED(x) StretchX(x) -#define MENU_X_RIGHT_ALIGNED(x) SCREEN_STRETCH_FROM_RIGHT(x) #define MENU_X(x) StretchX(x) #define MENU_Y(y) StretchY(y) #endif @@ -1425,7 +1412,6 @@ CMenuManager::Draw() #endif if (i == m_nCurrOption && itemsAreSelectable) { #ifdef PS2_LIKE_MENU - // We keep stretching, because we also stretch background image and we want that bar to be aligned with borders of background CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(29.0f), MENU_Y(bitAboveNextItemY), MENU_X_RIGHT_ALIGNED(29.0f), MENU_Y(usableLineHeight + nextItemY)), CRGBA(100, 200, 50, FadeIn(50))); @@ -2348,12 +2334,11 @@ CMenuManager::DrawFrontEndNormal() if (!m_bGameNotLoaded) { CSprite2d *bg = LoadSplash(nil); - bg->Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255)); + bg->Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(48, 48, 48, 255)); } else { CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(0, 0, 0, 255)); } - RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST); RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); @@ -2461,6 +2446,46 @@ CMenuManager::DrawFrontEndNormal() break; } + // Positions/style from PS2 menu, credits to Fire_Head + /* Draw controller buttons */ + CFont::SetFontStyle(FONT_BANK); + CFont::SetBackgroundOff(); + CFont::SetScale(SCREEN_SCALE_X(0.35f), SCREEN_SCALE_Y(0.64f)); + CFont::SetPropOn(); + CFont::SetCentreOff(); + CFont::SetJustifyOn(); + CFont::SetRightJustifyOff(); + CFont::SetBackGroundOnlyTextOn(); + CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(40.0f)); // 600.0f + CFont::SetColor(CRGBA(16, 16, 16, 255)); + switch (m_nCurrScreen) { + + // Page names overlaps buttons on those. + case MENUPAGE_MOUSE_CONTROLS: + case MENUPAGE_KEYBOARD_CONTROLS: + break; + + default: + { + CFont::PrintString(MENU_X_LEFT_ALIGNED(52.0f), MENU_Y(360.0f), TheText.Get("FEDS_SE")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(52.0f), MENU_Y(372.0f), TheText.Get("FEDS_BA")); + if (!m_bGameNotLoaded) + CFont::PrintString(MENU_X_LEFT_ALIGNED(52.0f), MENU_Y(384.0f), TheText.Get("FEDS_ST")); + + if (bottomBarActive) + CFont::PrintString(MENU_X_LEFT_ALIGNED(242.0f), MENU_Y(372.0f), TheText.Get("FEDS_AM")); // <>-CHANGE MENU + else if (m_nCurrScreen != MENUPAGE_STATS && m_nCurrScreen != MENUPAGE_BRIEFS) { + CFont::PrintString(MENU_X_LEFT_ALIGNED(242.0f), MENU_Y(360.0f + 3.5f), TheText.Get("FEA_UP")); // ; + CFont::PrintString(MENU_X_LEFT_ALIGNED(242.0f), MENU_Y(384.0f - 3.5f), TheText.Get("FEA_DO")); // = + CFont::PrintString(MENU_X_LEFT_ALIGNED(242.0f - 10.0f), MENU_Y(372.0f), TheText.Get("FEA_LE")); // < + CFont::PrintString(MENU_X_LEFT_ALIGNED(242.0f + 11.0f), MENU_Y(372.0f), TheText.Get("FEA_RI")); // > + CFont::PrintString(MENU_X_LEFT_ALIGNED(242.0f + 20.0f), MENU_Y(372.0f), TheText.Get("FEDSAS3")); // - CHANGE SELECTION + } + + break; + } + } + #define optionWidth MENU_X(66.0f) #define rawOptionHeight 22.0f #define optionBottom SCREEN_SCALE_FROM_BOTTOM(20.0f) @@ -3560,15 +3585,15 @@ CMenuManager::MessageScreen(const char *text) CFont::SetPropOn(); CFont::SetJustifyOn(); CFont::SetBackGroundOnlyTextOn(); - CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(170.0f)); - CFont::SetRightJustifyWrap(SCREEN_SCALE_FROM_RIGHT(170.0f)); - CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(120.0f), SCREEN_SCALE_Y(150.0f), SCREEN_SCALE_FROM_RIGHT(120.0f), SCREEN_SCALE_FROM_BOTTOM(220.0f)), CRGBA(50, 50, 50, 210)); + CFont::SetWrapx(SCREEN_WIDTH - StretchX(170.0f)); + CFont::SetRightJustifyWrap(SCREEN_WIDTH - StretchX(170.0f)); + CSprite2d::DrawRect(CRect(StretchX(120.0f), StretchY(150.0f), SCREEN_WIDTH - StretchX(120.0f), SCREEN_HEIGHT - StretchY(220.0f)), CRGBA(50, 50, 50, 210)); CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); - CFont::SetCentreSize(SCREEN_SCALE_X(380.0f)); + CFont::SetCentreSize(SCREEN_STRETCH_X(380.0f)); CFont::SetCentreOn(); CFont::SetColor(CRGBA(255, 217, 106, 255)); CFont::SetScale(SCREEN_SCALE_X(SMALLTEXT_X_SCALE), SCREEN_SCALE_Y(SMALLTEXT_Y_SCALE)); - CFont::PrintString(SCREEN_SCALE_X(320.0f), SCREEN_SCALE_Y(170.0f), TheText.Get(text)); + CFont::PrintString(StretchX(320.0f), StretchY(170.0f), TheText.Get(text)); CFont::DrawFonts(); DoRWStuffEndOfFrame(); } @@ -4543,18 +4568,24 @@ CMenuManager::ProcessButtonPresses(void) return; } else if (CPad::GetPad(0)->GetLeftJustDown() || CPad::GetPad(0)->GetAnaloguePadLeft() || CPad::GetPad(0)->GetDPadLeftJustDown() || CPad::GetPad(0)->GetUpJustDown() || CPad::GetPad(0)->GetAnaloguePadUp() || CPad::GetPad(0)->GetDPadUpJustDown()) { + + if (reverseAlpha && m_nMenuFadeAlpha > 30) + return; + m_bShowMouse = false; DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); - if (curBottomBarOption > 0) - curBottomBarOption--; + curBottomBarOption = ((curBottomBarOption + bbTabCount) - 1) % bbTabCount; ChangeScreen(bbNames[curBottomBarOption].screenId, 0, true, true); return; } else if (CPad::GetPad(0)->GetRightJustDown() || CPad::GetPad(0)->GetAnaloguePadRight() || CPad::GetPad(0)->GetDPadRightJustDown() || CPad::GetPad(0)->GetDownJustDown() || CPad::GetPad(0)->GetAnaloguePadDown() || CPad::GetPad(0)->GetDPadDownJustDown()) { + + if (reverseAlpha && m_nMenuFadeAlpha > 30) + return; + m_bShowMouse = false; DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); - if (curBottomBarOption < bbTabCount-1) - curBottomBarOption++; + curBottomBarOption = ((curBottomBarOption + bbTabCount) + 1) % bbTabCount; ChangeScreen(bbNames[curBottomBarOption].screenId, 0, true, true); return; } @@ -5121,7 +5152,7 @@ CMenuManager::ProcessButtonPresses(void) return; #endif } -#ifdef PS2_LIKE_MENU +#ifdef PS2_SAVE_DIALOG else if (m_nCurrScreen == MENUPAGE_CHOOSE_SAVE_SLOT || m_nCurrScreen == MENUPAGE_SAVE) { #else else if (m_nCurrScreen == MENUPAGE_CHOOSE_SAVE_SLOT) { diff --git a/src/core/Frontend_PS2.cpp b/src/core/Frontend_PS2.cpp index 8e604978..d474ee65 100644 --- a/src/core/Frontend_PS2.cpp +++ b/src/core/Frontend_PS2.cpp @@ -203,6 +203,19 @@ static const char* FrontendFilenames[][2] = {"fe_radio9", "" }, }; +#ifdef CUTSCENE_BORDERS_SWITCH +bool CMenuManager::m_PrefsCutsceneBorders = true; +#endif + +#ifdef MULTISAMPLING +int8 CMenuManager::m_nPrefsMSAALevel = 0; +int8 CMenuManager::m_nDisplayMSAALevel = 0; +#endif + +#ifdef NO_ISLAND_LOADING +int8 CMenuManager::m_DisplayIslandLoading = ISLAND_LOADING_LOW; +int8 CMenuManager::m_PrefsIslandLoading = ISLAND_LOADING_LOW; +#endif int32 CMenuManager::m_PrefsSfxVolume = 102; int32 CMenuManager::m_PrefsMusicVolume = 102; diff --git a/src/core/Frontend_PS2.h b/src/core/Frontend_PS2.h index 2f226dc3..c1e42291 100644 --- a/src/core/Frontend_PS2.h +++ b/src/core/Frontend_PS2.h @@ -160,7 +160,30 @@ public: static int32 m_PrefsLanguage; static CONTRCONFIG m_PrefsControllerConfig; static bool m_PrefsUseVibration; +#ifdef NO_ISLAND_LOADING + enum + { + ISLAND_LOADING_LOW = 0, + ISLAND_LOADING_MEDIUM, + ISLAND_LOADING_HIGH + }; + + static int8 m_DisplayIslandLoading; + static int8 m_PrefsIslandLoading; +#define ISLAND_LOADING_IS(p) if (CMenuManager::m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_##p) +#define ISLAND_LOADING_ISNT(p) if (CMenuManager::m_PrefsIslandLoading != CMenuManager::ISLAND_LOADING_##p) +#else +#define ISLAND_LOADING_IS(p) +#define ISLAND_LOADING_ISNT(p) +#endif +#ifdef CUTSCENE_BORDERS_SWITCH + static bool m_PrefsCutsceneBorders; +#endif +#ifdef MULTISAMPLING + static int8 m_nPrefsMSAALevel; + static int8 m_nDisplayMSAALevel; +#endif #ifdef GTA_PC bool m_bQuitGameNoCD; diff --git a/src/core/common.h b/src/core/common.h index e876c4ec..9b5c2369 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -144,8 +144,11 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w) #ifdef ASPECT_RATIO_SCALE #define SCREEN_SCALE_AR(a) ((a) * DEFAULT_ASPECT_RATIO / SCREEN_ASPECT_RATIO) +extern float ScaleAndCenterX(float x); +#define SCALE_AND_CENTER_X(x) ScaleAndCenterX(x) #else #define SCREEN_SCALE_AR(a) (a) +#define SCALE_AND_CENTER_X(x) SCREEN_STRETCH_X(x) #endif #include "maths.h" diff --git a/src/core/config.h b/src/core/config.h index 13a0c099..e8e15ebe 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -235,7 +235,7 @@ enum Config { // Hud, frontend and radar #define HUD_ENHANCEMENTS // Adjusts some aspects to make the HUD look/behave a little bit better. -#define BETA_SLIDING_TEXT +// #define BETA_SLIDING_TEXT #define TRIANGULAR_BLIPS // height indicating triangular radar blips, as in VC #define PC_MENU diff --git a/src/render/Credits.cpp b/src/render/Credits.cpp index 2d33ce40..6b28ff04 100644 --- a/src/render/Credits.cpp +++ b/src/render/Credits.cpp @@ -11,13 +11,6 @@ bool CCredits::bCreditsGoing; uint32 CCredits::CreditsStartTime; -#ifdef ASPECT_RATIO_SCALE -#define SCALE_AND_CENTER(x) ScaleAndCenterX(x) -extern float ScaleAndCenterX(float x); -#else -#define SCALE_AND_CENTER(x) SCREEN_STRETCH_X(x) -#endif - void CCredits::Init(void) { @@ -69,7 +62,7 @@ CCredits::Render(void) scrolloffset = (CTimer::GetTimeInMilliseconds() - CreditsStartTime) / 24.0f; CFont::SetJustifyOff(); CFont::SetBackgroundOff(); - CFont::SetCentreSize(SCALE_AND_CENTER(DEFAULT_SCREEN_WIDTH - 20)); + CFont::SetCentreSize(SCALE_AND_CENTER_X(DEFAULT_SCREEN_WIDTH - 20)); CFont::SetCentreOn(); CFont::SetPropOn(); CFont::SetColor(CRGBA(220, 220, 220, 220)); @@ -503,6 +496,4 @@ CCredits::Render(void) bool CCredits::AreCreditsDone(void) { return !bCreditsGoing; -} - -#undef SCALE_AND_CENTER \ No newline at end of file +} \ No newline at end of file diff --git a/src/render/Draw.cpp b/src/render/Draw.cpp index db87e76d..4e323ec2 100644 --- a/src/render/Draw.cpp +++ b/src/render/Draw.cpp @@ -70,3 +70,14 @@ CDraw::SetFOV(float fov) #endif ms_fFOV = fov; } + +#ifdef ASPECT_RATIO_SCALE +float +ScaleAndCenterX(float x) +{ + if (SCREEN_WIDTH == DEFAULT_SCREEN_WIDTH) + return x; + else + return (SCREEN_WIDTH - SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)) / 2 + SCREEN_SCALE_X(x); +} +#endif \ No newline at end of file diff --git a/src/render/Font.cpp b/src/render/Font.cpp index de7de81a..58e44a5b 100644 --- a/src/render/Font.cpp +++ b/src/render/Font.cpp @@ -244,8 +244,8 @@ CFont::Initialise(void) SetColor(CRGBA(0xFF, 0xFF, 0xFF, 0)); SetJustifyOff(); SetCentreOff(); - SetWrapx(DEFAULT_SCREEN_WIDTH); - SetCentreSize(DEFAULT_SCREEN_WIDTH); + SetWrapx(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); + SetCentreSize(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); SetBackgroundOff(); SetBackgroundColor(CRGBA(0x80, 0x80, 0x80, 0x80)); SetBackGroundOnlyTextOff(); diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 08c0cb85..5c0dd86e 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -336,7 +336,7 @@ void CHud::Draw() CFont::SetScale(SCREEN_SCALE_X(0.4f), SCREEN_SCALE_Y(0.6f)); CFont::SetJustifyOff(); CFont::SetCentreOn(); - CFont::SetCentreSize(SCREEN_SCALE_X(640.0f)); + CFont::SetCentreSize(SCREEN_WIDTH); CFont::SetPropOn(); CFont::SetFontStyle(FONT_BANK); @@ -740,7 +740,7 @@ void CHud::Draw() CFont::SetRightJustifyWrap(0.0f); CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING)); CFont::SetColor(CRGBA(244, 20, 20, 255)); - CFont::SetWrapx(SCREEN_SCALE_X(640.0f)); + CFont::SetWrapx(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); CFont::SetPropOff(); CFont::SetBackGroundOnlyTextOn(); @@ -869,8 +869,8 @@ void CHud::Draw() else CFont::SetCentreOff(); - CFont::SetWrapx(SCREEN_SCALE_X(CTheScripts::IntroTextLines[i].m_fWrapX)); - CFont::SetCentreSize(SCREEN_SCALE_X(CTheScripts::IntroTextLines[i].m_fCenterSize)); + CFont::SetWrapx(SCALE_AND_CENTER_X(CTheScripts::IntroTextLines[i].m_fWrapX)); + CFont::SetCentreSize(SCALE_AND_CENTER_X(CTheScripts::IntroTextLines[i].m_fCenterSize)); if (CTheScripts::IntroTextLines[i].m_bBackground) CFont::SetBackgroundOn(); @@ -890,7 +890,7 @@ void CHud::Draw() CFont::SetPropOff(); CFont::SetFontStyle(FONT_LOCALE(CTheScripts::IntroTextLines[i].m_nFont)); - CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - CTheScripts::IntroTextLines[i].m_fAtX), SCREEN_SCALE_Y(DEFAULT_SCREEN_HEIGHT - CTheScripts::IntroTextLines[i].m_fAtY), CTheScripts::IntroTextLines[i].m_Text); + CFont::PrintString(SCALE_AND_CENTER_X(DEFAULT_SCREEN_WIDTH - CTheScripts::IntroTextLines[i].m_fAtX), SCREEN_SCALE_Y(DEFAULT_SCREEN_HEIGHT - CTheScripts::IntroTextLines[i].m_fAtY), CTheScripts::IntroTextLines[i].m_Text); } } for (int i = 0; i < ARRAY_SIZE(CTheScripts::IntroRectangles); i++) { @@ -957,9 +957,11 @@ void CHud::Draw() CFont::SetScale(SCREEN_SCALE_X(1.8f), SCREEN_SCALE_Y(1.8f)); CFont::SetPropOn(); CFont::SetCentreOn(); - CFont::SetCentreSize(SCREEN_SCALE_X(615.0f)); + CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(25.0f)); CFont::SetFontStyle(FONT_HEADING); + // Appearently sliding text in here was abandoned very early, since this text is centered now. + if (BigMessageX[0] >= SCREEN_SCALE_FROM_RIGHT(20.0f)) { BigMessageInUse[0] += CTimer::GetTimeStep(); @@ -974,7 +976,7 @@ void CHud::Draw() } } else { - BigMessageX[0] += (CTimer::GetTimeStepInMilliseconds() * 0.3f); + BigMessageX[0] += SCREEN_SCALE_X((CTimer::GetTimeStepInMilliseconds() * 0.3f)); BigMessageAlpha[0] += (CTimer::GetTimeStepInMilliseconds() * 0.3f); if (BigMessageAlpha[0] > 255.0f) @@ -983,17 +985,19 @@ void CHud::Draw() CFont::SetColor(CRGBA(0, 0, 0, BigMessageAlpha[0])); #ifdef FIX_BUGS - CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(18.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[0]); +#define Y_OFFSET 18.0f #else - CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(20.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[0]); +#define Y_OFFSET 20.0f #endif - + CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(Y_OFFSET) + SCREEN_SCALE_Y(2.0f), m_BigMessage[0]); CFont::SetColor(CRGBA(BIGMESSAGE_COLOR.r, BIGMESSAGE_COLOR.g, BIGMESSAGE_COLOR.b, BigMessageAlpha[0])); CFont::PrintString(SCREEN_WIDTH / 2, (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(18.0f), m_BigMessage[0]); + +#undef Y_OFFSET } else { BigMessageAlpha[0] = 0.0f; - BigMessageX[0] = -60.0f; + BigMessageX[0] = SCALE_AND_CENTER_X(-60.0f); BigMessageInUse[0] = 1.0f; } } @@ -1162,8 +1166,8 @@ void CHud::DrawAfterFade() else CFont::SetCentreOff(); - CFont::SetWrapx(SCREEN_SCALE_X(line.m_fWrapX)); - CFont::SetCentreSize(SCREEN_SCALE_X(line.m_fCenterSize)); + CFont::SetWrapx(SCALE_AND_CENTER_X(line.m_fWrapX)); + CFont::SetCentreSize(SCALE_AND_CENTER_X(line.m_fCenterSize)); if (line.m_bBackground) CFont::SetBackgroundOn(); else @@ -1181,7 +1185,7 @@ void CHud::DrawAfterFade() CFont::SetPropOff(); CFont::SetFontStyle(line.m_nFont); - CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - line.m_fAtX), SCREEN_SCALE_Y(DEFAULT_SCREEN_HEIGHT - line.m_fAtY), line.m_Text); + CFont::PrintString(SCALE_AND_CENTER_X(DEFAULT_SCREEN_WIDTH - line.m_fAtX), SCREEN_SCALE_Y(DEFAULT_SCREEN_HEIGHT - line.m_fAtY), line.m_Text); } } for (int i = 0; i < ARRAY_SIZE(CTheScripts::IntroRectangles); i++) { @@ -1209,7 +1213,7 @@ void CHud::DrawAfterFade() CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f)); CFont::SetCentreOn(); CFont::SetPropOn(); - CFont::SetCentreSize(SCREEN_SCALE_X(600.0f)); + CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(40.0f)); CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); CFont::SetColor(CRGBA(0, 0, 0, 255)); @@ -1225,7 +1229,7 @@ void CHud::DrawAfterFade() CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f)); CFont::SetCentreOn(); CFont::SetPropOn(); - CFont::SetCentreSize(SCREEN_SCALE_X(620.0f)); + CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(20.0f)); CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); @@ -1329,7 +1333,7 @@ void CHud::DrawAfterFade() BigMessageAlpha[1] = 0.0f; } } else { - BigMessageX[1] += (CTimer::GetTimeStepInMilliseconds() * 0.3f); + BigMessageX[1] += SCREEN_SCALE_X((CTimer::GetTimeStepInMilliseconds() * 0.3f)); BigMessageAlpha[1] += (CTimer::GetTimeStepInMilliseconds() * 0.3f); if (BigMessageAlpha[1] > 255.0f) @@ -1337,14 +1341,21 @@ void CHud::DrawAfterFade() } CFont::SetColor(CRGBA(40, 40, 40, BigMessageAlpha[1])); +#ifdef BETA_SLIDING_TEXT + CFont::PrintString(SCREEN_SCALE_X(2.0f) + BigMessageX[1], SCREEN_SCALE_FROM_BOTTOM(120.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[1]); + + CFont::SetColor(CRGBA(MISSIONTITLE_COLOR.r, MISSIONTITLE_COLOR.g, MISSIONTITLE_COLOR.b, BigMessageAlpha[1])); + CFont::PrintString(BigMessageX[1], SCREEN_SCALE_FROM_BOTTOM(120.0f), m_BigMessage[1]); +#else CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[1]); CFont::SetColor(CRGBA(MISSIONTITLE_COLOR.r, MISSIONTITLE_COLOR.g, MISSIONTITLE_COLOR.b, BigMessageAlpha[1])); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), m_BigMessage[1]); +#endif } else { BigMessageAlpha[1] = 0.0f; - BigMessageX[1] = -60.0f; + BigMessageX[1] = SCALE_AND_CENTER_X(-60.0f); BigMessageInUse[1] = 1.0f; } } diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index d7feb885..b9dbf5ac 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1721,7 +1721,6 @@ main(int argc, char *argv[]) #else LoadingScreen(nil, nil, "loadsc0"); #endif - if ( !CGame::InitialiseOnceAfterRW() ) RsGlobal.quit = TRUE; @@ -1734,6 +1733,7 @@ main(int argc, char *argv[]) break; } +#ifndef PS2_MENU case GS_INIT_FRONTEND: { LoadingScreen(nil, nil, "loadsc0"); @@ -1754,7 +1754,6 @@ main(int argc, char *argv[]) break; } -#ifndef PS2_MENU case GS_FRONTEND: { if(!glfwGetWindowAttrib(PSGLOBAL(window), GLFW_ICONIFIED)) diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index 03eb0d09..119e666e 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -2513,8 +2513,10 @@ WinMain(HINSTANCE instance, { if ( gGameState == GS_PLAYING_GAME ) CGame::ShutDown(); +#ifndef MASTER else if ( gGameState == GS_ANIMVIEWER ) CAnimViewer::Shutdown(); +#endif CTimer::Stop(); @@ -2538,8 +2540,10 @@ WinMain(HINSTANCE instance, if ( gGameState == GS_PLAYING_GAME ) CGame::ShutDown(); +#ifndef MASTER else if ( gGameState == GS_ANIMVIEWER ) CAnimViewer::Shutdown(); +#endif DMAudio.Terminate(); -- cgit v1.2.3 From 37e382c7581426d38d482a27f53c522af184df77 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Mon, 28 Sep 2020 03:29:45 +0300 Subject: fix for frequency misscalculation --- src/audio/AudioManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 58483602..cd01fb59 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -794,7 +794,7 @@ cAudioManager::ProcessActiveQueues() if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) { int32 freq; if (sample.m_nFrequency <= m_asActiveSamples[j].m_nFrequency) { - freq = Max(sample.m_nFrequency, m_asActiveSamples[j].m_nFrequency - 6000); + freq = Max((int32)sample.m_nFrequency, (int32)(m_asActiveSamples[j].m_nFrequency - 6000)); } else { freq = Min(sample.m_nFrequency, m_asActiveSamples[j].m_nFrequency + 6000); } -- cgit v1.2.3 From 7576b003c6862280cd2c7ca13e4804c8f78f28ae Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Mon, 28 Sep 2020 20:48:28 +0300 Subject: change for better understanding --- src/audio/AudioManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index feaa6708..754bce18 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -794,7 +794,7 @@ cAudioManager::ProcessActiveQueues() if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) { int32 freq; if (sample.m_nFrequency <= m_asActiveSamples[j].m_nFrequency) { - freq = Max((int32)sample.m_nFrequency, (int32)(m_asActiveSamples[j].m_nFrequency - 6000)); + freq = Max((int32)sample.m_nFrequency, (int32)(m_asActiveSamples[j].m_nFrequency) - 6000); } else { freq = Min(sample.m_nFrequency, m_asActiveSamples[j].m_nFrequency + 6000); } -- cgit v1.2.3 From c317d3d9b14d8169a9e5c920ebf2a5b9db4f8cc4 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Mon, 28 Sep 2020 21:09:06 +0300 Subject: tiny style fix --- src/audio/AudioLogic.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 9154e6a6..28da2a75 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -2377,13 +2377,6 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) float maxDist; cPedParams pedParams; - static uint8 WaveIndex = 41; - static uint8 GunIndex = 53; - static uint8 iWheelIndex = 82; - static uint8 CrunchOffset = 0; - static uint8 heliIndex = 0; - - for (int i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; i++) { noReflections = 0; m_sQueueSample.m_bRequireReflection = false; @@ -2471,13 +2464,14 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) } break; case SOUND_CAR_JUMP: { const float SOUND_INTENSITY = 35.0f; + static uint8 WheelIndex = 82; emittingVol = Max(80.f, 2 * (100.f * m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i])); maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_TYRE_BUMP; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nCounter = iWheelIndex++; - if (iWheelIndex > 85) - iWheelIndex = 82; + m_sQueueSample.m_nCounter = WheelIndex++; + if (WheelIndex > 85) + WheelIndex = 82; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TYRE_BUMP); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); if (params->m_nIndex == RCBANDIT) { @@ -2566,6 +2560,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) } case SOUND_CAR_SPLASH: { const float SOUND_INTENSITY = 40.0f; + static uint8 WaveIndex = 41; vol = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i]; if (vol <= 300.f) continue; @@ -2659,6 +2654,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) } case SOUND_31:{ const float SOUND_INTENSITY = 35.0f; + static uint8 HeliIndex = 0; relVol = ((CAutomobile*)params->m_pVehicle)->m_aWheelSpeed[1] * 50.0f / 11.0f; if (relVol < 0.2f || relVol == 1.0f) continue; @@ -2666,8 +2662,8 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_ROT; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nCounter = heliIndex + 89; - heliIndex = heliIndex != 1 ? heliIndex + 1 : 0; //maybe better use 1 and 0, to avoid extreme values + m_sQueueSample.m_nCounter = HeliIndex + 89; + HeliIndex = HeliIndex != 1 ? HeliIndex + 1 : 0; //maybe better use 1 and 0, to avoid extreme values m_sQueueSample.m_nFrequency = (8000.0f * relVol) + 16000; m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); m_sQueueSample.m_nReleasingVolumeModificator = 2; @@ -2677,6 +2673,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) } case SOUND_WEAPON_SHOT_FIRED: { const float SOUND_INTENSITY = 120.0f; + static uint8 GunIndex = 53; emittingVol = m_anRandomTable[2]; maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_UZI_LEFT; @@ -2755,6 +2752,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) } case SOUND_SPLATTER: { const float SOUND_INTENSITY = 40.0f; + static uint8 CrunchOffset = 0; m_sQueueSample.m_nSampleIndex = CrunchOffset + SFX_PED_CRUNCH_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 48; @@ -3369,7 +3367,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) if (automobile != nil) automobile->GetComponentWorldPosition(CAR_BOOT, m_sQueueSample.m_vecPos); else if (params->m_VehicleType == VEHICLE_TYPE_HELI) - m_sQueueSample.m_vecPos = { 0.0f, -10.0f, 0.0f }; //this is from android, but for real it's not used + m_sQueueSample.m_vecPos = CVector(0.0f, -10.0f, 0.0f); //this is from android, but for real it's not used params->m_bDistanceCalculated = false; params->m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); -- cgit v1.2.3 From a5269b998baa5db5c37674f506d9a41c61939cdf Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Mon, 28 Sep 2020 21:11:24 +0300 Subject: reverse compare --- src/audio/AudioLogic.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 28da2a75..e98151e7 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -3135,10 +3135,10 @@ cAudioManager::ProcessCarHeli(cVehicleParams* params) if (boat != nil) { m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO3; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - if (accelerateState <= 0 && brakeState <= 0) - m_sQueueSample.m_nFrequency = 3651 + Min(1.0f, freqModifier) * 949; - else + if (accelerateState > 0 || brakeState > 0) m_sQueueSample.m_nFrequency = 4600 + Min(1.0f, (Max(accelerateState, brakeState) / 255.0f) * freqModifier) * 563; + else + m_sQueueSample.m_nFrequency = 3651 + Min(1.0f, freqModifier) * 949; } else { m_sQueueSample.m_nSampleIndex = SFX_HELI_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; -- cgit v1.2.3 From 742ca47a436632eb84de925c8d3386b7bc7dd2d2 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Mon, 28 Sep 2020 21:25:14 +0300 Subject: fixed cargen --- src/vehicles/CarGen.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vehicles/CarGen.cpp b/src/vehicles/CarGen.cpp index dd727e2b..5de478b7 100644 --- a/src/vehicles/CarGen.cpp +++ b/src/vehicles/CarGen.cpp @@ -28,7 +28,7 @@ void CCarGenerator::SwitchOff() void CCarGenerator::SwitchOn() { - m_nUsesRemaining = 255; + m_nUsesRemaining = UINT16_MAX; m_nTimer = CalcNextGen(); ++CTheCarGenerators::CurrentActiveCount; } @@ -111,10 +111,10 @@ void CCarGenerator::DoInternalProcessing() } } #ifdef FIX_BUGS - if (m_nUsesRemaining != 0) + if (m_nUsesRemaining < UINT16_MAX) --m_nUsesRemaining; #else - if (m_nUsesRemaining < -1) + if (m_nUsesRemaining < ~0) --m_nUsesRemaining; #endif m_nTimer = CalcNextGen(); -- cgit v1.2.3 From 5144b5051ccf7bbbbbf6022e7526431dd8fe2fa8 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 28 Sep 2020 21:37:59 +0300 Subject: Fix arg types --- src/audio/AudioLogic.cpp | 4 ++-- src/audio/AudioManager.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 5ea03aff..174bd5fa 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -2796,7 +2796,7 @@ cAudioManager::SetupJumboTaxiSound(uint8 vol) } bool -cAudioManager::SetupJumboWhineSound(uint8 emittingVol, int32 freq) +cAudioManager::SetupJumboWhineSound(uint8 emittingVol, uint32 freq) { const float SOUND_INTENSITY = 170.0f; @@ -2828,7 +2828,7 @@ cAudioManager::SetupJumboWhineSound(uint8 emittingVol, int32 freq) } bool -cAudioManager::SetupJumboEngineSound(uint8 vol, int32 freq) +cAudioManager::SetupJumboEngineSound(uint8 vol, uint32 freq) { const float SOUND_INTENSITY = 180.0f; if (m_sQueueSample.m_fDistance >= SOUND_INTENSITY) diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index b6bbef8f..a1aa96f5 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -457,11 +457,11 @@ public: void SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 counter); void SetUpOneShotCollisionSound(const cAudioCollision &col); bool SetupCrimeReport(); - bool SetupJumboEngineSound(uint8 vol, int32 freq); + bool SetupJumboEngineSound(uint8 vol, uint32 freq); bool SetupJumboFlySound(uint8 emittingVol); bool SetupJumboRumbleSound(uint8 emittingVol); bool SetupJumboTaxiSound(uint8 vol); - bool SetupJumboWhineSound(uint8 emittingVol, int32 freq); + bool SetupJumboWhineSound(uint8 emittingVol, uint32 freq); void SetupPedComments(cPedParams *params, uint32 sound); void SetupSuspectLastSeenReport(); -- cgit v1.2.3 From a729f32c83c93cab54596911e957b0fbee028ebc Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Tue, 29 Sep 2020 01:39:59 +0300 Subject: TEMPORALY remove flying cars --- src/vehicles/Vehicle.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 795219ba..378a4c0a 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -351,11 +351,6 @@ CVehicle::FlyingControl(eFlightModel flightModel) fSteerUD *= -fSteerMult; // thrust -#ifdef ALT_DODO_CHEAT //allow fly on cars - float dooCompinsator = ((CPad::GetPad(0)->GetAccelerate() - CPad::GetPad(0)->GetBrake()) / 255.0f) * 2; - if (bAltDodoCheat) - ApplyMoveForce(GetForward() * CTimer::GetTimeStep() * dooCompinsator); -#endif float fForwSpeed = DotProduct(GetMoveSpeed(), GetForward()); CVector vecTail = GetColModel()->boundingBox.min.y * GetForward(); float fThrust = (CPad::GetPad(0)->GetAccelerate() - CPad::GetPad(0)->GetBrake()) / 255.0f; -- cgit v1.2.3 From a0588ef8b1e54765c042dd5cdeb9b4b31cad578f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Tue, 29 Sep 2020 02:29:10 +0300 Subject: Restore All Cars are Heli cheat --- src/core/ControllerConfig.cpp | 3 --- src/core/Pad.cpp | 4 ++-- src/core/Pad.h | 8 +++---- src/core/config.h | 5 ++--- src/vehicles/Automobile.cpp | 45 ++++++++++++++++++++++---------------- src/vehicles/Automobile.h | 3 ++- src/vehicles/Vehicle.cpp | 51 ++++++++++++++++++++++++------------------- 7 files changed, 63 insertions(+), 56 deletions(-) diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index b0e04e2b..e7982221 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -733,9 +733,6 @@ void CControllerConfigManager::AffectControllerStateOn_ButtonDown_Driving(int32 FindPlayerVehicle()->GetModelIndex() == MI_DODO #ifdef FIX_BUGS || CVehicle::bAllDodosCheat -#ifdef ALLCARSHELI_CHEAT - || bAllCarCheat -#endif #endif ))) { diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index a8ccbc36..36e14e55 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -526,7 +526,7 @@ void KangarooCheat() } #endif -#ifdef ALLCARSHELI_CHEAT +#ifdef RESTORE_ALLCARSHELI_CHEAT void AllCarsHeliCheat(void) { wchar* string; @@ -1438,7 +1438,7 @@ void CPad::AddToPCCheatString(char c) CPed::SwitchDebugDisplay(); #endif -#ifdef ALLCARSHELI_CHEAT +#ifdef RESTORE_ALLCARSHELI_CHEAT // "CARSAREHELI" if (!_CHEATCMP("ILEHERASRAC")) AllCarsHeliCheat(); diff --git a/src/core/Pad.h b/src/core/Pad.h index 72851317..cde2d3c5 100644 --- a/src/core/Pad.h +++ b/src/core/Pad.h @@ -286,6 +286,8 @@ public: bool GetMiddleMouseJustUp() { return !!(!NewMouseControllerState.MMB && OldMouseControllerState.MMB); } bool GetMouseWheelUpJustUp() { return !!(!NewMouseControllerState.WHEELUP && OldMouseControllerState.WHEELUP); } bool GetMouseWheelDownJustUp() { return !!(!NewMouseControllerState.WHEELDN && OldMouseControllerState.WHEELDN); } + bool GetMouseX1JustUp() { return !!(!NewMouseControllerState.MXB1 && OldMouseControllerState.MXB1); } + bool GetMouseX2JustUp() { return !!(!NewMouseControllerState.MXB2 && OldMouseControllerState.MXB2); } bool GetLeftMouse() { return NewMouseControllerState.LMB; } bool GetRightMouse() { return NewMouseControllerState.RMB; } @@ -469,8 +471,4 @@ public: }; VALIDATE_SIZE(CPad, 0xFC); -extern CPad Pads[MAX_PADS]; - -#ifdef ALLCARSHELI_CHEAT -extern bool bAllCarCheat; -#endif +extern CPad Pads[MAX_PADS]; \ No newline at end of file diff --git a/src/core/config.h b/src/core/config.h index 82044f75..327230d0 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -250,7 +250,7 @@ enum Config { #endif #define DETECT_PAD_INPUT_SWITCH // Adds automatic switch of pad related stuff between controller and kb/m #define KANGAROO_CHEAT -#define ALLCARSHELI_CHEAT +#define RESTORE_ALLCARSHELI_CHEAT #define ALT_DODO_CHEAT #define WALLCLIMB_CHEAT #define REGISTER_START_BUTTON @@ -258,14 +258,13 @@ enum Config { // Hud, frontend and radar #define HUD_ENHANCEMENTS // Adjusts some aspects to make the HUD look/behave a little bit better. -#define BETA_SLIDING_TEXT +//#define BETA_SLIDING_TEXT #define TRIANGULAR_BLIPS // height indicating triangular radar blips, as in VC #define PC_MENU #ifndef PC_MENU # define PS2_MENU //# define PS2_MENU_USEALLPAGEICONS -//# define PS2_LIKE_MENU // An effort to recreate PS2 menu, cycling through tabs, different bg etc. #else # define MAP_ENHANCEMENTS // Adding waypoint etc. # define TRIANGLE_BACK_BUTTON diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index eec44c35..5c5cf6b4 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -100,7 +100,7 @@ CAutomobile::CAutomobile(int32 id, uint8 CreatedBy) } pHandling = mod_HandlingManager.GetHandlingData((eHandlingId)mi->m_handlingId); - pFlyingHandling = mod_HandlingManager.GetFlyingPointer((eHandlingId)mi->m_handlingId); + pFlyingHandling = mod_HandlingManager.GetFlyingPointer((eHandlingId)mi->m_handlingId); m_auto_unused1 = 20.0f; m_auto_unused2 = 0; @@ -1293,7 +1293,7 @@ CAutomobile::ProcessControl(void) // Process front wheels off ground - if(!IsRealHeli()){ + if (!IsRealHeli()) { if(m_aWheelTimer[CARWHEEL_FRONT_LEFT] <= 0.0f){ if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f) m_aWheelSpeed[CARWHEEL_FRONT_LEFT] *= 0.95f; @@ -1397,24 +1397,31 @@ CAutomobile::ProcessControl(void) }else if(GetModelIndex() == MI_RCBARON){ FlyingControl(FLIGHT_MODEL_RCPLANE); }else if(IsRealHeli() || bAllCarCheat){ - // Speed up rotor - if(m_aWheelSpeed[1] < 0.22f && !bIsInWater){ - if(GetModelIndex() == MI_RCRAIDER || GetModelIndex() == MI_RCGOBLIN) - m_aWheelSpeed[1] += 0.003f; - else - m_aWheelSpeed[1] += 0.001f; - } +#ifdef RESTORE_ALLCARSHELI_CHEAT + if (bAllCarCheat) + FlyingControl(FLIGHT_MODEL_HELI); + else +#endif + { + // Speed up rotor + if (m_aWheelSpeed[1] < 0.22f && !bIsInWater) { + if (GetModelIndex() == MI_RCRAIDER || GetModelIndex() == MI_RCGOBLIN) + m_aWheelSpeed[1] += 0.003f; + else + m_aWheelSpeed[1] += 0.001f; + } - // Fly - if(m_aWheelSpeed[1] > 0.15f){ - if(GetModelIndex() == MI_RCRAIDER || GetModelIndex() == MI_RCGOBLIN) - FlyingControl(FLIGHT_MODEL_RCHELI); - else if(m_nWheelsOnGround < 4 && !(GetModelIndex() == MI_SEASPAR && bTouchingWater) || - CPad::GetPad(0)->GetAccelerate() != 0 || CPad::GetPad(0)->GetCarGunUpDown() > 1.0f || - Abs(m_vecMoveSpeed.x) > 0.02f || - Abs(m_vecMoveSpeed.y) > 0.02f || - Abs(m_vecMoveSpeed.z) > 0.02f) - FlyingControl(FLIGHT_MODEL_HELI); + // Fly + if (m_aWheelSpeed[1] > 0.15f) { + if (GetModelIndex() == MI_RCRAIDER || GetModelIndex() == MI_RCGOBLIN) + FlyingControl(FLIGHT_MODEL_RCHELI); + else if (m_nWheelsOnGround < 4 && !(GetModelIndex() == MI_SEASPAR && bTouchingWater) || + CPad::GetPad(0)->GetAccelerate() != 0 || CPad::GetPad(0)->GetCarGunUpDown() > 1.0f || + Abs(m_vecMoveSpeed.x) > 0.02f || + Abs(m_vecMoveSpeed.y) > 0.02f || + Abs(m_vecMoveSpeed.z) > 0.02f) + FlyingControl(FLIGHT_MODEL_HELI); + } } // Blade collision diff --git a/src/vehicles/Automobile.h b/src/vehicles/Automobile.h index 3dee998d..b2f0643c 100644 --- a/src/vehicles/Automobile.h +++ b/src/vehicles/Automobile.h @@ -167,4 +167,5 @@ public: static void SetAllTaxiLights(bool set); }; -extern CVector vecHunterGunPos; \ No newline at end of file +extern CVector vecHunterGunPos; +extern bool bAllCarCheat; \ No newline at end of file diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 378a4c0a..2e790e81 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -432,7 +432,12 @@ CVehicle::FlyingControl(eFlightModel flightModel) case FLIGHT_MODEL_RCHELI: case FLIGHT_MODEL_HELI: { - float rm = Pow(pFlyingHandling->fMoveRes, CTimer::GetTimeStep()); +#ifdef RESTORE_ALLCARSHELI_CHEAT + tFlyingHandlingData* flyingHandling = bAllCarCheat && GetStatus() == STATUS_PLAYER && !IsRealHeli() ? mod_HandlingManager.GetFlyingPointer(HANDLING_MAVERICK) : pFlyingHandling; +#else + tFlyingHandlingData* flyingHandling = pFlyingHandling; +#endif + float rm = Pow(flyingHandling->fMoveRes, CTimer::GetTimeStep()); m_vecMoveSpeed *= rm; if (GetStatus() != STATUS_PLAYER && GetStatus() != STATUS_PLAYER_REMOTE) return; @@ -441,11 +446,11 @@ CVehicle::FlyingControl(eFlightModel flightModel) if(fThrust < 0.0f) fThrust *= 2.0f; if(flightModel == FLIGHT_MODEL_RCHELI){ - fThrust = pFlyingHandling->fThrust * fThrust + 0.45f; + fThrust = flyingHandling->fThrust * fThrust + 0.45f; ApplyMoveForce(GRAVITY * CVector(0.0f, 0.0f, 0.5f) * m_fMass * CTimer::GetTimeStep()); }else - fThrust = pFlyingHandling->fThrust * fThrust + 0.95f; - fThrust -= pFlyingHandling->fThrustFallOff * fUpSpeed; + fThrust = flyingHandling->fThrust * fThrust + 0.95f; + fThrust -= flyingHandling->fThrustFallOff * fUpSpeed; if(flightModel == FLIGHT_MODEL_RCHELI && GetPosition().z > 40.0f) fThrust *= 10.0f/(GetPosition().z - 30.0f); else if(GetPosition().z > 80.0f) @@ -453,20 +458,20 @@ CVehicle::FlyingControl(eFlightModel flightModel) ApplyMoveForce(GRAVITY * GetUp() * fThrust * m_fMass * CTimer::GetTimeStep()); if (GetUp().z > 0.0f){ - float upRight = clamp(GetRight().z, -pFlyingHandling->fFormLift, pFlyingHandling->fFormLift); - float upImpulseRight = -upRight * pFlyingHandling->fAttackLift * m_fTurnMass * CTimer::GetTimeStep(); + float upRight = clamp(GetRight().z, -flyingHandling->fFormLift, flyingHandling->fFormLift); + float upImpulseRight = -upRight * flyingHandling->fAttackLift * m_fTurnMass * CTimer::GetTimeStep(); ApplyTurnForce(upImpulseRight * GetUp(), GetRight()); - float upFwd = clamp(GetForward().z, -pFlyingHandling->fFormLift, pFlyingHandling->fFormLift); - float upImpulseFwd = -upFwd * pFlyingHandling->fAttackLift * m_fTurnMass * CTimer::GetTimeStep(); + float upFwd = clamp(GetForward().z, -flyingHandling->fFormLift, flyingHandling->fFormLift); + float upImpulseFwd = -upFwd * flyingHandling->fAttackLift * m_fTurnMass * CTimer::GetTimeStep(); ApplyTurnForce(upImpulseFwd * GetUp(), GetForward()); }else{ - float upRight = GetRight().z < 0.0f ? -pFlyingHandling->fFormLift : pFlyingHandling->fFormLift; - float upImpulseRight = -upRight * pFlyingHandling->fAttackLift * m_fTurnMass * CTimer::GetTimeStep(); + float upRight = GetRight().z < 0.0f ? -flyingHandling->fFormLift : flyingHandling->fFormLift; + float upImpulseRight = -upRight * flyingHandling->fAttackLift * m_fTurnMass * CTimer::GetTimeStep(); ApplyTurnForce(upImpulseRight * GetUp(), GetRight()); - float upFwd = GetForward().z < 0.0f ? -pFlyingHandling->fFormLift : pFlyingHandling->fFormLift; - float upImpulseFwd = -upFwd * pFlyingHandling->fAttackLift * m_fTurnMass * CTimer::GetTimeStep(); + float upFwd = GetForward().z < 0.0f ? -flyingHandling->fFormLift : flyingHandling->fFormLift; + float upImpulseFwd = -upFwd * flyingHandling->fAttackLift * m_fTurnMass * CTimer::GetTimeStep(); ApplyTurnForce(upImpulseFwd * GetUp(), GetForward()); } @@ -490,25 +495,25 @@ CVehicle::FlyingControl(eFlightModel flightModel) fPitch = -CPad::GetPad(0)->GetCarGunUpDown() / 128.0f; if (CPad::GetPad(0)->GetHorn()) { fYaw = 0.0f; - fPitch = clamp(pFlyingHandling->fPitchStab * DotProduct(m_vecMoveSpeed, GetForward()), -200.0f, 1.3f); - fRoll = clamp(pFlyingHandling->fRollStab * DotProduct(m_vecMoveSpeed, GetRight()), -200.0f, 1.3f); + fPitch = clamp(flyingHandling->fPitchStab * DotProduct(m_vecMoveSpeed, GetForward()), -200.0f, 1.3f); + fRoll = clamp(flyingHandling->fRollStab * DotProduct(m_vecMoveSpeed, GetRight()), -200.0f, 1.3f); } - ApplyTurnForce(fPitch * GetUp() * pFlyingHandling->fPitch * m_fTurnMass * CTimer::GetTimeStep(), GetForward()); - ApplyTurnForce(fRoll * GetUp() * pFlyingHandling->fRoll * m_fTurnMass * CTimer::GetTimeStep(), GetRight()); + ApplyTurnForce(fPitch * GetUp() * flyingHandling->fPitch * m_fTurnMass * CTimer::GetTimeStep(), GetForward()); + ApplyTurnForce(fRoll * GetUp() * flyingHandling->fRoll * m_fTurnMass * CTimer::GetTimeStep(), GetRight()); float fSideSpeed = -DotProduct(GetMoveSpeed(), GetRight()); - float fSideSlipAccel = pFlyingHandling->fSideSlip * fSideSpeed * Abs(fSideSpeed); + float fSideSlipAccel = flyingHandling->fSideSlip * fSideSpeed * Abs(fSideSpeed); ApplyMoveForce(m_fMass * GetRight() * fSideSlipAccel * CTimer::GetTimeStep()); - float fYawAccel = pFlyingHandling->fYawStab * fSideSpeed * Abs(fSideSpeed) + pFlyingHandling->fYaw * fYaw; + float fYawAccel = flyingHandling->fYawStab * fSideSpeed * Abs(fSideSpeed) + flyingHandling->fYaw * fYaw; ApplyTurnForce(fYawAccel * GetRight() * m_fTurnMass * CTimer::GetTimeStep(), -GetForward()); - ApplyTurnForce(fYaw * GetForward() * pFlyingHandling->fYaw * m_fTurnMass * CTimer::GetTimeStep(), GetRight()); + ApplyTurnForce(fYaw * GetForward() * flyingHandling->fYaw * m_fTurnMass * CTimer::GetTimeStep(), GetRight()); - float rX = Pow(pFlyingHandling->vecTurnRes.x, CTimer::GetTimeStep()); - float rY = Pow(pFlyingHandling->vecTurnRes.y, CTimer::GetTimeStep()); - float rZ = Pow(pFlyingHandling->vecTurnRes.z, CTimer::GetTimeStep()); + float rX = Pow(flyingHandling->vecTurnRes.x, CTimer::GetTimeStep()); + float rY = Pow(flyingHandling->vecTurnRes.y, CTimer::GetTimeStep()); + float rZ = Pow(flyingHandling->vecTurnRes.z, CTimer::GetTimeStep()); CVector vecTurnSpeed = Multiply3x3(m_vecTurnSpeed, GetMatrix()); - float fResistanceMultiplier = Pow(1.0f / (pFlyingHandling->vecSpeedRes.z * SQR(vecTurnSpeed.z) + 1.0f) * rZ, CTimer::GetTimeStep()); + float fResistanceMultiplier = Pow(1.0f / (flyingHandling->vecSpeedRes.z * SQR(vecTurnSpeed.z) + 1.0f) * rZ, CTimer::GetTimeStep()); float fResistance = vecTurnSpeed.z * fResistanceMultiplier - vecTurnSpeed.z; vecTurnSpeed.x *= rX; vecTurnSpeed.y *= rY; -- cgit v1.2.3 From a0b6410801b38c5e429b4dd4a2e8975615a615db Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 16:56:40 +0200 Subject: Make frequency more consistent with vanilla --- src/audio/AudioManager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 754bce18..994cab35 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -794,7 +794,11 @@ cAudioManager::ProcessActiveQueues() if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) { int32 freq; if (sample.m_nFrequency <= m_asActiveSamples[j].m_nFrequency) { - freq = Max((int32)sample.m_nFrequency, (int32)(m_asActiveSamples[j].m_nFrequency) - 6000); +#if FIX_BUGS + freq = Max((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency - 6000); +#else + freq = Max((int32)sample.m_nFrequency, int32(m_asActiveSamples[j].m_nFrequency - 6000)); +#endif } else { freq = Min(sample.m_nFrequency, m_asActiveSamples[j].m_nFrequency + 6000); } -- cgit v1.2.3 From 8424eabf2240541782fa6c9b358cdef022477778 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 17:02:47 +0200 Subject: Fix build (if -> ifdef) --- src/audio/AudioManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 994cab35..a42aa16f 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -794,7 +794,7 @@ cAudioManager::ProcessActiveQueues() if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) { int32 freq; if (sample.m_nFrequency <= m_asActiveSamples[j].m_nFrequency) { -#if FIX_BUGS +#ifdef FIX_BUGS freq = Max((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency - 6000); #else freq = Max((int32)sample.m_nFrequency, int32(m_asActiveSamples[j].m_nFrequency - 6000)); -- cgit v1.2.3 From eeb26cfc7db1b010e9b9373f6f3f5bce3f2240fa Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 17:16:02 +0200 Subject: Fix warning ISO C++11 does not allow conversion from string literal to 'char * --- src/core/timebars.cpp | 4 ++-- src/core/timebars.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/timebars.cpp b/src/core/timebars.cpp index 6b841a5c..7aaa04e6 100644 --- a/src/core/timebars.cpp +++ b/src/core/timebars.cpp @@ -50,7 +50,7 @@ void tbInit() #endif } -void tbStartTimer(int32 unk, char *name) +void tbStartTimer(int32 unk, const char *name) { strcpy(TimerBar.Timers[TimerBar.count].name, name); TimerBar.Timers[TimerBar.count].unk = unk; @@ -58,7 +58,7 @@ void tbStartTimer(int32 unk, char *name) TimerBar.count++; } -void tbEndTimer(char* name) +void tbEndTimer(const char* name) { uint32 n = 1500; for (uint32 i = 0; i < TimerBar.count; i++) { diff --git a/src/core/timebars.h b/src/core/timebars.h index 6d3b853e..1a5a0573 100644 --- a/src/core/timebars.h +++ b/src/core/timebars.h @@ -1,6 +1,6 @@ #pragma once void tbInit(); -void tbStartTimer(int32, char*); -void tbEndTimer(char*); +void tbStartTimer(int32, const char*); +void tbEndTimer(const char*); void tbDisplay(); \ No newline at end of file -- cgit v1.2.3 From 874b31d82b7a277a5b34fe09f3c6802c065d6e3f Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 17:27:36 +0200 Subject: Use Const instead of const (last commit) --- src/core/timebars.cpp | 4 ++-- src/core/timebars.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/timebars.cpp b/src/core/timebars.cpp index 7aaa04e6..5ac5565d 100644 --- a/src/core/timebars.cpp +++ b/src/core/timebars.cpp @@ -50,7 +50,7 @@ void tbInit() #endif } -void tbStartTimer(int32 unk, const char *name) +void tbStartTimer(int32 unk, Const char *name) { strcpy(TimerBar.Timers[TimerBar.count].name, name); TimerBar.Timers[TimerBar.count].unk = unk; @@ -58,7 +58,7 @@ void tbStartTimer(int32 unk, const char *name) TimerBar.count++; } -void tbEndTimer(const char* name) +void tbEndTimer(Const char* name) { uint32 n = 1500; for (uint32 i = 0; i < TimerBar.count; i++) { diff --git a/src/core/timebars.h b/src/core/timebars.h index 1a5a0573..3871b61c 100644 --- a/src/core/timebars.h +++ b/src/core/timebars.h @@ -1,6 +1,6 @@ #pragma once void tbInit(); -void tbStartTimer(int32, const char*); -void tbEndTimer(const char*); +void tbStartTimer(int32, Const char*); +void tbEndTimer(Const char*); void tbDisplay(); \ No newline at end of file -- cgit v1.2.3 From e324f3dac0d960a3e16d538b056c36d34c6682d4 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 17:43:34 +0200 Subject: Some more const --- src/extras/frontendoption.cpp | 2 +- src/extras/frontendoption.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/extras/frontendoption.cpp b/src/extras/frontendoption.cpp index f8d9f81e..70489c3c 100644 --- a/src/extras/frontendoption.cpp +++ b/src/extras/frontendoption.cpp @@ -279,7 +279,7 @@ void FrontendOptionAddBackButton(const wchar* text, bool fadeIn) option.save = false; } -uint8 FrontendScreenAdd(char* gxtKey, eMenuSprites sprite, int prevPage, int columnWidth, int headerHeight, int lineHeight, +uint8 FrontendScreenAdd(const char* gxtKey, eMenuSprites sprite, int prevPage, int columnWidth, int headerHeight, int lineHeight, int8 font, float fontScaleX, float fontScaleY, int8 alignment, bool showLeftRightHelper, ReturnPrevPageFunc returnPrevPageFunc) { uint8 screenOrder = RegisterNewScreen(gxtKey, prevPage); diff --git a/src/extras/frontendoption.h b/src/extras/frontendoption.h index 8e2dd668..b2bfbf5e 100644 --- a/src/extras/frontendoption.h +++ b/src/extras/frontendoption.h @@ -158,5 +158,5 @@ void FrontendOptionAddDynamic(const wchar* leftText, DrawFunc rightTextDrawFunc, void FrontendOptionAddRedirect(const wchar* text, int to, int8 selectedOption = 0, bool fadeIn = true); void FrontendOptionAddBackButton(const wchar* text, bool fadeIn = true); -uint8 FrontendScreenAdd(char* gxtKey, eMenuSprites sprite, int prevPage, int columnWidth, int headerHeight, int lineHeight, int8 font, float fontScaleX, float fontScaleY, int8 alignment, bool showLeftRightHelper, ReturnPrevPageFunc returnPrevPageFunc = nil); +uint8 FrontendScreenAdd(const char* gxtKey, eMenuSprites sprite, int prevPage, int columnWidth, int headerHeight, int lineHeight, int8 font, float fontScaleX, float fontScaleY, int8 alignment, bool showLeftRightHelper, ReturnPrevPageFunc returnPrevPageFunc = nil); #endif \ No newline at end of file -- cgit v1.2.3 From 8235fe08d116366964577a8ddb0367b96b718531 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 17:47:48 +0200 Subject: Fix more --- src/extras/frontendoption.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extras/frontendoption.cpp b/src/extras/frontendoption.cpp index 70489c3c..b365a3fe 100644 --- a/src/extras/frontendoption.cpp +++ b/src/extras/frontendoption.cpp @@ -118,7 +118,7 @@ RemoveCustomFrontendOptions() lastOgScreen = MENUPAGES; } -int8 RegisterNewScreen(char *name, int prevPage) +int8 RegisterNewScreen(const char *name, int prevPage) { if (lastOgScreen == MENUPAGES) lastOgScreen = GetLastMenuScreen(); -- cgit v1.2.3 From 35d7591defb352c2af49af0d6e0d3340e7b59672 Mon Sep 17 00:00:00 2001 From: shfil Date: Sat, 26 Sep 2020 20:11:25 +0200 Subject: some SilentPatch fixes # Conflicts: # src/core/Camera.cpp # src/weapons/Weapon.cpp --- src/control/Garages.cpp | 6 ++++++ src/core/CdStream.cpp | 4 +++- src/core/Radar.cpp | 12 ++++++++++++ src/skel/win/win.cpp | 17 ++++++++++++++++- src/vehicles/DamageManager.cpp | 2 ++ 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index 9aba431c..290bacad 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -1819,7 +1819,13 @@ CVehicle* CStoredCar::RestoreCar() #ifdef FIX_BUGS if (pVehicle->IsCar()) #endif + { ((CAutomobile*)pVehicle)->m_bombType = m_nCarBombType; +#ifdef FIX_BUGS + if (m_nCarBombType != CARBOMB_NONE) + ((CAutomobile*)pVehicle)->m_pBombRigger = FindPlayerPed(); +#endif + } pVehicle->bHasBeenOwnedByPlayer = true; pVehicle->m_nDoorLock = CARLOCK_UNLOCKED; pVehicle->bBulletProof = m_bBulletproof; diff --git a/src/core/CdStream.cpp b/src/core/CdStream.cpp index d9978040..c11fb72a 100644 --- a/src/core/CdStream.cpp +++ b/src/core/CdStream.cpp @@ -106,12 +106,14 @@ CdStreamInit(int32 numChannels) GetDiskFreeSpace(nil, &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters); _gdwCdStreamFlags = 0; - + +#ifndef FIX_BUGS // this just slows down streaming if ( BytesPerSector <= CDSTREAM_SECTOR_SIZE ) { _gdwCdStreamFlags |= FILE_FLAG_NO_BUFFERING; debug("Using no buffered loading for streaming\n"); } +#endif _gbCdStreamOverlapped = TRUE; diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 559a8cd6..b9fc369d 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -1151,6 +1151,10 @@ int CRadar::SetCoordBlip(eBlipType type, CVector pos, int32 color, eBlipDisplay if (!ms_RadarTrace[nextBlip].m_bInUse) break; } +#ifdef FIX_BUGS + if (nextBlip == NUMRADARBLIPS) + return -1; +#endif ms_RadarTrace[nextBlip].m_eBlipType = type; ms_RadarTrace[nextBlip].m_nColor = color; ms_RadarTrace[nextBlip].m_bDim = true; @@ -1182,6 +1186,10 @@ int CRadar::SetEntityBlip(eBlipType type, int32 handle, int32 color, eBlipDispla if (!ms_RadarTrace[nextBlip].m_bInUse) break; } +#ifdef FIX_BUGS + if (nextBlip == NUMRADARBLIPS) + return -1; +#endif ms_RadarTrace[nextBlip].m_eBlipType = type; ms_RadarTrace[nextBlip].m_nColor = color; ms_RadarTrace[nextBlip].m_bDim = true; @@ -1526,6 +1534,10 @@ CRadar::ToggleTargetMarker(float x, float y) if (!ms_RadarTrace[nextBlip].m_bInUse) break; } +#ifdef FIX_BUGS + if (nextBlip == NUMRADARBLIPS) + return; +#endif ms_RadarTrace[nextBlip].m_eBlipType = BLIP_COORD; ms_RadarTrace[nextBlip].m_nColor = 0x333333FF; ms_RadarTrace[nextBlip].m_bDim = 1; diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index cc106e39..5d67d343 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -1099,8 +1099,11 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) if ( wParam == VK_SHIFT ) _InputTranslateShiftKeyUpDown(&ks); - +#ifdef FIX_BUGS + break; +#else return 0L; +#endif } case WM_KEYUP: @@ -1113,7 +1116,11 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) if ( wParam == VK_SHIFT ) _InputTranslateShiftKeyUpDown(&ks); +#ifdef FIX_BUGS + break; +#else return 0L; +#endif } case WM_SYSKEYDOWN: @@ -1126,7 +1133,11 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) if ( wParam == VK_SHIFT ) _InputTranslateShiftKeyUpDown(&ks); +#ifdef FIX_BUGS + break; +#else return 0L; +#endif } case WM_SYSKEYUP: @@ -1139,7 +1150,11 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) if ( wParam == VK_SHIFT ) _InputTranslateShiftKeyUpDown(&ks); +#ifdef FIX_BUGS + break; +#else return 0L; +#endif } case WM_ACTIVATEAPP: diff --git a/src/vehicles/DamageManager.cpp b/src/vehicles/DamageManager.cpp index e4c28c95..8ba235b7 100644 --- a/src/vehicles/DamageManager.cpp +++ b/src/vehicles/DamageManager.cpp @@ -48,8 +48,10 @@ CDamageManager::FuckCarCompletely(void) #endif } // Why set to no damage? +#ifndef FIX_BUGS m_lightStatus = 0; m_panelStatus = 0; +#endif SetEngineStatus(250); } -- cgit v1.2.3 From 35656fe0e88dcc5334cc9b7e3234df2ffac5d1d3 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sun, 27 Sep 2020 00:32:14 +0200 Subject: Add target arm64 # Conflicts: # premake5.lua --- premake5.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/premake5.lua b/premake5.lua index 478ac18d..b61a9c4c 100644 --- a/premake5.lua +++ b/premake5.lua @@ -47,6 +47,8 @@ function getarch(a) return 'amd64' elseif a == 'ARM' then return 'arm' + elseif a == 'ARM64' then + return 'arm64' end return a end @@ -75,6 +77,7 @@ workspace "reVC" "linux-x86-librw_gl3_glfw-oal", "linux-amd64-librw_gl3_glfw-oal", "linux-arm-librw_gl3_glfw-oal", + "linux-arm64-librw_gl3_glfw-oal", } filter { "system:bsd" } -- cgit v1.2.3 From f35fd97c7632784e206093891272f03dc11653a8 Mon Sep 17 00:00:00 2001 From: shfil Date: Mon, 28 Sep 2020 20:05:28 +0200 Subject: Merge pull request #722 from theR4K/master fix for frequency miscalculation --- src/audio/AudioManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index c0a70e31..aadfde92 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -811,7 +811,7 @@ cAudioManager::ProcessActiveQueues() if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) { int32 freq; if (sample.m_nFrequency <= m_asActiveSamples[j].m_nFrequency) { - freq = Max(sample.m_nFrequency, m_asActiveSamples[j].m_nFrequency - 6000); + freq = Max((int32)sample.m_nFrequency, (int32)(m_asActiveSamples[j].m_nFrequency) - 6000); } else { freq = Min(sample.m_nFrequency, m_asActiveSamples[j].m_nFrequency + 6000); } -- cgit v1.2.3 From 9cce324316e0c2794c8509d34c2868f9fdd7f986 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Mon, 28 Sep 2020 21:25:14 +0300 Subject: fixed cargen # Conflicts: # src/vehicles/CarGen.cpp --- src/vehicles/CarGen.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vehicles/CarGen.cpp b/src/vehicles/CarGen.cpp index 84a19b82..130bf1e9 100644 --- a/src/vehicles/CarGen.cpp +++ b/src/vehicles/CarGen.cpp @@ -32,7 +32,7 @@ void CCarGenerator::SwitchOff() void CCarGenerator::SwitchOn() { - m_nUsesRemaining = 255; + m_nUsesRemaining = UINT16_MAX; m_nTimer = CalcNextGen(); ++CTheCarGenerators::CurrentActiveCount; } @@ -143,10 +143,10 @@ void CCarGenerator::DoInternalProcessing() m_nVehicleHandle = CPools::GetVehiclePool()->GetIndex(pVehicle); /* I don't think this is a correct comparasion */ #ifdef FIX_BUGS - if (m_nUsesRemaining != 0) + if (m_nUsesRemaining < UINT16_MAX) --m_nUsesRemaining; #else - if (m_nUsesRemaining < -1) + if (m_nUsesRemaining < ~0) --m_nUsesRemaining; #endif m_nTimer = CalcNextGen(); -- cgit v1.2.3 From 2129cc290650527945d389c1de9c466b5b305183 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 28 Sep 2020 21:37:59 +0300 Subject: Fix arg types --- src/audio/AudioLogic.cpp | 4 ++-- src/audio/AudioManager.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 6865b7ae..18fe4fc5 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -3646,7 +3646,7 @@ cAudioManager::SetupJumboTaxiSound(uint8 vol) } bool -cAudioManager::SetupJumboWhineSound(uint8 emittingVol, int32 freq) +cAudioManager::SetupJumboWhineSound(uint8 emittingVol, uint32 freq) { const float SOUND_INTENSITY = 170.0f; @@ -3678,7 +3678,7 @@ cAudioManager::SetupJumboWhineSound(uint8 emittingVol, int32 freq) } bool -cAudioManager::SetupJumboEngineSound(uint8 vol, int32 freq) +cAudioManager::SetupJumboEngineSound(uint8 vol, uint32 freq) { const float SOUND_INTENSITY = 180.0f; if (m_sQueueSample.m_fDistance >= SOUND_INTENSITY) diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 949de7d1..0b9dd4f7 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -405,11 +405,11 @@ public: void SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 counter); void SetUpOneShotCollisionSound(const cAudioCollision &col); bool SetupCrimeReport(); - bool SetupJumboEngineSound(uint8 vol, int32 freq); + bool SetupJumboEngineSound(uint8 vol, uint32 freq); bool SetupJumboFlySound(uint8 emittingVol); bool SetupJumboRumbleSound(uint8 emittingVol); bool SetupJumboTaxiSound(uint8 vol); - bool SetupJumboWhineSound(uint8 emittingVol, int32 freq); + bool SetupJumboWhineSound(uint8 emittingVol, uint32 freq); void SetupPedComments(cPedParams *params, uint32 sound); void SetupSuspectLastSeenReport(); -- cgit v1.2.3 From ff2998bee36509e8db74ea482eb33217c9129d63 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 16:56:40 +0200 Subject: Make frequency more consistent with vanilla --- src/audio/AudioManager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index aadfde92..61bf5a86 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -811,7 +811,11 @@ cAudioManager::ProcessActiveQueues() if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) { int32 freq; if (sample.m_nFrequency <= m_asActiveSamples[j].m_nFrequency) { - freq = Max((int32)sample.m_nFrequency, (int32)(m_asActiveSamples[j].m_nFrequency) - 6000); +#if FIX_BUGS + freq = Max((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency - 6000); +#else + freq = Max((int32)sample.m_nFrequency, int32(m_asActiveSamples[j].m_nFrequency - 6000)); +#endif } else { freq = Min(sample.m_nFrequency, m_asActiveSamples[j].m_nFrequency + 6000); } -- cgit v1.2.3 From 855c6a3c056f93cdd05daf39beacabd49ea9a97b Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 17:02:47 +0200 Subject: Fix build (if -> ifdef) --- src/audio/AudioManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 61bf5a86..f230731b 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -811,7 +811,7 @@ cAudioManager::ProcessActiveQueues() if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) { int32 freq; if (sample.m_nFrequency <= m_asActiveSamples[j].m_nFrequency) { -#if FIX_BUGS +#ifdef FIX_BUGS freq = Max((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency - 6000); #else freq = Max((int32)sample.m_nFrequency, int32(m_asActiveSamples[j].m_nFrequency - 6000)); -- cgit v1.2.3 From 6c59d97520c309a5fff6ed6da4499518281817ba Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 17:16:02 +0200 Subject: Fix warning ISO C++11 does not allow conversion from string literal to 'char * --- src/core/timebars.cpp | 4 ++-- src/core/timebars.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/timebars.cpp b/src/core/timebars.cpp index 884feffd..f7dedf0c 100644 --- a/src/core/timebars.cpp +++ b/src/core/timebars.cpp @@ -50,7 +50,7 @@ void tbInit() #endif } -void tbStartTimer(int32 unk, char *name) +void tbStartTimer(int32 unk, const char *name) { strcpy(TimerBar.Timers[TimerBar.count].name, name); TimerBar.Timers[TimerBar.count].unk = unk; @@ -58,7 +58,7 @@ void tbStartTimer(int32 unk, char *name) TimerBar.count++; } -void tbEndTimer(char* name) +void tbEndTimer(const char* name) { uint32 n = 1500; for (uint32 i = 0; i < TimerBar.count; i++) { diff --git a/src/core/timebars.h b/src/core/timebars.h index 6d3b853e..1a5a0573 100644 --- a/src/core/timebars.h +++ b/src/core/timebars.h @@ -1,6 +1,6 @@ #pragma once void tbInit(); -void tbStartTimer(int32, char*); -void tbEndTimer(char*); +void tbStartTimer(int32, const char*); +void tbEndTimer(const char*); void tbDisplay(); \ No newline at end of file -- cgit v1.2.3 From 73e4350320a11b0f3ca7530cedc9364363c2ce03 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 17:27:36 +0200 Subject: Use Const instead of const (last commit) --- src/core/timebars.cpp | 4 ++-- src/core/timebars.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/timebars.cpp b/src/core/timebars.cpp index f7dedf0c..31949009 100644 --- a/src/core/timebars.cpp +++ b/src/core/timebars.cpp @@ -50,7 +50,7 @@ void tbInit() #endif } -void tbStartTimer(int32 unk, const char *name) +void tbStartTimer(int32 unk, Const char *name) { strcpy(TimerBar.Timers[TimerBar.count].name, name); TimerBar.Timers[TimerBar.count].unk = unk; @@ -58,7 +58,7 @@ void tbStartTimer(int32 unk, const char *name) TimerBar.count++; } -void tbEndTimer(const char* name) +void tbEndTimer(Const char* name) { uint32 n = 1500; for (uint32 i = 0; i < TimerBar.count; i++) { diff --git a/src/core/timebars.h b/src/core/timebars.h index 1a5a0573..3871b61c 100644 --- a/src/core/timebars.h +++ b/src/core/timebars.h @@ -1,6 +1,6 @@ #pragma once void tbInit(); -void tbStartTimer(int32, const char*); -void tbEndTimer(const char*); +void tbStartTimer(int32, Const char*); +void tbEndTimer(Const char*); void tbDisplay(); \ No newline at end of file -- cgit v1.2.3