Project

General

Profile

Feature #1012 » 0058-Unhardcode-unit-selection-animation-frames-count.patch

Marko Lindqvist, 10/23/2024 04:37 AM

View differences:

client/tilespec.c
TRUE); \
} while (FALSE)
/************************************************************************//**
Load an animation
@param t Tileset to load animation from
@param tag Base tag of the animation sprites
****************************************************************************/
static struct anim *anim_load(struct tileset *t, const char *tag)
{
int frames = 0;
char buf[1500];
struct anim *ret;
int i;
do {
fc_snprintf(buf, sizeof(buf), "%s%d", tag, frames++);
} while (sprite_exists(t, buf));
if (--frames == 0) {
return nullptr;
}
ret = anim_new(frames);
for (i = 0; i < frames; i++) {
fc_snprintf(buf, sizeof(buf), "%s%d", tag, i);
ret->sprites[i] = load_sprite(t, buf, TRUE, TRUE, FALSE);
if (ret->sprites[i] == nullptr) {
tileset_error(LOG_FATAL, tileset_name_get(t),
_("Animation sprite for tag '%s' missing."), buf);
}
}
return ret;
}
/************************************************************************//**
Setup the graphics for specialist types in the default sprite set.
****************************************************************************/
......
t->sprites.unit.vet_lev[i] = load_sprite(t, buffer, TRUE, TRUE, FALSE);
}
t->sprites.unit.select = nullptr;
if (sprite_exists(t, "unit.select0")) {
t->sprites.unit.select = anim_new(NUM_TILES_SELECT);
for (i = 0; i < t->sprites.unit.select->frames; i++) {
fc_snprintf(buffer, sizeof(buffer), "unit.select%d", i);
SET_SPRITE(unit.select->sprites[i], buffer);
}
}
t->sprites.unit.select = anim_load(t, "unit.select");
SET_SPRITE(citybar.shields, "citybar.shields");
SET_SPRITE(citybar.food, "citybar.food");
(1-1/2)