Chris-plus-alphanumericgibberish / dNAO

Merge of dnethack onto the nethack.alt.org sources.
Other
20 stars 29 forks source link

Operator precedence issues with mutation code cha bonuses to seduction #2253

Closed demogorgon22 closed 5 months ago

demogorgon22 commented 5 months ago
src/seduce.c:836:85: warning: operator '?:' has lower precedence than '+'; '+' will be evaluated first [-Wparentheses]
        mayberem_common(obj, str, !(rn2(20) < (ACURR(A_CHA) + check_mutation(TENDRIL_HAIR) ? 10 : 0)));
                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
cd dat && ../util/lev_comp endgame.des && touch endgame.tag
src/seduce.c:836:85: note: place parentheses around the '+' expression to silence this warning
        mayberem_common(obj, str, !(rn2(20) < (ACURR(A_CHA) + check_mutation(TENDRIL_HAIR) ? 10 : 0)));
                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
src/seduce.c:836:85: note: place parentheses around the '?:' expression to evaluate it first
        mayberem_common(obj, str, !(rn2(20) < (ACURR(A_CHA) + check_mutation(TENDRIL_HAIR) ? 10 : 0)));
                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
cd dat && ../util/lev_comp gehennom.des && touch gehennom.tag
src/seduce.c:845:85: warning: operator '?:' has lower precedence than '+'; '+' will be evaluated first [-Wparentheses]
        mayberem_common(obj, str, !(rn2(60) < (ACURR(A_CHA) + check_mutation(TENDRIL_HAIR) ? 30 : 0)));
                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
src/seduce.c:845:85: note: place parentheses around the '+' expression to silence this warning
        mayberem_common(obj, str, !(rn2(60) < (ACURR(A_CHA) + check_mutation(TENDRIL_HAIR) ? 30 : 0)));
                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
src/seduce.c:845:85: note: place parentheses around the '?:' expression to evaluate it first
        mayberem_common(obj, str, !(rn2(60) < (ACURR(A_CHA) + check_mutation(TENDRIL_HAIR) ? 30 : 0)));
                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
src/seduce.c:854:97: warning: operator '?:' has lower precedence than '+'; '+' will be evaluated first [-Wparentheses]
        mayberem_common(obj, str, helpless || !(rn2(60) < (ACURR(A_CHA) + check_mutation(TENDRIL_HAIR) ? 30 : 0)));
                                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
src/seduce.c:854:97: note: place parentheses around the '+' expression to silence this warning
        mayberem_common(obj, str, helpless || !(rn2(60) < (ACURR(A_CHA) + check_mutation(TENDRIL_HAIR) ? 30 : 0)));
                                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
src/seduce.c:854:97: note: place parentheses around the '?:' expression to evaluate it first
        mayberem_common(obj, str, helpless || !(rn2(60) < (ACURR(A_CHA) + check_mutation(TENDRIL_HAIR) ? 30 : 0)));

Ignore the line numbers as they aren't quite right, but this seems potentially like something that should be addressed and is a valid concern.