Ticket #28: quickstart.v1.diff

File quickstart.v1.diff, 8.9 kB (added by takkaria, 1 year ago)

Old quickstart patch as basis for future work

  • src/birth.c

    old new  
    111111 
    112112        /* Load the data */ 
    113113        p_ptr->age = prev.age; 
    114         p_ptr->wt = prev.wt; 
    115         p_ptr->ht = prev.ht; 
     114        p_ptr->wt = p_ptr->wt_birth = prev.wt; 
     115        p_ptr->ht = p_ptr->ht_birth = prev.ht; 
    116116        p_ptr->sc = prev.sc; 
    117         p_ptr->au = prev.au; 
     117        p_ptr->au = p_ptr->au_birth = prev.au; 
    118118 
    119119        /* Load the stats */ 
    120120        for (i = 0; i < A_MAX; i++) 
    121121        { 
    122                 p_ptr->stat_max[i] = prev.stat[i]; 
    123                 p_ptr->stat_cur[i] = prev.stat[i]; 
     122                p_ptr->stat_max[i] = p_ptr->stat_cur[i] = p_ptr->stat_birth[i] = prev.stat[i]; 
    124123        } 
    125124 
    126125        /* Load the history */ 
     
    265264                        /* Save the resulting stat maximum */ 
    266265                        p_ptr->stat_cur[i] = p_ptr->stat_max[i] = stat_use[i]; 
    267266                } 
     267 
     268                p_ptr->stat_birth[i] = p_ptr->stat_max[i]; 
    268269        } 
    269270} 
    270271 
     
    385386        /* Calculate the height/weight for males */ 
    386387        if (p_ptr->psex == SEX_MALE) 
    387388        { 
    388                 p_ptr->ht = Rand_normal(rp_ptr->m_b_ht, rp_ptr->m_m_ht); 
    389                 p_ptr->wt = Rand_normal(rp_ptr->m_b_wt, rp_ptr->m_m_wt); 
     389                p_ptr->ht = p_ptr->ht_birth = Rand_normal(rp_ptr->m_b_ht, rp_ptr->m_m_ht); 
     390                p_ptr->wt = p_ptr->wt_birth = Rand_normal(rp_ptr->m_b_wt, rp_ptr->m_m_wt); 
    390391        } 
    391392 
    392393        /* Calculate the height/weight for females */ 
    393394        else if (p_ptr->psex == SEX_FEMALE) 
    394395        { 
    395                 p_ptr->ht = Rand_normal(rp_ptr->f_b_ht, rp_ptr->f_m_ht); 
    396                 p_ptr->wt = Rand_normal(rp_ptr->f_b_wt, rp_ptr->f_m_wt); 
     396                p_ptr->ht = p_ptr->ht_birth = Rand_normal(rp_ptr->f_b_ht, rp_ptr->f_m_ht); 
     397                p_ptr->wt = p_ptr->wt_birth = Rand_normal(rp_ptr->f_b_wt, rp_ptr->f_m_wt); 
    397398        } 
    398399} 
    399400 
     
    426427        if (gold < 100) gold = 100; 
    427428 
    428429        /* Save the gold */ 
    429         p_ptr->au = gold; 
     430        p_ptr->au = p_ptr->au_birth = gold; 
    430431} 
    431432 
    432433 
     
    10301031static bool player_birth_aux_1(void) 
    10311032{ 
    10321033        int i, res, cur; 
     1034 
     1035        /* Wipe the player */ 
     1036        player_wipe(); 
     1037 
    10331038 
    10341039        /*** Instructions ***/ 
    10351040 
     
    11771182                        if (adult_maximize) 
    11781183                        { 
    11791184                                /* Reset stats */ 
    1180                                 p_ptr->stat_cur[i] = p_ptr->stat_max[i] = stats[i]; 
    1181  
     1185                                p_ptr->stat_cur[i] = p_ptr->stat_max[i] = p_ptr->stat_birth[i] = stats[i]; 
    11821186                        } 
    11831187 
    11841188                        /* Fixed stat maxes */ 
     
    12101214                } 
    12111215 
    12121216                /* Gold is inversely proportional to cost */ 
    1213                 p_ptr->au = (100 * (48 - cost)) + 100; 
     1217                p_ptr->au = p_ptr->au_birth = (100 * (48 - cost)) + 100; 
    12141218 
    12151219                /* Calculate the bonuses and hitpoints */ 
    12161220                p_ptr->update |= (PU_BONUS | PU_HP); 
     
    17001704 
    17011705 
    17021706/* 
     1707 * Helper function for 'player_birth_quick()'. 
     1708 * 
     1709 * See "display_player" for screen layout code. 
     1710 */ 
     1711static bool player_birth_quick(void) 
     1712{ 
     1713    char ch; 
     1714    int i; 
     1715    birther old_char; 
     1716    byte old_class; 
     1717    byte old_race; 
     1718    byte old_sex; 
     1719    byte old_hitdie; 
     1720    u16b old_expfact; 
     1721    s16b old_hp[PY_MAX_LEVEL]; 
     1722 
     1723    old_sex = p_ptr->psex; 
     1724    old_class = p_ptr->pclass; 
     1725    old_race = p_ptr->prace; 
     1726 
     1727    old_hitdie = p_ptr->hitdie; 
     1728    old_expfact = p_ptr->expfact; 
     1729 
     1730    old_char.age = p_ptr->age; 
     1731    old_char.au = p_ptr->au_birth; 
     1732    old_char.ht = p_ptr->ht_birth; 
     1733    old_char.wt = p_ptr->wt_birth; 
     1734    old_char.sc = p_ptr->sc; 
     1735 
     1736    /* Save the stats */ 
     1737    for (i = 0; i < A_MAX; i++) 
     1738    { 
     1739        old_char.stat[i] = p_ptr->stat_birth[i]; 
     1740    } 
     1741 
     1742    /* Save the history */ 
     1743    my_strcpy(old_char.history, p_ptr->history, sizeof(old_char.history)); 
     1744 
     1745    /* Save the hp */ 
     1746    for (i = 0; i < PY_MAX_LEVEL; i++) 
     1747    { 
     1748        old_hp[i] = p_ptr->player_hp[i]; 
     1749    } 
     1750 
     1751    /* Wipe the player */ 
     1752    player_wipe(); 
     1753 
     1754    /* Level one */ 
     1755    p_ptr->max_lev = p_ptr->lev = 1; 
     1756 
     1757    p_ptr->psex = old_sex; 
     1758    p_ptr->pclass = old_class; 
     1759    p_ptr->prace = old_race; 
     1760 
     1761    p_ptr->hitdie = old_hitdie; 
     1762    p_ptr->expfact = old_expfact; 
     1763 
     1764    p_ptr->age = old_char.age; 
     1765    p_ptr->au_birth = p_ptr->au = old_char.au; 
     1766    p_ptr->ht = old_char.ht; 
     1767    p_ptr->wt = old_char.wt; 
     1768    p_ptr->sc = old_char.sc; 
     1769 
     1770    /* Load the stats */ 
     1771    for (i = 0; i < A_MAX; i++) 
     1772    { 
     1773        p_ptr->stat_birth[i] = p_ptr->stat_cur[i] = p_ptr->stat_max[i] = old_char.stat[i]; 
     1774    } 
     1775 
     1776    /* Load the history */ 
     1777    my_strcpy(p_ptr->history, old_char.history, sizeof(p_ptr->history)); 
     1778 
     1779    /* Load the hp */ 
     1780    for (i = 0; i < PY_MAX_LEVEL; i++) 
     1781    { 
     1782        p_ptr->player_hp[i] = old_hp[i]; 
     1783    } 
     1784 
     1785        /* Set adult options from birth options */ 
     1786        for (i = OPT_BIRTH; i < OPT_CHEAT; i++) 
     1787        { 
     1788                op_ptr->opt[OPT_ADULT + (i - OPT_BIRTH)] = op_ptr->opt[i]; 
     1789        } 
     1790 
     1791        /* Reset score options from cheat options */ 
     1792        for (i = OPT_CHEAT; i < OPT_ADULT; i++) 
     1793        { 
     1794                op_ptr->opt[OPT_SCORE + (i - OPT_CHEAT)] = op_ptr->opt[i]; 
     1795        } 
     1796 
     1797    /* Calculate the bonuses and hitpoints */ 
     1798    p_ptr->update |= (PU_BONUS | PU_HP); 
     1799 
     1800    /* Update stuff */ 
     1801    update_stuff(); 
     1802 
     1803    /* Fully healed */ 
     1804    p_ptr->chp = p_ptr->mhp; 
     1805 
     1806    /* Fully rested */ 
     1807    p_ptr->csp = p_ptr->msp; 
     1808 
     1809    /* Display the player */ 
     1810    display_player(0); 
     1811 
     1812    /* Get a name, prepare savefile */ 
     1813    get_name(); 
     1814 
     1815    /* Prompt for it */ 
     1816    prt("['CTRL-X' to quit, 'ESC' to start over, or any other key to continue]", 23, 5); 
     1817 
     1818    /* Get a key */ 
     1819    ch = inkey(); 
     1820 
     1821    /* Quit */ 
     1822    if (ch == KTRL('X')) quit(NULL); 
     1823 
     1824    /* Start over */ 
     1825    if (ch == ESCAPE) return (FALSE); 
     1826 
     1827    /* Accept */ 
     1828    return (TRUE); 
     1829} 
     1830 
     1831 
     1832 
     1833/* 
    17031834 * Create a new character. 
    17041835 * 
    17051836 * Note that we may be called with "junk" leftover in the various 
     
    17081839void player_birth(void) 
    17091840{ 
    17101841        int i, n; 
     1842        bool done = FALSE; 
     1843        char ch; 
     1844 
     1845 
     1846    /* 
     1847     * If this a pre-existing savefile, offer to do a quick creation, based 
     1848     * on the previous character. 
     1849     */ 
     1850    if (character_existed) 
     1851    { 
     1852        /* Prompt */ 
     1853        while (TRUE) 
     1854        { 
     1855            Term_clear(); 
     1856 
     1857            put_str("Quick-start character based on previous one (y/n)? ", 2, 2); 
     1858            ch = inkey(); 
     1859            if (ch == KTRL('X')) quit(NULL); 
     1860            if ((ch == ESCAPE) || (ch == '\r') || (ch == '\n')) break; 
     1861            if (strchr("YyNn", ch)) break; 
     1862            if (ch == '?') (void)show_file("birth.hlp", NULL, 0, 0); 
     1863            else bell("Illegal answer!"); 
     1864        } 
     1865 
     1866        /* Quick generation */ 
     1867        if ((ch == 'y') || (ch == 'Y')) 
     1868        { 
     1869            if (player_birth_quick()) done = TRUE; 
     1870        } 
     1871    } 
    17111872 
    17121873 
    17131874        /* Create a new character */ 
    1714         while (1) 
    1715         { 
    1716                 /* Wipe the player */ 
    1717                 player_wipe(); 
    1718  
     1875        while (!done) 
     1876        { 
    17191877                /* Roll up a new character */ 
    1720                 if (player_birth_aux()) break
     1878                done = player_birth_aux()
    17211879        } 
    17221880 
    17231881 
  • src/externs.h

    old new  
    9191extern bool arg_force_original; 
    9292extern bool arg_force_roguelike; 
    9393extern bool character_generated; 
     94extern bool character_existed; 
    9495extern bool character_dungeon; 
    9596extern bool character_loaded; 
    9697extern bool character_saved; 
  • src/load.c

    old new  
    989989        /* Age/Height/Weight */ 
    990990        rd_s16b(&p_ptr->age); 
    991991        rd_s16b(&p_ptr->ht); 
     992        rd_s16b(&p_ptr->ht_birth); 
    992993        rd_s16b(&p_ptr->wt); 
     994        rd_s16b(&p_ptr->wt_birth); 
    993995 
    994996        /* Read the stat info */ 
    995997        for (i = 0; i < A_MAX; i++) rd_s16b(&p_ptr->stat_max[i]); 
    996998        for (i = 0; i < A_MAX; i++) rd_s16b(&p_ptr->stat_cur[i]); 
     999        for (i = 0; i < A_MAX; i++) rd_s16b(&p_ptr->stat_birth[i]); 
    9971000 
    9981001        strip_bytes(24);        /* oops */ 
    9991002 
    10001003        rd_s32b(&p_ptr->au); 
     1004        rd_s32b(&p_ptr->au_birth); 
    10011005 
    10021006        rd_s32b(&p_ptr->max_exp); 
    10031007        rd_s32b(&p_ptr->exp); 
     
    22312235                        /* Forget death */ 
    22322236                        p_ptr->is_dead = FALSE; 
    22332237 
     2238                        /* A character existed in this savefile. */ 
     2239                        character_existed = TRUE; 
     2240 
    22342241                        /* Count lives */ 
    22352242                        sf_lives++; 
    22362243 
  • src/save.c

    old new  
    10261026        wr_s16b(p_ptr->age); 
    10271027        wr_s16b(p_ptr->ht); 
    10281028        wr_s16b(p_ptr->wt); 
    1029  
    1030         /* Dump the stats (maximum and current) */ 
     1029        wr_s16b(p_ptr->ht_birth); 
     1030        wr_s16b(p_ptr->wt_birth); 
     1031 
     1032        /* Dump the stats (maximum and current and birth) */ 
    10311033        for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_max[i]); 
    10321034        for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_cur[i]); 
     1035        for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_birth[i]); 
    10331036 
    10341037        /* Ignore the transient stats */ 
    10351038        for (i = 0; i < 12; ++i) wr_s16b(0); 
    10361039 
    10371040        wr_u32b(p_ptr->au); 
     1041        wr_u32b(p_ptr->au_birth); 
     1042 
    10381043 
    10391044        wr_u32b(p_ptr->max_exp); 
    10401045        wr_u32b(p_ptr->exp); 
  • src/types.h

    old new  
    10471047        byte ammo_tval;         /* Ammo variety */ 
    10481048 
    10491049        s16b pspeed;            /* Current speed */ 
     1050 
     1051    /* Generation fields (for quick start) */ 
     1052    s32b au_birth;          /* Birth gold */ 
     1053    byte stat_birth[A_MAX]; /* Birth "natural" stat values */ 
     1054    s16b ht_birth;          /* Birth Height */ 
     1055    s16b wt_birth;          /* Birth Weight */ 
    10501056}; 
    10511057 
    10521058 
  • src/variable.c

    old new  
    6161 */ 
    6262 
    6363bool character_generated;       /* The character exists */ 
     64bool character_existed;         /* A character existed on the same savefile */ 
    6465bool character_dungeon;         /* The character has a dungeon */ 
    6566bool character_loaded;          /* The character was loaded from a savefile */ 
    6667bool character_saved;           /* The character was just saved to a savefile */