From 83ee764b45bf45d1223e38d308ba1903a45be361 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Tue, 23 Jan 2024 11:25:54 +0100 Subject: [PATCH] remove migration system --- content/system/hands/hands.tscn | 6 +-- lib/globals/save_system.gd | 67 +++------------------------------ lib/migrations/2024-01-22.gd | 4 -- 3 files changed, 9 insertions(+), 68 deletions(-) delete mode 100644 lib/migrations/2024-01-22.gd diff --git a/content/system/hands/hands.tscn b/content/system/hands/hands.tscn index a0efb03..ab65844 100644 --- a/content/system/hands/hands.tscn +++ b/content/system/hands/hands.tscn @@ -42,7 +42,7 @@ transform = Transform3D(1, -7.45058e-09, -2.22045e-16, 7.45058e-09, 1, 0, 0, 0, shape = SubResource("CapsuleShape3D_dopke") [node name="ThumbTip" type="BoneAttachment3D" parent="XRHandLeft"] -transform = Transform3D(0.937246, 0.0284254, -0.347508, 0.0184905, 0.991216, 0.130949, 0.348178, -0.129157, 0.928488, 0.0498668, 0.0560917, -0.112777) +transform = Transform3D(0.937246, 0.0284254, -0.347508, 0.0184905, 0.991216, 0.130949, 0.348178, -0.129157, 0.928487, 0.0498668, 0.0560917, -0.112777) bone_name = "Thumb_Tip_L" bone_idx = 4 use_external_skeleton = true @@ -52,7 +52,7 @@ external_skeleton = NodePath("../left_hand/Armature_001/Skeleton3D") gizmo_extents = 0.02 [node name="MiddleTip" type="BoneAttachment3D" parent="XRHandLeft"] -transform = Transform3D(0.0812012, -0.650531, -0.755125, 0.996577, 0.064817, 0.051326, 0.0155558, -0.756708, 0.653568, 0.032112, 0.00654224, -0.171612) +transform = Transform3D(0.0812012, -0.650531, -0.755125, 0.996576, 0.064817, 0.051326, 0.0155558, -0.756708, 0.653567, 0.032112, 0.00654224, -0.171612) bone_name = "Middle_Tip_L" bone_idx = 14 use_external_skeleton = true @@ -94,7 +94,7 @@ hand_skeleton = NodePath("right_hand/Armature/Skeleton3D") transform = Transform3D(1, 0, 4.7579e-13, 0, 1, 0, -1.34149e-12, 1.77636e-15, 1, 0, 0, 0) [node name="IndexTip" type="BoneAttachment3D" parent="XRHandRight"] -transform = Transform3D(0.19221, 0.669966, 0.717079, -0.091543, -0.715277, 0.69282, 0.977075, -0.19881, -0.0761527, -0.0345977, -0.164767, -0.0355401) +transform = Transform3D(0.19221, 0.669966, 0.717078, -0.091543, -0.715277, 0.69282, 0.977075, -0.19881, -0.0761527, -0.0345978, -0.164767, -0.0355401) bone_name = "Index_Tip_R" bone_idx = 9 use_external_skeleton = true diff --git a/lib/globals/save_system.gd b/lib/globals/save_system.gd index 4e49715..c7b03a5 100644 --- a/lib/globals/save_system.gd +++ b/lib/globals/save_system.gd @@ -28,13 +28,13 @@ func save(): var save_tree = _generate_save_tree(get_tree().root.get_node("Main")) var json_text = JSON.stringify({ - "version": "1.0.0", + "version": get_version(), "tree": save_tree }) save_file.store_line(json_text) func load(): - await clear() + await clear() if HomeApi.has_connected() == false: return @@ -49,17 +49,15 @@ func load(): var json_text = save_file.get_line() var save_data = JSON.parse_string(json_text) - save_data = migrate(save_data) - - if save_data == null: - save() - return - var save_tree = save_data["tree"] if save_tree == null: return + if save_tree.has("version") == false: + save() + return + if save_tree is Array: for tree in save_tree: _build_save_tree(tree) @@ -69,59 +67,6 @@ func load(): loaded.emit() is_loaded = true -func migrate(data: Dictionary): - var migration_version = data["migration"] - var migrations = load_migrations() - - if migration_version == null || migrations == {}: - return null - - var migration_keys = migrations.keys().sort() - - for key in migration_keys: - if is_migration_newer(migration_version, key): - var migration = migrations[key] - - data = migration.migrate(data) - - data["migration"] = key - - return data - -func is_migration_newer(version, new_version): - var version_split = version.split(".") - var new_version_split = new_version.split(".") - - for i in range(0, 3): - if int(version_split[i]) > int(new_version_split[i]): - return false - elif int(version_split[i]) < int(new_version_split[i]): - return true - - return false - -func load_migrations(): - var migrations = {} - var migrations_dir := DirAccess.open("res://lib/migrations") - - if migrations == null: - return {} - - migrations_dir.list_dir_begin() - var file_name = migrations_dir.get_next() - - while file_name != "": - if file_name.ends_with(".gd"): - var version = file_name.substr(0, -3) - - migrations[version] = load("res://lib/migrations/%s" % file_name) - - file_name = migrations_dir.get_next() - - migrations_dir.list_dir_end() - - return migrations - func get_version(): var config_error = export_config.load(export_config_path) diff --git a/lib/migrations/2024-01-22.gd b/lib/migrations/2024-01-22.gd deleted file mode 100644 index 5a9d461..0000000 --- a/lib/migrations/2024-01-22.gd +++ /dev/null @@ -1,4 +0,0 @@ -extends Object - -static func migrate(data: Dictionary): - return data \ No newline at end of file