Login
User Name:

Password:



Register

Forgot your password?
do_owhere recursive
Author: Khonsu
Submitted by: Khonsu
Changes list / Addchange
Author: Khonsu
Submitted by: Khonsu
6Dragons mp3 sound pack
Author: Vladaar
Submitted by: Vladaar
AFKMud 2.2.3
Author: AFKMud Team
Submitted by: Samson
SWFOTEFUSS 1.5
Author: Various
Submitted by: Samson
Users Online
AhrefsBot

Members: 0
Guests: 31
Stats
Files
Topics
Posts
Members
Newest Member
489
3,791
19,644
596
Elwood

Today's Birthdays
There are no member birthdays today.
» 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,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.

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,685
JoinedJan 1, 2002

 
Thanks, that's got the compiler happy now.

Pages:<< prev 1 next >>