src/hcode/btech/p.mech.partnames.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void list_phashstats (dbref player)
void initialize_partname_tables (void)
char * get_parts_short_name (int i, int b)
char * get_parts_long_name (int i, int b)
char * get_parts_vlong_name (int i, int b)
int find_matching_vlong_part (char *wc, int *ind, int *id, int *brand)
int find_matching_long_part (char *wc, int *i, int *id, int *brand)
int find_matching_short_part (char *wc, int *ind, int *id, int *brand)
void ListForms (dbref player, void *data, char *buffer)
char * partname_func (int index, int size)


Function Documentation

int find_matching_long_part ( char *  wc,
int *  i,
int *  id,
int *  brand 
)

Definition at line 166 of file mech.partnames.c.

References PN::index, long_sorted, object_count, UNPACK_PART, and wildcard_match.

Referenced by fun_btaddstores(), fun_btgetpartcost(), fun_btgetweight(), fun_btpartmatch(), fun_btparttype(), fun_btremovestores(), fun_btsetpartcost(), fun_btstores(), fun_btweapstat(), list_matching(), stuff_change_sub(), and tech_parsegun().

00167 {
00168         PN *p;
00169 
00170         for((*i)++; *i < object_count; (*i)++)
00171                 if(wildcard_match(wc, (p = long_sorted[*i])->longy)) {
00172                         UNPACK_PART(p->index, *id, *brand);
00173                         return 1;
00174                 }
00175         return 0;
00176 }

int find_matching_short_part ( char *  wc,
int *  ind,
int *  id,
int *  brand 
)

Definition at line 178 of file mech.partnames.c.

References hashfind(), PN::index, MBUF_SIZE, short_hash, short_sorted, ToLower, and UNPACK_PART.

Referenced by fun_btaddstores(), fun_btpartmatch(), and stuff_change_sub().

00179 {
00180         PN *p;
00181         char *tmpc1, *tmpc2;
00182         char tmpbuf[MBUF_SIZE];
00183         int *i;
00184 
00185         if(*ind >= 0)
00186                 return 0;
00187         for(tmpc1 = wc, tmpc2 = tmpbuf; *tmpc1; tmpc1++, tmpc2++) {
00188                 *tmpc2 = ToLower(*tmpc1);
00189         }
00190         *tmpc2 = 0;
00191         if((i = hashfind(tmpbuf, &short_hash))) {
00192                 if((p = short_sorted[((int) i) - 1])) {
00193                         *ind = ((int) i);
00194                         UNPACK_PART(p->index, *id, *brand);
00195                         return 1;
00196                 }
00197         }
00198         return 0;
00199 }

int find_matching_vlong_part ( char *  wc,
int *  ind,
int *  id,
int *  brand 
)

Definition at line 142 of file mech.partnames.c.

References hashfind(), PN::index, MBUF_SIZE, short_sorted, ToLower, UNPACK_PART, and vlong_hash.

Referenced by FindSpecialItemCodeFromString(), fun_btaddstores(), fun_btgetpartcost(), fun_btgetweight(), fun_btpartmatch(), fun_btparttype(), fun_btremovestores(), fun_btsetpartcost(), fun_btstores(), fun_btweapstat(), initialize_pc(), load_template(), LoadSpecialObjects(), stuff_change_sub(), and WeaponIndexFromString().

00143 {
00144         PN *p;
00145         char *tmpc1, *tmpc2;
00146         char tmpbuf[MBUF_SIZE];
00147         int *i;
00148 
00149         if(ind && *ind >= 0)
00150                 return 0;
00151         for(tmpc1 = wc, tmpc2 = tmpbuf; *tmpc1; tmpc1++, tmpc2++) {
00152                 *tmpc2 = ToLower(*tmpc1);
00153         }
00154         *tmpc2 = 0;
00155         if((i = hashfind(tmpbuf, &vlong_hash))) {
00156                 if((p = short_sorted[((int) i) - 1])) {
00157                         if(ind)
00158                                 *ind = ((int) i);
00159                         UNPACK_PART(p->index, *id, *brand);
00160                         return 1;
00161                 }
00162         }
00163         return 0;
00164 }

char* get_parts_long_name ( int  i,
int  b 
)

char* get_parts_short_name ( int  i,
int  b 
)

char* get_parts_vlong_name ( int  i,
int  b 
)

void initialize_partname_tables ( void   ) 

Definition at line 94 of file mech.partnames.c.

00095 {
00096         int i, j, c = 0, m, n;
00097         char tmpbuf[MBUF_SIZE];
00098         char *tmpc1, *tmpc2;
00099 
00100         bzero(index_sorted, sizeof(index_sorted));
00101         for(j = 0; j <= BRANDCOUNT; j++)
00102                 for(i = 0; i < NUM_ITEMS; i++)
00103                         c += create_brandname(i, j);
00104         Create(short_sorted, PN *, c);
00105         Create(long_sorted, PN *, c);
00106         Create(vlong_sorted, PN *, c);
00107         /* bubble-sort 'em and insert to array */
00108         i = 0;
00109         for(m = 0; m <= BRANDCOUNT; m++)
00110                 for(n = 0; n < NUM_ITEMS; n++)
00111                         if(index_sorted[m][n])
00112                                 insert_sorted_brandname(i++, index_sorted[m][n]);
00113         hashinit(&short_hash, 20 * HASH_FACTOR);
00114         hashinit(&vlong_hash, 20 * HASH_FACTOR);
00115 #define DASH(fromval,tohash) \
00116   for (tmpc1 = short_sorted[i]->fromval, tmpc2 = tmpbuf ; *tmpc1 ; tmpc1++, tmpc2++) \
00117     *tmpc2 = ToLower(*tmpc1); \
00118   *tmpc2 = 0; \
00119   hashadd(tmpbuf, (int *) (i+1), &tohash);
00120 
00121         for(i = 0; i < c; i++) {
00122                 DASH(shorty, short_hash);
00123 
00124 /*       DASH(longy, long_hash); */
00125                 DASH(vlongy, vlong_hash);
00126         }
00127         object_count = c;
00128 }

void list_phashstats ( dbref  player  ) 

void ListForms ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 201 of file mech.partnames.c.

References notify, notify_printf(), object_count, and short_sorted.

00202 {
00203         int i;
00204 
00205         notify(player, "Listing of forms:");
00206         for(i = 0; i < object_count; i++)
00207                 notify_printf(player, "%3d %-20s %-25s %s", i,
00208                                           short_sorted[i]->shorty, short_sorted[i]->longy,
00209                                           short_sorted[i]->vlongy);
00210 
00211 }

char* partname_func ( int  index,
int  size 
)

Definition at line 273 of file mech.partnames.c.

References BRANDCOUNT, index_sorted, PN::longy, MBUF_SIZE, PN::shorty, UNPACK_PART, and PN::vlongy.

Referenced by fun_btpartname(), and payloadlist_func().

00274 {
00275 
00276         static char buffer[MBUF_SIZE];
00277         int id, brand;
00278         PN *p;
00279 
00280         UNPACK_PART(index, id, brand);
00281         if(brand < 0 || brand > BRANDCOUNT || id < 0) {
00282                 snprintf(buffer, MBUF_SIZE, "%s", "#-1 INVALID PART NUMBER");
00283                 return buffer;
00284         }
00285 
00286         p = index_sorted[brand][id];
00287         if(!p) {
00288                 snprintf(buffer, MBUF_SIZE, "%s", "#-1 INVALID PART NUMBER");
00289                 return buffer;
00290         }
00291 
00292         switch (size) {
00293         case 's':
00294         case 'S':
00295                 snprintf(buffer, MBUF_SIZE, "%s", p->shorty);
00296                 break;
00297         case 'l':
00298         case 'L':
00299                 snprintf(buffer, MBUF_SIZE, "%s", p->longy);
00300                 break;
00301         case 'v':
00302         case 'V':
00303                 snprintf(buffer, MBUF_SIZE, "%s", p->vlongy);
00304                 break;
00305         default:
00306                 snprintf(buffer, MBUF_SIZE, "%s", "#-1 INVALID NAME TYPE");
00307                 break;
00308         }
00309 
00310         return buffer;
00311 }


Generated on Mon May 28 04:25:42 2007 for BattletechMUX by  doxygen 1.4.7