int add_autoinscription(s16b kind, const char *inscription) { int index; /* Paranoia */ if (kind == 0) return 0; /* If there's no inscription, remove it */ if (!inscription || (inscription[0] == 0)) return remove_autoinscription(kind); index = get_autoinscription_index(kind); if (index == -1) index = inscriptions_count; if (index >= AUTOINSCRIPTIONS_MAX) { msg("This inscription (%s) cannot be added because the inscription array is full!", inscription); return 0; } inscriptions[index].kind_idx = kind; inscriptions[index].inscription_idx = quark_add(inscription); /* Only increment count if inscription added to end of array */ if (index == inscriptions_count) inscriptions_count++; return 1; }
/* * Special key actions for object inscription. */ static void o_xtra_act(struct keypress ch, int oid) { object_kind *k_ptr = &k_info[oid]; s16b idx = get_autoinscription_index(oid); /* Forget it if we've never seen the thing */ if (!k_ptr->everseen) return; /* Uninscribe */ if (ch.code == '}') { if (idx != -1) remove_autoinscription(oid); return; } /* Inscribe */ else if (ch.code == '{') { char note_text[80] = ""; /* Avoid the prompt getting in the way */ screen_save(); /* Prompt */ prt("Inscribe with: ", 0, 0); /* Default note */ if (idx != -1) strnfmt(note_text, sizeof(note_text), "%s", get_autoinscription(oid)); /* Get an inscription */ if (askfor_aux(note_text, sizeof(note_text), NULL)) { /* Remove old inscription if existent */ if (idx != -1) 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(); } }
/* * Helper function which actually removes the inscription */ void uninscribe(object_type *o_ptr) { /* Remove the inscription */ o_ptr->obj_note = 0; /*The object kind has an autoinscription*/ // Sil-y: removed restriction to known items (through 'object_aware') if (!(k_info[o_ptr->k_idx].flags3 & (TR3_INSTA_ART)) && (get_autoinscription_index(o_ptr->k_idx) != -1)) { char tmp_val[160]; char o_name2[80]; /*make a fake object so we can give a proper message*/ object_type *i_ptr; object_type object_type_body; /* Get local object */ i_ptr = &object_type_body; /* Wipe the object */ object_wipe(i_ptr); /* Create the object */ object_prep(i_ptr, o_ptr->k_idx); /*make it plural*/ i_ptr->number = 2; /*now describe with correct amount*/ object_desc(o_name2, sizeof(o_name2), i_ptr, FALSE, 0); /* Prompt */ strnfmt(tmp_val, sizeof(tmp_val), "Remove automatic inscription for %s? ", o_name2); /* Auto-Inscribe if they want that */ if (get_check(tmp_val)) obliterate_autoinscription(o_ptr->k_idx); } /* Message */ msg_print("Inscription removed."); /* Combine the pack */ p_ptr->notice |= (PN_COMBINE); /* Window stuff */ p_ptr->window |= (PW_INVEN | PW_EQUIP); }
int remove_autoinscription(s16b kind) { int i = get_autoinscription_index(kind); /* It's not here. */ if (i == -1) return 0; while (i < inscriptions_count - 1) { inscriptions[i] = inscriptions[i + 1]; i++; } inscriptions_count--; return 1; }
/* * Display special prompt for object inscription. */ static const char *o_xtra_prompt(int oid) { object_kind *k_ptr = &k_info[oid]; s16b idx = get_autoinscription_index(oid); const char *no_insc = ", 's' to toggle squelch, 'r'ecall, '{'"; const char *with_insc = ", 's' to toggle squelch, 'r'ecall, '{', '}'"; /* Forget it if we've never seen the thing */ if (k_ptr->flavor && !k_ptr->aware) return ""; /* If it's already inscribed */ if (idx != -1) return with_insc; return no_insc; }