2004-08-23 01:38:21 +00:00
|
|
|
#include "progsint.h"
|
2016-09-08 19:04:35 +00:00
|
|
|
#include "qcc.h"
|
2004-08-23 01:38:21 +00:00
|
|
|
|
2023-07-01 22:20:13 +00:00
|
|
|
#if !defined(FTE_TARGET_WEB) && !defined(_XBOX)
|
2018-01-22 19:18:04 +00:00
|
|
|
#ifndef AVAIL_ZLIB
|
2016-09-01 14:31:24 +00:00
|
|
|
#define AVAIL_ZLIB
|
|
|
|
#endif
|
2018-01-22 19:18:04 +00:00
|
|
|
#endif
|
2009-05-24 10:11:17 +00:00
|
|
|
|
2018-08-23 07:04:55 +00:00
|
|
|
#ifdef NO_ZLIB
|
|
|
|
#undef AVAIL_ZLIB
|
|
|
|
#endif
|
|
|
|
|
2004-08-23 01:38:21 +00:00
|
|
|
#ifdef AVAIL_ZLIB
|
2013-09-26 14:36:52 +00:00
|
|
|
#include <zlib.h>
|
2004-08-23 01:38:21 +00:00
|
|
|
#endif
|
|
|
|
|
2009-05-24 10:11:17 +00:00
|
|
|
pbool QC_decodeMethodSupported(int method)
|
|
|
|
{
|
|
|
|
if (method == 0)
|
|
|
|
return true;
|
|
|
|
if (method == 1)
|
|
|
|
return true;
|
|
|
|
if (method == 2)
|
|
|
|
{
|
|
|
|
#ifdef AVAIL_ZLIB
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-03-27 12:53:40 +00:00
|
|
|
|
|
|
|
#ifdef ZLIB_DEFLATE64
|
|
|
|
#include "infback9.h" //an obscure compile-your-own part of zlib.
|
|
|
|
struct def64ctx
|
|
|
|
{
|
|
|
|
const char *in;
|
|
|
|
char *out;
|
|
|
|
size_t csize;
|
|
|
|
size_t usize;
|
|
|
|
|
|
|
|
char window[65536];
|
|
|
|
};
|
|
|
|
static unsigned int QC_Deflate64_Grab(void *vctx, unsigned char **bufptr)
|
|
|
|
{
|
|
|
|
struct def64ctx *ctx = vctx;
|
|
|
|
|
|
|
|
unsigned int avail = ctx->csize;
|
|
|
|
*bufptr = (unsigned char *)ctx->in;
|
|
|
|
ctx->csize = 0;
|
|
|
|
ctx->in += avail;
|
|
|
|
|
|
|
|
return avail;
|
|
|
|
}
|
|
|
|
static int QC_Deflate64_Spew(void *vctx, unsigned char *buf, unsigned int buflen)
|
|
|
|
{
|
|
|
|
struct def64ctx *ctx = vctx;
|
|
|
|
|
|
|
|
if (buflen > ctx->usize)
|
|
|
|
return 1; //over the size of our buffer...
|
|
|
|
memcpy(ctx->out, buf, buflen);
|
|
|
|
ctx->out += buflen;
|
|
|
|
ctx->usize -= buflen;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-20 01:00:18 +00:00
|
|
|
char *QC_decode(progfuncs_t *progfuncs, int complen, int len, int method, const void *info, char *buffer)
|
2004-08-23 01:38:21 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
if (method == 0) //copy
|
|
|
|
{
|
2019-09-25 20:23:24 +00:00
|
|
|
if (complen != len) externs->Sys_Error("lengths do not match");
|
2004-08-23 01:38:21 +00:00
|
|
|
memcpy(buffer, info, len);
|
|
|
|
}
|
2009-05-24 10:11:17 +00:00
|
|
|
else if (method == 1) //xor encryption
|
2004-08-23 01:38:21 +00:00
|
|
|
{
|
2019-09-25 20:23:24 +00:00
|
|
|
if (complen != len) externs->Sys_Error("lengths do not match");
|
2004-08-23 01:38:21 +00:00
|
|
|
for (i = 0; i < len; i++)
|
2019-01-20 01:00:18 +00:00
|
|
|
buffer[i] = ((const char*)info)[i] ^ 0xA5;
|
2004-08-23 01:38:21 +00:00
|
|
|
}
|
2009-05-24 10:11:17 +00:00
|
|
|
#ifdef AVAIL_ZLIB
|
2016-09-08 19:04:35 +00:00
|
|
|
else if (method == 2 || method == 8) //compression (ZLIB)
|
|
|
|
{
|
2004-08-23 01:38:21 +00:00
|
|
|
z_stream strm = {
|
2016-09-08 19:04:35 +00:00
|
|
|
(char*)info,
|
2004-08-23 01:38:21 +00:00
|
|
|
complen,
|
|
|
|
0,
|
|
|
|
|
|
|
|
buffer,
|
|
|
|
len,
|
|
|
|
0,
|
|
|
|
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
|
|
|
|
Z_BINARY,
|
|
|
|
0,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2016-09-08 19:04:35 +00:00
|
|
|
if (method == 8)
|
|
|
|
inflateInit2(&strm, -MAX_WBITS);
|
|
|
|
else
|
|
|
|
inflateInit(&strm);
|
2004-08-23 01:38:21 +00:00
|
|
|
if (Z_STREAM_END != inflate(&strm, Z_FINISH)) //decompress it in one go.
|
2019-09-25 20:23:24 +00:00
|
|
|
externs->Sys_Error("Failed block decompression\n");
|
2004-08-23 01:38:21 +00:00
|
|
|
inflateEnd(&strm);
|
2009-05-24 10:11:17 +00:00
|
|
|
}
|
2023-03-27 12:53:40 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ZLIB_DEFLATE64
|
|
|
|
else if (method == 9)
|
|
|
|
{
|
|
|
|
z_stream strm = {NULL};
|
|
|
|
struct def64ctx ctx;
|
|
|
|
ctx.in = info;
|
|
|
|
ctx.csize = complen;
|
|
|
|
ctx.out = buffer;
|
|
|
|
ctx.usize = len;
|
|
|
|
|
|
|
|
strm.data_type = Z_UNKNOWN;
|
|
|
|
inflateBack9Init(&strm, ctx.window);
|
|
|
|
//getting inflateBack9 to
|
|
|
|
if (Z_STREAM_END != inflateBack9(&strm, QC_Deflate64_Grab, &ctx, QC_Deflate64_Spew, &ctx))
|
|
|
|
{ //some stream error?
|
|
|
|
externs->Printf("Decompression error\n");
|
|
|
|
buffer = NULL;
|
|
|
|
}
|
|
|
|
else if (ctx.csize != 0 || ctx.usize != 0)
|
|
|
|
{ //corrupt file table?
|
|
|
|
externs->Printf("Decompression size error\n");
|
|
|
|
externs->Printf("read %i of %i bytes\n", (unsigned)ctx.csize, (unsigned)complen);
|
|
|
|
externs->Printf("wrote %i of %i bytes\n", (unsigned)ctx.usize, (unsigned)len);
|
|
|
|
buffer = NULL;
|
|
|
|
}
|
|
|
|
inflateBack9End(&strm);
|
|
|
|
return buffer;
|
|
|
|
}
|
2016-09-08 19:04:35 +00:00
|
|
|
#endif
|
2004-08-23 01:38:21 +00:00
|
|
|
//add your decryption/decompression routine here.
|
|
|
|
else
|
2019-09-25 20:23:24 +00:00
|
|
|
externs->Sys_Error("Bad file encryption routine\n");
|
2004-08-23 01:38:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2013-04-02 05:18:17 +00:00
|
|
|
#if !defined(MINIMAL) && !defined(OMIT_QCC)
|
2016-09-01 14:31:24 +00:00
|
|
|
int QC_encodecrc(int len, char *in)
|
|
|
|
{
|
|
|
|
#ifdef AVAIL_ZLIB
|
|
|
|
return crc32(0, in, len);
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
2016-09-08 19:04:35 +00:00
|
|
|
void SafeWrite(int hand, const void *buf, long count);
|
2004-08-23 01:38:21 +00:00
|
|
|
int SafeSeek(int hand, int ofs, int mode);
|
|
|
|
//we are allowed to trash our input here.
|
2016-09-08 19:04:35 +00:00
|
|
|
int QC_encode(progfuncs_t *progfuncs, int len, int method, const char *in, int handle)
|
2004-08-23 01:38:21 +00:00
|
|
|
{
|
2013-09-26 14:36:52 +00:00
|
|
|
if (method == 0) //copy, allows a lame pass-through.
|
2004-08-23 01:38:21 +00:00
|
|
|
{
|
|
|
|
SafeWrite(handle, in, len);
|
|
|
|
return len;
|
|
|
|
}
|
2016-09-08 19:04:35 +00:00
|
|
|
/*else if (method == 1) //xor encryption, not secure. maybe useful for the string table.
|
2004-08-23 01:38:21 +00:00
|
|
|
{
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
in[i] = in[i] ^ 0xA5;
|
|
|
|
SafeWrite(handle, in, len);
|
|
|
|
return len;
|
2016-09-08 19:04:35 +00:00
|
|
|
}*/
|
2016-09-01 14:31:24 +00:00
|
|
|
else if (method == 2 || method == 8) //compression (ZLIB)
|
2004-08-23 01:38:21 +00:00
|
|
|
{
|
2009-05-24 10:11:17 +00:00
|
|
|
#ifdef AVAIL_ZLIB
|
2004-08-23 01:38:21 +00:00
|
|
|
char out[8192];
|
2016-12-21 15:48:52 +00:00
|
|
|
int i=0;
|
2004-08-23 01:38:21 +00:00
|
|
|
|
|
|
|
z_stream strm = {
|
2016-09-08 19:04:35 +00:00
|
|
|
(char *)in,
|
2004-08-23 01:38:21 +00:00
|
|
|
len,
|
|
|
|
0,
|
|
|
|
|
|
|
|
out,
|
|
|
|
sizeof(out),
|
|
|
|
0,
|
|
|
|
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
|
|
|
|
Z_BINARY,
|
|
|
|
0,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2016-09-01 14:31:24 +00:00
|
|
|
if (method == 8)
|
|
|
|
deflateInit2(&strm, 9, Z_DEFLATED, -MAX_WBITS, 9, Z_DEFAULT_STRATEGY); //zip deflate compression
|
|
|
|
else
|
|
|
|
deflateInit(&strm, Z_BEST_COMPRESSION); //zlib compression
|
2004-08-23 01:38:21 +00:00
|
|
|
while(deflate(&strm, Z_FINISH) == Z_OK)
|
|
|
|
{
|
|
|
|
SafeWrite(handle, out, sizeof(out) - strm.avail_out); //compress in chunks of 8192. Saves having to allocate a huge-mega-big buffer
|
|
|
|
i+=sizeof(out) - strm.avail_out;
|
|
|
|
strm.next_out = out;
|
|
|
|
strm.avail_out = sizeof(out);
|
|
|
|
}
|
|
|
|
SafeWrite(handle, out, sizeof(out) - strm.avail_out);
|
|
|
|
i+=sizeof(out) - strm.avail_out;
|
|
|
|
deflateEnd(&strm);
|
|
|
|
return i;
|
|
|
|
#endif
|
2019-09-25 20:23:24 +00:00
|
|
|
externs->Sys_Error("ZLIB compression not supported in this build");
|
2009-05-24 10:11:17 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2004-08-23 01:38:21 +00:00
|
|
|
//add your compression/decryption routine here.
|
|
|
|
else
|
|
|
|
{
|
2019-09-25 20:23:24 +00:00
|
|
|
externs->Sys_Error("Wierd method");
|
2004-08-23 01:38:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-09-08 19:04:35 +00:00
|
|
|
static int QC_ReadRawInt(const unsigned char *blob)
|
|
|
|
{
|
|
|
|
return (blob[0]<<0) | (blob[1]<<8) | (blob[2]<<16) | (blob[3]<<24);
|
|
|
|
}
|
|
|
|
static int QC_ReadRawShort(const unsigned char *blob)
|
|
|
|
{
|
|
|
|
return (blob[0]<<0) | (blob[1]<<8);
|
|
|
|
}
|
2017-06-21 01:24:25 +00:00
|
|
|
int QC_EnumerateFilesFromBlob(const void *blob, size_t blobsize, void (*cb)(const char *name, const void *compdata, size_t compsize, int method, size_t plainsize))
|
2016-09-08 19:04:35 +00:00
|
|
|
{
|
|
|
|
unsigned int cdentries;
|
|
|
|
unsigned int cdlen;
|
2023-04-23 05:21:46 +00:00
|
|
|
unsigned int cdstart;
|
|
|
|
unsigned int zipoffset = 0;
|
2016-09-08 19:04:35 +00:00
|
|
|
const unsigned char *eocd;
|
|
|
|
const unsigned char *cd;
|
2023-03-27 12:53:40 +00:00
|
|
|
unsigned int ofs_le;
|
|
|
|
unsigned int cd_nl,cd_el,cd_cl;
|
2017-06-21 01:24:25 +00:00
|
|
|
int ret = 0;
|
2023-03-27 12:53:40 +00:00
|
|
|
|
|
|
|
const unsigned char *le;
|
2023-04-23 05:21:46 +00:00
|
|
|
unsigned int csize, usize;
|
|
|
|
int method; //negatives for errors.
|
2023-03-27 12:53:40 +00:00
|
|
|
unsigned int le_nl,le_el;
|
|
|
|
char name[256];
|
|
|
|
|
|
|
|
const void *data;
|
|
|
|
|
2016-09-08 19:04:35 +00:00
|
|
|
if (blobsize < 22)
|
2017-06-21 01:24:25 +00:00
|
|
|
return ret;
|
2018-07-05 16:21:44 +00:00
|
|
|
if (!strncmp(blob, "PACK", 4))
|
|
|
|
{
|
|
|
|
const packheader_t *head = blob;
|
|
|
|
const packfile_t *f = (packfile_t*)((char*)blob + head->dirofs);
|
|
|
|
for (ret = 0; ret < head->dirlen/sizeof(*f); ret++, f++)
|
|
|
|
{
|
|
|
|
cb(f->name, (const char*)blob+f->filepos, f->filelen, 0, f->filelen);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-04-23 05:21:46 +00:00
|
|
|
//treat it as a zip (with no comment, too lazy to scan)
|
2016-09-08 19:04:35 +00:00
|
|
|
eocd = blob;
|
|
|
|
eocd += blobsize-22;
|
2023-04-23 05:21:46 +00:00
|
|
|
for (cdlen = 0; ; eocd--, cdlen++)
|
|
|
|
{
|
|
|
|
if (cdlen > 65535 || eocd < (const unsigned char*)blob)
|
|
|
|
{
|
|
|
|
printf("No zip EOCD\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (QC_ReadRawInt(eocd+0) == 0x06054b50)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (QC_ReadRawShort(eocd+4) || QC_ReadRawShort(eocd+6) || QC_ReadRawShort(eocd+20)!=cdlen || QC_ReadRawShort(eocd+8) != QC_ReadRawShort(eocd+10))
|
|
|
|
{ //this-disk start-disk comment-length numfiles_thisdisk numfiles_all
|
|
|
|
printf("Unsupported zip\n");
|
2017-06-21 01:24:25 +00:00
|
|
|
return ret;
|
2023-04-23 05:21:46 +00:00
|
|
|
}
|
|
|
|
cdstart = QC_ReadRawInt(eocd+16);
|
2016-09-08 19:04:35 +00:00
|
|
|
cdlen = QC_ReadRawInt(eocd+12);
|
2021-06-01 09:23:42 +00:00
|
|
|
cdentries = QC_ReadRawShort(eocd+10);
|
2023-04-23 05:21:46 +00:00
|
|
|
cd = blob;
|
|
|
|
cd += cdstart + zipoffset;
|
|
|
|
if (cdlen < 46 || cd+cdlen>=(const unsigned char*)blob+blobsize || cd[0]!='P'||cd[1]!='K'||cd[2]!=1||cd[3]!=2)
|
|
|
|
{ //cd looks corrupt? assume eocd starts right after the cd and use that as an offset at the start of the zip (concatenated onto a binary or w/e)
|
|
|
|
zipoffset += (eocd-(const unsigned char*)blob) - (cdstart+cdlen);
|
|
|
|
|
|
|
|
cd = blob;
|
|
|
|
cd += cdstart + zipoffset;
|
|
|
|
|
|
|
|
if (cdlen < 46 || zipoffset > blobsize || cd+cdlen>=(const unsigned char*)blob+blobsize || cd[0]!='P'||cd[1]!='K'||cd[2]!=1||cd[3]!=2)
|
|
|
|
{
|
|
|
|
printf("Zip CentralDir not found: %s\n", cd);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
//okay, we're at an offset.
|
|
|
|
printf("Zip offset is %u\n", zipoffset);
|
|
|
|
}
|
2016-09-08 19:04:35 +00:00
|
|
|
|
|
|
|
|
2023-03-27 12:53:40 +00:00
|
|
|
for(; cdentries --> 0 && (QC_ReadRawInt(cd+0) == 0x02014b50); cd += 46 + cd_nl+cd_el+cd_cl)
|
2016-09-08 19:04:35 +00:00
|
|
|
{
|
2023-03-27 12:53:40 +00:00
|
|
|
data = NULL, csize=usize=0, method=-1;
|
|
|
|
|
|
|
|
cd_nl = QC_ReadRawShort(cd+28); //name length
|
|
|
|
cd_el = QC_ReadRawShort(cd+30); //extras length
|
|
|
|
cd_cl = QC_ReadRawShort(cd+32); //comment length
|
|
|
|
|
|
|
|
ofs_le = QC_ReadRawInt(cd+42);
|
|
|
|
|
|
|
|
if (cd_nl < sizeof(name)) //make can't be too long...
|
|
|
|
QC_strlcpy(name, cd+46, (cd_nl+1<sizeof(name))?cd_nl+1:sizeof(name));
|
|
|
|
else
|
|
|
|
QC_strlcpy(name, "?", sizeof(name));
|
2016-09-08 19:04:35 +00:00
|
|
|
|
2016-11-20 20:52:41 +00:00
|
|
|
//1=encrypted
|
|
|
|
//2,4=encoder flags
|
|
|
|
//8=crc etc info is dodgy
|
|
|
|
//10=enhanced deflate
|
|
|
|
//20=patchdata
|
|
|
|
//40=strong encryption
|
|
|
|
//80,100,200,400=unused
|
|
|
|
//800=utf-8
|
|
|
|
//1000=enh comp
|
|
|
|
//2000=masked localheader
|
|
|
|
//4000,8000=reserved
|
2023-03-27 12:53:40 +00:00
|
|
|
if (!(QC_ReadRawShort(cd+8) & ~0x80e)) //only accept known cd general purpose flags
|
2016-09-08 19:04:35 +00:00
|
|
|
{
|
2023-03-27 12:53:40 +00:00
|
|
|
if (ofs_le+46 < blobsize)
|
|
|
|
{
|
2023-04-23 05:21:46 +00:00
|
|
|
le = (const unsigned char*)blob + zipoffset + QC_ReadRawInt(cd+42);
|
2023-03-27 12:53:40 +00:00
|
|
|
|
|
|
|
if (QC_ReadRawInt(le+0) == 0x04034b50) //needs proper local entry tag
|
|
|
|
if (!(QC_ReadRawShort(le+6) & ~0x80e)) //ignore unsupported general purpose flags
|
|
|
|
{
|
|
|
|
le_nl = QC_ReadRawShort(le+26);
|
|
|
|
le_el = QC_ReadRawShort(le+28);
|
|
|
|
if (cd_nl == le_nl) //name (length) must match...
|
|
|
|
// if (cd_el != le_el) //extras does NOT match
|
|
|
|
{
|
2023-04-23 05:21:46 +00:00
|
|
|
unsigned short gpflags = QC_ReadRawShort(le+6);
|
|
|
|
if (gpflags & (1u<<3))
|
|
|
|
{ //stream-compressed (csize+usize+crc are AFTER the data... just fall back to the central directory instead)
|
|
|
|
csize = QC_ReadRawInt(cd+20);
|
|
|
|
usize = QC_ReadRawInt(cd+24);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
csize = QC_ReadRawInt(le+18);
|
|
|
|
usize = QC_ReadRawInt(le+22);
|
|
|
|
}
|
|
|
|
|
|
|
|
//parse extra
|
|
|
|
if (le_el)
|
|
|
|
{
|
|
|
|
const pbyte *extra = le + 30 + le_nl, *extraend = extra + le_el;
|
|
|
|
unsigned short extrachunk_tag;
|
|
|
|
unsigned short extrachunk_len;
|
|
|
|
|
|
|
|
while(extra+4 < extraend)
|
|
|
|
{
|
|
|
|
extrachunk_tag = QC_ReadRawShort(extra+0);
|
|
|
|
extrachunk_len = QC_ReadRawShort(extra+2);
|
|
|
|
if (extra + extrachunk_len > extraend)
|
|
|
|
break; //error
|
|
|
|
extra += 4;
|
|
|
|
|
|
|
|
switch(extrachunk_tag)
|
|
|
|
{
|
|
|
|
case 1: //zip64 extended information extra field. the attributes are only present if the reegular file info is nulled out with a -1
|
|
|
|
if (usize == 0xffffffffu)
|
|
|
|
{
|
|
|
|
usize = QC_ReadRawInt/*64*/(extra);
|
|
|
|
if (QC_ReadRawInt(extra+4))
|
|
|
|
method=-1-method;
|
|
|
|
extra += 8;
|
|
|
|
}
|
|
|
|
if (csize == 0xffffffffu)
|
|
|
|
{
|
|
|
|
csize = QC_ReadRawInt/*64*/(extra);
|
|
|
|
if (QC_ReadRawInt(extra+4))
|
|
|
|
method=-1-method;
|
|
|
|
extra += 8;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* printf("Unknown chunk %x\n", extrachunk_tag);
|
|
|
|
case 0x000a: //NTFS (timestamps)
|
|
|
|
case 0x5455: //extended timestamp
|
|
|
|
case 0x7875: //unix uid/gid
|
|
|
|
*/ extra += extrachunk_len;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-03-27 12:53:40 +00:00
|
|
|
|
|
|
|
data = le+30+le_nl+le_el;
|
|
|
|
|
|
|
|
method = QC_ReadRawShort(le+8);
|
2023-04-23 05:21:46 +00:00
|
|
|
if (method >= 0 && (method != 0
|
2023-03-27 12:53:40 +00:00
|
|
|
#ifdef AVAIL_ZLIB
|
|
|
|
&& method != 8
|
|
|
|
#endif
|
|
|
|
#ifdef ZLIB_DEFLATE64
|
|
|
|
&& method != 9
|
|
|
|
#endif
|
2023-04-23 05:21:46 +00:00
|
|
|
))
|
2023-03-27 12:53:40 +00:00
|
|
|
method=-1-method;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-08 19:04:35 +00:00
|
|
|
}
|
2023-03-27 12:53:40 +00:00
|
|
|
cb(name, data, csize, method, usize);
|
|
|
|
ret++;
|
2016-09-08 19:04:35 +00:00
|
|
|
}
|
2017-06-21 01:24:25 +00:00
|
|
|
return ret;
|
2016-09-08 19:04:35 +00:00
|
|
|
}
|
|
|
|
|
2019-01-20 01:00:18 +00:00
|
|
|
char *PDECL filefromprogs(pubprogfuncs_t *ppf, progsnum_t prnum, const char *fname, size_t *size, char *buffer)
|
2004-08-23 01:38:21 +00:00
|
|
|
{
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
progfuncs_t *progfuncs = (progfuncs_t*)ppf;
|
2004-08-23 01:38:21 +00:00
|
|
|
int num;
|
|
|
|
includeddatafile_t *s;
|
2014-10-05 20:04:11 +00:00
|
|
|
if (size)
|
|
|
|
*size = 0;
|
2004-08-23 01:38:21 +00:00
|
|
|
if (!pr_progstate[prnum].progs)
|
|
|
|
return NULL;
|
2005-02-28 07:16:19 +00:00
|
|
|
if (pr_progstate[prnum].progs->version != PROG_EXTENDEDVERSION)
|
2004-08-23 01:38:21 +00:00
|
|
|
return NULL;
|
2017-01-29 13:10:53 +00:00
|
|
|
if (pr_progstate[prnum].progs->secondaryversion != PROG_SECONDARYVERSION16 &&
|
|
|
|
pr_progstate[prnum].progs->secondaryversion != PROG_SECONDARYVERSION32)
|
2004-08-23 01:38:21 +00:00
|
|
|
return NULL;
|
2016-09-01 14:31:24 +00:00
|
|
|
|
2004-08-23 01:38:21 +00:00
|
|
|
num = *(int*)((char *)pr_progstate[prnum].progs + pr_progstate[prnum].progs->ofsfiles);
|
|
|
|
s = (includeddatafile_t *)((char *)pr_progstate[prnum].progs + pr_progstate[prnum].progs->ofsfiles+4);
|
|
|
|
while(num>0)
|
|
|
|
{
|
|
|
|
if (!strcmp(s->filename, fname))
|
|
|
|
{
|
|
|
|
if (size)
|
|
|
|
*size = s->size;
|
|
|
|
if (!buffer)
|
2014-10-05 20:04:11 +00:00
|
|
|
return NULL;
|
2004-08-23 01:38:21 +00:00
|
|
|
return QC_decode(progfuncs, s->compsize, s->size, s->compmethod, (char *)pr_progstate[prnum].progs+s->ofs, buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
s++;
|
|
|
|
num--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size)
|
|
|
|
*size = 0;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-06-13 11:57:52 +00:00
|
|
|
/*
|
2019-01-20 01:00:18 +00:00
|
|
|
char *filefromnewprogs(progfuncs_t *progfuncs, const char *prname, const char *fname, int *size, char *buffer)
|
2004-08-23 01:38:21 +00:00
|
|
|
{
|
|
|
|
int num;
|
|
|
|
includeddatafile_t *s;
|
|
|
|
progstate_t progs;
|
|
|
|
if (!PR_ReallyLoadProgs(progfuncs, prname, -1, &progs, false))
|
|
|
|
{
|
|
|
|
if (size)
|
|
|
|
*size = 0;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-02-28 07:16:19 +00:00
|
|
|
if (progs.progs->version < PROG_EXTENDEDVERSION)
|
2004-08-23 01:38:21 +00:00
|
|
|
return NULL;
|
|
|
|
if (!progs.progs->ofsfiles)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
num = *(int*)((char *)progs.progs + progs.progs->ofsfiles);
|
|
|
|
s = (includeddatafile_t *)((char *)progs.progs + progs.progs->ofsfiles+4);
|
|
|
|
while(num>0)
|
|
|
|
{
|
|
|
|
if (!strcmp(s->filename, fname))
|
|
|
|
{
|
|
|
|
if (size)
|
|
|
|
*size = s->size;
|
|
|
|
if (!buffer)
|
|
|
|
return (char *)0xffffffff;
|
|
|
|
return QC_decode(progfuncs, s->compsize, s->size, s->compmethod, (char *)progs.progs+s->ofs, buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
s++;
|
|
|
|
num--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size)
|
|
|
|
*size = 0;
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-06-13 11:57:52 +00:00
|
|
|
*/
|