From: Mario Date: Thu, 6 Oct 2016 10:10:28 +0000 (+1000) Subject: Move tuba instrument networking to the weapon entity X-Git-Tag: xonotic-v0.8.2~326^2~51 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4d2aa5ea3a66a812a44abc7514f4b1b6be5c8827;p=xonotic%2Fxonotic-data.pk3dir.git Move tuba instrument networking to the weapon entity --- diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index a48524047..d4e4d6093 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -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) { diff --git a/qcsrc/common/weapons/weapon/tuba.qc b/qcsrc/common/weapons/weapon/tuba.qc index bd6edcef0..1c6948c39 100644 --- a/qcsrc/common/weapons/weapon/tuba.qc +++ b/qcsrc/common/weapons/weapon/tuba.qc @@ -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; diff --git a/qcsrc/common/wepent.qc b/qcsrc/common/wepent.qc index e53c19750..bb9308424 100644 --- a/qcsrc/common/wepent.qc +++ b/qcsrc/common/wepent.qc @@ -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(); }) \ \ /**/ diff --git a/qcsrc/common/wepent.qh b/qcsrc/common/wepent.qh index 32f0cab3e..ee4209256 100644 --- a/qcsrc/common/wepent.qh +++ b/qcsrc/common/wepent.qh @@ -4,6 +4,7 @@ REGISTER_NET_LINKED(ENT_CLIENT_WEPENT) REGISTER_NET_TEMP(CLIENT_WEPENT) .float vortex_charge; +.int tuba_instrument; #ifdef SVQC