diff --git a/targets/app/common/Audio/Consoles_SoundEngine.cpp b/targets/app/common/Audio/Consoles_SoundEngine.cpp deleted file mode 100644 index 57d54565b..000000000 --- a/targets/app/common/Audio/Consoles_SoundEngine.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "Consoles_SoundEngine.h" - -bool ConsoleSoundEngine::GetIsPlayingStreamingCDMusic() { - return m_bIsPlayingStreamingCDMusic; -} -bool ConsoleSoundEngine::GetIsPlayingStreamingGameMusic() { - return m_bIsPlayingStreamingGameMusic; -} -void ConsoleSoundEngine::SetIsPlayingStreamingCDMusic(bool bVal) { - m_bIsPlayingStreamingCDMusic = bVal; -} -void ConsoleSoundEngine::SetIsPlayingStreamingGameMusic(bool bVal) { - m_bIsPlayingStreamingGameMusic = bVal; -} -bool ConsoleSoundEngine::GetIsPlayingEndMusic() { return m_bIsPlayingEndMusic; } -bool ConsoleSoundEngine::GetIsPlayingNetherMusic() { - return m_bIsPlayingNetherMusic; -} -void ConsoleSoundEngine::SetIsPlayingEndMusic(bool bVal) { - m_bIsPlayingEndMusic = bVal; -} -void ConsoleSoundEngine::SetIsPlayingNetherMusic(bool bVal) { - m_bIsPlayingNetherMusic = bVal; -} diff --git a/targets/app/common/Audio/SoundEngine.cpp b/targets/app/common/Audio/SoundEngine.cpp index 76abaccbe..5883cb5ac 100644 --- a/targets/app/common/Audio/SoundEngine.cpp +++ b/targets/app/common/Audio/SoundEngine.cpp @@ -10,7 +10,7 @@ #include #include -#include "app/common/Audio/Consoles_SoundEngine.h" +#include "minecraft/sounds/ConsoleSoundEngine.h" #include "app/linux/Iggy/include/rrCore.h" #include "app/linux/LinuxGame.h" #include "java/Random.h" @@ -1938,40 +1938,3 @@ char* SoundEngine::ConvertSoundPathToName(const std::string& name, return nullptr; } -void ConsoleSoundEngine::tick() { - if (scheduledSounds.empty()) { - return; - } - - for (auto it = scheduledSounds.begin(); it != scheduledSounds.end();) { - SoundEngine::ScheduledSound* next = *it; - next->delay--; - - if (next->delay <= 0) { - play(next->iSound, next->x, next->y, next->z, next->volume, - next->pitch); - it = scheduledSounds.erase(it); - delete next; - } else { - ++it; - } - } -} - -void ConsoleSoundEngine::schedule(int iSound, float x, float y, float z, - float volume, float pitch, int delayTicks) { - scheduledSounds.push_back(new SoundEngine::ScheduledSound( - iSound, x, y, z, volume, pitch, delayTicks)); -} - -ConsoleSoundEngine::ScheduledSound::ScheduledSound(int iSound, float x, float y, - float z, float volume, - float pitch, int delay) { - this->iSound = iSound; - this->x = x; - this->y = y; - this->z = z; - this->volume = volume; - this->pitch = pitch; - this->delay = delay; -} diff --git a/targets/app/common/Audio/SoundEngine.h b/targets/app/common/Audio/SoundEngine.h index f4e604b39..99b5a707d 100644 --- a/targets/app/common/Audio/SoundEngine.h +++ b/targets/app/common/Audio/SoundEngine.h @@ -7,7 +7,7 @@ class Random; #include #include -#include "app/common/Audio/Consoles_SoundEngine.h" +#include "minecraft/sounds/ConsoleSoundEngine.h" #include "app/linux/Iggy/include/rrCore.h" #include "minecraft/sounds/SoundTypes.h" #include "platform/PlatformTypes.h" diff --git a/targets/app/common/Audio/SoundNames.cpp b/targets/app/common/Audio/SoundNames.cpp index dd44c7f52..8d390cb72 100644 --- a/targets/app/common/Audio/SoundNames.cpp +++ b/targets/app/common/Audio/SoundNames.cpp @@ -1,4 +1,4 @@ -#include "Consoles_SoundEngine.h" +#include "minecraft/sounds/ConsoleSoundEngine.h" #include "minecraft/sounds/SoundTypes.h" const char* ConsoleSoundEngine::wchSoundNames[eSoundType_MAX] = { diff --git a/targets/app/common/Game.h b/targets/app/common/Game.h index 0a1cca1b7..557a6d7a8 100644 --- a/targets/app/common/Game.h +++ b/targets/app/common/Game.h @@ -11,7 +11,7 @@ #include "app/common/App_structs.h" #include "app/common/ArchiveManager.h" -#include "app/common/Audio/Consoles_SoundEngine.h" +#include "minecraft/sounds/ConsoleSoundEngine.h" #include "app/common/BannedListManager.h" #include "app/common/DLC/DLCManager.h" #include "app/common/DLCController.h" diff --git a/targets/app/common/Game_XuiActions.cpp b/targets/app/common/Game_XuiActions.cpp index 0616a5d7b..dde40f3ce 100644 --- a/targets/app/common/Game_XuiActions.cpp +++ b/targets/app/common/Game_XuiActions.cpp @@ -993,10 +993,13 @@ void Game::HandleXuiActions(void) { // need to stop the streaming audio - by playing // streaming audio from the default texture pack now // reset the streaming sounds back to the normal ones - pMinecraft->soundEngine->SetStreamingSounds( - eStream_Overworld_Calm1, eStream_Overworld_piano3, - eStream_Nether1, eStream_Nether4, - eStream_end_dragon, eStream_end_end, eStream_CD_1); + static_cast(pMinecraft->soundEngine) + ->SetStreamingSounds(eStream_Overworld_Calm1, + eStream_Overworld_piano3, + eStream_Nether1, + eStream_Nether4, + eStream_end_dragon, + eStream_end_end, eStream_CD_1); pMinecraft->soundEngine->playStreaming("", 0, 0, 0, 1, 1); diff --git a/targets/app/common/UI/UIController.cpp b/targets/app/common/UI/UIController.cpp index 8655de601..f4a1e559e 100644 --- a/targets/app/common/UI/UIController.cpp +++ b/targets/app/common/UI/UIController.cpp @@ -1354,9 +1354,11 @@ void UIController::NavigateToHomeMenu() { // need to stop the streaming audio - by playing streaming audio from // the default texture pack now reset the streaming sounds back to the // normal ones - pMinecraft->soundEngine->SetStreamingSounds( - eStream_Overworld_Calm1, eStream_Overworld_piano3, eStream_Nether1, - eStream_Nether4, eStream_end_dragon, eStream_end_end, eStream_CD_1); + static_cast(pMinecraft->soundEngine) + ->SetStreamingSounds(eStream_Overworld_Calm1, + eStream_Overworld_piano3, eStream_Nether1, + eStream_Nether4, eStream_end_dragon, + eStream_end_end, eStream_CD_1); pMinecraft->soundEngine->playStreaming("", 0, 0, 0, 1, 1); // if(pDLCTexPack->m_pStreamedWaveBank!=nullptr) diff --git a/targets/app/common_sources.txt b/targets/app/common_sources.txt index cab1ba816..b2f71748c 100644 --- a/targets/app/common_sources.txt +++ b/targets/app/common_sources.txt @@ -1,6 +1,5 @@ common/AppGameServices.cpp common/ArchiveManager.cpp -common/Audio/Consoles_SoundEngine.cpp common/Audio/SoundEngine.cpp common/Audio/SoundNames.cpp common/BannedListManager.cpp diff --git a/targets/app/linux/Linux_UIController.cpp b/targets/app/linux/Linux_UIController.cpp index 642b672be..8d1871446 100644 --- a/targets/app/linux/Linux_UIController.cpp +++ b/targets/app/linux/Linux_UIController.cpp @@ -2,6 +2,7 @@ // GDraw GL backend for Linux #include "platform/renderer/renderer.h" +#include "renderer/gl/gl_compat.h" #include "Linux_UIController.h" #include "app/common/UI/All Platforms/UIStructs.h" #include "app/linux/Iggy/gdraw/gdraw.h" diff --git a/targets/minecraft/client/Minecraft.h b/targets/minecraft/client/Minecraft.h index f728e66a0..0d4b83764 100644 --- a/targets/minecraft/client/Minecraft.h +++ b/targets/minecraft/client/Minecraft.h @@ -31,7 +31,7 @@ class BackgroundDownloader; class HumanoidModel; class HitResult; class Options; -class SoundEngine; +class ConsoleSoundEngine; class IPlatformLeaderboard; class MinecraftApplet; class MouseHandler; @@ -191,7 +191,7 @@ protected: MinecraftApplet* minecraftApplet; public: - SoundEngine* soundEngine; + ConsoleSoundEngine* soundEngine; MouseHandler* mouseHandler; public: diff --git a/targets/minecraft/client/Options.cpp b/targets/minecraft/client/Options.cpp index c0fd1f95a..e585fb3f2 100644 --- a/targets/minecraft/client/Options.cpp +++ b/targets/minecraft/client/Options.cpp @@ -1,7 +1,7 @@ #include "Options.h" #include "KeyMapping.h" -#include "app/common/Audio/SoundEngine.h" +#include "minecraft/sounds/ConsoleSoundEngine.h" #include "java/File.h" #include "java/InputOutputStream/BufferedReader.h" #include "java/InputOutputStream/DataOutputStream.h" diff --git a/targets/minecraft/client/gui/Screen.cpp b/targets/minecraft/client/gui/Screen.cpp index 86e51b9f1..1fb75ec16 100644 --- a/targets/minecraft/client/gui/Screen.cpp +++ b/targets/minecraft/client/gui/Screen.cpp @@ -1,7 +1,7 @@ #include "Screen.h" #include "Button.h" -#include "app/common/Audio/SoundEngine.h" +#include "minecraft/sounds/ConsoleSoundEngine.h" #include "minecraft/GameEnums.h" #include "minecraft/IGameServices.h" #include "minecraft/client/Minecraft.h" diff --git a/targets/minecraft/client/gui/achievement/StatsScreen.cpp b/targets/minecraft/client/gui/achievement/StatsScreen.cpp index 512450ca1..2426fb71e 100644 --- a/targets/minecraft/client/gui/achievement/StatsScreen.cpp +++ b/targets/minecraft/client/gui/achievement/StatsScreen.cpp @@ -1,5 +1,5 @@ #include "StatsScreen.h" -#include "app/common/Audio/SoundEngine.h" +#include "minecraft/sounds/ConsoleSoundEngine.h" #include "minecraft/client/Minecraft.h" #include "minecraft/client/gui/Button.h" #include "minecraft/client/gui/Font.h" diff --git a/targets/minecraft/client/multiplayer/MultiPlayerGameMode.cpp b/targets/minecraft/client/multiplayer/MultiPlayerGameMode.cpp index 054300597..777df3e5c 100644 --- a/targets/minecraft/client/multiplayer/MultiPlayerGameMode.cpp +++ b/targets/minecraft/client/multiplayer/MultiPlayerGameMode.cpp @@ -4,7 +4,7 @@ #include "ClientConnection.h" #include "MultiPlayerLevel.h" -#include "app/common/Audio/SoundEngine.h" +#include "minecraft/sounds/ConsoleSoundEngine.h" #include "java/Class.h" #include "minecraft/IGameServices.h" #include "minecraft/client/Minecraft.h" diff --git a/targets/minecraft/client/multiplayer/MultiPlayerLevel.cpp b/targets/minecraft/client/multiplayer/MultiPlayerLevel.cpp index b5c9c5e38..3285549e6 100644 --- a/targets/minecraft/client/multiplayer/MultiPlayerLevel.cpp +++ b/targets/minecraft/client/multiplayer/MultiPlayerLevel.cpp @@ -12,7 +12,7 @@ #include "ClientConnection.h" #include "MultiPlayerChunkCache.h" #include "MultiPlayerLocalPlayer.h" -#include "app/common/Audio/SoundEngine.h" +#include "minecraft/sounds/ConsoleSoundEngine.h" #include "java/JavaMath.h" #include "java/Random.h" #include "minecraft/Console_Debug_enum.h" diff --git a/targets/minecraft/client/player/LocalPlayer.cpp b/targets/minecraft/client/player/LocalPlayer.cpp index f24cf33af..506d38c0d 100644 --- a/targets/minecraft/client/player/LocalPlayer.cpp +++ b/targets/minecraft/client/player/LocalPlayer.cpp @@ -31,7 +31,7 @@ #include "PlatformTypes.h" #include "Pos.h" #include "app/common/App_structs.h" -#include "app/common/Audio/SoundEngine.h" +#include "minecraft/sounds/ConsoleSoundEngine.h" #include "app/common/Tutorial/Tutorial.h" #include "app/common/Tutorial/TutorialMode.h" #include "app/linux/Linux_UIController.h" diff --git a/targets/minecraft/client/renderer/LevelRenderer.cpp b/targets/minecraft/client/renderer/LevelRenderer.cpp index 4d80b0502..c9b638797 100644 --- a/targets/minecraft/client/renderer/LevelRenderer.cpp +++ b/targets/minecraft/client/renderer/LevelRenderer.cpp @@ -15,7 +15,7 @@ #include "Chunk.h" #include "GameRenderer.h" #include "Tesselator.h" -#include "app/common/Audio/SoundEngine.h" +#include "minecraft/sounds/ConsoleSoundEngine.h" #include "java/Class.h" #include "java/JavaMath.h" #include "java/Random.h" diff --git a/targets/minecraft/client/skins/DLCTexturePack.cpp b/targets/minecraft/client/skins/DLCTexturePack.cpp index 36449770b..9776bf8ec 100644 --- a/targets/minecraft/client/skins/DLCTexturePack.cpp +++ b/targets/minecraft/client/skins/DLCTexturePack.cpp @@ -409,11 +409,14 @@ int DLCTexturePack::onPackMounted(int iPad, std::uint32_t dwErr, iEndC = dlcFile->GetCountofType(DLCAudioFile::e_AudioType_End); - Minecraft::GetInstance()->soundEngine->SetStreamingSounds( - iOverworldStart, iOverworldStart + iOverworldC, - iNetherStart, iNetherStart + iNetherC, iEndStart, - iEndStart + iEndC, - iEndStart + iEndC); // push the CD start to after + static_cast( + Minecraft::GetInstance()->soundEngine) + ->SetStreamingSounds( + iOverworldStart, iOverworldStart + iOverworldC, + iNetherStart, iNetherStart + iNetherC, iEndStart, + iEndStart + iEndC, + iEndStart + + iEndC); // push the CD start to after } } texturePack->loadColourTable(); diff --git a/targets/minecraft/sounds/ConsoleSoundEngine.cpp b/targets/minecraft/sounds/ConsoleSoundEngine.cpp new file mode 100644 index 000000000..f8ffdd212 --- /dev/null +++ b/targets/minecraft/sounds/ConsoleSoundEngine.cpp @@ -0,0 +1,62 @@ +#include "minecraft/sounds/ConsoleSoundEngine.h" + +bool ConsoleSoundEngine::GetIsPlayingStreamingCDMusic() { + return m_bIsPlayingStreamingCDMusic; +} +bool ConsoleSoundEngine::GetIsPlayingStreamingGameMusic() { + return m_bIsPlayingStreamingGameMusic; +} +void ConsoleSoundEngine::SetIsPlayingStreamingCDMusic(bool bVal) { + m_bIsPlayingStreamingCDMusic = bVal; +} +void ConsoleSoundEngine::SetIsPlayingStreamingGameMusic(bool bVal) { + m_bIsPlayingStreamingGameMusic = bVal; +} +bool ConsoleSoundEngine::GetIsPlayingEndMusic() { return m_bIsPlayingEndMusic; } +bool ConsoleSoundEngine::GetIsPlayingNetherMusic() { + return m_bIsPlayingNetherMusic; +} +void ConsoleSoundEngine::SetIsPlayingEndMusic(bool bVal) { + m_bIsPlayingEndMusic = bVal; +} +void ConsoleSoundEngine::SetIsPlayingNetherMusic(bool bVal) { + m_bIsPlayingNetherMusic = bVal; +} + +void ConsoleSoundEngine::tick() { + if (scheduledSounds.empty()) { + return; + } + + for (auto it = scheduledSounds.begin(); it != scheduledSounds.end();) { + ConsoleSoundEngine::ScheduledSound* next = *it; + next->delay--; + + if (next->delay <= 0) { + play(next->iSound, next->x, next->y, next->z, next->volume, + next->pitch); + it = scheduledSounds.erase(it); + delete next; + } else { + ++it; + } + } +} + +void ConsoleSoundEngine::schedule(int iSound, float x, float y, float z, + float volume, float pitch, int delayTicks) { + scheduledSounds.push_back(new ConsoleSoundEngine::ScheduledSound( + iSound, x, y, z, volume, pitch, delayTicks)); +} + +ConsoleSoundEngine::ScheduledSound::ScheduledSound(int iSound, float x, float y, + float z, float volume, + float pitch, int delay) { + this->iSound = iSound; + this->x = x; + this->y = y; + this->z = z; + this->volume = volume; + this->pitch = pitch; + this->delay = delay; +} diff --git a/targets/app/common/Audio/Consoles_SoundEngine.h b/targets/minecraft/sounds/ConsoleSoundEngine.h similarity index 88% rename from targets/app/common/Audio/Consoles_SoundEngine.h rename to targets/minecraft/sounds/ConsoleSoundEngine.h index 9616dcfc2..d78639fa1 100644 --- a/targets/app/common/Audio/Consoles_SoundEngine.h +++ b/targets/minecraft/sounds/ConsoleSoundEngine.h @@ -21,6 +21,11 @@ typedef struct { class Options; class Mob; +// Game-side sound engine interface. The concrete backend +// (app/common/Audio/SoundEngine) inherits from this and forwards into +// IPlatformSound. minecraft/ consumers see only the abstract base, so +// they don't have to drag the concrete backend (and its miniaudio +// pimpl) into their compilation units. class ConsoleSoundEngine { public: ConsoleSoundEngine() @@ -29,6 +34,8 @@ public: m_bIsPlayingEndMusic(false), m_bIsPlayingNetherMusic(false) {} + virtual ~ConsoleSoundEngine() = default; + virtual void tick(std::shared_ptr* players, float a) = 0; virtual void destroy() = 0; virtual void play(int iSound, float x, float y, float z, float volume, diff --git a/targets/minecraft/sources.txt b/targets/minecraft/sources.txt index 75324ed89..a4f4996a2 100644 --- a/targets/minecraft/sources.txt +++ b/targets/minecraft/sources.txt @@ -395,6 +395,7 @@ server/level/TrackedEntity.cpp server/network/PendingConnection.cpp server/network/PlayerConnection.cpp server/network/ServerConnection.cpp +sounds/ConsoleSoundEngine.cpp stats/Achievement.cpp stats/Achievements.cpp stats/CommonStats.cpp