Changeset 303
- Timestamp:
- 07/08/07 11:51:57 (1 year ago)
- Files:
-
- trunk/src/birth.c (modified) (11 diffs)
- trunk/src/externs.h (modified) (1 diff)
- trunk/src/load.c (modified) (2 diffs)
- trunk/src/save.c (modified) (1 diff)
- trunk/src/types.h (modified) (1 diff)
- trunk/src/variable.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/birth.c
r246 r303 116 116 /* Load the data */ 117 117 p_ptr->age = prev.age; 118 p_ptr->wt = p rev.wt;119 p_ptr->ht = p rev.ht;118 p_ptr->wt = p_ptr->wt_birth = prev.wt; 119 p_ptr->ht = p_ptr->ht_birth = prev.ht; 120 120 p_ptr->sc = prev.sc; 121 p_ptr->au = p rev.au;121 p_ptr->au = p_ptr->au_birth = prev.au; 122 122 123 123 /* Load the stats */ 124 124 for (i = 0; i < A_MAX; i++) 125 125 { 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]; 128 127 } 129 128 … … 270 269 p_ptr->stat_cur[i] = p_ptr->stat_max[i] = stat_use[i]; 271 270 } 271 272 p_ptr->stat_birth[i] = p_ptr->stat_max[i]; 272 273 } 273 274 } … … 390 391 if (p_ptr->psex == SEX_MALE) 391 392 { 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); 394 395 } 395 396 … … 397 398 else if (p_ptr->psex == SEX_FEMALE) 398 399 { 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); 401 402 } 402 403 } … … 431 432 432 433 /* Save the gold */ 433 p_ptr->au = gold;434 p_ptr->au = p_ptr->au_birth = gold; 434 435 } 435 436 … … 439 440 * Clear all the global "character" data 440 441 */ 441 static void player_wipe( bool really_wipe)442 static void player_wipe(void) 442 443 { 443 444 int i; 444 445 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; 460 450 461 451 /* Wipe the player */ … … 1088 1078 { 1089 1079 /* 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]; 1092 1081 } 1093 1082 … … 1121 1110 1122 1111 /* 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; 1124 1113 1125 1114 /* Calculate the bonuses and hitpoints */ … … 1680 1669 state = BIRTH_RESTART; 1681 1670 1682 if (ch == KTRL('X'))1671 if (ch == KTRL('X')) 1683 1672 quit(NULL); 1684 1673 … … 1705 1694 1706 1695 /* 1696 * Helper function for 'player_birth_quick()'. 1697 * 1698 * See "display_player" for screen layout code. 1699 */ 1700 static 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 /* 1707 1812 * Create a new character. 1708 1813 * … … 1712 1817 void player_birth(void) 1713 1818 { 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 } 1719 1863 1720 1864 /* Note player birth in the message recall */ trunk/src/externs.h
r279 r303 99 99 extern int arg_graphics; 100 100 extern bool character_generated; 101 extern bool character_existed; 101 102 extern bool character_dungeon; 102 103 extern bool character_saved; trunk/src/load.c
r270 r303 1111 1111 for (i = 0; i < A_MAX; i++) rd_s16b(&p_ptr->stat_max[i]); 1112 1112 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); 1115 1120 1116 1121 rd_s32b(&p_ptr->au); … … 2307 2312 p_ptr->is_dead = FALSE; 2308 2313 2314 /* A character existed in this savefile. */ 2315 character_existed = TRUE; 2316 2309 2317 /* Count lives */ 2310 2318 sf_lives++; trunk/src/save.c
r270 r303 471 471 wr_s16b(p_ptr->wt); 472 472 473 /* Dump the stats (maximum and current ) */473 /* Dump the stats (maximum and current and birth) */ 474 474 for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_max[i]); 475 475 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); 479 484 480 485 wr_u32b(p_ptr->au); 486 481 487 482 488 wr_u32b(p_ptr->max_exp); trunk/src/types.h
r231 r303 1057 1057 1058 1058 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 */ 1059 1065 }; 1060 1066 trunk/src/variable.c
r232 r303 60 60 61 61 bool character_generated; /* The character exists */ 62 bool character_existed; /* A character existed on the same savefile */ 62 63 bool character_dungeon; /* The character has a dungeon */ 63 64 bool character_saved; /* The character was just saved to a savefile */
