]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/itemstime.qc
Merge branch 'master' into terencehill/lms_itemtimes_fix
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / itemstime.qc
index 975eb29f3ea12b755c156c6510f67c81dad0ffca..4f4f81fb6d5088d4e4fc1ae4a635ffecee765c29 100644 (file)
@@ -26,6 +26,17 @@ NET_HANDLE(itemstime, bool isNew)
 #endif
 
 #ifdef CSQC
+void Item_ItemsTime_Init()
+{
+    FOREACH(Items, true, LAMBDA(
+        ItemsTime_time[it.m_id] = -1;
+    ));
+}
+
+STATIC_INIT(ItemsTime_Init) {
+    Item_ItemsTime_Init();
+}
+
 int autocvar_hud_panel_itemstime = 2;
 float autocvar_hud_panel_itemstime_dynamicsize = 1;
 float autocvar_hud_panel_itemstime_ratio = 2;
@@ -110,9 +121,7 @@ void Item_ItemsTime_SetTime(entity e, float t)
 
 void Item_ItemsTime_SetTimesForAllPlayers()
 {
-    entity e;
-    FOR_EACH_REALCLIENT(e) if (warmup_stage || !IS_PLAYER(e))
-        Item_ItemsTime_SetTimesForPlayer(e);
+    FOREACH_CLIENT(IS_REAL_CLIENT(it) && (warmup_stage || !IS_PLAYER(it)), LAMBDA(Item_ItemsTime_SetTimesForPlayer(it)));
 }
 
 float Item_ItemsTime_UpdateTime(entity e, float t)
@@ -146,6 +155,17 @@ MUTATOR_HOOKFUNCTION(itemstime, MakePlayerObserver)
     Item_ItemsTime_SetTimesForPlayer(self);
 }
 
+MUTATOR_HOOKFUNCTION(itemstime, ClientConnect, CBC_ORDER_LAST)
+{SELFPARAM();
+       if(IS_PLAYER(self))
+       {
+               // client became player on connection skipping putObserverInServer step
+               if (IS_REAL_CLIENT(self))
+               if (warmup_stage)
+                       Item_ItemsTime_SetTimesForPlayer(self);
+       }
+}
+
 MUTATOR_HOOKFUNCTION(itemstime, PlayerSpawn)
 {SELFPARAM();
     if (warmup_stage) return;