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 ➜ Room Flags as Extended Bitvectors

Room Flags as Extended Bitvectors

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


Pages: 1  2 

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #15 on Tue 29 Mar 2005 03:09 AM (UTC)
Message
That line is in grub.c, under do_diagnose.

   ch_printf (ch, "\n\rRoom Vnums\n\r");
   for (cou = 0; cou < MAX_KEY_HASH; cou++)
   {
      if ( room_index_hash[cou] )
         for (pRoom = room_index_hash[cou]; pRoom; pRoom = pRoom->next)
         {
            if (pRoom->vnum >= lo && pRoom->vnum <= hi)
            {
            if ( match == (match & pRoom->room_flags)
            && hit_cou < DIAG_RF_MAX_SIZE)
               vnum[hit_cou++] = pRoom->vnum;
            }
         }
   }

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Robert Powell   Australia  (367 posts)  Bio
Date Reply #16 on Tue 29 Mar 2005 03:16 AM (UTC)
Message
I must be realy lucky as i do not have grub.c in SmaugFUSS, i guess if you dont use diagnose you could just scrub it, and from what the help file says diagnose will return the most popular objects in the game, something i have no need to know.

So i guess what that part of the code is cheching is for how many rooms in the mud have that room flag?

For my mind if no one uses diagnose then blow it away.

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

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #17 on Tue 29 Mar 2005 03:23 AM (UTC)
Message
Diagnose is really useful in my opinion. It can find room flags in the mud without having to grep through area files.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #18 on Tue 29 Mar 2005 05:33 AM (UTC)

Amended on Tue 29 Mar 2005 05:45 AM (UTC) by Greven

Message
The "&" operation basically make a comparison between two sets of bit flags. In this case, it takes the value(s) of match, compares it to the room flag, and re-sets match to contain only matching flags. It kind of works like this:

    01010101
 &  11110001
------------
 =  01010001
It only matches if both are set, so this is kind of filtering everything else out of the equation. In this case, I beleive that it is, and please anyone correct me if I am wrong, checking to see if whats supplied in the match variable is an exact match to the room flags. Now I'm not great with bitwise code, but if match and the rooms flags weren't exactly the same, then the result would not be equal to match, and so the code in the if check only gets executed if match has the same value as room_flags, at which point it puts the room in an array of rooms to be printed, I would assume?

If this is the circumstance, and you want to use xBV's, you could make a small function, if one doesn't already exist that just loops through the array of integers in the extended bitvectors and compares index 0 to index 0, 1 to 1, etc, and if all of them match, then add it to the list. You would also need to convert match to an extended bitvector, and set it with the extended bitvector functions.

[EDIT]
K, so a quick check came up with this:

#define xSAME_BITS(var, bit)	(ext_same_bits(&(var), &(bit)))

/* for use by xSAME_BITS() -- works like == */
bool ext_same_bits(EXT_BV * var, EXT_BV * bits)
{
        int       x;

        for (x = 0; x < XBI; x++)
                if (var->bits[x] != bits->bits[x])
                        return FALSE;

        return TRUE;
}

This should produce the same effect. Hope this helps.

[EDIT2]

Sure seem to be alot of edits lately, huh? Anyways, after looking at that again, its not checking for an exact match, its checking to see if all the flags specified in match are also in room_flags, but allows for more than just the ones specified, so you probably want to use xHAS_BITS(var, bit) instead.

You should be able to use
   ch_printf (ch, "\n\rRoom Vnums\n\r");
   for (cou = 0; cou < MAX_KEY_HASH; cou++)
   {
      if ( room_index_hash[cou] )
         for (pRoom = room_index_hash[cou]; pRoom; pRoom = pRoom->next)
         {
            if (pRoom->vnum >= lo && pRoom->vnum <= hi)
            {
            if ( xHAS_BITs(pRoom->room_flag, match)
            && hit_cou < DIAG_RF_MAX_SIZE)
               vnum[hit_cou++] = pRoom->vnum;
            }
         }
   }
Not tested, but lemme know.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Samson   USA  (683 posts)  Bio
Date Reply #19 on Tue 29 Mar 2005 11:25 AM (UTC)
Message
Quote:

#define BFS_MARK 536870912


Surprised nobody caught this :)

Just for fun, what happens if you try to access the 536870912th an array that's only 128 members long? :)

The BFS_MARK value needs to be tamed basically. 536870912 may have been appropriate when your bitflags were huge values and this was expected. But it's a Bad Thing(tm) with EXT_BV. IT's probably best to include BFS_MARK in your new enum of room flags and reserve a spot for it in the r_flags list in build.c so that you don't get them out of synch.
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #20 on Tue 29 Mar 2005 03:50 PM (UTC)
Message
Yes we (Saiyr and I) were aware that was not a thing that would work, but the gdb really was pointing us in the wrong direction. So I finally just went and removed that line, and added it to the enum list. Works fine.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Saiyr   USA  (6 posts)  Bio
Date Reply #21 on Tue 29 Mar 2005 04:44 PM (UTC)

Amended on Tue 29 Mar 2005 04:45 PM (UTC) by Saiyr

Message
The reason why we "semi-caught" it, was because it's still defined like that in the DBSC codebase...but it still works. I still blame our having to take a long time to solve this problem on miscommunication.

On the other hand, Greven, I don't think that'll work. EXT_BVs typically use the size of 4 ints, being 16 bytes or 128 bits. This won't fit into a single integer, obviously, which is what match is setup to be. I haven't thoroughly tested what I've done, but I think mine works. http://www.sourceforge.net/projects/dbsaga (Zeno already knows about this, this is really just for you) has it under the patch tracker. I basically said, "Why use numbers instead of actual flag names? Not everyone knows how to calculate bitvectors." I revamped the diagnose function a bit so that it would take flag arguments instead of a bitvector that could just be obtained with atoi. I've done some testing, and it works well from what I've seen. Using numbers, still, you would have to use fread_bitvector on it, rather than atoi. Personally, I don't know how to type in EXT_BV's in number form, anyway. Never bothered to look at it.
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #22 on Wed 30 Mar 2005 02:23 AM (UTC)
Message
See with this I had no clue how it actually worked. I generally work with SWR and it doesn't have this commands, so I'm a little unfamiliar. You actually had to enter the flags number? That would be less than useful I would think.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Saiyr   USA  (6 posts)  Bio
Date Reply #23 on Thu 31 Mar 2005 01:23 AM (UTC)
Message
Yep. That's what I was thinking, also. Apparently you're supposed to enter the bitvector in int form already, which is kinda silly. Using words is so much more user-friendly. I don't actually have a use for this command at all; I've never used diagnose. I fixed it because he asked me about it, and I actually understand bitwise operations fairly well now.
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #24 on Thu 31 Mar 2005 01:28 AM (UTC)
Message
See with this I assumed that you entered flags names, and it looped through the supplied list, took a number, and used SET_BIT based on the comparison between the names your entered and the value, similiar to how you can apply multiple flags at once while building. If this were the case, as I had erroneously though, all would have to do is create a local EXT_BV variable, and use the xSET_BIT on the local based on the supplied names, and then compare that to the rooms flags.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
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.


68,129 views.

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

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.