X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fdebug.qh;h=4a75c50fd2a214a61eb4ff0c67e1469b4b3aa787;hb=80a353319ac67130b65e8cd6b1ea2420f31928e2;hp=25dc11d1c391f2e2e1907cb0a868dd47f1169371;hpb=16d6ec38d2ddf13a0880b9cd50a3968c48da8f8a;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/debug.qh b/qcsrc/common/debug.qh index 25dc11d1c..4a75c50fd 100644 --- a/qcsrc/common/debug.qh +++ b/qcsrc/common/debug.qh @@ -1,9 +1,12 @@ #ifndef DEBUG_H #define DEBUG_H +#ifndef MENUQC .bool debug; .int sv_entnum; REGISTER_NET_TEMP(net_debug) +#endif + #ifdef CSQC NET_HANDLE(net_debug, bool isNew) { @@ -28,7 +31,7 @@ REGISTER_NET_TEMP(net_debug) int channel = MSG_ONE; msg_entity = to; WriteHeader(channel, net_debug); - WriteShort(channel, num_for_edict(this)); + WriteShort(channel, etof(this)); WriteByte(channel, is_pure(this)); WriteCoord(channel, this.origin.x); WriteCoord(channel, this.origin.y); @@ -40,10 +43,12 @@ REGISTER_NET_TEMP(net_debug) } #endif +#ifndef MENUQC bool autocvar_debugdraw; +#endif #ifdef CSQC - string autocvar_debugdraw_filter; + string autocvar_debugdraw_filter, autocvar_debugdraw_filterout; .int debugdraw_last; vector project_3d_to_2d(vector vec); void Debug_Draw() @@ -51,7 +56,7 @@ bool autocvar_debugdraw; if (!autocvar_debugdraw) return; static int debugdraw_frame; ++debugdraw_frame; - const int size = 8; + const int sz = 8; FOREACH_ENTITY(true, LAMBDA( if (it.debugdraw_last == debugdraw_frame) continue; int ofs = 0; @@ -60,8 +65,57 @@ bool autocvar_debugdraw; if (e.debugdraw_last == debugdraw_frame) continue; e.debugdraw_last = debugdraw_frame; vector rgb = (e.debug) ? '0 0 1' : '1 0 0'; + if (autocvar_debugdraw_filterout != "" && strhasword(autocvar_debugdraw_filterout, e.classname)) continue; if (autocvar_debugdraw_filter != "" && !strhasword(autocvar_debugdraw_filter, e.classname)) continue; - if (is_pure(e)) + if (autocvar_debugdraw == 3) + { + if (!e.entnum) continue; + } + if (autocvar_debugdraw == 4) + { + if (e.origin) continue; + } + else if (autocvar_debugdraw > 4) + { + bool flag = true; + do { +// if (e.modelindex) break; +// if (e.absmin) break; +// if (e.absmax) break; +// if (e.entnum) break; +// if (e.drawmask) break; +// if (e.predraw) break; +// if (e.movetype) break; + if (e.solid) break; +// if (e.origin) break; +// if (e.oldorigin) break; +// if (e.velocity) break; +// if (e.angles) break; +// if (e.avelocity) break; +// if (e.classname) break; +// if (e.model) break; +// if (e.frame) break; +// if (e.skin) break; +// if (e.effects) break; +// if (e.mins) break; +// if (e.maxs) break; +// if (e.size) break; +// if (e.touch) break; +// if (e.use) break; +// if (e.think) break; +// if (e.blocked) break; +// if (e.nextthink) break; +// if (e.chain) break; +// if (e.netname) break; +// if (e.enemy) break; +// if (e.flags) break; +// if (e.colormap) break; +// if (e.owner) break; + flag = false; + } while (0); + if (!flag) continue; + } + else if (is_pure(e)) { if (autocvar_debugdraw < 2) continue; rgb.y = 1; @@ -69,11 +123,11 @@ bool autocvar_debugdraw; vector pos = project_3d_to_2d(e.origin); if (pos.z < 0) continue; pos.z = 0; - pos.y += ofs * size; + pos.y += ofs * sz; drawcolorcodedstring2(pos, - sprintf("%d: '%s'@%s:%d", (e.debug ? e.sv_entnum : num_for_edict(e)), + sprintf("%d: '%s'@%s:%d", (e.debug ? e.sv_entnum : etof(e)), e.classname, e.sourceLocFile, e.sourceLocLine), - size * '1 1 0', rgb, 0.5, DRAWFLAG_NORMAL); + sz * '1 1 0', rgb, 0.5, DRAWFLAG_NORMAL); ++ofs; } )); @@ -81,7 +135,7 @@ bool autocvar_debugdraw; #endif #ifdef SVQC - GENERIC_COMMAND(debugdraw_sv, "Dump all server entities") + COMMON_COMMAND(debugdraw_sv, "Dump all server entities") { switch (request) { @@ -111,4 +165,26 @@ bool autocvar_debugdraw; } #endif +GENERIC_COMMAND(bufstr_get, "Examine a string buffer object") +{ + switch (request) + { + case CMD_REQUEST_COMMAND: + { + int bufhandle = stof(argv(1)); + int string_index = stof(argv(2)); + string s = bufstr_get(bufhandle, string_index); + LOG_INFOF("%s\n", s); + return; + } + + default: + case CMD_REQUEST_USAGE: + { + LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " bufstr_get bufhandle string_index")); + return; + } + } +} + #endif