]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/main.qc
Merge branch 'terencehill/fps_display_fix' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / main.qc
index ad11dbd296254b5bdbf580109d0b9b3276278d2e..d111e8aadaaa023c09c4a1dfdd98f1c8b65d7187 100644 (file)
@@ -1,8 +1,8 @@
 #include "main.qh"
 
+#include <client/draw.qh>
 #include <client/items/items.qh>
 #include <common/ent_cs.qh>
-#include "miscfunctions.qh"
 #include <common/effects/effect.qh>
 #include <common/effects/qc/_mod.qh>
 #include <common/effects/all.qh>
@@ -46,7 +46,7 @@ void CSQC_Init()
        prvm_language = strzone(cvar_string("prvm_language"));
 
 #ifdef WATERMARK
-       LOG_INFOF("^4CSQC Build information: ^1%s", WATERMARK);
+       LOG_TRACEF("^4CSQC Build information: ^1%s", WATERMARK);
 #endif
 
        {
@@ -187,6 +187,128 @@ void Shutdown()
        ReplicateVars(true); // destroy
 }
 
+void AuditLists()
+{
+       entity e;
+       entity prev;
+
+       prev = players;
+       for(e = prev.sort_next; e; prev = e, e = e.sort_next)
+       {
+               if(prev != e.sort_prev)
+                       error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
+       }
+
+       prev = teams;
+       for(e = prev.sort_next; e; prev = e, e = e.sort_next)
+       {
+               if(prev != e.sort_prev)
+                       error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
+       }
+}
+
+float RegisterPlayer(entity player)
+{
+       entity pl;
+       AuditLists();
+       for(pl = players.sort_next; pl; pl = pl.sort_next)
+               if(pl == player)
+                       error("Player already registered!");
+       player.sort_next = players.sort_next;
+       player.sort_prev = players;
+       if(players.sort_next)
+               players.sort_next.sort_prev = player;
+       players.sort_next = player;
+       AuditLists();
+       return true;
+}
+
+void RemovePlayer(entity player)
+{
+       entity pl, parent;
+       AuditLists();
+       parent = players;
+       for(pl = players.sort_next; pl && pl != player; pl = pl.sort_next)
+               parent = pl;
+
+       if(!pl)
+       {
+               error("Trying to remove a player which is not in the playerlist!");
+               return;
+       }
+       parent.sort_next = player.sort_next;
+       if(player.sort_next)
+               player.sort_next.sort_prev = parent;
+       AuditLists();
+}
+
+void MoveToLast(entity e)
+{
+       AuditLists();
+       entity ent = e.sort_next;
+       while(ent)
+       {
+               SORT_SWAP(ent, e);
+               ent = e.sort_next;
+       }
+       AuditLists();
+}
+
+float RegisterTeam(entity Team)
+{
+       assert_once(Team.team, eprint(Team));
+       entity tm;
+       AuditLists();
+       for(tm = teams.sort_next; tm; tm = tm.sort_next)
+               if(tm == Team)
+                       error("Team already registered!");
+       Team.sort_next = teams.sort_next;
+       Team.sort_prev = teams;
+       if(teams.sort_next)
+               teams.sort_next.sort_prev = Team;
+       teams.sort_next = Team;
+       if(Team.team && Team.team != NUM_SPECTATOR)
+               ++team_count;
+       AuditLists();
+       return true;
+}
+
+void RemoveTeam(entity Team)
+{
+       entity tm, parent;
+       AuditLists();
+       parent = teams;
+       for(tm = teams.sort_next; tm && tm != Team; tm = tm.sort_next)
+               parent = tm;
+
+       if(!tm)
+       {
+               LOG_INFO(_("Trying to remove a team which is not in the teamlist!"));
+               return;
+       }
+       parent.sort_next = Team.sort_next;
+       if(Team.sort_next)
+               Team.sort_next.sort_prev = parent;
+       if(Team.team && Team.team != NUM_SPECTATOR)
+               --team_count;
+       AuditLists();
+}
+
+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 NULL;
+       entity tm = new_pure(team);
+       tm.team = Team;
+       teamslots[num] = tm;
+       RegisterTeam(tm);
+       return tm;
+}
+
 .float has_team;
 bool SetTeam(entity o, int Team)
 {
@@ -1207,3 +1329,26 @@ string _getcommandkey(string cmd_name, string command, bool forcename)
        else
                return keys;
 }
+
+/** 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
+       }
+       else if (id == URI_GET_DISCARD)
+       {
+               // discard
+       }
+       else if (id >= URI_GET_CURL && id <= URI_GET_CURL_END)
+       {
+               // sv_cmd curl
+               Curl_URI_Get_Callback(id, status, data);
+       }
+       else
+       {
+               LOG_INFOF("Received HTTP request data for an invalid id %d.", id);
+       }
+}