Added the new "volume_mult" property for HUD sound call back. Removed all indoor framework related engine side code#338
Conversation
Removed all indoor sound's related engine side code, the project will move to Lua now.
|
Sorry for the long ass title lol |
78ab047 to
60dd34f
Compare
|
Known bug, |
|
By the looks of it should work fine. Maybe you can set the default value of volume multiplier to 1 instead of nil, that way you wouldn't need a nil check |
|
It still doesn't solve the problem of when the property is 0, |
…-monolith into all-in-one-vs2022-wpo
|
Ok I was wrong, it does return 0 but idk that in C++, not (a 0 float value) return true |
0b1751f to
04ac146
Compare
|
Apparently, a 0.f is the same as NULL, so there is no way afaik I can distinct them, I will just put a notice. God this driving me crazy. |
There was a problem hiding this comment.
Comparing floats with 0 directly is potentially erroneous/inaccurate due to how floats work in hardware.
X-Ray has a special function fis_zero to check if a float is zero and it's always better to use it.
0.f is the same as NULL
It is not, but luabind automatically converts nil to 0.f. It's possible to avoid that.
src/xrGame/HudSound.cpp
Outdated
| { | ||
| Msg("!_G.COnBeforePlayHudSound callback, HUD_SOUND_COLLECTION_LAYERED::PlaySound, failed to override sound item %s, no section specified", alias); | ||
| } | ||
| if (!volume_mult_ex) { |
There was a problem hiding this comment.
| if (!volume_mult_ex) { | |
| if (fis_zero(volume_mult_ex)) | |
| { |
src/xrGame/HudSound.cpp
Outdated
| { | ||
| Msg("!_G.COnBeforePlayHudSound callback, HUD_SOUND_COLLECTION_LAYERED::PlaySound, failed to override sound item %s, no line specified", alias); | ||
| } | ||
| if (!volume_mult_ex) { |
There was a problem hiding this comment.
| if (!volume_mult_ex) { | |
| if (fis_zero(volume_mult_ex)) | |
| { |
src/xrGame/WeaponMagazined.cpp
Outdated
| m_sounds.LoadSound(section, "snd_shoot_actor", "sndShotActor", false, m_eSoundShot); | ||
|
|
||
| //-Alundaio | ||
|
|
To detect if Lua's auto volume_mult_ex_obj = output["volume_mult"]; // receive Lua object
bool volume_mult_ex_is_nil = luabind::type(volume_mult_ex_obj) == LUA_TNIL; // the actual check for nil
float volume_mult_ex = ::luabind::object_cast<float>(volume_mult_ex_obj); // receive the actual value. nil will be converted to 0.f automaticallyThen, you can use |
08abb20 to
da8e2c6
Compare
|
let me know when its ready for review |
Test Fix Solved by Xottab_DUTY Co-Authored-By: Sultan Luchezarniy <Xottab-DUTY@users.noreply.github.com>
8731483 to
6f3006b
Compare
|
@themrdemonized ready for review, thanks |
|
I made a commit that simplifies the |
Added the new "volume_mult" property for HUD sound call back. Removed all indoor framework related engine side code
Add the new
volume_multforon_before_play_hud_soundcallback. You can use it to change the volume of any hud sound, with or without replacing the sound itself. (more info in thecallbacks_gameobject.script)Example:
Or:
Also removed all indoor framework related engine side code become the project the move to Lua and rely on the callback.