00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #if defined(macintosh)
00029 #include <types.h>
00030 #else
00031 #include <sys/types.h>
00032 #endif
00033 #include <stdio.h>
00034 #include <time.h>
00035 #include <string.h>
00036 #include "merc.h"
00037 #include "tables.h"
00038
00039 int flag_lookup (const char *name, const struct flag_type *flag_table)
00040 {
00041 int flag;
00042
00043 for (flag = 0; flag_table[flag].name != NULL; flag++)
00044 {
00045 if (LOWER (name[0]) == LOWER (flag_table[flag].name[0])
00046 && !str_prefix (name, flag_table[flag].name))
00047 return flag_table[flag].bit;
00048 }
00049
00050 return NO_FLAG;
00051 }
00052 int cont_lookup (const char *name)
00053 {
00054 int cont;
00055 if (name == NULL)
00056 return 0;
00057
00058 for (cont = 0; cont < MAX_CONT; cont++)
00059 {
00060 if (LOWER(name[0]) == LOWER(conts_table[cont].name[0])
00061 && !str_prefix (name, conts_table[cont].name))
00062 return cont;
00063 }
00064 return 0;
00065 }
00066
00067 int clan_lookup (const char *name)
00068 {
00069 int clan;
00070
00071 if (name == NULL)
00072 return 0;
00073
00074 for (clan = 0; clan < MAX_CLAN; clan++)
00075 {
00076 if (LOWER (name[0]) == LOWER (clan_table[clan].name[0])
00077 && !str_prefix (name, clan_table[clan].name))
00078 return clan;
00079 }
00080
00081 return 0;
00082 }
00083
00084 int dragon_lookup (const char *name)
00085 {
00086 int dragon;
00087
00088 for (dragon =0; dragon < 2; dragon++)
00089 {
00090 if(LOWER(name[0]) == LOWER(dragon_table[dragon].name[0])
00091 && !str_prefix(name, dragon_table[dragon].name))
00092 return dragon;
00093 }
00094 return 0;
00095 }
00096
00097 int kingdom_lookup (const char *name)
00098 {
00099 int kingdom;
00100 if (name == NULL)
00101 return 0;
00102 for (kingdom =0; kingdom < MAX_KINGDOM; kingdom++)
00103 {
00104 if (LOWER (name[0]) == LOWER (kingdom_table[kingdom].name[0])
00105 && !str_prefix (name, kingdom_table[kingdom].name))
00106 return kingdom;
00107 }
00108 return 0;
00109 }
00110
00111 int position_lookup (const char *name)
00112 {
00113 int pos;
00114
00115 for (pos = 0; position_table[pos].name != NULL; pos++)
00116 {
00117 if (LOWER (name[0]) == LOWER (position_table[pos].name[0])
00118 && !str_prefix (name, position_table[pos].name))
00119 return pos;
00120 }
00121
00122 return -1;
00123 }
00124
00125 int sex_lookup (const char *name)
00126 {
00127 int sex;
00128
00129 for (sex = 0; sex_table[sex].name != NULL; sex++)
00130 {
00131 if (LOWER (name[0]) == LOWER (sex_table[sex].name[0])
00132 && !str_prefix (name, sex_table[sex].name))
00133 return sex;
00134 }
00135
00136 return -1;
00137 }
00138
00139 int size_lookup (const char *name)
00140 {
00141 int size;
00142
00143 for (size = 0; size_table[size].name != NULL; size++)
00144 {
00145 if (LOWER (name[0]) == LOWER (size_table[size].name[0])
00146 && !str_prefix (name, size_table[size].name))
00147 return size;
00148 }
00149
00150 return -1;
00151 }
00152
00153
00154 int race_lookup (const char *name)
00155 {
00156 int race;
00157
00158 for (race = 0; race_table[race].name != NULL; race++)
00159 {
00160 if (LOWER (name[0]) == LOWER (race_table[race].name[0])
00161 && !str_prefix (name, race_table[race].name))
00162 return race;
00163 }
00164
00165 return 0;
00166 }
00167
00168 int item_lookup (const char *name)
00169 {
00170 int type;
00171
00172 for (type = 0; item_table[type].name != NULL; type++)
00173 {
00174 if (LOWER (name[0]) == LOWER (item_table[type].name[0])
00175 && !str_prefix (name, item_table[type].name))
00176 return item_table[type].type;
00177 }
00178
00179 return -1;
00180 }
00181
00182 int liq_lookup (const char *name)
00183 {
00184 int liq;
00185
00186 for (liq = 0; liq_table[liq].liq_name != NULL; liq++)
00187 {
00188 if (LOWER (name[0]) == LOWER (liq_table[liq].liq_name[0])
00189 && !str_prefix (name, liq_table[liq].liq_name))
00190 return liq;
00191 }
00192
00193 return -1;
00194 }
00195
00196 HELP_DATA *help_lookup (char *keyword)
00197 {
00198 HELP_DATA *pHelp;
00199 char temp[MIL], argall[MIL];
00200
00201 argall[0] = '\0';
00202
00203 while (keyword[0] != '\0')
00204 {
00205 keyword = one_argument (keyword, temp);
00206 if (argall[0] != '\0')
00207 strcat (argall, " ");
00208 strcat (argall, temp);
00209 }
00210
00211 for (pHelp = help_first; pHelp != NULL; pHelp = pHelp->next)
00212 if (is_name (argall, pHelp->keyword))
00213 return pHelp;
00214
00215 return NULL;
00216 }
00217
00218 HELP_AREA *had_lookup (char *arg)
00219 {
00220 HELP_AREA *temp;
00221 extern HELP_AREA *had_list;
00222
00223 for (temp = had_list; temp; temp = temp->next)
00224 if (!str_cmp (arg, temp->filename))
00225 return temp;
00226
00227 return NULL;
00228 }