/
rogue24b3/
rogue24b3/data/
#include "merc.h"
#include "track.h"
#include "interp.h"

int	find_first_step(RID *src, char *target);
int	find_first_step(RID *src, RID *target);

SInt32	NamedCharInRoom	(RID *room, CPtr data);
SInt32	FullNameInRoom	(RID *room, CPtr data);
SInt32	CharInRoom	(RID *room, CPtr data);
SInt32	SameRoomNR	(RID *room, CPtr data);

struct NCIRData {
	char *		name;
	CHAR_DATA *	vict;
};


SInt32 NamedCharInRoom(RID *room, CPtr data) {
    NCIRData *	ncir = (NCIRData *)data;
    CHAR_DATA *	ch;

    if (room == NULL)
	return 0;

    for (ch = room->people; ch; ch = ch->next_in_room) {
	if (isname(ncir->name, ch->name) && !AFF_FLAGGED(ch, AFF_NOTRACK)) {
	    ncir->vict = ch;
	    return 1;
	}
    }
    return 0;
}

Path *  Path2Name(RID *start, char *name, SInt32 depth, Flags flags) {
    NCIRData	ncir = { name, NULL };
    Path *	path;

    if ((path = PathBuild(start, NamedCharInRoom, &ncir, depth, flags)))
	path->victim = ncir.vict;

    return path;
}

SInt32 FullNameInRoom(RID *room, Ptr data) {
    NCIRData *	fnir = (NCIRData *)data;
    CharData *	ch;

    if (room == NULL)
	return 0;

    for (ch = room->people; ch; ch = ch->next_in_room) {
	if (!str_cmp(ch->name, fnir->name)) {
	    fnir->vict = ch;
	    return 1;
	}
    }
    return 0;
}

Path * Path2FullName(RID *start, char *name, SInt32 depth, Flags flags) {
    NCIRData	fnir = { name, NULL };
    Path *	path;

    if ((path = PathBuild(start, FullNameInRoom, &fnir, depth, flags)))
	path->victim = fnir.vict;

    return path;
}

SInt32 CharInRoom(RID *room, Ptr data) {
	CharData *ch;

    if (room == -1)
	return 0;

    START_ITER(iter, ch, CharData *, world[room].people) {
	if (ch == (CharData *)data) {
	   return 1;
	}
    }
    return 0;
}