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

Fix NREs in DiscordService. #21327

Merged
merged 1 commit into from Feb 7, 2024
Merged

Conversation

RoosterDragon
Copy link
Member

@RoosterDragon RoosterDragon commented Feb 3, 2024

Handle the client being null. Previously, a service could be created with a null client. This would leads to NREs when invoking the static Update methods. Now we provide a static helper to get the instance created for the mod. This avoids two instances of the DiscordService being created (a static one, and an instance created in the mod manifest).

Fixes #21275

Copy link
Member

@PunkPun PunkPun left a comment

Choose a reason for hiding this comment

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

When I launch a dedicated server discord detects it. While on bleed it doesn't

@RoosterDragon
Copy link
Member Author

When I launch a dedicated server discord detects it. While on bleed it doesn't

You are correct. There's two instances going on here. One created by the mod manifest and the static one created if you use the static helper methods. A bit ugly.

Streamlined to use one instance, and ensure that instance is able to deal with a null client.

@anvilvapre
Copy link
Contributor

There was a reason to allow for disabling the service. #19343
To me it seems like an implementation issue in the client library.

Many players on slower system would benefit from it being disabled.

@RoosterDragon
Copy link
Member Author

The disabling logic if (!Game.Settings.Game.EnableDiscordService) return; is still there in the constructor.

Handle the client being null. Previously, a service could be created with a null client. This would leads to NREs when invoking the static Update methods. Now we guard against a null client.
Copy link
Member

@PunkPun PunkPun left a comment

Choose a reason for hiding this comment

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

LGTM

@PunkPun PunkPun merged commit 0c22499 into OpenRA:bleed Feb 7, 2024
3 checks passed
@PunkPun
Copy link
Member

PunkPun commented Feb 7, 2024

changelog

@RoosterDragon RoosterDragon deleted the discord-fix branch February 7, 2024 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NullReferenceException in DiscordService.UpdateParty
3 participants