Skip to content

Conversation

@Caball009
Copy link

@Caball009 Caball009 commented Jan 7, 2026

Scripted audio events are synchronized across clients. That means that if the script execution fails for some reason (e.g. caused by another bug), there's a CRC mismatch. This PR changes that, so that scripted audio events are still likely to be same across clients but script execution failure does not result in a mismatch.

TODO:

  • Deal with AudioEventRTS::getIsLogicalAudio. Could maybe delete the function or add an assertion that it should be used with the new random value macros.
  • Expand comments for new functions.

@Caball009 Caball009 added Audio Is audio related Major Severity: Minor < Major < Critical < Blocker NoRetail This fix or change is not applicable with Retail game compatibility Script Is related to Script Engine, SCB labels Jan 7, 2026
@Caball009 Caball009 changed the title feat(logic): Decouple scripted audio events from CRC calculation feat(logic): Decouple scripted audio events from CRC computation Jan 7, 2026
@xezon xezon marked this pull request as draft January 7, 2026 18:09
@Caball009 Caball009 marked this pull request as ready for review January 8, 2026 11:13
Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

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

In principle this looks like the right thing to avoid mismatching.

extern Int GetGameLogicRandomValue( int lo, int hi, const char *file, int line );
extern Int GetGameLogicRandomValueUnsynchronized(int lo, int hi, const char* file, int line);
extern Real GetGameLogicRandomValueReal( Real lo, Real hi, const char *file, int line );
extern Real GetGameLogicRandomValueRealUnsynchronized(Real lo, Real hi, const char* file, int line);
Copy link

Choose a reason for hiding this comment

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

Unsynchronized reads a bit brutal. Perhaps there is an alternative word for it? Perhaps GetGameLogicCurrentValue?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, that's fair.

Copy link
Author

Choose a reason for hiding this comment

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

Still a bit awkward but it's currently like this:
macro: GameLogicCurrentRandomValue
function: GetGameLogicCurrentRandomValue

Leaving the 'random' part out of the name seems undesirable to me.

}

//
// Integer random value; does not change the seed values
Copy link

Choose a reason for hiding this comment

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

I suspect this will always return the same value on consecutive calls?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, that's correct.

Copy link
Author

@Caball009 Caball009 Jan 8, 2026

Choose a reason for hiding this comment

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

Do you have a suggestion for a more descriptive code comment, or is it good 'as is'?

Copy link

Choose a reason for hiding this comment

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

I suggest to clarify that it just returns the current logic value without taking the necessary steps to generate a different value on next call. And then can also provide an example use case to explain what this is useful for.

Copy link
Author

Choose a reason for hiding this comment

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

Info comments added.

@Caball009 Caball009 linked an issue Jan 8, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Audio Is audio related Major Severity: Minor < Major < Critical < Blocker NoRetail This fix or change is not applicable with Retail game compatibility Script Is related to Script Engine, SCB

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Playing sounds exclusively for "Local Player" can mismatch the game

2 participants