1
0
Fork 0
forked from fte/fteqw

Removed the prints, added a -Wno-mundane, and readded some ifstring stuff that black took out a while ago. grr. if he carelessly breaks anything like that again.... grr.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1384 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2005-09-28 16:57:10 +00:00
parent ad96c59e77
commit 184ca975fc
5 changed files with 65 additions and 172 deletions

View file

@ -276,7 +276,7 @@ int QC_RegisterFieldVar(progfuncs_t *progfuncs, unsigned int type, char *name, i
{ //the engine is setting up a list of required field indexes.
//paranoid checking of the offset.
for (i = 0; i < numfields-1; i++)
/* for (i = 0; i < numfields-1; i++)
{
if (field[i].ofs == ((unsigned)engineofs)/4)
{
@ -288,7 +288,7 @@ int QC_RegisterFieldVar(progfuncs_t *progfuncs, unsigned int type, char *name, i
else
Sys_Error("Duplicated offset");
}
}
}*/
if (engineofs&3)
Sys_Error("field %s is %i&3", name, engineofs);
field[fnum].ofs = ofs = engineofs/4;
@ -357,10 +357,10 @@ void QC_AddSharedFieldVar(progfuncs_t *progfuncs, int num, char *stringtable)
{
if (!strcmp(pr_fielddefs16[i].s_name+stringtable, pr_globaldefs16[num].s_name+stringtable))
{
int old = *(int *)&pr_globals[pr_globaldefs16[num].ofs];
// int old = *(int *)&pr_globals[pr_globaldefs16[num].ofs];
*(int *)&pr_globals[pr_globaldefs16[num].ofs] = QC_RegisterFieldVar(progfuncs, pr_fielddefs16[i].type, pr_globaldefs16[num].s_name+stringtable, -1, *(int *)&pr_globals[pr_globaldefs16[num].ofs]);
printf("Field %s %i -> %i\n", pr_globaldefs16[num].s_name+stringtable, old, *(int *)&pr_globals[pr_globaldefs16[num].ofs]);
// printf("Field %s %i -> %i\n", pr_globaldefs16[num].s_name+stringtable, old, *(int *)&pr_globals[pr_globaldefs16[num].ofs]);
return;
}
}
@ -372,9 +372,9 @@ void QC_AddSharedFieldVar(progfuncs_t *progfuncs, int num, char *stringtable)
o = field[i].progsofs;
if (o == *(unsigned int *)&pr_globals[pr_globaldefs16[num].ofs])
{
int old = *(int *)&pr_globals[pr_globaldefs16[num].ofs];
// int old = *(int *)&pr_globals[pr_globaldefs16[num].ofs];
*(int *)&pr_globals[pr_globaldefs16[num].ofs] = field[i].ofs-progfuncs->fieldadjust;
printf("Field %s %i -> %i\n", pr_globaldefs16[num].s_name+stringtable, old, *(int *)&pr_globals[pr_globaldefs16[num].ofs]);
// printf("Field %s %i -> %i\n", pr_globaldefs16[num].s_name+stringtable, old, *(int *)&pr_globals[pr_globaldefs16[num].ofs]);
return;
}
}
@ -416,150 +416,3 @@ void QC_AddSharedFieldVar(progfuncs_t *progfuncs, int num, char *stringtable)
Sys_Error("Should be unreachable");
}
/*
//Just a bit of code that makes a window appear with lots of variables listed.
//A little useless really.
static void WatchDraw(window_t *wnd);
static void WatchDead(window_t *wnd);
static bool WatchKeyDown(window_t *wnd, int k);
typedef struct {
int progs;
int globofs;
} watchinfo_t;
static window_t watchtemplate = {
sizeof(window_t), //int size; //for possible later expansion
"Watch", //char *title;
BORDER_RESIZE, //void (*DrawBorder) (struct window_s *wnd); //the border drawing func (use a borde type)
WatchDraw, //void (*DrawWindow) (struct window_s *); //the drawing func
NULL, //void (*Draw3dWindow) (struct window_s *); //the function to draw 3d stuff
WatchDead, //void (*CloseWindow) (struct window_s *); //when it is closed
WatchKeyDown, //bool (*KeyDown) (struct window_s *, int key); //return true to stop the main game from recieving the call
NULL, //void (*KeyUp) (struct window_s *, int key); //sent to all
NULL, //void (*Think) (struct window_s *);
NULL, //void (*ReloadTex) (struct window_s *);
{320, 0, 640, 240},//float viewarea[4]; //l, t, r, b
{1, 10, 1, 1},//float bordersize[4]; //l,t,r,b
{0, 0, 0},//float vieworigin[3]; //3d view origin
{0, 0, 0},//float viewangles[3]; //3d angles
TRUE,//bool clear; //should it be cleared first (for 3d rendering and default border routine)
NULL,//void *data; //use this to get unique windows of the same type
0,//int classid; //a randomly chosen number that is the same for each of this window's type
0,//int subclass; //a number if an app needs to identify between windows of the same class
NULL//void *(*comunicate) (int type, void *info, void *moreinfo); //later development for chatting between windows (like the 'SendMessage' function in the OS)
//for multiple windows
//struct window_s *next;
//struct window_s *prev;
};
void ShowWatch(void)
{
watchinfo_t *inf;
window_t *wnd;
wnd = memalloc(sizeof(window_t)+sizeof(watchinfo_t), "watch window");
memcpy(wnd, &watchtemplate, sizeof(window_t));
wnd->data = inf = (watchinfo_t *)(wnd+1);
inf->globofs = 1;
inf->progs = 0;
AddWindow(wnd);
}
static void WatchDead(window_t *wnd)
{
RemoveWindow(wnd);
memfree(wnd);
}
static bool WatchKeyDown(window_t *wnd, int k)
{
watchinfo_t *inf = wnd->data;
int progs = inf->progs;
if (progs < 0)
progs = pr_typecurrent;
switch(k)
{
case K_MOUSEWUP:
inf->globofs-=8;
if (inf->globofs < 1)
inf->globofs = 1;
break;
case K_MOUSEWDOWN:
inf->globofs+=8;
if (inf->globofs > pr_progstate[progs].progs->numglobaldefs-1)
inf->globofs = pr_progstate[progs].progs->numglobaldefs-1;
break;
case K_ESCAPE:
RemoveWindow(wnd);
break;
}
return true;
}
char *PR_ValueString (etype_t type, eval_t *val);
static void WatchDraw(window_t *wnd)
{
float yofs;
int def=0;
int progs = ((watchinfo_t *)wnd->data)->progs;
if (progs < 0)
progs = pr_typecurrent;
if (!pr_progstate[progs].progs)
{
Draw_String(wnd->viewarea[0], wnd->viewarea[1]+8+def*8, "Progs not loaded", 1, 0);
return;
}
// if (sv_edicts==NULL)
// return;
yofs=wnd->viewarea[1];
Draw_String(wnd->viewarea[0], yofs, pr_progstate[progs].filename, 1, 0);yofs+=8;
Draw_String(wnd->viewarea[0], yofs, Sva("%3i %16s %s", OFS_RETURN, "RETURN", PR_ValueString(ev_vector, (eval_t *)&pr_progstate[progs].globals[OFS_RETURN])), 1, 0);yofs+=8;
Draw_String(wnd->viewarea[0], yofs, Sva("%3i %16s %s", OFS_PARM0, "PARM0", PR_ValueString(ev_vector, (eval_t *)&pr_progstate[progs].globals[OFS_PARM0])), 1, 0);yofs+=8;
Draw_String(wnd->viewarea[0], yofs, Sva("%3i %16s %s", OFS_PARM1, "PARM1", PR_ValueString(ev_vector, (eval_t *)&pr_progstate[progs].globals[OFS_PARM1])), 1, 0);yofs+=8;
Draw_String(wnd->viewarea[0], yofs, Sva("%3i %16s %s", OFS_PARM2, "PARM2", PR_ValueString(ev_vector, (eval_t *)&pr_progstate[progs].globals[OFS_PARM2])), 1, 0);yofs+=8;
Draw_String(wnd->viewarea[0], yofs, Sva("%3i %16s %s", OFS_PARM3, "PARM3", PR_ValueString(ev_vector, (eval_t *)&pr_progstate[progs].globals[OFS_PARM3])), 1, 0);yofs+=8;
Draw_String(wnd->viewarea[0], yofs, Sva("%3i %16s %s", OFS_PARM4, "PARM4", PR_ValueString(ev_vector, (eval_t *)&pr_progstate[progs].globals[OFS_PARM4])), 1, 0);yofs+=8;
Draw_String(wnd->viewarea[0], yofs, Sva("%3i %16s %s", OFS_PARM5, "PARM5", PR_ValueString(ev_vector, (eval_t *)&pr_progstate[progs].globals[OFS_PARM5])), 1, 0);yofs+=8;
Draw_String(wnd->viewarea[0], yofs, Sva("%3i %16s %s", OFS_PARM6, "PARM6", PR_ValueString(ev_vector, (eval_t *)&pr_progstate[progs].globals[OFS_PARM6])), 1, 0);yofs+=8;
Draw_String(wnd->viewarea[0], yofs, Sva("%3i %16s %s", OFS_PARM7, "PARM7", PR_ValueString(ev_vector, (eval_t *)&pr_progstate[progs].globals[OFS_PARM7])), 1, 0);yofs+=8;
for (def = ((watchinfo_t *)wnd->data)->globofs; def < pr_progstate[progs].progs->numglobaldefs; def++)
{
if ((pr_progstate[progs].globaldefs[def].type &~DEF_SAVEGLOBAL)== ev_entity && sv_edicts==NULL)
{
grColor4f(0.5, 0.5, 0.5, 1);
Draw_String(wnd->viewarea[0], yofs, Sva("%3i %16s %s", pr_progstate[progs].globaldefs[def].ofs, pr_progstate[progs].globaldefs[def].s_name, "Entities not initialized"), 1, 0);
}
else
{
if (pr_progstate[progs].globaldefs[def].type == ev_void || pr_progstate[progs].globaldefs[def].type == ev_field || pr_progstate[progs].globaldefs[def].type == ev_function || !(pr_progstate[progs].globaldefs[def].type & DEF_SAVEGLOBAL))
grColor4f(0.5, 0.5, 0.5, 1);
else
grColor4f(1, 1, 1, 1);
Draw_String(wnd->viewarea[0], yofs, Sva("%3i %16s %s", pr_progstate[progs].globaldefs[def].ofs, pr_progstate[progs].globaldefs[def].s_name, PR_ValueString(pr_progstate[progs].globaldefs[def].type, (eval_t *)&pr_progstate[progs].globals[pr_progstate[progs].globaldefs[def].ofs])), 1, 0);
}
yofs+=8;
}
}
*/

View file

@ -563,11 +563,13 @@ enum {
WARN_TOOMANYPARAMS,
WARN_UNEXPECTEDPUNCT,
WARN_ASSIGNMENTTOCONSTANT,
WARN_ASSIGNMENTTOCONSTANTFUNC,
WARN_MISSINGRETURNVALUE,
WARN_WRONGRETURNTYPE,
WARN_POINTLESSSTATEMENT,
WARN_MISSINGRETURN,
WARN_DUPLICATEDEFINITION,
WARN_UNDEFNOTDEFINED,
WARN_PRECOMPILERMESSAGE,
WARN_TOOMANYPARAMETERSFORFUNC,
WARN_STRINGTOOLONG,
@ -596,11 +598,14 @@ enum {
WARN_NOTSTANDARDBEHAVIOUR,
WARN_INEFFICIENTPLUSPLUS,
WARN_DUPLICATEPRECOMPILER,
WARN_IDENTICALPRECOMPILER,
WARN_FTE_SPECIFIC, //extension that only FTEQCC will have a clue about.
WARN_EXTENSION_USED, //extension that frikqcc also understands
WARN_IFSTRING_USED,
WARN_LAXCAST, //some errors become this with a compiler flag
WARN_UNDESIRABLECONVENTION,
WARN_SAMENAMEASGLOBAL,
WARN_CONSTANTCOMPARISON,
ERR_PARSEERRORS, //caused by qcc_pr_parseerror being called.

View file

@ -1331,15 +1331,15 @@ QCC_def_t *QCC_PR_Statement ( QCC_opcode_t *op, QCC_def_t *var_a, QCC_def_t *var
{
case OP_AND:
if (var_a->ofs == var_b->ofs)
QCC_PR_ParseWarning(0, "Parameter offsets for && are the same");
QCC_PR_ParseWarning(WARN_CONSTANTCOMPARISON, "Parameter offsets for && are the same");
if (var_a->constant || var_b->constant)
QCC_PR_ParseWarning(0, "Result of comparison is constant");
QCC_PR_ParseWarning(WARN_CONSTANTCOMPARISON, "Result of comparison is constant");
break;
case OP_OR:
if (var_a->ofs == var_b->ofs)
QCC_PR_ParseWarning(0, "Parameters for || are the same");
QCC_PR_ParseWarning(WARN_CONSTANTCOMPARISON, "Parameters for || are the same");
if (var_a->constant || var_b->constant)
QCC_PR_ParseWarning(0, "Result of comparison is constant");
QCC_PR_ParseWarning(WARN_CONSTANTCOMPARISON, "Result of comparison is constant");
break;
case OP_EQ_F:
case OP_EQ_S:
@ -1361,16 +1361,16 @@ QCC_def_t *QCC_PR_Statement ( QCC_opcode_t *op, QCC_def_t *var_a, QCC_def_t *var
case OP_LT:
case OP_GT:
if ((var_a->constant && var_b->constant && !var_a->temp && !var_b->temp) || var_a->ofs == var_b->ofs)
QCC_PR_ParseWarning(0, "Result of comparison is constant");
QCC_PR_ParseWarning(WARN_CONSTANTCOMPARISON, "Result of comparison is constant");
break;
case OP_IFS:
case OP_IFNOTS:
case OP_IF:
case OP_IFNOT:
// if (var_a->type->type == ev_function && !var_a->temp)
// QCC_PR_ParseWarning(0, "Result of comparison is constant");
// QCC_PR_ParseWarning(WARN_CONSTANTCOMPARISON, "Result of comparison is constant");
if (var_a->constant && !var_a->temp)
QCC_PR_ParseWarning(0, "Result of comparison is constant");
QCC_PR_ParseWarning(WARN_CONSTANTCOMPARISON, "Result of comparison is constant");
break;
default:
break;
@ -2465,9 +2465,9 @@ QCC_def_t *QCC_PR_ParseFunctionCall (QCC_def_t *func) //warning, the func could
def_ret.type = rettype;
return &def_ret;
}
}
} //so it's not an intrinsic.
if (opt_precache_file)
if (opt_precache_file) //should we strip out all precache_file calls?
{
if (!strncmp(func->name,"precache_file", 13))
{
@ -2505,6 +2505,10 @@ QCC_def_t *QCC_PR_ParseFunctionCall (QCC_def_t *func) //warning, the func could
if (opt_vectorcalls && (t->num_parms == 1 && t->param->type == ev_vector))
{ //if we're using vectorcalls
//if it's a function, takes a vector
//vectorcalls is an evil hack
//it'll make your mod bigger and less efficient.
//however, it'll cut down on numpr_globals, so your mod can become a much greater size.
vec3_t arg;
if (pr_token_type == tt_immediate && pr_immediate_type == type_vector)
{
@ -4359,9 +4363,17 @@ QCC_def_t *QCC_PR_Expression (int priority)
{
qcc_usefulstatement = true;
if (e->constant || e->ofs < OFS_PARM0)
{
if (e->type->type == ev_function)
{
QCC_PR_ParseWarning(WARN_ASSIGNMENTTOCONSTANTFUNC, "Assignment to function %s", e->name);
QCC_PR_ParsePrintDef(WARN_ASSIGNMENTTOCONSTANTFUNC, e);
}
else
{
QCC_PR_ParseWarning(WARN_ASSIGNMENTTOCONSTANT, "Assignment to constant %s", e->name);
QCC_PR_ParsePrintDef(WARN_ASSIGNMENTTOCONSTANT, e);
}
#ifndef QCC
editbadfile(strings+s_file, pr_source_line);
#endif
@ -4652,7 +4664,7 @@ void QCC_PR_ParseStatement (void)
else
patch1 = NULL;
}
else if (!typecmp( e->type, type_string)) //special case, as strings are now pointers, not offsets from string table
else if (!typecmp( e->type, type_string) && flag_ifstring) //special case, as strings are now pointers, not offsets from string table
{
QCC_PR_ParseWarning(0, "while (string) can result in bizzare behaviour");
QCC_FreeTemp(QCC_PR_Statement (&pr_opcodes[OP_IFNOTS], e, 0, &patch1));
@ -4811,7 +4823,7 @@ void QCC_PR_ParseStatement (void)
}
else
{
if (!typecmp( e->type, type_string))
if (!typecmp( e->type, type_string) && flag_ifstring)
{
QCC_PR_ParseWarning(WARN_IFSTRING_USED, "do {} while(string) can result in bizzare behaviour");
QCC_FreeTemp(QCC_PR_Statement (&pr_opcodes[OP_IFS], e, NULL, &patch2));
@ -4907,7 +4919,7 @@ void QCC_PR_ParseStatement (void)
if (negate)
{
if (!typecmp( e->type, type_string)) //special case, as strings are now pointers, not offsets from string table
if (!typecmp( e->type, type_string) && flag_ifstring)
{
QCC_PR_ParseWarning(WARN_IFSTRING_USED, "if not(string) can result in bizzare behaviour");
QCC_FreeTemp(QCC_PR_Statement (&pr_opcodes[OP_IFS], e, 0, &patch1));
@ -4917,7 +4929,7 @@ void QCC_PR_ParseStatement (void)
}
else
{
if (!typecmp( e->type, type_string)) //special case, as strings are now pointers, not offsets from string table
if (!typecmp( e->type, type_string) && flag_ifstring)
{
QCC_PR_ParseWarning(WARN_IFSTRING_USED, "if (string) can result in bizzare behaviour");
QCC_FreeTemp(QCC_PR_Statement (&pr_opcodes[OP_IFNOTS], e, 0, &patch1));
@ -7110,7 +7122,7 @@ QCC_def_t *QCC_PR_GetDef (QCC_type_t *type, char *name, QCC_def_t *scope, pbool
if (scope)
{
if (QCC_PR_GetDef(type, name, NULL, false, arraysize))
QCC_PR_ParseWarning(0, "Local \"%s\" defined with name of a global", name);
QCC_PR_ParseWarning(WARN_SAMENAMEASGLOBAL, "Local \"%s\" defined with name of a global", name);
}
ofs = numpr_globals;

View file

@ -1688,7 +1688,7 @@ pbool QCC_PR_UndefineName(char *name)
c = pHash_Get(&compconstantstable, name);
if (!c)
{
QCC_PR_ParseWarning(WARN_NOTDEFINED, "Precompiler constant %s was not defined", name);
QCC_PR_ParseWarning(WARN_UNDEFNOTDEFINED, "Precompiler constant %s was not defined", name);
return false;
}
@ -1816,6 +1816,7 @@ void QCC_PR_Undefine(void)
void QCC_PR_ConditionCompilation(void)
{
char *oldval;
char *d;
char *s;
int quote=false;
@ -1829,9 +1830,11 @@ void QCC_PR_ConditionCompilation(void)
cnst = pHash_Get(&compconstantstable, pr_token);
if (cnst)
{
oldval = cnst->value;
Hash_Remove(&compconstantstable, pr_token);
QCC_PR_ParseWarning(WARN_DUPLICATEPRECOMPILER, "Duplicate definition of %s", pr_token);
}
else
oldval = NULL;
cnst = QCC_PR_DefineName(pr_token);
@ -1897,6 +1900,11 @@ void QCC_PR_ConditionCompilation(void)
*d-- = '\0';
if (strlen(cnst->value) >= sizeof(cnst->value)) //this is too late.
QCC_PR_ParseError(ERR_CONSTANTTOOLONG, "Macro %s too long (%i not %i)", cnst->name, strlen(cnst->value), sizeof(cnst->value));
if (oldval && strcmp(oldval, cnst->value))
QCC_PR_ParseWarning(WARN_DUPLICATEPRECOMPILER, "Alternate precompiler definition of %s", pr_token);
else
QCC_PR_ParseWarning(WARN_IDENTICALPRECOMPILER, "Identical precompiler definition of %s", pr_token);
}
int QCC_PR_CheakCompConst(void)

View file

@ -2350,6 +2350,21 @@ void QCC_PR_CommandLinePrecompilerOptions (void)
memset(qccwarningdisabled, 0, sizeof(qccwarningdisabled));
else if (!stricmp(myargv[i]+2, "none"))
memset(qccwarningdisabled, 1, sizeof(qccwarningdisabled));
else if (!stricmp(myargv[i]+2, "no-mundane"))
{ //disable mundane performance/efficiency/blah warnings that don't affect code.
qccwarningdisabled[WARN_SAMENAMEASGLOBAL] = true;
qccwarningdisabled[WARN_DUPLICATEDEFINITION] = true;
qccwarningdisabled[WARN_CONSTANTCOMPARISON] = true;
qccwarningdisabled[WARN_ASSIGNMENTINCONDITIONAL] = true;
qccwarningdisabled[WARN_DEADCODE] = true;
qccwarningdisabled[WARN_NOTREFERENCEDCONST] = true;
qccwarningdisabled[WARN_NOTREFERENCED] = true;
qccwarningdisabled[WARN_POINTLESSSTATEMENT] = true;
qccwarningdisabled[WARN_ASSIGNMENTTOCONSTANTFUNC] = true;
qccwarningdisabled[WARN_BADPRAGMA] = true; //C specs say that these should be ignored. We're close enough to C that I consider that a valid statement.
qccwarningdisabled[WARN_IDENTICALPRECOMPILER] = true;
qccwarningdisabled[WARN_UNDEFNOTDEFINED] = true;
}
else
{
p = 0;