Skip to content

Fix saveMapData not writing element attributes - #5531

Open
iManGaaX wants to merge 3 commits into
multitheftauto:masterfrom
iManGaaX:fix/saveMapData-attributes
Open

iManGaaX wants to merge 3 commits into
multitheftauto:masterfrom
iManGaaX:fix/saveMapData-attributes

Conversation

@iManGaaX

@iManGaaX iManGaaX commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

CElement::OutputToXML only wrote custom data and child nodes, so every element saved by saveMapData came out empty (<object>) and the file could not be loaded back

Adds CElement::WriteSpecialData, the counterpart of ReadSpecialData, and implements it for every element type the map loader supports: object, building, vehicle, ped, pickup, marker, blip, radar area, team, water and dummy. also writes the shared id / attachTo attributes and adds XMLColorFromInt for colour attributes

Colshapes are left out on purpose - they have no XML loading path, both map loaders fall through to a dummy element for them

Also teaches loadMapData about <building> nodes, which CResourceMapItem already supported

This PR also fixes #1473

Test plan

Created one of each element type, saved them with saveMapData, then loaded the resulting file back with loadMapData

Before ->
<object note="custom data" />

After ->
<object model="1337" posX="1.000000" posY="2.000000" posZ="3.000000" rotX="0.000000" ... alpha="255" scale="1.000000" note="custom data" />

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

saveMapData doesn't save attributes

1 participant