Compiler warning for decorate_room
< Newer Topic
:: Older Topic >
Pages:<< prev 1 next >>
#1 Mar 10, 2020 2:26 pm
Black Hand
GroupAdministrators
Posts3,685
JoinedJan 1, 2002
So I got bored and decided to do some cleanup on GCC 7.5 since it's been awhile since the last time that was done. There's one issue left to clear up but my C/C++ is too rusty these days.
That's part of this block in the function:
I've tried fiddling with it but came up empty. Honestly I'm not even sure it works at all considering the virtual room support is in itself a big mess that I'm pretty sure was never used for anything.
act_move.c: In function ‘void decorate_room(ROOM_INDEX_DATA*)’: act_move.c:257:43: warning: ‘*’ in boolean context, suggest ‘&&’ instead [-Wint-in-bool-context] switch ( number_range( 1, ( 2 * ( iRand == nRand - 1 ) ) ? 1 : 2 ) ) ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
That's part of this block in the function:
if( len == 0 ) { switch ( number_range( 1, ( 2 * ( iRand == nRand - 1 ) ) ? 1 : 2 ) ) { case 1: pre = "You notice "; post = "."; break; case 2: pre = "You see "; post = "."; break; case 3: pre = "You see "; post = ", and "; break; case 4: pre = "You notice "; post = ", and "; break; } snprintf( buf2, MAX_STRING_LENGTH, "%s%s%s", pre, room_sents[sector][x], post ); }
I've tried fiddling with it but came up empty. Honestly I'm not even sure it works at all considering the virtual room support is in itself a big mess that I'm pretty sure was never used for anything.
#2 Mar 11, 2020 4:40 pm
Fledgling
GroupMembers
Posts24
JoinedJul 8, 2012
It's still ugly, but I think it will do the same without the compiler complaining
switch ( number_range( 1, ( ( 2 * ( iRand == nRand - 1 ) ) > 0 ) ? 1 : 2 ) )
switch ( number_range( 1, ( ( 2 * ( iRand == nRand - 1 ) ) > 0 ) ? 1 : 2 ) )
#3 Mar 12, 2020 3:03 pm
Black Hand
GroupAdministrators
Posts3,685
JoinedJan 1, 2002
Thanks, that's got the compiler happy now.
Pages:<< prev 1 next >>