From 9434025e6d933ff5fdd298911ad1bb1574e312a5 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Thu, 15 Nov 2012 21:09:56 +0000 Subject: [PATCH] Minor loadpics() cleanups, don't expose filegrp[] from cache1d.c. git-svn-id: https://svn.eduke32.com/eduke32@3187 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/cache1d.h | 4 +++- polymer/eduke32/build/src/cache1d.c | 7 ++++++- polymer/eduke32/build/src/engine.c | 28 ++++++++++++++++++------- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/polymer/eduke32/build/include/cache1d.h b/polymer/eduke32/build/include/cache1d.h index cddb2bcc0..ad9bba8fd 100644 --- a/polymer/eduke32/build/include/cache1d.h +++ b/polymer/eduke32/build/include/cache1d.h @@ -13,7 +13,9 @@ extern "C" { #define MAXGROUPFILES 8 //Warning: Fix groupfil if this is changed #define MAXOPENFILES 64 //Warning: Fix filehan if this is changed -extern char filegrp[MAXOPENFILES]; +#ifdef WITHKPLIB +int32_t cache1d_file_fromzip(int32_t fil); +#endif void initcache(intptr_t dacachestart, int32_t dacachesize); void allocache(intptr_t *newhandle, int32_t newbytes, char *newlockptr); diff --git a/polymer/eduke32/build/src/cache1d.c b/polymer/eduke32/build/src/cache1d.c index f4f961357..b9781055c 100644 --- a/polymer/eduke32/build/src/cache1d.c +++ b/polymer/eduke32/build/src/cache1d.c @@ -530,7 +530,7 @@ static int32_t groupfilpos[MAXGROUPFILES]; static char *gfilelist[MAXGROUPFILES]; static int32_t *gfileoffs[MAXGROUPFILES]; -char filegrp[MAXOPENFILES]; +static char filegrp[MAXOPENFILES]; static int32_t filepos[MAXOPENFILES]; static intptr_t filehan[MAXOPENFILES] = { @@ -542,6 +542,11 @@ static intptr_t filehan[MAXOPENFILES] = #ifdef WITHKPLIB static char filenamsav[MAXOPENFILES][260]; static int32_t kzcurhand = -1; + +int32_t cache1d_file_fromzip(int32_t fil) +{ + return (filegrp[fil] == 254); +} #endif int32_t initgroupfile(const char *filename) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 2c877481d..2894d8754 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -10457,8 +10457,7 @@ void set_picsizanm(int32_t picnum, int16_t dasizx, int16_t dasizy, int32_t daanm // int32_t loadpics(const char *filename, int32_t askedsize) { - int32_t offscount, localtilestart, localtileend, dasiz; - int32_t i, fil, tilefilei, numtiles_dummy; + int32_t i, tilefilei; Bstrcpy(artfilename,filename); @@ -10470,12 +10469,17 @@ int32_t loadpics(const char *filename, int32_t askedsize) for (tilefilei=0; tilefilei= MAXTILES || (uint32_t)localtileend >= MAXTILES) { initprintf("loadpics: Invalid localtilestart or localtileend in %s\n", artfilename); @@ -10498,9 +10504,13 @@ int32_t loadpics(const char *filename, int32_t askedsize) kclose(fil); continue; } - kread(fil,&tilesizx[localtilestart],(localtileend-localtilestart+1)<<1); - kread(fil,&tilesizy[localtilestart],(localtileend-localtilestart+1)<<1); - kread(fil,&picanm[localtilestart],(localtileend-localtilestart+1)<<2); + + localnumtiles = (localtileend-localtilestart+1); + + kread(fil,&tilesizx[localtilestart], localnumtiles<<1); + kread(fil,&tilesizy[localtilestart], localnumtiles<<1); + kread(fil,&picanm[localtilestart], localnumtiles<<2); + for (i=localtilestart; i<=localtileend; i++) { tilesizx[i] = B_LITTLE16(tilesizx[i]); @@ -10508,18 +10518,20 @@ int32_t loadpics(const char *filename, int32_t askedsize) picanm[i] = B_LITTLE32(picanm[i]); } - offscount = 4+4+4+4+((localtileend-localtilestart+1)<<3); + offscount = 4+4+4+4+(localnumtiles<<3); for (i=localtilestart; i<=localtileend; i++) { + int32_t dasiz = tilesizx[i]*tilesizy[i]; + tilefilenum[i] = tilefilei; tilefileoffs[i] = offscount; - dasiz = (int32_t)(tilesizx[i]*tilesizy[i]); + offscount += dasiz; artsize += ((dasiz+15)&0xfffffff0); } #ifdef WITHKPLIB - if (filegrp[fil] == 254) // from zip + if (cache1d_file_fromzip(fil)) // from zip { i = kfilelength(fil); artptrs[tilefilei] = (char *)Brealloc(artptrs[tilefilei], i);