]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/miscfunctions.qc
Merge branch 'master' into terencehill/dynamic_hud
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / miscfunctions.qc
index 683f455bff2d9fb8d4134fadf98ec5909fd1f923..970a681e37b202f9bfc2a49c6f2c6377b0a13715 100644 (file)
 #include "miscfunctions.qh"
 
-#include "../common/urllib.qh"
+#include "hud/all.qh"
 
-#include "../common/command/generic.qh"
+#include <common/command/generic.qh>
 
-void InitializeEntity(entity e, void(void) func, float order)
-{
-    entity prev, cur;
-
-    if (!e || e.initialize_entity)
-    {
-        // make a proxy initializer entity
-        entity e_old;
-        e_old = e;
-        e = spawn();
-        e.classname = "initialize_entity";
-        e.enemy = e_old;
-    }
-
-    e.initialize_entity = func;
-    e.initialize_entity_order = order;
-
-    cur = initialize_entity_first;
-    prev = world;
-    for (;;)
-    {
-        if (!cur || cur.initialize_entity_order > order)
-        {
-            // insert between prev and cur
-            if (prev)
-                prev.initialize_entity_next = e;
-            else
-                initialize_entity_first = e;
-            e.initialize_entity_next = cur;
-            return;
-        }
-        prev = cur;
-        cur = cur.initialize_entity_next;
-    }
-}
-void InitializeEntitiesRun()
-{
-    entity startoflist;
-    startoflist = initialize_entity_first;
-    initialize_entity_first = world;
-    for (self = startoflist; self; self = self.initialize_entity_next)
-    {
-       //self.remove_except_protected_forbidden = 1;
-    }
-    for (self = startoflist; self; )
-    {
-        entity e;
-        var void(void) func;
-        e = self.initialize_entity_next;
-        func = self.initialize_entity;
-        self.initialize_entity_order = 0;
-        self.initialize_entity = func_null;
-        self.initialize_entity_next = world;
-       //self.remove_except_protected_forbidden = 0;
-        if (self.classname == "initialize_entity")
-        {
-            entity e_old;
-            e_old = self.enemy;
-            remove(self);
-            self = e_old;
-        }
-        //dprint("Delayed initialization: ", self.classname, "\n");
-        if(func)
-            func();
-        else
-        {
-            eprint(self);
-            backtrace(strcat("Null function in: ", self.classname, "\n"));
-        }
-        self = e;
-    }
-}
-
-void defer_think()
-{
-    entity oself;
-
-    oself           = self;
-    self            = self.owner;
-    oself.think     = SUB_Remove;
-    oself.nextthink = time;
+#include <common/teams.qh>
 
-    oself.use();
-}
-
-/*
-    Execute func() after time + fdelay.
-    self when func is executed = self when defer is called
-*/
-void defer(float fdelay, void() func)
-{
-    entity e;
-
-    e           = spawn();
-    e.classname = "defer";
-    e.owner     = self;
-    e.use       = func;
-    e.think     = defer_think;
-    e.nextthink = time + fdelay;
-}
-
-void defer_clear(entity ent)
-{
-       entity e;
-       for(e = world; (e = find(e, classname, "defer")); )
-               if(e.owner == ent)
-                       remove(e);
-}
+#include <lib/csqcmodel/cl_model.qh>
 
 
 void AuditLists()
@@ -184,6 +79,7 @@ void MoveToLast(entity e)
 
 float RegisterTeam(entity Team)
 {
+       assert_once(Team.team, eprint(Team));
        entity tm;
        AuditLists();
        for(tm = teams.sort_next; tm; tm = tm.sort_next)
@@ -210,7 +106,7 @@ void RemoveTeam(entity Team)
 
        if(!tm)
        {
-               print(_("Trying to remove a team which is not in the teamlist!"));
+               LOG_INFO(_("Trying to remove a team which is not in the teamlist!"));
                return;
        }
        parent.sort_next = Team.sort_next;
@@ -223,12 +119,13 @@ void RemoveTeam(entity Team)
 
 entity GetTeam(int Team, bool add)
 {
+    TC(int, Team); TC(bool, add);
        int num = (Team == NUM_SPECTATOR) ? 16 : Team;
        if(teamslots[num])
                return teamslots[num];
        if (!add)
                return world;
-       entity tm = spawn();
+       entity tm = new_pure(team);
        tm.team = Team;
        teamslots[num] = tm;
        RegisterTeam(tm);
@@ -260,26 +157,10 @@ float PreviewExists(string name)
        return false;
 }
 
-vector rotate(vector v, float a)
-{
-       vector w = '0 0 0';
-       // FTEQCC SUCKS AGAIN
-       w.x =      v.x * cos(a) + v.y * sin(a);
-       w.y = -1 * v.x * sin(a) + v.y * cos(a);
-       return w;
-}
-
-string ColorTranslateRGB(string s)
-{
-       if(ColorTranslateMode & 1)
-               return strdecolorize(s);
-       else
-               return s;
-}
-
 // decolorizes and team colors the player name when needed
 string playername(string thename, float teamid)
 {
+    TC(int, teamid);
     string t;
     if (teamplay)
     {
@@ -311,10 +192,6 @@ vector project_3d_to_2d(vector vec)
        return vec;
 }
 
-void dummyfunction(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8)
-{
-}
-
 float expandingbox_sizefactor_from_fadelerp(float fadelerp)
 {
        return 1.2 / (1.2 - fadelerp);
@@ -399,7 +276,6 @@ void drawstring_expanding(vector position, string text, vector theScale, vector
        sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
 
        drawfontscale = sz * '1 1 0';
-       dummyfunction(0, 0, 0, 0, 0, 0, 0, 0);
        drawstring(position + expandingbox_resize_centered_box_offset(sz, theScale, stringwidth(text, false, theScale * (sz / drawfontscale.x)) / (theScale.x * sz)), text, theScale * (sz / drawfontscale.x), rgb, theAlpha * (1 - fadelerp), flag);
        // width parameter:
        //    (scale_x * sz / drawfontscale_x) * drawfontscale_x * SIZE1 / (scale_x * sz)
@@ -419,7 +295,6 @@ void drawcolorcodedstring_expanding(vector position, string text, vector theScal
        sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
 
        drawfontscale = sz * '1 1 0';
-       dummyfunction(0, 0, 0, 0, 0, 0, 0, 0);
        drawcolorcodedstring(position + expandingbox_resize_centered_box_offset(sz, theScale, stringwidth(text, true, theScale * (sz / drawfontscale.x)) / (theScale.x * sz)), text, theScale * (sz / drawfontscale.x), theAlpha * (1 - fadelerp), flag);
        drawfontscale = '1 1 0';
 }
@@ -609,59 +484,10 @@ void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector
        }
 }
 
-vector getplayerorigin(int pl)
-{
-       entity e;
-
-       e = CSQCModel_server2csqc(pl + 1);
-       if(e)
-               return e.origin;
-
-       e = entcs_receiver[pl];
-       if(e)
-               return e.origin;
-
-       return GETPLAYERORIGIN_ERROR;
-}
-
-float getplayeralpha(float pl)
-{
-       entity e;
-
-       e = CSQCModel_server2csqc(pl + 1);
-       if(e)
-               return e.alpha;
-
-       return 1;
-}
-
-vector getcsqcplayercolor(float pl)
-{
-       entity e;
-
-       e = CSQCModel_server2csqc(pl);
-       if(e)
-       {
-               if(e.colormap > 0)
-                       return colormapPaletteColor(((e.colormap >= 1024) ? e.colormap : stof(getplayerkeyvalue(e.colormap - 1, "colors"))) & 0x0F, true);
-       }
-
-       return '1 1 1';
-}
-
-float getplayerisdead(float pl)
-{
-       entity e;
-
-       e = CSQCModel_server2csqc(pl + 1);
-       if(e)
-               return e.csqcmodel_isdead;
-
-       return false;
-}
-
-void URI_Get_Callback(int id, float status, string data)
+/** engine callback */
+void URI_Get_Callback(int id, int status, string data)
 {
+    TC(int, id); TC(int, status);
        if(url_URI_Get_Callback(id, status, data))
        {
                // handled
@@ -677,20 +503,10 @@ void URI_Get_Callback(int id, float status, string data)
        }
        else
        {
-               printf("Received HTTP request data for an invalid id %d.\n", id);
+               LOG_INFOF("Received HTTP request data for an invalid id %d.\n", id);
        }
 }
 
-void draw_beginBoldFont()
-{
-       drawfont = FONT_USER+2;
-}
-
-void draw_endBoldFont()
-{
-       drawfont = FONT_USER+1;
-}
-
 void Accuracy_LoadLevels()
 {
        if(autocvar_accuracy_color_levels != acc_color_levels)
@@ -702,7 +518,7 @@ void Accuracy_LoadLevels()
                if(acc_levels > MAX_ACCURACY_LEVELS)
                        acc_levels = MAX_ACCURACY_LEVELS;
                if(acc_levels < 2)
-                       print("Warning: accuracy_color_levels must contain at least 2 values\n");
+                       LOG_INFO("Warning: accuracy_color_levels must contain at least 2 values\n");
 
                int i;
                for(i = 0; i < acc_levels; ++i)