]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/scoreboard_item_stats 663/head
authorMario <mario.mario@y7mail.com>
Tue, 26 Jan 2021 11:58:13 +0000 (21:58 +1000)
committerMario <mario.mario@y7mail.com>
Tue, 26 Jan 2021 11:58:13 +0000 (21:58 +1000)
23 files changed:
_hud_common.cfg
_hud_descriptions.cfg
hud_luma.cfg
hud_luminos.cfg
hud_luminos_minimal.cfg
hud_luminos_minimal_xhair.cfg
hud_luminos_old.cfg
hud_nexuiz.cfg
qcsrc/client/hud/panel/centerprint.qc
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/client/hud/panel/scoreboard.qh
qcsrc/client/mutators/events.qh
qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc
qcsrc/common/gamemodes/gamemode/invasion/_mod.inc
qcsrc/common/gamemodes/gamemode/invasion/_mod.qh
qcsrc/common/gamemodes/gamemode/invasion/cl_invasion.qc [new file with mode: 0644]
qcsrc/common/gamemodes/gamemode/invasion/cl_invasion.qh [new file with mode: 0644]
qcsrc/common/gamemodes/gamemode/nexball/cl_nexball.qc
qcsrc/common/gamemodes/gamemode/race/cl_race.qc
qcsrc/common/items/all.qh
qcsrc/common/items/inventory.qh
qcsrc/common/state.qc
qcsrc/server/command/vote.qc

index 4973ef0bc008d88d2dc1e1f6dda768c30c451961..9719c9dbee806e29f7979b4adad73549d7d19cda 100644 (file)
@@ -45,8 +45,9 @@ seta hud_panel_centerprint      1 "enable this panel"
 seta hud_panel_itemstime        2 "enable this panel, 1 = show when spectating, 2 = even playing in warmup stage"
 //seta hud_panel_quickmenu        1 "enable this panel"
 //seta hud_panel_scoreboard       1 "enable this panel"
-seta hud_panel_scoreboard_accuracy 1 "show weapon accuracy stats panel on scoreboard; colors can be configured with accuracy_color* cvars"
+seta hud_panel_scoreboard_accuracy 1 "show weapon accuracy stats panel in the scoreboard; colors can be configured with accuracy_color* cvars"
 seta hud_panel_scoreboard_ctf_leaderboard 1 "show a capture time rankings leaderboard in the scoreboard if allowed by the server"
+seta hud_panel_scoreboard_itemstats 1 "show item stats panel in the scoreboard"
 seta hud_panel_strafehud        3 "enable this panel, 1 = show if not observing, 2 = show always, 3 = show only in race/cts if not observing"
 
 seta hud_panel_weapons_dynamichud          1 "apply the dynamic hud effects to this panel"
@@ -120,13 +121,17 @@ seta hud_panel_scoreboard_others_showscore 1 "show scores of players listed in t
 seta hud_panel_scoreboard_spectators_showping 1 "show ping of spectators"
 seta hud_panel_scoreboard_spectators_aligned 0 "align spectators in columns"
 seta hud_panel_scoreboard_minwidth 0.6 "minimum width of the scoreboard"
+seta hud_panel_scoreboard_team_size_position 0 "where to show the team size (0 = do not show, 1 = left of scoreboard, 2 = right of scoreboard), will move team scores to the other side if necessary"
 seta hud_panel_scoreboard_playerid 0 "show player id (server entity number) next to player's name"
 seta hud_panel_scoreboard_playerid_prefix "#" "player id prefix"
 seta hud_panel_scoreboard_playerid_suffix " " "player id suffix"
 
 seta hud_panel_scoreboard_accuracy_showdelay 2 "how long to delay displaying accuracy below the scoreboard if it's too far down"
 seta hud_panel_scoreboard_accuracy_showdelay_minpos 0.75 "delay displaying the accuracy panel only if its position is lower than this percentage of the screen height from the top"
-seta hud_panel_scoreboard_team_size_position 0 "where to show the team size (0 = do not show, 1 = left of scoreboard, 2 = right of scoreboard), will move team scores to the other side if necessary"
+
+seta hud_panel_scoreboard_itemstats_filter 1 "filter out less interesting items (ammo and smaller health/armor)"
+seta hud_panel_scoreboard_itemstats_showdelay 2.2 "how long to delay displaying item stats below the scoreboard if it's too far down"
+seta hud_panel_scoreboard_itemstats_showdelay_minpos 0.75 "delay displaying the item stats panel only if its position is lower than this percentage of the screen height from the top"
 
 seta _hud_panel_strafehud_demo "0" "strafehud changes angle during configure"
 seta hud_panel_strafehud_mode "0" "strafehud mode which controls whether the strafehud is centered at \"0\" = view angle, \"1\" = velocity angle"
index 4bb0582cfa6231e1605197e21056cd338bba3acb..02d2d5a0f46adb114c507ccbc327b5dc57ed39c3 100644 (file)
@@ -379,6 +379,7 @@ seta hud_panel_scoreboard_table_highlight_alpha_eliminated "" "eliminated highli
 seta hud_panel_scoreboard_bg_teams_color_team "" "override panel team color in team tables"
 seta hud_panel_scoreboard_accuracy_doublerows "" "use two rows instead of one"
 seta hud_panel_scoreboard_accuracy_nocolors "" "don't use colors displaying accuracy stats"
+seta hud_panel_scoreboard_itemstats_doublerows "" "use two rows instead of one"
 
 seta hud_panel_strafehud_pos "" "position of this base of the panel"
 seta hud_panel_strafehud_size "" "size of this panel"
index 0ae785b714b91ce2fe09c6061848e9afacc24d8f..9ad2425a7c498bf97171eff9bea3acbb18ca03a3 100644 (file)
@@ -380,6 +380,7 @@ seta hud_panel_scoreboard_table_highlight_alpha_eliminated "0.6"
 seta hud_panel_scoreboard_bg_teams_color_team "0"
 seta hud_panel_scoreboard_accuracy_doublerows "0"
 seta hud_panel_scoreboard_accuracy_nocolors "0"
+seta hud_panel_scoreboard_itemstats_doublerows "0"
 
 seta hud_panel_strafehud_pos "0.320000 0.570000"
 seta hud_panel_strafehud_size "0.360000 0.020000"
index f34ba0e23ab5702512b8841e91f7a8a06bdcc59d..c642ac38f46121727ce1487c6a78b6cc8a8d2462 100644 (file)
@@ -380,6 +380,7 @@ seta hud_panel_scoreboard_table_highlight_alpha_eliminated "0.5"
 seta hud_panel_scoreboard_bg_teams_color_team "0"
 seta hud_panel_scoreboard_accuracy_doublerows "1"
 seta hud_panel_scoreboard_accuracy_nocolors "0"
+seta hud_panel_scoreboard_itemstats_doublerows "0"
 
 seta hud_panel_strafehud_pos "0.330000 0.570000"
 seta hud_panel_strafehud_size "0.340000 0.020000"
index 0756e25399b45a254aff48e699e0228f518dad48..d15dd868ac2c37c074f2a17da73137ebb99774a6 100644 (file)
@@ -380,6 +380,7 @@ seta hud_panel_scoreboard_table_highlight_alpha_eliminated "0.5"
 seta hud_panel_scoreboard_bg_teams_color_team "0.7"
 seta hud_panel_scoreboard_accuracy_doublerows "1"
 seta hud_panel_scoreboard_accuracy_nocolors "0"
+seta hud_panel_scoreboard_itemstats_doublerows "0"
 
 seta hud_panel_strafehud_pos "0.380000 0.550000"
 seta hud_panel_strafehud_size "0.240000 0.025000"
index 53287c16fa33229c7b6c09d2a9865bff2bcdd887..11c57ee484bdc0344e34c507f5408a9d35d41a1a 100644 (file)
@@ -380,6 +380,7 @@ seta hud_panel_scoreboard_table_highlight_alpha_eliminated "0.5"
 seta hud_panel_scoreboard_bg_teams_color_team "0.7"
 seta hud_panel_scoreboard_accuracy_doublerows "1"
 seta hud_panel_scoreboard_accuracy_nocolors "0"
+seta hud_panel_scoreboard_itemstats_doublerows "0"
 
 seta hud_panel_strafehud_pos "0.330000 0.700000"
 seta hud_panel_strafehud_size "0.340000 0.015000"
index f30c21064512a4513d4429fd4974f60feaee5bfb..42a79015cdc43267e21a93505aa7a287987c133a 100644 (file)
@@ -380,6 +380,7 @@ seta hud_panel_scoreboard_table_highlight_alpha_eliminated "0.5"
 seta hud_panel_scoreboard_bg_teams_color_team "0.7"
 seta hud_panel_scoreboard_accuracy_doublerows "1"
 seta hud_panel_scoreboard_accuracy_nocolors "0"
+seta hud_panel_scoreboard_itemstats_doublerows "0"
 
 seta hud_panel_strafehud_pos "0.320000 0.540000"
 seta hud_panel_strafehud_size "0.360000 0.025000"
index fc87b820123de396577d43921c2b556140396528..9200283c3d3c1aeaed050a7933f4f9e675039ca7 100644 (file)
@@ -380,6 +380,7 @@ seta hud_panel_scoreboard_table_highlight_alpha_eliminated "0.5"
 seta hud_panel_scoreboard_bg_teams_color_team "0.7"
 seta hud_panel_scoreboard_accuracy_doublerows "1"
 seta hud_panel_scoreboard_accuracy_nocolors "0"
+seta hud_panel_scoreboard_itemstats_doublerows "0"
 
 seta hud_panel_strafehud_pos "0.360000 0.570000"
 seta hud_panel_strafehud_size "0.280000 0.025000"
index a0a5389e7e159e9e3f4ac52df534303ef47da9b0..105908094e5e0cc77ee41f0e0b8713b97b37a21d 100644 (file)
@@ -189,7 +189,7 @@ void HUD_CenterPrint()
 
        if ( HUD_Radar_Clickable() )
        {
-               if (hud_panel_radar_bottom >= 0.96 * vid_conheight)
+               if (hud_panel_radar_bottom >= vid_conheight)
                        return;
 
                panel_pos.x = 0.5 * (vid_conwidth - panel_size.x);
@@ -198,15 +198,16 @@ void HUD_CenterPrint()
        }
        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 = 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);
                        panel_size.y = min(panel_size.y, vid_conheight - scoreboard_bottom);
                }
+
+               // move the panel below the scoreboard
+               if (panel_pos.y >= vid_conheight)
+                       return;
        }
 
        if (autocvar_hud_panel_centerprint_dynamichud)
index 9965d58fb4ed257d341596517b046a33be301e48..82f96d02d55e60dbd89a603a551d2f4002addb9a 100644 (file)
@@ -13,6 +13,7 @@
 #include <common/scores.qh>
 #include <common/stats.qh>
 #include <common/teams.qh>
+#include <common/items/inventory.qh>
 
 // Scoreboard (#24)
 
@@ -86,6 +87,12 @@ bool autocvar_hud_panel_scoreboard_accuracy_nocolors = false;
 float autocvar_hud_panel_scoreboard_accuracy_showdelay = 2;
 float autocvar_hud_panel_scoreboard_accuracy_showdelay_minpos = 0.75;
 
+bool autocvar_hud_panel_scoreboard_itemstats = true;
+bool autocvar_hud_panel_scoreboard_itemstats_doublerows = false;
+bool autocvar_hud_panel_scoreboard_itemstats_filter = true;
+float autocvar_hud_panel_scoreboard_itemstats_showdelay = 2.2; // slightly more delayed than accuracy
+float autocvar_hud_panel_scoreboard_itemstats_showdelay_minpos = 0.75;
+
 bool autocvar_hud_panel_scoreboard_dynamichud = false;
 
 float autocvar_hud_panel_scoreboard_maxheight = 0.6;
@@ -1088,7 +1095,7 @@ vector Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_size)
        panel_size.y += panel_bg_padding * 2;
        HUD_Panel_DrawBg();
 
-       vector end_pos = panel_pos + eY * (panel_size.y + 0.5* hud_fontsize.y);
+       vector end_pos = panel_pos + eY * (panel_size.y + 0.5 * hud_fontsize.y);
        if(panel.current_panel_bg != "0")
                end_pos.y += panel_bg_border * 2;
 
@@ -1178,14 +1185,7 @@ bool Scoreboard_WouldDraw()
 float average_accuracy;
 vector Scoreboard_AccuracyStats_Draw(vector pos, vector rgb, vector bg_size)
 {
-       if (frametime)
-       {
-               if (scoreboard_fade_alpha == 1)
-                       scoreboard_acc_fade_alpha = min(1, scoreboard_acc_fade_alpha + frametime * 10);
-               else
-                       scoreboard_acc_fade_alpha = 1; // sync fading with the scoreboard
-       }
-       vector initial_pos = pos;
+       scoreboard_acc_fade_alpha = min(scoreboard_fade_alpha, scoreboard_acc_fade_alpha + frametime * 10);
 
        WepSet weapons_stat = WepSet_GetFromStat();
        WepSet weapons_inmap = WepSet_GetFromStat_InMap();
@@ -1234,7 +1234,7 @@ vector Scoreboard_AccuracyStats_Draw(vector pos, vector rgb, vector bg_size)
        HUD_Panel_DrawBg();
        panel_bg_alpha = panel_bg_alpha_save;
 
-       vector end_pos = panel_pos + eY * (panel_size.y + hud_fontsize.y);
+       vector end_pos = panel_pos + eY * (panel_size.y + 0.5 * hud_fontsize.y);
        if(panel.current_panel_bg != "0")
                end_pos.y += panel_bg_border * 2;
 
@@ -1326,9 +1326,120 @@ vector Scoreboard_AccuracyStats_Draw(vector pos, vector rgb, vector bg_size)
 
        panel_size.x += panel_bg_padding * 2; // restore initial width
 
-       if (scoreboard_acc_fade_alpha == 1)
-               return end_pos;
-       return initial_pos + (end_pos - initial_pos) * scoreboard_acc_fade_alpha;
+       return end_pos;
+}
+
+.bool uninteresting;
+STATIC_INIT(default_order_items_label)
+{
+       IL_EACH(default_order_items, true, {
+               if(!(it.instanceOfPowerup
+                       || it == ITEM_HealthMega || it == ITEM_HealthBig
+                       || it == ITEM_ArmorMega || it == ITEM_ArmorBig
+                       ))
+               {
+                       it.uninteresting = true;
+               }
+       });
+}
+
+vector Scoreboard_ItemStats_Draw(vector pos, vector rgb, vector bg_size)
+{
+       scoreboard_itemstats_fade_alpha = min(scoreboard_fade_alpha, scoreboard_itemstats_fade_alpha + frametime * 10);
+
+       int disowned_cnt = 0;
+       int uninteresting_cnt = 0;
+       IL_EACH(default_order_items, true, {
+               int q = g_inventory.inv_items[it.m_id];
+               //q = 1; // debug: display all items
+               if (autocvar_hud_panel_scoreboard_itemstats_filter && it.uninteresting)
+                       ++uninteresting_cnt;
+               else if (!q)
+                       ++disowned_cnt;
+       });
+       int items_cnt = REGISTRY_COUNT(Items) - uninteresting_cnt;
+       int n = items_cnt - disowned_cnt;
+       if (n <= 0) return pos;
+
+       int rows = (autocvar_hud_panel_scoreboard_itemstats_doublerows && n >= floor(REGISTRY_COUNT(Items) / 2)) ? 2 : 1;
+       int columnns = max(6, ceil(n / rows));
+
+       float height = 40;
+       float fontsize = height * 1/3;
+       float item_height = height * 2/3;
+
+       drawstring(pos + eX * panel_bg_padding, _("Item stats"), hud_fontsize, '1 1 1', panel_fg_alpha * scoreboard_itemstats_fade_alpha, DRAWFLAG_NORMAL);
+       pos.y += 1.25 * hud_fontsize.y;
+       if(panel.current_panel_bg != "0")
+               pos.y += panel_bg_border;
+
+       panel_pos = pos;
+       panel_size.y = height * rows;
+       panel_size.y += panel_bg_padding * 2;
+
+       float panel_bg_alpha_save = panel_bg_alpha;
+       panel_bg_alpha *= scoreboard_itemstats_fade_alpha;
+       HUD_Panel_DrawBg();
+       panel_bg_alpha = panel_bg_alpha_save;
+
+       vector end_pos = panel_pos + eY * (panel_size.y + 0.5 * hud_fontsize.y);
+       if(panel.current_panel_bg != "0")
+               end_pos.y += panel_bg_border * 2;
+
+       if(panel_bg_padding)
+       {
+               panel_pos += '1 1 0' * panel_bg_padding;
+               panel_size -= '2 2 0' * panel_bg_padding;
+       }
+
+       pos = panel_pos;
+       vector tmp = panel_size;
+
+       float item_width = tmp.x / columnns / rows;
+
+       if (sbt_bg_alpha)
+               drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb, sbt_bg_alpha * scoreboard_itemstats_fade_alpha, DRAWFLAG_NORMAL);
+
+       if(sbt_highlight)
+       {
+               // column highlighting
+               for (int i = 0; i < columnns; ++i)
+                       if ((i % 2) == 0)
+                               drawfill(pos + '1 0 0' * item_width * rows * i, '0 1 0' * height * rows + '1 0 0' * item_width * rows, '0 0 0', sbt_highlight_alpha * scoreboard_itemstats_fade_alpha, DRAWFLAG_NORMAL);
+
+               // row highlighting
+               for (int i = 0; i < rows; ++i)
+                       drawfill(pos + '0 1 0' * item_height + '0 1 0' * height * i, '1 0 0' * panel_size.x + '0 1 0' * fontsize, rgb, sbt_highlight_alpha * scoreboard_itemstats_fade_alpha, DRAWFLAG_NORMAL);
+       }
+
+       if (rows == 2)
+               pos.x += item_width / 2;
+
+       float oldposx = pos.x;
+       vector tmpos = pos;
+
+       int column = 0;
+       IL_EACH(default_order_items, !(autocvar_hud_panel_scoreboard_itemstats_filter && it.uninteresting), {
+               int n = g_inventory.inv_items[it.m_id];
+               //n = 1 + floor(i * 3 + 4.8) % 7; // debug: display a value for each item
+               if (n <= 0) continue;
+               drawpic_aspect_skin(tmpos, it.m_icon, '1 0 0' * item_width + '0 1 0' * item_height, '1 1 1', panel_fg_alpha * scoreboard_itemstats_fade_alpha, DRAWFLAG_NORMAL);
+               string s = ftos(n);
+               float padding = (item_width - stringwidth(s, false, '1 0 0' * fontsize)) / 2; // center
+               drawstring(tmpos + '1 0 0' * padding + '0 1 0' * item_height, s, '1 1 0' * fontsize, '1 1 1', panel_fg_alpha * scoreboard_itemstats_fade_alpha, DRAWFLAG_NORMAL);
+               tmpos.x += item_width * rows;
+               pos.x += item_width * rows;
+               if (rows == 2 && column == columnns - 1) {
+                       tmpos.x = oldposx;
+                       tmpos.y += height;
+                       pos.y += height;
+               }
+               ++column;
+       });
+
+       panel_size.x += panel_bg_padding * 2; // restore initial width
+
+       return end_pos;
 }
 
 vector MapStats_DrawKeyValue(vector pos, string key, string value) {
@@ -1378,7 +1489,7 @@ vector Scoreboard_MapStats_Draw(vector pos, vector rgb, vector bg_size) {
        panel_size.y += panel_bg_padding * 2;
        HUD_Panel_DrawBg();
 
-       vector end_pos = panel_pos + eY * (panel_size.y + hud_fontsize.y);
+       vector end_pos = panel_pos + eY * (panel_size.y + 0.5 * hud_fontsize.y);
        if(panel.current_panel_bg != "0")
                end_pos.y += panel_bg_border * 2;
 
@@ -1464,7 +1575,7 @@ vector Scoreboard_Rankings_Draw(vector pos, string ranktitle, entity pl, vector
 
        HUD_Panel_DrawBg();
 
-       vector end_pos = panel_pos + eY * (panel_size.y + hud_fontsize.y);
+       vector end_pos = panel_pos + eY * (panel_size.y + 0.5 * hud_fontsize.y);
        if(panel.current_panel_bg != "0")
                end_pos.y += panel_bg_border * 2;
 
@@ -1552,6 +1663,42 @@ bool Scoreboard_AccuracyStats_WouldDraw(float ypos)
        return true;
 }
 
+bool have_item_stats;
+bool Scoreboard_ItemStats_WouldDraw(float ypos)
+{
+       if (MUTATOR_CALLHOOK(DrawScoreboardItemStats))
+               return false;
+       if (!autocvar_hud_panel_scoreboard_itemstats || !g_inventory || warmup_stage || ypos > 0.91 * vid_conheight)
+               return false;
+
+       if (time < scoreboard_time + autocvar_hud_panel_scoreboard_itemstats_showdelay
+               && ypos > autocvar_hud_panel_scoreboard_itemstats_showdelay_minpos * vid_conheight
+               && !intermission)
+       {
+               return false;
+       }
+
+       if (!have_item_stats)
+       {
+               IL_EACH(default_order_items, true, {
+                       if (!(autocvar_hud_panel_scoreboard_itemstats_filter && it.uninteresting))
+                       {
+                               int q = g_inventory.inv_items[it.m_id];
+                               //q = 1; // debug: display all items
+                               if (q)
+                               {
+                                       have_item_stats = true;
+                                       break;
+                               }
+                       }
+               });
+               if (!have_item_stats)
+                       return false;
+       }
+
+       return true;
+}
+
 void Scoreboard_Draw()
 {
        if(!autocvar__hud_configure)
@@ -1560,7 +1707,7 @@ void Scoreboard_Draw()
 
                // frametime checks allow to toggle the scoreboard even when the game is paused
                if(scoreboard_active) {
-                       if (scoreboard_fade_alpha < 1)
+                       if (scoreboard_fade_alpha == 0)
                                scoreboard_time = time;
                        if(hud_configure_menu_open == 1)
                                scoreboard_fade_alpha = 1;
@@ -1587,6 +1734,7 @@ void Scoreboard_Draw()
                if (!scoreboard_fade_alpha)
                {
                        scoreboard_acc_fade_alpha = 0;
+                       scoreboard_itemstats_fade_alpha = 0;
                        return;
                }
        }
@@ -1622,6 +1770,7 @@ void Scoreboard_Draw()
 
        Scoreboard_UpdatePlayerTeams();
 
+       float initial_pos_y = panel_pos.y;
        vector pos = panel_pos;
        entity pl, tm;
        string str;
@@ -1835,6 +1984,8 @@ void Scoreboard_Draw()
 
        if (Scoreboard_AccuracyStats_WouldDraw(pos.y))
                pos = Scoreboard_AccuracyStats_Draw(pos, panel_bg_color, bg_size);
+       if (Scoreboard_ItemStats_WouldDraw(pos.y))
+               pos = Scoreboard_ItemStats_Draw(pos, panel_bg_color, bg_size);
 
        if(MUTATOR_CALLHOOK(ShowRankings)) {
                string ranktitle = M_ARGV(0, string);
@@ -1911,5 +2062,14 @@ void Scoreboard_Draw()
                drawcolorcodedstring(pos + '0.5 0 0' * (panel_size.x - stringwidth(str, true, hud_fontsize)), str, hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
        }
 
-       scoreboard_bottom = pos.y + 2 * hud_fontsize.y;
+       pos.y += 2 * hud_fontsize.y;
+       if (scoreboard_fade_alpha < 1)
+               scoreboard_bottom = initial_pos_y + (pos.y - initial_pos_y) * scoreboard_fade_alpha;
+       else if (pos.y != scoreboard_bottom)
+       {
+               if (pos.y > scoreboard_bottom)
+                       scoreboard_bottom = min(pos.y, scoreboard_bottom + frametime * 10 * (pos.y - initial_pos_y));
+               else
+                       scoreboard_bottom = max(pos.y, scoreboard_bottom - frametime * 10 * (pos.y - initial_pos_y));
+       }
 }
index f0dbdb5c6d6a1f92fa2505533d8ffe2d8dba48e0..7189143e669831af26eb7576c6ff43453f214ba6 100644 (file)
@@ -9,6 +9,7 @@ bool scoreboard_showscores;
 bool scoreboard_active;
 float scoreboard_fade_alpha;
 float scoreboard_acc_fade_alpha;
+float scoreboard_itemstats_fade_alpha;
 
 void Cmd_Scoreboard_SetFields(int argc);
 void Scoreboard_Draw();
index 7115ed4dfba7c6b27233c8b4123ec11928e78ff8..6f6f34399f18e19a476771b9b7d41bc0bf237daa 100644 (file)
@@ -181,6 +181,9 @@ MUTATOR_HOOKABLE(DrawDeathScoreboard, EV_NO_ARGS);
 /** Return true to not show accuracy stats in the scoreboard */
 MUTATOR_HOOKABLE(DrawScoreboardAccuracy, EV_NO_ARGS);
 
+/** Return true to not show item pickup stats in the scoreboard */
+MUTATOR_HOOKABLE(DrawScoreboardItemStats, EV_NO_ARGS);
+
 /** Called when drawing info messages, allows adding new info messages. Return true to hide the standard join message */
 #define EV_DrawInfoMessages(i, o) \
        /** pos */                          i(vector, MUTATOR_ARGV_0_vector) \
index ee62df152f06143c8e6cb68fd60c1fad24d399a2..ce095bf2032a0e1a63fccaaac1fc0c3840d91148 100644 (file)
@@ -19,6 +19,11 @@ MUTATOR_HOOKFUNCTION(cl_cts, HUD_Score_show)
        return spectatee_status == -1 && ISGAMETYPE(CTS); // hide the score panel while observing
 }
 
+MUTATOR_HOOKFUNCTION(cl_cts, DrawScoreboardItemStats)
+{
+       return ISGAMETYPE(CTS); // hide the item stats panel
+}
+
 MUTATOR_HOOKFUNCTION(cl_cts, DrawDeathScoreboard)
 {
        return ISGAMETYPE(CTS); // no scoreboard shown while dead
index e8b28e96bc460ff67f58b3c84b0ab228c16e551d..ab033e317906f8210f245600ba21fa0cfad53f55 100644 (file)
@@ -1,5 +1,8 @@
 // generated file; do not modify
 #include <common/gamemodes/gamemode/invasion/invasion.qc>
+#ifdef CSQC
+    #include <common/gamemodes/gamemode/invasion/cl_invasion.qc>
+#endif
 #ifdef SVQC
     #include <common/gamemodes/gamemode/invasion/sv_invasion.qc>
 #endif
index 5181956f2023028ddb6c2ff4e6bef2e37bc8ce0b..0b663f5ab455013d58022a5e1c2ea0fd237cf7e9 100644 (file)
@@ -1,5 +1,8 @@
 // generated file; do not modify
 #include <common/gamemodes/gamemode/invasion/invasion.qh>
+#ifdef CSQC
+    #include <common/gamemodes/gamemode/invasion/cl_invasion.qh>
+#endif
 #ifdef SVQC
     #include <common/gamemodes/gamemode/invasion/sv_invasion.qh>
 #endif
diff --git a/qcsrc/common/gamemodes/gamemode/invasion/cl_invasion.qc b/qcsrc/common/gamemodes/gamemode/invasion/cl_invasion.qc
new file mode 100644 (file)
index 0000000..e7dc879
--- /dev/null
@@ -0,0 +1,10 @@
+#include "cl_invasion.qh"
+
+#include <common/mutators/base.qh>
+
+REGISTER_MUTATOR(cl_inv, true);
+
+MUTATOR_HOOKFUNCTION(cl_inv, DrawScoreboardItemStats)
+{
+       return ISGAMETYPE(INVASION); // hide the item stats panel
+}
diff --git a/qcsrc/common/gamemodes/gamemode/invasion/cl_invasion.qh b/qcsrc/common/gamemodes/gamemode/invasion/cl_invasion.qh
new file mode 100644 (file)
index 0000000..6f70f09
--- /dev/null
@@ -0,0 +1 @@
+#pragma once
index 27699571675d1bd65ccb812d17df16b878425b77..fa7be6e5072bb003ef7b996cc2cb04a5c928ee51 100644 (file)
@@ -48,3 +48,8 @@ MUTATOR_HOOKFUNCTION(cl_nb, DrawScoreboardAccuracy)
 {
        return ISGAMETYPE(NEXBALL); // accuracy is not a factor in this gamemode
 }
+
+MUTATOR_HOOKFUNCTION(cl_nb, DrawScoreboardItemStats)
+{
+       return ISGAMETYPE(NEXBALL); // hide the item stats panel
+}
index a47ce272e49d7fd12ec5105be2bc84037146caaa..4311ce777aa813560420fa6cb2bc3fb0df62696f 100644 (file)
@@ -166,6 +166,11 @@ MUTATOR_HOOKFUNCTION(cl_race, HUD_Score_show)
        return spectatee_status == -1 && ISGAMETYPE(RACE); // hide the score panel while observing
 }
 
+MUTATOR_HOOKFUNCTION(cl_race, DrawScoreboardItemStats)
+{
+       return ISGAMETYPE(RACE); // hide the item stats panel
+}
+
 MUTATOR_HOOKFUNCTION(cl_race, ShowRankings)
 {
        if(ISGAMETYPE(RACE))
index 359c0017955794bade60ea96a9565ed2edf5c009..bb2e387fb9cd7df3dad696d3401f06ea77e7aadb 100644 (file)
@@ -12,6 +12,19 @@ REGISTRY_DEPENDS(Items, Models)
 REGISTER_REGISTRY(Items)
 #define REGISTER_ITEM(id, class) REGISTER(Items, ITEM, id, m_id, NEW(class))
 
+#ifdef CSQC
+// Copy Items registry here before it gets sorted alphabetically by REGISTRY_SORT
+// so we can keep items sorted by categories (as they appear in the code)
+IntrusiveList default_order_items;
+STATIC_INIT(default_order_items)
+{
+       default_order_items = IL_NEW();
+       FOREACH(Items, true, {
+               IL_PUSH(default_order_items, it);
+       });
+}
+#endif
+
 REGISTRY_SORT(Items)
 REGISTRY_CHECK(Items)
 
index c47be669978bb90b00afa5724297fc7d21c48544..abc367d51389615815274c79100f7a462e208e31 100644 (file)
@@ -38,10 +38,17 @@ STATIC_INIT(Inventory)
 
 #ifdef CSQC
 Inventory g_inventory;
+void Inventory_remove(entity this)
+{
+    if(g_inventory == this)
+        g_inventory = NULL;
+}
+
 NET_HANDLE(ENT_CLIENT_INVENTORY, bool isnew)
 {
     make_pure(this);
     g_inventory = this;
+    this.entremove = Inventory_remove;
     const int majorBits = Readbits(Inventory_groups_major);
     for (int i = 0; i < Inventory_groups_major; ++i) {
         if (!(majorBits & BIT(i))) {
@@ -133,9 +140,19 @@ void Inventory_new(PlayerState this)
     setcefc(inv, Inventory_customize);
     Net_LinkEntity((inv.owner = this).inventory = inv, false, 0, Inventory_Send);
 }
-void Inventory_delete(entity e) { delete(e.inventory.inventory); delete(e.inventory); }
+void Inventory_delete(entity e) { delete(e.inventory); }
 void Inventory_update(entity e) { e.inventory.SendFlags = 0xFFFFFF; }
 
+void Inventory_clear(entity store)
+{
+    // NOTE: you will need to perform Inventory_update after this to update the storage entity
+    // (unless store is the storage entity)
+    FOREACH(Items, true, {
+        .int fld = inv_items[it.m_id];
+        store.(fld) = 0;
+    });
+}
+
 void InventoryStorage_attach(entity e) { e.inventory_store = NEW(Inventory); e.inventory_store.drawonlytoclient = e; }
-void InventoryStorage_detach(entity e) { delete(e.inventory_store); }
+void InventoryStorage_delete(entity e) { delete(e.inventory_store); }
 #endif
index 651a86f917f5a83ead5c6517070b05bd6be1cd4c..018f626e0318bcf02dee8807f08260afd1262158 100644 (file)
@@ -4,8 +4,9 @@
 
 void Inventory_new(PlayerState this);
 void Inventory_delete(entity this);
+void Inventory_clear(PlayerState this);
 void InventoryStorage_attach(PlayerState this);
-void InventoryStorage_detach(PlayerState this);
+void InventoryStorage_delete(PlayerState this);
 
 void PlayerState_attach(entity this)
 {
@@ -22,6 +23,7 @@ void PlayerState_detach(entity this)
     PlayerState ps = PS(this);
        if (!ps) return;  // initial connect
        PS(this) = NULL;
+    Inventory_clear(this.inventory_store); // no need to network updates, as there is no inventory attached
 
        if (ps.m_client != this) return;  // don't own state, spectator
        ps.ps_push(ps, this);
@@ -74,7 +76,7 @@ void ClientState_detach(entity this)
     W_HitPlotClose(this);
     ClientData_Detach(this);
     entcs_detach(this);
-    InventoryStorage_detach(this);
+    InventoryStorage_delete(this);
        delete(CS(this));
        this._cs = NULL;
 
index e3347980d40a530169766f39150a720c44984a84..f8301e70a616bef3d02c89d7313b13c92a3dbe3a 100644 (file)
@@ -3,6 +3,7 @@
 #include <common/command/_mod.qh>
 #include <common/constants.qh>
 #include <common/gamemodes/_mod.qh>
+#include <common/items/inventory.qh>
 #include <common/mapinfo.qh>
 #include <common/net_linked.qh>
 #include <common/notifications/all.qh>
@@ -349,6 +350,17 @@ void reset_map(bool dorespawn)
                shuffleteams();
                shuffleteams_on_reset_map = false;
        }
+
+       FOREACH_CLIENT(IS_PLAYER(it),
+       {
+               entity store = PS(it);
+               if (store)
+               {
+                       Inventory_clear(store.inventory);
+                       Inventory_update(store);
+               }
+       });
+
        MUTATOR_CALLHOOK(reset_map_global);
 
        FOREACH_ENTITY_FLOAT_ORDERED(pure_data, false,