summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2016-09-17 09:58:14 +0200
committerBardur Arantsson <bardur@scientician.net>2016-09-17 09:58:14 +0200
commit013e27d39ee8ee513208d2855c7e3f6252f0c0bf (patch)
tree78ff86f87247b6bbcc43b14e1c00d10cfaca683f
parentb15461dbcedf27f28a843f700ce0473d57364230 (diff)
Refactor object_type 'inscription' field to std::string
We don't really need quarks for this since we're not nearly as memory-constrained these days.
-rw-r--r--src/cmd1.cc20
-rw-r--r--src/cmd3.cc17
-rw-r--r--src/cmd5.cc39
-rw-r--r--src/cmd5.hpp4
-rw-r--r--src/cmd7.cc32
-rw-r--r--src/dungeon.cc21
-rw-r--r--src/loadsave.cc20
-rw-r--r--src/melee1.cc8
-rw-r--r--src/melee2.cc14
-rw-r--r--src/object1.cc71
-rw-r--r--src/object2.cc10
-rw-r--r--src/object_type.hpp5
-rw-r--r--src/q_fireprof.cc8
-rw-r--r--src/q_god.cc2
-rw-r--r--src/q_poison.cc3
-rw-r--r--src/spells1.cc6
-rw-r--r--src/squelch/condition.cc6
-rw-r--r--src/squelch/rule.cc6
-rw-r--r--src/store.cc10
-rw-r--r--src/util.cc9
20 files changed, 134 insertions, 177 deletions
diff --git a/src/cmd1.cc b/src/cmd1.cc
index 642c9df8..36b164b5 100644
--- a/src/cmd1.cc
+++ b/src/cmd1.cc
@@ -622,16 +622,12 @@ static void carried_monster_attack(s16b m_idx, bool_ *fear, bool_ *mdeath,
{
monster_type *t_ptr = &m_list[m_idx];
- monster_race *r_ptr;
-
int ap_cnt;
int ac, rlev, pt;
char t_name[80];
- cptr sym_name = symbiote_name(TRUE);
-
char temp[80];
bool_ blinked = FALSE, touched = FALSE;
@@ -640,14 +636,12 @@ static void carried_monster_attack(s16b m_idx, bool_ *fear, bool_ *mdeath,
byte x_saver = t_ptr->fx;
- object_type *o_ptr;
-
-
/* Get the carried monster */
- o_ptr = &p_ptr->inventory[INVEN_CARRY];
+ auto o_ptr = &p_ptr->inventory[INVEN_CARRY];
if (!o_ptr->k_idx) return;
- r_ptr = &r_info[o_ptr->pval];
+ /* Get monster race of the symbiote */
+ monster_race *r_ptr = &r_info[o_ptr->pval];
/* Not allowed to attack */
if (r_ptr->flags & RF_NEVER_BLOW) return;
@@ -877,7 +871,9 @@ static void carried_monster_attack(s16b m_idx, bool_ *fear, bool_ *mdeath,
{
strnfmt(temp, sizeof(temp), act, t_name);
if (t_ptr->ml)
- msg_format("%s %s", sym_name, temp);
+ {
+ msg_format("%s %s", symbiote_name(true).c_str(), temp);
+ }
}
@@ -1092,7 +1088,7 @@ static void carried_monster_attack(s16b m_idx, bool_ *fear, bool_ *mdeath,
disturb(1);
/* Message */
- msg_format("%s misses %s.", sym_name, t_name);
+ msg_format("%s misses %s.", symbiote_name(true).c_str(), t_name);
break;
}
}
@@ -1102,7 +1098,7 @@ static void carried_monster_attack(s16b m_idx, bool_ *fear, bool_ *mdeath,
/* Blink away */
if (blinked)
{
- msg_format("You and %s flee laughing!", symbiote_name(FALSE));
+ msg_format("You and %s flee laughing!", symbiote_name(false).c_str());
teleport_player(MAX_SIGHT * 2 + 5);
}
diff --git a/src/cmd3.cc b/src/cmd3.cc
index b6f8de28..c333a599 100644
--- a/src/cmd3.cc
+++ b/src/cmd3.cc
@@ -732,7 +732,7 @@ void do_cmd_uninscribe(void)
object_type *o_ptr = get_object(item);
/* Nothing to remove */
- if (!o_ptr->note)
+ if (o_ptr->inscription.empty())
{
msg_print("That item had no inscription to remove.");
return;
@@ -742,7 +742,7 @@ void do_cmd_uninscribe(void)
msg_print("Inscription removed.");
/* Remove the incription */
- o_ptr->note = 0;
+ o_ptr->inscription.clear();
/* Combine the pack */
p_ptr->notice |= (PN_COMBINE);
@@ -778,22 +778,15 @@ void do_cmd_inscribe(void)
msg_format("Inscribing %s.", o_name);
msg_print(NULL);
- /* Start with nothing */
+ /* Start with old inscription */
char out_val[80];
- strcpy(out_val, "");
-
- /* Use old inscription */
- if (o_ptr->note)
- {
- /* Start with the old inscription */
- strcpy(out_val, quark_str(o_ptr->note));
- }
+ strcpy(out_val, o_ptr->inscription.c_str());
/* Get a new inscription (possibly empty) */
if (get_string("Inscription: ", out_val, sizeof(out_val)))
{
/* Save the inscription */
- o_ptr->note = quark_add(out_val);
+ o_ptr->inscription = out_val;
/* Combine the pack */
p_ptr->notice |= (PN_COMBINE);
diff --git a/src/cmd5.cc b/src/cmd5.cc
index f4885609..6e54c76e 100644
--- a/src/cmd5.cc
+++ b/src/cmd5.cc
@@ -535,43 +535,48 @@ void fetch(int dir, int wgt, bool_ require_los)
/*
* Return the symbiote's name or description.
*/
-cptr symbiote_name(bool_ capitalize)
+std::string symbiote_name(bool capitalize)
{
object_type *o_ptr = &p_ptr->inventory[INVEN_CARRY];
- static char buf[80];
- /* Make sure there actually is a symbiote there... */
+ std::string buf;
+ buf.reserve(32);
+
+ // Fallback; shouldn't ever be necessary
if (!o_ptr->k_idx)
{
- strcpy(buf, "A non-existent symbiote");
+ buf += "A non-existent symbiote";
}
else
{
monster_race *r_ptr = &r_info[o_ptr->pval];
- cptr s = NULL;
+ std::size_t i = 0;
if (r_ptr->flags & RF_UNIQUE)
{
- /* Unique monster; no preceding "your", and ignore our name. */
- strncpy(buf, r_ptr->name, sizeof(buf));
+ // Unique monster; no preceding "your" and ignore name
+ buf += r_ptr->name;
}
- else if (o_ptr->note &&
- (s = strstr(quark_str(o_ptr->note), "#named ")) != NULL)
+ else if ((i = o_ptr->inscription.find("#named ")) != std::string::npos)
{
- /* We've named it. */
- strncpy(buf, s + 7, sizeof(buf));
+ // We've named it; extract the name */
+ buf += o_ptr->inscription.substr(i);
}
else
{
- /* No special cases, just return "Your <monster type>". */
- strcpy(buf, "your ");
- strncpy(buf + 5, r_ptr->name, sizeof(buf) - 5);
+ // No special cases; just return "Your <monster type>".
+ buf += "your ";
+ buf += r_ptr->name;
}
}
- /* Just in case... */
- buf[sizeof(buf) - 1] = '\0';
- if (capitalize) buf[0] = toupper(buf[0]);
+ // Capitalize?
+ if (capitalize)
+ {
+ buf[0] = toupper(buf[0]);
+ }
+
+ // Done
return buf;
}
diff --git a/src/cmd5.hpp b/src/cmd5.hpp
index 7a0cd27a..89bbab8c 100644
--- a/src/cmd5.hpp
+++ b/src/cmd5.hpp
@@ -4,6 +4,8 @@
#include "object_type_fwd.hpp"
#include "monster_race_fwd.hpp"
#include "monster_power_fwd.hpp"
+
+#include <string>
#include <vector>
extern bool_ is_magestaff(void);
@@ -11,7 +13,7 @@ extern void do_cmd_browse_aux(object_type *o_ptr);
extern void do_cmd_browse(void);
extern void fetch(int dir, int wgt, bool_ require_los);
extern void do_poly_self(void);
-extern cptr symbiote_name(bool_ capitalize);
+extern std::string symbiote_name(bool capitalize);
extern int use_symbiotic_power(int r_idx, bool great);
extern void use_monster_power(int r_idx, bool great);
extern bool_ is_ok_spell(s32b spell_idx, s32b pval);
diff --git a/src/cmd7.cc b/src/cmd7.cc
index 2d9ae191..49de2611 100644
--- a/src/cmd7.cc
+++ b/src/cmd7.cc
@@ -3237,13 +3237,6 @@ void do_cmd_rune_add_mem()
*/
void do_cmd_rune_carve()
{
- rune_spell s_ptr;
-
- int item, i;
-
- char out_val[80];
-
-
/* Not when confused */
if (p_ptr->confused)
{
@@ -3263,9 +3256,14 @@ void do_cmd_rune_carve()
return;
}
- if (!get_runespell(&s_ptr)) return;
+ rune_spell s_ptr;
+ if (!get_runespell(&s_ptr))
+ {
+ return;
+ }
/* Get an item */
+ int item;
if (!get_item(&item,
"Use which runestone? ",
"You have no runestone to use.",
@@ -3282,21 +3280,15 @@ void do_cmd_rune_carve()
o_ptr->pval2 = s_ptr.rune2;
o_ptr->pval3 = s_ptr.mana;
- /* Start with nothing */
- strcpy(out_val, "");
-
- /* Use old inscription */
- if (o_ptr->note)
- {
- /* Start with the old inscription */
- strcpy(out_val, quark_str(o_ptr->note));
- }
+ /* Start with old inscription */
+ char out_val[80];
+ strcpy(out_val, o_ptr->inscription.c_str());
/* Get a new inscription (possibly empty) */
if (get_string("Name this runestone: ", out_val, 80))
{
/* Save the inscription */
- o_ptr->note = quark_add(out_val);
+ o_ptr->inscription = out_val;
/* Combine the pack */
p_ptr->notice |= (PN_COMBINE);
@@ -3306,7 +3298,7 @@ void do_cmd_rune_carve()
}
/* Delete the runes */
- for (i = 0; i < INVEN_WIELD; i++)
+ for (int i = 0; i < INVEN_WIELD; i++)
{
o_ptr = &p_ptr->inventory[i];
@@ -4259,7 +4251,7 @@ void do_cmd_symbiotic(void)
o_ptr->pval2 += hp;
if (o_ptr->pval2 > o_ptr->pval3) o_ptr->pval2 = o_ptr->pval3;
- msg_format("%s is healed.", symbiote_name(TRUE));
+ msg_format("%s is healed.", symbiote_name(true).c_str());
/* Display the monster hitpoints */
p_ptr->redraw |= (PR_FRAME);
diff --git a/src/dungeon.cc b/src/dungeon.cc
index bdb31fa1..2e42e871 100644
--- a/src/dungeon.cc
+++ b/src/dungeon.cc
@@ -610,16 +610,14 @@ static bool_ pattern_effect(void)
*/
static void recharged_notice(object_type *o_ptr)
{
- char o_name[80];
-
- cptr s;
-
-
/* No inscription */
- if (!o_ptr->note) return;
+ if (o_ptr->inscription.empty())
+ {
+ return;
+ }
/* Find a '!' */
- s = strchr(quark_str(o_ptr->note), '!');
+ auto s = strchr(o_ptr->inscription.c_str(), '!');
/* Process notification request. */
while (s)
@@ -628,6 +626,7 @@ static void recharged_notice(object_type *o_ptr)
if (s[1] == '!')
{
/* Describe (briefly) */
+ char o_name[80];
object_desc(o_name, o_ptr, FALSE, 0);
/* Notify the player */
@@ -1295,7 +1294,7 @@ static void process_world(void)
if ((randint(1000) < r_ptr->level - ((p_ptr->lev * 2) + get_skill(SKILL_SYMBIOTIC))))
{
msg_format("%s breaks free from hypnosis!",
- symbiote_name(TRUE));
+ symbiote_name(true).c_str());
carried_make_attack_normal(o_ptr->pval);
}
}
@@ -2773,11 +2772,9 @@ static void process_world(void)
}
else
{
- if (p_ptr->wild_mode ||
- (o_ptr->note && strchr(quark_str(o_ptr->note), '.')))
+ if (p_ptr->wild_mode || strchr(o_ptr->inscription.c_str(), '.'))
{
- /* Do nothing */
- /* msg_print("Teleport aborted.") */;
+ /* Suppress teleportation */
}
else if (get_check("Teleport? "))
{
diff --git a/src/loadsave.cc b/src/loadsave.cc
index b8544f01..6da23406 100644
--- a/src/loadsave.cc
+++ b/src/loadsave.cc
@@ -1138,16 +1138,13 @@ static void do_item(object_type *o_ptr, ls_flag_t flag)
do_s16b(&o_ptr->found_aux3, flag);
do_s16b(&o_ptr->found_aux4, flag);
+ // Inscription
+ do_std_string(o_ptr->inscription, flag);
+
+ /* Artifact name */
if (flag == ls_flag_t::LOAD)
{
char buf[128];
- /* Inscription */
- load_string(buf, 128);
- if (buf[0])
- {
- o_ptr->note = quark_add(buf);
- }
- /* Artifact name */
load_string(buf, 128);
if (buf[0])
{
@@ -1156,15 +1153,6 @@ static void do_item(object_type *o_ptr, ls_flag_t flag)
}
if (flag == ls_flag_t::SAVE)
{
- /* Save the inscription (if any) */
- if (o_ptr->note)
- {
- save_string(quark_str(o_ptr->note));
- }
- else
- {
- save_string("");
- }
if (o_ptr->art_name)
{
save_string(quark_str(o_ptr->art_name));
diff --git a/src/melee1.cc b/src/melee1.cc
index ecc44356..5a61a424 100644
--- a/src/melee1.cc
+++ b/src/melee1.cc
@@ -231,7 +231,7 @@ bool_ carried_make_attack_normal(int r_idx)
int do_cut, do_stun;
char ddesc[80] = "your symbiote";
- cptr sym_name = symbiote_name(TRUE);
+ auto sym_name = symbiote_name(true);
bool_ alive = TRUE;
@@ -286,7 +286,7 @@ bool_ carried_make_attack_normal(int r_idx)
((rand_int(100) + p_ptr->lev) > 50))
{
/* Message */
- msg_format("%s is repelled.", sym_name);
+ msg_format("%s is repelled.", sym_name.c_str());
/* Hack -- Next attack */
continue;
@@ -454,7 +454,7 @@ bool_ carried_make_attack_normal(int r_idx)
}
/* Message */
- if (act) msg_format("%s %s", sym_name, act);
+ if (act) msg_format("%s %s", sym_name.c_str(), act);
/* Roll out the damage */
@@ -1165,7 +1165,7 @@ bool_ carried_make_attack_normal(int r_idx)
disturb(1);
/* Message */
- msg_format("%s misses you.", sym_name);
+ msg_format("%s misses you.", sym_name.c_str());
break;
}
diff --git a/src/melee2.cc b/src/melee2.cc
index 130b74ee..562bca57 100644
--- a/src/melee2.cc
+++ b/src/melee2.cc
@@ -2381,12 +2381,9 @@ void curse_equipment(int chance, int heavy_chance)
if (changed)
{
msg_print("There is a malignant black aura surrounding you...");
- if (o_ptr->note)
+ if (o_ptr->inscription == "uncursed")
{
- if (streq(quark_str(o_ptr->note), "uncursed"))
- {
- o_ptr->note = 0;
- }
+ o_ptr->inscription.clear();
}
}
}
@@ -2438,12 +2435,9 @@ void curse_equipment_dg(int chance, int heavy_chance)
if (changed)
{
msg_print("There is a malignant black aura surrounding you...");
- if (o_ptr->note)
+ if (o_ptr->inscription == "uncursed")
{
- if (streq(quark_str(o_ptr->note), "uncursed"))
- {
- o_ptr->note = 0;
- }
+ o_ptr->inscription.clear();
}
}
}
diff --git a/src/object1.cc b/src/object1.cc
index c93d1ff1..a7c1edf1 100644
--- a/src/object1.cc
+++ b/src/object1.cc
@@ -1526,16 +1526,10 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode)
/* Dagger inscribed {@w0%Smelly} will be named
* Smelly Dagger {@w0} */
- if (o_ptr->note)
+ if (auto str = strchr(o_ptr->inscription.c_str(), '%'))
{
- cptr str = strchr(quark_str(o_ptr->note), '%');
-
- /* Add the false name */
- if (str)
- {
- t += &str[1];
- t += ' ';
- }
+ t += &str[1];
+ t += ' ';
}
}
@@ -1680,16 +1674,10 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode)
/* -TM- Hack -- Add false-artifact names */
/* Dagger inscribed {@w0#of Smell} will be named
* Dagger of Smell {@w0} */
- if (o_ptr->note)
+ if (auto str = strchr(o_ptr->inscription.c_str(), '#'))
{
- cptr str = strchr(quark_str(o_ptr->note), '#');
-
- /* Add the false name */
- if (str)
- {
- t += ' ';
- t += &str[1];
- }
+ t += ' ';
+ t += &str[1];
}
/* Is it a new random artifact ? */
@@ -2061,17 +2049,13 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode)
inscrip.push_back("cursed");
}
- /* Use the standard inscription if available */
- if (o_ptr->note)
+ /* Use the standard inscription if available;
+ Chop at '#' or '%' if present. The suffix of the
+ '%' or '#' is handled elsewhere in this function.
+ */
+ if (auto const pos = o_ptr->inscription.find_first_of("%#") != std::string::npos)
{
- // Chop at '#' or '%' if present. The suffix of the
- // '%' or '#' is handled elsewhere in this function.
- std::string note = quark_str(o_ptr->note);
- auto const pos = note.find_first_of("%#");
- if (pos > 0)
- {
- inscrip.push_back(note.substr(0, pos));
- }
+ inscrip.push_back(o_ptr->inscription.substr(0, pos));
}
/* Mega-Hack -- note empty wands/staffs */
@@ -4570,18 +4554,17 @@ bool_ verify(cptr prompt, int item)
*/
static bool_ get_item_allow(int item)
{
- cptr s;
-
- object_type *o_ptr;
-
/* Get object */
- o_ptr = get_object(item);
+ auto o_ptr = get_object(item);
/* No inscription */
- if (!o_ptr->note) return (TRUE);
+ if (o_ptr->inscription.empty())
+ {
+ return TRUE;
+ }
/* Find a '!' */
- s = strchr(quark_str(o_ptr->note), '!');
+ auto s = strchr(o_ptr->inscription.c_str(), '!');
/* Process preventions */
while (s)
@@ -4631,23 +4614,25 @@ static bool get_item_okay(int i, object_filter_t const &filter)
*/
static int get_tag(int *cp, char tag)
{
- int i;
- cptr s;
-
-
/* Check every object */
- for (i = 0; i < INVEN_TOTAL; ++i)
+ for (int i = 0; i < INVEN_TOTAL; ++i)
{
object_type *o_ptr = &p_ptr->inventory[i];
/* Skip non-objects */
- if (!o_ptr->k_idx) continue;
+ if (!o_ptr->k_idx)
+ {
+ continue;
+ }
/* Skip empty inscriptions */
- if (!o_ptr->note) continue;
+ if (o_ptr->inscription.empty())
+ {
+ continue;
+ }
/* Find a '@' */
- s = strchr(quark_str(o_ptr->note), '@');
+ auto s = strchr(o_ptr->inscription.c_str(), '@');
/* Process all tags */
while (s)
diff --git a/src/object2.cc b/src/object2.cc
index 89378fb2..b4226f76 100644
--- a/src/object2.cc
+++ b/src/object2.cc
@@ -1734,7 +1734,10 @@ bool_ object_similar(object_type const *o_ptr, object_type const *j_ptr)
if ((o_ptr->ident & (IDENT_CURSED)) != (j_ptr->ident & (IDENT_CURSED))) return (0);
/* Hack -- require semi-matching "inscriptions" */
- if (o_ptr->note && j_ptr->note && (o_ptr->note != j_ptr->note)) return (0);
+ if ((!o_ptr->inscription.empty()) && (!j_ptr->inscription.empty()) && (o_ptr->inscription != j_ptr->inscription))
+ {
+ return (0);
+ }
/* Maximal "stacking" limit */
if (total >= MAX_STACK_SIZE) return (0);
@@ -1770,7 +1773,10 @@ void object_absorb(object_type *o_ptr, object_type *j_ptr)
if (j_ptr->ident & (IDENT_MENTAL)) o_ptr->ident |= (IDENT_MENTAL);
/* Hack -- blend "inscriptions" */
- if (j_ptr->note) o_ptr->note = j_ptr->note;
+ if (!j_ptr->inscription.empty())
+ {
+ o_ptr->inscription = j_ptr->inscription;
+ }
/* Hack -- could average discounts XXX XXX XXX */
/* Hack -- save largest discount XXX XXX XXX */
diff --git a/src/object_type.hpp b/src/object_type.hpp
index 48d18cf1..aec713b0 100644
--- a/src/object_type.hpp
+++ b/src/object_type.hpp
@@ -3,6 +3,8 @@
#include "h-basic.h"
#include "object_flag_set.hpp"
+#include <string>
+
/**
* Object information for a specific object.
*
@@ -75,7 +77,8 @@ struct object_type
byte marked = 0; /* Object is marked */
- u16b note = 0; /* Inscription index */
+ std::string inscription; /* Inscription index */
+
u16b art_name = 0; /* Artifact name (random artifacts) */
object_flag_set art_flags; /* Flags */
diff --git a/src/q_fireprof.cc b/src/q_fireprof.cc
index eb762fc4..033aec05 100644
--- a/src/q_fireprof.cc
+++ b/src/q_fireprof.cc
@@ -498,18 +498,16 @@ static bool_ fireproof_gen_hook(void *, void *, void *)
/* create essence */
{
- int x, y;
object_type forge;
-
object_prep(&forge, lookup_kind(settings->tval, fireproof_get_sval()));
/* mark item */
forge.pval2 = fireproof_get_sval();
- forge.note = quark_add("quest");
+ forge.inscription = "quest";
/* roll for co-ordinates in top half of map */
- y = randint(3) + 2;
- x = randint(45) + 2;
+ int const y = randint(3) + 2;
+ int const x = randint(45) + 2;
/* drop it */
drop_near(&forge, -1, y, x);
diff --git a/src/q_god.cc b/src/q_god.cc
index 67371f46..c2dd3760 100644
--- a/src/q_god.cc
+++ b/src/q_god.cc
@@ -389,7 +389,7 @@ static void quest_god_generate_relic()
object_prep(&relic, lookup_kind(TV_JUNK, get_relic_num()));
/* inscribe it to prevent automatizer 'accidents' */
- relic.note = quark_add("quest");
+ relic.inscription = "quest";
/* If no safe co-ords were found, put it in the players backpack */
if (tries == 0)
diff --git a/src/q_poison.cc b/src/q_poison.cc
index 45e7ede8..70eebcb9 100644
--- a/src/q_poison.cc
+++ b/src/q_poison.cc
@@ -178,7 +178,8 @@ static bool_ quest_poison_quest_hook(void *, void *in_, void *)
object_aware(q_ptr);
object_known(q_ptr);
q_ptr->ident |= IDENT_STOREB;
- q_ptr->note = quark_add("quest");
+ q_ptr->inscription = "quest";
+
(void)inven_carry(q_ptr, FALSE);
del_hook_new(HOOK_INIT_QUEST, quest_poison_quest_hook);
diff --git a/src/spells1.cc b/src/spells1.cc
index 3dc6c97f..3f09e592 100644
--- a/src/spells1.cc
+++ b/src/spells1.cc
@@ -1281,13 +1281,13 @@ void take_hit(int damage, cptr hit_from)
/* Hurt the wielded monster if any */
if ((o_ptr->k_idx) && (magik(5 + get_skill(SKILL_SYMBIOTIC))) && (!carried_monster_hit))
{
- cptr sym_name = symbiote_name(TRUE);
+ auto sym_name = symbiote_name(true);
if (o_ptr->pval2 - damage <= 0)
{
cmsg_format(TERM_L_RED,
"%s dies from protecting you, you feel very sad...",
- sym_name);
+ sym_name.c_str());
inc_stack_size_ex(INVEN_CARRY, -1, OPTIMIZE, NO_DESCRIBE);
damage -= o_ptr->pval2;
o_ptr->pval2 = 0;
@@ -1295,7 +1295,7 @@ void take_hit(int damage, cptr hit_from)
}
else
{
- msg_format("%s takes the damage instead of you.", sym_name);
+ msg_format("%s takes the damage instead of you.", sym_name.c_str());
o_ptr->pval2 -= damage;
monster_take = TRUE;
}
diff --git a/src/squelch/condition.cc b/src/squelch/condition.cc
index 1b58b752..bb598158 100644
--- a/src/squelch/condition.cc
+++ b/src/squelch/condition.cc
@@ -627,12 +627,8 @@ void ClassCondition::to_json(json_t *j) const
bool InscriptionCondition::is_match(object_type *o_ptr) const
{
- if (o_ptr->note == 0)
- {
- return false;
- }
return boost::algorithm::icontains(
- quark_str(o_ptr->note),
+ o_ptr->inscription,
m_inscription);
}
diff --git a/src/squelch/rule.cc b/src/squelch/rule.cc
index 2bdef61b..0f952ebb 100644
--- a/src/squelch/rule.cc
+++ b/src/squelch/rule.cc
@@ -238,7 +238,7 @@ bool DestroyRule::do_apply_rule(object_type *o_ptr, int item_idx) const
}
// Never destroy inscribed items
- if (o_ptr->note)
+ if (!o_ptr->inscription.empty())
{
return false;
}
@@ -317,14 +317,14 @@ void InscribeRule::do_write_tree(TreePrinter *p) const
bool InscribeRule::do_apply_rule(object_type *o_ptr, int) const
{
// Already inscribed?
- if (o_ptr->note != 0)
+ if (!o_ptr->inscription.empty())
{
return false;
}
// Inscribe
msg_format("<Auto-Inscribe {%s}>", m_inscription.c_str());
- o_ptr->note = quark_add(m_inscription.c_str());
+ o_ptr->inscription = m_inscription;
return true;
}
diff --git a/src/store.cc b/src/store.cc
index dd7aa484..71d6b2d0 100644
--- a/src/store.cc
+++ b/src/store.cc
@@ -957,7 +957,7 @@ static int store_carry(object_type *o_ptr)
o_ptr->ident |= IDENT_MENTAL;
/* Erase the inscription */
- o_ptr->note = 0;
+ o_ptr->inscription.clear();
/* Check each existing item (try to combine) */
for (slot = 0; slot < st_ptr->stock.size(); slot++)
@@ -1979,7 +1979,7 @@ void store_stole(void)
msg_format("You steal %s.", o_name);
/* Erase the inscription */
- j_ptr->note = 0;
+ j_ptr->inscription.clear();
/* Give it to the player */
int const item_new = inven_carry(j_ptr, FALSE);
@@ -2236,7 +2236,7 @@ void store_purchase(void)
msg_format("You bought %s for " FMTs32b " gold.", o_name, price);
/* Erase the inscription */
- j_ptr->note = 0;
+ j_ptr->inscription.clear();
/* Hack -- If a rod or wand, allocate total maximum
* timeouts or charges between those picked up and
@@ -2481,7 +2481,7 @@ void store_sell(void)
/* Remove any inscription for stores */
if ((cur_store_num != 7) && !museum)
{
- q_ptr->note = 0;
+ q_ptr->inscription.clear();
}
/* Is there room in the store (or the home?) */
@@ -3400,7 +3400,7 @@ void store_shuffle(int which)
o_ptr->discount = 50;
/* Mega-Hack -- Note that the item is "on sale" */
- o_ptr->note = quark_add("on sale");
+ o_ptr->inscription = "on sale";
}
}
diff --git a/src/util.cc b/src/util.cc
index b393c610..70cc3f4f 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -2968,18 +2968,19 @@ void request_command(int shopping)
/* Hack -- Scan equipment */
for (i = INVEN_WIELD; i < INVEN_TOTAL; i++)
{
- cptr s;
-
object_type *o_ptr = &p_ptr->inventory[i];
/* Skip non-objects */
if (!o_ptr->k_idx) continue;
/* No inscription */
- if (!o_ptr->note) continue;
+ if (o_ptr->inscription.empty())
+ {
+ continue;
+ }
/* Obtain the inscription */
- s = quark_str(o_ptr->note);
+ auto s = o_ptr->inscription.c_str();
/* Find a '^' */
s = strchr(s, '^');