teleport.c
src/teleport.c · 5.0 KB
From the archive rom24src.tar.gz
Download the archive « Back to the archive contents
/***************************************************************************
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. *
* *
* Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* *
* In order to use any part of this Merc Diku Mud, you must comply with *
* both the original Diku license in 'license.doc' as well the Merc *
* license in 'license.txt'. In particular, you may not remove either of *
* these copyright notices. *
* *
* Much time and thought has gone into this software and you are *
* benefitting. We hope that you share your changes too. What goes *
* around, comes around. *
***************************************************************************/
#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "merc.h"
#include "teleport.h"
ROOM_INDEX_DATA *room_by_name(char *keywords, int level, bool fError)
{
ROOM_INDEX_DATA *room, *result = NULL;
int count = 0;
int i,x,y;
if (fError)
{
/* begin traversing list */
for (i = 0; destination[i].word_list != NULL; i++)
{
if (is_name(keywords,destination[i].word_list))
{
for (x = 0; x < MAX_ROOMS; x++)
{
if (destination[i].error[x] == 0)
break;
room = get_room_index(destination[i].error[x]);
if (room != NULL && number_range(0,count++) == 0)
result = room;
}
}
}
return result;
}
/* traverse list for appropriate level location */
for (i = 0; destination[i].word_list != NULL; i++)
{
if (is_name(keywords,destination[i].word_list))
{
for (x = 0; x < MAX_LIST; x++)
{
if (destination[i].rooms[x].level == -1)
break;
if (level < destination[i].rooms[x].level)
continue;
for (y = 0; y < MAX_ROOMS; y++)
{
if (destination[i].rooms[x].vnum[y] == 0)
break;
room = get_room_index(destination[i].rooms[x].vnum[y]);
if (room != NULL && number_range(0,count++) == 0)
result = room;
}
}
}
}
return result;
}
const KEY_LIST destination[] =
{
{
"high tower mage sorcery", { 3001 },
{ { 0, { 1312 } }, {-1} }
},
{
"mahn-tor mahn tor minotaur", { 3001 },
{ { 0, {2341,2352} }, {-1} }
},
{
"hell gate gates entrance", { 3001 },
{ { 30, {10401} },
{ 40, {10450} },
{-1}
}
},
{
"drow city underdark", { 3001 },
{ { 0, {5267, 5201} }, {-1} }
},
{
"arachnos spider webs", { 3001 },
{ { 0, {6130} }, {-1} }
},
{
"dragon tower draconian", { 3001 },
{ { 25, {2201} }, {-1} }
},
{
"galaxy stars space constellations", {10401},
{ { 10, {9303} }, {-1} }
},
{
"catcombs", {3001},
{ { 0, {6500,2001}}, {-1} }
},
{
"astral gate", {3001},
{ { 0, {7706,7750}}, {-1} }
},
{
"githyanki keep", {7706},
{ {10, {7750}}, {-1} }
},
{
"graveyard elm street chapel", {3001},
{ {0, {3600}}, {-1} }
},
{
"nirvana balance primus", {3001},
{ {30, {9000}}, {-1} }
},
{
"moria mines balrog", {3001},
{ {0, {4029}}, {-1} }
},
{
"ogre village", {3001},
{ { 0, {2341}}, {-1} }
},
{
"pyramid great desert", {3001},
{ { 0, {8706}}, {-1} }
},
{ NULL, {}, {{}} }
};