else
o_ptr->stack_idx = 0;
+ if ((flags & SAVE_ITEM_SMITH) && !loading_savefile_version_is_older_than(7)) {
+ int16_t tmp16s;
+ rd_s16b(&tmp16s);
+ if (tmp16s > 0) {
+ o_ptr->smith_effect = static_cast<SmithEffect>(tmp16s);
+ }
+ rd_s16b(&tmp16s);
+ if (tmp16s > 0) {
+ o_ptr->smith_act_idx = static_cast<random_art_activation_type>(tmp16s);
+ }
+ }
+
if (flags & SAVE_ITEM_INSCRIPTION) {
char buf[128];
rd_string(buf, sizeof(buf));
SAVE_ITEM_DS = 0x00000800,
SAVE_ITEM_IDENT = 0x00001000,
SAVE_ITEM_MARKED = 0x00002000,
- SAVE_ITEM_00004000 = 0x00004000, //<! 未使用
+ SAVE_ITEM_SMITH = 0x00004000,
SAVE_ITEM_00008000 = 0x00008000, //<! 未使用
SAVE_ITEM_00010000 = 0x00010000, //<! 未使用
SAVE_ITEM_00020000 = 0x00020000, //<! 未使用
*/
std::optional<SmithEffect> Smith::object_effect(const object_type *o_ptr)
{
- auto effect = i2enum<SmithEffect>(o_ptr->xtra3);
- if (!o_ptr->is_weapon_armour_ammo() || effect == SmithEffect::NONE) {
- return std::nullopt;
- }
-
- return effect;
+ return o_ptr->smith_effect;
}
/*!
bool BasicSmithInfo::add_essence(player_type *, object_type *o_ptr, int) const
{
- o_ptr->xtra3 = static_cast<decltype(o_ptr->xtra3)>(effect);
+ o_ptr->smith_effect = effect;
return true;
}
void BasicSmithInfo::erase_essence(object_type *o_ptr) const
{
- o_ptr->xtra3 = 0;
+ o_ptr->smith_effect = std::nullopt;
auto flgs = object_flags(o_ptr);
if (flgs.has_none_of(TR_PVAL_FLAG_MASK))
o_ptr->pval = 0;
-#pragma once
+#pragma once
#include "system/system-variables.h"
RESISTANCE = 220, //!< 全耐性
SLAY_GLOVE = 221, //!< 殺戮の小手
- SAVE_EFFECT_MAX = 256, //!< 鍛冶師の銘付きアイテムに付与された鍛冶効果の保存領域が1バイトなので、この値未満を割り当てる必要あり
+ SAVE_EFFECT_MAX = 8192, //!< 鍛冶師の銘付きアイテムに付与された鍛冶効果の保存領域は2バイト。とりあえず余裕を持って8192としておく。
//! @note これ以降は鍛冶師の銘付きアイテムになる鍛冶効果ではないので、効果番号を保存しなくてよい。
// 鍛冶効果のリストを管理するためだけのものである。したがって SAVE_EFFECT_MAX 以降に自動的に番号の割り振りを行う
#include "object/object-kind.h"
#include "save/save-util.h"
#include "system/object-type-definition.h"
+#include "util/enum-converter.h"
#include "util/quarks.h"
static void write_item_flags(object_type *o_ptr, BIT_FLAGS *flags)
if (o_ptr->stack_idx)
*flags |= SAVE_ITEM_STACK_IDX;
+ if (o_ptr->is_smith()) {
+ *flags |= SAVE_ITEM_SMITH;
+ }
+
wr_u32b(*flags);
}
if (flags & SAVE_ITEM_STACK_IDX)
wr_s16b(o_ptr->stack_idx);
+
+ if (flags & SAVE_ITEM_SMITH) {
+ if (o_ptr->smith_effect.has_value()){
+ wr_s16b(enum2i(o_ptr->smith_effect.value()));
+ } else {
+ wr_s16b(0);
+ }
+ if (o_ptr->smith_act_idx.has_value()) {
+ wr_s16b(enum2i(o_ptr->smith_act_idx.value()));
+ } else {
+ wr_s16b(0);
+ }
+ }
}
/*!
* @date 2021/05/02
*/
+#include "object-enchant/tr-flags.h"
#include "object-enchant/trc-types.h"
#include "object/tval-types.h"
#include "system/angband.h"
#include "system/system-variables.h"
#include "util/flag-group.h"
-#include "object-enchant/tr-flags.h"
+#include <optional>
+
+enum class SmithEffect;
+enum random_art_activation_type : uint8_t;
struct player_type;
typedef struct object_type {
XTRA8 xtra1{}; /*!< Extra info type (now unused) */
XTRA16 xtra2{}; /*!< エゴ/アーティファクトの発動ID / Extra info activation index */
- XTRA8 xtra3{}; /*!< 複数の使用用途 捕らえたモンスターの速度,付加した特殊なエッセンスID / Extra info for weaponsmith */
+ XTRA8 xtra3{}; /*!< 複数の使用用途 捕らえたモンスターの速度 / Extra info */
XTRA16 xtra4{}; /*!< 複数の使用用途 光源の残り寿命、あるいは捕らえたモンスターの現HP / Extra info fuel or captured monster's current HP */
XTRA16 xtra5{}; /*!< 複数の使用用途 捕らえたモンスターの最大HP / Extra info captured monster's max HP */
+ std::optional<SmithEffect> smith_effect; //!< 鍛冶で付与された効果
+ std::optional<random_art_activation_type> smith_act_idx; //!< 鍛冶で付与された発動効果のID
+
HIT_PROB to_h{}; /*!< Plusses to hit */
HIT_POINT to_d{}; /*!< Plusses to damage */
ARMOUR_CLASS to_a{}; /*!< Plusses to AC */