From 94cd25657bfec8821989cfa607199269b0b8fb3a Mon Sep 17 00:00:00 2001 From: Deskull Date: Thu, 3 Jan 2019 09:03:46 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#37353=20=E5=9E=8B=E3=81=AE?= =?utf8?q?=E7=BD=AE=E6=8F=9B=E3=80=82=20/=20Type=20replacement.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/birth.c | 3 +- src/cmd-spell.c | 4 - src/cmd5.c | 18 +-- src/rooms-city.c | 14 +- src/rooms-normal.c | 372 ++++++++++++++++++++++++++--------------------------- 5 files changed, 205 insertions(+), 206 deletions(-) diff --git a/src/birth.c b/src/birth.c index 5b01a9277..3e73a20e7 100644 --- a/src/birth.c +++ b/src/birth.c @@ -2847,7 +2847,8 @@ static bool get_player_class(void) */ static bool get_player_seikaku(void) { - int k, n, os, cs; + CHARACATER_IDX k; + int n, os, cs; char c; char sym[MAX_SEIKAKU]; char p2 = ')'; diff --git a/src/cmd-spell.c b/src/cmd-spell.c index 9b8f06589..7eb5eacad 100644 --- a/src/cmd-spell.c +++ b/src/cmd-spell.c @@ -178,10 +178,6 @@ cptr info_weight(WEIGHT weight) #endif } - - - - /*! * @brief 魔法処理のメインルーチン * @param realm 魔法領域のID diff --git a/src/cmd5.c b/src/cmd5.c index 92a0a113e..7f37b26da 100644 --- a/src/cmd5.c +++ b/src/cmd5.c @@ -52,17 +52,17 @@ cptr spell_category_name(OBJECT_TYPE_VALUE tval) */ static int get_spell(SPELL_IDX *sn, cptr prompt, OBJECT_SUBTYPE_VALUE sval, bool learned, REALM_IDX use_realm) { - int i; + int i; SPELL_IDX spell = -1; - int num = 0; - int ask = TRUE; - MANA_POINT need_mana; - SPELL_IDX spells[64]; - bool flag, redraw, okay; - char choice; + int num = 0; + int ask = TRUE; + MANA_POINT need_mana; + SPELL_IDX spells[64]; + bool flag, redraw, okay; + char choice; const magic_type *s_ptr; - char out_val[160]; - cptr p; + char out_val[160]; + cptr p; COMMAND_CODE code; #ifdef JP char jverb_buf[128]; diff --git a/src/rooms-city.c b/src/rooms-city.c index df6ff39bf..a55ae5689 100644 --- a/src/rooms-city.c +++ b/src/rooms-city.c @@ -12,9 +12,10 @@ */ static bool precalc_ugarcade(int town_hgt, int town_wid, int n) { - int i, y, x, center_y, center_x, tmp, attempt = 10000; - int max_bldg_hgt = 3 * town_hgt / MAX_TOWN_HGT; - int max_bldg_wid = 5 * town_wid / MAX_TOWN_WID; + POSITION i, y, x, center_y, center_x; + int tmp, attempt = 10000; + POSITION max_bldg_hgt = 3 * town_hgt / MAX_TOWN_HGT; + POSITION max_bldg_wid = 5 * town_wid / MAX_TOWN_WID; ugbldg_type *cur_ugbldg; bool **ugarcade_used, abort; @@ -97,10 +98,11 @@ static bool precalc_ugarcade(int town_hgt, int town_wid, int n) * @note * Note: ltcy and ltcx indicate "left top corner". */ -static void build_stores(int ltcy, int ltcx, int stores[], int n) +static void build_stores(POSITION ltcy, POSITION ltcx, int stores[], int n) { - int i, y, x; - IDX j; + int i; + POSITION y, x; + FEAT_IDX j; ugbldg_type *cur_ugbldg; for (i = 0; i < n; i++) diff --git a/src/rooms-normal.c b/src/rooms-normal.c index 31d08de91..bef9b5a18 100644 --- a/src/rooms-normal.c +++ b/src/rooms-normal.c @@ -329,8 +329,8 @@ bool build_type3(void) POSITION y1a, x1a, y2a, x2a; POSITION y1b, x1b, y2b, x2b; POSITION yval, xval; - bool light; - cave_type *c_ptr; + bool light; + cave_type *c_ptr; /* Find and reserve some space in the dungeon. Get center of room. */ @@ -584,8 +584,8 @@ bool build_type4(void) { POSITION y, x, y1, x1; POSITION y2, x2, tmp, yval, xval; - bool light; - cave_type *c_ptr; + bool light; + cave_type *c_ptr; /* Find and reserve some space in the dungeon. Get center of room. */ @@ -655,243 +655,243 @@ bool build_type4(void) /* Inner room variations */ switch (randint1(5)) { - /* Just an inner room with a monster */ - case 1: - { - /* Place a secret door */ - switch (randint1(4)) + /* Just an inner room with a monster */ + case 1: { - case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break; - case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break; - case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break; - case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break; - } - - /* Place a monster in the room */ - vault_monsters(yval, xval, 1); + /* Place a secret door */ + switch (randint1(4)) + { + case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break; + case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break; + case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break; + case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break; + } - break; - } + /* Place a monster in the room */ + vault_monsters(yval, xval, 1); - /* Treasure Vault (with a door) */ - case 2: - { - /* Place a secret door */ - switch (randint1(4)) - { - case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break; - case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break; - case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break; - case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break; + break; } - /* Place another inner room */ - for (y = yval - 1; y <= yval + 1; y++) + /* Treasure Vault (with a door) */ + case 2: { - for (x = xval - 1; x <= xval + 1; x++) + /* Place a secret door */ + switch (randint1(4)) { - if ((x == xval) && (y == yval)) continue; - c_ptr = &cave[y][x]; - place_inner_grid(c_ptr); + case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break; + case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break; + case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break; + case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break; } - } - /* Place a locked door on the inner room */ - switch (randint1(4)) - { - case 1: place_locked_door(yval - 1, xval); break; - case 2: place_locked_door(yval + 1, xval); break; - case 3: place_locked_door(yval, xval - 1); break; - case 4: place_locked_door(yval, xval + 1); break; - } + /* Place another inner room */ + for (y = yval - 1; y <= yval + 1; y++) + { + for (x = xval - 1; x <= xval + 1; x++) + { + if ((x == xval) && (y == yval)) continue; + c_ptr = &cave[y][x]; + place_inner_grid(c_ptr); + } + } - /* Monsters to guard the "treasure" */ - vault_monsters(yval, xval, randint1(3) + 2); + /* Place a locked door on the inner room */ + switch (randint1(4)) + { + case 1: place_locked_door(yval - 1, xval); break; + case 2: place_locked_door(yval + 1, xval); break; + case 3: place_locked_door(yval, xval - 1); break; + case 4: place_locked_door(yval, xval + 1); break; + } - /* Object (80%) */ - if (randint0(100) < 80) - { - place_object(yval, xval, 0L); - } + /* Monsters to guard the "treasure" */ + vault_monsters(yval, xval, randint1(3) + 2); - /* Stairs (20%) */ - else - { - place_random_stairs(yval, xval); - } + /* Object (80%) */ + if (randint0(100) < 80) + { + place_object(yval, xval, 0L); + } - /* Traps to protect the treasure */ - vault_traps(yval, xval, 4, 10, 2 + randint1(3)); + /* Stairs (20%) */ + else + { + place_random_stairs(yval, xval); + } - break; - } + /* Traps to protect the treasure */ + vault_traps(yval, xval, 4, 10, 2 + randint1(3)); - /* Inner pillar(s). */ - case 3: - { - /* Place a secret door */ - switch (randint1(4)) - { - case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break; - case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break; - case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break; - case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break; + break; } - /* Large Inner Pillar */ - for (y = yval - 1; y <= yval + 1; y++) + /* Inner pillar(s). */ + case 3: { - for (x = xval - 1; x <= xval + 1; x++) + /* Place a secret door */ + switch (randint1(4)) { - c_ptr = &cave[y][x]; - place_inner_grid(c_ptr); + case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break; + case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break; + case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break; + case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break; } - } - /* Occasionally, two more Large Inner Pillars */ - if (one_in_(2)) - { - tmp = randint1(2); + /* Large Inner Pillar */ for (y = yval - 1; y <= yval + 1; y++) { - for (x = xval - 5 - tmp; x <= xval - 3 - tmp; x++) + for (x = xval - 1; x <= xval + 1; x++) { c_ptr = &cave[y][x]; place_inner_grid(c_ptr); } - for (x = xval + 3 + tmp; x <= xval + 5 + tmp; x++) + } + + /* Occasionally, two more Large Inner Pillars */ + if (one_in_(2)) + { + tmp = randint1(2); + for (y = yval - 1; y <= yval + 1; y++) { - c_ptr = &cave[y][x]; - place_inner_grid(c_ptr); + for (x = xval - 5 - tmp; x <= xval - 3 - tmp; x++) + { + c_ptr = &cave[y][x]; + place_inner_grid(c_ptr); + } + for (x = xval + 3 + tmp; x <= xval + 5 + tmp; x++) + { + c_ptr = &cave[y][x]; + place_inner_grid(c_ptr); + } } } - } - - /* Occasionally, some Inner rooms */ - if (one_in_(3)) - { - int door_type = ((d_info[dungeon_type].flags1 & DF1_CURTAIN) && - one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN : - ((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR); - /* Long horizontal walls */ - for (x = xval - 5; x <= xval + 5; x++) + /* Occasionally, some Inner rooms */ + if (one_in_(3)) { - c_ptr = &cave[yval - 1][x]; + int door_type = ((d_info[dungeon_type].flags1 & DF1_CURTAIN) && + one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN : + ((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR); + + /* Long horizontal walls */ + for (x = xval - 5; x <= xval + 5; x++) + { + c_ptr = &cave[yval - 1][x]; + place_inner_grid(c_ptr); + c_ptr = &cave[yval + 1][x]; + place_inner_grid(c_ptr); + } + + /* Close off the left/right edges */ + c_ptr = &cave[yval][xval - 5]; place_inner_grid(c_ptr); - c_ptr = &cave[yval + 1][x]; + c_ptr = &cave[yval][xval + 5]; place_inner_grid(c_ptr); - } - /* Close off the left/right edges */ - c_ptr = &cave[yval][xval - 5]; - place_inner_grid(c_ptr); - c_ptr = &cave[yval][xval + 5]; - place_inner_grid(c_ptr); + /* Secret doors (random top/bottom) */ + place_secret_door(yval - 3 + (randint1(2) * 2), xval - 3, door_type); + place_secret_door(yval - 3 + (randint1(2) * 2), xval + 3, door_type); - /* Secret doors (random top/bottom) */ - place_secret_door(yval - 3 + (randint1(2) * 2), xval - 3, door_type); - place_secret_door(yval - 3 + (randint1(2) * 2), xval + 3, door_type); + /* Monsters */ + vault_monsters(yval, xval - 2, randint1(2)); + vault_monsters(yval, xval + 2, randint1(2)); - /* Monsters */ - vault_monsters(yval, xval - 2, randint1(2)); - vault_monsters(yval, xval + 2, randint1(2)); + /* Objects */ + if (one_in_(3)) place_object(yval, xval - 2, 0L); + if (one_in_(3)) place_object(yval, xval + 2, 0L); + } - /* Objects */ - if (one_in_(3)) place_object(yval, xval - 2, 0L); - if (one_in_(3)) place_object(yval, xval + 2, 0L); + break; } - break; - } - - /* Maze inside. */ - case 4: - { - /* Place a secret door */ - switch (randint1(4)) + /* Maze inside. */ + case 4: { - case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break; - case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break; - case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break; - case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break; - } + /* Place a secret door */ + switch (randint1(4)) + { + case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break; + case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break; + case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break; + case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break; + } - /* Maze (really a checkerboard) */ - for (y = y1; y <= y2; y++) - { - for (x = x1; x <= x2; x++) + /* Maze (really a checkerboard) */ + for (y = y1; y <= y2; y++) { - if (0x1 & (x + y)) + for (x = x1; x <= x2; x++) { - c_ptr = &cave[y][x]; - place_inner_grid(c_ptr); + if (0x1 & (x + y)) + { + c_ptr = &cave[y][x]; + place_inner_grid(c_ptr); + } } } - } - - /* Monsters just love mazes. */ - vault_monsters(yval, xval - 5, randint1(3)); - vault_monsters(yval, xval + 5, randint1(3)); - /* Traps make them entertaining. */ - vault_traps(yval, xval - 3, 2, 8, randint1(3)); - vault_traps(yval, xval + 3, 2, 8, randint1(3)); + /* Monsters just love mazes. */ + vault_monsters(yval, xval - 5, randint1(3)); + vault_monsters(yval, xval + 5, randint1(3)); - /* Mazes should have some treasure too. */ - vault_objects(yval, xval, 3); + /* Traps make them entertaining. */ + vault_traps(yval, xval - 3, 2, 8, randint1(3)); + vault_traps(yval, xval + 3, 2, 8, randint1(3)); - break; - } - - /* Four small rooms. */ - case 5: - { - int door_type = ((d_info[dungeon_type].flags1 & DF1_CURTAIN) && - one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN : - ((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR); + /* Mazes should have some treasure too. */ + vault_objects(yval, xval, 3); - /* Inner "cross" */ - for (y = y1; y <= y2; y++) - { - c_ptr = &cave[y][xval]; - place_inner_grid(c_ptr); - } - for (x = x1; x <= x2; x++) - { - c_ptr = &cave[yval][x]; - place_inner_grid(c_ptr); + break; } - /* Doors into the rooms */ - if (randint0(100) < 50) - { - int i = randint1(10); - place_secret_door(y1 - 1, xval - i, door_type); - place_secret_door(y1 - 1, xval + i, door_type); - place_secret_door(y2 + 1, xval - i, door_type); - place_secret_door(y2 + 1, xval + i, door_type); - } - else + /* Four small rooms. */ + case 5: { - int i = randint1(3); - place_secret_door(yval + i, x1 - 1, door_type); - place_secret_door(yval - i, x1 - 1, door_type); - place_secret_door(yval + i, x2 + 1, door_type); - place_secret_door(yval - i, x2 + 1, door_type); - } + int door_type = ((d_info[dungeon_type].flags1 & DF1_CURTAIN) && + one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN : + ((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR); + + /* Inner "cross" */ + for (y = y1; y <= y2; y++) + { + c_ptr = &cave[y][xval]; + place_inner_grid(c_ptr); + } + for (x = x1; x <= x2; x++) + { + c_ptr = &cave[yval][x]; + place_inner_grid(c_ptr); + } + + /* Doors into the rooms */ + if (randint0(100) < 50) + { + int i = randint1(10); + place_secret_door(y1 - 1, xval - i, door_type); + place_secret_door(y1 - 1, xval + i, door_type); + place_secret_door(y2 + 1, xval - i, door_type); + place_secret_door(y2 + 1, xval + i, door_type); + } + else + { + int i = randint1(3); + place_secret_door(yval + i, x1 - 1, door_type); + place_secret_door(yval - i, x1 - 1, door_type); + place_secret_door(yval + i, x2 + 1, door_type); + place_secret_door(yval - i, x2 + 1, door_type); + } - /* Treasure, centered at the center of the cross */ - vault_objects(yval, xval, 2 + randint1(2)); + /* Treasure, centered at the center of the cross */ + vault_objects(yval, xval, 2 + randint1(2)); - /* Gotta have some monsters. */ - vault_monsters(yval + 1, xval - 4, randint1(4)); - vault_monsters(yval + 1, xval + 4, randint1(4)); - vault_monsters(yval - 1, xval - 4, randint1(4)); - vault_monsters(yval - 1, xval + 4, randint1(4)); + /* Gotta have some monsters. */ + vault_monsters(yval + 1, xval - 4, randint1(4)); + vault_monsters(yval + 1, xval + 4, randint1(4)); + vault_monsters(yval - 1, xval - 4, randint1(4)); + vault_monsters(yval - 1, xval + 4, randint1(4)); - break; - } + break; + } } return TRUE; @@ -961,7 +961,7 @@ bool build_type12(void) bool emptyflag = TRUE; /* Make a random metric */ - int h1, h2, h3, h4; + POSITION h1, h2, h3, h4; h1 = randint1(32) - 16; h2 = randint1(16); h3 = randint1(32); -- 2.11.0