Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ SWR room flags (above BV30)

SWR room flags (above BV30)

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


Pages: 1 2  

Posted by Destiny   (14 posts)  Bio
Date Mon 13 Jan 2003 09:03 AM (UTC)
Message
Since the place is using just 32-bit numbers for room flags, how do you go over BV30 without it going hay-wire on you? i know its possible because i was building for this other guy and he has about 50 room flags.
Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #1 on Mon 13 Jan 2003 09:23 AM (UTC)
Message
Either he reworked the bitflag structure or he was using a second roomflag structure. Odds are he used a second structure since reworking the bitflag structure entirely is obnoxiously difficult and is hardly worth the effort.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by Destiny   (14 posts)  Bio
Date Reply #2 on Mon 13 Jan 2003 09:59 AM (UTC)
Message
how would you set that up? I see where you define room_flags in build.c, but i cant see where it links those to their corresponding bit variables.

Meaning:
(in build.c)

char * const r_flags [] =
{
"dark", "reserved", "nomob", "indoors", "can_land", "can_fly", "no_drive",
"nomagic", "bank", "private", "safe", "remove_this_flag", "petshop", "norecall",
"donation", "nodropall", "silence", "logspeech", "nodrop", "clanstoreroom",
"plr_home", "empty_home", "teleport", "hotel", "nofloor", "refinery", "factory",
"republic_recruit", "shipyard", "spacecraft", "prototype", "auction"
};

(in mud.h)

#define ROOM_DARK BV00
/* BV01 now reserved for track BV01 and hunt */
#define ROOM_NO_MOB BV02
#define ROOM_INDOORS BV03
#define ROOM_CAN_LAND BV04
#define ROOM_CAN_FLY BV05
#define ROOM_NO_DRIVING BV06
#define ROOM_NO_MAGIC BV07
#define ROOM_BANK BV08



Where does it tell you that "nomob" = ROOM_NO_MOB or BV02?
Top

Posted by Dave   Australia  (93 posts)  Bio
Date Reply #3 on Mon 13 Jan 2003 10:34 AM (UTC)
Message
Quote:
Where does it tell you that "nomob" = ROOM_NO_MOB or BV02?


In C, you start counting arrays from 0. So in char * const r_flags [] = { "dark", "reserved", "nomob", ...,

dark is BV00, reserved is BV01, and nomob is BV02.
Top

Posted by Destiny   (14 posts)  Bio
Date Reply #4 on Mon 13 Jan 2003 10:41 AM (UTC)
Message
I realize that, but you see, there are about 80 BV00 flags located in mud.h i want to know how the mud knows which one is the right one to use. i found an interesting line in act_wiz.c that says:

flag_string(location->room_flags, r_flags) );

and flag_string is this:

char * flag_string args( ( int bitvector, char * const flagarray[] ) );

that looks kinda like what im looking for, but the thing is i still dont see how it knows that location->room_flags tells it to use that certain set of Bit variables,
Top

Posted by Boborak   USA  (228 posts)  Bio
Date Reply #5 on Mon 13 Jan 2003 03:50 PM (UTC)
Message
Each BV00 all do the same thing, they all toggle bit 0 of an integer. But defines have been created so that you can use names such as ROOM_DARK instead of BV00 to save your sanity. What you are doing is toggling bit 0 of the 32-bit integer you have setup in your structs. For example:

in room_index_data you have..
int flags;

The SET_BIT() macro takes that 32 bit integer and toggles one of 32 bits that make up that integer.
In all actuality you could have:

SET_BIT(room->flags, BV00);

and it would be the same as..

SET_BIT(room->flags, ROOM_DARK);

What 'redit flags dark' does, is it takes the argument 'dark' and searches through the r_flags[] array, until it finds a match.. it then takes that array position (in this case position 0) and sets the cooresponding bit (BV00)on the room->flags integer, using SET_BIT.
Top

Posted by Destiny   (14 posts)  Bio
Date Reply #6 on Mon 13 Jan 2003 04:14 PM (UTC)
Message
Perhaps I'm just not understanding, or maybe im not wording my question right. I know the bitvectors are and what they do and how to create arrays. All i want to know how to do is to create a second array of flags that redit and rstat will pick up on. I can make the array just fine, but i cant get the commands to pick up on the new array as well. there was one time about 5 hours ago or so that redit picked up on it, but rstat just crashed the mud, regardless of whether or not i had used the new array, so my thought was that the compiler got the two arrays confused. that's why redit could assign a bitvector, but redit cant read two at once.

Can someone please just tell me how to create an array or a structure within the current array to expand the number of room flags that i have and can use.

-David Rocco
Top

Posted by Boborak   USA  (228 posts)  Bio
Date Reply #7 on Mon 13 Jan 2003 04:53 PM (UTC)
Message
Here's what you need to do..

First open build.c..

add your second array:

char * const r_flags2 [] =
{
"r00", "r01", "r02", "r03", "r04", "r05",
"r06", "r07", "r08", "r09", "r10", "r11",
"r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31"
};

further down.. below get_rflag..

add this:

int get_rflag2( char *flag )
{
int x;

for ( x = 0; x < 32; x++ )
if ( !str_cmp( flag, r_flags2[x] ) )
return x;
return -1;
}

then in do_redit()

add this below the.. if ( !str_cmp( arg, "flags" ) ) section

if ( !str_cmp( arg, "flags2" ) )
{
if ( !argument || argument[0] == '\0' )
{
send_to_char( "Toggle the room flags.\n\r", ch );
send_to_char( "Usage: redit flags <flag> [flag]...\n\r", ch );
send_to_char( "\n\rPossible Flags: \n\r", ch );
send_to_char( "blah blah blah\n\r", ch );
return;
}
while ( argument[0] != '\0' )
{
argument = one_argument( argument, arg2 );
value = get_rflag2( arg2 );
if ( value < 0 || value > 31 )
ch_printf( ch, "Unknown flag: %s\n\r", arg2 );
TOGGLE_BIT( location->room_flags2, 1 << value );
}
return;
}

then open act_wiz.c

and in do_rstat()

below..
ch_printf( ch, "&GRoom flags: &W%s\n\r",
flag_string(location->room_flags, r_flags) );

add..
ch_printf( ch, "&GRoom flags2: &W%s\n\r",
flag_string(location->room_flags2, r_flags2) );

then open up mud.h

and add this to room_index_data..

int room_flags2;

Now all you have to do is add a second set of defines..

For example:

...
#define ROOM_PROTOTYPE BV30
#define ROOM_AUCTION BV31

/* Second Set of Room Flags */
#define ROOM_FLAG1 BV00
#define ROOM_FLAG2 BV01

Recompile and you're done.. now too add more flags, add them too array r_flags2 instead of r_flags in build.c,
and use 'redit flags2' instead of 'redit flags'

When using the flags in your code.. just use SET_BIT(room->room_flags2, ROOM_FLAG1); instead of room->room_flags

Hope this helps.. I don't actually use this code (i use extended BV's) and I may have forgot something.. but it should work for ya.
Top

Posted by Boborak   USA  (228 posts)  Bio
Date Reply #8 on Mon 13 Jan 2003 04:56 PM (UTC)
Message
Also you may want to use things like
ROOM2_FLAG1 instead of ROOM_ to help keep track of what is what. This *IS* the easiest way to get extra flags. I know you probably wanted to just add to the r_flag[] array and not have to use 'redit flags2' but.. trust me.. the alternative can be quite a pain. ;-)
Top

Posted by Destiny   (14 posts)  Bio
Date Reply #9 on Mon 13 Jan 2003 04:59 PM (UTC)
Message
Awesome, thank you so much
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #10 on Mon 13 Jan 2003 09:42 PM (UTC)
Message
You also need to change the load/save code for rooms to load/save the extra integer. Be warned this will make your area files incompatible with stock SMAUG and SMAUG editors, if you use those.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #11 on Mon 13 Jan 2003 10:27 PM (UTC)
Message
Acually I was doing this to my MUD also. This is the easiest way to get more flags but you did forget one thing. When you compile all of that then you will get an error like this one:
act_wiz.c: In function `do_rstat':
act_wiz.c:1035: `r_flags2' undeclared

To fix this all you need to do is go into mud.h and find this:
extern char * const r_flags [];

Thats about line 3279, this way you won't have to search for it to much. Under that just add this:

extern char * const r_flags2 [];

Then everything should compile correctly. Hope that helped if you were having trouble. Thanks for the code Boborak.

~Nick Cash
http://www.nick-cash.com
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #12 on Mon 13 Jan 2003 11:04 PM (UTC)

Amended on Mon 13 Jan 2003 11:07 PM (UTC) by Nick Cash

Message
Nick is right. So here is what you need to do for it to save/load the flags.

For loading:
in void load_rooms()
go down below for ( ; ; ) and find:
int x1, x2, x3, x4, x5, x6;
and add make it look like this (add x7)
int x1, x2, x3, x4, x5, x6, x7;

then go down and find this:
sscanf( ln, "%d %d %d %d %d %d",
&x1, &x2, &x3, &x4, &x5, &x6 );
And make it look like this:
sscanf( ln, "%d %d %d %d %d %d %d",
&x1, &x2, &x3, &x4, &x5, &x6, &x7 );

Below that look for this (should be about two lines down):

pRoomIndex->room_flags = x2;
Below that add:
pRoomIndex->room_flags2 = x7;

I think you need to do this, I've never acually messed with the read/save functions for rooms:
Find this:
x1=x2=x3=x4=x5=x6=0;
Change it to this:
x1=x2=x3=x4=x5=x6=x7=0;

Thas all for db.c and the load function. Now for the save function.

All of this is under void fold_area():
Search for:
/* save rooms */
This will put you in the general area of code you need to be. Go down and find this:
fprintf( fpout, "0 %d %d %d %d %d \n", room->room_flags,
room->sector_type,
room->tele_delay,
room->tele_vnum,
room->tunnel );
And change the fprintf to this:
fprintf( fpout, "0 %d %d %d %d %d %d \n",
Then next to the room->room_flags make it look like this:
room->room_flags, room->room_flags2,

The end result should look something like this:
fprintf( fpout, "0 %d %d %d %d %d %d\n", room->room_flags,
room->room_flags2,
room->sector_type,
room->tele_delay,
room->tele_vnum,
room->tunnel );

Yeah, again I have never toyed with these functions but it compiles alright so I think it should work alright also. Good luck, and if it doesn't/does work then post the answer here.

~Nick Cash
http://www.nick-cash.com
Top

Posted by Polexian   (1 post)  Bio
Date Reply #13 on Thu 13 Mar 2003 11:18 PM (UTC)
Message
you will also have to add this in your do_look function so you can see the room flags when you do look in your mud.


set_char_color(AT_CYAN, ch);
send_to_char("[", ch);
send_to_char(flag_string(ch->in_room->room_flags, r_flags), ch);
send_to_char(" ", ch);
send_to_char(flag_string(ch->in_room->room_flags2, r_flags2), ch);
send_to_char("]", ch);
Top

Posted by Crix   (11 posts)  Bio
Date Reply #14 on Wed 19 Mar 2003 11:01 PM (UTC)
Message
I added all of the above stuff, and I tried getting it to work. Now all of it works, except for the saving. I've been staring at it for at least half an hour, I figured that the x7 parts were a bit backwards, so I changed those around, and it's still not working. Anyone see any typos on any of this? Or is my problem a bit more serious? Thanks
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.


48,856 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 page

Go to topic:           Search the forum


[Go to top] top

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