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

Feat/improve exceptions #164

Merged
merged 23 commits into from
Dec 3, 2024
Merged

Conversation

SnowyWhite
Copy link
Contributor

What does this PR do?

This pull request improves the message shown when the game crashes.
It replaces the old MessageBox with a TaskDialog that offers more customisation options.

The following information is included in the new message:

  • The IW4x revision of the client
  • The Windows Version
  • The launch parameters

And if the crash happened in-game:

  • Whether it was in private match or on a dedicated server
  • The IW4x revision of the server
  • The server name
  • the IP address of the server
  • The gametype
  • The map name

It also includes a hyperlink to join the Discord server.

Anything else we should know?

To make this possible, a few other things were added or changed too.

  • sv_version dvar, which contains the version parsed from an Infostring
  • shortversion dvar, which contains the client version (was already part of the game)
  • UI_GetGameTypeDisplayName method, for completeness, not really required
  • A new utility method the get the Windows version as a string
  • The required minimum version of Windows is updated from 5 to 6 (Vista), as the new Windows Controls library has this limit
Screenshot of crash messages

Crash happened when playing on a dedicated server

dedicated_server

Crash happened when playing a private match

private_match

Crash happened somewhere at the main menu

pregame

Copy link
Contributor

@Rackover Rackover 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 overall, few things to change

src/Components/Modules/Exception.cpp Outdated Show resolved Hide resolved
src/Components/Modules/Exception.cpp Outdated Show resolved Hide resolved
src/Components/Modules/Exception.cpp Outdated Show resolved Hide resolved
src/Utils/Utils.cpp Outdated Show resolved Hide resolved
@Rackover
Copy link
Contributor

Rackover commented Nov 5, 2024

I'm testing this as soon as I have a bit of time

src/Utils/Utils.cpp Outdated Show resolved Hide resolved
src/Utils/Utils.cpp Outdated Show resolved Hide resolved
src/Components/Modules/Exception.cpp Outdated Show resolved Hide resolved
@@ -132,6 +132,10 @@ namespace Game
extern const dvar_t** cg_scoreboardWidth;

extern const dvar_t** version;
/// <summary>

This comment was marked as resolved.

Copy link
Contributor

Choose a reason for hiding this comment

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

why so? care to explain? :P

This comment was marked as resolved.

Copy link
Contributor

@Rackover Rackover Nov 7, 2024

Choose a reason for hiding this comment

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

yea but as a result of it being microsoft-specific, this comment is visible in Intellisense when you type the name of the function or variable in Visual Studio.

If you type Game::version it will print in a tooltip the content of the <summary> placed just above, making it convenient to use. I do not have the same behaviour with just /// (although maybe there are other ways to achieve it)

If you have a practical case where the XML Documentation actually poses a problem, one that I can verify, in comparison to slash code documentation (or other methods) tell me! I do not know one, but I also work predominantly with M$ tooling

Copy link
Contributor

Choose a reason for hiding this comment

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

🤔

If what you mean by " 👎 " is that Visual Studio doesn't handle XML comments in Intellisense, I can provide examples where it does.
If what you mean by " 👎 " is that you know no practical downsides to using XML documentation then i'm happy to mark this conversation as resolved.

If you meant to express anything else, please use your words, I'm not fluent in "👎 " 😄

This comment was marked as resolved.

Copy link
Contributor

Choose a reason for hiding this comment

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

My question is: Is there anything that XML documentation breaks in comparison to ///? For instance, is there a widely used code editor that simply won't accept or display XML comments but would display /// comments?

If this is not the case then XML comments are the way to go - a large portion of people who work with this project are using or will use Visual Studio predominantly, where having Intellisense enabled by default means XML comments do have an advantage over /// comments. But if XML comments breaks other widely used IDEs, I don't mind considering leaving them out of the codebase.

I'm looking for a practical example of XML docs presenting a problem, in a real environment - i understand the theory behind having things standard or not but it's just not something that strikes me as particularly important in that project or in that ecosystem, so practical cases where something actually breaks take priority.

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used the XML style comments on purpose for a couple of reasons:

  1. As mentioned by louve, one just needs to type /// and it will automatically create the <summary> tag and others for return types and parameters etc.

  2. Being able to distinguish them from other comments might come in handy in the future (perhaps the wiki will get a section explaining the codebase, and XML comments would make it easy for automated export and formatting).

  3. I am aware that this is a Visual Studio specific feature, but on the other hand most people will be working on the project with this IDE anyway and will therefore benefit from it, while users of other IDEs will not have much of a disadvantage. Moreover, the XML style is just the default option in Visual Studio, there are other, more standardized options, switching to another that works for everyone would be no problem:
    docs

  4. Having an eye-catching doc style will hopefully remind and encourage others to document their code too :D

const auto serverVersion = Dvar::Var("sv_version").get<std::string>();
const auto ipAddress = Network::Address(*Game::connectedHost).getString();

char serverName[256]{ 0 };
Copy link
Collaborator

Choose a reason for hiding this comment

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

non-constant bound is dangerous

Copy link
Contributor

Choose a reason for hiding this comment

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

feel free to accompany your comment with a snippet or a suggestion for something that the offending code should be replaced with

Copy link
Collaborator

Choose a reason for hiding this comment

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

None that come to mind right now without more context. I believe the first step would be to look into StripColors and StripAllTextIcons and see how we can handle it better; perhaps leave a TODO for now or a FIXME;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I opened issue #165 for this.

@Rackover
Copy link
Contributor

So it's really cool and it passes testing but it's missing one thing..... fs_game 🤔
image

I think this is just an oversight cause I remember you talking about it.
Here I'm on a heavily modded server, fs_game is definitely not vanilla, so it should probably be part of the exception message!

Once this is handled i'm ready to merge it & release

@Rackover Rackover merged commit 4d79e89 into iw4x:develop Dec 3, 2024
2 checks passed
@SnowyWhite SnowyWhite deleted the feat/improve-exceptions branch December 17, 2024 23:04
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.

4 participants