Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

変愚「misc.txt を廃止した」のマージ #4266

Merged
merged 3 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/edit/WildernessDefinition.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

# Road Flags: Sum of NORTH 1, SOUTH 2, EAST 4, WEST 8

# Maximum width
M:WX:99

# Maximum height
M:WY:66

?:[EQU $WILDERNESS NORMAL]

# Edge of the world
Expand Down
34 changes: 0 additions & 34 deletions lib/edit/misc.txt

This file was deleted.

30 changes: 2 additions & 28 deletions src/floor/fixed-map-generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,33 +389,6 @@ static bool parse_qtw_P(PlayerType *player_ptr, qtwg_type *qtwg_ptr, char **zz)
return true;
}

static bool parse_qtw_M(qtwg_type *qtwg_ptr, char **zz)
{
if (qtwg_ptr->buf[0] != 'M') {
return false;
}

if ((tokenize(qtwg_ptr->buf + 2, 2, zz, 0) == 2) == 0) {
return true;
}

if (zz[0][0] == 'O') {
w_ptr->max_o_idx = (OBJECT_IDX)atoi(zz[1]);
} else if (zz[0][0] == 'M') {
w_ptr->max_m_idx = (MONSTER_IDX)atoi(zz[1]);
} else if (zz[0][0] == 'W') {
if (zz[0][1] == 'X') {
w_ptr->max_wild_x = (POSITION)atoi(zz[1]);
}

if (zz[0][1] == 'Y') {
w_ptr->max_wild_y = (POSITION)atoi(zz[1]);
}
}

return true;
}

/*!
* @brief 固定マップ (クエスト&街&広域マップ)をフロアに生成する
* Parse a sub-file of the "extra info"
Expand Down Expand Up @@ -494,7 +467,8 @@ parse_error_type generate_fixed_map_floor(PlayerType *player_ptr, qtwg_type *qtw
return parse_line_alliance(player_ptr->current_floor_ptr, qtwg_ptr->buf);
}

if (parse_qtw_M(qtwg_ptr, zz)) {
if (qtwg_ptr->buf[0] == 'M') {
// skip
return PARSE_ERROR_NONE;
}

Expand Down
20 changes: 6 additions & 14 deletions src/floor/wild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
constexpr auto MAX_FEAT_IN_TERRAIN = 18;

std::vector<std::vector<wilderness_type>> wilderness;
bool generate_encounter;
static bool generate_encounter;

struct border_type {
int16_t north[MAX_WID];
Expand Down Expand Up @@ -816,19 +816,6 @@ void seed_wilderness(void)
}
}

/*!
* @brief ゲーム開始時の荒野初期化メインルーチン /
* Initialize wilderness array
* @return エラーコード
*/
errr init_wilderness(void)
{
wilderness.assign(w_ptr->max_wild_y, std::vector<wilderness_type>(w_ptr->max_wild_x));

generate_encounter = false;
return 0;
}

/*!
* @brief 荒野の地勢設定を初期化する /
* Initialize wilderness array
Expand Down Expand Up @@ -896,6 +883,11 @@ void init_wilderness_terrains(void)
MAX_FEAT_IN_TERRAIN - 8);
}

void init_wilderness_encounter()
{
generate_encounter = false;
}

/*!
* @brief 荒野から広域マップへの切り替え処理 /
* Initialize arrays for wilderness terrains
Expand Down
4 changes: 2 additions & 2 deletions src/floor/wild.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class PlayerType;
void set_floor_and_wall(DUNGEON_IDX type);
void wilderness_gen(PlayerType *player_ptr);
void wilderness_gen_small(PlayerType *player_ptr);
errr init_wilderness(void);
void init_wilderness_terrains(void);
void init_wilderness_terrains();
void init_wilderness_encounter();
void seed_wilderness(void);
parse_error_type parse_line_wilderness(PlayerType *player_ptr, char *buf, int xmin, int xmax, int *y, int *x);
bool change_wild_mode(PlayerType *player_ptr, bool encount);
7 changes: 1 addition & 6 deletions src/main/angband-initializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,6 @@ void init_angband(PlayerType *player_ptr, bool no_term)

void (*init_note)(concptr) = (no_term ? init_note_no_term : init_note_term);

init_note(_("[変数を初期化しています...(その他)", "[Initializing values... (misc)]"));
if (init_misc(player_ptr)) {
quit(_("その他の変数を初期化できません", "Cannot initialize misc. values"));
}

init_note(_("[データの初期化中... (地形)]", "[Initializing arrays... (features)]"));
if (init_terrains_info()) {
quit(_("地形初期化不能", "Cannot initialize features"));
Expand Down Expand Up @@ -281,7 +276,7 @@ void init_angband(PlayerType *player_ptr, bool no_term)
}

init_note(_("[配列を初期化しています... (荒野)]", "[Initializing arrays... (wilderness)]"));
if (init_wilderness()) {
if (!init_wilderness()) {
quit(_("荒野を初期化できません", "Cannot initialize wilderness"));
}

Expand Down
58 changes: 52 additions & 6 deletions src/main/info-initializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

#include "main/info-initializer.h"
#include "floor/wild.h"
#include "grid/feature.h"
#include "info-reader/artifact-reader.h"
#include "info-reader/baseitem-reader.h"
Expand Down Expand Up @@ -33,13 +34,17 @@
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
#include "util/angband-files.h"
#include "util/string-processor.h"
#include "view/display-messages.h"
#include "world/world.h"
#include <fstream>
#include <string>
#include <string_view>
#include <sys/stat.h>

#ifndef WINDOWS
#include <sys/types.h>
#endif
#include <string_view>

namespace {

Expand Down Expand Up @@ -228,12 +233,53 @@ errr init_vaults_info()
return init_info("VaultDefinitions.txt", vaults_header, vaults_info, parse_vaults_info);
}

static bool read_wilderness_definition(std::ifstream &ifs)
{
std::string line;
while (!ifs.eof()) {
if (!std::getline(ifs, line)) {
return false;
}

if (line.empty() || line.starts_with('#')) {
continue;
}

const auto &splits = str_split(line, ':');
if ((splits.size() != 3) || (splits[0] != "M")) {
continue;
}

if (splits[1] == "WX") {
w_ptr->max_wild_x = std::stoi(splits[2]);
} else if (splits[1] == "WY") {
w_ptr->max_wild_y = std::stoi(splits[2]);
} else {
return false;
}

if ((w_ptr->max_wild_x > 0) && (w_ptr->max_wild_y > 0)) {
wilderness.assign(w_ptr->max_wild_y, std::vector<wilderness_type>(w_ptr->max_wild_x));
init_wilderness_encounter();
return true;
}
}

return false;
}

/*!
* @brief 基本情報読み込みのメインルーチン
* @param player_ptr プレイヤーへの参照ポインタ
* @return エラーコード
* @brief 荒野情報読み込み処理
* @return 読み込みに成功したか
*/
errr init_misc(PlayerType *player_ptr)
bool init_wilderness()
{
return parse_fixed_map(player_ptr, "misc.txt", 0, 0, 0, 0);
char path[1024]{};
path_build(path, sizeof(path), ANGBAND_DIR_EDIT, WILDERNESS_DEFINITION);
std::ifstream ifs(path);
if (!ifs) {
return false;
}

return read_wilderness_definition(ifs);
}
2 changes: 1 addition & 1 deletion src/main/info-initializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ errr init_egos_info();
errr init_monster_race_definitions();
errr init_terrains_info();
errr init_vaults_info();
errr init_misc(PlayerType *player_ptr);
bool init_wilderness();
4 changes: 2 additions & 2 deletions src/world/world.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ struct world_type {

bool wizard{}; /* This world under wizard mode */

OBJECT_IDX max_o_idx{}; /*!< Maximum number of objects in the level */
MONSTER_IDX max_m_idx{}; /*!< Maximum number of monsters in the level */
OBJECT_IDX max_o_idx = 1024; /*!< 1フロアに存在可能な最大アイテム数 */
MONSTER_IDX max_m_idx = 1024; /*!< 1フロアに存在可能な最大モンスター数 */
};

extern world_type *w_ptr;
Expand Down
Loading