X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fgenerate.c;h=bf75742643ca985f836e89523ca64ffec07a61b9;hb=c4eca4127f6e4a89fb979b3381ca1b5562140237;hp=514bd52a7b35ed7f1ebf674a2ee5979bbafbd08d;hpb=ea1146cbb7a96df77b11fb7f0df1be8e151503ac;p=hengband%2Fhengband.git diff --git a/src/generate.c b/src/generate.c index 514bd52a7..bf7574264 100644 --- a/src/generate.c +++ b/src/generate.c @@ -469,7 +469,7 @@ static void try_door(int y, int x) /* Place quest monsters */ -void place_quest_monsters(void) +bool place_quest_monsters(void) { int i; @@ -479,7 +479,7 @@ void place_quest_monsters(void) monster_race *r_ptr; u32b mode; int j; - + if (quest[i].status != QUEST_STATUS_TAKEN || (quest[i].type != QUEST_TYPE_KILL_LEVEL && quest[i].type != QUEST_TYPE_RANDOM) || @@ -514,16 +514,24 @@ void place_quest_monsters(void) /* Find an empty grid */ for (l = SAFE_MAX_ATTEMPTS; l > 0; l--) { + cave_type *c_ptr; + feature_type *f_ptr; + y = randint0(cur_hgt); x = randint0(cur_wid); + c_ptr = &cave[y][x]; + f_ptr = &f_info[c_ptr->feat]; + + if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) continue; if (!monster_can_enter(y, x, r_ptr, 0)) continue; if (distance(y, x, py, px) < 10) continue; + if (c_ptr->info & CAVE_ICKY) continue; else break; } /* Failed to place */ - if (!l) break; + if (!l) return FALSE; /* Try to place the monster */ if (place_monster_aux(0, y, x, quest[i].r_idx, mode)) @@ -537,8 +545,13 @@ void place_quest_monsters(void) continue; } } + + /* Failed to place */ + if (k == SAFE_MAX_ATTEMPTS) return FALSE; } } + + return TRUE; } @@ -780,15 +793,17 @@ static bool cave_gen(void) build_maze_vault(cur_wid/2-1, cur_hgt/2-1, cur_wid-4, cur_hgt-4, FALSE); /* Place 3 or 4 down stairs near some walls */ - if (!alloc_stairs(FEAT_MORE, rand_range(2, 3), 3)) return FALSE; + if (!alloc_stairs(feat_down_stair, rand_range(2, 3), 3)) return FALSE; /* Place 1 or 2 up stairs near some walls */ - if (!alloc_stairs(FEAT_LESS, 1, 3)) return FALSE; + if (!alloc_stairs(feat_up_stair, 1, 3)) return FALSE; } /* Build some rooms */ else { + int tunnel_fail_count = 0; + /* * Build each type of room in turn until we cannot build any more. */ @@ -815,13 +830,13 @@ static bool cave_gen(void) /* Choose water or lava */ if ((randint1(MAX_DEPTH * 2) - 1 > dun_level) && (d_info[dungeon_type].flags1 & DF1_WATER_RIVER)) { - feat1 = FEAT_DEEP_WATER; - feat2 = FEAT_SHAL_WATER; + feat1 = feat_deep_water; + feat2 = feat_shallow_water; } else if (d_info[dungeon_type].flags1 & DF1_LAVA_RIVER) { - feat1 = FEAT_DEEP_LAVA; - feat2 = FEAT_SHAL_LAVA; + feat1 = feat_deep_lava; + feat2 = feat_shallow_lava; } else feat1 = 0; @@ -873,14 +888,16 @@ static bool cave_gen(void) if (randint1(dun_level) > d_info[dungeon_type].tunnel_percent) { /* make cave-like tunnel */ - build_tunnel2(dun->cent[i].x, dun->cent[i].y, x, y, 2, 2); + (void)build_tunnel2(dun->cent[i].x, dun->cent[i].y, x, y, 2, 2); } else { /* make normal tunnel */ - build_tunnel(dun->cent[i].y, dun->cent[i].x, y, x); + if (!build_tunnel(dun->cent[i].y, dun->cent[i].x, y, x)) tunnel_fail_count++; } + if (tunnel_fail_count >= 2) return FALSE; + /* Turn the tunnel into corridor */ for (j = 0; j < dun->tunn_n; j++) { @@ -951,10 +968,10 @@ static bool cave_gen(void) } /* Place 3 or 4 down stairs near some walls */ - if (!alloc_stairs(FEAT_MORE, rand_range(3, 4), 3)) return FALSE; + if (!alloc_stairs(feat_down_stair, rand_range(3, 4), 3)) return FALSE; /* Place 1 or 2 up stairs near some walls */ - if (!alloc_stairs(FEAT_LESS, rand_range(1, 2), 3)) return FALSE; + if (!alloc_stairs(feat_up_stair, rand_range(1, 2), 3)) return FALSE; } if (!dun->laketype) @@ -995,7 +1012,7 @@ static bool cave_gen(void) /* Determine the character location */ if (!new_player_spot()) return FALSE; - place_quest_monsters(); + if (!place_quest_monsters()) return FALSE; /* Basic "amount" */ k = (dun_level / 3); @@ -1058,7 +1075,7 @@ msg_format(" object_level = base_level; /* Put the Guardian */ - (void)alloc_guardian(); + if (!alloc_guardian(TRUE)) return FALSE; if (dun->empty_level && (!one_in_(DARK_EMPTY) || (randint1(100) > dun_level)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS)) { @@ -1165,14 +1182,23 @@ static void arena_gen(void) for (x = qx + 1; x < qx + SCREEN_WID - 1; x++) { /* Create empty floor */ - cave[y][x].feat = FEAT_FLOOR; + cave[y][x].feat = feat_floor; } } build_arena(); - place_monster_aux(0, py + 5, px, arena_info[p_ptr->arena_number].r_idx, - (PM_NO_KAGE | PM_NO_PET)); + if(!place_monster_aux(0, py + 5, px, arena_info[p_ptr->arena_number].r_idx, (PM_NO_KAGE | PM_NO_PET))) + { + p_ptr->exit_bldg = TRUE; + p_ptr->arena_number++; +#ifdef JP + msg_print("Áê¼ê¤Ï·ç¾ì¤·¤¿¡£¤¢¤Ê¤¿¤ÎÉÔÀᄀ¤À¡£"); +#else + msg_print("The enemy is unable appear. You won by default."); +#endif + } + } @@ -1226,9 +1252,15 @@ static void build_battle(void) place_extra_perm_bold(y_depth-4, x_right-18); cave[y_depth-4][x_right-18].info |= (CAVE_GLOW | CAVE_MARK); - i = y_height + 4; + for (i = y_height + 1; i <= y_height + 5; i++) + for (j = x_left + 20 + 2 * (y_height + 5 - i); j <= x_right - 20 - 2 * (y_height + 5 - i); j++) + { + cave[i][j].feat = feat_permanent_glass_wall; + } + + i = y_height + 1; j = xval; - cave[i][j].feat = FEAT_BLDG_HEAD + 3; + cave[i][j].feat = f_tag_to_index("BUILDING_3"); cave[i][j].info |= (CAVE_GLOW | CAVE_MARK); player_place(i, j); } @@ -1262,7 +1294,7 @@ static void battle_gen(void) for (x = qx + 1; x < qx + SCREEN_WID - 1; x++) { /* Create empty floor */ - cave[y][x].feat = FEAT_FLOOR; + cave[y][x].feat = feat_floor; } } @@ -1270,9 +1302,9 @@ static void battle_gen(void) for(i=0;i<4;i++) { - place_monster_aux(0, py + 5 + (i/2)*4, px - 2 + (i%2)*4, battle_mon[i], + place_monster_aux(0, py + 8 + (i/2)*4, px - 2 + (i%2)*4, battle_mon[i], (PM_NO_KAGE | PM_NO_PET)); - set_friendly(&m_list[cave[py+5+(i/2)*4][px-2+(i%2)*4].m_idx]); + set_friendly(&m_list[cave[py+8+(i/2)*4][px-2+(i%2)*4].m_idx]); } for(i = 1; i < m_max; i++) { @@ -1317,7 +1349,7 @@ static void quest_gen(void) /* Prepare allocation table */ get_mon_num_prep(get_monster_hook(), NULL); - init_flags = INIT_CREATE_DUNGEON | INIT_ASSIGN; + init_flags = INIT_CREATE_DUNGEON; process_dungeon_file("q_info.txt", 0, 0, MAX_HGT, MAX_WID); } @@ -1400,7 +1432,7 @@ static bool level_gen(cptr *why) /* * Wipe all unnecessary flags after cave generation */ -static void wipe_generate_cave_flags(void) +void wipe_generate_cave_flags(void) { int x, y; @@ -1445,6 +1477,7 @@ void clear_cave(void) C_WIPE(m_list, m_max, monster_type); m_max = 1; m_cnt = 0; + for (i = 0; i < MAX_MTIMED; i++) mproc_max[i] = 0; /* Pre-calc cur_num of pets in party_mon[] */ precalc_cur_num_of_pet();