Skip to content

Commit

Permalink
Explicitly check the value of a boolean JSON object member.
Browse files Browse the repository at this point in the history
  • Loading branch information
BevapDin committed Dec 25, 2019
1 parent 8690cb4 commit 328dd45
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/npctalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2918,6 +2918,10 @@ dynamic_line_t::dynamic_line_t( const JsonObject &jo )
const dynamic_line_t no = from_member( jo, "no" );
for( const std::string &sub_member : dialogue_data::simple_string_conds ) {
if( jo.has_bool( sub_member ) ) {
// This also marks the member as visited.
if( !jo.get_bool( sub_member ) ) {
jo.throw_error( "value must be true", sub_member );
}
dcondition = conditional_t<dialogue>( sub_member );
function = [dcondition, yes, no]( const dialogue & d ) {
return ( dcondition( d ) ? yes : no )( d );
Expand Down

0 comments on commit 328dd45

Please sign in to comment.