]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Viewmodels: network switchdelays
authorTimePath <andrew.hardaker1995@gmail.com>
Mon, 30 Nov 2015 01:55:56 +0000 (12:55 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 30 Nov 2015 01:55:56 +0000 (12:55 +1100)
qcsrc/client/view.qc
qcsrc/common/weapons/all.qc

index df4a6d335552a1520fd6eac509fb221718ff692a..09bfd4544072bfd01752b0f66047f56478a5e486 100644 (file)
@@ -266,6 +266,7 @@ void viewmodel_animate(entity this)
 .vector viewmodel_origin, viewmodel_angles;
 .float weapon_nextthink;
 .float weapon_eta_last;
+.float weapon_switchdelay;
 
 void viewmodel_draw(entity this)
 {
@@ -309,16 +310,12 @@ void viewmodel_draw(entity this)
        {
                case WS_RAISE:
                {
-                       // entity newwep = Weapons_from(activeweapon);
-                       float delay = 0.2; // TODO: newwep.switchdelay_raise;
-                       f = eta / max(eta, delay);
+                       f = eta / max(eta, this.weapon_switchdelay);
                        break;
                }
                case WS_DROP:
                {
-                       // entity oldwep = Weapons_from(activeweapon);
-                       float delay = 0.2; // TODO: newwep.switchdelay_drop;
-                       f = 1 - eta / max(eta, delay);
+                       f = 1 - eta / max(eta, this.weapon_switchdelay);
                        break;
                }
                case WS_CLEAR:
index ab613bb940195a257af28f5b758464d7a671d827..d95bf12606e6b8dcc0875f3a86563b73037e35b1 100644 (file)
@@ -563,6 +563,16 @@ NET_HANDLE(wframe, bool isNew)
        viewmodel.state = ReadByte();
        viewmodel.weapon_nextthink = ReadFloat();
        viewmodel.alpha = ReadByte() / 255;
+       switch (viewmodel.state)
+       {
+               case WS_RAISE:
+               case WS_DROP:
+                       viewmodel.weapon_switchdelay = ReadFloat();
+                       break;
+        default:
+            viewmodel.weapon_switchdelay = 0;
+            break;
+       }
        return true;
 }
 #endif
@@ -581,6 +591,16 @@ void wframe_send(entity actor, entity weaponentity, vector a, bool restartanim)
        WriteByte(channel, weaponentity.state);
        WriteFloat(channel, weaponentity.weapon_nextthink);
        WriteByte(channel, weaponentity.alpha * 255);
+       Weapon w = Weapons_from(actor.weapon);
+       switch (weaponentity.state)
+       {
+               case WS_RAISE:
+                       WriteFloat(channel, w.switchdelay_raise);
+                       break;
+               case WS_DROP:
+                       WriteFloat(channel, w.switchdelay_drop);
+                       break;
+       }
 }
 #endif