From 48d2e89b9d19a9654c48622466c30005857712d2 Mon Sep 17 00:00:00 2001 From: TimePath Date: Tue, 15 Mar 2016 21:55:00 +1100 Subject: [PATCH] Check viewmodel alignment more frequently Fixes #1639 --- qcsrc/client/view.qc | 8 +++++--- qcsrc/common/physics/player.qc | 6 ++++-- qcsrc/common/weapons/all.qc | 3 ++- qcsrc/common/weapons/all.qh | 2 +- qcsrc/common/weapons/weapon/tuba.qc | 2 +- qcsrc/server/weapons/weaponsystem.qc | 6 +++--- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 64a8642b2..a52794ec5 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -300,10 +300,11 @@ void viewmodel_draw(entity this) { static string name_last; string name = wep.mdl; - if (name != name_last) + bool swap = name != name_last; + // if (swap) { name_last = name; - CL_WeaponEntity_SetModel(this, name); + CL_WeaponEntity_SetModel(this, name, swap); this.viewmodel_origin = this.origin; this.viewmodel_angles = this.angles; } @@ -312,7 +313,8 @@ void viewmodel_draw(entity this) anim_set(this, this.anim_idle, true, false, false); } float f = 0; // 0..1; 0: fully active - float eta = (this.weapon_nextthink - time) / STAT(WEAPONRATEFACTOR); + float rate = STAT(WEAPONRATEFACTOR); + float eta = rate ? ((this.weapon_nextthink - time) / rate) : 0; if (eta <= 0) f = this.weapon_eta_last; else switch (this.state) { diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc index af3f87c15..253010c0c 100644 --- a/qcsrc/common/physics/player.qc +++ b/qcsrc/common/physics/player.qc @@ -1247,8 +1247,10 @@ void PM_air(entity this, float buttons_prev, float maxspd_mod) if (PHYS_WARSOWBUNNY_TURNACCEL(this) && accelerating && this.movement.y == 0 && this.movement.x != 0) PM_AirAccelerate(this, wishdir, wishspeed2); - else - PM_Accelerate(this, wishdir, wishspeed, wishspeed0, airaccel, airaccelqw, PHYS_AIRACCEL_QW_STRETCHFACTOR(this), PHYS_AIRACCEL_SIDEWAYS_FRICTION(this) / maxairspd, PHYS_AIRSPEEDLIMIT_NONQW(this)); + else { + float sidefric = maxairspd ? (PHYS_AIRACCEL_SIDEWAYS_FRICTION(this) / maxairspd) : 0; + PM_Accelerate(this, wishdir, wishspeed, wishspeed0, airaccel, airaccelqw, PHYS_AIRACCEL_QW_STRETCHFACTOR(this), sidefric, PHYS_AIRSPEEDLIMIT_NONQW(this)); + } if (PHYS_AIRCONTROL(this)) CPM_PM_Aircontrol(this, wishdir, wishspeed2); diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index b126005eb..4eef9e788 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -387,7 +387,7 @@ vector shotorg_adjust_values(vector vecs, bool y_is_right, bool visual, int algn * call again with "" * remove the ent */ -void CL_WeaponEntity_SetModel(entity this, string name) +void CL_WeaponEntity_SetModel(entity this, string name, bool _anim) { if (name == "") { @@ -540,6 +540,7 @@ void CL_WeaponEntity_SetModel(entity this, string name) // check if an instant weapon switch occurred setorigin(this, this.view_ofs); + if (!_anim) return; // reset animstate now this.wframe = WFRAME_IDLE; setanim(this, this.anim_idle, true, false, true); diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index 6f380ecec..7fe6cef93 100644 --- a/qcsrc/common/weapons/all.qh +++ b/qcsrc/common/weapons/all.qh @@ -355,7 +355,7 @@ ENUMCLASS_END(WFRAME) .WFRAME wframe; vector shotorg_adjust_values(vector vecs, bool y_is_right, bool visual, int algn); -void CL_WeaponEntity_SetModel(entity this, string name); +void CL_WeaponEntity_SetModel(entity this, string name, bool _anim); #endif #endif diff --git a/qcsrc/common/weapons/weapon/tuba.qc b/qcsrc/common/weapons/weapon/tuba.qc index 593af8518..0760f79e3 100644 --- a/qcsrc/common/weapons/weapon/tuba.qc +++ b/qcsrc/common/weapons/weapon/tuba.qc @@ -413,7 +413,7 @@ NET_HANDLE(tuba_instrument, bool) string s = (i == 0) ? "tuba" : (i == 1) ? "akordeon" : "kleinbottle" ; - CL_WeaponEntity_SetModel(viewmodel, s); + CL_WeaponEntity_SetModel(viewmodel, s, true); } #endif #ifdef SVQC diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 12dcb4514..1a2aaeafa 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -52,9 +52,9 @@ vector CL_Weapon_GetShotOrg(int wpn) { entity wi = Weapons_from(wpn); entity e = spawn(); - CL_WeaponEntity_SetModel(e, wi.mdl); + CL_WeaponEntity_SetModel(e, wi.mdl, false); vector ret = e.movedir; - CL_WeaponEntity_SetModel(e, ""); + CL_WeaponEntity_SetModel(e, "", false); remove(e); return ret; } @@ -91,7 +91,7 @@ void CL_Weaponentity_Think() this.dmg = this.owner.modelindex; this.deadflag = this.owner.deadflag; - CL_WeaponEntity_SetModel(this, this.owner.weaponname); + CL_WeaponEntity_SetModel(this, this.owner.weaponname, true); } this.alpha = -1; // TODO: don't render this entity at all -- 2.39.2