From beec5ec512fcc8e9a6961711acca6a5e37f30038 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Mon, 23 Jun 2014 02:25:07 +0000 Subject: [PATCH] Keep track of allocated cache space for ANM files so they aren't allocated multiple times. Also, unlock the handles after playback is done so they can be freed if necessary. git-svn-id: https://svn.eduke32.com/eduke32@4524 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/anim.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/polymer/eduke32/source/anim.c b/polymer/eduke32/source/anim.c index 3c18c0a61..b1200c746 100644 --- a/polymer/eduke32/source/anim.c +++ b/polymer/eduke32/source/anim.c @@ -207,9 +207,11 @@ static void endanimvol43(int32_t fr) } } +static uint8_t* animbuf[NUM_HARDCODED_ANIMS]; +static char animlock[NUM_HARDCODED_ANIMS]; + int32_t G_PlayAnim(const char *fn, char t) { - uint8_t *animbuf; int32_t i, length=0, numframes=0; #ifdef USE_OPENGL int32_t ogltexfiltermode=gltexfiltermode; @@ -232,11 +234,9 @@ int32_t G_PlayAnim(const char *fn, char t) // 10: vol4e2 // 11: vol4e3 - if (t != 7 && t != 9 && t != 10 && t != 11) - I_ClearAllInput(); - if (I_CheckAllInput()) { + I_ClearAllInput(); FX_StopAllSounds(); running = 0; goto end_anim; @@ -370,16 +370,18 @@ int32_t G_PlayAnim(const char *fn, char t) } walock[TILE_ANIM] = 219+t; + animlock[t-1] = 1; - allocache((intptr_t *)&animbuf, length+1, &walock[TILE_ANIM]); + if (!animbuf[t-1]) + allocache((intptr_t *)&animbuf[t-1], length+1, &animlock[t-1]); tilesizx[TILE_ANIM] = 200; tilesizy[TILE_ANIM] = 320; - kread(handle, animbuf, length); + kread(handle, animbuf[t-1], length); kclose(handle); - if (ANIM_LoadAnim(animbuf, length) < 0) + if (ANIM_LoadAnim(animbuf[t-1], length) < 0) { // XXX: ANM_LoadAnim() still checks less than the bare minimum, // e.g. ANM file could still be too small and not contain any frames. @@ -468,6 +470,7 @@ end_anim: I_ClearAllInput(); ANIM_FreeAnim(); walock[TILE_ANIM] = 1; + animlock[t-1] = 0; return !running; }