more do_look() glyph usage without it being set properly

Changes to be committed:
	modified:   src/pager.c

When the previous occurrence that triggered a segfault
was fixed, I didn't check for more of them. It turns out there
were more instances.

This also removes some dead code.
This commit is contained in:
nhmall
2015-03-17 18:47:21 +02:00
committed by Pasi Kallinen
parent 63e7d97148
commit 20b16455ef
+23 -53
View File
@@ -453,7 +453,7 @@ do_look(mode, click_cc)
{ {
boolean quick = (mode == 1); /* use cursor && don't search for "more info" */ boolean quick = (mode == 1); /* use cursor && don't search for "more info" */
boolean clicklook = (mode == 2); /* right mouse-click method */ boolean clicklook = (mode == 2); /* right mouse-click method */
char out_str[BUFSZ], look_buf[BUFSZ]; char out_str[BUFSZ], look_buf[BUFSZ], prefix[BUFSZ];
const char *x_str, *firstmatch = 0; const char *x_str, *firstmatch = 0;
struct permonst *pm = 0; struct permonst *pm = 0;
int glyph; /* glyph at selected position */ int glyph; /* glyph at selected position */
@@ -532,36 +532,14 @@ do_look(mode, click_cc)
glyph = glyph_at(cc.x,cc.y); glyph = glyph_at(cc.x,cc.y);
/* Convert the glyph at the selected position to a symbol. */ /* Convert the glyph at the selected position to a symbol. */
#if 0
if (glyph_is_cmap(glyph)) {
sym = showsyms[glyph_to_cmap(glyph)];
} else if (glyph_is_trap(glyph)) {
sym = showsyms[trap_to_defsym(glyph_to_trap(glyph))];
} else if (glyph_is_statue(glyph)) {
sym = showsyms[(int)mons[glyph_to_mon(glyph)].mlet + SYM_OFF_M];
} else if (glyph_is_object(glyph)) {
sym = showsyms[(int)objects[glyph_to_obj(glyph)].oc_class + SYM_OFF_O];
if (sym == '`' && iflags.bouldersym && (int)glyph_to_obj(glyph) == BOULDER)
sym = iflags.bouldersym;
} else if (glyph_is_monster(glyph)) {
/* takes care of pets, detected, ridden, and regular mons */
sym = showsyms[(int)mons[glyph_to_mon(glyph)].mlet + SYM_OFF_M];
} else if (glyph_is_swallow(glyph)) {
sym = showsyms[glyph_to_swallow(glyph)+S_sw_tl];
} else if (glyph_is_invisible(glyph)) {
sym = DEF_INVISIBLE;
} else if (glyph_is_warning(glyph)) {
sym = glyph_to_warning(glyph);
sym = showsyms[sym + SYM_OFF_W];
} else {
impossible("do_look: bad glyph %d at (%d,%d)",
glyph, (int)cc.x, (int)cc.y);
sym = ' ';
}
#endif
so = mapglyph(glyph, &sym, &oc, &os, cc.x, cc.y); so = mapglyph(glyph, &sym, &oc, &os, cc.x, cc.y);
} }
if (from_screen || clicklook)
Sprintf(prefix, "%s ", encglyph(glyph));
else
Sprintf(prefix, "%s ", sym);
/* /*
* Check all the possibilities, saving all explanations in a buffer. * Check all the possibilities, saving all explanations in a buffer.
* When all have been checked then the string is printed. * When all have been checked then the string is printed.
@@ -574,14 +552,8 @@ do_look(mode, click_cc)
def_monsyms[i].explain) { def_monsyms[i].explain) {
need_to_look = TRUE; need_to_look = TRUE;
if (!found) { if (!found) {
if (from_screen || clicklook) Sprintf(out_str, "%s%s",
Sprintf(out_str, "%s %s", prefix, an(def_monsyms[i].explain));
encglyph(glyph),
an(def_monsyms[i].explain));
else
Sprintf(out_str, "%c %s",
sym,
an(def_monsyms[i].explain));
firstmatch = def_monsyms[i].explain; firstmatch = def_monsyms[i].explain;
found++; found++;
} else { } else {
@@ -605,8 +577,8 @@ do_look(mode, click_cc)
*/ */
if (u.uswallow && (from_screen || clicklook) && is_swallow_sym(sym)) { if (u.uswallow && (from_screen || clicklook) && is_swallow_sym(sym)) {
if (!found) { if (!found) {
Sprintf(out_str, "%s %s", Sprintf(out_str, "%s%s",
encglyph(glyph), mon_interior); prefix, mon_interior);
firstmatch = mon_interior; firstmatch = mon_interior;
} else { } else {
found += append_str(out_str, mon_interior); found += append_str(out_str, mon_interior);
@@ -624,9 +596,8 @@ do_look(mode, click_cc)
continue; continue;
} }
if (!found) { if (!found) {
Sprintf(out_str, "%s %s", Sprintf(out_str, "%s%s",
encglyph(glyph), prefix, an(def_oc_syms[i].explain));
an(def_oc_syms[i].explain));
firstmatch = def_oc_syms[i].explain; firstmatch = def_oc_syms[i].explain;
found++; found++;
} else { } else {
@@ -637,8 +608,8 @@ do_look(mode, click_cc)
if (sym == DEF_INVISIBLE) { if (sym == DEF_INVISIBLE) {
if (!found) { if (!found) {
Sprintf(out_str, "%s %s", Sprintf(out_str, "%s%s",
encglyph(glyph), prefix,
an(invisexplain)); an(invisexplain));
firstmatch = invisexplain; firstmatch = invisexplain;
found++; found++;
@@ -662,12 +633,11 @@ do_look(mode, click_cc)
if (!found) { if (!found) {
if (is_cmap_trap(i)) { if (is_cmap_trap(i)) {
Sprintf(out_str, "%s a trap", Sprintf(out_str, "%sa trap", prefix);
encglyph(glyph));
hit_trap = TRUE; hit_trap = TRUE;
} else { } else {
Sprintf(out_str, "%s %s", Sprintf(out_str, "%s%s",
encglyph(glyph), prefix,
article == 2 ? the(x_str) : article == 2 ? the(x_str) :
article == 1 ? an(x_str) : x_str); article == 1 ? an(x_str) : x_str);
} }
@@ -692,8 +662,8 @@ do_look(mode, click_cc)
if (sym == ((from_screen || clicklook) ? if (sym == ((from_screen || clicklook) ?
warnsyms[i] : def_warnsyms[i].sym)) { warnsyms[i] : def_warnsyms[i].sym)) {
if (!found) { if (!found) {
Sprintf(out_str, "%s %s", Sprintf(out_str, "%s%s",
encglyph(glyph), def_warnsyms[i].explanation); prefix, def_warnsyms[i].explanation);
firstmatch = def_warnsyms[i].explanation; firstmatch = def_warnsyms[i].explanation;
found++; found++;
} else { } else {
@@ -711,8 +681,8 @@ do_look(mode, click_cc)
if (skipped_venom && found < 2) { if (skipped_venom && found < 2) {
x_str = def_oc_syms[VENOM_CLASS].explain; x_str = def_oc_syms[VENOM_CLASS].explain;
if (!found) { if (!found) {
Sprintf(out_str, "%s %s", Sprintf(out_str, "%s%s",
encglyph(glyph), an(x_str)); prefix, an(x_str));
firstmatch = x_str; firstmatch = x_str;
found++; found++;
} else { } else {
@@ -724,8 +694,8 @@ do_look(mode, click_cc)
if (iflags.bouldersym && sym == iflags.bouldersym) { if (iflags.bouldersym && sym == iflags.bouldersym) {
if (!found) { if (!found) {
firstmatch = "boulder"; firstmatch = "boulder";
Sprintf(out_str, "%s %s", Sprintf(out_str, "%s%s",
encglyph(glyph), an(firstmatch)); prefix, an(firstmatch));
found++; found++;
} else { } else {
found += append_str(out_str, "boulder"); found += append_str(out_str, "boulder");