From: TimePath Date: Fri, 18 Dec 2015 00:30:06 +0000 (+1100) Subject: debugdraw: filtering improvements X-Git-Tag: xonotic-v0.8.2~1478 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=292502018a08f0a0f82358e5644f62fee3c7eed0;p=xonotic%2Fxonotic-data.pk3dir.git debugdraw: filtering improvements --- diff --git a/qcsrc/common/debug.qh b/qcsrc/common/debug.qh index 7470235f1..4285a5941 100644 --- a/qcsrc/common/debug.qh +++ b/qcsrc/common/debug.qh @@ -43,7 +43,7 @@ REGISTER_NET_TEMP(net_debug) bool autocvar_debugdraw; #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 +51,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 +60,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 +118,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 : 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; } )); diff --git a/qcsrc/lib/oo.qh b/qcsrc/lib/oo.qh index 0a9451097..2f871ccf1 100644 --- a/qcsrc/lib/oo.qh +++ b/qcsrc/lib/oo.qh @@ -13,6 +13,7 @@ .vector origin; .bool pure_data; +/** deprecated, use new_pure or NEW(class) */ #define make_pure(e) \ MACRO_BEGIN \ { \ @@ -36,7 +37,12 @@ entity __spawn(string _classname, string _sourceFile, int _sourceLine, bool pure this.classname = _classname; this.sourceLocFile = _sourceFile; this.sourceLocLine = _sourceLine; - if (pure) make_pure(this); + if (pure) { + make_pure(this); + #ifdef CSQC + setorigin(this, '0 0 10000'); + #endif + } return this; } @@ -46,18 +52,22 @@ entity __spawn(string _classname, string _sourceFile, int _sourceLine, bool pure #ifndef QCC_SUPPORT_ENTITYCLASS #define entityclass_2(name, base) typedef entity name #define class(name) - #define new(class) __spawn( #class, __FILE__, __LINE__, false) + #define _new(class, pure) __spawn( #class, __FILE__, __LINE__, pure) #else #define entityclass_2(name, base) entityclass name : base {} #define class(name) [[class(name)]] - #define new(class) ((class) __spawn( #class, __FILE__, __LINE__, false)) + #define _new(class, pure) ((class) __spawn( #class, __FILE__, __LINE__, pure)) #endif +/** entities you care about seeing (.origin works) */ +#define new(class) _new(class, false) +/** purely logical entities (.origin doesn't work) */ +#define new_pure(class) _new(class, true) #define spawn() __spawn("entity", __FILE__, __LINE__, false) entity _clearentity_ent; STATIC_INIT(clearentity) { - _clearentity_ent = new(clearentity); + _clearentity_ent = new_pure(clearentity); make_pure(_clearentity_ent); } void clearentity(entity e) @@ -79,7 +89,7 @@ void clearentity(entity e) // Macros to hide this implementation detail: #ifdef GMQCC #define NEW(cname, ...) \ - OVERLOAD(spawn##cname, new(cname),##__VA_ARGS__) + OVERLOAD(spawn##cname, new_pure(cname),##__VA_ARGS__) #define CONSTRUCT(cname, ...) \ OVERLOAD(spawn##cname, this,##__VA_ARGS__) @@ -87,7 +97,7 @@ void clearentity(entity e) #define NEW_(cname, ...) \ OVERLOAD_(spawn##cname, __VA_ARGS__) #define NEW(cname, ...) \ - NEW_(cname, new(cname),##__VA_ARGS__)(new(cname),##__VA_ARGS__) + NEW_(cname, new_pure(cname),##__VA_ARGS__)(new_pure(cname),##__VA_ARGS__) #define CONSTRUCT_(cname, ...) \ OVERLOAD_(spawn##cname, __VA_ARGS__) @@ -116,8 +126,7 @@ STATIC_INIT(RegisterClasses) entity cname##_vtbl; \ void cname##_vtbl_init() \ { \ - cname e = new(vtbl); \ - make_pure(e); \ + cname e = new_pure(vtbl); \ spawn##cname##_static(e); \ e.vtblname = #cname; \ /* Top level objects refer to themselves */ \