From 9ebd68f202223129303198665ba187f793a6f6cb Mon Sep 17 00:00:00 2001 From: Samual Lenks Date: Sun, 24 Feb 2013 15:10:40 -0500 Subject: [PATCH] Add comments to initialization code --- qcsrc/common/notifications.qc | 2 -- qcsrc/common/notifications.qh | 31 ++++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index b5192cbe3..4482df616 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -104,8 +104,6 @@ void Dump_Notifications(float fh, float alsoprint) NOTIF_WRITE("seta notification_show_sprees_info 3 \"Show spree information in MSG_INFO messages... 0 = off, 1 = target only, 2 = attacker only, 3 = target and attacker\"\n"); NOTIF_WRITE("seta notification_show_sprees_info_newline 0 \"Show attacker spree information for MSG_INFO messages on a separate line than the death notification itself\"\n"); NOTIF_WRITE("seta notification_show_sprees_info_specialonly 1 \"Don't show attacker spree information in MSG_INFO messages if it isn't an achievement\"\n"); - NOTIF_WRITE("seta notification_version_mismatch_client_error 0 \"Cause a notif error on client if the version in notifications.cfg mismatches the code\"\n"); - NOTIF_WRITE("seta notification_version_mismatch_server_error 1 \"Cause a notif error on server if the version in notifications.cfg mismatches the code\"\n"); NOTIF_WRITE("seta notification_errors_are_fatal 1 \"If a notification fails upon initialization, cause a Host_Error to stop the program\"\n"); NOTIF_WRITE("seta notification_ctf_pickup_team_verbose 1 \"Show extra information if a team mate picks up a flag\"\n"); NOTIF_WRITE("seta notification_ctf_pickup_enemy_verbose 1 \"Show extra information if an enemy picks up a flag\"\n"); diff --git a/qcsrc/common/notifications.qh b/qcsrc/common/notifications.qh index a754567d0..706bc0bf1 100644 --- a/qcsrc/common/notifications.qh +++ b/qcsrc/common/notifications.qh @@ -958,7 +958,10 @@ string Process_Notif_Args(float arg_type, string args, string notiftype, string } #define CREATE_NOTIF_ENTITY(default,type,name,infoname,centername,strnum,flnum,args,hudargs,icon,cpid,durcnt,normal,gentle,check_newline,subcalls) \ +{ \ notif_error = FALSE; \ + \ + /* global entity setup */ \ entity notif = spawn(); \ msg_##type##_notifs[name - 1] = notif; \ notif.classname = "msg_#type#_notification"; \ @@ -966,7 +969,9 @@ string Process_Notif_Args(float arg_type, string args, string notiftype, string notif.nent_name = strzone(#name); \ notif.nent_id = name; \ notif.nent_enabled = (1 <= autocvar_notification_##name); \ - #if subcalls \ + \ + /* notification specific settings */ \ + #if subcalls /* MSG_DEATH and MSG_WEAPON */ \ #if (infoname == NO_MSG) && (centername == NO_MSG) \ print(sprintf("^1NOTIFICATION WITH NO SUBCALLS: ^7net_type = MSG_%s, net_name = %s.\n", strtoupper(#type), #name)); \ notif_error = TRUE; \ @@ -982,18 +987,27 @@ string Process_Notif_Args(float arg_type, string args, string notiftype, string centername_stringcount = notif.nent_msgcenter.nent_stringcount; \ centername_floatcount = notif.nent_msgcenter.nent_floatcount; \ #endif \ + /* set the requirements of THIS notification to the total requirements of its subcalls */ \ notif.nent_stringcount = max(infoname_stringcount, centername_stringcount); \ notif.nent_floatcount = max(infoname_floatcount, centername_floatcount); \ #endif \ - #else \ + #else /* MSG_INFO and MSG_CENTER */ \ float nent_chat = (autocvar_notification_##name > 1); \ + \ notif.nent_stringcount = strnum; \ notif.nent_floatcount = flnum; \ if(args != "") { notif.nent_args = strzone(Process_Notif_Args(1, args, strtoupper(#type), #name)); } \ - if(hudargs != "") { notif.nent_hudargs = strzone(Process_Notif_Args(2, hudargs, strtoupper(#type), #name)); } \ - if(icon != "") { notif.nent_icon = strzone(icon); } \ + \ + /* MSG_INFO only */ \ + if(hudargs != "") { notif.nent_hudargs = strzone(Process_Notif_Args(2, hudargs, strtoupper(#type), #name)); } \ + if(icon != "") { notif.nent_icon = strzone(icon); } \ + \ + /* MSG_CENTER only */ \ if(cpid != NO_MSG) { notif.nent_cpid = cpid; } \ if(durcnt != "") { notif.nent_durcnt = strzone(Process_Notif_Args(3, durcnt, strtoupper(#type), #name)); } \ + \ + /* string setup */ \ + /* select gentle/normal string and bake color codes in on init, this way it does not need to be re-processed at run time */ \ if(GENTLE) \ { \ if(gentle != "") { notif.nent_string = strzone(CCR(Process_Notif_Line(check_newline, nent_chat, gentle, strtoupper(#type), #name, "GENTLE"))); } \ @@ -1002,11 +1016,14 @@ string Process_Notif_Args(float arg_type, string args, string notiftype, string else if(normal != "") { notif.nent_string = strzone(CCR(Process_Notif_Line(check_newline, nent_chat, normal, strtoupper(#type), #name, "NORMAL"))); } \ if(notif.nent_string == "") { print(sprintf("^1EMPTY NOTIFICATION: ^7net_type = MSG_%s, net_name = %s.\n", strtoupper(#type), #name)); notif_error = TRUE; } \ #endif \ + \ + /* now check to see if any errors happened */ \ if(notif_error) \ { \ - notif.nent_enabled = FALSE; \ - notif_global_error = TRUE; \ - } + 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 */ \ + } \ +} #define MSG_INFO_NOTIF(default,name,strnum,flnum,args,hudargs,icon,normal,gentle) \ NOTIF_ADD_AUTOCVAR(name, default) \ -- 2.39.2