X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fdebug.qh;h=c95bb2d73cf95e458a66485679e06b74f79357e5;hp=936f1e028857e121d97fcdc985af76011bde90e3;hb=93afc08b09294e6dea4d0c98ce5226fdee9d1c92;hpb=c3f4bfe02b1f024b183210717a4da3f84ddc0079 diff --git a/qcsrc/common/debug.qh b/qcsrc/common/debug.qh index 936f1e028..c95bb2d73 100644 --- a/qcsrc/common/debug.qh +++ b/qcsrc/common/debug.qh @@ -1,5 +1,9 @@ #pragma once +#ifdef CSQC +#include +#endif + // This includes some functions useful for debugging. // Some more bot-specific ones are in server/pathlib/debug.qc. @@ -193,7 +197,7 @@ bool autocvar_debugdraw; #endif -GENERIC_COMMAND(bufstr_get, "Examine a string buffer object") +GENERIC_COMMAND(bufstr_get, "Examine a string buffer object", false) { switch (request) { @@ -201,8 +205,7 @@ GENERIC_COMMAND(bufstr_get, "Examine a string buffer object") { int bufhandle = stof(argv(1)); int string_index = stof(argv(2)); - string s = bufstr_get(bufhandle, string_index); - LOG_INFOF("%s", s); + LOG_INFO(bufstr_get(bufhandle, string_index)); return; } @@ -216,7 +219,7 @@ GENERIC_COMMAND(bufstr_get, "Examine a string buffer object") } -GENERIC_COMMAND(version, "Print the current version") +GENERIC_COMMAND(version, "Print the current version", false) { switch (request) { @@ -238,7 +241,7 @@ GENERIC_COMMAND(version, "Print the current version") #ifdef CSQC void(float bufhandle, string pattern, string antipattern) buf_cvarlist = #517; #endif -GENERIC_COMMAND(cvar_localchanges, "Print locally changed cvars") +GENERIC_COMMAND(cvar_localchanges, "Print locally changed cvars", false) { switch (request) { @@ -288,16 +291,16 @@ MUTATOR_HOOKFUNCTION(trace, SV_StartFrame) it.debug_trace_button = btn; if (!btn || skip) continue; FOREACH_ENTITY(true, { - it.solid_prev = it.solid; + it.solid_prev = it.solid; it.solid = SOLID_BBOX; }); vector forward = '0 0 0'; vector right = '0 0 0'; vector up = '0 0 0'; - MAKEVECTORS(makevectors, it.v_angle, forward, right, up); + MAKE_VECTORS(it.v_angle, forward, right, up); vector pos = it.origin + it.view_ofs; traceline(pos, pos + forward * max_shot_distance, MOVE_NORMAL, it); FOREACH_ENTITY(true, { - it.solid = it.solid_prev; - it.solid_prev = 0; + it.solid = it.solid_prev; + it.solid_prev = 0; }); entity e = trace_ent; int i = etof(e); @@ -329,7 +332,7 @@ STATIC_INIT(TRACE_ENT) #endif -GENERIC_COMMAND(find, "Search through entities for matching classname") +GENERIC_COMMAND(find, "Search through entities for matching classname", false) { switch (request) { @@ -360,7 +363,7 @@ GENERIC_COMMAND(find, "Search through entities for matching classname") } -GENERIC_COMMAND(findat, "Search through entities for matching origin") +GENERIC_COMMAND(findat, "Search through entities for matching origin", false) { switch (request) { @@ -403,7 +406,7 @@ CLASS(DebugText3d, Object) CONSTRUCT(DebugText3d); this.origin = pos; this.message = strzone(msg); - this.health = align; + SetResource(this, RES_HEALTH, align); this.hit_time = time; this.fade_rate = fade_rate_; this.velocity = vel; @@ -411,7 +414,7 @@ CLASS(DebugText3d, Object) } DESTRUCTOR(DebugText3d) { - strunzone(this.message); + strfree(this.message); } void DebugText3d_draw2d(DebugText3d this) { @@ -423,16 +426,25 @@ CLASS(DebugText3d, Object) return; } - int size = 8; + int size = 11; vector screen_pos = project_3d_to_2d(this.origin) + since_created * this.velocity; - float align = this.health; - if (align > 0) - screen_pos.x -= stringwidth(this.message, true, size * '1 1 0') * min(1, align); if (screen_pos.z < 0) return; // behind camera + screen_pos.z = 0; + float align = GetResource(this, RES_HEALTH); + string msg; + vector msg_pos; - vector rgb = '1 1 0'; - drawcolorcodedstring2_builtin(screen_pos, this.message, size * '1 1 0', rgb, alpha_, DRAWFLAG_NORMAL); + int n = tokenizebyseparator(this.message, "\n"); + for(int k = 0; k < n; ++k) + { + msg = argv(k); + msg_pos = screen_pos + k * 1.25 * size * eY; + if (align > 0) + msg_pos.x -= stringwidth(msg, true, size * '1 1 0') * min(1, align); + + drawcolorcodedstring_builtin(msg_pos, msg, size * '1 1 0', alpha_, DRAWFLAG_NORMAL); + } } ATTRIB(DebugText3d, draw2d, void(DebugText3d), DebugText3d_draw2d); ENDCLASS(DebugText3d)