Skip to content

Commit

Permalink
Fix "Test from here" position being overriden by save file
Browse files Browse the repository at this point in the history
  • Loading branch information
Vankata453 committed Jul 19, 2023
1 parent 36c8ca7 commit b35f247
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/supertux/game_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ GameManager::start_worldmap(const World& world, const std::string& worldmap_file
{
start_worldmap(world, worldmap_filename, start_pos ? start_pos->first : "");
if (start_pos)
worldmap::WorldMapSector::current()->get_tux().set_pos(start_pos->second);
worldmap::WorldMapSector::current()->get_tux().set_initial_pos(start_pos->second);
}

bool
Expand Down
7 changes: 6 additions & 1 deletion src/worldmap/tux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ Tux::Tux(WorldMap* worldmap) :
m_controller(InputManager::current()->get_controller()),
m_input_direction(Direction::NONE),
m_direction(Direction::NONE),
m_tile_pos(0.0f, 0.0f),
m_initial_tile_pos(),
m_tile_pos(),
m_offset(0),
m_moving(false),
m_ghost_mode(false)
Expand Down Expand Up @@ -371,6 +372,10 @@ Tux::update(float dt_sec)
void
Tux::setup()
{
// Set initial tile position, if provided
if (m_initial_tile_pos != Vector())
m_tile_pos = m_initial_tile_pos;

// check if we already touch a SpriteChange object
auto sprite_change = m_worldmap->get_sector().at_object<SpriteChange>(m_tile_pos);
change_sprite(sprite_change);
Expand Down
3 changes: 2 additions & 1 deletion src/worldmap/tux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Tux final : public GameObject
Vector get_pos() const;
Vector get_axis() const;
Vector get_tile_pos() const { return m_tile_pos; }
void set_pos(const Vector& pos) { m_tile_pos = pos / 32.f; }
void set_initial_pos(const Vector& pos) { m_initial_tile_pos = pos / 32.f; }
void set_tile_pos(const Vector& pos) { m_tile_pos = pos; }

void process_special_tile(SpecialTile* special_tile);
Expand All @@ -76,6 +76,7 @@ class Tux final : public GameObject

Direction m_input_direction;
Direction m_direction;
Vector m_initial_tile_pos;
Vector m_tile_pos;
/** Length by which tux is away from its current tile, length is in
input_direction direction */
Expand Down

0 comments on commit b35f247

Please sign in to comment.