#include "player/process-name.h"
#include "autopick/autopick-reader-writer.h"
#include "core/asking-player.h"
+#include "game-option/birth-options.h"
#include "io/files-util.h"
#include "player/player-personality.h"
+#include "system/player-type-definition.h"
#include "term/screen-processor.h"
#include "term/term-color-types.h"
#include "util/angband-files.h"
* Extract a clean "base name".
* Build the savefile name if needed.
*/
-void process_player_name(player_type *creature_ptr, bool sf)
+void process_player_name(player_type *creature_ptr, bool is_new_savefile)
{
char old_player_base[32] = "";
if (current_world_ptr->character_generated)
if (!creature_ptr->base_name[0])
strcpy(creature_ptr->base_name, "PLAYER");
-#ifdef SAVEFILE_MUTABLE
- sf = TRUE;
+ auto is_modified = false;
+ if (is_new_savefile && (!savefile[0] || !keep_savefile)) {
+ char temp[128];
+
+#ifdef SAVEFILE_USE_UID
+ /* Rename the savefile, using the creature_ptr->player_uid and creature_ptr->base_name */
+ (void)sprintf(temp, "%d.%s", creature_ptr->player_uid, creature_ptr->base_name);
+#else
+ /* Rename the savefile, using the creature_ptr->base_name */
+ (void)sprintf(temp, "%s", creature_ptr->base_name);
#endif
- if (!savefile_base[0] && savefile[0]) {
+ path_build(savefile, sizeof(savefile), ANGBAND_DIR_SAVE, temp);
+ is_modified = true;
+ }
+
+ if (is_modified || !savefile_base[0]) {
concptr s = savefile;
while (TRUE) {
concptr t;
s = t + 1;
}
- strcpy(savefile_base, s);
- }
-
- if (!savefile_base[0] || !savefile[0])
- sf = TRUE;
-
- if (sf) {
- char temp[128];
- strcpy(savefile_base, creature_ptr->base_name);
-
#ifdef SAVEFILE_USE_UID
- /* Rename the savefile, using the creature_ptr->player_uid and creature_ptr->base_name */
- (void)sprintf(temp, "%d.%s", creature_ptr->player_uid, creature_ptr->base_name);
+ strcpy(savefile_base, angband_strstr(s, ".") + 1);
#else
- /* Rename the savefile, using the creature_ptr->base_name */
- (void)sprintf(temp, "%s", creature_ptr->base_name);
+ strcpy(savefile_base, s);
#endif
- path_build(savefile, sizeof(savefile), ANGBAND_DIR_SAVE, temp);
}
if (current_world_ptr->character_generated && !streq(old_player_base, creature_ptr->base_name)) {
term_erase(34, 1, 255);
c_put_str(TERM_L_BLUE, tmp, 1, 34);
clear_from(22);
-}
\ No newline at end of file
+}