Skip to content

Commit c5eb76c

Browse files
committed
Fix lengths of enum-linked arrays
to automatically infer the length based on the values in the enum, so that when Toady adds new enum entries we don't end up missing them. Also fix the siege engine facing direction fields to use a new enum with correct values.
1 parent c7da8a7 commit c5eb76c

34 files changed

+508
-325
lines changed

df.abstract_building.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
</struct-type>
116116

117117
<struct-type type-name='ab_reputation_infost'>
118-
<static-array name='reputation' type-name='int32_t' count='8' index-enum='abstract_building_reputation_type'/>
118+
<static-array name='reputation' type-name='int32_t' index-enum='abstract_building_reputation_type'/>
119119
</struct-type>
120120

121121
<class-type type-name='abstract_building' original-name='abstract_buildingst' key-field='id'>

df.adventure.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@
752752

753753
<struct-type type-name='adventure_rumor_infost'>
754754
<stl-vector name='base_data' pointer-type='adventure_rumor_datast' since='v0.44.10'/>
755-
<static-array name='data' count='34' index-enum='entity_event_type'>
755+
<static-array name='data' index-enum='entity_event_type'>
756756
<stl-vector pointer-type='adventure_rumor_datast'/>
757757
</static-array>
758758
</struct-type>

df.announcement.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@
136136

137137
<struct-type type-name='combat_event_listst'>
138138
<static-array name='slotdata' count='100' type-name='combat_eventst'/>
139-
<static-array name='slot_id_used' type-name='int16_t' count='38' index-enum='combat_report_event_type'/>
140-
<static-array name='slot_id_idx1' type-name='int16_t' count='38' index-enum='combat_report_event_type'/>
141-
<static-array name='slot_id_idx2' type-name='int16_t' count='38' index-enum='combat_report_event_type'/>
139+
<static-array name='slot_id_used' type-name='int16_t' index-enum='combat_report_event_type'/>
140+
<static-array name='slot_id_idx1' type-name='int16_t' index-enum='combat_report_event_type'/>
141+
<static-array name='slot_id_idx2' type-name='int16_t' index-enum='combat_report_event_type'/>
142142
<int16_t name='slots_used'/>
143143
</struct-type>
144144

df.belief_system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<stl-vector name='story' pointer-type='storyst'/>
2222
<stl-vector name='deities' type-name='int32_t' ref-target="historical_figure" comment="historical figure ID of gods the belief system is concerned with"/>
2323
<stl-vector name='worship_levels' type-name='int32_t' comment="worship level for each god referenced in the deities field"/>
24-
<static-array name='value' type-name='int32_t' count='64' index-enum='value_type'/>
24+
<static-array name='value' type-name='int32_t' count='64' index-enum='value_type'/> SAVE_VALUENUM
2525
</struct-type>
2626

2727
<struct-type type-name='belief_system_handlerst'>

df.building.xml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@
300300
<compound name='links' type-name='stockpile_links'/>
301301
<int32_t name='max_general_orders'/>
302302
<bitfield name='flags' base-type='uint32_t' type-name='workshop_profile_flag'/>
303-
<static-array name='blocked_labors' type-name='bool' count='94' index-enum='unit_labor'/>
303+
<static-array name='blocked_labors' type-name='bool' index-enum='unit_labor'/>
304304
</struct-type>
305305

306306
<class-type type-name='building' original-name='buildingst'
@@ -1402,20 +1402,21 @@
14021402
<enum-item name="BoltThrower"/>
14031403
</enum-type>
14041404

1405+
<enum-type type-name='siegeengine_orientation' base-type='int8_t'> no bay12 enum
1406+
<enum-item name='North'/>
1407+
<enum-item name='Northeast'/>
1408+
<enum-item name='East'/>
1409+
<enum-item name='Southeast'/>
1410+
<enum-item name='South'/>
1411+
<enum-item name='Southwest'/>
1412+
<enum-item name='West'/>
1413+
<enum-item name='Northwest'/>
1414+
</enum-type>
1415+
14051416
<class-type type-name='building_siegeenginest' inherits-from='building_actual'>
14061417
<enum base-type='int16_t' name="type" type-name='siegeengine_type'/>
1407-
<enum name='facing' base-type='int8_t'>
1408-
<enum-item name='Left'/>
1409-
<enum-item name='Up'/>
1410-
<enum-item name='Right'/>
1411-
<enum-item name='Down'/>
1412-
</enum>
1413-
<enum name='resting_orientation' base-type='int8_t'>
1414-
<enum-item name='Orientation_Left'/>
1415-
<enum-item name='Orientation_Up'/>
1416-
<enum-item name='Orientation_Right'/>
1417-
<enum-item name='Orientation_Down'/>
1418-
</enum>
1418+
<enum name='facing' type-name='siegeengine_orientation' base-type='int8_t'/>
1419+
<enum name='resting_orientation' type-name='siegeengine_orientation' base-type='int8_t'/>
14191420
<enum name='action' base-type='int8_t'>
14201421
<enum-item name='NotInUse'/>
14211422
<enum-item name='PrepareToFire'/>
@@ -1516,7 +1517,7 @@
15161517
</bitfield-type>
15171518

15181519
<class-type type-name='building_farmplotst' inherits-from='building_actual'>
1519-
<static-array name='plant_id' count='4'>
1520+
<static-array name='plant_id' index-enum='season'>
15201521
<int16_t ref-target='plant_raw'/>
15211522
</static-array>
15221523
<int32_t name='material_amount'/>
@@ -1775,7 +1776,7 @@
17751776
<!-- <item-attr name='civzone' value='ActivityZone'/> -->
17761777
</enum-item>
17771778

1778-
-- 98 different civzone subtypes
1779+
-- 98 different civzone subtypes: array of length BUILDING_CIVZONENUM
17791780
<enum-item name='ZONE_HOME'>
17801781
<item-attr name='building' value='Civzone'/>
17811782
<item-attr name='civzone' value='Home'/>

df.civagreement.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</enum-type>
2424

2525
<struct-type type-name='entity_sell_requests' original-name='civgoods_demandst'>
26-
<static-array count='107' index-enum='entity_sell_category' name='priority'>
26+
<static-array index-enum='entity_sell_category' name='priority'>
2727
<stl-vector type-name='int8_t'/>
2828
</static-array>
2929
</struct-type>
@@ -50,7 +50,7 @@
5050

5151
<struct-type type-name='entity_sell_prices' original-name='civ_tradeagreementst'>
5252
<pointer type-name='entity_sell_requests' name='items'/>
53-
<static-array count='107' index-enum='entity_sell_category' name='price'>
53+
<static-array index-enum='entity_sell_category' name='price'>
5454
<stl-vector type-name='int32_t'/>
5555
</static-array>
5656
</struct-type>

df.creature.xml

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@
426426
</struct-type>
427427

428428
<enum-type type-name='gait_type' base-type='int32_t'> bay12: GaitType
429+
<enum-item name='NONE' value='-1'/>
429430
<enum-item name='WALK'/>
430431
<enum-item name='FLY'/>
431432
<enum-item name='SWIM'/>
@@ -489,7 +490,7 @@
489490

490491
<bitfield name='flags' base-type='int32_t' type-name='body_flag' since='v0.34.01'/>
491492

492-
<static-array name='gait_info' count="5" index-enum='gait_type'>
493+
<static-array name='gait_info' index-enum='gait_type'>
493494
<stl-vector pointer-type='gait_info'/>
494495
</static-array>
495496

@@ -501,17 +502,17 @@
501502
<int32_t name='fraction_fat'/>
502503
<int32_t name='fraction_muscle'/>
503504

504-
<static-array name='default_gait_index' count="5" index-enum='gait_type' type-name='int32_t'/>
505-
<static-array name='fastest_gait_index' count="5" index-enum='gait_type' type-name='int32_t'/>
506-
<static-array name='slowest_gait_index' count="5" index-enum='gait_type' type-name='int32_t'/>
505+
<static-array name='default_gait_index' index-enum='gait_type' type-name='int32_t'/>
506+
<static-array name='fastest_gait_index' index-enum='gait_type' type-name='int32_t'/>
507+
<static-array name='slowest_gait_index' index-enum='gait_type' type-name='int32_t'/>
507508

508509
<pointer name='clothing_items' type-name='clothing_needsst'/>
509510
</struct-type>
510511

511512
<struct-type type-name='creature_personality_profilest'>
512-
<static-array type-name='int16_t' name='min' count='50' index-enum='personality_facet_type'/>
513-
<static-array type-name='int16_t' name='med' count='50' index-enum='personality_facet_type'/>
514-
<static-array type-name='int16_t' name='max' count='50' index-enum='personality_facet_type'/>
513+
<static-array type-name='int16_t' name='min' index-enum='personality_facet_type'/>
514+
<static-array type-name='int16_t' name='med' index-enum='personality_facet_type'/>
515+
<static-array type-name='int16_t' name='max' index-enum='personality_facet_type'/>
515516
</struct-type>
516517

517518
<enum-type type-name='secretion_condition'> bay12: SecretionCondition, no base type
@@ -536,13 +537,13 @@
536537
<stl-string name='token'/>
537538

538539
<static-array name='texpos' count='2'>
539-
<static-array count='7' index-enum='creature_graphics_role'>
540+
<static-array index-enum='creature_graphics_role'>
540541
<static-array count='3'><static-array count='2' type-name='int32_t'/></static-array>
541542
</static-array>
542543
</static-array>
543-
<static-array name='texpos_add_color' count='7' index-enum='creature_graphics_role' type-name='int8_t'/>
544+
<static-array name='texpos_add_color' index-enum='creature_graphics_role' type-name='int8_t'/>
544545
<static-array name='sheet_icon_texpos' count='2'>
545-
<static-array count='7' index-enum='creature_graphics_role' type-name='int32_t'/>
546+
<static-array index-enum='creature_graphics_role' type-name='int32_t'/>
546547
</static-array>
547548
</struct-type>
548549

@@ -706,34 +707,34 @@
706707
</enum-type>
707708

708709
<struct-type type-name='creature_raw_graphics' original-name='creature_graphicsst'>
709-
<static-array name='creature_texture_texpos' count='2'><static-array count='7' index-enum='creature_graphics_role'><static-array count='3'><static-array type-name='int32_t' count='2'/></static-array></static-array></static-array>
710-
<static-array name='creature_texture_add_color' type-name='bool' count='7' index-enum='creature_graphics_role'/>
711-
<static-array name='creature_texture_sheet_icon_texpos' count='2'><static-array type-name='int32_t' count='7' index-enum='creature_graphics_role'/></static-array>
710+
<static-array name='creature_texture_texpos' count='2'><static-array index-enum='creature_graphics_role'><static-array count='3'><static-array type-name='int32_t' count='2'/></static-array></static-array></static-array>
711+
<static-array name='creature_texture_add_color' type-name='bool' index-enum='creature_graphics_role'/>
712+
<static-array name='creature_texture_sheet_icon_texpos' count='2'><static-array type-name='int32_t' index-enum='creature_graphics_role'/></static-array>
712713

713-
<static-array name='entity_link_texpos' count='2'><static-array count='18' index-enum='histfig_entity_link_type'><static-array count='7' index-enum='creature_graphics_role'><static-array count='3'><static-array count='2' type-name='int32_t'/></static-array></static-array></static-array></static-array>
714-
<static-array name='entity_link_add_color' count='18' index-enum='histfig_entity_link_type'><static-array type-name='bool' count='7' index-enum='creature_graphics_role'/></static-array>
715-
<static-array name='entity_link_sheet_icon_texpos' count='2'><static-array count='18' index-enum='histfig_entity_link_type'><static-array type-name='int32_t' count='7' index-enum='creature_graphics_role'/></static-array></static-array>
714+
<static-array name='entity_link_texpos' count='2'><static-array index-enum='creature_graphics_role'><static-array index-enum='histfig_entity_link_type'><static-array count='3'><static-array count='2' type-name='int32_t'/></static-array></static-array></static-array></static-array>
715+
<static-array name='entity_link_add_color' index-enum='creature_graphics_role'><static-array type-name='bool' index-enum='histfig_entity_link_type'/></static-array>
716+
<static-array name='entity_link_sheet_icon_texpos' count='2'><static-array index-enum='creature_graphics_role'><static-array type-name='int32_t' index-enum='histfig_entity_link_type'/></static-array></static-array>
716717

717-
<static-array name='site_link_texpos' count='2'><static-array count='10' index-enum='histfig_site_link_type'><static-array count='7' index-enum='creature_graphics_role'><static-array count='3'><static-array count='2' type-name='int32_t'/></static-array></static-array></static-array></static-array>
718-
<static-array name='site_link_add_color' count='10' index-enum='histfig_site_link_type'><static-array type-name='bool' count='7' index-enum='creature_graphics_role'/></static-array>
719-
<static-array name='site_link_sheet_icon_texpos' count='2'><static-array count='10' index-enum='histfig_site_link_type'><static-array type-name='int32_t' count='7' index-enum='creature_graphics_role'/></static-array></static-array>
718+
<static-array name='site_link_texpos' count='2'><static-array index-enum='creature_graphics_role'><static-array index-enum='histfig_site_link_type'><static-array count='3'><static-array count='2' type-name='int32_t'/></static-array></static-array></static-array></static-array>
719+
<static-array name='site_link_add_color' index-enum='creature_graphics_role'><static-array type-name='bool' index-enum='histfig_site_link_type'/></static-array>
720+
<static-array name='site_link_sheet_icon_texpos' count='2'><static-array index-enum='creature_graphics_role'><static-array type-name='int32_t' index-enum='histfig_site_link_type'/></static-array></static-array>
720721

721-
<static-array name='profession_texpos' count='2'><static-array count='135' index-enum='profession'><static-array count='7' index-enum='creature_graphics_role'><static-array count='3'><static-array count='2' type-name='int32_t'/></static-array></static-array></static-array></static-array>
722-
<static-array name='profession_add_color' count='135' index-enum='profession'><static-array type-name='bool' count='7' index-enum='creature_graphics_role'/></static-array>
723-
<static-array name='profession_sheet_icon_texpos' count='2'><static-array count='135' index-enum='profession'><static-array type-name='int32_t' count='7' index-enum='creature_graphics_role'/></static-array></static-array>
722+
<static-array name='profession_texpos' count='2'><static-array index-enum='creature_graphics_role'><static-array index-enum='profession'><static-array count='3'><static-array count='2' type-name='int32_t'/></static-array></static-array></static-array></static-array>
723+
<static-array name='profession_add_color' index-enum='creature_graphics_role'><static-array type-name='bool' index-enum='profession'/></static-array>
724+
<static-array name='profession_sheet_icon_texpos' count='2'><static-array index-enum='creature_graphics_role'><static-array type-name='int32_t' index-enum='profession'/></static-array></static-array>
724725

725726
<stl-vector name='position_graphics' pointer-type='creature_position_graphicst'/>
726727
<stl-vector name='graphics_layer_set' pointer-type='creature_graphics_layer_setst'/>
727728

728-
<static-array name='creature_small_texpos' type-name='int32_t' count='12' index-enum='creature_small_texture_type'/>
729+
<static-array name='creature_small_texpos' type-name='int32_t' index-enum='creature_small_texture_type'/>
729730

730731
<int32_t name='egg_texpos'/>
731732
<int32_t name='list_icon_texpos'/>
732733
<int32_t name='skeleton_with_skull_texpos'/>
733734
<int32_t name='skeleton_texpos'/>
734735

735-
<static-array name='layer_unitless_texpos' count='135' index-enum='profession'><static-array count='3'><static-array count='2'><stl-vector type-name='int32_t'/></static-array></static-array></static-array>
736-
<static-array name='layer_unitless_sheet_icon_texpos' count='135' index-enum='profession'><stl-vector type-name='int32_t'/></static-array>
736+
<static-array name='layer_unitless_texpos' index-enum='profession'><static-array count='3'><static-array count='2'><stl-vector type-name='int32_t'/></static-array></static-array></static-array>
737+
<static-array name='layer_unitless_sheet_icon_texpos' index-enum='profession'><stl-vector type-name='int32_t'/></static-array>
737738

738739
<int32_t name='texpos_glow'/>
739740
<int32_t name='texpos_glow_left_gone'/>
@@ -1046,24 +1047,24 @@
10461047
<stl-vector name='caste_speech_token' pointer-type='stl-string'/>
10471048

10481049
<static-array name='skill_rates' count='4'> learn_ip_perc, last_used, rust, demote
1049-
<static-array type-name='int32_t' count='149' index-enum='job_skill'/>
1050+
<static-array type-name='int32_t' index-enum='job_skill'/>
10501051
</static-array>
10511052

10521053
<compound name='attributes'> not a compound
1053-
<static-array name='phys_att_range' count='6' index-enum='physical_attribute_type'>
1054+
<static-array name='phys_att_range' index-enum='physical_attribute_type'>
10541055
<static-array type-name='int32_t' count='7'/>
10551056
</static-array>
1056-
<static-array name='ment_att_range' count='13' index-enum='mental_attribute_type'>
1057+
<static-array name='ment_att_range' index-enum='mental_attribute_type'>
10571058
<static-array type-name='int32_t' count='7'/>
10581059
</static-array>
1059-
<static-array name='phys_att_rates' count='6' index-enum='physical_attribute_type'>
1060+
<static-array name='phys_att_rates' index-enum='physical_attribute_type'>
10601061
<static-array type-name='int32_t' count='4'/>
10611062
</static-array>
1062-
<static-array name='ment_att_rates' count='13' index-enum='mental_attribute_type'>
1063+
<static-array name='ment_att_rates' index-enum='mental_attribute_type'>
10631064
<static-array type-name='int32_t' count='4'/>
10641065
</static-array>
1065-
<static-array type-name='int32_t' name='phys_att_cap_perc' count='6' index-enum='physical_attribute_type'/>
1066-
<static-array type-name='int32_t' name='ment_att_cap_perc' count='13' index-enum='mental_attribute_type'/>
1066+
<static-array type-name='int32_t' name='phys_att_cap_perc' index-enum='physical_attribute_type'/>
1067+
<static-array type-name='int32_t' name='ment_att_cap_perc' index-enum='mental_attribute_type'/>
10671068
</compound>
10681069

10691070
<enum name='sex' type-name='pronoun_type'/>
@@ -1103,10 +1104,10 @@
11031104
<stl-vector name='tissue_styles' pointer-type='tissue_style_raw'/>
11041105
<stl-vector name='shearable_tissue_layer' pointer-type='shearable_tissue_layerst'/>
11051106

1106-
<static-array name='body_app_mode_rate_index' count='4'>
1107-
<stl-vector/>
1107+
<static-array name='body_app_mode_rate_index' index-enum='appearance_modifier_growth_interval'>
1108+
<stl-vector type-name='int32_t'/>
11081109
</static-array>
1109-
<static-array name='bp_app_mode_rate_index' count='4'>
1110+
<static-array name='bp_app_mode_rate_index' index-enum='appearance_modifier_growth_interval'>
11101111
<stl-vector type-name='int32_t'/>
11111112
</static-array>
11121113

@@ -1255,9 +1256,9 @@
12551256
</compound>
12561257

12571258
<stl-vector name='sound' pointer-type='creature_soundst'/>
1258-
<stl-vector type-name='int32_t' name='sound_alert'/> bay12: vector[CreatureSoundType]
1259-
<stl-vector type-name='int32_t' name='sound_peaceful_intermittent'
1260-
refers-to='$$._global.sound[$]'/>
1259+
<static-array name='sound_index' index-enum='creature_sound_type'>
1260+
<stl-vector type-name='int32_t' refers-to='$$._global.sound[$]'/>
1261+
</static-array>
12611262

12621263
<stl-vector name='material_force_adjust' since='v0.34.01' pointer-type='material_force_adjustst'/>
12631264

df.cultural_identity.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
<int32_t name="site_id" ref-target='world_site'/>
4040
<int32_t name="civ_id" ref-target='historical_entity'/>
4141
<stl-vector name='group_log' pointer-type='cultural_identity_entityst' comment='the circumstances of groups joining or leaving this culture'/>
42-
<static-array name='ethic' count='22' type-name='ethic_response' index-enum='ethic_type'/>
43-
<static-array name='values' type-name='int32_t' count='64' index-enum='value_type'/>
42+
<static-array name='ethic' type-name='ethic_response' index-enum='ethic_type'/>
43+
<static-array name='values' type-name='int32_t' count='64' index-enum='value_type'/> SAVE_VALUENUM
4444
<stl-vector name='events' pointer-type='entity_event'/>
4545
<int32_t name='world_general_knowledge_year' init-value='-1'/>
4646
<stl-vector name="known_heid" type-name='int32_t' ref-target='history_event'/>

0 commit comments

Comments
 (0)