more comprehensive attempt at fixing the qccgui bug reported by shpuld.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5247 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2018-04-20 19:09:14 +00:00
parent 9f17116412
commit d56226aac5
13 changed files with 63 additions and 24 deletions

View File

@ -94,7 +94,7 @@ extern sfx_t *cl_sfx_ric2;
extern sfx_t *cl_sfx_ric3;
extern sfx_t *cl_sfx_r_exp3;
#define ENDLIST
#define ENDLIST //clarifies \ in list macros.
#ifdef NOLEGACY
#define legacycsqcglobals
#else
@ -6887,7 +6887,7 @@ void CSQC_Shutdown(void)
}
//when the qclib needs a file, it calls out to this function.
void *PDECL CSQC_PRLoadFile (const char *path, unsigned char *(PDECL *buf_get)(void *ctx, size_t len), void *buf_ctx, size_t *sz)
void *PDECL CSQC_PRLoadFile (const char *path, unsigned char *(PDECL *buf_get)(void *ctx, size_t len), void *buf_ctx, size_t *sz, pbool issource)
{
extern cvar_t sv_demo_write_csqc;
qbyte *file = NULL;

View File

@ -2485,7 +2485,7 @@ pbool PDECL Menu_CheckHeaderCrc(pubprogfuncs_t *inst, progsnum_t idx, int crc)
return false;
}
static void *PDECL MP_PRReadFile (const char *path, qbyte *(PDECL *buf_get)(void *buf_ctx, size_t size), void *buf_ctx, size_t *size)
static void *PDECL MP_PRReadFile (const char *path, qbyte *(PDECL *buf_get)(void *buf_ctx, size_t size), void *buf_ctx, size_t *size, pbool issource)
{
flocation_t loc;
if (FS_FLocateFile(path, FSLF_IFFOUND|FSLF_SECUREONLY, &loc))

View File

@ -15,7 +15,7 @@
static char *cvargroup_progs = "Progs variables";
cvar_t sv_gameplayfix_nolinknonsolid = CVARD("sv_gameplayfix_nolinknonsolid", "1", "When 0, setorigin et al will not link the entity into the collision nodes (which is faster, especially if you have a lot of non-solid entities. When 1, allows entities to freely switch between .solid values (except for SOLID_BSP) without relinking. A lot of DP mods assume a value of 1 and will bug out otherwise, while 0 will restore a bugs present in various mods.");
cvar_t sv_gameplayfix_blowupfallenzombies = CVARD("sv_gameplayfix_blowupfallenzombies", "0", "Allow findradius to find non-solid entities. This may break certain mods.");
cvar_t sv_gameplayfix_blowupfallenzombies = CVARD("sv_gameplayfix_blowupfallenzombies", "0", "Allow findradius to find non-solid entities. This may break certain mods. It is better for mods to use FL_FINDABLE_NONSOLID instead.");
cvar_t dpcompat_findradiusarealinks = CVARD("dpcompat_findradiusarealinks", "0", "Use the world collision info to accelerate findradius instead of looping through every single entity. May actually be slower for large radiuses, or fail to find entities which have not been linked properly with setorigin.");
#ifndef NOLEGACY
cvar_t dpcompat_strcat_limit = CVARD("dpcompat_strcat_limit", "", "When set, cripples strcat (and related function) string lengths to the value specified.\nSet to 16383 to replicate DP's limit, otherwise leave as 0 to avoid limits.");

View File

@ -10,7 +10,7 @@ int QCC_RawFileSize (const char *fname);
pbool QCC_WriteFile (const char *name, void *data, int len);
void GUI_DialogPrint(char *title, char *text);
void *GUIReadFile(const char *fname, unsigned char *(*buf_get)(void *ctx, size_t len), void *buf_ctx, size_t *out_size);
void *GUIReadFile(const char *fname, unsigned char *(*buf_get)(void *ctx, size_t len), void *buf_ctx, size_t *out_size, pbool issourcefile);
int GUIFileSize(const char *fname);
int GUI_ParseCommandLine(char *args, pbool keepsrcanddir); //0=gui, 1=commandline

View File

@ -1625,7 +1625,7 @@ void Packager_ParseText(struct pkgctx_s *ctx, char *scripttext)
void Packager_ParseFile(struct pkgctx_s *ctx, char *scriptname)
{
size_t remaining = 0;
char *file = qccprogfuncs->funcs.parms->ReadFile(scriptname, NULL, NULL, &remaining);
char *file = qccprogfuncs->funcs.parms->ReadFile(scriptname, NULL, NULL, &remaining, true);
strcpy(ctx->gamepath, scriptname);
strcpy(ctx->sourcepath, scriptname);
Packager_ParseText(ctx, file);

View File

@ -2564,7 +2564,7 @@ int PR_ReallyLoadProgs (progfuncs_t *progfuncs, const char *filename, progstate_
retry:
hmark = PRHunkMark(progfuncs);
pr_progs = externs->ReadFile(filename, PR_GetHeapBuffer, progfuncs, &fsz);
pr_progs = externs->ReadFile(filename, PR_GetHeapBuffer, progfuncs, &fsz, false);
if (!pr_progs)
{
if (externs->autocompile == PR_COMPILENEXIST || externs->autocompile == PR_COMPILECHANGED) //compile if file is not found (if 2, we have already tried, so don't bother)
@ -2574,7 +2574,7 @@ retry:
printf("couldn't open progs %s. Attempting to compile.\n", filename);
CompileFile(progfuncs, filename);
}
pr_progs = externs->ReadFile(filename, PR_GetHeapBuffer, progfuncs, &fsz);
pr_progs = externs->ReadFile(filename, PR_GetHeapBuffer, progfuncs, &fsz, false);
if (!pr_progs)
{
printf("Couldn't find or compile file %s\n", filename);
@ -2824,7 +2824,7 @@ retry:
strcpy(lnoname, filename);
StripExtension(lnoname);
strcat(lnoname, ".lno");
file = externs->ReadFile(lnoname, PR_GetHeapBuffer, progfuncs, &fsz);
file = externs->ReadFile(lnoname, PR_GetHeapBuffer, progfuncs, &fsz, false);
if (file)
{
if ( file[0] != lnotype

View File

@ -202,7 +202,7 @@ struct pubprogfuncs_s
typedef struct progexterns_s {
int progsversion; //PROGSTRUCT_VERSION
void *(PDECL *ReadFile) (const char *fname, unsigned char *(PDECL *buf_get)(void *ctx, size_t len), void *buf_ctx, size_t *out_size);
void *(PDECL *ReadFile) (const char *fname, unsigned char *(PDECL *buf_get)(void *ctx, size_t len), void *buf_ctx, size_t *out_size, pbool issourcefile);
int (PDECL *FileSize) (const char *fname); //-1 if file does not exist
pbool (PDECL *WriteFile) (const char *name, void *data, int len);
int (VARGS *Printf) (const char *, ...) LIKEPRINTF(1);

View File

@ -592,7 +592,7 @@ Returns the argument number (1 to argc-1) or 0 if not present
*/
int QCC_CheckParm (char *check)
{
int i;
int i;
for (i = 1;i<myargc;i++)
{
@ -603,6 +603,19 @@ int QCC_CheckParm (char *check)
return 0;
}
const char *QCC_ReadParm (char *check)
{
int i;
for (i = 1;i+1<myargc;i++)
{
if ( !QC_strcasecmp(check, myargv[i]) )
return myargv[i+1];
}
return 0;
}
/*
@ -1224,7 +1237,7 @@ long QCC_LoadFile (char *filename, void **bufferptr)
int orig;
pbool warned = false;
mem = externs->ReadFile(filename, QCC_LoadFileHunk, NULL, &len);
mem = externs->ReadFile(filename, QCC_LoadFileHunk, NULL, &len, true);
if (!mem)
{
QCC_Error(ERR_COULDNTOPENFILE, "Couldn't open file %s", filename);
@ -1274,7 +1287,7 @@ void QCC_AddFile (char *filename)
char *mem;
size_t len;
mem = externs->ReadFile(filename, QCC_LoadFileHunk, NULL, &len);
mem = externs->ReadFile(filename, QCC_LoadFileHunk, NULL, &len, false);
if (!mem)
externs->Abort("failed to find file %s", filename);
sfile = (qcc_cachedsourcefile_t*)(mem-sizeof(qcc_cachedsourcefile_t));
@ -1299,7 +1312,7 @@ static unsigned char *PDECL FS_ReadToMem_Alloc(void *ctx, size_t size)
void *FS_ReadToMem(char *filename, size_t *len)
{
progfuncs_t *progfuncs = qccprogfuncs;
return externs->ReadFile(filename, FS_ReadToMem_Alloc, NULL, len);
return externs->ReadFile(filename, FS_ReadToMem_Alloc, NULL, len, false);
}
void FS_CloseFromMem(void *mem)

View File

@ -12132,7 +12132,7 @@ QCC_function_t *QCC_PR_GenerateBuiltinFunction (QCC_def_t *def, int builtinnum,
{
QCC_function_t *func;
if (numfunctions >= MAX_FUNCTIONS)
QCC_PR_ParseError(ERR_INTERNAL, "Too many functions - %i\nAdd \"MAX_FUNCTIONS\" \"%i\" to qcc.cfg", numfunctions, (numfunctions+4096)&~4095);
QCC_PR_ParseError(ERR_INTERNAL, "Too many functions - %i\nAdd '-max_functions %i' to the commandline", numfunctions, (numfunctions+4096)&~4095);
func = &functions[numfunctions++];
func->filen = s_filen;
func->s_filed = s_filed;
@ -12155,7 +12155,7 @@ static QCC_function_t *QCC_PR_GenerateQCFunction (QCC_def_t *def, QCC_type_t *ty
{
QCC_function_t *func = NULL;
if (numfunctions >= MAX_FUNCTIONS)
QCC_PR_ParseError(ERR_INTERNAL, "Too many functions - %i\nAdd \"MAX_FUNCTIONS\" \"%i\" to qcc.cfg", numfunctions, (numfunctions+4096)&~4095);
QCC_PR_ParseError(ERR_INTERNAL, "Too many functions - %i\nAdd '-max_functions %i' to the commandline", numfunctions, (numfunctions+4096)&~4095);
if (!pif_flags)
;
@ -15344,6 +15344,7 @@ void QCC_Cleanup(void)
pr_cases = NULL;
pr_casesref = NULL;
pr_casesref2 = NULL;
*compilingrootfile = 0;
#ifdef _DEBUG
OpAssignsTo_Debug();

View File

@ -3350,7 +3350,7 @@ static unsigned char *buf_get_malloc(void *ctx, size_t len)
{
return malloc(len);
}
void *GUIReadFile(const char *fname, unsigned char *(*buf_get)(void *ctx, size_t len), void *buf_ctx, size_t *out_size)
void *GUIReadFile(const char *fname, unsigned char *(*buf_get)(void *ctx, size_t len), void *buf_ctx, size_t *out_size, pbool issourcefile)
{
editor_t *e;
size_t blen;
@ -3410,6 +3410,9 @@ void *GUIReadFile(const char *fname, unsigned char *(*buf_get)(void *ctx, size_t
}
}
if (issourcefile)
AddSourceFile(compilingrootfile, fname);
return QCC_ReadFile(fname, buf_get, buf_ctx, out_size);
}

View File

@ -32,7 +32,7 @@ int Grep(char *filename, char *string)
if (!filename)
return foundcount;
raw = GUIReadFile(filename, NULL, NULL, &sz);
raw = GUIReadFile(filename, NULL, NULL, &sz, false);
if (!raw)
return foundcount;
if (raw[sz] != 0)

View File

@ -431,6 +431,7 @@ Runs qbsp and light on all of the models with a .bsp extension
=================
*/
int QCC_CheckParm (char *check);
const char *QCC_ReadParm (char *check);
void QCC_BspModels (void)
{
@ -1364,10 +1365,10 @@ pbool QCC_WriteData (int crc)
progs.blockscompressed=0;
if (numstatements > MAX_STATEMENTS)
QCC_Error(ERR_TOOMANYSTATEMENTS, "Too many statements - %i\nAdd \"MAX_STATEMENTS\" \"%i\" to qcc.cfg", numstatements, (numstatements+32768)&~32767);
QCC_Error(ERR_TOOMANYSTATEMENTS, "Too many statements - %i\nAdd '-max_statements %i' to the commandline", numstatements, (numstatements+32768)&~32767);
if (strofs > MAX_STRINGS)
QCC_Error(ERR_TOOMANYSTRINGS, "Too many strings - %i\nAdd \"MAX_STRINGS\" \"%i\" to qcc.cfg", strofs, (strofs+32768)&~32767);
QCC_Error(ERR_TOOMANYSTRINGS, "Too many strings - %i\nAdd '-max_strings %i' to the commandline", strofs, (strofs+32768)&~32767);
//part of how compilation works. This def is always present, and never used.
def = QCC_PR_GetDef(NULL, "end_sys_globals", NULL, false, 0, false);
@ -1909,7 +1910,7 @@ pbool QCC_WriteData (int crc)
}
if (numglobaldefs > MAX_GLOBALS)
QCC_Error(ERR_TOOMANYGLOBALS, "Too many globals - %i\nAdd \"MAX_GLOBALS\" \"%i\" to qcc.cfg", numglobaldefs, (numglobaldefs+32768)&~32767);
QCC_Error(ERR_TOOMANYGLOBALS, "Too many globals - %i\nAdd '-max_globals %i' to the commandline", numglobaldefs, (numglobaldefs+32768)&~32767);
dupewarncount = 0;
@ -2781,7 +2782,7 @@ void QCC_ImportProgs(const char *filename)
//FIXME: find temps. strip them. you get the idea.
//FIXME: find immediates. set up hash tables for them for reuse. HAH!
prog = externs->ReadFile(filename, QCC_LoadFileHunkAlloc, NULL, &flen);
prog = externs->ReadFile(filename, QCC_LoadFileHunkAlloc, NULL, &flen, false);
if (!prog)
{
QCC_Error(ERR_COULDNTOPENFILE, "Couldn't open file %s", filename);
@ -4615,6 +4616,7 @@ pbool QCC_main (int argc, char **argv) //as part of the quake engine
size_t p;
extern int qccpersisthunk;
const char *arg;
char *s;
@ -4667,7 +4669,27 @@ pbool QCC_main (int argc, char **argv) //as part of the quake engine
strcpy(destfile, "");
compressoutput = 0;
s = externs->ReadFile("qcc.cfg", QCC_LoadFileHunkAlloc, NULL, &p);
if ((arg = QCC_ReadParm("-max_regs")))
MAX_REGS = max(100, atoi(arg));
if ((arg = QCC_ReadParm("-max_strings")))
MAX_STRINGS = max(100, atoi(arg));
if ((arg = QCC_ReadParm("-max_globals")))
MAX_GLOBALS = max(64, atoi(arg));
if ((arg = QCC_ReadParm("-max_fields")))
MAX_FIELDS = max(0, atoi(arg));
if ((arg = QCC_ReadParm("-max_statements")))
MAX_STATEMENTS = max(1, atoi(arg));
if ((arg = QCC_ReadParm("-max_functions")))
MAX_FUNCTIONS = max(1, atoi(arg));
if ((arg = QCC_ReadParm("-max_types")))
maxtypeinfos = max(100, atoi(arg));
if ((arg = QCC_ReadParm("-max_temps")))
max_temps = max(100, atoi(arg));
if ((arg = QCC_ReadParm("-max_macros")))
MAX_CONSTANTS = max(100, atoi(arg));
//FIXME: strip this.
s = externs->ReadFile("qcc.cfg", QCC_LoadFileHunkAlloc, NULL, &p, false);
if (s)
{
while(1)

View File

@ -622,7 +622,7 @@ pbool PDECL PR_SSQC_CheckHeaderCrc(pubprogfuncs_t *inst, progsnum_t idx, int crc
return false;
return true;
}
static void *PDECL SSQC_PRReadFile (const char *path, qbyte *(PDECL *buf_get)(void *buf_ctx, size_t size), void *buf_ctx, size_t *size)
static void *PDECL SSQC_PRReadFile (const char *path, qbyte *(PDECL *buf_get)(void *buf_ctx, size_t size), void *buf_ctx, size_t *size, pbool issource)
{
flocation_t loc;
if (FS_FLocateFile(path, FSLF_IFFOUND, &loc))