* @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
* @return 適用したアーティファクト情報への参照ポインタ
*/
-std::unique_ptr<ArtifactType> apply_artifact(PlayerType *player_ptr, ObjectType *o_ptr)
+void apply_artifact(PlayerType *player_ptr, ObjectType *o_ptr)
{
- auto a_ptr = std::make_unique<ArtifactType>(a_info.at(o_ptr->fixed_artifact_idx));
- o_ptr->pval = a_ptr->pval;
- o_ptr->ac = a_ptr->ac;
- o_ptr->dd = a_ptr->dd;
- o_ptr->ds = a_ptr->ds;
- o_ptr->to_a = a_ptr->to_a;
- o_ptr->to_h = a_ptr->to_h;
- o_ptr->to_d = a_ptr->to_d;
- o_ptr->weight = a_ptr->weight;
- o_ptr->activation_id = a_ptr->act_idx;
-
- invest_curse_to_fixed_artifact(*a_ptr, o_ptr);
- fixed_artifact_random_abilities(player_ptr, *a_ptr, o_ptr);
-
- return a_ptr;
+ auto &a_ref = a_info.at(o_ptr->fixed_artifact_idx);
+ o_ptr->pval = a_ref.pval;
+ o_ptr->ac = a_ref.ac;
+ o_ptr->dd = a_ref.dd;
+ o_ptr->ds = a_ref.ds;
+ o_ptr->to_a = a_ref.to_a;
+ o_ptr->to_h = a_ref.to_h;
+ o_ptr->to_d = a_ref.to_d;
+ o_ptr->weight = a_ref.weight;
+ o_ptr->activation_id = a_ref.act_idx;
+
+ invest_curse_to_fixed_artifact(a_ref, o_ptr);
+ fixed_artifact_random_abilities(player_ptr, a_ref, o_ptr);
}
/*!
q_ptr->prep(i);
q_ptr->fixed_artifact_idx = a_idx;
- (void)apply_artifact(player_ptr, q_ptr);
+ apply_artifact(player_ptr, q_ptr);
return drop_near(player_ptr, q_ptr, -1, y, x) > 0;
}
*/
#include "system/angband.h"
-#include <memory>
enum class FixedArtifactId : short;
class ArtifactType;
class PlayerType;
bool create_named_art(PlayerType *player_ptr, FixedArtifactId a_idx, POSITION y, POSITION x);
bool make_artifact(PlayerType *player_ptr, ObjectType *o_ptr);
-std::unique_ptr<ArtifactType> apply_artifact(PlayerType *player_ptr, ObjectType *o_ptr);
+void apply_artifact(PlayerType *player_ptr, ObjectType *o_ptr);
bool make_artifact_special(PlayerType *player_ptr, ObjectType *o_ptr);
return false;
}
- auto a_ptr = apply_artifact(this->player_ptr, this->o_ptr);
- a_ptr->is_generated = true;
+ apply_artifact(this->player_ptr, this->o_ptr);
+ auto &a_ref = a_info.at(this->o_ptr->fixed_artifact_idx);
+ a_ref.is_generated = true;
if (w_ptr->character_dungeon) {
- a_ptr->floor_id = this->player_ptr->floor_id;
+ a_ref.floor_id = this->player_ptr->floor_id;
}
return true;
for (auto i = 0U; i < tmp16u; i++) {
const auto a_idx = i2enum<FixedArtifactId>(i);
const auto it = a_info.find(a_idx);
- const auto &a_ref = it != a_info.end() ? a_info.at(a_idx) : dummy;
+ const auto &a_ref = it != a_info.end() ? it->second : dummy;
wr_bool(a_ref.is_generated);
wr_s16b(a_ref.floor_id);
}