Is your feature request related to a problem? Please describe.
I was having problems using the OBJECT rescomp type to read objects from my Tiled map - the generated objects array was of non-zero size but was empty. Inspecting the generated rescomp files confirmed that the arrays existed but were empty:
.align 2
map_inca_1_obj_object_1:
.align 2
.global map_inca_1_obj
map_inca_1_obj:
dc.l map_inca_1_obj_object_1
After some investigation, it turns out the issue was that my objects were 'object templates'. Detaching my objects solved the issue.
Object templates are how objects are usually stored in a Tiled project and are a separate .tx file containing the object template data. The problem is when you place the object in a map, instead of saving the object data as a <object> in the <objectgroup> group of objects as normal, Tiles instead saves a file path reference to the .tx file along with any value overrides for this template instance. It seems that this reference is what ResComp isn't able to handle.
Detaching the object removes the template reference and stores the object as a raw object as normal in the objectgroup, which ResComp handles fine.
Describe the solution you'd like
- While support for Tiled object templates would be very useful...
- ...an acceptable solution would also be an error message and/or failed compile when an object template is encountered.
Detaching the objects can be done manually, or as a default option when doing exports (if using exports), but it would have been nice if the build gave an error message to alert on this bug, or even failed to avoid the bug entirely..
Additional context
Here is an example of the issue.
Map with one detached object and one template object:
<objectgroup id="3" name="obj">
<object id="1" gid="2147484069" x="116" y="64" width="16" height="16">
<properties>
<property name="ObjectType" type="int" propertytype="ObjectTypeEnum" value="1"/>
<property name="exportPosition" type="bool" value="true"/>
<property name="exportSize" type="bool" value="true"/>
</properties>
</object>
<object id="2" template="templates/object_player.tx" x="176" y="64"/>
</objectgroup>
resources.s definitions show the second object fails to be exported and is empty, see the empty map_inca_1_obj_object_2 definition:
.align 2
map_inca_1_obj_object_1:
dc.w 116 // x
dc.w 64 // y
dc.w 16 // width
dc.w 16 // height
dc.b 1 // objecttype
.align 2
map_inca_1_obj_object_2:
.align 2
.global map_inca_1_obj
map_inca_1_obj:
dc.l map_inca_1_obj_object_1
dc.l map_inca_1_obj_object_2
Also, the resources.h show there should be two values, but inspecting the ROM data and the symbol.txt shows the value for the second object is not added:
extern const void* map_inca_1_obj[2];
The rescomp tool or compiler gives no error that I can see when compiling this.
Is your feature request related to a problem? Please describe.
I was having problems using the OBJECT rescomp type to read objects from my Tiled map - the generated objects array was of non-zero size but was empty. Inspecting the generated rescomp files confirmed that the arrays existed but were empty:
After some investigation, it turns out the issue was that my objects were 'object templates'. Detaching my objects solved the issue.
Object templates are how objects are usually stored in a Tiled project and are a separate .tx file containing the object template data. The problem is when you place the object in a map, instead of saving the object data as a
<object>in the<objectgroup>group of objects as normal, Tiles instead saves a file path reference to the .tx file along with any value overrides for this template instance. It seems that this reference is what ResComp isn't able to handle.Detaching the object removes the template reference and stores the object as a raw object as normal in the objectgroup, which ResComp handles fine.
Describe the solution you'd like
Detaching the objects can be done manually, or as a default option when doing exports (if using exports), but it would have been nice if the build gave an error message to alert on this bug, or even failed to avoid the bug entirely..
Additional context
Here is an example of the issue.
Map with one detached object and one template object:
resources.s definitions show the second object fails to be exported and is empty, see the empty
map_inca_1_obj_object_2definition:Also, the resources.h show there should be two values, but inspecting the ROM data and the
symbol.txtshows the value for the second object is not added:The rescomp tool or compiler gives no error that I can see when compiling this.