@@ -98,31 +98,37 @@ DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) {
9898// Invoked with DF suspended, and always before the matching plugin_onupdate.
9999// More event codes may be added in the future.
100100DFhackCExport command_result plugin_onstatechange (color_ostream &out, state_change_event event) {
101- DEBUG (status,out).print (" game state changed: %d\n " , event);
102-
103- if (is_enabled) {
104- switch (event) {
105- case SC_UNKNOWN :
106- break ;
107- case SC_WORLD_LOADED :
108- break ;
109- case SC_WORLD_UNLOADED :
110- break ;
111- case SC_MAP_LOADED :
112- break ;
113- case SC_MAP_UNLOADED :
114- break ;
115- case SC_VIEWSCREEN_CHANGED :
116- break ;
117- case SC_CORE_INITIALIZED :
118- break ;
119- case SC_BEGIN_UNLOAD :
120- break ;
121- case SC_PAUSED :
122- break ;
123- case SC_UNPAUSED :
124- break ;
125- }
101+ switch (event) {
102+ case SC_UNKNOWN :
103+ DEBUG (status,out).print (" game state changed: SC_UNKNOWN\n " );
104+ break ;
105+ case SC_WORLD_LOADED :
106+ DEBUG (status,out).print (" game state changed: SC_WORLD_LOADED\n " );
107+ break ;
108+ case SC_WORLD_UNLOADED :
109+ DEBUG (status,out).print (" game state changed: SC_WORLD_UNLOADED\n " );
110+ break ;
111+ case SC_MAP_LOADED :
112+ DEBUG (status,out).print (" game state changed: SC_MAP_LOADED\n " );
113+ break ;
114+ case SC_MAP_UNLOADED :
115+ DEBUG (status,out).print (" game state changed: SC_MAP_UNLOADED\n " );
116+ break ;
117+ case SC_VIEWSCREEN_CHANGED :
118+ DEBUG (status,out).print (" game state changed: SC_VIEWSCREEN_CHANGED\n " );
119+ break ;
120+ case SC_CORE_INITIALIZED :
121+ DEBUG (status,out).print (" game state changed: SC_CORE_INITIALIZED\n " );
122+ break ;
123+ case SC_BEGIN_UNLOAD :
124+ DEBUG (status,out).print (" game state changed: SC_BEGIN_UNLOAD\n " );
125+ break ;
126+ case SC_PAUSED :
127+ DEBUG (status,out).print (" game state changed: SC_PAUSED\n " );
128+ break ;
129+ case SC_UNPAUSED :
130+ DEBUG (status,out).print (" game state changed: SC_UNPAUSED\n " );
131+ break ;
126132 }
127133
128134 return CR_OK ;
@@ -145,14 +151,17 @@ DFhackCExport command_result plugin_onupdate (color_ostream &out) {
145151DFhackCExport command_result plugin_save_data (color_ostream &out) {
146152 DEBUG (status,out).print (" save or unload is imminent; time to persist state\n " );
147153
148- // Call functions in the Persistence module here.
154+ // Call functions in the Persistence module here. If your PersistantDataItem
155+ // objects are already up to date, then they will get persisted with the
156+ // save automatically and there is nothing extra you need to do here.
149157 return CR_OK ;
150158}
151159
152160DFhackCExport command_result plugin_load_data (color_ostream &out) {
153161 DEBUG (status,out).print (" world is loading; time to load persisted state\n " );
154162
155- // Call functions in the Persistence module here.
163+ // Call functions in the Persistence module here. See
164+ // persistent_per_save_example.cpp for an example.
156165 return CR_OK ;
157166}
158167
0 commit comments