Skip to content

Commit

Permalink
Wrap the DF-style custom linked lists into a special container tag.
Browse files Browse the repository at this point in the history
This makes them appear as proper sequences in the gui.
  • Loading branch information
angavrilov committed Mar 4, 2012
1 parent 754a04a commit 0b6d1d0
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 40 deletions.
4 changes: 4 additions & 0 deletions StructFields.pm
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ my %custom_container_handlers = (
my $item = get_container_item_type($_, -void => 'void*');
return "DfArray<$item >";
},
'df-linked-list' => sub {
my $item = get_container_item_type($_);
return $item; # Just use the link type
},
);

my %custom_container_inits = (
Expand Down
16 changes: 16 additions & 0 deletions df-code.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
(def (class* eas) df-array (array-item data-field concrete-item)
())

(def (class* eas) df-linked-list (sequence-item data-field concrete-item)
())

(in-package :cl-linux-debug.data-info)

;; df-flagarray implementation
Expand Down Expand Up @@ -43,6 +46,19 @@
(when (< size most-positive-fixnum)
(setf ,ptr-var start ,cnt-var size)))))

;; df-linked-list implementation

(defmethod compute-effective-fields ((type df-linked-list))
(assert (type-name-of type))
(list
(make-instance 'compound :name $head :type-name (type-name-of type))))

(defmethod sequence-content-items ((type df-linked-list) ref)
(loop for cur = $ref.head.next then $cur.next
while (valid-ref? cur)
collect @cur.item into items
finally (return (coerce items 'vector))))

(in-package :cl-linux-debug.data-xml)

(defun find-entity (key) (find-by-id $global.world.entities.all $id key))
Expand Down
4 changes: 2 additions & 2 deletions df.map.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
<pointer type-name='block_square_event'/>
</stl-vector>

<compound name='block_burrows' type-name='block_burrow_link'/>
<df-linked-list name='block_burrows' type-name='block_burrow_link'/>

<int32_t name='local_feature'/>
<int32_t name='global_feature'/>
Expand Down Expand Up @@ -254,7 +254,7 @@

<static-array name='cave_columns' count='16'>
<static-array count='16'>
<compound type-name='cave_column_link'/>
<df-linked-list type-name='cave_column_link'/>
</static-array>
</static-array>

Expand Down
6 changes: 3 additions & 3 deletions df.world.xml
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@

-- Jobs and projectiles

<compound name='job_list' type-name='job_list_link'/>
<df-linked-list name='job_list' type-name='job_list_link'/>

<compound name='proj_list' type-name='proj_list_link'/>
<df-linked-list name='proj_list' type-name='proj_list_link'/>

-- Buildings

Expand Down Expand Up @@ -415,7 +415,7 @@

-- Adventure quests

<compound name='quests' type-name='quest_list_link'/>
<df-linked-list name='quests' type-name='quest_list_link'/>

-- Unknown

Expand Down
11 changes: 6 additions & 5 deletions linux/all.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8117,7 +8117,7 @@
"map_block","0","0x0","0x1d78","struct-type","map_block","",""
"map_block","1","0x0","0x4","block_flags","flags","",""
"map_block","1","0x4","0xc","stl-vector","block_events","block_square_event*",""
"map_block","1","0x10","0xc","block_burrow_link","block_burrows","",""
"map_block","1","0x10","0xc","df-linked-list","block_burrows","block_burrow_link",""
"map_block","1","0x1c","0x4","int32_t","local_feature","",""
"map_block","1","0x20","0x4","int32_t","global_feature","",""
"map_block","1","0x24","0x4","int32_t","unk2","",""
Expand Down Expand Up @@ -8166,7 +8166,8 @@
"map_block_column::anon2","1","0x10","0x4","static-array","unk2","uint8_t",""
"map_block_column","1","0x14","0x2","int16_t","z_base","",""
"map_block_column","1","0x18","0xc00","static-array","cave_columns","map_block_column::anon3",""
"map_block_column::anon3","0","0x0","0xc0","static-array","","cave_column_link",""
"map_block_column::anon3","0","0x0","0xc0","static-array","","map_block_column::anon4",""
"map_block_column::anon4","0","0x0","0xc","df-linked-list","","cave_column_link",""
"map_block_column","1","0xc18","0xc","stl-vector","column_rectangles","padding*",""
"map_block_column","1","0xc24","0x2","int16_t","unk_c2c","",""
"map_block_column","1","0xc28","0x8","df-flagarray","flags","flag-bit",""
Expand Down Expand Up @@ -12972,8 +12973,8 @@
"world","1","0x14098","0x18","compound","artifacts","",""
"world","2","0x14098","0xc","stl-vector","artifacts.all","artifact_record*",""
"world","2","0x140a4","0xc","stl-vector","artifacts.bad","artifact_record*",""
"world","1","0x140b0","0xc","job_list_link","job_list","",""
"world","1","0x140bc","0xc","proj_list_link","proj_list","",""
"world","1","0x140b0","0xc","df-linked-list","job_list","job_list_link",""
"world","1","0x140bc","0xc","df-linked-list","proj_list","proj_list_link",""
"world","1","0x140c8","0x420","compound","buildings","",""
"world","2","0x140c8","0xc","stl-vector","buildings.all","building*",""
"world","2","0x140d4","0x408","static-array","buildings.other","world::anon5",""
Expand Down Expand Up @@ -13005,7 +13006,7 @@
"world","2","0x14600","0xc","stl-vector","plants.all","plant*",""
"world","2","0x1460c","0x3c","static-array","plants.other","world::anon6",""
"world::anon6","0","0x0","0xc","stl-vector","","plant*",""
"world","1","0x14648","0xc","quest_list_link","quests","",""
"world","1","0x14648","0xc","df-linked-list","quests","quest_list_link",""
"world","1","0x14654","0x1f4","padding","","","bool array?"
"world","1","0x14848","0x3d090","static-array","unk_14818","int8_t",""
"world","1","0x518d8","0x4","int32_t","unk_518a8","",""
Expand Down
15 changes: 3 additions & 12 deletions linux/globals.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3340,14 +3340,8 @@
"world","1","0x958cf58","0x18","compound","world.artifacts","",""
"world","2","0x958cf58","0xc","stl-vector","world.artifacts.all","artifact_record*",""
"world","2","0x958cf64","0xc","stl-vector","world.artifacts.bad","artifact_record*",""
"world","1","0x958cf70","0xc","struct-type","world.job_list","",""
"world","2","0x958cf70","0x4","pointer","world.job_list.item","job",""
"world","2","0x958cf74","0x4","pointer","world.job_list.prev","job_list_link",""
"world","2","0x958cf78","0x4","pointer","world.job_list.next","job_list_link",""
"world","1","0x958cf7c","0xc","struct-type","world.proj_list","",""
"world","2","0x958cf7c","0x4","pointer","world.proj_list.item","projectile",""
"world","2","0x958cf80","0x4","pointer","world.proj_list.prev","proj_list_link",""
"world","2","0x958cf84","0x4","pointer","world.proj_list.next","proj_list_link",""
"world","1","0x958cf70","0xc","df-linked-list","world.job_list","job_list_link",""
"world","1","0x958cf7c","0xc","df-linked-list","world.proj_list","proj_list_link",""
"world","1","0x958cf88","0x420","compound","world.buildings","",""
"world","2","0x958cf88","0xc","stl-vector","world.buildings.all","building*",""
"world","2","0x958cf94","0x408","static-array","world.buildings.other","world::anon5",""
Expand Down Expand Up @@ -3468,10 +3462,7 @@
"world","3","0x958d4e4","0xc","stl-vector","world.plants.other[2]","plant*",""
"world","3","0x958d4f0","0xc","stl-vector","world.plants.other[3]","plant*",""
"world","3","0x958d4fc","0xc","stl-vector","world.plants.other[4]","plant*",""
"world","1","0x958d508","0xc","struct-type","world.quests","",""
"world","2","0x958d508","0x4","pointer","world.quests.item","adv_task",""
"world","2","0x958d50c","0x4","pointer","world.quests.prev","quest_list_link",""
"world","2","0x958d510","0x4","pointer","world.quests.next","quest_list_link",""
"world","1","0x958d508","0xc","df-linked-list","world.quests","quest_list_link",""
"world","1","0x958d514","0x1f4","padding","world","","bool array?"
"world","1","0x958d708","0x3d090","static-array","world.unk_14818","int8_t",""
"world","1","0x95ca798","0x4","int32_t","world.unk_518a8","",""
Expand Down
2 changes: 1 addition & 1 deletion lower-1.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
</xsl:template>

<!-- Misc containers: meta='container' subtype='$tag' -->
<xsl:template match='stl-vector|stl-deque|stl-bit-vector|df-flagarray|df-array'>
<xsl:template match='stl-vector|stl-deque|stl-bit-vector|df-flagarray|df-array|df-linked-list'>
<xsl:param name='level' select='-1'/>
<ld:field ld:meta='container'>
<xsl:attribute name='ld:level'><xsl:value-of select='$level'/></xsl:attribute>
Expand Down
11 changes: 6 additions & 5 deletions windows/all.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8117,7 +8117,7 @@
"map_block","0","0x0","0x1d88","struct-type","map_block","",""
"map_block","1","0x0","0x4","block_flags","flags","",""
"map_block","1","0x4","0x10","stl-vector","block_events","block_square_event*",""
"map_block","1","0x14","0xc","block_burrow_link","block_burrows","",""
"map_block","1","0x14","0xc","df-linked-list","block_burrows","block_burrow_link",""
"map_block","1","0x20","0x4","int32_t","local_feature","",""
"map_block","1","0x24","0x4","int32_t","global_feature","",""
"map_block","1","0x28","0x4","int32_t","unk2","",""
Expand Down Expand Up @@ -8166,7 +8166,8 @@
"map_block_column::anon2","1","0x10","0x4","static-array","unk2","uint8_t",""
"map_block_column","1","0x18","0x2","int16_t","z_base","",""
"map_block_column","1","0x1c","0xc00","static-array","cave_columns","map_block_column::anon3",""
"map_block_column::anon3","0","0x0","0xc0","static-array","","cave_column_link",""
"map_block_column::anon3","0","0x0","0xc0","static-array","","map_block_column::anon4",""
"map_block_column::anon4","0","0x0","0xc","df-linked-list","","cave_column_link",""
"map_block_column","1","0xc1c","0x10","stl-vector","column_rectangles","padding*",""
"map_block_column","1","0xc2c","0x2","int16_t","unk_c2c","",""
"map_block_column","1","0xc30","0x8","df-flagarray","flags","flag-bit",""
Expand Down Expand Up @@ -12972,8 +12973,8 @@
"world","1","0x14348","0x20","compound","artifacts","",""
"world","2","0x14348","0x10","stl-vector","artifacts.all","artifact_record*",""
"world","2","0x14358","0x10","stl-vector","artifacts.bad","artifact_record*",""
"world","1","0x14368","0xc","job_list_link","job_list","",""
"world","1","0x14374","0xc","proj_list_link","proj_list","",""
"world","1","0x14368","0xc","df-linked-list","job_list","job_list_link",""
"world","1","0x14374","0xc","df-linked-list","proj_list","proj_list_link",""
"world","1","0x14380","0x580","compound","buildings","",""
"world","2","0x14380","0x10","stl-vector","buildings.all","building*",""
"world","2","0x14390","0x560","static-array","buildings.other","world::anon5",""
Expand Down Expand Up @@ -13005,7 +13006,7 @@
"world","2","0x14a50","0x10","stl-vector","plants.all","plant*",""
"world","2","0x14a60","0x50","static-array","plants.other","world::anon6",""
"world::anon6","0","0x0","0x10","stl-vector","","plant*",""
"world","1","0x14ab0","0xc","quest_list_link","quests","",""
"world","1","0x14ab0","0xc","df-linked-list","quests","quest_list_link",""
"world","1","0x14abc","0x1f4","padding","","","bool array?"
"world","1","0x14cb0","0x3d090","static-array","unk_14818","int8_t",""
"world","1","0x51d40","0x4","int32_t","unk_518a8","",""
Expand Down
15 changes: 3 additions & 12 deletions windows/globals.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3226,14 +3226,8 @@
"world","1","0x179a030","0x20","compound","world.artifacts","",""
"world","2","0x179a030","0x10","stl-vector","world.artifacts.all","artifact_record*",""
"world","2","0x179a040","0x10","stl-vector","world.artifacts.bad","artifact_record*",""
"world","1","0x179a050","0xc","struct-type","world.job_list","",""
"world","2","0x179a050","0x4","pointer","world.job_list.item","job",""
"world","2","0x179a054","0x4","pointer","world.job_list.prev","job_list_link",""
"world","2","0x179a058","0x4","pointer","world.job_list.next","job_list_link",""
"world","1","0x179a05c","0xc","struct-type","world.proj_list","",""
"world","2","0x179a05c","0x4","pointer","world.proj_list.item","projectile",""
"world","2","0x179a060","0x4","pointer","world.proj_list.prev","proj_list_link",""
"world","2","0x179a064","0x4","pointer","world.proj_list.next","proj_list_link",""
"world","1","0x179a050","0xc","df-linked-list","world.job_list","job_list_link",""
"world","1","0x179a05c","0xc","df-linked-list","world.proj_list","proj_list_link",""
"world","1","0x179a068","0x580","compound","world.buildings","",""
"world","2","0x179a068","0x10","stl-vector","world.buildings.all","building*",""
"world","2","0x179a078","0x560","static-array","world.buildings.other","world::anon5",""
Expand Down Expand Up @@ -3354,10 +3348,7 @@
"world","3","0x179a768","0x10","stl-vector","world.plants.other[2]","plant*",""
"world","3","0x179a778","0x10","stl-vector","world.plants.other[3]","plant*",""
"world","3","0x179a788","0x10","stl-vector","world.plants.other[4]","plant*",""
"world","1","0x179a798","0xc","struct-type","world.quests","",""
"world","2","0x179a798","0x4","pointer","world.quests.item","adv_task",""
"world","2","0x179a79c","0x4","pointer","world.quests.prev","quest_list_link",""
"world","2","0x179a7a0","0x4","pointer","world.quests.next","quest_list_link",""
"world","1","0x179a798","0xc","df-linked-list","world.quests","quest_list_link",""
"world","1","0x179a7a4","0x1f4","padding","world","","bool array?"
"world","1","0x179a998","0x3d090","static-array","world.unk_14818","int8_t",""
"world","1","0x17d7a28","0x4","int32_t","world.unk_518a8","",""
Expand Down

0 comments on commit 0b6d1d0

Please sign in to comment.