summaryrefslogtreecommitdiff
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
commit7ccb0c1a48d571abd6dc3aca725275e2d264aa2d (patch)
treecf8704730d08eb3567e9de519f768b6f8baae4af
parent667acd0e312301ad613b6a71f843c51d2062aee6 (diff)
Change strings in dungeon_info_type to std::string
-rw-r--r--src/cmd1.cc2
-rw-r--r--src/cmd2.cc2
-rw-r--r--src/cmd6.cc2
-rw-r--r--src/dungeon_info_type.hpp8
-rw-r--r--src/files.cc4
-rw-r--r--src/generate.cc4
-rw-r--r--src/init1.cc22
-rw-r--r--src/object1.cc2
-rw-r--r--src/spells1.cc2
-rw-r--r--src/spells2.cc16
-rw-r--r--src/wizard2.cc2
-rw-r--r--src/xtra2.cc8
12 files changed, 34 insertions, 40 deletions
diff --git a/src/cmd1.cc b/src/cmd1.cc
index 7d53fbef..19a52062 100644
--- a/src/cmd1.cc
+++ b/src/cmd1.cc
@@ -3153,7 +3153,7 @@ void move_player_aux(int dir, int do_pickup, int run, bool_ disarm)
/* Mega-hack for dungeon branches */
if ((feat == FEAT_MORE) && c_ptr->special)
{
- msg_format("There is %s", d_info[c_ptr->special].text);
+ msg_format("There is %s", d_info[c_ptr->special].text.c_str());
}
else
{
diff --git a/src/cmd2.cc b/src/cmd2.cc
index c581d89b..dd5f302a 100644
--- a/src/cmd2.cc
+++ b/src/cmd2.cc
@@ -548,7 +548,7 @@ void do_cmd_go_down(void)
dun_level = d_ptr->mindepth;
}
- msg_format("You go into %s", d_info[dungeon_type].text);
+ msg_format("You go into %s", d_info[dungeon_type].text.c_str());
}
else
{
diff --git a/src/cmd6.cc b/src/cmd6.cc
index e52d1e32..195d9648 100644
--- a/src/cmd6.cc
+++ b/src/cmd6.cc
@@ -2977,7 +2977,7 @@ void do_cmd_read_scroll(void)
}
msg_format("Recall reset to %s at level %d.",
- d_info[p_ptr->recall_dungeon].name,
+ d_info[p_ptr->recall_dungeon].name.c_str(),
max_dlv[p_ptr->recall_dungeon]);
ident = TRUE;
diff --git a/src/dungeon_info_type.hpp b/src/dungeon_info_type.hpp
index b15cf9fe..324a32bd 100644
--- a/src/dungeon_info_type.hpp
+++ b/src/dungeon_info_type.hpp
@@ -15,11 +15,11 @@ constexpr int TOWN_DUNGEON = 4;
/* A structure for the != dungeon types */
struct dungeon_info_type
{
- const char *name = nullptr; /* Name */
- char *text = nullptr; /* Description */
- char short_name[3] = { 0 }; /* Short name */
+ std::string name; /* Name */
+ std::string text; /* Description */
+ std::string short_name; /* Short name */
- char generator[30] = { 0 }; /* Name of the level generator */
+ std::string generator; /* Name of the level generator */
s16b floor1 = 0; /* Floor tile 1 */
byte floor_percent1[2] = { 0 }; /* Chance of type 1 */
diff --git a/src/files.cc b/src/files.cc
index d85a7dbf..183ae0af 100644
--- a/src/files.cc
+++ b/src/files.cc
@@ -2335,7 +2335,7 @@ cptr describe_player_location()
if (dungeon_type != DUNGEON_WILDERNESS && dun_level > 0)
{
- sprintf(desc, "on level %d of %s", dun_level, d_info[dungeon_type].name);
+ sprintf(desc, "on level %d of %s", dun_level, d_info[dungeon_type].name.c_str());
}
else if (wf_info[feat].terrain_idx == TERRAIN_TOWN)
{
@@ -2698,7 +2698,7 @@ errr file_character(cptr name, bool_ full)
{
if (max_dlv[y])
fprintf(fff, "\n %s: Level %d (%d')",
- d_info[y].name,
+ d_info[y].name.c_str(),
max_dlv[y], 50 * (max_dlv[y]));
}
fprintf(fff, "\n");
diff --git a/src/generate.cc b/src/generate.cc
index a3b3d0bd..96f4ebaf 100644
--- a/src/generate.cc
+++ b/src/generate.cc
@@ -7633,7 +7633,9 @@ static bool_ cave_gen(void)
char generator_name[100];
if (!get_dungeon_generator(generator_name))
- strnfmt(generator_name, 99, "%s", d_ptr->generator);
+ {
+ strnfmt(generator_name, sizeof(generator_name)-1, "%s", d_ptr->generator.c_str());
+ }
/*
* We generate a double dungeon. First we should halve the desired
diff --git a/src/init1.cc b/src/init1.cc
index 5fd257b0..4233b032 100644
--- a/src/init1.cc
+++ b/src/init1.cc
@@ -5169,13 +5169,10 @@ errr init_d_info_txt(FILE *fp)
/* Point at the "info" */
d_ptr = &expand_to_fit_index(d_info, i);
+ assert(d_ptr->name.empty());
/* Copy name */
- assert(!d_ptr->name);
- d_ptr->name = my_strdup(s);
-
- /* Initialize description */
- d_ptr->text = my_strdup("");
+ d_ptr->name = s;
/* HACK -- Those ones HAVE to have a set default value */
d_ptr->size_x = -1;
@@ -5202,7 +5199,7 @@ errr init_d_info_txt(FILE *fp)
d_ptr->objs = obj_theme::defaults();
/* The default generator */
- strcpy(d_ptr->generator, "dungeon");
+ d_ptr->generator = "dungeon";
/* Next... */
continue;
@@ -5215,15 +5212,12 @@ errr init_d_info_txt(FILE *fp)
if (buf[0] == 'D')
{
/* Acquire short name */
- d_ptr->short_name[0] = buf[2];
- d_ptr->short_name[1] = buf[3];
- d_ptr->short_name[2] = buf[4];
-
- /* Acquire the text */
- char *s = buf + 6;
+ d_ptr->short_name += buf[2];
+ d_ptr->short_name += buf[3];
+ d_ptr->short_name += buf[4];
/* Append to description */
- strappend(&d_ptr->text, s);
+ d_ptr->text += (buf + 6);
/* Next... */
continue;
@@ -5312,7 +5306,7 @@ errr init_d_info_txt(FILE *fp)
/* Process 'G' for "Generator" (one line only) */
if (buf[0] == 'G')
{
- strnfmt(d_ptr->generator, 30, "%s", buf + 2);
+ d_ptr->generator = (buf + 2);
/* Next... */
continue;
diff --git a/src/object1.cc b/src/object1.cc
index fe777d10..3e783121 100644
--- a/src/object1.cc
+++ b/src/object1.cc
@@ -2503,7 +2503,7 @@ static cptr object_out_desc_where_found(s16b level, s16b dungeon)
}
else
{
- sprintf(str, "on level %d of %s", level, d_info[dungeon].name);
+ sprintf(str, "on level %d of %s", level, d_info[dungeon].name.c_str());
}
return str;
diff --git a/src/spells1.cc b/src/spells1.cc
index ab789a38..8be8b06a 100644
--- a/src/spells1.cc
+++ b/src/spells1.cc
@@ -7010,7 +7010,7 @@ static bool_ project_p(int who, int r, int y, int x, int dam, int typ, int a_rad
/* Did the dungeon do it? */
if (who == -100)
{
- sprintf(killer, "%s", d_info[dungeon_type].name);
+ sprintf(killer, "%s", d_info[dungeon_type].name.c_str());
}
if (who == -101)
{
diff --git a/src/spells2.cc b/src/spells2.cc
index 2540146e..ae7f8aa1 100644
--- a/src/spells2.cc
+++ b/src/spells2.cc
@@ -6089,7 +6089,6 @@ static void print_dungeon_batch(std::vector<int> const &dungeon_idxs,
{
auto const &d_info = game->edit_data.d_info;
- char buf[80];
int i, j;
byte attr;
@@ -6099,7 +6098,9 @@ static void print_dungeon_batch(std::vector<int> const &dungeon_idxs,
{
auto d_ptr = &d_info[dungeon_idxs[j]];
- strnfmt(buf, 80, " %c) %-30s", I2A(i), d_ptr->name);
+ char buf[80];
+ strnfmt(buf, 80, " %c) %-30s", I2A(i), d_ptr->name.c_str());
+
if (mode)
{
if (d_ptr->min_plev > p_ptr->lev)
@@ -6125,11 +6126,6 @@ static int find_dungeon_by_name(char const *name)
/* Find the index corresponding to the name */
for (std::size_t i = 1; i < d_info.size(); i++)
{
- /* Skip non-initialized entries. */
- if (d_info[i].name == nullptr)
- {
- continue;
- }
if (iequals(name, d_info[i].name))
{
return i;
@@ -6208,7 +6204,8 @@ static int reset_recall_aux()
else if (which == '@')
{
char buf[80];
- strcpy(buf, d_info[p_ptr->recall_dungeon].name);
+ strcpy(buf, d_info[p_ptr->recall_dungeon].name.c_str());
+
if (!get_string("Which dungeon? ", buf, 79)) continue;
/* Find the index corresponding to the name */
@@ -6281,8 +6278,9 @@ bool_ reset_recall(bool_ no_trepas_max_depth)
max = d_info[dun].maxdepth;
else
max = max_dlv[dun];
+
depth = get_quantity(format("Which level in %s(%d-%d)? ",
- d_info[dun].name,
+ d_info[dun].name.c_str(),
d_info[dun].mindepth, max),
max);
diff --git a/src/wizard2.cc b/src/wizard2.cc
index 5c4ff5cd..046fd80c 100644
--- a/src/wizard2.cc
+++ b/src/wizard2.cc
@@ -1577,7 +1577,7 @@ void do_cmd_debug()
{
dungeon_type = command_arg;
dun_level = d_info[dungeon_type].mindepth;
- msg_format("You go into %s", d_info[dungeon_type].text);
+ msg_format("You go into %s", d_info[dungeon_type].text.c_str());
/* Leaving */
p_ptr->leaving = TRUE;
diff --git a/src/xtra2.cc b/src/xtra2.cc
index 496bcbf0..95234f79 100644
--- a/src/xtra2.cc
+++ b/src/xtra2.cc
@@ -4200,7 +4200,7 @@ static int target_set_aux(int y, int x, int mode, cptr info)
/* Terrain feature if needed */
if (boring || (feat >= FEAT_GLYPH))
{
- cptr name;
+ std::string name;
/* Hack -- special handling for building doors */
if (feat == FEAT_SHOP)
@@ -4246,7 +4246,7 @@ static int target_set_aux(int y, int x, int mode, cptr info)
auto const &wf = wf_info[wilderness(x, y).feat];
s3 = "";
- name = format("%s(%s)", wf.name, wf.text);
+ name = fmt::format("{}({})", wf.name, wf.text);
}
if ((feat == FEAT_FOUNTAIN) && (c_ptr->info & CAVE_IDNT))
@@ -4270,12 +4270,12 @@ static int target_set_aux(int y, int x, int mode, cptr info)
/* Display a message */
if (!wizard)
{
- sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
+ sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name.c_str(), info);
}
else
{
sprintf(out_val, "%s%s%s%s [%s] (%d:%d:%d)",
- s1, s2, s3, name, info,
+ s1, s2, s3, name.c_str(), info,
c_ptr->feat, c_ptr->mimic, c_ptr->special);
}
prt(out_val, 0, 0);