Skip to content

Commit

Permalink
Fix issue with dialog tags in EOC (CleverRaven#61314)
Browse files Browse the repository at this point in the history
* First

* Update npctalk.cpp

* Update npctalk.cpp

* Update npctalk.cpp

* Update npctalk.cpp

* Update npctalk.cpp

* Update npctalk.cpp

* Update npctalk.cpp
  • Loading branch information
Ramza13 authored and captainego committed Oct 9, 2022
1 parent fcb8d10 commit 33eb7b4
Showing 1 changed file with 23 additions and 5 deletions.
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

0 comments on commit 33eb7b4

Please sign in to comment.