]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
RJZ: Total armor pickups in timestimes panel
authorz411 <z411@omaera.org>
Wed, 13 Oct 2021 00:38:06 +0000 (21:38 -0300)
committerz411 <z411@omaera.org>
Wed, 13 Oct 2021 00:38:06 +0000 (21:38 -0300)
qcsrc/client/main.qh
qcsrc/common/mutators/mutator/itemstime/itemstime.qc
qcsrc/common/mutators/mutator/itemstime/itemstime.qh
qcsrc/common/net_linked.qh
qcsrc/server/client.qc
qcsrc/server/items/items.qc
qcsrc/server/world.qc
qcsrc/server/world.qh

index 9d0f6ef2d65353a7f0af704f7c3f671fce10f03e..f456260476a70025a44e6110fea2c1ad1c3de0c7 100644 (file)
@@ -195,3 +195,4 @@ float serverprevtime, serverdeltatime;
 float ticrate;
 
 int serverflags;
+
index d30f1694306766c5420a38e5941cee26cb74deea..005b27b62185061365047c942641eeb9fa512217 100644 (file)
@@ -25,6 +25,15 @@ NET_HANDLE(itemstime, bool isNew)
     return = true;
     ItemsTime_time[i] = f;
 }
+
+NET_HANDLE(TE_CSQC_TOTALSHARDS, bool isNew)
+{
+       // for RJZ
+       total_shards = ReadInt24_t();
+       
+       return = true;
+}
+
 #endif
 
 #ifdef CSQC
@@ -200,6 +209,25 @@ void HUD_ItemsTime_Export(int fh)
        HUD_Write_Cvar("hud_panel_itemstime_dynamicsize");
 }
 
+// for RJZ
+void DrawItemsTimeItemFixed(vector myPos, vector mySize, float ar, string item_icon, float t)
+{
+       vector picpos, numpos;
+    if (autocvar_hud_panel_itemstime_iconalign)
+    {
+        numpos = myPos;
+        picpos = myPos + eX * (ar - 1) * mySize_y;
+    }
+    else
+    {
+        numpos = myPos + eX * mySize_y;
+        picpos = myPos;
+    }
+    
+    drawstring_aspect(numpos, ftos(t), vec2(((ar - 1)/ar) * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+    drawpic_aspect_skin(picpos, item_icon, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+}
+
 void DrawItemsTimeItem(vector myPos, vector mySize, float ar, string item_icon, float item_time, bool item_available, float item_availableTime)
 {
     float t = 0;
@@ -323,6 +351,10 @@ void HUD_ItemsTime()
         });
         count += (Item_ItemsTime_GetTime(REGISTRY_MAX(Items)) != -1);
     }
+    // for RJZ
+    if (total_shards != -1)
+               count++;
+       
     if (count == 0)
         return;
 
@@ -399,6 +431,7 @@ void HUD_ItemsTime()
     FOREACH(Items, Item_ItemsTime_Allow(it) && Item_ItemsTime_GetTime(it.m_id) != -1, {
        id = it.m_id;
        icon = it.m_icon;
+               
 
 LABEL(iteration)
         float item_time = Item_ItemsTime_GetTime(id);
@@ -441,6 +474,18 @@ LABEL(iteration)
         if(id == REGISTRY_MAX(Items)) // can happen only in the last fake iteration
                break;
     });
+       
+       // for RJZ
+       if(total_shards != -1) {
+               DrawItemsTimeItemFixed(pos + vec2(column * (itemstime_size.x + offset.x), row * (itemstime_size.y + offset.y)), itemstime_size, ar, "armor", total_shards);
+               ++row;
+               if (row >= rows)
+               {
+                       row = 0;
+                       column = column + 1;
+               }
+       }
+       
     // add another fake iteration for superweapons time
     if(id < REGISTRY_MAX(Items) && Item_ItemsTime_GetTime(REGISTRY_MAX(Items)) != -1)
     {
index abbb1de483a45239d8dc37f49509569290627042..50a89602fc6bb3b50951ef456a7fe09db4b388d9 100644 (file)
@@ -1,5 +1,9 @@
 #pragma once
 
+#ifdef CSQC
+int total_shards = -1;
+#endif
+
 #ifdef SVQC
 int autocvar_sv_itemstime;
 #endif
index 4e888e7c31c66bc61dbf15dd0b96e3d50edfbb18..e8e32cc06d50ad267f7d605ce82cd1b6b8febcc5 100644 (file)
@@ -10,6 +10,7 @@ REGISTER_NET_TEMP(TE_CSQC_VEHICLESETUP)
 REGISTER_NET_TEMP(TE_CSQC_TEAMNAMES)
 REGISTER_NET_TEMP(TE_CSQC_CHATSOUND)
 REGISTER_NET_TEMP(TE_CSQC_WEAPONPICKUP)
+REGISTER_NET_TEMP(TE_CSQC_TOTALSHARDS) // for RJZ
 
 const int RACE_NET_CHECKPOINT_HIT_QUALIFYING = 0; // byte checkpoint, short time, short recordtime, string recordholder
 const int RACE_NET_CHECKPOINT_CLEAR = 1;
index d9b893fda7a6b24d6d2aceb5a757c288ab4d4522..8d5526deefea57c8deaf0e19de8b85284c53ca7b 100644 (file)
@@ -407,6 +407,12 @@ void PutObserverInServer(entity this, bool is_forced)
 
        if (CS(this).just_joined)
                CS(this).just_joined = false;
+       
+       // for RJZ
+       if (autocvar_g_count_shards) {
+               total_shards = 0;
+               send_TotalShards(this);
+       }
 }
 
 int player_getspecies(entity this)
index be104b8a71064836dc795124237912ffabd1a91a..06f1333aaf572e543ecf480603bdbd51834c35a0 100644 (file)
@@ -527,6 +527,13 @@ bool Item_GiveTo(entity item, entity player)
        pickedup |= Item_GiveAmmoTo(item, player, RES_CELLS, g_pickup_cells_max);
        pickedup |= Item_GiveAmmoTo(item, player, RES_PLASMA, g_pickup_plasma_max);
        pickedup |= Item_GiveAmmoTo(item, player, RES_FUEL, g_pickup_fuel_max);
+       
+       // for RJZ
+       if (autocvar_g_count_shards && item.itemdef == ITEM_ArmorSmall) {
+               total_shards++;
+               send_TotalShardsAll();
+       }
+       
        if (item.itemdef.instanceOfWeaponPickup)
        {
                WepSet w, wp;
index 0ea6f9fd7124ad99e0ef9e50735baa4fa8999e75..81f83218b6a7efc400809f2ca86ed5625108a6a9 100644 (file)
@@ -101,6 +101,27 @@ void PingPLReport_Spawn()
 
 const float SPAWNFLAG_NO_WAYPOINTS_FOR_ITEMS = 1;
 
+void send_TotalShards(entity to) {
+       // for RJZ
+       // Send total number of picked up shards
+       if(!autocvar_g_count_shards) return;
+       if(!IS_REAL_CLIENT(to)) return;
+       
+       msg_entity = to;
+       WriteHeader(MSG_ONE, TE_CSQC_TOTALSHARDS);
+       WriteInt24_t(MSG_ONE, total_shards);
+}
+
+void send_TotalShardsAll() {
+       // for RJZ
+       // Send total number of picked up shards
+       if(!autocvar_g_count_shards) return;
+       
+       FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_SPEC(it) || IS_OBSERVER(it)), {
+               send_TotalShards(it);
+       });
+}
+
 void SetDefaultAlpha()
 {
        if (!MUTATOR_CALLHOOK(SetDefaultAlpha))
index 9f8b080545320be491102fdddf95aa45479b27c4..ff99958f021c932c7651b804d898f469cc42e51f 100644 (file)
@@ -160,5 +160,11 @@ void readlevelcvars();
 .vector dropped_origin;
 void droptofloor(entity this);
 
+/* z411 for RJZ */
+bool autocvar_g_count_shards = false;
+int  total_shards = 0;
+void send_TotalShards(entity to);
+void send_TotalShardsAll();
+
 IntrusiveList g_moveables;
 STATIC_INIT(g_moveables) { g_moveables = IL_NEW(); }