git-svn-id: https://svn.eduke32.com/eduke32@1159 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2008-11-26 02:43:47 +00:00
parent 52cf05a012
commit a562568daf
6 changed files with 86 additions and 34 deletions

View file

@ -607,7 +607,7 @@ int mdloadskin_trytexcache(char *fn, int len, int pal, char effect, texcachehead
} }
while (cacheindexptr->next); while (cacheindexptr->next);
*/ */
i = HASH_findcase(&cacheH,cachefn); i = HASH_find(&cacheH,cachefn);
if (i != -1) if (i != -1)
{ {
texcacheindex *cacheindexptr = cacheptrs[i]; 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); // initprintf("Loading cached skin: %s\n", cachefn);
if (Bread(cachefilehandle, head, sizeof(texcacheheader)) < (int)sizeof(texcacheheader)) goto failure; 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->xdim = B_LITTLE32(head->xdim);
head->ydim = B_LITTLE32(head->ydim); head->ydim = B_LITTLE32(head->ydim);

View file

@ -334,7 +334,7 @@ char TEXCACHEDIR[BMAX_PATH] = "textures";
typedef struct typedef struct
{ {
char magic[8]; // 'Polymost' char magic[4]; // 'PMST', was 'Polymost'
int xdim, ydim; // of image, unpadded int xdim, ydim; // of image, unpadded
int flags; // 1 = !2^x, 2 = has alpha, 4 = lzw compressed int flags; // 1 = !2^x, 2 = has alpha, 4 = lzw compressed
int quality; // r_downsize at the time the cache was written int quality; // r_downsize at the time the cache was written
@ -929,7 +929,7 @@ void polymost_glinit()
datextures = &firstcacheindex; datextures = &firstcacheindex;
numcacheentries = 0; numcacheentries = 0;
Bmemset(&cacheptrs[0],0,sizeof(cacheptrs)); Bmemset(&cacheptrs[0], 0, sizeof(cacheptrs));
HASH_init(&cacheH); HASH_init(&cacheH);
LoadCacheOffsets(); LoadCacheOffsets();
@ -942,6 +942,15 @@ void polymost_glinit()
initprintf("Unable to open cache index!\n"); initprintf("Unable to open cache index!\n");
return; 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); cachefilehandle = Bopen(TEXCACHEDIR,BO_BINARY|BO_CREAT|BO_APPEND|BO_RDWR,BS_IREAD|BS_IWRITE);
if (cachefilehandle < 0) if (cachefilehandle < 0)
@ -975,7 +984,7 @@ void invalidatecache(void)
datextures = &firstcacheindex; datextures = &firstcacheindex;
numcacheentries = 0; numcacheentries = 0;
Bmemset(&cacheptrs[0],0,sizeof(cacheptrs)); Bmemset(&cacheptrs[0], 0, sizeof(cacheptrs));
Bstrcpy(tempbuf,TEXCACHEDIR); Bstrcpy(tempbuf,TEXCACHEDIR);
Bstrcat(tempbuf,".cache"); Bstrcat(tempbuf,".cache");
@ -986,6 +995,15 @@ void invalidatecache(void)
initprintf("Unable to open cache index!\n"); initprintf("Unable to open cache index!\n");
return; 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); cachefilehandle = Bopen(TEXCACHEDIR,BO_BINARY|BO_CREAT|BO_TRUNC|BO_RDWR,BS_IREAD|BS_IWRITE);
if (cachefilehandle < 0) if (cachefilehandle < 0)
@ -1362,7 +1380,7 @@ int gloadtile_art(int dapic, int dapal, int dameth, pthtyp *pth, int doalloc)
static int LoadCacheOffsets(void) static int LoadCacheOffsets(void)
{ {
int foffset, fsize; int foffset, fsize, i;
char *fname; char *fname;
scriptfile *script; scriptfile *script;
@ -1379,13 +1397,25 @@ static int LoadCacheOffsets(void)
if (scriptfile_getnumber(script, &foffset)) break; // offset in cache if (scriptfile_getnumber(script, &foffset)) break; // offset in cache
if (scriptfile_getnumber(script, &fsize)) break; // size if (scriptfile_getnumber(script, &fsize)) break; // size
strncpy(datextures->name, fname, BMAX_PATH); i = HASH_find(&cacheH,fname);
datextures->offset = foffset; if (i != -1)
datextures->len = fsize; {
datextures->next = Bcalloc(1, sizeof(texcacheindex)); // update an existing entry
HASH_replace(&cacheH, Bstrdup(fname), numcacheentries); texcacheindex *cacheindex = cacheptrs[i];
cacheptrs[numcacheentries++] = datextures; cacheindex->offset = foffset;
datextures = datextures->next; 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); scriptfile_close(script);
@ -1449,12 +1479,12 @@ int trytexcache(char *fn, int len, int dameth, char effect, texcacheheader *head
cacheindexptr = cacheindexptr->next; cacheindexptr = cacheindexptr->next;
} }
while (cacheindexptr->next); */ while (cacheindexptr->next); */
i = HASH_findcase(&cacheH,cachefn); i = HASH_find(&cacheH,cachefn);
if (i != -1) if (i != -1)
{ {
texcacheindex *cacheindexptr = cacheptrs[i]; texcacheindex *cacheindex = cacheptrs[i];
len = cacheindexptr->len; len = cacheindex->len;
offset = cacheindexptr->offset; offset = cacheindex->offset;
// initprintf("got a match for %s offset %d\n",cachefn,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); // initprintf("Loading cached tex: %s\n", cachefn);
if (Bread(cachefilehandle, head, sizeof(texcacheheader)) < (int)sizeof(texcacheheader)) goto failure; 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->xdim = B_LITTLE32(head->xdim);
head->ydim = B_LITTLE32(head->ydim); head->ydim = B_LITTLE32(head->ydim);
head->flags = B_LITTLE32(head->flags); 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 alloclen=0, level, miplen;
unsigned int padx=0, pady=0; unsigned int padx=0, pady=0;
GLuint gi; GLuint gi;
int offset = 0;
if (!glinfo.texcompr || !glusetexcompr || !glusetexcache || !cacheindexptr || cachefilehandle < 0) return; if (!glinfo.texcompr || !glusetexcompr || !glusetexcache || !cacheindexptr || cachefilehandle < 0) return;
if (!bglCompressedTexImage2DARB || !bglGetCompressedTexImageARB) 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); // fil = Bopen(cachefn,BO_BINARY|BO_CREAT|BO_TRUNC|BO_RDWR,BS_IREAD|BS_IWRITE);
// if (fil < 0) return; // 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; 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 (Bwrite(cachefilehandle, &pict, sizeof(texcachepicture)) != sizeof(texcachepicture)) goto failure;
if (dxtfilter(cachefilehandle, &pict, pic, midbuf, packbuf, miplen)) 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); if (cacheindexptr)
cacheptrs[numcacheentries++] = datextures; fprintf(cacheindexptr, "%s %d %d\n", cacheindex->name, cacheindex->offset, cacheindex->len);
datextures = datextures->next; }
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; goto success;

View file

@ -44,7 +44,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <shellapi.h> #include <shellapi.h>
#endif #endif
#define BUILDDATE " 20081121" #define BUILDDATE " 20081125"
#define VERSION " 1.2.0devel" #define VERSION " 1.2.0devel"
static int floor_over_floor; static int floor_over_floor;

View file

@ -237,7 +237,7 @@ void CONFIG_SetDefaults(void)
ud.screen_tilting = 1; ud.screen_tilting = 1;
ud.shadows = 1; ud.shadows = 1;
ud.statusbarmode = 0; ud.statusbarmode = 0;
ud.statusbarscale = 50; ud.statusbarscale = 100;
ud.team = 0; ud.team = 0;
ud.viewbob = 1; ud.viewbob = 1;
ud.weaponsway = 1; ud.weaponsway = 1;

View file

@ -78,7 +78,7 @@ extern int g_scriptVersion, g_Shareware, g_gameType;
#define BYTEVERSION_13 27 #define BYTEVERSION_13 27
#define BYTEVERSION_14 116 #define BYTEVERSION_14 116
#define BYTEVERSION_15 117 #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 #define BYTEVERSION (BYTEVERSION_JF+(PLUTOPAK?1:(VOLUMEONE<<1))) // JBF 20040116: different data files give different versions

View file

@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
#include "duke3d.h" #include "duke3d.h"
const char *s_buildDate = "20081122"; const char *s_buildDate = "20081125";
char *MusicPtr = NULL; char *MusicPtr = NULL;
int g_musicSize; int g_musicSize;