summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-12-05 14:06:26 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-12-05 14:06:26 +0000
commit376d7d8be0443ac004a1fe5d88f56325497d1921 (patch)
treed62c43ed0b1f20302776380fdd15eb53c7c65459 /crawl-ref/source
parent55812ea322d83879cd9ed09d27f18ab2d0345def (diff)
downloadcrawl-ref-376d7d8be0443ac004a1fe5d88f56325497d1921.tar.gz
crawl-ref-376d7d8be0443ac004a1fe5d88f56325497d1921.zip
Slight cleanup of randart autoinscription.
Code cleanup with unrandarts and fixedarts. Bugfix for isomorphic-up-to-colour unrandarts being confused when lost in the Abyss. Trowel will not clobber critical features (stairs, portals, etc.) Nemelex is unhappy about Trowel failing. Breaks savefiles. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3003 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/acr.cc6
-rw-r--r--crawl-ref/source/decks.cc13
-rw-r--r--crawl-ref/source/describe.cc190
-rw-r--r--crawl-ref/source/itemprop.h23
-rw-r--r--crawl-ref/source/items.cc27
-rw-r--r--crawl-ref/source/randart.cc130
-rw-r--r--crawl-ref/source/randart.h2
-rw-r--r--crawl-ref/source/terrain.cc2
-rw-r--r--crawl-ref/source/terrain.h2
9 files changed, 175 insertions, 220 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index da9eeefe63..db89ab8298 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -568,7 +568,8 @@ static void handle_wizard_command( void )
}
// create all fixed artefacts
- for (tmp = SPWPN_SINGING_SWORD; tmp <= SPWPN_STAFF_OF_WUCAD_MU; tmp++)
+ for (tmp = SPWPN_START_FIXEDARTS;
+ tmp < SPWPN_START_NOGEN_FIXEDARTS; tmp++)
{
int islot = get_item_slot();
if (islot == NON_ITEM)
@@ -581,6 +582,9 @@ static void handle_wizard_command( void )
set_ident_flags( mitm[ islot ], ISFLAG_IDENT_MASK );
move_item_to_grid( &islot, you.x_pos, you.y_pos );
+
+ msg::streams(MSGCH_DIAGNOSTICS) <<
+ "Made " << mitm[islot].name(DESC_NOCAP_A) << std::endl;
}
}
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index 44bfc24e7d..e8cbee7841 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -2119,8 +2119,15 @@ static void dowsing_card(int power, deck_rarity_type rarity)
detect_creatures( random2(power/4) );
}
-static void trowel_card(int power, deck_rarity_type rarity)
+static bool trowel_card(int power, deck_rarity_type rarity)
{
+ // Early exit: don't clobber important features
+ if (is_critical_feature(grd[you.x_pos][you.y_pos]))
+ {
+ mpr("The dungeon trembles momentarily.");
+ return false;
+ }
+
const int power_level = get_power_level(power, rarity);
bool done_stuff = false;
if ( power_level >= 2 )
@@ -2213,7 +2220,7 @@ static void trowel_card(int power, deck_rarity_type rarity)
if ( !done_stuff )
canned_msg(MSG_NOTHING_HAPPENS);
- return;
+ return done_stuff;
}
static void genie_card(int power, deck_rarity_type rarity)
@@ -2540,7 +2547,7 @@ bool card_effect(card_type which_card, deck_rarity_type rarity,
case CARD_SUMMON_FLYING: summon_flying(power, rarity); break;
case CARD_SUMMON_SKELETON: summon_skeleton(power, rarity); break;
case CARD_XOM: xom_acts(5 + random2(power/10)); break;
- case CARD_TROWEL: trowel_card(power, rarity); break;
+ case CARD_TROWEL: rc = trowel_card(power, rarity); break;
case CARD_SPADE: your_spells(SPELL_DIG, random2(power/4), false); break;
case CARD_BANSHEE: mass_enchantment(ENCH_FEAR, power, MHITYOU); break;
case CARD_TORMENT: torment(TORMENT_CARDS, you.x_pos, you.y_pos); break;
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index f546c61e3d..83869abced 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -152,6 +152,30 @@ void print_description( const std::string &d )
}
}
+const char* jewellery_base_ability_string(int subtype)
+{
+ switch(subtype)
+ {
+ case RING_REGENERATION: return "Regen";
+ case RING_SUSTAIN_ABILITIES: return "SustAbil";
+ case RING_SUSTENANCE: return "-Hun";
+ case RING_WIZARDRY: return "Wiz";
+ case RING_FIRE: return "F-Mag";
+ case RING_ICE: return "I-Mag";
+ case RING_TELEPORT_CONTROL: return "TC";
+ case AMU_RESIST_SLOW: return "RSlow";
+ case AMU_CLARITY: return "Clar";
+ case AMU_WARDING: return "Ward";
+ case AMU_RESIST_CORROSION: return "RA";
+ case AMU_THE_GOURMAND: return "Gourm";
+ case AMU_CONSERVATION: return "Csrv";
+ case AMU_CONTROLLED_FLIGHT: return "CFly";
+ case AMU_RESIST_MUTATION: return "RMut";
+ }
+ return "";
+}
+
+
#define known_proprt(prop) (proprt[(prop)] && known[(prop)])
struct property_descriptors
@@ -170,112 +194,57 @@ static std::vector<std::string> randart_propnames( const item_def& item )
std::vector<std::string> propnames;
const property_descriptors propdescs[] = {
- { "AC", RAP_AC, 0 },
- { "EV", RAP_EVASION, 0 },
- { "Str", RAP_STRENGTH, 0 },
- { "Dex", RAP_DEXTERITY, 0 },
- { "Int", RAP_INTELLIGENCE, 0 },
- { "Acc", RAP_ACCURACY, 0 },
- { "Dam", RAP_DAMAGE, 0 },
- { "RF", RAP_FIRE, 1 },
- { "RC", RAP_COLD, 1 },
- { "RE", RAP_ELECTRICITY, 1 },
- { "RP", RAP_POISON, 1 },
- { "RN", RAP_NEGATIVE_ENERGY, 1 },
- { "MP", RAP_MAGICAL_POWER, 0 },
- { "MR", RAP_MAGIC, 2 },
- { "SInv", RAP_EYESIGHT, 2 },
- { "Stl", RAP_STEALTH, 2 },
-
- { "Ang", RAP_BERSERK, 2 },
- { "Noi", RAP_NOISES, 2 },
- { "-Spl", RAP_PREVENT_SPELLCASTING, 2 },
- { "-Tp", RAP_PREVENT_TELEPORTATION, 2 },
- { "+Tp", RAP_CAUSE_TELEPORTATION, 2 },
- { "Hun", RAP_METABOLISM, 1 },
- { "Mut", RAP_MUTAGENIC, 2 },
-
- { "Inv", RAP_INVISIBLE, 2 },
- { "Lev", RAP_LEVITATE, 2 },
- { "Blk", RAP_BLINK, 2 },
- { "?Tp", RAP_CAN_TELEPORT, 2 },
- { "Map", RAP_MAPPING, 2 },
+
+ // Positive, quantative attributes
+ { "AC", RAP_AC, 0 },
+ { "EV", RAP_EVASION, 0 },
+ { "Str", RAP_STRENGTH, 0 },
+ { "Dex", RAP_DEXTERITY, 0 },
+ { "Int", RAP_INTELLIGENCE, 0 },
+ { "Acc", RAP_ACCURACY, 0 },
+ { "Dam", RAP_DAMAGE, 0 },
+
+ // Resists
+ { "RF", RAP_FIRE, 1 },
+ { "RC", RAP_COLD, 1 },
+ { "RE", RAP_ELECTRICITY, 1 },
+ { "RP", RAP_POISON, 1 },
+ { "RN", RAP_NEGATIVE_ENERGY, 1 },
+ { "MR", RAP_MAGIC, 2 },
+
+ // Positive, qualitative attributes
+ { "MP", RAP_MAGICAL_POWER, 0 },
+ { "SInv", RAP_EYESIGHT, 2 },
+ { "Stl", RAP_STEALTH, 2 },
+
+ // (Generally) negative attributes
+ { "Ang", RAP_BERSERK, 2 },
+ { "Noi", RAP_NOISES, 2 },
+ { "-Spl", RAP_PREVENT_SPELLCASTING, 2 },
+ { "-Tp", RAP_PREVENT_TELEPORTATION, 2 },
+ { "+Tp", RAP_CAUSE_TELEPORTATION, 2 },
+ { "Hun", RAP_METABOLISM, 1 },
+ { "Mut", RAP_MUTAGENIC, 2 },
+
+ // Evokable abilities
+ { "Inv", RAP_INVISIBLE, 2 },
+ { "Lev", RAP_LEVITATE, 2 },
+ { "Blk", RAP_BLINK, 2 },
+ { "?Tp", RAP_CAN_TELEPORT, 2 },
+ { "Map", RAP_MAPPING, 2 }
+
};
- // For randart jewellry, note the base jewelery type if it's not
+ // For randart jewellery, note the base jewellery type if it's not
// covered by randart_desc_properties()
if (item.base_type == OBJ_JEWELLERY
- && item_ident( item, ISFLAG_KNOW_PROPERTIES ))
+ && item_ident(item, ISFLAG_KNOW_PROPERTIES))
{
- std::string type = "";
-
- switch(item.sub_type)
- {
- case RING_REGENERATION:
- type = "Regen";
- break;
-
- case RING_SUSTAIN_ABILITIES:
- type = "SustAbil";
- break;
-
- case RING_SUSTENANCE:
- type = "Susten";
- break;
-
- case RING_WIZARDRY:
- type = "Wiz";
- break;
-
- case RING_FIRE:
- type = "F-Mag";
- break;
-
- case RING_ICE:
- type = "I-Mag";
- break;
-
- case RING_TELEPORT_CONTROL:
- type = "T-Cont";
- break;
-
- case AMU_RESIST_SLOW:
- type = "RSlow";
- break;
-
- case AMU_CLARITY:
- type = "Clar";
- break;
-
- case AMU_WARDING:
- type = "Ward";
- break;
-
- case AMU_RESIST_CORROSION:
- type = "RAcid";
- break;
-
- case AMU_THE_GOURMAND:
- type = "Gourm";
- break;
-
- case AMU_CONSERVATION:
- type = "Conserv";
- break;
-
- case AMU_CONTROLLED_FLIGHT:
- type = "C-Fly";
- break;
-
- case AMU_RESIST_MUTATION:
- type = "RMut";
- break;
- }
- if (type != "")
+ const std::string type = jewellery_base_ability_string(item.sub_type);
+ if ( !type.empty() )
propnames.push_back(type);
}
-
for ( unsigned i = 0; i < ARRAYSIZE(propdescs); ++i )
{
if (known_proprt(propdescs[i].prop))
@@ -307,7 +276,7 @@ static std::vector<std::string> randart_propnames( const item_def& item )
static std::string randart_auto_inscription( const item_def& item )
{
- std::vector<std::string> propnames = randart_propnames(item);
+ const std::vector<std::string> propnames = randart_propnames(item);
return comma_separated_line(propnames.begin(), propnames.end(),
", ", ", ");
@@ -329,11 +298,9 @@ static void trim_randart_inscrip( item_def& item )
prop = propnames[i];
item.inscription = replace_all(item.inscription, prop, "");
}
-
trim_string(item.inscription);
}
-
static std::string randart_descrip( const item_def &item )
{
std::string description;
@@ -3700,13 +3667,17 @@ void describe_item( item_def &item, bool allow_inscribe )
{
gotoxy(1, wherey() + 2);
- // OK, technically inefficient to call randart_auto_inscription
- // when we don't need to.
+ std::string ainscrip;
+
+ if (is_random_artefact(item))
+ ainscrip = randart_auto_inscription(item);
+
+ // Only allow autoinscription if we don't have all the text
+ // already.
const bool allow_autoinscribe =
- is_random_artefact(item) &&
- (randart_auto_inscription(item) != "") &&
- (item.inscription.find(randart_auto_inscription(item))
- == std::string::npos);
+ is_random_artefact(item)
+ && !ainscrip.empty()
+ && item.inscription.find(ainscrip) == std::string::npos;
if ( allow_autoinscribe )
{
@@ -3734,9 +3705,10 @@ void describe_item( item_def &item, bool allow_inscribe )
// Remove previous randart inscription
trim_randart_inscrip(item);
- if (item.inscription != "")
+ if (!item.inscription.empty())
item.inscription += " ";
- item.inscription += randart_auto_inscription(item);
+
+ item.inscription += ainscrip;
}
}
else if (getch() == 0)
diff --git a/crawl-ref/source/itemprop.h b/crawl-ref/source/itemprop.h
index 24231fa2f2..6616236128 100644
--- a/crawl-ref/source/itemprop.h
+++ b/crawl-ref/source/itemprop.h
@@ -102,24 +102,29 @@ enum brand_type // equivalent to (you.inv[].special or mitm[].special) % 30
SPWPN_DUMMY_CRUSHING, // ONLY TEMPORARY USAGE -- converts to VORPAL
// everything above this point is a special artefact wield:
- SPWPN_SINGING_SWORD = 181, // 181
+ SPWPN_START_FIXEDARTS = 181,
+
+ SPWPN_SINGING_SWORD = SPWPN_START_FIXEDARTS,
SPWPN_WRATH_OF_TROG,
SPWPN_SCYTHE_OF_CURSES,
SPWPN_MACE_OF_VARIABILITY,
- SPWPN_GLAIVE_OF_PRUNE, // 185
+ SPWPN_GLAIVE_OF_PRUNE,
SPWPN_SCEPTRE_OF_TORMENT,
SPWPN_SWORD_OF_ZONGULDROK,
-
- // these three are not generated randomly {dlb}
- SPWPN_SWORD_OF_CEREBOV,
- SPWPN_STAFF_OF_DISPATER,
- SPWPN_SCEPTRE_OF_ASMODEUS, // 190
-
SPWPN_SWORD_OF_POWER,
SPWPN_KNIFE_OF_ACCURACY,
SPWPN_STAFF_OF_OLGREB,
SPWPN_VAMPIRES_TOOTH,
- SPWPN_STAFF_OF_WUCAD_MU // 195, must be last (see randart.cc)
+ SPWPN_STAFF_OF_WUCAD_MU,
+
+ // these three are not generated randomly {dlb}
+ SPWPN_START_NOGEN_FIXEDARTS,
+
+ SPWPN_SWORD_OF_CEREBOV = SPWPN_START_NOGEN_FIXEDARTS,
+ SPWPN_STAFF_OF_DISPATER,
+ SPWPN_SCEPTRE_OF_ASMODEUS,
+
+ SPWPN_END_FIXEDARTS = SPWPN_SCEPTRE_OF_ASMODEUS
};
enum corpse_type
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index c813175175..2399c68080 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -192,17 +192,18 @@ int cull_items(void)
if (item_ok_to_clean(item) && random2(100) < 15)
{
- if (is_fixed_artefact( mitm[item] ))
+ const item_def& obj(mitm[item]);
+ if (is_fixed_artefact(obj))
{
// 7. move uniques to abyss
- set_unique_item_status( OBJ_WEAPONS, mitm[item].special,
+ set_unique_item_status( OBJ_WEAPONS, obj.special,
UNIQ_LOST_IN_ABYSS );
}
- else if (is_unrandom_artefact( mitm[item] ))
+ else if (is_unrandom_artefact(obj))
{
// 9. unmark unrandart
- int z = find_unrandart_index(item);
- if (z >= 0)
+ const int z = find_unrandart_index(obj);
+ if (z != -1)
set_unrandart_exist(z, false);
}
@@ -509,21 +510,25 @@ void destroy_item( int dest, bool never_created )
unlink_item( dest );
+ item_def& item(mitm[dest]);
+
if (never_created)
{
- if (is_fixed_artefact(mitm[dest]))
- set_unique_item_status( mitm[dest].base_type, mitm[dest].special,
- UNIQ_NOT_EXISTS );
- else if (is_unrandom_artefact(mitm[dest]))
+ if (is_fixed_artefact(item))
+ {
+ set_unique_item_status(item.base_type, item.special,
+ UNIQ_NOT_EXISTS);
+ }
+ else if (is_unrandom_artefact(item))
{
- const int unrand = find_unrandart_index(dest);
+ const int unrand = find_unrandart_index(item);
if (unrand != -1)
set_unrandart_exist( unrand, false );
}
}
// paranoia, shouldn't be needed
- mitm[dest].clear();
+ item.clear();
}
static void handle_gone_item(const item_def &item)
diff --git a/crawl-ref/source/randart.cc b/crawl-ref/source/randart.cc
index 432fa4801e..5f7d849c86 100644
--- a/crawl-ref/source/randart.cc
+++ b/crawl-ref/source/randart.cc
@@ -792,7 +792,7 @@ static unrandart_entry unranddata[] = {
static FixedVector < bool, NO_UNRANDARTS > unrandart_exist;
-static struct unrandart_entry *seekunrandart( const item_def &item );
+static unrandart_entry *seekunrandart( const item_def &item );
void set_unrandart_exist(int whun, bool is_exist)
{
@@ -821,12 +821,12 @@ bool is_unrandom_artefact( const item_def &item )
return (item.flags & ISFLAG_UNRANDART);
}
-// returns true if item is one of the origional fixed artefacts
+// returns true if item is one of the original fixed artefacts
bool is_fixed_artefact( const item_def &item )
{
if (!is_random_artefact( item )
&& item.base_type == OBJ_WEAPONS
- && item.special >= SPWPN_SINGING_SWORD)
+ && item.special >= SPWPN_START_FIXEDARTS)
{
return (true);
}
@@ -837,42 +837,22 @@ bool is_fixed_artefact( const item_def &item )
unique_item_status_type get_unique_item_status( object_class_type base_type,
int art )
{
- // Note: for weapons "art" is in item.special,
- // for orbs it's the sub_type.
- if (base_type == OBJ_WEAPONS)
+ if (base_type == OBJ_WEAPONS
+ && art >= SPWPN_START_FIXEDARTS && art < SPWPN_START_NOGEN_FIXEDARTS)
{
- if (art >= SPWPN_SINGING_SWORD && art <= SPWPN_SWORD_OF_ZONGULDROK)
- return (you.unique_items[ art - SPWPN_SINGING_SWORD ]);
- else if (art >= SPWPN_SWORD_OF_POWER && art <= SPWPN_STAFF_OF_WUCAD_MU)
- return (you.unique_items[ art - SPWPN_SWORD_OF_POWER + 24 ]);
+ return (you.unique_items[art - SPWPN_START_FIXEDARTS]);
}
- else if (base_type == OBJ_ORBS)
- {
- if (art >= 4 && art <= 19)
- return (you.unique_items[ art + 3 ]);
-
- }
-
- return (UNIQ_NOT_EXISTS);
+ else
+ return (UNIQ_NOT_EXISTS);
}
void set_unique_item_status( object_class_type base_type, int art,
unique_item_status_type status )
{
- // Note: for weapons "art" is in item.special,
- // for orbs it's the sub_type.
- if (base_type == OBJ_WEAPONS)
+ if (base_type == OBJ_WEAPONS
+ && art >= SPWPN_START_FIXEDARTS && art < SPWPN_START_NOGEN_FIXEDARTS)
{
- if (art >= SPWPN_SINGING_SWORD && art <= SPWPN_SWORD_OF_ZONGULDROK)
- you.unique_items[ art - SPWPN_SINGING_SWORD ] = status;
- else if (art >= SPWPN_SWORD_OF_POWER && art <= SPWPN_STAFF_OF_WUCAD_MU)
- you.unique_items[ art - SPWPN_SWORD_OF_POWER + 24 ] = status;
- }
- else if (base_type == OBJ_ORBS)
- {
- if (art >= 4 && art <= 19)
- you.unique_items[ art + 3 ] = status;
-
+ you.unique_items[art - SPWPN_START_FIXEDARTS] = status;
}
}
@@ -1059,7 +1039,7 @@ static int randart_add_one_property( const item_def &item,
int skip = -1;
// Determine if we need to skip any of the above.
- if (cl == OBJ_ARMOUR || cl == OBJ_JEWELLERY && ty == RING_PROTECTION)
+ if (cl == OBJ_ARMOUR || (cl == OBJ_JEWELLERY && ty == RING_PROTECTION))
skip = 0;
else if (cl == OBJ_JEWELLERY && ty == RING_EVASION)
skip = 1;
@@ -1707,7 +1687,7 @@ std::string randart_name( const item_def &item )
if (is_unrandom_artefact( item ))
{
- const struct unrandart_entry *unrand = seekunrandart( item );
+ const unrandart_entry *unrand = seekunrandart( item );
return (item_type_known(item) ? unrand->name : unrand->unid_name);
}
@@ -1757,7 +1737,7 @@ std::string randart_armour_name( const item_def &item )
if (is_unrandom_artefact( item ))
{
- const struct unrandart_entry *unrand = seekunrandart( item );
+ const unrandart_entry *unrand = seekunrandart( item );
return (item_type_known(item) ? unrand->name : unrand->unid_name);
}
@@ -1807,10 +1787,8 @@ std::string randart_jewellery_name( const item_def &item )
if (is_unrandom_artefact( item ))
{
- struct unrandart_entry *unrand = seekunrandart( item );
-
- return (item_type_known(item) ? unrand->name
- : unrand->unid_name);
+ const unrandart_entry *unrand = seekunrandart( item );
+ return (item_type_known(item) ? unrand->name : unrand->unid_name);
}
const long seed = calc_seed( item );
@@ -1855,83 +1833,65 @@ std::string randart_jewellery_name( const item_def &item )
return result;
}
-static struct unrandart_entry *seekunrandart( const item_def &item )
+int find_unrandart_index(const item_def& artefact)
{
- int x = 0;
-
- while (x < NO_UNRANDARTS)
+ for (int i=0; i < NO_UNRANDARTS; i++)
{
- if (unranddata[x].ura_cl == item.base_type
- && unranddata[x].ura_ty == item.sub_type
- && unranddata[x].ura_pl == item.plus
- && unranddata[x].ura_pl2 == item.plus2
- && unranddata[x].ura_col == item.colour)
+ const unrandart_entry& candidate = unranddata[i];
+ if (candidate.ura_cl == artefact.base_type
+ && candidate.ura_ty == artefact.sub_type
+ && candidate.ura_pl == artefact.plus
+ && candidate.ura_pl2 == artefact.plus2
+ && candidate.ura_col == artefact.colour)
{
- return (&unranddata[x]);
+ return i;
}
-
- x++;
}
- return (&unranddata[0]); // Dummy object
-} // end seekunrandart()
+ return (-1);
+}
-int find_unrandart_index(int item_number)
+static unrandart_entry *seekunrandart( const item_def &item )
{
- int x;
-
- for(x=0; x < NO_UNRANDARTS; x++)
- {
- if (unranddata[x].ura_cl == mitm[item_number].base_type
- && unranddata[x].ura_ty == mitm[item_number].sub_type
- && unranddata[x].ura_pl == mitm[item_number].plus
- && unranddata[x].ura_pl2 == mitm[item_number].plus2)
- {
- return (x);
- }
- }
-
- return (-1);
+ const int idx = find_unrandart_index(item);
+ if ( idx == -1 )
+ return &unranddata[0]; // dummy unrandart
+ else
+ return &unranddata[idx];
}
int find_okay_unrandart(unsigned char aclass, unsigned char atype)
{
- int x, count;
int ret = -1;
- for (x = 0, count = 0; x < NO_UNRANDARTS; x++)
+ // Pick randomly among not-yet-existing unrandarts with the proper
+ // base_type and sub_type.
+ for (int i = 0, count = 0; i < NO_UNRANDARTS; i++)
{
- if (unranddata[x].ura_cl == aclass
- && !does_unrandart_exist(x)
- && (atype == OBJ_RANDOM || unranddata[x].ura_ty == atype))
+ if (unranddata[i].ura_cl == aclass
+ && !does_unrandart_exist(i)
+ && (atype == OBJ_RANDOM || unranddata[i].ura_ty == atype))
{
count++;
if (one_chance_in(count))
- ret = x;
+ ret = i;
}
}
return (ret);
-} // end find_okay_unrandart()
+}
// which == 0 (default) gives random fixed artefact.
// Returns true if successful.
bool make_item_fixed_artefact( item_def &item, bool in_abyss, int which )
{
- bool force = true; // we force any one asked for specifically
+ const bool force = (which != 0);
- if (!which)
+ if (!force)
{
- // using old behaviour... try only once. -- bwr
- force = false;
-
- do {
- which = SPWPN_SINGING_SWORD +
- random2(SPWPN_STAFF_OF_WUCAD_MU - SPWPN_SINGING_SWORD + 1);
- } while ( which == SPWPN_SWORD_OF_CEREBOV ||
- which == SPWPN_STAFF_OF_DISPATER ||
- which == SPWPN_SCEPTRE_OF_ASMODEUS );
+ which = SPWPN_START_FIXEDARTS +
+ random2(SPWPN_START_NOGEN_FIXEDARTS - SPWPN_START_FIXEDARTS);
}
const unique_item_status_type status =
diff --git a/crawl-ref/source/randart.h b/crawl-ref/source/randart.h
index dc07310a03..e8be21e047 100644
--- a/crawl-ref/source/randart.h
+++ b/crawl-ref/source/randart.h
@@ -106,6 +106,6 @@ void set_unrandart_exist(int whun, bool is_exist);
/* ***********************************************************************
* called from: items
* *********************************************************************** */
-int find_unrandart_index(int item_index);
+int find_unrandart_index(const item_def& artefact);
#endif
diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc
index 8c9e122944..fd0a9e0ff6 100644
--- a/crawl-ref/source/terrain.cc
+++ b/crawl-ref/source/terrain.cc
@@ -333,7 +333,7 @@ static bool dgn_shift_item(const coord_def &pos, item_def &item)
return (false);
}
-static bool is_critical_feature(dungeon_feature_type feat)
+bool is_critical_feature(dungeon_feature_type feat)
{
return (grid_stair_direction(feat) != CMD_NO_CMD
|| grid_altar_god(feat) != GOD_NO_GOD);
diff --git a/crawl-ref/source/terrain.h b/crawl-ref/source/terrain.h
index 51caa559d6..16b728c5c4 100644
--- a/crawl-ref/source/terrain.h
+++ b/crawl-ref/source/terrain.h
@@ -55,4 +55,6 @@ void dungeon_terrain_changed(const coord_def &pos,
bool preserve_features = false,
bool preserve_items = false);
+bool is_critical_feature(dungeon_feature_type feat);
+
#endif