Well, I finally finished my tracking code. So, I compiled it, ran into some stupid little errors, fixed them, and finally got the code working. Only to discover that the mud went in to a horrible, horrible crash (to the best of my knowledge). The only feedback I got from the terminal was "Bus error"

Those are generally bad. :P

I'm going to post the relevant code/location, and the feedback I received.

In "void move_char( CHAR_DATA *ch, int door, bool follow )" in "act_move.c", directly before "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 ( in_room->tracking ) {
            if ( in_room->tracking->player == ch ) {
                in_room->tracking->dir_to = door;
                in_room->tracking->age = 0;
            }
            else {
if ( ( inTrack = alloc_mem( sizeof( TRACK_DATA ) ) ) != NULL ) {
                    inTrack->player = ch;
                    inTrack->age = 0;
                    inTrack->dir_to = door;
                    in_room->tracking->next = inTrack;
                    send_to_char( "Allocated. First block.\n\r", ch );
                }
            }
        }
        else {
if ( ( inTrack = alloc_mem( sizeof( TRACK_DATA ) ) ) != NULL ) {
                inTrack->player = ch;
                inTrack->age = 0;
                inTrack->dir_to = door;
                in_room->tracking = inTrack;
                send_to_char( "Allocated. Second block.\n\r", ch );
            }
        }

        if ( to_room->tracking ) {
            if ( to_room->tracking->player == ch ) {
                to_room->tracking->dir_from = rev_dir[door];
                to_room->tracking->age = 0;
            }
            else {
if ( ( toTrack = alloc_mem( sizeof( TRACK_DATA ) ) ) != NULL ) {
                    toTrack->player = ch;
                    toTrack->age = 0;
                    toTrack->dir_from = rev_dir[door];
                    to_room->tracking->next = toTrack;
                    send_to_char( "Allocated. Third block.\n\r", ch );
                }
            }
        }
        else {
if ( ( toTrack = alloc_mem( sizeof( TRACK_DATA ) ) ) != NULL ) {
                toTrack->player = ch;
                toTrack->age = 0;
                toTrack->dir_from = rev_dir[door];
                to_room->tracking = inTrack;
                send_to_char( "Allocated. Fourth block.\n\r", ch );
            }
        }

    }
/* END TRACKING CODE */

do_track is just a bool to determine if the tracking code should be executed. An example, is do_track will be false if ch is an immortal. The "Allocated. X block" send_to_char()s are there just so I can walk around and determine if things are supposedly working.

the track_data struct, located in "merc.h":
/* BEGIN TRACK STRUCT */
struct  track_data
{
    CHAR_DATA *         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 */
};
/* END TRACK STRUCT */

room_index_data contains a TRACK_DATA struct, with the name "tracking."

In "void load_rooms( FILE *fp )" in "db.c", at very bottom, right before "iHash = vnum % MAX_KEY_HASH;": /* This is to initialize the tracking struct.. was causing funny things to happen before I added this line */
pRoomIndex->tracking = NULL;
/* end */

In "void reset_area( AREA_DATA *pArea )" in "db.c", case 'R': directly after the "for ( d0 = 0; d0 < pReset->arg2 - 1; d0++ )" loop finishes (this code is located AFTER the loop, and AFTER the bracket directly after it, thus past the if/else statement):
/*
* This is the tracking reset code. Every PULSE_AREA, we update/destroy the tracks
*/
if ( pRoomIndex->tracking ) {
for ( ; !pRoomIndex->tracking; ) { /* I just saw this now.. should I not have the ! in there? */
        killTrack = FALSE;
        pRoomIndex->tracking->age += pRoomIndex->tracking->age;

        switch ( pRoomIndex->sector_type ) {
        case 0: case 1:
            if ( pRoomIndex->tracking->age >= ( 3 * PULSE_AREA ) )
            {
                killTrack = TRUE;
                break;
            }
        case 2: case 4: case 5:
            if ( pRoomIndex->tracking->age >= ( 7 * PULSE_AREA ) )
            {
                killTrack = TRUE;
                break;
            }
        case 3:
            if ( pRoomIndex->tracking->age >= ( 15 * PULSE_AREA ) )
            {
                killTrack = TRUE;
                break;
            }
        case 10:
            if ( pRoomIndex->tracking->age >= ( 10 * PULSE_AREA ) )
            {
                killTrack = TRUE;
                break;
            }
        }

        if ( killTrack )
        {
            if ( pRoomIndex->tracking->next ) {
if ( ( tmpTrack = alloc_mem( sizeof( *tmpTrack ) ) ) != NULL ) {
                    tmpTrack = pRoomIndex->tracking->next;
                    free_mem( pRoomIndex->tracking, sizeof
( *pRoomIndex->tracking ) );
                    pRoomIndex->tracking = tmpTrack;
                }
            }
            else {
                free_mem( pRoomIndex->tracking, sizeof
( *pRoomIndex->tracking ) );
            }
        }
    }
}
/* END */

I also implemented a "track" command, which was originally going to be used for feedback (and will, of course, eventually become fully implemented as a skill), but I don't believe that pertains to this problem, as the problem arises without using the command.

So, here's the situation. I wander around a few rooms, and the mud crashes with a Bus error. Here's the in game feedback:
/* BEGIN */
Welcome to ROM 2.4.  Please do not feed the mobiles.
The Checkpoint
  You are met by a group of heavily armored knights.  They check you over
for contraband, and then allow you to pass on. One of the knights cautions to
not stray into the desert, lest you lose your way.

[Exits: east west]
You have no unread notes.

<20hp 100m 71mv> w
DO_TRACK IS TRUE
Allocated. Second block.
Allocated. Fourth block.
Along the Eastern Road
You are travelling down the eastern road between Midgaard and the eastern
lands.  The road back to Midgaard is west of you, and a heavily guarded
checkpoint is east.  A beautiful grove of trees is north, and a dirt path
wanders off to the south.

[Exits: north east south west]

<20hp 100m 69mv> w
DO_TRACK IS TRUE
Allocated. Fourth block.
Along the Eastern Road
  You are walking along a well-travelled road between Midgaard and lands
east. A northern road crosses this one to the west, towards Midgaard. You
hear faint, happy singing to the north.

[Exits: north east west]

<20hp 100m 67mv> w
Lost Server Connection.
/* END */

I repeated this, with random directions, 3 times. Attempting the 3rd direction each time caused the crash. I apologize for this being extremely long, but I wanted to be as detailed as possible in one fell swoop. If anyone has any ideas as to the cause of my distress, I'd be more than happy to receive feedback ;)

--Daniel

p.s. If I knew how to get the system error log in a *nix environment, I'd post that too. If I can get that info, I can post the crash log as well. ROM does NOT write any logs, I checked ;)


Reply via email to