X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmutators%2Fmutator%2Fwaypoints%2Fwaypointsprites.qc;h=326a26219b34e8008fe275f5b6d22076c958454a;hb=e51ce3d45d2852ca793118fc73da9c25f789101f;hp=325bc05c9e1ec855637c43ff7dcf0077566f3d3e;hpb=9bce1b76574731019d36203e7704870957c4273b;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc index 325bc05c9..326a26219 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc @@ -47,9 +47,7 @@ bool WaypointSprite_SendEntity(entity this, entity to, float sendflags) if (sendflags & 64) { - WriteCoord(MSG_ENTITY, this.origin.x); - WriteCoord(MSG_ENTITY, this.origin.y); - WriteCoord(MSG_ENTITY, this.origin.z); + WriteVector(MSG_ENTITY, this.origin); } if (sendflags & 1) @@ -108,9 +106,9 @@ NET_HANDLE(waypointsprites, bool isnew) { void Ent_RemoveWaypointSprite(entity this) { - if (this.netname) strunzone(this.netname); - if (this.netname2) strunzone(this.netname2); - if (this.netname3) strunzone(this.netname3); + strfree(this.netname); + strfree(this.netname2); + strfree(this.netname3); } /** flags origin [team displayrule] [spritename] [spritename2] [spritename3] [lifetime maxdistance hideable] */ @@ -159,9 +157,7 @@ void Ent_WaypointSprite(entity this, bool isnew) if (sendflags & 64) { // unfortunately, this needs to be exact (for the 3D display) - this.origin_x = ReadCoord(); - this.origin_y = ReadCoord(); - this.origin_z = ReadCoord(); + this.origin = ReadVector(); setorigin(this, this.origin); } @@ -173,23 +169,17 @@ void Ent_WaypointSprite(entity this, bool isnew) if (sendflags & 2) { - if (this.netname) - strunzone(this.netname); - this.netname = strzone(ReadString()); + strcpy(this.netname, ReadString()); } if (sendflags & 4) { - if (this.netname2) - strunzone(this.netname2); - this.netname2 = strzone(ReadString()); + strcpy(this.netname2, ReadString()); } if (sendflags & 8) { - if (this.netname3) - strunzone(this.netname3); - this.netname3 = strzone(ReadString()); + strcpy(this.netname3, ReadString()); } if (sendflags & 16) @@ -249,6 +239,8 @@ vector spritelookupcolor(entity this, string s, vector def) string spritelookuptext(entity this, string s) { + if(autocvar_g_waypointsprite_spam && waypointsprite_count >= autocvar_g_waypointsprite_spam) + return "Spam"; // no need to translate this debug string if (s == WP_RaceStartFinish.netname) return (race_checkpointtime || race_mycheckpointtime) ? _("Finish") : _("Start"); if (s == WP_Weapon.netname) return Weapons_from(this.wp_extra).m_name; if (s == WP_Item.netname) return Items_from(this.wp_extra).m_waypoint; @@ -384,7 +376,7 @@ vector drawspritearrow(vector o, float ang, vector rgb, float a, float t) } // returns location of sprite healthbar -vector drawsprite_TextOrIcon(bool is_text, vector o, float ang, float minwidth, vector rgb, float a, vector sz, string str, string pic) +vector drawsprite_TextOrIcon(bool is_text, vector o, float ang, float minwidth, vector rgb, float a, vector sz, string str) { float algnx, algny; float sw, w, h; @@ -437,7 +429,7 @@ vector drawsprite_TextOrIcon(bool is_text, vector o, float ang, float minwidth, if (is_text) drawstring(o, str, sz, rgb, a, DRAWFLAG_NORMAL); else - drawpic(o, pic, sz, rgb, a, DRAWFLAG_NORMAL); + drawpic(o, str, sz, rgb, a, DRAWFLAG_NORMAL); o.x += 0.5 * sw; o.y += 0.5 * h; @@ -591,15 +583,16 @@ void Draw_WaypointSprite(entity this) { // scale it to be just in view vector d; - float f1, f2; d = o - '0.5 0 0' * vid_conwidth - '0 0.5 0' * vid_conheight; ang = atan2(-d.x, -d.y); if (o.z < 0) ang += M_PI; - f1 = d.x / vid_conwidth; - f2 = d.y / vid_conheight; + float f1 = d.x / vid_conwidth; + float f2 = d.y / vid_conheight; + if (f1 == 0) { f1 = 0.000001; } + if (f2 == 0) { f2 = 0.000001; } if (max(f1, -f1) > max(f2, -f2)) { if (d.z * f1 > 0) { @@ -673,41 +666,49 @@ void Draw_WaypointSprite(entity this) o = drawspritearrow(o, ang, rgb, a, SPRITE_ARROW_SCALE * t); - vector iconcolor = ((autocvar_g_waypointsprite_iconcolor) ? '1 1 1' : rgb); - string spr_icon = spritelookupicon(this, spriteimage); - string pic = spr_icon; - bool icon_found = !(!spr_icon || spr_icon == ""); - if (icon_found) // it's valid, but let's make sure it exists! - { - pic = strcat(hud_skin_path, "/", spr_icon); - if(precache_pic(pic) == "") - { - pic = strcat("gfx/hud/default/", spr_icon); - if(!precache_pic(pic)) - icon_found = false; - } - } - + string pic = ""; + bool is_text = true; + if (!autocvar_g_waypointsprite_text) + { + string spr_icon = spritelookupicon(this, spriteimage); + pic = spr_icon; + bool icon_found = !(!spr_icon || spr_icon == ""); + if (icon_found) // it's valid, but let's make sure it exists! + { + pic = strcat(hud_skin_path, "/", spr_icon); + if(precache_pic(pic) == "") + { + pic = strcat("gfx/hud/default/", spr_icon); + if(!precache_pic(pic)) + icon_found = false; + } + } + if (icon_found) + is_text = false; + } + + vector sz; + vector txt_color; string txt = string_null; - if (autocvar_g_waypointsprite_text || !icon_found) + if (is_text) { - if (autocvar_g_waypointsprite_spam && waypointsprite_count >= autocvar_g_waypointsprite_spam) - txt = _("Spam"); - else - txt = spritelookuptext(this, spriteimage); + txt = spritelookuptext(this, spriteimage); if (this.helpme && time < this.helpme) txt = sprintf(_("%s needing help!"), txt); if (autocvar_g_waypointsprite_uppercase) txt = strtoupper(txt); + txt_color = rgb; + sz = waypointsprite_fontsize * '1 1 0'; + } + else + { + // for convenience icon path and color are saved to txt and txt_color + txt = pic; + txt_color = ((autocvar_g_waypointsprite_iconcolor) ? '1 1 1' : rgb); + sz = autocvar_g_waypointsprite_iconsize * '1 1 0'; } draw_beginBoldFont(); - bool is_text = (autocvar_g_waypointsprite_text || !icon_found); - vector sz; - if (is_text) - sz = waypointsprite_fontsize * '1 1 0'; - else - sz = autocvar_g_waypointsprite_iconsize * '1 1 0'; if (this.health >= 0) { float align = 0, marg; @@ -721,7 +722,7 @@ void Draw_WaypointSprite(entity this) marg = SPRITE_HEALTHBAR_MARGIN * t + 0.5 * sz.y; float minwidth = (SPRITE_HEALTHBAR_WIDTH + 2 * SPRITE_HEALTHBAR_BORDER) * t; - o = drawsprite_TextOrIcon(is_text, o, ang, minwidth, iconcolor, a, sz, txt, pic); + o = drawsprite_TextOrIcon(is_text, o, ang, minwidth, txt_color, a, sz, txt); drawhealthbar( o, 0, @@ -742,7 +743,7 @@ void Draw_WaypointSprite(entity this) } else { - drawsprite_TextOrIcon(is_text, o, ang, 0, iconcolor, a, sz, txt, pic); + drawsprite_TextOrIcon(is_text, o, ang, 0, txt_color, a, sz, txt); } draw_endBoldFont();