-
Notifications
You must be signed in to change notification settings - Fork 238
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
Clean up version flags #1047
Clean up version flags #1047
Conversation
Download the artifacts for this pull request here: GUI:
CLI: |
@Miepee You said you had comments on this? Just want to bump it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't checked the actual replacements yet, only the new approach.
return DisplayName + " (GMS " + Major + "." + Minor + "." + Release + "." + Build + ", bytecode " + BytecodeVersion + ")"; | ||
if (Major == 2) | ||
return DisplayName + " (" + Enum.GetName(typeof(GMSVersions), GMS2Version).Replace("_", ".") + ", bytecode " + BytecodeVersion + ")"; | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's just my preference. Keeping all returns on the same level.
/// <param name="minor">The minor version.</param> | ||
/// <param name="release">The release version.</param> | ||
/// <param name="build">The build version.</param> | ||
public void SetGMS2Version(uint major, uint minor = 0, uint release = 0, uint build = 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this this error in any way when invalid major is given, instead of just doing nothing silently?
Also, why is this done with a major/minor/release/build approach? I'd personally like if enums were still used for this, for safety, but I assume that created too much boilerplate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UndertaleGeneralInfo.GMSVersions.GMS2_2_2_302
qualifies as too much boilerplate, IMO.
Most invalid versions are actually just versions that don't have any distinguishing characteristics in the data file, but I see what you mean about major versions in particular. I can add a throw
there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UndertaleGeneralInfo.GMSVersions.GMS2_2_2_302 qualifies as too much boilerplate, IMO.
AFAIK, you don't have give the full name like that, GMSVersions.GMS2_2_2_302
should be valid too, but may need some specific usings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added error: "Attempted to set a version of GameMaker {major} using SetGMS2Version". Not going to resolve this in case it's still possible to get in those usings and make it pretty.
To-do:
|
@@ -495,19 +468,24 @@ private bool TestGMS1Version(uint stableBuild, uint betaBuild, bool allowGMS2 = | |||
/// <param name="release">The release version.</param> | |||
/// <param name="build">The build version.</param> | |||
/// <returns>Whether the version of the data file is the same or higher than a specified version.</returns> | |||
public bool IsVersionAtLeast(uint major, uint minor, uint release, uint build) | |||
public bool IsVersionAtLeast(uint major, uint minor = 0, uint release = 0, uint build = 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method shouldn't be used within (de)compiler, because compared to the boolean check (GMS2_3
), it's expensive.
/// <summary> | ||
/// Whether the data file is from version GMS2.3 | ||
/// </summary> | ||
public bool GMS2_3 = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should revert this field removal, and update the description so it's clear that only this field is kept because of performance.
(see my commentary at IsVersionAtLeast()
)
I suggest instead of setting
|
@@ -120,7 +117,7 @@ public class UndertaleChunkEXTN : UndertaleListChunk<UndertaleExtension> | |||
|
|||
internal override void UnserializeChunk(UndertaleReader reader) | |||
{ | |||
if (reader.undertaleData.GMS2_3) | |||
if (reader.undertaleData.IsVersionAtLeast(2, 3) && !reader.undertaleData.IsVersionAtLeast(2022, 6)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a 2022.6 check necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. That code block is to set the version to 2022.6, so if the versions n has already been set higher it would be redundant.
@@ -339,7 +336,7 @@ internal override void SerializeChunk(UndertaleWriter writer) | |||
|
|||
internal override void UnserializeChunk(UndertaleReader reader) | |||
{ | |||
if (reader.undertaleData.GeneralInfo?.BytecodeVersion >= 17) | |||
if (!reader.undertaleData.IsVersionAtLeast(2022, 2) && reader.undertaleData.GeneralInfo?.BytecodeVersion >= 17) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(the same question as above)
Everything seems fine. |
Rebasing to update the change from #1048... |
because it's haunted
that just leaves merge conflicts
Ooh, the generic readers and writers are actually important... that makes sense.
Co-authored-by: VladiStep <vlad2001.21@mail.ru>
Description
UndertaleData.GMS2_2_2_302
,UndertaleData.GMS2_3
,UndertaleData.GMS2_3_1
,GMS2_3_2
,GMS2022_1
,GMS2022_2
,GM2022_3
, andGM2022_5
booleans in favor of creating anUndertaleGeneralInfo.GMSVersions
enum, as well asUndertaleGeneralInfo.GMS2Version
using said enum. Closes GMS2 flag spam #1045.UndertaleData.IsVersionAtLeast()
has been updated to accept these newer versions, andUndertaleData.SetGMS2Version()
has been added to easily change the value ofGMS2Version
.reader.undertaleData.GeneralInfo.Major >= 2
being simplified to the existingUndertaleData.IsGameMaker2()
function.UndertaleGeneralInfo.ToString()
has been updated to read fromGMS2Version
and thus display a more accurate version in the title bar, helping with Display proper GM version in the window title #929:Caveats
Notes
N/A