Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Yahoo!, DotBot

Members: 0
Guests: 17
Stats
Files
Topics
Posts
Members
Newest Member
477
3,705
19,232
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SmaugFUSS » Random reset exits not coded ...
Forum Rules | Mark all | Recent Posts

Random reset exits not coded correctly?
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Oct 2, 2009, 7:56 pm   Last edited Oct 2, 2009, 8:00 pm by Zeno
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

      send_to_char( "Usage: reset randomize <direction>\n\r", ch );

   if( !str_cmp( arg, "random" ) )

First off, that's a "typo" obviously.

Secondly...
      int vnum = get_dir( arg );
      argument = one_argument( argument, arg );

      if( vnum < 0 || vnum > 9 )
      {
         send_to_char( "Reset which random doors?\n\r", ch );
         return;
      }

      if( vnum == 0 )
      {
         send_to_char( "There is no point in randomizing one door.\n\r", ch );
         return;
      }

      if( !get_room_index( vnum ) )
      {
         send_to_char( "Target room does not exist.\n\r", ch );
         return;
      }



What? If arg is "random", then what is get_dir being used on it for?

Er, even more confused now. If vnum is suppose to be the exit number... then why is it later assuming it's a room vnum?
       
Post is unread #2 Oct 3, 2009, 4:25 am
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,858
JoinedJul 26, 2005

Well I looked at this and it seems that the vnum should be how many of the directions you want it to randomize 0-9. You don't really have to use get_dir if you don't want to, but I guess its an easy way for them to set which exit dir they want to randomize up too. Don't need to do the get_room_index check though.

It will randomize all exits from 0 to #.
       
Post is unread #3 Aug 24, 2011, 8:15 pm
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

Bumping again because I think this needs a bug fix. The old system used to be something like "reset add rand 3" to randomize 3 exits. The new reset system doesn't seem to accept any arguments as valid.
       
Post is unread #4 Aug 26, 2011, 11:40 am   Last edited Aug 26, 2011, 11:40 am by Zeno
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

I can't edit my posts..?

Anyway here's the original 1.4a code:
  if ( !str_cmp(arg, "random") )
  {
    argument = one_argument(argument, arg);
    vnum = get_dir( arg );
    if ( vnum < 0 || vnum > 9 )
    {
      send_to_char( "Reset which random doors?\n\r", ch );
      return;
    }
    if ( vnum == 0 )
    {
      send_to_char( "There is no point in randomizing one door.\n\r", ch );
      return;
    }
    pRoom = find_room(ch, argument, aRoom);
    if ( pRoom->area != pArea )
    {
      send_to_char( "Cannot randomize doors in other areas.\n\r", ch );
      return;
    }
    pReset = make_reset('R', 0, pRoom->vnum, vnum, 0);
    LINK(pReset, pArea->first_reset, pArea->last_reset, next, prev);
    send_to_char( "Reset random doors created.\n\r", ch );
    return;
  }
       
Post is unread #5 Aug 26, 2011, 5:55 pm
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

This looks completely different in 1.9.

         case 'R':
            if( !( pRoomIndex = get_room_index( pReset->arg1 ) ) )
            {
               bug( "%s: %s: 'R': bad room vnum %d.", __FUNCTION__, filename, pReset->arg1 );
               continue;
            }
            randomize_exits( pRoomIndex, pReset->arg2 - 1 );
            break;

and randomize_exits:
void randomize_exits( ROOM_INDEX_DATA * room, short maxdir )
{
   EXIT_DATA *pexit;
   int nexits, /* maxd, */ d0, d1, count, door; /* Maxd unused */
   int vdirs[MAX_REXITS];

   nexits = 0;
   for( pexit = room->first_exit; pexit; pexit = pexit->next )
      vdirs[nexits++] = pexit->vdir;

   for( d0 = 0; d0 < nexits; d0++ )
   {
      if( vdirs[d0] > maxdir )
         continue;
      count = 0;
      while( vdirs[( d1 = number_range( d0, nexits - 1 ) )] > maxdir || ++count > 5 );
      if( vdirs[d1] > maxdir )
         continue;
      door = vdirs[d0];
      vdirs[d0] = vdirs[d1];
      vdirs[d1] = door;
   }
   count = 0;
   for( pexit = room->first_exit; pexit; pexit = pexit->next )
      pexit->vdir = vdirs[count++];

   sort_exits( room );
}
       
Post is unread #6 Feb 18, 2012, 12:10 pm
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

Does it work in 1.9?
       
Post is unread #7 Feb 18, 2012, 2:23 pm
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

Don't know, never actually used it. heh And I no longer have 1.9 on my system. Would probably be faster for you to download/install yourself than for me to go through the process again.
       
Post is unread #8 Feb 19, 2012, 10:46 am   Last edited Feb 19, 2012, 10:49 am by Zeno
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

I checked it out.

This looks completely different in 1.9.


I think you were looking in the wrong place. Here's the code in 1.9:
   if( !str_cmp( arg, "random" ) )
   {
      RESET_DATA *pReset;
      int vnum = get_dir( arg );

      argument = one_argument( argument, arg );

      if( vnum < 0 || vnum > 9 )
      {
         send_to_char( "Reset which random doors?\r\n", ch );
         return;
      }

      if( vnum == 0 )
      {
         send_to_char( "There is no point in randomizing one door.\r\n", ch );
         return;
      }

      if( !get_room_index( vnum ) )
      {
         send_to_char( "Target room does not exist.\r\n", ch );
         return;
      }

      pReset = make_reset( 'R', 0, ch->in_room->vnum, vnum, 0 );
      pReset->prev = NULL;
      pReset->next = ch->in_room->first_reset;
      if( ch->in_room->first_reset )
         ch->in_room->first_reset->prev = pReset;
      ch->in_room->first_reset = pReset;
      if( !ch->in_room->last_reset )
         ch->in_room->last_reset = pReset;
      send_to_char( "Reset random doors created.\r\n", ch );
      return;
   }


Which still seems to be the broken version.

I believe...
      int vnum = get_dir( arg );

Is not placed right, as arg doesn't get set until the line after.
       
Post is unread #9 Feb 19, 2012, 1:00 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,858
JoinedJul 26, 2005

Well checked mine to see, guess i had fixed it back when you mentioned it before or maybe before that no clue....
heres what I use and it seems to work great.
   if( !str_cmp( arg, "random" ) )
   {
      RESET_DATA *pReset;
      int dir = -1;

      argument = one_argument( argument, arg );

      if( arg != NULL && arg[0] != '\0' && is_number( arg ) )
         dir = atoi( arg );

      if( dir < 0 || dir > 9 )
      {
         send_to_char( "Reset which directions randomly?\r\n", ch );
         send_to_char( "3 would randomize north, south, east, west.\r\n", ch );
         send_to_char( "5 would do those and up, down.\r\n", ch );
         send_to_char( "9 would do those and ne, nw, se, sw.\r\n", ch );
         return;
      }

      if( dir == 0 )
      {
         send_to_char( "There is no point in randomizing only one direction.\r\n", ch );
         return;
      }

      pReset = make_reset( 'R', 0, ch->in_room->vnum, dir, 0, 100, 0, 0, false );
      pReset->prev = NULL;
      pReset->next = ch->in_room->first_reset;
      if( ch->in_room->first_reset )
         ch->in_room->first_reset->prev = pReset;
      ch->in_room->first_reset = pReset;
      if( !ch->in_room->last_reset )
         ch->in_room->last_reset = pReset;
      ch_printf( ch, "Reset door(s) randomly 0 - %d in room %d has been created.\r\n", dir, ch->in_room->vnum );
      return;
   }

reset random 9
Reset door(s) randomly 0 - 9 in room 21043 has been created.

redit rlist
 1) Randmoize exits 0 to 9 -> The Darkhaven Bakery (21043) (100)

But of course I've done various changes over time. but yea zeno it is a bit buggy the way it is.
       
Post is unread #10 Feb 19, 2012, 1:11 pm
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

Yup, just looked through the copy I have for 6 Dragons, and the
int vnum = get_dir(arg);

was pushed 1 line below
argument = one_argument(argument, arg);

line. And tested with success for 6 Dragons.

If that doesn't work for you in the change, I'd say take a look at get_dire and randomize_exits to see how it's being handled.
       
Pages:<< prev 1 next >>