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

Correct function definitions and 2.3 FancyRoomSelect #921

Merged
merged 5 commits into from
Jun 11, 2022

Conversation

Jacky720
Copy link
Contributor

@Jacky720 Jacky720 commented May 21, 2022

Description

Adds support for function scr_myscript() formatting in GMS 2.3+ in both compilation and decompilation. Minor tweaks to FancyRoomSelect.csx to function on 2.3+ with strange room orders.

Caveats

Struct definition isn't 100% due to me not knowing how struct definition works. The new decompiler code hackily uses FunctionDefinition as both an Expression and a Statement depending on context. The code does not differentiate in decompilation; scr_myscript = function() no longer appears even if it is the format used, although it is still accepted in compilation.

I didn't bother to restrict the myroom_last variable to 2.3, so technically it defines one additional unused variable when the script is used on older games. This will not cause performance issues.

Notes

Closes #926. Closes #951.

@github-actions
Copy link

github-actions bot commented May 21, 2022

return result;
if (expression)
return result;
else // Whatever you call non-anonymous
Copy link
Contributor

Choose a reason for hiding this comment

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

Else is unnecessary here, due to the return from above.

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 feel that keeping both returns on the same level makes it clear at a glance that neither is especially a "default". You can't miss the if anymore and assume it always does the one thing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Which is fair, I just dislike the nesting. Probably a better thing to have in this case though.

UndertaleModLib/Compiler/Parser.cs Outdated Show resolved Hide resolved
UndertaleModLib/Compiler/Parser.cs Outdated Show resolved Hide resolved
UndertaleModTool/CommunityScripts/FancyRoomSelect.csx Outdated Show resolved Hide resolved
@BenjaminUrquhart
Copy link
Member

So, the reason why struct decompilation uses FunctionDefinition is because as far as I can tell, the bytecode is identical. The only difference is a variable in the code entry that's set to an identical struct. Go figure.

@Jacky720
Copy link
Contributor Author

Jacky720 commented Jun 7, 2022

Oh, that worked pretty well.

No more conflicts, right?

Copy link
Contributor

@Miepee Miepee left a comment

Choose a reason for hiding this comment

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

Doesn't seem to be.
Would still personally prefer to get rid of the else to reduce nesting, but that's not something that's merge blocking or anything.

@Grossley Grossley merged commit e2b8022 into UnderminersTeam:master Jun 11, 2022
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.

GM2022 game with a new room can't be saved.
4 participants