summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-12-16 23:02:32 +0000
committerPaweł Redman <pawel.redman@gmail.com>2017-12-16 23:02:32 +0000
commit3d69504213f9788ced2ec18ceba9175b1ccb84dc (patch)
tree3ffb0fa9ae85eb487acfb1234b07e32f6721579d
parentc0531bd165643c8482e00ea04297498474be113e (diff)
Fix a bug in the waking code; more debugging info.
-rw-r--r--src/common.hpp1
-rw-r--r--src/game/game.cpp7
-rw-r--r--src/game/interface.cpp7
-rw-r--r--src/game/units.cpp21
-rw-r--r--src/main.cpp1
5 files changed, 36 insertions, 1 deletions
diff --git a/src/common.hpp b/src/common.hpp
index 02e8b1a..e8f531a 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -15,6 +15,7 @@
extern bool debug_draw_cmodels;
extern bool debug_draw_paths;
extern bool debug_draw_tile_coords;
+extern bool debug_AI;
namespace procgen {
class prng_t {
diff --git a/src/game/game.cpp b/src/game/game.cpp
index 64dd224..fb130d9 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -163,7 +163,12 @@ void state_t::wake_everything(v2f_t x, float range)
if (!ent)
continue;
- if (ent->ignore_waking || ent->awake)
+ if (ent->ignore_waking)
+ continue;
+
+ ent->wake_time = now;
+
+ if (ent->awake)
continue;
ent->wake();
diff --git a/src/game/interface.cpp b/src/game/interface.cpp
index 148f790..d1734af 100644
--- a/src/game/interface.cpp
+++ b/src/game/interface.cpp
@@ -103,16 +103,23 @@ void state_t::tick(double dt)
switch (event.key.code) {
case sf::Keyboard::Key::F1:
debug_draw_cmodels ^= 1;
+ print("debug_draw_cmodels = " + std::to_string(debug_draw_cmodels));
break;
case sf::Keyboard::Key::F2:
debug_draw_paths ^= 1;
+ print("debug_draw_paths = " + std::to_string(debug_draw_paths));
break;
case sf::Keyboard::Key::F3:
debug_draw_tile_coords ^= 1;
+ print("debug_draw_tile_coords = " + std::to_string(debug_draw_tile_coords));
break;
+ case sf::Keyboard::Key::F4:
+ debug_AI ^= 1;
+ print("debug_AI = " + std::to_string(debug_AI));
+ break;
default:;
}
default:;
diff --git a/src/game/units.cpp b/src/game/units.cpp
index 583dd11..0c03079 100644
--- a/src/game/units.cpp
+++ b/src/game/units.cpp
@@ -51,6 +51,27 @@ void unit_t::render_to(render::state_t *render)
render::ALIGN_CENTER_BOTTOM,
sf::Color::White);
}
+
+ if (debug_AI) {
+ v2f_t text_pos;
+ float height;
+ std::stringstream ss;
+
+ if (dead)
+ ss << "D";
+
+ if (awake)
+ ss << "A";
+ else
+ ss << "S";
+
+ text_pos = render_bounds[0] + v2f_t(render_bounds.dim(0) / 2, -render_bounds.dim(1) * 0.1);
+ height = size.dim_min() * 0.40f;
+ text_pos[1] -= height;
+ render->render_text(text_pos, height, ss.str(),
+ render::ALIGN_CENTER_BOTTOM,
+ sf::Color::White);
+ }
}
void unit_t::say(std::string str)
diff --git a/src/main.cpp b/src/main.cpp
index e503cad..37c75af 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -4,6 +4,7 @@
bool debug_draw_cmodels = false;
bool debug_draw_paths = false;
bool debug_draw_tile_coords = false;
+bool debug_AI = false;
render::state_t *debug_render;
uint64_t nano_clock(void)