From: Mario Date: Fri, 29 May 2020 09:53:19 +0000 (+1000) Subject: Merge branch 'master' into Mario/qc_stats X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=dc44e46c250b3110b22cce3f5b8d957e033543ef;p=xonotic%2Fxonotic-data.pk3dir.git Merge branch 'master' into Mario/qc_stats --- dc44e46c250b3110b22cce3f5b8d957e033543ef diff --cc qcsrc/lib/fteqcc.log index 0000000000,0000000000..b1520c39ea new file mode 100644 --- /dev/null +++ b/qcsrc/lib/fteqcc.log @@@ -1,0 -1,0 +1,2 @@@ ++Args: F:\msys64\home\Admin\xonotic\fteqw\engine\release\fteqcc64.exe --version ++FTEQCC: May 19 2020 diff --cc qcsrc/lib/stats.qh index 06c168ba45,9bd4a3af94..6ee8079795 --- a/qcsrc/lib/stats.qh +++ b/qcsrc/lib/stats.qh @@@ -8,37 -8,64 +8,38 @@@ .int m_id; USING(vectori, vector); -const int STATS_ENGINE_RESERVE = 32; -// must be listed in ascending order -#define MAGIC_STATS(_, x) \ - _(x, MOVEVARS_AIRACCEL_QW_STRETCHFACTOR, 220) \ - _(x, MOVEVARS_AIRCONTROL_PENALTY, 221) \ - _(x, MOVEVARS_AIRSPEEDLIMIT_NONQW, 222) \ - _(x, MOVEVARS_AIRSTRAFEACCEL_QW, 223) \ - _(x, MOVEVARS_AIRCONTROL_POWER, 224) \ - _(x, MOVEFLAGS, 225) \ - _(x, MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL, 226) \ - _(x, MOVEVARS_WARSOWBUNNY_ACCEL, 227) \ - _(x, MOVEVARS_WARSOWBUNNY_TOPSPEED, 228) \ - _(x, MOVEVARS_WARSOWBUNNY_TURNACCEL, 229) \ - _(x, MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO, 230) \ - _(x, MOVEVARS_AIRSTOPACCELERATE, 231) \ - _(x, MOVEVARS_AIRSTRAFEACCELERATE, 232) \ - _(x, MOVEVARS_MAXAIRSTRAFESPEED, 233) \ - _(x, MOVEVARS_AIRCONTROL, 234) \ - _(x, FRAGLIMIT, 235) \ - _(x, TIMELIMIT, 236) \ - _(x, MOVEVARS_WALLFRICTION, 237) \ - _(x, MOVEVARS_FRICTION, 238) \ - _(x, MOVEVARS_WATERFRICTION, 239) \ - _(x, MOVEVARS_TICRATE, 240) \ - _(x, MOVEVARS_TIMESCALE, 241) \ - _(x, MOVEVARS_GRAVITY, 242) \ - _(x, MOVEVARS_STOPSPEED, 243) \ - _(x, MOVEVARS_MAXSPEED, 244) \ - _(x, MOVEVARS_SPECTATORMAXSPEED, 245) \ - _(x, MOVEVARS_ACCELERATE, 246) \ - _(x, MOVEVARS_AIRACCELERATE, 247) \ - _(x, MOVEVARS_WATERACCELERATE, 248) \ - _(x, MOVEVARS_ENTGRAVITY, 249) \ - _(x, MOVEVARS_JUMPVELOCITY, 250) \ - _(x, MOVEVARS_EDGEFRICTION, 251) \ - _(x, MOVEVARS_MAXAIRSPEED, 252) \ - _(x, MOVEVARS_STEPHEIGHT, 253) \ - _(x, MOVEVARS_AIRACCEL_QW, 254) \ - _(x, MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION, 255) \ - /**/ - -int g_magic_stats_hole = 0; - -#define MAGIC_STATS_FIX_MANUAL(it, var, id) \ - if (it.registered_id == "STAT_" #var) { --g_magic_stats_hole; it.m_id = id; } else - -#define MAGIC_STATS_FIX_AUTO(it, var, id) \ - if (it.m_id == id) { ++g_magic_stats_hole; ++it.m_id; } - -#define MAGIC_STATS_FIX(it) \ - it.m_id += g_magic_stats_hole; \ - MAGIC_STATS(MAGIC_STATS_FIX_MANUAL, it) { MAGIC_STATS(MAGIC_STATS_FIX_AUTO, it) } +REGISTRY(Stats, 256) - #define Stats_from(i) _Stats_from(i, NULL) +REGISTER_REGISTRY(Stats) +REGISTRY_SORT(Stats) +REGISTRY_CHECK(Stats) +STATIC_INIT(Stats_renumber) { FOREACH(Stats, true, it.m_id = i); } + ++REGISTRY_DEFINE_GET(Stats, NULL) + #define REGISTER_STAT(...) EVAL_REGISTER_STAT(OVERLOAD(REGISTER_STAT, __VA_ARGS__)) #define EVAL_REGISTER_STAT(...) __VA_ARGS__ + +#if defined(CSQC) + #define stats_get_int() ReadInt24_t() + #define stats_get_bool() boolean(ReadByte()) + #define stats_get_float() ReadFloat() + #define stats_get_vector() ReadVector() + #define stats_get_vectori() ReadInt72_t() + +.void(entity ent) m_receive; +#elif defined(SVQC) + #define stats_write_int(chan,id,ent) WriteInt24_t(chan, STAT(id, ent)) + #define stats_write_bool(chan,id,ent) WriteByte(chan, STAT(id, ent)) + #define stats_write_float(chan,id,ent) WriteFloat(chan, STAT(id, ent)) + #define stats_write_vector(chan,id,ent) WriteVector(chan, STAT(id, ent)) + #define stats_write_vectori(chan,id,ent) WriteInt72_t(chan, STAT(id, ent)) + +.bool(entity ent, entity player) m_check; +.void(entity ent, entity player) m_set; +.void(int chan, entity ent) m_send; +#endif + #if defined(CSQC) - /** Get all stats and store them as globals, access with `STAT(ID)` */ - void stats_get() {} #define STAT(...) EVAL_STAT(OVERLOAD(STAT, __VA_ARGS__)) #define EVAL_STAT(...) __VA_ARGS__ #define STAT_1(id) (RVALUE, _STAT(id)) @@@ -93,120 -164,19 +94,120 @@@ #define REGISTER_STAT_3(id, T, expr) #endif -REGISTRY(Stats, 256 - STATS_ENGINE_RESERVE) -REGISTER_REGISTRY(Stats) -REGISTRY_SORT(Stats) -REGISTRY_CHECK(Stats) +#ifdef GAMEQC +/** Player stats */ +.entity stats; -REGISTRY_DEFINE_GET(Stats, NULL) -STATIC_INIT(Stats_renumber) +REGISTER_NET_LINKED(ENT_CLIENT_STATS) + +const int Stats_groups_minor = 12; - const int Stats_groups_major = 22; // ceil(Stats_MAX / Stats_groups_minor) ++const int Stats_groups_major = 22; // ceil(REGISTRY_MAX(Stats) / Stats_groups_minor) + +#define G_MAJOR(id) (floor((id) / Stats_groups_minor)) +#define G_MINOR(id) ((id) % Stats_groups_minor) +#endif + +#ifdef CSQC +NET_HANDLE(ENT_CLIENT_STATS, bool isnew) +{ + make_pure(this); + const int majorBits = ReadInt24_t(); + for (int i = 0; i < Stats_groups_major; ++i) { + if (!(majorBits & BIT(i))) { + continue; + } + const int minorBits = ReadInt24_t(); + for (int j = 0; j < Stats_groups_minor; ++j) { + if (!(minorBits & BIT(j))) { + continue; + } - const entity it = Stats_from(Stats_groups_minor * i + j); ++ const entity it = REGISTRY_GET(Stats, Stats_groups_minor * i + j); + it.m_receive(it); + } + } + return true; +} +#endif + +#ifdef SVQC +int statsminorBitsArr[Stats_groups_major]; +void Stats_Write(entity data) +{ + if (!data) { + WriteShort(MSG_ENTITY, 0); + return; + } + TC(entity, data); + + for (int i = 0; i < Stats_groups_major; ++i) + statsminorBitsArr[i] = 0; + + int majorBits = 0; + FOREACH(Stats, true, { + const bool changed = it.m_check(data, data.owner); + if (changed) { + it.m_set(data, data.owner); + int maj = G_MAJOR(it.m_id); + majorBits = BITSET(majorBits, BIT(maj), true); + statsminorBitsArr[maj] = BITSET(statsminorBitsArr[maj], BIT(G_MINOR(it.m_id)), true); + } + }); + WriteInt24_t(MSG_ENTITY, majorBits); + + for (int i = 0; i < Stats_groups_major; ++i) + { + if (!(majorBits & BIT(i))) + continue; + + const int minorBits = statsminorBitsArr[i]; + WriteInt24_t(MSG_ENTITY, minorBits); + for (int j = 0; j < Stats_groups_minor; ++j) + { + if (!(minorBits & BIT(j))) + continue; + - const entity it = Stats_from(Stats_groups_minor * i + j); ++ const entity it = REGISTRY_GET(Stats, Stats_groups_minor * i + j); + it.m_send(MSG_ENTITY, data); + } + } +} +#endif + +#undef G_MAJOR +#undef G_MINOR + +#ifdef SVQC +bool Stats_Send(entity this, entity to, int sf) +{ + TC(entity, this); + WriteHeader(MSG_ENTITY, ENT_CLIENT_STATS); + TC(entity, this.owner); + Stats_Write(this); + return true; +} + +void Stats_update(entity e) { e.stats.SendFlags = 0xFFFFFF; } +void Stats_checkupdate(entity this) { FOREACH(Stats, true, { - it.m_id = STATS_ENGINE_RESERVE + i; - MAGIC_STATS_FIX(it); + const bool changed = it.m_check(this, this.owner); + if(changed) + { + Stats_update(this.owner); + break; // no need to keep looping once we've found a stat that needs updating + } }); + + this.nextthink = time; } -#ifdef SVQC -STATIC_INIT(stats_add) { stats_add(); } + +void Stats_new(entity this) +{ + entity ent = new_pure(Stats); + setthink(ent, Stats_checkupdate); + ent.nextthink = time; + ent.drawonlytoclient = this; + Net_LinkEntity((ent.owner = this).stats = ent, false, 0, Stats_Send); +} +void Stats_delete(entity e) { delete(e.stats); } #endif diff --cc qcsrc/tools/fteqcc.log index 0000000000,0000000000..4cd57b4758 new file mode 100644 --- /dev/null +++ b/qcsrc/tools/fteqcc.log @@@ -1,0 -1,0 +1,7 @@@ ++Args: F:\msys64\home\Admin\xonotic\fteqw\engine\release\fteqcc64.exe -std=gmqcc -Ooverlap-locals -O3 -Werror -Wall -Wno-field-redeclared -flno -futf8 -fno-bail-on-werror -frelaxed-switch -freturn-assignments -o F:/msys64/home/Admin/xonotic/data/xonotic-data.pk3dir/qcsrc/../progs.dat ../../.tmp/server.qc ++:: warning: Disabling -Ofilenames to satisfy -flno request ++FTEQCC: May 19 2020 ++Source file: ../../.tmp/server.qc ++Globals exceeds 32k - an enhanced QCVM will be required ++Compile finished: F:/msys64/home/Admin/xonotic/data/xonotic-data.pk3dir/qcsrc/../progs.dat (id format) ++Done. 0 warnings