/* * Determines if an object is already squelched. Same as squelch_item_ok above, * without the first (p_ptr->unignoring) test. */ bool object_is_squelched(const object_type *o_ptr) { byte type; /* Do squelch individual objects that marked ignore */ if (o_ptr->ignore) return TRUE; /* Don't squelch artifacts unless marked to be squelched */ if (o_ptr->artifact || check_for_inscrip(o_ptr, "!k") || check_for_inscrip(o_ptr, "!*")) return FALSE; /* Do squelching by kind */ if (object_flavor_is_aware(o_ptr) ? kind_is_squelched_aware(o_ptr->kind) : kind_is_squelched_unaware(o_ptr->kind)) return TRUE; type = squelch_type_of(o_ptr); if (type == TYPE_MAX) return FALSE; /* Squelch items known not to be special */ if (object_is_known_not_artifact(o_ptr) && squelch_level[type] == SQUELCH_ALL) return TRUE; /* Get result based on the feeling and the squelch_level */ if (squelch_level_of(o_ptr) <= squelch_level[type]) return TRUE; else return FALSE; }
/* * Determines if an object is eligible for squelching. */ bool squelch_item_ok(const object_type *o_ptr) { object_kind *k_ptr = &k_info[o_ptr->k_idx]; byte type; /* Don't squelch artifacts unless marked to be squelched */ if (artifact_p(o_ptr)) return FALSE; /* Don't squelch stuff inscribed not to be destroyed (!k) */ if (check_for_inscrip(o_ptr, "!k") || check_for_inscrip(o_ptr, "!*")) return FALSE; /* Auto-squelch dead chests */ if (o_ptr->tval == TV_CHEST && o_ptr->pval == 0) return TRUE; /* check option for worthless kinds */ if (OPT(squelch_worthless) && o_ptr->tval != TV_GOLD) { if (object_flavor_is_aware(o_ptr) && k_ptr->cost == 0) return TRUE; if (object_is_known_cursed(o_ptr)) return TRUE; } /* Do squelching by kind */ if (object_flavor_is_aware(o_ptr) ? kind_is_squelched_aware(k_ptr) : kind_is_squelched_unaware(k_ptr)) return TRUE; type = squelch_type_of(o_ptr); if (type == TYPE_MAX) return FALSE; /* Squelch items known not to be special */ if (object_is_known_not_artifact(o_ptr) && squelch_level[type] == SQUELCH_ALL) return TRUE; /* Get result based on the feeling and the squelch_level */ if (squelch_level_of(o_ptr) <= squelch_level[type]) return TRUE; else return FALSE; }
/* * Display the objects in a group. */ static void display_object(int col, int row, bool cursor, int oid) { object_kind *kind = &k_info[oid]; const char *inscrip = get_autoinscription(kind); char o_name[80]; /* Choose a color */ bool aware = (!kind->flavor || kind->aware); byte attr = curs_attrs[(int)aware][(int)cursor]; /* Find graphics bits -- versions of the object_char and object_attr defines */ bool use_flavour = (kind->flavor) && !(aware && kind->tval == TV_SCROLL); byte a = use_flavour ? kind->flavor->x_attr : kind->x_attr; byte c = use_flavour ? kind->flavor->x_char : kind->x_char; /* Display known artifacts differently */ if (of_has(kind->flags, OF_INSTA_ART) && artifact_is_known(get_artifact_from_kind(kind))) get_artifact_display_name(o_name, sizeof(o_name), get_artifact_from_kind(kind)); else object_kind_name(o_name, sizeof(o_name), kind, OPT(cheat_know)); /* If the type is "tried", display that */ if (kind->tried && !aware) my_strcat(o_name, " {tried}", sizeof(o_name)); /* Display the name */ c_prt(attr, o_name, row, col); /* Show squelch status */ if ((aware && kind_is_squelched_aware(kind)) || (!aware && kind_is_squelched_unaware(kind))) c_put_str(attr, "Yes", row, 46); /* Show autoinscription if around */ if (aware && inscrip) c_put_str(TERM_YELLOW, inscrip, row, 55); if (tile_height == 1) { big_pad(76, row, a, c); } }
void wr_object_memory(void) { int k_idx; wr_u16b(z_info->k_max); for (k_idx = 0; k_idx < z_info->k_max; k_idx++) { byte tmp8u = 0; object_kind *k_ptr = &k_info[k_idx]; if (k_ptr->aware) tmp8u |= 0x01; if (k_ptr->tried) tmp8u |= 0x02; if (kind_is_squelched_aware(k_ptr)) tmp8u |= 0x04; if (k_ptr->everseen) tmp8u |= 0x08; if (kind_is_squelched_unaware(k_ptr)) tmp8u |= 0x10; wr_byte(tmp8u); } }
/* * Special key actions for object inscription. */ static void o_xtra_act(struct keypress ch, int oid) { object_kind *k = objkind_byid(oid); /* Toggle squelch */ if (squelch_tval(k->tval) && (ch.code == 's' || ch.code == 'S')) { if (k->aware) { if (kind_is_squelched_aware(k)) kind_squelch_clear(k); else kind_squelch_when_aware(k); } else { if (kind_is_squelched_unaware(k)) kind_squelch_clear(k); else kind_squelch_when_unaware(k); } return; } /* Forget it if we've never seen the thing */ if (k->flavor && !k->aware) return; /* Uninscribe */ if (ch.code == '}') { if (k->note) remove_autoinscription(oid); } else if (ch.code == '{') { /* Inscribe */ char note_text[80] = ""; /* Avoid the prompt getting in the way */ screen_save(); /* Prompt */ prt("Inscribe with: ", 0, 0); /* Default note */ if (k->note) strnfmt(note_text, sizeof(note_text), "%s", get_autoinscription(k)); /* Get an inscription */ if (askfor_aux(note_text, sizeof(note_text), NULL)) { /* Remove old inscription if existent */ if (k->note) remove_autoinscription(oid); /* Add the autoinscription */ add_autoinscription(oid, note_text); /* Notice stuff (later) */ p_ptr->notice |= (PN_AUTOINSCRIBE); p_ptr->redraw |= (PR_INVEN | PR_EQUIP); } /* Reload the screen */ screen_load(); } }
void textui_cmd_destroy(void) { int item; object_type *o_ptr; char out_val[160]; menu_type *m; region r; int selected; /* Get an item */ const char *q = "Ignore which item? "; const char *s = "You have nothing to ignore."; if (!get_item(&item, q, s, CMD_DESTROY, USE_INVEN | USE_EQUIP | USE_FLOOR)) return; o_ptr = object_from_item_idx(item); m = menu_dynamic_new(); m->selections = lower_case; /* Basic ignore option */ if (!o_ptr->ignore) { menu_dynamic_add(m, "This item only", IGNORE_THIS_ITEM); } else { menu_dynamic_add(m, "Unignore this item", UNIGNORE_THIS_ITEM); } /* Flavour-aware squelch */ if (squelch_tval(o_ptr->tval) && (!o_ptr->artifact || !object_flavor_is_aware(o_ptr))) { bool squelched = kind_is_squelched_aware(o_ptr->kind) || kind_is_squelched_unaware(o_ptr->kind); char tmp[70]; object_desc(tmp, sizeof(tmp), o_ptr, ODESC_BASE | ODESC_PLURAL); if (!squelched) { strnfmt(out_val, sizeof out_val, "All %s", tmp); menu_dynamic_add(m, out_val, IGNORE_THIS_FLAVOR); } else { strnfmt(out_val, sizeof out_val, "Unignore all %s", tmp); menu_dynamic_add(m, out_val, UNIGNORE_THIS_FLAVOR); } } /* Quality squelching */ if (object_was_sensed(o_ptr) || object_was_worn(o_ptr) || object_is_known_not_artifact(o_ptr)) { byte value = squelch_level_of(o_ptr); int type = squelch_type_of(o_ptr); if (object_is_jewelry(o_ptr) && squelch_level_of(o_ptr) != SQUELCH_BAD) value = SQUELCH_MAX; if (value != SQUELCH_MAX && type != TYPE_MAX) { strnfmt(out_val, sizeof out_val, "All %s %s", quality_values[value].name, quality_choices[type].name); menu_dynamic_add(m, out_val, IGNORE_THIS_QUALITY); } } /* work out display region */ r.width = menu_dynamic_longest_entry(m) + 3 + 2; /* +3 for tag, 2 for pad */ r.col = 80 - r.width; r.row = 1; r.page_rows = m->count; screen_save(); menu_layout(m, &r); region_erase_bordered(&r); prt("(Enter to select, ESC) Ignore:", 0, 0); selected = menu_dynamic_select(m); screen_load(); if (selected == IGNORE_THIS_ITEM) { cmd_insert(CMD_DESTROY); cmd_set_arg_item(cmd_get_top(), 0, item); } else if (selected == UNIGNORE_THIS_ITEM) { o_ptr->ignore = FALSE; } else if (selected == IGNORE_THIS_FLAVOR) { object_squelch_flavor_of(o_ptr); } else if (selected == UNIGNORE_THIS_FLAVOR) { kind_squelch_clear(o_ptr->kind); } else if (selected == IGNORE_THIS_QUALITY) { byte value = squelch_level_of(o_ptr); int type = squelch_type_of(o_ptr); squelch_level[type] = value; } p_ptr->notice |= PN_SQUELCH; menu_dynamic_free(m); }