From ff8894cc6bec9eeae81b222ec8116e3bb8793174 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 13 Jun 2017 18:24:42 +0200 Subject: Avoid overwriting existing characters for "New Character" Fixes #17 --- src/birth.cc | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/birth.cc b/src/birth.cc index c920854b..7d54d3a3 100644 --- a/src/birth.cc +++ b/src/birth.cc @@ -57,6 +57,7 @@ #include "z-rand.hpp" #include +#include #include #include #include @@ -3132,6 +3133,10 @@ savefile_try_again: continue; } + // + // React + // + if (k == 'a') { /* Display prompt */ @@ -3143,7 +3148,34 @@ savefile_try_again: /* Process the player name */ process_player_name(TRUE); - return (TRUE); + // If the savefile already exists, we do *NOT* want to + // create a new game, so we'll need to return FALSE for + // that. + if (boost::filesystem::exists(savefile)) + { + // Show a message so user doesn't get confused. + msg_print(NULL); + + // Prompt for it + prt(fmt::format( + "Character '{}' already exists! Press any key to load.", + game->player_base), + 0, 0); + + // Wait + inkey(); + + // Erase the prompt + prt("", 0, 0); + + // Load character + return FALSE; + } + else + { + // Start new game + return TRUE; + } } if (k == 'b') { -- cgit v1.2.3