mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
git-svn-id: https://svn.eduke32.com/eduke32@1166 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
2ac3fe6312
commit
0cf8a909d4
7 changed files with 87 additions and 112 deletions
|
@ -1399,7 +1399,7 @@ static int defsparser(scriptfile *script)
|
|||
double scale=1.0;
|
||||
scriptfile_getdouble(script,&scale);
|
||||
#ifdef SUPERBUILD
|
||||
voxscale[lastvoxid] = 65536*scale;
|
||||
voxscale[lastvoxid] = (int)(65536*scale);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -5783,8 +5783,6 @@ void uninitengine(void)
|
|||
//OSD_Printf("cacheresets = %d, cacheinvalidates = %d\n", cacheresets, cacheinvalidates);
|
||||
|
||||
#if defined(POLYMOST) && defined(USE_OPENGL)
|
||||
texcacheindex *index;
|
||||
|
||||
polymost_glreset();
|
||||
hicinit();
|
||||
freeallmodels();
|
||||
|
@ -5792,15 +5790,6 @@ void uninitengine(void)
|
|||
Bclose(cachefilehandle);
|
||||
if (cacheindexptr != NULL)
|
||||
Bfclose(cacheindexptr); */
|
||||
datextures = &firstcacheindex;
|
||||
while (datextures->next)
|
||||
{
|
||||
index = datextures;
|
||||
datextures = datextures->next;
|
||||
if (index != &firstcacheindex)
|
||||
Bfree(index);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
uninitsystem();
|
||||
|
@ -12228,8 +12217,9 @@ void setpolymost2dview(void)
|
|||
void HASH_init(struct HASH_table *t)
|
||||
{
|
||||
HASH_free(t);
|
||||
t->items=Bcalloc(1,t->size * sizeof(struct HASH_item));
|
||||
Bmemset(t->items,0,t->size * sizeof(struct HASH_item));
|
||||
t->items=Bcalloc(1, t->size * sizeof(struct HASH_item));
|
||||
// memset commented because it's redundant with calloc
|
||||
// Bmemset(t->items,0,t->size * sizeof(struct HASH_item));
|
||||
}
|
||||
|
||||
void HASH_free(struct HASH_table *t)
|
||||
|
@ -12238,26 +12228,27 @@ void HASH_free(struct HASH_table *t)
|
|||
int i;
|
||||
int num;
|
||||
|
||||
if (t->items==NULL)return;
|
||||
if (t->items == NULL)
|
||||
return;
|
||||
// initprintf("*free, num:%d\n",t->size);
|
||||
i=t->size-1;
|
||||
i= t->size-1;
|
||||
do
|
||||
{
|
||||
cur=t->items[i];
|
||||
num=0;
|
||||
cur = t->items[i];
|
||||
num = 0;
|
||||
while (cur)
|
||||
{
|
||||
tmp=cur;
|
||||
cur=cur->next;
|
||||
tmp = cur;
|
||||
cur = cur->next;
|
||||
// initprintf("Free %4d '%s'\n",tmp->key,(tmp->string)?tmp->string:".");
|
||||
Bfree(tmp);
|
||||
num++;
|
||||
}
|
||||
// initprintf("#%4d: %3d\t",i,num);
|
||||
}
|
||||
while (--i>=0);
|
||||
while (--i > -1);
|
||||
Bfree(t->items);
|
||||
t->items=0;
|
||||
t->items = 0;
|
||||
}
|
||||
|
||||
inline int HASH_getcode(const char *s)
|
||||
|
@ -12277,10 +12268,15 @@ void HASH_add(struct HASH_table *t, const char *s, int key)
|
|||
struct HASH_item *cur, *prev=NULL;
|
||||
int code;
|
||||
|
||||
if (!s)return;
|
||||
if (t->items==NULL) {initprintf("HASH_add: not initalized\n");return;}
|
||||
code=HASH_getcode(s)%t->size;
|
||||
cur=t->items[code];
|
||||
if (!s)
|
||||
return;
|
||||
if (t->items == NULL)
|
||||
{
|
||||
initprintf("HASH_add: not initalized\n");
|
||||
return;
|
||||
}
|
||||
code = HASH_getcode(s)%t->size;
|
||||
cur = t->items[code];
|
||||
|
||||
if (!cur)
|
||||
{
|
||||
|
@ -12294,7 +12290,8 @@ void HASH_add(struct HASH_table *t, const char *s, int key)
|
|||
|
||||
do
|
||||
{
|
||||
if (Bstrcmp(s,cur->string)==0)return;
|
||||
if (Bstrcmp(s,cur->string)==0)
|
||||
return;
|
||||
prev=cur;
|
||||
cur=cur->next;
|
||||
}
|
||||
|
|
|
@ -574,7 +574,7 @@ int mdloadskin_trytexcache(char *fn, int len, int pal, char effect, texcachehead
|
|||
}
|
||||
|
||||
md4once((unsigned char *)fn, strlen(fn), mdsum);
|
||||
// for (cp = cachefn, fp = 0; (*cp = TEXCACHEDIR[fp]); cp++,fp++);
|
||||
// for (cp = cachefn, fp = 0; (*cp = TEXCACHEFILE[fp]); cp++,fp++);
|
||||
// *(cp++) = '/';
|
||||
cp = cachefn;
|
||||
for (fp = 0; fp < 16; phex(mdsum[fp++], cp), cp+=2);
|
||||
|
@ -1049,7 +1049,7 @@ static md2model *md2load(int fil, const char *filnam)
|
|||
int i, j, k;
|
||||
|
||||
m = (md2model *)calloc(1,sizeof(md2model)); if (!m) return(0);
|
||||
m->mdnum = 2; m->scale = .01;
|
||||
m->mdnum = 2; m->scale = .01f;
|
||||
|
||||
kread(fil,(char *)&head,sizeof(md2head_t));
|
||||
head.id = B_LITTLE32(head.id); head.vers = B_LITTLE32(head.vers);
|
||||
|
|
|
@ -330,7 +330,7 @@ FILE *cacheindexptr = NULL;
|
|||
|
||||
static struct HASH_table cacheH = { MAXTILES<<2, NULL };
|
||||
|
||||
char TEXCACHEDIR[BMAX_PATH] = "textures";
|
||||
char TEXCACHEFILE[BMAX_PATH] = "textures";
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -727,44 +727,18 @@ void polymost_glreset()
|
|||
Bfclose(cacheindexptr);
|
||||
cacheindexptr = NULL;
|
||||
}
|
||||
|
||||
datextures = &firstcacheindex;
|
||||
numcacheentries = 0;
|
||||
Bmemset(&cacheptrs[0],0,sizeof(cacheptrs));
|
||||
HASH_init(&cacheH);
|
||||
LoadCacheOffsets();
|
||||
|
||||
Bstrcpy(tempbuf,TEXCACHEDIR);
|
||||
Bstrcat(tempbuf,".cache");
|
||||
cacheindexptr = Bfopen(tempbuf, "at");
|
||||
if (!cacheindexptr)
|
||||
{
|
||||
glusetexcache = 0;
|
||||
initprintf("Unable to open cache index!\n");
|
||||
return;
|
||||
}
|
||||
texcacheindex *index;
|
||||
|
||||
cachefilehandle = Bopen(TEXCACHEDIR,BO_BINARY|BO_CREAT|BO_APPEND|BO_RDWR,BS_IREAD|BS_IWRITE);
|
||||
|
||||
if (cachefilehandle < 0)
|
||||
datextures = firstcacheindex.next;
|
||||
while (datextures)
|
||||
{
|
||||
glusetexcache = 0;
|
||||
initprintf("Unable to open cache file! %s\n",strerror(errno));
|
||||
}
|
||||
|
||||
#if 0
|
||||
i = 0;
|
||||
|
||||
datextures = &firstcacheindex;
|
||||
while (datextures->next)
|
||||
{
|
||||
i += datextures->len;
|
||||
index = datextures;
|
||||
datextures = datextures->next;
|
||||
Bfree(index);
|
||||
}
|
||||
firstcacheindex.next = NULL;
|
||||
}
|
||||
datextures = &firstcacheindex;
|
||||
initprintf("Cache contains %d bytes of garbage data\n",Blseek(cachefilehandle, 0, BSEEK_END)-i);
|
||||
Blseek(cachefilehandle, 0, BSEEK_SET);
|
||||
#endif
|
||||
}
|
||||
|
||||
// one-time initialization of OpenGL for polymost
|
||||
|
@ -941,17 +915,18 @@ void polymost_glinit()
|
|||
|
||||
datextures = &firstcacheindex;
|
||||
numcacheentries = 0;
|
||||
Bmemset(&firstcacheindex, 0, sizeof(texcacheindex));
|
||||
Bmemset(&cacheptrs[0], 0, sizeof(cacheptrs));
|
||||
HASH_init(&cacheH);
|
||||
LoadCacheOffsets();
|
||||
|
||||
Bstrcpy(tempbuf,TEXCACHEDIR);
|
||||
Bstrcpy(tempbuf,TEXCACHEFILE);
|
||||
Bstrcat(tempbuf,".cache");
|
||||
cacheindexptr = Bfopen(tempbuf, "at");
|
||||
if (!cacheindexptr)
|
||||
{
|
||||
glusetexcache = 0;
|
||||
initprintf("Unable to open cache index!\n");
|
||||
initprintf("Unable to open cache index: %s\n",strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -959,15 +934,15 @@ void polymost_glinit()
|
|||
if (!ftell(cacheindexptr))
|
||||
{
|
||||
rewind(cacheindexptr);
|
||||
fprintf(cacheindexptr,"// this file automatically generated by EDuke32\n// DO NOT MODIFY\n");
|
||||
fprintf(cacheindexptr,"// automatically generated by EDuke32, DO NOT MODIFY!\n");
|
||||
}
|
||||
else rewind(cacheindexptr);
|
||||
|
||||
cachefilehandle = Bopen(TEXCACHEDIR,BO_BINARY|BO_CREAT|BO_APPEND|BO_RDWR,BS_IREAD|BS_IWRITE);
|
||||
cachefilehandle = Bopen(TEXCACHEFILE,BO_BINARY|BO_CREAT|BO_APPEND|BO_RDWR,BS_IREAD|BS_IWRITE);
|
||||
|
||||
if (cachefilehandle < 0)
|
||||
{
|
||||
initprintf("Unable to open cache file! %s\n",strerror(errno));
|
||||
initprintf("Unable to open cache file: %s\n",strerror(errno));
|
||||
glusetexcache = 0;
|
||||
return;
|
||||
}
|
||||
|
@ -988,7 +963,7 @@ void polymost_glinit()
|
|||
|
||||
void invalidatecache(void)
|
||||
{
|
||||
if (cachefilehandle > -1)
|
||||
if (cachefilehandle != -1)
|
||||
{
|
||||
Bclose(cachefilehandle);
|
||||
cachefilehandle = -1;
|
||||
|
@ -999,37 +974,45 @@ void invalidatecache(void)
|
|||
Bfclose(cacheindexptr);
|
||||
cacheindexptr = NULL;
|
||||
}
|
||||
{
|
||||
texcacheindex *index;
|
||||
|
||||
datextures = firstcacheindex.next;
|
||||
while (datextures)
|
||||
{
|
||||
index = datextures;
|
||||
datextures = datextures->next;
|
||||
Bfree(index);
|
||||
}
|
||||
}
|
||||
|
||||
datextures = &firstcacheindex;
|
||||
numcacheentries = 0;
|
||||
Bmemset(&firstcacheindex, 0, sizeof(texcacheindex));
|
||||
Bmemset(&cacheptrs[0], 0, sizeof(cacheptrs));
|
||||
HASH_init(&cacheH);
|
||||
// LoadCacheOffsets();
|
||||
|
||||
Bstrcpy(tempbuf,TEXCACHEDIR);
|
||||
Bstrcpy(tempbuf,TEXCACHEFILE);
|
||||
Bstrcat(tempbuf,".cache");
|
||||
cacheindexptr = Bfopen(tempbuf, "wt");
|
||||
if (!cacheindexptr)
|
||||
{
|
||||
glusetexcache = 0;
|
||||
initprintf("Unable to open cache index!\n");
|
||||
initprintf("Unable to open cache index: %s\n",strerror(errno));
|
||||
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);
|
||||
fprintf(cacheindexptr,"// automatically generated by EDuke32, DO NOT MODIFY!\n");
|
||||
|
||||
cachefilehandle = Bopen(TEXCACHEDIR,BO_BINARY|BO_CREAT|BO_TRUNC|BO_RDWR,BS_IREAD|BS_IWRITE);
|
||||
cachefilehandle = Bopen(TEXCACHEFILE,BO_BINARY|BO_TRUNC|BO_APPEND|BO_RDWR,BS_IREAD|BS_IWRITE);
|
||||
|
||||
if (cachefilehandle < 0)
|
||||
{
|
||||
initprintf("Unable to open cache file: %s\n",strerror(errno));
|
||||
glusetexcache = 0;
|
||||
initprintf("Unable to open cache file! %s\n",strerror(errno));
|
||||
return;
|
||||
}
|
||||
HASH_init(&cacheH);
|
||||
}
|
||||
|
||||
void resizeglcheck()
|
||||
|
@ -1403,7 +1386,7 @@ static int LoadCacheOffsets(void)
|
|||
|
||||
scriptfile *script;
|
||||
|
||||
Bstrcpy(tempbuf,TEXCACHEDIR);
|
||||
Bstrcpy(tempbuf,TEXCACHEFILE);
|
||||
Bstrcat(tempbuf,".cache");
|
||||
script = scriptfile_fromfile(tempbuf);
|
||||
|
||||
|
@ -1465,7 +1448,7 @@ int trytexcache(char *fn, int len, int dameth, char effect, texcacheheader *head
|
|||
}
|
||||
|
||||
md4once((unsigned char *)fn, strlen(fn), mdsum);
|
||||
// for (cp = cachefn, fp = 0; (*cp = TEXCACHEDIR[fp]); cp++,fp++);
|
||||
// for (cp = cachefn, fp = 0; (*cp = TEXCACHEFILE[fp]); cp++,fp++);
|
||||
// *(cp++) = '/';
|
||||
cp = cachefn;
|
||||
for (fp = 0; fp < 16; phex(mdsum[fp++], cp), cp+=2);
|
||||
|
@ -1479,21 +1462,6 @@ int trytexcache(char *fn, int len, int dameth, char effect, texcacheheader *head
|
|||
int len = 0;
|
||||
int i;
|
||||
|
||||
// texcacheindex *cacheindexptr = &firstcacheindex;
|
||||
|
||||
/* do
|
||||
{
|
||||
// initprintf("checking %s against %s\n",cachefn,cacheindexptr->name);
|
||||
if (!Bstrcmp(cachefn,cacheindexptr->name))
|
||||
{
|
||||
offset = cacheindexptr->offset;
|
||||
len = cacheindexptr->len;
|
||||
// initprintf("got a match for %s offset %d\n",cachefn,offset);
|
||||
// break;
|
||||
}
|
||||
cacheindexptr = cacheindexptr->next;
|
||||
}
|
||||
while (cacheindexptr->next); */
|
||||
i = HASH_find(&cacheH,cachefn);
|
||||
if (i != -1)
|
||||
{
|
||||
|
@ -1504,7 +1472,11 @@ int trytexcache(char *fn, int len, int dameth, char effect, texcacheheader *head
|
|||
}
|
||||
|
||||
if (len == 0) return -1; // didn't find it
|
||||
Blseek(cachefilehandle, offset, BSEEK_SET);
|
||||
if (Blseek(cachefilehandle, offset, BSEEK_SET) == -1)
|
||||
{
|
||||
OSD_Printf("Cache seek error: %s\n",strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// initprintf("Loading cached tex: %s\n", cachefn);
|
||||
|
@ -1555,18 +1527,18 @@ void writexcache(char *fn, int len, int dameth, char effect, texcacheheader *hea
|
|||
/*
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(TEXCACHEDIR, &st) < 0)
|
||||
if (stat(TEXCACHEFILE, &st) < 0)
|
||||
{
|
||||
if (errno == ENOENT) // path doesn't exist
|
||||
{
|
||||
// try to create the cache directory
|
||||
if (Bmkdir(TEXCACHEDIR, S_IRWXU) < 0)
|
||||
if (Bmkdir(TEXCACHEFILE, S_IRWXU) < 0)
|
||||
{
|
||||
OSD_Printf("Failed to create texture cache directory %s\n", TEXCACHEDIR);
|
||||
OSD_Printf("Failed to create texture cache directory %s\n", TEXCACHEFILE);
|
||||
glusetexcache = 0;
|
||||
return;
|
||||
}
|
||||
else OSD_Printf("Created texture cache directory %s\n", TEXCACHEDIR);
|
||||
else OSD_Printf("Created texture cache directory %s\n", TEXCACHEFILE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1588,7 +1560,7 @@ void writexcache(char *fn, int len, int dameth, char effect, texcacheheader *hea
|
|||
if (gi != GL_TRUE) return;
|
||||
|
||||
md4once((unsigned char *)fn, strlen(fn), mdsum);
|
||||
// for (cp = cachefn, fp = 0; (*cp = TEXCACHEDIR[fp]); cp++,fp++);
|
||||
// for (cp = cachefn, fp = 0; (*cp = TEXCACHEFILE[fp]); cp++,fp++);
|
||||
// *(cp++) = '/';
|
||||
cp = cachefn;
|
||||
for (fp = 0; fp < 16; phex(mdsum[fp++], cp), cp+=2);
|
||||
|
|
|
@ -7419,7 +7419,13 @@ static void G_CheckCommandLine(int argc, const char **argv)
|
|||
{
|
||||
if (argc > i+1)
|
||||
{
|
||||
#if defined(POLYMOST) && defined(USE_OPENGL)
|
||||
extern char TEXCACHEFILE[BMAX_PATH];
|
||||
Bsprintf(tempbuf,"%s/%s",argv[i+1],TEXCACHEFILE);
|
||||
Bstrcpy(TEXCACHEFILE,tempbuf);
|
||||
#endif
|
||||
AddGamePath(argv[i+1]);
|
||||
|
||||
COPYARG(i);
|
||||
COPYARG(i+1);
|
||||
i++;
|
||||
|
|
|
@ -117,7 +117,7 @@ static char *confilename = defaultconfilename;
|
|||
char *duke3ddef = "duke3d.def";
|
||||
char mod_dir[BMAX_PATH] = "/";
|
||||
#if defined(POLYMOST)
|
||||
extern char TEXCACHEDIR[BMAX_PATH];
|
||||
extern char TEXCACHEFILE[BMAX_PATH];
|
||||
#endif
|
||||
extern int lastvisinc;
|
||||
|
||||
|
@ -11067,8 +11067,8 @@ void app_main(int argc,const char **argv)
|
|||
addsearchpath(root);
|
||||
// addsearchpath(mod_dir);
|
||||
#if defined(POLYMOST) && defined(USE_OPENGL)
|
||||
Bsprintf(tempbuf,"%s/%s",mod_dir,TEXCACHEDIR);
|
||||
Bstrcpy(TEXCACHEDIR,tempbuf);
|
||||
Bsprintf(tempbuf,"%s/%s",mod_dir,TEXCACHEFILE);
|
||||
Bstrcpy(TEXCACHEFILE,tempbuf);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ static int getfilenames(char *path)
|
|||
#define POPULATE_GAMEDIRS 8
|
||||
|
||||
#if defined(POLYMOST)
|
||||
extern char TEXCACHEDIR[];
|
||||
extern char TEXCACHEFILE[];
|
||||
#endif
|
||||
|
||||
extern int g_noSetup;
|
||||
|
@ -193,7 +193,7 @@ static void PopulateForm(int pgs)
|
|||
for (dirs=finddirs,i=1; dirs != NULL; dirs=dirs->next,i++)
|
||||
{
|
||||
#if defined(POLYMOST) && defined(USE_OPENGL)
|
||||
if (Bstrcasecmp(TEXCACHEDIR,dirs->name) == 0) continue;
|
||||
if (Bstrcasecmp(TEXCACHEFILE,dirs->name) == 0) continue;
|
||||
#endif
|
||||
j = ComboBox_AddString(hwnd, dirs->name);
|
||||
(void)ComboBox_SetItemData(hwnd, j, i);
|
||||
|
|
Loading…
Reference in a new issue