cleanup killmessages

* remove server-side custom killmessages (log files need to be uniform)
* clean up client-side custom killmessages
This commit is contained in:
ac-stef
2017-05-22 20:19:15 +02:00
parent 271d5b3929
commit 2bc8936680
9 changed files with 29 additions and 124 deletions
+17 -9
View File
@@ -814,26 +814,34 @@ VARP(hitsound, 0, 0, 2);
void setkillmessage(const char *gun, bool gib, const char *message)
{
int guni = getlistindex(gun, gunnames, true, -1);
if(guni < 0)
if(!valid_weapon(guni))
{
conoutf("invalid gun specified");
}
else
{
if(!message || !*message)
{
result(killmessage(guni, gib));
}
else
{
copystring(killmessages[gib ? 1 : 0][guni], message, sizeof(killmessages[gib ? 1 : 0][guni]));
}
defformatstring(aname)("%smessage_%s", gib ? "gib" : "frag", gunnames[guni]);
if(*message) alias(aname, message);
const char *res = getalias(aname);
result(res ? res : "");
}
}
COMMANDF(fragmessage, "ss", (const char *gun, const char *message) { setkillmessage(gun, false, message); });
COMMANDF(gibmessage, "ss", (const char *gun, const char *message) { setkillmessage(gun, true, message); });
const char *killmessage(int gun, bool gib = false)
{
if(valid_weapon(gun))
{
extern const char *killmessages[2][NUMGUNS];
defformatstring(aname)("%smessage_%s", gib ? "gib" : "frag", gunnames[gun]);
const char *res = getalias(aname);
return res ? res : killmessages[gib ? 1 : 0][gun];
}
return "";
}
COMMANDF(burstshots, "si", (char *gun, int *shots)
{
int guni = getlistindex(gun, gunnames, true, -1);
+3 -3
View File
@@ -1531,9 +1531,9 @@ void writecfg()
f->printf("\n");
audiomgr.writesoundconfig(f);
f->printf("\n");
f->printf("// crosshairs and kill messages for each weapon\n\nlooplist [\n");
loopi(NUMGUNS) f->printf(" %-7s %-11s %-12s %s\n", gunnames[i], crosshairs[i] && crosshairs[i] != notexture ? behindpath(crosshairs[i]->name) : "\"\"", escapestring(killmessage(i, false)), escapestring(killmessage(i, true)));
f->printf("] [ w cc f g ] [ loadcrosshair $w $cc ; fragmessage $w $f ; gibmessage $w $g ]\n");
f->printf("// crosshairs for each weapon\n\nlooplist [\n");
loopi(NUMGUNS) f->printf(" %-7s %s\n", gunnames[i], crosshairs[i] && crosshairs[i] != notexture ? behindpath(crosshairs[i]->name) : "\"\"");
f->printf("] [ w cc ] [ loadcrosshair $w $cc ]\n");
f->printf("\n\n// client variables (unchanged default values %s)\n", omitunchangeddefaults ? "omitted" : "commented out");
vector<ident *> sids;
enumerate(*idents, ident, id,
-9
View File
@@ -647,12 +647,3 @@ public:
enum {MD_FRAGS = 0, MD_DEATHS, END_MDS};
struct medalsst {bool assigned; int cn; int item;};
#define MAXKILLMSGLEN 16
extern char killmessages[2][NUMGUNS][MAXKILLMSGLEN];
inline const char *killmessage(int gun, bool gib = false)
{
if(gun<0 || gun>=NUMGUNS) return "";
return killmessages[gib?1:0][gun];
}
+3 -4
View File
@@ -1109,7 +1109,7 @@ struct serverconfigfile
struct servercommandline
{
int uprate, serverport, syslogfacility, filethres, syslogthres, maxdemos, maxclients, kickthreshold, banthreshold, verbose, incoming_limit, afk_limit, ban_time, demotimelocal;
const char *ip, *master, *logident, *serverpassword, *adminpasswd, *demopath, *maprot, *pwdfile, *blfile, *nbfile, *infopath, *motdpath, *forbidden, *killmessages, *demofilenameformat, *demotimestampformat;
const char *ip, *master, *logident, *serverpassword, *adminpasswd, *demopath, *maprot, *pwdfile, *blfile, *nbfile, *infopath, *motdpath, *forbidden, *demofilenameformat, *demotimestampformat;
bool logtimestamp, demo_interm, loggamestatus;
string motd, servdesc_full, servdesc_pre, servdesc_suf, voteperm, mapperm;
int clfilenesting;
@@ -1119,7 +1119,7 @@ struct servercommandline
maxclients(DEFAULTCLIENTS), kickthreshold(-5), banthreshold(-6), verbose(0), incoming_limit(10), afk_limit(45000), ban_time(20*60*1000), demotimelocal(0),
ip(""), master(NULL), logident(""), serverpassword(""), adminpasswd(""), demopath(""),
maprot("config/maprot.cfg"), pwdfile("config/serverpwd.cfg"), blfile("config/serverblacklist.cfg"), nbfile("config/nicknameblacklist.cfg"),
infopath("config/serverinfo"), motdpath("config/motd"), forbidden("config/forbidden.cfg"), killmessages("config/serverkillmessages.cfg"),
infopath("config/serverinfo"), motdpath("config/motd"), forbidden("config/forbidden.cfg"),
logtimestamp(false), demo_interm(false), loggamestatus(true),
clfilenesting(0)
{
@@ -1136,7 +1136,7 @@ struct servercommandline
int ai = atoi(a);
// client: dtwhzbsave
switch(arg[1])
{ // todo: gjlqGHJQUYZ
{ // todo: gjlqEGHJQUYZ
case '-':
if(!strncmp(arg, "--demofilenameformat=", 21))
{
@@ -1212,7 +1212,6 @@ struct servercommandline
case 'X': pwdfile = a; break;
case 'B': blfile = a; break;
case 'K': nbfile = a; break;
case 'E': killmessages = a; break;
case 'I': infopath = a; break;
case 'o': filterrichtext(motd, a); break;
case 'O': motdpath = a; break;
+1 -4
View File
@@ -27,7 +27,6 @@ servernickblacklist nickblacklist;
serverforbiddenlist forbiddenlist;
serverpasswords passwords;
serverinfofile infofiles;
killmessagesfile killmsgs;
// server state
bool isdedicated = false;
@@ -1604,7 +1603,7 @@ void serverdamage(client *target, client *actor, int damage, int gun, bool gib,
target->position.setsize(0);
ts.state = CS_DEAD;
ts.lastdeath = gamemillis;
if(!suic) logline(ACLOG_INFO, "[%s] %s %s%s %s", actor->hostname, actor->name, killmessage(gun, gib), tk ? " their teammate" : "", target->name);
if(!suic) logline(ACLOG_INFO, "[%s] %s %s%s %s", actor->hostname, actor->name, valid_weapon(gun) ? killmessages[gib ? 1 : 0][gun] : "smurfed", tk ? " their teammate" : "", target->name);
if(m_flags && targethasflag >= 0)
{
if(m_ctf)
@@ -3815,7 +3814,6 @@ void rereadcfgs(void)
nickblacklist.read();
forbiddenlist.read();
passwords.read();
killmsgs.read();
}
void loggamestatus(const char *reason)
@@ -4339,7 +4337,6 @@ void initserver(bool dedicated, int argc, char **argv)
ipblacklist.init(scl.blfile);
nickblacklist.init(scl.nbfile);
forbiddenlist.init(scl.forbidden);
killmsgs.init(scl.killmessages);
infofiles.init(scl.infopath, scl.motdpath);
infofiles.getinfo("en"); // cache 'en' serverinfo
logline(ACLOG_VERBOSE, "holding up to %d recorded demos in memory", scl.maxdemos);
+5 -3
View File
@@ -544,9 +544,11 @@ const char *gunnames[NUMGUNS + 1];
const char *teamnames[] = {"CLA", "RVSF", "CLA-SPECT", "RVSF-SPECT", "SPECTATOR", "", "void"};
const char *teamnames_s[] = {"CLA", "RVSF", "CSPC", "RSPC", "SPEC", "", "void"};
// for both client and server
// default messages are hardcoded !
char killmessages[2][NUMGUNS][MAXKILLMSGLEN] = {{ "", "busted", "picked off", "peppered", "sprayed", "punctured", "shredded", "busted", "", "busted" }, { "slashed", "", "", "splattered", "", "headshot", "", "", "gibbed", "" }};
const char *killmessages[2][NUMGUNS] =
{
{ "", "busted", "picked off", "peppered", "sprayed", "punctured", "shredded", "busted", "", "busted" },
{ "slashed", "", "", "splattered", "", "headshot", "", "", "gibbed", "" }
};
#define C(x) (1<<(SC_##x))
soundcfgitem soundcfg[S_NULL] =
-73
View File
@@ -1424,76 +1424,3 @@ struct serverinfofile
}
};
struct killmessagesfile : serverconfigfile
{
void init(const char *name) { serverconfigfile::init(name); }
void read()
{
if(getfilesize(filename) == filelen) return;
if(!load()) return;
char *b, *l, *s, *p = buf;
const char *sep = " \"";
int line = 0;
logline(ACLOG_VERBOSE,"reading kill messages file '%s'", filename);
while(p < buf + filelen)
{
l = p; p += strlen(p) + 1;
l = strtok_r(l, sep, &b);
char *message;
if(l)
{
s = strtok_r(NULL, sep, &b);
bool fragmsg = !strcmp(l, "fragmessage");
bool gibmsg = !strcmp(l, "gibmessage");
if(s && (fragmsg || gibmsg))
{
int errors = 0;
int gun = atoi(s);
s += strlen(s) + 1;
while(s[0] == ' ') s++;
int hasquotes = strspn(s, "\"");
s += hasquotes;
message = s;
const char *seps = "\" \n", *end = NULL;
char cursep;
while( (cursep = *seps++) != '\0')
{
if(cursep == '"' && !hasquotes) continue;
end = strchr(message, cursep);
if(end) break;
}
if(end) message[end-message] = '\0';
if(gun < 0 || gun >= NUMGUNS)
{
logline(ACLOG_INFO, " error in line %d, invalid gun : %d", line, gun);
errors++;
}
if(strlen(message)>MAXKILLMSGLEN)
{
logline(ACLOG_INFO, " error in line %d, too long message : string length is %d, max. allowed is %d", line, int(strlen(message)), MAXKILLMSGLEN);
errors++;
}
if(!errors)
{
if(fragmsg)
{
copystring(killmessages[0][gun], message, MAXKILLMSGLEN);
logline(ACLOG_VERBOSE, " added msg '%s' for frags with weapon %d ", message, gun);
}
else
{
copystring(killmessages[1][gun], message, MAXKILLMSGLEN);
logline(ACLOG_VERBOSE, " added msg '%s' for gibs with weapon %d ", message, gun);
}
}
s = NULL;
line++;
}
}
}
}
};