From 07a705b4b98055b34d2d411571622860cbf54fd4 Mon Sep 17 00:00:00 2001
From: pubby <pubby8@gmail.com>
Date: Sun, 30 Jun 2013 14:01:58 -0500
Subject: [PATCH] Remove use of 'you' inside player member functions

'you' seemed to be pointless in such context anyways, and lead to some
const correctness bugs since '*this' could have a different const-ness
from 'you'.
---
 crawl-ref/source/actor-los.cc  |   4 +-
 crawl-ref/source/actor.h       |   2 +-
 crawl-ref/source/areas.cc      |  12 +--
 crawl-ref/source/behold.cc     |  12 +--
 crawl-ref/source/fearmonger.cc |  10 +-
 crawl-ref/source/monster.cc    |   2 +-
 crawl-ref/source/monster.h     |   2 +-
 crawl-ref/source/place-info.cc |   2 +-
 crawl-ref/source/player-act.cc |  38 ++++----
 crawl-ref/source/player.cc     | 215 +++++++++++++++++++++--------------------
 crawl-ref/source/player.h      |   2 +-
 crawl-ref/source/teleport.cc   |   2 +-
 12 files changed, 153 insertions(+), 150 deletions(-)

diff --git a/crawl-ref/source/actor-los.cc b/crawl-ref/source/actor-los.cc
index 136e0e1..d8dfe30 100644
--- a/crawl-ref/source/actor-los.cc
+++ b/crawl-ref/source/actor-los.cc
@@ -28,7 +28,7 @@ bool player::see_cell(const coord_def &p) const
     if (crawl_state.game_is_arena() && is_player())
         return true;
     if (xray_vision)
-        return ((pos() - p).abs() <= dist_range(you.current_vision));
+        return ((pos() - p).abs() <= dist_range(current_vision));
     return actor::see_cell(p);
 }
 
@@ -65,7 +65,7 @@ const los_base* player::get_los()
     else if (xray_vision)
     {
         los = los_glob(pos(), LOS_ARENA,
-                       circle_def(you.current_vision, C_ROUND));
+                       circle_def(current_vision, C_ROUND));
         return &los;
     }
     else
diff --git a/crawl-ref/source/actor.h b/crawl-ref/source/actor.h
index 2246ed2..84fa42e 100644
--- a/crawl-ref/source/actor.h
+++ b/crawl-ref/source/actor.h
@@ -111,7 +111,7 @@ public:
         return weapon(0);
     }
     virtual int has_claws(bool allow_tran = true) const = 0;
-    virtual item_def *shield() = 0;
+    virtual item_def *shield() const = 0;
     virtual item_def *slot_item(equipment_type eq,
                                 bool include_melded=false) const = 0;
     virtual int wearing(equipment_type slot, int sub_type,
diff --git a/crawl-ref/source/areas.cc b/crawl-ref/source/areas.cc
index d2e275b..633cc1f 100644
--- a/crawl-ref/source/areas.cc
+++ b/crawl-ref/source/areas.cc
@@ -549,7 +549,7 @@ static int _silence_range(int dur)
 
 int player::silence_radius2() const
 {
-    return _silence_range(you.duration[DUR_SILENCE]);
+    return _silence_range(duration[DUR_SILENCE]);
 }
 
 int monster::silence_radius2() const
@@ -597,11 +597,11 @@ int player::halo_radius2() const
 {
     int size = -1;
 
-    if (you.religion == GOD_SHINING_ONE && you.piety >= piety_breakpoint(0)
-        && !you.penance[GOD_SHINING_ONE])
+    if (religion == GOD_SHINING_ONE && piety >= piety_breakpoint(0)
+        && !penance[GOD_SHINING_ONE])
     {
         // Preserve the middle of old radii.
-        const int r = you.piety - 10;
+        const int r = piety - 10;
         // The cap is 64, just less than the LOS of 65.
         size = min(LOS_RADIUS*LOS_RADIUS, r * r / 400);
     }
@@ -661,7 +661,7 @@ int monster::halo_radius2() const
 
 int player::liquefying_radius2() const
 {
-    return _silence_range(you.duration[DUR_LIQUEFYING]);
+    return _silence_range(duration[DUR_LIQUEFYING]);
 }
 
 int monster::liquefying_radius2() const
@@ -840,7 +840,7 @@ int player::soul_aura_radius2() const
 // Player radius
 int player::heat_radius2() const
 {
-    if (you.species != SP_LAVA_ORC)
+    if (species != SP_LAVA_ORC)
         return -1;
 
     if (!temperature_effect(LORC_HEAT_AURA))
diff --git a/crawl-ref/source/behold.cc b/crawl-ref/source/behold.cc
index db4cdcd..d9c1cce 100644
--- a/crawl-ref/source/behold.cc
+++ b/crawl-ref/source/behold.cc
@@ -25,11 +25,11 @@ static bool _mermaid_beholder(const monster* mons)
 // Add a monster to the list of beholders.
 void player::add_beholder(const monster* mon, bool axe)
 {
-    if (is_sanctuary(you.pos()) && !axe)
+    if (is_sanctuary(pos()) && !axe)
     {
         if (_mermaid_beholder(mon))
         {
-            if (you.can_see(mon))
+            if (can_see(mon))
             {
                 mprf("%s's singing sounds muted, and has no effect on you.",
                      mon->name(DESC_THE).c_str());
@@ -39,7 +39,7 @@ void player::add_beholder(const monster* mon, bool axe)
         }
         else
         {
-            if (you.can_see(mon))
+            if (can_see(mon))
                 mprf("%s's is no longer quite as mesmerising!", mon->name(DESC_THE).c_str());
             else
                 mpr("Your mesmeriser suddenly seems less interesting!");
@@ -50,7 +50,7 @@ void player::add_beholder(const monster* mon, bool axe)
 
     if (!duration[DUR_MESMERISED])
     {
-        you.set_duration(DUR_MESMERISED, 7, 12);
+        set_duration(DUR_MESMERISED, 7, 12);
         beholders.push_back(mon->mindex());
         if (!axe)
         {
@@ -60,7 +60,7 @@ void player::add_beholder(const monster* mon, bool axe)
     }
     else
     {
-        you.increase_duration(DUR_MESMERISED, 5, 12);
+        increase_duration(DUR_MESMERISED, 5, 12);
         if (!beheld_by(mon))
             beholders.push_back(mon->mindex());
     }
@@ -263,6 +263,6 @@ bool player::possible_beholder(const monster* mon) const
              && !mon->confused()
              && !mon->asleep() && !mon->cannot_move()
              && !mon->berserk() && !mons_is_fleeing(mon)
-             && !is_sanctuary(you.pos())
+             && !is_sanctuary(pos())
            || player_equip_unrand_effect(UNRAND_DEMON_AXE)));
 }
diff --git a/crawl-ref/source/fearmonger.cc b/crawl-ref/source/fearmonger.cc
index 9bf3373..fa08a93 100644
--- a/crawl-ref/source/fearmonger.cc
+++ b/crawl-ref/source/fearmonger.cc
@@ -18,9 +18,9 @@
 // Add a monster to the list of fearmongers.
 bool player::add_fearmonger(const monster* mon)
 {
-    if (is_sanctuary(you.pos()))
+    if (is_sanctuary(pos()))
     {
-        if (you.can_see(mon))
+        if (can_see(mon))
         {
             mprf("%s's aura of fear is muted, and has no effect on you.",
                  mon->name(DESC_THE).c_str());
@@ -33,14 +33,14 @@ bool player::add_fearmonger(const monster* mon)
 
     if (!duration[DUR_AFRAID])
     {
-        you.set_duration(DUR_AFRAID, 7, 12);
+        set_duration(DUR_AFRAID, 7, 12);
         fearmongers.push_back(mon->mindex());
         mprf(MSGCH_WARN, "You are terrified of %s!",
                          mon->name(DESC_THE).c_str());
     }
     else
     {
-        you.increase_duration(DUR_AFRAID, 5, 12);
+        increase_duration(DUR_AFRAID, 5, 12);
         if (!afraid_of(mon))
             fearmongers.push_back(mon->mindex());
     }
@@ -187,5 +187,5 @@ bool player::_possible_fearmonger(const monster* mon) const
          && !mon->asleep() && !mon->cannot_move()
          && !mon->wont_attack() && !mon->pacified()
          && !mon->berserk() && !mons_is_fleeing(mon)
-         && !is_sanctuary(you.pos()));
+         && !is_sanctuary(pos()));
 }
diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc
index e877934..411833b 100644
--- a/crawl-ref/source/monster.cc
+++ b/crawl-ref/source/monster.cc
@@ -2460,7 +2460,7 @@ item_def *monster::mslot_item(mon_inv_type mslot) const
     return (mi == NON_ITEM ? NULL : &mitm[mi]);
 }
 
-item_def *monster::shield()
+item_def *monster::shield() const
 {
     return mslot_item(MSLOT_SHIELD);
 }
diff --git a/crawl-ref/source/monster.h b/crawl-ref/source/monster.h
index 13f9a81..4046e93 100644
--- a/crawl-ref/source/monster.h
+++ b/crawl-ref/source/monster.h
@@ -238,7 +238,7 @@ public:
     item_def *weapon(int which_attack = -1) const;
     item_def *launcher();
     item_def *missiles();
-    item_def *shield();
+    item_def *shield() const;
 
     bool      can_wield(const item_def &item,
                         bool ignore_curse = false,
diff --git a/crawl-ref/source/place-info.cc b/crawl-ref/source/place-info.cc
index d0122e1..49cb365 100644
--- a/crawl-ref/source/place-info.cc
+++ b/crawl-ref/source/place-info.cc
@@ -127,7 +127,7 @@ PlaceInfo& player::get_place_info(branch_type branch) const
 
 void player::clear_place_info()
 {
-    you.global_info = PlaceInfo();
+    global_info = PlaceInfo();
     for (unsigned int i = 0; i < NUM_BRANCHES; ++i)
         branch_info[i] = PlaceInfo();
 }
diff --git a/crawl-ref/source/player-act.cc b/crawl-ref/source/player-act.cc
index d5ea690..c55b1f7 100644
--- a/crawl-ref/source/player-act.cc
+++ b/crawl-ref/source/player-act.cc
@@ -102,7 +102,7 @@ void player::set_position(const coord_def &c)
     {
         reset_prev_move();
 
-        if (you.duration[DUR_QUAD_DAMAGE])
+        if (duration[DUR_QUAD_DAMAGE])
             invalidate_agrid(true);
 
         if (player_has_orb())
@@ -226,9 +226,9 @@ brand_type player::damage_brand(int)
     brand_type ret = SPWPN_NORMAL;
     const int wpn = equip[EQ_WEAPON];
 
-    if (wpn != -1 && !you.melded[EQ_WEAPON])
+    if (wpn != -1 && !melded[EQ_WEAPON])
     {
-        if (!is_range_weapon(inv[wpn]) && !you.suppressed())
+        if (!is_range_weapon(inv[wpn]) && !suppressed())
             ret = get_weapon_brand(inv[wpn]);
     }
     else if (duration[DUR_CONFUSING_TOUCH])
@@ -281,7 +281,7 @@ item_def *player::slot_item(equipment_type eq, bool include_melded) const
 // Returns the item in the player's weapon slot.
 item_def *player::weapon(int /* which_attack */) const
 {
-    if (you.melded[EQ_WEAPON])
+    if (melded[EQ_WEAPON])
         return NULL;
 
     return slot_item(EQ_WEAPON, false);
@@ -344,7 +344,7 @@ bool player::could_wield(const item_def &item, bool ignore_brand,
 }
 
 // Returns the shield the player is wearing, or NULL if none.
-item_def *player::shield()
+item_def *player::shield() const
 {
     return slot_item(EQ_SHIELD, false);
 }
@@ -417,9 +417,9 @@ string player::hand_name(bool plural, bool *can_plural) const
     {
         if (species == SP_FELID)
             str = "paw";
-        else if (you.has_usable_claws())
+        else if (has_usable_claws())
             str = "claw";
-        else if (you.has_usable_tentacles())
+        else if (has_usable_tentacles())
             str = "tentacle";
     }
 
@@ -454,9 +454,9 @@ string player::foot_name(bool plural, bool *can_plural) const
     {
         if (player_mutation_level(MUT_HOOVES) >= 3)
             str = "hoof";
-        else if (you.has_usable_talons())
+        else if (has_usable_talons())
             str = "talon";
-        else if (you.has_usable_tentacles())
+        else if (has_usable_tentacles())
         {
             str         = "tentacles";
             *can_plural = false;
@@ -665,7 +665,7 @@ bool player::can_go_berserk(bool intentional, bool potion, bool quiet) const
         return false;
     }
 
-    if (!you.can_bleed(false))
+    if (!can_bleed(false))
     {
         // XXX: This message assumes that you're undead.
         if (verbose)
@@ -675,7 +675,7 @@ bool player::can_go_berserk(bool intentional, bool potion, bool quiet) const
         return false;
     }
 
-    if (you.species == SP_GARGOYLE && you.petrifying())
+    if (species == SP_GARGOYLE && petrifying())
     {
         if (verbose)
             mpr("You cannot rage while you turn to stone.");
@@ -686,23 +686,23 @@ bool player::can_go_berserk(bool intentional, bool potion, bool quiet) const
     // trigger when the player attempts to activate berserk,
     // auto-iding at that point, but also killing the berserk and
     // wasting a turn.
-    if (you.stasis(false))
+    if (stasis(false))
     {
         if (verbose)
         {
-            const item_def *amulet = you.slot_item(EQ_AMULET, false);
+            const item_def *amulet = slot_item(EQ_AMULET, false);
             mprf("You cannot go berserk with %s on.",
                  amulet? amulet->name(DESC_YOUR).c_str() : "your amulet");
         }
         return false;
     }
 
-    if (!intentional && !potion && you.clarity())
+    if (!intentional && !potion && clarity())
     {
         if (verbose)
         {
             mpr("You're too calm and focused to rage.");
-            if (!you.clarity(false))
+            if (!clarity(false))
                 maybe_id_clarity();
         }
 
@@ -710,7 +710,7 @@ bool player::can_go_berserk(bool intentional, bool potion, bool quiet) const
     }
 
     ASSERT(HUNGER_STARVING - 100 + BERSERK_NUTRITION < 2066);
-    if (you.hunger <= 2066)
+    if (hunger <= 2066)
     {
         if (verbose)
             mpr("You're too hungry to go berserk.");
@@ -727,7 +727,7 @@ bool player::berserk() const
 
 bool player::can_cling_to_walls() const
 {
-    return you.form == TRAN_SPIDER;
+    return form == TRAN_SPIDER;
 }
 
 bool player::is_web_immune() const
@@ -740,7 +740,7 @@ bool player::shove(const char* feat_name)
 {
     for (distance_iterator di(pos()); di; ++di)
         if (in_bounds(*di) && !actor_at(*di) && !is_feat_dangerous(grd(*di))
-            && you.can_pass_through_feat(grd(*di)))
+            && can_pass_through_feat(grd(*di)))
         {
             moveto(*di);
             if (*feat_name)
@@ -753,5 +753,5 @@ bool player::shove(const char* feat_name)
 
 int player::constriction_damage() const
 {
-    return roll_dice(2, div_rand_round(you.strength(), 5));
+    return roll_dice(2, div_rand_round(strength(), 5));
 }
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 6e34a93..8b92000 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -1736,7 +1736,7 @@ bool player::res_corr(bool calc_unid, bool items) const
     if (religion == GOD_JIYVA && piety >= piety_breakpoint(2))
         return true;
 
-    if (you.form == TRAN_JELLY || you.form == TRAN_WISP)
+    if (form == TRAN_JELLY || form == TRAN_WISP)
         return 1;
 
     if (items && !suppressed())
@@ -1749,8 +1749,8 @@ bool player::res_corr(bool calc_unid, bool items) const
         }
     }
 
-    if ((form_keeps_mutations() || you.form == TRAN_DRAGON)
-        && you.species == SP_YELLOW_DRACONIAN)
+    if ((form_keeps_mutations() || form == TRAN_DRAGON)
+        && species == SP_YELLOW_DRACONIAN)
     {
         return true;
     }
@@ -4561,20 +4561,20 @@ int player::scan_artefacts(artefact_prop_type which_property,
 
     for (int i = EQ_WEAPON; i < NUM_EQUIP; ++i)
     {
-        if (you.melded[i] || you.equip[i] == -1)
+        if (melded[i] || equip[i] == -1)
             continue;
 
-        const int eq = you.equip[i];
+        const int eq = equip[i];
 
         // Only weapons give their effects when in our hands.
-        if (i == EQ_WEAPON && you.inv[ eq ].base_type != OBJ_WEAPONS)
+        if (i == EQ_WEAPON && inv[ eq ].base_type != OBJ_WEAPONS)
             continue;
 
-        if (!is_artefact(you.inv[ eq ]))
+        if (!is_artefact(inv[ eq ]))
             continue;
 
         bool known;
-        int val = artefact_wpn_property(you.inv[eq], which_property, known);
+        int val = artefact_wpn_property(inv[eq], which_property, known);
         if (calc_unid || known)
             retval += val;
     }
@@ -6017,7 +6017,7 @@ player::~player()
 flight_type player::flight_mode() const
 {
     if (duration[DUR_FLIGHT]
-        || you.attribute[ATTR_PERM_FLIGHT]
+        || attribute[ATTR_PERM_FLIGHT]
         || form == TRAN_WISP
         // dragon and bat should be FL_WINGED, but we don't want paralysis
         // instakills over lava
@@ -6095,7 +6095,7 @@ bool player::cannot_speak() const
 
 string player::shout_verb() const
 {
-    switch (you.form)
+    switch (form)
     {
     case TRAN_DRAGON:
         return "roar";
@@ -6118,7 +6118,7 @@ string player::shout_verb() const
         return "whoosh"; // any wonder why?
 
     default:
-        if (you.species == SP_FELID)
+        if (species == SP_FELID)
             return coinflip() ? "meow" : "yowl";
         // depends on SCREAM mutation
         int level = player_mutation_level(MUT_SCREAM);
@@ -6142,7 +6142,7 @@ void player::banish(actor *agent, const string &who)
     if (brdepth[BRANCH_ABYSS] == -1)
         return;
 
-    if (you.elapsed_time <= you.attribute[ATTR_BANISHMENT_IMMUNITY])
+    if (elapsed_time <= attribute[ATTR_BANISHMENT_IMMUNITY])
     {
         mpr("You resist the pull of the Abyss.");
         return;
@@ -6231,11 +6231,11 @@ void player::shield_block_succeeded(actor *foe)
 
 int player::missile_deflection() const
 {
-    if (you.duration[DUR_DEFLECT_MISSILES])
+    if (duration[DUR_DEFLECT_MISSILES])
         return 2;
-    if (you.duration[DUR_REPEL_MISSILES]
+    if (duration[DUR_REPEL_MISSILES]
         || player_mutation_level(MUT_DISTORTION_FIELD) == 3
-        || (!you.suppressed() && you.scan_artefacts(ARTP_RMSL, true)))
+        || (!suppressed() && scan_artefacts(ARTP_RMSL, true)))
     {
         return 1;
     }
@@ -6261,7 +6261,7 @@ int player::adjusted_body_armour_penalty(int scale, bool use_size) const
 
     if (use_size)
     {
-        const int size = you.body_size(PSIZE_BODY);
+        const int size = body_size(PSIZE_BODY);
 
         const int size_bonus_factor = (size - SIZE_MEDIUM) * scale / 4;
 
@@ -6280,12 +6280,12 @@ int player::adjusted_body_armour_penalty(int scale, bool use_size) const
 // The EV penalty to the player for wearing their current shield.
 int player::adjusted_shield_penalty(int scale) const
 {
-    const item_def *shield_l = you.slot_item(EQ_SHIELD, false);
+    const item_def *shield_l = slot_item(EQ_SHIELD, false);
     if (!shield_l)
         return 0;
 
     const int base_shield_penalty = -property(*shield_l, PARM_EVASION);
-    return max(0, (base_shield_penalty * scale - you.skill(SK_SHIELDS, scale)
+    return max(0, (base_shield_penalty * scale - skill(SK_SHIELDS, scale)
                   / max(1, 5 + _player_evasion_size_factor())));
 }
 
@@ -6308,14 +6308,17 @@ int player::skill(skill_type sk, int scale, bool real) const
     int level = skills[sk] * scale + get_skill_progress(sk, scale);
     if (real)
         return level;
-    if (you.duration[DUR_HEROISM] && sk <= SK_LAST_MUNDANE)
+    if (duration[DUR_HEROISM] && sk <= SK_LAST_MUNDANE)
         level = min(level + 5 * scale, 27 * scale);
-    if (you.penance[GOD_ASHENZARI])
+    if (penance[GOD_ASHENZARI])
         level = max(level - min(4 * scale, level / 2), 0);
-    else if (you.religion == GOD_ASHENZARI && you.skill_boost[sk]
-             && piety_rank() > 2)
+    else if (religion == GOD_ASHENZARI && piety_rank() > 2)
     {
-        level = ash_skill_boost(sk, scale);
+        if (skill_boost.find(sk) != skill_boost.end()
+            && skill_boost.find(sk)->second)
+        {
+            level = ash_skill_boost(sk, scale);
+        }
     }
 
     return level;
@@ -6400,17 +6403,17 @@ int player::armour_class() const
     }
 
     // All effects negated by magical suppression should go in here.
-    if (!you.suppressed())
+    if (!suppressed())
     {
-        AC += you.wearing(EQ_RINGS_PLUS, RING_PROTECTION) * 100;
+        AC += wearing(EQ_RINGS_PLUS, RING_PROTECTION) * 100;
 
-        if (you.wearing_ego(EQ_WEAPON, SPWPN_PROTECTION))
+        if (wearing_ego(EQ_WEAPON, SPWPN_PROTECTION))
             AC += 500;
 
-        if (you.wearing_ego(EQ_SHIELD, SPARM_PROTECTION))
+        if (wearing_ego(EQ_SHIELD, SPARM_PROTECTION))
             AC += 300;
 
-        AC += you.scan_artefacts(ARTP_AC) * 100;
+        AC += scan_artefacts(ARTP_AC) * 100;
     }
 
     if (duration[DUR_ICY_ARMOUR])
@@ -6433,7 +6436,7 @@ int player::armour_class() const
 
         if (player_genus(GENPC_DRACONIAN))
         {
-            AC += 400 + 100 * (you.experience_level / 3);  // max 13
+            AC += 400 + 100 * (experience_level / 3);  // max 13
             if (species == SP_GREY_DRACONIAN) // no breath
                 AC += 500;
             if (form == TRAN_DRAGON)
@@ -6481,7 +6484,7 @@ int player::armour_class() const
             break;
 
         case TRAN_WISP:
-            AC += 500 + 50 * you.experience_level;
+            AC += 500 + 50 * experience_level;
             break;
         case TRAN_FUNGUS:
             AC += 1200;
@@ -6496,7 +6499,7 @@ int player::armour_class() const
             break;
 
         case TRAN_TREE: // extreme bonus, no EV
-            AC += 2000 + 50 * you.experience_level;
+            AC += 2000 + 50 * experience_level;
             break;
         }
     }
@@ -6543,7 +6546,7 @@ int player::armour_class() const
   **/
 int player::gdr_perc() const
 {
-    switch (you.form)
+    switch (form)
     {
     case TRAN_DRAGON:
         return 34; // base AC 8
@@ -6600,7 +6603,7 @@ mon_holy_type player::holiness() const
 bool player::undead_or_demonic() const
 {
     // This is only for TSO-related stuff, so demonspawn are included.
-    return you.is_undead || you.species == SP_DEMONSPAWN;
+    return is_undead || species == SP_DEMONSPAWN;
 }
 
 bool player::is_holy(bool check_spells) const
@@ -6613,7 +6616,7 @@ bool player::is_holy(bool check_spells) const
 
 bool player::is_unholy(bool check_spells) const
 {
-    return you.species == SP_DEMONSPAWN;
+    return species == SP_DEMONSPAWN;
 }
 
 bool player::is_evil(bool check_spells) const
@@ -6642,7 +6645,7 @@ bool player::is_artificial() const
 
 bool player::is_unbreathing() const
 {
-    switch (you.form)
+    switch (form)
     {
     case TRAN_LICH:
     case TRAN_STATUE:
@@ -6663,7 +6666,7 @@ bool player::is_unbreathing() const
 
 bool player::is_insubstantial() const
 {
-    return you.form == TRAN_WISP;
+    return form == TRAN_WISP;
 }
 
 int player::res_acid(bool calc_unid) const
@@ -6678,7 +6681,7 @@ int player::res_fire() const
 
 int player::res_holy_fire() const
 {
-    if (you.species == SP_DJINNI)
+    if (species == SP_DJINNI)
         return 3;
     return actor::res_holy_fire();
 }
@@ -6703,16 +6706,16 @@ int player::res_water_drowning() const
     int rw = 0;
 
     if (is_unbreathing()
-        || you.species == SP_MERFOLK && !form_changed_physiology()
-        || you.species == SP_OCTOPODE && !form_changed_physiology()
-        || you.form == TRAN_ICE_BEAST)
+        || species == SP_MERFOLK && !form_changed_physiology()
+        || species == SP_OCTOPODE && !form_changed_physiology()
+        || form == TRAN_ICE_BEAST)
     {
         rw++;
     }
 
     // A fiery lich/hot statue suffers from quenching but not drowning, so
     // neutral resistance sounds ok.
-    if (you.species == SP_DJINNI)
+    if (species == SP_DJINNI)
         rw--;
 
     return rw;
@@ -6737,7 +6740,7 @@ int player::res_rotting(bool temp) const
     if (temp && (petrified() || form == TRAN_STATUE || form == TRAN_WISP))
         return 3;
 
-    if (you.mutation[MUT_FOUL_STENCH])
+    if (mutation[MUT_FOUL_STENCH])
         return 1;
 
     switch (is_undead)
@@ -6750,12 +6753,12 @@ int player::res_rotting(bool temp) const
         return 1; // rottable by Zin, not by necromancy
 
     case US_SEMI_UNDEAD:
-        if (temp && you.hunger_state < HS_SATIATED)
+        if (temp && hunger_state < HS_SATIATED)
             return 1;
         return 0; // no permanent resistance
 
     case US_UNDEAD:
-        if (!temp && you.form == TRAN_LICH)
+        if (!temp && form == TRAN_LICH)
             return 0;
         return 3; // full immunity
     }
@@ -6793,7 +6796,7 @@ int player::res_torment() const
 int player::res_wind() const
 {
     // Full control of the winds around you can negate a hostile tornado.
-    return you.duration[DUR_TORNADO] ? 1 : 0;
+    return duration[DUR_TORNADO] ? 1 : 0;
 }
 
 int player::res_petrify(bool temp) const
@@ -6801,15 +6804,15 @@ int player::res_petrify(bool temp) const
     if (player_mutation_level(MUT_PETRIFICATION_RESISTANCE))
         return 1;
 
-    if (temp && (you.form == TRAN_STATUE || you.form == TRAN_WISP))
+    if (temp && (form == TRAN_STATUE || form == TRAN_WISP))
         return 1;
     return 0;
 }
 
 int player::res_constrict() const
 {
-    if (you.form == TRAN_JELLY || you.form == TRAN_PORCUPINE
-        || you.form == TRAN_WISP)
+    if (form == TRAN_JELLY || form == TRAN_PORCUPINE
+        || form == TRAN_WISP)
     {
         return 3;
     }
@@ -6889,42 +6892,42 @@ int player_res_magic(bool calc_unid, bool temp)
 
 bool player::no_tele(bool calc_unid, bool permit_id, bool blinking) const
 {
-    if (you.duration[DUR_DIMENSION_ANCHOR])
+    if (duration[DUR_DIMENSION_ANCHOR])
         return true;
 
     if (crawl_state.game_is_sprint() && !blinking)
         return true;
 
-    if (you.form == TRAN_TREE)
+    if (form == TRAN_TREE)
         return true;
 
-    return (you.has_notele_item(calc_unid)
+    return (has_notele_item(calc_unid)
             || stasis_blocks_effect(calc_unid, permit_id, NULL)
-            || crawl_state.game_is_zotdef() && orb_haloed(you.pos()));
+            || crawl_state.game_is_zotdef() && orb_haloed(pos()));
 }
 
 bool player::fights_well_unarmed(int heavy_armour_penalty)
 {
-    return (you.burden_state == BS_UNENCUMBERED
-            && x_chance_in_y(you.skill(SK_UNARMED_COMBAT, 10), 200)
+    return (burden_state == BS_UNENCUMBERED
+            && x_chance_in_y(skill(SK_UNARMED_COMBAT, 10), 200)
             && x_chance_in_y(2, 1 + heavy_armour_penalty));
 }
 
 bool player::cancellable_flight() const
 {
-    return you.duration[DUR_FLIGHT] && !you.permanent_flight()
-           && !you.attribute[ATTR_FLIGHT_UNCANCELLABLE];
+    return duration[DUR_FLIGHT] && !permanent_flight()
+           && !attribute[ATTR_FLIGHT_UNCANCELLABLE];
 }
 
 bool player::permanent_flight() const
 {
-    return you.attribute[ATTR_PERM_FLIGHT];
+    return attribute[ATTR_PERM_FLIGHT];
 }
 
 bool player::racial_permanent_flight() const
 {
-    return (you.species == SP_TENGU && you.experience_level >= 15
-            || you.species == SP_BLACK_DRACONIAN && you.experience_level >= 14);
+    return (species == SP_TENGU && experience_level >= 15
+            || species == SP_BLACK_DRACONIAN && experience_level >= 14);
 }
 
 bool player::tengu_flight() const
@@ -6949,7 +6952,7 @@ reach_type player::reach_range() const
 
 monster_type player::mons_species(bool zombie_base) const
 {
-    return player_species_to_mons_species(you.species);
+    return player_species_to_mons_species(species);
 }
 
 bool player::poison(actor *agent, int amount, bool force)
@@ -6988,7 +6991,7 @@ int player::hurt(const actor *agent, int amount, beam_type flavour,
     {
         const monster* mon = agent->as_monster();
         ouch(amount, mon->mindex(),
-             KILLED_BY_MONSTER, "", mon->visible_to(&you), NULL,
+             KILLED_BY_MONSTER, "", mon->visible_to(this), NULL,
              attacker_effects);
     }
     else
@@ -7022,13 +7025,13 @@ bool player::rot(actor *who, int amount, int immediate, bool quiet)
     if (amount <= 0 && immediate <= 0)
         return false;
 
-    if (res_rotting() || you.duration[DUR_DEATHS_DOOR])
+    if (res_rotting() || duration[DUR_DEATHS_DOOR])
     {
         mpr("You feel terrible.");
         return false;
     }
 
-    if (you.duration[DUR_DIVINE_STAMINA] > 0)
+    if (duration[DUR_DIVINE_STAMINA] > 0)
     {
         mpr("Your divine stamina protects you from decay!");
         return false;
@@ -7097,7 +7100,7 @@ void player::paralyse(actor *who, int str, string source)
     if (!paralysis && !source.empty())
     {
         take_note(Note(NOTE_PARALYSIS, str, 0, source.c_str()));
-        you.props["paralysed_by"] = source;
+        props["paralysed_by"] = source;
     }
 
 
@@ -7118,39 +7121,39 @@ void player::petrify(actor *who, bool force)
 {
     ASSERT(!crawl_state.game_is_arena());
 
-    if (you.res_petrify() && !force)
+    if (res_petrify() && !force)
     {
         canned_msg(MSG_YOU_UNAFFECTED);
         return;
     }
 
-    if (you.duration[DUR_DIVINE_STAMINA] > 0)
+    if (duration[DUR_DIVINE_STAMINA] > 0)
     {
         mpr("Your divine stamina protects you from petrification!");
         return;
     }
 
-    if (you.petrifying())
+    if (petrifying())
     {
         mpr("Your limbs have turned to stone.");
-        you.duration[DUR_PETRIFYING] = 1;
+        duration[DUR_PETRIFYING] = 1;
         return;
     }
 
-    if (you.petrified())
+    if (petrified())
         return;
 
-    you.duration[DUR_PETRIFYING] = 3 * BASELINE_DELAY;
+    duration[DUR_PETRIFYING] = 3 * BASELINE_DELAY;
 
-    you.redraw_evasion = true;
+    redraw_evasion = true;
     mpr("You are slowing down.", MSGCH_WARN);
 }
 
 bool player::fully_petrify(actor *foe, bool quiet)
 {
-    you.duration[DUR_PETRIFIED] = 6 * BASELINE_DELAY
+    duration[DUR_PETRIFIED] = 6 * BASELINE_DELAY
                         + random2(4 * BASELINE_DELAY);
-    you.redraw_evasion = true;
+    redraw_evasion = true;
     mpr("You have turned to stone.");
     return true;
 }
@@ -7177,7 +7180,7 @@ int player::has_claws(bool allow_tran) const
             return 0;
     }
 
-    if (const int c = species_has_claws(you.species))
+    if (const int c = species_has_claws(species))
         return c;
 
     return player_mutation_level(MUT_CLAWS, allow_tran);
@@ -7191,7 +7194,7 @@ bool player::has_usable_claws(bool allow_tran) const
 int player::has_talons(bool allow_tran) const
 {
     // XXX: Do merfolk in water belong under allow_tran?
-    if (you.fishtail)
+    if (fishtail)
         return 0;
 
     return player_mutation_level(MUT_TALONS, allow_tran);
@@ -7234,7 +7237,7 @@ int player::has_tail(bool allow_tran) const
 
     // XXX: Do merfolk in water belong under allow_tran?
     if (player_genus(GENPC_DRACONIAN)
-        || you.fishtail
+        || fishtail
         || player_mutation_level(MUT_STINGER, allow_tran))
     {
         return 1;
@@ -7247,7 +7250,7 @@ int player::has_usable_tail(bool allow_tran) const
 {
     // TSO worshippers don't use their stinger in order
     // to avoid poisoning.
-    if (you.religion == GOD_SHINING_ONE
+    if (religion == GOD_SHINING_ONE
         && player_mutation_level(MUT_STINGER, allow_tran) > 0)
     {
         return 0;
@@ -7281,7 +7284,7 @@ int player::usable_tentacles() const
 
     int free_tentacles = numtentacle - num_constricting();
 
-    if (you.shield())
+    if (shield())
         free_tentacles -= 2;
 
     const item_def* wp = slot_item(EQ_WEAPON);
@@ -7313,7 +7316,7 @@ int player::has_tentacles(bool allow_tran) const
             return 0;
     }
 
-    if (you.species == SP_OCTOPODE)
+    if (species == SP_OCTOPODE)
         return 8;
 
     return 0;
@@ -7331,7 +7334,7 @@ bool player::sicken(int amount, bool allow_hint, bool quiet)
     if (res_rotting() || amount <= 0)
         return false;
 
-    if (you.duration[DUR_DIVINE_STAMINA] > 0)
+    if (duration[DUR_DIVINE_STAMINA] > 0)
     {
         mpr("Your divine stamina protects you from disease!");
         return false;
@@ -7355,13 +7358,13 @@ bool player::can_see_invisible(bool calc_unid, bool items) const
         return true;
 
     // All effects negated by magical suppression should go in here.
-    if (items && !you.suppressed())
+    if (items && !suppressed())
     {
-        if (you.wearing(EQ_RINGS, RING_SEE_INVISIBLE, calc_unid)
+        if (wearing(EQ_RINGS, RING_SEE_INVISIBLE, calc_unid)
             // armour: (checks head armour only)
-            || you.wearing_ego(EQ_HELMET, SPARM_SEE_INVISIBLE)
+            || wearing_ego(EQ_HELMET, SPARM_SEE_INVISIBLE)
             // randart gear
-            || you.scan_artefacts(ARTP_EYESIGHT, calc_unid) > 0)
+            || scan_artefacts(ARTP_EYESIGHT, calc_unid) > 0)
         {
             return true;
         }
@@ -7381,7 +7384,7 @@ bool player::can_see_invisible(bool calc_unid, bool items) const
     if (player_mutation_level(MUT_EYEBALLS) == 3)
         return true;
 
-    if (you.religion == GOD_ASHENZARI && you.piety >= piety_breakpoint(2)
+    if (religion == GOD_ASHENZARI && piety >= piety_breakpoint(2)
         && !player_under_penance())
     {
         return true;
@@ -7452,18 +7455,18 @@ void player::backlight()
 {
     if (!duration[DUR_INVIS])
     {
-        if (duration[DUR_CORONA] || you.glows_naturally())
+        if (duration[DUR_CORONA] || glows_naturally())
             mpr("You glow brighter.");
         else
             mpr("You are outlined in light.");
 
-        you.increase_duration(DUR_CORONA, random_range(15, 35), 250);
+        increase_duration(DUR_CORONA, random_range(15, 35), 250);
     }
     else
     {
         mpr("You feel strangely conspicuous.");
 
-        you.increase_duration(DUR_CORONA, random_range(3, 5), 250);
+        increase_duration(DUR_CORONA, random_range(3, 5), 250);
     }
 }
 
@@ -7491,9 +7494,9 @@ bool player::can_safely_mutate() const
 
 bool player::can_polymorph() const
 {
-    if (you.transform_uncancellable)
+    if (transform_uncancellable)
         return false;
-    if (you.is_undead)
+    if (is_undead)
         return is_undead == US_SEMI_UNDEAD && hunger_state > HS_SATIATED;
     return true;
 }
@@ -7503,9 +7506,9 @@ bool player::can_bleed(bool allow_tran) const
     if (allow_tran)
     {
         // These transformations don't bleed. Lichform is handled as undead.
-        if (you.form == TRAN_STATUE || you.form == TRAN_ICE_BEAST
-            || you.form == TRAN_SPIDER || you.form == TRAN_TREE
-            || you.form == TRAN_FUNGUS || you.form == TRAN_PORCUPINE)
+        if (form == TRAN_STATUE || form == TRAN_ICE_BEAST
+            || form == TRAN_SPIDER || form == TRAN_TREE
+            || form == TRAN_FUNGUS || form == TRAN_PORCUPINE)
         {
             return false;
         }
@@ -7574,7 +7577,7 @@ bool player::polymorph(int pow)
 
     if (f && transform(pow, f))
     {
-        you.transform_uncancellable = true;
+        transform_uncancellable = true;
         return true;
     }
     return false;
@@ -7794,15 +7797,15 @@ void player::increase_duration(duration_type dur, int turns, int cap,
         mpr(msg);
     cap *= BASELINE_DELAY;
 
-    you.duration[dur] += turns * BASELINE_DELAY;
-    if (cap && you.duration[dur] > cap)
-        you.duration[dur] = cap;
+    duration[dur] += turns * BASELINE_DELAY;
+    if (cap && duration[dur] > cap)
+        duration[dur] = cap;
 }
 
 void player::set_duration(duration_type dur, int turns,
                           int cap, const char * msg)
 {
-    you.duration[dur] = 0;
+    duration[dur] = 0;
     increase_duration(dur, turns, cap, msg);
 }
 
@@ -7810,7 +7813,7 @@ void player::goto_place(const level_id &lid)
 {
     where_are_you = static_cast<branch_type>(lid.branch);
     depth = lid.depth;
-    ASSERT_RANGE(depth, 1, brdepth[you.where_are_you] + 1);
+    ASSERT_RANGE(depth, 1, brdepth[where_are_you] + 1);
 }
 
 bool player::attempt_escape(int attempts)
@@ -7843,7 +7846,7 @@ bool player::attempt_escape(int attempts)
         emsg += themonst->name(DESC_THE, true);
         emsg += " fails, but you feel that another attempt might succeed.";
         mpr(emsg);
-        you.turn_is_over = true;
+        turn_is_over = true;
         return false;
     }
 }
@@ -7853,12 +7856,12 @@ void player::sentinel_mark(bool trap)
     if (duration[DUR_SENTINEL_MARK])
     {
         mpr("The mark upon you grows brighter.");
-        you.increase_duration(DUR_SENTINEL_MARK, random_range(30, 50), 250);
+        increase_duration(DUR_SENTINEL_MARK, random_range(30, 50), 250);
     }
     else
     {
         mpr("A sentinel's mark forms upon you.", MSGCH_WARN);
-        you.increase_duration(DUR_SENTINEL_MARK, (trap ? random_range(35, 55)
+        increase_duration(DUR_SENTINEL_MARK, (trap ? random_range(35, 55)
                                                        : random_range(50, 80)),
                               250);
     }
@@ -7866,18 +7869,18 @@ void player::sentinel_mark(bool trap)
 
 bool player::made_nervous_by(const coord_def &p)
 {
-    if (you.form != TRAN_FUNGUS)
+    if (form != TRAN_FUNGUS)
         return false;
     monster* mons = monster_at(p);
     if (mons && !mons_is_firewood(mons))
         return false;
-    for (monster_iterator mi(you.get_los()); mi; ++mi)
+    for (monster_iterator mi(get_los()); mi; ++mi)
     {
             if (!(mons_is_wandering(*mi)
                         || mi->asleep()
                         || mi->confused()
                         || mi->cannot_act())
-                && you.see_cell(mi->pos())
+                && see_cell(mi->pos())
                 && !mons_is_firewood(*mi)
                 && !mi->neutral())
                 return true;
@@ -7892,7 +7895,7 @@ void player::weaken(actor *attacker, int pow)
     else
         mpr("You feel as though you will be weak longer.", MSGCH_WARN);
 
-    you.increase_duration(DUR_WEAK, pow + random2(pow + 3), 50);
+    increase_duration(DUR_WEAK, pow + random2(pow + 3), 50);
 }
 
 /*
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index 188fd4c..41ad141 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -535,7 +535,7 @@ public:
                        bool calc_unid = true) const;
 
     item_def *weapon(int which_attack = -1) const;
-    item_def *shield();
+    item_def *shield() const;
 
     bool      can_wield(const item_def &item,
                         bool ignore_curse = false,
diff --git a/crawl-ref/source/teleport.cc b/crawl-ref/source/teleport.cc
index caa6ceb..5c39c9e 100644
--- a/crawl-ref/source/teleport.cc
+++ b/crawl-ref/source/teleport.cc
@@ -33,7 +33,7 @@ bool player::blink_to(const coord_def& dest, bool quiet)
     if (dest == pos())
         return false;
 
-    if (you.no_tele(true, true, true))
+    if (no_tele(true, true, true))
     {
         if (!quiet)
             canned_msg(MSG_STRANGE_STASIS);
-- 
1.8.2.3

