Skip to content

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

Closed

Description

@ab9rf

Something goes wrong in building plan (and possibly other tools) when loading a reclaimed fort for the first time. The material filter options on the "Global settings" tab of the building plan filter dialogs are inoperative immediately after reclaiming a site. Clicking any of these buttons results in no change on the screen and the message "all contruction materials disabled; resetting config" is printed to the console each time a button is pressed.

Furthermore, during initial fortress load, the following errors are logged to the console, during or immediately after running onLoad.init

<path>\hack\lua\dfhack.lua:804: unable to save data in key 'autotraining'
stack traceback:
        [C]: in field '?'
        <path>\hack\lua\dfhack.lua:804: in upvalue 'persistent_saveData'
        <path>\hack\lua\dfhack.lua:818: in field 'saveSiteData'
        <path>/hack/scripts/autotraining.lua:51: in global 'persist_state'
        <path>/scripts/autotraining.lua:90: in function <E:/Kelly/DF/df_53_10_steam/hack/scripts/autotraining.lua:72>
true
<path>\hack\lua\dfhack.lua:804: unable to save data in key 'buildingplan/quick-filters'
stack traceback:
        [C]: in field '?'
        <path>\hack\lua\dfhack.lua:804: in upvalue 'persistent_saveData'
        <path>\hack\lua\dfhack.lua:818: in field 'saveSiteData'
        <path>\hack\lua\plugins\buildingplan\planneroverlay.lua:490: in function <<path>\hack\lua\plugins\buildingplan\planneroverlay.lua:477>

I don't know where that "true" came from. That itself is kinda weird. The fact that autotraining is also generating an error suggests that the problem is with the common API both use rather than with either tool itself.

Best guess this is an issue with the persistence API not working correctly in a newly reclaimed fort. The problem resolves when the fortress is saved and reloaded, so this is likely due to something along the lines of that a reclaimed procedurally generated fortress doesn't have a cosave yet, but the API is expecting there to be be one.

Activity

  1. moved this to Todo in 53.10-r2on Feb 9, 2026
  2. moved this from Todo to Has linked PR in 53.10-r2on Sep 16, 2026
  3. Alistair-Afton commented on Sep 16, 2026

    @Alistair-Afton
    Contributor

    Confirmed and fixed in #5923.

    The problem isn't a missing cosave — it's that plotinfo->site_id (yoursiteid) stays -1 on a newly reclaimed fortress until the first save. World::GetCurrentSiteId() returns that -1 verbatim in fortress mode, so is_good_entity_id rejects it and every saveSiteData/getSiteData call errors out — which is exactly the unable to save data tracebacks from autotraining and buildingplan. And since IsSiteLoaded() is false at SC_MAP_LOADED, the site-scoped persistence data is never loaded at all, which is why the buildingplan filter config stays empty (all material categories read as disabled → "resetting config" on every click).

    The fix: plotinfo->main.fortress_site is already set at embark time on a reclaim and points at the reclaimed site record — the same world_site that site_id resolves to after the first save. GetCurrentSiteId now falls back to fortress_site->id when site_id is negative, so site persistence works for the whole initial session.

    Verified live: with site_id forced to -1 on a loaded fort, saveSiteData produced the reported error before the fix and round-trips correctly through the site entity after it.

  4. added a commit that references this issue on Sep 17, 2026
    8367043
  5. moved this from Has linked PR to Done in 53.10-r2on Sep 17, 2026
  6. added a commit that references this issue on Sep 17, 2026
    6e84ca3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions