From 7a9bff248e3351f051884ef01d7e3b083491000a Mon Sep 17 00:00:00 2001 From: EliteMasterEric <ericmyllyoja@gmail.com> Date: Wed, 6 Mar 2024 12:24:25 -0500 Subject: [PATCH 1/3] Fix an issue with array.clone() on HTML5 --- source/funkin/import.hx | 2 +- source/funkin/util/tools/DynamicAccessTools.hx | 16 ++++++++++++++++ source/funkin/util/tools/DynamicTools.hx | 14 -------------- 3 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 source/funkin/util/tools/DynamicAccessTools.hx delete mode 100644 source/funkin/util/tools/DynamicTools.hx diff --git a/source/funkin/import.hx b/source/funkin/import.hx index 02055d4ed..66c3470ff 100644 --- a/source/funkin/import.hx +++ b/source/funkin/import.hx @@ -13,7 +13,7 @@ using Lambda; using StringTools; using funkin.util.tools.ArraySortTools; using funkin.util.tools.ArrayTools; -using funkin.util.tools.DynamicTools; +using funkin.util.tools.DynamicAccessTools; using funkin.util.tools.FloatTools; using funkin.util.tools.Int64Tools; using funkin.util.tools.IntTools; diff --git a/source/funkin/util/tools/DynamicAccessTools.hx b/source/funkin/util/tools/DynamicAccessTools.hx new file mode 100644 index 000000000..1c83ce039 --- /dev/null +++ b/source/funkin/util/tools/DynamicAccessTools.hx @@ -0,0 +1,16 @@ +package funkin.util.tools; + +import haxe.DynamicAccess; + +class DynamicAccessTools +{ + /** + * Creates a full clone of the input `DynamicAccess`. + * @param input The `Dynamic` to clone. + * @return A clone of the input `Dynamic`. + */ + public static function clone(input:DynamicAccess<T>):DynamicAccess<T> + { + return Reflect.copy(input); + } +} diff --git a/source/funkin/util/tools/DynamicTools.hx b/source/funkin/util/tools/DynamicTools.hx deleted file mode 100644 index 47501ea22..000000000 --- a/source/funkin/util/tools/DynamicTools.hx +++ /dev/null @@ -1,14 +0,0 @@ -package funkin.util.tools; - -class DynamicTools -{ - /** - * Creates a full clone of the input `Dynamic`. Only guaranteed to work on anonymous structures. - * @param input The `Dynamic` to clone. - * @return A clone of the input `Dynamic`. - */ - public static function clone(input:Dynamic):Dynamic - { - return Reflect.copy(input); - } -} From 2fa1d18dce85a6127148406d5f6822279e48bfc6 Mon Sep 17 00:00:00 2001 From: EliteMasterEric <ericmyllyoja@gmail.com> Date: Wed, 6 Mar 2024 12:29:54 -0500 Subject: [PATCH 2/3] Fix build --- source/funkin/ui/debug/charting/ChartEditorState.hx | 2 +- source/funkin/util/tools/DynamicAccessTools.hx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 78e73bf27..191f3cb15 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -4532,7 +4532,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState else { // Create a note and place it in the chart. - var newNoteData:SongNoteData = new SongNoteData(cursorSnappedMs, cursorColumn, 0, noteKindToPlace.clone()); + var newNoteData:SongNoteData = new SongNoteData(cursorSnappedMs, cursorColumn, 0, noteKindToPlace); performCommand(new AddNotesCommand([newNoteData], FlxG.keys.pressed.CONTROL)); diff --git a/source/funkin/util/tools/DynamicAccessTools.hx b/source/funkin/util/tools/DynamicAccessTools.hx index 1c83ce039..14b9a6c68 100644 --- a/source/funkin/util/tools/DynamicAccessTools.hx +++ b/source/funkin/util/tools/DynamicAccessTools.hx @@ -9,7 +9,7 @@ class DynamicAccessTools * @param input The `Dynamic` to clone. * @return A clone of the input `Dynamic`. */ - public static function clone(input:DynamicAccess<T>):DynamicAccess<T> + public static function clone<T>(input:DynamicAccess<T>):DynamicAccess<T> { return Reflect.copy(input); } From f671cc856902713618d270137592a4bb0a606348 Mon Sep 17 00:00:00 2001 From: EliteMasterEric <ericmyllyoja@gmail.com> Date: Wed, 6 Mar 2024 14:13:48 -0500 Subject: [PATCH 3/3] Remove DynamicAccessTools entirely. --- source/funkin/import.hx | 1 - .../funkin/ui/debug/charting/ChartEditorState.hx | 2 +- source/funkin/util/tools/DynamicAccessTools.hx | 16 ---------------- 3 files changed, 1 insertion(+), 18 deletions(-) delete mode 100644 source/funkin/util/tools/DynamicAccessTools.hx diff --git a/source/funkin/import.hx b/source/funkin/import.hx index 66c3470ff..250de99cb 100644 --- a/source/funkin/import.hx +++ b/source/funkin/import.hx @@ -13,7 +13,6 @@ using Lambda; using StringTools; using funkin.util.tools.ArraySortTools; using funkin.util.tools.ArrayTools; -using funkin.util.tools.DynamicAccessTools; using funkin.util.tools.FloatTools; using funkin.util.tools.Int64Tools; using funkin.util.tools.IntTools; diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 191f3cb15..29d7ddf97 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -4525,7 +4525,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState { // Create an event and place it in the chart. // TODO: Figure out configuring event data. - var newEventData:SongEventData = new SongEventData(cursorSnappedMs, eventKindToPlace, eventDataToPlace.clone()); + var newEventData:SongEventData = new SongEventData(cursorSnappedMs, eventKindToPlace, eventDataToPlace.copy()); performCommand(new AddEventsCommand([newEventData], FlxG.keys.pressed.CONTROL)); } diff --git a/source/funkin/util/tools/DynamicAccessTools.hx b/source/funkin/util/tools/DynamicAccessTools.hx deleted file mode 100644 index 14b9a6c68..000000000 --- a/source/funkin/util/tools/DynamicAccessTools.hx +++ /dev/null @@ -1,16 +0,0 @@ -package funkin.util.tools; - -import haxe.DynamicAccess; - -class DynamicAccessTools -{ - /** - * Creates a full clone of the input `DynamicAccess`. - * @param input The `Dynamic` to clone. - * @return A clone of the input `Dynamic`. - */ - public static function clone<T>(input:DynamicAccess<T>):DynamicAccess<T> - { - return Reflect.copy(input); - } -}