mirror of
https://github.com/libretro/devilutionX.git
synced 2026-11-10 17:20:56 -10:00
Fixes big-endian tests, which currently build with `-DNOSOUND` to reduce build time.
28 lines
609 B
C++
28 lines
609 B
C++
#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
|