Skip to content
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

Option change handlers should be registered outside of options.cpp #7638

Open
glebm opened this issue Jan 10, 2025 · 0 comments · May be fixed by #7639
Open

Option change handlers should be registered outside of options.cpp #7638

glebm opened this issue Jan 10, 2025 · 0 comments · May be fixed by #7639

Comments

@glebm
Copy link
Collaborator

glebm commented Jan 10, 2025

Almost everything depends on options.cpp and options.cpp depends on almost everything because the change handlers are registered withing options.cpp.

It'd be great to untangle this by moving the change handlers outside of options.cpp.

E.g. currently in options.cpp we have:

void OptionExperienceBarChanged()
{
	if (!gbRunGame)
		return;
	if (*sgOptions.Gameplay.experienceBar)
		InitXPBar();
	else
		FreeXPBar();
}
	experienceBar.SetValueChangedCallback(OptionExperienceBarChanged);

This code should be moved to xpbar.cpp to avoid this circular dependency.

This will let us do things like building data_file_test without depending on all of DevilutionX.

glebm added a commit to glebm/devilutionX that referenced this issue Jan 10, 2025
In C++, globals initialization order accross translation units is not
defined. Accessing a global via a function ensures that it is initialized.

This will be needed for diasurgical#7638, which will statically initialize change
handlers after the Options object has been initialized.
glebm added a commit to glebm/devilutionX that referenced this issue Jan 10, 2025
In C++, globals initialization order accross translation units is not
defined. Accessing a global via a function ensures that it is initialized.

This will be needed for diasurgical#7638, which will statically initialize change
handlers after the Options object has been initialized.
glebm added a commit to glebm/devilutionX that referenced this issue Jan 10, 2025
In C++, globals initialization order accross translation units is not
defined. Accessing a global via a function ensures that it is initialized.

This will be needed for diasurgical#7638, which will statically initialize change
handlers after the Options object has been initialized.
@glebm glebm linked a pull request Jan 10, 2025 that will close this issue
glebm added a commit to glebm/devilutionX that referenced this issue Jan 11, 2025
glebm added a commit to glebm/devilutionX that referenced this issue Jan 11, 2025
glebm added a commit to glebm/devilutionX that referenced this issue Jan 11, 2025
In C++, globals initialization order accross translation units is not
defined. Accessing a global via a function ensures that it is initialized.

This will be needed for diasurgical#7638, which will statically initialize change
handlers after the Options object has been initialized.
glebm added a commit to glebm/devilutionX that referenced this issue Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant