From 96af8c4c3a7bcfc576aa5132e492346673788bc4 Mon Sep 17 00:00:00 2001 From: klei1984 <53688147+klei1984@users.noreply.github.com> Date: Sun, 1 Oct 2023 09:36:01 +0200 Subject: [PATCH] Hide sound manager implementation. --- src/buildmenu.cpp | 2 +- src/button.cpp | 2 +- src/game_manager.cpp | 130 +++++++++++++++++------------------ src/helpmenu.cpp | 2 +- src/main.cpp | 2 +- src/menu.cpp | 10 +-- src/menulandingsequence.cpp | 4 +- src/movie.cpp | 2 +- src/optionsmenu.cpp | 14 ++-- src/pathrequest.cpp | 2 +- src/paths.cpp | 4 +- src/remote.cpp | 4 +- src/repairshopmenu.cpp | 8 +-- src/researchmenu.cpp | 8 +-- src/resource_manager.cpp | 8 +-- src/saveloadmenu.cpp | 4 +- src/scrollbar.cpp | 2 +- src/sound_manager.cpp | 133 ++++++++++++++++++++++++++++++++++-- src/sound_manager.hpp | 119 ++++---------------------------- src/text.cpp | 4 +- src/unitinfo.cpp | 46 ++++++------- src/units_manager.cpp | 40 +++++------ src/unittypeselector.cpp | 2 +- src/upgradecontrol.cpp | 4 +- 24 files changed, 294 insertions(+), 262 deletions(-) diff --git a/src/buildmenu.cpp b/src/buildmenu.cpp index 1e755843..9bc0b1d8 100644 --- a/src/buildmenu.cpp +++ b/src/buildmenu.cpp @@ -946,7 +946,7 @@ void MobileBuildMenu::Build() { MessageManager_DrawMessage(_(06cb), 0, 0); if (ini_get_setting(INI_GAME_FILE_TYPE) == GAME_TYPE_TRAINING) { - SoundManager.PlayVoice(V_M049, V_F050); + SoundManager_PlayVoice(V_M049, V_F050); } } else { diff --git a/src/button.cpp b/src/button.cpp index 701ef4fb..fa3fb7fe 100644 --- a/src/button.cpp +++ b/src/button.cpp @@ -397,7 +397,7 @@ void Button::SetRestState(bool rest_state) { } } -void Button::PlaySound() const { SoundManager.PlaySfx(sfx); } +void Button::PlaySound() const { SoundManager_PlaySfx(sfx); } void Button::SetSfx(ResourceID id) { sfx = id; } diff --git a/src/game_manager.cpp b/src/game_manager.cpp index 62c6afce..ef6e9645 100644 --- a/src/game_manager.cpp +++ b/src/game_manager.cpp @@ -899,7 +899,7 @@ void GameManager_GameLoop(int32_t game_state) { ResourceManager_ExitGame(EXIT_CODE_THANKS); } - SoundManager.PlayMusic(MAIN_MSC, false); + SoundManager_PlayMusic(MAIN_MSC, false); } void GameManager_UpdateDrawBounds() { @@ -1519,7 +1519,7 @@ bool GameManager_SelectSite(uint16_t team) { flag = true; MessageManager_DrawMessage(_(dfe1), 0, 0); - SoundManager.PlayVoice(V_M278, V_F177); + SoundManager_PlayVoice(V_M278, V_F177); } else { flag = false; @@ -1928,7 +1928,7 @@ void GameManager_UpdateMainMapView(int32_t mode, int32_t ulx, int32_t uly, bool GameManager_RenderEnable = true; } - SoundManager.UpdateSfxPosition(); + SoundManager_UpdateSfxPosition(); } void GameManager_AutoSelectNext(UnitInfo* unit) { @@ -2101,7 +2101,7 @@ void GameManager_GameSetup(int32_t game_state) { Access_UpdateVisibilityStatus(GameManager_AllVisible); - SoundManager.PlayMusic(static_cast(ini_get_setting(INI_WORLD) / 6 + SNOW_MSC), true); + SoundManager_PlayMusic(static_cast(ini_get_setting(INI_WORLD) / 6 + SNOW_MSC), true); GameManager_MenuAnimateDisplayControls(); GameManager_MenuInitDisplayControls(); @@ -2121,7 +2121,7 @@ void GameManager_GameLoopCleanup() { GameManager_RequestMenuExit = false; GameManager_TurnTimerValue = 0; - SoundManager.FreeAllSamples(); + SoundManager_FreeAllSamples(); GameManager_DeinitPopupButtons(false); @@ -2262,7 +2262,7 @@ void GameManager_AnnounceWinner(uint16_t team) { resource_id1 = static_cast(V_M118 + team * (sample_count + 1)); resource_id2 = static_cast(resource_id1 + sample_count); - SoundManager.PlayVoice(resource_id1, resource_id2); + SoundManager_PlayVoice(resource_id1, resource_id2); } } @@ -2333,10 +2333,10 @@ void GameManager_DrawTurnTimer(int32_t turn_time, bool mode) { if (turn_time <= 20) { if (GameManager_IsTurnTimerActive && GameManager_PlayerTeam == GameManager_ActiveTurnTeam) { if (turn_time == 20 && ini_get_setting(INI_TIMER) > 20) { - SoundManager.PlayVoice(V_M272, V_F273); + SoundManager_PlayVoice(V_M272, V_F273); } else if (!UnitsManager_TeamInfo[GameManager_PlayerTeam].finished_turn && ini_get_setting(INI_TIMER) > 20 && Remote_UpdatePauseTimer) { - SoundManager.PlayVoice(V_M275, V_F275); + SoundManager_PlayVoice(V_M275, V_F275); } GameManager_IsTurnTimerActive = false; @@ -2415,7 +2415,7 @@ void GameManager_UpdateGuiControl(uint16_t team) { GameManager_FillOrRestoreWindow(WINDOW_STAT_WINDOW, COLOR_BLACK, true); if (GameManager_SelectedUnit != nullptr) { - SoundManager.PlaySfx(&*GameManager_SelectedUnit, SFX_TYPE_INVALID); + SoundManager_PlaySfx(&*GameManager_SelectedUnit, SFX_TYPE_INVALID); } GameManager_UpdateMainMapView(0, 4, 0, true); @@ -2630,7 +2630,7 @@ void GameManager_UpdateGui(uint16_t team, int32_t game_state, bool enable_autosa } if (GameManager_ActiveTurnTeam == GameManager_PlayerTeam) { - SoundManager.PlayVoice(V_M053, V_F053); + SoundManager_PlayVoice(V_M053, V_F053); } } @@ -2802,7 +2802,7 @@ bool GameManager_ProcessPopupMenuInput(int32_t key) { } if (result) { - SoundManager.PlaySfx(KCARG0); + SoundManager_PlaySfx(KCARG0); GameManager_PopupButtons.r_func[button_index]( 0, reinterpret_cast(GameManager_SelectedUnit.Get())); } @@ -3069,7 +3069,7 @@ void GameManager_ProcessCheatCodes() { void GameManager_InitUnitsAndGameState() { GameManager_IsCheater = false; - SoundManager.SetVolume(AUDIO_TYPE_MUSIC, ini_get_setting(INI_MUSIC_LEVEL) / 3); + SoundManager_SetVolume(AUDIO_TYPE_MUSIC, ini_get_setting(INI_MUSIC_LEVEL) / 3); ResourceManager_FreeResources(); WindowManager_ScaleResources(); @@ -3426,7 +3426,7 @@ bool GameManager_LoadGame(int32_t save_slot, Color* palette_buffer) { if (save_slot) { if (GameManager_SelectedUnit != nullptr) { - SoundManager.PlaySfx(&*GameManager_SelectedUnit, SFX_TYPE_INVALID); + SoundManager_PlaySfx(&*GameManager_SelectedUnit, SFX_TYPE_INVALID); } MessageManager_ClearMessageBox(); @@ -3480,7 +3480,7 @@ bool GameManager_LoadGame(int32_t save_slot, Color* palette_buffer) { WindowManager_FadeIn(0); - SoundManager.PlayMusic(static_cast(ini_get_setting(INI_WORLD) / 6 + SNOW_MSC), true); + SoundManager_PlayMusic(static_cast(ini_get_setting(INI_WORLD) / 6 + SNOW_MSC), true); GameManager_MenuAnimateDisplayControls(); @@ -3580,7 +3580,7 @@ void GameManager_NotifyEvent(UnitInfo* unit, int32_t event) { MessageManager_DrawMessage(text, 1, unit, GameManager_SpottedEnemyPosition); if (resource_id1 != INVALID_ID) { - SoundManager.PlayVoice(resource_id1, resource_id2); + SoundManager_PlayVoice(resource_id1, resource_id2); } } @@ -3592,7 +3592,7 @@ void GameManager_SelectBuildSite(UnitInfo* unit) { MessageManager_ClearMessageBox(); if (unit->state == ORDER_STATE_25) { - SoundManager.PlayVoice(V_M049, V_F050, -1); + SoundManager_PlayVoice(V_M049, V_F050, -1); SDL_assert(GameManager_TempTape != nullptr); @@ -3610,7 +3610,7 @@ void GameManager_SelectBuildSite(UnitInfo* unit) { UnitsManager_SetNewOrder(unit, ORDER_BUILD, ORDER_STATE_13); if (GameManager_SelectedUnit == unit) { - SoundManager.PlaySfx(unit, SFX_TYPE_POWER_CONSUMPTION_END); + SoundManager_PlaySfx(unit, SFX_TYPE_POWER_CONSUMPTION_END); } } @@ -4621,7 +4621,7 @@ uint8_t GameManager_GetWindowCursor(int32_t grid_x, int32_t grid_y) { void GameManager_PathBuild(UnitInfo* unit) { SDL_assert(GameManager_TempTape != nullptr); - SoundManager.PlayVoice(V_M049, V_F050, -1); + SoundManager_PlayVoice(V_M049, V_F050, -1); unit->target_grid_x = GameManager_TempTape->grid_x; unit->target_grid_y = GameManager_TempTape->grid_y; @@ -4653,41 +4653,41 @@ void GameManager_PathBuild(UnitInfo* unit) { void GameManager_ReloadUnit(UnitInfo* unit1, UnitInfo* unit2) { if (unit2->orders == ORDER_DISABLE) { - SoundManager.PlaySfx(NCANC0); + SoundManager_PlaySfx(NCANC0); MessageManager_DrawMessage(_(d984), 1, 0); } else if (unit1->storage) { unit1->SetParent(unit2); MessageManager_DrawMessage(_(1fd7), 0, 0); UnitsManager_SetNewOrder(unit1, ORDER_RELOAD, ORDER_STATE_INIT); - SoundManager.PlayVoice(V_M085, V_F085); + SoundManager_PlayVoice(V_M085, V_F085); } else { - SoundManager.PlaySfx(NCANC0); + SoundManager_PlaySfx(NCANC0); MessageManager_DrawMessage(_(930a), 1, 0); } } void GameManager_RepairUnit(UnitInfo* unit1, UnitInfo* unit2) { if (unit2->orders == ORDER_DISABLE) { - SoundManager.PlaySfx(NCANC0); + SoundManager_PlaySfx(NCANC0); MessageManager_DrawMessage(_(7c90), 1, 0); } else if (unit1->storage) { unit1->SetParent(unit2); MessageManager_DrawMessage(_(5ae3), 0, 0); UnitsManager_SetNewOrder(unit1, ORDER_REPAIR, ORDER_STATE_INIT); - SoundManager.PlayVoice(V_M210, V_F210); + SoundManager_PlayVoice(V_M210, V_F210); } else { - SoundManager.PlaySfx(NCANC0); + SoundManager_PlaySfx(NCANC0); MessageManager_DrawMessage(_(c65e), 1, 0); } } void GameManager_TransferCargo(UnitInfo* unit1, UnitInfo* unit2) { if (unit2->orders == ORDER_DISABLE) { - SoundManager.PlaySfx(NCANC0); + SoundManager_PlaySfx(NCANC0); MessageManager_DrawMessage(_(42b7), 1, 0); } else if (UnitsManager_BaseUnits[unit1->unit_type].cargo_type == @@ -4726,7 +4726,7 @@ void GameManager_TransferCargo(UnitInfo* unit1, UnitInfo* unit2) { MessageManager_DrawMessage(message, 0, 0); - SoundManager.PlayVoice(V_M224, V_F224); + SoundManager_PlayVoice(V_M224, V_F224); } } } @@ -5432,7 +5432,7 @@ void GameManager_ProcessKey() { } if (GameManager_IsMainMenuEnabled && !UnitsManager_TeamInfo[GameManager_PlayerTeam].finished_turn) { - SoundManager.PlaySfx(MBUTT0); + SoundManager_PlaySfx(MBUTT0); GameManager_ResetRenderState(); if (!GameManager_RefreshOrders(GameManager_PlayerTeam, GameManager_RequestMenuExit)) { @@ -5496,7 +5496,7 @@ void GameManager_ProcessKey() { case GNW_KB_KEY_G: case GNW_KB_KEY_SHIFT_G: case 1033: { - SoundManager.PlaySfx(IGRID0); + SoundManager_PlaySfx(IGRID0); GameManager_MenuClickGridButton(!GameManager_DisplayButtonGrid); } break; @@ -5612,7 +5612,7 @@ void GameManager_ProcessKey() { } break; case 1003: { - SoundManager.PlaySfx(MBUTT0); + SoundManager_PlaySfx(MBUTT0); GameManager_ResetRenderState(); if (!GameManager_RefreshOrders(GameManager_PlayerTeam, GameManager_RequestMenuExit)) { @@ -5633,7 +5633,7 @@ void GameManager_ProcessKey() { } break; case 1015: { - SoundManager.PlaySfx(MBUTT0); + SoundManager_PlaySfx(MBUTT0); GameManager_MenuClickLockButton(!GameManager_DisplayButtonLock); } break; @@ -5679,52 +5679,52 @@ void GameManager_ProcessKey() { } break; case 1026: { - SoundManager.PlaySfx(ISURV0); + SoundManager_PlaySfx(ISURV0); GameManager_MenuClickSurveyButton(!GameManager_DisplayButtonSurvey); } break; case 1027: { - SoundManager.PlaySfx(ISTAT0); + SoundManager_PlaySfx(ISTAT0); GameManager_MenuClickStatusButton(!GameManager_DisplayButtonStatus); } break; case 1028: { - SoundManager.PlaySfx(ICOLO0); + SoundManager_PlaySfx(ICOLO0); GameManager_MenuClickColorsButton(!GameManager_DisplayButtonColors); } break; case 1029: { - SoundManager.PlaySfx(IHITS0); + SoundManager_PlaySfx(IHITS0); GameManager_MenuClickHitsButton(!GameManager_DisplayButtonHits); } break; case 1030: { - SoundManager.PlaySfx(IAMMO0); + SoundManager_PlaySfx(IAMMO0); GameManager_MenuClickAmmoButton(!GameManager_DisplayButtonAmmo); } break; case 1031: { - SoundManager.PlaySfx(IRANG0); + SoundManager_PlaySfx(IRANG0); GameManager_MenuClickRangeButton(!GameManager_DisplayButtonRange); } break; case 1032: { - SoundManager.PlaySfx(IVISI0); + SoundManager_PlaySfx(IVISI0); GameManager_MenuClickScanButton(!GameManager_DisplayButtonScan); } break; case 1034: { - SoundManager.PlaySfx(INAME0); + SoundManager_PlaySfx(INAME0); GameManager_MenuClickNamesButton(!GameManager_DisplayButtonNames); } break; case 1036: { - SoundManager.PlaySfx(IAMMO0); + SoundManager_PlaySfx(IAMMO0); GameManager_MenuClickMinimap2xButton(!GameManager_DisplayButtonMinimap2x); } break; case 1037: { - SoundManager.PlaySfx(IAMMO0); + SoundManager_PlaySfx(IAMMO0); GameManager_MenuClickMinimapTntButton(!GameManager_DisplayButtonMinimapTnt); } break; @@ -5740,7 +5740,7 @@ void GameManager_ProcessKey() { } } else { - SoundManager.PlaySfx(MBUTT0); + SoundManager_PlaySfx(MBUTT0); } GameManager_SiteSelectReleaseEvent = true; @@ -6577,7 +6577,7 @@ void GameManager_ProcessInput() { case WINDOW_MAIN_MAP: { if (!(GameManager_MouseButtons & (MOUSE_PRESS_LEFT | MOUSE_PRESS_RIGHT))) { - SoundManager.PlaySfx(KCARG0); + SoundManager_PlaySfx(KCARG0); if (MessageManager_MessageBox_IsActive) { MessageManager_ClearMessageBox(); @@ -6591,10 +6591,10 @@ void GameManager_ProcessInput() { if (Cursor_GetCursor() == CURSOR_UNIT_GO) { GameManager_GameState = GAME_STATE_13; - SoundManager.PlaySfx(NDONE0); + SoundManager_PlaySfx(NDONE0); } else { - SoundManager.PlaySfx(NCANC0); + SoundManager_PlaySfx(NCANC0); } } else { @@ -6977,7 +6977,7 @@ void GameManager_MenuUnitSelect(UnitInfo* unit) { if (GameManager_DisplayControlsInitialized) { if (GameManager_SelectedUnit != nullptr && GameManager_SelectedUnit != unit) { GameManager_SelectedUnit->RefreshScreen(); - SoundManager.PlaySfx(&*GameManager_SelectedUnit, SFX_TYPE_INVALID); + SoundManager_PlaySfx(&*GameManager_SelectedUnit, SFX_TYPE_INVALID); } Gamemanager_FlicButton->Enable(unit && unit->team == GameManager_PlayerTeam); @@ -7069,7 +7069,7 @@ void GameManager_MenuUnitSelect(UnitInfo* unit) { sound = SFX_TYPE_BUILDING; } - SoundManager.PlaySfx(unit, sound); + SoundManager_PlaySfx(unit, sound); if (unit->GetUnitList()) { unit->MoveToFrontInUnitList(); @@ -7766,7 +7766,7 @@ void GameManager_PlayUnitStatusVoice(UnitInfo* unit) { is_damaged = false; is_critical = false; - SoundManager.PlayVoice(V_START, V_START2, -1); + SoundManager_PlayVoice(V_START, V_START2, -1); unit_ammo = unit->GetBaseValues()->GetAttribute(ATTRIB_AMMO); @@ -7787,60 +7787,60 @@ void GameManager_PlayUnitStatusVoice(UnitInfo* unit) { } if (is_ammo_depleted) { - SoundManager.PlayVoice(V_M142, V_F142); + SoundManager_PlayVoice(V_M142, V_F142); } else if (is_ammo_low) { - SoundManager.PlayVoice(V_M138, V_F138); + SoundManager_PlayVoice(V_M138, V_F138); } if (is_movement_exhausted) { - SoundManager.PlayVoice(V_M145, V_F145); + SoundManager_PlayVoice(V_M145, V_F145); } if (is_critical) { - SoundManager.PlayVoice(V_M154, V_F155); + SoundManager_PlayVoice(V_M154, V_F155); } else if (is_damaged) { - SoundManager.PlayVoice(V_M150, V_F151); + SoundManager_PlayVoice(V_M150, V_F151); } if (!is_ammo_depleted && !is_ammo_low && !is_movement_exhausted && !is_damaged) { if (unit->unit_type == SURVEYOR) { - SoundManager.PlayVoice(V_M191, V_F192); + SoundManager_PlayVoice(V_M191, V_F192); } else if (unit->orders == ORDER_MOVE_TO_ATTACK) { - SoundManager.PlayVoice(V_M196, V_F198); + SoundManager_PlayVoice(V_M196, V_F198); } else if ((unit->orders == ORDER_AWAIT || unit->orders == ORDER_MOVE) && unit->GetLayingState() == 2) { - SoundManager.PlayVoice(V_M181, V_F182); + SoundManager_PlayVoice(V_M181, V_F182); } else if ((unit->orders == ORDER_AWAIT || unit->orders == ORDER_MOVE) && unit->GetLayingState() == 1) { - SoundManager.PlayVoice(V_M186, V_F187); + SoundManager_PlayVoice(V_M186, V_F187); } else if (unit->orders == ORDER_CLEAR) { - SoundManager.PlayVoice(V_M171, V_F171); + SoundManager_PlayVoice(V_M171, V_F171); } else if (unit->orders == ORDER_SENTRY && (unit->flags & (MOBILE_AIR_UNIT | MOBILE_SEA_UNIT | MOBILE_LAND_UNIT))) { - SoundManager.PlayVoice(V_M158, V_F158); + SoundManager_PlayVoice(V_M158, V_F158); } else if (unit->orders == ORDER_BUILD) { if (unit->state == ORDER_STATE_BUILDING_READY) { - SoundManager.PlayVoice(V_M162, V_F165); + SoundManager_PlayVoice(V_M162, V_F165); } else if (unit->state == ORDER_STATE_UNIT_READY) { - SoundManager.PlayVoice(V_M166, V_F169); + SoundManager_PlayVoice(V_M166, V_F169); } else { - SoundManager.PlayVoice(V_M284, V_F284); + SoundManager_PlayVoice(V_M284, V_F284); } } else if (unit->unit_type == RESEARCH && unit->orders == ORDER_POWER_ON && UnitsManager_TeamInfo[unit->team].research_topics[unit->research_topic].turns_to_complete == 0) { - SoundManager.PlayVoice(V_M093, V_F093); + SoundManager_PlayVoice(V_M093, V_F093); } else if (unit->flags & (MOBILE_AIR_UNIT | MOBILE_SEA_UNIT | MOBILE_LAND_UNIT)) { - SoundManager.PlayVoice(V_M001, V_F004); + SoundManager_PlayVoice(V_M001, V_F004); } } } @@ -7963,7 +7963,7 @@ void GameManager_ReportNewUnitsMessage(uint16_t* counts) { strcat(message, _(e3cd)); if (flag) { - SoundManager.PlayVoice(V_M215, V_F217); + SoundManager_PlayVoice(V_M215, V_F217); } } else { @@ -7971,7 +7971,7 @@ void GameManager_ReportNewUnitsMessage(uint16_t* counts) { strcat(message, _(9753)); if (flag) { - SoundManager.PlayVoice(V_M206, V_F207); + SoundManager_PlayVoice(V_M206, V_F207); } } } diff --git a/src/helpmenu.cpp b/src/helpmenu.cpp index 93f4f8fd..eade84d2 100644 --- a/src/helpmenu.cpp +++ b/src/helpmenu.cpp @@ -476,7 +476,7 @@ void HelpMenu_Menu(HelpSectionId section_id, int32_t window_index, bool mode) { } if (mouse_event.buttons & MOUSE_RELEASE_LEFT) { - SoundManager.PlaySfx(KCARG0); + SoundManager_PlaySfx(KCARG0); if (section_id == HELPMENU_GAME_SCREEN_SETUP && HelpMenu_UnitReport(mouse_event.point.x, mouse_event.point.y)) { diff --git a/src/main.cpp b/src/main.cpp index 9455a9dc..999e4db3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,7 +32,7 @@ int main(int argc, char* argv[]) { menu_draw_logo(ILOGO, 3000); } - SoundManager.PlayMusic(MAIN_MSC, false); + SoundManager_PlayMusic(MAIN_MSC, false); menu_draw_logo(MLOGO, 3000); main_menu(); diff --git a/src/menu.cpp b/src/menu.cpp index dd7c5396..5b4e9020 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -697,7 +697,7 @@ void menu_wrap_up_game(uint16_t* teams, int32_t teams_in_play, int32_t global_tu Remote_UpdatePauseTimer = false; - SoundManager.FreeAllSamples(); + SoundManager_FreeAllSamples(); GameManager_DeinitPopupButtons(false); @@ -728,11 +728,11 @@ void menu_wrap_up_game(uint16_t* teams, int32_t teams_in_play, int32_t global_tu } if (is_winner) { - SoundManager.PlayVoice(V_M283, V_F283); - SoundManager.PlayMusic(WINR_MSC, false); + SoundManager_PlayVoice(V_M283, V_F283); + SoundManager_PlayMusic(WINR_MSC, false); } else { - SoundManager.PlayMusic(LOSE_MSC, false); + SoundManager_PlayMusic(LOSE_MSC, false); } if (mission_briefing.GetLength() > 0) { @@ -2462,7 +2462,7 @@ void main_menu() { draw_copyright_label(window); menu_draw_main_menu_buttons(main_menu_buttons, sizeof(main_menu_buttons) / sizeof(struct MenuButton)); mouse_show(); - SoundManager.PlayMusic(MAIN_MSC, false); + SoundManager_PlayMusic(MAIN_MSC, false); Cursor_SetCursor(CURSOR_HAND); mouse_show(); palette_from_image = 0; diff --git a/src/menulandingsequence.cpp b/src/menulandingsequence.cpp index ca814d7e..db07d05d 100644 --- a/src/menulandingsequence.cpp +++ b/src/menulandingsequence.cpp @@ -111,7 +111,7 @@ void MenuLandingSequence::AnimateStep(int32_t offset) { void MenuLandingSequence::OpenPanel() { DeleteButtons(); - SoundManager.PlaySfx(IOPEN0); + SoundManager_PlaySfx(IOPEN0); for (int32_t i = 0; i < PANEL_STEP_COUNT; ++i) { time_stamp = timer_get(); @@ -145,7 +145,7 @@ void MenuLandingSequence::ClosePanel() { GameManager_MenuDeinitButtons(); - SoundManager.PlaySfx(ICLOS0); + SoundManager_PlaySfx(ICLOS0); for (int32_t i = 0; i < PANEL_STEP_COUNT; ++i) { time_stamp = timer_get(); diff --git a/src/movie.cpp b/src/movie.cpp index da6f5aaf..2aec4a89 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -107,7 +107,7 @@ int32_t movie_run(ResourceID resource_id, int32_t mode) { char* file_name; uint8_t* palette; - SoundManager.FreeMusic(); + SoundManager_FreeMusic(); WindowManager_ClearWindow(); diff --git a/src/optionsmenu.cpp b/src/optionsmenu.cpp index c7d6a0c3..7d14b852 100644 --- a/src/optionsmenu.cpp +++ b/src/optionsmenu.cpp @@ -404,7 +404,7 @@ void OptionsMenu::UpdateSlider(int32_t id) { } void OptionsMenu::SetVolume(int32_t id, int32_t audio_type, int32_t value) { - SoundManager.SetVolume(audio_type, value); + SoundManager_SetVolume(audio_type, value); ini_set_setting(options_menu_buttons[id].ini_param_index, value); } @@ -654,19 +654,19 @@ int32_t OptionsMenu::ProcessKeyPress(int32_t key) { } break; case INI_DISABLE_MUSIC: { ini_set_setting(INI_DISABLE_MUSIC, last_value); - SoundManager.HaltMusicPlayback(last_value); + SoundManager_HaltMusicPlayback(last_value); } break; case INI_DISABLE_FX: { ini_set_setting(INI_DISABLE_FX, last_value); - SoundManager.HaltSfxPlayback(last_value); + SoundManager_HaltSfxPlayback(last_value); } break; case INI_DISABLE_VOICE: { ini_set_setting(INI_DISABLE_VOICE, last_value); - SoundManager.HaltVoicePlayback(last_value); + SoundManager_HaltVoicePlayback(last_value); } break; } @@ -703,15 +703,15 @@ int32_t OptionsMenu::ProcessKeyPress(int32_t key) { switch (ini_param_index) { case INI_DISABLE_MUSIC: { - SoundManager.HaltMusicPlayback(value); + SoundManager_HaltMusicPlayback(value); } break; case INI_DISABLE_FX: { - SoundManager.HaltSfxPlayback(value); + SoundManager_HaltSfxPlayback(value); } break; case INI_DISABLE_VOICE: { - SoundManager.HaltVoicePlayback(value); + SoundManager_HaltVoicePlayback(value); } break; } diff --git a/src/pathrequest.cpp b/src/pathrequest.cpp index 7c6d45bf..585d007c 100644 --- a/src/pathrequest.cpp +++ b/src/pathrequest.cpp @@ -181,7 +181,7 @@ void PathRequest::Finish(GroundPath* path) { } if (GameManager_SelectedUnit == client) { - SoundManager.PlayVoice(V_M094, V_F095); + SoundManager_PlayVoice(V_M094, V_F095); } } else { diff --git a/src/paths.cpp b/src/paths.cpp index 196dbf11..04363e2d 100644 --- a/src/paths.cpp +++ b/src/paths.cpp @@ -302,7 +302,7 @@ bool AirPath::Path_vfunc10(UnitInfo* unit) { delta_y >>= 1; } else if (GameManager_SelectedUnit == unit && unit->sound != SFX_TYPE_DRIVE) { - SoundManager.PlaySfx(unit, SFX_TYPE_DRIVE); + SoundManager_PlaySfx(unit, SFX_TYPE_DRIVE); } } @@ -352,7 +352,7 @@ bool AirPath::Path_vfunc10(UnitInfo* unit) { Access_UpdateMapStatus(&*target_unit, false); if (GameManager_SelectedUnit == unit && length == 1) { - SoundManager.PlaySfx(unit, SFX_TYPE_STOP); + SoundManager_PlaySfx(unit, SFX_TYPE_STOP); } } diff --git a/src/remote.cpp b/src/remote.cpp index 5ce31e84..370a39ba 100644 --- a/src/remote.cpp +++ b/src/remote.cpp @@ -421,7 +421,7 @@ void Remote_ResponseTimeout(uint16_t team, bool mode) { sprintf(message, _(9a28), menu_team_names[team]); - SoundManager.PlayVoice(static_cast(V_M025 + team * 4), static_cast(V_F026 + team * 4)); + SoundManager_PlayVoice(static_cast(V_M025 + team * 4), static_cast(V_F026 + team * 4)); } if (GameManager_GameState != GAME_STATE_3_MAIN_MENU) { @@ -1442,7 +1442,7 @@ void Remote_ReceiveNetPacket_06(NetPacket& packet) { MessageManager_DrawMessage(message, 1, 0); - SoundManager.PlayVoice(static_cast(V_M279 + entity_id * 2), + SoundManager_PlayVoice(static_cast(V_M279 + entity_id * 2), static_cast(V_F279 + entity_id * 2)); } } diff --git a/src/repairshopmenu.cpp b/src/repairshopmenu.cpp index cdc3d55b..ce96eaf8 100644 --- a/src/repairshopmenu.cpp +++ b/src/repairshopmenu.cpp @@ -764,7 +764,7 @@ void RepairShopSlot_OnClick_Reload(ButtonID bid, intptr_t value) { slot->DrawStats(true); slot->UpdateButtons(); - SoundManager.PlayVoice(V_M085, V_F085); + SoundManager_PlayVoice(V_M085, V_F085); } } @@ -780,7 +780,7 @@ void RepairShopSlot_OnClick_Repair(ButtonID bid, intptr_t value) { slot->DrawStats(true); slot->UpdateButtons(); - SoundManager.PlayVoice(V_M210, V_F210); + SoundManager_PlayVoice(V_M210, V_F210); } } @@ -875,7 +875,7 @@ void RepairShopMenu_OnClick_ReloadAll(ButtonID bid, intptr_t value) { shop->Draw(true); if (success) { - SoundManager.PlayVoice(V_M089, V_F089); + SoundManager_PlayVoice(V_M089, V_F089); } } @@ -896,7 +896,7 @@ void RepairShopMenu_OnClick_RepairAll(ButtonID bid, intptr_t value) { shop->Draw(true); if (success) { - SoundManager.PlayVoice(V_M211, V_F211); + SoundManager_PlayVoice(V_M211, V_F211); } } diff --git a/src/researchmenu.cpp b/src/researchmenu.cpp index 57fe5de0..fc17a82d 100644 --- a/src/researchmenu.cpp +++ b/src/researchmenu.cpp @@ -231,7 +231,7 @@ void ResearchMenu_NewTurn(uint16_t team) { ResearchMenu_ApplyUpgrades(team, i); if (team == GameManager_PlayerTeam) { - SoundManager.PlayVoice(V_M093, V_F093); + SoundManager_PlayVoice(V_M093, V_F093); } } } @@ -340,8 +340,7 @@ void ResearchControl::UpdateButtons() { uint16_t ResearchControl::GetValue() const { return topic_value; } -void ResearchControl::Init(ResearchMenu *menu, uint8_t research_topic_index, - uint16_t research_topic_value) { +void ResearchControl::Init(ResearchMenu *menu, uint8_t research_topic_index, uint16_t research_topic_value) { WindowInfo window; SmartString string; int32_t uly_slider; @@ -554,8 +553,7 @@ void ResearchMenu_OnClick_Cancel(ButtonID bid, intptr_t value) { control->exit_loop = true; } -ResearchMenu::ResearchMenu(uint16_t team) - : Window(RSRCHPIC, GameManager_GetDialogWindowCenterMode()), team(team) { +ResearchMenu::ResearchMenu(uint16_t team) : Window(RSRCHPIC, GameManager_GetDialogWindowCenterMode()), team(team) { WindowInfo window; uint16_t research_topics[RESEARCH_TOPIC_COUNT]; diff --git a/src/resource_manager.cpp b/src/resource_manager.cpp index b496ab2b..0e8a0c08 100644 --- a/src/resource_manager.cpp +++ b/src/resource_manager.cpp @@ -535,7 +535,7 @@ void ResourceManager_InitInternals() { ResourceManager_DisableEnhancedGraphics = !ini_get_setting(INI_ENHANCED_GRAPHICS); - SoundManager.Init(); + SoundManager_Init(); register_pause(-1, nullptr); register_screendump(GNW_KB_KEY_LALT_C, screendump_pcx); } @@ -547,13 +547,13 @@ void ResourceManager_TestMouse() { } void ResourceManager_ExitGame(int32_t error_code) { - SoundManager.FreeAllSamples(); + SoundManager_FreeAllSamples(); if ((error_code == EXIT_CODE_NO_ERROR) || (error_code == EXIT_CODE_THANKS)) { menu_draw_exit_logos(); } - SoundManager.Deinit(); + SoundManager_Deinit(); win_exit(); Svga_Deinit(); SDL_Log("%s", ResourceManager_ErrorCodes[error_code]); @@ -993,7 +993,7 @@ void ResourceManager_InitInGameAssets(int32_t world) { delete[] ResourceManager_CargoMap; ResourceManager_CargoMap = nullptr; - SoundManager.FreeMusic(); + SoundManager_FreeMusic(); WindowManager_LoadBigImage(FRAMEPIC, window, window->width, true, false, -1, -1, false, true); diff --git a/src/saveloadmenu.cpp b/src/saveloadmenu.cpp index b8806214..173f4b1d 100644 --- a/src/saveloadmenu.cpp +++ b/src/saveloadmenu.cpp @@ -246,7 +246,7 @@ int32_t SaveLoadMenu_GetSavedGameInfo(int32_t save_slot, int32_t game_file_type, return result; } -void SaveLoadMenu_PlaySfx(ResourceID id) { SoundManager.PlaySfx(id); } +void SaveLoadMenu_PlaySfx(ResourceID id) { SoundManager_PlaySfx(id); } void SaveLoadMenu_Init(SaveSlot *slots, int32_t num_buttons, Button *buttons[], Flic **flc, bool is_saving_allowed, int32_t save_file_type, int32_t first_slot_on_page, bool mode) { @@ -877,7 +877,7 @@ void SaveLoadMenu_Save(const char *file_name, const char *save_name, bool play_v } if (play_voice) { - SoundManager.PlayVoice(V_M013, V_F013); + SoundManager_PlayVoice(V_M013, V_F013); } } diff --git a/src/scrollbar.cpp b/src/scrollbar.cpp index 969e787a..b1a05562 100644 --- a/src/scrollbar.cpp +++ b/src/scrollbar.cpp @@ -94,7 +94,7 @@ void Scrollbar::ProcessValueChange(int16_t value) { this->value = value; if (old_value != value) { - SoundManager.PlaySfx(KCARG0); + SoundManager_PlaySfx(KCARG0); EventScrollbarChange event(this, old_value); RefreshScreen(); window->EventHandler(&event); diff --git a/src/sound_manager.cpp b/src/sound_manager.cpp index 5400646e..1ec744f8 100644 --- a/src/sound_manager.cpp +++ b/src/sound_manager.cpp @@ -43,10 +43,113 @@ #define SOUNDMGR_SFX_FLAG_UNKNOWN_2 2 #define SOUNDMGR_SFX_FLAG_INFINITE_LOOPING 4 -#define SOUNDMGR_SCALE_VOLUME(volume) (((volume)*MIX_MAX_VOLUME) / SOUNDMGR_MAX_VALUE) -#define SOUNDMGR_SCALE_PANNING_RIGHT(panning) (((panning)*254u) / SOUNDMGR_PANNING_RIGHT) - -CSoundManager SoundManager; +#define SOUNDMGR_SCALE_VOLUME(volume) (((volume) * MIX_MAX_VOLUME) / SOUNDMGR_MAX_VALUE) +#define SOUNDMGR_SCALE_PANNING_RIGHT(panning) (((panning) * 254u) / SOUNDMGR_PANNING_RIGHT) + +#include + +#include + +class CSoundManager { +public: + CSoundManager(); + ~CSoundManager(); + void Init(); + void Deinit(); + + void PlayMusic(ResourceID id, bool shuffle); + void HaltMusicPlayback(bool disable); + void FreeMusic(); + + void PlaySfx(ResourceID id); + void PlaySfx(UnitInfo* unit, int32_t sound, bool mode = false); + void UpdateSfxPosition(); + void UpdateSfxPosition(UnitInfo* unit); + void UpdateAllSfxPositions(); + void HaltSfxPlayback(bool disable); + + void PlayVoice(ResourceID id1, ResourceID id2, int16_t priority = 0); + void HaltVoicePlayback(bool disable); + + void FreeAllSamples(); + void SetVolume(int32_t type, int32_t volume); + + void BkProcess(); + +private: + typedef enum { JOB_TYPE_SFX0, JOB_TYPE_SFX1, JOB_TYPE_SFX2, JOB_TYPE_VOICE, JOB_TYPE_MUSIC } JOB_TYPE; + + typedef struct { + int32_t volume; + char flags; + } SoundVolume; + + typedef struct { + ResourceID id; + JOB_TYPE type; + uint32_t volume_1; + uint32_t volume_2; + uint16_t panning; + int32_t loop_count; + int16_t grid_x; + int16_t grid_y; + int16_t priority; + int32_t sound; + uint16_t unit_id; + } SoundJob; + + typedef struct { + ResourceID id; + JOB_TYPE type; + uint32_t volume_1; + uint32_t volume_2; + int32_t loop_count; + int16_t grid_x; + int16_t grid_y; + int16_t priority; + uint32_t time_stamp; + uint32_t loop_point_start; + int32_t loop_point_length; + + int32_t mixer_channel; + Mix_Chunk* chunk; + Mix_Music* music; + } SoundSample; + + bool is_audio_enabled; + + SoundVolume* volumes; + + ResourceID current_music_played; + ResourceID last_music_played; + + bool shuffle_music; + bool shuffle_music_playlist[BKG9_MSC - MAIN_MSC + 1]; + + ResourceID voice_played; + + std::list jobs; + + std::list samples; + int32_t mixer_channels_count; + SoundSample* music; + SoundSample* voice; + SoundSample* sfx; + + void AddJob(SoundJob& job); + int32_t ProcessJob(SoundJob& job); + void FreeSample(SoundSample* sample); + void UpdateMusic(); + void FreeSfx(UnitInfo* unit); + void FreeVoice(ResourceID id1, ResourceID id2); + bool IsVoiceGroupScheduled(ResourceID id1, ResourceID id2); + static int32_t GetPanning(int32_t distance, bool reverse); + bool LoadMusic(ResourceID id); + int32_t LoadSound(SoundJob& job, SoundSample& sample); + void LoadLoopPoints(FILE* fp, SoundSample& sample); +}; + +static CSoundManager SoundManager; static const uint8_t soundmgr_sfx_type_flags[SFX_TYPE_LIMIT] = { SOUNDMGR_SFX_FLAG_INVALID, @@ -1033,7 +1136,7 @@ void CSoundManager::LoadLoopPoints(FILE* fp, SoundSample& sample) { SampleLoop sample_loop; for (int32_t i = 0; i < sampler_chunk.num_sample_loops && - fread(&sample_loop, sizeof(sample_loop), 1, fp); + fread(&sample_loop, sizeof(sample_loop), 1, fp); i++) { sample.loop_point_start = sample_loop.start; sample.loop_point_length = sample_loop.end - sample_loop.start; @@ -1055,3 +1158,23 @@ void CSoundManager::LoadLoopPoints(FILE* fp, SoundSample& sample) { } } } + +void SoundManager_Init() noexcept { SoundManager.Init(); } +void SoundManager_Deinit() noexcept { SoundManager.Deinit(); } +void SoundManager_PlayMusic(const ResourceID id, const bool shuffle) noexcept { SoundManager.PlayMusic(id, shuffle); } +void SoundManager_HaltMusicPlayback(const bool disable) noexcept { SoundManager.HaltMusicPlayback(disable); } +void SoundManager_FreeMusic() noexcept { SoundManager.FreeMusic(); } +void SoundManager_PlaySfx(const ResourceID id) noexcept { SoundManager.PlaySfx(id); } +void SoundManager_PlaySfx(UnitInfo* const unit, const int32_t sound, const bool mode) noexcept { + SoundManager.PlaySfx(unit, sound, mode); +} +void SoundManager_UpdateSfxPosition() noexcept { SoundManager.UpdateSfxPosition(); } +void SoundManager_UpdateSfxPosition(UnitInfo* const unit) noexcept { SoundManager.UpdateSfxPosition(unit); } +void SoundManager_UpdateAllSfxPositions() noexcept { SoundManager.UpdateAllSfxPositions(); } +void SoundManager_HaltSfxPlayback(const bool disable) noexcept { SoundManager.HaltSfxPlayback(disable); } +void SoundManager_PlayVoice(const ResourceID id1, const ResourceID id2, const int16_t priority) noexcept { + SoundManager.PlayVoice(id1, id2, priority); +} +void SoundManager_HaltVoicePlayback(const bool disable) noexcept { SoundManager.HaltVoicePlayback(disable); } +void SoundManager_FreeAllSamples() noexcept { SoundManager.FreeAllSamples(); } +void SoundManager_SetVolume(const int32_t type, const int32_t volume) noexcept { SoundManager.SetVolume(type, volume); } diff --git a/src/sound_manager.hpp b/src/sound_manager.hpp index 714090ca..496cb37f 100644 --- a/src/sound_manager.hpp +++ b/src/sound_manager.hpp @@ -22,10 +22,6 @@ #ifndef SOUND_MANAGER_HPP #define SOUND_MANAGER_HPP -#include - -#include - #include "unitinfo.hpp" enum AudioType { @@ -36,105 +32,20 @@ enum AudioType { AUDIO_TYPE_MUSIC, }; -class CSoundManager { -public: - CSoundManager(); - ~CSoundManager(); - void Init(); - void Deinit(); - - void PlayMusic(ResourceID id, bool shuffle); - void HaltMusicPlayback(bool disable); - void FreeMusic(); - - void PlaySfx(ResourceID id); - void PlaySfx(UnitInfo* unit, int32_t sound, bool mode = false); - void UpdateSfxPosition(); - void UpdateSfxPosition(UnitInfo* unit); - void UpdateAllSfxPositions(); - void HaltSfxPlayback(bool disable); - - void PlayVoice(ResourceID id1, ResourceID id2, int16_t priority = 0); - void HaltVoicePlayback(bool disable); - - void FreeAllSamples(); - void SetVolume(int32_t type, int32_t volume); - - void BkProcess(); - -private: - typedef enum { JOB_TYPE_SFX0, JOB_TYPE_SFX1, JOB_TYPE_SFX2, JOB_TYPE_VOICE, JOB_TYPE_MUSIC } JOB_TYPE; - - typedef struct { - int32_t volume; - char flags; - } SoundVolume; - - typedef struct { - ResourceID id; - JOB_TYPE type; - uint32_t volume_1; - uint32_t volume_2; - uint16_t panning; - int32_t loop_count; - int16_t grid_x; - int16_t grid_y; - int16_t priority; - int32_t sound; - uint16_t unit_id; - } SoundJob; - - typedef struct { - ResourceID id; - JOB_TYPE type; - uint32_t volume_1; - uint32_t volume_2; - int32_t loop_count; - int16_t grid_x; - int16_t grid_y; - int16_t priority; - uint32_t time_stamp; - uint32_t loop_point_start; - int32_t loop_point_length; - - int32_t mixer_channel; - Mix_Chunk* chunk; - Mix_Music* music; - } SoundSample; - - bool is_audio_enabled; - - SoundVolume* volumes; - - ResourceID current_music_played; - ResourceID last_music_played; - - bool shuffle_music; - bool shuffle_music_playlist[BKG9_MSC - MAIN_MSC + 1]; - - ResourceID voice_played; - - std::list jobs; - - std::list samples; - int32_t mixer_channels_count; - SoundSample* music; - SoundSample* voice; - SoundSample* sfx; - - void AddJob(SoundJob& job); - int32_t ProcessJob(SoundJob& job); - void FreeSample(SoundSample* sample); - void UpdateMusic(); - void FreeSfx(UnitInfo* unit); - void FreeVoice(ResourceID id1, ResourceID id2); - bool IsVoiceGroupScheduled(ResourceID id1, ResourceID id2); - static int32_t GetPanning(int32_t distance, bool reverse); - bool LoadMusic(ResourceID id); - int32_t LoadSound(SoundJob& job, SoundSample& sample); - void LoadLoopPoints(FILE* fp, SoundSample& sample); -}; - -extern CSoundManager SoundManager; +void SoundManager_Init() noexcept; +void SoundManager_Deinit() noexcept; +void SoundManager_PlayMusic(const ResourceID id, const bool shuffle) noexcept; +void SoundManager_HaltMusicPlayback(const bool disable) noexcept; +void SoundManager_FreeMusic() noexcept; +void SoundManager_PlaySfx(const ResourceID id) noexcept; +void SoundManager_PlaySfx(UnitInfo* const unit, const int32_t sound, const bool mode = false) noexcept; +void SoundManager_UpdateSfxPosition() noexcept; +void SoundManager_UpdateSfxPosition(UnitInfo* const unit) noexcept; +void SoundManager_UpdateAllSfxPositions() noexcept; +void SoundManager_HaltSfxPlayback(const bool disable) noexcept; +void SoundManager_PlayVoice(const ResourceID id1, const ResourceID id2, const int16_t priority = 0) noexcept; +void SoundManager_HaltVoicePlayback(const bool disable) noexcept; +void SoundManager_FreeAllSamples() noexcept; +void SoundManager_SetVolume(const int32_t type, const int32_t volume) noexcept; #endif /* SOUND_MANAGER_HPP */ diff --git a/src/text.cpp b/src/text.cpp index 9cf8aac7..fedf511d 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -831,7 +831,7 @@ void Text_TypeWriter_TextBox(WindowInfo* window, const char* text, int32_t ulx, time_stamp = timer_get(); if (Text_TypeWriter_CharacterTimeMs > 0) { - SoundManager.PlaySfx(MBUTT0); + SoundManager_PlaySfx(MBUTT0); } while (text[text_position] && width > 0) { @@ -856,7 +856,7 @@ void Text_TypeWriter_TextBox(WindowInfo* window, const char* text, int32_t ulx, if (Text_TypeWriter_CharacterTimeMs > 0) { if (timer_elapsed_time(time_stamp) >= Text_TypeWriter_BeepTimeMs) { - SoundManager.PlaySfx(MBUTT0); + SoundManager_PlaySfx(MBUTT0); time_stamp = timer_get(); } diff --git a/src/unitinfo.cpp b/src/unitinfo.cpp index 6996f7c7..cb5af60e 100644 --- a/src/unitinfo.cpp +++ b/src/unitinfo.cpp @@ -2215,7 +2215,7 @@ void UnitInfo::Build() { SetParent(nullptr); ClearBuildListAndPath(); - SoundManager.PlaySfx(this, SFX_TYPE_IDLE); + SoundManager_PlaySfx(this, SFX_TYPE_IDLE); } } else { @@ -2250,11 +2250,11 @@ void UnitInfo::Move() { if (GameManager_SelectedUnit == this) { if (speed > 0 && !path->IsEndStep()) { if (sound != SFX_TYPE_DRIVE && sound != SFX_TYPE_STOP) { - SoundManager.PlaySfx(this, SFX_TYPE_DRIVE); + SoundManager_PlaySfx(this, SFX_TYPE_DRIVE); } } else { - SoundManager.PlaySfx(this, SFX_TYPE_STOP); + SoundManager_PlaySfx(this, SFX_TYPE_STOP); } } @@ -2349,7 +2349,7 @@ void UnitInfo::Move() { } if (GameManager_SelectedUnit == this) { - SoundManager.UpdateSfxPosition(this); + SoundManager_UpdateSfxPosition(this); } Ai_MarkMineMapPoint(Point(grid_x, grid_y), team); @@ -3102,10 +3102,10 @@ void UnitInfo::Attack(int32_t grid_x, int32_t grid_y) { UnitsManager_DeployUnit(HITEXPLD, team, nullptr, grid_x, grid_y, 0, true); if (Access_GetModifiedSurfaceType(grid_x, grid_y) == SURFACE_TYPE_LAND) { - SoundManager.PlaySfx(&*explosion, SFX_TYPE_HIT); + SoundManager_PlaySfx(&*explosion, SFX_TYPE_HIT); } else { - SoundManager.PlaySfx(&*explosion, SFX_TYPE_EXPLOAD); + SoundManager_PlaySfx(&*explosion, SFX_TYPE_EXPLOAD); } } } @@ -3158,7 +3158,7 @@ void UnitInfo::StartBuilding() { if (GameManager_SelectedUnit == this) { GameManager_UpdateInfoDisplay(&*GameManager_SelectedUnit); - SoundManager.PlaySfx(this, SFX_TYPE_POWER_CONSUMPTION_START); + SoundManager_PlaySfx(this, SFX_TYPE_POWER_CONSUMPTION_START); } } else { @@ -3221,7 +3221,7 @@ void UnitInfo::SpotByTeam(uint16_t team) { RadarPing(); } else if (unit_type == SUBMARNE && this->team == GameManager_PlayerTeam) { - SoundManager.PlayVoice(V_M201, V_F201); + SoundManager_PlayVoice(V_M201, V_F201); } } } @@ -3311,7 +3311,7 @@ void UnitInfo::UpdateProduction() { team_units->SetGold(Cargo_GetGoldConsumptionRate(unit_type) + gold_reserves); if (!gold_reserves && GameManager_PlayerTeam == team && team_units->GetGold() > 0) { - SoundManager.PlayVoice(V_M276, V_F276); + SoundManager_PlayVoice(V_M276, V_F276); } } @@ -3320,7 +3320,7 @@ void UnitInfo::UpdateProduction() { ++UnitsManager_TeamInfo[team].team_points; if (GameManager_PlayerTeam != team && UnitsManager_TeamInfo[team].team_points == 1) { - SoundManager.PlayVoice(static_cast(V_M098 + team * 2), + SoundManager_PlayVoice(static_cast(V_M098 + team * 2), static_cast(V_M098 + team * 2 + 1)); } } @@ -3330,7 +3330,7 @@ void UnitInfo::UpdateProduction() { shots = ammo; if (GameManager_SelectedUnit == this && GameManager_PlayerTeam == team) { - SoundManager.PlayVoice(V_M270, V_F271); + SoundManager_PlayVoice(V_M270, V_F271); } } else { @@ -3808,7 +3808,7 @@ void UnitInfo::SpawnNewUnit() { SetParent(nullptr); if (GameManager_SelectedUnit == this) { - SoundManager.PlaySfx(this, SFX_TYPE_IDLE); + SoundManager_PlaySfx(this, SFX_TYPE_IDLE); } } else { @@ -3844,7 +3844,7 @@ void UnitInfo::SpawnNewUnit() { } else { if (GameManager_SelectedUnit == this) { - SoundManager.PlaySfx(this, SFX_TYPE_IDLE); + SoundManager_PlaySfx(this, SFX_TYPE_IDLE); } new_unit = Access_GetUnit7(team, position_x, position_y); @@ -3953,7 +3953,7 @@ void UnitInfo::MoveFinished(bool mode) { if (GameManager_SelectedUnit == this) { GameManager_UpdateInfoDisplay(this); GameManager_AutoSelectNext(this); - SoundManager.PlaySfx(this, SFX_TYPE_IDLE); + SoundManager_PlaySfx(this, SFX_TYPE_IDLE); } velocity = 0; @@ -3998,7 +3998,7 @@ void UnitInfo::MoveFinished(bool mode) { void UnitInfo::RadarPing() { if (orders != ORDER_BUILD && orders != ORDER_CLEAR && (!(flags & STATIONARY) || unit_type == LANDMINE || unit_type == SEAMINE) && (flags & SELECTABLE)) { - SoundManager.PlaySfx(RADRPING); + SoundManager_PlaySfx(RADRPING); GameManager_NotifyEvent(this, 0); } } @@ -4113,7 +4113,7 @@ bool UnitInfo::Land() { bool result; if (moved == 0 && GameManager_SelectedUnit == this) { - SoundManager.PlaySfx(this, SFX_TYPE_LAND); + SoundManager_PlaySfx(this, SFX_TYPE_LAND); } RefreshScreen(); @@ -4146,7 +4146,7 @@ bool UnitInfo::Take() { bool result; if (moved == 0 && GameManager_SelectedUnit == this) { - SoundManager.PlaySfx(this, SFX_TYPE_TAKE); + SoundManager_PlaySfx(this, SFX_TYPE_TAKE); } RefreshScreen(); @@ -4452,7 +4452,7 @@ void UnitInfo::CancelBuilding() { } if (GameManager_SelectedUnit == this) { - SoundManager.PlaySfx(this, SFX_TYPE_POWER_CONSUMPTION_END); + SoundManager_PlaySfx(this, SFX_TYPE_POWER_CONSUMPTION_END); GameManager_UpdateInfoDisplay(this); } @@ -4489,7 +4489,7 @@ void UnitInfo::CancelBuilding() { } if (GameManager_SelectedUnit == this) { - SoundManager.PlaySfx(this, SFX_TYPE_IDLE); + SoundManager_PlaySfx(this, SFX_TYPE_IDLE); } } } @@ -4536,7 +4536,7 @@ void UnitInfo::Reload(UnitInfo* parent) { if (need_action) { if (GameManager_SelectedUnit == this) { - SoundManager.PlaySfx(this, SFX_TYPE_POWER_CONSUMPTION_START, true); + SoundManager_PlaySfx(this, SFX_TYPE_POWER_CONSUMPTION_START, true); } parent->ammo = parent->GetBaseValues()->GetAttribute(ATTRIB_AMMO); @@ -4733,7 +4733,7 @@ void UnitInfo::PlaceMine() { if (GameManager_SelectedUnit == this) { GameManager_UpdateInfoDisplay(this); - SoundManager.PlaySfx(this, SFX_TYPE_POWER_CONSUMPTION_START, true); + SoundManager_PlaySfx(this, SFX_TYPE_POWER_CONSUMPTION_START, true); } } } @@ -4764,7 +4764,7 @@ void UnitInfo::PickUpMine() { if (GameManager_SelectedUnit == this) { GameManager_UpdateInfoDisplay(this); - SoundManager.PlaySfx(this, SFX_TYPE_POWER_CONSUMPTION_END, true); + SoundManager_PlaySfx(this, SFX_TYPE_POWER_CONSUMPTION_END, true); } } } @@ -4896,7 +4896,7 @@ void UnitInfo::PrepareFire() { if (team_visibility || UnitsManager_TeamInfo[GameManager_PlayerTeam] .heat_map_complete[target_grid_y * ResourceManager_MapSize.x + target_grid_x]) { - SoundManager.PlaySfx(this, SFX_TYPE_FIRE); + SoundManager_PlaySfx(this, SFX_TYPE_FIRE); } if (flags & HAS_FIRING_SPRITE) { diff --git a/src/units_manager.cpp b/src/units_manager.cpp index 1ce04c71..76f8320e 100644 --- a/src/units_manager.cpp +++ b/src/units_manager.cpp @@ -2081,7 +2081,7 @@ bool UnitsManager_SelfDestructActiveMenu(WindowInfo* window) { if (key == GNW_INPUT_PRESS + GNW_KB_KEY_RETURN) { button_destruct->PlaySound(); } else { - SoundManager.PlaySfx(NCANC0); + SoundManager_PlaySfx(NCANC0); } event_release = true; @@ -3687,7 +3687,7 @@ void UnitsManager_TestBustedCommando(UnitInfo* unit) { void UnitsManager_ScaleUnit(UnitInfo* unit, int32_t state) { if (GameManager_PlayerTeam == unit->team) { - SoundManager.PlaySfx(unit, state == ORDER_STATE_EXPAND ? SFX_TYPE_EXPAND : SFX_TYPE_SHRINK); + SoundManager_PlaySfx(unit, state == ORDER_STATE_EXPAND ? SFX_TYPE_EXPAND : SFX_TYPE_SHRINK); } UnitsManager_SetNewOrderInt(unit, ORDER_AWAIT_SCALING, state); @@ -4077,7 +4077,7 @@ void UnitsManager_DestroyUnit(UnitInfo* unit) { PathsManager_RemoveRequest(unit); if (unit_to_destroy == GameManager_SelectedUnit) { - SoundManager.PlaySfx(unit, SFX_TYPE_INVALID); + SoundManager_PlaySfx(unit, SFX_TYPE_INVALID); GameManager_SelectedUnit = nullptr; if (GameManager_IsMainMenuEnabled) { @@ -4312,7 +4312,7 @@ void UnitsManager_FinishUnitScaling(UnitInfo* unit) { } if (GameManager_SelectedUnit == unit) { - SoundManager.PlaySfx(unit, SFX_TYPE_INVALID); + SoundManager_PlaySfx(unit, SFX_TYPE_INVALID); GameManager_UpdateInfoDisplay(unit); GameManager_AutoSelectNext(unit); @@ -4572,7 +4572,7 @@ void UnitsManager_ProcessOrderFire(UnitInfo* unit) { unit->state = ORDER_STATE_IN_PROGRESS; if (GameManager_SelectedUnit == unit) { - SoundManager.PlaySfx(unit, SFX_TYPE_TURRET); + SoundManager_PlaySfx(unit, SFX_TYPE_TURRET); } UnitsManager_OrdersPending = true; @@ -4622,7 +4622,7 @@ void UnitsManager_ProcessOrderBuild(UnitInfo* unit) { } if (GameManager_SelectedUnit == unit) { - SoundManager.PlaySfx(unit, SFX_TYPE_BUILDING); + SoundManager_PlaySfx(unit, SFX_TYPE_BUILDING); } } break; @@ -4701,7 +4701,7 @@ void UnitsManager_ProcessOrderPowerOn(UnitInfo* unit) { Ai_SetTasksPendingFlag("Power up"); if (GameManager_SelectedUnit == unit) { - SoundManager.PlaySfx(unit, SFX_TYPE_POWER_CONSUMPTION_START); + SoundManager_PlaySfx(unit, SFX_TYPE_POWER_CONSUMPTION_START); } UnitsManager_PowerUpUnit(unit, -1); @@ -5315,7 +5315,7 @@ void UnitsManager_PowerDownUnit(UnitInfo* unit) { Ai_SetTasksPendingFlag("Power Down"); if (GameManager_SelectedUnit == unit) { - SoundManager.PlaySfx(unit, SFX_TYPE_POWER_CONSUMPTION_END); + SoundManager_PlaySfx(unit, SFX_TYPE_POWER_CONSUMPTION_END); } UnitsManager_PowerUpUnit(unit, 1); @@ -5845,14 +5845,14 @@ void UnitsManager_StartExplosion(UnitInfo* unit) { unit->RefreshScreen(); if (unit->hits > 0) { - SoundManager.PlaySfx(unit, SFX_TYPE_HIT); + SoundManager_PlaySfx(unit, SFX_TYPE_HIT); } else { if (GameManager_SelectedUnit == unit) { - SoundManager.PlaySfx(unit, SFX_TYPE_INVALID); + SoundManager_PlaySfx(unit, SFX_TYPE_INVALID); } - SoundManager.PlaySfx(unit, SFX_TYPE_EXPLOAD); + SoundManager_PlaySfx(unit, SFX_TYPE_EXPLOAD); } if ((unit->unit_type == COMMANDO || unit->unit_type == INFANTRY) && unit->hits == 0) { @@ -5957,7 +5957,7 @@ void UnitsManager_ProgressExplosion(UnitInfo* unit) { void UnitsManager_ProgressUnloading(UnitInfo* unit) { if (unit->Land()) { if (GameManager_SelectedUnit == unit) { - SoundManager.PlaySfx(unit, SFX_TYPE_POWER_CONSUMPTION_END, true); + SoundManager_PlaySfx(unit, SFX_TYPE_POWER_CONSUMPTION_END, true); } SmartPointer parent(unit->GetParent()); @@ -6021,7 +6021,7 @@ void UnitsManager_StartClearing(UnitInfo* unit) { unit->DrawSpriteFrame(unit->GetImageIndex() + 8); if (GameManager_SelectedUnit == unit) { - SoundManager.PlaySfx(unit, SFX_TYPE_BUILDING); + SoundManager_PlaySfx(unit, SFX_TYPE_BUILDING); } } @@ -6033,7 +6033,7 @@ void UnitsManager_ProgressLoading(UnitInfo* unit) { if (parent->hits > 0 && parent->orders != ORDER_FIRE && parent->orders != ORDER_EXPLODE && parent->state != ORDER_STATE_14) { if (GameManager_SelectedUnit == unit) { - SoundManager.PlaySfx(unit, SFX_TYPE_POWER_CONSUMPTION_START, true); + SoundManager_PlaySfx(unit, SFX_TYPE_POWER_CONSUMPTION_START, true); } parent->path = nullptr; @@ -6138,7 +6138,7 @@ void UnitsManager_Repair(UnitInfo* unit) { SmartPointer parent(unit->GetParent()); if (GameManager_SelectedUnit == unit) { - SoundManager.PlaySfx(unit, SFX_TYPE_POWER_CONSUMPTION_START, true); + SoundManager_PlaySfx(unit, SFX_TYPE_POWER_CONSUMPTION_START, true); } if (unit->GetComplex()) { @@ -6327,7 +6327,7 @@ bool UnitsManager_AttemptStealthAction(UnitInfo* unit) { MessageManager_DrawMessage(_(a939), 1, unit, Point(unit->grid_x, unit->grid_y)); } - SoundManager.PlayVoice(V_M007, V_F012); + SoundManager_PlayVoice(V_M007, V_F012); } UnitsManager_AddToDelayedReactionList(unit); @@ -6350,7 +6350,7 @@ void UnitsManager_CaptureUnit(UnitInfo* unit) { } else if (GameManager_PlayerTeam == old_team) { MessageManager_DrawMessage(_(8c00), 0, &*parent, Point(parent->grid_x, parent->grid_y)); - SoundManager.PlayVoice(V_M239, V_F242); + SoundManager_PlayVoice(V_M239, V_F242); } if (parent->orders == ORDER_BUILD || parent->orders == ORDER_CLEAR) { @@ -6404,7 +6404,7 @@ void UnitsManager_DisableUnit(UnitInfo* unit) { MessageManager_DrawMessage(message.GetCStr(), 0, &*parent, position); } - SoundManager.PlayVoice(V_M244, V_F244); + SoundManager_PlayVoice(V_M244, V_F244); } switch (parent->orders) { @@ -6654,7 +6654,7 @@ bool UnitsManager_CheckReaction(UnitInfo* unit1, UnitInfo* unit2) { if (GameManager_PlayerTeam == unit1->team && GameManager_SelectedUnit == unit1 && !GameManager_IsAtGridPosition(unit1)) { - SoundManager.PlayVoice(V_M250, V_F251); + SoundManager_PlayVoice(V_M250, V_F251); } result = true; @@ -6829,7 +6829,7 @@ bool UnitsManager_CheckDelayedReactions(uint16_t team) { if (GameManager_PlayerTeam == unit1->team && GameManager_SelectedUnit == unit1 && !GameManager_IsAtGridPosition(unit1)) { - SoundManager.PlayVoice(V_M250, V_F251); + SoundManager_PlayVoice(V_M250, V_F251); } if (GameManager_SelectedUnit == unit1) { diff --git a/src/unittypeselector.cpp b/src/unittypeselector.cpp index 860e9435..e162fb37 100644 --- a/src/unittypeselector.cpp +++ b/src/unittypeselector.cpp @@ -253,7 +253,7 @@ bool UnitTypeSelector::ProcessKeys(int32_t key_press) { void UnitTypeSelector::Select(uint8_t value) { EventUnitSelect event(this, value); - SoundManager.PlaySfx(KCARG0); + SoundManager_PlaySfx(KCARG0); window->EventHandler(&event); } diff --git a/src/upgradecontrol.cpp b/src/upgradecontrol.cpp index fe1699db..6e7f9705 100644 --- a/src/upgradecontrol.cpp +++ b/src/upgradecontrol.cpp @@ -122,7 +122,7 @@ void UpgradeControl::Init(int32_t id, int32_t team_base_value, int32_t control_b } void UpgradeControl::Increase() { - SoundManager.PlaySfx(KCARG0); + SoundManager_PlaySfx(KCARG0); if (id != UPGRADE_CONTROL_9) { *team_gold -= CalculateCost(); @@ -140,7 +140,7 @@ void UpgradeControl::Increase() { } void UpgradeControl::Decrease() { - SoundManager.PlaySfx(KCARG0); + SoundManager_PlaySfx(KCARG0); if (id == UPGRADE_CONTROL_9) { *team_gold -= CalculateCost();