From 2bc89366806d29df186ff0be9d47f249513fe176 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Mon, 22 May 2017 20:19:15 +0200 Subject: [PATCH] cleanup killmessages * remove server-side custom killmessages (log files need to be uniform) * clean up client-side custom killmessages --- config/servercmdline.txt | 1 - config/serverkillmessages.cfg | 18 --------- source/src/clientgame.cpp | 26 ++++++++----- source/src/command.cpp | 6 +-- source/src/entity.h | 9 ----- source/src/protos.h | 7 ++-- source/src/server.cpp | 5 +-- source/src/server.h | 8 ++-- source/src/serverfiles.h | 73 ----------------------------------- 9 files changed, 29 insertions(+), 124 deletions(-) delete mode 100644 config/serverkillmessages.cfg diff --git a/config/servercmdline.txt b/config/servercmdline.txt index de823fbe..436bb4a4 100644 --- a/config/servercmdline.txt +++ b/config/servercmdline.txt @@ -40,7 +40,6 @@ // -B // server IP blacklist file, default config/serverblacklist.cfg // -K // server nickname blacklist file, default config/nicknameblacklist.cfg // -g // server forbidden words file, default config/forbidden.cfg -// -E // server kill messages file, default config/serverkillmessages.cfg // -P // voting permission string (read docs/commandline.html) // k kick players // b ban players (and remove bans) diff --git a/config/serverkillmessages.cfg b/config/serverkillmessages.cfg deleted file mode 100644 index 44a428e1..00000000 --- a/config/serverkillmessages.cfg +++ /dev/null @@ -1,18 +0,0 @@ -// kill messages - -// set frag and kills messages that appear in server logs - -fragmessage 1 busted // pistol -fragmessage 2 "picked off" // carbine -fragmessage 3 peppered // shotgun -fragmessage 4 sprayed // smg -fragmessage 5 punctured // sniper -fragmessage 6 shredded // assault rifle -fragmessage 7 busted // cpistol -fragmessage 9 busted // akimbo - -gibmessage 0 slashed // knife -gibmessage 3 splattered // shotgun gib -gibmessage 5 headshot // sniper gib -gibmessage 8 gibbed // nade gib - diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 1da9651d..3b0ef41e 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -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); diff --git a/source/src/command.cpp b/source/src/command.cpp index f23e80a0..17597713 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -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 sids; enumerate(*idents, ident, id, diff --git a/source/src/entity.h b/source/src/entity.h index 19dce4d1..ce88fc2d 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -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]; -} - diff --git a/source/src/protos.h b/source/src/protos.h index 2155cf44..052dcfc5 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -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; diff --git a/source/src/server.cpp b/source/src/server.cpp index 9f1b56aa..7290f094 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -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); diff --git a/source/src/server.h b/source/src/server.h index da0fec4b..3ad4d368 100644 --- a/source/src/server.h +++ b/source/src/server.h @@ -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] = diff --git a/source/src/serverfiles.h b/source/src/serverfiles.h index 32f07e8e..aaebb0fb 100644 --- a/source/src/serverfiles.h +++ b/source/src/serverfiles.h @@ -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++; - } - } - } - } -};