From ca31acefea38b1ecac3e3578c8e063da6f5775db Mon Sep 17 00:00:00 2001 From: Spoike Date: Mon, 5 Jun 2017 15:20:57 +0000 Subject: [PATCH] qccgui: add custom right-click menu. move buttons for more screen space. some fixes for various other small things. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5112 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/sbar.h | 2 +- engine/common/pr_bgcmd.c | 91 +++++----- engine/gl/gl_heightmap.c | 2 + engine/qclib/qcc_pr_comp.c | 71 +++++--- engine/qclib/qcc_pr_lex.c | 5 + engine/qclib/qccgui.c | 349 ++++++++++++++++++++++++------------- engine/qclib/qccguistuff.c | 57 +++++- engine/server/pr_cmds.c | 42 +++-- 8 files changed, 406 insertions(+), 213 deletions(-) diff --git a/engine/client/sbar.h b/engine/client/sbar.h index 9cf5c7c4..967b76f6 100644 --- a/engine/client/sbar.h +++ b/engine/client/sbar.h @@ -59,7 +59,7 @@ int Sbar_TranslateHudClick(void); #define Sbar_Draw(pv) #define Sbar_Flush() #define Sbar_ShouldDraw(pv) false -#define Sbar_DrawScoreboard() +#define Sbar_DrawScoreboard(pv) #define Sbar_FinaleOverlay() #define Sbar_IntermissionOverlay(pv) #define Sbar_TranslateHudClick() 0 diff --git a/engine/common/pr_bgcmd.c b/engine/common/pr_bgcmd.c index 74891542..a8db67c5 100644 --- a/engine/common/pr_bgcmd.c +++ b/engine/common/pr_bgcmd.c @@ -3773,8 +3773,8 @@ void QCBUILTIN PF_strftime (pubprogfuncs_t *prinst, struct globalvars_s *pr_glob struct strbuf { pubprogfuncs_t *prinst; char **strings; - int used; - int allocated; + size_t used; + size_t allocated; }; #define BUFSTRBASE 1 @@ -3783,7 +3783,7 @@ struct strbuf strbuflist[NUMSTRINGBUFS]; void PF_buf_shutdown(pubprogfuncs_t *prinst) { - int i, bufno; + size_t i, bufno; for (bufno = 0; bufno < NUMSTRINGBUFS; bufno++) { @@ -3805,7 +3805,7 @@ void PF_buf_shutdown(pubprogfuncs_t *prinst) // #440 float() buf_create (DP_QC_STRINGBUFFERS) void QCBUILTIN PF_buf_create (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { - int i; + size_t i; const char *type = ((prinst->callargc>0)?PR_GetStringOfs(prinst, OFS_PARM0):"string"); // unsigned int flags = ((prinst->callargc>1)?G_FLOAT(OFS_PARM1):1); @@ -3837,10 +3837,10 @@ void QCBUILTIN PF_buf_create (pubprogfuncs_t *prinst, struct globalvars_s *pr_g // #441 void(float bufhandle) buf_del (DP_QC_STRINGBUFFERS) void QCBUILTIN PF_buf_del (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { - int i; - int bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE; + size_t i; + size_t bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE; - if ((unsigned int)bufno >= NUMSTRINGBUFS) + if (bufno >= NUMSTRINGBUFS) return; if (strbuflist[bufno].prinst != prinst) return; @@ -3858,9 +3858,9 @@ void QCBUILTIN PF_buf_del (pubprogfuncs_t *prinst, struct globalvars_s *pr_glob // #442 float(float bufhandle) buf_getsize (DP_QC_STRINGBUFFERS) void QCBUILTIN PF_buf_getsize (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { - int bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE; + size_t bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE; - if ((unsigned int)bufno >= NUMSTRINGBUFS) + if (bufno >= NUMSTRINGBUFS) return; if (strbuflist[bufno].prinst != prinst) return; @@ -3870,17 +3870,17 @@ void QCBUILTIN PF_buf_getsize (pubprogfuncs_t *prinst, struct globalvars_s *pr_ // #443 void(float bufhandle_from, float bufhandle_to) buf_copy (DP_QC_STRINGBUFFERS) void QCBUILTIN PF_buf_copy (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { - int buffrom = G_FLOAT(OFS_PARM0)-BUFSTRBASE; - int bufto = G_FLOAT(OFS_PARM1)-BUFSTRBASE; - int i; + size_t buffrom = G_FLOAT(OFS_PARM0)-BUFSTRBASE; + size_t bufto = G_FLOAT(OFS_PARM1)-BUFSTRBASE; + size_t i; if (bufto == buffrom) //err... return; - if ((unsigned int)buffrom >= NUMSTRINGBUFS) + if (buffrom >= NUMSTRINGBUFS) return; if (strbuflist[buffrom].prinst != prinst) return; - if ((unsigned int)bufto >= NUMSTRINGBUFS) + if (bufto >= NUMSTRINGBUFS) return; if (strbuflist[bufto].prinst != prinst) return; @@ -3908,13 +3908,13 @@ static int QDECL PF_buf_sort_descending(const void *b, const void *a) // #444 void(float bufhandle, float sortprefixlen, float backward) buf_sort (DP_QC_STRINGBUFFERS) void QCBUILTIN PF_buf_sort (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { - int bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE; + size_t bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE; int sortprefixlen = G_FLOAT(OFS_PARM1); - int backwards = G_FLOAT(OFS_PARM2); + qboolean backwards = G_FLOAT(OFS_PARM2); int s,d; char **strings; - if ((unsigned int)bufno >= NUMSTRINGBUFS) + if (bufno >= NUMSTRINGBUFS) return; if (strbuflist[bufno].prinst != prinst) return; @@ -3944,14 +3944,14 @@ void QCBUILTIN PF_buf_sort (pubprogfuncs_t *prinst, struct globalvars_s *pr_glo // #445 string(float bufhandle, string glue) buf_implode (DP_QC_STRINGBUFFERS) void QCBUILTIN PF_buf_implode (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { - int bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE; + size_t bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE; const char *glue = PR_GetStringOfs(prinst, OFS_PARM1); unsigned int gluelen = strlen(glue); - unsigned int retlen, l, i; + size_t retlen, l, i; char **strings; char *ret; - if ((unsigned int)bufno >= NUMSTRINGBUFS) + if (bufno >= NUMSTRINGBUFS) return; if (strbuflist[bufno].prinst != prinst) return; @@ -3993,8 +3993,8 @@ void QCBUILTIN PF_buf_implode (pubprogfuncs_t *prinst, struct globalvars_s *pr_ // #446 string(float bufhandle, float string_index) bufstr_get (DP_QC_STRINGBUFFERS) void QCBUILTIN PF_bufstr_get (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { - int bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE; - int index = G_FLOAT(OFS_PARM1); + size_t bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE; + size_t index = G_FLOAT(OFS_PARM1); if ((unsigned int)bufno >= NUMSTRINGBUFS) { @@ -4018,18 +4018,23 @@ void QCBUILTIN PF_bufstr_get (pubprogfuncs_t *prinst, struct globalvars_s *pr_g // #447 void(float bufhandle, float string_index, string str) bufstr_set (DP_QC_STRINGBUFFERS) void QCBUILTIN PF_bufstr_set (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { - int bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE; - int index = G_FLOAT(OFS_PARM1); + size_t bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE; + size_t index = G_FLOAT(OFS_PARM1); const char *string = PR_GetStringOfs(prinst, OFS_PARM2); - int oldcount; + size_t oldcount; - if ((unsigned int)bufno >= NUMSTRINGBUFS) + if (bufno >= NUMSTRINGBUFS) return; if (strbuflist[bufno].prinst != prinst) return; if (index >= strbuflist[bufno].allocated) { + if (index > 1024*1024) + { + PR_RunWarning(prinst, "index outside sanity range\n"); + return; + } oldcount = strbuflist[bufno].allocated; strbuflist[bufno].allocated = (index + 256); strbuflist[bufno].strings = BZ_Realloc(strbuflist[bufno].strings, strbuflist[bufno].allocated*sizeof(char*)); @@ -4044,9 +4049,9 @@ void QCBUILTIN PF_bufstr_set (pubprogfuncs_t *prinst, struct globalvars_s *pr_g strbuflist[bufno].used = index+1; } -int PF_bufstr_add_internal(int bufno, const char *string, int appendonend) +size_t PF_bufstr_add_internal(int bufno, const char *string, int appendonend) { - int index; + size_t index; if (appendonend) { //add on end @@ -4085,11 +4090,11 @@ int PF_bufstr_add_internal(int bufno, const char *string, int appendonend) // #448 float(float bufhandle, string str, float order) bufstr_add (DP_QC_STRINGBUFFERS) void QCBUILTIN PF_bufstr_add (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { - int bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE; + size_t bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE; const char *string = PR_GetStringOfs(prinst, OFS_PARM1); int order = G_FLOAT(OFS_PARM2); - if ((unsigned int)bufno >= NUMSTRINGBUFS) + if (bufno >= NUMSTRINGBUFS) return; if (strbuflist[bufno].prinst != prinst) return; @@ -4099,10 +4104,10 @@ void QCBUILTIN PF_bufstr_add (pubprogfuncs_t *prinst, struct globalvars_s *pr_g // #449 void(float bufhandle, float string_index) bufstr_free (DP_QC_STRINGBUFFERS) void QCBUILTIN PF_bufstr_free (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { - int bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE; - int index = G_FLOAT(OFS_PARM1); + size_t bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE; + size_t index = G_FLOAT(OFS_PARM1); - if ((unsigned int)bufno >= NUMSTRINGBUFS) + if (bufno >= NUMSTRINGBUFS) return; if (strbuflist[bufno].prinst != prinst) return; @@ -4117,7 +4122,7 @@ void QCBUILTIN PF_bufstr_free (pubprogfuncs_t *prinst, struct globalvars_s *pr_ void QCBUILTIN PF_buf_cvarlist (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { - int bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE; + size_t bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE; const char *pattern = PR_GetStringOfs(prinst, OFS_PARM1); const char *antipattern = PR_GetStringOfs(prinst, OFS_PARM2); int i; @@ -4125,7 +4130,7 @@ void QCBUILTIN PF_buf_cvarlist (pubprogfuncs_t *prinst, struct globalvars_s *pr cvar_t *var; extern cvar_group_t *cvar_groups; - if ((unsigned int)bufno >= NUMSTRINGBUFS) + if (bufno >= NUMSTRINGBUFS) return; if (strbuflist[bufno].prinst != prinst) return; @@ -4153,14 +4158,14 @@ void QCBUILTIN PF_buf_cvarlist (pubprogfuncs_t *prinst, struct globalvars_s *pr void QCBUILTIN PF_buf_loadfile (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { const char *fname = PR_GetStringOfs(prinst, OFS_PARM0); - int bufno = G_FLOAT(OFS_PARM1)-BUFSTRBASE; + size_t bufno = G_FLOAT(OFS_PARM1)-BUFSTRBASE; vfsfile_t *file; char line[8192]; const char *fallback; G_FLOAT(OFS_RETURN) = 0; - if ((unsigned int)bufno >= NUMSTRINGBUFS) + if (bufno >= NUMSTRINGBUFS) return; if (strbuflist[bufno].prinst != prinst) return; @@ -4188,19 +4193,19 @@ void QCBUILTIN PF_buf_loadfile (pubprogfuncs_t *prinst, struct globalvars_s *pr void QCBUILTIN PF_buf_writefile (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { - unsigned int fnum = G_FLOAT(OFS_PARM0) - FIRST_QC_FILE_INDEX; - int bufno = G_FLOAT(OFS_PARM1)-BUFSTRBASE; + size_t fnum = G_FLOAT(OFS_PARM0) - FIRST_QC_FILE_INDEX; + size_t bufno = G_FLOAT(OFS_PARM1)-BUFSTRBASE; char **strings; int idx, midx; G_FLOAT(OFS_RETURN) = 0; - if ((unsigned int)bufno >= (unsigned int)NUMSTRINGBUFS) + if (bufno >= NUMSTRINGBUFS) return; if (strbuflist[bufno].prinst != prinst) return; - if ((unsigned int)fnum >= (unsigned int)MAX_QC_FILES) + if (fnum >= MAX_QC_FILES) return; if (pf_fopen_files[fnum].prinst != prinst) return; @@ -4213,8 +4218,8 @@ void QCBUILTIN PF_buf_writefile (pubprogfuncs_t *prinst, struct globalvars_s *p midx = idx + G_FLOAT(OFS_PARM3); else midx = strbuflist[bufno].used - idx; - idx = bound(0, idx, strbuflist[bufno].used); - midx = min(midx, strbuflist[bufno].used); + idx = bound(0, idx, (int)strbuflist[bufno].used); + midx = min(midx, (int)strbuflist[bufno].used); for(strings = strbuflist[bufno].strings; idx < midx; idx++) { if (strings[idx]) diff --git a/engine/gl/gl_heightmap.c b/engine/gl/gl_heightmap.c index 700a3e65..0c83df4f 100644 --- a/engine/gl/gl_heightmap.c +++ b/engine/gl/gl_heightmap.c @@ -574,7 +574,9 @@ static void QDECL Terr_AddMesh(heightmap_t *hm, int loadflags, model_t *mod, con hm->entities = e; } +#ifdef HEXEN2 e->ent.drawflags = SCALE_ORIGIN_ORIGIN; +#endif e->ent.scale = scale; e->ent.playerindex = -1; e->ent.framestate.g[FS_REG].lerpweight[0] = 1; diff --git a/engine/qclib/qcc_pr_comp.c b/engine/qclib/qcc_pr_comp.c index 4420d6f3..4fec7fe7 100644 --- a/engine/qclib/qcc_pr_comp.c +++ b/engine/qclib/qcc_pr_comp.c @@ -6041,6 +6041,7 @@ QCC_sref_t QCC_PR_ParseFunctionCall (QCC_ref_t *funcref) //warning, the func cou //don't warn if we omited optional arguments while (arg < np && func.cast->params[arg].defltvalue.cast && !func.cast->params[arg].optional) { + QCC_ForceUnFreeDef(func.cast->params[arg].defltvalue.sym); param[arg] = QCC_DefToRef(¶mbuf[arg], func.cast->params[arg].defltvalue); arg++; } @@ -7508,30 +7509,12 @@ QCC_sref_t QCC_PR_GenerateLogicalNot(QCC_sref_t e, const char *errormessage) } } -QCC_sref_t QCC_EvaluateCast(QCC_sref_t src, QCC_type_t *cast, pbool implicit) +//doesn't consider parents +QCC_sref_t QCC_TryEvaluateCast(QCC_sref_t src, QCC_type_t *cast, pbool implicit) { QCC_type_t *tmp; int totype; - if ( (cast->type == ev_accessor && cast->parentclass == src.cast) - || (src.cast->type == ev_accessor && src.cast->parentclass == cast)) - { - if (implicit) - { - char typea[256]; - char typeb[256]; - TypeName(src.cast, typea, sizeof(typea)); - TypeName(cast, typeb, sizeof(typeb)); - QCC_PR_ParseWarning(0, "Implicit cast from %s to %s", typea, typeb); - } - src.cast = cast; - return src; - } - -//casting from an accessor uses the base type of that accessor (this allows us to properly read void* accessors) - while (src.cast->type == ev_accessor) - src.cast = src.cast->parentclass; - for (tmp = cast; tmp->type == ev_accessor; tmp = tmp->parentclass) ; totype = tmp->type; @@ -7625,17 +7608,49 @@ QCC_sref_t QCC_EvaluateCast(QCC_sref_t src, QCC_type_t *cast, pbool implicit) src.cast = cast; else if (!implicit && cast->type == ev_void) src.cast = type_void; //anything can be cast to void, but only do it explicitly. - else - { - char typea[256]; - char typeb[256]; - TypeName(src.cast, typea, sizeof(typea)); - TypeName(cast, typeb, sizeof(typeb)); - QCC_PR_ParseError(0, "Cannot cast from %s to %s", typea, typeb); - } + else //failed + return nullsref; return src; } +QCC_sref_t QCC_EvaluateCast(QCC_sref_t src, QCC_type_t *cast, pbool implicit) +{ + QCC_sref_t r; + if ( (cast->type == ev_accessor && cast->parentclass == src.cast) + || (src.cast->type == ev_accessor && src.cast->parentclass == cast)) + { + if (implicit) + { + char typea[256]; + char typeb[256]; + TypeName(src.cast, typea, sizeof(typea)); + TypeName(cast, typeb, sizeof(typeb)); + QCC_PR_ParseWarning(0, "Implicit cast from %s to %s", typea, typeb); + } + src.cast = cast; + return src; + } + +//casting from an accessor uses the base type of that accessor (this allows us to properly read void* accessors) + for(;;) + { + r = QCC_TryEvaluateCast(src, cast, implicit); + if (r.cast) + return r; //success + + if (src.cast->type == ev_accessor) + src.cast = src.cast->parentclass; + else + { + char typea[256]; + char typeb[256]; + TypeName(src.cast, typea, sizeof(typea)); + TypeName(cast, typeb, sizeof(typeb)); + QCC_PR_ParseError(0, "Cannot cast from %s to %s", typea, typeb); + } + } +} + /* ============ PR_Term diff --git a/engine/qclib/qcc_pr_lex.c b/engine/qclib/qcc_pr_lex.c index e773d80c..00cf26d6 100644 --- a/engine/qclib/qcc_pr_lex.c +++ b/engine/qclib/qcc_pr_lex.c @@ -4507,7 +4507,12 @@ QCC_type_t *QCC_PR_ParseFunctionType (int newtype, QCC_type_t *returntype) strcpy (pr_parm_names[numparms], ""); if (QCC_PR_CheckToken("=")) + { paramlist[numparms].defltvalue = QCC_PR_ParseDefaultInitialiser(paramlist[numparms].type); + if (!paramlist[numparms].defltvalue.sym->constant) + QCC_PR_ParseError(0, "Default initialiser is not constant\n"); + QCC_FreeTemp(paramlist[numparms].defltvalue); + } numparms++; } while (QCC_PR_CheckToken (",")); diff --git a/engine/qclib/qccgui.c b/engine/qclib/qccgui.c index 27a5e55e..c2140129 100644 --- a/engine/qclib/qccgui.c +++ b/engine/qclib/qccgui.c @@ -19,6 +19,7 @@ #define IDI_ICON_FTEQCC MAKEINTRESOURCE(101) +void OptionsDialog(void); static void GUI_CreateInstaller_Windows(void); static void GUI_CreateInstaller_Android(void); void AddSourceFile(const char *parentsrc, const char *filename); @@ -54,7 +55,9 @@ void AddSourceFile(const char *parentsrc, const char *filename); #define SCI_GETCHARAT 2007 #define SCI_GETCURRENTPOS 2008 #define SCI_GETANCHOR 2009 +#define SCI_REDO 2011 #define SCI_SETSAVEPOINT 2014 +#define SCI_CANREDO 2016 #define SCI_GETCURLINE 2027 #define SCI_CONVERTEOLS 2029 #define SC_EOL_CRLF 0 @@ -87,9 +90,15 @@ void AddSourceFile(const char *parentsrc, const char *filename); #define SCI_AUTOCSETFILLUPS 2112 #define SCI_GETLINE 2153 #define SCI_SETSEL 2160 +#define SCI_GETSELTEXT 2161 #define SCI_LINEFROMPOSITION 2166 #define SCI_POSITIONFROMLINE 2167 #define SCI_REPLACESEL 2170 +#define SCI_CANUNDO 2174 +#define SCI_UNDO 2176 +#define SCI_CUT 2177 +#define SCI_COPY 2178 +#define SCI_PASTE 2179 #define SCI_SETTEXT 2181 #define SCI_GETTEXT 2182 #define SCI_CALLTIPSHOW 2200 @@ -120,6 +129,7 @@ void AddSourceFile(const char *parentsrc, const char *filename); #define SCI_BRACEBADLIGHT 2352 #define SCI_BRACEMATCH 2353 #define SCI_SETVIEWEOL 2356 +#define SCI_USEPOPUP 2371 #define SCI_ANNOTATIONSETTEXT 2540 #define SCI_ANNOTATIONGETTEXT 2541 #define SCI_ANNOTATIONSETSTYLE 2542 @@ -711,8 +721,6 @@ HWND optionsmenu; HWND outputbox; HWND projecttree; HWND search_name; -HWND search_gotodef; -HWND search_grep; HACCEL accelerators; @@ -838,11 +846,6 @@ static void SplitterUpdate(void) if (!numsplits) return; - //figure out the total height - for (s = numsplits; s-- > 0; ) - { - y += splits[s].cursize; - } y = splitterrect.bottom-splitterrect.top; //now figure out their positions relative to that @@ -892,25 +895,7 @@ static void SplitterUpdate(void) SetWindowPos(splits[s].wnd, HWND_TOP, splitterrect.left, splitterrect.top+splits[s].cury, splitterrect.right-splitterrect.left, splits[s].cursize, SWP_NOZORDER); } } -static void SplitterFocus(HWND w, int minsize) -{ - struct splits_s *s = SplitterGet(w); - if (s) - { - if (s->cursize < minsize) - { - s->cursize += SplitterShrinkPrior(s-splits-1, (minsize-s->cursize)/2); - if (s->cursize < minsize) - s->cursize += SplitterShrinkNext(s-splits+1, minsize-s->cursize); - if (s->cursize < minsize) - s->cursize += SplitterShrinkPrior(s-splits-1, minsize-s->cursize); - SplitterUpdate(); - } - } - - SetFocus(w); -} -static void SplitterAdd(HWND w, int minsize) +static void SplitterAdd(HWND w, int minsize, int newsize) { struct splits_s *n = malloc(sizeof(*n)*(numsplits+1)); memcpy(n, splits, sizeof(*n)*numsplits); @@ -921,7 +906,7 @@ static void SplitterAdd(HWND w, int minsize) n->wnd = w; n->splitter = NULL; n->minsize = minsize; - n->cursize = minsize; + n->cursize = newsize; n->cury = 0; numsplits++; @@ -929,6 +914,27 @@ static void SplitterAdd(HWND w, int minsize) SplitterUpdate(); ShowWindow(w, SW_SHOW); } +//adds if needed. +static void SplitterFocus(HWND w, int minsize, int newsize) +{ + struct splits_s *s = SplitterGet(w); + if (s) + { + if (s->cursize < newsize) + { + s->cursize += SplitterShrinkPrior(s-splits-1, (newsize-s->cursize)/2); + if (s->cursize < newsize) + s->cursize += SplitterShrinkNext(s-splits+1, newsize-s->cursize); + if (s->cursize < newsize) + s->cursize += SplitterShrinkPrior(s-splits-1, newsize-s->cursize); + SplitterUpdate(); + } + } + else + SplitterAdd(w, minsize, newsize); + + SetFocus(w); +} static void SplitterRemove(HWND w) { struct splits_s *s = SplitterGet(w); @@ -959,23 +965,25 @@ struct{ int washit; } buttons[] = { {"Compile"}, - {"Progs.src"}, #ifdef EMBEDDEBUG + {NULL}, {"Debug"}, #endif {"Options"}, - {"Quit"} + {"Def"}, + {"Grep"} }; enum { ID_COMPILE = 0, - ID_EDIT, #ifdef EMBEDDEBUG + ID_NULL, ID_RUN, #endif ID_OPTIONS, - ID_QUIT + ID_DEF, + ID_GREP }; #define NUMBUTTONS sizeof(buttons)/sizeof(buttons[0]) @@ -1014,6 +1022,9 @@ LRESULT CALLBACK MySubclassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l { switch(wParam) { + case VK_ESCAPE: + SplitterRemove(outputbox); + break; case VK_SPACE: { BYTE keystate[256]; @@ -1261,6 +1272,8 @@ HWND CreateAnEditControl(HWND parent, pbool *scintillaokay) "TODO FIXME BUG" ); + SendMessage(newc, SCI_USEPOPUP, 0/*SC_POPUP_NEVER*/, 0); //so we can do right-click menus ourselves. + SendMessage(newc, SCI_SETMOUSEDWELLTIME, 1000, 0); SendMessage(newc, SCI_AUTOCSETORDER, SC_ORDER_PERFORMSORT, 0); SendMessage(newc, SCI_AUTOCSETFILLUPS, 0, (LPARAM)".,[<>(*/+-=\t\n"); @@ -1520,11 +1533,15 @@ enum { IDM_QUIT, IDM_UNDO, IDM_REDO, + IDM_CUT, + IDM_COPY, + IDM_PASTE, IDM_ABOUT, IDM_CASCADE, IDM_TILE_HORIZ, IDM_TILE_VERT, IDM_DEBUG_REBUILD, + IDM_DEBUG_BUILD_OPTIONS, IDM_DEBUG_SETNEXT, IDM_DEBUG_RUN, IDM_DEBUG_STEPOVER, @@ -1617,7 +1634,10 @@ void GenericMenu(WPARAM wParam) case IDM_OUTPUT_WINDOW: - SplitterFocus(outputbox, 128); + if (GetFocus() == outputbox) + SplitterRemove(outputbox); + else + SplitterFocus(outputbox, 64, 128); break; case IDM_SHOWLINENUMBERS: { @@ -1647,6 +1667,9 @@ void GenericMenu(WPARAM wParam) case IDM_DEBUG_REBUILD: buttons[ID_COMPILE].washit = true; return; + case IDM_DEBUG_BUILD_OPTIONS: + OptionsDialog(); + return; case IDM_DEBUG_STEPOVER: EditFile(NULL, -1, true); EngineCommandf("qcstep over\n"); @@ -1759,6 +1782,36 @@ static char *WordUnderCursor(editor_t *editor, char *word, int wordsize, char *t } return word; } +static char *ReadTextSelection(editor_t *editor, char *word, int wordsize) +{ + int total; + if (editor->scintilla) + { + total = SendMessage(editor->editpane, SCI_GETSELTEXT, 0, (LPARAM)NULL); + if (total < wordsize) + total = SendMessage(editor->editpane, SCI_GETSELTEXT, 0, (LPARAM)word); + else + total = 0; + } + else + { + CHARRANGE ffs; + SendMessage(editor->editpane, EM_EXGETSEL, 0, (LPARAM)&ffs); + if (ffs.cpMax-ffs.cpMin > wordsize-1) + total = 0; //don't crash through the use of a crappy API. + else + total = SendMessage(editor->editpane, EM_GETSELTEXT, (WPARAM)0, (LPARAM)word); + } + if (total) + word[total]='\0'; + else + { + if (*WordUnderCursor(editor, word, wordsize, NULL, 0, SendMessage(editor->editpane, SCI_GETCURRENTPOS, 0, 0))) + return word; + return NULL; + } + return word; +} static void GUI_Recode(editor_t *editor, int target) { @@ -1920,10 +1973,7 @@ void EditorMenu(editor_t *editor, WPARAM wParam) case IDM_OPENDOCU: { char buffer[1024]; - int total; - total = SendMessage(editor->editpane, EM_GETSELTEXT, (WPARAM)sizeof(buffer)-1, (LPARAM)buffer); - buffer[total]='\0'; - if (!total && !WordUnderCursor(editor, buffer, sizeof(buffer), NULL, 0, SendMessage(editor->editpane, SCI_GETCURRENTPOS, 0, 0))) + if (!ReadTextSelection(editor, buffer, sizeof(buffer))) { MessageBox(NULL, "There is no name currently selected.", "Whoops", 0); break; @@ -1964,10 +2014,7 @@ void EditorMenu(editor_t *editor, WPARAM wParam) case IDM_GREP: { char buffer[1024]; - int total; - total = SendMessage(editor->editpane, EM_GETSELTEXT, (WPARAM)sizeof(buffer)-1, (LPARAM)buffer); - buffer[total]='\0'; - if (!total && !WordUnderCursor(editor, buffer, sizeof(buffer), NULL, 0, SendMessage(editor->editpane, SCI_GETCURRENTPOS, 0, 0))) + if (!ReadTextSelection(editor, buffer, sizeof(buffer))) { MessageBox(NULL, "There is no search text specified.", "Whoops", 0); break; @@ -1997,7 +2044,6 @@ void EditorMenu(editor_t *editor, WPARAM wParam) case IDM_GOTODEF: { char buffer[1024]; - int total; { navhistory[navhistory_pos&navhistory_size].editor = editor; @@ -2008,9 +2054,7 @@ void EditorMenu(editor_t *editor, WPARAM wParam) navhistory_first = navhistory_pos - navhistory_size; } - total = SendMessage(editor->editpane, EM_GETSELTEXT, (WPARAM)sizeof(buffer)-1, (LPARAM)buffer); - buffer[total]='\0'; - if (!total && !WordUnderCursor(editor, buffer, sizeof(buffer), NULL, 0, SendMessage(editor->editpane, SCI_GETCURRENTPOS, 0, 0))) + if (!ReadTextSelection(editor, buffer, sizeof(buffer))) { MessageBox(NULL, "There is no name currently selected.", "Whoops", 0); break; @@ -2021,10 +2065,29 @@ void EditorMenu(editor_t *editor, WPARAM wParam) break; case IDM_UNDO: - Edit_Undo(editor->editpane); + if (editor->scintilla) + SendMessage(editor->editpane, SCI_UNDO, 0, 0); + else + Edit_Undo(editor->editpane); break; case IDM_REDO: - Edit_Redo(editor->editpane); + if (editor->scintilla) + SendMessage(editor->editpane, SCI_REDO, 0, 0); + else + Edit_Redo(editor->editpane); + break; + + case IDM_CUT: + if (editor->scintilla) + SendMessage(editor->editpane, SCI_CUT, 0, 0); + break; + case IDM_COPY: + if (editor->scintilla) + SendMessage(editor->editpane, SCI_COPY, 0, 0); + break; + case IDM_PASTE: + if (editor->scintilla) + SendMessage(editor->editpane, SCI_PASTE, 0, 0); break; case IDM_DEBUG_TOGGLEBREAK: @@ -2556,11 +2619,69 @@ static LRESULT CALLBACK EditorWndProc(HWND hWnd,UINT message, } else { - if (mdibox) - goto gdefault; +// if (mdibox) +// goto gdefault; EditorMenu(editor, wParam); } break; + case WM_CONTEXTMENU: + { + char buffer[1024]; + int x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam); + HMENU menu = CreatePopupMenu(); + if (x == -1 && y == -1) + { + POINT p; + GetCursorPos(&p); //not the best. but too lazy to work out scintilla/richedit. + x = p.x; + y = p.y; + } + + if (ReadTextSelection(editor, buffer, sizeof(buffer))) + { + char tmp[1024]; + QC_snprintfz(tmp, sizeof(tmp), "Go to definition: %s", buffer); + AppendMenuA(menu, MF_ENABLED, + IDM_GOTODEF, tmp); + + QC_snprintfz(tmp, sizeof(tmp), "Grep for %s", buffer); + AppendMenuA(menu, MF_ENABLED, + IDM_GREP, tmp); + + AppendMenuA(menu, MF_SEPARATOR, 0, NULL); + } + + AppendMenuA(menu, MF_ENABLED, + IDM_DEBUG_TOGGLEBREAK, "Toggle Breakpoint"); + + if (gamewindow) + { + AppendMenuA(menu, MF_ENABLED, IDM_DEBUG_SETNEXT, "Set next statement"); + AppendMenuA(menu, MF_ENABLED, IDM_DEBUG_RUN, "Resume"); + } + else + AppendMenuA(menu, MF_ENABLED, IDM_DEBUG_RUN, "Begin Debugging"); + + AppendMenuA(menu, MF_SEPARATOR, 0, NULL); + + AppendMenuA(menu, editor->modified?MF_ENABLED:(MF_DISABLED|MF_GRAYED), + IDM_SAVE, "Save File"); + // AppendMenuA(menu, MF_ENABLED, IDM_FIND, "&Find"); + AppendMenuA(menu, (editor->scintilla&&!SendMessage(editor->editpane, SCI_CANUNDO,0,0))?(MF_DISABLED|MF_GRAYED):MF_ENABLED, + IDM_UNDO, "Undo"); + AppendMenuA(menu, (editor->scintilla&&!SendMessage(editor->editpane, SCI_CANREDO,0,0))?(MF_DISABLED|MF_GRAYED):MF_ENABLED, + IDM_REDO, "Redo"); + AppendMenuA(menu, MF_ENABLED, + IDM_CUT, "Cut"); + AppendMenuA(menu, MF_ENABLED, + IDM_COPY, "Copy"); + AppendMenuA(menu, MF_ENABLED, + IDM_PASTE, "Paste"); + + TrackPopupMenu(menu, TPM_LEFTBUTTON|TPM_RIGHTBUTTON, x, y, 0, hWnd, NULL); + DestroyMenu(menu); + } + break; case WM_NOTIFY: { NMHDR *nmhdr; @@ -3966,8 +4087,7 @@ void RunEngine(void) gamewindow = (HWND) SendMessage (mdibox, WM_MDICREATE, 0, (LONG_PTR) (LPMDICREATESTRUCT) &mcs); } - SplitterAdd(watches, 0); - SplitterFocus(watches, 64); + SplitterFocus(watches, 64, 64); } else { @@ -5557,7 +5677,7 @@ static LRESULT CALLBACK SearchComboSubClass(HWND hWnd,UINT message, switch (wParam) { case VK_RETURN: - PostMessage(mainwindow, WM_COMMAND, 0x4404, (LPARAM)search_gotodef); + PostMessage(mainwindow, WM_COMMAND, ID_DEF, (LPARAM)buttons[ID_DEF].hwnd); return true; } } @@ -5567,7 +5687,6 @@ static LRESULT CALLBACK SearchComboSubClass(HWND hWnd,UINT message, static LRESULT CALLBACK MainWndProc(HWND hWnd,UINT message, WPARAM wParam,LPARAM lParam) { - int width; int i; RECT rect; PAINTSTRUCT ps; @@ -5586,7 +5705,6 @@ static LRESULT CALLBACK MainWndProc(HWND hWnd,UINT message, AppendMenu(rootmenu, MF_POPUP, (UINT_PTR)(m = CreateMenu()), "&File"); AppendMenu(m, 0, IDM_OPENNEW, "Open new file "); AppendMenu(m, 0, IDM_SAVE, "&Save\tCtrl+S "); - AppendMenu(m, 0, IDM_RECOMPILE, "&Recompile\tCtrl+R "); // AppendMenu(m, 0, IDM_FIND, "&Find"); AppendMenu(m, 0, IDM_UNDO, "Undo\tCtrl+Z"); AppendMenu(m, 0, IDM_REDO, "Redo\tCtrl+Y"); @@ -5597,7 +5715,7 @@ static LRESULT CALLBACK MainWndProc(HWND hWnd,UINT message, AppendMenu(m, 0, IDM_QUIT, "Exit"); AppendMenu(rootmenu, MF_POPUP, (UINT_PTR)(m = CreateMenu()), "&Navigation"); AppendMenu(m, 0, IDM_GOTODEF, "Go to definition\tF12"); - AppendMenu(m, 0, IDM_RETURNDEF, "Return from definition\tF12"); + AppendMenu(m, 0, IDM_RETURNDEF, "Return from definition\tShift+F12"); AppendMenu(m, 0, IDM_GREP, "Grep for selection\tCtrl+G"); AppendMenu(m, 0, IDM_OPENDOCU, "Open selected file"); AppendMenu(m, 0, IDM_OUTPUT_WINDOW, "Show Output Window\tF6"); @@ -5614,6 +5732,8 @@ static LRESULT CALLBACK MainWndProc(HWND hWnd,UINT message, AppendMenu(m, 0, IDM_TILE_VERT, "Tile Vertically"); AppendMenu(rootmenu, MF_POPUP, (UINT_PTR)(m = CreateMenu()), "&Debug"); AppendMenu(m, 0, IDM_DEBUG_REBUILD, "Rebuild\tF7"); + AppendMenu(m, 0, IDM_DEBUG_BUILD_OPTIONS, "Build Options"); + AppendMenu(m, MF_SEPARATOR, 0, NULL); AppendMenu(m, 0, IDM_DEBUG_SETNEXT, "Set Next Statement\tF8"); AppendMenu(m, 0, IDM_DEBUG_RUN, "Run/Resume\tF5"); AppendMenu(m, 0, IDM_DEBUG_STEPOVER, "Step Over\tF10"); @@ -5643,7 +5763,7 @@ static LRESULT CALLBACK MainWndProc(HWND hWnd,UINT message, WS_CHILD | WS_VSCROLL | WS_HSCROLL | LVS_REPORT | LVS_EDITLABELS, 0, 0, 320, 200, hWnd, (HMENU) 0xCAD, ghInstance, NULL); - SplitterAdd(mdibox, 32); + SplitterAdd(mdibox, 32, 32); if (watches) { @@ -5690,15 +5810,6 @@ static LRESULT CALLBACK MainWndProc(HWND hWnd,UINT message, combosubclassproc = (WNDPROC) SetWindowLongPtr(comboedit, GWLP_WNDPROC, (DWORD_PTR) SearchComboSubClass); } ShowWindow(search_name, SW_SHOW); - - search_gotodef = CreateWindowEx(WS_EX_CLIENTEDGE, "BUTTON", "Def", - WS_CHILD | WS_CLIPCHILDREN/* | BS_DEFPUSHBUTTON*/, - 0, 0, 320, 200, hWnd, (HMENU) 0x4404, ghInstance, (LPSTR) NULL); - ShowWindow(search_gotodef, SW_SHOW); - search_grep = CreateWindowEx(WS_EX_CLIENTEDGE, "BUTTON", "Grep", - WS_CHILD | WS_CLIPCHILDREN/* | BS_DEFPUSHBUTTON*/, - 0, 0, 320, 200, hWnd, (HMENU) 0x4405, ghInstance, (LPSTR) NULL); - ShowWindow(search_grep, SW_SHOW); } } break; @@ -5724,30 +5835,33 @@ static LRESULT CALLBACK MainWndProc(HWND hWnd,UINT message, break; case WM_SIZE: - GetClientRect(mainwindow, &rect); - if (projecttree) { - SetWindowPos(projecttree, NULL, 0, 0, 192, rect.bottom-rect.top - 48, SWP_NOZORDER); + int y; + GetClientRect(mainwindow, &rect); + y = rect.bottom; - SetWindowPos(search_name, NULL, 0, rect.bottom-rect.top - 48, 192, 24, SWP_NOZORDER); - SetWindowPos(search_gotodef, NULL, 0, rect.bottom-rect.top - 24, 192/2, 24, SWP_NOZORDER); - SetWindowPos(search_grep, NULL, 192/2, rect.bottom-rect.top - 24, 192/2, 24, SWP_NOZORDER); + for (i = 0; i < NUMBUTTONS; i+=2) + { + y -= 24; + if (!buttons[i+1].hwnd) + SetWindowPos(buttons[i].hwnd, NULL, 0, y, 192, 24, SWP_NOZORDER); + else + { + SetWindowPos(buttons[i].hwnd, NULL, 0, y, 192/2, 24, SWP_NOZORDER); + SetWindowPos(buttons[i+1].hwnd, NULL, 192/2, y, 192-192/2, 24, SWP_NOZORDER); + } + } + + y -= 24; + SetWindowPos(search_name, NULL, 0, y, 192, 24, SWP_NOZORDER); + + if (projecttree) + SetWindowPos(projecttree, NULL, 0, 0, 192, y, SWP_NOZORDER); splitterrect.left = 192; - } - else - { - splitterrect.left = 0; - } - splitterrect.right = rect.right-rect.left; - splitterrect.bottom = rect.bottom-rect.top-32; - SplitterUpdate(); - width = (rect.right-rect.left)-splitterrect.left; - for (i = 0; i < NUMBUTTONS; i++) - { - int l = splitterrect.left+(width*i)/(NUMBUTTONS); - int r = splitterrect.left+(width*(i+1))/(NUMBUTTONS); - SetWindowPos(buttons[i].hwnd, NULL, l, rect.bottom-rect.top - 32, r-l, 32, SWP_NOZORDER); + splitterrect.right = rect.right-rect.left; + splitterrect.bottom = rect.bottom-rect.top; + SplitterUpdate(); } break; // goto gdefault; @@ -5789,19 +5903,20 @@ static LRESULT CALLBACK MainWndProc(HWND hWnd,UINT message, } goto gdefault; } - if (i == 0x4404) - { - GetWindowText(search_name, finddef, sizeof(finddef)-1); - return true; - } - if (i == 0x4405) - { - GetWindowText(search_name, greptext, sizeof(greptext)-1); - return true; - } if (i>=20 && i < 20+NUMBUTTONS) { - buttons[i-20].washit = 1; + i -= 20; + if (i == ID_DEF) + { + GetWindowText(search_name, finddef, sizeof(finddef)-1); + return true; + } + if (i == ID_GREP) + { + GetWindowText(search_name, greptext, sizeof(greptext)-1); + return true; + } + buttons[i].washit = 1; break; } if (i < IDM_FIRSTCHILD) @@ -6253,7 +6368,7 @@ int GUIprintf(const char *msg, ...) outlen = 0; /*make sure its active so we can actually scroll. stupid windows*/ - SplitterFocus(outputbox, 0); + SplitterFocus(outputbox, 64, 0); /*colour background to default*/ TreeView_SetBkColor(projecttree, -1); @@ -6393,6 +6508,8 @@ void compilecb(void) { //used to repaint the output window periodically instead of letting it redraw as stuff gets sent to it. this can save significant time on mods with boatloads of warnings. MSG wmsg; + if (!SplitterGet(outputbox)) + return; SendMessage(outputbox, WM_SETREDRAW, TRUE, 0); RedrawWindow(outputbox, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN); while (PeekMessage (&wmsg, NULL, 0, 0, PM_REMOVE)) @@ -6467,7 +6584,7 @@ void RunCompiler(char *args, pbool quick) else logfile = NULL; - if (outputbox) + if (SplitterGet(outputbox)) SendMessage(outputbox, WM_SETREDRAW, FALSE, 0); argc = GUI_BuildParms(args, argv, quick); @@ -6482,7 +6599,7 @@ void RunCompiler(char *args, pbool quick) } } - if (outputbox) + if (SplitterGet(outputbox)) { SendMessage(outputbox, WM_SETREDRAW, TRUE, 0); RedrawWindow(outputbox, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN); @@ -6500,9 +6617,8 @@ void CreateOutputWindow(pbool doannoates) if (!outputbox) { outputbox = CreateAnEditControl(mainwindow, NULL); - SplitterAdd(outputbox, 64); } - SplitterFocus(outputbox, 128); + SplitterFocus(outputbox, 64, 128); } @@ -6715,7 +6831,6 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin {FCONTROL|FVIRTKEY, 'S', IDM_SAVE}, {FCONTROL|FVIRTKEY, 'F', IDM_FIND}, {FCONTROL|FVIRTKEY, 'G', IDM_GREP}, - {FCONTROL|FVIRTKEY, 'R', IDM_RECOMPILE}, {FVIRTKEY, VK_F3, IDM_FINDNEXT}, {FSHIFT|FVIRTKEY, VK_F3, IDM_FINDPREV}, // {FVIRTKEY, VK_F4, IDM_NEXTERROR}, @@ -6885,15 +7000,18 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin for (i = 0; i < NUMBUTTONS; i++) { - buttons[i].hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, - "BUTTON", - buttons[i].text, - WS_CHILD | WS_VISIBLE, - 0, 0, 5, 5, - mainwindow, - (HMENU)(LONG_PTR)(i+20), - ghInstance, - NULL); + if (!buttons[i].text) + buttons[i].hwnd = NULL; + else + buttons[i].hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, + "BUTTON", + buttons[i].text, + WS_CHILD | WS_VISIBLE, + 0, 0, 5, 5, + mainwindow, + (HMENU)(LONG_PTR)(i+20), + ghInstance, + NULL); } ShowWindow(mainwindow, SW_SHOWDEFAULT); @@ -6977,12 +7095,6 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin buttons[ID_COMPILE].washit = false; } - if (buttons[ID_EDIT].washit) - { - buttons[ID_EDIT].washit = false; - if (*progssrcname) - EditFile(progssrcname, -1, false); - } #ifdef EMBEDDEBUG if (buttons[ID_RUN].washit) { @@ -6995,11 +7107,6 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin buttons[ID_OPTIONS].washit = false; OptionsDialog(); } - if (buttons[ID_QUIT].washit) - { - buttons[ID_QUIT].washit = false; - DestroyWindow(mainwindow); - } } if (*finddef) diff --git a/engine/qclib/qccguistuff.c b/engine/qclib/qccguistuff.c index 55c0938e..c8061900 100644 --- a/engine/qclib/qccguistuff.c +++ b/engine/qclib/qccguistuff.c @@ -72,7 +72,13 @@ int Grep(char *filename, char *string) } void GoToDefinition(char *name) { - QCC_def_t *def; + #define MAXSOURCEFILESLIST 8 + extern char sourcefileslist[MAXSOURCEFILESLIST][1024]; + extern QCC_def_t *sourcefilesdefs[MAXSOURCEFILESLIST]; + extern int sourcefilesnumdefs; + int fno; + + QCC_def_t *def, *guess; QCC_function_t *fnc; char *strip; //trim whitespace (for convieniance). @@ -95,19 +101,64 @@ void GoToDefinition(char *name) def = QCC_PR_GetDef(NULL, name, NULL, false, 0, false); + //no exact match, see if we can get a case-insensitive match + if (!def && *name) + { + for (fno = 0; fno < sourcefilesnumdefs; fno++) + { + for (def = sourcefilesdefs[fno]; def; def = def->next) + { + if (def->scope) + continue; //ignore locals, because we don't know where we are, and they're probably irrelevent. + if (!QC_strcasecmp(def->name, name)) + { + fno = sourcefilesnumdefs; + break; + } + } + } + } + + //no exact match, see if we can get a partial + if (!def && *name) + { + int prefixlen = strlen(name); + for (fno = 0; fno < sourcefilesnumdefs; fno++) + { + for (guess = sourcefilesdefs[fno]; guess; guess = guess->next) + { + if (guess->scope) + continue; //ignore locals, because we don't know where we are, and they're probably irrelevent. + + //make sure it has the right prefix + if (!QC_strncasecmp(guess->name, name, prefixlen)) + { + if (guess->type->type == ev_function && guess->constant && !guess->arraysize) + { //if we found a function, use that one above all others. + def = guess; + fno = sourcefilesnumdefs; + break; + } + else if (!def) + def = guess; + } + } + } + } + if (def) { //with functions, the def is the prototype. //we want the body, so zoom to the first statement of the function instead if (def->type->type == ev_function && def->constant && !def->arraysize) { - int fnum = def->symboldata[def->ofs].function; + int fnum = def->symboldata[0].function; if (fnum > 0 && fnum < numfunctions) { fnc = &functions[fnum]; if (fnc->code>=0 && fnc->filen) { - EditFile(fnc->filen, statements[fnc->code].linenum-1, false); + EditFile(fnc->filen, fnc->line, false); return; } } diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index 14fb2372..7a3ebfb8 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -1443,6 +1443,12 @@ static void PR_FallbackSpawn_Misc_Model(pubprogfuncs_t *progfuncs, edict_t *self void *pr_globals; eval_t *val; + if (sv.world.worldmodel && sv.world.worldmodel->type==mod_brush && sv.world.worldmodel->fromgame == fg_quake3) + { //on q3bsp, these are expected to be handled directly by q3map2, but it doesn't always strip it. + ED_Free(progfuncs, self); + return; + } + if (!self->v->model && (val = progfuncs->GetEdictFieldValue(progfuncs, self, "mdl", ev_string, NULL))) self->v->model = val->string; if (!*PR_GetString(progfuncs, self->v->model)) //must have a model, because otherwise various things will assume its not valid at all. @@ -1492,7 +1498,7 @@ static void PDECL PR_DoSpawnInitialEntity(pubprogfuncs_t *progfuncs, struct edic eclassname = PR_GetString(progfuncs, ed->v->classname); if (!*eclassname) { - printf("No classname\n"); + Con_Printf("No classname\n"); ED_Free(progfuncs, ed); } else @@ -1562,7 +1568,7 @@ static void PDECL PR_DoSpawnInitialEntity(pubprogfuncs_t *progfuncs, struct edic { if (!ctx->spawnwarned[i]) { - printf("Couldn't find spawn function for %s\n", eclassname); + Con_Printf("Couldn't find spawn function for %s\n", eclassname); ctx->spawnwarned[i] = eclassname; break; } @@ -9455,6 +9461,8 @@ static void QCBUILTIN PF_runclientphys(pubprogfuncs_t *prinst, struct globalvars msecs -= pmove.cmd.msec; PM_PlayerMove(1); + if (client) + client->jump_held = pmove.jump_held; ent->xv->pmove_flags = 0; ent->xv->pmove_flags += ((int)pmove.jump_held?PMF_JUMP_HELD:0); ent->xv->pmove_flags += ((int)pmove.onladder?PMF_LADDER:0); @@ -10584,7 +10592,7 @@ BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs {"buf_implode", PF_Fixme, 0, 0, 0, 445, "string(strbuf bufhandle, string glue)"},//DP_QC_STRINGBUFFERS {"bufstr_get", PF_Fixme, 0, 0, 0, 446, "string(strbuf bufhandle, float string_index)"},//DP_QC_STRINGBUFFERS {"bufstr_set", PF_Fixme, 0, 0, 0, 447, "void(strbuf bufhandle, float string_index, string str)"},//DP_QC_STRINGBUFFERS - {"bufstr_add", PF_Fixme, 0, 0, 0, 448, "float(strbuf bufhandle, string str, float order)"},//DP_QC_STRINGBUFFERS + {"bufstr_add", PF_Fixme, 0, 0, 0, 448, "float(strbuf bufhandle, string str, float ordered)"},//DP_QC_STRINGBUFFERS {"bufstr_free", PF_Fixme, 0, 0, 0, 449, "void(strbuf bufhandle, float string_index)"},//DP_QC_STRINGBUFFERS {"iscachedpic", PF_Fixme, 0, 0, 0, 451, "float(string name)"},// (EXT_CSQC) {"precache_pic", PF_Fixme, 0, 0, 0, 452, "string(string name, optional float trywad)"},// (EXT_CSQC) @@ -10638,7 +10646,7 @@ BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs {"buf_implode", PF_buf_implode, 0, 0, 0, 465, "string(strbuf bufhandle, string glue)"},//DP_QC_STRINGBUFFERS {"bufstr_get", PF_bufstr_get, 0, 0, 0, 466, "string(strbuf bufhandle, float string_index)"},//DP_QC_STRINGBUFFERS {"bufstr_set", PF_bufstr_set, 0, 0, 0, 467, "void(strbuf bufhandle, float string_index, string str)"},//DP_QC_STRINGBUFFERS - {"bufstr_add", PF_bufstr_add, 0, 0, 0, 468, "float(strbuf bufhandle, string str, float order)"},//DP_QC_STRINGBUFFERS + {"bufstr_add", PF_bufstr_add, 0, 0, 0, 468, "float(strbuf bufhandle, string str, float ordered)"},//DP_QC_STRINGBUFFERS {"bufstr_free", PF_bufstr_free, 0, 0, 0, 469, "void(strbuf bufhandle, float string_index)"},//DP_QC_STRINGBUFFERS //end non-menu @@ -11674,20 +11682,20 @@ void PR_DumpPlatform_f(void) {"CONTENT_SKY", "const float", QW|NQ|CS, NULL, Q1CONTENTS_SKY}, {"CONTENT_LADDER", "const float", QW|NQ|CS, D("If this value is assigned to a solid_bsp's .skin field, the entity will become a ladder volume."), Q1CONTENTS_LADDER}, - {"CONTENTBIT_NONE", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_EMPTY)}, - {"CONTENTBIT_SOLID", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_SOLID)}, - {"CONTENTBIT_LAVA", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_LAVA)}, - {"CONTENTBIT_SLIME", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_SLIME)}, - {"CONTENTBIT_WATER", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_WATER)}, - {"CONTENTBIT_FTELADDER", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_LADDER)}, - {"CONTENTBIT_PLAYERCLIP", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_PLAYERCLIP)}, - {"CONTENTBIT_MONSTERCLIP", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_MONSTERCLIP)}, - {"CONTENTBIT_BODY", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_BODY)}, - {"CONTENTBIT_CORPSE", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_CORPSE)}, - {"CONTENTBIT_Q2LADDER", "const int", QW|NQ|CS, D("Content bit specific to q2bsp"), 0,STRINGIFY(Q2CONTENTS_LADDER)}, + {"CONTENTBIT_NONE", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_EMPTY)"i"}, + {"CONTENTBIT_SOLID", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_SOLID)"i"}, + {"CONTENTBIT_LAVA", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_LAVA)"i"}, + {"CONTENTBIT_SLIME", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_SLIME)"i"}, + {"CONTENTBIT_WATER", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_WATER)"i"}, + {"CONTENTBIT_FTELADDER", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_LADDER)"i"}, + {"CONTENTBIT_PLAYERCLIP", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_PLAYERCLIP)"i"}, + {"CONTENTBIT_MONSTERCLIP", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_MONSTERCLIP)"i"}, + {"CONTENTBIT_BODY", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_BODY)"i"}, + {"CONTENTBIT_CORPSE", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_CORPSE)"i"}, + {"CONTENTBIT_Q2LADDER", "const int", QW|NQ|CS, D("Content bit specific to q2bsp"), 0,STRINGIFY(Q2CONTENTS_LADDER)"i"}, {"CONTENTBIT_SKY", "const int", QW|NQ|CS, NULL, 0,STRINGIFY(FTECONTENTS_SKY)"i"}, - {"CONTENTBITS_POINTSOLID", "const int", QW|NQ|CS, D("Bits that traceline would normally consider solid"), 0,"CONTENTBIT_SOLID|"STRINGIFY(Q2CONTENTS_WINDOW)"|CONTENTBIT_BODY"}, - {"CONTENTBITS_BOXSOLID", "const int", QW|NQ|CS, D("Bits that tracebox would normally consider solid"), 0,"CONTENTBIT_SOLID|"STRINGIFY(Q2CONTENTS_WINDOW)"|CONTENTBIT_BODY|CONTENTBIT_PLAYERCLIP"}, + {"CONTENTBITS_POINTSOLID", "const int", QW|NQ|CS, D("Bits that traceline would normally consider solid"), 0,"CONTENTBIT_SOLID|"STRINGIFY(Q2CONTENTS_WINDOW)"i|CONTENTBIT_BODY"}, + {"CONTENTBITS_BOXSOLID", "const int", QW|NQ|CS, D("Bits that tracebox would normally consider solid"), 0,"CONTENTBIT_SOLID|"STRINGIFY(Q2CONTENTS_WINDOW)"i|CONTENTBIT_BODY|CONTENTBIT_PLAYERCLIP"}, {"CONTENTBITS_FLUID", "const int", QW|NQ|CS, NULL, 0,"CONTENTBIT_WATER|CONTENTBIT_SLIME|CONTENTBIT_LAVA|CONTENTBIT_SKY"}, {"SPA_POSITION", "const int", QW|NQ|CS, D("These SPA_* constants are to specify which attribute is returned by the getsurfacepointattribute builtin"), 0},