From a562568dafdd0808e820dee2ec551f3d09bda325 Mon Sep 17 00:00:00 2001 From: terminx Date: Wed, 26 Nov 2008 02:43:47 +0000 Subject: [PATCH] git-svn-id: https://svn.eduke32.com/eduke32@1159 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/mdsprite.c | 4 +- polymer/eduke32/build/src/polymost.c | 108 ++++++++++++++++++++------- polymer/eduke32/source/astub.c | 2 +- polymer/eduke32/source/config.c | 2 +- polymer/eduke32/source/duke3d.h | 2 +- polymer/eduke32/source/global.c | 2 +- 6 files changed, 86 insertions(+), 34 deletions(-) diff --git a/polymer/eduke32/build/src/mdsprite.c b/polymer/eduke32/build/src/mdsprite.c index c7188ca5b..624f3fabe 100644 --- a/polymer/eduke32/build/src/mdsprite.c +++ b/polymer/eduke32/build/src/mdsprite.c @@ -607,7 +607,7 @@ int mdloadskin_trytexcache(char *fn, int len, int pal, char effect, texcachehead } while (cacheindexptr->next); */ - i = HASH_findcase(&cacheH,cachefn); + i = HASH_find(&cacheH,cachefn); if (i != -1) { texcacheindex *cacheindexptr = cacheptrs[i]; @@ -622,7 +622,7 @@ int mdloadskin_trytexcache(char *fn, int len, int pal, char effect, texcachehead // initprintf("Loading cached skin: %s\n", cachefn); if (Bread(cachefilehandle, head, sizeof(texcacheheader)) < (int)sizeof(texcacheheader)) goto failure; - if (memcmp(head->magic, "Polymost", 8)) goto failure; + if (memcmp(head->magic, "PMST", 4)) goto failure; head->xdim = B_LITTLE32(head->xdim); head->ydim = B_LITTLE32(head->ydim); diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 7acdd17c9..ec2b7fbe8 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -334,7 +334,7 @@ char TEXCACHEDIR[BMAX_PATH] = "textures"; typedef struct { - char magic[8]; // 'Polymost' + char magic[4]; // 'PMST', was 'Polymost' int xdim, ydim; // of image, unpadded int flags; // 1 = !2^x, 2 = has alpha, 4 = lzw compressed int quality; // r_downsize at the time the cache was written @@ -929,7 +929,7 @@ void polymost_glinit() datextures = &firstcacheindex; numcacheentries = 0; - Bmemset(&cacheptrs[0],0,sizeof(cacheptrs)); + Bmemset(&cacheptrs[0], 0, sizeof(cacheptrs)); HASH_init(&cacheH); LoadCacheOffsets(); @@ -942,6 +942,15 @@ void polymost_glinit() initprintf("Unable to open cache index!\n"); return; } + + fseek(cacheindexptr, 0, BSEEK_END); + if (!ftell(cacheindexptr)) + { + rewind(cacheindexptr); + fprintf(cacheindexptr,"// this file automatically generated by EDuke32\n// DO NOT MODIFY\n"); + } + else rewind(cacheindexptr); + cachefilehandle = Bopen(TEXCACHEDIR,BO_BINARY|BO_CREAT|BO_APPEND|BO_RDWR,BS_IREAD|BS_IWRITE); if (cachefilehandle < 0) @@ -975,7 +984,7 @@ void invalidatecache(void) datextures = &firstcacheindex; numcacheentries = 0; - Bmemset(&cacheptrs[0],0,sizeof(cacheptrs)); + Bmemset(&cacheptrs[0], 0, sizeof(cacheptrs)); Bstrcpy(tempbuf,TEXCACHEDIR); Bstrcat(tempbuf,".cache"); @@ -986,6 +995,15 @@ void invalidatecache(void) initprintf("Unable to open cache index!\n"); return; } + + fseek(cacheindexptr, 0, BSEEK_END); + if (!ftell(cacheindexptr)) + { + rewind(cacheindexptr); + fprintf(cacheindexptr,"// this file automatically generated by EDuke32\n// DO NOT MODIFY\n"); + } + else rewind(cacheindexptr); + cachefilehandle = Bopen(TEXCACHEDIR,BO_BINARY|BO_CREAT|BO_TRUNC|BO_RDWR,BS_IREAD|BS_IWRITE); if (cachefilehandle < 0) @@ -1362,7 +1380,7 @@ int gloadtile_art(int dapic, int dapal, int dameth, pthtyp *pth, int doalloc) static int LoadCacheOffsets(void) { - int foffset, fsize; + int foffset, fsize, i; char *fname; scriptfile *script; @@ -1379,13 +1397,25 @@ static int LoadCacheOffsets(void) if (scriptfile_getnumber(script, &foffset)) break; // offset in cache if (scriptfile_getnumber(script, &fsize)) break; // size - strncpy(datextures->name, fname, BMAX_PATH); - datextures->offset = foffset; - datextures->len = fsize; - datextures->next = Bcalloc(1, sizeof(texcacheindex)); - HASH_replace(&cacheH, Bstrdup(fname), numcacheentries); - cacheptrs[numcacheentries++] = datextures; - datextures = datextures->next; + i = HASH_find(&cacheH,fname); + if (i != -1) + { + // update an existing entry + texcacheindex *cacheindex = cacheptrs[i]; + cacheindex->offset = foffset; + cacheindex->len = fsize; +// initprintf("got a match for %s offset %d\n",cachefn,offset); + } + else + { + strncpy(datextures->name, fname, BMAX_PATH); + datextures->offset = foffset; + datextures->len = fsize; + datextures->next = Bcalloc(1, sizeof(texcacheindex)); + HASH_replace(&cacheH, Bstrdup(fname), numcacheentries); + cacheptrs[numcacheentries++] = datextures; + datextures = datextures->next; + } } scriptfile_close(script); @@ -1449,12 +1479,12 @@ int trytexcache(char *fn, int len, int dameth, char effect, texcacheheader *head cacheindexptr = cacheindexptr->next; } while (cacheindexptr->next); */ - i = HASH_findcase(&cacheH,cachefn); + i = HASH_find(&cacheH,cachefn); if (i != -1) { - texcacheindex *cacheindexptr = cacheptrs[i]; - len = cacheindexptr->len; - offset = cacheindexptr->offset; + texcacheindex *cacheindex = cacheptrs[i]; + len = cacheindex->len; + offset = cacheindex->offset; // initprintf("got a match for %s offset %d\n",cachefn,offset); } @@ -1465,7 +1495,7 @@ int trytexcache(char *fn, int len, int dameth, char effect, texcacheheader *head // initprintf("Loading cached tex: %s\n", cachefn); if (Bread(cachefilehandle, head, sizeof(texcacheheader)) < (int)sizeof(texcacheheader)) goto failure; - if (memcmp(head->magic, "Polymost", 8)) goto failure; + if (memcmp(head->magic, "PMST", 4)) goto failure; head->xdim = B_LITTLE32(head->xdim); head->ydim = B_LITTLE32(head->ydim); head->flags = B_LITTLE32(head->flags); @@ -1497,6 +1527,7 @@ void writexcache(char *fn, int len, int dameth, char effect, texcacheheader *hea unsigned int alloclen=0, level, miplen; unsigned int padx=0, pady=0; GLuint gi; + int offset = 0; if (!glinfo.texcompr || !glusetexcompr || !glusetexcache || !cacheindexptr || cachefilehandle < 0) return; if (!bglCompressedTexImage2DARB || !bglGetCompressedTexImageARB) @@ -1551,12 +1582,13 @@ void writexcache(char *fn, int len, int dameth, char effect, texcacheheader *hea // fil = Bopen(cachefn,BO_BINARY|BO_CREAT|BO_TRUNC|BO_RDWR,BS_IREAD|BS_IWRITE); // if (fil < 0) return; - Bstrcpy(datextures->name, cachefn); - Blseek(cachefilehandle, 0, BSEEK_END); - datextures->offset = Blseek(cachefilehandle, 0, BSEEK_CUR); - OSD_Printf("Writing cached tex %s, offset 0x%x\n", cachefn, datextures->offset); - memcpy(head->magic, "Polymost", 8); // sizes are set by caller + Blseek(cachefilehandle, 0, BSEEK_END); + + offset = Blseek(cachefilehandle, 0, BSEEK_CUR); + OSD_Printf("Writing cached tex %s, offset 0x%x\n", cachefn, offset); + + memcpy(head->magic, "PMST", 4); // sizes are set by caller if (glusetexcachecompression) head->flags |= 4; @@ -1611,15 +1643,35 @@ void writexcache(char *fn, int len, int dameth, char effect, texcacheheader *hea if (Bwrite(cachefilehandle, &pict, sizeof(texcachepicture)) != sizeof(texcachepicture)) goto failure; if (dxtfilter(cachefilehandle, &pict, pic, midbuf, packbuf, miplen)) goto failure; } - datextures->len = Blseek(cachefilehandle, 0, BSEEK_CUR) - datextures->offset; - datextures->next = (texcacheindex *)Bcalloc(1,sizeof(texcacheindex)); - if (cacheindexptr) - fprintf(cacheindexptr, "\"%s\" %d %d\n", datextures->name, datextures->offset, datextures->len); + { + int i = HASH_find(&cacheH,cachefn); + if (i != -1) + { + // update an existing entry + texcacheindex *cacheindex = cacheptrs[i]; + cacheindex->offset = offset; + cacheindex->len = Blseek(cachefilehandle, 0, BSEEK_CUR) - cacheindex->offset; + // initprintf("got a match for %s offset %d\n",cachefn,offset); - HASH_replace(&cacheH, Bstrdup(cachefn), numcacheentries); - cacheptrs[numcacheentries++] = datextures; - datextures = datextures->next; + if (cacheindexptr) + fprintf(cacheindexptr, "%s %d %d\n", cacheindex->name, cacheindex->offset, cacheindex->len); + } + else + { + Bstrcpy(datextures->name, cachefn); + datextures->offset = offset; + datextures->len = Blseek(cachefilehandle, 0, BSEEK_CUR) - datextures->offset; + datextures->next = (texcacheindex *)Bcalloc(1,sizeof(texcacheindex)); + + if (cacheindexptr) + fprintf(cacheindexptr, "%s %d %d\n", datextures->name, datextures->offset, datextures->len); + + HASH_replace(&cacheH, Bstrdup(cachefn), numcacheentries); + cacheptrs[numcacheentries++] = datextures; + datextures = datextures->next; + } + } goto success; diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 250ce58ae..f2e956b05 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -44,7 +44,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #endif -#define BUILDDATE " 20081121" +#define BUILDDATE " 20081125" #define VERSION " 1.2.0devel" static int floor_over_floor; diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index 22fd2d971..83f73ab86 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -237,7 +237,7 @@ void CONFIG_SetDefaults(void) ud.screen_tilting = 1; ud.shadows = 1; ud.statusbarmode = 0; - ud.statusbarscale = 50; + ud.statusbarscale = 100; ud.team = 0; ud.viewbob = 1; ud.weaponsway = 1; diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index 1723d4dfc..404b06f92 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -78,7 +78,7 @@ extern int g_scriptVersion, g_Shareware, g_gameType; #define BYTEVERSION_13 27 #define BYTEVERSION_14 116 #define BYTEVERSION_15 117 -#define BYTEVERSION_JF 183 // increase by 3, because atomic GRP adds 1, and Shareware adds 2 +#define BYTEVERSION_JF 186 // increase by 3, because atomic GRP adds 1, and Shareware adds 2 #define BYTEVERSION (BYTEVERSION_JF+(PLUTOPAK?1:(VOLUMEONE<<1))) // JBF 20040116: different data files give different versions diff --git a/polymer/eduke32/source/global.c b/polymer/eduke32/source/global.c index 6d53825a0..bca11a114 100644 --- a/polymer/eduke32/source/global.c +++ b/polymer/eduke32/source/global.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //------------------------------------------------------------------------- #include "duke3d.h" -const char *s_buildDate = "20081122"; +const char *s_buildDate = "20081125"; char *MusicPtr = NULL; int g_musicSize;