-
Notifications
You must be signed in to change notification settings - Fork 3
/
serverlogging.patch
169 lines (159 loc) · 7.31 KB
/
serverlogging.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
Index: src/engine/rendergl.cpp
===================================================================
--- src/engine/rendergl.cpp (revision 6502)
+++ src/engine/rendergl.cpp (working copy)
@@ -2165,8 +2165,6 @@
VARP(wallclock24, 0, 0, 1);
VARP(wallclocksecs, 0, 0, 1);
-static time_t walltime = 0;
-
VARP(showfps, 0, 1, 1);
VARP(showfpsrange, 0, 0, 1);
VAR(showeditstats, 0, 0, 1);
Index: src/engine/server.cpp
===================================================================
--- src/engine/server.cpp (revision 6502)
+++ src/engine/server.cpp (working copy)
@@ -45,11 +45,25 @@
va_end(args);
}
+time_t walltime = 0;
+MOD(VARP, logtime, 0, 1, 1);
static void writelog(FILE *file, const char *buf)
{
static uchar ubuf[512];
size_t len = strlen(buf), carry = 0;
+ if(isdedicatedserver() && logtime)
+ {
+ if(!walltime) { walltime = time(NULL); walltime -= totalsecs; if(!walltime) walltime++; }
+ time_t walloffset = walltime + totalsecs;
+ struct tm *localvals = localtime(&walloffset);
+ static string ts;
+ if(localvals)
+ {
+ int tslen = strftime(ts, sizeof(ts), "[%Y-%m-%d %H:%M:%S] ", localvals);
+ if(tslen) fwrite(ts, 1, tslen, file);
+ }
+ }
while(carry < len)
{
size_t numu = encodeutf8(ubuf, sizeof(ubuf)-1, &((const uchar *)buf)[carry], len - carry, &carry);
@@ -339,8 +339,8 @@ void disconnect_client(int n, int reason)
delclient(clients[n]);
const char *msg = disconnectreason(reason);
string s;
- if(msg) formatstring(s, "client (%s) disconnected because: %s", clients[n]->hostname, msg);
- else formatstring(s, "client (%s) disconnected", clients[n]->hostname);
+ if(msg) formatstring(s, "client %s (cn %d) disconnected because: %s", clients[n]->hostname, n, msg);
+ else formatstring(s, "client %s (cn %d) disconnected", clients[n]->hostname, n);
logoutf("%s", s);
server::sendservmsg(s);
}
@@ -661,7 +675,7 @@
c.peer->data = &c;
string hn;
copystring(c.hostname, (enet_address_get_host_ip(&c.peer->address, hn, sizeof(hn))==0) ? hn : "unknown");
- logoutf("client connected (%s)", c.hostname);
+ logoutf("connected: %s (cn %d)", c.hostname, c.num);
int reason = server::clientconnect(c.num, c.peer->address.host);
if(reason) disconnect_client(c.num, reason);
break;
@@ -677,7 +691,7 @@
{
client *c = (client *)event.peer->data;
if(!c) break;
- logoutf("disconnected client (%s)", c->hostname);
+ logoutf("disconnected: %s (cn %d)", c->hostname, c->num);
server::clientdisconnect(c->num);
delclient(c);
break;
Index: src/fpsgame/server.cpp
===================================================================
--- src/fpsgame/server.cpp (revision 6502)
+++ src/fpsgame/server.cpp (working copy)
@@ -1486,10 +1486,22 @@
string msg;
if(val && authname)
{
- if(authdesc && authdesc[0]) formatstring(msg, "%s claimed %s as '\fs\f5%s\fr' [\fs\f0%s\fr]", colorname(ci), name, authname, authdesc);
- else formatstring(msg, "%s claimed %s as '\fs\f5%s\fr'", colorname(ci), name, authname);
+ if(authdesc && authdesc[0])
+ {
+ formatstring(msg, "%s claimed %s as '\fs\f5%s\fr' [\fs\f0%s\fr]", colorname(ci), name, authname, authdesc);
+ if(isdedicatedserver()) logoutf("privilege: %s (cn %d) claimed %s as '%s' [%s]", ci->name, ci->clientnum, name, authname, authdesc);
}
- else formatstring(msg, "%s %s %s", colorname(ci), val ? "claimed" : "relinquished", name);
+ else
+ {
+ formatstring(msg, "%s claimed %s as '\fs\f5%s\fr'", colorname(ci), name, authname);
+ if(isdedicatedserver()) logoutf("privilege: %s (cn %d) claimed %s as '%s'", ci->name, ci->clientnum, name, authname);
+ }
+ }
+ else
+ {
+ formatstring(msg, "%s %s %s", colorname(ci), val ? "claimed" : "relinquished", name);
+ if(isdedicatedserver()) logoutf("privilege: %s (cn %d) %s %s", ci->name, ci->clientnum, val ? "claimed" : "relinquished", name);
+ }
packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE);
putint(p, N_SERVMSG);
sendstring(msg, p);
@@ -1525,9 +1525,17 @@ namespace server
else formatstring(kicker, "%s as '\fs\f5%s\fr'", colorname(ci), authname);
}
else copystring(kicker, colorname(ci));
- if(reason && reason[0]) sendservmsgf("%s kicked %s because: %s", kicker, colorname(vinfo), reason);
- else sendservmsgf("%s kicked %s", kicker, colorname(vinfo));
+ if(reason && reason[0])
+ {
+ sendservmsgf("%s kicked %s because: %s", kicker, colorname(vinfo), reason);
+ logoutf("%s (cn %d) kicked %s (cn %d) because: %s", kicker, ci->clientnum, colorname(vinfo), victim, reason);
+ }
+ else
+ {
+ sendservmsgf("%s kicked %s", kicker, colorname(vinfo));
+ logoutf("%s (cn %d) kicked %s (cn %d)", kicker, ci->clientnum, colorname(vinfo), victim);
+ }
uint ip = getclientip(victim);
addban(ip, 4*60*60000);
kickclients(ip, ci, priv);
}
@@ -2089,6 +2101,8 @@
}
if(smode) smode->setup();
+
+ if(isdedicatedserver()) logoutf("started %s on %s", modename(mode, "unknown mode"), smapname);
}
void rotatemap(bool next)
@@ -2942,6 +2956,7 @@
sendwelcome(ci);
if(restorescore(ci)) sendresume(ci);
sendinitclient(ci);
+ if(isdedicatedserver()) logoutf("join: %s (cn %d)", ci->name, ci->clientnum);
aiman::addclient(ci);
@@ -3279,7 +3294,7 @@
getstring(text, p);
filtertext(text, text, true, true);
QUEUE_STR(text);
- if(isdedicatedserver() && cq) logoutf("%s: %s", colorname(cq), text);
+ if(isdedicatedserver() && cq) logoutf("%s (cn %d): %s", colorname(cq), cq->clientnum, text);
break;
}
@@ -3294,7 +3309,7 @@
if(t==cq || t->state.state==CS_SPECTATOR || t->state.aitype != AI_NONE || strcmp(cq->team, t->team)) continue;
sendf(t->clientnum, 1, "riis", N_SAYTEAM, cq->clientnum, text);
}
- if(isdedicatedserver() && cq) logoutf("%s <%s>: %s", colorname(cq), ci->state.state==CS_SPECTATOR ? "spec" : cq->team, text);
+ if(isdedicatedserver() && cq) logoutf("%s (cn %d) <%s>: %s", colorname(cq), cq->clientnum, ci->state.state==CS_SPECTATOR ? "spec" : cq->team, text);
break;
}
Index: src/shared/iengine.h
===================================================================
--- src/shared/iengine.h (revision 6502)
+++ src/shared/iengine.h (working copy)
@@ -6,6 +6,7 @@
extern int totalmillis; // total elapsed time
extern uint totalsecs;
extern int gamespeed, paused;
+extern time_t walltime; // wall time at engine startup (add totalmillis/1000 for current wall time)
enum
{