summaryrefslogtreecommitdiff
path: root/src/game/unit_repl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/unit_repl.cpp')
-rw-r--r--src/game/unit_repl.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/game/unit_repl.cpp b/src/game/unit_repl.cpp
index 08a43d2..bad5ab0 100644
--- a/src/game/unit_repl.cpp
+++ b/src/game/unit_repl.cpp
@@ -43,7 +43,7 @@ void unit_repl_t::on_damage(unit_t *attacker)
void unit_repl_t::on_death(void)
{
game->explosion(x);
- delete this;
+ game->deletion_list.insert(this);
}
void unit_repl_t::render_to(render::state_t *render)
@@ -52,19 +52,31 @@ void unit_repl_t::render_to(render::state_t *render)
unit_t::render_to(render);
}
-void unit_repl_t::activate(void)
+void unit_repl_t::activate(unit_t::type_t type)
{
- unit_soldier_t *soldier;
world::cmodel_t cmodel;
-
- soldier = new unit_soldier_t(game);
- soldier->place(&game->world, x);
-
- for (world::entity_t *ent : game->world.get_entities(soldier->cmodel.bounds, soldier->move.cflags))
+ world::entity_t *spawned;
+
+ if (type == UNIT_SOLDIER) {
+ unit_soldier_t *soldier;
+
+ soldier = new unit_soldier_t(game);
+ soldier->place(&game->world, x);
+ spawned = soldier;
+ } else if (type == UNIT_SCIENTIST) {
+ unit_scientist_t *scientist;
+
+ scientist = new unit_scientist_t(game);
+ scientist->place(&game->world, x);
+ spawned = scientist;
+ } else
+ abort();
+
+ for (world::entity_t *ent : game->world.get_entities(spawned->cmodel.bounds, CF_BODY|CF_BODY_SMALL))
{
unit_t *unit;
- if (ent == soldier)
+ if (ent == spawned)
continue;
if (ent->type != ET_UNIT)