X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fworldmap%2Ftux.cpp;h=f505fc263a5fb935456b054f59fc201a0fdabc06;hb=8b8e1c3576cedddb1d88eafa5fd4804e8257793c;hp=2e89f04803cdf66101039facf9be28e71b4b0aa7;hpb=a113d3bd1feddd510e3b2852b0d42522735eee40;p=supertux.git diff --git a/src/worldmap/tux.cpp b/src/worldmap/tux.cpp index 2e89f0480..f505fc263 100644 --- a/src/worldmap/tux.cpp +++ b/src/worldmap/tux.cpp @@ -20,6 +20,7 @@ #include #include "tux.hpp" +#include "sprite/sprite.hpp" #include "sprite/sprite_manager.hpp" #include "video/drawing_context.hpp" #include "player_status.hpp" @@ -29,13 +30,14 @@ #include "sprite_change.hpp" #include "control/joystickkeyboardcontroller.hpp" #include "scripting/squirrel_util.hpp" +#include "tile.hpp" #include "main.hpp" namespace WorldMapNS { static const float TUXSPEED = 200; -static const float map_message_TIME = 2.8; +static const float map_message_TIME = 2.8f; Tux::Tux(WorldMap* worldmap_) : worldmap(worldmap_) @@ -144,12 +146,12 @@ Tux::tryStartWalking() } bool -Tux::canWalk(const Tile* tile, Direction dir) +Tux::canWalk(int tile_data, Direction dir) { - return ((tile->getData() & Tile::WORLDMAP_NORTH && dir == D_NORTH) || - (tile->getData() & Tile::WORLDMAP_SOUTH && dir == D_SOUTH) || - (tile->getData() & Tile::WORLDMAP_EAST && dir == D_EAST) || - (tile->getData() & Tile::WORLDMAP_WEST && dir == D_WEST)); + return ((tile_data & Tile::WORLDMAP_NORTH && dir == D_NORTH) || + (tile_data & Tile::WORLDMAP_SOUTH && dir == D_SOUTH) || + (tile_data & Tile::WORLDMAP_EAST && dir == D_EAST) || + (tile_data & Tile::WORLDMAP_WEST && dir == D_WEST)); } void @@ -180,9 +182,9 @@ Tux::tryContinueWalking(float elapsed_time) // direction and the apply_action_ are opposites, since they "see" // directions in a different way if((direction == D_NORTH && special_tile->apply_action_south) || - (direction == D_SOUTH && special_tile->apply_action_north) || - (direction == D_WEST && special_tile->apply_action_east) || - (direction == D_EAST && special_tile->apply_action_west)) + (direction == D_SOUTH && special_tile->apply_action_north) || + (direction == D_WEST && special_tile->apply_action_east) || + (direction == D_EAST && special_tile->apply_action_west)) { if(special_tile->passive_message) { worldmap->passive_message = special_tile->map_message; @@ -204,7 +206,7 @@ Tux::tryContinueWalking(float elapsed_time) // stop if we reached a level, a WORLDMAP_STOP tile, a teleporter or a special tile without a passive_message if ((worldmap->at_level()) - || (worldmap->at(tile_pos)->getData() & Tile::WORLDMAP_STOP) + || (worldmap->tile_data_at(tile_pos) & Tile::WORLDMAP_STOP) || (special_tile && !special_tile->passive_message && special_tile->script == "") || (teleporter)) { @@ -216,21 +218,19 @@ Tux::tryContinueWalking(float elapsed_time) } // if user wants to change direction, try changing, else guess the direction in which to walk next - const Tile* tile = worldmap->at(tile_pos); - if (direction != input_direction) { - if(canWalk(tile, input_direction)) { - direction = input_direction; - back_direction = reverse_dir(direction); - } + const int tile_data = worldmap->tile_data_at(tile_pos); + if ((direction != input_direction) && canWalk(tile_data, input_direction)) { + direction = input_direction; + back_direction = reverse_dir(direction); } else { Direction dir = D_NONE; - if (tile->getData() & Tile::WORLDMAP_NORTH && back_direction != D_NORTH) + if (tile_data & Tile::WORLDMAP_NORTH && back_direction != D_NORTH) dir = D_NORTH; - else if (tile->getData() & Tile::WORLDMAP_SOUTH && back_direction != D_SOUTH) + else if (tile_data & Tile::WORLDMAP_SOUTH && back_direction != D_SOUTH) dir = D_SOUTH; - else if (tile->getData() & Tile::WORLDMAP_EAST && back_direction != D_EAST) + else if (tile_data & Tile::WORLDMAP_EAST && back_direction != D_EAST) dir = D_EAST; - else if (tile->getData() & Tile::WORLDMAP_WEST && back_direction != D_WEST) + else if (tile_data & Tile::WORLDMAP_WEST && back_direction != D_WEST) dir = D_WEST; if (dir == D_NONE) { @@ -251,7 +251,7 @@ Tux::tryContinueWalking(float elapsed_time) Vector next_tile; if (!worldmap->path_ok(direction, tile_pos, &next_tile)) { - log_warning << "Tilemap data is buggy" << std::endl; + log_debug << "Tilemap data is buggy" << std::endl; stop(); return; }