diff options
Diffstat (limited to 'src/game/unit_repl.cpp')
-rw-r--r-- | src/game/unit_repl.cpp | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/src/game/unit_repl.cpp b/src/game/unit_repl.cpp index 57e18f8..6dfa005 100644 --- a/src/game/unit_repl.cpp +++ b/src/game/unit_repl.cpp @@ -55,35 +55,39 @@ void unit_repl_t::render_to(render::state_t *render) void unit_repl_t::activate(unit_t::type_t type) { world::cmodel_t cmodel; - 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 + unit_t *unit; + + switch (type) { + case UNIT_SOLDIER: + unit = new unit_soldier_t(game); + break; + + case UNIT_SCIENTIST: + unit = new unit_scientist_t(game); + break; + + case UNIT_BUILDER: + unit = new unit_builder_t(game); + break; + + default: abort(); + } + + unit->place(world, x); - for (world::entity_t *ent : game->world.get_entities(spawned->cmodel.bounds, CF_BODY|CF_BODY_SMALL)) + for (world::entity_t *ent : game->world.get_entities(unit->cmodel.bounds, CF_BODY|CF_BODY_SMALL)) { - unit_t *unit; + unit_t *other; - if (ent == spawned) + if (ent == unit) continue; if (ent->type != ET_UNIT) continue; - unit = dynamic_cast<unit_t*>(ent); - unit->damage(200, NULL); + other = dynamic_cast<unit_t*>(ent); + other->damage(200, NULL); } assets::repl.sound.play_3d(x); |