X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fdebug.qh;h=a8a76e47182f9fa67f757ce8428cb9bed355e3d0;hb=5d929ee0b1dc587e3154a4fa4b56e83b9ba9100b;hp=7144bf3da5ed6bb4166c3cc5b3f8f4895d416a7f;hpb=dd4a23ef1c7bac69cd8f09b604b022f5f9f6fe28;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/debug.qh b/qcsrc/common/debug.qh index 7144bf3da..a8a76e471 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. @@ -288,7 +292,7 @@ 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'; @@ -296,8 +300,8 @@ MUTATOR_HOOKFUNCTION(trace, SV_StartFrame) 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); @@ -403,7 +407,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 +415,7 @@ CLASS(DebugText3d, Object) } DESTRUCTOR(DebugText3d) { - strunzone(this.message); + strfree(this.message); } void DebugText3d_draw2d(DebugText3d this) { @@ -423,16 +427,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) @@ -459,13 +472,13 @@ NET_HANDLE(debug_text_3d, bool is_new) { #define debug_text_3d_5(pos, msg, align, dur, vel) debug_text_3d_fn(pos, msg, align, dur, vel) ERASEABLE -void debug_text_3d_fn(vector pos, string msg, float align, float duration, vector velocity) { +void debug_text_3d_fn(vector pos, string msg, float align, float duration, vector vel) { WriteHeader(MSG_BROADCAST, debug_text_3d); WriteVector(MSG_BROADCAST, pos); WriteString(MSG_BROADCAST, msg); WriteFloat(MSG_BROADCAST, align); WriteFloat(MSG_BROADCAST, duration); - WriteVector(MSG_BROADCAST, velocity); + WriteVector(MSG_BROADCAST, vel); } #endif // SVQC