summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2016-10-05 18:45:08 +0200
committerBardur Arantsson <bardur@scientician.net>2016-10-05 18:45:08 +0200
commite02a2dfd184a996a02ecc6004a0a03bcfbd19131 (patch)
treecb37d7099bfabb409ab97fffeb4ca71fdb9e110e /src
parentaebc48dffa75698be4d2c1bb2b1a0927b10be1cc (diff)
Change store_info_type::name to std::string
Diffstat (limited to 'src')
-rw-r--r--src/files.cc2
-rw-r--r--src/init1.cc4
-rw-r--r--src/object1.cc4
-rw-r--r--src/store.cc41
-rw-r--r--src/store_info_type.hpp2
5 files changed, 25 insertions, 28 deletions
diff --git a/src/files.cc b/src/files.cc
index eef16227..6e795923 100644
--- a/src/files.cc
+++ b/src/files.cc
@@ -2525,7 +2525,7 @@ static void file_character_print_store(FILE *fff, wilderness_type_info *place, s
if (st_ptr->stock.size())
{
/* Header with name of the town */
- fprintf(fff, " [%s Inventory - %s]\n\n", st_info[store].name, place->name);
+ fprintf(fff, " [%s Inventory - %s]\n\n", st_info[store].name.c_str(), place->name);
/* Dump all available items */
for (std::size_t i = 0; i < st_ptr->stock.size(); i++)
diff --git a/src/init1.cc b/src/init1.cc
index fb44c99b..658cf8e2 100644
--- a/src/init1.cc
+++ b/src/init1.cc
@@ -5669,10 +5669,10 @@ errr init_st_info_txt(FILE *fp)
/* Point at the "info" */
st_ptr = &expand_to_fit_index(st_info, i);
- assert(!st_ptr->name);
+ assert(st_ptr->name.empty());
/* Copy name */
- st_ptr->name = my_strdup(s);
+ st_ptr->name = s;
/* Next... */
continue;
diff --git a/src/object1.cc b/src/object1.cc
index b035326f..656446c3 100644
--- a/src/object1.cc
+++ b/src/object1.cc
@@ -3493,12 +3493,12 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait
else if (o_ptr->found == OBJ_FOUND_STORE)
{
text_out(format("\nYou bought it from the %s.",
- st_info[o_ptr->found_aux1].name));
+ st_info[o_ptr->found_aux1].name.c_str()));
}
else if (o_ptr->found == OBJ_FOUND_STOLEN)
{
text_out(format("\nYou stole it from the %s.",
- st_info[o_ptr->found_aux1].name));
+ st_info[o_ptr->found_aux1].name.c_str()));
}
else if (o_ptr->found == OBJ_FOUND_SELFMADE)
{
diff --git a/src/store.cc b/src/store.cc
index 161601e4..47d5d943 100644
--- a/src/store.cc
+++ b/src/store.cc
@@ -43,6 +43,7 @@
#include "z-rand.hpp"
#include <cassert>
+#include <fmt/format.h>
#define STORE_GENERAL_STORE "General Store"
#define STORE_ARMOURY "Armoury"
@@ -632,7 +633,7 @@ static bool store_will_buy(object_type const *o_ptr)
{
auto const &st_info = game->edit_data.st_info;
- cptr store_name = st_info[st_ptr->st_idx].name;
+ auto const &store_name = st_info[st_ptr->st_idx].name;
/* Hack -- The Home is simple */
if (cur_store_num == 7)
@@ -652,7 +653,7 @@ static bool store_will_buy(object_type const *o_ptr)
}
/* What do stores buy? */
- if (streq(store_name, STORE_GENERAL_STORE))
+ if ((store_name == STORE_GENERAL_STORE))
{
switch (o_ptr->tval)
{
@@ -670,7 +671,7 @@ static bool store_will_buy(object_type const *o_ptr)
return true;
}
}
- else if (streq(store_name, STORE_ARMOURY))
+ else if ((store_name == STORE_ARMOURY))
{
switch (o_ptr->tval)
{
@@ -686,7 +687,7 @@ static bool store_will_buy(object_type const *o_ptr)
return true;
}
}
- else if (streq(store_name, STORE_WEAPONSMITH))
+ else if ((store_name == STORE_WEAPONSMITH))
{
switch (o_ptr->tval)
{
@@ -704,7 +705,7 @@ static bool store_will_buy(object_type const *o_ptr)
return true;
}
}
- else if (streq(store_name, STORE_TEMPLE))
+ else if ((store_name == STORE_TEMPLE))
{
switch (o_ptr->tval)
{
@@ -743,7 +744,7 @@ static bool store_will_buy(object_type const *o_ptr)
return true;
}
}
- else if (streq(store_name, STORE_ALCHEMY))
+ else if ((store_name == STORE_ALCHEMY))
{
switch (o_ptr->tval)
{
@@ -754,7 +755,7 @@ static bool store_will_buy(object_type const *o_ptr)
return true;
}
}
- else if (streq(store_name, STORE_MAGIC))
+ else if ((store_name == STORE_MAGIC))
{
switch (o_ptr->tval)
{
@@ -785,11 +786,11 @@ static bool store_will_buy(object_type const *o_ptr)
return true;
}
}
- else if (streq(store_name, STORE_BLACK_MARKET))
+ else if ((store_name == STORE_BLACK_MARKET))
{
return true;
}
- else if (streq(store_name, STORE_BOOKS))
+ else if ((store_name == STORE_BOOKS))
{
switch (o_ptr->tval)
{
@@ -801,11 +802,11 @@ static bool store_will_buy(object_type const *o_ptr)
return true;
}
}
- else if (streq(store_name, STORE_PETS))
+ else if ((store_name == STORE_PETS))
{
return (o_ptr->tval == TV_EGG);
}
- else if (streq(store_name, STORE_HUNTING_SUPPLIES))
+ else if ((store_name == STORE_HUNTING_SUPPLIES))
{
switch (o_ptr->tval)
{
@@ -819,7 +820,7 @@ static bool store_will_buy(object_type const *o_ptr)
return true;
}
}
- else if (streq(store_name, STORE_RUNIC_MAGIC))
+ else if ((store_name == STORE_RUNIC_MAGIC))
{
switch (o_ptr->tval)
{
@@ -828,7 +829,7 @@ static bool store_will_buy(object_type const *o_ptr)
return true;
}
}
- else if (streq(store_name, STORE_CONSTRUCTION_SUPPLIES))
+ else if ((store_name == STORE_CONSTRUCTION_SUPPLIES))
{
switch (o_ptr->tval)
{
@@ -837,7 +838,7 @@ static bool store_will_buy(object_type const *o_ptr)
return true;
}
}
- else if (streq(store_name, STORE_MUSIC))
+ else if ((store_name == STORE_MUSIC))
{
return (o_ptr->tval == TV_INSTRUMENT);
}
@@ -1219,7 +1220,7 @@ static void store_create(void)
obj_all_done = FALSE;
/* Magic Shop */
- if (streq(st_info[st_ptr->st_idx].name, STORE_MAGIC) &&
+ if ((st_info[st_ptr->st_idx].name == STORE_MAGIC) &&
magik(20))
{
s16b spell;
@@ -1235,7 +1236,7 @@ static void store_create(void)
}
/* Temple */
- else if (streq(st_info[st_ptr->st_idx].name, STORE_TEMPLE) &&
+ else if ((st_info[st_ptr->st_idx].name == STORE_TEMPLE) &&
magik(20))
{
s16b spell;
@@ -1581,8 +1582,7 @@ void display_store(void)
else if (st_info[st_ptr->st_idx].flags & STF_MUSEUM)
{
/* Show the name of the store */
- strnfmt(buf, 80, "%s", st_info[cur_store_num].name);
- prt(buf, 3, 30);
+ prt(st_info[cur_store_num].name, 3, 30);
/* Label the item descriptions */
put_str("Item Description", 5, 3);
@@ -1599,10 +1599,7 @@ void display_store(void)
put_str(buf, 3, 10);
/* Show the max price in the store (above prices) */
- strnfmt(buf, 80, "%s (" FMTs16b ")",
- st_info[cur_store_num].name,
- ot_ptr->max_cost);
- prt(buf, 3, 50);
+ prt(fmt::format("{:s} ({:d})", st_info[cur_store_num].name, ot_ptr->max_cost), 3, 50);
/* Label the item descriptions */
put_str("Item Description", 5, 3);
diff --git a/src/store_info_type.hpp b/src/store_info_type.hpp
index abb87095..78aa071e 100644
--- a/src/store_info_type.hpp
+++ b/src/store_info_type.hpp
@@ -11,7 +11,7 @@
*/
struct store_info_type
{
- const char *name = nullptr; /* Name */
+ std::string name; /* Name */
std::vector<store_item> items; /* Table -- Legal item kinds */