]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/miscfunctions.qc
Split the gamelog code out of miscfunctions and into its own file
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / miscfunctions.qc
index 6e2bbb8d7cd3c8a52868f9d3456c6b17d789db04..98bd7756a435844daf520e25fba77de9059bca51 100644 (file)
@@ -4,6 +4,7 @@
 #include "command/common.qh"
 #include "constants.qh"
 #include "g_hook.qh"
+#include <server/gamelog.qh>
 #include "ipban.qh"
 #include <server/mutators/_mod.qh>
 #include "../common/t_items.qh"
@@ -84,61 +85,6 @@ void dedicated_print(string input)
        if (server_is_dedicated) print(input);
 }
 
-string GameLog_ProcessIP(string s)
-{
-       if(!autocvar_sv_eventlog_ipv6_delimiter)
-               return s;
-       return strreplace(":", "_", s);
-}
-
-void GameLogEcho(string s)
-{
-    string fn;
-    int matches;
-
-    if (autocvar_sv_eventlog_files)
-    {
-        if (!logfile_open)
-        {
-            logfile_open = true;
-            matches = autocvar_sv_eventlog_files_counter + 1;
-            cvar_set("sv_eventlog_files_counter", itos(matches));
-            fn = ftos(matches);
-            if (strlen(fn) < 8)
-                fn = strcat(substring("00000000", 0, 8 - strlen(fn)), fn);
-            fn = strcat(autocvar_sv_eventlog_files_nameprefix, fn, autocvar_sv_eventlog_files_namesuffix);
-            logfile = fopen(fn, FILE_APPEND);
-            fputs(logfile, ":logversion:3\n");
-        }
-        if (logfile >= 0)
-        {
-            if (autocvar_sv_eventlog_files_timestamps)
-                fputs(logfile, strcat(":time:", strftime(true, "%Y-%m-%d %H:%M:%S", "\n", s, "\n")));
-            else
-                fputs(logfile, strcat(s, "\n"));
-        }
-    }
-    if (autocvar_sv_eventlog_console)
-    {
-        dedicated_print(strcat(s, "\n"));
-    }
-}
-
-void GameLogInit()
-{
-    logfile_open = 0;
-    // will be opened later
-}
-
-void GameLogClose()
-{
-    if (logfile_open && logfile >= 0)
-    {
-        fclose(logfile);
-        logfile = -1;
-    }
-}
-
 entity findnearest(vector point, bool checkitems, vector axismod)
 {
     vector dist;
@@ -243,7 +189,7 @@ string WeaponNameFromWeaponentity(entity this, .entity weaponentity)
                return wepent.m_weapon.m_name;
        else if(wepent.m_switchweapon != WEP_Null)
                return wepent.m_switchweapon.m_name;
-       return "none"; //Weapons_from(wepent.cnt).m_name;
+       return "none"; //REGISTRY_GET(Weapons, wepent.cnt).m_name;
 }
 
 string formatmessage(entity this, string msg)
@@ -719,7 +665,7 @@ void readplayerstartcvars()
                for (int j = 0; j < t; ++j)
                {
                        s = argv(j);
-                       Weapon wep = Weapons_fromstr(s);
+                       Weapon wep = Weapon_from_name(s);
                        if(wep != WEP_Null)
                        {
                                g_weaponarena_weapons |= (wep.m_wepset);
@@ -856,9 +802,14 @@ void readplayerstartcvars()
 
 void precache_playermodel(string m)
 {
-       float globhandle, i, n;
+       int globhandle, i, n;
        string f;
 
+       // remove :<skinnumber> suffix
+       int j = strstrofs(m, ":", 0);
+       if(j >= 0)
+               m = substring(m, 0, j);
+
        if(substring(m, -9, 5) == "_lod1")
                return;
        if(substring(m, -9, 5) == "_lod2")
@@ -901,10 +852,8 @@ void precache_playermodels(string s)
        FOREACH_WORD(s, true, { precache_playermodel(it); });
 }
 
-void precache()
+PRECACHE(PlayerModels)
 {
-    // gamemode related things
-
     // Precache all player models if desired
     if (autocvar_sv_precacheplayermodels)
     {
@@ -924,20 +873,6 @@ void precache()
                precache_playermodels(autocvar_sv_defaultplayermodel_pink);
                precache_playermodels(autocvar_sv_defaultplayermodel);
     }
-
-#if 0
-    // Disabled this code because it simply does not work (e.g. ignores bgmvolume, overlaps with "cd loop" controlled tracks).
-
-    if (!this.noise && this.music) // quake 3 uses the music field
-        this.noise = this.music;
-
-    // plays music for the level if there is any
-    if (this.noise)
-    {
-        precache_sound (this.noise);
-        ambientsound ('0 0 0', this.noise, VOL_BASE, ATTEN_NONE);
-    }
-#endif
 }