Skip to content

[GEN][ZH] Synchronize GameAudio and MilesAudio implementations between Generals and ZH #782

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Mauller
Copy link

@Mauller Mauller commented Apr 29, 2025

merge by rebase - MilesAudioManager inherits from GameAudio so is dependent if MilesAudioManager ever needs reverting.

This PR makes the changes required to synchronize the audio implementations between Generals and Zero hour.

Most changes are backports to Generals, while some small tweaks are made to zero hour to match generals.

This PR also removes some instances where the empty stopAllAmbientBy functions were being called in gamelogic and fxListDie.

@Mauller Mauller added Generals Related Generals only ZeroHour Relates to Zero Hour Refactor Improves the structure of the code, with negligible changes in function. Unify Unifies code between Generals and Zero Hour labels Apr 29, 2025
@Mauller Mauller changed the title [GEN][ZH] Synchronise SystemAudio and MilesAudio implementations between Generals and ZH [GEN][ZH] Synchronise GameAudio and MilesAudio implementations between Generals and ZH Apr 29, 2025
@Mauller Mauller force-pushed the port-miles-and-sys-audio branch 2 times, most recently from f32af8c to eca7e23 Compare April 29, 2025 19:53
@Mauller Mauller changed the title [GEN][ZH] Synchronise GameAudio and MilesAudio implementations between Generals and ZH [GEN][ZH] Synchronize GameAudio and MilesAudio implementations between Generals and ZH Apr 29, 2025
Comment on lines 56 to 61
// union
// {
HSAMPLE m_sample;
H3DSAMPLE m_3DSample;
HSTREAM m_stream;
};
// };
Copy link
Author

@Mauller Mauller Apr 30, 2025

Choose a reason for hiding this comment

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

I think the generals way of handling this might have been better on memory.

Playing audio will only ever be a single type which gets set on m_type so im not sure where they were going with doing this.

Choose a reason for hiding this comment

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

I tend to agree and suggest removing the commenting out in ZH rather than back porting it to Gen.

Copy link

Choose a reason for hiding this comment

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

Yes it looks like it should be a union. The difference is that in Zero Hour these are 0 initialized. But in Generals they are probably also zero initialized because of the Game Memory.

Copy link
Author

@Mauller Mauller Apr 30, 2025

Choose a reason for hiding this comment

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

I will revert the zero hour way of doing it and Null initialise one of the members in both.

That should make sure the memory is initialised then.

Comment on lines 173 to 175
virtual void stopAllAmbientsBy( Object *objID );
virtual void stopAllAmbientsBy( Drawable *drawID );

Copy link
Author

@Mauller Mauller Apr 30, 2025

Choose a reason for hiding this comment

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

Although the functionality for these is empty at the moment, it appears that the idea was to use them to stop ambient audio in specific circumstances.

Ambient audio seems to be constantly playing sound effects that occur in the background. These have some code within generals that would have paused them when the in game menu loaded.

The other situation could be that they get paused when out of range etc. But i think audio culling is handled elsewhere.

And since Generals has code that calls these, it's probably better to port them forward to zero hour during the synchronisation.

Copy link

Choose a reason for hiding this comment

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

Perhaps this was just legacy code that was meant to be removed? There are these 2 functions:

Drawable::startAmbientSound
Drawable::stopAmbientSound

I suspect these are all we need to start and stop ambient audio on drawables?

Generals

In Generals there are these 2 calls to stopAllAmbientsBy:

void GameLogic::setGamePaused( Bool paused, Bool pauseMusic )
	...
	if(paused)
	{
	...
	}
	else
	{
	...
		while( drawable )
		{
			drawable->startAmbientSound();
			TheAudio->stopAllAmbientsBy( drawable );
			drawable = drawable->getNextDrawable(); // <--- This call makes no sense
		}
	}
...
void FXListDie::onDie( const DamageInfo *damageInfo )
{
	...
	if (d->m_defaultDeathFX)
	{
		// if the object has any ambient sound(s), kill 'em now.
		TheAudio->stopAllAmbientsBy(getObject());
		
		if (d->m_orientToObject)
		{
		...

Zero Hour

void FXListDie::onDie( const DamageInfo *damageInfo )
{
	...
	if (d->m_defaultDeathFX)
	{
		if (d->m_orientToObject)
		{
		...
}

I suggest to remove these virtual functions from Generals because they have no use in both titles.

Copy link
Author

@Mauller Mauller Apr 30, 2025

Choose a reason for hiding this comment

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

Yeah, if we don't think they are useful In the end I will remove them from both variants.

Will then make a followup PR to correct any code that used them.

Will also check the situation with the FXList variant wanting to kill ambient sounds on an object, I don't think Generals or zero hour puts ambient sounds on objects and only puts them on drawables.

Copy link
Author

@Mauller Mauller Apr 30, 2025

Choose a reason for hiding this comment

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

Yeah looks like only drawables have ambient sounds on them.

So the object version of the function would have needed to check if the object had a drawable, then it would have to disable the sound on the drawable if it had one.

Removed the instances of these functions in GameAudio and MilesAudioManager.

@Mauller Mauller self-assigned this Apr 30, 2025
@Mauller Mauller force-pushed the port-miles-and-sys-audio branch from eca7e23 to 1e5bfa4 Compare April 30, 2025 19:55
@Mauller
Copy link
Author

Mauller commented Apr 30, 2025

Updated and addressed the discussed points above, will push a small followup PR to remove the stragling bits of code associated with the removed interface functions from GameAudio.

@Mauller Mauller force-pushed the port-miles-and-sys-audio branch from fa2370f to bf0a507 Compare April 30, 2025 20:05
@Mauller
Copy link
Author

Mauller commented Apr 30, 2025

Had to make a small push again to include the removal of calls to stopAllAmbientSoundsBy() since the build pipeline would fail otherwise for the generals build.

There are so few instances where these functions are called that it might as well be a part of this PR.

@xezon
Copy link

xezon commented Apr 30, 2025

Is this change meant to be merged with rebase or not?

Commit number 3 of this change appears to error:

Error: D:\a\GeneralsGameCode\GeneralsGameCode\Generals\Code\GameEngine\Source\GameLogic\Object\Die\FXListDie.cpp(69) : error C2039: 'stopAllAmbientsBy' : is not a member of 'AudioManager'

@Mauller
Copy link
Author

Mauller commented Apr 30, 2025

Is this change meant to be merged with rebase or not?

Commit number 3 of this change appears to error:

Error: D:\a\GeneralsGameCode\GeneralsGameCode\Generals\Code\GameEngine\Source\GameLogic\Object\Die\FXListDie.cpp(69) : error C2039: 'stopAllAmbientsBy' : is not a member of 'AudioManager'

The build of this PR should be fixed with the last commit i made to add removing those calls to stopAllAmbientsBy

since MilesAudioManager inherits from GameAudio, those two commits are kind of interdependent, so i thought it would be better to squash and merge this.

But merging by rebase should be okay, i tweaked the PR description above to cover this.

@xezon
Copy link

xezon commented Apr 30, 2025

If commit number 3 fails to compile on its own, then it cannot be merged with rebase.

@Mauller Mauller force-pushed the port-miles-and-sys-audio branch from bf0a507 to 0dbc5dc Compare April 30, 2025 22:10
@Mauller
Copy link
Author

Mauller commented Apr 30, 2025

If commit number 3 fails to compile on its own, then it cannot be merged with rebase.

Reordered the commits to break the problematic dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Generals Related Generals only Refactor Improves the structure of the code, with negligible changes in function. Unify Unifies code between Generals and Zero Hour ZeroHour Relates to Zero Hour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants