summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/ouch.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-04-21 16:18:19 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-04-21 16:18:19 +0000
commitfac344b62ebbf48e7b1d2a7b5f0bcdd3608bd4a7 (patch)
tree8cc8a0b1312414c79f2c2d6e3d1e455754be41ea /crawl-ref/source/ouch.cc
parentb2ea8143ccf52a2cacfa48d19ce2ea603ddaab5e (diff)
downloadcrawl-ref-fac344b62ebbf48e7b1d2a7b5f0bcdd3608bd4a7.tar.gz
crawl-ref-fac344b62ebbf48e7b1d2a7b5f0bcdd3608bd4a7.zip
Eliminated it_name(), in_name(), item_name(). The function to use is
now item_def::name(). Cleaned up a lot of code in the process. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1341 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/ouch.cc')
-rw-r--r--crawl-ref/source/ouch.cc38
1 files changed, 18 insertions, 20 deletions
diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc
index db94e5d87e..41fd58617b 100644
--- a/crawl-ref/source/ouch.cc
+++ b/crawl-ref/source/ouch.cc
@@ -74,8 +74,8 @@
#include "view.h"
-void end_game( struct scorefile_entry &se );
-void item_corrode( char itco );
+static void end_game( scorefile_entry &se );
+static void item_corrode( int itco );
/* NOTE: DOES NOT check for hellfire!!! */
@@ -319,7 +319,7 @@ void weapon_acid( char acid_strength )
}
} // end weapon_acid()
-void item_corrode( char itco )
+void item_corrode( int itco )
{
int chance_corr = 0; // no idea what its full range is {dlb}
bool it_resists = false; // code simplifier {dlb}
@@ -340,17 +340,18 @@ void item_corrode( char itco )
if (how_rusty < -5)
return;
+ item_def& item = you.inv[itco];
// determine possibility of resistance by object type {dlb}:
- switch (you.inv[itco].base_type)
+ switch (item.base_type)
{
case OBJ_ARMOUR:
- if (is_random_artefact( you.inv[itco] ))
+ if (is_random_artefact( item ))
{
it_resists = true;
suppress_msg = true;
}
- else if ((you.inv[itco].sub_type == ARM_CRYSTAL_PLATE_MAIL
- || get_equip_race(you.inv[itco]) == ISFLAG_DWARVEN)
+ else if ((item.sub_type == ARM_CRYSTAL_PLATE_MAIL
+ || get_equip_race(item) == ISFLAG_DWARVEN)
&& !one_chance_in(5))
{
it_resists = true;
@@ -359,13 +360,13 @@ void item_corrode( char itco )
break;
case OBJ_WEAPONS:
- if (is_fixed_artefact(you.inv[itco])
- || is_random_artefact(you.inv[itco]))
+ if (is_fixed_artefact(item)
+ || is_random_artefact(item))
{
it_resists = true;
suppress_msg = true;
}
- else if (get_equip_race(you.inv[itco]) == ISFLAG_DWARVEN
+ else if (get_equip_race(item) == ISFLAG_DWARVEN
&& !one_chance_in(5))
{
it_resists = true;
@@ -374,7 +375,7 @@ void item_corrode( char itco )
break;
case OBJ_MISSILES:
- if (get_equip_race(you.inv[itco]) == ISFLAG_DWARVEN
+ if (get_equip_race(item) == ISFLAG_DWARVEN
&& !one_chance_in(5))
{
it_resists = true;
@@ -402,7 +403,7 @@ void item_corrode( char itco )
if (chance_corr >= 0 && chance_corr <= 4)
{
it_resists = (random2(100) <
- 2 + (2 << (1 + chance_corr)) + (chance_corr * 8));
+ 2 + (4 << chance_corr) + (chance_corr * 8));
}
else
it_resists = true; // no idea how often this occurs {dlb}
@@ -414,21 +415,18 @@ void item_corrode( char itco )
// handle message output and item damage {dlb}:
if (!suppress_msg)
{
- char str_pass[ ITEMNAME_SIZE ];
- in_name(itco, DESC_CAP_YOUR, str_pass);
- strcpy(info, str_pass);
- strcat(info, (it_resists) ? " resists." : " is eaten away!");
- mpr(info);
+ mprf("%s %s", item.name(DESC_CAP_YOUR).c_str(),
+ (it_resists) ? " resists." : " is eaten away!");
}
if (!it_resists)
{
how_rusty--;
- if (you.inv[itco].base_type == OBJ_WEAPONS)
- you.inv[itco].plus2 = how_rusty;
+ if (item.base_type == OBJ_WEAPONS)
+ item.plus2 = how_rusty;
else
- you.inv[itco].plus = how_rusty;
+ item.plus = how_rusty;
you.redraw_armour_class = 1; // for armour, rings, etc. {dlb}