]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move itemstime to mutator
authorTimePath <andrew.hardaker1995@gmail.com>
Mon, 24 Aug 2015 01:43:44 +0000 (11:43 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 24 Aug 2015 01:43:44 +0000 (11:43 +1000)
qcsrc/common/mutators/mutator/itemstime.qc
qcsrc/server/command/vote.qc
qcsrc/server/t_items.qc

index 122212dc293655134f18dc9caf1f37aa3f985d23..329db6d16a24b6f6a8f292555ab732d6438c0c8b 100644 (file)
@@ -21,3 +21,177 @@ MUTATOR_HOOKFUNCTION(itemstime, CSQC_Parse_TempEntity) {
     return true;
 }
 #endif
+
+#ifdef SVQC
+float it_armor_large_time;
+float it_health_mega_time;
+float it_invisible_time;
+float it_speed_time;
+float it_extralife_time;
+float it_strength_time;
+float it_shield_time;
+float it_fuelregen_time;
+float it_jetpack_time;
+float it_superweapons_time;
+
+void Item_ItemsTime_Init()
+{
+    it_armor_large_time = -1;
+    it_health_mega_time = -1;
+    it_invisible_time = -1;
+    it_speed_time = -1;
+    it_extralife_time = -1;
+    it_strength_time = -1;
+    it_shield_time = -1;
+    it_fuelregen_time = -1;
+    it_jetpack_time = -1;
+    it_superweapons_time = -1;
+}
+
+STATIC_INIT(ItemsTime_Init) {
+    // items time
+    Item_ItemsTime_Init();
+}
+
+void Item_ItemsTime_ResetTimes()
+{
+    it_armor_large_time  = (it_armor_large_time  == -1) ? -1 : 0;
+    it_health_mega_time  = (it_health_mega_time  == -1) ? -1 : 0;
+    it_invisible_time    = (it_invisible_time    == -1) ? -1 : 0;
+    it_speed_time        = (it_speed_time        == -1) ? -1 : 0;
+    it_extralife_time    = (it_extralife_time    == -1) ? -1 : 0;
+    it_strength_time     = (it_strength_time     == -1) ? -1 : 0;
+    it_shield_time       = (it_shield_time       == -1) ? -1 : 0;
+    it_fuelregen_time    = (it_fuelregen_time    == -1) ? -1 : 0;
+    it_jetpack_time      = (it_jetpack_time      == -1) ? -1 : 0;
+    it_superweapons_time = (it_superweapons_time == -1) ? -1 : 0;
+}
+
+void Item_ItemsTime_ResetTimesForPlayer(entity e)
+{
+    IT_Write(e, item_armor_large_time , (it_armor_large_time  == -1) ? -1 : 0);
+    IT_Write(e, item_health_mega_time , (it_health_mega_time  == -1) ? -1 : 0);
+    IT_Write(e, item_invisible_time   , (it_invisible_time    == -1) ? -1 : 0);
+    IT_Write(e, item_speed_time       , (it_speed_time        == -1) ? -1 : 0);
+    IT_Write(e, item_extralife_time   , (it_extralife_time    == -1) ? -1 : 0);
+    IT_Write(e, item_strength_time    , (it_strength_time     == -1) ? -1 : 0);
+    IT_Write(e, item_shield_time      , (it_shield_time       == -1) ? -1 : 0);
+    IT_Write(e, item_fuelregen_time   , (it_fuelregen_time    == -1) ? -1 : 0);
+    IT_Write(e, item_jetpack_time     , (it_jetpack_time      == -1) ? -1 : 0);
+    IT_Write(e, item_superweapons_time, (it_superweapons_time == -1) ? -1 : 0);
+}
+
+void Item_ItemsTime_SetTimesForPlayer(entity e)
+{
+    IT_Write(e, item_armor_large_time , it_armor_large_time );
+    IT_Write(e, item_health_mega_time , it_health_mega_time );
+    IT_Write(e, item_invisible_time   , it_invisible_time   );
+    IT_Write(e, item_speed_time       , it_speed_time       );
+    IT_Write(e, item_extralife_time   , it_extralife_time   );
+    IT_Write(e, item_strength_time    , it_strength_time    );
+    IT_Write(e, item_shield_time      , it_shield_time      );
+    IT_Write(e, item_fuelregen_time   , it_fuelregen_time   );
+    IT_Write(e, item_jetpack_time     , it_jetpack_time     );
+    IT_Write(e, item_superweapons_time, it_superweapons_time);
+}
+
+void Item_ItemsTime_SetTime(entity e, float t)
+{
+    if (!autocvar_sv_itemstime)
+        return;
+
+    if (g_instagib)
+    {
+        switch (e.items)
+        {
+            case IT_STRENGTH://"item-invis"
+                it_invisible_time = t;
+                break;
+            case IT_NAILS://"item-extralife"
+                it_extralife_time = t;
+                break;
+            case IT_INVINCIBLE://"item-speed"
+                it_speed_time = t;
+                break;
+        }
+    }
+    else
+    {
+        switch (e.items)
+        {
+            case ITEM_HealthMega.m_itemid:
+                // if (e.itemdef == ITEM_HealthMega) // e.items == IT_HEALTH unequivocally identifies it
+                    it_health_mega_time = t;
+                break;
+            case ITEM_ArmorMega.m_itemid:
+                if (e.itemdef == ITEM_ArmorMega) // e.items == IT_ARMOR doesn't unequivocally identifies it
+                    it_armor_large_time = t;
+                break;
+            case IT_STRENGTH://"item-strength"
+                it_strength_time = t;
+                break;
+            case IT_INVINCIBLE://"item-shield"
+                it_shield_time = t;
+                break;
+            default:
+                if (e.weapons & WEPSET_SUPERWEAPONS)
+                    it_superweapons_time = t;
+        }
+    }
+    switch (e.items)
+    {
+        case IT_FUEL_REGEN://"item-fuelregen"
+            it_fuelregen_time = t;
+            break;
+        case IT_JETPACK://"item-jetpack"
+            it_jetpack_time = t;
+            break;
+    }
+}
+
+void Item_ItemsTime_SetTimesForAllPlayers()
+{
+    entity e;
+    FOR_EACH_REALCLIENT(e) if (warmup_stage || !IS_PLAYER(e))
+        Item_ItemsTime_SetTimesForPlayer(e);
+}
+
+float Item_ItemsTime_UpdateTime(entity e, float t)
+{
+    bool isavailable = (t == 0);
+    if (e.weapons & WEPSET_SUPERWEAPONS)
+    {
+        for (entity head = world; (head = nextent(head)); )
+        {
+            if (clienttype(head) != CLIENTTYPE_NOTACLIENT || !(head.weapons & WEPSET_SUPERWEAPONS) || head.classname == "weapon_info")
+                continue;
+            if (e == head)
+                continue;
+
+            if (head.scheduledrespawntime <= time)
+                isavailable = true;
+            else if (t == 0 || head.scheduledrespawntime < t)
+                t = head.scheduledrespawntime;
+        }
+    }
+    else
+    {
+        for (entity head = world; (head = nextent(head)); )
+        {
+            if (head.itemdef != e.itemdef)
+                continue;
+            if (e == head)
+                continue;
+
+            if (head.scheduledrespawntime <= time)
+                isavailable = true;
+            else if (t == 0 || head.scheduledrespawntime < t)
+                t = head.scheduledrespawntime;
+        }
+    }
+    if (isavailable)
+        t = -t; // let know the client there's another available item
+    return t;
+}
+
+#endif
index 6ea03dd43fdaad2c88dca9ee34ce0b0171a73adc..f9b8fae070d8161ad1cf0c761baead2e9f4fc160 100644 (file)
@@ -432,6 +432,8 @@ void ReadyRestart_think()
        return;
 }
 
+void Item_ItemsTime_ResetTimes();
+
 // Forces a restart of the game without actually reloading the map // this is a mess...
 void ReadyRestart_force()
 {
index 0dd5c9c2b1ae8e656a6e23146c524228372545c8..747075812b9a58933bfd0970328888b11bbd119b 100644 (file)
@@ -412,186 +412,9 @@ void Item_Think()
        }
 }
 
-float it_armor_large_time;
-float it_health_mega_time;
-float it_invisible_time;
-float it_speed_time;
-float it_extralife_time;
-float it_strength_time;
-float it_shield_time;
-float it_fuelregen_time;
-float it_jetpack_time;
-float it_superweapons_time;
-
-void Item_ItemsTime_Init()
-{
-       it_armor_large_time = -1;
-       it_health_mega_time = -1;
-       it_invisible_time = -1;
-       it_speed_time = -1;
-       it_extralife_time = -1;
-       it_strength_time = -1;
-       it_shield_time = -1;
-       it_fuelregen_time = -1;
-       it_jetpack_time = -1;
-       it_superweapons_time = -1;
-}
-
-STATIC_INIT(ItemsTime_Init) {
-    // items time
-    Item_ItemsTime_Init();
-}
-
-void Item_ItemsTime_ResetTimes()
-{
-       it_armor_large_time = (it_armor_large_time == -1) ? -1 : 0;
-       it_health_mega_time = (it_health_mega_time == -1) ? -1 : 0;
-       it_invisible_time   = (it_invisible_time   == -1) ? -1 : 0;
-       it_speed_time       = (it_speed_time       == -1) ? -1 : 0;
-       it_extralife_time   = (it_extralife_time   == -1) ? -1 : 0;
-       it_strength_time    = (it_strength_time    == -1) ? -1 : 0;
-       it_shield_time      = (it_shield_time      == -1) ? -1 : 0;
-       it_fuelregen_time   = (it_fuelregen_time   == -1) ? -1 : 0;
-       it_jetpack_time     = (it_jetpack_time     == -1) ? -1 : 0;
-       it_superweapons_time= (it_superweapons_time== -1) ? -1 : 0;
-}
-void IT_Write(entity, int, float);
-void Item_ItemsTime_ResetTimesForPlayer(entity e)
-{
-    IT_Write(e, item_armor_large_time , (it_armor_large_time  == -1) ? -1 : 0);
-    IT_Write(e, item_health_mega_time , (it_health_mega_time  == -1) ? -1 : 0);
-    IT_Write(e, item_invisible_time   , (it_invisible_time    == -1) ? -1 : 0);
-    IT_Write(e, item_speed_time       , (it_speed_time        == -1) ? -1 : 0);
-    IT_Write(e, item_extralife_time   , (it_extralife_time    == -1) ? -1 : 0);
-    IT_Write(e, item_strength_time    , (it_strength_time     == -1) ? -1 : 0);
-    IT_Write(e, item_shield_time      , (it_shield_time       == -1) ? -1 : 0);
-    IT_Write(e, item_fuelregen_time   , (it_fuelregen_time    == -1) ? -1 : 0);
-    IT_Write(e, item_jetpack_time     , (it_jetpack_time      == -1) ? -1 : 0);
-    IT_Write(e, item_superweapons_time, (it_superweapons_time == -1) ? -1 : 0);
-}
-void Item_ItemsTime_SetTimesForPlayer(entity e)
-{
-    IT_Write(e, item_armor_large_time , it_armor_large_time );
-    IT_Write(e, item_health_mega_time , it_health_mega_time );
-    IT_Write(e, item_invisible_time   , it_invisible_time   );
-    IT_Write(e, item_speed_time       , it_speed_time       );
-    IT_Write(e, item_extralife_time   , it_extralife_time   );
-    IT_Write(e, item_strength_time    , it_strength_time    );
-    IT_Write(e, item_shield_time      , it_shield_time      );
-    IT_Write(e, item_fuelregen_time   , it_fuelregen_time   );
-    IT_Write(e, item_jetpack_time     , it_jetpack_time     );
-    IT_Write(e, item_superweapons_time, it_superweapons_time);
-}
-
-void Item_ItemsTime_SetTime(entity e, float t)
-{
-       if(!autocvar_sv_itemstime)
-               return;
-
-       if(g_instagib)
-       {
-               switch(e.items)
-               {
-                       case IT_STRENGTH://"item-invis"
-                               it_invisible_time = t;
-                               break;
-                       case IT_NAILS://"item-extralife"
-                               it_extralife_time = t;
-                               break;
-                       case IT_INVINCIBLE://"item-speed"
-                               it_speed_time = t;
-                               break;
-               }
-       }
-       else
-       {
-               switch(e.items)
-               {
-                       case ITEM_HealthMega.m_itemid:
-                               // if(e.itemdef == ITEM_HealthMega) // e.items == IT_HEALTH unequivocally identifies it
-                                       it_health_mega_time = t;
-                               break;
-                       case ITEM_ArmorMega.m_itemid:
-                               if(e.itemdef == ITEM_ArmorMega) // e.items == IT_ARMOR doesn't unequivocally identifies it
-                                       it_armor_large_time = t;
-                               break;
-                       case IT_STRENGTH://"item-strength"
-                               it_strength_time = t;
-                               break;
-                       case IT_INVINCIBLE://"item-shield"
-                               it_shield_time = t;
-                               break;
-                       default:
-                               if(e.weapons & WEPSET_SUPERWEAPONS)
-                                       it_superweapons_time = t;
-               }
-       }
-       switch(e.items)
-       {
-               case IT_FUEL_REGEN://"item-fuelregen"
-                       it_fuelregen_time = t;
-                       break;
-               case IT_JETPACK://"item-jetpack"
-                       it_jetpack_time = t;
-                       break;
-       }
-}
-void Item_ItemsTime_SetTimesForAllPlayers()
-{
-       entity e;
-       if(warmup_stage)
-       {
-               FOR_EACH_REALCLIENT(e)
-                       Item_ItemsTime_SetTimesForPlayer(e);
-       }
-       else
-       {
-               FOR_EACH_REALCLIENT(e)
-               {
-                       if(!IS_PLAYER(e))
-                               Item_ItemsTime_SetTimesForPlayer(e);
-               }
-       }
-}
-
-float Item_ItemsTime_UpdateTime(entity e, float t)
-{
-       entity head;
-       bool isavailable = (t == 0);
-       if(e.weapons & WEPSET_SUPERWEAPONS)
-       {
-               for(head = world; (head = nextent(head)); )
-               {
-                       if(clienttype(head) != CLIENTTYPE_NOTACLIENT || !(head.weapons & WEPSET_SUPERWEAPONS) || head.classname == "weapon_info")
-                               continue;
-                       if(e == head)
-                               continue;
-
-                       if(head.scheduledrespawntime <= time)
-                               isavailable = true;
-                       else if(t == 0 || head.scheduledrespawntime < t)
-                               t = head.scheduledrespawntime;
-               }
-       }
-       else
-       {
-               for(head = world; (head = nextent(head)); )
-               {
-                       if(head.itemdef != e.itemdef)
-                               continue;
-                       if(e == head)
-                               continue;
-
-                       if(head.scheduledrespawntime <= time)
-                               isavailable = true;
-                       else if(t == 0 || head.scheduledrespawntime < t)
-                               t = head.scheduledrespawntime;
-               }
-       }
-       if(isavailable)
-               t = -t; // let know the client there's another available item
-       return t;
-}
+float Item_ItemsTime_UpdateTime(entity e, float t);
+void Item_ItemsTime_SetTime(entity e, float t);
+void Item_ItemsTime_SetTimesForAllPlayers();
 
 void Item_Respawn (void)
 {