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

Enable loading FDS files with error handling #35

Merged
merged 5 commits into from
Sep 29, 2018
Merged

Enable loading FDS files with error handling #35

merged 5 commits into from
Sep 29, 2018

Conversation

rzumer
Copy link
Contributor

@rzumer rzumer commented Aug 3, 2018

Continued from #32.

FDS files cannot use the same parsing strategy as regular NES files. This solves the problem by falling back onto the default loading strategy if NES header parsing fails.

This also fixes #33, by displaying an error message when a game fails to load for System::kNintendo, and exiting the application, as this is the most graceful way to handle this failure currently (all other methods tested result in access violation errors down the line).

Also exit the application, as any further operation will cause access
violation errors.
@rzumer rzumer requested a review from leiradel August 3, 2018 23:30
@leiradel
Copy link
Contributor

leiradel commented Aug 5, 2018

We cannot exit the application on this error, or on any other error. If the application gets stuck in an invalid state when the game fails to load, it must be fixed.

@rzumer
Copy link
Contributor Author

rzumer commented Aug 5, 2018

@leiradel Would you prefer leaving the application in an error state that will crash it on a later operation? I don't think that's a better situation. Like I said, exiting following an error message is the most graceful way to provide feedback and avoid later crashes, until these access violations can be avoided - which can be done as part of a later patch. Yes, this is a stopgap measure, and I can add a comment in the code to reflect that if you would like, but this is preferable to a silent failure or crash.

Note that these access violations are not introduced by this PR, they already occur now following an attempt to load an FDS file, with or without a system present. This PR eliminates the issue and enables FDS support when a system is present, and provides feedback when it is absent.

@leiradel
Copy link
Contributor

leiradel commented Aug 5, 2018

No, I'm saying that we should never exit the application because of a bug. The bug should be fixed, but it doesn't need to be fixed in this PR. If you can open an issue describing how to replicate the bug, it'll be awesome.

This PR is good since it adds support for more games for NES, but we need to get rid of the exit call, and use MessageBox to present the error to the user instead of using the dialog hack needed to generate dialogs on-the-fly.

@rzumer
Copy link
Contributor Author

rzumer commented Aug 5, 2018

@leiradel OK, see #39. I will update this PR based on your feedback.

@leiradel
Copy link
Contributor

leiradel commented Aug 5, 2018

To be fair, you don't need to change code to use MessageBox, there are other dialogs that use the dynamic dialog hack but could use the Win32 API directly.

@leiradel
Copy link
Contributor

leiradel commented Aug 5, 2018

Oops, I just saw that you've already made this change. Sorry about that.

src/Emulator.cpp Outdated Show resolved Hide resolved
// Assume that the FDS system is missing
_logger.debug(TAG "Game load failure (Nintendo)");

MessageBox(g_mainWindow, "Game load error. Are you missing a system file?", "Core Error", MB_OK);
Copy link
Member

Choose a reason for hiding this comment

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

recommend showing a generic message for all systems. it's useful feedback, and there may be other reasons this fails for NES.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That seems fine, but I want to keep this message, since a generic error message is no more helpful than crashing when a file is missing. I don't know if it is possible to differentiate between different types of errors in libretro, so the alternative would be to detect the system file ourselves before falling back to a generic error message. In any case, errors during core operations should be added at all levels, not just the loading stage, so I think another PR with better error handling would be more adequate.

@leiradel leiradel merged commit 85570fd into RetroAchievements:develop Sep 29, 2018
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.

FDS file loading silently fails when a system is absent
3 participants