Skip to content

Commit 6117a9c

Browse files
committed
Flags: Use C++11 default values for initialisation
1 parent df49a63 commit 6117a9c

10 files changed

Lines changed: 67 additions & 80 deletions

File tree

generator/templates/rpg_header.tmpl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,12 @@ namespace rpg {
8282
union {
8383
struct {
8484
{%- for flag in field.type|flags_for %}
85-
bool {{ flag.field }};
85+
bool {{ flag.field }} = {{ field|flag_set(loop.index) }};
8686
{%- endfor %}
8787
};
8888
std::array<bool, {{ field.type|flags_for|length }}> flags;
8989
};
90-
{{ field.type }}() noexcept
91-
{%- for flag in flags[struct_name] %}
92-
{%- if loop.first %}:{%- else %},{%- endif %} {{ flag.field }}({{ field|flag_set(loop.index) }})
93-
{%- endfor %}
94-
{}
90+
{{ field.type }}() noexcept {}
9591
} {{ field.name }};
9692
{%- else %}
9793
{{ field.type|cpp_type(prefix=False) }} {{ field.name }}{{ field|pod_default }};

src/generated/lcf/rpg/eventpagecondition.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,17 @@ namespace rpg {
4747
struct EventPageCondition_Flags {
4848
union {
4949
struct {
50-
bool switch_a;
51-
bool switch_b;
52-
bool variable;
53-
bool item;
54-
bool actor;
55-
bool timer;
56-
bool timer2;
50+
bool switch_a = false;
51+
bool switch_b = false;
52+
bool variable = false;
53+
bool item = false;
54+
bool actor = false;
55+
bool timer = false;
56+
bool timer2 = false;
5757
};
5858
std::array<bool, 7> flags;
5959
};
60-
EventPageCondition_Flags() noexcept: switch_a(false), switch_b(false), variable(false), item(false), actor(false), timer(false), timer2(false)
61-
{}
60+
EventPageCondition_Flags() noexcept {}
6261
} flags;
6362
int32_t switch_a_id = 1;
6463
int32_t switch_b_id = 1;

src/generated/lcf/rpg/saveeasyrpgtext.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,14 @@ namespace rpg {
3737
struct SaveEasyRpgText_Flags {
3838
union {
3939
struct {
40-
bool draw_gradient;
41-
bool draw_shadow;
42-
bool bold;
43-
bool italic;
40+
bool draw_gradient = true;
41+
bool draw_shadow = true;
42+
bool bold = false;
43+
bool italic = false;
4444
};
4545
std::array<bool, 4> flags;
4646
};
47-
SaveEasyRpgText_Flags() noexcept: draw_gradient(true), draw_shadow(true), bold(false), italic(false)
48-
{}
47+
SaveEasyRpgText_Flags() noexcept {}
4948
} flags;
5049
};
5150

src/generated/lcf/rpg/saveeasyrpgwindow.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ namespace rpg {
3939
struct SaveEasyRpgWindow_Flags {
4040
union {
4141
struct {
42-
bool draw_frame;
43-
bool border_margin;
42+
bool draw_frame = true;
43+
bool border_margin = true;
4444
};
4545
std::array<bool, 2> flags;
4646
};
47-
SaveEasyRpgWindow_Flags() noexcept: draw_frame(true), border_margin(true)
48-
{}
47+
SaveEasyRpgWindow_Flags() noexcept {}
4948
} flags;
5049
};
5150

src/generated/lcf/rpg/saveeventexecframe.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,11 @@ namespace rpg {
4242
struct EasyRpgFrameRuntime_Flags {
4343
union {
4444
struct {
45-
bool reserved_1;
45+
bool reserved_1 = false;
4646
};
4747
std::array<bool, 1> flags;
4848
};
49-
EasyRpgFrameRuntime_Flags() noexcept
50-
{}
49+
EasyRpgFrameRuntime_Flags() noexcept {}
5150
} easyrpg_runtime_flags;
5251
};
5352

src/generated/lcf/rpg/saveeventexecstate.h

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,31 +57,30 @@ namespace rpg {
5757
struct EasyRpgStateRuntime_Flags {
5858
union {
5959
struct {
60-
bool conf_override_active;
61-
bool reserved_1;
62-
bool reserved_2;
63-
bool reserved_3;
64-
bool patch_destiny_on;
65-
bool patch_destiny_off;
66-
bool patch_dynrpg_on;
67-
bool patch_dynrpg_off;
68-
bool patch_maniac_on;
69-
bool patch_maniac_off;
70-
bool patch_common_this_event_on;
71-
bool patch_common_this_event_off;
72-
bool patch_unlock_pics_on;
73-
bool patch_unlock_pics_off;
74-
bool patch_keypatch_on;
75-
bool patch_keypatch_off;
76-
bool patch_rpg2k3_cmds_on;
77-
bool patch_rpg2k3_cmds_off;
78-
bool use_rpg2k_battle_system_on;
79-
bool use_rpg2k_battle_system_off;
60+
bool conf_override_active = false;
61+
bool reserved_1 = false;
62+
bool reserved_2 = false;
63+
bool reserved_3 = false;
64+
bool patch_destiny_on = false;
65+
bool patch_destiny_off = false;
66+
bool patch_dynrpg_on = false;
67+
bool patch_dynrpg_off = false;
68+
bool patch_maniac_on = false;
69+
bool patch_maniac_off = false;
70+
bool patch_common_this_event_on = false;
71+
bool patch_common_this_event_off = false;
72+
bool patch_unlock_pics_on = false;
73+
bool patch_unlock_pics_off = false;
74+
bool patch_keypatch_on = false;
75+
bool patch_keypatch_off = false;
76+
bool patch_rpg2k3_cmds_on = false;
77+
bool patch_rpg2k3_cmds_off = false;
78+
bool use_rpg2k_battle_system_on = false;
79+
bool use_rpg2k_battle_system_off = false;
8080
};
8181
std::array<bool, 20> flags;
8282
};
83-
EasyRpgStateRuntime_Flags() noexcept
84-
{}
83+
EasyRpgStateRuntime_Flags() noexcept {}
8584
} easyrpg_runtime_flags;
8685
};
8786

src/generated/lcf/rpg/savemapeventbase.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,11 @@ namespace rpg {
7474
struct EasyRpgEventRuntime_Flags {
7575
union {
7676
struct {
77-
bool reserved_1;
77+
bool reserved_1 = false;
7878
};
7979
std::array<bool, 1> flags;
8080
};
81-
EasyRpgEventRuntime_Flags() noexcept
82-
{}
81+
EasyRpgEventRuntime_Flags() noexcept {}
8382
} easyrpg_runtime_flags;
8483
};
8584

src/generated/lcf/rpg/savepicture.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,17 @@ namespace rpg {
131131
struct SavePicture_Flags {
132132
union {
133133
struct {
134-
bool erase_on_map_change;
135-
bool erase_on_battle_end;
136-
bool unused_bit;
137-
bool unused_bit2;
138-
bool affected_by_tint;
139-
bool affected_by_flash;
140-
bool affected_by_shake;
134+
bool erase_on_map_change = true;
135+
bool erase_on_battle_end = false;
136+
bool unused_bit = false;
137+
bool unused_bit2 = false;
138+
bool affected_by_tint = false;
139+
bool affected_by_flash = true;
140+
bool affected_by_shake = true;
141141
};
142142
std::array<bool, 7> flags;
143143
};
144-
SavePicture_Flags() noexcept: erase_on_map_change(true), erase_on_battle_end(false), unused_bit(false), unused_bit2(false), affected_by_tint(false), affected_by_flash(true), affected_by_shake(true)
145-
{}
144+
SavePicture_Flags() noexcept {}
146145
} flags;
147146
double finish_x = 0.0;
148147
double finish_y = 0.0;

src/generated/lcf/rpg/terrain.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,14 @@ namespace rpg {
7777
struct Terrain_Flags {
7878
union {
7979
struct {
80-
bool back_party;
81-
bool back_enemies;
82-
bool lateral_party;
83-
bool lateral_enemies;
80+
bool back_party = false;
81+
bool back_enemies = false;
82+
bool lateral_party = false;
83+
bool lateral_enemies = false;
8484
};
8585
std::array<bool, 4> flags;
8686
};
87-
Terrain_Flags() noexcept: back_party(false), back_enemies(false), lateral_party(false), lateral_enemies(false)
88-
{}
87+
Terrain_Flags() noexcept {}
8988
} special_flags;
9089
int32_t special_back_party = 15;
9190
int32_t special_back_enemies = 10;

src/generated/lcf/rpg/trooppagecondition.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,20 @@ namespace rpg {
2929
struct TroopPageCondition_Flags {
3030
union {
3131
struct {
32-
bool switch_a;
33-
bool switch_b;
34-
bool variable;
35-
bool turn;
36-
bool fatigue;
37-
bool enemy_hp;
38-
bool actor_hp;
39-
bool turn_enemy;
40-
bool turn_actor;
41-
bool command_actor;
32+
bool switch_a = false;
33+
bool switch_b = false;
34+
bool variable = false;
35+
bool turn = false;
36+
bool fatigue = false;
37+
bool enemy_hp = false;
38+
bool actor_hp = false;
39+
bool turn_enemy = false;
40+
bool turn_actor = false;
41+
bool command_actor = false;
4242
};
4343
std::array<bool, 10> flags;
4444
};
45-
TroopPageCondition_Flags() noexcept: switch_a(false), switch_b(false), variable(false), turn(false), fatigue(false), enemy_hp(false), actor_hp(false), turn_enemy(false), turn_actor(false), command_actor(false)
46-
{}
45+
TroopPageCondition_Flags() noexcept {}
4746
} flags;
4847
int32_t switch_a_id = 1;
4948
int32_t switch_b_id = 1;

0 commit comments

Comments
 (0)