On Thu, Apr 25, 2002 at 11:29:30PM -0500, Daniel Byer wrote:
> Ok, rewrote the code. Now my problems are far, far worse. I tried 
> compiling the mud.. didn't work, forgot some semicolons and tried to 
> reference a non existent field of a struct. Easy fix. So, it compiled, 
> yay, time to test it out. Place the executable in the area folder, cd'ed 
> over to it, and did a good ol' "./rom"
> 
> "Bus error"
> 
> And that was on startup.. didn't even send a single message before I 
> received the error.
> 
> Doh. Figured it might be because I was initializing the tracking struct 
> fields to NULL, then the struct itself to NULL. Changed some values 
> around, figured maybe int types can't be NULL, changed them to 0, 
> removed the pRoomIndex->tracking = NULL; line.
> 
> Compiled, ran. Bus Error. Then, instead of returning to the prompt, it 
> just went to an empty line. So I ctrl+x'ed out of it. All of a sudden, 
> another Bus error came up. They are periodically scrolling my screen.. 
> at the exact moment of this writing, I have -18- bus errors scrolled on 
> my screen. *cough*
> 
> This happened to me before with some code I was trying to install OLC 
> on. So, I figured it was a lost cause, deleted the entire thing, and re 
> downloaded stock rom and started my tracking endeavour. I have this 
> awful feeling I am doomed to not be able to have a MUD. Evil *nix gods, 
> EVIL!

Did you bow in the direction of Berkeley three times? Berkeley...
B-E-R-K-E-L-E-Y. It's close to San Francisco. It's where they
developed BSD Unix. Unix, not Linux. Linux comes from Finland.
That's the other cardinal direction. Berkeley is west, Finland is
east.

Well, if you start bowing, then I'll continue with how to solve
your problem. First, make sure you allocate everything you use. So
if you're using pRoomIndex->tracking, you have to allocate memory
for the tracking-structure. Check db.c for pRoomIndex=alloc_perm().
There you also have to allocate memory for the tracking structure.

Further, next time when you have such a problem, run your mud in
GDB. GDB is a debugger. It will, just before your computer breaks,
step in and halt the program, so you have a chance of finding out
why it went wrong. Try http://www.refcards.com for a reference
sheet. Just run in the area-directory: "gdb ../src/rom" and type
run, it will break at a certain moment. Make sure your code is
compiled with the -g option.

Good luck and don't forget: It's called B-E-R-K-E-L-E-Y.
Edwin



> 
> My new and updated code (which seems to work much, much worse than 
> before):
> in "db.c" in "void load_rooms( FILE *fp )" right before the "iHash = 
> vnum % MAX_KEY_HASH;" line:
> /* begin: zero out the data */
>          pRoomIndex->tracking->player = NULL;
>          pRoomIndex->tracking->age = 0; /* was NULL */
>          pRoomIndex->tracking->dir_to = 0; /* was NULL */
>          pRoomIndex->tracking->dir_from = 0; /* was NULL */
>          pRoomIndex->tracking->next = NULL;
>          pRoomIndex->tracking = NULL;
> /* end */
> 
> in "db.c" in "void reset_area( AREA_DATA *pArea )" in case 'R' (I was 
> told this was in the wrong spot.. why? I would like this code executed 
> on every room in every area, and this looks to me like the place to do 
> it.. any other recommendations?) after the d0 = 0 for loop:
>              /*
>               * This is the tracking reset code. Every PULSE_AREA, we 
> update/destroy the tracks
>              */
>              /* tracks are in room, update them */
>              if ( pRoomIndex->tracking ) {
>                  if ( ( srchTrack = alloc_mem( sizeof
> ( TRACK_DATA ) ) ) != NULL
>                          && ( prevTrack = alloc_mem( sizeof
> ( TRACK_DATA ) ) ) != NULL
>                          && ( tmpTrack = alloc_mem( sizeof
> ( TRACK_DATA ) ) ) != NULL ) {
>                      srchTrack = pRoomIndex->tracking;
>                      prevTrack->age = NULL;
>                      prevTrack->dir_to = NULL;
>                      prevTrack->dir_from = NULL;
>                      prevTrack->player = NULL;
>                      prevTrack->next = NULL;
> 
>                      firstTrack = TRUE;
>                  /* go through all tracks, update */
>                      for ( ; srchTrack; ) {
>                          /* make sure we don't kill tracks we want to 
> keep */
>                          killTrack = FALSE;
>                          /* age the tracks */
>                          srchTrack->age += 1;
>                          /* keep the last struct so we don't lose it */
>                          prevTrack = srchTrack;
> 
>                          /* this is fun. tracks will "age" based on the 
> sector type. forest tracks
>                          * last longer than tracks in the mountains, so 
> we act accordingly
>                          */
>                          switch ( pRoomIndex->sector_type ) {
>                          case 0: case 1:
>                              /* since PULSE_AREA is the amount of beats 
> it takes for the area to age,
>                              * we do X * PULSE_AREA so track aging is 
> dynamic. makes it easy to change
>                              * the age rate of areas without changing 
> track code
>                              */
>                              if ( srchTrack->age >= ( 3 * PULSE_AREA ) )
>                              {
>                                  killTrack = TRUE;
>                                  break;
>                              }
>                          case 2: case 4: case 5:
>                              if ( srchTrack->age >= ( 7 * PULSE_AREA ) )
>                              {
>                                  killTrack = TRUE;
>                                  break;
>                              }
>                          case 3:
>                              if ( srchTrack->age >= ( 15 * PULSE_AREA ) )
>                              {
>                                  killTrack = TRUE;
>                                  break;
>                              }
>                          case 10:
>                              if ( srchTrack->age >= ( 10 * PULSE_AREA ) )
>                              {
>                                  killTrack = TRUE;
>                                  break;
>                              }
>                          }
> 
>                          if ( killTrack ) {
>                              if ( firstTrack ) {
>                                  tmpTrack = srchTrack;
>                                  free_mem( pRoomIndex->tracking, sizeof
> ( *pRoomIndex->tracking ) );
>                                  pRoomIndex->tracking = tmpTrack;
>                                  srchTrack = tmpTrack;
>                              }
>                              else {
>                                  prevTrack->next = srchTrack->next;
>                                  *tmpTrack = *srchTrack;
>                                  free_mem( srchTrack, sizeof
> ( *srchTrack ) );
>                                  *srchTrack = *prevTrack->next;
>                              }
>                          }
> 
>                          if ( srchTrack != pRoomIndex->tracking ) {
>                              firstTrack = FALSE;
>                          }
>                      /* end for */
>                      }
>                  /* end if */
>                  }
>              /* end if */
>              }
> /* END */
> 
> in "act_move.c" in "void move_char( CHAR_DATA *ch, int door, bool 
> follow )" between "char_from_room( ch );" and "char_to_room( ch, 
> to_room );":
> /*    TRACKING CODE. COMPLETE(?). */
>      if ( do_track ) {
>          send_to_char( "DO_TRACK IS TRUE\n\r", ch );
> 
>          if ( ( srchTrack = alloc_mem( sizeof( TRACK_DATA ) ) ) != 
> NULL ) {
>              /* initialize the struct */
>              srchTrack->player = NULL;
>              srchTrack->dir_to = NULL;
>              srchTrack->dir_from = NULL;
>              srchTrack->age = NULL;
>              srchTrack->next = NULL;
> 
>              /* Tracking is already in room, so we modify/possibly add to 
> it */
>              if ( in_room->tracking ) {
>                  /* Iterate through the list */
>                  for ( srchTrack = in_room->tracking; srchTrack; ) {
>                      /* If the tracks are ch's, update them */
>                      if ( strcmp( srchTrack->player, ch->name ) == 0 ) {
>                          srchTrack->dir_to = door;
>                          srchTrack->age = 0;
>                      }
>                      else {
>                          /* If we're at end of list, and no one's been 
> found, we add a new entry */
>                          if ( !srchTrack->next ) {
>                              if ( ( inTrack = alloc_mem( sizeof
> ( TRACK_DATA ) ) ) != NULL ) {
>                                  inTrack->player = str_dup( ch->name );
>                                  inTrack->age = 0;
>                                  inTrack->dir_to = door;
>                                  inTrack->dir_from = NULL;
>                                  inTrack->next = NULL;
>                                  srchTrack->next = inTrack;
>                                  send_to_char( "Allocated. First 
> block.\n\r", ch );
>                               /* get us out of loop ;) */
>                                  break;
>                              }
>                          }
>                          else {
>                              srchTrack = srchTrack->next;
>                          }
>                      }
>                  }
>              }
>              /* no tracking in room, let's make some! */
>              else {
>                  if ( ( inTrack = alloc_mem( sizeof( TRACK_DATA ) ) ) != 
> NULL ) {
>                      inTrack->player = str_dup( ch->name );
>                      inTrack->age = 0;
>                      inTrack->dir_to = door;
>                      inTrack->dir_from = NULL;
>                      inTrack->next = NULL;
>                      in_room->tracking = inTrack;
>                      send_to_char( "Allocated. Second block.\n\r", ch );
>                  }
>              }
> 
>              /* gotta allocate the to_room also */
>              if ( to_room->tracking ) {
>                  /* iterate through the to_room tracks */
>                  for ( srchTrack = to_room->tracking; srchTrack; ) {
>                      if ( strcmp( to_room->tracking->player, 
> ch->name ) == 0 ) {
>                          to_room->tracking->dir_from = rev_dir[door];
>                          to_room->tracking->age = 0;
>                      }
>                      else {
>                          if ( !srchTrack->next ) {
>                              if ( ( toTrack = alloc_mem( sizeof
> ( TRACK_DATA ) ) ) != NULL ) {
>                                  toTrack->player = str_dup( ch->name );
>                                  toTrack->age = 0;
>                                  toTrack->dir_to = NULL;
>                                  toTrack->dir_from = rev_dir[door];
>                                  toTrack->next = NULL;
>                                  srchTrack->next = toTrack;
>                                  send_to_char( "Allocated. Third 
> block.\n\r", ch );
>                                  break;
>                              }
>                          }
>                          else {
>                              srchTrack = srchTrack->next;
>                          }
>                      }
>                  }
>              }
>              else {
>                  /* no tracking in room, make tracks */
>                  if ( ( toTrack = alloc_mem( sizeof( TRACK_DATA ) ) ) != 
> NULL ) {
>                      toTrack->player = str_dup( ch->name );
>                      toTrack->age = 0;
>                      toTrack->dir_to = NULL;
>                      toTrack->dir_from = rev_dir[door];
>                      toTrack->next = NULL;
>                      to_room->tracking = toTrack;
>                      send_to_char( "Allocated. Fourth block.\n\r", ch );
>                  }
>              }
> 
>          }
>      }
> /* END TRACKING CODE */
> 
> A note of comment. I switched the "player" field if TRACK_DATA to a 
> char * instead of CHAR_DATA * so we can just use the player's name. This 
> way, I can actually keep tracks around when the player logs off, piece 
> of cake. In fact, that's the way it's currently set up.. I'd have to 
> make changes in order to prevent the tracks from being permanent (blah 
> :P).
> 
> Well, let me know what your comments are this time.. by the way, I 
> -really- appreciate all your help. I'm at least gaining good programming 
> experience destroying my operating system ;)
> 
> Oh, and I just stumbled across the reset commends. No wonder 'R' is a 
> bad place to put it. Would 'D' be better? I'm sure some of these little 
> issues, like where it's placed, is probably making all the difference 
> right now.. i'm fairly confident my tracking code is decently stable ;)
> 
> And for the heck of it:
> struct        track_data
> {
>      char *           player;         /* player to pass through exit */
>      sh_int           age;            /* age of tracks */
>      sh_int           dir_to;         /* direction tracks go to */
>      sh_int           dir_from;       /* direction tracks come from */
>      TRACK_DATA *     next;           /* next tracking data, say, if another 
> player passes through exit */
> };
> 
> Another note about the bus error.. it happens, seriously, before I 
> receive ANY feedback the mud startup normally gives (resets, mobs, etc). 
> It's like, something completely different is going wrong. Because it 
> won't even start trying to work. Who knows, maybe that's the way it DOES 
> work.. *hopes so*
> 
> --Daniel, the long winded.
> 
> 
> -- 
> ROM mailing list
> [email protected]
> http://www.rom.org/cgi-bin/mailman/listinfo/rom

-- 
Edwin Groothuis      |           Personal website: http://www.MavEtJu.org
[EMAIL PROTECTED]    |        Interested in MUDs? Visit Fatal Dimensions:
bash$ :(){ :|:&};:   |                    http://www.FatalDimensions.org/

Reply via email to