Changeset 303

Show
Ignore:
Timestamp:
07/08/07 11:51:57 (1 year ago)
Author:
takkaria
Message:

Add quickstart. (closes #28)

Files:

Legend:

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

    r246 r303  
    116116        /* Load the data */ 
    117117        p_ptr->age = prev.age; 
    118         p_ptr->wt = prev.wt; 
    119         p_ptr->ht = prev.ht; 
     118        p_ptr->wt = p_ptr->wt_birth = prev.wt; 
     119        p_ptr->ht = p_ptr->ht_birth = prev.ht; 
    120120        p_ptr->sc = prev.sc; 
    121         p_ptr->au = prev.au; 
     121        p_ptr->au = p_ptr->au_birth = prev.au; 
    122122 
    123123        /* Load the stats */ 
    124124        for (i = 0; i < A_MAX; i++) 
    125125        { 
    126                 p_ptr->stat_max[i] = prev.stat[i]; 
    127                 p_ptr->stat_cur[i] = prev.stat[i]; 
     126                p_ptr->stat_max[i] = p_ptr->stat_cur[i] = p_ptr->stat_birth[i] = prev.stat[i]; 
    128127        } 
    129128 
     
    270269                        p_ptr->stat_cur[i] = p_ptr->stat_max[i] = stat_use[i]; 
    271270                } 
     271 
     272                p_ptr->stat_birth[i] = p_ptr->stat_max[i]; 
    272273        } 
    273274} 
     
    390391        if (p_ptr->psex == SEX_MALE) 
    391392        { 
    392                 p_ptr->ht = Rand_normal(rp_ptr->m_b_ht, rp_ptr->m_m_ht); 
    393                 p_ptr->wt = Rand_normal(rp_ptr->m_b_wt, rp_ptr->m_m_wt); 
     393                p_ptr->ht = p_ptr->ht_birth = Rand_normal(rp_ptr->m_b_ht, rp_ptr->m_m_ht); 
     394                p_ptr->wt = p_ptr->wt_birth = Rand_normal(rp_ptr->m_b_wt, rp_ptr->m_m_wt); 
    394395        } 
    395396 
     
    397398        else if (p_ptr->psex == SEX_FEMALE) 
    398399        { 
    399                 p_ptr->ht = Rand_normal(rp_ptr->f_b_ht, rp_ptr->f_m_ht); 
    400                 p_ptr->wt = Rand_normal(rp_ptr->f_b_wt, rp_ptr->f_m_wt); 
     400                p_ptr->ht = p_ptr->ht_birth = Rand_normal(rp_ptr->f_b_ht, rp_ptr->f_m_ht); 
     401                p_ptr->wt = p_ptr->wt_birth = Rand_normal(rp_ptr->f_b_wt, rp_ptr->f_m_wt); 
    401402        } 
    402403} 
     
    431432 
    432433        /* Save the gold */ 
    433         p_ptr->au = gold; 
     434        p_ptr->au = p_ptr->au_birth = gold; 
    434435} 
    435436 
     
    439440 * Clear all the global "character" data 
    440441 */ 
    441 static void player_wipe(bool really_wipe
     442static void player_wipe(void
    442443{ 
    443444        int i; 
    444445 
    445         byte psex, prace, pclass; 
    446  
    447         if (really_wipe) 
    448         { 
    449                 psex = 0; 
    450                 prace = 0; 
    451                 pclass = 0; 
    452         } 
    453         else 
    454         { 
    455                 /* Backup the player choices */ 
    456                 psex = p_ptr->psex; 
    457                 prace = p_ptr->prace; 
    458                 pclass = p_ptr->pclass; 
    459         } 
     446        /* Backup the player choices */ 
     447        byte psex = p_ptr->psex; 
     448        byte prace = p_ptr->prace; 
     449        byte pclass = p_ptr->pclass; 
    460450 
    461451        /* Wipe the player */ 
     
    10881078                        { 
    10891079                                /* Reset stats */ 
    1090                                 p_ptr->stat_cur[i] = p_ptr->stat_max[i] = stats[i]; 
    1091  
     1080                                p_ptr->stat_cur[i] = p_ptr->stat_max[i] = p_ptr->stat_birth[i] = stats[i]; 
    10921081                        } 
    10931082 
     
    11211110 
    11221111                /* Gold is inversely proportional to cost */ 
    1123                 p_ptr->au = (100 * (48 - cost)) + 100; 
     1112                p_ptr->au = p_ptr->au_birth = (100 * (48 - cost)) + 100; 
    11241113 
    11251114                /* Calculate the bonuses and hitpoints */ 
     
    16801669                                        state = BIRTH_RESTART; 
    16811670 
    1682                                 if(ch == KTRL('X'))  
     1671                                if (ch == KTRL('X'))  
    16831672                                        quit(NULL); 
    16841673 
     
    17051694 
    17061695/* 
     1696 * Helper function for 'player_birth_quick()'. 
     1697 * 
     1698 * See "display_player" for screen layout code. 
     1699 */ 
     1700static bool player_birth_quick(void) 
     1701{ 
     1702    char ch; 
     1703    int i; 
     1704    birther old_char; 
     1705    byte old_hitdie; 
     1706    u16b old_expfact; 
     1707    s16b old_hp[PY_MAX_LEVEL]; 
     1708 
     1709    old_hitdie = p_ptr->hitdie; 
     1710    old_expfact = p_ptr->expfact; 
     1711 
     1712    old_char.age = p_ptr->age; 
     1713    old_char.au = p_ptr->au_birth; 
     1714    old_char.ht = p_ptr->ht_birth; 
     1715    old_char.wt = p_ptr->wt_birth; 
     1716    old_char.sc = p_ptr->sc; 
     1717 
     1718    /* Save the stats */ 
     1719    for (i = 0; i < A_MAX; i++) 
     1720    { 
     1721        old_char.stat[i] = p_ptr->stat_birth[i]; 
     1722    } 
     1723 
     1724    /* Save the history */ 
     1725    my_strcpy(old_char.history, p_ptr->history, sizeof(old_char.history)); 
     1726 
     1727    /* Save the hp */ 
     1728    for (i = 0; i < PY_MAX_LEVEL; i++) 
     1729    { 
     1730        old_hp[i] = p_ptr->player_hp[i]; 
     1731    } 
     1732 
     1733    /* Wipe the player */ 
     1734    player_wipe(); 
     1735 
     1736    /* Level one */ 
     1737    p_ptr->max_lev = p_ptr->lev = 1; 
     1738 
     1739    p_ptr->hitdie = old_hitdie; 
     1740    p_ptr->expfact = old_expfact; 
     1741 
     1742    p_ptr->age = old_char.age; 
     1743    p_ptr->au_birth = p_ptr->au = old_char.au; 
     1744    p_ptr->ht_birth = p_ptr->ht = old_char.ht; 
     1745    p_ptr->wt_birth = p_ptr->wt = old_char.wt; 
     1746    p_ptr->sc = old_char.sc; 
     1747 
     1748    /* Load the stats */ 
     1749    for (i = 0; i < A_MAX; i++) 
     1750    { 
     1751        p_ptr->stat_birth[i] = p_ptr->stat_cur[i] = p_ptr->stat_max[i] = old_char.stat[i]; 
     1752    } 
     1753 
     1754    /* Load the history */ 
     1755    my_strcpy(p_ptr->history, old_char.history, sizeof(p_ptr->history)); 
     1756 
     1757    /* Load the hp */ 
     1758    for (i = 0; i < PY_MAX_LEVEL; i++) 
     1759    { 
     1760        p_ptr->player_hp[i] = old_hp[i]; 
     1761    } 
     1762 
     1763        /* Set adult options from birth options */ 
     1764        for (i = OPT_BIRTH; i < OPT_CHEAT; i++) 
     1765        { 
     1766                op_ptr->opt[OPT_ADULT + (i - OPT_BIRTH)] = op_ptr->opt[i]; 
     1767        } 
     1768 
     1769        /* Reset score options from cheat options */ 
     1770        for (i = OPT_CHEAT; i < OPT_ADULT; i++) 
     1771        { 
     1772                op_ptr->opt[OPT_SCORE + (i - OPT_CHEAT)] = op_ptr->opt[i]; 
     1773        } 
     1774 
     1775    /* Calculate the bonuses and hitpoints */ 
     1776    p_ptr->update |= (PU_BONUS | PU_HP); 
     1777 
     1778    /* Update stuff */ 
     1779    update_stuff(); 
     1780 
     1781    /* Fully healed */ 
     1782    p_ptr->chp = p_ptr->mhp; 
     1783 
     1784    /* Fully rested */ 
     1785    p_ptr->csp = p_ptr->msp; 
     1786 
     1787    /* Display the player */ 
     1788    display_player(0); 
     1789 
     1790    /* Get a name, prepare savefile */ 
     1791    get_name(FALSE); 
     1792 
     1793    /* Prompt for it */ 
     1794    prt("['CTRL-X' to quit, 'ESC' to start over, or any other key to continue]", 23, 5); 
     1795 
     1796    /* Get a key */ 
     1797    ch = inkey(); 
     1798 
     1799    /* Quit */ 
     1800    if (ch == KTRL('X')) quit(NULL); 
     1801 
     1802    /* Start over */ 
     1803    if (ch == ESCAPE) return (FALSE); 
     1804 
     1805    /* Accept */ 
     1806    return (TRUE); 
     1807} 
     1808 
     1809 
     1810 
     1811/* 
    17071812 * Create a new character. 
    17081813 * 
     
    17121817void player_birth(void) 
    17131818{ 
    1714         /* Wipe the player properly */ 
    1715         player_wipe(TRUE); 
    1716  
    1717         /* Create a new character */ 
    1718         player_birth_aux(); 
     1819        bool quickstart = FALSE; 
     1820        char ch; 
     1821 
     1822        /* 
     1823         * If this a pre-existing savefile, offer to do a quick creation, based 
     1824         * on the previous character. 
     1825         */ 
     1826        if (character_existed && p_ptr->ht_birth) 
     1827        { 
     1828                /* Prompt */ 
     1829                while (TRUE) 
     1830                { 
     1831                        Term_clear(); 
     1832 
     1833                        put_str("Quick-start character based on previous one (y/n)? ", 2, 2); 
     1834                        ch = inkey(); 
     1835 
     1836                        if (ch == KTRL('X')) 
     1837                                quit(NULL); 
     1838                        else if ((ch == ESCAPE) || strchr("YyNn\r\n", ch)) 
     1839                                break; 
     1840                        else if (ch == '?') 
     1841                                (void)show_file("birth.hlp", NULL, 0, 0); 
     1842                        else 
     1843                                bell("Illegal answer!"); 
     1844                } 
     1845 
     1846                /* Quick generation */ 
     1847                if ((ch == 'y') || (ch == 'Y')) 
     1848                { 
     1849                        if (player_birth_quick()) quickstart = TRUE; 
     1850                } 
     1851        } 
     1852 
     1853 
     1854        /* Quickstart trumps normal creation */ 
     1855        if (!quickstart) 
     1856        { 
     1857                /* Wipe the player properly */ 
     1858                player_wipe(); 
     1859 
     1860                /* Create a new character */ 
     1861                player_birth_aux(); 
     1862        } 
    17191863 
    17201864        /* Note player birth in the message recall */ 
  • trunk/src/externs.h

    r279 r303  
    9999extern int arg_graphics; 
    100100extern bool character_generated; 
     101extern bool character_existed; 
    101102extern bool character_dungeon; 
    102103extern bool character_saved; 
  • trunk/src/load.c

    r270 r303  
    11111111        for (i = 0; i < A_MAX; i++) rd_s16b(&p_ptr->stat_max[i]); 
    11121112        for (i = 0; i < A_MAX; i++) rd_s16b(&p_ptr->stat_cur[i]); 
    1113  
    1114         strip_bytes(24);        /* oops */ 
     1113        for (i = 0; i < A_MAX; i++) rd_s16b(&p_ptr->stat_birth[i]); 
     1114 
     1115        rd_s16b(&p_ptr->ht_birth); 
     1116        rd_s16b(&p_ptr->wt_birth); 
     1117        rd_s32b(&p_ptr->au_birth); 
     1118 
     1119        strip_bytes(4); 
    11151120 
    11161121        rd_s32b(&p_ptr->au); 
     
    23072312                        p_ptr->is_dead = FALSE; 
    23082313 
     2314                        /* A character existed in this savefile. */ 
     2315                        character_existed = TRUE; 
     2316 
    23092317                        /* Count lives */ 
    23102318                        sf_lives++; 
  • trunk/src/save.c

    r270 r303  
    471471        wr_s16b(p_ptr->wt); 
    472472 
    473         /* Dump the stats (maximum and current) */ 
     473        /* Dump the stats (maximum and current and birth) */ 
    474474        for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_max[i]); 
    475475        for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_cur[i]); 
    476  
    477         /* Ignore the transient stats */ 
    478         for (i = 0; i < 12; ++i) wr_s16b(0); 
     476        for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_birth[i]); 
     477 
     478        wr_s16b(p_ptr->ht_birth); 
     479        wr_s16b(p_ptr->wt_birth); 
     480        wr_u32b(p_ptr->au_birth); 
     481 
     482        /* Padding */ 
     483        wr_u32b(0); 
    479484 
    480485        wr_u32b(p_ptr->au); 
     486 
    481487 
    482488        wr_u32b(p_ptr->max_exp); 
  • trunk/src/types.h

    r231 r303  
    10571057 
    10581058        s16b pspeed;            /* Current speed */ 
     1059 
     1060    /* Generation fields (for quick start) */ 
     1061        s32b au_birth;          /* Birth gold */ 
     1062        s16b stat_birth[A_MAX]; /* Birth "natural" stat values */ 
     1063        s16b ht_birth;          /* Birth Height */ 
     1064        s16b wt_birth;          /* Birth Weight */ 
    10591065}; 
    10601066 
  • trunk/src/variable.c

    r232 r303  
    6060 
    6161bool character_generated;       /* The character exists */ 
     62bool character_existed;         /* A character existed on the same savefile */ 
    6263bool character_dungeon;         /* The character has a dungeon */ 
    6364bool character_saved;           /* The character was just saved to a savefile */