From 2fffcb6f1a1b4dc6eb256183cd8c3f95fd82c163 Mon Sep 17 00:00:00 2001 From: Lucas GAUTHERON Date: Sat, 21 May 2011 08:21:48 +0000 Subject: [PATCH] killmessage simplification. git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6453 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 3 +-- source/src/entity.h | 6 ++---- source/src/server.cpp | 6 +++--- source/src/server.h | 5 ++--- source/src/serverfiles.h | 10 ++++++---- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index b07c5b9b..855b287c 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -777,8 +777,7 @@ void setkillmessage(int gun, bool gib, const char *message) return; } - if(gib) copystring(gibmessages[gun], message, sizeof(gibmessages[gun])); - else copystring(fragmessages[gun], message, sizeof(fragmessages[gun])); + copystring(killmessages[gib?1:0][gun], message, sizeof(killmessages[gib?1:0][gun])); } void fragmessage(const char *gun, const char *message) diff --git a/source/src/entity.h b/source/src/entity.h index be409a43..5b800408 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -615,12 +615,10 @@ enum {MD_FRAGS = 0, MD_DEATHS, END_MDS}; struct medalsst {bool assigned; int cn; int item;}; #define MAXKILLMSGLEN 16 -extern char fragmessages[NUMGUNS][MAXKILLMSGLEN]; -extern char gibmessages[NUMGUNS][MAXKILLMSGLEN]; +extern char killmessages[2][NUMGUNS][MAXKILLMSGLEN]; inline const char *killmessage(int gun, bool gib = false) { if(gun<0 || gun>=NUMGUNS) return ""; - if(gib) return gibmessages[gun]; - else return fragmessages[gun]; + return killmessages[gib?1:0][gun]; } diff --git a/source/src/server.cpp b/source/src/server.cpp index 98b7ad8d..b32c730c 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -19,7 +19,7 @@ servernickblacklist nickblacklist; serverforbiddenlist forbiddenlist; serverpasswords passwords; serverinfofile infofiles; -killmessagesfile killmessages; +killmessagesfile killmsgs; // server state bool isdedicated = false; @@ -3582,7 +3582,7 @@ void rereadcfgs(void) nickblacklist.read(); forbiddenlist.read(); passwords.read(); - killmessages.read(); + killmsgs.read(); } void loggamestatus(const char *reason) @@ -4100,7 +4100,7 @@ void initserver(bool dedicated, int argc, char **argv) ipblacklist.init(scl.blfile); nickblacklist.init(scl.nbfile); forbiddenlist.init(scl.forbidden); - killmessages.init(scl.killmessages); + 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 c216cdba..f9e27e62 100644 --- a/source/src/server.h +++ b/source/src/server.h @@ -496,6 +496,5 @@ const char *teamnames[TEAM_NUM+1] = {"CLA", "RVSF", "CLA-SPECT", "RVSF-SPECT", " const char *teamnames_s[TEAM_NUM+1] = {"CLA", "RVSF", "CSPC", "RSPC", "SPEC", "void"}; // for both client and server -// default messages are hardcoded ! (in case there's a problem with cfgs) -char fragmessages[NUMGUNS][MAXKILLMSGLEN] = { "", "busted", "picked off", "peppered", "sprayed", "punctured", "shredded", "busted", "", "busted" }; -char gibmessages[NUMGUNS][MAXKILLMSGLEN] = { "slashed", "", "", "splattered", "", "headshot", "", "", "gibbed", "" }; +// default messages are hardcoded ! +char killmessages[2][NUMGUNS][MAXKILLMSGLEN] = {{ "", "busted", "picked off", "peppered", "sprayed", "punctured", "shredded", "busted", "", "busted" }, { "slashed", "", "", "splattered", "", "headshot", "", "", "gibbed", "" }}; diff --git a/source/src/serverfiles.h b/source/src/serverfiles.h index f6b1edc7..f28be208 100644 --- a/source/src/serverfiles.h +++ b/source/src/serverfiles.h @@ -909,7 +909,9 @@ struct killmessagesfile : serverconfigfile if(l) { s = strtok(NULL, sep); - if(s && (!strcmp(l, "fragmessage") || !strcmp(l, "gibmessage"))) + bool fragmsg = !strcmp(l, "fragmessage"); + bool gibmsg = !strcmp(l, "gibmessage"); + if(s && (fragmsg || gibmsg)) { int errors = 0; int gun = atoi(s); @@ -950,14 +952,14 @@ struct killmessagesfile : serverconfigfile } if(!errors) { - if(!strcmp(l, "fragmessage")) + if(fragmsg) { - formatstring(fragmessages[gun])("%s", message); + formatstring(killmessages[0][gun])("%s", message); logline(ACLOG_VERBOSE, " added msg '%s' for frags with weapon %i ", message, gun); } else { - formatstring(gibmessages[gun])("%s", message); + formatstring(killmessages[1][gun])("%s", message); logline(ACLOG_VERBOSE, " added msg '%s' for gibs with weapon %i ", message, gun); } }