Skip to content

Commit 89d7387

Browse files
committed
Return a simpler lambda early instead if we're in test mode
1 parent 6744a18 commit 89d7387

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/npctalk.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6383,6 +6383,25 @@ talk_effect_fun_t::func f_run_eoc_selector( const JsonObject &jo, std::string_vi
63836383
translation title = to_translation( "Select an option." );
63846384
jo.read( "title", title );
63856385

6386+
// Selector dialog can't be initialized in tests, so either cancel or activate first eoc
6387+
if( test_mode ) {
6388+
return [eocs, context, can_cancel]( dialogue & d ) {
6389+
if( allow_cancel ) {
6390+
return;
6391+
}
6392+
6393+
dialogue newDialog( d );
6394+
if( !context.empty() ) {
6395+
for( const auto &val : context[0] ) {
6396+
newDialog.set_value( val.first, val.second.evaluate( d ) );
6397+
}
6398+
}
6399+
const effect_on_condition_id first_eoc =
6400+
eocs[0].var ? effect_on_condition_id( eocs[0].var->evaluate( d ) ) : eocs[0].id;
6401+
first_eoc->activate( newDialog );
6402+
};
6403+
}
6404+
63866405
return [eocs, context, title, eoc_names, eoc_keys, eoc_descriptions,
63876406
hide_failing, allow_cancel, hilight_disabled]( dialogue & d ) {
63886407
uilist eoc_list;
@@ -6446,21 +6465,11 @@ talk_effect_fun_t::func f_run_eoc_selector( const JsonObject &jo, std::string_vi
64466465
return;
64476466
}
64486467

6449-
if( test_mode ) {
6450-
if( eoc_list.allow_cancel ) {
6451-
eoc_list.ret = -1;
6452-
} else {
6453-
eoc_list.ret = 0;
6454-
}
6455-
} else {
6456-
eoc_list.query();
6457-
}
6458-
6468+
eoc_list.query();
64596469
if( eoc_list.ret < 0 ) {
64606470
return;
64616471
}
64626472

6463-
64646473
// add context variables
64656474
dialogue newDialog( d );
64666475
int contextIndex = 0;

0 commit comments

Comments
 (0)