Changeset 450

Show
Ignore:
Timestamp:
08/05/07 20:39:00 (1 year ago)
Author:
ctate
Message:

Eliminate the monster_level global. Equivalent depth for monster creation is now passed as a parameter, typically based on the player's depth (or offsets from that; e.g. vaults).

More cleanup towards unit testing, see #55.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/defines.h

    r449 r450  
    270270 
    271271/* 
    272  * There is a 1/50 (2%) chance of inflating the requested monster_level 
     272 * There is a 1/50 (2%) chance of inflating the requested monster level 
    273273 * during the creation of a monsters (see "get_mon_num()" in "monster.c"). 
    274274 * Lower values yield harder monsters more often. 
  • trunk/src/dungeon.c

    r449 r450  
    736736        { 
    737737                /* Make a new monster */ 
    738                 (void)alloc_monster(MAX_SIGHT + 5, FALSE); 
     738                (void)alloc_monster(MAX_SIGHT + 5, FALSE, p_ptr->depth); 
    739739        } 
    740740 
     
    16311631 
    16321632        /*** Process this dungeon level ***/ 
    1633  
    1634         /* Reset the monster generation level */ 
    1635         monster_level = p_ptr->depth; 
    16361633 
    16371634        /* Main loop */ 
  • trunk/src/externs.h

    r449 r450  
    108108extern u32b seed_town; 
    109109extern s16b num_repro; 
    110 extern s16b monster_level; 
    111110extern char summon_kin_type; 
    112111extern s32b turn; 
     
    380379extern s16b monster_place(int y, int x, monster_type *n_ptr); 
    381380extern bool place_monster_aux(int y, int x, int r_idx, bool slp, bool grp); 
    382 extern bool place_monster(int y, int x, bool slp, bool grp); 
    383 extern bool alloc_monster(int dis, bool slp); 
     381extern bool place_monster(int y, int x, int depth, bool slp, bool grp); 
     382extern bool alloc_monster(int dis, bool slp, int depth); 
    384383extern bool summon_specific(int y1, int x1, int lev, int type); 
    385384extern bool multiply_monster(int m_idx); 
  • trunk/src/generate.c

    r449 r450  
    17071707        (void)mon_restrict(symbol, (byte)depth, &dummy, TRUE); 
    17081708 
    1709         /* Set generation level */ 
    1710         monster_level = depth; 
    1711  
    17121709        /* Build the monster probability table. */ 
    17131710        if (!get_mon_num(depth)) return; 
     
    17421739 
    17431740                /* Place the monster (sleeping, allow groups) */ 
    1744                 (void)place_monster(y, x, TRUE, TRUE); 
     1741                (void)place_monster(y, x, depth, TRUE, TRUE); 
    17451742 
    17461743                /* Rein in monster groups and escorts a little. */ 
     
    17541751        /* Remove monster restrictions. */ 
    17551752        (void)mon_restrict('\0', (byte)depth, &dummy, TRUE); 
    1756  
    1757         /* Reset monster generation level. */ 
    1758         monster_level = p_ptr->depth; 
    17591753} 
    17601754 
     
    24372431 
    24382432                        /* Let's guard the treasure well */ 
    2439                         monster_level = p_ptr->depth + 4; 
    2440                         (void)place_monster(y0, x0, TRUE, TRUE); 
    2441                         monster_level = p_ptr->depth; 
     2433                        (void)place_monster(y0, x0, p_ptr->depth + 4, TRUE, TRUE); 
    24422434 
    24432435                        /* Traps, naturally. */ 
     
    30653057                                case '&': 
    30663058                                { 
    3067                                         monster_level = p_ptr->depth + 5; 
    3068                                         place_monster(y, x, TRUE, TRUE); 
    3069                                         monster_level = p_ptr->depth; 
     3059                                        place_monster(y, x, p_ptr->depth + 5, TRUE, TRUE); 
    30703060                                        break; 
    30713061                                } 
     
    30743064                                case '@': 
    30753065                                { 
    3076                                         monster_level = p_ptr->depth + 11; 
    3077                                         place_monster(y, x, TRUE, TRUE); 
    3078                                         monster_level = p_ptr->depth; 
     3066                                        place_monster(y, x, p_ptr->depth + 11, TRUE, TRUE); 
    30793067                                        break; 
    30803068                                } 
     
    30833071                                case '9': 
    30843072                                { 
    3085                                         monster_level = p_ptr->depth + 9; 
    3086                                         place_monster(y, x, TRUE, TRUE); 
    3087                                         monster_level = p_ptr->depth; 
     3073                                        place_monster(y, x, p_ptr->depth + 9, TRUE, TRUE); 
    30883074                                        place_object(y, x, p_ptr->depth + 7, TRUE, FALSE); 
    30893075                                        break; 
     
    30933079                                case '8': 
    30943080                                { 
    3095                                         monster_level = p_ptr->depth + 40; 
    3096                                         place_monster(y, x, TRUE, TRUE); 
    3097                                         monster_level = p_ptr->depth; 
     3081                                        place_monster(y, x, p_ptr->depth + 40, TRUE, TRUE); 
    30983082                                        place_object(y, x, p_ptr->depth + 20, TRUE, TRUE); 
    30993083                                        break; 
     
    31053089                                        if (rand_int(100) < 50) 
    31063090                                        { 
    3107                                                 monster_level = p_ptr->depth + 3; 
    3108                                                 place_monster(y, x, TRUE, TRUE); 
    3109                                                 monster_level = p_ptr->depth; 
     3091                                                place_monster(y, x, p_ptr->depth + 3, TRUE, TRUE); 
    31103092                                        } 
    31113093                                        if (rand_int(100) < 50) 
     
    47504732        mon_restrict('\0', (byte)p_ptr->depth, &dummy, TRUE); 
    47514733 
    4752         /* Paranoia -- Reset the monster generation depth. */ 
    4753         monster_level = p_ptr->depth; 
    4754  
    47554734 
    47564735        /* Pick a base number of monsters */ 
     
    47614740        { 
    47624741                /* Place a random monster */ 
    4763                 (void)alloc_monster(0, TRUE); 
     4742                (void)alloc_monster(0, TRUE, p_ptr->depth); 
    47644743        } 
    47654744 
     
    50505029        { 
    50515030                /* Make a resident */ 
    5052                 (void)alloc_monster(3, TRUE); 
     5031                (void)alloc_monster(3, TRUE, p_ptr->depth); 
    50535032        } 
    50545033} 
     
    51125091                Term->offset_x = DUNGEON_WID; 
    51135092 
    5114  
    5115                 /* Reset the monster generation level */ 
    5116                 monster_level = p_ptr->depth; 
    51175093 
    51185094                /* Nothing special here yet */ 
  • trunk/src/monster2.c

    r448 r450  
    18861886 * Hack -- attempt to place a monster at the given location 
    18871887 * 
    1888  * Attempt to find a monster appropriate to the "monster_level" 
    1889  */ 
    1890 bool place_monster(int y, int x, bool slp, bool grp) 
     1888 * Attempt to find a monster appropriate to the given depth 
     1889 */ 
     1890bool place_monster(int y, int x, int depth, bool slp, bool grp) 
    18911891{ 
    18921892        int r_idx; 
    18931893 
    18941894        /* Pick a monster */ 
    1895         r_idx = get_mon_num(monster_level); 
     1895        r_idx = get_mon_num(depth); 
    18961896 
    18971897        /* Handle failure */ 
     
    19711971 * Use "slp" to choose the initial "sleep" status 
    19721972 * 
    1973  * Use "monster_level" for the monster level 
    1974  */ 
    1975 bool alloc_monster(int dis, bool slp
     1973 * Use "depth" for the monster level 
     1974 */ 
     1975bool alloc_monster(int dis, bool slp, int depth
    19761976{ 
    19771977        int py = p_ptr->py; 
     
    20062006 
    20072007        /* Attempt to place the monster, allow groups */ 
    2008         if (place_monster(y, x, slp, TRUE)) return (TRUE); 
     2008        if (place_monster(y, x, depth, slp, TRUE)) return (TRUE); 
    20092009 
    20102010        /* Nope */ 
  • trunk/src/variable.c

    r449 r450  
    7373 
    7474s16b num_repro;                 /* Current reproducer count */ 
    75 s16b monster_level;             /* Current monster creation level */ 
    7675 
    7776char summon_kin_type;           /* Hack -- See summon_specific() */