From d19c9797a71064a657bde66f40f29cd06cc2480b Mon Sep 17 00:00:00 2001 From: Samual Lenks Date: Tue, 25 Sep 2012 15:23:13 -0400 Subject: [PATCH] More structuring, more work on networking --- qcsrc/client/Main.qc | 4 + qcsrc/common/constants.qh | 1 + qcsrc/common/notifications.qc | 146 ++++++++++++++++++---------------- qcsrc/server/miscfunctions.qc | 28 ------- 4 files changed, 84 insertions(+), 95 deletions(-) diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index 076b255a3..43cb8cb2f 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -1186,6 +1186,10 @@ float CSQC_Parse_TempEntity() cl_notice_read(); bHandled = true; break; + case TE_CSQC_NOTIFICATION: + Read_Notification(); + bHandled = true; + break; default: // No special logic for this temporary entity; return 0 so the engine can handle it bHandled = false; diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 9717905b6..09c1e923b 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -47,6 +47,7 @@ const float TE_CSQC_MINELAYER_MAXMINES = 117; const float TE_CSQC_HAGAR_MAXROCKETS = 118; const float TE_CSQC_VEHICLESETUP = 119; const float TE_CSQC_SVNOTICE = 120; +const float TE_CSQC_NOTIFICATION = 121; const float RACE_NET_CHECKPOINT_HIT_QUALIFYING = 0; // byte checkpoint, short time, short recordtime, string recordholder const float RACE_NET_CHECKPOINT_CLEAR = 1; diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index da4f4f5b9..b60f5d9f4 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -1,6 +1,8 @@ -// ===================== -// Notification System -// ===================== +// ================================================ +// Unified notification system, written by Samual +// Last updated: September, 2012 +// ================================================ + // main types/groups of notifications #define MSG_INFO 1 // information messages (sent to console) #define MSG_NOTIFY 2 // events to be sent to the notification panel @@ -57,34 +59,35 @@ float NOTIF_CPID_COUNT; ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name) -// =================== -// Notification List -// =================== - -// List of all notifications (including identifiers and display information) -// Format: name, number, args, special, normal, gentle -// Specifications: -// Name of notification -// ID number of notification -// Arguments for sprintf(string, args), if no args needed then use "" -// Special: -// MSG_INFO: NULL/FLOAT: leave as FALSE -// MSG_NOTIFY: STRING: icon string name for the hud notify panel, "" if no icon is used -// MSG_CENTER: FLOAT: centerprint ID number (CPID_*), NO_CPID if no CPID is needed -// MSG_WEAPON: NULL/FLOAT: leave as FALSE -// Normal message (string for sprintf when gentle messages are NOT enabled) -// Gentle message (string for sprintf when gentle messages ARE enabled) -// -// Messages have ^F1, ^F2, and ^BG in them-- these are replaced -// with colors according to the cvars the user has chosen. -// ^F1 = highest priority, "primary" -// ^F2 = next highest priority, "secondary" -// ^BG = normal/less important priority, "tertiary" -// Guidlines: -// ALWAYS start the string with a color, preferably background -// ALWAYS end messages with a new line -// ARIRE unir frk jvgu lbhe bja zbgure (gvc sbe zvxrrhfn) - +// ==================================== +// Notifications List and Information +// ==================================== +/* + List of all notifications (including identifiers and display information) + Format: name, number, args, special, normal, gentle + Specifications: + Name of notification + ID number of notification + Arguments for sprintf(string, args), if no args needed then use "" + Special: + MSG_INFO: NULL/FLOAT: leave as FALSE + MSG_NOTIFY: STRING: icon string name for the hud notify panel, "" if no icon is used + MSG_CENTER: FLOAT: centerprint ID number (CPID_*), NO_CPID if no CPID is needed + MSG_WEAPON: NULL/FLOAT: leave as FALSE + Normal message (string for sprintf when gentle messages are NOT enabled) + Gentle message (string for sprintf when gentle messages ARE enabled) + + Messages have ^F1, ^F2, and ^BG in them-- these are replaced + with colors according to the cvars the user has chosen. + ^F1 = highest priority, "primary" + ^F2 = next highest priority, "secondary" + ^BG = normal/less important priority, "tertiary" + + Guidlines: + ALWAYS start the string with a color, preferably background + ALWAYS end messages with a new line + ARIRE unir frk jvgu lbhe bja zbgure (gvc sbe zvxrrhfn) +*/ #define MSG_INFO_NOTIFICATIONS \ MSG_INFO_NOTIF(DEATH_MARBLES_LOST, CLPS3(s1, s2, s3), _("^F1%s^BG lost their marbles against ^F1%s^BG using the ^F2%s^BG\n"), "") \ /* nothing */ @@ -119,31 +122,16 @@ MSG_WEAPON_NOTIFICATIONS #undef MSG_CENTER_NOTIF #undef MSG_WEAPON_NOTIF -/* -#define MSG_WEAPON_NOTIFICATIONS \ - NOTIFICATION(DEATH_MARBLES_LOST3, 1, CLPS3(s1, s2, s3), "notify_death", _("^F1%s^BG lost their marbles against ^F1%s^BG using the ^F2%s^BG\n"), "") \ - /* nothing */ - -/*#define NOTIFICATION(name,num,args,special,normal,gentle) \ - #ifndef name \ - #define name num \ - #endif -MSG_INFO_NOTIFICATIONS -MSG_NOTIFY_NOTIFICATIONS -MSG_CENTER_NOTIFICATIONS -MSG_WEAPON_NOTIFICATIONS -#undef NOTIFICATION -// declare centerprint priorities -#ifdef CSQC -#define NOTIFICATION(name,num,args,special,normal,gentle) \ - #ifndef special \ - #define special num \ - #endif -MSG_CENTER_NOTIFICATIONS -#undef NOTIFICATION -#endif */ +// ====================== +// Supporting Functions +// ====================== +#ifdef SVQC +#define WRITESPECTATABLE_MSG_ONE_VARNAME(varname,statement) entity varname; varname = msg_entity; FOR_EACH_REALCLIENT(msg_entity) if(msg_entity == varname || (msg_entity.classname == STR_SPECTATOR && msg_entity.enemy == varname)) statement msg_entity = varname +#define WRITESPECTATABLE_MSG_ONE(statement) WRITESPECTATABLE_MSG_ONE_VARNAME(oldmsg_entity, statement) +#define WRITESPECTATABLE(msg,statement) if(msg == MSG_ONE) { WRITESPECTATABLE_MSG_ONE(statement); } else statement float WRITESPECTATABLE_workaround = 0 +#endif string CCR(string input) // color code replace, place inside of sprintf and parse the string { @@ -157,30 +145,30 @@ string CCR(string input) // color code replace, place inside of sprintf and pars } -#ifdef CSQC +// =============================== +// Frontend Notification Pushing +// =============================== + + +// ========================= +// Notification Networking +// ========================= -void readnotificationorwhatever() +#ifdef CSQC +void Read_Notification() { - //stuff and things + } #endif - - -// ================ -// #ifdef SVQC -//#define WRITESPECTATABLE_MSG_ONE_VARNAME(varname,statement) entity varname; varname = msg_entity; FOR_EACH_REALCLIENT(msg_entity) if(msg_entity == varname || (msg_entity.classname == STR_SPECTATOR && msg_entity.enemy == varname)) statement msg_entity = varname -//#define WRITESPECTATABLE_MSG_ONE(statement) WRITESPECTATABLE_MSG_ONE_VARNAME(oldmsg_entity, statement) -//#define WRITESPECTATABLE(msg,statement) if(msg == MSG_ONE) { WRITESPECTATABLE_MSG_ONE(statement); } else statement float WRITESPECTATABLE_workaround = 0 - void Send_Notification(float type, entity client, float id, string s, float duration, float countdown_num) { - if ((clienttype(client) == CLIENTTYPE_REAL) && (client.flags & FL_CLIENT)) + if((clienttype(client) == CLIENTTYPE_REAL) && (client.flags & FL_CLIENT)) { msg_entity = client; WRITESPECTATABLE_MSG_ONE({ WriteByte(MSG_ONE, SVC_TEMPENTITY); - //WriteByte(MSG_ONE, TE_CSQC_NOTIFICATION); + WriteByte(MSG_ONE, TE_CSQC_NOTIFICATION); WriteByte(MSG_ONE, id); WriteString(MSG_ONE, s); if (id != 0 && s != "") @@ -191,4 +179,28 @@ void Send_Notification(float type, entity client, float id, string s, float dura }); } } + +// LEGACY NOTIFICATION SYSTEMS +void Send_CSQC_Centerprint_Generic(entity e, float id, string s, float duration, float countdown_num) +{ + if ((clienttype(e) == CLIENTTYPE_REAL) && (e.flags & FL_CLIENT)) + { + msg_entity = e; + WRITESPECTATABLE_MSG_ONE({ + WriteByte(MSG_ONE, SVC_TEMPENTITY); + WriteByte(MSG_ONE, TE_CSQC_CENTERPRINT_GENERIC); + WriteByte(MSG_ONE, id); + WriteString(MSG_ONE, s); + if (id != 0 && s != "") + { + WriteByte(MSG_ONE, duration); + WriteByte(MSG_ONE, countdown_num); + } + }); + } +} +void Send_CSQC_Centerprint_Generic_Expire(entity e, float id) +{ + Send_CSQC_Centerprint_Generic(e, id, "", 1, 0); +} #endif diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 20828800d..ef8b2bb70 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -1657,34 +1657,6 @@ void precache() #endif } -// sorry, but using \ in macros breaks line numbers -#define WRITESPECTATABLE_MSG_ONE_VARNAME(varname,statement) entity varname; varname = msg_entity; FOR_EACH_REALCLIENT(msg_entity) if(msg_entity == varname || (msg_entity.classname == STR_SPECTATOR && msg_entity.enemy == varname)) statement msg_entity = varname -#define WRITESPECTATABLE_MSG_ONE(statement) WRITESPECTATABLE_MSG_ONE_VARNAME(oldmsg_entity, statement) -#define WRITESPECTATABLE(msg,statement) if(msg == MSG_ONE) { WRITESPECTATABLE_MSG_ONE(statement); } else statement float WRITESPECTATABLE_workaround = 0 - - -void Send_CSQC_Centerprint_Generic(entity e, float id, string s, float duration, float countdown_num) -{ - if ((clienttype(e) == CLIENTTYPE_REAL) && (e.flags & FL_CLIENT)) - { - msg_entity = e; - WRITESPECTATABLE_MSG_ONE({ - WriteByte(MSG_ONE, SVC_TEMPENTITY); - WriteByte(MSG_ONE, TE_CSQC_CENTERPRINT_GENERIC); - WriteByte(MSG_ONE, id); - WriteString(MSG_ONE, s); - if (id != 0 && s != "") - { - WriteByte(MSG_ONE, duration); - WriteByte(MSG_ONE, countdown_num); - } - }); - } -} -void Send_CSQC_Centerprint_Generic_Expire(entity e, float id) -{ - Send_CSQC_Centerprint_Generic(e, id, "", 1, 0); -} // WARNING: this kills the trace globals #define EXACTTRIGGER_TOUCH if(WarpZoneLib_ExactTrigger_Touch()) return #define EXACTTRIGGER_INIT WarpZoneLib_ExactTrigger_Init() -- 2.39.2