summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-12-19 14:04:28 +0100
committerPaweł Redman <pawel.redman@gmail.com>2017-12-19 14:04:36 +0100
commitfec522f3c77696ea1d7907a1a2484910f8e391ca (patch)
tree68b64977452531bc804bac7be3b4d45569f9109c /src
parente29c796801dd6b7a406ef457c0c68b4a1c7f527a (diff)
Fix panicking units stopping for no reason.
Diffstat (limited to 'src')
-rw-r--r--src/common.hpp2
-rw-r--r--src/game/units.cpp4
-rw-r--r--src/render.cpp11
3 files changed, 7 insertions, 10 deletions
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<v2f_t> *path);
+ void debug_path(v2f_t x, std::list<v2f_t> *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<v2f_t> *path)
+void state_t::debug_path(v2f_t x, std::list<v2f_t> *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);
}
}