From 025f95238eaf555edb4de9ebb69068dfc5ad73bf Mon Sep 17 00:00:00 2001 From: Spoike Date: Sun, 18 May 2014 23:02:04 +0000 Subject: [PATCH] try to compensate for id's bugs/warnings, for ease of use. fix a couple of bugs/spam. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4662 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/image.c | 13 +++- engine/client/pr_menu.c | 27 ++++---- engine/common/net_wins.c | 3 + engine/common/pr_bgcmd.c | 16 ++++- .../droid/src/com/fteqw/FTEDroidActivity.java | 4 +- engine/gl/gl_alias.c | 6 +- engine/qclib/execloop.h | 6 ++ engine/qclib/qcc_pr_comp.c | 68 +++++++++++++++---- engine/qclib/qcc_pr_lex.c | 4 +- engine/qclib/qccmain.c | 17 +++-- 10 files changed, 121 insertions(+), 43 deletions(-) diff --git a/engine/client/image.c b/engine/client/image.c index cc8c05ba4..0ff27ca85 100644 --- a/engine/client/image.c +++ b/engine/client/image.c @@ -2500,8 +2500,17 @@ texid_tf GL_ReadBLPFile(const char *iname, unsigned char *buffer, int filesize, case 1: //BGRX palette, 8bit //1bit trailing alpha - for (i = 0; i < w*h; i++) - tmpmem[i] = (tmpmem[i] & 0xffffff) | (*in++?0xff000000:0); + for (i = 0; i < w*h; i+=8, in++) + { + tmpmem[i+0] = (tmpmem[i+0] & 0xffffff) | ((*in&0x01)?0xff000000:0); + tmpmem[i+1] = (tmpmem[i+1] & 0xffffff) | ((*in&0x02)?0xff000000:0); + tmpmem[i+2] = (tmpmem[i+2] & 0xffffff) | ((*in&0x04)?0xff000000:0); + tmpmem[i+3] = (tmpmem[i+3] & 0xffffff) | ((*in&0x08)?0xff000000:0); + tmpmem[i+4] = (tmpmem[i+4] & 0xffffff) | ((*in&0x10)?0xff000000:0); + tmpmem[i+5] = (tmpmem[i+5] & 0xffffff) | ((*in&0x20)?0xff000000:0); + tmpmem[i+6] = (tmpmem[i+6] & 0xffffff) | ((*in&0x40)?0xff000000:0); + tmpmem[i+7] = (tmpmem[i+7] & 0xffffff) | ((*in&0x80)?0xff000000:0); + } break; case 4: //BGRX palette, 8bit diff --git a/engine/client/pr_menu.c b/engine/client/pr_menu.c index 99a04a9e5..075a8a524 100644 --- a/engine/client/pr_menu.c +++ b/engine/client/pr_menu.c @@ -1814,8 +1814,6 @@ func_t mp_keydown_function; func_t mp_keyup_function; func_t mp_toggle_function; -float *mp_time; - jmp_buf mp_abort; @@ -1909,7 +1907,10 @@ qboolean MP_Init (void) } if (forceqmenu.value) + { + Con_DPrintf("menu.dat disabled\n"); return false; + } MP_SetupBuiltins(); @@ -1982,9 +1983,9 @@ qboolean MP_Init (void) PF_InitTempStrings(menu_world.progs); - mp_time = (float*)PR_FindGlobal(menu_world.progs, "time", 0, NULL); - if (mp_time) - *mp_time = Sys_DoubleTime(); + menu_world.g.time = (float*)PR_FindGlobal(menu_world.progs, "time", 0, NULL); + if (menu_world.g.time) + *menu_world.g.time = Sys_DoubleTime(); menu_world.g.drawfont = (float*)PR_FindGlobal(menu_world.progs, "drawfont", 0, NULL); menu_world.g.drawfontscale = (float*)PR_FindGlobal(menu_world.progs, "drawfontscale", 0, NULL); @@ -2120,8 +2121,8 @@ void MP_Draw(void) return; menutime = Sys_DoubleTime(); - if (mp_time) - *mp_time = menutime; + if (menu_world.g.time) + *menu_world.g.time = menutime; inmenuprogs++; if (mp_draw_function) @@ -2160,8 +2161,8 @@ void MP_Keydown(int key, int unicode) } menutime = Sys_DoubleTime(); - if (mp_time) - *mp_time = menutime; + if (menu_world.g.time) + *menu_world.g.time = menutime; inmenuprogs++; if (mp_keydown_function) @@ -2185,8 +2186,8 @@ void MP_Keyup(int key, int unicode) return; menutime = Sys_DoubleTime(); - if (mp_time) - *mp_time = menutime; + if (menu_world.g.time) + *menu_world.g.time = menutime; inmenuprogs++; if (mp_keyup_function) @@ -2212,8 +2213,8 @@ qboolean MP_Toggle(void) return false; menutime = Sys_DoubleTime(); - if (mp_time) - *mp_time = menutime; + if (menu_world.g.time) + *menu_world.g.time = menutime; inmenuprogs++; if (mp_toggle_function) diff --git a/engine/common/net_wins.c b/engine/common/net_wins.c index b363f15ac..ca0eb9fc1 100644 --- a/engine/common/net_wins.c +++ b/engine/common/net_wins.c @@ -1598,6 +1598,9 @@ void NET_SendLoopPacket (int sock, int length, const void *data, netadr_t *to) sock &= 1; loop = &loopbacks[sock^1]; + if (!loop->inited) + return; + i = loop->send & (MAX_LOOPBACK-1); if (length > loop->msgs[i].datamax) { diff --git a/engine/common/pr_bgcmd.c b/engine/common/pr_bgcmd.c index ffeb9c2f5..85deb4965 100644 --- a/engine/common/pr_bgcmd.c +++ b/engine/common/pr_bgcmd.c @@ -1616,12 +1616,26 @@ void QCBUILTIN PF_fputs (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals void PF_fcloseall (pubprogfuncs_t *prinst) { + qboolean write; int i; for (i = 0; i < MAX_QC_FILES; i++) { if (pf_fopen_files[i].prinst != prinst) continue; - Con_Printf("qc file %s was still open\n", pf_fopen_files[i].name); + + switch(pf_fopen_files[i].accessmode) + { + case FRIK_FILE_APPEND: + case FRIK_FILE_WRITE: + case FRIK_FILE_MMAP_RW: + write = true; + break; + default: + write = false; + break; + } + if (developer.ival || write) + Con_Printf("qc file %s was still open\n", pf_fopen_files[i].name); PF_fclose_i(i); } tokenizeqc("", false); diff --git a/engine/droid/src/com/fteqw/FTEDroidActivity.java b/engine/droid/src/com/fteqw/FTEDroidActivity.java index 893e83571..d3c2d5cab 100644 --- a/engine/droid/src/com/fteqw/FTEDroidActivity.java +++ b/engine/droid/src/com/fteqw/FTEDroidActivity.java @@ -35,8 +35,6 @@ import android.os.Vibrator; public class FTEDroidActivity extends Activity { - private static final int USE_GLES_VERSION = 1; //valid values: 1 or 2. If set to 2, it'll still fall back to 1 if gles2 isn't supported on this device. - private SensorManager sensorman; private Sensor sensoracc; private FTEView view; @@ -268,7 +266,7 @@ public class FTEDroidActivity extends Activity public void run() { theview.setVisibility(theview.GONE); - AlertDialog ad = new AlertDialog.Builder(act).create(); + AlertDialog ad = new AlertDialog.Builder(act); ad.setTitle("FTE ERROR"); ad.setMessage(errormsg); ad.setCancelable(false); diff --git a/engine/gl/gl_alias.c b/engine/gl/gl_alias.c index fa67ac674..063a22a41 100644 --- a/engine/gl/gl_alias.c +++ b/engine/gl/gl_alias.c @@ -65,8 +65,12 @@ static skinfile_t **registeredskins; static skinid_t numregisteredskins; void Mod_WipeSkin(skinid_t id) { - skinfile_t *sk = registeredskins[id-1]; + skinfile_t *sk; int i; + id--; + if (id >= numregisteredskins) + return; //invalid! + sk = registeredskins[id]; if (!sk) return; diff --git a/engine/qclib/execloop.h b/engine/qclib/execloop.h index 071ff9b05..2ea9b9340 100644 --- a/engine/qclib/execloop.h +++ b/engine/qclib/execloop.h @@ -889,7 +889,10 @@ reeval: if ((unsigned int)i > prinst.addressableused-sizeof(int)) { if (i == -1) + { + OPC->_int = 0; break; + } pr_xstatement = st-pr_statements; PR_RunError (&progfuncs->funcs, "bad pointer read in %s", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name)); } @@ -902,7 +905,10 @@ reeval: if ((unsigned int)i > prinst.addressableused-sizeof(vec3_t)) { if (i == -1) + { + OPC->_int = 0; break; + } pr_xstatement = st-pr_statements; PR_RunError (&progfuncs->funcs, "bad pointer read in %s", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name)); } diff --git a/engine/qclib/qcc_pr_comp.c b/engine/qclib/qcc_pr_comp.c index 727f3af01..a33acb584 100644 --- a/engine/qclib/qcc_pr_comp.c +++ b/engine/qclib/qcc_pr_comp.c @@ -4523,8 +4523,29 @@ QCC_def_t *QCC_PR_ParseFunctionCall (QCC_ref_t *funcref) //warning, the func cou np--; if (arg < np) { - QCC_PR_ParseWarning (WARN_TOOFEWPARAMS, "too few parameters on call to %s", func->name); - QCC_PR_ParsePrintDef (WARN_TOOFEWPARAMS, func); + if (arg+1==np && !strcmp(func->name, "makestatic")) + { + //vanilla QC sucks. I want fteextensions.qc to compile with vanilla, yet also result in errors for when the mod fucks up. + QCC_PR_ParseWarning (WARN_BADPARAMS, "too few parameters on call to %s. Passing 'self'.", func->name); + QCC_PR_ParsePrintDef (WARN_BADPARAMS, func); + + param[arg] = QCC_PR_GetDef(NULL, "self", NULL, 0, 0, false); + paramtypes[arg] = param[arg]->type; + } + else if (arg+1==np && !strcmp(func->name, "ai_charge")) + { + //vanilla QC sucks. I want fteextensions.qc to compile with vanilla, yet also result in errors for when the mod fucks up. + QCC_PR_ParseWarning (WARN_BADPARAMS, "too few parameters on call to %s. Passing 0.", func->name); + QCC_PR_ParsePrintDef (WARN_BADPARAMS, func); + + param[arg] = QCC_MakeFloatConst(0); + paramtypes[arg] = param[arg]->type; + } + else + { + QCC_PR_ParseWarning (WARN_TOOFEWPARAMS, "too few parameters on call to %s", func->name); + QCC_PR_ParsePrintDef (WARN_TOOFEWPARAMS, func); + } } return QCC_PR_GenerateFunctionCall(newself, func, param, paramtypes, arg); @@ -6371,7 +6392,7 @@ QCC_def_t *QCC_LoadFromArray(QCC_def_t *base, QCC_def_t *index, QCC_type_t *t, p //reads a ref as required QCC_def_t *QCC_RefToDef(QCC_ref_t *ref, pbool freetemps) { - QCC_def_t *tmp = NULL; + QCC_def_t *tmp = NULL, *idx; QCC_def_t *ret = ref->base; if (ref->postinc) { @@ -6448,7 +6469,11 @@ QCC_def_t *QCC_RefToDef(QCC_ref_t *ref, pbool freetemps) break; case REF_POINTER: tmp = QCC_GetTemp(ref->cast); - QCC_LoadFromPointer(tmp->ofs, ref->base->ofs, ref->index?ref->index->ofs:0, ref->cast); + if (ref->index) + idx = QCC_SupplyConversion(ref->index, ev_integer, true); + else + idx = NULL; + QCC_LoadFromPointer(tmp->ofs, ref->base->ofs, idx?idx->ofs:0, ref->cast); if (freetemps) QCC_PR_DiscardRef(ref); return tmp; @@ -10088,20 +10113,35 @@ QCC_def_t *QCC_PR_GetDef (QCC_type_t *type, char *name, QCC_def_t *scope, pbool { if (pr_scope || typecmp_lax(def->type, type)) { - //unequal even when we're lax - QCC_PR_ParseErrorPrintDef (ERR_TYPEMISMATCHREDEC, def, "Type mismatch on redeclaration of %s. %s, should be %s",name, TypeName(type, typebuf1, sizeof(typebuf1)), TypeName(def->type, typebuf2, sizeof(typebuf2))); + if (!strcmp("droptofloor", def->name)) + { + //this is a hack. droptofloor was wrongly declared in vanilla qc, which causes problems with replacement extensions.qc. + //yes, this is a selfish lazy hack for this, there's probably a better way, but at least we spit out a warning still. + QCC_PR_ParseWarning (WARN_LAXCAST, "%s builtin was wrongly defined as %s. ignoring invalid dupe definition",name, TypeName(type, typebuf1, sizeof(typebuf1))); + QCC_PR_ParsePrintDef(WARN_DUPLICATEDEFINITION, def); + } + else + { + //unequal even when we're lax + QCC_PR_ParseErrorPrintDef (ERR_TYPEMISMATCHREDEC, def, "Type mismatch on redeclaration of %s. %s, should be %s",name, TypeName(type, typebuf1, sizeof(typebuf1)), TypeName(def->type, typebuf2, sizeof(typebuf2))); + } } else { - QCC_PR_ParseWarning (WARN_LAXCAST, "Optional arguments differ on redeclaration of %s. %s, should be %s",name, TypeName(type, typebuf1, sizeof(typebuf1)), TypeName(def->type, typebuf2, sizeof(typebuf2))); - QCC_PR_ParsePrintDef(WARN_DUPLICATEDEFINITION, def); - - if (type->type == ev_function) + if (type->type != ev_function || type->num_parms != def->type->num_parms || !(def->type->vargs && !type->vargs)) { - //update the def's type to the new one if the mandatory argument count is longer - //FIXME: don't change the param names! - if (type->num_parms > def->type->num_parms) - def->type = type; + //if the second def simply has no ..., don't bother warning about it. + + QCC_PR_ParseWarning (WARN_LAXCAST, "Optional arguments differ on redeclaration of %s. %s, should be %s",name, TypeName(type, typebuf1, sizeof(typebuf1)), TypeName(def->type, typebuf2, sizeof(typebuf2))); + QCC_PR_ParsePrintDef(WARN_DUPLICATEDEFINITION, def); + + if (type->type == ev_function) + { + //update the def's type to the new one if the mandatory argument count is longer + //FIXME: don't change the param names! + if (type->num_parms > def->type->num_parms) + def->type = type; + } } } } diff --git a/engine/qclib/qcc_pr_lex.c b/engine/qclib/qcc_pr_lex.c index 9875da25c..fb3fe7b6f 100644 --- a/engine/qclib/qcc_pr_lex.c +++ b/engine/qclib/qcc_pr_lex.c @@ -3673,7 +3673,7 @@ int typecmp_lax(QCC_type_t *a, QCC_type_t *b) } if (a->num_parms > minargs) { - for (t = 0; t < a->num_parms; t++) + for (t = minargs; t < a->num_parms; t++) { if (!a->params[t].optional) return 1; @@ -3681,7 +3681,7 @@ int typecmp_lax(QCC_type_t *a, QCC_type_t *b) } if (b->num_parms > minargs) { - for (t = 0; t < b->num_parms; t++) + for (t = minargs; t < b->num_parms; t++) { if (!b->params[t].optional) return 1; diff --git a/engine/qclib/qccmain.c b/engine/qclib/qccmain.c index e6b0ab445..662014e06 100644 --- a/engine/qclib/qccmain.c +++ b/engine/qclib/qccmain.c @@ -682,7 +682,7 @@ pbool QCC_WriteData (int crc) pbool debugtarget = false; pbool types = false; int outputsttype = PST_DEFAULT; - pbool warnedunref = false; + int warnedunref = 0; int *statement_linenums; if (numstatements==1 && numfunctions==1 && numglobaldefs==1 && numfielddefs==1) @@ -857,13 +857,16 @@ pbool QCC_WriteData (int crc) if (strcmp(def->name, "IMMEDIATE")) { char typestr[256]; - if (QCC_PR_Warning(wt, strings + def->s_file, def->s_line, "%s %s no references.", TypeName(def->type, typestr, sizeof(typestr)), def->name)) + if (warnedunref >= 10) { - if (!warnedunref && wt == WARN_NOTREFERENCED) - { - QCC_PR_Note(WARN_NOTREFERENCED, NULL, 0, "You can use the noref prefix or pragma to silence this message."); - warnedunref = true; - } + if (qccwarningaction[wt]) + pr_warning_count++; + } + else if (QCC_PR_Warning(wt, strings + def->s_file, def->s_line, "%s %s no references.", TypeName(def->type, typestr, sizeof(typestr)), def->name)) + { + warnedunref++; + if (warnedunref == 10) + QCC_PR_Note(wt, NULL, 0, "Not reporting other unreferenced variables. You can use the noref prefix or pragma to silence these messages as you clearly don't care."); } } pr_scope = NULL;