summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/birth.cc10
-rw-r--r--src/files.cc10
-rw-r--r--src/notes.cc3
-rw-r--r--src/util.cc12
-rw-r--r--src/util.hpp2
5 files changed, 20 insertions, 17 deletions
diff --git a/src/birth.cc b/src/birth.cc
index f3897496..db481866 100644
--- a/src/birth.cc
+++ b/src/birth.cc
@@ -1927,7 +1927,8 @@ static bool_ player_birth_aux_ask()
rmp_ptr = &race_mod_info[p_ptr->pracem];
/* Display */
- c_put_str(TERM_L_BLUE, get_player_race_name(p_ptr->prace, p_ptr->pracem), 4, 9);
+ auto const race_name = get_player_race_name(p_ptr->prace, p_ptr->pracem);
+ c_put_str(TERM_L_BLUE, race_name.c_str(), 4, 9);
}
}
@@ -2745,8 +2746,8 @@ static bool_ player_birth_aux_auto()
c_put_str(TERM_L_BLUE, player_name, 2, 9);
c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
- strnfmt(buf, 80, "%s", get_player_race_name(p_ptr->prace, p_ptr->pracem));
- c_put_str(TERM_L_BLUE, buf, 4, 9);
+ auto const player_race_name = get_player_race_name(p_ptr->prace, p_ptr->pracem);
+ c_put_str(TERM_L_BLUE, player_race_name.c_str(), 4, 9);
c_put_str(TERM_L_BLUE, spp_ptr->title, 5, 9);
/* Label stats */
@@ -3512,9 +3513,10 @@ void save_savefile_names()
* Save, use '@' intead of ':' as a separator because it cannot exists
* in savefiles
*/
+ auto const player_race_name = get_player_race_name(p_ptr->prace, p_ptr->pracem);
fprintf(fff, "%s@%c%s@%s, the %s %s is %s\n", game_module,
(death) ? '0' : '1', player_base, player_name,
- get_player_race_name(p_ptr->prace, p_ptr->pracem),
+ player_race_name.c_str(),
spp_ptr->title,
(!death) ? "alive" : "dead");
diff --git a/src/files.cc b/src/files.cc
index cc168ba5..09c9f8e7 100644
--- a/src/files.cc
+++ b/src/files.cc
@@ -2207,9 +2207,12 @@ void display_player(int mode)
c_put_str(TERM_L_BLUE, tmp, 3, 9);
}
else
+ {
c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
- sprintf(buf, "%s", get_player_race_name(p_ptr->prace, p_ptr->pracem));
- c_put_str(TERM_L_BLUE, buf, 4, 9);
+ }
+
+ auto const player_race_name = get_player_race_name(p_ptr->prace, p_ptr->pracem);
+ c_put_str(TERM_L_BLUE, player_race_name.c_str(), 4, 9);
c_put_str(TERM_L_BLUE, spp_ptr->title, 5, 9);
c_put_str(TERM_L_BLUE, r_ptr->name, 6, 9);
c_put_str(TERM_L_BLUE, deity_info[p_ptr->pgod].name, 7, 9);
@@ -4788,11 +4791,12 @@ static void display_scores_aux(int highscore_fd, int from, int to, int note, hig
for (aged = the_score.turns; isspace(*aged); aged++) /* loop */;
/* Dump some info */
+ auto const player_race_name = get_player_race_name(pr, ps);
sprintf(out_val, "%3d.%9s %s the %s %s, Level %d",
place,
the_score.pts,
the_score.who,
- get_player_race_name(pr, ps),
+ player_race_name.c_str(),
class_info[pc].spec[pcs].title,
clev);
diff --git a/src/notes.cc b/src/notes.cc
index 326381c9..69269291 100644
--- a/src/notes.cc
+++ b/src/notes.cc
@@ -129,9 +129,10 @@ void add_note_type(int note_number)
char player[100];
/* Build the string containing the player information */
+ auto const player_race_name = get_player_race_name(p_ptr->prace, p_ptr->pracem);
sprintf(player,
"the %s %s",
- get_player_race_name(p_ptr->prace, p_ptr->pracem),
+ player_race_name.c_str(),
class_info[p_ptr->pclass].spec[p_ptr->pspec].title);
/* Add in "character start" information */
diff --git a/src/util.cc b/src/util.cc
index 8f3374d5..efbd4e38 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -3430,27 +3430,23 @@ std::string get_day(s32b day_no)
}
}
-cptr get_player_race_name(int pr, int ps)
+std::string get_player_race_name(int pr, int ps)
{
- static char buf[50];
-
if (ps)
{
if (race_mod_info[ps].place)
{
- sprintf(buf, "%s %s", race_info[pr].title, race_mod_info[ps].title);
+ return std::string(race_info[pr].title) + " " + race_mod_info[ps].title;
}
else
{
- sprintf(buf, "%s %s", race_mod_info[ps].title, race_info[pr].title);
+ return std::string(race_mod_info[ps].title) + " " + race_info[pr].title;
}
}
else
{
- sprintf(buf, "%s", race_info[pr].title);
+ return std::string(race_info[pr].title);
}
-
- return (buf);
}
/*
diff --git a/src/util.hpp b/src/util.hpp
index 6e7d74fa..deddff42 100644
--- a/src/util.hpp
+++ b/src/util.hpp
@@ -9,7 +9,7 @@
extern bool_ input_box(cptr text, int y, int x, char *buf, int max);
extern void draw_box(int y, int x, int h, int w);
extern void display_list(int y, int x, int h, int w, cptr title, cptr *list, int max, int begin, int sel, byte sel_color);
-extern cptr get_player_race_name(int pr, int ps);
+extern std::string get_player_race_name(int pr, int ps);
extern std::string get_day(s32b day);
extern s32b bst(s32b what, s32b t);
extern errr path_temp(char *buf, int max);