Added comments and changed inline assignments to increase readability for animation functions. Removed draw_free() definition, as it is not used anymore. Added animation free function to the dgn_catch() clause in main.

This commit is contained in:
Slade Getz 2023-09-04 12:15:06 -05:00
parent 0eb0050c69
commit 93ddcefc14
3 changed files with 14 additions and 7 deletions

View File

@ -374,9 +374,11 @@ void animate_free(struct term_buf* buf)
{
if (config.animate)
{
int i;
if ((i = config.animation) < ANIMATION_NUM)
int i = config.animation;
// make sure the animation chosen is valid
if (i < ANIMATION_NUM)
{
// load appropriate free function and execute
void (*fun_ptr)(struct term_buf*);
fun_ptr = ANIM_FREES[i];
(*fun_ptr)(buf);
@ -391,9 +393,11 @@ void animate(struct term_buf* buf)
if (config.animate)
{
int i;
if ((i = config.animation) < ANIMATION_NUM)
int i = config.animation;
// make sure the animation chosen is valid
if (i < ANIMATION_NUM)
{
// runs corresponding animation function
void (*fun_ptr)(struct term_buf*);
fun_ptr = ANIM_RUNS[i];
(*fun_ptr)(buf);
@ -405,9 +409,12 @@ void animate_init(struct term_buf* buf)
{
if (config.animate)
{
int i;
if ((i = config.animation) < ANIMATION_NUM)
int i = config.animation;
// make sure the animation chosen is valid
if (i < ANIMATION_NUM)
{
// grab the corresponding animation
// initialize function and execute
void (*fun_ptr)(struct term_buf*);
fun_ptr = ANIM_INITS[i];
(*fun_ptr)(buf);

View File

@ -41,7 +41,6 @@ struct term_buf
void draw_init(struct term_buf* buf);
void draw_free(struct term_buf* buf);
void draw_box(struct term_buf* buf);
struct tb_cell* strn_cell(char* s, uint16_t len);

View File

@ -164,6 +164,7 @@ int main(int argc, char** argv)
if (dgn_catch())
{
config.animate = false;
animate_free(&buf);
dgn_reset();
}
}