@ -80,18 +80,6 @@ inline void saveConfig() {
}
}
}
}
//struct player_pause_hook : df::viewscreen_dwarfmodest {
// typedef df::viewscreen_dwarfmodest interpose_base;
// DEFINE_VMETHOD_INTERPOSE(void, feed, (std::set<df::interface_key>* input)) {
// if ((ui->main.mode == ui_sidebar_mode::Default) && !allow_player_pause) {
// input->erase(interface_key::D_PAUSE);
// }
// INTERPOSE_NEXT(feed)(input);
// }
//};
//
//IMPLEMENT_VMETHOD_INTERPOSE(player_pause_hook, feed);
command_result spectate ( color_ostream & out , std : : vector < std : : string > & parameters ) ;
command_result spectate ( color_ostream & out , std : : vector < std : : string > & parameters ) ;
DFhackCExport command_result plugin_init ( color_ostream & out , std : : vector < PluginCommand > & commands ) {
DFhackCExport command_result plugin_init ( color_ostream & out , std : : vector < PluginCommand > & commands ) {
@ -206,7 +194,6 @@ void enable_auto_unpause(color_ostream &out, bool state) {
// we don't need to do any of this yet if the plugin isn't enabled
// we don't need to do any of this yet if the plugin isn't enabled
if ( enabled ) {
if ( enabled ) {
// todo: R.E. UNDEAD_ATTACK event [still pausing regardless of announcement settings]
// todo: R.E. UNDEAD_ATTACK event [still pausing regardless of announcement settings]
if ( pause_lock ) {
// lock_collision == true means: enable_auto_unpause() was already invoked and didn't complete
// lock_collision == true means: enable_auto_unpause() was already invoked and didn't complete
// The onupdate function above ensure the procedure properly completes, thus we only care about
// The onupdate function above ensure the procedure properly completes, thus we only care about
// state reversal here ergo `enabled != state`
// state reversal here ergo `enabled != state`
@ -251,7 +238,6 @@ void enable_auto_unpause(color_ostream &out, bool state) {
pause_lock - > reportLocks ( out ) ;
pause_lock - > reportLocks ( out ) ;
}
}
}
}
}
unpause_enabled = state ;
unpause_enabled = state ;
}
}
@ -277,7 +263,7 @@ command_result spectate (color_ostream &out, std::vector <std::string> & paramet
focus_jobs_enabled = state ;
focus_jobs_enabled = state ;
} else if ( parameters [ 1 ] = = " tick-threshold " & & set & & parameters . size ( ) = = 3 ) {
} else if ( parameters [ 1 ] = = " tick-threshold " & & set & & parameters . size ( ) = = 3 ) {
try {
try {
tick_threshold = std : : stol( parameters [ 2 ] ) ;
tick_threshold = std : : abs( 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 ( ) ) ;
}
}
@ -298,7 +284,6 @@ command_result spectate (color_ostream &out, std::vector <std::string> & paramet
// every tick check whether to decide to follow a dwarf
// every tick check whether to decide to follow a dwarf
void onTick ( color_ostream & out , void * ptr ) {
void onTick ( color_ostream & out , void * ptr ) {
if ( ! df : : global : : ui ) return ;
int32_t tick = df : : global : : world - > frame_counter ;
int32_t tick = df : : global : : world - > frame_counter ;
if ( our_dorf ) {
if ( our_dorf ) {
if ( ! Units : : isAlive ( our_dorf ) ) {
if ( ! Units : : isAlive ( our_dorf ) ) {
@ -315,7 +300,6 @@ void onTick(color_ostream& out, void* ptr) {
dwarves . push_back ( unit ) ;
dwarves . push_back ( unit ) ;
}
}
std : : uniform_int_distribution < uint64_t > follow_any ( 0 , dwarves . size ( ) - 1 ) ;
std : : uniform_int_distribution < uint64_t > follow_any ( 0 , dwarves . size ( ) - 1 ) ;
if ( df : : global : : ui ) {
// if you're looking at a warning about a local address escaping, it means the unit* from dwarves (which aren't local)
// if you're looking at a warning about a local address escaping, it means the unit* from dwarves (which aren't local)
our_dorf = dwarves [ follow_any ( RNG ) ] ;
our_dorf = dwarves [ follow_any ( RNG ) ] ;
df : : global : : ui - > follow_unit = our_dorf - > id ;
df : : global : : ui - > follow_unit = our_dorf - > id ;
@ -324,7 +308,7 @@ void onTick(color_ostream& out, void* ptr) {
if ( ! job_watched ) {
if ( ! job_watched ) {
timestamp = tick ;
timestamp = tick ;
}
}
}
}
}
}
}
@ -345,8 +329,7 @@ void onJobStart(color_ostream& out, void* job_ptr) {
std : : bernoulli_distribution follow_job ( p ) ;
std : : bernoulli_distribution follow_job ( p ) ;
if ( ! job - > flags . bits . special & & follow_job ( RNG ) ) {
if ( ! job - > flags . bits . special & & follow_job ( RNG ) ) {
job_watched = job ;
job_watched = job ;
df : : unit * unit = Job : : getWorker ( job ) ;
if ( df : : unit * unit = Job : : getWorker ( job ) ) {
if ( df : : global : : ui & & unit ) {
our_dorf = unit ;
our_dorf = unit ;
df : : global : : ui - > follow_unit = unit - > id ;
df : : global : : ui - > follow_unit = unit - > id ;
}
}
@ -360,11 +343,9 @@ void onJobStart(color_ostream& out, void* job_ptr) {
nonworkers . push_back ( unit ) ;
nonworkers . push_back ( unit ) ;
}
}
std : : uniform_int_distribution < > follow_drunk ( 0 , nonworkers . size ( ) - 1 ) ;
std : : uniform_int_distribution < > follow_drunk ( 0 , nonworkers . size ( ) - 1 ) ;
if ( df : : global : : ui ) {
df : : global : : ui - > follow_unit = nonworkers [ follow_drunk ( RNG ) ] - > id ;
df : : global : : ui - > follow_unit = nonworkers [ follow_drunk ( RNG ) ] - > id ;
}
}
}
}
}
}
}
// every job completed can be forgotten about
// every job completed can be forgotten about