]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/itemstime.qc
Merge branch 'TimePath/unified_weapons' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / itemstime.qc
index c3a025080d39315274a0676db7812d682001fc47..3cdb7b69978ad6ef98c85787bc733bf0913378f9 100644 (file)
@@ -118,7 +118,7 @@ float Item_ItemsTime_UpdateTime(entity e, float t)
     {
         for (entity head = world; (head = nextent(head)); )
         {
-            if (clienttype(head) != CLIENTTYPE_NOTACLIENT || !(head.weapons & WEPSET_SUPERWEAPONS) || head.classname == "weapon_info")
+            if (clienttype(head) != CLIENTTYPE_NOTACLIENT || !(head.weapons & WEPSET_SUPERWEAPONS) || head.instanceOfWeapon)
                 continue;
             if (e == head)
                 continue;
@@ -149,24 +149,28 @@ float Item_ItemsTime_UpdateTime(entity e, float t)
     return t;
 }
 
-MUTATOR_HOOKFUNCTION(itemstime, reset_map_global) {
+MUTATOR_HOOKFUNCTION(itemstime, reset_map_global)
+{SELFPARAM();
     Item_ItemsTime_ResetTimes();
     // ALL the times need to be reset before .reset()ing each item
     // since Item_Reset schedules respawn of superweapons and powerups
-    for (self = world; (self = nextent(self)); )
-    if (IS_NOT_A_CLIENT(self))
+    for (entity e = NULL; (e = nextent(e)); )
+    if (IS_NOT_A_CLIENT(e))
     {
+        setself(e);
         if (self.reset)
             Item_ItemsTime_SetTime(self, 0);
     }
     Item_ItemsTime_SetTimesForAllPlayers();
 }
 
-MUTATOR_HOOKFUNCTION(itemstime, MakePlayerObserver) {
+MUTATOR_HOOKFUNCTION(itemstime, MakePlayerObserver)
+{SELFPARAM();
     Item_ItemsTime_SetTimesForPlayer(self);
 }
 
-MUTATOR_HOOKFUNCTION(itemstime, PlayerSpawn) {
+MUTATOR_HOOKFUNCTION(itemstime, PlayerSpawn)
+{SELFPARAM();
     if (warmup_stage) return;
     Item_ItemsTime_ResetTimesForPlayer(self);
 }
@@ -228,10 +232,15 @@ void DrawItemsTimeItem(vector myPos, vector mySize, float ar, entity item, float
         HUD_Panel_DrawProgressBar(p_pos, p_size, autocvar_hud_panel_itemstime_progressbar_name, t/autocvar_hud_panel_itemstime_progressbar_maxtime, 0, autocvar_hud_panel_itemstime_iconalign, color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
     }
 
-    if (t > 0 && autocvar_hud_panel_itemstime_text)
-        drawstring_aspect(numpos, ftos(t), eX * ((ar - 1)/ar) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
-    else
-        picpos.x = myPos.x + mySize.x / 2 - mySize.y / 2;
+    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);
+        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);
+        else // legacy code, if the image is missing just center the icon
+            picpos.x = myPos.x + mySize.x / 2 - mySize.y / 2;
+    }
     if (item_availableTime)
         drawpic_aspect_skin_expanding(picpos, item.m_icon, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * picalpha, DRAWFLAG_NORMAL, item_availableTime);
     drawpic_aspect_skin(picpos, item.m_icon, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * picalpha, DRAWFLAG_NORMAL);