Remove stale unit and building types

This commit is contained in:
Xavier Del Campo Romero 2024-01-27 14:14:37 +01:00
parent 0f21739551
commit 27553f8ed1
Signed by: xavi
GPG Key ID: 84FF3612A9BF43F2
5 changed files with 10 additions and 69 deletions

View File

@ -3,8 +3,6 @@
enum building_type
{
BUILDING_TYPE_BARRACKS,
MAX_BUILDING_TYPES
};

View File

@ -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];
}

View File

@ -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;

View File

@ -3,8 +3,6 @@
enum unit_type
{
UNIT_TYPE_PEASANT,
MAX_UNIT_TYPES
};

View File

@ -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];
}