From c1e991f31c26371907111ce84da842f71d6497cf Mon Sep 17 00:00:00 2001 From: Spoike Date: Mon, 29 Dec 2014 02:35:10 +0000 Subject: [PATCH] hide console while updating packages. fix rate indicator with http downloads. fix gamedir change crash. force r_shadow_realtime_world_lightmaps to 0 if there are no rtlights on the map (to work around TF/etc maps where such 'useless' entities got stripped). tweak profile lists to be slightly more verbose. add extra parms to fteextensions.qc, so that people realise that fte actually supports that. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4808 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/Makefile | 37 ++++++++++++++++++++----------------- engine/client/cl_main.c | 8 ++++++-- engine/client/cl_screen.c | 5 +++-- engine/client/console.c | 17 ++++++++++++++--- engine/common/common.c | 3 ++- engine/common/cvar.c | 15 +++++++++++++++ engine/common/cvar.h | 2 ++ engine/common/fs.c | 14 +++++--------- engine/gl/gl_shadow.c | 6 ++++++ engine/http/httpclient.c | 20 ++++++++++++++++++++ engine/qclib/initlib.c | 7 ++++++- engine/server/pr_cmds.c | 5 ++++- 12 files changed, 103 insertions(+), 36 deletions(-) diff --git a/engine/Makefile b/engine/Makefile index d1ef57780..9a8da1f66 100644 --- a/engine/Makefile +++ b/engine/Makefile @@ -121,6 +121,23 @@ ifeq ($(DROID_ARCH),) DROID_ARCH=armeabi endif ifeq ($(FTE_TARGET),droid) + DROID_API_LEVEL=4 + + ifeq ($(DROID_ARCH),x86) + DROID_PLAT_INC=arch-x86 + #google fecked up. anything before api_level 9 will fail to compile on x86 + DROID_API_LEVEL=9 + else + DROID_PLAT_INC=arch-arm + + #there are 3 ABI targets + #armv5 (works on all arm droids) + #armv7 (more common on 2.2+ droids) + #armv7+neon + DROID_ABI?=-mfloat-abi=softfp + endif + DROIDSYSROOT=$(realpath $(ANDROID_NDK_ROOT)/platforms/android-$(DROID_API_LEVEL)/$(DROID_PLAT_INC)) + #if we're running under windows, then we want to run some other binary ifeq ($(shell uname -o 2>&1 | grep Cygwin),) #set up for linux @@ -150,26 +167,12 @@ ifeq ($(FTE_TARGET),droid) DEPCC= #configure hates android, with its broken default sysroot and lack of path etc - TOOLOVERRIDES=PATH="/usr/bin:$(shell cygpath -u $(realpath $(TOOLCHAINPATH)))" CFLAGS=--sysroot="$(shell cygpath -m $(realpath $(ANDROID_NDK_ROOT)/platforms/android-$(DROID_API_LEVEL)/$(DROID_PLAT_INC)))" CPPFLAGS=--sysroot="$(shell cygpath -m $(realpath $(ANDROID_NDK_ROOT)/platforms/android-$(DROID_API_LEVEL)/$(DROID_PLAT_INC)))" + DROIDSYSROOT:=$(shell cygpath -m $(DROIDSYSROOT)) + TOOLOVERRIDES=PATH="/usr/bin:$(shell cygpath -u $(realpath $(TOOLCHAINPATH)))" CFLAGS=--sysroot="$(DROIDSYSROOT)" CPPFLAGS=--sysroot="$(DROIDSYSROOT)" CONFIGARGS= --with-sysroot="$(shell cygpath -u $(realpath $(ANDROID_NDK_ROOT)/platforms/android-$(DROID_API_LEVEL)/$(DROID_PLAT_INC)))" endif - DROID_API_LEVEL=4 - - ifeq ($(DROID_ARCH),x86) - DROID_PLAT_INC=arch-x86 - #google fecked up. anything before api_level 9 will fail to compile on x86 - DROID_API_LEVEL=9 - else - DROID_PLAT_INC=arch-arm - - #there are 3 ABI targets - #armv5 (works on all arm droids) - #armv7 (more common on 2.2+ droids) - #armv7+neon - DROID_ABI?=-mfloat-abi=softfp - endif - CC:=$(TOOLCHAIN)gcc --sysroot="$(shell cygpath -m $(realpath $(ANDROID_NDK_ROOT)/platforms/android-$(DROID_API_LEVEL)/$(DROID_PLAT_INC)))" -DANDROID $(DROID_ABI) -fno-strict-aliasing + CC:=$(TOOLCHAIN)gcc --sysroot="$(DROIDSYSROOT)" -DANDROID $(DROID_ABI) -fno-strict-aliasing DO_LD:=$(DO_ECHO) $(CC) -Wl,-soname,libftedroid.so -shared -Wl,--no-undefined -Wl,-z,noexecstack -o $@ $(LTO_LD) $(WCFLAGS) $(BRANDFLAGS) $(CFLAGS) -llog -lc -lz -lm LD:=$(TOOLCHAIN)ld AR:=$(TOOLCHAIN)ar diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index b17041446..75d16bb70 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -4252,8 +4252,10 @@ void Host_DoRunFile(hrf_t *f) } else if (f->flags & HRF_MODEL) { - FS_FixupGamedirForExternalFile(f->fname, loadcommand, sizeof(loadcommand)); - Cbuf_AddText(va("modelviewer \"%s\"\n", loadcommand), RESTRICT_LOCAL); + if (!FS_FixupGamedirForExternalFile(f->fname, loadcommand, sizeof(loadcommand))) + Con_Printf("%s is not within the current gamedir\n", f->fname); + else + Cbuf_AddText(va("modelviewer \"%s\"\n", loadcommand), RESTRICT_LOCAL); f->flags |= HRF_ABORT; Host_DoRunFile(f); return; @@ -4787,6 +4789,8 @@ void CL_ReadCDKey(void) void CL_StartCinematicOrMenu(void) { + COM_MainThreadWork(); + if (cls.download) { startuppending = true; diff --git a/engine/client/cl_screen.c b/engine/client/cl_screen.c index 085524291..e81e1cc7b 100644 --- a/engine/client/cl_screen.c +++ b/engine/client/cl_screen.c @@ -1790,6 +1790,7 @@ SCR_SetUpToDrawConsole */ void SCR_SetUpToDrawConsole (void) { + extern qboolean startuppending; //true if we're downloading media or something and have not yet triggered the startup action (read: main menu or cinematic) #ifdef TEXTEDITOR //extern qboolean editoractive; //unused variable #endif @@ -1810,7 +1811,7 @@ void SCR_SetUpToDrawConsole (void) // Key_Dest_Add(kdm_console); scr_conlines = scr_con_current = vid.height * fullscreenpercent; } - else if (!Key_Dest_Has(kdm_menu) && (!Key_Dest_Has(~((!con_stayhidden.ival?kdm_console:0)|kdm_game))) && SCR_GetLoadingStage() == LS_NONE && cls.state < ca_active && !Media_PlayingFullScreen() && !CSQC_UnconnectedOkay(false)) + else if (!startuppending && !Key_Dest_Has(kdm_menu) && (!Key_Dest_Has(~((!con_stayhidden.ival?kdm_console:0)|kdm_game))) && SCR_GetLoadingStage() == LS_NONE && cls.state < ca_active && !Media_PlayingFullScreen() && !CSQC_UnconnectedOkay(false)) { //go fullscreen if we're not doing anything #ifdef VM_UI @@ -1837,7 +1838,7 @@ void SCR_SetUpToDrawConsole (void) Key_Dest_Add(kdm_console); } } - if (!con_stayhidden.ival && Key_Dest_Has(kdm_console)) + if (!con_stayhidden.ival && !startuppending && Key_Dest_Has(kdm_console)) scr_con_current = scr_conlines = vid.height * fullscreenpercent; } else if (Key_Dest_Has(kdm_console) || scr_chatmode) diff --git a/engine/client/console.c b/engine/client/console.c index d9934acd6..2ff26382a 100644 --- a/engine/client/console.c +++ b/engine/client/console.c @@ -1289,6 +1289,7 @@ void Con_ClearNotify(void) } void Con_DrawNotify (void) { + extern qboolean startuppending; console_t *con; con_main.flags |= CONF_NOTIFY; @@ -1305,10 +1306,20 @@ void Con_DrawNotify (void) con_chat->notif_t = con_notifytime_chat.value; } - for (con = &con_main; con; con = con->next) + if (startuppending) { - if (con->flags & CONF_NOTIFY) - Con_DrawNotifyOne(con); + int x,y; + Font_BeginString(font_console, 0, 0, &x, &y); + Con_DrawProgress(0, vid.width, 0); + Font_EndString(font_console); + } + else + { + for (con = &con_main; con; con = con->next) + { + if (con->flags & CONF_NOTIFY) + Con_DrawNotifyOne(con); + } } if (Key_Dest_Has(kdm_message)) diff --git a/engine/common/common.c b/engine/common/common.c index f7efbadaf..659d71ab8 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -4863,7 +4863,7 @@ void COM_DestroyWorkerThread(void) com_resourcemutex = NULL; } -//partial means we're waiting for an explicit response. the caller will need to check when that response arrives. +//fully flushes ALL pending work. void COM_WorkerFullSync(void) { qboolean repeat; @@ -4895,6 +4895,7 @@ void COM_WorkerFullSync(void) repeat = true; } while (COM_DoWork(0, false) || repeat); //outer loop ensures there isn't anything pingponging between } + //main thread wants a specific object to be prioritised. //an ancestor of the work must be pending on either the main thread or the worker thread. //typically the worker gives us a signal to handle the final activation of the object. diff --git a/engine/common/cvar.c b/engine/common/cvar.c index bbe729f8a..dcb759b63 100644 --- a/engine/common/cvar.c +++ b/engine/common/cvar.c @@ -409,6 +409,21 @@ void Cvar_List_f (void) } } +//default values are meant to be constants. +//sometimes that just doesn't make sense. +//so provide a safe way to change it (MUST be initialised to NULL) +void Cvar_SetEngineDefault(cvar_t *var, char *val) +{ + qboolean wasdefault = (var->defaultstr == var->enginevalue); + Z_Free(var->enginevalue); + if (val) + var->enginevalue = Z_StrDup(val); + else + var->enginevalue = NULL; + + if (wasdefault) + var->defaultstr = var->enginevalue; +} void Cvar_LockDefaults_f(void) { cvar_group_t *grp; diff --git a/engine/common/cvar.h b/engine/common/cvar.h index 9cbfbcea2..1ab6c4c4b 100644 --- a/engine/common/cvar.h +++ b/engine/common/cvar.h @@ -209,6 +209,8 @@ void Cvar_WriteVariables (vfsfile_t *f, qboolean all); cvar_t *Cvar_FindVar (const char *var_name); +void Cvar_SetEngineDefault(cvar_t *var, char *val); + void Cvar_Init(void); void Cvar_Shutdown(void); diff --git a/engine/common/fs.c b/engine/common/fs.c index 80886dde8..62544c29e 100644 --- a/engine/common/fs.c +++ b/engine/common/fs.c @@ -3303,10 +3303,8 @@ void FS_Shutdown(void) Sys_DestroyMutex(fs_thread_mutex); fs_thread_mutex = NULL; - Z_Free(fs_gamename.enginevalue); - fs_gamename.enginevalue = NULL; - Z_Free(com_protocolname.enginevalue); - fs_gamename.enginevalue = NULL; + Cvar_SetEngineDefault(&fs_gamename, NULL); + Cvar_SetEngineDefault(&com_protocolname, NULL); } //returns false if the directory is not suitable. @@ -3977,11 +3975,9 @@ qboolean FS_ChangeGame(ftemanifest_t *man, qboolean allowreloadconfigs) if (reloadconfigs) { - Z_Free(fs_gamename.enginevalue); - fs_gamename.enginevalue = Z_StrDup(man->formalname?man->formalname:"FTE"); - Z_Free(com_protocolname.enginevalue); - com_protocolname.enginevalue = Z_StrDup(man->protocolname?man->protocolname:"FTE"); - //FIXME: flag this instead and do it after a delay + Cvar_SetEngineDefault(&fs_gamename, man->formalname?man->formalname:"FTE"); + Cvar_SetEngineDefault(&com_protocolname, man->protocolname?man->protocolname:"FTE"); + //FIXME: flag this instead and do it after a delay? Cvar_ForceSet(&fs_gamename, fs_gamename.enginevalue); Cvar_ForceSet(&com_protocolname, com_protocolname.enginevalue); diff --git a/engine/gl/gl_shadow.c b/engine/gl/gl_shadow.c index d47087598..a76ea991f 100644 --- a/engine/gl/gl_shadow.c +++ b/engine/gl/gl_shadow.c @@ -3255,12 +3255,18 @@ void Sh_PreGenerateLights(void) qbyte *lvis; int i; + r_shadow_realtime_world_lightmaps.value = atof(r_shadow_realtime_world_lightmaps.string); if (r_shadow_realtime_dlight.ival || r_shadow_realtime_world.ival) { if (RTL_FIRST == rtlights_max) R_LoadRTLights(); if (RTL_FIRST == rtlights_max) R_ImportRTLights(cl.worldmodel->entities); + if (RTL_FIRST == rtlights_max && r_shadow_realtime_world.ival) + { + r_shadow_realtime_world_lightmaps.value = 1; + Con_Printf(CON_ERROR "No lights detected in map. Disabling realtime lights.\n"); + } } ignoreflags = (r_shadow_realtime_world.value?LFLAG_REALTIMEMODE:LFLAG_NORMALMODE); diff --git a/engine/http/httpclient.c b/engine/http/httpclient.c index c23113e3d..c0da149b5 100644 --- a/engine/http/httpclient.c +++ b/engine/http/httpclient.c @@ -1176,6 +1176,19 @@ struct dl_download *HTTP_CL_Get(const char *url, const char *localfile, void (*N newdl->next = activedownloads; activedownloads = newdl; + + if (!cls.download) + { + cls.download = &newdl->qdownload; + newdl->qdownload.method = DL_HTTP; + if (*newdl->localname) + Q_strncpyz(newdl->qdownload.localname, newdl->localname, sizeof(newdl->qdownload.localname)); + else + Q_strncpyz(newdl->qdownload.localname, newdl->url, sizeof(newdl->qdownload.localname)); + Q_strncpyz(newdl->qdownload.remotename, newdl->url, sizeof(newdl->qdownload.remotename)); + newdl->qdownload.starttime = Sys_DoubleTime(); + } + return newdl; } @@ -1247,6 +1260,13 @@ void HTTP_CL_Think(void) else dl->qdownload.percent = dl->completed*100.0f/dl->totalsize; dl->qdownload.completedbytes = dl->completed; + + if (dl->qdownload.ratetime < Sys_DoubleTime()) + { + dl->qdownload.ratetime = Sys_DoubleTime()+1; + dl->qdownload.rate = (dl->qdownload.completedbytes - dl->qdownload.ratebytes) / 1; + dl->qdownload.ratebytes = dl->qdownload.completedbytes; + } } } #endif diff --git a/engine/qclib/initlib.c b/engine/qclib/initlib.c index e9918af35..c9258d872 100644 --- a/engine/qclib/initlib.c +++ b/engine/qclib/initlib.c @@ -1047,6 +1047,7 @@ pbool PDECL PR_DumpProfiles (pubprogfuncs_t *ppf) char *fname; int profile; unsigned long long profiletime; + unsigned long long totaltime; } *sorted, t; if (!prinst.profiling) { @@ -1073,6 +1074,7 @@ pbool PDECL PR_DumpProfiles (pubprogfuncs_t *ppf) sorted[s].fname = ps->functions[f].s_name+progfuncs->funcs.stringtable; sorted[s].profile = ps->functions[f].profile; sorted[s].profiletime = ps->functions[f].profiletime - ps->functions[f].profilechildtime; + sorted[s].totaltime = ps->functions[f].profiletime; ps->functions[f].profile = 0; ps->functions[f].profiletime = 0; s++; @@ -1080,6 +1082,7 @@ pbool PDECL PR_DumpProfiles (pubprogfuncs_t *ppf) // good 'ol bubble sort for (f = 0; f < s; f++) + { for (j = f; j < s; j++) if (sorted[f].profiletime > sorted[j].profiletime) { @@ -1087,10 +1090,12 @@ pbool PDECL PR_DumpProfiles (pubprogfuncs_t *ppf) sorted[f] = sorted[j]; sorted[j] = t; } + } //print it out + printf("%5s %5s %5s: %s\n", "ops", "self-time", "total-time", "function"); for (f = 0; f < s; f++) - printf("%s: %u %g\n", sorted[f].fname, sorted[f].profile, (float)(((double)sorted[f].profiletime) / cpufrequency)); + printf("%5u %5g %5g: %s\n", sorted[f].profile, (float)(((double)sorted[f].profiletime) / cpufrequency), (float)(((double)sorted[f].totaltime) / cpufrequency), sorted[f].fname); free(sorted); } return true; diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index 522fb0753..23179dc4f 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -10526,6 +10526,9 @@ void PR_DumpPlatform_f(void) {"m_keyup", "void(float scan, float chr)", MENU}, {"m_toggle", "void(float mode)", MENU}, + {"parm17, parm18, parm19, parm20, parm21, parm22, parm23, parm24, parm25, parm26, parm27, parm28, parm29, parm30, parm31, parm32", "float", QW|NQ}, + {"parm33, parm34, parm35, parm36, parm37, parm38, parm39, parm40, parm41, parm42, parm43, parm44, parm45, parm46, parm47, parm48", "float", QW|NQ}, + {"parm49, parm50, parm51, parm52, parm53, parm54, parm55, parm56, parm57, parm58, parm59, parm60, parm61, parm62, parm63, parm64", "float", QW|NQ}, {"physics_mode", "var float", QW|NQ|CS, "0: original csqc - physics are not run\n1: DP-compat. Thinks occur, but not true movetypes.\n2: movetypes occur just as they do in ssqc.", 2}, {"gamespeed", "float", CS, "Set by the engine, this is the value of the sv_gamespeed cvar"}, {"numclientseats", "float", CS, "This is the number of splitscreen clients currently running on this client."}, @@ -10770,7 +10773,7 @@ void PR_DumpPlatform_f(void) {"EV_FLOAT", "const float", QW|NQ|CS, NULL, ev_float}, {"EV_VECTOR", "const float", QW|NQ|CS, NULL, ev_vector}, {"EV_ENTITY", "const float", QW|NQ|CS, NULL, ev_entity}, -// {"EV_FIELD", "const float", QW|NQ|CS, NULL, ev_field}, + {"EV_FIELD", "const float", QW|NQ|CS, NULL, ev_field}, {"EV_FUNCTION", "const float", QW|NQ|CS, NULL, ev_function}, {"EV_POINTER", "const float", QW|NQ|CS, NULL, ev_pointer}, {"EV_INTEGER", "const float", QW|NQ|CS, NULL, ev_integer},