Skip to content

persistence module doesn't handle dwarf arena mode well #6052

Backlog

Description

@ab9rf

While testing DFHack/scripts#1654, I got errors from autotraining and buildingplan/quick-filters about not being able to save persistent data. This is because arena mode doesn't have any means to persist data; these tools should not be trying to persist data in arena mode.

There are two interrelated defects here.

One is that these two tools (and likely others) are using the wrong gate logic to detect when they should enable. autotraining is meaningless in arena mode, but it tries to start anyway because it only checks gamemode for DWARF but dwarf arena mode is also gamemode == DWARF. Tools that should only run in dwarf mode, but not in dwarf arena mode, need to use dfhack.world.isFortressMode() instead to avoid incorrectly activating in dwarf arena mode.

The other is that the persistence layer is assuming that GetCurrentSiteId will return an actual site, and doesn't handle the -1 "no site" return cleanly, leading to a Lua error.

A brief scan identified prioritize, immortal-cravings, idle-crafting, husbandry, warn-stranded, source, emigration, hermit, fix/protect-nicks, and autofish as all exhibiting the same defect pattern - as well as the API documentation (at or about line 7924).

Activity

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

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions