[Breaking Change] Rename init and make it not use the super constructor arguments
#286
+27
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #241
HScriptedClass.initis pretty odd because it's used throughout FNF as the equivalent ofnewfor script classes, but it accepts the super class's constructor arguments as its own, and then initializes an instance of the script class using those arguments, however a script class is actually independent from the super class in this regard and can have any arguments it wants, which may not be the same the super class has. When scripts use it, it causes issues in some targets, where some of the arguments either get converted incorrectly, become null or, on HashLink, throws an error about the incompatible type.One instance of that in FNF is
phillyTrain.hxc, which instantiates an instance ofBuildingEffectShaderwithScriptedFlxRuntimeShader.init('BuildingEffectShader', 1.0), which calls aninitof arguments (Null<String>, Null<String>, Null<String>), it works fine on C++ since there is no type-checking, but on HL it throws an error about being unable to cast a float to a string. This is not a mistake on the script's end, since it does accept a float as its argument.So I've made it use haxe.Rest for the arguments, however since it doesn't work well with Reflect I had to add some backwards compatibility handling for scripts using it.
The registries and other parts of Haxe code that call
initseem to work well with these changes somehow, but I recommend caution regarding any breaking changes this could introduce.