@ -136,7 +136,6 @@ DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) {
EM : : registerListener ( EventType : : TICK , ticking , plugin_self ) ;
EM : : registerListener ( EventType : : TICK , ticking , plugin_self ) ;
EM : : registerListener ( EventType : : JOB_STARTED , start , plugin_self ) ;
EM : : registerListener ( EventType : : JOB_STARTED , start , plugin_self ) ;
EM : : registerListener ( EventType : : JOB_COMPLETED , complete , plugin_self ) ;
EM : : registerListener ( EventType : : JOB_COMPLETED , complete , plugin_self ) ;
out . print ( " running: spectate auto-unpause %d \n " , unpause_enabled ) ;
enabled = true ; // enable_auto_unpause won't do anything without this set now
enabled = true ; // enable_auto_unpause won't do anything without this set now
enable_auto_unpause ( out , unpause_enabled ) ;
enable_auto_unpause ( out , unpause_enabled ) ;
} else if ( ! enable & & enabled ) {
} else if ( ! enable & & enabled ) {
@ -191,6 +190,7 @@ DFhackCExport command_result plugin_onupdate(color_ostream &out) {
// dismiss announcement popup(s)
// dismiss announcement popup(s)
Gui : : getCurViewscreen ( true ) - > feed_key ( interface_key : : CLOSE_MEGA_ANNOUNCEMENT ) ;
Gui : : getCurViewscreen ( true ) - > feed_key ( interface_key : : CLOSE_MEGA_ANNOUNCEMENT ) ;
if ( World : : ReadPauseState ( ) ) {
if ( World : : ReadPauseState ( ) ) {
// WARNING: This has a possibility of conflicting with `reveal hell` - if Hermes himself runs `reveal hell` on precisely the right moment that is
World : : SetPauseState ( false ) ;
World : : SetPauseState ( false ) ;
}
}
}
}
@ -257,37 +257,28 @@ void enable_auto_unpause(color_ostream &out, bool state) {
command_result spectate ( color_ostream & out , std : : vector < std : : string > & parameters ) {
command_result spectate ( color_ostream & out , std : : vector < std : : string > & parameters ) {
if ( ! parameters . empty ( ) ) {
if ( ! parameters . empty ( ) ) {
if ( parameters . size ( ) % 2 ! = 0 ) {
if ( parameters . size ( ) > = 2 & & parameters . size ( ) < = 3 ) {
return DFHack : : CR_WRONG_USAGE ;
bool state ;
}
bool set = false ;
for ( size_t i = 0 ; i + 1 < parameters . size ( ) ; i + = 2 ) {
if ( parameters [ 0 ] = = " enable " ) {
if ( parameters [ i ] = = " auto-unpause " ) {
state = true ;
if ( parameters [ i + 1 ] = = " 0 " ) {
} else if ( parameters [ 0 ] = = " disable " ) {
enable_auto_unpause ( out , false ) ;
state = false ;
} else if ( parameters [ i + 1 ] = = " 1 " ) {
} else if ( parameters [ 0 ] = = " set " ) {
enable_auto_unpause ( out , true ) ;
set = true ;
} else {
} else {
return DFHack : : CR_WRONG_USAGE ;
return DFHack : : CR_WRONG_USAGE ;
}
}
} else if ( parameters [ i ] = = " auto-disengage " ) {
auto & arg = parameters [ 1 ] ;
if ( parameters [ i + 1 ] = = " 0 " ) {
if ( arg = = " auto-unpause " ) {
disengage_enabled = false ;
enable_auto_unpause ( out , state ) ;
} else if ( parameters [ i + 1 ] = = " 1 " ) {
} else if ( arg = = " auto-disengage " ) {
disengage_enabled = true ;
disengage_enabled = state ;
} else {
} else if ( arg = = " focus-jobs " ) {
return DFHack : : CR_WRONG_USAGE ;
focus_jobs_enabled = state ;
}
} else if ( arg = = " tick-threshold " & & set & & parameters . size ( ) = = 3 ) {
} else if ( parameters [ i ] = = " focus-jobs " ) {
if ( parameters [ i + 1 ] = = " 0 " ) {
focus_jobs_enabled = false ;
} else if ( parameters [ i + 1 ] = = " 1 " ) {
focus_jobs_enabled = true ;
} else {
return DFHack : : CR_WRONG_USAGE ;
}
} else if ( parameters [ i ] = = " tick-threshold " ) {
try {
try {
tick_threshold = std : : stol ( parameters [ i + 1 ] ) ;
tick_threshold = std : : stol ( parameters [ 2 ] ) ;
} catch ( const std : : exception & e ) {
} catch ( const std : : exception & e ) {
out . printerr ( " %s \n " , e . what ( ) ) ;
out . printerr ( " %s \n " , e . what ( ) ) ;
}
}