From 0bda1b5c3855480943d173bde6f2ccb21ee5de33 Mon Sep 17 00:00:00 2001 From: Spoike Date: Wed, 1 Jul 2020 05:32:21 +0000 Subject: [PATCH] Add support for writing uhexen2's v7 progs files. Try to fix issues with newer gcc not merging common symbols any more. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5720 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- CMakeLists.txt | 2 + engine/Makefile | 7 ++- engine/client/cl_main.c | 5 -- engine/client/m_download.c | 2 +- engine/client/pr_menu.c | 7 ++- engine/client/snd_dma.c | 35 +++++++---- engine/client/sys_linux.c | 2 +- engine/common/com_mesh.h | 1 + engine/common/com_phys_ode.c | 1 - engine/common/common.c | 3 - engine/common/pr_bgcmd.c | 4 +- engine/qclib/decomp.c | 2 +- engine/qclib/initlib.c | 3 + engine/qclib/pr_comp.h | 2 + engine/qclib/pr_edict.c | 89 +++++++++++++++++++++++++- engine/qclib/pr_exec.c | 6 ++ engine/qclib/pr_multi.c | 1 + engine/qclib/progsint.h | 1 + engine/qclib/qcc.h | 2 +- engine/qclib/qcc_pr_comp.c | 9 +-- engine/qclib/qcc_pr_lex.c | 6 +- engine/qclib/qccguistuff.c | 4 +- engine/qclib/qccmain.c | 119 ++++++++++++++++++++++++++++++----- engine/qclib/qcctui.c | 33 +++++++--- engine/server/sv_main.c | 8 --- plugins/ezhud/ezquakeisms.c | 4 ++ plugins/ezhud/ezquakeisms.h | 18 +++--- plugins/models/gltf.c | 4 +- 28 files changed, 296 insertions(+), 84 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 639d8f8b2..d1eaa51be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,6 +174,8 @@ IF(CMAKE_C_COMPILER_ID MATCHES "GNU") ELSE() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") ENDIF() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--warn-common") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wformat-truncation=1") ENDIF() IF(CMAKE_BUILD_TYPE MATCHES "Debug") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-strong") diff --git a/engine/Makefile b/engine/Makefile index 8d7285969..b0691a98e 100644 --- a/engine/Makefile +++ b/engine/Makefile @@ -1468,6 +1468,7 @@ ifneq (,$(findstring linux,$(FTE_TARGET))) endif CL_CFLAGS=-DMULTITHREAD -DDYNAMIC_SDL $(HAVE_EGL) $(HAVE_WAYLAND) -DX11QUAKE + BASELDFLAGS+=-Wl,--warn-common QCC_DIR=linqcc$(BITS) @@ -1477,7 +1478,7 @@ ifneq (,$(findstring linux,$(FTE_TARGET))) NPFTE_CFLAGS=$(NPFTECFLAGS) $(W32_CFLAGS) -DMULTITHREAD -fPIC -DDYNAMIC_LIBPNG -DDYNAMIC_LIBJPEG NPFTEB_DIR=npfte_linux$(BITS) - GLCL_OBJS=$(GL_OBJS) $(D3DGL_OBJS) $(GLQUAKE_OBJS) $(BOTLIB_OBJS) gl_vidlinuxglx.o gl_vidwayland.o gl_videgl.o snd_alsa.o snd_linux.o snd_sdl.o cd_linux.o sys_linux.o sys_linux_threads.o + GLCL_OBJS=$(GL_OBJS) $(D3DGL_OBJS) $(GLQUAKE_OBJS) $(BOTLIB_OBJS) gl_vidlinuxglx.o gl_vidwayland.o gl_videgl.o snd_pulse.o snd_alsa.o snd_linux.o snd_sdl.o cd_linux.o sys_linux.o sys_linux_threads.o GL_EXE_NAME=../$(EXE_NAME)-gl$(BITS) GLCL_EXE_NAME=../$(EXE_NAME)-glcl$(BITS) GL_LDFLAGS=$(GLLDFLAGS) $(XLDFLAGS) @@ -1485,7 +1486,7 @@ ifneq (,$(findstring linux,$(FTE_TARGET))) GLB_DIR=gl_linux$(BITS) GLCL_DIR=glcl_linux$(BITS) - VKCL_OBJS=$(GL_OBJS) $(D3DGL_OBJS) $(GLQUAKE_OBJS) $(BOTLIB_OBJS) gl_vidlinuxglx.o gl_vidwayland.o gl_videgl.o snd_alsa.o snd_linux.o snd_sdl.o cd_linux.o sys_linux.o sys_linux_threads.o + VKCL_OBJS=$(GL_OBJS) $(D3DGL_OBJS) $(GLQUAKE_OBJS) $(BOTLIB_OBJS) gl_vidlinuxglx.o gl_vidwayland.o gl_videgl.o snd_pulse.o snd_alsa.o snd_linux.o snd_sdl.o cd_linux.o sys_linux.o sys_linux_threads.o VK_EXE_NAME=../$(EXE_NAME)-vk$(BITS) VKCL_EXE_NAME=../$(EXE_NAME)-vkcl$(BITS) VK_LDFLAGS=$(GLLDFLAGS) $(XLDFLAGS) @@ -1493,7 +1494,7 @@ ifneq (,$(findstring linux,$(FTE_TARGET))) VKB_DIR=vk_linux$(BITS) VKCL_DIR=vkcl_linux$(BITS) - MCL_OBJS=$(D3DGL_OBJS) $(GLQUAKE_OBJS) $(SOFTWARE_OBJS) $(BOTLIB_OBJS) gl_vidlinuxglx.o gl_vidwayland.o gl_videgl.o snd_linux.o snd_sdl.o snd_alsa.o cd_linux.o sys_linux.o sys_linux_threads.o + MCL_OBJS=$(D3DGL_OBJS) $(GLQUAKE_OBJS) $(SOFTWARE_OBJS) $(BOTLIB_OBJS) gl_vidlinuxglx.o gl_vidwayland.o gl_videgl.o snd_linux.o snd_sdl.o snd_pulse.o snd_alsa.o cd_linux.o sys_linux.o sys_linux_threads.o M_EXE_NAME=../$(EXE_NAME)$(BITS) MCL_EXE_NAME=../$(EXE_NAME)-cl$(BITS) M_LDFLAGS=$(GL_LDFLAGS) diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 368bc77e1..c0722f69e 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -292,13 +292,8 @@ static struct // qbyte fingerprint[5*4]; //sha1 hash of accepted dtls certs } connectinfo; -quakeparms_t host_parms; - -qboolean host_initialized; // true if into command execution qboolean nomaster; -double host_frametime; -double realtime; // without any filtering or bounding double oldrealtime; // last frame run int host_framecount; diff --git a/engine/client/m_download.c b/engine/client/m_download.c index d5f864c41..56cd07a1c 100644 --- a/engine/client/m_download.c +++ b/engine/client/m_download.c @@ -310,7 +310,7 @@ void PM_ValidateAuthenticity(package_t *p) int r; char authority[MAX_QPATH], *sig; -#if 1 +#if 1//ndef _DEBUG #pragma message("Temporary code.") //this is temporary code and should be removed once everything else has been fixed. //ignore the signature (flag as accepted) for any packages with all mirrors on our own update site. diff --git a/engine/client/pr_menu.c b/engine/client/pr_menu.c index 778db8d59..44adc307e 100644 --- a/engine/client/pr_menu.c +++ b/engine/client/pr_menu.c @@ -1530,7 +1530,12 @@ void QCBUILTIN PF_isserver (pubprogfuncs_t *prinst, struct globalvars_s *pr_glob #ifdef CLIENTONLY G_FLOAT(OFS_RETURN) = false; #else - G_FLOAT(OFS_RETURN) = sv.state != ss_dead; + if (sv.state == ss_dead) + G_FLOAT(OFS_RETURN) = false; + else if (sv.allocated_client_slots == 1) + G_FLOAT(OFS_RETURN) = 0.5; + else + G_FLOAT(OFS_RETURN) = true; #endif } void QCBUILTIN PF_isdemo (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) diff --git a/engine/client/snd_dma.c b/engine/client/snd_dma.c index 6e37281eb..1a8495bbb 100644 --- a/engine/client/snd_dma.c +++ b/engine/client/snd_dma.c @@ -21,6 +21,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" +#ifdef __GNUC__ + #define fte_weakstruct __attribute__((weak)) +#else + //msvc's uninitialised symbols are always weak, so this is fine. + #define fte_weakstruct +#endif + #ifdef CSQC_DAT //for sounds following csqc ents #include "pr_common.h" @@ -561,13 +568,17 @@ static qboolean S_Speex_Init(void) #ifdef AVAIL_OPENAL extern snd_capture_driver_t OPENAL_Capture; #endif -snd_capture_driver_t DSOUND_Capture; -snd_capture_driver_t OSS_Capture; -snd_capture_driver_t SDL_Capture; +#ifdef _WIN32 +snd_capture_driver_t fte_weakstruct DSOUND_Capture; +#endif +snd_capture_driver_t fte_weakstruct OSS_Capture; +snd_capture_driver_t fte_weakstruct SDL_Capture; snd_capture_driver_t *capturedrivers[] = { +#ifdef _WIN32 &DSOUND_Capture, +#endif &SDL_Capture, &OSS_Capture, #ifdef AVAIL_OPENAL @@ -1822,12 +1833,12 @@ extern sounddriver_t XAUDIO2_Output; #ifdef AVAIL_DSOUND extern sounddriver_t DSOUND_Output; #endif -sounddriver_t SDL_Output; +sounddriver_t fte_weakstruct SDL_Output; #ifdef __linux__ -sounddriver_t ALSA_Output; -sounddriver_t Pulse_Output; +extern sounddriver_t ALSA_Output; +extern sounddriver_t Pulse_Output; #endif -sounddriver_t OSS_Output; +sounddriver_t fte_weakstruct OSS_Output; #ifdef AVAIL_OPENAL extern sounddriver_t OPENAL_Output; #endif @@ -1839,19 +1850,19 @@ extern sounddriver_t WaveOut_Output; #endif #ifdef MACOSX -sounddriver_t MacOS_AudioOutput; //prefered on mac +sounddriver_t fte_weakstruct MacOS_AudioOutput; //prefered on mac #endif #ifdef ANDROID -sounddriver_t OSL_Output; //general audio library, but android has all kinds of quirks. -sounddriver_t Droid_AudioOutput; +sounddriver_t fte_weakstruct OSL_Output; //general audio library, but android has all kinds of quirks. +sounddriver_t fte_weakstruct Droid_AudioOutput; #endif #if defined(__MORPHOS__) -sounddriver_t AHI_AudioOutput; //prefered on morphos +sounddriver_t fte_weakstruct AHI_AudioOutput; //prefered on morphos #endif #ifdef NACL extern sounddriver_t PPAPI_AudioOutput; //nacl #endif -sounddriver_t SNDIO_AudioOutput; //bsd +sounddriver_t fte_weakstruct SNDIO_AudioOutput; //bsd //in order of preference static sounddriver_t *outputdrivers[] = diff --git a/engine/client/sys_linux.c b/engine/client/sys_linux.c index 075fe536a..8cc95fd19 100644 --- a/engine/client/sys_linux.c +++ b/engine/client/sys_linux.c @@ -69,7 +69,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static int noconinput = 0; static int nostdout = 0; -int isPlugin; +extern int isPlugin; int sys_parentleft; int sys_parenttop; int sys_parentwidth; diff --git a/engine/common/com_mesh.h b/engine/common/com_mesh.h index 25895fc86..88666b034 100644 --- a/engine/common/com_mesh.h +++ b/engine/common/com_mesh.h @@ -181,6 +181,7 @@ typedef struct galiasinfo_s unsigned int mappedbones; unsigned int nummorphs; //extra data after the xyz/norm/stvect arrays const float *(QDECL *AnimateMorphs)(const struct galiasinfo_s *surf, const framestate_t *framestate); + int meshrootbone; float *baseframeofs; /*non-heirachical*/ int numbones; diff --git a/engine/common/com_phys_ode.c b/engine/common/com_phys_ode.c index 744645255..511749bfd 100644 --- a/engine/common/com_phys_ode.c +++ b/engine/common/com_phys_ode.c @@ -50,7 +50,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define BZ_Malloc malloc #define BZ_Free free #define Z_Free BZ_Free -vec3_t vec3_origin; #define VectorCompare VectorComparestatic static int VectorCompare (const vec3_t v1, const vec3_t v2) { diff --git a/engine/common/common.c b/engine/common/common.c index e4236b8fd..a923817de 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -26,13 +26,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include qboolean sys_nounload; -#ifndef HAVE_CLIENT double host_frametime; double realtime; // without any filtering or bounding qboolean host_initialized; // true if into command execution (compatability) quakeparms_t host_parms; -int host_hunklevel; -#endif //by adding 'extern' to one definition of a function in a translation unit, then the definition in that TU is NOT considered an inline definition. meaning non-inlined references in other TUs can link to it instead of their own if needed. diff --git a/engine/common/pr_bgcmd.c b/engine/common/pr_bgcmd.c index 52d809e8c..a3ad6a196 100644 --- a/engine/common/pr_bgcmd.c +++ b/engine/common/pr_bgcmd.c @@ -3424,9 +3424,9 @@ void QCBUILTIN PF_findradius_list (pubprogfuncs_t *prinst, struct globalvars_s * { world_t *w = prinst->parms->user; wedict_t *ent; - float rad; + pvec_t rad; float *org; - vec3_t eorg; + pvec3_t eorg; int i, j; wedict_t **nearent; vec3_t mins, maxs; diff --git a/engine/qclib/decomp.c b/engine/qclib/decomp.c index 6f67f7578..35098f048 100644 --- a/engine/qclib/decomp.c +++ b/engine/qclib/decomp.c @@ -3104,7 +3104,7 @@ void DecompileDecompileFunctions(const char *origcopyright) dfunction_t *d; pbool bogusname; vfile_t *f = NULL; - char fname[512]; + char fname[1024]; int lastglob = 1; int lastfileofs = 0; QCC_ddef_t *def; diff --git a/engine/qclib/initlib.c b/engine/qclib/initlib.c index 8c13e86fa..bff140bdf 100644 --- a/engine/qclib/initlib.c +++ b/engine/qclib/initlib.c @@ -691,6 +691,7 @@ func_t PDECL PR_FindFunc(pubprogfuncs_t *ppf, const char *funcname, progsnum_t p return *(int *)&ps->globals[var16->ofs]; case PST_QTEST: case PST_FTE32: + case PST_UHEXEN2: var32 = ED_FindTypeGlobalFromProgs32(progfuncs, ps, funcname, ev_function); //we must make sure we actually have a function def - 'light' is defined as a field before it is defined as a function. if (!var32) return (f - ps->functions) | (pnum << 24); @@ -738,6 +739,7 @@ static void PDECL QC_FindPrefixedGlobals(pubprogfuncs_t *ppf, int pnum, char *pr break; case PST_QTEST: case PST_FTE32: + case PST_UHEXEN2: for (i=1 ; inumglobaldefs ; i++) { def32 = &pr_progstate[pnum].globaldefs32[i]; @@ -788,6 +790,7 @@ eval_t *PDECL PR_FindGlobal(pubprogfuncs_t *ppf, const char *globname, progsnum_ return (eval_t *)&cp->globals[var16->ofs]; case PST_QTEST: case PST_FTE32: + case PST_UHEXEN2: if (!(var32 = ED_FindGlobalFromProgs32(progfuncs, cp, globname))) return NULL; diff --git a/engine/qclib/pr_comp.h b/engine/qclib/pr_comp.h index 60cadd72c..bcee4d617 100644 --- a/engine/qclib/pr_comp.h +++ b/engine/qclib/pr_comp.h @@ -586,6 +586,8 @@ typedef struct #define PROG_EXTENDEDVERSION 7 #define PROG_SECONDARYVERSION16 ((('1'<<0)|('F'<<8)|('T'<<16)|('E'<<24))^(('P'<<0)|('R'<<8)|('O'<<16)|('G'<<24))) //something unlikly and still meaningful (to me) #define PROG_SECONDARYVERSION32 ((('1'<<0)|('F'<<8)|('T'<<16)|('E'<<24))^(('3'<<0)|('2'<<8)|('B'<<16)|(' '<<24))) //something unlikly and still meaningful (to me) +#define PROG_SECONDARYUHEXEN2 ((('U'<<0)|('H'<<8)|('2'<<16)|('7'<<24))) //something unlikly and still meaningful (to me) +#define PROG_SECONDARYKKQWSV ((('K'<<0)|('K'<<8)|('Q'<<16)|('W'<<24))) //something unlikly and still meaningful (to me) typedef struct { int version; diff --git a/engine/qclib/pr_edict.c b/engine/qclib/pr_edict.c index 25984bbcc..6d9b37fbc 100644 --- a/engine/qclib/pr_edict.c +++ b/engine/qclib/pr_edict.c @@ -355,10 +355,12 @@ unsigned int ED_FindGlobalOfs (progfuncs_t *progfuncs, char *name) return d16?d16->ofs:0; case PST_QTEST: case PST_FTE32: + case PST_UHEXEN2: d32 = ED_FindGlobal32(progfuncs, name); return d32?d32->ofs:0; + default: + externs->Sys_Error("ED_FindGlobalOfs - bad struct type"); } - externs->Sys_Error("ED_FindGlobalOfs - bad struct type"); return 0; } @@ -452,12 +454,14 @@ unsigned int *ED_FindGlobalOfsFromProgs (progfuncs_t *progfuncs, progstate_t *ps return &pos; case PST_QTEST: case PST_FTE32: + case PST_UHEXEN2: def32 = ED_FindTypeGlobalFromProgs32(progfuncs, ps, name, type); if (!def32) return NULL; return &def32->ofs; + default: + externs->Sys_Error("ED_FindGlobalOfsFromProgs - bad struct type"); } - externs->Sys_Error("ED_FindGlobalOfsFromProgs - bad struct type"); return 0; } @@ -914,6 +918,7 @@ char *PR_GlobalString (progfuncs_t *progfuncs, int ofs, struct QCC_type_s **type break; case PST_QTEST: case PST_FTE32: + case PST_UHEXEN2: def32 = ED_GlobalAtOfs32(progfuncs, ofs); break; default: @@ -974,6 +979,7 @@ char *PR_GlobalStringNoContents (progfuncs_t *progfuncs, int ofs) break; case PST_QTEST: case PST_FTE32: + case PST_UHEXEN2: def32 = ED_GlobalAtOfs32(progfuncs, ofs); if (def32) nameofs = def32->s_name; @@ -1591,6 +1597,7 @@ char *ED_WriteGlobals(progfuncs_t *progfuncs, char *buf, size_t *bufofs, size_t break; case PST_QTEST: case PST_FTE32: + case PST_UHEXEN2: for (i=0 ; inumglobaldefs ; i++) { size_t nlen; @@ -2162,6 +2169,7 @@ int PDECL PR_LoadEnts(pubprogfuncs_t *ppf, const char *file, void *ctx, void (PD break; case PST_QTEST: case PST_FTE32: + case PST_UHEXEN2: if (!(d32 = ED_FindGlobal32(progfuncs, qcc_token))) { externs->Printf("global value %s not found\n", qcc_token); @@ -2277,6 +2285,7 @@ int PDECL PR_LoadEnts(pubprogfuncs_t *ppf, const char *file, void *ctx, void (PD break; case PST_QTEST: case PST_FTE32: + case PST_UHEXEN2: if (!(d32 = ED_FindGlobal32(progfuncs, qcc_token))) { externs->Printf("global value %s not found\n", qcc_token); @@ -2722,8 +2731,21 @@ retry: // externs->Printf("Opening 32bit fte progs file \"%s\"\n", filename); current_progstate->structtype = PST_FTE32; } + else if (pr_progs->secondaryversion == PROG_SECONDARYUHEXEN2) + { +// externs->Printf("Opening uhexen2 progs file \"%s\"\n", filename); + current_progstate->structtype = PST_UHEXEN2; + pr_progs->version = PROG_VERSION; //not fte. + } + else if (pr_progs->secondaryversion == PROG_SECONDARYKKQWSV) + { +// externs->Printf("Opening KK7 progs file \"%s\"\n", filename); + current_progstate->structtype = PST_KKQWSV; //KK progs. Yuck. Disabling saving would be a VERY good idea. + pr_progs->version = PROG_VERSION; //not fte. + } else { + externs->Printf ("%s has no v7 verification code, assuming kkqwsv format\n", filename); // externs->Printf("Opening KK7 progs file \"%s\"\n", filename); current_progstate->structtype = PST_KKQWSV; //KK progs. Yuck. Disabling saving would be a VERY good idea. pr_progs->version = PROG_VERSION; //not fte. @@ -2806,6 +2828,7 @@ retry: len=sizeof(dstatement16_t)*pr_progs->numstatements; break; case PST_FTE32: + case PST_UHEXEN2: len=sizeof(dstatement32_t)*pr_progs->numstatements; break; default: @@ -2825,6 +2848,7 @@ retry: len=sizeof(ddef16_t)*pr_progs->numglobaldefs; break; case PST_FTE32: + case PST_UHEXEN2: len=sizeof(ddef32_t)*pr_progs->numglobaldefs; break; default: @@ -2844,6 +2868,7 @@ retry: len=sizeof(ddef16_t)*pr_progs->numglobaldefs; break; case PST_FTE32: + case PST_UHEXEN2: len=sizeof(ddef32_t)*pr_progs->numglobaldefs; break; default: @@ -2988,6 +3013,7 @@ retry: case PST_KKQWSV: case PST_DEFAULT: case PST_FTE32: + case PST_UHEXEN2: pr_cp_functions = PRHunkAlloc(progfuncs, sizeof(*pr_cp_functions)*pr_progs->numfunctions, "mfunctions"); for (i=0,fnc2=pr_cp_functions; inumfunctions; i++, fnc2++) { @@ -3166,6 +3192,49 @@ retry: QC_RegisterFieldVar(&progfuncs->funcs, type, pr_fielddefs32[i].s_name+pr_strings-stringadjust, -1, pr_fielddefs32[i].ofs); } break; + case PST_UHEXEN2: + for (i=0 ; inumglobaldefs ; i++) + { + pr_globaldefs32[i].type = (unsigned int)PRLittleLong (pr_globaldefs32[i].type)>>16; +#ifndef NOENDIAN + pr_globaldefs32[i].ofs = PRLittleLong (pr_globaldefs32[i].ofs); + pr_globaldefs32[i].s_name = (string_t)PRLittleLong ((long)pr_globaldefs32[i].s_name); +#endif + pr_globaldefs32[i].s_name += stringadjust; + } + + for (i=0 ; inumfielddefs ; i++) + { + pr_fielddefs32[i].type = (unsigned int)PRLittleLong (pr_fielddefs32[i].type)>>16; +#ifndef NOENDIAN + pr_fielddefs32[i].ofs = PRLittleLong (pr_fielddefs32[i].ofs); + pr_fielddefs32[i].s_name = (string_t)PRLittleLong ((long)pr_fielddefs32[i].s_name); +#endif + + if (reorg) + { + if (pr_types) + type = pr_types[pr_fielddefs32[i].type & ~(DEF_SHARED|DEF_SAVEGLOBAL)].type; + else + type = pr_fielddefs32[i].type & ~(DEF_SHARED|DEF_SAVEGLOBAL); + if (progfuncs->funcs.fieldadjust && !prinst.pr_typecurrent) //we need to make sure all fields appear in their original place. + QC_RegisterFieldVar(&progfuncs->funcs, type, pr_fielddefs32[i].s_name+pr_strings, 4*(pr_fielddefs32[i].ofs+progfuncs->funcs.fieldadjust), -1); + else if (type == ev_vector) + QC_RegisterFieldVar(&progfuncs->funcs, type, pr_fielddefs32[i].s_name+pr_strings, -1, pr_fielddefs32[i].ofs); + } + pr_fielddefs32[i].s_name += stringadjust; + } + if (reorg && !(progfuncs->funcs.fieldadjust && !prinst.pr_typecurrent)) + for (i=0 ; inumfielddefs ; i++) + { + if (pr_types) + type = pr_types[pr_fielddefs32[i].type & ~(DEF_SHARED|DEF_SAVEGLOBAL)].type; + else + type = pr_fielddefs32[i].type & ~(DEF_SHARED|DEF_SAVEGLOBAL); + if (type != ev_vector) + QC_RegisterFieldVar(&progfuncs->funcs, type, pr_fielddefs32[i].s_name+pr_strings-stringadjust, -1, pr_fielddefs32[i].ofs); + } + break; default: externs->Sys_Error("Bad struct type"); } @@ -3209,6 +3278,19 @@ retry: PR_CleanUpStatements16(progfuncs, st16, hexencalling); break; + case PST_UHEXEN2: + hexencalling = true; + for (i=0 ; inumstatements ; i++) + { + pr_statements32[i].op = (unsigned int)PRLittleLong(pr_statements32[i].op)>>16; +#ifndef NOENDIAN + pr_statements32[i].a = PRLittleLong(pr_statements32[i].a); + pr_statements32[i].b = PRLittleLong(pr_statements32[i].b); + pr_statements32[i].c = PRLittleLong(pr_statements32[i].c); +#endif + } + PR_CleanUpStatements32(progfuncs, pr_statements32, hexencalling); + break; case PST_KKQWSV: case PST_FTE32: for (i=0 ; inumstatements ; i++) @@ -3319,6 +3401,7 @@ retry: case PST_QTEST: //not likely to need this case PST_KKQWSV: //fixme... case PST_FTE32: //fingers crossed... + case PST_UHEXEN2: break; } } @@ -3375,6 +3458,7 @@ retry: break; case PST_QTEST: case PST_FTE32: + case PST_UHEXEN2: for (i=0 ; inumglobaldefs ; i++) { if (pr_types) @@ -3485,6 +3569,7 @@ retry: case PST_QTEST: case PST_KKQWSV: break; //cannot happen anyway. + case PST_UHEXEN2: case PST_FTE32: if (pr_progs->version == PROG_EXTENDEDVERSION && pr_progs->numbodylessfuncs) { diff --git a/engine/qclib/pr_exec.c b/engine/qclib/pr_exec.c index 23a42d792..f8f92896b 100644 --- a/engine/qclib/pr_exec.c +++ b/engine/qclib/pr_exec.c @@ -1197,6 +1197,7 @@ int PDECL PR_ToggleBreakpoint(pubprogfuncs_t *ppf, const char *filename, int lin break; case PST_KKQWSV: case PST_FTE32: + case PST_UHEXEN2: op = ((dstatement32_t*)cp->statements + i)->op; break; default: @@ -1239,6 +1240,7 @@ int PDECL PR_ToggleBreakpoint(pubprogfuncs_t *ppf, const char *filename, int lin break; case PST_KKQWSV: case PST_FTE32: + case PST_UHEXEN2: ((dstatement32_t*)cp->statements + i)->op = op; break; default: @@ -1271,6 +1273,7 @@ int PDECL PR_ToggleBreakpoint(pubprogfuncs_t *ppf, const char *filename, int lin break; case PST_KKQWSV: case PST_FTE32: + case PST_UHEXEN2: op = ((dstatement32_t*)cp->statements + i)->op; break; default: @@ -1312,6 +1315,7 @@ int PDECL PR_ToggleBreakpoint(pubprogfuncs_t *ppf, const char *filename, int lin break; case PST_KKQWSV: case PST_FTE32: + case PST_UHEXEN2: ((dstatement32_t*)cp->statements + i)->op = op; break; default: @@ -1381,6 +1385,7 @@ static const char *lastfile = NULL; { switch(pr_progstate[pn].structtype) { + case PST_UHEXEN2: case PST_FTE32: case PST_KKQWSV: { @@ -1781,6 +1786,7 @@ static void PR_ExecuteCode (progfuncs_t *progfuncs, int s) continue; case PST_KKQWSV: case PST_FTE32: + case PST_UHEXEN2: s = PR_ExecuteCode32(progfuncs, s, &runaway); if (s == -1) return; diff --git a/engine/qclib/pr_multi.c b/engine/qclib/pr_multi.c index 4aa6626e2..bc45b1eca 100644 --- a/engine/qclib/pr_multi.c +++ b/engine/qclib/pr_multi.c @@ -475,6 +475,7 @@ void PDECL QC_AddSharedFieldVar(pubprogfuncs_t *ppf, int num, char *stringtable) return; case PST_FTE32: case PST_QTEST: + case PST_UHEXEN2: { ddef32_t *gd = pr_globaldefs32; ddef32_t *fld = pr_fielddefs32; diff --git a/engine/qclib/progsint.h b/engine/qclib/progsint.h index 4cce961f9..4b126a3b2 100644 --- a/engine/qclib/progsint.h +++ b/engine/qclib/progsint.h @@ -327,6 +327,7 @@ typedef enum PST_FTE32, //everything 32bit PST_KKQWSV, //32bit statements, 16bit globaldefs. NO SAVED GAMES. PST_QTEST, //16bit statements, 32bit globaldefs(other differences converted on load) + PST_UHEXEN2,//everything 32bit like fte's without a header, but with pre-padding rather than post-extended (little-endian) types. } progstructtype_t; #ifndef COMPILER diff --git a/engine/qclib/qcc.h b/engine/qclib/qcc.h index 93a09bd3b..a2d1fa60b 100644 --- a/engine/qclib/qcc.h +++ b/engine/qclib/qcc.h @@ -84,7 +84,7 @@ extern int MAX_CONSTANTS; #define MAXCONSTANTPARAMLENGTH 32 #define MAXCONSTANTPARAMS 32 -typedef enum {QCF_STANDARD, QCF_HEXEN2, QCF_DARKPLACES, QCF_FTE, QCF_FTEDEBUG, QCF_FTEH2, QCF_KK7, QCF_QTEST} qcc_targetformat_t; +typedef enum {QCF_STANDARD, QCF_HEXEN2, QCF_UHEXEN2, QCF_DARKPLACES, QCF_FTE, QCF_FTEDEBUG, QCF_FTEH2, QCF_KK7, QCF_QTEST} qcc_targetformat_t; extern qcc_targetformat_t qcc_targetformat; void QCC_OPCodeSetTarget(qcc_targetformat_t targfmt); diff --git a/engine/qclib/qcc_pr_comp.c b/engine/qclib/qcc_pr_comp.c index ac6ac7843..50a566985 100644 --- a/engine/qclib/qcc_pr_comp.c +++ b/engine/qclib/qcc_pr_comp.c @@ -1179,6 +1179,7 @@ static pbool QCC_OPCodeValidForTarget(qcc_targetformat_t targfmt, QCC_opcode_t * if (num < OP_MULSTORE_F) return true; return false; + case QCF_UHEXEN2: case QCF_HEXEN2: if (num >= OP_SWITCH_V && num <= OP_SWITCH_FNC) //these were assigned numbers but were never actually implemtented in standard h2. return false; @@ -6270,7 +6271,7 @@ static QCC_sref_t QCC_PR_ParseFunctionCall (QCC_ref_t *funcref) //warning, the f if (QCC_OPCodeValid(&pr_opcodes[OP_RAND0])) { - if(qcc_targetformat != QCF_HEXEN2) + if(qcc_targetformat != QCF_HEXEN2 && qcc_targetformat != QCF_UHEXEN2) out = QCC_GetTemp(type_float); else { //hexen2 requires the output be def_ret @@ -6341,7 +6342,7 @@ static QCC_sref_t QCC_PR_ParseFunctionCall (QCC_ref_t *funcref) //warning, the f if (QCC_OPCodeValid(&pr_opcodes[OP_RANDV0])) { - if(qcc_targetformat != QCF_HEXEN2) + if(qcc_targetformat != QCF_HEXEN2 && qcc_targetformat != QCF_UHEXEN2) out = QCC_GetTemp(type_vector); else { //hexen2 requires the output be def_ret @@ -11218,7 +11219,7 @@ void QCC_PR_ParseStatement (void) QCC_PR_ParseWarning (WARN_FTE_SPECIFIC, "if !() is specific to fteqcc"); negate = 2; } - else if (negate && qcc_targetformat != QCF_HEXEN2 && qcc_targetformat != QCF_FTEH2) + else if (negate && qcc_targetformat != QCF_HEXEN2 && qcc_targetformat != QCF_UHEXEN2 && qcc_targetformat != QCF_FTEH2) QCC_PR_ParseWarning (WARN_FTE_SPECIFIC, "if not() is specific to fteqcc or hexen2"); QCC_PR_Expect ("("); @@ -13941,7 +13942,7 @@ QCC_def_t *QCC_PR_DummyDef(QCC_type_t *type, const char *name, QCC_function_t *s KEYWORD(continue); KEYWORD(state); KEYWORD(string); - if (qcc_targetformat != QCF_HEXEN2) + if (qcc_targetformat != QCF_HEXEN2 && qcc_targetformat != QCF_UHEXEN2) KEYWORD(float); //hmm... hexen2 requires this... KEYWORD(entity); KEYWORD(vector); diff --git a/engine/qclib/qcc_pr_lex.c b/engine/qclib/qcc_pr_lex.c index 3cbb4c1ec..c4a9e91c4 100644 --- a/engine/qclib/qcc_pr_lex.c +++ b/engine/qclib/qcc_pr_lex.c @@ -1327,6 +1327,8 @@ static pbool QCC_PR_Precompiler(void) QCC_COM_Parse(msg); if (!QC_strcasecmp(qcc_token, "H2") || !QC_strcasecmp(qcc_token, "HEXEN2")) newtype = QCF_HEXEN2; + else if (!QC_strcasecmp(qcc_token, "UHEXEN2")) + newtype = QCF_UHEXEN2; else if (!QC_strcasecmp(qcc_token, "KK7")) newtype = QCF_KK7; else if (!QC_strcasecmp(qcc_token, "DP") || !QC_strcasecmp(qcc_token, "DARKPLACES")) @@ -1351,9 +1353,9 @@ static pbool QCC_PR_Precompiler(void) if (numstatements > 1) { - if ((qcc_targetformat == QCF_HEXEN2 || qcc_targetformat == QCF_FTEH2) && (newtype != QCF_HEXEN2 && newtype != QCF_FTEH2)) + if ((qcc_targetformat == QCF_HEXEN2 || qcc_targetformat == QCF_UHEXEN2 || qcc_targetformat == QCF_FTEH2) && (newtype != QCF_HEXEN2 && newtype != QCF_UHEXEN2 && newtype != QCF_FTEH2)) QCC_PR_ParseWarning(WARN_BADTARGET, "Cannot switch from hexen2 target \'%s\' after the first statement. Ignored.", msg); - if ((newtype == QCF_HEXEN2 || newtype == QCF_FTEH2) && (qcc_targetformat != QCF_HEXEN2 && qcc_targetformat != QCF_FTEH2)) + if ((newtype == QCF_HEXEN2 || newtype == QCF_UHEXEN2 || newtype == QCF_FTEH2) && (qcc_targetformat != QCF_HEXEN2 && qcc_targetformat != QCF_UHEXEN2 && qcc_targetformat != QCF_FTEH2)) QCC_PR_ParseWarning(WARN_BADTARGET, "Cannot switch to hexen2 target \'%s\' after the first statement. Ignored.", msg); } diff --git a/engine/qclib/qccguistuff.c b/engine/qclib/qccguistuff.c index 69cf71b71..d981607b4 100644 --- a/engine/qclib/qccguistuff.c +++ b/engine/qclib/qccguistuff.c @@ -36,7 +36,6 @@ vfile_t *qcc_vfiles; extern QCC_def_t *sourcefilesdefs[]; extern int sourcefilesnumdefs; -int qccpersisthunk = 1; int Grep(const char *filename, const char *string) { int foundcount = 0; @@ -507,6 +506,7 @@ int GUI_ParseCommandLine(const char *args, pbool keepsrcanddir) int l, p; const char *next; int mode = 0; + extern int qccpersisthunk; if (!*args) { @@ -848,6 +848,8 @@ int GUI_ParseCommandLine(const char *args, pbool keepsrcanddir) parameters[paramlen-1] = '\0'; else *parameters = '\0'; + + qccpersisthunk = (mode!=1); return mode; } diff --git a/engine/qclib/qccmain.c b/engine/qclib/qccmain.c index 07f7e0fda..f7d605e46 100644 --- a/engine/qclib/qccmain.c +++ b/engine/qclib/qccmain.c @@ -409,6 +409,7 @@ struct { {QCF_STANDARD, "quakec"}, {QCF_HEXEN2, "hexen2"}, {QCF_HEXEN2, "h2"}, + {QCF_UHEXEN2, "uhexen2"}, {QCF_KK7, "kkqwsv"}, {QCF_KK7, "kk7"}, {QCF_KK7, "bigprogs"}, @@ -1443,8 +1444,16 @@ static pbool QCC_WriteData (int crc) } else if (numpr_globals > 65530) { - externs->Printf("Forcing target to FTE32 due to numpr_globals\n"); - outputsttype = PST_FTE32; + if (qcc_targetformat == QCF_HEXEN2) + { + externs->Printf("Forcing target to uHexen2 due to numpr_globals\n"); + outputsttype = PST_UHEXEN2; + } + else + { + externs->Printf("Forcing target to FTE32 due to numpr_globals\n"); + outputsttype = PST_FTE32; + } } else if (qcc_targetformat == QCF_FTEH2) { @@ -1473,7 +1482,7 @@ static pbool QCC_WriteData (int crc) if (qcc_targetformat == QCF_FTEDEBUG) debugtarget = true; - if (outputsttype != PST_FTE32) + if (outputsttype != PST_FTE32 && outputsttype != PST_UHEXEN2) { if (bigjumps) { @@ -1513,10 +1522,20 @@ static pbool QCC_WriteData (int crc) { if (qcc_targetformat == QCF_DARKPLACES) externs->Printf("DarkPlaces or FTE will be required\n"); + else if (outputsttype == PST_UHEXEN2) + externs->Printf("FTE or uHexen2 will be required\n"); else externs->Printf("FTE's QCLib will be required\n"); } break; + case QCF_UHEXEN2: + debugtarget = false; + outputsttype = PST_UHEXEN2; + if (verbose) + externs->Printf("uHexen2 will be required\n"); + if (numpr_globals < 65535) + externs->Printf("Warning: outputting 32 uHexen2 format when 16bit would suffice\n"); + break; case QCF_KK7: if (bodylessfuncs) externs->Printf("Warning: There are some functions without bodies.\n"); @@ -1565,6 +1584,7 @@ static pbool QCC_WriteData (int crc) funcdatasize = numfunctions*sizeof(*funcs); } break; + case PST_UHEXEN2: case PST_DEFAULT: case PST_KKQWSV: case PST_FTE32: @@ -2017,7 +2037,7 @@ strofs = (strofs+3)&~3; progs.ofs_statements = SafeSeek (h, 0, SEEK_CUR); progs.numstatements = numstatements; - if (qcc_targetformat == QCF_HEXEN2 || qcc_targetformat == QCF_FTEH2) + if (qcc_targetformat == QCF_HEXEN2 || qcc_targetformat == QCF_UHEXEN2 || qcc_targetformat == QCF_FTEH2) { for (i=0 ; iofs:0) + statements[i].a.ofs); + statements32[i].b = PRLittleLong((statements[i].b.sym?statements[i].b.sym->ofs:0) + statements[i].b.ofs); + statements32[i].c = PRLittleLong((statements[i].c.sym?statements[i].c.sym->ofs:0) + statements[i].c.ofs); + + if (verbose >= VERBOSE_DEBUGSTATEMENTS) + externs->Printf("code: %s:%i: @%i %s %i %i %i\n", QCC_FileForStatement(i), statements[i].linenum, i, pr_opcodes[statements[i].op].name, statements32[i].a, statements32[i].b, statements32[i].c); + } + + SafeWrite (h, statements32, numstatements*sizeof(QCC_dstatement32_t)); + } + break; case PST_KKQWSV: case PST_FTE32: { @@ -2227,6 +2264,52 @@ strofs = (strofs+3)&~3; fields[i].s_name = PRLittleLong (fields[i].s_name); } + if (progs.blockscompressed&4) + { + SafeWrite (h, &len, sizeof(int)); //save for later + len = QC_encode(progfuncs, numfielddefs*sizeof(QCC_ddef_t), 2, (char *)fields, h); //write + i = SafeSeek (h, 0, SEEK_CUR); + SafeSeek(h, progs.ofs_fielddefs, SEEK_SET);//seek back + len = PRLittleLong(len); + SafeWrite (h, &len, sizeof(int)); //write size. + SafeSeek(h, i, SEEK_SET); + } + else + SafeWrite (h, fields, numfielddefs*sizeof(QCC_ddef_t)); + break; + case PST_UHEXEN2: + progs.ofs_globaldefs = SafeSeek (h, 0, SEEK_CUR); + progs.numglobaldefs = numglobaldefs; + for (i=0 ; iPrintf("Compile finished: %s (id format)\n", destfile); break; case QCF_HEXEN2: - externs->Printf("Compile finished: %s (hexen2 format)\n", destfile); + case QCF_UHEXEN2: + if (progs.version == PROG_VERSION) + externs->Printf("Compile finished: %s (hexen2 format)\n", destfile); + else + externs->Printf("Compile finished: %s (uhexen2 format)\n", destfile); break; case QCF_DARKPLACES: externs->Printf("Compile finished: %s (patched-dp format)\n", destfile); @@ -3413,7 +3502,7 @@ static unsigned short QCC_PR_WriteProgdefs (char *filename) // print global vars until the first field is defined ADD_CRC("\n/* "); - if (qcc_targetformat == QCF_HEXEN2 || qcc_targetformat == QCF_FTEH2) + if (qcc_targetformat == QCF_HEXEN2 || qcc_targetformat == QCF_UHEXEN2 || qcc_targetformat == QCF_FTEH2) EAT_CRC("generated by hcc, do not modify"); else EAT_CRC("file generated by qcc, do not modify"); @@ -4485,7 +4574,7 @@ static void QCC_SetDefaultProperties (void) { qcc_targetformat_t targ; if (QCC_CheckParm ("-h2")) - targ = QCF_HEXEN2; + targ = QCF_HEXEN2; else if (QCC_CheckParm ("-fte")) targ = QCF_FTE; else if (QCC_CheckParm ("-fteh2")) @@ -4521,7 +4610,7 @@ static void QCC_SetDefaultProperties (void) qccwarningaction[WARN_IDENTICALPRECOMPILER] = WA_IGNORE; qccwarningaction[WARN_DENORMAL] = WA_ERROR; //DAZ provides a speedup on modern machines, so any engine compiled for sse2+ will have problems with denormals, so make their use look serious. - if (qcc_targetformat == QCF_HEXEN2 || qcc_targetformat == QCF_FTEH2) + if (qcc_targetformat == QCF_HEXEN2 || qcc_targetformat == QCF_UHEXEN2 || qcc_targetformat == QCF_FTEH2) qccwarningaction[WARN_CASEINSENSITIVEFRAMEMACRO] = WA_IGNORE; //hexenc consides these fair game. if (QCC_CheckParm ("-Fqccx")) @@ -4534,7 +4623,7 @@ static void QCC_SetDefaultProperties (void) QCC_PR_CommandLinePrecompilerOptions(); - if (qcc_targetformat == QCF_HEXEN2 || qcc_targetformat == QCF_FTEH2) //force on the thinktime keyword if hexen2 progs. + if (qcc_targetformat == QCF_HEXEN2 || qcc_targetformat == QCF_UHEXEN2 || qcc_targetformat == QCF_FTEH2) //force on the thinktime keyword if hexen2 progs. { keyword_thinktime = true; //thinktime self : 0.1; keyword_until = true; //until(cond) {code}; or do{code}until(cond); diff --git a/engine/qclib/qcctui.c b/engine/qclib/qcctui.c index c0842ff5f..e01c6a86f 100644 --- a/engine/qclib/qcctui.c +++ b/engine/qclib/qcctui.c @@ -124,6 +124,7 @@ int main (int argc, const char **argv) #else pbool writelog = false; //other systems are sane. #endif + int colours = 2; //auto progexterns_t ext; progfuncs_t funcs; progfuncs = &funcs; @@ -136,8 +137,27 @@ int main (int argc, const char **argv) funcs.funcs.parms->Printf = logprintf; funcs.funcs.parms->Sys_Error = Sys_Error; + for (i = 0; i < argc; i++) + { + if (!argv[i]) + continue; + if (!strcmp(argv[i], "-log")) + writelog = true; + else if (!strcmp(argv[i], "-nolog")) + writelog = false; + + //arg consistency with ls + else if (!strcmp(argv[i], "--color=always") || !strcmp(argv[i], "--color")) + colours = 1; + else if (!strcmp(argv[i], "--color=never")) + colours = 0; + else if (!strcmp(argv[i], "--color=auto")) + colours = 2; + } #if defined(__linux__) || defined(__unix__) - if (isatty(STDOUT_FILENO)) + if (colours == 2) + colours = isatty(STDOUT_FILENO); + if (colours) { //only use colours if its a tty, and not if we're redirected. col_none = "\e[0;m"; //reset to white col_error = "\e[0;31m"; //red @@ -148,17 +168,10 @@ int main (int argc, const char **argv) //col_ = "\e[0;36m"; //cyan col_location = "\e[0;1;37m"; //bright white } +#else + (void)colours; #endif - for (i = 0; i < argc; i++) - { - if (!argv[i]) - continue; - if (!strcmp(argv[i], "-log")) - writelog = true; - else if (!strcmp(argv[i], "-nolog")) - writelog = false; - } logfile = writelog?fopen("fteqcc.log", "wt"):false; if (logfile) diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index bed139eda..d76c88d05 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -31,14 +31,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define INVIS_CHAR2 (char)138 #define INVIS_CHAR3 (char)160 -#ifndef HAVE_CLIENT -double host_frametime; -double realtime; // without any filtering or bounding -qboolean host_initialized; // true if into command execution (compatability) -quakeparms_t host_parms; -int host_hunklevel; -#endif - client_t *host_client; // current client void CvarPostfixKMG(cvar_t *v, char *oldval) diff --git a/plugins/ezhud/ezquakeisms.c b/plugins/ezhud/ezquakeisms.c index 9d0afecb2..bb027c13d 100644 --- a/plugins/ezhud/ezquakeisms.c +++ b/plugins/ezhud/ezquakeisms.c @@ -8,6 +8,10 @@ plugclientfuncs_t *clientfuncs; plugfsfuncs_t *filefuncs; pluginputfuncs_t *inputfuncs; +struct ezcl_s cl; +struct ezcls_s cls; +struct ezvid_s vid; + int sb_lines; float scr_con_current; int sb_showteamscores; diff --git a/plugins/ezhud/ezquakeisms.h b/plugins/ezhud/ezquakeisms.h index cf5cddbdd..c85927e66 100644 --- a/plugins/ezhud/ezquakeisms.h +++ b/plugins/ezhud/ezquakeisms.h @@ -30,12 +30,12 @@ extern pluginputfuncs_t *inputfuncs; #define Q_strdup strdup #define Q_free free #define Q_rint(x) ((int)(x+0.5)) -#define Q_atoi atoi -#define strlcpy Q_strlcpy -#define strlcat Q_strlcat - -#undef mpic_t -#define mpic_t void +#define Q_atoi atoi +#define strlcpy Q_strlcpy +#define strlcat Q_strlcat + +#undef mpic_t +#define mpic_t void #define MV_VIEWS 4 @@ -59,7 +59,7 @@ extern cvar_t *cl_multiview; #define cl plugcl #define player_info_t plugclientinfo_t -struct { +extern struct ezcl_s{ int intermission; int teamplay; int deathmatch; @@ -79,7 +79,7 @@ struct { int splitscreenview; } cl; -struct { +extern struct ezcls_s{ int state; float min_fps; float fps; @@ -88,7 +88,7 @@ struct { qbool mvdplayback; int demoplayback; } cls; -struct { +extern struct ezvid_s{ int width; int height; // float displayFrequency; diff --git a/plugins/models/gltf.c b/plugins/models/gltf.c index e73897c5a..b4b897e53 100644 --- a/plugins/models/gltf.c +++ b/plugins/models/gltf.c @@ -2392,6 +2392,7 @@ static qboolean GLTF_ProcessMesh(gltf_t *gltf, json_t *meshid, int basebone, dou GLTF_AccessorToDataF(gltf, surf->numverts, countof(surf->ofs_skel_norm[0]), &morph_norm[i], surf->ofs_skel_norm+offset); //if no normals, normals should be flat (fragment shader or unwelding the verts...) GLTF_AccessorToTangents(gltf, surf->ofs_skel_norm+offset, surf->numverts, &morph_tang[i], surf->ofs_skel_svect+offset, surf->ofs_skel_tvect+offset); } + surf->meshrootbone = basebone; //needed for morph anims surf->ofs_st_array = GLTF_AccessorToDataF(gltf, surf->numverts, countof(surf->ofs_st_array[0]), &tc_0, NULL); if (tc_1.data) @@ -3053,13 +3054,12 @@ struct galiasanimation_gltf_s struct gltf_animsampler rot,scale,trans,morph; } bone[1]; }; -cvar_t temp1; static const float *QDECL GLTF_AnimateMorphs(const galiasinfo_t *surf, const framestate_t *framestate) { static float morphs[MAX_MORPHWEIGHTS]; float imorphs[MAX_MORPHWEIGHTS], *src; size_t influence, m; - int bone = temp1.ival; + int bone = surf->meshrootbone; const struct galiasanimation_gltf_s *a; const struct framestateregion_s *fg = &framestate->g[FS_REG]; memset(morphs, 0, sizeof(morphs[0])*surf->nummorphs);