fix for / command to find names like "Hachi" via screen
Changes to be committed:
modified: doc/fixes36.1
modified: src/pager.c
fix bug bz54; this bug had no web ID
Report:
For /, asking via cursor can't find special named entries like "Hachi"
because the entry for the monster type like "dog" gets used instead.
Change:
Instead of "More info?", when applicable it will now do:
More info about "hachi"? [yn] (n) n
More info about "little dog"? [yn] (n)
This commit is contained in:
@@ -155,6 +155,8 @@ jumping while punished could leave ball and chain in the wrong place
|
|||||||
improve Deaf message handling for the minetown watch and shops
|
improve Deaf message handling for the minetown watch and shops
|
||||||
issues with Warning when you're adjacent to an undetected hider; clearly you
|
issues with Warning when you're adjacent to an undetected hider; clearly you
|
||||||
are aware a monster is present so this causes you to search it out
|
are aware a monster is present so this causes you to search it out
|
||||||
|
allow lookup of names like Hachi when selecting monsters from the map
|
||||||
|
lookup "More Info?" prompt will now tell you what it will look for on 'y'
|
||||||
|
|
||||||
|
|
||||||
Platform- and/or Interface-Specific Fixes
|
Platform- and/or Interface-Specific Fixes
|
||||||
|
|||||||
+104
-77
@@ -382,11 +382,11 @@ struct permonst *pm;
|
|||||||
boolean user_typed_name, without_asking;
|
boolean user_typed_name, without_asking;
|
||||||
{
|
{
|
||||||
dlb *fp;
|
dlb *fp;
|
||||||
char buf[BUFSZ], newstr[BUFSZ];
|
char buf[BUFSZ], newstr[BUFSZ], givenname[BUFSZ];
|
||||||
char *ep, *dbase_str;
|
char *ep, *dbase_str;
|
||||||
unsigned long txt_offset = 0L;
|
unsigned long txt_offset = 0L;
|
||||||
int chk_skip;
|
int chk_skip, pass = 1;
|
||||||
boolean found_in_file = FALSE, skipping_entry = FALSE;
|
boolean found_in_file = FALSE, skipping_entry = FALSE, yes_to_moreinfo;
|
||||||
winid datawin = WIN_ERR;
|
winid datawin = WIN_ERR;
|
||||||
|
|
||||||
fp = dlb_fopen(DATAFILE, "r");
|
fp = dlb_fopen(DATAFILE, "r");
|
||||||
@@ -441,8 +441,13 @@ boolean user_typed_name, without_asking;
|
|||||||
|
|
||||||
if ((ep = strstri(dbase_str, " named ")) != 0)
|
if ((ep = strstri(dbase_str, " named ")) != 0)
|
||||||
alt = ep + 7;
|
alt = ep + 7;
|
||||||
else
|
else if ((ep = strstri(dbase_str, " called ")) != 0) {
|
||||||
ep = strstri(dbase_str, " called ");
|
if (strlen(ep + 8) < BUFSZ - 1) {
|
||||||
|
Strcpy(givenname, ep + 8);
|
||||||
|
givenname[BUFSZ-1] = '\0';
|
||||||
|
alt = &givenname[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!ep)
|
if (!ep)
|
||||||
ep = strstri(dbase_str, ", ");
|
ep = strstri(dbase_str, ", ");
|
||||||
if (ep && ep > dbase_str)
|
if (ep && ep > dbase_str)
|
||||||
@@ -459,85 +464,107 @@ boolean user_typed_name, without_asking;
|
|||||||
if (!alt)
|
if (!alt)
|
||||||
alt = makesingular(dbase_str);
|
alt = makesingular(dbase_str);
|
||||||
|
|
||||||
/* skip first record; read second */
|
if (!strcmp(alt, dbase_str))
|
||||||
txt_offset = 0L;
|
pass = 0;
|
||||||
if (!dlb_fgets(buf, BUFSZ, fp) || !dlb_fgets(buf, BUFSZ, fp)) {
|
|
||||||
impossible("can't read 'data' file");
|
|
||||||
(void) dlb_fclose(fp);
|
|
||||||
return;
|
|
||||||
} else if (sscanf(buf, "%8lx\n", &txt_offset) < 1 || txt_offset == 0L)
|
|
||||||
goto bad_data_file;
|
|
||||||
|
|
||||||
/* look for the appropriate entry */
|
for (; pass >= 0; pass--) {
|
||||||
while (dlb_fgets(buf, BUFSZ, fp)) {
|
txt_offset = 0L;
|
||||||
if (*buf == '.')
|
if (dlb_fseek(fp, txt_offset, SEEK_SET) < 0 ) {
|
||||||
break; /* we passed last entry without success */
|
impossible("can't get to start of 'data' file");
|
||||||
|
dlb_fclose(fp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* skip first record; read second */
|
||||||
|
if (!dlb_fgets(buf, BUFSZ, fp) || !dlb_fgets(buf, BUFSZ, fp)) {
|
||||||
|
impossible("can't read 'data' file");
|
||||||
|
(void) dlb_fclose(fp);
|
||||||
|
return;
|
||||||
|
} else if (sscanf(buf, "%8lx\n", &txt_offset) < 1 || txt_offset == 0L)
|
||||||
|
goto bad_data_file;
|
||||||
|
|
||||||
if (digit(*buf)) {
|
/* look for the appropriate entry */
|
||||||
/* a number indicates the end of current entry */
|
while (dlb_fgets(buf, BUFSZ, fp)) {
|
||||||
skipping_entry = FALSE;
|
if (*buf == '.')
|
||||||
} else if (!skipping_entry) {
|
break; /* we passed last entry without success */
|
||||||
if (!(ep = index(buf, '\n')))
|
|
||||||
goto bad_data_file;
|
if (digit(*buf)) {
|
||||||
(void) strip_newline((ep > buf) ? ep - 1 : ep);
|
/* a number indicates the end of current entry */
|
||||||
/* if we match a key that begins with "~", skip this entry */
|
skipping_entry = FALSE;
|
||||||
chk_skip = (*buf == '~') ? 1 : 0;
|
} else if (!skipping_entry) {
|
||||||
if (pmatch(&buf[chk_skip], dbase_str)
|
if (!(ep = index(buf, '\n')))
|
||||||
|| (alt && pmatch(&buf[chk_skip], alt))) {
|
goto bad_data_file;
|
||||||
if (chk_skip) {
|
(void) strip_newline((ep > buf) ? ep - 1 : ep);
|
||||||
skipping_entry = TRUE;
|
/* if we match a key that begins with "~", skip this entry */
|
||||||
continue;
|
chk_skip = (*buf == '~') ? 1 : 0;
|
||||||
} else {
|
if ((pass == 0 && pmatch(&buf[chk_skip], dbase_str)) ||
|
||||||
found_in_file = TRUE;
|
(pass == 1 && alt && pmatch(&buf[chk_skip], alt))) {
|
||||||
break;
|
if (chk_skip) {
|
||||||
|
skipping_entry = TRUE;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
found_in_file = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (found_in_file) {
|
||||||
|
long entry_offset;
|
||||||
|
int entry_count;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* skip over other possible matches for the info */
|
||||||
|
do {
|
||||||
|
if (!dlb_fgets(buf, BUFSZ, fp))
|
||||||
|
goto bad_data_file;
|
||||||
|
} while (!digit(*buf));
|
||||||
|
if (sscanf(buf, "%ld,%d\n", &entry_offset, &entry_count) < 2) {
|
||||||
|
bad_data_file:
|
||||||
|
impossible("'data' file in wrong format or corrupted");
|
||||||
|
/* window will exist if we came here from below via 'goto' */
|
||||||
|
if (datawin != WIN_ERR)
|
||||||
|
destroy_nhwindow(datawin);
|
||||||
|
(void) dlb_fclose(fp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
yes_to_moreinfo = FALSE;
|
||||||
|
if (!user_typed_name && !without_asking) {
|
||||||
|
unsigned maxt = strlen("More info about \"\"?");
|
||||||
|
char *entrytext = pass ? alt : dbase_str;
|
||||||
|
char question[BUFSZ];
|
||||||
|
if (strlen(entrytext) < BUFSZ - maxt) {
|
||||||
|
Strcpy(question, "More info about \"");
|
||||||
|
Strcat(question, entrytext);
|
||||||
|
Strcat(question, "\"?");
|
||||||
|
}
|
||||||
|
if (yn(question) == 'y')
|
||||||
|
yes_to_moreinfo = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_typed_name || without_asking || yes_to_moreinfo) {
|
||||||
|
if (dlb_fseek(fp,
|
||||||
|
(long) txt_offset + entry_offset, SEEK_SET) < 0) {
|
||||||
|
pline("? Seek error on 'data' file!");
|
||||||
|
(void) dlb_fclose(fp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
datawin = create_nhwindow(NHW_MENU);
|
||||||
|
for (i = 0; i < entry_count; i++) {
|
||||||
|
if (!dlb_fgets(buf, BUFSZ, fp))
|
||||||
|
goto bad_data_file;
|
||||||
|
(void) strip_newline(buf);
|
||||||
|
if (index(buf + 1, '\t') != 0)
|
||||||
|
(void) tabexpand(buf + 1);
|
||||||
|
putstr(datawin, 0, buf + 1);
|
||||||
|
}
|
||||||
|
display_nhwindow(datawin, FALSE);
|
||||||
|
destroy_nhwindow(datawin);
|
||||||
|
}
|
||||||
|
} else if (user_typed_name && pass == 0)
|
||||||
|
pline("I don't have any information on those things.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found_in_file) {
|
|
||||||
long entry_offset;
|
|
||||||
int entry_count;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* skip over other possible matches for the info */
|
|
||||||
do {
|
|
||||||
if (!dlb_fgets(buf, BUFSZ, fp))
|
|
||||||
goto bad_data_file;
|
|
||||||
} while (!digit(*buf));
|
|
||||||
if (sscanf(buf, "%ld,%d\n", &entry_offset, &entry_count) < 2) {
|
|
||||||
bad_data_file:
|
|
||||||
impossible("'data' file in wrong format or corrupted");
|
|
||||||
/* window will exist if we came here from below via 'goto' */
|
|
||||||
if (datawin != WIN_ERR)
|
|
||||||
destroy_nhwindow(datawin);
|
|
||||||
(void) dlb_fclose(fp);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user_typed_name || without_asking || yn("More info?") == 'y') {
|
|
||||||
if (dlb_fseek(fp, (long) txt_offset + entry_offset, SEEK_SET)
|
|
||||||
< 0) {
|
|
||||||
pline("? Seek error on 'data' file!");
|
|
||||||
(void) dlb_fclose(fp);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
datawin = create_nhwindow(NHW_MENU);
|
|
||||||
for (i = 0; i < entry_count; i++) {
|
|
||||||
if (!dlb_fgets(buf, BUFSZ, fp))
|
|
||||||
goto bad_data_file;
|
|
||||||
(void) strip_newline(buf);
|
|
||||||
if (index(buf + 1, '\t') != 0)
|
|
||||||
(void) tabexpand(buf + 1);
|
|
||||||
putstr(datawin, 0, buf + 1);
|
|
||||||
}
|
|
||||||
display_nhwindow(datawin, FALSE);
|
|
||||||
destroy_nhwindow(datawin);
|
|
||||||
}
|
|
||||||
} else if (user_typed_name)
|
|
||||||
pline("I don't have any information on those things.");
|
|
||||||
|
|
||||||
(void) dlb_fclose(fp);
|
(void) dlb_fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user