From dfa5d1245fa352034a5b16b3d6c52ae7a06a2c6b Mon Sep 17 00:00:00 2001 From: Daniel Bross Date: Tue, 18 Mar 2025 22:38:30 +0100 Subject: [PATCH] Fixed bool serialization --- core/entity.jai | 10 +++++----- metaprogram.jai | 20 ++++++++++++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/core/entity.jai b/core/entity.jai index 315d5ad..ee3e666 100644 --- a/core/entity.jai +++ b/core/entity.jai @@ -43,11 +43,11 @@ Node_Render_Data :: struct { Renderable :: struct { visible: bool = true; - type : Renderable_Type; + type : Renderable_Type; @DontSerialize - model: *Model; - nodes: [MAX_NODES] Node_Render_Data; - num_nodes: s64; + model: *Model; @DontSerialize + nodes: [MAX_NODES] Node_Render_Data; @DontSerialize + num_nodes: s64; @DontSerialize } MAX_CHILDREN :: 16; @@ -75,7 +75,7 @@ Entity :: struct { snap_offset: Vector3; snap_intervals: Vector3 = .{1,1,1}; - renderable: Renderable; @DontSerialize + renderable: Renderable; animator: Animator; @DontSerialize // Physics diff --git a/metaprogram.jai b/metaprogram.jai index 6c9a965..86d46b9 100644 --- a/metaprogram.jai +++ b/metaprogram.jai @@ -44,7 +44,7 @@ build :: (build_release: bool, main_path: string, game_name: string, working_dir entity_serialize_proc_string: [..] string; should_serialize :: (type: *Type_Info_Struct, member: Type_Info_Struct_Member) -> bool { - if type!= null { + if type != null { if type.name == { case "Vector2"; { if member.name == { @@ -205,9 +205,9 @@ if updated { } DONE -generate_member_serialization :: (type: *Type_Info_Struct, builder: *String_Builder, path: string = "") { - for type.members { - if should_serialize(type, it) { +generate_member_serialization :: (struct_type: *Type_Info_Struct, builder: *String_Builder, path: string = "") { + for struct_type.members { + if should_serialize(struct_type, it) { new_path : string; if path.count == 0 { new_path = it.name; @@ -242,9 +242,10 @@ generate_member_serialization :: (type: *Type_Info_Struct, builder: *String_Buil } } -generate_member_deserialization :: (type: *Type_Info_Struct, builder: *String_Builder, path: string = "") { - for type.members { - if should_serialize(type, it) { +generate_member_deserialization :: (struct_type: *Type_Info_Struct, builder: *String_Builder, path: string = "") { + for struct_type.members { + if should_serialize(struct_type, it) { + print("DESER %\n", struct_type.name); new_path : string; if path.count == 0 { new_path = it.name; @@ -269,7 +270,10 @@ generate_member_deserialization :: (type: *Type_Info_Struct, builder: *String_Bu print_to_builder(builder, "\t\t\t\tcase \"%\";\n", new_path); print_to_builder(builder, "\t\t\t\tif values[1].count > 0 { e.%1 = copy_string(trim(values[1])); }\n", new_path); } - case .BOOL; #through; + case .BOOL; { + print_to_builder(builder, "\t\t\t\tcase \"%\";\n", new_path); + print_to_builder(builder, "\t\t\t\t\tscan2(trim(values[1]), \"\%\", *e.%);\n", new_path); + } case .FLOAT; #through; case .ENUM; { print_to_builder(builder, "\t\t\t\tcase \"%\";\n", new_path);