From: TimePath Date: Fri, 11 Dec 2015 08:08:02 +0000 (+1100) Subject: Weapons: fix cvar networking for late joins X-Git-Tag: xonotic-v0.8.2~1512 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f68bb77582de0b390edf0c4ee7c8122327ffb177;p=xonotic%2Fxonotic-data.pk3dir.git Weapons: fix cvar networking for late joins --- diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index 429dfbd79..7972e7f0f 100644 --- a/qcsrc/common/weapons/all.qh +++ b/qcsrc/common/weapons/all.qh @@ -97,22 +97,26 @@ GENERIC_COMMAND(dumpweapons, "Dump all weapons into weapons_dump.txt") // WEAPON #ifdef SVQC entity W_PROP_reloader; float autocvar_w_prop_interval = 0; -.void(Weapon this) wr_net; -void W_PROP_reload() +.void(Weapon this, int) wr_net; +void W_PROP_reload(int chan, entity to) { - SELFPARAM(); - this.nextthink = time + autocvar_w_prop_interval; + W_PROP_reloader.nextthink = time + autocvar_w_prop_interval; + msg_entity = to; FOREACH(Weapons, true, { it.wr_update(it); - void(Weapon) f = it.wr_net; - if (f) f(it); + void(Weapon, int) f = it.wr_net; + if (f) f(it, chan); }); } +void W_PROP_think() +{ + W_PROP_reload(MSG_ALL, NULL); +} STATIC_INIT_LATE(W_PROP_reloader) { entity e = W_PROP_reloader = new(W_PROP_reloader); make_pure(e); - WITH(entity, self, e, (e.think = W_PROP_reload)()); + WITH(entity, self, e, (e.think = W_PROP_think)()); } #endif @@ -241,28 +245,22 @@ X(reload_time, float) #define W_NET_END() } #elif defined(SVQC) #define W_NET_BEGIN(class) \ - METHOD(class, wr_net, void(class this)) \ + METHOD(class, wr_net, void(class this, int chan)) \ { \ - int chan = MSG_INIT; \ - for (;;) \ + bool commit = false; \ + int i = 0; + #define _W_NET(class, fld, T, wepname) \ { \ - bool commit = false; \ - int i = 0; - #define _W_NET(class, fld, T, wepname) \ + ++i; \ + T it = this.wepvar_##fld; \ + if (chan == MSG_ONE || it != this.baseline.wepvar_##fld) \ { \ - ++i; \ - T it = this.wepvar_##fld; \ - if (it != this.baseline.wepvar_##fld) \ - { \ - if (!commit) { commit = true; WriteHeader(chan, WeaponUpdate); WriteByte(chan, this.m_id); } \ - WriteByte(chan, i); Write_##T(chan, it); \ - } \ - } - #define W_NET_END() \ - if (commit) WriteByte(chan, 0); \ - if (chan == MSG_INIT) chan = MSG_ALL; \ - else break; \ - } \ + if (!commit) { commit = true; WriteHeader(chan, WeaponUpdate); WriteByte(chan, this.m_id); } \ + WriteByte(chan, i); Write_##T(chan, it); \ + } \ + } + #define W_NET_END() \ + if (commit) WriteByte(chan, 0); \ } #else #define W_NET_BEGIN(class) diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 953f79c84..ad5b5fc9e 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -630,6 +630,8 @@ void PutClientInServer() } } +void ClientInit_misc(); + .float ebouncefactor, ebouncestop; // electro's values // TODO do we need all these fields, or should we stop autodetecting runtime // changes and just have a console command to update this? @@ -638,7 +640,15 @@ bool ClientInit_SendEntity(entity this, entity to, int sf) WriteHeader(MSG_ENTITY, _ENT_CLIENT_INIT); return = true; msg_entity = to; + // MSG_INIT replacement + // TODO: make easier to use Registry_send_all(); + W_PROP_reload(MSG_ONE, to); + ClientInit_misc(); + MUTATOR_CALLHOOK(Ent_Init); +} +void ClientInit_misc() +{ int channel = MSG_ONE; WriteHeader(channel, ENT_CLIENT_INIT); WriteByte(channel, g_nexball_meter_period * 32); @@ -658,8 +668,6 @@ bool ClientInit_SendEntity(entity this, entity to, int sf) WriteByte(channel, self.count * 255.0); // g_balance_armor_blockpercent WriteByte(channel, serverflags); // client has to know if it should zoom or not WriteCoord(channel, autocvar_g_trueaim_minrange); - - MUTATOR_CALLHOOK(Ent_Init); } void ClientInit_CheckUpdate()