Login
User Name:

Password:



Register

Forgot your password?
void nanny_get_new_race -- comm.c
Mar 13, 2025 7:08 am
By Elwood
IPv6
Jan 25, 2025 10:45 pm
By Samson
mudstrlcpy and mudstrlcat
Jan 18, 2025 5:23 pm
By Samson
I3 and IMC
Jan 17, 2025 9:35 pm
By Samson
AFKMud 2.5.1
Jan 17, 2025 2:22 pm
By Samson
SWFotEFUSS 1.5.3
Author: Various
Submitted by: Samson
SWRFUSS 1.4.3
Author: Various
Submitted by: Samson
SmaugFUSS 1.9.8
Author: Various
Submitted by: Samson
AFKMud 2.5.2
Author: AFKMud Team
Submitted by: Samson
SmaugFUSS 1.9.7
Author: Various
Submitted by: Samson
Users Online
Anthropic, DotBot, Bing, AhrefsBot, Bytespider, GPTBot, Amazonbot

Members: 0
Guests: 4
Stats
Files
Topics
Posts
Members
Newest Member
507
3,812
19,722
591
TracySpencer

» SmaugMuds » Codebases » SmaugFUSS » Compiler warning for decorate...
Forum Rules | Mark all | Recent Posts

Compiler warning for decorate_room
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Mar 10, 2020 2:26 pm   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,707
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.

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.

Post is unread #2 Mar 11, 2020 4:40 pm   
Go to the top of the page
Go to the bottom of the page

Leia
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 ) )

Post is unread #3 Mar 12, 2020 3:03 pm   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,707
JoinedJan 1, 2002

 
Thanks, that's got the compiler happy now.

Pages:<< prev 1 next >>