Skip to content

persistence: fall back to fortress_site when site_id is unassigned - #5923

Open
Alistair-Afton wants to merge 1 commit into
DFHack:developfrom
Alistair-Afton:fix-reclaim-site-id
Open

Alistair-Afton wants to merge 1 commit into
DFHack:developfrom
Alistair-Afton:fix-reclaim-site-id

Conversation

@Alistair-Afton

Copy link
Copy Markdown
Contributor

Summary

Fixes #5716

On a newly reclaimed fortress, plotinfo->site_id stays -1 until the first save. The persistent site data API (World::GetCurrentSiteIdAddPersistentSiteData/GetPersistentSiteDatadfhack.persistent.saveSiteData/getSiteData, and IsSiteLoaded gating the SC_MAP_LOADED data load) therefore failed for the entire initial reclaim session — producing unable to save data errors from autotraining and buildingplan and leaving buildingplan's per-site filter config unloaded (the inoperative "Global settings" buttons).

The plotinfo->main.fortress_site pointer is already set at embark time, so use it as a fallback when site_id is negative. On reclaim it points at the reclaimed site — the same world_site record that site_id resolves to once assigned (site history continues on the same record, e.g. history_event_site_retiredst with IS_UNRETIRE).

Test plan

  • Reproduced the reported error on a live fort: with plotinfo.site_id temporarily set to -1, dfhack.persistent.saveSiteData failed with unable to save data in key ...
  • With the fix installed: same scenario succeeds, and the data round-trips through the correct site entity (getSiteData/deleteSiteData verified against site id 25 both via the fallback and via normal site_id resolution)
  • Adventure-mode site resolution path unchanged

On a newly reclaimed fortress, plotinfo->site_id stays -1 until the
first save, so the persistent site data API (dfhack.persistent
.saveSiteData/getSiteData, World::IsSiteLoaded, and everything built
on them) failed for the whole initial session. The fortress_site
pointer is already set at embark time, so use it as a fallback when
site_id is negative.

Fixes DFHack#5716
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.

building-plan material filters broken in reclaimed fort - probably persistence api

1 participant