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: [PATCH 01/44] 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 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: [PATCH 02/44] new frontend customization --- src/core/Cam.cpp | 2 +- src/core/Frontend.cpp | 714 +++++++++++++++------------------- src/core/Frontend.h | 48 +-- src/core/MenuScreens.cpp | 92 +---- src/core/config.h | 2 +- src/core/re3.cpp | 276 +++++++++++-- src/extras/frontendoption.cpp | 243 +++++++++--- src/extras/frontendoption.h | 121 ++++-- 8 files changed, 856 insertions(+), 642 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); - } +#ifdef CUSTOM_FRONTEND_OPTIONS + extern void RestoreDefGraphics(int8); + extern void RestoreDefDisplay(int8); - CStreaming::LoadAllRequestedModels(true); - } else - m_PrefsIslandLoading = m_DisplayIslandLoading; -#endif // NO_ISLAND_LOADING -#ifdef PS2_ALPHA_TEST - gPS2alphaTest = false; -#endif // PS2_ALPHA_TEST + 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 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 +#ifdef PS2_ALPHA_TEST +void PS2AlphaTestChange(int8 displayedValue) +{ + gPS2alphaTest = !!displayedValue; + FrontEndMenuManager.SaveSettings(); +} +#endif + + +// Important: Make sure to read the warnings/informations in frontendoption.h!! void CustomFrontendOptionsPopulate(void) { RemoveCustomFrontendOptions(); // if exist + // -- 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 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); + 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 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); + FrontendOptionSetCursor(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); + // -- 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 -/*#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*/ + 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 + 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 + + 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) + 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_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)); + } + } + } + } + free(customFrontendOptions); + numCustomFrontendOptions = 0; + + if (numFrontendOptionReplacements != 0) { + free(frontendOptionReplacements); + numFrontendOptionReplacements = 0; + } + } + + if (numCustomFrontendScreens == 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--; - } + if (i > lastOgScreen) { + aScreens[i].m_ScreenName[0] = '\0'; + aScreens[i].unk = 0; } } - free(customFrontendOptions); - numCustomFrontendOptions = 0; + free(customFrontendScreens); + numCustomFrontendScreens = 0; + lastOgScreen = MENUPAGES; } -int8 RegisterNewOption(int screen) +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() { 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--; - } - } - } 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++; - } + optionCursor = curIdx = numOptions + optionCursor + 1; + } else + curIdx = 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; + 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 { + customFrontendOptions[numCustomFrontendOptions - 1].ogOptionId = -1; + } + customFrontendOptions[numCustomFrontendOptions - 1].screen = currentMenu; + + 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) -{ - int8 screenOptionOrder = RegisterNewOption(currentMenu); +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(); 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! + +// 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. -// 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. +// -- Option types // -// 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. +// 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. +// +// 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 From 700967dd2d931368a8aff614cf07b6654973d54a Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 25 Aug 2020 00:04:01 +0200 Subject: [PATCH 03/44] 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 From 290faa5e4bea56460ff7638a66fac15bd09c7205 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Tue, 25 Aug 2020 02:06:27 +0300 Subject: [PATCH 04/44] 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 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: [PATCH 05/44] 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; 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: [PATCH 06/44] Fixes from miami --- src/audio/sampman_oal.cpp | 2 +- src/control/PathFind.cpp | 2 +- src/control/Script.cpp | 6 +- src/peds/Ped.cpp | 123 +++++++++++++++++++------------------- src/peds/Ped.h | 1 + 5 files changed, 66 insertions(+), 68 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) { + CAnimBlendAssociation *fallAnim = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FALL_FALL); + if (!bWasStanding && speed > upperSpeedLimit && (/*!bPushedAlongByCar ||*/ 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; + 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); + 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)) { + 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); - 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); + 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; From 38ec1bd50de234faf476daa15ea41778a860ca0b Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 14 Sep 2020 20:48:49 +0300 Subject: [PATCH 07/44] 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; } From 9c2e9fcf886533ea2a1fdd415b31c659ca733286 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Tue, 15 Sep 2020 00:31:32 +0300 Subject: [PATCH 08/44] 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 From 7efc153dc9c452e63a6010226d7eba0f13358d41 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 19 Sep 2020 15:55:27 +0300 Subject: [PATCH 09/44] 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; } From db2c34923dba92012f023b2453a35aba4bd6846e Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 19 Sep 2020 16:39:31 +0300 Subject: [PATCH 10/44] 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; } From c6cf16447bfe5b7d8130588e53a65c9a99658603 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 23 Sep 2020 15:57:13 +0300 Subject: [PATCH 11/44] 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 From 6dfb32d285f40bbae86322689e24775343dfd626 Mon Sep 17 00:00:00 2001 From: shfil Date: Fri, 25 Sep 2020 13:56:15 +0200 Subject: [PATCH 12/44] 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. From 0ce8082bdaac94f127f6783023b99d6d4cf8e297 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 26 Sep 2020 00:24:30 +0300 Subject: [PATCH 13/44] 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()); From 3f0a80f7c75e62a868362a0ab95b0497b41768c9 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 26 Sep 2020 05:10:22 +0300 Subject: [PATCH 14/44] 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(); From b42d9e3e7c1caf6ad06ad81eb34cc27e09bd9bb9 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 26 Sep 2020 13:30:22 +0300 Subject: [PATCH 15/44] 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 From 2eb2e9ac12e66d3520d88547037217b53997b1fb Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 26 Sep 2020 14:12:42 +0300 Subject: [PATCH 16/44] 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 From 05e65baabe3e941cbbb546f546bae8719974b00f Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 26 Sep 2020 14:21:51 +0300 Subject: [PATCH 17/44] 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, From f7d5021ac59026435165e97aba869a76cfef1059 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 26 Sep 2020 21:10:23 +0300 Subject: [PATCH 18/44] VC replays --- src/animation/AnimManager.h | 1 + src/control/Garages.h | 1 + src/control/Replay.cpp | 551 ++++++++++++++++++++++++++++-------- src/control/Replay.h | 127 +++++++-- src/control/Script.cpp | 2 +- src/core/EventList.cpp | 4 + src/render/Particle.cpp | 4 + src/render/WaterLevel.cpp | 8 + src/vehicles/Boat.cpp | 4 + src/weapons/Explosion.cpp | 14 +- src/weapons/Explosion.h | 1 + vendor/opusfile | 2 +- 12 files changed, 574 insertions(+), 145 deletions(-) diff --git a/src/animation/AnimManager.h b/src/animation/AnimManager.h index 8658c056..a55577b1 100644 --- a/src/animation/AnimManager.h +++ b/src/animation/AnimManager.h @@ -139,4 +139,5 @@ public: static void LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32] = nil); static void CreateAnimAssocGroups(void); static void RemoveLastAnimFile(void); + static CAnimBlendAssocGroup* GetAnimAssocGroups(void) { return ms_aAnimAssocGroups; } }; diff --git a/src/control/Garages.h b/src/control/Garages.h index 79905ede..43f40261 100644 --- a/src/control/Garages.h +++ b/src/control/Garages.h @@ -300,5 +300,6 @@ private: static bool IsThisGarageTypeSafehouse(eGarageType type) { return FindSafeHouseIndexForGarageType(type) >= 0; } friend class cAudioManager; + friend class CReplay; friend class CGarage; }; diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp index 80c05f31..4ae1cf1b 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -1,15 +1,22 @@ #include "common.h" +#include "AnimBlendAssocGroup.h" #include "AnimBlendAssociation.h" +#include "Bike.h" #include "Boat.h" #include "SpecialFX.h" #include "CarCtrl.h" #include "CivilianPed.h" +#include "CopPed.h" #include "Wanted.h" #include "Clock.h" #include "DMAudio.h" #include "Draw.h" +#include "Explosion.h" #include "FileMgr.h" +#include "Fire.h" +#include "Frontend.h" +#include "Garages.h" #include "Heli.h" #include "main.h" #include "Matrix.h" @@ -17,12 +24,15 @@ #include "ModelInfo.h" #include "Object.h" #include "Pad.h" +#include "Particle.h" #include "PedAttractor.h" #include "Phones.h" #include "Pickups.h" #include "Plane.h" #include "Pools.h" #include "Population.h" +#include "Projectile.h" +#include "ProjectileInfo.h" #include "Replay.h" #include "References.h" #include "Pools.h" @@ -30,6 +40,7 @@ #include "RwHelper.h" #include "CutsceneMgr.h" #include "Skidmarks.h" +#include "Stinger.h" #include "Streaming.h" #include "Timer.h" #include "Train.h" @@ -103,6 +114,31 @@ bool CReplay::bPlayerInRCBuggy; float CReplay::fDistanceLookAroundCam; float CReplay::fBetaAngleLookAroundCam; float CReplay::fAlphaAngleLookAroundCam; +int CReplay::ms_nNumCivMale_Stored; +int CReplay::ms_nNumCivFemale_Stored; +int CReplay::ms_nNumCop_Stored; +int CReplay::ms_nNumEmergency_Stored; +int CReplay::ms_nNumGang1_Stored; +int CReplay::ms_nNumGang2_Stored; +int CReplay::ms_nNumGang3_Stored; +int CReplay::ms_nNumGang4_Stored; +int CReplay::ms_nNumGang5_Stored; +int CReplay::ms_nNumGang6_Stored; +int CReplay::ms_nNumGang7_Stored; +int CReplay::ms_nNumGang8_Stored; +int CReplay::ms_nNumGang9_Stored; +int CReplay::ms_nNumDummy_Stored; +int CReplay::ms_nTotalCarPassengerPeds_Stored; +int CReplay::ms_nTotalCivPeds_Stored; +int CReplay::ms_nTotalGangPeds_Stored; +int CReplay::ms_nTotalPeds_Stored; +int CReplay::ms_nTotalMissionPeds_Stored; +uint8* CReplay::pGarages; +CFire* CReplay::FireArray; +uint32 CReplay::NumOfFires; +uint8* CReplay::paProjectileInfo; +uint8* CReplay::paProjectiles; +uint8 CReplay::CurrArea; #ifdef FIX_BUGS int CReplay::nHandleOfPlayerPed[NUMPLAYERS]; #endif @@ -119,9 +155,11 @@ static void(*CBArray[])(CAnimBlendAssociation*, void*) = &CPed::FinishedAttackCB, &CPed::FinishFightMoveCB, &PhonePutDownCB, &PhonePickUpCB, &CPed::PedAnimDoorCloseRollingCB, &CPed::FinishJumpCB, &CPed::PedLandCB, &CPed::RestoreHeadingRateCB, &CPed::PedSetQuickDraggedOutCarPositionCB, &CPed::PedSetDraggedOutCarPositionCB, - &CPed::FinishedReloadCB, &StartTalkingOnMobileCB, &FinishTalkingOnMobileCB + &CPed::PedSetPreviousStateCB, &CPed::FinishedReloadCB, /*&CPed::PedSetGetInCarPositionCB, TODO(MIAMI)*/ + &CPed::PedAnimShuffleCB, &CPed::DeleteSunbatheIdleAnimCB, &StartTalkingOnMobileCB, &FinishTalkingOnMobileCB }; +// --MIAMI: Done static uint8 FindCBFunctionID(void(*f)(CAnimBlendAssociation*, void*)) { for (int i = 0; i < sizeof(CBArray) / sizeof(*CBArray); i++){ @@ -132,11 +170,13 @@ static uint8 FindCBFunctionID(void(*f)(CAnimBlendAssociation*, void*)) return 0; } +// --MIAMI: Done static void(*FindCBFunction(uint8 id))(CAnimBlendAssociation*, void*) { return CBArray[id]; } +// --MIAMI: Done static void ApplyPanelDamageToCar(uint32 panels, CAutomobile* vehicle, bool flying) { if(vehicle->Damage.GetPanelStatus(VEHPANEL_FRONT_LEFT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_LEFT)){ @@ -169,6 +209,7 @@ static void ApplyPanelDamageToCar(uint32 panels, CAutomobile* vehicle, bool flyi } } +// --MIAMI: Done void PrintElementsInPtrList(void) { for (CPtrNode* node = CWorld::GetBigBuildingList(LEVEL_GENERIC).first; node; node = node->next) { @@ -176,6 +217,7 @@ void PrintElementsInPtrList(void) } } +// --MIAMI: Done void CReplay::Init(void) { pBuf0 = nil; @@ -215,23 +257,29 @@ void CReplay::Init(void) SlowMotion = 1; FramesActiveLookAroundCam = 0; bDoLoadSceneWhenDone = false; + MarkEverythingAsNew(); } +// --MIAMI: Done void CReplay::DisableReplays(void) { bReplayEnabled = false; } +// --MIAMI: Done void CReplay::EnableReplays(void) { bReplayEnabled = true; } void PlayReplayFromHD(void); +// --MIAMI: Done void CReplay::Update(void) { - if (CCutsceneMgr::IsCutsceneProcessing() || CTimer::GetIsPaused() || CScriptPaths::IsOneActive()) + if (CCutsceneMgr::IsCutsceneProcessing() || CPad::GetPad(0)->ArePlayerControlsDisabled() || CScriptPaths::IsOneActive() || FrontEndMenuManager.GetIsMenuActive()) { + Init(); return; + } switch (Mode){ case MODE_RECORD: RecordThisFrame(); @@ -260,15 +308,19 @@ void CReplay::Update(void) } } +// --MIAMI: Done except TODO void CReplay::RecordThisFrame(void) { -#ifdef FIX_REPLAY_BUGS - uint32 memory_required = sizeof(tGeneralPacket) + sizeof(tClockPacket) + sizeof(tWeatherPacket) + sizeof(tTimerPacket); + uint32 memory_required = sizeof(tGeneralPacket) + sizeof(tClockPacket) + sizeof(tWeatherPacket) + sizeof(tTimerPacket) + sizeof(tMiscPacket); CVehiclePool* vehiclesT = CPools::GetVehiclePool(); for (int i = 0; i < vehiclesT->GetSize(); i++) { CVehicle* v = vehiclesT->GetSlot(i); - if (v && v->m_rwObject && v->GetModelIndex() != MI_AIRTRAIN && v->GetModelIndex() != MI_TRAIN) - memory_required += sizeof(tVehicleUpdatePacket); + if (v && v->m_rwObject && v->GetModelIndex() != MI_AIRTRAIN && v->GetModelIndex() != MI_TRAIN) { + if (v->IsBike()) + memory_required += sizeof(tBikeUpdatePacket); + else + memory_required += sizeof(tVehicleUpdatePacket); + } } CPedPool* pedsT = CPools::GetPedPool(); for (int i = 0; i < pedsT->GetSize(); i++) { @@ -286,17 +338,8 @@ void CReplay::RecordThisFrame(void) memory_required += sizeof(tBulletTracePacket); } memory_required += sizeof(tEndOfFramePacket) + 1; // 1 for Record.m_pBase[Record.m_nOffset] = REPLAYPACKET_END; - if (Record.m_nOffset + memory_required > REPLAYBUFFERSIZE) { - Record.m_pBase[Record.m_nOffset] = REPLAYPACKET_END; - BufferStatus[Record.m_bSlot] = REPLAYBUFFER_PLAYBACK; - Record.m_bSlot = (Record.m_bSlot + 1) % NUM_REPLAYBUFFERS; - BufferStatus[Record.m_bSlot] = REPLAYBUFFER_RECORD; - Record.m_pBase = Buffers[Record.m_bSlot]; - Record.m_nOffset = 0; - *Record.m_pBase = REPLAYPACKET_END; - MarkEverythingAsNew(); - } -#endif + if (Record.m_nOffset + memory_required > REPLAYBUFFERSIZE - 16) + GoToNextBlock(); tGeneralPacket* general = (tGeneralPacket*)&Record.m_pBase[Record.m_nOffset]; general->type = REPLAYPACKET_GENERAL; general->camera_pos.CopyOnlyMatrix(&TheCamera.GetMatrix()); @@ -321,8 +364,12 @@ void CReplay::RecordThisFrame(void) CVehiclePool* vehicles = CPools::GetVehiclePool(); for (int i = 0; i < vehicles->GetSize(); i++){ CVehicle* v = vehicles->GetSlot(i); - if (v && v->m_rwObject && v->GetModelIndex() != MI_AIRTRAIN && v->GetModelIndex() != MI_TRAIN) - StoreCarUpdate(v, i); + if (v && v->m_rwObject && v->GetModelIndex() != MI_AIRTRAIN && v->GetModelIndex() != MI_TRAIN) { + if (v->IsBike()) + StoreBikeUpdate(v, i); + else + StoreCarUpdate(v, i); + } } CPedPool* peds = CPools::GetPedPool(); for (int i = 0; i < peds->GetSize(); i++) { @@ -352,17 +399,23 @@ void CReplay::RecordThisFrame(void) bt->sup = CBulletTraces::aTraces[i].m_vecTargetPos; Record.m_nOffset += sizeof(*bt); } + tMiscPacket* misc = (tMiscPacket*)&Record.m_pBase[Record.m_nOffset]; + misc->type = REPLAYPACKET_MISC; + misc->cam_shake_start = TheCamera.m_uiCamShakeStart; + misc->cam_shake_strength = TheCamera.m_fCamShakeForce; + misc->cur_area = CGame::currArea; + //misc->special_fx_flags; // TODO(MIAMI)!!! + Record.m_nOffset += sizeof(*misc); tEndOfFramePacket* eof = (tEndOfFramePacket*)&Record.m_pBase[Record.m_nOffset]; eof->type = REPLAYPACKET_ENDOFFRAME; Record.m_nOffset += sizeof(*eof); Record.m_pBase[Record.m_nOffset] = REPLAYPACKET_END; -#ifndef FIX_REPLAY_BUGS - if (Record.m_nOffset <= REPLAYBUFFERSIZE - 3000){ - /* Unsafe assumption which can cause buffer overflow - * if size of next frame exceeds 3000 bytes. - * Most notably it causes various timecyc errors. */ - return; - } +} + +// --MIAMI: Done +void CReplay::GoToNextBlock(void) +{ + Record.m_pBase[Record.m_nOffset] = REPLAYPACKET_END; BufferStatus[Record.m_bSlot] = REPLAYBUFFER_PLAYBACK; Record.m_bSlot = (Record.m_bSlot + 1) % NUM_REPLAYBUFFERS; BufferStatus[Record.m_bSlot] = REPLAYBUFFER_RECORD; @@ -370,9 +423,32 @@ void CReplay::RecordThisFrame(void) Record.m_nOffset = 0; *Record.m_pBase = REPLAYPACKET_END; MarkEverythingAsNew(); -#endif } +// --MIAMI: Done +void CReplay::RecordParticle(tParticleType type, const CVector& vecPos, const CVector& vecDir, float fSize, const RwRGBA& color) +{ + if (Record.m_nOffset > REPLAYBUFFERSIZE - 16 - sizeof(tParticlePacket)) + GoToNextBlock(); + tParticlePacket* pp = (tParticlePacket*)&Record.m_pBase[Record.m_nOffset]; + pp->type = REPLAYPACKET_PARTICLE; + pp->particle_type = type; + pp->pos_x = 4.0f * vecPos.x; + pp->pos_y = 4.0f * vecPos.y; + pp->pos_z = 4.0f * vecPos.z; + pp->dir_x = 120.0f * clamp(vecDir.x, -1.0f, 1.0f); + pp->dir_y = 120.0f * clamp(vecDir.y, -1.0f, 1.0f); + pp->dir_z = 120.0f * clamp(vecDir.z, -1.0f, 1.0f); + pp->size = fSize; + pp->r = color.red; + pp->g = color.green; + pp->b = color.blue; + pp->a = color.alpha; + Record.m_nOffset += sizeof(tParticlePacket); + Record.m_pBase[Record.m_nOffset] = REPLAYPACKET_END; +} + +// --MIAMI: Done void CReplay::StorePedUpdate(CPed *ped, int id) { tPedUpdatePacket* pp = (tPedUpdatePacket*)&Record.m_pBase[Record.m_nOffset]; @@ -381,6 +457,7 @@ void CReplay::StorePedUpdate(CPed *ped, int id) pp->heading = 128.0f / PI * ped->m_fRotationCur; pp->matrix.CompressFromFullMatrix(ped->GetMatrix()); pp->assoc_group_id = ped->m_animGroup; + pp->is_visible = ped->bIsVisible; /* Would be more sane to use GetJustIndex(ped->m_pMyVehicle) in following assignment */ if (ped->InVehicle()) pp->vehicle_index = (CPools::GetVehiclePool()->GetIndex(ped->m_pMyVehicle) >> 8) + 1; @@ -391,6 +468,7 @@ void CReplay::StorePedUpdate(CPed *ped, int id) Record.m_nOffset += sizeof(tPedUpdatePacket); } +// --MIAMI: Done void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state) { CAnimBlendAssociation* second; @@ -400,21 +478,25 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state) state->animId = main->animId; state->time = 255.0f / 4.0f * clamp(main->currentTime, 0.0f, 4.0f); state->speed = 255.0f / 3.0f * clamp(main->speed, 0.0f, 3.0f); + state->groupId = main->groupId; }else{ state->animId = 3; state->time = 0; state->speed = 85; + state->groupId = 0; } if (second) { state->secAnimId = second->animId; state->secTime = 255.0f / 4.0f * clamp(second->currentTime, 0.0f, 4.0f); state->secSpeed = 255.0f / 3.0f * clamp(second->speed, 0.0f, 3.0f); state->blendAmount = 255.0f / 2.0f * clamp(blend_amount, 0.0f, 2.0f); + state->secGroupId = second->groupId; }else{ state->secAnimId = 0; state->secTime = 0; state->secSpeed = 0; state->blendAmount = 0; + state->secGroupId = 0; } CAnimBlendAssociation* partial = RpAnimBlendClumpGetMainPartialAssociation((RpClump*)ped->m_rwObject); if (partial) { @@ -422,14 +504,17 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state) state->partAnimTime = 255.0f / 4.0f * clamp(partial->currentTime, 0.0f, 4.0f); state->partAnimSpeed = 255.0f / 3.0f * clamp(partial->speed, 0.0f, 3.0f); state->partBlendAmount = 255.0f / 2.0f * clamp(partial->blendAmount, 0.0f, 2.0f); + state->partGroupId = partial->groupId; }else{ state->partAnimId = 0; state->partAnimTime = 0; state->partAnimSpeed = 0; state->partBlendAmount = 0; + state->partGroupId = 0; } } +// --MIAMI: Done void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state) { for (int i = 0; i < NUM_MAIN_ANIMS_IN_REPLAY; i++){ @@ -439,10 +524,9 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState state->aCurTime[i] = 255.0f / 4.0f * clamp(assoc->currentTime, 0.0f, 4.0f); state->aSpeed[i] = 255.0f / 3.0f * clamp(assoc->speed, 0.0f, 3.0f); state->aBlendAmount[i] = 255.0f / 2.0f * clamp(assoc->blendAmount, 0.0f, 2.0f); -#ifdef FIX_REPLAY_BUGS state->aBlendDelta[i] = 127.0f / 32.0f * clamp(assoc->blendDelta, -16.0f, 16.0f); -#endif state->aFlags[i] = assoc->flags; + state->aGroupId[i] = assoc->groupId; if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) { state->aFunctionCallbackID[i] = FindCBFunctionID(assoc->callback); if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH) @@ -456,6 +540,7 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState state->aSpeed[i] = 85; state->aFunctionCallbackID[i] = 0; state->aFlags[i] = 0; + state->aGroupId[i] = 0; } } for (int i = 0; i < NUM_PARTIAL_ANIMS_IN_REPLAY; i++) { @@ -465,10 +550,9 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState state->aCurTime2[i] = 255.0f / 4.0f * clamp(assoc->currentTime, 0.0f, 4.0f); state->aSpeed2[i] = 255.0f / 3.0f * clamp(assoc->speed, 0.0f, 3.0f); state->aBlendAmount2[i] = 255.0f / 2.0f * clamp(assoc->blendAmount, 0.0f, 2.0f); -#ifdef FIX_REPLAY_BUGS state->aBlendDelta2[i] = 127.0f / 16.0f * clamp(assoc->blendDelta, -16.0f, 16.0f); -#endif state->aFlags2[i] = assoc->flags; + state->aGroupId2[i] = assoc->groupId; if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) { state->aFunctionCallbackID2[i] = FindCBFunctionID(assoc->callback); if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH) @@ -483,10 +567,12 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState state->aSpeed2[i] = 85; state->aFunctionCallbackID2[i] = 0; state->aFlags2[i] = 0; + state->aGroupId2[i] = 0; } } } +// --MIAMI: Done void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayBuffer *buffer) { tPedUpdatePacket *pp = (tPedUpdatePacket*)&buffer->m_pBase[buffer->m_nOffset]; @@ -504,7 +590,7 @@ void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayB ped->GetMatrix() += CMatrix(interpolation) * ped_matrix; if (pp->vehicle_index) { ped->m_pMyVehicle = CPools::GetVehiclePool()->GetSlot(pp->vehicle_index - 1); - ped->bInVehicle = pp->vehicle_index; + ped->bInVehicle = true; } else { ped->m_pMyVehicle = nil; @@ -515,6 +601,9 @@ void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayB if (ped == FindPlayerPed()) ((CPlayerPed*)ped)->ReApplyMoveAnims(); } + ped->bIsVisible = pp->is_visible; + if (FramesActiveLookAroundCam && ped->m_nPedType == PEDTYPE_PLAYER1) + ped->bIsVisible = true; RetrievePedAnimation(ped, &pp->anim_state); ped->RemoveWeaponModel(-1); if (pp->weapon_model != (uint16)-1) { @@ -528,12 +617,25 @@ void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayB buffer->m_nOffset += sizeof(tPedUpdatePacket); } +// --MIAMI: Done +bool HasAnimGroupLoaded(uint8 group) +{ + CAnimBlendAssocGroup* pGroup = &CAnimManager::GetAnimAssocGroups()[group]; + return pGroup->animBlock && pGroup->animBlock->isLoaded; +} + +// --MIAMI: Done void CReplay::RetrievePedAnimation(CPed *ped, CStoredAnimationState *state) { - CAnimBlendAssociation* anim1 = CAnimManager::BlendAnimation( - (RpClump*)ped->m_rwObject, - (state->animId > 3) ? ASSOCGRP_STD : ped->m_animGroup, - (AnimationId)state->animId, 100.0f); + CAnimBlendAssociation* anim1; + if (state->animId <= 3) + anim1 = CAnimManager::BlendAnimation( + (RpClump*)ped->m_rwObject, ped->m_animGroup, (AnimationId)state->animId, 100.0f); + else if (HasAnimGroupLoaded(state->groupId)) + anim1 = CAnimManager::BlendAnimation((RpClump*)ped->m_rwObject, (AssocGroupId)state->groupId, (AnimationId)state->animId, 100.0f); + else + anim1 = CAnimManager::BlendAnimation((RpClump*)ped->m_rwObject, ASSOCGRP_STD, ANIM_WALK, 100.0f); + anim1->SetCurrentTime(state->time * 4.0f / 255.0f); anim1->speed = state->speed * 3.0f / 255.0f; anim1->SetBlend(1.0f, 1.0f); @@ -544,7 +646,7 @@ void CReplay::RetrievePedAnimation(CPed *ped, CStoredAnimationState *state) float blend = state->blendAmount * 2.0f / 255.0f; CAnimBlendAssociation* anim2 = CAnimManager::BlendAnimation( (RpClump*)ped->m_rwObject, - (state->secAnimId > 3) ? ASSOCGRP_STD : ped->m_animGroup, + (state->secAnimId > 3) ? (AssocGroupId)state->secGroupId : ped->m_animGroup, (AnimationId)state->secAnimId, 100.0f); anim2->SetCurrentTime(time); anim2->speed = speed; @@ -556,9 +658,9 @@ void CReplay::RetrievePedAnimation(CPed *ped, CStoredAnimationState *state) float time = state->partAnimTime * 4.0f / 255.0f; float speed = state->partAnimSpeed * 3.0f / 255.0f; float blend = state->partBlendAmount * 2.0f / 255.0f; - if (blend > 0.0f && state->partAnimId != ANIM_IDLE_STANCE){ + if (blend > 0.0f && state->partAnimId != ANIM_IDLE_STANCE && HasAnimGroupLoaded(state->partGroupId)){ CAnimBlendAssociation* anim3 = CAnimManager::BlendAnimation( - (RpClump*)ped->m_rwObject, ASSOCGRP_STD, (AnimationId)state->partAnimId, 1000.0f); + (RpClump*)ped->m_rwObject, (AssocGroupId)state->partGroupId, (AnimationId)state->partAnimId, 1000.0f); anim3->SetCurrentTime(time); anim3->speed = speed; anim3->SetBlend(blend, 0.0f); @@ -566,35 +668,23 @@ void CReplay::RetrievePedAnimation(CPed *ped, CStoredAnimationState *state) } } +// --MIAMI: Done void CReplay::RetrieveDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state) { -#ifdef FIX_REPLAY_BUGS CAnimBlendAssociation* assoc; for (int i = 0; ((assoc = RpAnimBlendClumpGetMainAssociation_N(ped->GetClump(), i))); i++) assoc->SetBlend(0.0f, -1.0f); for (int i = 0; ((assoc = RpAnimBlendClumpGetMainPartialAssociation_N(ped->GetClump(), i))); i++) assoc->SetBlend(0.0f, -1.0f); -#endif for (int i = 0; i < NUM_MAIN_ANIMS_IN_REPLAY; i++) { if (state->aAnimId[i] == NUM_ANIMS) continue; -#ifdef FIX_REPLAY_BUGS CAnimBlendAssociation* anim = CAnimManager::AddAnimation(ped->GetClump(), - state->aAnimId[i] > 3 ? ASSOCGRP_STD : ped->m_animGroup, + state->aAnimId[i] > 3 ? (AssocGroupId)state->aGroupId[i] : ped->m_animGroup, (AnimationId)state->aAnimId[i]); -#else - CAnimBlendAssociation* anim = CAnimManager::BlendAnimation( - (RpClump*)ped->m_rwObject, - state->aAnimId[i] > 3 ? ASSOCGRP_STD : ped->m_animGroup, - (AnimationId)state->aAnimId[i], 100.0f); -#endif anim->SetCurrentTime(state->aCurTime[i] * 4.0f / 255.0f); anim->speed = state->aSpeed[i] * 3.0f / 255.0f; -#ifdef FIX_REPLAY_BUGS anim->SetBlend(state->aBlendAmount[i] * 2.0f / 255.0f, state->aBlendDelta[i] * 16.0f / 127.0f); -#else - anim->SetBlend(state->aBlendAmount[i], 1.0f); -#endif anim->flags = state->aFlags[i]; uint8 callback = state->aFunctionCallbackID[i]; if (!callback) @@ -607,23 +697,12 @@ void CReplay::RetrieveDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationSt for (int i = 0; i < NUM_PARTIAL_ANIMS_IN_REPLAY; i++) { if (state->aAnimId2[i] == NUM_ANIMS) continue; -#ifdef FIX_REPLAY_BUGS CAnimBlendAssociation* anim = CAnimManager::AddAnimation(ped->GetClump(), - state->aAnimId2[i] > 3 ? ASSOCGRP_STD : ped->m_animGroup, + state->aAnimId2[i] > 3 ? (AssocGroupId)state->aGroupId2[i] : ped->m_animGroup, (AnimationId)state->aAnimId2[i]); -#else - CAnimBlendAssociation* anim = CAnimManager::BlendAnimation( - (RpClump*)ped->m_rwObject, - state->aAnimId2[i] > 3 ? ASSOCGRP_STD : ped->m_animGroup, - (AnimationId)state->aAnimId2[i], 100.0f); -#endif anim->SetCurrentTime(state->aCurTime2[i] * 4.0f / 255.0f); anim->speed = state->aSpeed2[i] * 3.0f / 255.0f; -#ifdef FIX_REPLAY_BUGS anim->SetBlend(state->aBlendAmount2[i] * 2.0f / 255.0f, state->aBlendDelta2[i] * 16.0f / 127.0f); -#else - anim->SetBlend(state->aBlendAmount2[i], 1.0f); -#endif anim->flags = state->aFlags2[i]; uint8 callback = state->aFunctionCallbackID2[i]; if (!callback) @@ -635,6 +714,7 @@ void CReplay::RetrieveDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationSt } } +// --MIAMI: Done void CReplay::PlaybackThisFrame(void) { static int FrameSloMo = 0; @@ -662,7 +742,7 @@ void CReplay::PlaybackThisFrame(void) // next two functions are only found in mobile version // most likely they were optimized out for being unused - +// --MIAMI: Done void CReplay::TriggerPlaybackLastCoupleOfSeconds(uint32 start, uint8 cam_mode, float cam_x, float cam_y, float cam_z, uint32 slomo) { if (Mode != MODE_RECORD) @@ -674,6 +754,7 @@ void CReplay::TriggerPlaybackLastCoupleOfSeconds(uint32 start, uint8 cam_mode, f Mode = MODE_RECORD; } +// --MIAMI: Done bool CReplay::FastForwardToTime(uint32 start) { uint32 timer = 0; @@ -683,6 +764,7 @@ bool CReplay::FastForwardToTime(uint32 start) return true; } +// --MIAMI: Done void CReplay::StoreCarUpdate(CVehicle *vehicle, int id) { tVehicleUpdatePacket* vp = (tVehicleUpdatePacket*)&Record.m_pBase[Record.m_nOffset]; @@ -716,9 +798,40 @@ void CReplay::StoreCarUpdate(CVehicle *vehicle, int id) vp->door_status |= BIT(i); } } + if (vehicle->GetModelIndex() == MI_SKIMMER) + vp->skimmer_speed = 50.0f * ((CBoat*)vehicle)->m_fMovingSpeed; + vp->render_scorched = vehicle->bRenderScorched; + vp->vehicle_type = vehicle->m_vehType; Record.m_nOffset += sizeof(tVehicleUpdatePacket); } +// --MIAMI: Done +void CReplay::StoreBikeUpdate(CVehicle* vehicle, int id) +{ + CBike* bike = (CBike*)vehicle; + tBikeUpdatePacket* vp = (tBikeUpdatePacket*)&Record.m_pBase[Record.m_nOffset]; + vp->type = REPLAYPACKET_BIKE; + vp->index = id; + vp->matrix.CompressFromFullMatrix(vehicle->GetMatrix()); + vp->health = vehicle->m_fHealth / 4.0f; /* Not anticipated that health can be > 1000. */ + vp->acceleration = vehicle->m_fGasPedal * 100.0f; + for (int i = 0; i < 4; i++) { + vp->wheel_susp_dist[i] = 50.0f * bike->m_aSuspensionSpringRatio[i]; + vp->wheel_rotation[i] = 128.0f / PI * bike->m_aWheelRotation[i]; + } + vp->velocityX = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().x)); /* 8000!? */ + vp->velocityY = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().y)); + vp->velocityZ = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().z)); + vp->mi = vehicle->GetModelIndex(); + vp->primary_color = vehicle->m_currentColour1; + vp->secondary_color = vehicle->m_currentColour2; + vp->wheel_state = 50.0f * vehicle->m_fSteerAngle; + vp->lean_angle = 50.0f * bike->m_fLeanLRAngle; + vp->wheel_angle = 50.0f * bike->m_fWheelAngle; + Record.m_nOffset += sizeof(tBikeUpdatePacket); +} + +// --MIAMI: Done void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressInReplayBuffer *buffer) { tVehicleUpdatePacket* vp = (tVehicleUpdatePacket*)&buffer->m_pBase[buffer->m_nOffset]; @@ -755,7 +868,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); } @@ -779,28 +892,56 @@ 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; + vehicle->bRenderScorched = vp->render_scorched; + if (vehicle->GetModelIndex() == MI_SKIMMER) + ((CBoat*)vehicle)->m_fMovingSpeed = vp->skimmer_speed / 50.0f; } -bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, float interpolation, uint32 *pTimer){ - /* Mistake. Not even sure what this is even doing here... - * PlayerWanted is a backup to restore at the end of replay. - * Setting current wanted pointer to it makes it useless. - * Causes picking up bribes in replays reducing wanted level bug. - * Obviously fact of picking them up is a bug on its own, - * but it doesn't cancel this one. - */ -#ifndef FIX_REPLAY_BUGS - FindPlayerPed()->m_pWanted = &PlayerWanted; -#endif +// --MIAMI: Done +void CReplay::ProcessBikeUpdate(CVehicle* vehicle, float interpolation, CAddressInReplayBuffer* buffer) +{ + CBike* bike = (CBike*)vehicle; + tBikeUpdatePacket* vp = (tBikeUpdatePacket*)&buffer->m_pBase[buffer->m_nOffset]; + if (!vehicle) { + printf("Replay:Car wasn't there"); + return; + } + CMatrix vehicle_matrix; + vp->matrix.DecompressIntoFullMatrix(vehicle_matrix); + vehicle->GetMatrix() = vehicle->GetMatrix() * CMatrix(1.0f - interpolation); + vehicle->GetMatrix().GetPosition() *= (1.0f - interpolation); + vehicle->GetMatrix() += CMatrix(interpolation) * vehicle_matrix; + vehicle->m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + vehicle->m_fHealth = 4 * vp->health; + vehicle->m_fGasPedal = vp->acceleration / 100.0f; + vehicle->m_vecMoveSpeed = CVector(vp->velocityX / 8000.0f, vp->velocityY / 8000.0f, vp->velocityZ / 8000.0f); + vehicle->m_fSteerAngle = vp->wheel_state / 50.0f; + vehicle->bEngineOn = true; + for (int i = 0; i < 4; i++) { + bike->m_aSuspensionSpringRatio[i] = vp->wheel_susp_dist[i] / 50.0f; + bike->m_aWheelRotation[i] = vp->wheel_rotation[i] / (128.0f / PI); + // NB: technically last assignment overflows - there are 2 wheels of bike + // however it saves two useful fields; this looks like unrolled loop, not sequential assignments + } + bike->m_fLeanLRAngle = vp->lean_angle / 50.0f; + bike->m_fWheelAngle = vp->wheel_angle / 50.0f; + bike->bLeanMatrixClean = false; + bike->CalculateLeanMatrix(); + CWorld::Remove(vehicle); + CWorld::Add(vehicle); +} +// --MIAMI: Done +bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, float interpolation, uint32 *pTimer) +{ CBulletTraces::Init(); float split = 1.0f - interpolation; int ped_min_index = 0; /* Optimization due to peds and vehicles placed in buffer sequentially. */ @@ -846,21 +987,25 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo CStreaming::RequestModel(mi, 0); } else { -// TODO(MIAMI): don't hardcode model indices - if (mi == MI_DEADDODO || mi == MI_AIRTRAIN) { - new_v = new(vp->index << 8) CPlane(mi, 2); - } - else if (mi == MI_TRAIN) { - new_v = new(vp->index << 8) CTrain(mi, 2); - } - else if (mi == MI_CHOPPER) { - new_v = new(vp->index << 8) CHeli(mi, 2); - } - else if (CModelInfo::IsBoatModel(mi)){ + switch (vp->vehicle_type) { + case VEHICLE_TYPE_CAR: + new_v = new(vp->index << 8) CAutomobile(mi, 2); + break; + case VEHICLE_TYPE_BOAT: new_v = new(vp->index << 8) CBoat(mi, 2); - } - else{ - new_v = new(vp->index << 8) CAutomobile(mi, 2); + break; + case VEHICLE_TYPE_TRAIN: + new_v = new(vp->index << 8) CTrain(mi, 2); + break; + case VEHICLE_TYPE_HELI: + new_v = new(vp->index << 8) CHeli(mi, 2); + break; + case VEHICLE_TYPE_PLANE: + new_v = new(vp->index << 8) CPlane(mi, 2); + break; + case VEHICLE_TYPE_BIKE: // not possible + new_v = new(vp->index << 8) CBike(mi, 2); + break; } new_v->SetStatus(STATUS_PLAYER_PLAYBACKFROMBUFFER); vp->matrix.DecompressIntoFullMatrix(new_v->GetMatrix()); @@ -873,15 +1018,51 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo buffer->m_nOffset += sizeof(tVehicleUpdatePacket); break; } + case REPLAYPACKET_BIKE: + { + tBikeUpdatePacket* vp = (tBikeUpdatePacket*)&ptr[offset]; + for (int i = vehicle_min_index; i < vp->index; i++) { + CVehicle* v = CPools::GetVehiclePool()->GetSlot(i); + if (!v) + continue; + /* Removing vehicles not present in this frame. */ + CWorld::Remove(v); + delete v; + } + vehicle_min_index = vp->index + 1; + CVehicle* v = CPools::GetVehiclePool()->GetSlot(vp->index); + CVehicle* new_v; + if (!v) { + int mi = vp->mi; + if (CStreaming::ms_aInfoForModel[mi].m_loadState != 1) { + CStreaming::RequestModel(mi, 0); + } + else { + new_v = new(vp->index << 8) CBike(mi, 2); + new_v->SetStatus(STATUS_PLAYER_PLAYBACKFROMBUFFER); + vp->matrix.DecompressIntoFullMatrix(new_v->GetMatrix()); + new_v->m_currentColour1 = vp->primary_color; + new_v->m_currentColour2 = vp->secondary_color; + CWorld::Add(new_v); + } + } + ProcessBikeUpdate(CPools::GetVehiclePool()->GetSlot(vp->index), interpolation, buffer); + buffer->m_nOffset += sizeof(tBikeUpdatePacket); + break; + } case REPLAYPACKET_PED_HEADER: { tPedHeaderPacket* ph = (tPedHeaderPacket*)&ptr[offset]; if (!CPools::GetPedPool()->GetSlot(ph->index)) { - if (CStreaming::ms_aInfoForModel[ph->mi].m_loadState != 1) { + if (!CStreaming::HasModelLoaded(ph->mi) || (ph->mi >= MI_SPECIAL01 && ph->mi < MI_LAST_PED)) { CStreaming::RequestModel(ph->mi, 0); } else { - CPed* new_p = new(ph->index << 8) CCivilianPed((ePedType)ph->pedtype, ph->mi); + CPed* new_p; + if (ph->pedtype != PEDTYPE_PLAYER1) + new_p = new(ph->index << 8) CCivilianPed((ePedType)ph->pedtype, ph->mi); + else + new_p = new(ph->index << 8) CPlayerPed(); new_p->SetStatus(STATUS_PLAYER_PLAYBACKFROMBUFFER); new_p->GetMatrix().SetUnity(); CWorld::Add(new_p); @@ -964,6 +1145,31 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo CBulletTraces::aTraces[pb->index].m_vecCurrentPos = pb->inf; CBulletTraces::aTraces[pb->index].m_vecTargetPos = pb->sup; buffer->m_nOffset += sizeof(tBulletTracePacket); + break; + } + case REPLAYPACKET_PARTICLE: + { + tParticlePacket* pp = (tParticlePacket*)&ptr[offset]; + CVector pos(pp->pos_x / 4.0f, pp->pos_y / 4.0f, pp->pos_z / 4.0f); + CVector dir(pp->dir_x / 120.0f, pp->dir_y / 120.0f, pp->dir_z / 120.0f); + RwRGBA color; + color.red = pp->r; + color.green = pp->g; + color.blue = pp->b; + color.alpha = pp->a; + CParticle::AddParticle((tParticleType)pp->particle_type, pos, dir, nil, pp->size, color); + buffer->m_nOffset += sizeof(tParticlePacket); + break; + } + case REPLAYPACKET_MISC: + { + tMiscPacket* pm = (tMiscPacket*)&ptr[offset]; + TheCamera.m_uiCamShakeStart = pm->cam_shake_start; + TheCamera.m_fCamShakeForce = pm->cam_shake_strength; + // TODO(MIAMI): SpecialFX + CGame::currArea = pm->cur_area; + buffer->m_nOffset += sizeof(tMiscPacket); + break; } default: break; @@ -990,6 +1196,7 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo return false; } +// --MIAMI: Done void CReplay::FinishPlayback(void) { if (Mode != MODE_PLAYBACK) @@ -1012,6 +1219,7 @@ void CReplay::FinishPlayback(void) DMAudio.SetMusicFadeVol(127); } +// --MIAMI: Done void CReplay::EmptyReplayBuffer(void) { if (Mode == MODE_PLAYBACK) @@ -1027,6 +1235,7 @@ void CReplay::EmptyReplayBuffer(void) MarkEverythingAsNew(); } +// --MIAMI: Done void CReplay::ProcessReplayCamera(void) { switch (CameraMode) { @@ -1071,6 +1280,9 @@ void CReplay::ProcessReplayCamera(void) RwFrameUpdateObjects(RwCameraGetFrame(TheCamera.m_pRwCamera)); } +extern CWeaponEffects gCrossHair; + +// --MIAMI: Done except TODO void CReplay::TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float cam_z, bool load_scene) { if (Mode != MODE_RECORD) @@ -1087,6 +1299,8 @@ void CReplay::TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float ca DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND); DMAudio.SetEffectsFadeVol(0); DMAudio.SetMusicFadeVol(0); + CEscalators::Shutdown(); + // TODO(MIAMI): CWaterCreatures::RemoveAll(); int current; for (current = 0; current < NUM_REPLAYBUFFERS; current++) if (BufferStatus[current] == REPLAYBUFFER_RECORD) @@ -1119,8 +1333,16 @@ void CReplay::TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float ca } if (cam_mode == REPLAYCAMMODE_ASSTORED) TheCamera.CarZoomIndicator = CAM_ZOOM_CINEMATIC; + gCrossHair.m_bActive = false; + CExplosion::ClearAllExplosions(); + CPlaneBanners::Init(); +#ifndef FIX_BUGS // this doesn't do anything useful and accesses destroyed player ped + TheCamera.Restore(); +#endif + CDraw::SetFOV(70.0f); } +// --MIAMI: Done void CReplay::StoreStuffInMem(void) { #ifdef FIX_BUGS @@ -1166,9 +1388,28 @@ void CReplay::StoreStuffInMem(void) OldWeatherType = CWeather::OldWeatherType; NewWeatherType = CWeather::NewWeatherType; WeatherInterpolationValue = CWeather::InterpolationValue; + CurrArea = CGame::currArea; TimeStepNonClipped = CTimer::GetTimeStepNonClipped(); TimeStep = CTimer::GetTimeStep(); TimeScale = CTimer::GetTimeScale(); + ms_nNumCivMale_Stored = CPopulation::ms_nNumCivMale; + ms_nNumCivFemale_Stored = CPopulation::ms_nNumCivFemale; + ms_nNumCop_Stored = CPopulation::ms_nNumCop; + ms_nNumEmergency_Stored = CPopulation::ms_nNumEmergency; + ms_nNumGang1_Stored = CPopulation::ms_nNumGang1; + ms_nNumGang2_Stored = CPopulation::ms_nNumGang2; + ms_nNumGang3_Stored = CPopulation::ms_nNumGang3; + ms_nNumGang4_Stored = CPopulation::ms_nNumGang4; + ms_nNumGang5_Stored = CPopulation::ms_nNumGang5; + ms_nNumGang6_Stored = CPopulation::ms_nNumGang6; + ms_nNumGang7_Stored = CPopulation::ms_nNumGang7; + ms_nNumGang8_Stored = CPopulation::ms_nNumGang8; + ms_nNumGang9_Stored = CPopulation::ms_nNumGang9; + ms_nNumDummy_Stored = CPopulation::ms_nNumDummy; + ms_nTotalCivPeds_Stored = CPopulation::ms_nTotalCivPeds; + ms_nTotalGangPeds_Stored = CPopulation::ms_nTotalGangPeds; + ms_nTotalPeds_Stored = CPopulation::ms_nTotalPeds; + ms_nTotalMissionPeds_Stored = CPopulation::ms_nTotalMissionPeds; int size = CPools::GetPedPool()->GetSize(); pPedAnims = new CStoredDetailedAnimationState[size]; for (int i = 0; i < size; i++) { @@ -1176,9 +1417,19 @@ void CReplay::StoreStuffInMem(void) if (ped) StoreDetailedPedAnimation(ped, &pPedAnims[i]); } + pGarages = new uint8[sizeof(CGarages::aGarages)]; + memcpy(pGarages, CGarages::aGarages, sizeof(CGarages::aGarages)); + FireArray = new CFire[NUM_FIRES]; + memcpy(FireArray, gFireManager.m_aFires, sizeof(gFireManager.m_aFires)); + NumOfFires = gFireManager.m_nTotalFires; + paProjectileInfo = new uint8[sizeof(gaProjectileInfo)]; + memcpy(paProjectileInfo, gaProjectileInfo, sizeof(gaProjectileInfo)); + paProjectiles = new uint8[sizeof(CProjectileInfo::ms_apProjectile)]; + memcpy(paProjectiles, CProjectileInfo::ms_apProjectile, sizeof(CProjectileInfo::ms_apProjectile)); CScriptPaths::Save_ForReplay(); } +// --MIAMI: Done void CReplay::RestoreStuffFromMem(void) { CPools::GetVehiclePool()->CopyBack(pBuf0, pBuf1); @@ -1241,8 +1492,14 @@ void CReplay::RestoreStuffFromMem(void) CStreaming::LoadAllRequestedModels(false); ped->m_weapons[j].Initialise(ped->m_weapons[j].m_eWeaponType, ped->m_weapons[j].m_nAmmoTotal); } - if (ped->m_wepModelID >= 0) + if (ped->m_wepModelID >= 0) { + ped->m_pWeaponModel = nil; + if (ped->IsPlayer()) + ((CPlayerPed*)ped)->m_pMinigunTopAtomic = nil; ped->AddWeaponModel(ped->m_wepModelID); + } + if (ped->m_nPedType == PEDTYPE_COP) + ((CCopPed*)ped)->m_pStinger = new CStinger; } i = CPools::GetVehiclePool()->GetSize(); while (--i >= 0) { @@ -1255,14 +1512,26 @@ void CReplay::RestoreStuffFromMem(void) vehicle->m_rwObject = nil; vehicle->m_modelIndex = -1; vehicle->SetModelIndex(mi); - if (mi == MI_DODO){ - CAutomobile* dodo = (CAutomobile*)vehicle; - RpAtomicSetFlags((RpAtomic*)GetFirstObject(dodo->m_aCarNodes[CAR_WHEEL_LF]), 0); - CMatrix tmp1; - tmp1.Attach(RwFrameGetMatrix(dodo->m_aCarNodes[CAR_WHEEL_RF]), false); - CMatrix tmp2(RwFrameGetMatrix(dodo->m_aCarNodes[CAR_WHEEL_LF]), false); - tmp1.GetPosition() += CVector(tmp2.GetPosition().x + 0.1f, 0.0f, tmp2.GetPosition().z); - tmp1.UpdateRW(); + if (vehicle->IsCar()) { + CAutomobile* car = (CAutomobile*)vehicle; + if (mi == MI_DODO) { + RpAtomicSetFlags((RpAtomic*)GetFirstObject(car->m_aCarNodes[CAR_WHEEL_LF]), 0); + CMatrix tmp1; + tmp1.Attach(RwFrameGetMatrix(car->m_aCarNodes[CAR_WHEEL_RF]), false); + CMatrix tmp2(RwFrameGetMatrix(car->m_aCarNodes[CAR_WHEEL_LF]), false); + tmp1.GetPosition() += CVector(tmp2.GetPosition().x + 0.1f, 0.0f, tmp2.GetPosition().z); + tmp1.UpdateRW(); + } + else if (mi == MI_HUNTER) { + RpAtomicSetFlags((RpAtomic*)GetFirstObject(car->m_aCarNodes[CAR_WHEEL_LF]), 0); + RpAtomicSetFlags((RpAtomic*)GetFirstObject(car->m_aCarNodes[CAR_WHEEL_RF]), 0); + RpAtomicSetFlags((RpAtomic*)GetFirstObject(car->m_aCarNodes[CAR_WHEEL_LB]), 0); + RpAtomicSetFlags((RpAtomic*)GetFirstObject(car->m_aCarNodes[CAR_WHEEL_RB]), 0); + } + else if (vehicle->IsRealHeli()) { + RpAtomicSetFlags((RpAtomic*)GetFirstObject(car->m_aCarNodes[CAR_WHEEL_LB]), 0); + RpAtomicSetFlags((RpAtomic*)GetFirstObject(car->m_aCarNodes[CAR_WHEEL_RB]), 0); + } } if (vehicle->IsCar()){ CAutomobile* car = (CAutomobile*)vehicle; @@ -1309,14 +1578,10 @@ void CReplay::RestoreStuffFromMem(void) if (!object) continue; int mi = object->GetModelIndex(); - CStreaming::RequestModel(mi, 0); - CStreaming::LoadAllRequestedModels(false); object->m_rwObject = nil; object->m_modelIndex = -1; - object->SetModelIndex(mi); + object->SetModelIndexNoCreate(mi); object->GetMatrix().m_attachment = nil; - if (RwObjectGetType(object->m_rwObject) == rpATOMIC) - object->GetMatrix().AttachRW(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic*)object->m_rwObject)), false); } i = CPools::GetDummyPool()->GetSize(); while (--i >= 0) { @@ -1324,15 +1589,12 @@ void CReplay::RestoreStuffFromMem(void) if (!dummy) continue; int mi = dummy->GetModelIndex(); - CStreaming::RequestModel(mi, 0); - CStreaming::LoadAllRequestedModels(false); dummy->m_rwObject = nil; dummy->m_modelIndex = -1; - dummy->SetModelIndex(mi); + dummy->SetModelIndexNoCreate(mi); dummy->GetMatrix().m_attachment = nil; - if (RwObjectGetType(dummy->m_rwObject) == rpATOMIC) - dummy->GetMatrix().AttachRW(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic*)dummy->m_rwObject)), false); } + ++ClockMinutes; CTimer::SetTimeInMilliseconds(Time1); CTimer::SetTimeInMillisecondsNonClipped(Time2); CTimer::SetPreviousTimeInMilliseconds(Time3); @@ -1345,6 +1607,25 @@ void CReplay::RestoreStuffFromMem(void) CWeather::OldWeatherType = OldWeatherType; CWeather::NewWeatherType = NewWeatherType; CWeather::InterpolationValue = WeatherInterpolationValue; + CGame::currArea = CurrArea; + CPopulation::ms_nNumCivMale = ms_nNumCivMale_Stored; + CPopulation::ms_nNumCivFemale = ms_nNumCivFemale_Stored; + CPopulation::ms_nNumCop = ms_nNumCop_Stored; + CPopulation::ms_nNumEmergency = ms_nNumEmergency_Stored; + CPopulation::ms_nNumGang1 = ms_nNumGang1_Stored; + CPopulation::ms_nNumGang2 = ms_nNumGang2_Stored; + CPopulation::ms_nNumGang3 = ms_nNumGang3_Stored; + CPopulation::ms_nNumGang4 = ms_nNumGang4_Stored; + CPopulation::ms_nNumGang5 = ms_nNumGang5_Stored; + CPopulation::ms_nNumGang6 = ms_nNumGang6_Stored; + CPopulation::ms_nNumGang7 = ms_nNumGang7_Stored; + CPopulation::ms_nNumGang8 = ms_nNumGang8_Stored; + CPopulation::ms_nNumGang9 = ms_nNumGang9_Stored; + CPopulation::ms_nNumDummy = ms_nNumDummy_Stored; + CPopulation::ms_nTotalCivPeds = ms_nTotalCivPeds_Stored; + CPopulation::ms_nTotalGangPeds = ms_nTotalGangPeds_Stored; + CPopulation::ms_nTotalPeds = ms_nTotalPeds_Stored; + CPopulation::ms_nTotalMissionPeds = ms_nTotalMissionPeds_Stored; for (int i = 0; i < CPools::GetPedPool()->GetSize(); i++) { CPed* ped = CPools::GetPedPool()->GetSlot(i); if (!ped) @@ -1353,12 +1634,27 @@ void CReplay::RestoreStuffFromMem(void) } delete[] pPedAnims; pPedAnims = nil; + memcpy(CGarages::aGarages, pGarages, sizeof(CGarages::aGarages)); + delete[] pGarages; + pGarages = nil; + memcpy(gFireManager.m_aFires, FireArray, sizeof(gFireManager.m_aFires)); + delete[] FireArray; + FireArray = nil; + gFireManager.m_nTotalFires = NumOfFires; + memcpy(gaProjectileInfo, paProjectileInfo, sizeof(gaProjectileInfo)); + delete[] paProjectileInfo; + paProjectileInfo = nil; + memcpy(CProjectileInfo::ms_apProjectile, paProjectiles, sizeof(CProjectileInfo::ms_apProjectile)); + delete[] paProjectiles; + paProjectiles = nil; CScriptPaths::Load_ForReplay(); + CExplosion::ClearAllExplosions(); DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND); DMAudio.SetRadioInCar(OldRadioStation); DMAudio.ChangeMusicMode(MUSICMODE_GAME); } +// --MIAMI: Done void CReplay::EmptyPedsAndVehiclePools(void) { int i = CPools::GetVehiclePool()->GetSize(); @@ -1379,6 +1675,7 @@ void CReplay::EmptyPedsAndVehiclePools(void) } } +// --MIAMI: Done void CReplay::EmptyAllPools(void) { EmptyPedsAndVehiclePools(); @@ -1400,6 +1697,7 @@ void CReplay::EmptyAllPools(void) } } +// --MIAMI: Done void CReplay::MarkEverythingAsNew(void) { int i = CPools::GetVehiclePool()->GetSize(); @@ -1449,6 +1747,7 @@ void CReplay::SaveReplayToHD(void) CFileMgr::SetDir(""); } +// --MIAMI: Done void PlayReplayFromHD(void) { CFileMgr::SetDirMyDocuments(); @@ -1481,6 +1780,7 @@ void PlayReplayFromHD(void) CReplay::StreamAllNecessaryCarsAndPeds(); } +// --MIAMI: Done void CReplay::StreamAllNecessaryCarsAndPeds(void) { for (int slot = 0; slot < NUM_REPLAYBUFFERS; slot++) { @@ -1491,6 +1791,9 @@ void CReplay::StreamAllNecessaryCarsAndPeds(void) case REPLAYPACKET_VEHICLE: CStreaming::RequestModel(((tVehicleUpdatePacket*)&Buffers[slot][offset])->mi, 0); break; + case REPLAYPACKET_BIKE: + CStreaming::RequestModel(((tBikeUpdatePacket*)&Buffers[slot][offset])->mi, 0); + break; case REPLAYPACKET_PED_HEADER: CStreaming::RequestModel(((tPedHeaderPacket*)&Buffers[slot][offset])->mi, 0); break; @@ -1502,6 +1805,7 @@ void CReplay::StreamAllNecessaryCarsAndPeds(void) CStreaming::LoadAllRequestedModels(false); } +// --MIAMI: Done void CReplay::FindFirstFocusCoordinate(CVector *coord) { *coord = CVector(0.0f, 0.0f, 0.0f); @@ -1517,6 +1821,7 @@ void CReplay::FindFirstFocusCoordinate(CVector *coord) } } +// --MIAMI: Done bool CReplay::ShouldStandardCameraBeProcessed(void) { if (Mode != MODE_PLAYBACK) @@ -1526,6 +1831,7 @@ bool CReplay::ShouldStandardCameraBeProcessed(void) return FindPlayerVehicle() != nil; } +// --MIAMI: Done void CReplay::ProcessLookAroundCam(void) { if (!bAllowLookAroundCam) @@ -1582,11 +1888,13 @@ void CReplay::ProcessLookAroundCam(void) RwFrameUpdateObjects(RwCameraGetFrame(TheCamera.m_pRwCamera)); } +// --MIAMI: Done size_t CReplay::FindSizeOfPacket(uint8 type) { switch (type) { case REPLAYPACKET_END: return 4; case REPLAYPACKET_VEHICLE: return sizeof(tVehicleUpdatePacket); + case REPLAYPACKET_BIKE: return sizeof(tBikeUpdatePacket); case REPLAYPACKET_PED_HEADER: return sizeof(tPedHeaderPacket); case REPLAYPACKET_PED_UPDATE: return sizeof(tPedUpdatePacket); case REPLAYPACKET_GENERAL: return sizeof(tGeneralPacket); @@ -1595,11 +1903,14 @@ size_t CReplay::FindSizeOfPacket(uint8 type) case REPLAYPACKET_ENDOFFRAME: return 4; case REPLAYPACKET_TIMER: return sizeof(tTimerPacket); case REPLAYPACKET_BULLET_TRACES:return sizeof(tBulletTracePacket); + case REPLAYPACKET_PARTICLE: return sizeof(tParticlePacket); + case REPLAYPACKET_MISC: return sizeof(tMiscPacket); default: assert(false); break; } return 0; } +// --MIAMI: Done (function didn't change since III and we already had it modified) void CReplay::Display() { static int TimeCount = 0; diff --git a/src/control/Replay.h b/src/control/Replay.h index fd484017..42d6ad1a 100644 --- a/src/control/Replay.h +++ b/src/control/Replay.h @@ -2,6 +2,7 @@ #include "Pools.h" #include "World.h" +#include "WeaponEffects.h" #include "ParticleType.h" #ifdef FIX_BUGS @@ -25,14 +26,17 @@ struct CStoredAnimationState uint8 animId; uint8 time; uint8 speed; + uint8 groupId; uint8 secAnimId; uint8 secTime; uint8 secSpeed; + uint8 secGroupId; uint8 blendAmount; uint8 partAnimId; uint8 partAnimTime; uint8 partAnimSpeed; uint8 partBlendAmount; + uint8 partGroupId; }; enum { @@ -46,20 +50,18 @@ struct CStoredDetailedAnimationState uint8 aCurTime[NUM_MAIN_ANIMS_IN_REPLAY]; uint8 aSpeed[NUM_MAIN_ANIMS_IN_REPLAY]; uint8 aBlendAmount[NUM_MAIN_ANIMS_IN_REPLAY]; -#ifdef FIX_REPLAY_BUGS int8 aBlendDelta[NUM_MAIN_ANIMS_IN_REPLAY]; -#endif uint8 aFunctionCallbackID[NUM_MAIN_ANIMS_IN_REPLAY]; uint16 aFlags[NUM_MAIN_ANIMS_IN_REPLAY]; + uint8 aGroupId[NUM_MAIN_ANIMS_IN_REPLAY]; uint8 aAnimId2[NUM_PARTIAL_ANIMS_IN_REPLAY]; uint8 aCurTime2[NUM_PARTIAL_ANIMS_IN_REPLAY]; uint8 aSpeed2[NUM_PARTIAL_ANIMS_IN_REPLAY]; uint8 aBlendAmount2[NUM_PARTIAL_ANIMS_IN_REPLAY]; -#ifdef FIX_REPLAY_BUGS int8 aBlendDelta2[NUM_PARTIAL_ANIMS_IN_REPLAY]; -#endif uint8 aFunctionCallbackID2[NUM_PARTIAL_ANIMS_IN_REPLAY]; uint16 aFlags2[NUM_PARTIAL_ANIMS_IN_REPLAY]; + uint8 aGroupId2[NUM_PARTIAL_ANIMS_IN_REPLAY]; }; void PlayReplayFromHD(void); @@ -73,21 +75,24 @@ class CReplay enum { REPLAYCAMMODE_ASSTORED = 0, - REPLAYCAMMODE_TOPDOWN = 1, - REPLAYCAMMODE_FIXED = 2 + REPLAYCAMMODE_TOPDOWN, + REPLAYCAMMODE_FIXED }; enum { REPLAYPACKET_END = 0, - REPLAYPACKET_VEHICLE = 1, - REPLAYPACKET_PED_HEADER = 2, - REPLAYPACKET_PED_UPDATE = 3, - REPLAYPACKET_GENERAL = 4, - REPLAYPACKET_CLOCK = 5, - REPLAYPACKET_WEATHER = 6, - REPLAYPACKET_ENDOFFRAME = 7, - REPLAYPACKET_TIMER = 8, - REPLAYPACKET_BULLET_TRACES = 9 + REPLAYPACKET_VEHICLE, + REPLAYPACKET_BIKE, + REPLAYPACKET_PED_HEADER, + REPLAYPACKET_PED_UPDATE, + REPLAYPACKET_GENERAL, + REPLAYPACKET_CLOCK, + REPLAYPACKET_WEATHER, + REPLAYPACKET_ENDOFFRAME, + REPLAYPACKET_TIMER, + REPLAYPACKET_BULLET_TRACES, + REPLAYPACKET_PARTICLE, + REPLAYPACKET_MISC }; enum { @@ -176,8 +181,9 @@ class CReplay int8 vehicle_index; CStoredAnimationState anim_state; CCompressedMatrixNotAligned matrix; - int8 assoc_group_id; uint16 weapon_model; + int8 assoc_group_id; + bool is_visible; }; VALIDATE_SIZE(tPedUpdatePacket, 40); @@ -203,8 +209,64 @@ class CReplay uint8 door_status; uint8 primary_color; uint8 secondary_color; + bool render_scorched; + int8 skimmer_speed; + int8 vehicle_type; + }; - VALIDATE_SIZE(tVehicleUpdatePacket, 48); + VALIDATE_SIZE(tVehicleUpdatePacket, 52); + + struct tBikeUpdatePacket + { + uint8 type; + uint8 index; + uint8 health; + uint8 acceleration; + CCompressedMatrixNotAligned matrix; + int8 door_angles[2]; + uint16 mi; + int8 velocityX; + int8 velocityY; + int8 velocityZ; + int8 wheel_state; + uint8 wheel_susp_dist[4]; + uint8 wheel_rotation[4]; + uint8 primary_color; + uint8 secondary_color; + int8 lean_angle; + int8 wheel_angle; + + }; + VALIDATE_SIZE(tBikeUpdatePacket, 44); + + struct tParticlePacket + { + uint8 type; + uint8 particle_type; + int8 dir_x; + int8 dir_y; + int8 dir_z; + uint8 r; + uint8 g; + uint8 b; + uint8 a; + int16 pos_x; + int16 pos_y; + int16 pos_z; + float size; + }; + VALIDATE_SIZE(tParticlePacket, 20); + + struct tMiscPacket + { + uint8 type; + uint32 cam_shake_start; + float cam_shake_strength; + uint8 cur_area; + uint8 special_fx_flags; + }; + + VALIDATE_SIZE(tMiscPacket, 16); private: static uint8 Mode; @@ -269,6 +331,31 @@ private: static float fDistanceLookAroundCam; static float fAlphaAngleLookAroundCam; static float fBetaAngleLookAroundCam; + static int ms_nNumCivMale_Stored; + static int ms_nNumCivFemale_Stored; + static int ms_nNumCop_Stored; + static int ms_nNumEmergency_Stored; + static int ms_nNumGang1_Stored; + static int ms_nNumGang2_Stored; + static int ms_nNumGang3_Stored; + static int ms_nNumGang4_Stored; + static int ms_nNumGang5_Stored; + static int ms_nNumGang6_Stored; + static int ms_nNumGang7_Stored; + static int ms_nNumGang8_Stored; + static int ms_nNumGang9_Stored; + static int ms_nNumDummy_Stored; + static int ms_nTotalCarPassengerPeds_Stored; + static int ms_nTotalCivPeds_Stored; + static int ms_nTotalGangPeds_Stored; + static int ms_nTotalPeds_Stored; + static int ms_nTotalMissionPeds_Stored; + static uint8* pGarages; + static CFire* FireArray; + static uint32 NumOfFires; + static uint8* paProjectileInfo; + static uint8* paProjectiles; + static uint8 CurrArea; #ifdef FIX_BUGS static int nHandleOfPlayerPed[NUMPLAYERS]; #endif @@ -288,8 +375,7 @@ public: static bool IsPlayingBack() { return Mode == MODE_PLAYBACK; } static bool IsPlayingBackFromFile() { return bPlayingBackFromFile; } - static void RecordParticle(tParticleType type, CVector const &vecPos, CVector const &vecDir, float fSize, RwRGBA const&color) - { } //TODO + static void RecordParticle(tParticleType type, CVector const& vecPos, CVector const& vecDir, float fSize, RwRGBA const& color); private: static void RecordThisFrame(void); static void StorePedUpdate(CPed *ped, int id); @@ -302,7 +388,9 @@ private: static void TriggerPlaybackLastCoupleOfSeconds(uint32, uint8, float, float, float, uint32); static bool FastForwardToTime(uint32); static void StoreCarUpdate(CVehicle *vehicle, int id); + static void StoreBikeUpdate(CVehicle* vehicle, int id); static void ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressInReplayBuffer *buffer); + static void ProcessBikeUpdate(CVehicle* vehicle, float interpolation, CAddressInReplayBuffer* buffer); static bool PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, float interpolation, uint32 *pTimer); static void ProcessReplayCamera(void); static void StoreStuffInMem(void); @@ -314,6 +402,7 @@ private: static void FindFirstFocusCoordinate(CVector *coord); static void ProcessLookAroundCam(void); static size_t FindSizeOfPacket(uint8); + static void GoToNextBlock(void); /* Absolute nonsense, but how could this function end up being outside of class? */ friend void PlayReplayFromHD(void); diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 5cd20001..f5391527 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -10102,7 +10102,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 || pVehicleInfo->m_vehicleType == VEHICLE_TYPE_BIKE) { switch (model) { case MI_LANDSTAL: case MI_LINERUN: diff --git a/src/core/EventList.cpp b/src/core/EventList.cpp index da0a5967..7eb1e186 100644 --- a/src/core/EventList.cpp +++ b/src/core/EventList.cpp @@ -230,7 +230,11 @@ CEventList::ReportCrimeForEvent(eEventType type, size_t crimeId, bool copsDontCa if(crime == CRIME_NONE) return; +#ifdef FIX_BUGS + CVector playerPedCoors = FindPlayerCoors(); +#else CVector playerPedCoors = FindPlayerPed()->GetPosition(); +#endif CVector playerCoors = FindPlayerCoors(); if(CWanted::WorkOutPolicePresence(playerCoors, 14.0f) != 0 || diff --git a/src/render/Particle.cpp b/src/render/Particle.cpp index db40781e..2f0c3809 100644 --- a/src/render/Particle.cpp +++ b/src/render/Particle.cpp @@ -1261,7 +1261,11 @@ void CParticle::Update() { if ( CTimer::GetFrameCounter() & 10 ) { +#ifdef FIX_BUGS + if ( FindPlayerPed() && FindPlayerPed()->GetWeapon()->m_eWeaponType == WEAPONTYPE_MINIGUN ) +#else if ( FindPlayerPed()->GetWeapon()->m_eWeaponType == WEAPONTYPE_MINIGUN ) +#endif { AddParticle(PARTICLE_HEATHAZE, particle->m_vecPosition, CVector(0.0f, 0.0f, 0.0f)); } diff --git a/src/render/WaterLevel.cpp b/src/render/WaterLevel.cpp index 13f52334..efcb6c14 100644 --- a/src/render/WaterLevel.cpp +++ b/src/render/WaterLevel.cpp @@ -2745,7 +2745,11 @@ CWaterLevel::RenderSeaBirds() void CWaterLevel::RenderShipsOnHorizon() { +#ifdef FIX_BUGS + CVector cur_pos = FindPlayerCoors(); +#else CVector cur_pos = FindPlayerPed()->GetPosition(); +#endif static CVector prev_pos(0.0f, 0.0f, 0.0f); static CVector prev_front(0.0f, 0.0f, 0.0f); @@ -2847,7 +2851,11 @@ CWaterLevel::HandleSeaLifeForms() void CWaterLevel::HandleBeachToysStuff(void) { +#ifdef FIX_BUGS + CVector cur_pos = FindPlayerCoors(); +#else CVector cur_pos = FindPlayerPed()->GetPosition(); +#endif static bool bBeachBallInit = true; static CVector FirstBeachBallPos = cur_pos; diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp index 086a5002..1664ffd0 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -132,7 +132,11 @@ CBoat::ProcessControl(void) if(bRenderScorched) m_fBuoyancy *= 0.99f; +#ifdef FIX_BUGS + if(FindPlayerPed() && FindPlayerPed()->m_pWanted->m_nWantedLevel > 0 && GetModelIndex() == MI_PREDATOR){ +#else if(FindPlayerPed()->m_pWanted->m_nWantedLevel > 0 && GetModelIndex() == MI_PREDATOR){ +#endif CVehicle *playerVeh = FindPlayerVehicle(); if(playerVeh && playerVeh->GetVehicleAppearance() == VEHICLE_APPEARANCE_BOAT && (AutoPilot.m_nCarMission == MISSION_RAMPLAYER_FARAWAY || diff --git a/src/weapons/Explosion.cpp b/src/weapons/Explosion.cpp index 74af1375..5d4b8f80 100644 --- a/src/weapons/Explosion.cpp +++ b/src/weapons/Explosion.cpp @@ -31,6 +31,16 @@ void CExplosion::Initialise() { debug("Initialising CExplosion...\n"); + ClearAllExplosions(); + AudioHandle = DMAudio.CreateEntity(AUDIOTYPE_EXPLOSION, (void*)1); + if (AudioHandle >= 0) + DMAudio.SetEntityStatus(AudioHandle, true); + debug("CExplosion ready\n"); +} + +void +CExplosion::ClearAllExplosions() +{ for (int i = 0; i < ARRAY_SIZE(gaExplosion); i++) { gaExplosion[i].m_ExplosionType = EXPLOSION_GRENADE; gaExplosion[i].m_vecPosition = CVector(0.0f, 0.0f, 0.0f); @@ -44,10 +54,6 @@ CExplosion::Initialise() gaExplosion[i].m_fStartTime = 0.0f; gaExplosion[i].m_bIsBoat = false; } - AudioHandle = DMAudio.CreateEntity(AUDIOTYPE_EXPLOSION, (void*)1); - if (AudioHandle >= 0) - DMAudio.SetEntityStatus(AudioHandle, true); - debug("CExplosion ready\n"); } void diff --git a/src/weapons/Explosion.h b/src/weapons/Explosion.h index cfa75ec1..f709012e 100644 --- a/src/weapons/Explosion.h +++ b/src/weapons/Explosion.h @@ -37,6 +37,7 @@ class CExplosion float m_fZshift; public: static void Initialise(); + static void ClearAllExplosions(); static void Shutdown(); static int8 GetExplosionActiveCounter(uint8 id); static void ResetExplosionActiveCounter(uint8 id); 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 From 796ad66d722cfde7e9152e52f914e1d9605cbf0b Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 26 Sep 2020 21:12:47 +0300 Subject: [PATCH 19/44] 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){ From 3c5624bc56c8ae6b28b298b8f00e37751887cbb0 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 26 Sep 2020 21:16:55 +0300 Subject: [PATCH 20/44] fixed tabs --- src/control/Replay.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp index 4ae1cf1b..45f1a143 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -1894,7 +1894,7 @@ size_t CReplay::FindSizeOfPacket(uint8 type) switch (type) { case REPLAYPACKET_END: return 4; case REPLAYPACKET_VEHICLE: return sizeof(tVehicleUpdatePacket); - case REPLAYPACKET_BIKE: return sizeof(tBikeUpdatePacket); + case REPLAYPACKET_BIKE: return sizeof(tBikeUpdatePacket); case REPLAYPACKET_PED_HEADER: return sizeof(tPedHeaderPacket); case REPLAYPACKET_PED_UPDATE: return sizeof(tPedUpdatePacket); case REPLAYPACKET_GENERAL: return sizeof(tGeneralPacket); @@ -1903,8 +1903,8 @@ size_t CReplay::FindSizeOfPacket(uint8 type) case REPLAYPACKET_ENDOFFRAME: return 4; case REPLAYPACKET_TIMER: return sizeof(tTimerPacket); case REPLAYPACKET_BULLET_TRACES:return sizeof(tBulletTracePacket); - case REPLAYPACKET_PARTICLE: return sizeof(tParticlePacket); - case REPLAYPACKET_MISC: return sizeof(tMiscPacket); + case REPLAYPACKET_PARTICLE: return sizeof(tParticlePacket); + case REPLAYPACKET_MISC: return sizeof(tMiscPacket); default: assert(false); break; } return 0; From 48a10de41fac345aae6140835191e699be1bea4f Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 26 Sep 2020 21:25:40 +0300 Subject: [PATCH 21/44] 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: From c5699a9b30c67ed15f6fe6ebe3c670736909695f Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 26 Sep 2020 21:35:09 +0300 Subject: [PATCH 22/44] now fixed properly --- src/control/Script.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/control/Script.cpp b/src/control/Script.cpp index f5391527..4516acf0 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -10098,11 +10098,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) model = CStreaming::ms_vehiclesLoaded[index]; if (model == -1) continue; - // desperatly want to believe this was inlined :| - CBaseModelInfo* pInfo = CModelInfo::GetModelInfo(model); - script_assert(pInfo->GetModelType() == MITYPE_VEHICLE); - CVehicleModelInfo* pVehicleInfo = (CVehicleModelInfo*)pInfo; - if (pVehicleInfo->m_vehicleType == VEHICLE_TYPE_CAR || pVehicleInfo->m_vehicleType == VEHICLE_TYPE_BIKE) { + if (CModelInfo::IsCarModel(model) || CModelInfo::IsBikeModel(model)) { switch (model) { case MI_LANDSTAL: case MI_LINERUN: From 6cfac662a1ebf3137b4d5e14315f14d341839cf9 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sun, 27 Sep 2020 00:32:14 +0200 Subject: [PATCH 23/44] 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" } 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: [PATCH 24/44] 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(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))); + 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; } { 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: [PATCH 25/44] 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(); 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: [PATCH 26/44] 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); } 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: [PATCH 27/44] 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); } From 742ca47a436632eb84de925c8d3386b7bc7dd2d2 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Mon, 28 Sep 2020 21:25:14 +0300 Subject: [PATCH 28/44] 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(); From 5144b5051ccf7bbbbbf6022e7526431dd8fe2fa8 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 28 Sep 2020 21:37:59 +0300 Subject: [PATCH 29/44] 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(); From a0b6410801b38c5e429b4dd4a2e8975615a615db Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 16:56:40 +0200 Subject: [PATCH 30/44] 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); } From 8424eabf2240541782fa6c9b358cdef022477778 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 17:02:47 +0200 Subject: [PATCH 31/44] 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)); From eeb26cfc7db1b010e9b9373f6f3f5bce3f2240fa Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 17:16:02 +0200 Subject: [PATCH 32/44] 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 From 874b31d82b7a277a5b34fe09f3c6802c065d6e3f Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 17:27:36 +0200 Subject: [PATCH 33/44] 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 From e324f3dac0d960a3e16d538b056c36d34c6682d4 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 17:43:34 +0200 Subject: [PATCH 34/44] 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 From 8235fe08d116366964577a8ddb0367b96b718531 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 17:47:48 +0200 Subject: [PATCH 35/44] 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(); From 35d7591defb352c2af49af0d6e0d3340e7b59672 Mon Sep 17 00:00:00 2001 From: shfil Date: Sat, 26 Sep 2020 20:11:25 +0200 Subject: [PATCH 36/44] 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); } From 35656fe0e88dcc5334cc9b7e3234df2ffac5d1d3 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sun, 27 Sep 2020 00:32:14 +0200 Subject: [PATCH 37/44] 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" } From f35fd97c7632784e206093891272f03dc11653a8 Mon Sep 17 00:00:00 2001 From: shfil Date: Mon, 28 Sep 2020 20:05:28 +0200 Subject: [PATCH 38/44] 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); } From 9cce324316e0c2794c8509d34c2868f9fdd7f986 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Mon, 28 Sep 2020 21:25:14 +0300 Subject: [PATCH 39/44] 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(); From 2129cc290650527945d389c1de9c466b5b305183 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 28 Sep 2020 21:37:59 +0300 Subject: [PATCH 40/44] 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(); From ff2998bee36509e8db74ea482eb33217c9129d63 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 16:56:40 +0200 Subject: [PATCH 41/44] 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); } From 855c6a3c056f93cdd05daf39beacabd49ea9a97b Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 17:02:47 +0200 Subject: [PATCH 42/44] 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)); From 6c59d97520c309a5fff6ed6da4499518281817ba Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 17:16:02 +0200 Subject: [PATCH 43/44] 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 From 73e4350320a11b0f3ca7530cedc9364363c2ce03 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 29 Sep 2020 17:27:36 +0200 Subject: [PATCH 44/44] 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