DFHack / dfhack

Memory hacking library for Dwarf Fortress and a set of tools that use it
Other
1.87k stars 475 forks source link

Seedwatch ignores map load event, prevents autoloading of plugin. #682

Closed ninmonkey closed 3 years ago

ninmonkey commented 9 years ago

Summary:

If you try to auto-load seedwatch it will always fail, because it ignores DF's map load event.

Fix

I think the only code change required is:

case SC_MAP_LOADED:
case SC_MAP_UNLOADED:

to:

case SC_MAP_LOADED:
    running = true;
    out.print("seedwatch supervision started.\n");
    break;

case SC_MAP_UNLOADED:

Because seedwatch start only toggles a bool.

Details:

Placing into one of the automatically ran config files such as onLoadWorld.init or PyLNP_dfhack_onLoad.init (From the PyLNP pack) will not work. Which gives the following DFHack output error:

seedwatch deactivated due to game load/unload

This is the config used:

# autobutcher runs fine; yet seedwatcher fails.
enable seedwatch
enable autobutcher
seedwatch start
autobutcher autowatch
autobutcher start

# Debug output shows seedwatcher fails
seedwatch info
autobutcher list

Even with this config every game save and load you must retype seedwatch start.

This is because seedwatcher does not load on DFHack::SC_MAP_LOADED, compared to autobutcher which does. (Seedwatcher toggles itself off when the event fires).

lethosor commented 9 years ago

It looks like seedwatch is supposed to disable itself when a new world loads, although I'm not exactly sure why - it could be that it only stores settings globally, or that restriction could be outdated (it's a very old plugin, given the comment that it doesn't work on Linux, which has been inaccurate since at least 2010). Also, your proposed fix will enable seedwatch for everyone when a world loads - it should at least check to make sure the plugin's enabled.