From fec522f3c77696ea1d7907a1a2484910f8e391ca Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Tue, 19 Dec 2017 14:04:28 +0100 Subject: Fix panicking units stopping for no reason. --- src/common.hpp | 2 +- src/game/units.cpp | 4 +++- src/render.cpp | 11 +++-------- 3 files changed, 7 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/common.hpp b/src/common.hpp index 13b843d..a253da5 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -341,7 +341,7 @@ namespace render { void render_hlrect(rectf_t rect, sf::Color color); void render_line(v2f_t x0, v2f_t x1, sf::Color color); - void debug_path(std::list *path); + void debug_path(v2f_t x, std::list *path); }; } diff --git a/src/game/units.cpp b/src/game/units.cpp index e310026..021f4ac 100644 --- a/src/game/units.cpp +++ b/src/game/units.cpp @@ -42,7 +42,7 @@ void unit_t::render_to(render::state_t *render) } if (move.moving && debug_draw_paths) - render->debug_path(&move.path); + render->debug_path(x, &move.path); if (!dead && say_time + 5.0 > game->now) { v2f_t text_pos; @@ -417,6 +417,7 @@ void unit_soldier_t::on_think(void) if (!keep_moving(4.0)) say(text::get(text::SAY_BLOCKED)); } else { + move.moving = true; keep_moving(6.0); if (game->now >= panic_turn) { @@ -427,6 +428,7 @@ void unit_soldier_t::on_think(void) move.path.clear(); move.path.push_back(x + t * 10); panic_turn = game->now + 0.3; + std::cout << "panic_turn to " << x + t * 10 << "\n"; } } } diff --git a/src/render.cpp b/src/render.cpp index 8f2fdc7..76701b6 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -277,20 +277,15 @@ void state_t::render_line(v2f_t x0, v2f_t x1, sf::Color color) window->draw(line, 2, sf::Lines); } -void state_t::debug_path(std::list *path) +void state_t::debug_path(v2f_t x, std::list *path) { - bool first = true; sf::Vertex line[2]; + line[0] = sf::Vertex(x, sf::Color::Blue); + for (v2f_t &point : *path) { line[1] = line[0]; line[0] = sf::Vertex(point, sf::Color::Blue); - - if (first) { - first = false; - continue; - } - window->draw(line, 2, sf::Lines); } } -- cgit