diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2020-04-20 17:38:46 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2020-04-20 17:38:46 -0700 |
commit | 3c7af33fd1ae6c1df1d26045222dfdc14c59e66c (patch) | |
tree | 9d002bb994cc439374fa605088bf1269e610cf6b | |
parent | 76872e49a0bff4979c89578d05d26c85563bc76b (diff) |
game: use stage_conf_t.adopt in conversions
Rather than a new-then-free dance this avoids creating a new
stage_t altogether by installing the new object into the existing
one via the stage_conf_t.parent pointer combined with adopt flag.
-rw-r--r-- | src/game.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -268,8 +268,7 @@ static ix2_search_status_t virus_search(void *cb_context, ix2_object_t *ix2_obje switch (entity->any.type) { case ENTITY_TYPE_BABY: /* convert baby into inanimate virus (off the viruses array) */ - stage_free(entity->any.node); - entity->any.node = virus_node_new(&(stage_conf_t){ .parent = search->game->viruses_node, .name = "baby-virus", .active = 1, .alpha = 1.f }, &entity->any.model_x); + (void) virus_node_new(&(stage_conf_t){ .parent = entity->any.node, .adopt = 1, .name = "baby-virus", .active = 1, .alpha = 1.f }, &entity->any.model_x); sfx_play(sfx.baby_infected); entity->any.type = ENTITY_TYPE_VIRUS; @@ -283,9 +282,8 @@ static ix2_search_status_t virus_search(void *cb_context, ix2_object_t *ix2_obje return IX2_SEARCH_STOP_HIT; case ENTITY_TYPE_ADULT: - /* convert adult into inanimate virus (of the viruses array) */ - stage_free(entity->any.node); - entity->any.node = virus_node_new(&(stage_conf_t){ .parent = search->game->viruses_node, .name = "adult-virus", .active = 1, .alpha = 1.f }, &entity->any.model_x); + /* convert adult into inanimate virus (off the viruses array) */ + (void) virus_node_new(&(stage_conf_t){ .parent = entity->any.node, .adopt = 1, .name = "adult-virus", .active = 1, .alpha = 1.f }, &entity->any.model_x); sfx_play(sfx.adult_infected); search->game->state = GAME_STATE_OVER; return IX2_SEARCH_STOP_HIT; |