mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-01-13 23:37:58 +03:00
Fixed warnings about conversions between soundlevel_t and float
This replaces the macros ATTN_TO_SNDLVL and SNDLVL_TO_ATTN with inline functions that properly handle conversions between float and soundlevel_t. Eliminates a large number of warnings when compiling with GCC.
This commit is contained in:
parent
f4c2cb4795
commit
2fe3adfe6e
@ -102,8 +102,22 @@ enum soundlevel_t
|
|||||||
#define MAX_SNDLVL_VALUE ((1<<MAX_SNDLVL_BITS)-1)
|
#define MAX_SNDLVL_VALUE ((1<<MAX_SNDLVL_BITS)-1)
|
||||||
|
|
||||||
|
|
||||||
#define ATTN_TO_SNDLVL( a ) (soundlevel_t)(int)((a) ? (50 + 20 / ((float)a)) : 0 )
|
inline soundlevel_t ATTN_TO_SNDLVL(float a)
|
||||||
#define SNDLVL_TO_ATTN( a ) ((a > 50) ? (20.0f / (float)(a - 50)) : 4.0 )
|
{
|
||||||
|
soundlevel_t sndlvl = soundlevel_t::SNDLVL_NONE;
|
||||||
|
|
||||||
|
if (a >= 0.0f)
|
||||||
|
{
|
||||||
|
sndlvl = soundlevel_t(float(soundlevel_t::SNDLVL_50dB) + float(soundlevel_t::SNDLVL_20dB) / a);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sndlvl;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float SNDLVL_TO_ATTN(soundlevel_t s)
|
||||||
|
{
|
||||||
|
return (s > soundlevel_t::SNDLVL_50dB)? (20.0f / float(s - soundlevel_t::SNDLVL_50dB)) : 4.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// This is a limit due to network encoding.
|
// This is a limit due to network encoding.
|
||||||
// It encodes attenuation * 64 in 8 bits, so the maximum is (255 / 64)
|
// It encodes attenuation * 64 in 8 bits, so the maximum is (255 / 64)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user