From: TimePath Date: Thu, 3 Mar 2016 11:01:03 +0000 (+1100) Subject: Notifications: cleanup X-Git-Tag: xonotic-v0.8.2~1132^2~7 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=39d7296bebbb6ea486c5cdb59c7f60d11aedd1c3;p=xonotic%2Fxonotic-data.pk3dir.git Notifications: cleanup --- diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc index 6f246d905..2ce3cf582 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc @@ -530,7 +530,7 @@ void ons_ControlPoint_Icon_Damage(entity this, entity inflictor, entity attacker { sound(this, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM); pointparticles(EFFECT_ROCKET_EXPLODE, this.origin, '0 0 0', 1); - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(this.team, INFO_ONSLAUGHT_CPDESTROYED_), this.owner.message, attacker.netname); + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM(this.team, INFO_ONSLAUGHT_CPDESTROYED), this.owner.message, attacker.netname); PlayerScore_Add(attacker, SP_ONS_TAKES, 1); PlayerScore_Add(attacker, SP_SCORE, 10); @@ -665,7 +665,7 @@ void ons_ControlPoint_Icon_BuildThink() if(IS_PLAYER(self.owner.ons_toucher)) { Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ONSLAUGHT_CAPTURE, self.owner.ons_toucher.netname, self.owner.message); - Send_Notification(NOTIF_ALL_EXCEPT, self.owner.ons_toucher, MSG_CENTER, APP_TEAM_ENT_4(self.owner.ons_toucher, CENTER_ONS_CAPTURE_), self.owner.message); + Send_Notification(NOTIF_ALL_EXCEPT, self.owner.ons_toucher, MSG_CENTER, APP_TEAM_NUM(self.owner.ons_toucher.team, CENTER_ONS_CAPTURE), self.owner.message); Send_Notification(NOTIF_ONE, self.owner.ons_toucher, MSG_CENTER, CENTER_ONS_CAPTURE, self.owner.message); PlayerScore_Add(self.owner.ons_toucher, SP_ONS_CAPS, 1); PlayerTeamScore_AddScore(self.owner.ons_toucher, 10); @@ -992,10 +992,10 @@ void ons_GeneratorDamage(entity this, entity inflictor, entity attacker, float d else { if (attacker == this) - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(this.team, INFO_ONSLAUGHT_GENDESTROYED_OVERTIME_)); + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM(this.team, INFO_ONSLAUGHT_GENDESTROYED_OVERTIME)); else { - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(this.team, INFO_ONSLAUGHT_GENDESTROYED_)); + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM(this.team, INFO_ONSLAUGHT_GENDESTROYED)); PlayerScore_Add(attacker, SP_SCORE, 100); } this.iscaptured = false; @@ -1050,7 +1050,7 @@ void ons_GeneratorThink() soundto(MSG_ONE, it, CHAN_AUTO, SND(KH_ALARM), VOL_BASE, ATTEN_NONE); // FIXME: unique sound? } else - Send_Notification(NOTIF_ONE, it, MSG_CENTER, APP_TEAM_NUM_4(self.team, CENTER_ONS_NOTSHIELDED_)); + Send_Notification(NOTIF_ONE, it, MSG_CENTER, APP_TEAM_NUM(self.team, CENTER_ONS_NOTSHIELDED)); )); } } @@ -1254,8 +1254,8 @@ bool Onslaught_CheckWinner() if(winner_team > 0) { - Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM_4(winner_team, CENTER_ROUND_TEAM_WIN_)); - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(winner_team, INFO_ROUND_TEAM_WIN_)); + Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN)); + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN)); TeamScore_AddToTeam(winner_team, ST_ONS_CAPS, +1); } else if(winner_team == -1) diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index 96edb6cf8..acde91a89 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -2,13 +2,13 @@ #include "../client/announcer.qh" #elif defined(MENUQC) #elif defined(SVQC) - #include "constants.qh" - #include "teams.qh" - #include "../server/autocvars.qh" - #include "../server/constants.qh" - #include "../server/defs.qh" - #include "notifications.qh" - #include + #include "constants.qh" + #include "teams.qh" + #include "../server/autocvars.qh" + #include "../server/constants.qh" + #include "../server/defs.qh" + #include "notifications.qh" + #include #endif // ================================================ @@ -16,135 +16,76 @@ // Last updated: August, 2013 // ================================================ -string Get_Notif_TypeName(int net_type) -{ - switch(net_type) - { - case MSG_ANNCE: return "MSG_ANNCE"; - case MSG_INFO: return "MSG_INFO"; - case MSG_CENTER: return "MSG_CENTER"; - case MSG_CENTER_CPID: return "MSG_CENTER_CPID"; - case MSG_MULTI: return "MSG_MULTI"; - case MSG_CHOICE: return "MSG_CHOICE"; - } - backtrace(sprintf("Get_Notif_TypeName(%d): Improper net type!\n", net_type)); - return ""; -} - -entity Get_Notif_Ent(int net_type, int net_name) -{ - switch(net_type) - { - case MSG_ANNCE: return msg_annce_notifs[net_name - 1]; - case MSG_INFO: return msg_info_notifs[net_name - 1]; - case MSG_CENTER: return msg_center_notifs[net_name - 1]; - case MSG_MULTI: return msg_multi_notifs[net_name - 1]; - case MSG_CHOICE: return msg_choice_notifs[net_name - 1]; - } - backtrace(sprintf("Get_Notif_Ent(%d, %d): Improper net type!\n", net_type, net_name)); - return world; -} - -#ifdef SVQC -#ifdef NOTIFICATIONS_DEBUG -string Get_Notif_BroadcastName(float broadcast) -{ - switch(broadcast) - { - case NOTIF_ONE: return "NOTIF_ONE"; - case NOTIF_ONE_ONLY: return "NOTIF_ONE_ONLY"; - case NOTIF_ALL_EXCEPT: return "NOTIF_ALL_EXCEPT"; - case NOTIF_ALL: return "NOTIF_ALL"; - case NOTIF_TEAM: return "NOTIF_TEAM"; - case NOTIF_TEAM_EXCEPT: return "NOTIF_TEAM_EXCEPT"; - } - backtrace(sprintf("Get_Notif_BroadcastName(%d): Improper broadcast!\n", broadcast)); - return ""; -} -#endif -#endif - -string Notification_CheckArgs_TypeName(float net_type, float net_name) -{ - // check supplied type and name for errors - string checkargs = ""; - #define CHECKARG_TYPENAME(type) case MSG_##type: \ - { if(!net_name || (net_name > NOTIF_##type##_COUNT)) \ - { checkargs = sprintf("Improper name: %d!", net_name); } break; } - switch(net_type) - { - CHECKARG_TYPENAME(ANNCE) - CHECKARG_TYPENAME(INFO) - CHECKARG_TYPENAME(CENTER) - CHECKARG_TYPENAME(MULTI) - CHECKARG_TYPENAME(CHOICE) - default: { checkargs = sprintf("Improper type: %d!", checkargs, net_type); break; } - } - #undef CHECKARG_TYPENAME - return checkargs; -} - #ifdef SVQC string Notification_CheckArgs( NOTIF broadcast, entity client, - float net_type, float net_name) + Notification net_name) { // check supplied broadcast, target, type, and name for errors - string checkargs = Notification_CheckArgs_TypeName(net_type, net_name); - if(checkargs != "") { checkargs = strcat(checkargs, " "); } - switch(broadcast) + string checkargs = ""; + if (!net_name) { checkargs = "No notification provided! "; } + switch (broadcast) { case NOTIF_ONE: case NOTIF_ONE_ONLY: { - if(IS_NOT_A_CLIENT(client)) - { checkargs = sprintf("%sNo client provided!", checkargs); } + if (IS_NOT_A_CLIENT(client)) { + checkargs = sprintf("%sNo client provided!", checkargs); + } break; } case NOTIF_ALL_EXCEPT: { - if(IS_NOT_A_CLIENT(client)) - { checkargs = sprintf("%sException can't be a non-client!", checkargs); } + if (IS_NOT_A_CLIENT(client)) { + checkargs = sprintf("%sException can't be a non-client!", checkargs); + } break; } case NOTIF_ALL: { - if(client) - { checkargs = sprintf("%sEntity provided when world was required!", checkargs); } + if (client) { + checkargs = sprintf("%sEntity provided when world was required!", checkargs); + } break; } case NOTIF_TEAM: { - if (!teamplay) - { checkargs = sprintf("%sTeamplay not active!", checkargs); } - //else if (!client.team) { checkargs = sprintf("%sNo team provided!", checkargs); } + if (!teamplay) { + checkargs = sprintf("%sTeamplay not active!", checkargs); + } else if (!client.team) { + // checkargs = sprintf("%sNo team provided!", checkargs); + } break; } case NOTIF_TEAM_EXCEPT: { - if (!teamplay) - { checkargs = sprintf("%sTeamplay not active!", checkargs); } - else if(IS_NOT_A_CLIENT(client)) - { checkargs = sprintf("%sException can't be a non-client!", checkargs); } + if (!teamplay) { + checkargs = sprintf("%sTeamplay not active!", checkargs); + } else if (IS_NOT_A_CLIENT(client)) { + checkargs = sprintf("%sException can't be a non-client!", checkargs); + } break; } - default: { checkargs = sprintf("%sImproper broadcast: %d!", checkargs, broadcast); break; } + default: + { + checkargs = sprintf("%sImproper broadcast: %d!", checkargs, broadcast); + break; + } } return checkargs; } -float Notification_ShouldSend(NOTIF broadcast, entity to_client, entity other_client) +bool Notification_ShouldSend(NOTIF broadcast, entity to_client, entity other_client) { - switch(broadcast) + switch (broadcast) { - case NOTIF_ONE: // send to one client and their spectator - { - if( + case NOTIF_ONE: + return ( (to_client == other_client) || ( @@ -152,17 +93,11 @@ float Notification_ShouldSend(NOTIF broadcast, entity to_client, entity other_cl && (to_client.enemy == other_client) ) - ) { return true; } - break; - } - case NOTIF_ONE_ONLY: // send ONLY to one client - { - if(to_client == other_client) { return true; } - break; - } - case NOTIF_TEAM: // send only to X team and their spectators - { - if( + ); + case NOTIF_ONE_ONLY: + return (to_client == other_client); + case NOTIF_TEAM: + return ( (to_client.team == other_client.team) || ( @@ -170,12 +105,9 @@ float Notification_ShouldSend(NOTIF broadcast, entity to_client, entity other_cl && (to_client.enemy.team == other_client.team) ) - ) { return true; } - break; - } - case NOTIF_TEAM_EXCEPT: // send only to X team and their spectators, except for Y person and their spectators - { - if( + ); + case NOTIF_TEAM_EXCEPT: + return ( (to_client != other_client) && ( @@ -191,16 +123,11 @@ float Notification_ShouldSend(NOTIF broadcast, entity to_client, entity other_cl ) ) ) - ) { return true; } - break; - } - case NOTIF_ALL: // send to everyone - { + ); + case NOTIF_ALL: return true; - } - case NOTIF_ALL_EXCEPT: // send to everyone except X person and their spectators - { - if( + case NOTIF_ALL_EXCEPT: + return ( (to_client != other_client) && !( @@ -208,11 +135,10 @@ float Notification_ShouldSend(NOTIF broadcast, entity to_client, entity other_cl && (to_client.enemy == other_client) ) - ) { return true; } - break; - } + ); + default: + return false; } - return false; } #endif @@ -224,25 +150,21 @@ float Notification_ShouldSend(NOTIF broadcast, entity to_client, entity other_cl // used by restartnotifs command to initialize notifications void Destroy_Notification_Entity(entity notif) { - if(notif.nent_name != "") { strunzone(notif.nent_name); } - if(notif.nent_snd != "") { strunzone(notif.nent_snd); } - if(notif.nent_args != "") { strunzone(notif.nent_args); } - if(notif.nent_hudargs != "") { strunzone(notif.nent_hudargs); } - if(notif.nent_icon != "") { strunzone(notif.nent_icon); } - if(notif.nent_durcnt != "") { strunzone(notif.nent_durcnt); } - if(notif.nent_string != "") { strunzone(notif.nent_string); } + if (notif.nent_name != "") strunzone(notif.nent_name); + if (notif.nent_snd != "") strunzone(notif.nent_snd); + if (notif.nent_args != "") strunzone(notif.nent_args); + if (notif.nent_hudargs != "") strunzone(notif.nent_hudargs); + if (notif.nent_icon != "") strunzone(notif.nent_icon); + if (notif.nent_durcnt != "") strunzone(notif.nent_durcnt); + if (notif.nent_string != "") strunzone(notif.nent_string); remove(notif); } void Destroy_All_Notifications() { - entity notif; - int i; - #define DESTROY_LOOP(type,count) MACRO_BEGIN { \ - for(i = 1; i <= count; ++i) \ - { \ - notif = Get_Notif_Ent(type, i); \ + for (int i = 1; i <= count; ++i) { \ + Notification notif = Get_Notif_Ent(type, i); \ if (!notif) { backtrace("Destroy_All_Notifications(): Missing notification entity!\n"); return; } \ Destroy_Notification_Entity(notif); \ } \ @@ -250,7 +172,7 @@ void Destroy_All_Notifications() // kill all networked notifications and centerprints #ifdef SVQC - Kill_Notification(NOTIF_ALL, world, 0, 0); + Kill_Notification(NOTIF_ALL, NULL, 0, 0); #else reset_centerprint_messages(); #endif @@ -507,47 +429,47 @@ void Create_Notification_Entity(entity notif, // Other pre-notif-setup requisites notif_error = false; - switch(typeId) + switch (typeId) { - case MSG_ANNCE: - case MSG_INFO: - case MSG_CENTER: - case MSG_MULTI: - case MSG_CHOICE: - break; - default: - LOG_INFOF( - strcat( - "^1NOTIFICATION WITH IMPROPER TYPE: ", - "^7net_type = %d, net_name = %s.\n" - ), - typeId, - namestring - ); - notif_error = true; - break; + case MSG_ANNCE: + case MSG_INFO: + case MSG_CENTER: + case MSG_MULTI: + case MSG_CHOICE: + break; + default: + LOG_INFOF( + strcat( + "^1NOTIFICATION WITH IMPROPER TYPE: ", + "^7net_type = %d, net_name = %s.\n" + ), + typeId, + namestring + ); + notif_error = true; + break; } // now check to see if any errors happened - if(notif_error) - { - notif.nent_enabled = false; // disable the notification so it can't cause trouble - notif_global_error = true; // throw the red flag that an error happened on init - } + if (notif_error) + { + notif.nent_enabled = false; // disable the notification so it can't cause trouble + notif_global_error = true; // throw the red flag that an error happened on init + } } void Create_Notification_Entity_Annce(entity notif, - float var_cvar, - string namestring, - /* MSG_ANNCE */ - float channel, - string snd, - float vol, - float position) + float var_cvar, + string namestring, + /* MSG_ANNCE */ + float channel, + string snd, + float vol, + float position) { // Set MSG_ANNCE information and handle precaching #ifdef CSQC - int typeId = MSG_ANNCE; + int typeId = MSG_ANNCE; if (!(GENTLE && (var_cvar == 1))) { if(snd != "") @@ -583,20 +505,20 @@ void Create_Notification_Entity_Annce(entity notif, } void Create_Notification_Entity_InfoCenter(entity notif, - float var_cvar, - string namestring, - int strnum, - int flnum, - /* MSG_INFO & MSG_CENTER */ - string args, - string hudargs, - string icon, - float cpid, - string durcnt, - string normal, - string gentle) + float var_cvar, + string namestring, + int strnum, + int flnum, + /* MSG_INFO & MSG_CENTER */ + string args, + string hudargs, + string icon, + float cpid, + string durcnt, + string normal, + string gentle) { - int typeId = notif.nent_type; + int typeId = notif.nent_type; // Set MSG_INFO and MSG_CENTER string/float counts notif.nent_stringcount = strnum; notif.nent_floatcount = flnum; @@ -607,7 +529,7 @@ void Create_Notification_Entity_InfoCenter(entity notif, #else float should_process_args = true; #endif - string typestring = Get_Notif_TypeName(typeId); + string typestring = Get_Notif_TypeName(typeId); if(should_process_args) { // ======================== @@ -744,18 +666,18 @@ void Create_Notification_Entity_InfoCenter(entity notif, } void Create_Notification_Entity_Multi(entity notif, - float var_cvar, - string namestring, - /* MSG_MULTI */ - Notification anncename, - Notification infoname, - Notification centername) + float var_cvar, + string namestring, + /* MSG_MULTI */ + Notification anncename, + Notification infoname, + Notification centername) { - int typeId = MSG_MULTI; + int typeId = MSG_MULTI; // Set MSG_MULTI string/float counts if((anncename == NO_MSG) && (infoname == NO_MSG) && (centername == NO_MSG)) { - string typestring = Get_Notif_TypeName(typeId); + string typestring = Get_Notif_TypeName(typeId); LOG_INFOF( strcat( "^1NOTIFICATION WITH NO SUBCALLS: ", @@ -795,19 +717,19 @@ void Create_Notification_Entity_Multi(entity notif, } void Create_Notification_Entity_Choice(entity notif, - float var_cvar, - string namestring, - /* MSG_CHOICE */ - float challow_def, - float challow_var, - int chtype, - Notification optiona, - Notification optionb) + float var_cvar, + string namestring, + /* MSG_CHOICE */ + float challow_def, + float challow_var, + int chtype, + Notification optiona, + Notification optionb) { - int typeId = MSG_CHOICE; + int typeId = MSG_CHOICE; if((chtype == NO_MSG_) || (optiona == NO_MSG) || (optionb == NO_MSG)) { - string typestring = Get_Notif_TypeName(typeId); + string typestring = Get_Notif_TypeName(typeId); LOG_INFOF( strcat( "^1NOTIFICATION IS MISSING CHOICE PARAMS: ", @@ -820,8 +742,8 @@ void Create_Notification_Entity_Choice(entity notif, } else { - notif.nent_optiona = optiona; - notif.nent_optionb = optionb; + notif.nent_optiona = optiona; + notif.nent_optionb = optionb; notif.nent_challow_def = challow_def; // 0: never allowed, 1: allowed in warmup, 2: always allowed notif.nent_challow_var = challow_var; // 0: never allowed, 1: allowed in warmup, 2: always allowed notif.nent_stringcount = max(notif.nent_optiona.nent_stringcount, notif.nent_optionb.nent_stringcount); @@ -859,7 +781,7 @@ void Create_Notification_Entity_Choice(entity notif, #ifdef SVQC void Notification_GetCvars() { - for(int i = 0; i <= NOTIF_CHOICE_COUNT; ++i) + for (int i = 0; i <= NOTIF_CHOICE_COUNT; ++i) { GetCvars_handleFloat( get_cvars_s, @@ -871,42 +793,41 @@ void Notification_GetCvars() } #endif -// used to output notifications.cfg file -void Dump_Notifications(float fh, float alsoprint) +/** used to output notifications.cfg file */ +void Dump_Notifications(int fh, bool alsoprint) { - #define NOTIF_WRITE(a) { \ + #define NOTIF_WRITE(a) MACRO_BEGIN { \ fputs(fh, a); \ - if(alsoprint) { LOG_INFO(a); } } - #define NOTIF_WRITE_ENTITY(description) { \ - notif_msg = \ - sprintf( \ - "seta notification_%s \"%d\" \"%s\"\n", \ - e.nent_name, e.nent_default, description \ - ); \ - NOTIF_WRITE(notif_msg) } - #define NOTIF_WRITE_ENTITY_CHOICE(descriptiona,descriptionb) { \ - notif_msg = \ - sprintf( \ - "seta notification_%s \"%d\" \"%s\"\n" \ - "seta notification_%s_ALLOWED \"%d\" \"%s\"\n", \ - e.nent_name, e.nent_default, descriptiona, \ - e.nent_name, e.nent_challow_def, descriptionb \ - ); \ - NOTIF_WRITE(notif_msg) } - #define NOTIF_WRITE_HARDCODED(cvar,default,description) { \ - notif_msg = \ - sprintf( \ - "seta notification_%s \"%s\" \"%s\"\n", \ - cvar, default, description \ - ); \ - NOTIF_WRITE(notif_msg) } - - string notif_msg; - int i; - entity e; + if (alsoprint) LOG_INFO(a); \ + } MACRO_END - // Note: This warning only applies to the notifications.cfg file that is output... + #define NOTIF_WRITE_ENTITY(e, description) MACRO_BEGIN { \ + string notif_msg = sprintf( \ + "seta notification_%s \"%d\" \"%s\"\n", \ + e.nent_name, e.nent_default, description \ + ); \ + NOTIF_WRITE(notif_msg); \ + } MACRO_END + + #define NOTIF_WRITE_ENTITY_CHOICE(e, descriptiona, descriptionb) MACRO_BEGIN { \ + string notif_msg = sprintf( \ + "seta notification_%s \"%d\" \"%s\"\n" \ + "seta notification_%s_ALLOWED \"%d\" \"%s\"\n", \ + e.nent_name, e.nent_default, descriptiona, \ + e.nent_name, e.nent_challow_def, descriptionb \ + ); \ + NOTIF_WRITE(notif_msg); \ + } MACRO_END + #define NOTIF_WRITE_HARDCODED(cvar, default, description) MACRO_BEGIN { \ + string notif_msg = sprintf( \ + "seta notification_%s \"%s\" \"%s\"\n", \ + cvar, default, description \ + ); \ + NOTIF_WRITE(notif_msg); \ + } MACRO_END + + // Note: This warning only applies to the notifications.cfg file that is output... // You ARE supposed to manually edit this function to add i.e. hard coded // notification variables for mutators or game modes or such and then // regenerate the notifications.cfg file from the new code. @@ -929,57 +850,57 @@ void Dump_Notifications(float fh, float alsoprint) // it is just a semi-helpful tool for those who want to manually change their user settings. NOTIF_WRITE(sprintf("\n// MSG_ANNCE notifications (count = %d):\n", NOTIF_ANNCE_COUNT)); - for(i = 1; i <= NOTIF_ANNCE_COUNT; ++i) + for (int i = 1; i <= NOTIF_ANNCE_COUNT; ++i) { - e = Get_Notif_Ent(MSG_ANNCE, i); + Notification e = Get_Notif_Ent(MSG_ANNCE, i); if (!e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; } - NOTIF_WRITE_ENTITY( + NOTIF_WRITE_ENTITY(e, "0 = disabled, 1 = enabled if gentle mode is off, 2 = always enabled" ); } NOTIF_WRITE(sprintf("\n// MSG_INFO notifications (count = %d):\n", NOTIF_INFO_COUNT)); - for(i = 1; i <= NOTIF_INFO_COUNT; ++i) + for (int i = 1; i <= NOTIF_INFO_COUNT; ++i) { - e = Get_Notif_Ent(MSG_INFO, i); + Notification e = Get_Notif_Ent(MSG_INFO, i); if (!e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; } - NOTIF_WRITE_ENTITY( + NOTIF_WRITE_ENTITY(e, "0 = off, 1 = print to console, " "2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)" ); } NOTIF_WRITE(sprintf("\n// MSG_CENTER notifications (count = %d):\n", NOTIF_CENTER_COUNT)); - for(i = 1; i <= NOTIF_CENTER_COUNT; ++i) + for (int i = 1; i <= NOTIF_CENTER_COUNT; ++i) { - e = Get_Notif_Ent(MSG_CENTER, i); + Notification e = Get_Notif_Ent(MSG_CENTER, i); if (!e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; } - NOTIF_WRITE_ENTITY( + NOTIF_WRITE_ENTITY(e, "0 = off, 1 = centerprint" ); } NOTIF_WRITE(sprintf("\n// MSG_MULTI notifications (count = %d):\n", NOTIF_MULTI_COUNT)); - for(i = 1; i <= NOTIF_MULTI_COUNT; ++i) + for (int i = 1; i <= NOTIF_MULTI_COUNT; ++i) { - e = Get_Notif_Ent(MSG_MULTI, i); + Notification e = Get_Notif_Ent(MSG_MULTI, i); if (!e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; } - NOTIF_WRITE_ENTITY( + NOTIF_WRITE_ENTITY(e, "Enable this multiple notification" ); } NOTIF_WRITE(sprintf("\n// MSG_CHOICE notifications (count = %d):\n", NOTIF_CHOICE_COUNT)); - for(i = 1; i <= NOTIF_CHOICE_COUNT; ++i) + for (int i = 1; i <= NOTIF_CHOICE_COUNT; ++i) { - e = Get_Notif_Ent(MSG_CHOICE, i); + Notification e = Get_Notif_Ent(MSG_CHOICE, i); if (!e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; } - NOTIF_WRITE_ENTITY_CHOICE( + NOTIF_WRITE_ENTITY_CHOICE(e, "Choice for this notification 0 = off, 1 = default message, 2 = verbose message", "Allow choice for this notification 0 = off, 1 = only in warmup mode, 2 = always" ); @@ -1090,8 +1011,6 @@ void Dump_Notifications(float fh, float alsoprint) NOTIF_MULTI_COUNT, NOTIF_CHOICE_COUNT )); - - return; #undef NOTIF_WRITE_HARDCODED #undef NOTIF_WRITE_ENTITY #undef NOTIF_WRITE @@ -1102,17 +1021,6 @@ void Dump_Notifications(float fh, float alsoprint) // Frontend Notification Pushing // =============================== -#ifdef NOTIFICATIONS_DEBUG -void Debug_Notification(string input) -{ - switch(autocvar_notification_debug) - { - case 1: { LOG_TRACE(input); break; } - case 2: { LOG_INFO(input); break; } - } -} -#endif - string Local_Notification_sprintf( string input, string args, string s1, string s2, string s3, string s4, @@ -1128,34 +1036,27 @@ string Local_Notification_sprintf( )); #endif - string selected; - int sel_num; - for(sel_num = 0; sel_num < NOTIF_MAX_ARGS; ++sel_num) { arg_slot[sel_num] = ""; } + for (int sel_num = 0; sel_num < NOTIF_MAX_ARGS; ++sel_num) { arg_slot[sel_num] = ""; } - string tmp_s; - - for(sel_num = 0;(args != "");) + for (int sel_num = 0; (args != ""); ) { - selected = car(args); args = cdr(args); + string selected = car(args); args = cdr(args); NOTIF_HIT_MAX(NOTIF_MAX_ARGS, "Local_Notification_sprintf"); - switch(strtolower(selected)) + string tmp_s; // used by NOTIF_ARGUMENT_LIST + switch (strtolower(selected)) { - #ifdef CSQC - #define ARG_CASE_ARG_CS_SV_HA(selected,result) case selected: { arg_slot[sel_num] = result; ++sel_num; break; } - #define ARG_CASE_ARG_CS_SV_DC(selected,result) case selected: { arg_slot[sel_num] = result; ++sel_num; break; } - #define ARG_CASE_ARG_CS_SV(selected,result) case selected: { arg_slot[sel_num] = result; ++sel_num; break; } - #define ARG_CASE_ARG_CS(selected,result) case selected: { arg_slot[sel_num] = result; ++sel_num; break; } - #define ARG_CASE_ARG_SV(selected,result) - #define ARG_CASE_ARG_DC(selected,result) - #else - #define ARG_CASE_ARG_CS_SV_HA(selected,result) case selected: { arg_slot[sel_num] = result; ++sel_num; break; } - #define ARG_CASE_ARG_CS_SV_DC(selected,result) case selected: { arg_slot[sel_num] = result; ++sel_num; break; } - #define ARG_CASE_ARG_CS_SV(selected,result) case selected: { arg_slot[sel_num] = result; ++sel_num; break; } - #define ARG_CASE_ARG_CS(selected,result) - #define ARG_CASE_ARG_SV(selected,result) case selected: { arg_slot[sel_num] = result; ++sel_num; break; } - #define ARG_CASE_ARG_DC(selected,result) - #endif - #define ARG_CASE(prog,selected,result) ARG_CASE_##prog(selected,result) + #define ARG_CASE_ARG_CS_SV_HA(selected, result) case selected: { arg_slot[sel_num++] = result; break; } + #define ARG_CASE_ARG_CS_SV_DC(selected, result) case selected: { arg_slot[sel_num++] = result; break; } + #define ARG_CASE_ARG_CS_SV(selected, result) case selected: { arg_slot[sel_num++] = result; break; } +#ifdef CSQC + #define ARG_CASE_ARG_CS(selected, result) case selected: { arg_slot[sel_num++] = result; break; } + #define ARG_CASE_ARG_SV(selected, result) +#else + #define ARG_CASE_ARG_CS(selected, result) + #define ARG_CASE_ARG_SV(selected, result) case selected: { arg_slot[sel_num++] = result; break; } +#endif + #define ARG_CASE_ARG_DC(selected, result) + #define ARG_CASE(prog, selected, result) ARG_CASE_##prog(selected, result) NOTIF_ARGUMENT_LIST #undef ARG_CASE #undef ARG_CASE_ARG_DC @@ -1181,14 +1082,14 @@ string Local_Notification_sprintf( #ifdef CSQC void Local_Notification_sound( - float soundchannel, string soundfile, + int soundchannel, string soundfile, float soundvolume, float soundposition) { - if((soundfile != prev_soundfile) || (time >= (prev_soundtime + autocvar_cl_announcer_antispam))) + if ((soundfile != prev_soundfile) || (time >= (prev_soundtime + autocvar_cl_announcer_antispam))) { #ifdef NOTIFICATIONS_DEBUG Debug_Notification(sprintf( - "Local_Notification_sound(world, %f, '%s', %f, %f);\n", + "Local_Notification_sound(%f, '%s', %f, %f);\n", soundchannel, sprintf( "announcer/%s/%s.wav", @@ -1201,7 +1102,7 @@ void Local_Notification_sound( #endif _sound( - world, + NULL, soundchannel, sprintf( "announcer/%s/%s.wav", @@ -1212,7 +1113,7 @@ void Local_Notification_sound( soundposition ); - if(prev_soundfile) { strunzone(prev_soundfile); } + if (prev_soundfile) strunzone(prev_soundfile); prev_soundfile = strzone(soundfile); prev_soundtime = time; } @@ -1245,23 +1146,21 @@ void Local_Notification_HUD_Notify_Push( string s1, string s2, string s3, string s4, float f1, float f2, float f3, float f4) { - string selected; arg_slot[0] = ""; arg_slot[1] = ""; - int sel_num; - for(sel_num = 0;(hudargs != "");) + for (int sel_num = 0; (hudargs != ""); ) { - selected = car(hudargs); hudargs = cdr(hudargs); + string selected = car(hudargs); hudargs = cdr(hudargs); NOTIF_HIT_MAX(NOTIF_MAX_HUDARGS, "Local_Notification_HUD_Notify_Push"); - switch(strtolower(selected)) + switch (strtolower(selected)) { - #define ARG_CASE_ARG_CS_SV_HA(selected,result) case selected: { arg_slot[sel_num] = result; ++sel_num; break; } - #define ARG_CASE_ARG_CS_SV_DC(selected,result) - #define ARG_CASE_ARG_CS_SV(selected,result) - #define ARG_CASE_ARG_CS(selected,result) - #define ARG_CASE_ARG_SV(selected,result) - #define ARG_CASE_ARG_DC(selected,result) - #define ARG_CASE(prog,selected,result) ARG_CASE_##prog(selected,result) + #define ARG_CASE_ARG_CS_SV_HA(selected, result) case selected: { arg_slot[sel_num++] = result; break; } + #define ARG_CASE_ARG_CS_SV_DC(selected, result) + #define ARG_CASE_ARG_CS_SV(selected, result) + #define ARG_CASE_ARG_CS(selected, result) + #define ARG_CASE_ARG_SV(selected, result) + #define ARG_CASE_ARG_DC(selected, result) + #define ARG_CASE(prog, selected, result) ARG_CASE_##prog(selected, result) NOTIF_ARGUMENT_LIST #undef ARG_CASE #undef ARG_CASE_ARG_DC @@ -1292,19 +1191,19 @@ void Local_Notification_centerprint_generic( { arg_slot[0] = ""; arg_slot[1] = ""; - for(int sel_num = 0;(durcnt != "");) + for (int sel_num = 0; (durcnt != ""); ) { string selected = car(durcnt); durcnt = cdr(durcnt); NOTIF_HIT_MAX(NOTIF_MAX_DURCNT, "Local_Notification_centerprint_generic"); - switch(strtolower(selected)) + switch (strtolower(selected)) { - #define ARG_CASE_ARG_CS_SV_HA(selected,result) - #define ARG_CASE_ARG_CS_SV_DC(selected,result) case selected: { arg_slot[sel_num] = result; ++sel_num; break; } - #define ARG_CASE_ARG_CS_SV(selected,result) - #define ARG_CASE_ARG_CS(selected,result) - #define ARG_CASE_ARG_SV(selected,result) - #define ARG_CASE_ARG_DC(selected,result) case selected: { arg_slot[sel_num] = result; ++sel_num; break; } - #define ARG_CASE(prog,selected,result) ARG_CASE_##prog(selected,result) + #define ARG_CASE_ARG_CS_SV_HA(selected, result) + #define ARG_CASE_ARG_CS_SV_DC(selected, result) case selected: { arg_slot[sel_num++] = result; break; } + #define ARG_CASE_ARG_CS_SV(selected, result) + #define ARG_CASE_ARG_CS(selected, result) + #define ARG_CASE_ARG_SV(selected, result) + #define ARG_CASE_ARG_DC(selected, result) case selected: { arg_slot[sel_num++] = result; break; } + #define ARG_CASE(prog, selected, result) ARG_CASE_##prog(selected,result) NOTIF_ARGUMENT_LIST #undef ARG_CASE #undef ARG_CASE_ARG_DC @@ -1315,7 +1214,7 @@ void Local_Notification_centerprint_generic( #undef ARG_CASE_ARG_CS_SV_HA default: { - if(ftos(stof(selected)) != "") { arg_slot[sel_num] = selected; ++sel_num; } + if (/* wtf */ ftos(stof(selected)) != "") { arg_slot[sel_num++] = selected; } else { NOTIF_HIT_UNKNOWN(NOTIF_MAX_DURCNT, "Local_Notification_centerprint_generic") } break; } @@ -1338,7 +1237,7 @@ void Local_Notification_centerprint_generic( void Local_Notification(int net_type, Notification net_name, ...count) { // check if this should be aborted - if(net_name == NOTIF_ABORT) + if (net_name == NOTIF_ABORT) { #ifdef NOTIFICATIONS_DEBUG Debug_Notification(sprintf( @@ -1350,21 +1249,6 @@ void Local_Notification(int net_type, Notification net_name, ...count) return; } - // check supplied type and name for errors - string checkargs = Notification_CheckArgs_TypeName(net_type, net_name.nent_id); - if(checkargs != "") - { - #ifdef NOTIFICATIONS_DEBUG - Debug_Notification(sprintf( - "Local_Notification(%s, %d, ...);\n", - Get_Notif_TypeName(net_type), - Get_Notif_Ent(net_type, net_name).nent_name - )); - #endif - backtrace(sprintf("Incorrect usage of Local_Notification: %s\n", checkargs)); - return; - } - // retreive entity of this notification entity notif = net_name; if (!notif) @@ -1376,7 +1260,7 @@ void Local_Notification(int net_type, Notification net_name, ...count) net_name )); #endif - backtrace("Local_Notification: Could not find notification entity!\n"); + backtrace(sprintf("Incorrect usage of Local_Notification: %s\n", "Null notification")); return; } @@ -1393,14 +1277,14 @@ void Local_Notification(int net_type, Notification net_name, ...count) return; } - string s1 = ((0 < notif.nent_stringcount) ? ...(0, string) : ""); - string s2 = ((1 < notif.nent_stringcount) ? ...(1, string) : ""); - string s3 = ((2 < notif.nent_stringcount) ? ...(2, string) : ""); - string s4 = ((3 < notif.nent_stringcount) ? ...(3, string) : ""); - float f1 = ((0 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 0), float) : 0); - float f2 = ((1 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 1), float) : 0); - float f3 = ((2 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 2), float) : 0); - float f4 = ((3 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 3), float) : 0); + string s1 = ((notif.nent_stringcount > 0) ? ...(0, string) : ""); + string s2 = ((notif.nent_stringcount > 1) ? ...(1, string) : ""); + string s3 = ((notif.nent_stringcount > 2) ? ...(2, string) : ""); + string s4 = ((notif.nent_stringcount > 3) ? ...(3, string) : ""); + float f1 = ((notif.nent_floatcount > 0) ? ...((notif.nent_stringcount + 0), float) : 0); + float f2 = ((notif.nent_floatcount > 1) ? ...((notif.nent_stringcount + 1), float) : 0); + float f3 = ((notif.nent_floatcount > 2) ? ...((notif.nent_stringcount + 2), float) : 0); + float f4 = ((notif.nent_floatcount > 3) ? ...((notif.nent_stringcount + 3), float) : 0); #ifdef NOTIFICATIONS_DEBUG Debug_Notification(sprintf( @@ -1412,28 +1296,12 @@ void Local_Notification(int net_type, Notification net_name, ...count) )); #endif - if((notif.nent_stringcount + notif.nent_floatcount) > count) - { - backtrace(sprintf( - strcat( - "Not enough arguments for Local_Notification(%s, %s, ...)! ", - "stringcount(%d) + floatcount(%d) > count(%d)\n", - "Check the definition and function call for accuracy...?\n" - ), - Get_Notif_TypeName(net_type), - notif.nent_name, - notif.nent_stringcount, - notif.nent_floatcount, - count - )); - return; - } - else if((notif.nent_stringcount + notif.nent_floatcount) < count) + if ((notif.nent_stringcount + notif.nent_floatcount) != count) { backtrace(sprintf( strcat( - "Too many arguments for Local_Notification(%s, %s, ...)! ", - "stringcount(%d) + floatcount(%d) < count(%d)\n", + "Arguments mismatch for Local_Notification(%s, %s, ...)! ", + "stringcount(%d) + floatcount(%d) != count(%d)\n", "Check the definition and function call for accuracy...?\n" ), Get_Notif_TypeName(net_type), @@ -1445,7 +1313,7 @@ void Local_Notification(int net_type, Notification net_name, ...count) return; } - switch(net_type) + switch (net_type) { case MSG_ANNCE: { @@ -1472,15 +1340,15 @@ void Local_Notification(int net_type, Notification net_name, ...count) f1, f2, f3, f4) ); #ifdef CSQC - if(notif.nent_icon != "") + if (notif.nent_icon != "") { - if ( notif.nent_iconargs != "" ) + if (notif.nent_iconargs != "") { - notif.nent_icon = Local_Notification_sprintf( + string s = Local_Notification_sprintf( notif.nent_icon,notif.nent_iconargs, s1, s2, s3, s4, f1, f2, f3, f4); - // remove the newline added by Local_Notification_sprintf - notif.nent_icon = strzone(substring(notif.nent_icon,0,strlen(notif.nent_icon)-1)); + // remove the trailing newline + notif.nent_icon = strzone(substring(s, 0, -1)); } Local_Notification_HUD_Notify_Push( notif.nent_icon, @@ -1510,8 +1378,7 @@ void Local_Notification(int net_type, Notification net_name, ...count) case MSG_MULTI: { - if(notif.nent_msginfo) - if(notif.nent_msginfo.nent_enabled) + if (notif.nent_msginfo && notif.nent_msginfo.nent_enabled) { Local_Notification_WOVA( MSG_INFO, @@ -1522,8 +1389,7 @@ void Local_Notification(int net_type, Notification net_name, ...count) f1, f2, f3, f4); } #ifdef CSQC - if(notif.nent_msgannce) - if(notif.nent_msgannce.nent_enabled) + if (notif.nent_msgannce && notif.nent_msgannce.nent_enabled) { Local_Notification_WOVA( MSG_ANNCE, @@ -1532,8 +1398,7 @@ void Local_Notification(int net_type, Notification net_name, ...count) "", "", "", "", 0, 0, 0, 0); } - if(notif.nent_msgcenter) - if(notif.nent_msgcenter.nent_enabled) + if (notif.nent_msgcenter && notif.nent_msgcenter.nent_enabled) { Local_Notification_WOVA( MSG_CENTER, @@ -1549,18 +1414,15 @@ void Local_Notification(int net_type, Notification net_name, ...count) case MSG_CHOICE: { - entity found_choice; - - if(notif.nent_challow_var && (warmup_stage || (notif.nent_challow_var == 2))) - { - switch(cvar(sprintf("notification_%s", notif.nent_name))) + entity found_choice = notif.nent_optiona; + if (notif.nent_challow_var && (warmup_stage || (notif.nent_challow_var == 2))) { + switch (cvar(sprintf("notification_%s", notif.nent_name))) { - case 1: found_choice = notif.nent_optiona; break; + case 1: break; case 2: found_choice = notif.nent_optionb; break; default: return; // not enabled anyway } } - else { found_choice = notif.nent_optiona; } Local_Notification_WOVA( found_choice.nent_type, @@ -1580,9 +1442,9 @@ void Local_Notification_WOVA( string s1, string s2, string s3, string s4, float f1, float f2, float f3, float f4) { - #define VARITEM(stringc,floatc,args) \ - if((stringcount == stringc) && (floatcount == floatc)) \ - { Local_Notification(net_type, net_name, args); return; } + #define VARITEM(stringc, floatc, args) \ + if ((stringcount == stringc) && (floatcount == floatc)) \ + { Local_Notification(net_type, net_name, args); return; } EIGHT_VARS_TO_VARARGS_VARLIST #undef VARITEM Local_Notification(net_type, net_name); // some notifications don't have any arguments at all @@ -1600,113 +1462,105 @@ NET_HANDLE(ENT_CLIENT_NOTIFICATION, bool is_new) { int net_type = ReadByte(); int net_name = ReadShort(); - return = true; - entity notif; + #ifdef NOTIFICATIONS_DEBUG + Debug_Notification(sprintf( + "Read_Notification(%d) at %f: net_type = %s, net_name = %s\n", + is_new, + time, + Get_Notif_TypeName(net_type), + notif.nent_name + )); + #endif - if(net_type == MSG_CENTER_CPID) + if (net_type == MSG_CENTER_CPID) { - #ifdef NOTIFICATIONS_DEBUG - Debug_Notification(sprintf( - "Read_Notification(%d) at %f: net_type = %s, net_name = %d\n", - is_new, - time, - Get_Notif_TypeName(net_type), - net_name - )); - #endif - - if(is_new) - { - if(net_name == 0) { reset_centerprint_messages(); } - else if(net_name != NO_CPID) - { - // in this case, net_name IS the cpid we want to kill - centerprint_generic(net_name, "", 0, 0); - } - else - { - backtrace(sprintf( - "Read_Notification(%d) at %f: ^1TRIED TO KILL NO_CPID CENTERPRINT!\n", - is_new, - time - )); - } + // killing + return = true; + if (!is_new) return; + if (net_name == NO_CPID) { + backtrace(sprintf( + "Read_Notification(%d) at %f: ^1TRIED TO KILL NO_CPID CENTERPRINT!\n", + is_new, + time + )); + return; + } + if (net_name == 0) { + // kill all + reset_centerprint_messages(); + return; } + // kill one + centerprint_generic(net_name, "", 0, 0); + return; } else { - notif = Get_Notif_Ent(net_type, net_name); - if (!notif) { backtrace("Read_Notification: Could not find notification entity!\n"); return; } + // creating + Notification notif = Get_Notif_Ent(net_type, net_name); + if (!notif) { + backtrace("Read_Notification: Could not find notification entity!\n"); + return false; + } - #ifdef NOTIFICATIONS_DEBUG - Debug_Notification(sprintf( - "Read_Notification(%d) at %f: net_type = %s, net_name = %s\n", - is_new, - time, - Get_Notif_TypeName(net_type), - notif.nent_name - )); - #endif + string s1 = ((notif.nent_stringcount > 0) ? ReadString() : ""); + string s2 = ((notif.nent_stringcount > 1) ? ReadString() : ""); + string s3 = ((notif.nent_stringcount > 2) ? ReadString() : ""); + string s4 = ((notif.nent_stringcount > 3) ? ReadString() : ""); + float f1 = ((notif.nent_floatcount > 0) ? ReadLong() : 0); + float f2 = ((notif.nent_floatcount > 1) ? ReadLong() : 0); + float f3 = ((notif.nent_floatcount > 2) ? ReadLong() : 0); + float f4 = ((notif.nent_floatcount > 3) ? ReadLong() : 0); - string s1 = ((0 < notif.nent_stringcount) ? ReadString() : ""); - string s2 = ((1 < notif.nent_stringcount) ? ReadString() : ""); - string s3 = ((2 < notif.nent_stringcount) ? ReadString() : ""); - string s4 = ((3 < notif.nent_stringcount) ? ReadString() : ""); - float f1 = ((0 < notif.nent_floatcount) ? ReadLong() : 0); - float f2 = ((1 < notif.nent_floatcount) ? ReadLong() : 0); - float f3 = ((2 < notif.nent_floatcount) ? ReadLong() : 0); - float f4 = ((3 < notif.nent_floatcount) ? ReadLong() : 0); + return = true; - if(is_new) - { - Local_Notification_WOVA( - net_type, notif, - notif.nent_stringcount, - notif.nent_floatcount, - s1, s2, s3, s4, - f1, f2, f3, f4); - } + if (!is_new) return; + Local_Notification_WOVA( + net_type, notif, + notif.nent_stringcount, + notif.nent_floatcount, + s1, s2, s3, s4, + f1, f2, f3, f4); + return; } } #endif #ifdef SVQC void Net_Notification_Remove() -{SELFPARAM(); - if (!self) { backtrace(sprintf("Net_Notification_Remove() at %f: Missing self!?\n", time)); return; } - +{ + SELFPARAM(); #ifdef NOTIFICATIONS_DEBUG Debug_Notification(sprintf( "Net_Notification_Remove() at %f: %s '%s - %s' notification\n", time, - ((self.nent_net_name == -1) ? "Killed" : "Removed"), - Get_Notif_TypeName(self.nent_net_type), - self.owner.nent_name + ((this.nent_net_name == -1) ? "Killed" : "Removed"), + Get_Notif_TypeName(this.nent_net_type), + this.owner.nent_name )); #endif - - for(int i = 0; i < 4; ++i) { if(self.nent_strings[i]) { strunzone(self.nent_strings[i]); } } - remove(self); + for (int i = 0; i < this.nent_stringcount; ++i) { if (this.nent_strings[i]) strunzone(this.nent_strings[i]); } + remove(this); } bool Net_Write_Notification(entity this, entity client, int sf) { - if(Notification_ShouldSend(self.nent_broadcast, client, self.nent_client)) - { - WriteHeader(MSG_ENTITY, ENT_CLIENT_NOTIFICATION); - WriteByte(MSG_ENTITY, self.nent_net_type); - WriteShort(MSG_ENTITY, self.nent_net_name); - for(int i = 0; i < self.nent_stringcount; ++i) { WriteString(MSG_ENTITY, self.nent_strings[i]); } - for(int i = 0; i < self.nent_floatcount; ++i) { WriteLong(MSG_ENTITY, self.nent_floats[i]); } - return true; - } - else { return false; } + if (!Notification_ShouldSend(self.nent_broadcast, client, self.nent_client)) return false; + WriteHeader(MSG_ENTITY, ENT_CLIENT_NOTIFICATION); + WriteByte(MSG_ENTITY, self.nent_net_type); + WriteShort(MSG_ENTITY, self.nent_net_name); + for (int i = 0; i < self.nent_stringcount; ++i) { WriteString(MSG_ENTITY, self.nent_strings[i]); } + for (int i = 0; i < self.nent_floatcount; ++i) { WriteLong(MSG_ENTITY, self.nent_floats[i]); } + return true; } void Kill_Notification( NOTIF broadcast, entity client, - float net_type, float net_name) + /** primary group */ + float net_type, + /** secondary group */ + float net_name) { #ifdef NOTIFICATIONS_DEBUG Debug_Notification(sprintf( @@ -1718,13 +1572,13 @@ void Kill_Notification( )); #endif - string checkargs = Notification_CheckArgs(broadcast, client, 1, 1); - if(checkargs != "") { backtrace(sprintf("Incorrect usage of Kill_Notification: %s\n", checkargs)); return; } + string checkargs = Notification_CheckArgs(broadcast, client, NO_MSG); + if (checkargs != "") { backtrace(sprintf("Incorrect usage of Kill_Notification: %s\n", checkargs)); return; } entity net_notif; float killed_cpid = NO_CPID; - switch(net_type) + switch (net_type) { case 0: { @@ -1758,7 +1612,7 @@ void Kill_Notification( } } - if(killed_cpid != NO_CPID) + if (killed_cpid != NO_CPID) { net_notif = new(net_kill_notification); make_pure(net_notif); @@ -1771,9 +1625,9 @@ void Kill_Notification( FOREACH_ENTITY_CLASS("net_notification", true, { - if(net_type) + if (net_type) { - if((killed_cpid != NO_CPID) && (it.nent_net_type == MSG_CENTER)) + if ((killed_cpid != NO_CPID) && (it.nent_net_type == MSG_CENTER)) { if(it.owner.nent_cpid == killed_cpid) { @@ -1782,11 +1636,11 @@ void Kill_Notification( } else { continue; } // we ARE looking for a specific CPID, don't kill everything else too } - else if(it.nent_net_type == net_type) + else if (it.nent_net_type == net_type) { - if(net_name) + if (net_name) { - if(it.nent_net_name == net_name) { it.nent_net_name = -1; it.nextthink = time; } + if (it.nent_net_name == net_name) { it.nent_net_name = -1; it.nextthink = time; } else { continue; } // we ARE looking for a certain net_name, don't kill everything else too } else { it.nent_net_name = -1; it.nextthink = time; } @@ -1803,7 +1657,7 @@ void Send_Notification( ...count) { // check if this should be aborted - if(net_name == NOTIF_ABORT) + if (net_name == NOTIF_ABORT) { #ifdef NOTIFICATIONS_DEBUG Debug_Notification(sprintf( @@ -1818,8 +1672,8 @@ void Send_Notification( } // check supplied broadcast, target, type, and name for errors - string checkargs = Notification_CheckArgs(broadcast, client, net_type, net_name.nent_id); - if(checkargs != "") + string checkargs = Notification_CheckArgs(broadcast, client, net_name); + if (checkargs != "") { #ifdef NOTIFICATIONS_DEBUG Debug_Notification(sprintf( @@ -1827,7 +1681,7 @@ void Send_Notification( Get_Notif_BroadcastName(broadcast), client.classname, Get_Notif_TypeName(net_type), - Get_Notif_Ent(net_type, net_name).nent_name + net_name.nent_name )); #endif backtrace(sprintf("Incorrect usage of Send_Notification: %s\n", checkargs)); @@ -1875,34 +1729,7 @@ void Send_Notification( )); #endif - if((notif.nent_stringcount + notif.nent_floatcount) > count) - { - string s = - #ifdef NOTIFICATIONS_DEBUG - Get_Notif_BroadcastName(broadcast); - #else - ftos(ORDINAL(broadcast)); - #endif - backtrace(sprintf( - strcat( - "Not enough arguments for Send_Notification(%s, ...)! ", - "stringcount(%d) + floatcount(%d) > count(%d)\n", - "Check the definition and function call for accuracy...?\n" - ), - sprintf( - "%s, '%s', %s, %s", - s, - client.classname, - Get_Notif_TypeName(net_type), - notif.nent_name - ), - notif.nent_stringcount, - notif.nent_floatcount, - count - )); - return; - } - else if((notif.nent_stringcount + notif.nent_floatcount) < count) + if ((notif.nent_stringcount + notif.nent_floatcount) != count) { string s = #ifdef NOTIFICATIONS_DEBUG @@ -1912,8 +1739,8 @@ void Send_Notification( #endif backtrace(sprintf( strcat( - "Too many arguments for Send_Notification(%s, ...)! ", - "stringcount(%d) + floatcount(%d) < count(%d)\n", + "Argument mismatch for Send_Notification(%s, ...)! ", + "stringcount(%d) + floatcount(%d) != count(%d)\n", "Check the definition and function call for accuracy...?\n" ), sprintf( @@ -1930,7 +1757,7 @@ void Send_Notification( return; } - if( + if ( server_is_dedicated && ( @@ -1954,7 +1781,7 @@ void Send_Notification( f1, f2, f3, f4); } - if(net_type == MSG_CHOICE) + if (net_type == MSG_CHOICE) { // THIS GETS TRICKY... now we have to cycle through each possible player (checking broadcast) // and then do an individual NOTIF_ONE_ONLY recursive call for each one depending on their option... @@ -1964,16 +1791,16 @@ void Send_Notification( entity found_choice; #define RECURSE_FROM_CHOICE(ent,action) MACRO_BEGIN { \ - if(notif.nent_challow_var && (warmup_stage || (notif.nent_challow_var == 2))) \ - { \ - switch(ent.msg_choice_choices[net_name.nent_id - 1]) \ + if (notif.nent_challow_var && (warmup_stage || (notif.nent_challow_var == 2))) { \ + switch (ent.msg_choice_choices[net_name.nent_id - 1]) \ { \ case 1: found_choice = notif.nent_optiona; break; \ case 2: found_choice = notif.nent_optionb; break; \ default: action; \ } \ + } else { \ + found_choice = notif.nent_optiona; \ } \ - else { found_choice = notif.nent_optiona; } \ Send_Notification_WOVA( \ NOTIF_ONE_ONLY, \ ent, \ @@ -1985,24 +1812,20 @@ void Send_Notification( f1, f2, f3, f4); \ } MACRO_END - switch(broadcast) + switch (broadcast) { case NOTIF_ONE_ONLY: // we can potentially save processing power with this broadcast method { - if(IS_REAL_CLIENT(client)) - { + if (IS_REAL_CLIENT(client)) { RECURSE_FROM_CHOICE(client, return); } break; } default: { - FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA( - if(Notification_ShouldSend(broadcast, it, client)) - { - RECURSE_FROM_CHOICE(it, continue); - } - )); + FOREACH_CLIENT(IS_REAL_CLIENT(it) && Notification_ShouldSend(broadcast, it, client), { + RECURSE_FROM_CHOICE(it, continue); + }); break; } } @@ -2019,19 +1842,17 @@ void Send_Notification( net_notif.nent_stringcount = notif.nent_stringcount; net_notif.nent_floatcount = notif.nent_floatcount; - for(int i = 0; i < net_notif.nent_stringcount; ++i) - { net_notif.nent_strings[i] = strzone(...(i, string)); } - for(int i = 0; i < net_notif.nent_floatcount; ++i) - { net_notif.nent_floats[i] = ...((net_notif.nent_stringcount + i), float); } + for (int i = 0; i < net_notif.nent_stringcount; ++i) { + net_notif.nent_strings[i] = strzone(...(i, string)); + } + for (int i = 0; i < net_notif.nent_floatcount; ++i) { + net_notif.nent_floats[i] = ...((net_notif.nent_stringcount + i), float); + } net_notif.think = Net_Notification_Remove; - net_notif.nextthink = - ((time > autocvar_notification_lifetime_mapload) - ? - (time + autocvar_notification_lifetime_runtime) - : - autocvar_notification_lifetime_mapload - ); + net_notif.nextthink = (time > autocvar_notification_lifetime_mapload) + ? (time + autocvar_notification_lifetime_runtime) + : autocvar_notification_lifetime_mapload; Net_LinkEntity(net_notif, false, 0, Net_Write_Notification); } @@ -2046,7 +1867,7 @@ void Send_Notification_WOVA( float f1, float f2, float f3, float f4) { #ifdef NOTIFICATIONS_DEBUG - entity notif = Get_Notif_Ent(net_type, net_name); + entity notif = net_name; Debug_Notification(sprintf( "Send_Notification_WOVA(%s, %d, %d, %s, %s);\n", sprintf( @@ -2063,9 +1884,9 @@ void Send_Notification_WOVA( )); #endif - #define VARITEM(stringc,floatc,args) \ - if((stringcount == stringc) && (floatcount == floatc)) \ - { Send_Notification(broadcast, client, net_type, net_name, args); return; } + #define VARITEM(stringc, floatc, args) \ + if ((stringcount == stringc) && (floatcount == floatc)) \ + { Send_Notification(broadcast, client, net_type, net_name, args); return; } EIGHT_VARS_TO_VARARGS_VARLIST #undef VARITEM Send_Notification(broadcast, client, net_type, net_name); // some notifications don't have any arguments at all @@ -2095,9 +1916,9 @@ void Send_Notification_WOCOVA( )); #endif - #define VARITEM(stringc,floatc,args) \ - if((notif.nent_stringcount == stringc) && (notif.nent_floatcount == floatc)) \ - { Send_Notification(broadcast, client, net_type, net_name, args); return; } + #define VARITEM(stringc, floatc, args) \ + if ((notif.nent_stringcount == stringc) && (notif.nent_floatcount == floatc)) \ + { Send_Notification(broadcast, client, net_type, net_name, args); return; } EIGHT_VARS_TO_VARARGS_VARLIST #undef VARITEM Send_Notification(broadcast, client, net_type, net_name); // some notifications don't have any arguments at all diff --git a/qcsrc/common/notifications.qh b/qcsrc/common/notifications.qh index 4df13ac90..3ba25c041 100644 --- a/qcsrc/common/notifications.qh +++ b/qcsrc/common/notifications.qh @@ -16,121 +16,140 @@ const int MSG_ANNCE = 1; // "Global" AND "personal" announcer messages const int MSG_INFO = 2; // "Global" information messages const int MSG_CENTER = 3; // "Personal" centerprint messages -const int MSG_CENTER_CPID = 4; // Kill centerprint message const int MSG_MULTI = 5; // Subcall MSG_INFO and/or MSG_CENTER notifications const int MSG_CHOICE = 6; // Choose which subcall wrapper to activate +const int MSG_CENTER_CPID = 4; // Kill centerprint message + +string Get_Notif_TypeName(int net_type) +{ + switch (net_type) + { + case MSG_ANNCE: return "MSG_ANNCE"; + case MSG_INFO: return "MSG_INFO"; + case MSG_CENTER: return "MSG_CENTER"; + case MSG_CENTER_CPID: return "MSG_CENTER_CPID"; + case MSG_MULTI: return "MSG_MULTI"; + case MSG_CHOICE: return "MSG_CHOICE"; + } + backtrace(sprintf("Get_Notif_TypeName(%d): Improper net type!\n", net_type)); + return ""; +} + typedef entity Notification; // negative confirmations /** allows various things to know when no information is added */ Notification NO_MSG; STATIC_INIT(NO_MSG) { NO_MSG = new(Notification); } +/** @deprecated */ const int NO_MSG_ = -12345; /** allows Send_Notification to safely abort sending */ Notification NOTIF_ABORT; STATIC_INIT(NOTIF_ABORT) { NOTIF_ABORT = new(Notification); } +// used for notification system multi-team identifiers +#define APP_TEAM_NUM(num, prefix) ((num == NUM_TEAM_1) ? prefix##_RED : ((num == NUM_TEAM_2) ? prefix##_BLUE : ((num == NUM_TEAM_3) ? prefix##_YELLOW : prefix##_PINK))) +/** @deprecated use APP_TEAM_NUM */ +#define APP_TEAM_ENT(ent, prefix) APP_TEAM_NUM(ent.team, prefix) + #define EIGHT_VARS_TO_VARARGS_VARLIST \ - VARITEM(1, 0, s1) \ - VARITEM(2, 0, XPD(s1, s2)) \ - VARITEM(3, 0, XPD(s1, s2, s3)) \ - VARITEM(4, 0, XPD(s1, s2, s3, s4)) \ - VARITEM(0, 1, f1) \ - VARITEM(1, 1, XPD(s1, f1)) \ - VARITEM(2, 1, XPD(s1, s2, f1)) \ - VARITEM(3, 1, XPD(s1, s2, s3, f1)) \ - VARITEM(4, 1, XPD(s1, s2, s3, s4, f1)) \ - VARITEM(0, 2, XPD(f1, f2)) \ - VARITEM(1, 2, XPD(s1, f1, f2)) \ - VARITEM(2, 2, XPD(s1, s2, f1, f2)) \ - VARITEM(3, 2, XPD(s1, s2, s3, f1, f2)) \ - VARITEM(4, 2, XPD(s1, s2, s3, s4, f1, f2)) \ - VARITEM(0, 3, XPD(f1, f2, f3)) \ - VARITEM(1, 3, XPD(s1, f1, f2, f3)) \ - VARITEM(2, 3, XPD(s1, s2, f1, f2, f3)) \ - VARITEM(3, 3, XPD(s1, s2, s3, f1, f2, f3)) \ - VARITEM(4, 3, XPD(s1, s2, s3, s4, f1, f2, f3)) \ - VARITEM(0, 4, XPD(f1, f2, f3, f4)) \ - VARITEM(1, 4, XPD(s1, f1, f2, f3, f4)) \ - VARITEM(2, 4, XPD(s1, s2, f1, f2, f3, f4)) \ - VARITEM(3, 4, XPD(s1, s2, s3, f1, f2, f3, f4)) \ - VARITEM(4, 4, XPD(s1, s2, s3, s4, f1, f2, f3, f4)) + VARITEM(1, 0, s1) \ + VARITEM(2, 0, XPD(s1, s2)) \ + VARITEM(3, 0, XPD(s1, s2, s3)) \ + VARITEM(4, 0, XPD(s1, s2, s3, s4)) \ + VARITEM(0, 1, f1) \ + VARITEM(1, 1, XPD(s1, f1)) \ + VARITEM(2, 1, XPD(s1, s2, f1)) \ + VARITEM(3, 1, XPD(s1, s2, s3, f1)) \ + VARITEM(4, 1, XPD(s1, s2, s3, s4, f1)) \ + VARITEM(0, 2, XPD(f1, f2)) \ + VARITEM(1, 2, XPD(s1, f1, f2)) \ + VARITEM(2, 2, XPD(s1, s2, f1, f2)) \ + VARITEM(3, 2, XPD(s1, s2, s3, f1, f2)) \ + VARITEM(4, 2, XPD(s1, s2, s3, s4, f1, f2)) \ + VARITEM(0, 3, XPD(f1, f2, f3)) \ + VARITEM(1, 3, XPD(s1, f1, f2, f3)) \ + VARITEM(2, 3, XPD(s1, s2, f1, f2, f3)) \ + VARITEM(3, 3, XPD(s1, s2, s3, f1, f2, f3)) \ + VARITEM(4, 3, XPD(s1, s2, s3, s4, f1, f2, f3)) \ + VARITEM(0, 4, XPD(f1, f2, f3, f4)) \ + VARITEM(1, 4, XPD(s1, f1, f2, f3, f4)) \ + VARITEM(2, 4, XPD(s1, s2, f1, f2, f3, f4)) \ + VARITEM(3, 4, XPD(s1, s2, s3, f1, f2, f3, f4)) \ + VARITEM(4, 4, XPD(s1, s2, s3, s4, f1, f2, f3, f4)) void Destroy_All_Notifications(); void Create_Notification_Entity(entity notif, - float var_default, - float var_cvar, - float typeId, - float nameid, - string namestring); + float var_default, + float var_cvar, + float typeId, + float nameid, + string namestring); void Create_Notification_Entity_Annce(entity notif, - float var_cvar, - string namestring, - /* MSG_ANNCE */ - float channel, - string snd, - float vol, - float position); + float var_cvar, + string namestring, + /* MSG_ANNCE */ + float channel, + string snd, + float vol, + float position); void Create_Notification_Entity_InfoCenter(entity notif, - float var_cvar, - string namestring, - int strnum, - int flnum, - /* MSG_INFO & MSG_CENTER */ - string args, - string hudargs, - string icon, - float cpid, - string durcnt, - string normal, - string gentle); + float var_cvar, + string namestring, + int strnum, + int flnum, + /* MSG_INFO & MSG_CENTER */ + string args, + string hudargs, + string icon, + float cpid, + string durcnt, + string normal, + string gentle); void Create_Notification_Entity_Multi(entity notif, - float var_cvar, - string namestring, - /* MSG_MULTI */ - Notification anncename, - Notification infoname, - Notification centername); + float var_cvar, + string namestring, + /* MSG_MULTI */ + Notification anncename, + Notification infoname, + Notification centername); void Create_Notification_Entity_Choice(entity notif, - float var_cvar, - string namestring, - /* MSG_CHOICE */ - float challow_def, - float challow_var, - int chtype, - Notification optiona, - Notification optionb); - -void Dump_Notifications(float fh, float alsoprint); + float var_cvar, + string namestring, + /* MSG_CHOICE */ + float challow_def, + float challow_var, + int chtype, + Notification optiona, + Notification optionb); +void Dump_Notifications(int fh, bool alsoprint); GENERIC_COMMAND(dumpnotifs, "Dump all notifications into notifications_dump.txt") { - switch(request) + switch (request) { case CMD_REQUEST_COMMAND: { #ifndef MENUQC - float fh, alsoprint = false; string filename = argv(1); - - if(filename == "") + bool alsoprint = false; + if (filename == "") { filename = "notifications_dump.cfg"; alsoprint = false; } - else if(filename == "-") + else if (filename == "-") { filename = "notifications_dump.cfg"; alsoprint = true; } - fh = fopen(filename, FILE_WRITE); - - if(fh >= 0) + int fh = fopen(filename, FILE_WRITE); + if (fh >= 0) { Dump_Notifications(fh, alsoprint); LOG_INFOF("Dumping notifications... File located in ^2data/data/%s^7.\n", filename); @@ -145,7 +164,6 @@ GENERIC_COMMAND(dumpnotifs, "Dump all notifications into notifications_dump.txt" #endif return; } - default: case CMD_REQUEST_USAGE: { @@ -159,49 +177,80 @@ GENERIC_COMMAND(dumpnotifs, "Dump all notifications into notifications_dump.txt" } #ifdef NOTIFICATIONS_DEBUG -void Debug_Notification(string input); +void Debug_Notification(string input) +{ + switch (autocvar_notification_debug) + { + case 1: { LOG_TRACE(input); break; } + case 2: { LOG_INFO(input); break; } + } +} #endif void Local_Notification(int net_type, Notification net_name, ...count); +/** glue for networking, forwards to `Local_Notification` */ void Local_Notification_WOVA( - float net_type, Notification net_name, - float stringcount, float floatcount, - string s1, string s2, string s3, string s4, - float f1, float f2, float f3, float f4); + float net_type, Notification net_name, + float stringcount, float floatcount, + string s1, string s2, string s3, string s4, + float f1, float f2, float f3, float f4); -#ifdef CSQC // CLIENT ONLY +#ifdef CSQC string prev_soundfile; float prev_soundtime; #endif -#ifdef SVQC // SERVER ONLY +#ifdef SVQC ENUMCLASS(NOTIF) - CASE(NOTIF, ONE) - CASE(NOTIF, ONE_ONLY) - CASE(NOTIF, TEAM) - CASE(NOTIF, TEAM_EXCEPT) - CASE(NOTIF, ALL) - CASE(NOTIF, ALL_EXCEPT) + /** send to one client and their spectators */ + CASE(NOTIF, ONE) + /** send ONLY to one client */ + CASE(NOTIF, ONE_ONLY) + /** send only to X team and their spectators */ + CASE(NOTIF, TEAM) + /** send only to X team and their spectators, except for Y person and their spectators */ + CASE(NOTIF, TEAM_EXCEPT) + /** send to everyone */ + CASE(NOTIF, ALL) + /** send to everyone except X person and their spectators */ + CASE(NOTIF, ALL_EXCEPT) ENUMCLASS_END(NOTIF) +#ifdef NOTIFICATIONS_DEBUG +string Get_Notif_BroadcastName(float broadcast) +{ + switch (broadcast) + { + case NOTIF_ONE: return "NOTIF_ONE"; + case NOTIF_ONE_ONLY: return "NOTIF_ONE_ONLY"; + case NOTIF_ALL_EXCEPT: return "NOTIF_ALL_EXCEPT"; + case NOTIF_ALL: return "NOTIF_ALL"; + case NOTIF_TEAM: return "NOTIF_TEAM"; + case NOTIF_TEAM_EXCEPT: return "NOTIF_TEAM_EXCEPT"; + } + backtrace(sprintf("Get_Notif_BroadcastName(%d): Improper broadcast!\n", broadcast)); + return ""; +} +#endif + void Kill_Notification( - NOTIF broadcast, entity client, - float net_type, float net_name); + NOTIF broadcast, entity client, + float net_type, float net_name); void Send_Notification( - NOTIF broadcast, entity client, - float net_type, Notification net_name, - ...count); + NOTIF broadcast, entity client, + float net_type, Notification net_name, + ...count); void Send_Notification_WOVA( - NOTIF broadcast, entity client, - float net_type, Notification net_name, - float stringcount, float floatcount, - string s1, string s2, string s3, string s4, - float f1, float f2, float f3, float f4); + NOTIF broadcast, entity client, + float net_type, Notification net_name, + float stringcount, float floatcount, + string s1, string s2, string s3, string s4, + float f1, float f2, float f3, float f4); void Send_Notification_WOCOVA( - NOTIF broadcast, entity client, - float net_type, Notification net_name, - string s1, string s2, string s3, string s4, - float f1, float f2, float f3, float f4); + NOTIF broadcast, entity client, + float net_type, Notification net_name, + string s1, string s2, string s3, string s4, + float f1, float f2, float f3, float f4); #endif // =========================== @@ -259,38 +308,38 @@ float autocvar_notification_show_sprees_center_specialonly = true; sprintf usage matches with proper %s placement. Argument descriptions: - s1-s4: string arguments to be literally swapped into sprintf - s2loc: s2 string of locations of deaths or other events - s3loc: s3 string of locations of deaths or other events - f1-f4: float arguments expanded into strings to be swapped into sprintf - f1p2dec: f1 float to string with 2 decimal places - f2p2dec: f2 float to string with 2 decimal places - f2primsec: f2 float primary or secondary selection for weapons - f3primsec: f3 float primary or secondary selection for weapons - f1secs: count_seconds of f1 - f1points: point or points depending on f1 - f1ord: count_ordinal of f1 - f1time: process_time of f1 - f1race_time: mmssss of f1 - f2race_time: mmssss of f2 - race_col: color of race time/position (i.e. good or bad) - race_diff: show time difference between f2 and f3 - missing_teams: show which teams still need players - pass_key: find the keybind for "passing" or "dropping" in CTF game mode - frag_ping: show the ping of a player - frag_stats: show health/armor/ping of a player - frag_pos: show score status and position in the match of a player - spree_cen: centerprint notif for kill spree/how many kills they have - spree_inf: info notif for kill spree/how many kills they have - spree_end: placed at the end of murder messages to show ending of sprees - spree_lost: placed at the end of suicide messages to show losing of sprees - item_wepname: return full name of a weapon from weaponid - item_wepammo: ammo display for weapon from string - item_centime: amount of time to display weapon message in centerprint - item_buffname: return full name of a buff from buffid - death_team: show the full name of the team a player is switching from - minigame1_name: return human readable name of a minigame from its id(s1) - minigame1_d: return descriptor name of a minigame from its id(s1) + s1-s4: string arguments to be literally swapped into sprintf + s2loc: s2 string of locations of deaths or other events + s3loc: s3 string of locations of deaths or other events + f1-f4: float arguments expanded into strings to be swapped into sprintf + f1p2dec: f1 float to string with 2 decimal places + f2p2dec: f2 float to string with 2 decimal places + f2primsec: f2 float primary or secondary selection for weapons + f3primsec: f3 float primary or secondary selection for weapons + f1secs: count_seconds of f1 + f1points: point or points depending on f1 + f1ord: count_ordinal of f1 + f1time: process_time of f1 + f1race_time: mmssss of f1 + f2race_time: mmssss of f2 + race_col: color of race time/position (i.e. good or bad) + race_diff: show time difference between f2 and f3 + missing_teams: show which teams still need players + pass_key: find the keybind for "passing" or "dropping" in CTF game mode + frag_ping: show the ping of a player + frag_stats: show health/armor/ping of a player + frag_pos: show score status and position in the match of a player + spree_cen: centerprint notif for kill spree/how many kills they have + spree_inf: info notif for kill spree/how many kills they have + spree_end: placed at the end of murder messages to show ending of sprees + spree_lost: placed at the end of suicide messages to show losing of sprees + item_wepname: return full name of a weapon from weaponid + item_wepammo: ammo display for weapon from string + item_centime: amount of time to display weapon message in centerprint + item_buffname: return full name of a buff from buffid + death_team: show the full name of the team a player is switching from + minigame1_name: return human readable name of a minigame from its id(s1) + minigame1_d: return descriptor name of a minigame from its id(s1) */ const float NOTIF_MAX_ARGS = 7; @@ -312,244 +361,230 @@ const float ARG_DC = 6; // unique result to durcnt/centerprint string BUFF_NAME(int i); #define NOTIF_ARGUMENT_LIST \ - ARG_CASE(ARG_CS_SV_HA, "s1", s1) \ - ARG_CASE(ARG_CS_SV_HA, "s2", s2) \ - ARG_CASE(ARG_CS_SV_HA, "s3", s3) \ - ARG_CASE(ARG_CS_SV_HA, "s4", s4) \ - ARG_CASE(ARG_CS_SV, "s2loc", ((autocvar_notification_show_location && (s2 != "")) ? sprintf(( ((tmp_s = autocvar_notification_show_location_string) != "") ? tmp_s : _(" (near %s)") ), s2) : "")) \ - ARG_CASE(ARG_CS_SV, "s3loc", ((autocvar_notification_show_location && (s3 != "")) ? sprintf(( ((tmp_s = autocvar_notification_show_location_string) != "") ? tmp_s : _(" (near %s)") ), s3) : "")) \ - ARG_CASE(ARG_CS_SV_DC, "f1", ftos(f1)) \ - ARG_CASE(ARG_CS_SV_DC, "f2", ftos(f2)) \ - ARG_CASE(ARG_CS_SV, "f3", ftos(f3)) \ - ARG_CASE(ARG_CS_SV, "f4", ftos(f4)) \ - ARG_CASE(ARG_CS_SV, "f1p2dec", ftos_decimals(f1/100, 2)) \ - ARG_CASE(ARG_CS_SV, "f2p2dec", ftos_decimals(f2/100, 2)) \ - ARG_CASE(ARG_CS, "f2primsec", (f2 ? _("secondary") : _("primary"))) \ - ARG_CASE(ARG_CS, "f3primsec", (f3 ? _("secondary") : _("primary"))) \ - ARG_CASE(ARG_CS, "f1secs", count_seconds(f1)) \ - ARG_CASE(ARG_CS, "f1points", (f1 == 1 ? _("point") : _("points"))) \ - ARG_CASE(ARG_CS_SV, "f1ord", count_ordinal(f1)) \ - ARG_CASE(ARG_CS, "f1time", process_time(2, f1)) \ - ARG_CASE(ARG_CS_SV_HA, "f1race_time", mmssss(f1)) \ - ARG_CASE(ARG_CS_SV_HA, "f2race_time", mmssss(f2)) \ - ARG_CASE(ARG_CS_SV_HA, "f3race_time", mmssss(f3)) \ - ARG_CASE(ARG_CS_SV, "race_col", CCR(((f1 == 1) ? "^F1" : "^F2"))) \ - ARG_CASE(ARG_CS_SV, "race_diff", ((f2 > f3) ? sprintf(CCR("^1[+%s]"), mmssss(f2 - f3)) : sprintf(CCR("^2[-%s]"), mmssss(f3 - f2)))) \ - ARG_CASE(ARG_CS, "missing_teams", notif_arg_missing_teams(f1)) \ - ARG_CASE(ARG_CS, "pass_key", ((((tmp_s = getcommandkey("pass", "+use")) != "pass") && !(strstrofs(tmp_s, "not bound", 0) >= 0)) ? sprintf(CCR(_(" ^F1(Press %s)")), tmp_s) : "")) \ - ARG_CASE(ARG_CS, "frag_ping", notif_arg_frag_ping(true, f2)) \ - ARG_CASE(ARG_CS, "frag_stats", notif_arg_frag_stats(f2, f3, f4)) \ - /*ARG_CASE(ARG_CS, "frag_pos", ((Should_Print_Score_Pos(f1)) ? sprintf("\n^BG%s", Read_Score_Pos(f1)) : ""))*/ \ - ARG_CASE(ARG_CS, "spree_cen", (autocvar_notification_show_sprees ? notif_arg_spree_cen(f1) : "")) \ - ARG_CASE(ARG_CS_SV, "spree_inf", (autocvar_notification_show_sprees ? notif_arg_spree_inf(1, input, s2, f2) : "")) \ - ARG_CASE(ARG_CS_SV, "spree_end", (autocvar_notification_show_sprees ? notif_arg_spree_inf(-1, "", "", f1) : "")) \ - ARG_CASE(ARG_CS_SV, "spree_lost", (autocvar_notification_show_sprees ? notif_arg_spree_inf(-2, "", "", f1) : "")) \ - ARG_CASE(ARG_CS_SV, "item_wepname", Weapons_from(f1).m_name) \ - ARG_CASE(ARG_CS_SV, "item_buffname", BUFF_NAME(f1)) \ - ARG_CASE(ARG_CS_SV, "f3buffname", BUFF_NAME(f3)) \ - ARG_CASE(ARG_CS_SV, "item_wepammo", (s1 != "" ? sprintf(_(" with %s"), s1) : "")) \ - ARG_CASE(ARG_DC, "item_centime", ftos(autocvar_notification_item_centerprinttime)) \ - ARG_CASE(ARG_SV, "death_team", Team_ColoredFullName(f1)) \ - ARG_CASE(ARG_CS, "death_team", Team_ColoredFullName(f1 - 1)) \ - ARG_CASE(ARG_CS_SV_HA, "minigame1_name",find(world,netname,s1).descriptor.message) \ - ARG_CASE(ARG_CS_SV_HA, "minigame1_d", find(world,netname,s1).descriptor.netname) + ARG_CASE(ARG_CS_SV_HA, "s1", s1) \ + ARG_CASE(ARG_CS_SV_HA, "s2", s2) \ + ARG_CASE(ARG_CS_SV_HA, "s3", s3) \ + ARG_CASE(ARG_CS_SV_HA, "s4", s4) \ + ARG_CASE(ARG_CS_SV, "s2loc", ((autocvar_notification_show_location && (s2 != "")) ? sprintf(( ((tmp_s = autocvar_notification_show_location_string) != "") ? tmp_s : _(" (near %s)") ), s2) : "")) \ + ARG_CASE(ARG_CS_SV, "s3loc", ((autocvar_notification_show_location && (s3 != "")) ? sprintf(( ((tmp_s = autocvar_notification_show_location_string) != "") ? tmp_s : _(" (near %s)") ), s3) : "")) \ + ARG_CASE(ARG_CS_SV_DC, "f1", ftos(f1)) \ + ARG_CASE(ARG_CS_SV_DC, "f2", ftos(f2)) \ + ARG_CASE(ARG_CS_SV, "f3", ftos(f3)) \ + ARG_CASE(ARG_CS_SV, "f4", ftos(f4)) \ + ARG_CASE(ARG_CS_SV, "f1p2dec", ftos_decimals(f1/100, 2)) \ + ARG_CASE(ARG_CS_SV, "f2p2dec", ftos_decimals(f2/100, 2)) \ + ARG_CASE(ARG_CS, "f2primsec", (f2 ? _("secondary") : _("primary"))) \ + ARG_CASE(ARG_CS, "f3primsec", (f3 ? _("secondary") : _("primary"))) \ + ARG_CASE(ARG_CS, "f1secs", count_seconds(f1)) \ + ARG_CASE(ARG_CS, "f1points", (f1 == 1 ? _("point") : _("points"))) \ + ARG_CASE(ARG_CS_SV, "f1ord", count_ordinal(f1)) \ + ARG_CASE(ARG_CS, "f1time", process_time(2, f1)) \ + ARG_CASE(ARG_CS_SV_HA, "f1race_time", mmssss(f1)) \ + ARG_CASE(ARG_CS_SV_HA, "f2race_time", mmssss(f2)) \ + ARG_CASE(ARG_CS_SV_HA, "f3race_time", mmssss(f3)) \ + ARG_CASE(ARG_CS_SV, "race_col", CCR(((f1 == 1) ? "^F1" : "^F2"))) \ + ARG_CASE(ARG_CS_SV, "race_diff", ((f2 > f3) ? sprintf(CCR("^1[+%s]"), mmssss(f2 - f3)) : sprintf(CCR("^2[-%s]"), mmssss(f3 - f2)))) \ + ARG_CASE(ARG_CS, "missing_teams", notif_arg_missing_teams(f1)) \ + ARG_CASE(ARG_CS, "pass_key", ((((tmp_s = getcommandkey("pass", "+use")) != "pass") && !(strstrofs(tmp_s, "not bound", 0) >= 0)) ? sprintf(CCR(_(" ^F1(Press %s)")), tmp_s) : "")) \ + ARG_CASE(ARG_CS, "frag_ping", notif_arg_frag_ping(true, f2)) \ + ARG_CASE(ARG_CS, "frag_stats", notif_arg_frag_stats(f2, f3, f4)) \ + /*ARG_CASE(ARG_CS, "frag_pos", ((Should_Print_Score_Pos(f1)) ? sprintf("\n^BG%s", Read_Score_Pos(f1)) : ""))*/ \ + ARG_CASE(ARG_CS, "spree_cen", (autocvar_notification_show_sprees ? notif_arg_spree_cen(f1) : "")) \ + ARG_CASE(ARG_CS_SV, "spree_inf", (autocvar_notification_show_sprees ? notif_arg_spree_inf(1, input, s2, f2) : "")) \ + ARG_CASE(ARG_CS_SV, "spree_end", (autocvar_notification_show_sprees ? notif_arg_spree_inf(-1, "", "", f1) : "")) \ + ARG_CASE(ARG_CS_SV, "spree_lost", (autocvar_notification_show_sprees ? notif_arg_spree_inf(-2, "", "", f1) : "")) \ + ARG_CASE(ARG_CS_SV, "item_wepname", Weapons_from(f1).m_name) \ + ARG_CASE(ARG_CS_SV, "item_buffname", BUFF_NAME(f1)) \ + ARG_CASE(ARG_CS_SV, "f3buffname", BUFF_NAME(f3)) \ + ARG_CASE(ARG_CS_SV, "item_wepammo", (s1 != "" ? sprintf(_(" with %s"), s1) : "")) \ + ARG_CASE(ARG_DC, "item_centime", ftos(autocvar_notification_item_centerprinttime)) \ + ARG_CASE(ARG_SV, "death_team", Team_ColoredFullName(f1)) \ + ARG_CASE(ARG_CS, "death_team", Team_ColoredFullName(f1 - 1)) \ + ARG_CASE(ARG_CS_SV_HA, "minigame1_name",find(world,netname,s1).descriptor.message) \ + ARG_CASE(ARG_CS_SV_HA, "minigame1_d", find(world,netname,s1).descriptor.netname) #define NOTIF_HIT_MAX(count,funcname) MACRO_BEGIN { \ - if(sel_num == count) { backtrace(sprintf("%s: Hit maximum arguments!\n", funcname)); break; } \ + if(sel_num == count) { backtrace(sprintf("%s: Hit maximum arguments!\n", funcname)); break; } \ } MACRO_END #define NOTIF_HIT_UNKNOWN(token,funcname) { backtrace(sprintf("%s: Hit unknown token in selected string! '%s'\n", funcname, selected)); break; } #define KILL_SPREE_LIST \ - SPREE_ITEM(3, 03, _("TRIPLE FRAG! "), _("%s^K1 made a TRIPLE FRAG! %s^BG"), _("%s^K1 made a TRIPLE SCORE! %s^BG")) \ - SPREE_ITEM(5, 05, _("RAGE! "), _("%s^K1 unlocked RAGE! %s^BG"), _("%s^K1 made FIVE SCORES IN A ROW! %s^BG")) \ - SPREE_ITEM(10, 10, _("MASSACRE! "), _("%s^K1 started a MASSACRE! %s^BG"), _("%s^K1 made TEN SCORES IN A ROW! %s^BG")) \ - SPREE_ITEM(15, 15, _("MAYHEM! "), _("%s^K1 executed MAYHEM! %s^BG"), _("%s^K1 made FIFTEEN SCORES IN A ROW! %s^BG")) \ - SPREE_ITEM(20, 20, _("BERSERKER! "), _("%s^K1 is a BERSERKER! %s^BG"), _("%s^K1 made TWENTY SCORES IN A ROW! %s^BG")) \ - SPREE_ITEM(25, 25, _("CARNAGE! "), _("%s^K1 inflicts CARNAGE! %s^BG"), _("%s^K1 made TWENTY FIVE SCORES IN A ROW! %s^BG")) \ - SPREE_ITEM(30, 30, _("ARMAGEDDON! "), _("%s^K1 unleashes ARMAGEDDON! %s^BG"), _("%s^K1 made THIRTY SCORES IN A ROW! %s^BG")) + SPREE_ITEM(3, 03, _("TRIPLE FRAG! "), _("%s^K1 made a TRIPLE FRAG! %s^BG"), _("%s^K1 made a TRIPLE SCORE! %s^BG")) \ + SPREE_ITEM(5, 05, _("RAGE! "), _("%s^K1 unlocked RAGE! %s^BG"), _("%s^K1 made FIVE SCORES IN A ROW! %s^BG")) \ + SPREE_ITEM(10, 10, _("MASSACRE! "), _("%s^K1 started a MASSACRE! %s^BG"), _("%s^K1 made TEN SCORES IN A ROW! %s^BG")) \ + SPREE_ITEM(15, 15, _("MAYHEM! "), _("%s^K1 executed MAYHEM! %s^BG"), _("%s^K1 made FIFTEEN SCORES IN A ROW! %s^BG")) \ + SPREE_ITEM(20, 20, _("BERSERKER! "), _("%s^K1 is a BERSERKER! %s^BG"), _("%s^K1 made TWENTY SCORES IN A ROW! %s^BG")) \ + SPREE_ITEM(25, 25, _("CARNAGE! "), _("%s^K1 inflicts CARNAGE! %s^BG"), _("%s^K1 made TWENTY FIVE SCORES IN A ROW! %s^BG")) \ + SPREE_ITEM(30, 30, _("ARMAGEDDON! "), _("%s^K1 unleashes ARMAGEDDON! %s^BG"), _("%s^K1 made THIRTY SCORES IN A ROW! %s^BG")) #ifdef CSQC -string notif_arg_frag_ping(float newline, float fping) +string notif_arg_frag_ping(bool newline, float fping) { - if(fping == NO_MSG_) - return sprintf(CCR(_("%s(^F1Bot^BG)")), (newline ? "\n" : " ")); - else - return sprintf(CCR(_("%s(Ping ^F1%d^BG)")), (newline ? "\n" : " "), fping); + string s = newline ? "\n" : " "; + if (fping == NO_MSG_) + return sprintf(CCR(_("%s(^F1Bot^BG)")), s); + else + return sprintf(CCR(_("%s(Ping ^F1%d^BG)")), s, fping); } string notif_arg_frag_stats(float fhealth, float farmor, float fping) { - if (!(fhealth < 1)) - return sprintf(CCR(_("\n(Health ^1%d^BG / Armor ^2%d^BG)%s")), fhealth, farmor, notif_arg_frag_ping(false, fping)); - else - return sprintf(CCR(_("\n(^F4Dead^BG)%s")), notif_arg_frag_ping(false, fping)); + string s = notif_arg_frag_ping(false, fping); + if (fhealth > 1) + return sprintf(CCR(_("\n(Health ^1%d^BG / Armor ^2%d^BG)%s")), fhealth, farmor, s); + else + return sprintf(CCR(_("\n(^F4Dead^BG)%s")), s); } string notif_arg_missing_teams(float f1) { - return sprintf("%s%s%s%s", - ((f1 & 1) ? - sprintf("%s%s", Team_ColoredFullName(NUM_TEAM_1), ((f1 & (2 + 4 + 8)) ? ", " : "")) - : - "" - ), - ((f1 & 2) ? - sprintf("%s%s", Team_ColoredFullName(NUM_TEAM_2), ((f1 & (4 + 8)) ? ", " : "")) - : - "" - ), - ((f1 & 4) ? - sprintf("%s%s", Team_ColoredFullName(NUM_TEAM_3), ((f1 & 8) ? ", " : "")) - : - "" - ), - ((f1 & 8) ? - Team_ColoredFullName(NUM_TEAM_4) - : - "" - ) - ); + return sprintf("%s%s%s%s", + ((f1 & BIT(0)) ? sprintf("%s%s", Team_ColoredFullName(NUM_TEAM_1), (f1 & (BIT(1) | BIT(2) | BIT(3)) ? ", " : "")) : ""), + ((f1 & BIT(1)) ? sprintf("%s%s", Team_ColoredFullName(NUM_TEAM_2), (f1 & ( BIT(2) | BIT(3)) ? ", " : "")) : ""), + ((f1 & BIT(2)) ? sprintf("%s%s", Team_ColoredFullName(NUM_TEAM_3), (f1 & ( BIT(3)) ? ", " : "")) : ""), + ((f1 & BIT(3)) ? Team_ColoredFullName(NUM_TEAM_4) : "") + ); } string notif_arg_spree_cen(float spree) { - // 0 = off, 1 = target (but only for first victim) and attacker - if(autocvar_notification_show_sprees_center) - { - if(spree > 1) - { - #define SPREE_ITEM(counta,countb,center,normal,gentle) \ - case counta: { return normal_or_gentle(center, sprintf(_("%d score spree! "), spree)); } - - switch(spree) - { - KILL_SPREE_LIST - default: - { - if (!autocvar_notification_show_sprees_center_specialonly) - { - return - sprintf( - normal_or_gentle( - _("%d frag spree! "), - _("%d score spree! ") - ), - spree); - } - else { return ""; } // don't show spree information if it isn't an achievement - } - } - - #undef SPREE_ITEM - } - else if(spree == -1) // first blood - { - return normal_or_gentle(_("First blood! "), _("First score! ")); - } - else if(spree == -2) // first victim - { - return normal_or_gentle(_("First victim! "), _("First casualty! ")); - } - } - return ""; + // 0 = off, 1 = target (but only for first victim) and attacker + if(autocvar_notification_show_sprees_center) + { + if(spree > 1) + { + #define SPREE_ITEM(counta,countb,center,normal,gentle) \ + case counta: { return normal_or_gentle(center, sprintf(_("%d score spree! "), spree)); } + + switch(spree) + { + KILL_SPREE_LIST + default: + { + if (!autocvar_notification_show_sprees_center_specialonly) + { + return + sprintf( + normal_or_gentle( + _("%d frag spree! "), + _("%d score spree! ") + ), + spree); + } + else { return ""; } // don't show spree information if it isn't an achievement + } + } + + #undef SPREE_ITEM + } + else if(spree == -1) // first blood + { + return normal_or_gentle(_("First blood! "), _("First score! ")); + } + else if(spree == -2) // first victim + { + return normal_or_gentle(_("First victim! "), _("First casualty! ")); + } + } + return ""; } #endif string notif_arg_spree_inf(float type, string input, string player, float spree) { - switch(type) - { - case 1: // attacker kill spree - { - // 0 = off, 1 = target only, 2 = attacker only, 3 = target and attacker - // this conditional (& 2) is true for 2 and 3 - if(autocvar_notification_show_sprees_info & 2) - { - #ifdef CSQC - string spree_newline = - ( autocvar_notification_show_sprees_info_newline ? - ((substring(input, 0, 1) == "\{3}") ? "\n\{3}" : "\n") : "" ); - #else - string spree_newline = - (autocvar_notification_show_sprees_info_newline ? "\n" : ""); - #endif - - if(spree > 1) - { - #define SPREE_ITEM(counta,countb,center,normal,gentle) \ - case counta: { return sprintf(CCR(normal_or_gentle(normal, gentle)), player, spree_newline); } - - switch(spree) - { - KILL_SPREE_LIST - default: - { - if (!autocvar_notification_show_sprees_info_specialonly) - { - return - sprintf( - CCR(normal_or_gentle( - _("%s^K1 has %d frags in a row! %s^BG"), - _("%s^K1 made %d scores in a row! %s^BG") - )), - player, - spree, - spree_newline - ); - } - else { return ""; } // don't show spree information if it isn't an achievement - } - } - - #undef SPREE_ITEM - } - else if(spree == -1) // firstblood - { - return - sprintf( - CCR(normal_or_gentle( - _("%s^K1 drew first blood! %s^BG"), - _("%s^K1 got the first score! %s^BG") - )), - player, - spree_newline - ); - } - } - break; - } - - case -1: // kill spree ended - { - if((spree > 1) && (autocvar_notification_show_sprees_info & 1)) - { - return - sprintf(normal_or_gentle( - _(", ending their %d frag spree"), - _(", ending their %d score spree") - ), - spree - ); - } - break; - } - - case -2: // kill spree lost - { - if((spree > 1) && (autocvar_notification_show_sprees_info & 1)) - { - return - sprintf(normal_or_gentle( - _(", losing their %d frag spree"), - _(", losing their %d score spree") - ), - spree - ); - } - break; - } - } - return ""; + switch(type) + { + case 1: // attacker kill spree + { + // 0 = off, 1 = target only, 2 = attacker only, 3 = target and attacker + // this conditional (& 2) is true for 2 and 3 + if(autocvar_notification_show_sprees_info & 2) + { + #ifdef CSQC + string spree_newline = + ( autocvar_notification_show_sprees_info_newline ? + ((substring(input, 0, 1) == "\{3}") ? "\n\{3}" : "\n") : "" ); + #else + string spree_newline = + (autocvar_notification_show_sprees_info_newline ? "\n" : ""); + #endif + + if(spree > 1) + { + #define SPREE_ITEM(counta,countb,center,normal,gentle) \ + case counta: { return sprintf(CCR(normal_or_gentle(normal, gentle)), player, spree_newline); } + + switch(spree) + { + KILL_SPREE_LIST + default: + { + if (!autocvar_notification_show_sprees_info_specialonly) + { + return + sprintf( + CCR(normal_or_gentle( + _("%s^K1 has %d frags in a row! %s^BG"), + _("%s^K1 made %d scores in a row! %s^BG") + )), + player, + spree, + spree_newline + ); + } + else { return ""; } // don't show spree information if it isn't an achievement + } + } + + #undef SPREE_ITEM + } + else if(spree == -1) // firstblood + { + return + sprintf( + CCR(normal_or_gentle( + _("%s^K1 drew first blood! %s^BG"), + _("%s^K1 got the first score! %s^BG") + )), + player, + spree_newline + ); + } + } + break; + } + + case -1: // kill spree ended + { + if((spree > 1) && (autocvar_notification_show_sprees_info & 1)) + { + return + sprintf(normal_or_gentle( + _(", ending their %d frag spree"), + _(", ending their %d score spree") + ), + spree + ); + } + break; + } + + case -2: // kill spree lost + { + if((spree > 1) && (autocvar_notification_show_sprees_info & 1)) + { + return + sprintf(normal_or_gentle( + _(", losing their %d frag spree"), + _(", losing their %d score spree") + ), + spree + ); + } + break; + } + } + return ""; } @@ -558,7 +593,7 @@ string notif_arg_spree_inf(float type, string input, string player, float spree) // ==================================== enum { - NO_CPID + NO_CPID , CPID_ASSAULT_ROLE , CPID_ROUND , CPID_CAMPCHECK @@ -593,26 +628,41 @@ enum { , NOTIF_CPID_COUNT }; // notification counts -const float NOTIF_FIRST = 1; -float NOTIF_ANNCE_COUNT; -float NOTIF_INFO_COUNT; -float NOTIF_CENTER_COUNT; -float NOTIF_MULTI_COUNT; -float NOTIF_CHOICE_COUNT; +/** @deprecated */ +const int NOTIF_FIRST = 1; +int NOTIF_ANNCE_COUNT; +int NOTIF_INFO_COUNT; +int NOTIF_CENTER_COUNT; +int NOTIF_MULTI_COUNT; +int NOTIF_CHOICE_COUNT; // notification limits -- INCREASE AS NECESSARY -const float NOTIF_ANNCE_MAX = 400; -const float NOTIF_INFO_MAX = 450; -const float NOTIF_CENTER_MAX = 350; -const float NOTIF_MULTI_MAX = 300; -const float NOTIF_CHOICE_MAX = 50; +const int NOTIF_ANNCE_MAX = 400; +const int NOTIF_INFO_MAX = 450; +const int NOTIF_CENTER_MAX = 350; +const int NOTIF_MULTI_MAX = 300; +const int NOTIF_CHOICE_MAX = 50; // notification entities -entity msg_annce_notifs[NOTIF_ANNCE_MAX]; -entity msg_info_notifs[NOTIF_INFO_MAX]; -entity msg_center_notifs[NOTIF_CENTER_MAX]; -entity msg_multi_notifs[NOTIF_MULTI_MAX]; -entity msg_choice_notifs[NOTIF_CHOICE_MAX]; +Notification msg_annce_notifs[NOTIF_ANNCE_MAX]; +Notification msg_info_notifs[NOTIF_INFO_MAX]; +Notification msg_center_notifs[NOTIF_CENTER_MAX]; +Notification msg_multi_notifs[NOTIF_MULTI_MAX]; +Notification msg_choice_notifs[NOTIF_CHOICE_MAX]; + +Notification Get_Notif_Ent(int net_type, int net_name) +{ + switch (net_type) + { + case MSG_ANNCE: return msg_annce_notifs[net_name - 1]; + case MSG_INFO: return msg_info_notifs[net_name - 1]; + case MSG_CENTER: return msg_center_notifs[net_name - 1]; + case MSG_MULTI: return msg_multi_notifs[net_name - 1]; + case MSG_CHOICE: return msg_choice_notifs[net_name - 1]; + } + backtrace(sprintf("Get_Notif_Ent(%d, %d): Improper net type!\n", net_type, net_name)); + return NULL; +} // common notification entity values .float nent_default; @@ -659,159 +709,159 @@ entity msg_choice_notifs[NOTIF_CHOICE_MAX]; .float nent_floats[4]; // other notification properties -.float msg_choice_choices[NOTIF_CHOICE_MAX]; // set on each player containing MSG_CHOICE choices +.int msg_choice_choices[NOTIF_CHOICE_MAX]; // set on each player containing MSG_CHOICE choices #define ACVNN(name) autocvar_notification_##name // initialization error detection -float notif_error; -float notif_global_error; +bool notif_error; +bool notif_global_error; #define MSG_ANNCE_NOTIF(name, default, sound, channel, volume, position) \ - MSG_ANNCE_NOTIF_(ANNCE_##name, default, sound, channel, volume, position) + MSG_ANNCE_NOTIF_(ANNCE_##name, default, sound, channel, volume, position) #define MSG_ANNCE_NOTIF_(name, default, sound, channel, volume, position) \ - NOTIF_ADD_AUTOCVAR(name, default) \ - Notification name; \ - void RegisterNotification_##name() \ - { \ - int name##_ = 0; \ - SET_FIELD_COUNT(name##_, NOTIF_FIRST, NOTIF_ANNCE_COUNT) \ - CHECK_MAX_COUNT(name##_, NOTIF_ANNCE_MAX, NOTIF_ANNCE_COUNT, "MSG_ANNCE") \ - entity this = name = msg_annce_notifs[name##_ - 1] = new_pure(msg_annce_notification); \ - Create_Notification_Entity (this, default, ACVNN(name), MSG_ANNCE, name##_, strtoupper(#name)); \ - Create_Notification_Entity_Annce(this, ACVNN(name), strtoupper(#name), \ - channel, /* channel */ \ - sound, /* snd */ \ - volume, /* vol */ \ - position); /* position */ \ - } \ - ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name) + NOTIF_ADD_AUTOCVAR(name, default) \ + Notification name; \ + void RegisterNotification_##name() \ + { \ + int name##_ = 0; \ + SET_FIELD_COUNT(name##_, NOTIF_FIRST, NOTIF_ANNCE_COUNT) \ + CHECK_MAX_COUNT(name##_, NOTIF_ANNCE_MAX, NOTIF_ANNCE_COUNT, "MSG_ANNCE") \ + entity this = name = msg_annce_notifs[name##_ - 1] = new_pure(msg_annce_notification); \ + Create_Notification_Entity (this, default, ACVNN(name), MSG_ANNCE, name##_, strtoupper(#name)); \ + Create_Notification_Entity_Annce(this, ACVNN(name), strtoupper(#name), \ + channel, /* channel */ \ + sound, /* snd */ \ + volume, /* vol */ \ + position); /* position */ \ + } \ + ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name) #define MSG_INFO_NOTIF(name, default, strnum, flnum, args, hudargs, icon, normal, gentle) \ - MSG_INFO_NOTIF_(INFO_##name, default, strnum, flnum, args, hudargs, icon, normal, gentle) + MSG_INFO_NOTIF_(INFO_##name, default, strnum, flnum, args, hudargs, icon, normal, gentle) #define MSG_INFO_NOTIF_(name, default, strnum, flnum, args, hudargs, icon, normal, gentle) \ - NOTIF_ADD_AUTOCVAR(name, default) \ - Notification name; \ - void RegisterNotification_##name() \ - { \ - int name##_ = 0; \ - SET_FIELD_COUNT(name##_, NOTIF_FIRST, NOTIF_INFO_COUNT) \ - CHECK_MAX_COUNT(name##_, NOTIF_INFO_MAX, NOTIF_INFO_COUNT, "MSG_INFO") \ - entity this = name = msg_info_notifs[name##_ - 1] = new_pure(msg_info_notification); \ - Create_Notification_Entity (this, default, ACVNN(name), MSG_INFO, name##_, strtoupper(#name)); \ - Create_Notification_Entity_InfoCenter(this, ACVNN(name), strtoupper(#name), strnum, flnum, \ - args, /* args */ \ - hudargs, /* hudargs */ \ - icon, /* icon */ \ - NO_MSG_, /* cpid */ \ - "", /* durcnt */ \ - normal, /* normal */ \ - gentle); /* gentle */ \ - } \ - ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name) + NOTIF_ADD_AUTOCVAR(name, default) \ + Notification name; \ + void RegisterNotification_##name() \ + { \ + int name##_ = 0; \ + SET_FIELD_COUNT(name##_, NOTIF_FIRST, NOTIF_INFO_COUNT) \ + CHECK_MAX_COUNT(name##_, NOTIF_INFO_MAX, NOTIF_INFO_COUNT, "MSG_INFO") \ + entity this = name = msg_info_notifs[name##_ - 1] = new_pure(msg_info_notification); \ + Create_Notification_Entity (this, default, ACVNN(name), MSG_INFO, name##_, strtoupper(#name)); \ + Create_Notification_Entity_InfoCenter(this, ACVNN(name), strtoupper(#name), strnum, flnum, \ + args, /* args */ \ + hudargs, /* hudargs */ \ + icon, /* icon */ \ + NO_MSG_, /* cpid */ \ + "", /* durcnt */ \ + normal, /* normal */ \ + gentle); /* gentle */ \ + } \ + ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name) .string nent_iconargs; #define MULTIICON_INFO(name, default, strnum, flnum, args, hudargs, iconargs, icon, normal, gentle) \ - MULTIICON_INFO_(INFO_##name, default, strnum, flnum, args, hudargs, iconargs, icon, normal, gentle) + MULTIICON_INFO_(INFO_##name, default, strnum, flnum, args, hudargs, iconargs, icon, normal, gentle) #define MULTIICON_INFO_(name, default, strnum, flnum, args, hudargs, iconargs, icon, normal, gentle) \ - NOTIF_ADD_AUTOCVAR(name, default) \ - Notification name; \ - void RegisterNotification_##name() \ - { \ - int name##_ = 0; \ - SET_FIELD_COUNT(name##_, NOTIF_FIRST, NOTIF_INFO_COUNT) \ - CHECK_MAX_COUNT(name##_, NOTIF_INFO_MAX, NOTIF_INFO_COUNT, "MSG_INFO") \ - entity this = name = msg_info_notifs[name##_ - 1] = new_pure(msg_info_notification); \ - Create_Notification_Entity (this, default, ACVNN(name), MSG_INFO, name##_, strtoupper(#name)); \ - Create_Notification_Entity_InfoCenter(this, ACVNN(name), strtoupper(#name), strnum, flnum, \ - args, /* args */ \ - hudargs, /* hudargs */ \ - icon, /* icon */ \ - NO_MSG_, /* cpid */ \ - "", /* durcnt */ \ - normal, /* normal */ \ - gentle); /* gentle */ \ - this.nent_iconargs = iconargs; \ - } \ - ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name) + NOTIF_ADD_AUTOCVAR(name, default) \ + Notification name; \ + void RegisterNotification_##name() \ + { \ + int name##_ = 0; \ + SET_FIELD_COUNT(name##_, NOTIF_FIRST, NOTIF_INFO_COUNT) \ + CHECK_MAX_COUNT(name##_, NOTIF_INFO_MAX, NOTIF_INFO_COUNT, "MSG_INFO") \ + entity this = name = msg_info_notifs[name##_ - 1] = new_pure(msg_info_notification); \ + Create_Notification_Entity (this, default, ACVNN(name), MSG_INFO, name##_, strtoupper(#name)); \ + Create_Notification_Entity_InfoCenter(this, ACVNN(name), strtoupper(#name), strnum, flnum, \ + args, /* args */ \ + hudargs, /* hudargs */ \ + icon, /* icon */ \ + NO_MSG_, /* cpid */ \ + "", /* durcnt */ \ + normal, /* normal */ \ + gentle); /* gentle */ \ + this.nent_iconargs = iconargs; \ + } \ + ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name) #define MSG_CENTER_NOTIF(name, default, strnum, flnum, args, cpid, durcnt, normal, gentle) \ - MSG_CENTER_NOTIF_(CENTER_##name, default, strnum, flnum, args, cpid, durcnt, normal, gentle) + MSG_CENTER_NOTIF_(CENTER_##name, default, strnum, flnum, args, cpid, durcnt, normal, gentle) #define MSG_CENTER_NOTIF_(name, default, strnum, flnum, args, cpid, durcnt, normal, gentle) \ - NOTIF_ADD_AUTOCVAR(name, default) \ - Notification name; \ - void RegisterNotification_##name() \ - { \ - int name##_ = 0; \ - SET_FIELD_COUNT(name##_, NOTIF_FIRST, NOTIF_CENTER_COUNT) \ - CHECK_MAX_COUNT(name##_, NOTIF_CENTER_MAX, NOTIF_CENTER_COUNT, "MSG_CENTER") \ - entity this = name = msg_center_notifs[name##_ - 1] = new_pure(msg_center_notification); \ - Create_Notification_Entity (this, default, ACVNN(name), MSG_CENTER, name##_, strtoupper(#name)); \ - Create_Notification_Entity_InfoCenter(this, ACVNN(name), strtoupper(#name), strnum, flnum, \ - args, /* args */ \ - "", /* hudargs */ \ - "", /* icon */ \ - cpid, /* cpid */ \ - durcnt, /* durcnt */ \ - normal, /* normal */ \ - gentle); /* gentle */ \ - } \ - ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name) + NOTIF_ADD_AUTOCVAR(name, default) \ + Notification name; \ + void RegisterNotification_##name() \ + { \ + int name##_ = 0; \ + SET_FIELD_COUNT(name##_, NOTIF_FIRST, NOTIF_CENTER_COUNT) \ + CHECK_MAX_COUNT(name##_, NOTIF_CENTER_MAX, NOTIF_CENTER_COUNT, "MSG_CENTER") \ + entity this = name = msg_center_notifs[name##_ - 1] = new_pure(msg_center_notification); \ + Create_Notification_Entity (this, default, ACVNN(name), MSG_CENTER, name##_, strtoupper(#name)); \ + Create_Notification_Entity_InfoCenter(this, ACVNN(name), strtoupper(#name), strnum, flnum, \ + args, /* args */ \ + "", /* hudargs */ \ + "", /* icon */ \ + cpid, /* cpid */ \ + durcnt, /* durcnt */ \ + normal, /* normal */ \ + gentle); /* gentle */ \ + } \ + ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name) #define MSG_MULTI_NOTIF(name, default, anncename, infoname, centername) \ - NOTIF_ADD_AUTOCVAR(name, default) \ - Notification name; \ - void RegisterNotification_##name() \ - { \ - int name##_ = 0; \ - SET_FIELD_COUNT(name##_, NOTIF_FIRST, NOTIF_MULTI_COUNT) \ - CHECK_MAX_COUNT(name##_, NOTIF_MULTI_MAX, NOTIF_MULTI_COUNT, "MSG_MULTI") \ - entity this = name = msg_multi_notifs[name##_ - 1] = new_pure(msg_multi_notification); \ - Create_Notification_Entity (this, default, ACVNN(name), MSG_MULTI, name##_, strtoupper(#name)); \ - Create_Notification_Entity_Multi(this, ACVNN(name), strtoupper(#name), \ - anncename, /* anncename */ \ - infoname, /* infoname */ \ - centername); /* centername */ \ - } \ - ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name) + NOTIF_ADD_AUTOCVAR(name, default) \ + Notification name; \ + void RegisterNotification_##name() \ + { \ + int name##_ = 0; \ + SET_FIELD_COUNT(name##_, NOTIF_FIRST, NOTIF_MULTI_COUNT) \ + CHECK_MAX_COUNT(name##_, NOTIF_MULTI_MAX, NOTIF_MULTI_COUNT, "MSG_MULTI") \ + entity this = name = msg_multi_notifs[name##_ - 1] = new_pure(msg_multi_notification); \ + Create_Notification_Entity (this, default, ACVNN(name), MSG_MULTI, name##_, strtoupper(#name)); \ + Create_Notification_Entity_Multi(this, ACVNN(name), strtoupper(#name), \ + anncename, /* anncename */ \ + infoname, /* infoname */ \ + centername); /* centername */ \ + } \ + ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name) #define MSG_CHOICE_NOTIF(name, default, challow, chtype, optiona, optionb) \ - MSG_CHOICE_NOTIF_(CHOICE_##name, default, challow, chtype, optiona, optionb) + MSG_CHOICE_NOTIF_(CHOICE_##name, default, challow, chtype, optiona, optionb) #define MSG_CHOICE_NOTIF_(name, default, challow, chtype, optiona, optionb) \ - NOTIF_ADD_AUTOCVAR(name, default) \ - NOTIF_ADD_AUTOCVAR(name##_ALLOWED, challow) \ - Notification name; \ - void RegisterNotification_##name() \ - { \ - int name##_ = 0; \ - SET_FIELD_COUNT(name##_, NOTIF_FIRST, NOTIF_CHOICE_COUNT) \ - CHECK_MAX_COUNT(name##_, NOTIF_CHOICE_MAX, NOTIF_CHOICE_COUNT, "MSG_CHOICE") \ - entity this = name = msg_choice_notifs[name##_ - 1] = new_pure(msg_choice_notification); \ - Create_Notification_Entity (this, default, ACVNN(name), MSG_CHOICE, name##_, strtoupper(#name)); \ - Create_Notification_Entity_Choice(this, ACVNN(name), strtoupper(#name), \ - challow, /* challow_def */ \ - autocvar_notification_##name##_ALLOWED, /* challow_var */ \ - chtype, /* chtype */ \ - optiona, /* optiona */ \ - optionb); /* optionb */ \ - } \ - ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name) + NOTIF_ADD_AUTOCVAR(name, default) \ + NOTIF_ADD_AUTOCVAR(name##_ALLOWED, challow) \ + Notification name; \ + void RegisterNotification_##name() \ + { \ + int name##_ = 0; \ + SET_FIELD_COUNT(name##_, NOTIF_FIRST, NOTIF_CHOICE_COUNT) \ + CHECK_MAX_COUNT(name##_, NOTIF_CHOICE_MAX, NOTIF_CHOICE_COUNT, "MSG_CHOICE") \ + entity this = name = msg_choice_notifs[name##_ - 1] = new_pure(msg_choice_notification); \ + Create_Notification_Entity (this, default, ACVNN(name), MSG_CHOICE, name##_, strtoupper(#name)); \ + Create_Notification_Entity_Choice(this, ACVNN(name), strtoupper(#name), \ + challow, /* challow_def */ \ + autocvar_notification_##name##_ALLOWED, /* challow_var */ \ + chtype, /* chtype */ \ + optiona, /* optiona */ \ + optionb); /* optionb */ \ + } \ + ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name) void RegisterNotifications_First() { - notif_global_error = false; + notif_global_error = false; } void RegisterNotifications_Done() { - if(notif_global_error) - { - // shit happened... stop the loading of the program now if this is unacceptable - if(autocvar_notification_errors_are_fatal) - LOG_FATAL("Notification initialization failed! Read above and fix the errors!\n"); - else - LOG_SEVERE("Notification initialization failed! Read above and fix the errors!\n"); - } + if(notif_global_error) + { + // shit happened... stop the loading of the program now if this is unacceptable + if(autocvar_notification_errors_are_fatal) + LOG_FATAL("Notification initialization failed! Read above and fix the errors!\n"); + else + LOG_SEVERE("Notification initialization failed! Read above and fix the errors!\n"); + } } // NOW we actually activate the declarations diff --git a/qcsrc/common/teams.qh b/qcsrc/common/teams.qh index f75ae1f02..0c0dd7568 100644 --- a/qcsrc/common/teams.qh +++ b/qcsrc/common/teams.qh @@ -164,9 +164,4 @@ float Team_TeamToNumber(float teamid) #define SAME_TEAM(a,b) (teamplay ? (a.team == b.team) : (a == b)) #define DIFF_TEAM(a,b) (teamplay ? (a.team != b.team) : (a != b)) -// used for notification system multi-team identifiers -#define APP_TEAM_NUM_2(num,prefix) ((num == NUM_TEAM_1) ? prefix##RED : prefix##BLUE) -#define APP_TEAM_NUM_4(num,prefix) ((num == NUM_TEAM_1) ? prefix##RED : ((num == NUM_TEAM_2) ? prefix##BLUE : ((num == NUM_TEAM_3) ? prefix##YELLOW : prefix##PINK))) -#define APP_TEAM_ENT_2(ent,prefix) ((ent.team == NUM_TEAM_1) ? prefix##RED : prefix##BLUE) -#define APP_TEAM_ENT_4(ent,prefix) ((ent.team == NUM_TEAM_1) ? prefix##RED : ((ent.team == NUM_TEAM_2) ? prefix##BLUE : ((ent.team == NUM_TEAM_3) ? prefix##YELLOW : prefix##PINK))) #endif diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index e683a4e24..22acf030d 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -906,7 +906,7 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2 self.killindicator.colormod = Team_ColorRGB(targetteam); if(IS_REAL_CLIENT(self)) if(self.killindicator.cnt > 0) - Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, APP_TEAM_NUM_4(targetteam, CENTER_TEAMCHANGE_), self.killindicator.cnt); + Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, APP_TEAM_NUM(targetteam, CENTER_TEAMCHANGE), self.killindicator.cnt); } } @@ -1078,7 +1078,7 @@ void ClientConnect() this.netname_previous = strzone(this.netname); - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && IS_PLAYER(this)) ? APP_TEAM_ENT_4(this, INFO_JOIN_CONNECT_TEAM_) : INFO_JOIN_CONNECT), this.netname); + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && IS_PLAYER(this)) ? APP_TEAM_ENT(this, INFO_JOIN_CONNECT_TEAM) : INFO_JOIN_CONNECT), this.netname); stuffcmd(this, clientstuff, "\n"); stuffcmd(this, "cl_particles_reloadeffects\n"); // TODO do we still need this? @@ -1828,7 +1828,7 @@ void LeaveSpectatorMode() PutClientInServer(); - if(IS_PLAYER(self)) { Send_Notification(NOTIF_ALL, world, MSG_INFO, ((teamplay && this.team != -1) ? APP_TEAM_ENT_4(this, INFO_JOIN_PLAY_TEAM_) : INFO_JOIN_PLAY), self.netname); } + if(IS_PLAYER(self)) { Send_Notification(NOTIF_ALL, world, MSG_INFO, ((teamplay && this.team != -1) ? APP_TEAM_ENT(this, INFO_JOIN_PLAY_TEAM) : INFO_JOIN_PLAY), self.netname); } } else stuffcmd(self, "menu_showteamselect\n"); diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index c897966aa..a76100038 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -180,7 +180,7 @@ void ClientCommand_join(float request) self.classname = STR_PLAYER; PlayerScore_Clear(self); Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_PREVENT_JOIN); - Send_Notification(NOTIF_ALL, world, MSG_INFO, ((teamplay && self.team != -1) ? APP_TEAM_ENT_4(this, INFO_JOIN_PLAY_TEAM_) : INFO_JOIN_PLAY), self.netname); + Send_Notification(NOTIF_ALL, world, MSG_INFO, ((teamplay && self.team != -1) ? APP_TEAM_ENT(this, INFO_JOIN_PLAY_TEAM) : INFO_JOIN_PLAY), self.netname); PutClientInServer(); } else diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index e73f80a68..a76550319 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -238,11 +238,12 @@ float Obituary_WeaponDeath( s1, s2, s3, "", f1, f2, 0, 0 ); + // send the info part to everyone Send_Notification_WOCOVA( NOTIF_ALL_EXCEPT, notif_target, MSG_INFO, - msg_multi_notifs[death_message.nent_id - 1].nent_msginfo, + death_message.nent_msginfo, s1, s2, s3, "", f1, f2, 0, 0 ); @@ -342,7 +343,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype) Send_Notification(NOTIF_ONE, attacker, MSG_CENTER, CENTER_DEATH_TEAMKILL_FRAG, targ.netname); Send_Notification(NOTIF_ONE, targ, MSG_CENTER, CENTER_DEATH_TEAMKILL_FRAGGED, attacker.netname); - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(targ.team, INFO_DEATH_TEAMKILL_), targ.netname, attacker.netname, deathlocation, targ.killcount); + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM(targ.team, INFO_DEATH_TEAMKILL), targ.netname, attacker.netname, deathlocation, targ.killcount); // In this case, the death message will ALWAYS be "foo was betrayed by bar" // No need for specific death/weapon messages... diff --git a/qcsrc/server/mutators/mutator/gamemode_ca.qc b/qcsrc/server/mutators/mutator/gamemode_ca.qc index c43eb88e0..0985b9c81 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ca.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ca.qc @@ -120,8 +120,8 @@ float CA_CheckWinner() int winner_team = CA_GetWinnerTeam(); if(winner_team > 0) { - Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM_4(winner_team, CENTER_ROUND_TEAM_WIN_)); - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(winner_team, INFO_ROUND_TEAM_WIN_)); + Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN)); + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN)); TeamScore_AddToTeam(winner_team, ST_CA_ROUNDS, +1); } else if(winner_team == -1) diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc index a8d2df201..eb650cbc3 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc @@ -310,9 +310,9 @@ void ctf_CaptureRecord(entity flag, entity player) // notify about shit if(ctf_oneflag) { Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_CTF_CAPTURE_NEUTRAL, player.netname); } - else if(!ctf_captimerecord) { Send_Notification(NOTIF_ALL, world, MSG_CHOICE, APP_TEAM_ENT_4(flag, CHOICE_CTF_CAPTURE_TIME_), player.netname, (cap_time * 100)); } - else if(cap_time < cap_record) { Send_Notification(NOTIF_ALL, world, MSG_CHOICE, APP_TEAM_ENT_4(flag, CHOICE_CTF_CAPTURE_BROKEN_), player.netname, refername, (cap_time * 100), (cap_record * 100)); } - else { Send_Notification(NOTIF_ALL, world, MSG_CHOICE, APP_TEAM_ENT_4(flag, CHOICE_CTF_CAPTURE_UNBROKEN_), player.netname, refername, (cap_time * 100), (cap_record * 100)); } + else if(!ctf_captimerecord) { Send_Notification(NOTIF_ALL, world, MSG_CHOICE, APP_TEAM_ENT(flag, CHOICE_CTF_CAPTURE_TIME), player.netname, (cap_time * 100)); } + else if(cap_time < cap_record) { Send_Notification(NOTIF_ALL, world, MSG_CHOICE, APP_TEAM_ENT(flag, CHOICE_CTF_CAPTURE_BROKEN), player.netname, refername, (cap_time * 100), (cap_record * 100)); } + else { Send_Notification(NOTIF_ALL, world, MSG_CHOICE, APP_TEAM_ENT(flag, CHOICE_CTF_CAPTURE_UNBROKEN), player.netname, refername, (cap_time * 100), (cap_record * 100)); } // write that shit in the database if(!ctf_oneflag) // but not in 1-flag mode @@ -510,7 +510,7 @@ void ctf_Handle_Drop(entity flag, entity player, int droptype) flag.ctf_status = FLAG_DROPPED; // messages and sounds - Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT_4(flag, INFO_CTF_LOST_) : INFO_CTF_LOST_NEUTRAL), player.netname); + Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT(flag, INFO_CTF_LOST) : INFO_CTF_LOST_NEUTRAL), player.netname); _sound(flag, CH_TRIGGER, flag.snd_flag_dropped, VOL_BASE, ATTEN_NONE); ctf_EventLog("dropped", player.team, player); @@ -572,11 +572,11 @@ void ctf_Handle_Retrieve(entity flag, entity player) FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA( if(it == sender) - Send_Notification(NOTIF_ONE, it, MSG_CENTER, ((flag.team) ? APP_TEAM_ENT_4(flag, CENTER_CTF_PASS_SENT_) : CENTER_CTF_PASS_SENT_NEUTRAL), player.netname); + Send_Notification(NOTIF_ONE, it, MSG_CENTER, ((flag.team) ? APP_TEAM_ENT(flag, CENTER_CTF_PASS_SENT) : CENTER_CTF_PASS_SENT_NEUTRAL), player.netname); else if(it == player) - Send_Notification(NOTIF_ONE, it, MSG_CENTER, ((flag.team) ? APP_TEAM_ENT_4(flag, CENTER_CTF_PASS_RECEIVED_) : CENTER_CTF_PASS_RECEIVED_NEUTRAL), sender.netname); + Send_Notification(NOTIF_ONE, it, MSG_CENTER, ((flag.team) ? APP_TEAM_ENT(flag, CENTER_CTF_PASS_RECEIVED) : CENTER_CTF_PASS_RECEIVED_NEUTRAL), sender.netname); else if(SAME_TEAM(it, sender)) - Send_Notification(NOTIF_ONE, it, MSG_CENTER, ((flag.team) ? APP_TEAM_ENT_4(flag, CENTER_CTF_PASS_OTHER_) : CENTER_CTF_PASS_OTHER_NEUTRAL), sender.netname, player.netname); + Send_Notification(NOTIF_ONE, it, MSG_CENTER, ((flag.team) ? APP_TEAM_ENT(flag, CENTER_CTF_PASS_OTHER) : CENTER_CTF_PASS_OTHER_NEUTRAL), sender.netname, player.netname); )); // create new waypoint @@ -708,7 +708,7 @@ void ctf_Handle_Capture(entity flag, entity toucher, int capturetype) player.throw_count = 0; // messages and sounds - Send_Notification(NOTIF_ONE, player, MSG_CENTER, ((enemy_flag.team) ? APP_TEAM_ENT_4(enemy_flag, CENTER_CTF_CAPTURE_) : CENTER_CTF_CAPTURE_NEUTRAL)); + Send_Notification(NOTIF_ONE, player, MSG_CENTER, ((enemy_flag.team) ? APP_TEAM_ENT(enemy_flag, CENTER_CTF_CAPTURE) : CENTER_CTF_CAPTURE_NEUTRAL)); ctf_CaptureRecord(enemy_flag, player); _sound(player, CH_TRIGGER, ((ctf_oneflag) ? player_team_flag.snd_flag_capture : ((DIFF_TEAM(player, flag)) ? enemy_flag.snd_flag_capture : flag.snd_flag_capture)), VOL_BASE, ATTEN_NONE); @@ -752,12 +752,12 @@ void ctf_Handle_Return(entity flag, entity player) // messages and sounds if(IS_MONSTER(player)) { - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_RETURN_MONSTER_), player.monster_name); + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT(flag, INFO_CTF_RETURN_MONSTER), player.monster_name); } else if(flag.team) { - Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_ENT_4(flag, CENTER_CTF_RETURN_)); - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_RETURN_), player.netname); + Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_ENT(flag, CENTER_CTF_RETURN)); + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT(flag, INFO_CTF_RETURN), player.netname); } _sound(player, CH_TRIGGER, flag.snd_flag_returned, VOL_BASE, ATTEN_NONE); ctf_EventLog("return", flag.team, player); @@ -823,13 +823,13 @@ void ctf_Handle_Pickup(entity flag, entity player, int pickuptype) } // messages and sounds - Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT_4(flag, INFO_CTF_PICKUP_) : INFO_CTF_PICKUP_NEUTRAL), player.netname); + Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT(flag, INFO_CTF_PICKUP) : INFO_CTF_PICKUP_NEUTRAL), player.netname); if(ctf_stalemate) { Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_CTF_STALEMATE_CARRIER); } if(!flag.team) { Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_CTF_PICKUP_NEUTRAL); } - else if(CTF_DIFFTEAM(player, flag)) { Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_ENT_4(flag, CENTER_CTF_PICKUP_)); } + else if(CTF_DIFFTEAM(player, flag)) { Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_ENT(flag, CENTER_CTF_PICKUP)); } else { Send_Notification(NOTIF_ONE, player, MSG_CENTER, ((SAME_TEAM(player, flag)) ? CENTER_CTF_PICKUP_TEAM : CENTER_CTF_PICKUP_TEAM_ENEMY), Team_ColorCode(flag.team)); } - Send_Notification(NOTIF_TEAM_EXCEPT, player, MSG_CHOICE, ((flag.team) ? APP_TEAM_ENT_4(flag, CHOICE_CTF_PICKUP_TEAM_) : CHOICE_CTF_PICKUP_TEAM_NEUTRAL), Team_ColorCode(player.team), player.netname); + Send_Notification(NOTIF_TEAM_EXCEPT, player, MSG_CHOICE, ((flag.team) ? APP_TEAM_ENT(flag, CHOICE_CTF_PICKUP_TEAM) : CHOICE_CTF_PICKUP_TEAM_NEUTRAL), Team_ColorCode(player.team), player.netname); if(!flag.team) FOREACH_CLIENT(IS_PLAYER(it) && it != player && DIFF_TEAM(it, player), LAMBDA(Send_Notification(NOTIF_ONE, it, MSG_CHOICE, CHOICE_CTF_PICKUP_ENEMY_NEUTRAL, Team_ColorCode(player.team), player.netname))); @@ -838,7 +838,7 @@ void ctf_Handle_Pickup(entity flag, entity player, int pickuptype) FOREACH_CLIENT(IS_PLAYER(it) && it != player, LAMBDA( if(CTF_SAMETEAM(flag, it)) if(SAME_TEAM(player, it)) - Send_Notification(NOTIF_ONE, it, MSG_CHOICE, APP_TEAM_ENT_4(flag, CHOICE_CTF_PICKUP_TEAM_), Team_ColorCode(player.team), player.netname); + Send_Notification(NOTIF_ONE, it, MSG_CHOICE, APP_TEAM_ENT(flag, CHOICE_CTF_PICKUP_TEAM), Team_ColorCode(player.team), player.netname); else Send_Notification(NOTIF_ONE, it, MSG_CHOICE, ((SAME_TEAM(flag, player)) ? CHOICE_CTF_PICKUP_ENEMY_TEAM : CHOICE_CTF_PICKUP_ENEMY), Team_ColorCode(player.team), player.netname); )); @@ -902,14 +902,14 @@ void ctf_CheckFlagReturn(entity flag, int returntype) { switch(returntype) { - case RETURN_DROPPED: Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT_4(flag, INFO_CTF_FLAGRETURN_DROPPED_) : INFO_CTF_FLAGRETURN_DROPPED_NEUTRAL)); break; - case RETURN_DAMAGE: Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT_4(flag, INFO_CTF_FLAGRETURN_DAMAGED_) : INFO_CTF_FLAGRETURN_DAMAGED_NEUTRAL)); break; - case RETURN_SPEEDRUN: Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT_4(flag, INFO_CTF_FLAGRETURN_SPEEDRUN_) : INFO_CTF_FLAGRETURN_SPEEDRUN_NEUTRAL), ctf_captimerecord); break; - case RETURN_NEEDKILL: Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT_4(flag, INFO_CTF_FLAGRETURN_NEEDKILL_) : INFO_CTF_FLAGRETURN_NEEDKILL_NEUTRAL)); break; + case RETURN_DROPPED: Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT(flag, INFO_CTF_FLAGRETURN_DROPPED) : INFO_CTF_FLAGRETURN_DROPPED_NEUTRAL)); break; + case RETURN_DAMAGE: Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT(flag, INFO_CTF_FLAGRETURN_DAMAGED) : INFO_CTF_FLAGRETURN_DAMAGED_NEUTRAL)); break; + case RETURN_SPEEDRUN: Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT(flag, INFO_CTF_FLAGRETURN_SPEEDRUN) : INFO_CTF_FLAGRETURN_SPEEDRUN_NEUTRAL), ctf_captimerecord); break; + case RETURN_NEEDKILL: Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT(flag, INFO_CTF_FLAGRETURN_NEEDKILL) : INFO_CTF_FLAGRETURN_NEEDKILL_NEUTRAL)); break; default: case RETURN_TIMEOUT: - { Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT_4(flag, INFO_CTF_FLAGRETURN_TIMEOUT_) : INFO_CTF_FLAGRETURN_TIMEOUT_NEUTRAL)); break; } + { Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT(flag, INFO_CTF_FLAGRETURN_TIMEOUT) : INFO_CTF_FLAGRETURN_TIMEOUT_NEUTRAL)); break; } } _sound(flag, CH_TRIGGER, flag.snd_flag_respawn, VOL_BASE, ATTEN_NONE); ctf_EventLog("returned", flag.team, world); @@ -2437,7 +2437,7 @@ MUTATOR_HOOKFUNCTION(ctf, AbortSpeedrun) {SELFPARAM(); if(self.flagcarried) { - Send_Notification(NOTIF_ALL, world, MSG_INFO, ((self.flagcarried.team) ? APP_TEAM_ENT_4(self.flagcarried, INFO_CTF_FLAGRETURN_ABORTRUN_) : INFO_CTF_FLAGRETURN_ABORTRUN_NEUTRAL)); + Send_Notification(NOTIF_ALL, world, MSG_INFO, ((self.flagcarried.team) ? APP_TEAM_ENT(self.flagcarried, INFO_CTF_FLAGRETURN_ABORTRUN) : INFO_CTF_FLAGRETURN_ABORTRUN_NEUTRAL)); ctf_RespawnFlag(self.flagcarried); return true; } diff --git a/qcsrc/server/mutators/mutator/gamemode_domination.qc b/qcsrc/server/mutators/mutator/gamemode_domination.qc index 1259364f0..1c1620414 100644 --- a/qcsrc/server/mutators/mutator/gamemode_domination.qc +++ b/qcsrc/server/mutators/mutator/gamemode_domination.qc @@ -424,8 +424,8 @@ float Domination_CheckWinner() if(winner_team > 0) { - Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM_4(winner_team, CENTER_ROUND_TEAM_WIN_)); - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(winner_team, INFO_ROUND_TEAM_WIN_)); + Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN)); + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN)); TeamScore_AddToTeam(winner_team, ST_DOM_CAPS, +1); } else if(winner_team == -1) diff --git a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc index abc5d8c5a..233f67824 100644 --- a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc +++ b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc @@ -165,8 +165,8 @@ float freezetag_CheckWinner() int winner_team = freezetag_getWinnerTeam(); if(winner_team > 0) { - Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM_4(winner_team, CENTER_ROUND_TEAM_WIN_)); - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(winner_team, INFO_ROUND_TEAM_WIN_)); + Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN)); + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN)); TeamScore_AddToTeam(winner_team, ST_SCORE, +1); } else if(winner_team == -1) diff --git a/qcsrc/server/mutators/mutator/gamemode_invasion.qc b/qcsrc/server/mutators/mutator/gamemode_invasion.qc index b7730592c..64b710f22 100644 --- a/qcsrc/server/mutators/mutator/gamemode_invasion.qc +++ b/qcsrc/server/mutators/mutator/gamemode_invasion.qc @@ -279,8 +279,8 @@ float Invasion_CheckWinner() { if(winner_team) { - Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM_4(winner_team, CENTER_ROUND_TEAM_WIN_)); - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(winner_team, INFO_ROUND_TEAM_WIN_)); + Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN)); + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN)); } } else if(winner) diff --git a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc index 6f8ec9551..dc34e08ec 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc @@ -499,7 +499,7 @@ void kh_Key_Collect(entity key, entity player) //a player picks up a dropped ke PlayerScore_Add(player, SP_KH_PICKUPS, 1); } key.kh_dropperteam = 0; - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_4(key, INFO_KEYHUNT_PICKUP_), player.netname); + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT(key, INFO_KEYHUNT_PICKUP), player.netname); kh_Key_AssignTo(key, player); // this also updates .kh_state } @@ -608,7 +608,7 @@ void kh_WinnerTeam(float teem) // runs when a team wins // Samual: Teem?.... TE first = false; } - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(teem, INFO_KEYHUNT_CAPTURE_), keyowner); + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM(teem, INFO_KEYHUNT_CAPTURE), keyowner); first = true; midpoint = '0 0 0'; @@ -717,7 +717,7 @@ void kh_LoserTeam(float teem, entity lostkey) // runs when a player pushes a fl } } - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_4(lostkey, INFO_KEYHUNT_LOST_), lostkey.kh_previous_owner.netname); + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT(lostkey, INFO_KEYHUNT_LOST), lostkey.kh_previous_owner.netname); play2all(SND(KH_DESTROY)); te_tarexplosion(lostkey.origin); @@ -772,7 +772,7 @@ void kh_Key_Think() // runs all the time else Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_KEYHUNT_HELP); else - Send_Notification(NOTIF_ONE, it, MSG_CENTER, APP_TEAM_NUM_4(kh_interferemsg_team, CENTER_KEYHUNT_INTERFERE_)); + Send_Notification(NOTIF_ONE, it, MSG_CENTER, APP_TEAM_NUM(kh_interferemsg_team, CENTER_KEYHUNT_INTERFERE)); )); } @@ -830,7 +830,7 @@ void kh_Key_Spawn(entity initial_owner, float _angle, float i) // runs every ti key.kh_worldkeynext = kh_worldkeylist; kh_worldkeylist = key; - Send_Notification(NOTIF_ONE, initial_owner, MSG_CENTER, APP_TEAM_NUM_4(initial_owner.team, CENTER_KEYHUNT_START_)); + Send_Notification(NOTIF_ONE, initial_owner, MSG_CENTER, APP_TEAM_NUM(initial_owner.team, CENTER_KEYHUNT_START)); WaypointSprite_Spawn(WP_KeyDropped, 0, 0, key, '0 0 1' * KH_KEY_WP_ZSHIFT, world, key.team, key, waypointsprite_attachedforcarrier, false, RADARICON_FLAG); key.waypointsprite_attachedforcarrier.waypointsprite_visible_for_player = kh_Key_waypointsprite_visible_for_player; @@ -873,7 +873,7 @@ void kh_Key_DropOne(entity key) kh_Scores_Event(player, key, "dropkey", 0, 0); PlayerScore_Add(player, SP_KH_LOSSES, 1); - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_4(key, INFO_KEYHUNT_DROP_), player.netname); + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT(key, INFO_KEYHUNT_DROP), player.netname); kh_Key_AssignTo(key, world); makevectors(player.v_angle); @@ -899,7 +899,7 @@ void kh_Key_DropAll(entity player, float suicide) // runs whenever a player dies { kh_Scores_Event(player, key, "losekey", 0, 0); PlayerScore_Add(player, SP_KH_LOSSES, 1); - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_4(key, INFO_KEYHUNT_LOST_), player.netname); + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT(key, INFO_KEYHUNT_LOST), player.netname); kh_Key_AssignTo(key, world); makevectors('-1 0 0' * (45 + 45 * random()) + '0 360 0' * random()); key.velocity = W_CalculateProjectileVelocity(player.velocity, autocvar_g_balance_keyhunt_dropvelocity * v_forward, false);