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

Editor: support loading a game with invalid property values #2563

Open
ivan-mogilko opened this issue Nov 1, 2024 · 0 comments
Open

Editor: support loading a game with invalid property values #2563

ivan-mogilko opened this issue Nov 1, 2024 · 0 comments
Labels
context: editor assets related to input files for editing the game type: enhancement a suggestion or necessity to have something improved what: editor related to the game editor

Comments

@ivan-mogilko
Copy link
Contributor

ivan-mogilko commented Nov 1, 2024

There's a certain problem, which is not too likely, but still potentially possible.
Our serialization system in the Editor works by reading xml entries, and assigning their values to game object properties in memory.
Some of the object properties throw exceptions if the value is not valid.
That works well for reporting when user edits these values in the editor; because value reverts to a previous one, user sees the error message, and can fix it or leave previous value.
But that does not work when a game is loaded, because there's no "fallback" operation. This results in game unable to load at all, and the only way to fix it is to open Game.agf by hand and edit it. That is very inconvenient, not to mention that user has to know valid range of values for this property.

We need some kind of backup scenario in case game cannot load like that.
I suppose, that for this scenario:

  1. We need a distinct exception class thrown by properties when they are assigned an invalid value. ArgumentException may not be a suitable choice, as it's too generic and may be thrown by a multitude of .NET functions. It's better to create a new custom one instead (may derive from ArgumentException), and make sure that properties throw only that.
  2. We need to handle such situation to be able to proceed. From what I see there are 2 main options:
    A. Leave property unchanged (it will likely retain default value), or assign default value explicitly (can use reflection).
    B. Find a closest value in valid range (?), but not sure if that's meaningful, and not every property type can have that.
  3. We need to record this problem, and report to user after game was loaded, in Output panel, and maybe somehow else, like write a log file into the project folder.
@ivan-mogilko ivan-mogilko added type: enhancement a suggestion or necessity to have something improved what: editor related to the game editor context: editor assets related to input files for editing the game labels Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
context: editor assets related to input files for editing the game type: enhancement a suggestion or necessity to have something improved what: editor related to the game editor
Projects
None yet
Development

No branches or pull requests

1 participant