From c80c47fc2123b399830d25a0d673c673a3b500c9 Mon Sep 17 00:00:00 2001 From: z411 Date: Tue, 12 Oct 2021 21:38:06 -0300 Subject: [PATCH] RJZ: Total armor pickups in timestimes panel --- qcsrc/client/main.qh | 1 + .../mutators/mutator/itemstime/itemstime.qc | 45 +++++++++++++++++++ .../mutators/mutator/itemstime/itemstime.qh | 4 ++ qcsrc/common/net_linked.qh | 1 + qcsrc/server/client.qc | 6 +++ qcsrc/server/items/items.qc | 7 +++ qcsrc/server/world.qc | 21 +++++++++ qcsrc/server/world.qh | 6 +++ 8 files changed, 91 insertions(+) diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index 9d0f6ef2d..f45626047 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -195,3 +195,4 @@ float serverprevtime, serverdeltatime; float ticrate; int serverflags; + diff --git a/qcsrc/common/mutators/mutator/itemstime/itemstime.qc b/qcsrc/common/mutators/mutator/itemstime/itemstime.qc index d30f16943..005b27b62 100644 --- a/qcsrc/common/mutators/mutator/itemstime/itemstime.qc +++ b/qcsrc/common/mutators/mutator/itemstime/itemstime.qc @@ -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) { diff --git a/qcsrc/common/mutators/mutator/itemstime/itemstime.qh b/qcsrc/common/mutators/mutator/itemstime/itemstime.qh index abbb1de48..50a89602f 100644 --- a/qcsrc/common/mutators/mutator/itemstime/itemstime.qh +++ b/qcsrc/common/mutators/mutator/itemstime/itemstime.qh @@ -1,5 +1,9 @@ #pragma once +#ifdef CSQC +int total_shards = -1; +#endif + #ifdef SVQC int autocvar_sv_itemstime; #endif diff --git a/qcsrc/common/net_linked.qh b/qcsrc/common/net_linked.qh index 4e888e7c3..e8e32cc06 100644 --- a/qcsrc/common/net_linked.qh +++ b/qcsrc/common/net_linked.qh @@ -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; diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index d9b893fda..8d5526dee 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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) diff --git a/qcsrc/server/items/items.qc b/qcsrc/server/items/items.qc index be104b8a7..06f1333aa 100644 --- a/qcsrc/server/items/items.qc +++ b/qcsrc/server/items/items.qc @@ -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; diff --git a/qcsrc/server/world.qc b/qcsrc/server/world.qc index 0ea6f9fd7..81f83218b 100644 --- a/qcsrc/server/world.qc +++ b/qcsrc/server/world.qc @@ -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)) diff --git a/qcsrc/server/world.qh b/qcsrc/server/world.qh index 9f8b08054..ff99958f0 100644 --- a/qcsrc/server/world.qh +++ b/qcsrc/server/world.qh @@ -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(); } -- 2.39.2