Changeset 135

Show
Ignore:
Timestamp:
05/14/07 03:27:00 (1 year ago)
Author:
takkaria
Message:

Prompt for overwriting an existing savefile (ajps' patch). Closes #87.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/birth.c

    r134 r135  
    15291529        cptr prompt = "['Q' to suicide, 'S' to start over, or any other key to continue]"; 
    15301530 
    1531         bool done = FALSE; 
    1532  
    15331531        /* Ask questions */ 
    15341532        if (!player_birth_aux_1()) return (FALSE); 
     
    15491547 
    15501548        /* Get a name, prepare savefile */ 
    1551         get_name(); 
     1549        get_name(FALSE); 
    15521550 
    15531551        /* Display the player */ 
  • trunk/src/cmd4.c

    r125 r135  
    17651765                if ((ke.key == 'c') || ((ke.key == '\xff') && (ke.mousey == 2) && (ke.mousex < 26))) 
    17661766                { 
    1767                         get_name(); 
     1767                        get_name(FALSE); 
    17681768                } 
    17691769 
  • trunk/src/dungeon.c

    r134 r135  
     1 
    12/* File: dungeon.c */ 
    23 
     
    1011 
    1112#include "angband.h" 
     13#include "z-file.h" 
    1214 
    1315#include "script.h" 
     
    18371839void play_game(bool new_game) 
    18381840{ 
     1841        bool character_loaded; 
     1842        bool reusing_savefile; 
     1843 
    18391844        /* Hack -- Increase "icky" depth */ 
    18401845        character_icky++; 
     
    18601865 
    18611866        /* Attempt to load */ 
    1862         if (!load_player()) 
     1867        if (!load_player(&character_loaded, &reusing_savefile)) 
    18631868        { 
    18641869                /* Oops */ 
     
    18741879                /* The dungeon is not ready */ 
    18751880                character_dungeon = FALSE; 
     1881 
     1882                /* XXX This is the place to add automatic character 
     1883                   numbering (i.e. Rocky IV, V, etc.) Probably. */ 
    18761884        } 
    18771885 
     
    19591967                process_player_name(TRUE); 
    19601968        } 
     1969         
     1970        /* Check if we're overwriting a savefile */ 
     1971        while (!reusing_savefile && my_fexists(savefile)) 
     1972        { 
     1973                /* Ask for confirmation */ 
     1974                bool newname = get_check("A savefile using that name already exists.  Choose a new name? "); 
     1975          
     1976                if (newname) 
     1977                { 
     1978                        get_name(TRUE); 
     1979                }                         
     1980                else 
     1981                { 
     1982                        break; 
     1983                }                         
     1984        } 
    19611985 
    19621986        /* Flash a message */ 
     
    19762000        /* Window stuff */ 
    19772001        p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER_0 | PW_PLAYER_1); 
    1978  
    1979         /* Window stuff */ 
    19802002        p_ptr->window |= (PW_MONSTER | PW_MESSAGE); 
    1981  
    1982         /* Window stuff */ 
    19832003        window_stuff(); 
    19842004 
  • trunk/src/externs.h

    r134 r135  
    9999extern bool character_generated; 
    100100extern bool character_dungeon; 
    101 extern bool character_loaded; 
    102101extern bool character_saved; 
    103102extern s16b character_icky; 
     
    327326extern void do_cmd_help(void); 
    328327extern void process_player_name(bool sf); 
    329 extern void get_name(void); 
     328extern void get_name(bool sf); 
    330329extern void do_cmd_suicide(void); 
    331330extern void do_cmd_save_game(void); 
     
    352351 
    353352/* load.c */ 
    354 extern bool load_player(void); 
     353extern bool load_player(bool *character_loaded, bool *reusing_savefile); 
    355354 
    356355/* melee1.c */ 
  • trunk/src/load.c

    r134 r135  
    21392139 * allowed to save his game when he quits. 
    21402140 * 
    2141  * We return "TRUE" if the savefile was usable, and we set the global 
     2141 * We return "TRUE" if the savefile was usable, and we set the 
    21422142 * flag "character_loaded" if a real, living, character was loaded. 
    21432143 * 
     
    21452145 * there is no such file, so we must check for "empty" savefile names. 
    21462146 */ 
    2147 bool load_player(void
     2147bool load_player(bool *character_loaded, bool *reusing_savefile
    21482148{ 
    21492149        int fd = -1; 
     
    21582158        /* Paranoia */ 
    21592159        turn = 0; 
    2160  
    2161         /* Paranoia */ 
    21622160        p_ptr->is_dead = FALSE; 
    2163  
     2161         
     2162        *character_loaded = FALSE; 
     2163        *reusing_savefile = FALSE; 
    21642164 
    21652165        /* Allow empty savefile name */ 
     
    22862286                        { 
    22872287                                /* A character was loaded */ 
    2288                                 character_loaded = TRUE; 
     2288                                *character_loaded = TRUE; 
    22892289 
    22902290                                /* Mark the savefile */ 
     
    23092309 
    23102310                /* A character was loaded */ 
    2311                 character_loaded = TRUE; 
     2311                *character_loaded = TRUE; 
    23122312 
    23132313                /* Still alive */ 
     
    23172317                        strcpy(p_ptr->died_from, "(alive and well)"); 
    23182318                } 
     2319 
     2320                *reusing_savefile = TRUE; 
    23192321 
    23202322                /* Success */ 
  • trunk/src/save.c

    r117 r135  
    10941094                safe_setuid_drop(); 
    10951095 
    1096                 /* Hack -- Pretend the character was loaded */ 
    1097                 character_loaded = TRUE; 
    1098  
    10991096                /* Success */ 
    11001097                result = TRUE; 
  • trunk/src/util.c

    r127 r135  
    28532853 * Gets a name for the character, reacting to name changes. 
    28542854 * 
     2855 * If sf is TRUE, we change the savefile name depending on the character name. 
     2856 * 
    28552857 * What a horrible name for a global function.  XXX XXX XXX 
    28562858 */ 
    2857 void get_name(void
     2859void get_name(bool sf
    28582860{ 
    28592861        bool res; 
     
    28812883 
    28822884                /* Process the player name */ 
    2883                 process_player_name(FALSE); 
     2885                process_player_name(sf); 
    28842886        } 
    28852887} 
  • trunk/src/variable.c

    r82 r135  
    6363bool character_generated;       /* The character exists */ 
    6464bool character_dungeon;         /* The character has a dungeon */ 
    65 bool character_loaded;          /* The character was loaded from a savefile */ 
    6665bool character_saved;           /* The character was just saved to a savefile */ 
    6766