Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with dialog tags in EOC #61314

Merged
merged 8 commits into from
Sep 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 23 additions & 5 deletions src/npctalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,14 @@ void parse_tags( std::string &phrase, const Character &u, const Character &me,
var.pop_back();
global_variables &globvars = get_globals();
phrase.replace( fa, l, globvars.get_global_value( "npctalk_var_" + var ) );
} else if( tag.find( "<city>" ) != std::string::npos ) {
std::string cityname = "nowhere";
tripoint_abs_sm abs_sub = get_map().get_abs_sub();
const city *c = overmap_buffer.closest_city( abs_sub ).city;
if( c != nullptr ) {
cityname = c->name;
}
phrase.replace( fa, l, cityname );
} else if( !tag.empty() ) {
debugmsg( "Bad tag. '%s' (%d - %d)", tag.c_str(), fa, fb );
phrase.replace( fa, fb - fa + 1, "????" );
Expand Down Expand Up @@ -1707,8 +1715,13 @@ talk_data talk_response::create_option_line( const dialogue &d, const input_even
ftext = string_format( pgettext( "talk option", "[%1$s %2$d%%] %3$s" ),
trial.name(), trial.calc_chance( d ), text );
}
parse_tags( ftext, *d.actor( false )->get_character(), *d.actor( true )->get_npc(),
success.next_topic.item_type );
if( d.actor( true )->get_npc() ) {
parse_tags( ftext, *d.actor( false )->get_character(), *d.actor( true )->get_npc(),
success.next_topic.item_type );
} else {
parse_tags( ftext, *d.actor( false )->get_character(), *d.actor( false )->get_character(),
success.next_topic.item_type );
}

nc_color color;
std::set<dialogue_consequence> consequences = get_consequences( d );
Expand Down Expand Up @@ -1788,8 +1801,13 @@ talk_topic dialogue::opt( dialogue_window &d_win, const talk_topic &topic )
}

// Parse any tags in challenge
parse_tags( challenge, *actor( false )->get_character(), *actor( true )->get_npc(),
topic.item_type );
if( actor( true )->get_npc() ) {
parse_tags( challenge, *actor( false )->get_character(), *actor( true )->get_npc(),
topic.item_type );
} else {
parse_tags( challenge, *actor( false )->get_character(), *actor( false )->get_character(),
topic.item_type );
}
challenge = uppercase_first_letter( challenge );

d_win.clear_history_highlights();
Expand Down Expand Up @@ -1852,7 +1870,7 @@ talk_topic dialogue::opt( dialogue_window &d_win, const talk_topic &topic )
generate_response_lines();

ui.on_redraw( [&]( const ui_adaptor & ) {
d_win.draw( actor( true )->disp_name(), response_lines );
d_win.draw( d_win.is_not_conversation ? "" : actor( true )->disp_name(), response_lines );
} );

size_t response_ind = response_hotkeys.size();
Expand Down