From: terencehill Date: Sat, 27 May 2017 16:15:28 +0000 (+0200) Subject: Optimize client and server vector operations mostly by replacing lots of eX * a ... X-Git-Tag: xonotic-v0.8.5~2699^2~3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=dcac7f66f9aab82bfd3d01668f70017e605931bc;p=xonotic%2Fxonotic-data.pk3dir.git Optimize client and server vector operations mostly by replacing lots of eX * a + eY * b with vec2(a, b) --- diff --git a/qcsrc/client/hud/hud.qc b/qcsrc/client/hud/hud.qc index 36de6b3f1..ad7f83fa9 100644 --- a/qcsrc/client/hud/hud.qc +++ b/qcsrc/client/hud/hud.qc @@ -109,10 +109,7 @@ vector HUD_GetTableSize_BestItemAR(int item_count, vector psize, float item_aspe rows = ceil(item_count/columns); } - if(vertical) - return eX * best_rows + eY * best_columns; - else - return eX * best_columns + eY * best_rows; + return (vertical) ? vec2(best_rows, best_columns) : vec2(best_columns, best_rows); } /* diff --git a/qcsrc/client/hud/hud.qh b/qcsrc/client/hud/hud.qh index 9f0f4e7bf..aa8b62654 100644 --- a/qcsrc/client/hud/hud.qh +++ b/qcsrc/client/hud/hud.qh @@ -356,7 +356,7 @@ REGISTER_HUD_PANEL(SCOREBOARD, Scoreboard_Draw, scoreboard, PANEL_CO new_size.x = max_panel_width; \ new_size.y = panel_size.y * (new_size.x / panel_size.x); \ } \ - vector new_pos = eX * (panel_bg_border + 0.5 * max_panel_width) + eY * 0.5 * vid_conheight - 0.5 * new_size; \ + vector new_pos = vec2(panel_bg_border + 0.5 * max_panel_width, 0.5 * vid_conheight) - 0.5 * new_size; \ panel_pos = (1 - autocvar__menu_alpha) * panel_pos + (autocvar__menu_alpha) * new_pos; \ panel_size = (1 - autocvar__menu_alpha) * panel_size + (autocvar__menu_alpha) * new_size; \ } MACRO_END diff --git a/qcsrc/client/hud/hud_config.qc b/qcsrc/client/hud/hud_config.qc index 4897ba551..0cea6f6c8 100644 --- a/qcsrc/client/hud/hud_config.qc +++ b/qcsrc/client/hud/hud_config.qc @@ -1229,11 +1229,11 @@ void HUD_Configure_DrawGrid() hud_configure_realGridSize.y = hud_configure_gridSize.y * vid_conheight; vector s; // x-axis - s = eX + eY * vid_conheight; + s = vec2(1, vid_conheight); for(i = 1; i < 1/hud_configure_gridSize.x; ++i) drawfill(eX * i * hud_configure_realGridSize.x, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL); // y-axis - s = eY + eX * vid_conwidth; + s = vec2(vid_conwidth, 1); for(i = 1; i < 1/hud_configure_gridSize.y; ++i) drawfill(eY * i * hud_configure_realGridSize.y, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL); } @@ -1285,11 +1285,13 @@ const string hlBorder = "gfx/hud/default/border_highlighted"; const string hlBorder2 = "gfx/hud/default/border_highlighted2"; void HUD_Panel_HlBorder(float myBorder, vector color, float theAlpha) { - drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * theAlpha, DRAWFLAG_NORMAL); - drawpic_tiled(panel_pos - '1 1 0' * myBorder, hlBorder, '8 1 0' * hlBorderSize, eX * (panel_size.x + 2 * myBorder) + eY * hlBorderSize, color, theAlpha, DRAWFLAG_NORMAL); - drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * (panel_size.y + 2 * myBorder - hlBorderSize), hlBorder, '8 1 0' * hlBorderSize, eX * (panel_size.x + 2 * myBorder) + eY * hlBorderSize, color, theAlpha, DRAWFLAG_NORMAL); - drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * hlBorderSize, hlBorder2, '1 8 0' * hlBorderSize, eY * (panel_size.y + 2 * myBorder - 2 * hlBorderSize) + eX * hlBorderSize, color, theAlpha, DRAWFLAG_NORMAL); - drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * hlBorderSize + eX * (panel_size.x + 2 * myBorder - hlBorderSize), hlBorder2, '1 8 0' * hlBorderSize, eY * (panel_size.y + 2 * myBorder - 2 * hlBorderSize) + eX * hlBorderSize, color, theAlpha, DRAWFLAG_NORMAL); + vector pos = panel_pos - vec2(myBorder, myBorder); + drawfill(pos, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * theAlpha, DRAWFLAG_NORMAL); + drawpic_tiled(pos, hlBorder, '8 1 0' * hlBorderSize, vec2(panel_size.x + 2 * myBorder, hlBorderSize), color, theAlpha, DRAWFLAG_NORMAL); + drawpic_tiled(pos + eY * (panel_size.y + 2 * myBorder - hlBorderSize), hlBorder, '8 1 0' * hlBorderSize, vec2(panel_size.x + 2 * myBorder, hlBorderSize), color, theAlpha, DRAWFLAG_NORMAL); + pos.y += hlBorderSize; + drawpic_tiled(pos, hlBorder2, '1 8 0' * hlBorderSize, vec2(hlBorderSize, panel_size.y + 2 * myBorder - 2 * hlBorderSize), color, theAlpha, DRAWFLAG_NORMAL); + drawpic_tiled(pos + eX * (panel_size.x + 2 * myBorder - hlBorderSize), hlBorder2, '1 8 0' * hlBorderSize, vec2(hlBorderSize, panel_size.y + 2 * myBorder - 2 * hlBorderSize), color, theAlpha, DRAWFLAG_NORMAL); } void HUD_Configure_PostDraw() diff --git a/qcsrc/client/hud/panel/ammo.qc b/qcsrc/client/hud/panel/ammo.qc index 94545ac4b..7bae78cb6 100644 --- a/qcsrc/client/hud/panel/ammo.qc +++ b/qcsrc/client/hud/panel/ammo.qc @@ -150,7 +150,7 @@ void HUD_Ammo() rows = HUD_GetRowCount(total_ammo_count, mySize, 3); columns = ceil((total_ammo_count)/rows); - ammo_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows); + ammo_size = vec2(mySize.x / columns, mySize.y / rows); vector offset = '0 0 0'; float newSize; @@ -207,7 +207,7 @@ void HUD_Ammo() { ammotype = GetAmmoFieldFromNum(i); DrawAmmoItem( - pos + eX * column * (ammo_size.x + offset.x) + eY * row * (ammo_size.y + offset.y), + pos + vec2(column * (ammo_size.x + offset.x), row * (ammo_size.y + offset.y)), ammo_size, ammotype, (wep.ammo_field == ammotype), @@ -229,7 +229,7 @@ void HUD_Ammo() float f = bound(0, nade_statuschange_elapsedtime*2, 1); - DrawAmmoNades(pos + eX * column * (ammo_size.x + offset.x) + eY * row * (ammo_size.y + offset.y), ammo_size, nade_prevstatus < nade_cnt && nade_cnt != 0 && f < 1, f); + DrawAmmoNades(pos + vec2(column * (ammo_size.x + offset.x), row * (ammo_size.y + offset.y)), ammo_size, nade_prevstatus < nade_cnt && nade_cnt != 0 && f < 1, f); } draw_endBoldFont(); diff --git a/qcsrc/client/hud/panel/centerprint.qc b/qcsrc/client/hud/panel/centerprint.qc index f67cbffbd..3c13fd9c2 100644 --- a/qcsrc/client/hud/panel/centerprint.qc +++ b/qcsrc/client/hud/panel/centerprint.qc @@ -161,16 +161,16 @@ void HUD_CenterPrint () if (hud_panel_radar_bottom >= 0.96 * vid_conheight) return; - panel_pos = eY * hud_panel_radar_bottom + eX * 0.5 * (vid_conwidth - panel_size_x); - panel_size_y = min(panel_size_y, vid_conheight - hud_panel_radar_bottom); + panel_pos.x = 0.5 * (vid_conwidth - panel_size.x); + panel_pos.y = hud_panel_radar_bottom; + panel_size.y = min(panel_size.y, vid_conheight - hud_panel_radar_bottom); } else if(!autocvar__hud_configure && scoreboard_fade_alpha) { // move the panel below the scoreboard if (scoreboard_bottom >= 0.96 * vid_conheight) return; - vector target_pos; - target_pos = eY * scoreboard_bottom + eX * 0.5 * (vid_conwidth - panel_size.x); + vector target_pos = vec2(0.5 * (vid_conwidth - panel_size.x), scoreboard_bottom); if(target_pos.y > panel_pos.y) { panel_pos = panel_pos + (target_pos - panel_pos) * sqrt(scoreboard_fade_alpha); diff --git a/qcsrc/client/hud/panel/healtharmor.qc b/qcsrc/client/hud/panel/healtharmor.qc index 69fced532..5e2bfd3a5 100644 --- a/qcsrc/client/hud/panel/healtharmor.qc +++ b/qcsrc/client/hud/panel/healtharmor.qc @@ -110,7 +110,7 @@ void HUD_HealthArmor() DrawNumIcon(pos, mySize, hp, biggercount, 0, iconalign, HUD_Get_Num_Color(hp, maxtotal), 1); if(fuel) - HUD_Panel_DrawProgressBar(pos, eX * mySize.x + eY * 0.2 * mySize.y, "progressbar", fuel/100, 0, (baralign == 1 || baralign == 3), autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); + HUD_Panel_DrawProgressBar(pos, vec2(mySize.x, 0.2 * mySize.y), "progressbar", fuel/100, 0, (baralign == 1 || baralign == 3), autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); } else { diff --git a/qcsrc/client/hud/panel/modicons.qc b/qcsrc/client/hud/panel/modicons.qc index b736dced6..c3e91d3e9 100644 --- a/qcsrc/client/hud/panel/modicons.qc +++ b/qcsrc/client/hud/panel/modicons.qc @@ -38,8 +38,8 @@ void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, int layout, int if(layout) { - drawpic_aspect_skin(myPos, pic, eX * 0.7 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(myPos + eX * 0.7 * mySize.x, ftos(stat), eX * 0.3 * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL); + drawpic_aspect_skin(myPos, pic, vec2(0.7 * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(myPos + eX * 0.7 * mySize.x, ftos(stat), vec2(0.3 * mySize.x, mySize.y), color, panel_fg_alpha, DRAWFLAG_NORMAL); } else drawstring_aspect(myPos, ftos(stat), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL); @@ -63,11 +63,12 @@ void HUD_Mod_CA(vector myPos, vector mySize) int i; float row = 0, column = 0; - vector pos, itemSize; - itemSize = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows); + vector pos = '0 0 0', itemSize; + itemSize = vec2(mySize.x / columns, mySize.y / rows); for(i=0; i mySize.y) { // Horizontal arrangement - slot_size = eX * mySize.x / all_keys + eY * mySize.y; + slot_size = vec2(mySize.x / all_keys, mySize.y); for(i = 0; i < all_keys; ++i) KH_SLOTS[i] = pos + eX * slot_size.x * i; } else { // Vertical arrangement - slot_size = eX * mySize.x + eY * mySize.y / all_keys; + slot_size = vec2(mySize.x, mySize.y / all_keys); for(i = 0; i < all_keys; ++i) KH_SLOTS[i] = pos + eY * slot_size.y * i; } @@ -432,10 +433,10 @@ void HUD_Mod_Keepaway(vector pos, vector mySize) if(mySize.x > mySize.y) { kaball_pos = pos + eX * 0.25 * mySize.x; - kaball_size = eX * 0.5 * mySize.x + eY * mySize.y; + kaball_size = vec2(0.5 * mySize.x, mySize.y); } else { kaball_pos = pos + eY * 0.25 * mySize.y; - kaball_size = eY * 0.5 * mySize.y + eX * mySize.x; + kaball_size = vec2(mySize.x, 0.5 * mySize.y); } float kaball_statuschange_elapsedtime = time - kaball_statuschange_time; @@ -445,7 +446,7 @@ void HUD_Mod_Keepaway(vector pos, vector mySize) drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f); if(kaball) - drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL); + drawpic_aspect_skin(pos, "keepawayball_carrying", vec2(mySize.x, mySize.y), '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL); } @@ -548,15 +549,19 @@ void HUD_Mod_Race(vector pos, vector mySize) if(mySize.x > mySize.y) { // text on left side squareSize = min(mySize.y, mySize.x/2); - textPos = pos + eX * 0.5 * max(0, mySize.x/2 - squareSize) + eY * 0.5 * (mySize.y - squareSize); - medalPos = pos + eX * 0.5 * max(0, mySize.x/2 - squareSize) + eX * 0.5 * mySize.x + eY * 0.5 * (mySize.y - squareSize); + vector ofs = vec2(0.5 * max(0, mySize.x/2 - squareSize), 0.5 * (mySize.y - squareSize)); + textPos = pos + ofs; + ofs.y += 0.5 * mySize.x; + medalPos = pos + ofs; } else { // text on top squareSize = min(mySize.x, mySize.y/2); - textPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eX * 0.5 * (mySize.x - squareSize); - medalPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eY * 0.5 * mySize.y + eX * 0.5 * (mySize.x - squareSize); + vector ofs = vec2(0.5 * (mySize.x - squareSize), 0.5 * max(0, mySize.y/2 - squareSize)); + textPos = pos + ofs; + ofs.y += 0.5 * mySize.y; + medalPos = pos + ofs; } - vector textSize = eX * squareSize + eY * 0.25 * squareSize; + vector textSize = vec2(squareSize, 0.25 * squareSize); race_showTime(_("Personal best"), textPos, eY * 0.25 * squareSize, t, textSize, time - crecordtime_change_time); @@ -665,9 +670,9 @@ void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, int layout, in //draw the text color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max if (layout == 2) // average pps - drawstring_aspect(myPos + eX * mySize.y, ftos_decimals(stat, 2), eX * (2/3) * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(myPos + eX * mySize.y, ftos_decimals(stat, 2), vec2((2/3) * mySize.x, mySize.y), color, panel_fg_alpha, DRAWFLAG_NORMAL); else // percentage of average pps - drawstring_aspect(myPos + eX * mySize.y, strcat( ftos(floor(pps_ratio*100 + 0.5)), "%" ), eX * (2/3) * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(myPos + eX * mySize.y, strcat( ftos(floor(pps_ratio*100 + 0.5)), "%" ), vec2((2/3) * mySize.x, mySize.y), color, panel_fg_alpha, DRAWFLAG_NORMAL); } //draw the icon @@ -694,10 +699,10 @@ void HUD_Mod_Dom(vector myPos, vector mySize) int i; float row = 0, column = 0; vector pos, itemSize; - itemSize = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows); + itemSize = vec2(mySize.x / columns, mySize.y / rows); for(i=0; i 0) // next one? - { s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname); - } } } if(s != "" && a > 0) { - drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL); + str_pos = pos + vec2(0.5 * (mySize.x - stringwidth(s, true, '1 1 0' * 0.2 * mySize.y)), 0.6 * mySize.y); + drawcolorcodedstring(str_pos, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL); } if(race_penaltytime) @@ -172,7 +175,8 @@ void HUD_RaceTimer () if(a > 0) { s = sprintf(_("^1PENALTY: %.1f (%s)"), race_penaltytime * 0.1, race_penaltyreason); - drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.8 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL); + str_pos = pos + vec2(0.5 * (mySize.x - stringwidth(s, true, '1 1 0' * 0.2 * mySize.y)), 0.8 * mySize.y); + drawcolorcodedstring(str_pos, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL); } } @@ -181,7 +185,8 @@ void HUD_RaceTimer () if(forcetime != "") { a = bound(0, (time - race_checkpointtime) / 0.5, 1); - drawstring_expanding(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(forcetime, false, '1 1 0' * 0.6 * mySize.y), forcetime, '1 1 0' * 0.6 * mySize.y, '1 1 1', panel_fg_alpha, 0, a); + str_pos = pos + eX * 0.5 * (mySize.x - stringwidth(forcetime, false, '1 1 0' * 0.6 * mySize.y)); + drawstring_expanding(str_pos, forcetime, '1 1 0' * 0.6 * mySize.y, '1 1 1', panel_fg_alpha, 0, a); } else a = 1; @@ -189,7 +194,8 @@ void HUD_RaceTimer () if(race_laptime && race_checkpoint != 255) { s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime)); - drawstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, false, '0.6 0.6 0' * mySize.y), s, '0.6 0.6 0' * mySize.y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); + str_pos = pos + eX * 0.5 * (mySize.x - stringwidth(s, false, '0.6 0.6 0' * mySize.y)); + drawstring(str_pos, s, '0.6 0.6 0' * mySize.y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); } draw_endBoldFont(); @@ -200,13 +206,15 @@ void HUD_RaceTimer () { a = bound(0, 2 - (time - race_mycheckpointtime), 1); s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -(race_mycheckpointenemy == ""), race_mycheckpointlapsdelta, race_mycheckpointenemy); - drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL); + str_pos = pos + vec2(0.5 * (mySize.x - stringwidth(s, true, '1 1 0' * 0.2 * mySize.y)), 0.6 * mySize.y); + drawcolorcodedstring(str_pos, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL); } if(race_othercheckpointtime && race_othercheckpointenemy != "") { a = bound(0, 2 - (time - race_othercheckpointtime), 1); s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -(race_othercheckpointenemy == ""), race_othercheckpointlapsdelta, race_othercheckpointenemy); - drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL); + str_pos = pos + vec2(0.5 * (mySize.x - stringwidth(s, true, '1 1 0' * 0.2 * mySize.y)), 0.6 * mySize.y); + drawcolorcodedstring(str_pos, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL); } if(race_penaltytime && !race_penaltyaccumulator) @@ -219,7 +227,8 @@ void HUD_RaceTimer () s = sprintf(_("^1PENALTY: %.1f (%s)"), (t - time) * 0.1, race_penaltyreason); else s = sprintf(_("^2PENALTY: %.1f (%s)"), 0, race_penaltyreason); - drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL); + str_pos = pos + vec2(0.5 * (mySize.x - stringwidth(s, true, '1 1 0' * 0.2 * mySize.y)), 0.6 * mySize.y); + drawcolorcodedstring(str_pos, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL); } } } diff --git a/qcsrc/client/hud/panel/score.qc b/qcsrc/client/hud/panel/score.qc index 972e4effb..24be15432 100644 --- a/qcsrc/client/hud/panel/score.qc +++ b/qcsrc/client/hud/panel/score.qc @@ -35,8 +35,8 @@ void HUD_Score_Rankings(vector pos, vector mySize, entity me) players_per_team = max(2, ceil((entries - 1) / team_count)); for(i=0; i 3) @@ -272,7 +272,7 @@ void HUD_Score() } } else - score_size = eX * mySize.x*(1/4) + eY * mySize.y*(1/3); + score_size = vec2(mySize.x / 4, mySize.y / 3); float max_fragcount; max_fragcount = -99; @@ -293,7 +293,7 @@ void HUD_Score() if (spectatee_status == -1) { - score_pos = pos + eX * column * (score_size.x + offset.x) + eY * row * (score_size.y + offset.y); + score_pos = pos + vec2(column * (score_size.x + offset.x), row * (score_size.y + offset.y)); if (max_fragcount == score) HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); drawstring_aspect(score_pos, ftos(score), score_size, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL); @@ -306,12 +306,12 @@ void HUD_Score() } else if(tm.team == myteam) { if (max_fragcount == score) - HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize.x + eY * mySize.y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL); + HUD_Panel_DrawHighlight(pos, vec2(0.75 * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(pos, ftos(score), vec2(0.75 * mySize.x, mySize.y), Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL); } else { if (max_fragcount == score) - HUD_Panel_DrawHighlight(pos + eX * 0.75 * mySize.x + eY * (1/3) * rows * mySize.y, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(pos + eX * 0.75 * mySize.x + eY * (1/3) * rows * mySize.y, ftos(score), score_size, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL); + HUD_Panel_DrawHighlight(pos + vec2(0.75 * mySize.x, (1/3) * rows * mySize.y), score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(pos + vec2(0.75 * mySize.x, (1/3) * rows * mySize.y), ftos(score), score_size, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL); ++rows; } } diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index b8c9a3ea1..795c7e53d 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -823,7 +823,7 @@ void Scoreboard_DrawItem(vector item_pos, vector rgb, entity pl, bool is_self, i bool is_spec = (entcs_GetTeam(pl.sv_entnum) == NUM_SPECTATOR); vector h_pos = item_pos; - vector h_size = eX * panel_size.x + eY * hud_fontsize.y * 1.25; + vector h_size = vec2(panel_size.x, hud_fontsize.y * 1.25); // alternated rows highlighting if(is_self) drawfill(h_pos, h_size, rgb, sbt_highlight_alpha_self, DRAWFLAG_NORMAL); @@ -833,6 +833,7 @@ void Scoreboard_DrawItem(vector item_pos, vector rgb, entity pl, bool is_self, i float fg_alpha = (is_self ? sbt_fg_alpha_self : sbt_fg_alpha); vector pos = item_pos; + vector pic_size = vec2(hud_fontsize.x * sbt_fixcolumnwidth_iconlen, hud_fontsize.y); pos.x += hud_fontsize.x * 0.5; pos.y += (1.25 - 1) / 2 * hud_fontsize.y; // center text vertically vector tmp = '0 0 0'; @@ -863,11 +864,11 @@ void Scoreboard_DrawItem(vector item_pos, vector rgb, entity pl, bool is_self, i tmp.x = sbt_field_size[i] + hud_fontsize.x; if(sbt_field_icon0 != "") - drawpic(pos - tmp, sbt_field_icon0, eY * hud_fontsize.y + eX * hud_fontsize.x * sbt_fixcolumnwidth_iconlen, sbt_field_icon1_rgb, fg_alpha, DRAWFLAG_NORMAL); + drawpic(pos - tmp, sbt_field_icon0, pic_size, sbt_field_icon1_rgb, fg_alpha, DRAWFLAG_NORMAL); if(sbt_field_icon1 != "") - drawpic(pos - tmp, sbt_field_icon1, eY * hud_fontsize.y + eX * hud_fontsize.x * sbt_fixcolumnwidth_iconlen, sbt_field_icon1_rgb, fg_alpha, DRAWFLAG_NORMAL); + drawpic(pos - tmp, sbt_field_icon1, pic_size, sbt_field_icon1_rgb, fg_alpha, DRAWFLAG_NORMAL); if(sbt_field_icon2 != "") - drawpic(pos - tmp, sbt_field_icon2, eY * hud_fontsize.y + eX * hud_fontsize.x * sbt_fixcolumnwidth_iconlen, sbt_field_icon2_rgb, fg_alpha, DRAWFLAG_NORMAL); + drawpic(pos - tmp, sbt_field_icon2, pic_size, sbt_field_icon2_rgb, fg_alpha, DRAWFLAG_NORMAL); } if(sbt_field[i] == SP_SEPARATOR) @@ -897,11 +898,11 @@ void Scoreboard_DrawItem(vector item_pos, vector rgb, entity pl, bool is_self, i tmp.x = sbt_field_size[i]; if(sbt_field_icon0 != "") - drawpic(pos - tmp, sbt_field_icon0, eY * hud_fontsize.y + eX * hud_fontsize.x * sbt_fixcolumnwidth_iconlen, sbt_field_icon1_rgb, fg_alpha, DRAWFLAG_NORMAL); + drawpic(pos - tmp, sbt_field_icon0, pic_size, sbt_field_icon1_rgb, fg_alpha, DRAWFLAG_NORMAL); if(sbt_field_icon1 != "") - drawpic(pos - tmp, sbt_field_icon1, eY * hud_fontsize.y + eX * hud_fontsize.x * sbt_fixcolumnwidth_iconlen, sbt_field_icon1_rgb, fg_alpha, DRAWFLAG_NORMAL); + drawpic(pos - tmp, sbt_field_icon1, pic_size, sbt_field_icon1_rgb, fg_alpha, DRAWFLAG_NORMAL); if(sbt_field_icon2 != "") - drawpic(pos - tmp, sbt_field_icon2, eY * hud_fontsize.y + eX * hud_fontsize.x * sbt_fixcolumnwidth_iconlen, sbt_field_icon2_rgb, fg_alpha, DRAWFLAG_NORMAL); + drawpic(pos - tmp, sbt_field_icon2, pic_size, sbt_field_icon2_rgb, fg_alpha, DRAWFLAG_NORMAL); pos.x -= sbt_field_size[i] + hud_fontsize.x; } } @@ -914,7 +915,7 @@ vector Scoreboard_DrawOthers(vector item_pos, vector rgb, int this_team, entity { int i = 0; vector h_pos = item_pos; - vector h_size = eX * panel_size.x + eY * hud_fontsize.y * 1.25; + vector h_size = vec2(panel_size.x, hud_fontsize.y * 1.25); bool complete = (this_team == NUM_SPECTATOR); @@ -1006,7 +1007,7 @@ vector Scoreboard_DrawOthers(vector item_pos, vector rgb, int this_team, entity pos.x += column_width; pos.x += hud_fontsize.x; } - return eX * item_pos.x + eY * (item_pos.y + i * hud_fontsize.y * 1.25); + return vec2(item_pos.x, item_pos.y + i * hud_fontsize.y * 1.25); } vector Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_size) @@ -1048,7 +1049,7 @@ vector Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_size) } pos = panel_pos; - vector tmp = eX * panel_size.x + eY * 1.25 * hud_fontsize.y; + vector tmp = vec2(panel_size.x, 1.25 * hud_fontsize.y); // rounded header if (sbt_bg_alpha) @@ -1185,11 +1186,11 @@ vector Scoreboard_AccuracyStats_Draw(vector pos, vector rgb, vector bg_size) // column highlighting for (int i = 0; i < columnns; ++i) if ((i % 2) == 0) - drawfill(pos + eX * weapon_width * rows * i, eY * height * rows + eX * weapon_width * rows, '0 0 0', sbt_highlight_alpha, DRAWFLAG_NORMAL); + drawfill(pos + eX * weapon_width * rows * i, vec2(weapon_width * rows, height * rows), '0 0 0', sbt_highlight_alpha, DRAWFLAG_NORMAL); // row highlighting for (int i = 0; i < rows; ++i) - drawfill(pos + eY * weapon_height + eY * height * i, eX * tmp.x + eY * hud_fontsize.y, rgb, sbt_highlight_alpha, DRAWFLAG_NORMAL); + drawfill(pos + eY * (weapon_height + height * i), vec2(tmp.x, hud_fontsize.y), rgb, sbt_highlight_alpha, DRAWFLAG_NORMAL); } average_accuracy = 0; @@ -1220,7 +1221,7 @@ vector Scoreboard_AccuracyStats_Draw(vector pos, vector rgb, vector bg_size) weapon_alpha = 0.2 * sbt_fg_alpha; // weapon icon - drawpic_aspect_skin(tmpos, it.model2, eX * weapon_width + eY * weapon_height, '1 1 1', weapon_alpha, DRAWFLAG_NORMAL); + drawpic_aspect_skin(tmpos, it.model2, vec2(weapon_width, weapon_height), '1 1 1', weapon_alpha, DRAWFLAG_NORMAL); // the accuracy if (weapon_stats >= 0) { weapons_with_stats += 1; @@ -1235,7 +1236,7 @@ vector Scoreboard_AccuracyStats_Draw(vector pos, vector rgb, vector bg_size) if(!autocvar_hud_panel_scoreboard_accuracy_nocolors) rgb = Accuracy_GetColor(weapon_stats); - drawstring(tmpos + eX * padding + eY * weapon_height, s, hud_fontsize, rgb, sbt_fg_alpha, DRAWFLAG_NORMAL); + drawstring(tmpos + vec2(padding, weapon_height), s, hud_fontsize, rgb, sbt_fg_alpha, DRAWFLAG_NORMAL); } tmpos.x += weapon_width * rows; pos.x += weapon_width * rows; @@ -1373,7 +1374,7 @@ vector Scoreboard_Rankings_Draw(vector pos, entity pl, vector rgb, vector bg_siz float ranksize = 3 * hud_fontsize.x; float timesize = 5 * hud_fontsize.x; - vector columnsize = eX * (ranksize + timesize + namesize + hud_fontsize.x) + eY * 1.25 * hud_fontsize.y; + vector columnsize = vec2(ranksize + timesize + namesize + hud_fontsize.x, 1.25 * hud_fontsize.y); int columns = max(1, floor((panel_size.x - 2 * panel_bg_padding) / columnsize.x)); columns = min(columns, RANKINGS_RECEIVED_CNT); @@ -1402,7 +1403,7 @@ vector Scoreboard_Rankings_Draw(vector pos, entity pl, vector rgb, vector bg_siz if (sbt_bg_alpha) drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, panel_size, rgb, sbt_bg_alpha, DRAWFLAG_NORMAL); - vector text_ofs = eX * 0.5 * hud_fontsize.x + eY * (1.25 - 1) / 2 * hud_fontsize.y; // center text vertically + vector text_ofs = vec2(0.5 * hud_fontsize.x, (1.25 - 1) / 2 * hud_fontsize.y); // center text vertically string str = ""; int column = 0, j = 0; for(i = 0; i < RANKINGS_RECEIVED_CNT; ++i) @@ -1509,6 +1510,7 @@ void Scoreboard_Draw() vector pos = panel_pos; entity pl, tm; string str; + vector str_pos; // Heading vector sb_heading_fontsize; @@ -1543,12 +1545,14 @@ void Scoreboard_Draw() draw_beginBoldFont(); vector rgb = Team_ColorRGB(tm.team); str = ftos(tm.(teamscores(ts_primary))); - drawstring(pos + team_score_baseoffset - eX * stringwidth(str, false, hud_fontsize * 1.5), str, hud_fontsize * 1.5, rgb, panel_fg_alpha, DRAWFLAG_NORMAL); + str_pos = pos + team_score_baseoffset - eX * stringwidth(str, false, hud_fontsize * 1.5); + drawstring(str_pos, str, hud_fontsize * 1.5, rgb, panel_fg_alpha, DRAWFLAG_NORMAL); if(ts_primary != ts_secondary) { str = ftos(tm.(teamscores(ts_secondary))); - drawstring(pos + team_score_baseoffset - eX * stringwidth(str, false, hud_fontsize) + eY * hud_fontsize.y * 1.5, str, hud_fontsize, rgb, panel_fg_alpha, DRAWFLAG_NORMAL); + str_pos = pos + team_score_baseoffset - vec2(stringwidth(str, false, hud_fontsize), hud_fontsize.y * 1.5); + drawstring(str_pos, str, hud_fontsize, rgb, panel_fg_alpha, DRAWFLAG_NORMAL); } draw_endBoldFont(); if(autocvar_hud_panel_scoreboard_bg_teams_color_team > 0) diff --git a/qcsrc/client/hud/panel/vote.qc b/qcsrc/client/hud/panel/vote.qc index d974bee4b..22f1678b6 100644 --- a/qcsrc/client/hud/panel/vote.qc +++ b/qcsrc/client/hud/panel/vote.qc @@ -74,8 +74,8 @@ void HUD_Vote() if(uid2name_dialog) { - panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight; - panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight; + panel_pos = vec2(0.3 * vid_conwidth, 0.1 * vid_conheight); + panel_size = vec2(0.4 * vid_conwidth, 0.3 * vid_conheight); } vector pos, mySize; @@ -115,20 +115,20 @@ void HUD_Vote() s = _("A vote has been called for:"); if(uid2name_dialog) s = _("Allow servers to store and display your name?"); - drawstring_aspect(pos, s, eX * mySize.x + eY * (2/8) * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(pos, s, vec2(mySize.x, (2/8) * mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); s = textShortenToWidth(ColorTranslateRGB(vote_called_vote), mySize.x, '1 1 0' * mySize.y * (1/8), stringwidth_colors); if(autocvar__hud_configure) s = _("^1Configure the HUD"); - drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize.y, s, eX * mySize.x + eY * (1.75/8) * mySize.y, panel_fg_alpha, DRAWFLAG_NORMAL); + drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize.y, s, vec2(mySize.x, (1.75/8) * mySize.y), panel_fg_alpha, DRAWFLAG_NORMAL); // print the yes/no counts s = sprintf("^2%s ^7(%d)", getcommandkey_forcename(_("Yes"), "vyes"), vote_yescount); - drawcolorcodedstring_aspect(pos + eY * (4/8) * mySize.y, s, eX * 0.5 * mySize.x + eY * (1.5/8) * mySize.y, panel_fg_alpha, DRAWFLAG_NORMAL); + drawcolorcodedstring_aspect(pos + eY * (4/8) * mySize.y, s, vec2(0.5 * mySize.x, (1.5/8) * mySize.y), panel_fg_alpha, DRAWFLAG_NORMAL); s = sprintf("^1%s ^7(%d)", getcommandkey_forcename(_("No"), "vno"), vote_nocount); - drawcolorcodedstring_aspect(pos + eX * 0.5 * mySize.x + eY * (4/8) * mySize.y, s, eX * 0.5 * mySize.x + eY * (1.5/8) * mySize.y, panel_fg_alpha, DRAWFLAG_NORMAL); + drawcolorcodedstring_aspect(pos + vec2(0.5 * mySize.x, (4/8) * mySize.y), s, vec2(0.5 * mySize.x, (1.5/8) * mySize.y), panel_fg_alpha, DRAWFLAG_NORMAL); pos.y += (5/8) * mySize.y; - vector tmp_size = eX * mySize.x + eY * (3/8) * mySize.y; + vector tmp_size = vec2(mySize.x, (3/8) * mySize.y); // draw the progress bar backgrounds drawpic_skin(pos, "voteprogress_back", tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); diff --git a/qcsrc/client/hud/panel/weapons.qc b/qcsrc/client/hud/panel/weapons.qc index 69fd82c9e..b4997467e 100644 --- a/qcsrc/client/hud/panel/weapons.qc +++ b/qcsrc/client/hud/panel/weapons.qc @@ -407,7 +407,7 @@ void HUD_Weapons() } // figure out the drawing position of weapon - weapon_pos = (panel_pos + eX * column * weapon_size.x + eY * row * weapon_size.y); + weapon_pos = panel_pos + vec2(column * weapon_size.x, row * weapon_size.y); // update position of the currently selected weapon if(it == panel_switchweapon) diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index a098bd7f9..c53943221 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -31,7 +31,7 @@ void draw_cursor(vector pos, vector ofs, string img, vector col, float a) { - ofs = eX * (ofs.x * SIZE_CURSOR.x) + eY * (ofs.y * SIZE_CURSOR.y); + ofs = vec2(ofs.x * SIZE_CURSOR.x, ofs.y * SIZE_CURSOR.y); drawpic(pos - ofs, strcat(draw_currentSkin, img), SIZE_CURSOR, col, a, DRAWFLAG_NORMAL); } diff --git a/qcsrc/client/mapvoting.qc b/qcsrc/client/mapvoting.qc index 7b07b6800..29728dfde 100644 --- a/qcsrc/client/mapvoting.qc +++ b/qcsrc/client/mapvoting.qc @@ -398,7 +398,7 @@ void MapVote_Draw() // higher than the image itself ratio for mapvote items to reserve space for long map names int item_aspect = (gametypevote) ? 3/1 : 5/3; - vector table_size = HUD_GetTableSize_BestItemAR(mv_num_maps, eX * (xmax - xmin) + eY * (ymax - ymin), item_aspect); + vector table_size = HUD_GetTableSize_BestItemAR(mv_num_maps, vec2(xmax - xmin, ymax - ymin), item_aspect); mv_columns = table_size.x; rows = table_size.y; diff --git a/qcsrc/client/shownames.qc b/qcsrc/client/shownames.qc index 6920a98d1..ceaf0a674 100644 --- a/qcsrc/client/shownames.qc +++ b/qcsrc/client/shownames.qc @@ -74,7 +74,7 @@ void Draw_ShowNames(entity this) vector eo = project_3d_to_2d(it.origin); if (eo.z < 0 || eo.x < 0 || eo.y < 0 || eo.x > vid_conwidth || eo.y > vid_conheight) continue; eo.z = 0; - if (vdist(((eX * o.x + eY * o.y) - eo), <, autocvar_hud_shownames_antioverlap_distance) + if (vdist((vec2(o) - eo), <, autocvar_hud_shownames_antioverlap_distance) && vlen2(it.origin - view_origin) < vlen2(this.origin - view_origin)) { overlap = 1; @@ -135,8 +135,8 @@ void Draw_ShowNames(entity this) if (o.z >= 0) { o.z = 0; - vector mySize = (eX * autocvar_hud_shownames_aspect + eY) * autocvar_hud_shownames_fontsize; - vector myPos = o - '0.5 0 0' * mySize.x - '0 1 0' * mySize.y; + vector mySize = (vec2(autocvar_hud_shownames_aspect, 1)) * autocvar_hud_shownames_fontsize; + vector myPos = o - vec2(0.5 * mySize.x, mySize.y); // size scaling mySize.x *= resize; mySize.y *= resize; @@ -147,17 +147,17 @@ void Draw_ShowNames(entity this) float namewidth = mySize.x; if (autocvar_hud_shownames_status && this.sameteam) { - vector v = namepos + '0 1 0' * autocvar_hud_shownames_fontsize * resize; - vector s = eX * 0.5 * mySize.x + eY * resize * autocvar_hud_shownames_statusbar_height; + vector pos = namepos + eY * autocvar_hud_shownames_fontsize * resize; + vector sz = vec2(0.5 * mySize.x, resize * autocvar_hud_shownames_statusbar_height); if (this.healthvalue > 0) { - HUD_Panel_DrawProgressBar(v, s, "nametag_statusbar", + HUD_Panel_DrawProgressBar(pos, sz, "nametag_statusbar", this.healthvalue / autocvar_hud_panel_healtharmor_maxhealth, false, 1, '1 0 0', a, DRAWFLAG_NORMAL); } if (this.armorvalue > 0) { - HUD_Panel_DrawProgressBar(v + eX * 0.5 * mySize.x, s, "nametag_statusbar", + HUD_Panel_DrawProgressBar(pos + eX * 0.5 * mySize.x, sz, "nametag_statusbar", this.armorvalue / autocvar_hud_panel_healtharmor_maxarmor, false, 0, '0 1 0', a, DRAWFLAG_NORMAL); } diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 8a70dcd61..651d0c3b2 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1200,7 +1200,7 @@ void HUD_Crosshair(entity this) } ring_inner_alpha = autocvar_crosshair_ring_vortex_inner_alpha; - ring_inner_rgb = eX * autocvar_crosshair_ring_vortex_inner_color_red + eY * autocvar_crosshair_ring_vortex_inner_color_green + eZ * autocvar_crosshair_ring_vortex_inner_color_blue; + ring_inner_rgb = vec3(autocvar_crosshair_ring_vortex_inner_color_red, autocvar_crosshair_ring_vortex_inner_color_green, autocvar_crosshair_ring_vortex_inner_color_blue); ring_inner_image = "gfx/crosshair_ring_inner.tga"; // draw the outer ring to show the current charge of the weapon @@ -1360,29 +1360,29 @@ void HUD_Draw(entity this) if(!intermission) if (MUTATOR_CALLHOOK(HUD_Draw_overlay)) { - drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, M_ARGV(0, vector), autocvar_hud_colorflash_alpha * M_ARGV(1, float), DRAWFLAG_ADDITIVE); + drawfill('0 0 0', vec2(vid_conwidth, vid_conheight), M_ARGV(0, vector), autocvar_hud_colorflash_alpha * M_ARGV(1, float), DRAWFLAG_ADDITIVE); } else if(STAT(FROZEN)) { - drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, ((STAT(REVIVE_PROGRESS)) ? ('0.25 0.90 1' + ('1 0 0' * STAT(REVIVE_PROGRESS)) + ('0 1 1' * STAT(REVIVE_PROGRESS) * -1)) : '0.25 0.90 1'), autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); + drawfill('0 0 0', vec2(vid_conwidth, vid_conheight), ((STAT(REVIVE_PROGRESS)) ? ('0.25 0.90 1' + ('1 0 0' * STAT(REVIVE_PROGRESS)) + ('0 1 1' * STAT(REVIVE_PROGRESS) * -1)) : '0.25 0.90 1'), autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); } HUD_Scale_Enable(); if(!intermission) if(STAT(NADE_TIMER) && autocvar_cl_nade_timer) // give nade top priority, as it's a matter of life and death { - DrawCircleClippedPic(eX * 0.5 * vid_conwidth + eY * 0.6 * vid_conheight, 0.1 * vid_conheight, "gfx/crosshair_ring.tga", STAT(NADE_TIMER), '0.25 0.90 1' + ('1 0 0' * STAT(NADE_TIMER)) - ('0 1 1' * STAT(NADE_TIMER)), autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); - drawstring_aspect(eY * 0.64 * vid_conheight, ((autocvar_cl_nade_timer == 2) ? _("Nade timer") : ""), eX * vid_conwidth + eY * 0.025 * vid_conheight, '1 1 1', 1, DRAWFLAG_NORMAL); + DrawCircleClippedPic(vec2(0.5 * vid_conwidth, 0.6 * vid_conheight), 0.1 * vid_conheight, "gfx/crosshair_ring.tga", STAT(NADE_TIMER), '0.25 0.90 1' + vec3(STAT(NADE_TIMER), -STAT(NADE_TIMER), -STAT(NADE_TIMER)), autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); + drawstring_aspect(eY * 0.64 * vid_conheight, ((autocvar_cl_nade_timer == 2) ? _("Nade timer") : ""), vec2(vid_conwidth, 0.025 * vid_conheight), '1 1 1', 1, DRAWFLAG_NORMAL); } else if(STAT(CAPTURE_PROGRESS)) { - DrawCircleClippedPic(eX * 0.5 * vid_conwidth + eY * 0.6 * vid_conheight, 0.1 * vid_conheight, "gfx/crosshair_ring.tga", STAT(CAPTURE_PROGRESS), '0.25 0.90 1', autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); - drawstring_aspect(eY * 0.64 * vid_conheight, _("Capture progress"), eX * vid_conwidth + eY * 0.025 * vid_conheight, '1 1 1', 1, DRAWFLAG_NORMAL); + DrawCircleClippedPic(vec2(0.5 * vid_conwidth, 0.6 * vid_conheight), 0.1 * vid_conheight, "gfx/crosshair_ring.tga", STAT(CAPTURE_PROGRESS), '0.25 0.90 1', autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); + drawstring_aspect(eY * 0.64 * vid_conheight, _("Capture progress"), vec2(vid_conwidth, 0.025 * vid_conheight), '1 1 1', 1, DRAWFLAG_NORMAL); } else if(STAT(REVIVE_PROGRESS)) { - DrawCircleClippedPic(eX * 0.5 * vid_conwidth + eY * 0.6 * vid_conheight, 0.1 * vid_conheight, "gfx/crosshair_ring.tga", STAT(REVIVE_PROGRESS), '0.25 0.90 1', autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); - drawstring_aspect(eY * 0.64 * vid_conheight, _("Revival progress"), eX * vid_conwidth + eY * 0.025 * vid_conheight, '1 1 1', 1, DRAWFLAG_NORMAL); + DrawCircleClippedPic(vec2(0.5 * vid_conwidth, 0.6 * vid_conheight), 0.1 * vid_conheight, "gfx/crosshair_ring.tga", STAT(REVIVE_PROGRESS), '0.25 0.90 1', autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); + drawstring_aspect(eY * 0.64 * vid_conheight, _("Revival progress"), vec2(vid_conwidth, 0.025 * vid_conheight), '1 1 1', 1, DRAWFLAG_NORMAL); } HUD_Scale_Disable(); @@ -2085,7 +2085,7 @@ void CSQC_UpdateView(entity this, float w, float h) contentavgalpha = contentavgalpha * (1 - contentalpha_temp) + incontent * contentalpha_temp; if(contentavgalpha) - drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, liquidcolor_prev, contentavgalpha * liquidalpha_prev, DRAWFLAG_NORMAL); + drawfill('0 0 0', vec2(vid_conwidth, vid_conheight), liquidcolor_prev, contentavgalpha * liquidalpha_prev, DRAWFLAG_NORMAL); if(autocvar_hud_postprocessing) { @@ -2161,13 +2161,13 @@ void CSQC_UpdateView(entity this, float w, float h) if(autocvar_cl_gentle_damage == 2) { if(myhealth_flash < pain_threshold) // only randomize when the flash is gone - myhealth_gentlergb = eX * random() + eY * random() + eZ * random(); + myhealth_gentlergb = randomvec(); } else myhealth_gentlergb = stov(autocvar_hud_damage_gentle_color); if(myhealth_flash_temp > 0) - drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, myhealth_gentlergb, autocvar_hud_damage_gentle_alpha_multiplier * bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL); + drawfill('0 0 0', vec2(vid_conwidth, vid_conheight), myhealth_gentlergb, autocvar_hud_damage_gentle_alpha_multiplier * bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL); } else if(myhealth_flash_temp > 0) drawpic(splash_pos, "gfx/blood", splash_size, stov(autocvar_hud_damage_color), bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL); diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc index 5525c4d6a..0e8262249 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc @@ -841,7 +841,7 @@ void ons_camSetup(entity this) float best_trace_fraction = 0; while(ang.y < 360) { - dir = eX * cos(ang.y * DEG2RAD) + eY * sin(ang.y * DEG2RAD); + dir = vec2(cos(ang.y * DEG2RAD), sin(ang.y * DEG2RAD)); dir *= 500; traceline(this.origin, this.origin - dir, MOVE_WORLDONLY, this); if(trace_fraction > best_trace_fraction) diff --git a/qcsrc/common/minigames/minigame/pong.qc b/qcsrc/common/minigames/minigame/pong.qc index dd57fb5c6..55d41617d 100644 --- a/qcsrc/common/minigames/minigame/pong.qc +++ b/qcsrc/common/minigames/minigame/pong.qc @@ -95,8 +95,8 @@ void pong_add_score(entity minigame, int team_thrower, int team_receiver, int de // get point in the box nearest to the given one (2D) vector box_nearest(vector box_min, vector box_max, vector p) { - return eX * ( p_x > box_max_x ? box_max_x : ( p_x < box_min_x ? box_min_x : p_x ) ) - + eY * ( p_y > box_max_y ? box_max_y : ( p_y < box_min_y ? box_min_y : p_y ) ); + return vec2( p.x > box_max.x ? box_max.x : ( p.x < box_min.x ? box_min.x : p.x ), + p.y > box_max.y ? box_max.y : ( p.y < box_min.y ? box_min.y : p.y ) ); } void pong_paddle_bounce(entity ball, int pteam) @@ -293,8 +293,8 @@ void pong_paddle_think(entity this) vector pong_team_to_box_halfsize(int nteam, float length, float width) { if ( nteam > 2 ) - return eY*width/2 + eX*length/2; - return eX*width/2 + eY*length/2; + return vec2(length/2, width/2); + return vec2(width/2, length/2); } vector pong_team_to_paddlepos(int nteam) diff --git a/qcsrc/common/minigames/minigames.qc b/qcsrc/common/minigames/minigames.qc index 227f3d9c6..6d14b2582 100644 --- a/qcsrc/common/minigames/minigames.qc +++ b/qcsrc/common/minigames/minigames.qc @@ -26,8 +26,8 @@ int minigame_tile_number(string id) // Get relative position of the center of a given tile vector minigame_tile_pos(string id, int rows, int columns) { - return eX*(minigame_tile_letter(id)+0.5)/columns + - eY - eY*(minigame_tile_number(id)+0.5)/rows; + return vec2((minigame_tile_letter(id) + 0.5) / columns, + (1 - (minigame_tile_number(id) + 0.5) / rows)); } // Get a tile name from indices diff --git a/qcsrc/common/mutators/mutator/itemstime/itemstime.qc b/qcsrc/common/mutators/mutator/itemstime/itemstime.qc index 3ffeb9371..472fc646d 100644 --- a/qcsrc/common/mutators/mutator/itemstime/itemstime.qc +++ b/qcsrc/common/mutators/mutator/itemstime/itemstime.qc @@ -238,7 +238,7 @@ void DrawItemsTimeItem(vector myPos, vector mySize, float ar, string item_icon, if (autocvar_hud_panel_itemstime_progressbar_reduced) { p_pos = numpos; - p_size = eX * ((ar - 1)/ar) * mySize_x + eY * mySize_y; + p_size = vec2(((ar - 1)/ar) * mySize.x, mySize.y); } else { @@ -251,9 +251,9 @@ void DrawItemsTimeItem(vector myPos, vector mySize, float ar, string item_icon, if(autocvar_hud_panel_itemstime_text) { if(t > 0) - drawstring_aspect(numpos, ftos(t), eX * ((ar - 1)/ar) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(numpos, ftos(t), vec2(((ar - 1)/ar) * mySize.x, mySize.y), color, panel_fg_alpha, DRAWFLAG_NORMAL); else if(precache_pic("gfx/hud/default/checkmark")) // COMPAT: check if this image exists, as 0.8.1 clients lack it - drawpic_aspect_skin(numpos, "checkmark", eX * (ar - 1) * mySize_y + eY * mySize_y, '1 1 1', panel_fg_alpha * picalpha, DRAWFLAG_NORMAL); + drawpic_aspect_skin(numpos, "checkmark", vec2((ar - 1) * mySize.y, mySize.y), '1 1 1', panel_fg_alpha * picalpha, DRAWFLAG_NORMAL); else // legacy code, if the image is missing just center the icon picpos.x = myPos.x + mySize.x / 2 - mySize.y / 2; } @@ -332,7 +332,7 @@ void HUD_ItemsTime() rows = HUD_GetRowCount(count, mySize, ar); columns = ceil(count/rows); - vector itemstime_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows); + vector itemstime_size = vec2(mySize.x / columns, mySize.y / rows); vector offset = '0 0 0'; float newSize; @@ -420,7 +420,7 @@ LABEL(iteration) if (!(Item_ItemsTime_GetTime(id) > time)) continue; - DrawItemsTimeItem(pos + eX * column * (itemstime_size.x + offset.x) + eY * row * (itemstime_size.y + offset.y), itemstime_size, ar, icon, item_time, item_available, f); + DrawItemsTimeItem(pos + vec2(column * (itemstime_size.x + offset.x), row * (itemstime_size.y + offset.y)), itemstime_size, ar, icon, item_time, item_available, f); ++row; if (row >= rows) { diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index da244ea1f..052a132b9 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -133,7 +133,7 @@ void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expan DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor); if(autocvar_hud_panel_ammo_text) - drawstring_aspect(textPos, ftos(bonusNades), eX * (2/3) * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(textPos, ftos(bonusNades), vec2((2/3) * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); if(draw_expanding) drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, expand_time); diff --git a/qcsrc/common/weapons/calculations.qc b/qcsrc/common/weapons/calculations.qc index 367bab6af..513af5209 100644 --- a/qcsrc/common/weapons/calculations.qc +++ b/qcsrc/common/weapons/calculations.qc @@ -90,15 +90,11 @@ vector solve_cubic_pq(float p, float q) // cos(a) // cos(a + 2pi/3) // cos(a + 4pi/3) - return - u * - ( - '1 0 0' * cos(a + 2.0/3.0*M_PI) - + - '0 1 0' * cos(a + 4.0/3.0*M_PI) - + - '0 0 1' * cos(a) - ); + return u * vec3( + cos(a + 2.0/3.0*M_PI), + cos(a + 4.0/3.0*M_PI), + cos(a) + ); } else if(D == 0) { @@ -107,17 +103,15 @@ vector solve_cubic_pq(float p, float q) return '0 0 0'; u = 3*q/p; v = -u/2; - if(u >= v) - return '1 1 0' * v + '0 0 1' * u; - else - return '0 1 1' * v + '1 0 0' * u; + return (u >= v) ? vec3(v, v, u) : vec3(u, v, v); } else { // cardano - u = cbrt(-q/2.0 + sqrt(D)); - v = cbrt(-q/2.0 - sqrt(D)); - return '1 1 1' * (u + v); + //u = cbrt(-q/2.0 + sqrt(D)); + //v = cbrt(-q/2.0 - sqrt(D)); + a = cbrt(-q/2.0 + sqrt(D)) + cbrt(-q/2.0 - sqrt(D)); + return vec3(a, a, a); } } vector solve_cubic_abcd(float a, float b, float c, float d) @@ -137,11 +131,7 @@ vector solve_cubic_abcd(float a, float b, float c, float d) vector findperpendicular(vector v) { - vector p; - p.x = v.z; - p.y = -v.x; - p.z = v.y; - return normalize(cliptoplane(p, v)); + return normalize(cliptoplane(vec3(v.z, -v.x, v.y), v)); } #ifdef SVQC diff --git a/qcsrc/common/weapons/weapon/tuba.qc b/qcsrc/common/weapons/weapon/tuba.qc index 2949a8a24..306842e78 100644 --- a/qcsrc/common/weapons/weapon/tuba.qc +++ b/qcsrc/common/weapons/weapon/tuba.qc @@ -157,7 +157,7 @@ void W_Tuba_NoteOff(entity this) if (actor.(weaponentity).tuba_note == this) { actor.(weaponentity).tuba_lastnotes_last = (actor.(weaponentity).tuba_lastnotes_last + 1) % MAX_TUBANOTES; - actor.(weaponentity).(tuba_lastnotes[actor.(weaponentity).tuba_lastnotes_last]) = eX * this.spawnshieldtime + eY * time + eZ * this.cnt; + actor.(weaponentity).(tuba_lastnotes[actor.(weaponentity).tuba_lastnotes_last]) = vec3(this.spawnshieldtime, time, this.cnt); actor.(weaponentity).tuba_note = NULL; actor.(weaponentity).tuba_lastnotes_cnt = bound(0, actor.(weaponentity).tuba_lastnotes_cnt + 1, MAX_TUBANOTES); diff --git a/qcsrc/lib/vector.qh b/qcsrc/lib/vector.qh index 0a887cfeb..151d788c0 100644 --- a/qcsrc/lib/vector.qh +++ b/qcsrc/lib/vector.qh @@ -104,10 +104,7 @@ noref vector _vec3; vector Rotate(vector v, float a) { float a_sin = sin(a), a_cos = cos(a); - vector r = '0 0 0'; - r.x = v.x * a_cos + v.y * a_sin; - r.y = -1 * v.x * a_sin + v.y * a_cos; - return r; + return vec2(v.x * a_cos + v.y * a_sin, -v.x * a_sin + v.y * a_cos); } noref vector _yinvert; @@ -164,10 +161,10 @@ vector vec_epsilon(vector this, float eps) vector m1 = box.mins + box.origin; vector m2 = box.maxs + box.origin; - vector ret; - ret.x = bound(m1.x, org.x, m2.x); - ret.y = bound(m1.y, org.y, m2.y); - ret.z = bound(m1.z, org.z, m2.z); - return ret; + return vec3( + bound(m1.x, org.x, m2.x), + bound(m1.y, org.y, m2.y), + bound(m1.z, org.z, m2.z) + ); } #endif