]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move tuba instrument networking to the weapon entity
authorMario <mario@smbclan.net>
Thu, 6 Oct 2016 10:10:28 +0000 (20:10 +1000)
committerMario <mario@smbclan.net>
Thu, 6 Oct 2016 10:10:28 +0000 (20:10 +1000)
qcsrc/client/view.qc
qcsrc/common/weapons/weapon/tuba.qc
qcsrc/common/wepent.qc
qcsrc/common/wepent.qh

index a485240470c8e2cfce90b44adf844578c3625247..d4e4d6093292e92b6d05eabcd6e03b2b98989eb5 100644 (file)
@@ -312,6 +312,12 @@ void viewmodel_draw(entity this)
        }
        {
                string name = wep.mdl;
+               if(wep == WEP_TUBA)
+               {
+                       name = (this.tuba_instrument == 0) ? "tuba" :
+                          (this.tuba_instrument == 1) ? "akordeon" :
+                                                    "kleinbottle";
+               }
                bool swap = name != this.name_last;
                // if (swap)
                {
index bd6edcef0b1d48489ee189db892b81eb0425dc9e..1c6948c390f53dc36eb55ca3ea3c37c5887cbb6b 100644 (file)
@@ -47,7 +47,6 @@ REGISTER_WEAPON(TUBA, tuba, NEW(Tuba));
 
 .entity tuba_note;
 .float tuba_smoketime;
-.float tuba_instrument;
 
 #define MAX_TUBANOTES 32
 .float tuba_lastnotes_last;
@@ -403,39 +402,13 @@ METHOD(Tuba, wr_setup, void(Tuba this, entity actor, .entity weaponentity))
 {
        actor.(weaponentity).tuba_instrument = 0;
 }
-#endif
 
-REGISTER_NET_S2C(tuba_instrument)
-#ifdef CSQC
-NET_HANDLE(tuba_instrument, bool)
-{
-       int i = ReadByte();
-       int slot = ReadByte();
-       return = true;
-       string s = (i == 0) ? "tuba" :
-                  (i == 1) ? "akordeon" :
-                             "kleinbottle" ;
-
-    entity wep = viewmodels[slot];
-    CL_WeaponEntity_SetModel(wep, s, true);
-}
-#endif
-#ifdef SVQC
-void tuba_instrument_send(entity this, .entity weaponentity, int instr)
-{
-       msg_entity = this;
-       int chan = MSG_ONE;
-       WriteHeader(chan, tuba_instrument);
-       WriteByte(chan, instr);
-       WriteByte(chan, weaponslot(weaponentity));
-}
 SPECTATE_COPY()
 {
        for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
        {
                .entity weaponentity = weaponentities[slot];
-               if(this.(weaponentity).tuba_instrument != spectatee.(weaponentity).tuba_instrument)
-                       tuba_instrument_send(this, weaponentity, this.(weaponentity).tuba_instrument = spectatee.(weaponentity).tuba_instrument);
+               this.(weaponentity).tuba_instrument = spectatee.(weaponentity).tuba_instrument;
        }
 }
 METHOD(Tuba, wr_reload, void(Tuba this, entity actor, .entity weaponentity))
@@ -458,7 +431,6 @@ METHOD(Tuba, wr_reload, void(Tuba this, entity actor, .entity weaponentity))
                                actor.(weaponentity).weaponname = "tuba";
                                break;
                }
-               tuba_instrument_send(actor, weaponentity, actor.(weaponentity).tuba_instrument);
                W_SetupShot(actor, weaponentity, false, 0, SND_Null, 0, 0);
                Send_Effect(EFFECT_TELEPORT, w_shotorg, '0 0 0', 1);
                actor.(weaponentity).state = WS_INUSE;
@@ -507,7 +479,6 @@ class(Tuba) .int note;
 class(Tuba) .bool tuba_attenuate;
 class(Tuba) .float tuba_volume;
 class(Tuba) .float tuba_volume_initial;
-class(Tuba) .int tuba_instrument;
 
 int Tuba_PitchStep;
 
index e53c197501e3d26cc238eda5a80595d04b214525..bb9308424c94e1e9d7ae7ebbb47bf77d1792fa1a 100644 (file)
@@ -20,6 +20,7 @@ MACRO_END
        .float w_vortex_charge;
        .int w_m_gunalign;
        .bool w_porto_v_angle_held;
+       .int w_tuba_instrument;
 #endif
 
 // #define PROP(public, fld, set, sv, cl)
@@ -55,6 +56,10 @@ MACRO_END
        { (viewmodels[this.m_wepent_slot]).angles_held_status = ReadByte(); if((viewmodels[this.m_wepent_slot]).angles_held_status) { \
                (viewmodels[this.m_wepent_slot]).angles_held_x = ReadAngle(); (viewmodels[this.m_wepent_slot]).angles_held_y = ReadAngle(); (viewmodels[this.m_wepent_slot]).angles_held_z = 0; } \
                else { (viewmodels[this.m_wepent_slot]).angles_held = '0 0 0'; } }) \
+    \
+    PROP(false, tuba_instrument, WEPENT_SET_NORMAL, \
+       { WriteByte(chan, this.tuba_instrument); }, \
+       { (viewmodels[this.m_wepent_slot]).tuba_instrument = ReadByte(); }) \
     \
        /**/
 
index 32f0cab3e062f618c7968c22277af788421e1d8f..ee420925692f9dcc9dfc3906c938b09e4c638b41 100644 (file)
@@ -4,6 +4,7 @@ REGISTER_NET_LINKED(ENT_CLIENT_WEPENT)
 REGISTER_NET_TEMP(CLIENT_WEPENT)
 
 .float vortex_charge;
+.int tuba_instrument;
 
 #ifdef SVQC