]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/gamelog.qc
Merge branch 'Mario/monsters' into 'develop'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / gamelog.qc
1 #include "gamelog.qh"
2 #include <server/intermission.qh>    // GetGametype(), GetMapname()
3 #include <server/weapons/tracing.qh> // autocvar_g_norecoil
4 #include <server/world.qh>           // matchid
5 #include <server/main.qh>
6
7 string GameLog_ProcessIP(string s)
8 {
9         if(!autocvar_sv_eventlog_ipv6_delimiter)
10                 return s;
11         return strreplace(":", "_", s);
12 }
13
14 void GameLogEcho(string s)
15 {
16         if (autocvar_sv_eventlog_files)
17         {
18                 if (!logfile_open)
19                 {
20                         logfile_open = true;
21                         int matches = autocvar_sv_eventlog_files_counter + 1;
22                         cvar_set("sv_eventlog_files_counter", itos(matches));
23                         string fn = ftos(matches);
24                         if (strlen(fn) < 8)
25                                 fn = strcat(substring("00000000", 0, 8 - strlen(fn)), fn);
26                         fn = strcat(autocvar_sv_eventlog_files_nameprefix, fn, autocvar_sv_eventlog_files_namesuffix);
27                         logfile = fopen(fn, FILE_APPEND);
28                         fputs(logfile, ":logversion:3\n");
29                 }
30                 if (logfile >= 0)
31                 {
32                         if (autocvar_sv_eventlog_files_timestamps)
33                                 fputs(logfile, strcat(":time:", strftime(true, "%Y-%m-%d %H:%M:%S", "\n", s, "\n")));
34                         else
35                                 fputs(logfile, strcat(s, "\n"));
36                 }
37         }
38         if (autocvar_sv_eventlog_console)
39         {
40                 dedicated_print(strcat(s, "\n"));
41         }
42 }
43
44 void GameLogInit()
45 {
46         GameLogEcho(strcat(":gamestart:", GetGametype(), "_", GetMapname(), ":", matchid));
47         string s = ":gameinfo:mutators:LIST";
48
49         MUTATOR_CALLHOOK(BuildMutatorsString, s);
50         s = M_ARGV(0, string);
51
52         // initialiation stuff, not good in the mutator system
53         if(!autocvar_g_use_ammunition)
54                 s = strcat(s, ":no_use_ammunition");
55
56         // initialiation stuff, not good in the mutator system
57         if(autocvar_g_pickup_items == 0)
58                 s = strcat(s, ":no_pickup_items");
59         if(autocvar_g_pickup_items > 0)
60                 s = strcat(s, ":pickup_items");
61
62         // initialiation stuff, not good in the mutator system
63         if(autocvar_g_weaponarena != "0")
64                 s = strcat(s, ":", autocvar_g_weaponarena, " arena");
65
66         // TODO to mutator system
67         if(autocvar_g_norecoil)
68                 s = strcat(s, ":norecoil");
69
70         GameLogEcho(s);
71         GameLogEcho(":gameinfo:end");
72 }
73
74 void GameLogClose()
75 {
76         if (logfile_open && logfile >= 0)
77         {
78                 fclose(logfile);
79                 logfile = -1;
80         }
81 }