From b15461dbcedf27f28a843f700ce0473d57364230 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:14 +0200 Subject: Remove redundant checks "around" artifact_p() Turns out artifact_p() already performs the necessary checks. --- src/cave.cc | 5 ++++- src/cmd2.cc | 3 +-- src/cmd3.cc | 2 +- src/cmd6.cc | 6 +++--- src/melee1.cc | 2 +- src/melee2.cc | 3 +-- src/object1.cc | 6 +++--- src/object2.cc | 6 +++--- src/spells1.cc | 6 +++--- src/spells2.cc | 6 +++--- src/wizard2.cc | 2 +- 11 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/cave.cc b/src/cave.cc index 956088e0..e460ddc8 100644 --- a/src/cave.cc +++ b/src/cave.cc @@ -384,7 +384,10 @@ bool_ cave_valid_bold(int y, int x) object_type *o_ptr = &o_list[o_idx]; /* Forbid artifact grids */ - if ((o_ptr->art_name) || artifact_p(o_ptr)) return (FALSE); + if (artifact_p(o_ptr)) + { + return (FALSE); + } } /* Accept */ diff --git a/src/cmd2.cc b/src/cmd2.cc index a67f1fda..b0c9e38e 100644 --- a/src/cmd2.cc +++ b/src/cmd2.cc @@ -4166,8 +4166,7 @@ void do_cmd_boomerang(void) j = (hit_body ? breakage_chance(o_ptr) : 0); /* Break the boomerang */ - if (!(o_ptr->art_name || artifact_p(o_ptr)) && - (rand_int(100) < j)) + if ((!artifact_p(o_ptr)) && (rand_int(100) < j)) { msg_print(format("Your %s is destroyed.", o_name)); inc_stack_size_ex(INVEN_BOW, -1, OPTIMIZE, NO_DESCRIBE); diff --git a/src/cmd3.cc b/src/cmd3.cc index fd97c8b3..b6f8de28 100644 --- a/src/cmd3.cc +++ b/src/cmd3.cc @@ -623,7 +623,7 @@ void do_cmd_destroy(void) /* Artifacts cannot be destroyed */ - if (artifact_p(o_ptr) || o_ptr->art_name) + if (artifact_p(o_ptr)) { byte feel = SENSE_SPECIAL; diff --git a/src/cmd6.cc b/src/cmd6.cc index 9c71584b..4bcade91 100644 --- a/src/cmd6.cc +++ b/src/cmd6.cc @@ -2739,7 +2739,7 @@ bool_ curse_armor(void) object_desc(o_name, o_ptr, FALSE, 3); /* Attempt a saving throw for artifacts */ - if (((o_ptr->art_name) || artifact_p(o_ptr)) && (rand_int(100) < 50)) + if (artifact_p(o_ptr) && (rand_int(100) < 50)) { /* Cool */ msg_format("A terrible black aura tries to surround your armour, " @@ -2801,7 +2801,7 @@ bool_ curse_weapon(void) object_desc(o_name, o_ptr, FALSE, 3); /* Attempt a saving throw */ - if ((artifact_p(o_ptr) || o_ptr->art_name) && (rand_int(100) < 50)) + if (artifact_p(o_ptr) && (rand_int(100) < 50)) { /* Cool */ msg_format("A terrible black aura tries to surround your weapon, " @@ -4644,7 +4644,7 @@ bool_ brand_bolts(void) if (o_ptr->tval != TV_BOLT) continue; /* Skip artifacts and ego-items */ - if (o_ptr->art_name || artifact_p(o_ptr) || ego_item_p(o_ptr)) continue; + if (artifact_p(o_ptr) || ego_item_p(o_ptr)) continue; /* Skip cursed/broken items */ if (cursed_p(o_ptr)) continue; diff --git a/src/melee1.cc b/src/melee1.cc index 7fdaca55..ecc44356 100644 --- a/src/melee1.cc +++ b/src/melee1.cc @@ -1867,7 +1867,7 @@ bool_ make_attack_normal(int m_idx, byte divis) if (!o_ptr->k_idx) continue; /* Skip artifacts */ - if (artifact_p(o_ptr) || o_ptr->art_name) continue; + if (artifact_p(o_ptr)) continue; /* Get a description */ object_desc(o_name, o_ptr, FALSE, 3); diff --git a/src/melee2.cc b/src/melee2.cc index d519dd8a..130b74ee 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -6211,8 +6211,7 @@ static void process_monster(int m_idx, bool_ is_frien) if (flags & TR_SLAY_EVIL) flg |= RF_EVIL; /* The object cannot be picked up by the monster */ - if (artifact_p(o_ptr) || (r_ptr->flags & flg) || - (o_ptr->art_name)) + if (artifact_p(o_ptr) || (r_ptr->flags & flg)) { /* Only give a message for "take_item" */ if (r_ptr->flags & RF_TAKE_ITEM) diff --git a/src/object1.cc b/src/object1.cc index 3f5d123f..c93d1ff1 100644 --- a/src/object1.cc +++ b/src/object1.cc @@ -1469,7 +1469,7 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode) {} /* Hack -- The only one of its kind */ - else if (known && (artifact_p(o_ptr) || o_ptr->art_name)) + else if (known && artifact_p(o_ptr)) { t += "The "; } @@ -1571,7 +1571,7 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode) } /* Hack -- The only one of its kind */ - else if (known && (artifact_p(o_ptr) || o_ptr->art_name)) + else if (known && artifact_p(o_ptr)) { t += "The "; } @@ -3463,7 +3463,7 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait /* Copying how others seem to do it. -- neil */ if (o_ptr->tval == TV_RING || o_ptr->tval == TV_AMULET || - !trim_down || (ego_item_p(o_ptr)) || (artifact_p(o_ptr))) + !trim_down || ego_item_p(o_ptr) || artifact_p(o_ptr)) { /* Where did we found it ? */ if (o_ptr->found == OBJ_FOUND_MONSTER) diff --git a/src/object2.cc b/src/object2.cc index c474fe18..89378fb2 100644 --- a/src/object2.cc +++ b/src/object2.cc @@ -311,7 +311,7 @@ void compact_objects(int size) chance = chance - cur_lev / 2; /* Artifacts */ - if ( artifact_p(o_ptr) || o_ptr->art_name ) + if (artifact_p(o_ptr)) { /* Artifacts are "immune if the level is lower */ /* than 300 + artifact level */ @@ -5082,7 +5082,7 @@ s16b drop_near(object_type *j_ptr, int chance, int y, int x) /* Handle normal "breakage" */ - if (!(j_ptr->art_name || artifact_p(j_ptr)) && (rand_int(100) < chance)) + if ((!artifact_p(j_ptr)) && (rand_int(100) < chance)) { /* Message */ msg_format("The %s disappear%s.", @@ -5187,7 +5187,7 @@ s16b drop_near(object_type *j_ptr, int chance, int y, int x) /* Handle lack of space */ - if (!flag && !(artifact_p(j_ptr) || j_ptr->art_name)) + if (!flag && (!artifact_p(j_ptr))) { /* Message */ msg_format("The %s disappear%s.", diff --git a/src/spells1.cc b/src/spells1.cc index 0054a1d6..3dc6c97f 100644 --- a/src/spells1.cc +++ b/src/spells1.cc @@ -1797,7 +1797,7 @@ static int inven_damage(inven_func typ, int perc) if (!o_ptr->k_idx) continue; /* Hack -- for now, skip artifacts */ - if (artifact_p(o_ptr) || o_ptr->art_name) continue; + if (artifact_p(o_ptr)) continue; /* Give this item slot a shot at death */ if ((*typ)(o_ptr)) @@ -2313,7 +2313,7 @@ bool_ apply_disenchant(int mode) /* Artifacts have 71% chance to resist */ - if ((artifact_p(o_ptr) || o_ptr->art_name) && (rand_int(100) < 71)) + if (artifact_p(o_ptr) && (rand_int(100) < 71)) { /* Message */ msg_format("Your %s (%c) resist%s disenchantment!", @@ -3853,7 +3853,7 @@ static bool_ project_o(int who, int r, int y, int x, int dam, int typ) if (o_ptr->number > 1) plural = TRUE; /* Check for artifact */ - if ((artifact_p(o_ptr) || o_ptr->art_name)) is_art = TRUE; + if (artifact_p(o_ptr)) is_art = TRUE; /* Analyze the type */ switch (typ) diff --git a/src/spells2.cc b/src/spells2.cc index bc5b8642..2b776c4f 100644 --- a/src/spells2.cc +++ b/src/spells2.cc @@ -728,7 +728,7 @@ bool_ alchemy(void) /* Turns an object into gold, gain some of its value in a sh } /* Artifacts cannot be destroyed */ - if (artifact_p(o_ptr) || o_ptr->art_name) + if (artifact_p(o_ptr)) { byte feel = SENSE_SPECIAL; @@ -2695,7 +2695,7 @@ bool_ enchant(object_type *o_ptr, int n, int eflag) { int i, chance, prob; bool_ res = FALSE; - bool_ a = (artifact_p(o_ptr) || o_ptr->art_name); + auto const a = artifact_p(o_ptr); /* Extract the flags */ @@ -3252,7 +3252,7 @@ static void note_found_object(object_type *o_ptr) char note[150]; char item_name[80]; - if (artifact_p(o_ptr) || o_ptr->name1) + if (artifact_p(o_ptr)) { object_desc(item_name, o_ptr, FALSE, 0); diff --git a/src/wizard2.cc b/src/wizard2.cc index 295bf5ca..266fc353 100644 --- a/src/wizard2.cc +++ b/src/wizard2.cc @@ -723,7 +723,7 @@ static void wiz_reroll_item(object_type *o_ptr) /* Hack -- leave artifacts alone */ - if (artifact_p(o_ptr) || o_ptr->art_name) return; + if (artifact_p(o_ptr)) return; /* Get local object */ -- cgit v1.2.3