Page MenuHomeWildfire Games

Fix compilation with --without-audio
ClosedPublic

Authored by nwtour on Mar 3 2021, 10:18 PM.

Details

Summary

Now 0ad not compile with option --without-audio

SoundGroup.cpp
../../../source/soundmanager/scripting/SoundGroup.cpp: In member function ‘float CSoundGroup::RadiansOffCenter(const CVector3D&, bool&, float&)’:
../../../source/soundmanager/scripting/SoundGroup.cpp:150:18: error: ‘MAX_ROLLOFF’ was not declared in this scope
    itemRollOff = MAX_ROLLOFF;
                  ^~~~~~~~~~~
../../../source/soundmanager/scripting/SoundGroup.cpp:165:17: error: ‘MAX_ROLLOFF’ was not declared in this scope
   itemRollOff = MAX_ROLLOFF;

Issue emerged in https://code.wildfiregames.com/D3108

RadiansOffCenter used only in SoundGroup.cpp and this method now work only with OpenAL (MAX_ROLLOFF its ALfloat from OpenAL).
Patch moved RadiansOffCenter in private and #if CONFIG2_AUDIO sections

Test Plan

.

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

nwtour requested review of this revision.Mar 3 2021, 10:18 PM
nwtour created this revision.
wraitii added a subscriber: wraitii.EditedMar 4 2021, 1:54 PM

Thanks or noticing.
I think it'd be better if you followed the usual conversion, which is doing something like

void someFunc()
{
#if !CONFIG2_AUDIO
UNUSED2(argument)...
#else
[regular function body]
#end
}

That way you wouldn't have to change the header

Stan added a subscriber: Stan.Mar 4 2021, 2:02 PM

One could also wrap the constants in a macro?

nwtour added a comment.Mar 4 2021, 4:42 PM

I think it'd be better if you followed the usual conversion, which is doing something like

void someFunc()

Yes. It's a good idea. But CSoundGroup::RadiansOffCenter return float.
I have no idea as make dummy method with return statement

Yes. It's a good idea. But CSoundGroup::RadiansOffCenter return float.
I have no idea as make dummy method with return statement

just return 0.f, I think it's acceptable given that's a 'sane' value to return even if it were called by mistake.

nwtour added a comment.Mar 4 2021, 5:52 PM

just return 0.f, I think it's acceptable given that's a 'sane' value to return even if it were called by mistake.

Okay, changed. Only this is your idea, I would not do such strange things ;-)

nwtour added a comment.Mar 4 2021, 6:15 PM
In D3631#158768, @Stan wrote:

One could also wrap the constants in a macro?

IMHO It doesn't fit the principle KISS (kiss keep it simple, stupid).
While RadiansOffCenter() is used only internally CSoundGroup , it is not worth complicating logic

Stan added a comment.Mar 4 2021, 6:29 PM

Fair enough, looks good to me.

wraitii accepted this revision.Mar 4 2021, 6:34 PM

I think removing the audio is either intended:

  • as a stop-gap for system with bad compilations issues / no openAL
  • for dedicated servers (which don't exist yet)

In both cases audio is unlikely to be used, so this looks fine to me.

This revision is now accepted and ready to land.Mar 4 2021, 6:34 PM
This revision was automatically updated to reflect the committed changes.