From ced297e76f53525002563ca323abf8a637bfa9fa Mon Sep 17 00:00:00 2001 From: div0 Date: Sun, 20 Dec 2009 09:36:18 +0000 Subject: [PATCH] - rename sys_ticrate global to sys_frametime, and premultiply it with slowmo (fixes lots of bugs) - make player weapon anims play one frame longer, gets rid of flicker introduced by subframe weaponframes git-svn-id: svn://svn.icculus.org/nexuiz/trunk@8436 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/anticheat.qc | 2 +- data/qcsrc/server/cl_client.qc | 2 ++ data/qcsrc/server/cl_weaponsystem.qc | 2 +- data/qcsrc/server/defs.qh | 2 +- data/qcsrc/server/g_hook.qc | 2 +- data/qcsrc/server/miscfunctions.qc | 2 +- data/qcsrc/server/mode_onslaught.qc | 14 +++++++------- data/qcsrc/server/pathlib.qc | 2 +- data/qcsrc/server/pathlib/main.qc | 2 +- data/qcsrc/server/sv_main.qc | 2 +- .../server/tturrets/system/system_aimprocs.qc | 12 ++++++------ data/qcsrc/server/tturrets/system/system_main.qc | 4 ++-- 12 files changed, 25 insertions(+), 23 deletions(-) diff --git a/data/qcsrc/server/anticheat.qc b/data/qcsrc/server/anticheat.qc index 9d4a6d22f..3b729ca48 100644 --- a/data/qcsrc/server/anticheat.qc +++ b/data/qcsrc/server/anticheat.qc @@ -58,7 +58,7 @@ void anticheat_physics() if(self.anticheat_div0_evade_offset == 0) { f = fabs(anticheat_div0_evade_evasion_delta - floor(anticheat_div0_evade_evasion_delta) - 0.5) * 2; // triangle function - self.anticheat_div0_evade_offset = time + sys_ticrate * (3 * f - 1); + self.anticheat_div0_evade_offset = time + sys_frametime * (3 * f - 1); self.anticheat_div0_evade_v_angle = self.v_angle; self.anticheat_div0_evade_forward_initial = v_forward; MEAN_ACCUMULATE(anticheat_div0_evade, 0, 1); diff --git a/data/qcsrc/server/cl_client.qc b/data/qcsrc/server/cl_client.qc index 7d747e9c5..fdc27c5b4 100644 --- a/data/qcsrc/server/cl_client.qc +++ b/data/qcsrc/server/cl_client.qc @@ -2709,6 +2709,8 @@ void PlayerPreThink (void) } target_voicescript_next(self); + + print(ftos(self.frame), "\n"); } // on dragger: diff --git a/data/qcsrc/server/cl_weaponsystem.qc b/data/qcsrc/server/cl_weaponsystem.qc index 6bf637ace..c1902637a 100644 --- a/data/qcsrc/server/cl_weaponsystem.qc +++ b/data/qcsrc/server/cl_weaponsystem.qc @@ -1178,7 +1178,7 @@ void weapon_thinkf(float fr, float t, void() func) { local vector anim; anim = self.anim_shoot; - anim_z = anim_y / t; + anim_z = anim_y / (t + sys_frametime); setanim(self, anim, FALSE, TRUE, TRUE); } }; diff --git a/data/qcsrc/server/defs.qh b/data/qcsrc/server/defs.qh index f685bbdf7..9727d1adc 100644 --- a/data/qcsrc/server/defs.qh +++ b/data/qcsrc/server/defs.qh @@ -285,7 +285,7 @@ float isJoinAllowed(); //sv_timeout: pauses the game by setting the gamespeed to a really low value (see TIMEOUT_SLOWMO_VALUE) #define TIMEOUT_SLOWMO_VALUE 0.0001 -float sys_ticrate; // gets initialised in worlspawn, saves the value from cvar("sys_ticrate") +float sys_frametime; // gets initialised in worlspawn, saves the value from cvar("sys_ticrate") float remainingTimeoutTime; // contains the time in seconds that the active timeout has left float remainingLeadTime; // contains the number of seconds left of the leadtime (before the timeout starts) float timeoutStatus; // (values: 0, 1, 2) contains whether a timeout is not active (0), was called but still at leadtime (1) or is active (2) diff --git a/data/qcsrc/server/g_hook.qc b/data/qcsrc/server/g_hook.qc index a3100db89..abaafe87f 100644 --- a/data/qcsrc/server/g_hook.qc +++ b/data/qcsrc/server/g_hook.qc @@ -270,7 +270,7 @@ void GrapplingHookTouch (void) if(other == world) { vector tic; - tic = self.velocity * sys_ticrate; + tic = self.velocity * sys_frametime; tic = tic + normalize(tic) * vlen(self.maxs - self.mins); traceline(self.origin - tic, self.origin + tic, MOVE_NORMAL, self); if(trace_fraction >= 1) diff --git a/data/qcsrc/server/miscfunctions.qc b/data/qcsrc/server/miscfunctions.qc index 5524b7e91..c78b1776d 100644 --- a/data/qcsrc/server/miscfunctions.qc +++ b/data/qcsrc/server/miscfunctions.qc @@ -2104,7 +2104,7 @@ float SUB_NoImpactCheck() if (other == world && self.size != '0 0 0') { vector tic; - tic = self.velocity * sys_ticrate; + tic = self.velocity * sys_frametime; tic = tic + normalize(tic) * vlen(self.maxs - self.mins); traceline(self.origin - tic, self.origin + tic, MOVE_NORMAL, self); if (trace_fraction >= 1) diff --git a/data/qcsrc/server/mode_onslaught.qc b/data/qcsrc/server/mode_onslaught.qc index bd4ccef72..b73bdb05f 100644 --- a/data/qcsrc/server/mode_onslaught.qc +++ b/data/qcsrc/server/mode_onslaught.qc @@ -967,7 +967,7 @@ void onslaught_controlpoint_icon_damage(entity inflictor, entity attacker, float if(self.owner.iscaptured) WaypointSprite_UpdateHealth(self.owner.sprite, self.health); else - WaypointSprite_UpdateBuildFinished(self.owner.sprite, time + (self.max_health - self.health) / (self.count / sys_ticrate)); + WaypointSprite_UpdateBuildFinished(self.owner.sprite, time + (self.max_health - self.health) / (self.count / sys_frametime)); self.pain_finished = time + 1; self.punchangle = (2 * randomvec() - '1 1 1') * 45; self.cp_bob_dmg_z = (2 * random() - 1) * 15; @@ -1027,7 +1027,7 @@ void onslaught_controlpoint_icon_damage(entity inflictor, entity attacker, float void onslaught_controlpoint_icon_think() { entity oself; - self.nextthink = time + sys_ticrate; + self.nextthink = time + sys_frametime; if (time > self.pain_finished + 5) { if(self.health < self.max_health) @@ -1115,7 +1115,7 @@ void onslaught_controlpoint_icon_buildthink() local entity oself; float a; - self.nextthink = time + sys_ticrate; + self.nextthink = time + sys_frametime; // only do this if there is power a = onslaught_controlpoint_can_be_linked(self.owner, self.owner.team); @@ -1127,7 +1127,7 @@ void onslaught_controlpoint_icon_buildthink() if (self.health >= self.max_health) { self.health = self.max_health; - self.count = cvar("g_onslaught_cp_regen") * sys_ticrate; // slow repair rate from now on + self.count = cvar("g_onslaught_cp_regen") * sys_frametime; // slow repair rate from now on self.think = onslaught_controlpoint_icon_think; sound(self, CHAN_TRIGGER, "onslaught/controlpoint_built.wav", VOL_BASE, ATTN_NORM); bprint(ColoredTeamName(self.team), " captured ", self.owner.message, " control point\n"); @@ -1190,12 +1190,12 @@ void onslaught_controlpoint_touch() e.team = other.team; e.colormap = 1024 + (e.team - 1) * 17; e.think = onslaught_controlpoint_icon_buildthink; - e.nextthink = time + sys_ticrate; - e.count = (e.max_health - e.health) * sys_ticrate / cvar("g_onslaught_cp_buildtime"); // how long it takes to build + e.nextthink = time + sys_frametime; + e.count = (e.max_health - e.health) * sys_frametime / cvar("g_onslaught_cp_buildtime"); // how long it takes to build sound(e, CHAN_TRIGGER, "onslaught/controlpoint_build.wav", VOL_BASE, ATTN_NORM); self.team = e.team; self.colormap = e.colormap; - WaypointSprite_UpdateBuildFinished(self.sprite, time + (e.max_health - e.health) / (e.count / sys_ticrate)); + WaypointSprite_UpdateBuildFinished(self.sprite, time + (e.max_health - e.health) / (e.count / sys_frametime)); onslaught_updatelinks(); }; diff --git a/data/qcsrc/server/pathlib.qc b/data/qcsrc/server/pathlib.qc index 4591a7afc..95aa2f965 100644 --- a/data/qcsrc/server/pathlib.qc +++ b/data/qcsrc/server/pathlib.qc @@ -1015,7 +1015,7 @@ entity pathlib_astar(vector from,vector to) dprint("Time used - rebuild & filter: ", ftos(ftime),"\n"); dprint("Time used - cleanup: ", ftos(ctime),"\n"); dprint("Time used - total: ", ftos(ptime + ftime + ctime),"\n"); - dprint("Time used - # frames: ", ftos(ceil((ptime + ftime + ctime) / sys_ticrate)),"\n\n"); + dprint("Time used - # frames: ", ftos(ceil((ptime + ftime + ctime) / sys_frametime)),"\n\n"); dprint("Nodes - created: ", ftos(pathlib_made_cnt),"\n"); dprint("Nodes - open: ", ftos(pathlib_open_cnt),"\n"); dprint("Nodes - merged: ", ftos(pathlib_merge_cnt),"\n"); diff --git a/data/qcsrc/server/pathlib/main.qc b/data/qcsrc/server/pathlib/main.qc index f6f854033..6d5a785cc 100644 --- a/data/qcsrc/server/pathlib/main.qc +++ b/data/qcsrc/server/pathlib/main.qc @@ -511,7 +511,7 @@ entity pathlib_astar(vector from,vector to) dprint("Time used - rebuild & filter: ", ftos(ftime),"\n"); dprint("Time used - cleanup: ", ftos(ctime),"\n"); dprint("Time used - total: ", ftos(ptime + ftime + ctime),"\n"); - dprint("Time used - # frames: ", ftos(ceil((ptime + ftime + ctime) / sys_ticrate)),"\n\n"); + dprint("Time used - # frames: ", ftos(ceil((ptime + ftime + ctime) / sys_frametime)),"\n\n"); dprint("Nodes - created: ", ftos(pathlib_made_cnt),"\n"); dprint("Nodes - open: ", ftos(pathlib_open_cnt),"\n"); dprint("Nodes - merged: ", ftos(pathlib_merge_cnt),"\n"); diff --git a/data/qcsrc/server/sv_main.qc b/data/qcsrc/server/sv_main.qc index 2e85efd89..4d3136121 100644 --- a/data/qcsrc/server/sv_main.qc +++ b/data/qcsrc/server/sv_main.qc @@ -197,7 +197,7 @@ void StartFrame (void) sv_warsowbunny_turnaccel = cvar("sv_warsowbunny_turnaccel"); sv_warsowbunny_backtosideratio = cvar("sv_warsowbunny_backtosideratio"); teamplay = cvar ("teamplay"); - sys_ticrate = cvar("sys_ticrate"); + sys_frametime = cvar("sys_ticrate") * cvar("slowmo"); if (timeoutStatus == 1) // just before the timeout (when timeoutStatus will be 2) orig_slowmo = cvar("slowmo"); // slowmo will be restored after the timeout diff --git a/data/qcsrc/server/tturrets/system/system_aimprocs.qc b/data/qcsrc/server/tturrets/system/system_aimprocs.qc index 5b9ed328d..a6b6b30c1 100644 --- a/data/qcsrc/server/tturrets/system/system_aimprocs.qc +++ b/data/qcsrc/server/tturrets/system/system_aimprocs.qc @@ -26,13 +26,13 @@ vector turret_stdproc_aim_generic() // Keep track of when we can shoot the next time and // try to predict where the target will be then, so we can put our aimpoint there. - // + sys_ticrate, becouse spawned REMOVE THIS IF sv_gameplayfix_delayprojectiles are 0! + // + sys_frametime, becouse spawned REMOVE THIS IF sv_gameplayfix_delayprojectiles are 0! // projectiles dont move during the first tic of their life. //if (self.turrcaps_flags & TFL_TURRCAPS_HITSCAN) - // mintime = max(self.attack_finished_single - time,0) + sys_ticrate; + // mintime = max(self.attack_finished_single - time,0) + sys_frametime; //else - mintime = max(self.attack_finished_single - time,0) + sys_ticrate; + mintime = max(self.attack_finished_single - time,0) + sys_frametime; // Baseline pre_pos = real_origin(self.enemy); @@ -77,10 +77,10 @@ vector turret_stdproc_aim_generic() float vz; prep_z = pre_pos_z; vz = self.enemy.velocity_z; - for(i = 0; i < impact_time; i += sys_ticrate) + for(i = 0; i < impact_time; i += sys_frametime) { - vz = vz - (sv_gravity * sys_ticrate); - prep_z = prep_z + vz * sys_ticrate; + vz = vz - (sv_gravity * sys_frametime); + prep_z = prep_z + vz * sys_frametime; } } pre_pos = prep; diff --git a/data/qcsrc/server/tturrets/system/system_main.qc b/data/qcsrc/server/tturrets/system/system_main.qc index cfbc26d47..028c96e6c 100644 --- a/data/qcsrc/server/tturrets/system/system_main.qc +++ b/data/qcsrc/server/tturrets/system/system_main.qc @@ -1004,7 +1004,7 @@ float turret_stdproc_init (string cvar_base_name, float csqc_shared, string base else if (!self.ticrate) self.ticrate = 0.1; // 10 fps for normal turrets - self.ticrate = bound(sys_ticrate,self.ticrate,60); // keep it sane + self.ticrate = bound(sys_frametime,self.ticrate,60); // keep it sane // General stuff if (self.netname == "") @@ -1295,7 +1295,7 @@ float turret_stdproc_init (string cvar_base_name, float csqc_shared, string base ++turret_count; self.nextthink = time + 1; - self.nextthink += turret_count * sys_ticrate; + self.nextthink += turret_count * sys_frametime; self.tur_head.team = self.team; self.view_ofs = '0 0 0'; -- 2.39.2