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:
nhmall
2016-02-14 22:23:59 -05:00
parent 592ae69726
commit 640267f53a
2 changed files with 106 additions and 77 deletions
+2
View File
@@ -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
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
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
+42 -15
View File
@@ -382,11 +382,11 @@ struct permonst *pm;
boolean user_typed_name, without_asking;
{
dlb *fp;
char buf[BUFSZ], newstr[BUFSZ];
char buf[BUFSZ], newstr[BUFSZ], givenname[BUFSZ];
char *ep, *dbase_str;
unsigned long txt_offset = 0L;
int chk_skip;
boolean found_in_file = FALSE, skipping_entry = FALSE;
int chk_skip, pass = 1;
boolean found_in_file = FALSE, skipping_entry = FALSE, yes_to_moreinfo;
winid datawin = WIN_ERR;
fp = dlb_fopen(DATAFILE, "r");
@@ -441,8 +441,13 @@ boolean user_typed_name, without_asking;
if ((ep = strstri(dbase_str, " named ")) != 0)
alt = ep + 7;
else
ep = strstri(dbase_str, " called ");
else if ((ep = strstri(dbase_str, " called ")) != 0) {
if (strlen(ep + 8) < BUFSZ - 1) {
Strcpy(givenname, ep + 8);
givenname[BUFSZ-1] = '\0';
alt = &givenname[0];
}
}
if (!ep)
ep = strstri(dbase_str, ", ");
if (ep && ep > dbase_str)
@@ -459,8 +464,17 @@ boolean user_typed_name, without_asking;
if (!alt)
alt = makesingular(dbase_str);
/* skip first record; read second */
if (!strcmp(alt, dbase_str))
pass = 0;
for (; pass >= 0; pass--) {
txt_offset = 0L;
if (dlb_fseek(fp, txt_offset, SEEK_SET) < 0 ) {
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);
@@ -482,8 +496,8 @@ boolean user_typed_name, without_asking;
(void) strip_newline((ep > buf) ? ep - 1 : ep);
/* if we match a key that begins with "~", skip this entry */
chk_skip = (*buf == '~') ? 1 : 0;
if (pmatch(&buf[chk_skip], dbase_str)
|| (alt && pmatch(&buf[chk_skip], alt))) {
if ((pass == 0 && pmatch(&buf[chk_skip], dbase_str)) ||
(pass == 1 && alt && pmatch(&buf[chk_skip], alt))) {
if (chk_skip) {
skipping_entry = TRUE;
continue;
@@ -494,8 +508,6 @@ boolean user_typed_name, without_asking;
}
}
}
}
if (found_in_file) {
long entry_offset;
int entry_count;
@@ -516,9 +528,23 @@ boolean user_typed_name, without_asking;
return;
}
if (user_typed_name || without_asking || yn("More info?") == 'y') {
if (dlb_fseek(fp, (long) txt_offset + entry_offset, SEEK_SET)
< 0) {
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;
@@ -535,9 +561,10 @@ boolean user_typed_name, without_asking;
display_nhwindow(datawin, FALSE);
destroy_nhwindow(datawin);
}
} else if (user_typed_name)
} else if (user_typed_name && pass == 0)
pline("I don't have any information on those things.");
}
}
(void) dlb_fclose(fp);
}