#include "wizard/spoiler-util.h"
/*!
- * @brief アーティファクトの特性一覧を出力する /
- * Write a line to the spoiler file and then "underline" it with hypens
- * @param art_flags アーティファクトのフラグ群
- * @param flag_ptr フラグ記述情報の参照ポインタ
- * @param desc_ptr 記述内容を返すための文字列参照ポインタ
- * @param n_elmnts フラグの要素数
- * @return desc_ptrと同じアドレス
- * @details
- * <pre>
- * This function does most of the actual "analysis". Given a set of bit flags
- * (which will be from one of the flags fields from the object in question),
- * a "flag description structure", a "description list", and the number of
- * elements in the "flag description structure", this function sets the
- * "description list" members to the appropriate descriptions contained in
- * the "flag description structure".
- * The possibly updated description pointer is returned.
- * </pre>
- */
-static concptr *spoiler_flag_aux(const TrFlags &art_flags, const flag_desc *flag_ptr, concptr *desc_ptr, const int n_elmnts)
-{
- for (int i = 0; i < n_elmnts; ++i) {
- if (art_flags.has(flag_ptr[i].flag)) {
- *desc_ptr++ = flag_ptr[i].desc;
- }
- }
-
- return desc_ptr;
-}
-
-/*!
* @brief アイテムの特定記述内容を返す /
* Acquire a "basic" description "The Cloak of Death [1,+10]"
* @param o_ptr 記述を得たいオブジェクトの参照ポインタ
* @param o_ptr オブジェクト構造体の参照ポインタ
* @param immune_list 免疫構造体の参照ポインタ
*/
-static void analyze_immune(ItemEntity *o_ptr, concptr *immune_list)
+static std::vector<std::string> analyze_immune(ItemEntity *o_ptr)
{
auto flags = object_flags(o_ptr);
- immune_list = spoiler_flag_aux(flags, immune_flags_desc, immune_list, N_ELEMENTS(immune_flags_desc));
- *immune_list = nullptr;
+ return extract_spoiler_flags(flags, immune_flags_desc);
}
/*!
desc_ptr->pval_info.analyze(*o_ptr);
desc_ptr->brands = analyze_brand(o_ptr);
desc_ptr->slays = analyze_slay(o_ptr);
- analyze_immune(o_ptr, desc_ptr->immunities);
+ desc_ptr->immunities = analyze_immune(o_ptr);
desc_ptr->resistances = analyze_resist(o_ptr);
desc_ptr->vulnerabilities = analyze_vulnerable(o_ptr);
desc_ptr->sustenances = analyze_sustains(o_ptr);
desc_ptr->pval_info.analyze(*o_ptr);
desc_ptr->brands = analyze_brand(o_ptr);
desc_ptr->slays = analyze_slay(o_ptr);
- analyze_immune(o_ptr, desc_ptr->immunities);
+ desc_ptr->immunities = analyze_immune(o_ptr);
desc_ptr->resistances = analyze_resist(o_ptr);
desc_ptr->vulnerabilities = analyze_vulnerable(o_ptr);
desc_ptr->sustenances = analyze_sustains(o_ptr);
}
/*!
- * @brief フラグ名称を出力する汎用関数
- * @param header ヘッダに出力するフラグ群の名前
- * @param list フラグ名リスト
- * @param separator フラグ表示の区切り記号
- * @todo 固定アーティファクトとランダムアーティファクトで共用、ここに置くべきかは要調整.
- * @todo いずれ上で定義したオーバーロードに吸収合併させてこれは消滅させる予定
- */
-void spoiler_outlist(concptr header, concptr *list, char separator)
-{
- if (*list == nullptr) {
- return;
- }
-
- std::string line = spoiler_indent;
- if (header && (header[0])) {
- line.append(header).append(" ");
- }
-
- while (true) {
- std::string elem = *list;
- if (list[1]) {
- elem.push_back(separator);
- elem.push_back(' ');
- }
-
- if (line.length() + elem.length() <= MAX_LINE_LEN) {
- line.append(elem);
- } else {
- if (line.length() > 1 && line[line.length() - 1] == ' ' && line[line.length() - 2] == list_separator) {
- line[line.length() - 2] = '\0';
- fprintf(spoiler_file, "%s\n", line.data());
- line = spoiler_indent;
- line.append(elem);
- } else {
- fprintf(spoiler_file, "%s\n", line.data());
- line = " ";
- line.append(elem);
- }
- }
-
- if (!*++list) {
- break;
- }
- }
-
- fprintf(spoiler_file, "%s\n", line.data());
-}
-
-/*!
* @brief アーティファクト情報を出力するためにダミー生成を行う /
* Hack -- Create a "forged" artifact
* @param o_ptr 一時生成先を保管するオブジェクト構造体
#include "wizard/spoiler-util.h"
void spoiler_outlist(std::string_view header, const std::vector<std::string> &descriptions, char seperator);
-void spoiler_outlist(concptr header, concptr *list, char separator);
SpoilerOutputResultType spoil_fixed_artifact(concptr fname);
};
/* Elemental immunities (along with poison) */
-const flag_desc immune_flags_desc[MAX_IMMUNITY_FLAGS_DESCRIPTION] = {
+const std::vector<flag_desc> immune_flags_desc = {
{ TR_IM_ACID, _("酸", "Acid") },
{ TR_IM_ELEC, _("電撃", "Lightning") },
{ TR_IM_FIRE, _("火炎", "Fire") },
#include "system/angband.h"
#include <vector>
-#define MAX_IMMUNITY_FLAGS_DESCRIPTION 4
-
/* A tval grouper */
struct grouper {
std::vector<ItemKindType> tval_set;
extern const std::vector<flag_desc> brand_flags_desc;
extern const std::vector<flag_desc> resist_flags_desc;
extern const std::vector<flag_desc> vulnerable_flags_desc;
-extern const flag_desc immune_flags_desc[MAX_IMMUNITY_FLAGS_DESCRIPTION];
+extern const std::vector<flag_desc> immune_flags_desc;
extern const std::vector<flag_desc> sustain_flags_desc;
extern const std::vector<flag_desc> misc_flags2_desc;
extern const std::vector<flag_desc> misc_flags3_desc;
/* MAX_LINE_LEN specifies when a line should wrap. */
#define MAX_LINE_LEN 75
-/* Given an array, determine how many elements are in the array */
-#define N_ELEMENTS(a) (sizeof(a) / sizeof((a)[0]))
-
enum class SpoilerOutputResultType {
CANCELED,
SUCCESSFUL,
ParameterValueInfo pval_info{}; /* Description of what is affected by an object's pval */
std::vector<std::string> slays{}; /* A list of an object's slaying preferences */
std::vector<std::string> brands{}; /* A list if an object's elemental brands */
- concptr immunities[N_ELEMENTS(immune_flags_desc) + 1]{}; /* A list of immunities granted by an object */
+ std::vector<std::string> immunities{}; /* A list of immunities granted by an object */
std::vector<std::string> resistances{}; /* A list of resistances granted by an object */
std::vector<std::string> vulnerabilities{}; /* A list of resistances granted by an object */
std::vector<std::string> sustenances{}; /* A list of stats sustained by an object */