Re: Issues with a couple of snippets, Buildwalk and Experience

From: Russell Brown (russell_brown@MFDG.COM)
Date: 07/03/02


On Wed, 3 Jul 2002 05:57:11 -0700, Mathew Earle Reuther
<graymere@zipcon.net> wrote:

<snip>
>My problem is, I can't figure out how to make it stay
>within the vnums properly . . . the way zones are handled has changed a
>bit since the buildwalk snippet was released, so I had to make some
>changes.  What I've currently got is below:
>
>/**************************************************************************
**
>* BuildWalk - OasisOLC Extension by D. Tyler Barnes
>*
>***************************************************************************
*/
>
>/* For buildwalk. Finds the next free vnum in the zone */
>room_vnum redit_find_new_vnum(zone_rnum zone) {
>
>  room_vnum vnum;
>  room_rnum rnum = real_room((vnum = zone_table[zone].number * 100));
>
>  if (rnum != NOWHERE) {
>    for(; world[rnum].number <= vnum; rnum++, vnum++)
>      if ((vnum > zone_table[zone].top) || (vnum < zone_table[zone].bot))
>        return(NOWHERE);
>  }
>  return(vnum);
>
>}
Try this for your redit_find_new_vnum function. I am assuming that
real_room returns NOWHERE when you pass it an unused vnum, since I
don't have access to the code right now. If it does not, replace
NOWHERE in the if evaluation with whatever value real_room returns
for an unused vnum.

<Standard Disclaimer> Mailer code, use at your own risk.
</Standard Disclaimer>
room_vnum redit_find_new_vnum(zone_rnum zone) {

  room_vnum vnum;

  for(vnum = zone_table[zone].bot; vnum <= zone_table[zone].top; vnum++)
    if(real_room(vnum) == NOWHERE)
      return(vnum);

  return(NOWHERE);
}

All this does is loop through the vnum range for the given zone from
bottom to top and return the lowest unused vnum. This should work fine
for most zones but there may be the some problems if you have overlapping
zones. I will leave the testing up to you. I hope this helps you out.

Russ

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT