Made code -Wshadow clean, missed a bunch of issues in the last commit
[supertux.git] / src / worldmap / tux.cpp
index 7503d62..95c1c3d 100644 (file)
@@ -1,5 +1,5 @@
 //  SuperTux -  A Jump'n Run
-//  Copyright (C) 2004 Ingo Ruhnke <grumbel@gmx.de>
+//  Copyright (C) 2004 Ingo Ruhnke <grumbel@gmail.com>
 //  Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
 //
 //  This program is free software: you can redistribute it and/or modify
 //  You should have received a copy of the GNU General Public License
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-#include "control/joystickkeyboardcontroller.hpp"
+#include "control/input_manager.hpp"
 #include "scripting/squirrel_util.hpp"
 #include "sprite/sprite.hpp"
 #include "sprite/sprite_manager.hpp"
 #include "supertux/globals.hpp"
 #include "supertux/player_status.hpp"
+#include "supertux/savegame.hpp"
 #include "supertux/tile.hpp"
 #include "worldmap/level.hpp"
 #include "worldmap/tux.hpp"
@@ -59,13 +60,16 @@ Tux::~Tux()
 void
 Tux::draw(DrawingContext& context)
 {
-  switch (worldmap->get_player_status()->bonus) {
+  switch (worldmap->get_savegame().get_player_status()->bonus) {
     case GROWUP_BONUS:
       sprite->set_action(moving ? "large-walking" : "large-stop");
       break;
     case FIRE_BONUS:
       sprite->set_action(moving ? "fire-walking" : "fire-stop");
       break;
+    case ICE_BONUS:
+      sprite->set_action(moving ? "ice-walking" : "ice-stop");
+      break;
     case NO_BONUS:
       sprite->set_action(moving ? "small-walking" : "small-stop");
       break;
@@ -144,7 +148,7 @@ Tux::tryStartWalking()
 
   // We got a new direction, so lets start walking when possible
   Vector next_tile;
-  if ((!level || level->solved)
+  if ((!level || level->solved || level->perfect)
       && worldmap->path_ok(input_direction, tile_pos, &next_tile)) {
     tile_pos = next_tile;
     moving = true;
@@ -161,7 +165,7 @@ Tux::tryStartWalking()
 bool
 Tux::canWalk(int tile_data, Direction dir)
 {
-  return ghost_mode || 
+  return ghost_mode ||
     ((tile_data & Tile::WORLDMAP_NORTH && dir == D_NORTH) ||
      (tile_data & Tile::WORLDMAP_SOUTH && dir == D_SOUTH) ||
      (tile_data & Tile::WORLDMAP_EAST  && dir == D_EAST) ||
@@ -287,14 +291,14 @@ Tux::tryContinueWalking(float elapsed_time)
 void
 Tux::updateInputDirection()
 {
-  Controller *controller = g_jk_controller->get_main_controller();
-  if(controller->hold(Controller::UP))
+  Controller* controller_ = g_input_manager->get_controller();
+  if(controller_->hold(Controller::UP))
     input_direction = D_NORTH;
-  else if(controller->hold(Controller::DOWN))
+  else if(controller_->hold(Controller::DOWN))
     input_direction = D_SOUTH;
-  else if(controller->hold(Controller::LEFT))
+  else if(controller_->hold(Controller::LEFT))
     input_direction = D_WEST;
-  else if(controller->hold(Controller::RIGHT))
+  else if(controller_->hold(Controller::RIGHT))
     input_direction = D_EAST;
 }