From 27553f8ed1d062c4d8175e7376f5b16cf2c8f9ef Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Sat, 27 Jan 2024 14:14:37 +0100 Subject: [PATCH] Remove stale unit and building types --- src/building/inc/building_type.h | 2 -- src/building/src/building.c | 10 ++------- src/player/src/player.c | 37 -------------------------------- src/unit/inc/unit_type.h | 2 -- src/unit/src/unit.c | 28 +++++++----------------- 5 files changed, 10 insertions(+), 69 deletions(-) diff --git a/src/building/inc/building_type.h b/src/building/inc/building_type.h index eca76b4..8b461f7 100644 --- a/src/building/inc/building_type.h +++ b/src/building/inc/building_type.h @@ -3,8 +3,6 @@ enum building_type { - BUILDING_TYPE_BARRACKS, - MAX_BUILDING_TYPES }; diff --git a/src/building/src/building.c b/src/building/src/building.c index 457d9e6..826ebe1 100644 --- a/src/building/src/building.c +++ b/src/building/src/building.c @@ -35,10 +35,7 @@ static void get_dimensions(const enum building_type type, short *const w, static const struct dim { short w, h; - } dim[] = - { - [BUILDING_TYPE_BARRACKS] = {.w = 68, .h = 66} - }; + } dim[1]; const struct dim *const d = &dim[type]; *w = d->w; @@ -72,10 +69,7 @@ void building_set_alive_cb(void (*const f)(const struct util_rect *, bool, void const char *building_str(const struct building *const b) { - static const char *const str[] = - { - [BUILDING_TYPE_BARRACKS] = "Barracks" - }; + static const char *const str[1]; return str[b->type]; } diff --git a/src/player/src/player.c b/src/player/src/player.c index e1932a5..5a69763 100644 --- a/src/player/src/player.c +++ b/src/player/src/player.c @@ -61,43 +61,6 @@ int player_create_building(const struct building_cfg *const cfg, struct player * int player_init(const struct player_cfg *const cfg, struct player *const pl) { - const unsigned long x = cfg->x, y = cfg->y; - - const struct building_cfg bcfg = - { - .type = BUILDING_TYPE_BARRACKS, - .x = x, - .y = y - }; - - const struct unit_cfg cfgs[] = - { - { - .type = UNIT_TYPE_PEASANT, - .x = x + 80, - .y = y - }, - - { - .type = UNIT_TYPE_PEASANT, - .x = x + 80, - .y = y + 40 - }, - - { - .type = UNIT_TYPE_PEASANT, - .x = x + 100, - .y = y + 20 - } - }; - - if (player_create_building(&bcfg, pl)) - return -1; - - for (size_t i = 0; i < sizeof cfgs / sizeof *cfgs; i++) - if (player_create_unit(&cfgs[i], pl)) - return -1; - pl->alive = true; pl->color = cfg->color; pl->team = cfg->team; diff --git a/src/unit/inc/unit_type.h b/src/unit/inc/unit_type.h index fddd5c9..f023784 100644 --- a/src/unit/inc/unit_type.h +++ b/src/unit/inc/unit_type.h @@ -3,8 +3,6 @@ enum unit_type { - UNIT_TYPE_PEASANT, - MAX_UNIT_TYPES }; diff --git a/src/unit/src/unit.c b/src/unit/src/unit.c index a95cca3..3333797 100644 --- a/src/unit/src/unit.c +++ b/src/unit/src/unit.c @@ -64,14 +64,7 @@ static void get_speed(const struct unit *const u, fix16_t *const x, static const struct speed { fix16_t x, y; - } speed[] = - { - [UNIT_TYPE_PEASANT] = - { - .x = FIX16_C_FROM_INT(1), - .y = FIX16_C_FROM_INT(1) - } - }; + } speed[1]; const struct speed *const s = &speed[u->type]; const int dx = abs(u->rx - u->tx); @@ -258,6 +251,7 @@ typedef const struct static anim_dim *peasant_anim(const struct unit *const u) { +#if 0 static anim_dim t[] = { { @@ -312,6 +306,9 @@ static anim_dim *peasant_anim(const struct unit *const u) return NULL; return &t[ux]; +#else + return NULL; +#endif } struct render_cfg @@ -367,10 +364,7 @@ static int unit_quad(const struct unit *const u, struct render_cfg *const rcfg) { struct instance_render_quad *const qcfg = &rcfg->qcfg; - static anim_dim *(*const f[])(const struct unit *) = - { - [UNIT_TYPE_PEASANT] = peasant_quad - }; + static anim_dim *(*const f[1])(const struct unit *); anim_dim *const dim = f[u->type](u); @@ -418,10 +412,7 @@ static void get_dimensions(const enum unit_type type, short *const w, static const struct dim { short w, h; - } dim[] = - { - [UNIT_TYPE_PEASANT] = {.w = 36, .h = 36} - }; + } dim[1]; const struct dim *const d = &dim[type]; *w = d->w; @@ -451,10 +442,7 @@ void unit_create(const struct unit_cfg *const cfg, struct unit *const u) const char *unit_str(const struct unit *const u) { - static const char *const str[] = - { - [UNIT_TYPE_PEASANT] = "Peasant" - }; + static const char *const str[1]; return str[u->type]; }