void load_teleporters( void )
{
FILE *fp;
char *string;
OBJ_DATA *obj;
CHAR buf[MAX_STRING_LENGTH];
bool tMatch = FALSE;
sprintf(buf, "%steleporters.dat", DATA_DIR);
if ( ( fp = fopen(buf, "r") ) == NULL )
{
log_string("Error: teleporters.dat file not found!");
return;
}
for ( ; ; )
{
string = feof(fp) ? "End" : fread_word(fp);
if (!str_cmp(string, "End") )
break;
switch (UPPER(string[0]))
{
case 'C':
fread_to_eol(fp);
tMatch = TRUE;
break;
case 'T':
obj = create_obj(
get_obj_index(OBJ_VNUM_TELEPORTER), MAX_LEVEL );
obj_to_room( obj, get_room_index( fread_number(fp) )
);
sprintf(buf, "%d %s", obj->in_room->vnum, "teleporter");
do_function(NULL, &do_activate_teleporter, buf);
tMatch = TRUE;
fread_to_eol(fp);
break;
}
if ( !tMatch )
{
bug("Load_teleporters: no match.", 0);
fread_to_eol(fp);
}
}
fclose(fp);
return;
}
void do_activate_teleporter( CHAR_DATA *ch, char *argument )
{
TELEPORTER_DATA *tp;
ROOM_INDEX_DATA *in_room;
OBJ_DATA *obj;
char arg1[MAX_INPUT_LENGTH];
argument = one_argument(argument, arg1);
if ( ( in_room = get_room_index( atoi(arg1) ) ) == NULL )
{
log_string("Bug: invalid room vnum");
return;
}
if ( ( obj = get_obj_list(ch, argument, in_room->contents) ) == NULL )
{
log_string("Bug: invalid teleporter object in room");
return;
}
/* set teleporter object as active */
obj->active = TRUE;
obj->active_room = obj->in_room->vnum;
/* add teleporter onto teleporter_list */
tp = new_teleporter();
tp->in_room = obj->in_room;
tp->cost = obj->cost;
tp->base_obj = obj;
tp->next = teleporter_list;
teleporter_list = tp;
return;
}
when i leave the function with the break under the do_function(NULL,
&do_activate_teleporter, buf); the mud crashes with a sigsegv fault in
handler.c and bool can_see_obj but when i place it above the sprintf in the
case 'T' the mud loads, places the teleporters right but doesn't activate
them. i was wondering if anyone could help me at all. i'm not sure if my
problem is in the load_teleporters or do_activate_teleporters, any help
would be greatly appreciated, because this is stumping me. thanks.