summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common.hpp1
-rw-r--r--src/game/game.cpp11
-rw-r--r--src/game/units.cpp2
-rw-r--r--src/world.cpp12
4 files changed, 25 insertions, 1 deletions
diff --git a/src/common.hpp b/src/common.hpp
index ae4deed..74fa9de 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -150,6 +150,7 @@ namespace world {
typedef struct {
cflags_t cflags;
rectf_t bounds;
+ bool ignore = false;
} cmodel_t;
typedef struct {
diff --git a/src/game/game.cpp b/src/game/game.cpp
index 185e2d1..f71b9d2 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -270,9 +270,16 @@ static void command_repl(unit_repl_t *repl, v2f_t x, int number)
void state_t::command(v2f_t x, int number)
{
+ bool unlink;
+
if (!selected_units.size())
return;
+ unlink = (number == COMMAND_MOVE);
+ if (unlink)
+ for (unit_t *unit : selected_units)
+ unit->cmodel.ignore = true;
+
for (unit_t *unit : selected_units) {
if (unit->dead || !unit->controllable)
continue;
@@ -291,6 +298,10 @@ void state_t::command(v2f_t x, int number)
default:;
}
}
+
+ if (unlink)
+ for (unit_t *unit : selected_units)
+ unit->cmodel.ignore = false;
}
void state_t::pause(void)
diff --git a/src/game/units.cpp b/src/game/units.cpp
index 43e6878..11379cb 100644
--- a/src/game/units.cpp
+++ b/src/game/units.cpp
@@ -177,7 +177,7 @@ bool unit_t::start_moving(v2f_t dst)
move.path.clear();
move.last_step = x;
- rep.cflags = move.cflags & ~(cmodel.cflags);
+ rep.cflags = move.cflags;
rep.bounds = cmodel.bounds;
if (!world->find_path(x, move.dst, &rep, this, &move.path)) {
diff --git a/src/world.cpp b/src/world.cpp
index d09001c..1066545 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -129,6 +129,9 @@ bool world_t::find_path(v2f_t src, v2f_t dst, cmodel_t *cmodel, entity_t *ignore
if (ent == ignore)
continue;
+ if (ent->cmodel.ignore)
+ continue;
+
if (!(ent->cmodel.cflags & cmodel->cflags))
continue;
@@ -203,6 +206,9 @@ std::list<entity_t*> world_t::get_entities(rectf_t rect, cflags_t cflags)
ent->cookie = cookie;
+ if (ent->cmodel.ignore)
+ continue;
+
if (!(ent->cmodel.cflags & cflags))
continue;
@@ -276,6 +282,9 @@ bool world_t::test_rect(const cmodel_t *cmodel, const entity_t *ignore)
ent->cookie = cookie;
+ if (ent->cmodel.ignore)
+ continue;
+
if (!(ent->cmodel.cflags & cmodel->cflags))
continue;
@@ -407,6 +416,9 @@ trace_t world_t::ray_v_ents(v2f_t start, v2f_t end, cflags_t cflags,
if (ent == ignore)
continue;
+ if (ent->cmodel.ignore)
+ continue;
+
trace = ray_v_rect(start, end, ent->cmodel.bounds);
if (!trace.hit)
continue;