[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Room Flags as Extended Bitvectors
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Room Flags as Extended Bitvectors

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Pages: 1 2  

Posted by Robert Powell   Australia  (367 posts)  [Biography] bio
Date Sun 06 Feb 2005 09:19 AM (UTC)

Amended on Sun 06 Feb 2005 09:21 AM (UTC) by Robert Powell

Message
Hi all, i got silly and decided to convert room flags to be extended bitvectors as i needed more than 32,

What i have done se far is change to this in mud.h

EXT_BV room_flags;

Changed the #defines to be a typedef enum with all the room flags nicely sorted, Have gone through all the code changing IS_SET to xIS_SET.
and changed calls to flag_string to be ext_flag_string. Now i still have a few compile errors that i cannot work out how to fix.

Incompatable type for argument 1 of ext_flag_string :

 ch_printf_color( ch, "&cRoom flags: &w%s\n\r", ext_flag_string(location->room_flags, r_flags) );

Incompatable types in assignment

pRoomIndex->room_flags		= x2;
and
room->room_flags  = ROOM_INDOORS | ROOM_PRIVATE | ROOM_NO_RECALL | ROOM_NO_SUMMON | ROOM_NO_ASTRAL | ROOM_SOLITARY;

and last but not least,
invalid operands to binary &&

location -> room_flags = ROOM_PROTOTYPE && rm -> room_flags;


Im sort of gathering that i will need to change a variable somewhere but for the life of me i have no idea, any help on this would be great. Thanks in advance.

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] bio
Date Reply #1 on Sun 06 Feb 2005 10:35 PM (UTC)
Message
Quote:

Incompatable type for argument 1 of ext_flag_string :


ch_printf_color( ch, "&cRoom flags: &w%s\n\r", ext_flag_string(location->room_flags, r_flags) );

You need to add a & in front of the location->room_flags. So it will look like:

 ch_printf_color( ch, "&cRoom flags: &w%s\n\r", ext_flag_string(&location->room_flags, r_flags) );


Incompatable types in assignment

Quote:

pRoomIndex->room_flags = x2;
and
room->room_flags = ROOM_INDOORS | ROOM_PRIVATE | ROOM_NO_RECALL | ROOM_NO_SUMMON | ROOM_NO_ASTRAL | ROOM_SOLITARY;

First off, when you save it, make sure you save it as a string like this:

	if ( !xIS_EMPTY(room->room_flags) )
      fprintf( fpout, "%s ", print_bitvector(&room->room_flags) );

Secondly, when read, you need to do this:

pRoomIndex->room_flags		= fread_bitvector( fp );


Quote:

invalid operands to binary &&


location -> room_flags = ROOM_PROTOTYPE && rm -> room_flags;

I don't quite remember how I fixed this as it was forever ago when I did it. The obvious solution seems to just change it to:

xSET_BIT( location->room_flags, ROOM_PROTOTYPE );


I'm sure a few other people will come along and fix/clarify up my post for ya, as my experience with this is rather limited and old. :P

~Nick Cash
http://www.nick-cash.com
[Go to top] top

Posted by Robert Powell   Australia  (367 posts)  [Biography] bio
Date Reply #2 on Mon 07 Feb 2005 05:15 AM (UTC)
Message
OK just about got it all working last problem is this, changed this pRoomIndex->room_flags = x2; to this pRoomIndex->room_flags = fread_bitvector( fp );

and now i get this error, fp, undeclared first use in function, i looked in the functions above that load mobs and object that use fread_bitvector but cannot see what to do so that it likes it, Thanks for the help so far.

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
[Go to top] top

Posted by Robert Powell   Australia  (367 posts)  [Biography] bio
Date Reply #3 on Mon 07 Feb 2005 05:47 AM (UTC)
Message
Please ignore last post, i worked out what i was ment to do, the = 0 is the room_flag 0 and all i needed to do was xIs_Set it to whatever i wanted the flag to be

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
[Go to top] top

Posted by Robert Powell   Australia  (367 posts)  [Biography] bio
Date Reply #4 on Mon 07 Feb 2005 09:44 AM (UTC)
Message
HEHE, it took some work but i managed to get it all to compile, and thanks to my friend GDb i got rid of all of the problems i had with loading and saving areas including a check to see if the flag number was less than 31, i dont know why people have to hard code numbers when its much prettier to put a MAX_RFLAG var there instead. Anywho im rambleing, Problem i now have is my room flags after 31 dont work when using a typedef enum with all the room flags listed in the correct order, i can set them on the room, they show in rstat they just dont work, i converted back to using #define room_flag 32 etc and it all works, am i missing something with the typedef enum or is it most likely a typist malfunction i cannot see just now.

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] bio
Date Reply #5 on Mon 07 Feb 2005 10:30 PM (UTC)
Message
What do you mean? They show in rstat and they "just don't work". How are they not working?

~Nick Cash
http://www.nick-cash.com
[Go to top] top

Posted by Robert Powell   Australia  (367 posts)  [Biography] bio
Date Reply #6 on Tue 08 Feb 2005 06:26 AM (UTC)
Message
Well it seems that for some reason it thinks any flag after 31 in the typedef enum, is not there, i can set them on a room an d they show, its just when i try to do something with it in code that it doesnt work, like lockers code, ROOM_LOCKER is flag number 33 its in spot 33 in the typedef enum, but the following condition always fails, even when rstat shows locker in the flags section.

if(!xIS_SET(ch->in_room->room_flags, ROOM_LOCKER))
        {
            send_to_char( "Does this smell like a locker room to you?\r\n", ch );
            return;
        }

If i define the flag numbers like so,
#define ROOM_LOCKER 33 , i have no problem at all. I will look at the enum list later, but as i recall there were no typos and all flags were in the correct order. As a test i put all the flags onto a room and it still didnt work, so its not an order issue, might look again to see if all my commas are there and what they are ment to be.

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] bio
Date Reply #7 on Tue 08 Feb 2005 06:29 AM (UTC)
Message
Could you post the enum list? It was probably just a typing mistake or some such thing.

~Nick Cash
http://www.nick-cash.com
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] bio
Date Reply #8 on Tue 08 Feb 2005 06:31 AM (UTC)
Message
Or rather, for your reference, it should look something like this (this is from UR):

typedef enum
{
	ROOM_NONE, ROOM_DARK, BFS_MARK, ROOM_NO_MOB, ROOM_INDOORS, 
	ROOM_NO_DRIVING, ROOM_NO_MAGIC, ROOM_BANK,
	ROOM_PRIVATE, ROOM_SAFE, ROOM_EMPTYSHOP, ROOM_PET_SHOP,
	ROOM_NODROPALL, ROOM_SILENCE, ROOM_LOGSPEECH, 
	ROOM_NODROP, ROOM_CLANSTOREROOM, ROOM_PLR_HOME,
	ROOM_EMPTY_HOME, ROOM_HOTEL, ROOM_NOFLOOR, ROOM_REFINERY,
	ROOM_FACTORY, ROOM_RECRUIT, ROOM_BOUNTY, ROOM_SPACECRAFT, ROOM_PROTOTYPE,
	ROOM_HOUSE, ROOM_BARRACKS, ROOM_DND, ROOM_NODEATH,
	ROOM_CRASH, ROOM_ARENA, ROOM_SANITARY, ROOM_DIRTY,
	MAX_ROOM_FLAG
} more_room_flags;

~Nick Cash
http://www.nick-cash.com
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Reply #9 on Tue 08 Feb 2005 06:47 AM (UTC)
Message
Just to clarify, any code thats set above the 31st value in your definitions will return false on xIS_SET but are infact set when you scan through the bits in your print function? What does your print function look like? Do the ones below 31 display and work properly?

It may be that xIS_SET is not checking anything past the 0 index of the xbit array.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by Robert Powell   Australia  (367 posts)  [Biography] bio
Date Reply #10 on Thu 10 Feb 2005 04:40 AM (UTC)
Message
All is fixed now, seems i overlooked a duplicate entry in the r_flags in build.c, i think i shouldnt be trying to code after working 14 hours.

Thank you all for the help.

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #11 on Mon 28 Mar 2005 07:35 PM (UTC)

Amended on Mon 28 Mar 2005 08:08 PM (UTC) by Zeno

Message
I've just recently installed this, and the only problem I ran into is this:
            if ( match == (match & pRoom->room_flags)


How do I convert that to EXT?

[EDIT] I also compared these...
  ROOM_DARK, ROOM_DEATH, ROOM_NO_MOB, ROOM_INDOORS, ROOM_BANK,
  ROOM_NEUTRAL, ROOM_CHAOTIC, ROOM_NO_MAGIC, ROOM_TUNNEL, ROOM_PRIVATE,
  ROOM_SAFE, ROOM_SOLITARY, ROOM_PET_SHOP, ROOM_PLR_HOME, ROOM_DONATION,
  ROOM_NODROPALL, ROOM_SILENCE, ROOM_LOGSPEECH, ROOM_NODROP, ROOM_CLANSTOREROOM,
  ROOM_NO_SUMMON, ROOM_NO_ASTRAL, ROOM_TELEPORT, ROOM_TELESHOWDESC, ROOM_NOFLOOR,
  ROOM_EMPTY_HOME, ROOM_ARENA, ROOM_NOMISSILE, ROOM_PROTOTYPE, ROOM_DND, ROOM_NO_TRAIN

"dark", "death", "nomob", "indoors", "bank", "neutral", "chaotic",
"nomagic", "tunnel", "private", "safe", "solitary", "petshop", "plr_home",
"donation", "nodropall", "silence", "logspeech", "nodrop", "clanstoreroom",
"nosummon", "noastral", "teleport", "teleshowdesc", "nofloor",
"apartment", "arena", "nomissile", "r4", "r5", "prototype", "dnd", "no_train"


I don't know why those r4 and r5 are there. Should I remove them?

[EDIT 2] Also, crashes are happening.
#0  find_first_step (src=0xa13df08, target=0xa13eea0, maxdist=1475)
    at track.c:143
143         MARK(src);
#0  find_first_step (src=0xa13df08, target=0xa13eea0, maxdist=1475)
    at track.c:143
#1  0x0814cbab in hunt_victim (ch=0xa1b11b8) at track.c:365
#2  0x0814e318 in mobile_update () at update.c:800
#3  0x08150e1e in update_handler () at update.c:2272
#4  0x080bf05f in game_loop () at comm.c:708
#5  0x080be8cd in main (argc=8, argv=0xbffde310) at comm.c:318



#define MARK(room)      (xSET_BIT(      (room)->room_flags, BFS_MARK) )
#define UNMARK(room)    (xREMOVE_BIT(   (room)->room_flags, BFS_MARK) )
#define IS_MARKED(room) (xIS_SET(       (room)->room_flags, BFS_MARK) )


What's wrong?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] bio
Date Reply #12 on Mon 28 Mar 2005 09:37 PM (UTC)
Message
I think I left BFS_MARK as it was when I was modifying the thing I was doing. In the SMAUG dist I have its defined in track.c as:

#define BFS_MARK    536870912

and in the UR release that I had lying around I see this in mud.h:

/* BFS_MARK is for track and hunt */
typedef enum
{
	ROOM_NONE, ROOM_DARK, BFS_MARK, ROOM_NO_MOB, ROOM_INDOORS, 
	ROOM_NO_DRIVING, ROOM_NO_MAGIC, ROOM_BANK,
	ROOM_PRIVATE, ROOM_SAFE, ROOM_EMPTYSHOP, ROOM_PET_SHOP,
	ROOM_NODROPALL, ROOM_SILENCE, ROOM_LOGSPEECH, 
	ROOM_NODROP, ROOM_CLANSTOREROOM, ROOM_PLR_HOME,
	ROOM_EMPTY_HOME, ROOM_HOTEL, ROOM_NOFLOOR, ROOM_REFINERY,
	ROOM_FACTORY, ROOM_RECRUIT, ROOM_BOUNTY, ROOM_SPACECRAFT, ROOM_PROTOTYPE,
	ROOM_HOUSE, ROOM_BARRACKS, ROOM_DND, ROOM_NODEATH,
	ROOM_CRASH, ROOM_ARENA, ROOM_SANITARY, ROOM_DIRTY,
	MAX_ROOM_FLAG
} more_room_flags;

I looked in track.c and BFS_MARK BV01 was commented out. I'm guessing maybe you have it defined wrong?

~Nick Cash
http://www.nick-cash.com
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #13 on Mon 28 Mar 2005 09:41 PM (UTC)

Amended on Tue 29 Mar 2005 12:22 AM (UTC) by Zeno

Message
It's the same as Stock smaug.

#define BFS_MARK    536870912


I don't have BFS_MARK in the enums list but it is defined in track.c, does it need to be in the enums list, if so, where?

[EDIT] Perhaps I will focus on this crash, which happens if I remove r4 and r5:
#0  0x008e20b9 in strcat () from /lib/tls/libc.so.6
#1  0x0809e407 in ext_flag_string (bitvector=0x88082c0, flagarray=0x8194040) at build.c:315
#2  0x0807cd54 in do_rstat (ch=0x8942e40, argument=0xbff77845 "") at act_wiz.c:1736
#3  0x080e9f60 in interpret (ch=0x8942e40, argument=0xbff77845 "") at interp.c:583
#4  0x080befd3 in game_loop () at comm.c:689
#5  0x080be875 in main (argc=2, argv=0xbff77c80) at comm.c:318

(gdb) f 1
#1  0x0809e407 in ext_flag_string (bitvector=0x88082c0, flagarray=0x8194040) at build.c:315
315                 strcat( buf, flagarray[x] );


x is 31.

[EDIT] I guess I was missing a flag. I added BFS_MARK to the end.
So the only thing I need to know is how to convert this to EXT_BV:
            if ( match == (match & pRoom->room_flags)


Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Robert Powell   Australia  (367 posts)  [Biography] bio
Date Reply #14 on Tue 29 Mar 2005 02:53 AM (UTC)

Amended on Tue 29 Mar 2005 02:58 AM (UTC) by Robert Powell

Message
if ( match == (match & pRoom->room_flags)

Errrr you lost me on that, i dont have anything in my code that faintly resembles that.

Just out of curiosity, what does match do, or is it just a variable.


[EDIT]
So match compares strings, did some looking up heh, i think im more lost than ever.

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


15,217 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]