Bits going negative?

Posted by Nick Cash on Thu 29 Jul 2004 09:39 PM — 3 posts, 13,999 views.

USA #0
Ok, well, I figure I havent stirred up trouble in a while, so here I go. I'm working with SocketMud 1.8. I've installed numerous bits of code, including some bitmask code by Runter. It works correctly, however, I keep getting this problem. I create an area like this:

new_area "Dragon's Den" Odis dragonsden.xml 1 100

This is all good and fine since one_arg now supports quoting, but for an odd reason it crashes. Here's a backtrace on the core file:

#0  0x08050849 in set_bit (mask=0x805bb48, bit=-1) at bits.c:89
89              if (pBlist->set == bit / 32) { /* Is this the correct set? */
(gdb) bt
#0  0x08050849 in set_bit (mask=0x805bb48, bit=-1) at bits.c:89
#1  0x080503bc in create_area (dMob=0x805ba70, area_name=0xbfffe070 "Dragon's Den", author=0xbfffe050 "Odis",
    filename=0xbfffe030 "dragonsden.xml", low_num=1, high_num=100) at areas.c:367
#2  0x080501b3 in cmd_new_area (dMob=0x805ba70, argument=0x805e4ea "100") at areas.c:305
#3  0x0804c4dc in handle_cmd_input (dsock=0x805d8a8, arg=0x805e4c5 "\"Dragon's Den\" Odis dragonsden.xml 1 100")
    at interpret.c:29
#4  0x080496d0 in game_loop (cont=3) at socket.c:176
#5  0x08049427 in main (argc=1, argv=0xbfffe654) at socket.c:84
#6  0x42017589 in __libc_start_main () from /lib/i686/libc.so.6

However, if I make an area like this:

new_area "Dragons Den" Odis dragonsden.xml 1 100

It works perfectly. I've tested the bitmask code, it works fine. My worries is here:

#0 0x08050849 in set_bit (mask=0x805bb48, bit=-1) at

It isnt -1, it should be 0. When I take the ' out of the name it seems to clear it up. Here is the corrosponding line of code that crashes it:

set_bit( new_area->flags, FLAG_DEFAULT );

Flag default is defined as:

#define FLAG_DEFAULT 0

Any thoughts? I've tested the bitmask system quite a few times and it works correctly, but the darned apostrophe keeps messing it up. I obviously can't have the code base crashing because of a silly apostrophe. :P

Thanks for any and all help. I always appreciate it.
Australia Forum Administrator #1
-1 basically means "all bits set" which isn't necessarily a disaster.

I don't have the source for this, I suggest you step through with the debugger on a new_area and see why it is doing that.
USA #2
Strange. I left it alone for a while ( a couple days ), came back, completely recompiled and its fine now. I guess its just one of those things :P