From d680b76bba412e7098a74ba2b9bbc79d332b911b Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 10 Dec 2020 21:00:15 +0000 Subject: [PATCH] Dynamic ticrate calculation (related to framerate) --- .gitignore | 3 ++- Projects/Android/AndroidManifest.xml | 4 ++-- .../Android/gradle/wrapper/gradle-wrapper.properties | 4 ++-- Projects/Android/jni/cmd.c | 8 -------- Projects/Android/jni/host.c | 6 ++++-- Projects/Android/jni/menu.c | 2 +- Projects/Android/jni/server.h | 1 - Projects/Android/jni/sv_main.c | 12 ++++++------ Projects/Android/jni/world.c | 4 +++- Src/QuakeQuest_SurfaceView.c | 5 +++++ 10 files changed, 25 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 8f26c70..57cc216 100644 --- a/.gitignore +++ b/.gitignore @@ -28,13 +28,14 @@ $RECYCLE.BIN/ projects/Android/build/* assets/oculussig* Projects/Android/.externalNativeBuild/ndkBuild/debug/arm64-v8a/android_gradle_build.json +Projects/Android/.cxx/ndkBuild/* *.json Projects/Android/.externalNativeBuild/ndkBuild/debug/arm64-v8a/ndkBuild_build_command.txt Projects/Android/.externalNativeBuild/ndkBuild/debug/arm64-v8a/ndkBuild_build_output.txt Projects/Android/.externalNativeBuild/ndkBuild/release/arm64-v8a/ndkBuild_build_command.txt Projects/Android/.externalNativeBuild/ndkBuild/release/armeabi-v7a/ndkBuild_build_output.txt *.bin -Projects/Android/.gradle/4.4/fileHashes/fileHashes.lock +Projects/Android/.gradle/* *.ser Projects/Android/.idea/codeStyles/Project.xml *.xml diff --git a/Projects/Android/AndroidManifest.xml b/Projects/Android/AndroidManifest.xml index 8eaf8b9..2849ce5 100644 --- a/Projects/Android/AndroidManifest.xml +++ b/Projects/Android/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="16" + android:versionName="1.4.8" android:installLocation="auto" > diff --git a/Projects/Android/gradle/wrapper/gradle-wrapper.properties b/Projects/Android/gradle/wrapper/gradle-wrapper.properties index c9ebeef..ac98cc8 100644 --- a/Projects/Android/gradle/wrapper/gradle-wrapper.properties +++ b/Projects/Android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Jul 27 06:47:04 BST 2019 +#Tue Dec 08 08:47:00 GMT 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/Projects/Android/jni/cmd.c b/Projects/Android/jni/cmd.c index 9cd09be..f6c0f26 100644 --- a/Projects/Android/jni/cmd.c +++ b/Projects/Android/jni/cmd.c @@ -519,7 +519,6 @@ static void Cmd_Exec(const char *filename) "sv_gameplayfix_q1bsptracelinereportstexture 0\n" "sv_gameplayfix_swiminbmodels 0\n" "sv_gameplayfix_downtracesupportsongroundflag 0\n" -"sys_ticrate 0.0138889\n" "r_shadow_gloss 1\n" "r_shadow_bumpscale_basetexture 0\n" ); @@ -543,7 +542,6 @@ static void Cmd_Exec(const char *filename) "sv_gameplayfix_q1bsptracelinereportstexture 0\n" "sv_gameplayfix_swiminbmodels 0\n" "sv_gameplayfix_downtracesupportsongroundflag 0\n" -"sys_ticrate 0.0138889\n" "r_shadow_gloss 1\n" "r_shadow_bumpscale_basetexture 0\n" ); @@ -571,7 +569,6 @@ static void Cmd_Exec(const char *filename) "sv_gameplayfix_q1bsptracelinereportstexture 0\n" "sv_gameplayfix_swiminbmodels 0\n" "sv_gameplayfix_downtracesupportsongroundflag 0\n" -"sys_ticrate 0.0138889\n" "r_shadow_gloss 1\n" "r_shadow_bumpscale_basetexture 0\n" ); @@ -596,7 +593,6 @@ static void Cmd_Exec(const char *filename) "sv_gameplayfix_q1bsptracelinereportstexture 0\n" "sv_gameplayfix_swiminbmodels 0\n" "sv_gameplayfix_downtracesupportsongroundflag 0\n" -"sys_ticrate 0.0138889\n" "r_shadow_gloss 1\n" "r_shadow_bumpscale_basetexture 0\n" ); @@ -620,7 +616,6 @@ static void Cmd_Exec(const char *filename) "sv_gameplayfix_q1bsptracelinereportstexture 0\n" "sv_gameplayfix_swiminbmodels 0\n" "sv_gameplayfix_downtracesupportsongroundflag 0\n" -"sys_ticrate 0.0138889\n" "r_shadow_gloss 2\n" "r_shadow_bumpscale_basetexture 4\n" ); @@ -644,7 +639,6 @@ static void Cmd_Exec(const char *filename) "sv_gameplayfix_q1bsptracelinereportstexture 1\n" "sv_gameplayfix_swiminbmodels 1\n" "sv_gameplayfix_downtracesupportsongroundflag 1\n" -"sys_ticrate 0.0138889\n" "sv_gameplayfix_q2airaccelerate 1\n" "sv_gameplayfix_stepmultipletimes 1\n" ); @@ -669,7 +663,6 @@ static void Cmd_Exec(const char *filename) "sv_gameplayfix_q1bsptracelinereportstexture 1\n" "sv_gameplayfix_swiminbmodels 1\n" "sv_gameplayfix_downtracesupportsongroundflag 1\n" -"sys_ticrate 0.0138889\n" "cl_csqc_generatemousemoveevents 0\n" ); break; @@ -692,7 +685,6 @@ static void Cmd_Exec(const char *filename) "sv_gameplayfix_q1bsptracelinereportstexture 1\n" "sv_gameplayfix_swiminbmodels 1\n" "sv_gameplayfix_downtracesupportsongroundflag 1\n" -"sys_ticrate 0.0138889\n" ); break; } diff --git a/Projects/Android/jni/host.c b/Projects/Android/jni/host.c index 79e8220..b666d25 100644 --- a/Projects/Android/jni/host.c +++ b/Projects/Android/jni/host.c @@ -662,6 +662,8 @@ Runs all active servers */ static void Host_Init(void); +float GetSysTicrate(); + double time1 = 0; double time2 = 0; double time3 = 0; @@ -842,7 +844,7 @@ void Host_BeginFrame(bool stopTime) // don't allow simulation to run too fast or too slow or logic glitches can occur // stop running server frames if the wall time reaches this value - if (sys_ticrate.value <= 0) + if (GetSysTicrate() <= 0) advancetime = sv_timer; else if (cl.islocalgame && !sv_fixedframeratesingleplayer.integer) { @@ -851,7 +853,7 @@ void Host_BeginFrame(bool stopTime) } else { - advancetime = sys_ticrate.value; + advancetime = GetSysTicrate(); // listen servers can run multiple server frames per client frame framelimit = cl_maxphysicsframesperserverframe.integer; aborttime = Sys_DirtyTime() + 0.1; diff --git a/Projects/Android/jni/menu.c b/Projects/Android/jni/menu.c index 700f50c..facaac1 100644 --- a/Projects/Android/jni/menu.c +++ b/Projects/Android/jni/menu.c @@ -3611,7 +3611,7 @@ static void M_Credits_Draw (void) " QQQQQQQQ QQQQQQQQ ", " QQQ QQQ ", " Q Q ", - " Q Q v1.4.7 "); + " Q Q v1.4.8 "); int i, l, linelength, firstline, lastline, lines; for (i = 0, linelength = 0, firstline = 9999, lastline = -1;m_credits_message[i];i++) diff --git a/Projects/Android/jni/server.h b/Projects/Android/jni/server.h index 669174b..be77dde 100644 --- a/Projects/Android/jni/server.h +++ b/Projects/Android/jni/server.h @@ -493,7 +493,6 @@ extern cvar_t sv_wallfriction; extern cvar_t sv_wateraccelerate; extern cvar_t sv_waterfriction; extern cvar_t sv_areadebug; -extern cvar_t sys_ticrate; extern cvar_t teamplay; extern cvar_t temp1; extern cvar_t timelimit; diff --git a/Projects/Android/jni/sv_main.c b/Projects/Android/jni/sv_main.c index a7bd478..1fd396e 100644 --- a/Projects/Android/jni/sv_main.c +++ b/Projects/Android/jni/sv_main.c @@ -151,7 +151,6 @@ cvar_t sv_warsowbunny_turnaccel = {0, "sv_warsowbunny_turnaccel", "0", "max shar cvar_t sv_warsowbunny_backtosideratio = {0, "sv_warsowbunny_backtosideratio", "0.8", "lower values make it easier to change direction without losing speed; the drawback is \"understeering\" in sharp turns"}; cvar_t sv_onlycsqcnetworking = {0, "sv_onlycsqcnetworking", "0", "disables legacy entity networking code for higher performance (except on clients, which can still be legacy)"}; cvar_t sv_areadebug = {0, "sv_areadebug", "0", "disables physics culling for debugging purposes (only for development)"}; -cvar_t sys_ticrate = {CVAR_SAVE, "sys_ticrate","0.0138889", "how long a server frame is in seconds, 0.05 is 20fps server rate, 0.1 is 10fps (can not be set higher than 0.1), 0 runs as many server frames as possible (makes games against bots a little smoother, overwhelms network players), 0.0138889 matches QuakeWorld physics"}; cvar_t teamplay = {CVAR_NOTIFY, "teamplay","0", "teamplay mode, values depend on mod but typically 0 = no teams, 1 = no team damage no self damage, 2 = team damage and self damage, some mods support 3 = no team damage but can damage self"}; cvar_t timelimit = {CVAR_NOTIFY, "timelimit","0", "ends level at this time (in minutes)"}; cvar_t sv_threaded = {0, "sv_threaded", "0", "enables a separate thread for server code, improving performance, especially when hosting a game while playing, EXPERIMENTAL, may be crashy"}; @@ -561,7 +560,6 @@ void SV_Init (void) Cvar_RegisterVariable (&sv_warsowbunny_backtosideratio); Cvar_RegisterVariable (&sv_onlycsqcnetworking); Cvar_RegisterVariable (&sv_areadebug); - Cvar_RegisterVariable (&sys_ticrate); Cvar_RegisterVariable (&teamplay); Cvar_RegisterVariable (&timelimit); Cvar_RegisterVariable (&sv_threaded); @@ -1958,6 +1956,8 @@ SV_WriteClientdataToMessage ================== */ +float GetSysTicrate(); + void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t *msg, int *stats) { prvm_prog_t *prog = SVVM_prog; @@ -2082,7 +2082,7 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t | (sv_gameplayfix_nogravityonground.integer ? MOVEFLAG_NOGRAVITYONGROUND : 0) | (sv_gameplayfix_gravityunaffectedbyticrate.integer ? MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE : 0) ; - statsf[STAT_MOVEVARS_TICRATE] = sys_ticrate.value; + statsf[STAT_MOVEVARS_TICRATE] = GetSysTicrate(); statsf[STAT_MOVEVARS_TIMESCALE] = slowmo.value; statsf[STAT_MOVEVARS_GRAVITY] = sv_gravity.value; statsf[STAT_MOVEVARS_STOPSPEED] = sv_stopspeed.value; @@ -2340,7 +2340,7 @@ static void SV_SendClientDatagram (client_t *client) // // at very low rates (or very small sys_ticrate) the packet size is // not reduced below 128, but packets may be sent less often - maxsize = (int)(clientrate * sys_ticrate.value); + maxsize = (int)(clientrate * GetSysTicrate()); maxsize = bound(128, maxsize, 1400); maxsize2 = 1400; // csqc entities can easily exceed 128 bytes, so disable throttling in @@ -3957,10 +3957,10 @@ static int SV_ThreadFunc(void *voiddata) double advancetime; float offset; - if (sys_ticrate.value <= 0) + if (GetSysTicrate() <= 0) advancetime = min(sv_timer, 0.1); // don't step more than 100ms else - advancetime = sys_ticrate.value; + advancetime = GetSysTicrate(); if(advancetime > 0) { diff --git a/Projects/Android/jni/world.c b/Projects/Android/jni/world.c index abacf51..57b997a 100644 --- a/Projects/Android/jni/world.c +++ b/Projects/Android/jni/world.c @@ -3010,6 +3010,8 @@ static void nearCallback (void *data, dGeomID o1, dGeomID o2) } #endif +float GetSysTicrate(); + void World_Physics_Frame(world_t *world, double frametime, double gravity) { prvm_prog_t *prog = world->prog; @@ -3034,7 +3036,7 @@ void World_Physics_Frame(world_t *world, double frametime, double gravity) if (physics_ode_constantstep.value > 0 && physics_ode_constantstep.value < 1) world->physics.ode_step = physics_ode_constantstep.value; else - world->physics.ode_step = sys_ticrate.value; + world->physics.ode_step = GetSysTicrate(); if (world->physics.ode_time > 0.2f) world->physics.ode_time = world->physics.ode_step; // set number of iterations to process diff --git a/Src/QuakeQuest_SurfaceView.c b/Src/QuakeQuest_SurfaceView.c index 1a759dc..91ae1fb 100644 --- a/Src/QuakeQuest_SurfaceView.c +++ b/Src/QuakeQuest_SurfaceView.c @@ -2275,6 +2275,11 @@ float GetFOV() return vrapi_GetSystemPropertyFloat( &java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_Y ); } +float GetSysTicrate() +{ + return 1.0F / (float)(vrapi_GetSystemPropertyInt(&java, VRAPI_SYS_PROP_DISPLAY_REFRESH_RATE)); +} + void * AppThreadFunction( void * parm ) { ovrAppThread * appThread = (ovrAppThread *)parm;