* 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");
- if (!keep_savefile || !savefile[0]) {
-#ifdef SAVEFILE_MUTABLE
- sf = TRUE;
-#endif
- if (!savefile_base[0] && savefile[0]) {
- concptr s = savefile;
- while (TRUE) {
- concptr t;
- t = angband_strstr(s, PATH_SEP);
- if (!t)
- break;
- s = t + 1;
- }
-
- strcpy(savefile_base, s);
- }
+ auto is_modified = false;
+ if (is_new_savefile && (!savefile[0] || !keep_savefile)) {
+ char temp[128];
- if (!savefile_base[0] || !savefile[0])
- sf = TRUE;
+#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
+ path_build(savefile, sizeof(savefile), ANGBAND_DIR_SAVE, temp);
+ is_modified = true;
+ }
- if (sf) {
- char temp[128];
- strcpy(savefile_base, creature_ptr->base_name);
+ if (is_modified || !savefile_base[0]) {
+ concptr s = savefile;
+ while (TRUE) {
+ concptr t;
+ t = angband_strstr(s, PATH_SEP);
+ if (!t)
+ break;
+ s = t + 1;
+ }
#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)) {