mirror of
https://github.com/diasurgical/DevilutionX.git
synced 2026-10-12 02:13:06 +00:00
Use real CalculateSoundPosition with NOSOUND
Fixes big-endian tests, which currently build with `-DNOSOUND` to reduce build time.
This commit is contained in:
@@ -106,6 +106,7 @@ set(libdevilutionx_SRCS
|
||||
engine/palette.cpp
|
||||
engine/path.cpp
|
||||
engine/random.cpp
|
||||
engine/sound_position.cpp
|
||||
engine/surface.cpp
|
||||
engine/trn.cpp
|
||||
|
||||
|
||||
+1
-19
@@ -8,6 +8,7 @@
|
||||
#include "engine/random.hpp"
|
||||
#include "engine/sound.h"
|
||||
#include "engine/sound_defs.hpp"
|
||||
#include "engine/sound_position.hpp"
|
||||
#include "init.h"
|
||||
#include "player.h"
|
||||
#include "utils/stdcompat/algorithm.hpp"
|
||||
@@ -1201,25 +1202,6 @@ void stream_stop()
|
||||
}
|
||||
}
|
||||
|
||||
bool CalculateSoundPosition(Point soundPosition, int *plVolume, int *plPan)
|
||||
{
|
||||
const auto &playerPosition = MyPlayer->position.tile;
|
||||
const auto delta = soundPosition - playerPosition;
|
||||
|
||||
int pan = (delta.deltaX - delta.deltaY) * 256;
|
||||
*plPan = clamp(pan, PAN_MIN, PAN_MAX);
|
||||
|
||||
int volume = playerPosition.ApproxDistance(soundPosition);
|
||||
volume *= -64;
|
||||
|
||||
if (volume <= ATTENUATION_MIN)
|
||||
return false;
|
||||
|
||||
*plVolume = volume;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PlaySFX(_sfx_id psfx)
|
||||
{
|
||||
psfx = RndSFX(psfx);
|
||||
|
||||
@@ -1177,7 +1177,6 @@ extern _sfx_id sfxdnum;
|
||||
|
||||
bool effect_is_playing(int nSFX);
|
||||
void stream_stop();
|
||||
bool CalculateSoundPosition(Point soundPosition, int *plVolume, int *plPan);
|
||||
void PlaySFX(_sfx_id psfx);
|
||||
void PlaySfxLoc(_sfx_id psfx, Point position, bool randomizeByCategory = true);
|
||||
void sound_stop();
|
||||
|
||||
@@ -12,7 +12,6 @@ _sfx_id sfxdnum;
|
||||
// clang-format off
|
||||
bool effect_is_playing(int nSFX) { return false; }
|
||||
void stream_stop() { }
|
||||
bool CalculateSoundPosition(Point soundPosition, int *plVolume, int *plPan) { return false; }
|
||||
void PlaySFX(_sfx_id psfx)
|
||||
{
|
||||
switch (psfx) {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#include "engine/sound_position.hpp"
|
||||
|
||||
#include "engine/sound_defs.hpp"
|
||||
#include "player.h"
|
||||
|
||||
namespace devilution {
|
||||
|
||||
bool CalculateSoundPosition(Point soundPosition, int *plVolume, int *plPan)
|
||||
{
|
||||
const auto &playerPosition = MyPlayer->position.tile;
|
||||
const auto delta = soundPosition - playerPosition;
|
||||
|
||||
int pan = (delta.deltaX - delta.deltaY) * 256;
|
||||
*plPan = clamp(pan, PAN_MIN, PAN_MAX);
|
||||
|
||||
int volume = playerPosition.ApproxDistance(soundPosition);
|
||||
volume *= -64;
|
||||
|
||||
if (volume <= ATTENUATION_MIN)
|
||||
return false;
|
||||
|
||||
*plVolume = volume;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace devilution
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "engine/point.hpp"
|
||||
|
||||
namespace devilution {
|
||||
|
||||
bool CalculateSoundPosition(Point soundPosition, int *plVolume, int *plPan);
|
||||
|
||||
} // namespace devilution
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "engine/points_in_rectangle_range.hpp"
|
||||
#include "engine/random.hpp"
|
||||
#include "engine/render/clx_render.hpp"
|
||||
#include "engine/sound_position.hpp"
|
||||
#include "engine/world_tile.hpp"
|
||||
#include "init.h"
|
||||
#include "levels/crypt.h"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "effects.h"
|
||||
#include "engine/sound_position.hpp"
|
||||
#include "player.h"
|
||||
|
||||
using namespace devilution;
|
||||
|
||||
Reference in New Issue
Block a user