|
|
|
@ -97,38 +97,49 @@ const uchar def_r_oc_syms[MAXOCLASSES] = {
|
|
|
|
|
* recognized, then MAXOCLASSES is returned. Used in detect.c, invent.c,
|
|
|
|
|
* objnam.c, options.c, pickup.c, sp_lev.c, lev_main.c, and tilemap.c.
|
|
|
|
|
*/
|
|
|
|
|
int
|
|
|
|
|
def_char_to_objclass(char ch)
|
|
|
|
|
int def_char_to_objclass(char ch)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 1; i < MAXOCLASSES; i++)
|
|
|
|
|
// Iterate through the object classes
|
|
|
|
|
for (i = 1; i < MAXOCLASSES; i++) {
|
|
|
|
|
// Check if the character matches the symbol of the current object class
|
|
|
|
|
if (ch == def_oc_syms[i].sym)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Return the index representing the object class if a match is found
|
|
|
|
|
// If no match is found, return MAXOCLASSES
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Convert a character into a monster class. This returns the _first_
|
|
|
|
|
* match made. If there are are no matches, return MAXMCLASSES.
|
|
|
|
|
* Used in detect.c, options.c, read.c, sp_lev.c, and lev_main.c
|
|
|
|
|
*/
|
|
|
|
|
int
|
|
|
|
|
def_char_to_monclass(char ch)
|
|
|
|
|
int def_char_to_monclass(char ch)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 1; i < MAXMCLASSES; i++)
|
|
|
|
|
// Iterate through the monster classes
|
|
|
|
|
for (i = 1; i < MAXMCLASSES; i++) {
|
|
|
|
|
// Check if the character matches the symbol of the current monster class
|
|
|
|
|
if (ch == def_monsyms[i].sym)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Return the index representing the monster class if a match is found
|
|
|
|
|
// If no match is found, return MAXMCLASSES
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* does 'ch' represent a furniture character? returns index into defsyms[] */
|
|
|
|
|
int
|
|
|
|
|
def_char_is_furniture(char ch)
|
|
|
|
|
int def_char_is_furniture(char ch)
|
|
|
|
|
{
|
|
|
|
|
/* note: these refer to defsyms[] order which is much different from
|
|
|
|
|
/* Note: these refer to defsyms[] order which is much different from
|
|
|
|
|
levl[][].typ order but both keep furniture in a contiguous block */
|
|
|
|
|
static const char first_furniture[] = "stair", /* "staircase up" */
|
|
|
|
|
last_furniture[] = "fountain";
|
|
|
|
@ -137,17 +148,22 @@ def_char_is_furniture(char ch)
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < MAXPCHARS; ++i) {
|
|
|
|
|
if (!furniture) {
|
|
|
|
|
// Check if the current explanation matches the start of furniture
|
|
|
|
|
if (!strncmp(defsyms[i].explanation, first_furniture, 5))
|
|
|
|
|
furniture = TRUE;
|
|
|
|
|
}
|
|
|
|
|
if (furniture) {
|
|
|
|
|
// If the current symbol matches the input character, return the index
|
|
|
|
|
if (defsyms[i].sym == (uchar) ch)
|
|
|
|
|
return i;
|
|
|
|
|
// If the current explanation matches the end of furniture, break the loop
|
|
|
|
|
if (!strcmp(defsyms[i].explanation, last_furniture))
|
|
|
|
|
break; /* reached last furniture */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// If no match is found, return -1
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*drawing.c*/
|
|
|
|
|