Files
mcpe/source/client/sound/SoundEngine.cpp
Brent a0f71c7b27 C++03 Support & Partial Xbox 360 Support (#37)
* WIP C++03 + Xbox 360 Support

* math.h & _USE_MATH_DEFINES on Level.hpp
Updated Xenon vcxproj file for new file structure.

* * Fix bad GUI scale setup.

* * Gui: Use ratios instead of hardcoded sub-1 floating point values, to make the mechanism more clear.

* Add Direct Connect Button and Screen (#30)

* Add Direct Connect Button and Screen

* Remove accidental extra build directories for wasm

* Add DirectConnectScreen.cpp to the CMake

* Use Hungarian coding style notation

* * Fix errors caused by #30

* * Improve the Chat Screen

* * Improve the DirectConnectScreen, among other things.

* * Update the game title once again.

* * Add build-wasm.bat.

* * Add info about compiling for wasm

* * Fix send to specific GUID actually broadcasting to everyone

* * Add command manager.

* * Add writeable configuration.

* * Allow dynamic screen size change on windows

* * Allow the same thing on the emscripten version.

* WIP C++03 + Xbox 360 Support

* Fixed a possible merging issue that broke RakNet?

* Additional Xbox 360 compatability fixes

---------

Co-authored-by: Brent Da Mage <BrentDaMage@users.noreply.github.com>
Co-authored-by: iProgramInCpp <iprogramincpp@gmail.com>
Co-authored-by: ts <124226059+uniformization@users.noreply.github.com>
2023-08-07 15:48:52 +03:00

92 lines
2.3 KiB
C++

/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
#include "SoundEngine.hpp"
#include "SoundDefs.hpp"
SoundEngine::SoundEngine()
{
field_40 = 0;
field_A1C = 0;
#ifndef ORIGINAL_CODE
m_pOptions = nullptr;
field_A20 = 0;
#endif
}
void SoundEngine::init(Options* options)
{
m_pOptions = options;
m_repository.add("step.cloth", SA_cloth1);
m_repository.add("step.cloth", SA_cloth2);
m_repository.add("step.cloth", SA_cloth3);
m_repository.add("step.cloth", SA_cloth4);
m_repository.add("step.grass", SA_grass1);
m_repository.add("step.grass", SA_grass2);
m_repository.add("step.grass", SA_grass3);
m_repository.add("step.grass", SA_grass4);
m_repository.add("step.gravel", SA_gravel1);
m_repository.add("step.gravel", SA_gravel2);
m_repository.add("step.gravel", SA_gravel3);
m_repository.add("step.gravel", SA_gravel4);
m_repository.add("step.sand", SA_sand1);
m_repository.add("step.sand", SA_sand2);
m_repository.add("step.sand", SA_sand3);
m_repository.add("step.sand", SA_sand4);
m_repository.add("step.stone", SA_stone1);
m_repository.add("step.stone", SA_stone2);
m_repository.add("step.stone", SA_stone3);
m_repository.add("step.stone", SA_stone4);
m_repository.add("step.wood", SA_wood1);
m_repository.add("step.wood", SA_wood2);
m_repository.add("step.wood", SA_wood3);
m_repository.add("step.wood", SA_wood4);
m_repository.add("random.splash", SA_splash);
m_repository.add("random.explode", SA_explode);
m_repository.add("random.click", SA_click);
}
void SoundEngine::play(const std::string& name)
{
if (m_pOptions->field_4 == 0.0f)
return;
SoundDesc sd;
if (m_repository.get(name, sd)) {
#ifdef USE_SDL
m_soundSystem.play(sd, 0, 0, 0, 1, 1, true);
#else
m_soundSystem.playAt(sd, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f);
#endif
}
}
void SoundEngine::play(const std::string& name, float a, float b, float c, float d, float e)
{
if (m_pOptions->field_4 == 0.0f || d <= 0.0f)
return;
SoundDesc sd;
if (m_repository.get(name, sd)) {
#ifdef USE_SDL
m_soundSystem.play(sd, a, b, c, d, e, false);
#else
m_soundSystem.playAt(sd, a, b, c, d, e);
#endif
}
}