Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fixed incorrect reverse light sound updating over network #2692

Merged
merged 1 commit into from
Feb 25, 2021

Conversation

tritonas00
Copy link
Collaborator

Reported from discord:

there’s this bug with the reverse beep being triggered every frame when the remote vehicle engine is not running

@ohlidalp
Copy link
Member

ohlidalp commented Feb 19, 2021

this way, the sound will never play. Try this example program at http://cpp.sh/:

// Example program
#include <iostream>
#include <string>

int main()
{
    bool b0 = false;
    bool b1 = true;
    const int mask = 8; // NETMASK_REVERSE
    
    if (b0 & mask) std::cout << "b0 " << std::endl;
    if (b1 & mask) std::cout << "b1 " << std::endl;
    std::cout << "finished" << std::endl;

}

checking a bool variable against a bit mask is nonsense in general.

The right fix is to check if the sound already runs:

    if (m_net_reverse_light) {
     if (!SOUND_GET_STATE(ar_instance_id, SS_TRIG_REVERSE_GEAR)) { // not running yet?
        SOUND_START(ar_instance_id, SS_TRIG_REVERSE_GEAR); } }

@tritonas00
Copy link
Collaborator Author

tritonas00 commented Feb 20, 2021

tried it, i get the same sound when the engine is not running and reverse is on

does the reverse sound loop refresh rate takes account engine rpm or something?

or maybe we can send the sound only if engine is running

@tritonas00
Copy link
Collaborator Author

tritonas00 commented Feb 25, 2021

So in single player the reverse light sound plays only if engine is running.

Made it that way on MP also, so it fixes the issue now.

@ohlidalp ohlidalp self-requested a review February 25, 2021 14:00
Copy link
Member

@ohlidalp ohlidalp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@tritonas00 tritonas00 merged commit 9b59269 into RigsOfRods:master Feb 25, 2021
@tritonas00 tritonas00 deleted the rev-net branch February 25, 2021 14:19
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants