mirror of
https://git.code.sf.net/p/quake/quakeforge-old
synced 2024-11-22 03:41:27 +00:00
Added sorting to the *.pak stuff..
Some other misc cleanups..
This commit is contained in:
parent
c097e1a282
commit
2678aa601f
6 changed files with 101 additions and 194 deletions
|
@ -1237,7 +1237,7 @@ void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboole
|
|||
int i, s;
|
||||
qboolean noalpha;
|
||||
int samples;
|
||||
static unsigned char scaled[1024*512]; // [512*256];
|
||||
static unsigned char scaled[1024*512]; // [512*256];
|
||||
int scaled_width, scaled_height;
|
||||
|
||||
s = width*height;
|
||||
|
|
|
@ -540,34 +540,35 @@ void R_TranslatePlayerSkin (int playernum)
|
|||
|
||||
GL_Upload8_EXT ((byte *)pixels, scaled_width, scaled_height, false, false);
|
||||
return;
|
||||
}
|
||||
} else { // This is for 24/32 bit GL displays...
|
||||
|
||||
for (i=0 ; i<256 ; i++)
|
||||
translate32[i] = d_8to24table[translate[i]];
|
||||
for (i=0 ; i<256 ; i++)
|
||||
translate32[i] = d_8to24table[translate[i]];
|
||||
|
||||
out = pixels;
|
||||
fracstep = inwidth*0x10000/scaled_width;
|
||||
for (i=0 ; i<scaled_height ; i++, out += scaled_width)
|
||||
{
|
||||
inrow = original + inwidth*(i*inheight/scaled_height);
|
||||
frac = fracstep >> 1;
|
||||
for (j=0 ; j<scaled_width ; j+=4)
|
||||
out = pixels;
|
||||
fracstep = inwidth*0x10000/scaled_width;
|
||||
for (i=0 ; i<scaled_height ; i++, out += scaled_width)
|
||||
{
|
||||
out[j] = translate32[inrow[frac>>16]];
|
||||
frac += fracstep;
|
||||
out[j+1] = translate32[inrow[frac>>16]];
|
||||
frac += fracstep;
|
||||
out[j+2] = translate32[inrow[frac>>16]];
|
||||
frac += fracstep;
|
||||
out[j+3] = translate32[inrow[frac>>16]];
|
||||
frac += fracstep;
|
||||
inrow = original + inwidth*(i*inheight/scaled_height);
|
||||
frac = fracstep >> 1;
|
||||
for (j=0 ; j<scaled_width ; j+=4)
|
||||
{
|
||||
out[j] = translate32[inrow[frac>>16]];
|
||||
frac += fracstep;
|
||||
out[j+1] = translate32[inrow[frac>>16]];
|
||||
frac += fracstep;
|
||||
out[j+2] = translate32[inrow[frac>>16]];
|
||||
frac += fracstep;
|
||||
out[j+3] = translate32[inrow[frac>>16]];
|
||||
frac += fracstep;
|
||||
}
|
||||
}
|
||||
}
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* QUAKEWORLD */
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
============================================================================
|
||||
|
@ -38,163 +39,6 @@
|
|||
============================================================================
|
||||
*/
|
||||
|
||||
#if 0
|
||||
void Q_memset (void *dest, int fill, int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
if ( (((long)dest | count) & 3) == 0)
|
||||
{
|
||||
count >>= 2;
|
||||
fill = fill | (fill<<8) | (fill<<16) | (fill<<24);
|
||||
for (i=0 ; i<count ; i++)
|
||||
((int *)dest)[i] = fill;
|
||||
}
|
||||
else
|
||||
for (i=0 ; i<count ; i++)
|
||||
((byte *)dest)[i] = fill;
|
||||
}
|
||||
|
||||
void Q_memcpy (void *dest, void *src, int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (( ( (long)dest | (long)src | count) & 3) == 0 )
|
||||
{
|
||||
count>>=2;
|
||||
for (i=0 ; i<count ; i++)
|
||||
((int *)dest)[i] = ((int *)src)[i];
|
||||
}
|
||||
else
|
||||
for (i=0 ; i<count ; i++)
|
||||
((byte *)dest)[i] = ((byte *)src)[i];
|
||||
}
|
||||
|
||||
int Q_memcmp (void *m1, void *m2, int count)
|
||||
{
|
||||
while(count)
|
||||
{
|
||||
count--;
|
||||
if (((byte *)m1)[count] != ((byte *)m2)[count])
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Q_strcpy (char *dest, char *src)
|
||||
{
|
||||
while (*src)
|
||||
{
|
||||
*dest++ = *src++;
|
||||
}
|
||||
*dest++ = 0;
|
||||
}
|
||||
|
||||
void Q_strncpy (char *dest, char *src, int count)
|
||||
{
|
||||
while (*src && count--)
|
||||
{
|
||||
*dest++ = *src++;
|
||||
}
|
||||
if (count)
|
||||
*dest++ = 0;
|
||||
}
|
||||
|
||||
int Q_strlen (char *str)
|
||||
{
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
while (str[count])
|
||||
count++;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
char *Q_strrchr(char *s, char c)
|
||||
{
|
||||
int len = Q_strlen(s);
|
||||
s += len;
|
||||
while (len--)
|
||||
if (*--s == c) return s;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Q_strcat (char *dest, char *src)
|
||||
{
|
||||
dest += Q_strlen(dest);
|
||||
Q_strcpy (dest, src);
|
||||
}
|
||||
|
||||
int Q_strcmp (char *s1, char *s2)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
if (*s1 != *s2)
|
||||
return -1; // strings not equal
|
||||
if (!*s1)
|
||||
return 0; // strings are equal
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Q_strncmp (char *s1, char *s2, int count)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
if (!count--)
|
||||
return 0;
|
||||
if (*s1 != *s2)
|
||||
return -1; // strings not equal
|
||||
if (!*s1)
|
||||
return 0; // strings are equal
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Q_strncasecmp (char *s1, char *s2, int n)
|
||||
{
|
||||
int c1, c2;
|
||||
|
||||
while (1)
|
||||
{
|
||||
c1 = *s1++;
|
||||
c2 = *s2++;
|
||||
|
||||
if (!n--)
|
||||
return 0; // strings are equal until end point
|
||||
|
||||
if (c1 != c2)
|
||||
{
|
||||
if (c1 >= 'a' && c1 <= 'z')
|
||||
c1 -= ('a' - 'A');
|
||||
if (c2 >= 'a' && c2 <= 'z')
|
||||
c2 -= ('a' - 'A');
|
||||
if (c1 != c2)
|
||||
return -1; // strings not equal
|
||||
}
|
||||
if (!c1)
|
||||
return 0; // strings are equal
|
||||
// s1++;
|
||||
// s2++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Q_strcasecmp (char *s1, char *s2)
|
||||
{
|
||||
return Q_strncasecmp (s1, s2, 99999);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int Q_atoi (char *str)
|
||||
{
|
||||
int val;
|
||||
|
@ -328,3 +172,35 @@ float Q_atof (char *str)
|
|||
|
||||
return val*sign;
|
||||
}
|
||||
|
||||
// Note, this is /NOT/ a work-alike strcmp, this groups numbers sanely.
|
||||
int Q_qstrcmp(const char *val, const char *ref)
|
||||
{
|
||||
int vc, rc;
|
||||
long vl, rl;
|
||||
const char *vp, *rp;
|
||||
|
||||
if (!val) val= "";
|
||||
if (!ref) ref= "";
|
||||
for (;;) {
|
||||
vp= val; while (*vp && !isdigit(*vp)) vp++;
|
||||
rp= ref; while (*rp && !isdigit(*rp)) rp++;
|
||||
for (;;) {
|
||||
vc= val == vp ? 0 : *val++;
|
||||
rc= ref == rp ? 0 : *ref++;
|
||||
if (!rc && !vc) break;
|
||||
if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */
|
||||
if (rc && !isalpha(rc)) rc += 256;
|
||||
if (vc != rc) return vc - rc;
|
||||
}
|
||||
val= vp;
|
||||
ref= rp;
|
||||
vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10);
|
||||
rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10);
|
||||
if (vl != rl) return vl - rl;
|
||||
if (!*val && !*ref) return 0;
|
||||
if (!*val) return -1;
|
||||
if (!*ref) return +1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,5 +58,6 @@
|
|||
|
||||
int Q_atoi (char *str);
|
||||
float Q_atof (char *str);
|
||||
int Q_qstrcmp(const char *val, const char *ref);
|
||||
|
||||
#endif // _LIB_REPLACE_H
|
||||
|
|
|
@ -88,7 +88,7 @@ byte *LoadPCX (char *file, cache_user_t *cache, int buf_x, int buf_y) {
|
|||
if (!buf_y)
|
||||
buf_y = pcx->ymax;
|
||||
|
||||
Con_Printf("PCX file %s %dx%d\n", file, buf_x, buf_y);
|
||||
Con_DPrintf("PCX file %s %dx%d\n", file, buf_x, buf_y);
|
||||
out = Cache_Alloc (cache, buf_x * buf_y, file);
|
||||
if (!out)
|
||||
Sys_Error("LoadPCX: couldn't allocate.");
|
||||
|
|
|
@ -723,29 +723,58 @@ COM_LoadGameDirectory(char *dir)
|
|||
char pakfile[MAX_OSPATH];
|
||||
DIR *dir_ptr;
|
||||
struct dirent *dirent;
|
||||
char **pakfiles;
|
||||
int i = 0, bufsize = 0, count = 0;
|
||||
|
||||
pakfiles = calloc(1, BLOCK_SIZE);
|
||||
bufsize += BLOCK_SIZE;
|
||||
if (!pakfiles)
|
||||
goto COM_LoadGameDirectory_free;
|
||||
|
||||
dir_ptr = opendir(dir);
|
||||
if (!dir_ptr)
|
||||
return;
|
||||
|
||||
while ((dirent = readdir(dir_ptr))) {
|
||||
if (!fnmatch("*.pak", dirent->d_name, FNMATCH_FLAGS)) {
|
||||
snprintf(pakfile, sizeof(pakfile), "%s/%s", dir, dirent->d_name);
|
||||
|
||||
pak = COM_LoadPackFile(pakfile);
|
||||
|
||||
if (!pak) {
|
||||
Sys_Error(va("Bad pakfile %s!!", pakfile));
|
||||
} else {
|
||||
search = Z_Malloc (sizeof(searchpath_t));
|
||||
search->pack = pak;
|
||||
search->next = com_searchpaths;
|
||||
com_searchpaths = search;
|
||||
if (count >= bufsize) {
|
||||
bufsize += BLOCK_SIZE;
|
||||
pakfiles = realloc(pakfiles, bufsize);
|
||||
if (!pakfiles)
|
||||
goto COM_LoadGameDirectory_free;
|
||||
for (i = count; i < bufsize; i++)
|
||||
pakfiles[i] = NULL;
|
||||
}
|
||||
pakfiles[count] = malloc(FNAME_SIZE);
|
||||
snprintf(pakfiles[count], FNAME_SIZE - 1, "%s/%s", dir,
|
||||
dirent->d_name);
|
||||
pakfiles[count][FNAME_SIZE - 1] = '\0';
|
||||
count++;
|
||||
}
|
||||
}
|
||||
closedir(dir_ptr);
|
||||
|
||||
qsort(pakfiles, count, FNAME_SIZE,
|
||||
(int (*)(const void *, const void *)) Q_qstrcmp);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
pak = COM_LoadPackFile(pakfiles[i]);
|
||||
|
||||
if (!pak) {
|
||||
Sys_Error(va("Bad pakfile %s!!", pakfiles[i]));
|
||||
} else {
|
||||
search = Z_Malloc (sizeof(searchpath_t));
|
||||
search->pack = pak;
|
||||
search->next = com_searchpaths;
|
||||
com_searchpaths = search;
|
||||
}
|
||||
}
|
||||
|
||||
COM_LoadGameDirectory_free:
|
||||
for (i = 0; i < count; i++)
|
||||
free(pakfiles[i]);
|
||||
free(pakfiles);
|
||||
|
||||
#ifdef GENERATIONS
|
||||
for (done=false, i=0 ; !done ; i++ ) {
|
||||
snprintf(pakfile, sizeof(pakfile), "%s/pak%i.qz", dir, i);
|
||||
|
@ -759,7 +788,7 @@ COM_LoadGameDirectory(char *dir)
|
|||
search->pack = pak;
|
||||
search->next = com_searchpaths;
|
||||
com_searchpaths = search;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue