From 81df7afdc2c73154d80a1c2564a1f8c869aa402b Mon Sep 17 00:00:00 2001 From: Samual Lenks Date: Tue, 25 Sep 2012 18:06:16 -0400 Subject: [PATCH] IT'S ALIVEEEEE... for 3 messages. :D --- qcsrc/common/notifications.qc | 79 ++++++++++++++++++++------- qcsrc/server/autocvars.qh | 1 + qcsrc/server/cl_client.qc | 2 +- qcsrc/server/cl_player.qc | 14 ++--- qcsrc/server/defs.qh | 1 - qcsrc/server/miscfunctions.qc | 1 - qcsrc/server/mutators/gamemode_ctf.qc | 6 +- 7 files changed, 70 insertions(+), 34 deletions(-) diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index a75f4baba..673a8e182 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -4,10 +4,10 @@ // ================================================ // 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 -#define MSG_CENTER 3 // centerprint messages -#define MSG_WEAPON 4 // weapon messages (like "You got the Nex", sent to weapon notify panel) +#define MSG_INFO 1 // "Global" information messages (sent to console) +#define MSG_NOTIFY 2 // "Global" events to be sent to the notification panel +#define MSG_CENTER 3 // "Personal" centerprint messages +#define MSG_WEAPON 4 // "Personal" weapon messages (like "You got the Nex", sent to weapon notify panel) // collapse multiple arguments into one argument #define CLPS4(s1,s2,s3,s4) s1, s2, s3, s4 @@ -16,6 +16,7 @@ // accumulate functions for declarations #define NOTIF_FIRST 1 +#define NOTIF_MAX 1024 float NOTIF_INFO_COUNT; float NOTIF_NOTIFY_COUNT; float NOTIF_CENTER_COUNT; @@ -125,8 +126,19 @@ MSG_WEAPON_NOTIFICATIONS #define WRITESPECTATABLE(msg,statement) if(msg == MSG_ONE) { WRITESPECTATABLE_MSG_ONE(statement); } else statement float WRITESPECTATABLE_workaround = 0 #endif -#define NORMAL_OR_GENTLE(normal,gentle) ((autocvar_cl_gentle || autocvar_cl_gentle_messages) ? gentle : normal) -#define HANDLE_CPID(cpid) ((min(256, cpid) == NO_CPID) ? FALSE : cpid) +#define HANDLE_CPID(cpid) ((min(NOTIF_MAX, cpid) == NO_CPID) ? FALSE : cpid) + +string normal_or_gentle(string normal, string gentle) +{ +#ifdef CSQC + if(autocvar_cl_gentle || autocvar_cl_gentle_messages) +#else + if(autocvar_sv_gentle) +#endif + return ((gentle != "") ? gentle : normal); + else + return normal; +} string CCR(string input) // color code replace, place inside of sprintf and parse the string { @@ -153,7 +165,7 @@ string CCR(string input) // color code replace, place inside of sprintf and pars void Read_Notification() { float net_type = ReadByte(); - float net_name = ReadByte(); + float net_name = ReadCoord(); // byte only has 256 selections, we need more than that string s1 = ReadString(); string s2 = ReadString(); string s3 = ReadString(); @@ -162,6 +174,10 @@ void Read_Notification() { case MSG_INFO: { + #define MSG_INFO_NOTIF(name,args,normal,gentle) \ + { if(min(NOTIF_MAX, name) == net_name) { print(sprintf(CCR(normal_or_gentle(normal, gentle)), args)); } } + + MSG_INFO_NOTIFICATIONS break; } @@ -173,7 +189,7 @@ void Read_Notification() case MSG_CENTER: { #define MSG_CENTER_NOTIF(name,args,cpid,normal,gentle) \ - { if(min(256, name) == net_name) { centerprint_generic(HANDLE_CPID(cpid), sprintf(CCR(NORMAL_OR_GENTLE(normal, gentle)), args), 0, 0); } } + { if(min(NOTIF_MAX, name) == net_name) { centerprint_generic(HANDLE_CPID(cpid), sprintf(CCR(normal_or_gentle(normal, gentle)), args), 0, 0); } } MSG_CENTER_NOTIFICATIONS break; @@ -187,24 +203,45 @@ void Read_Notification() } #endif #ifdef SVQC -void Send_Notification(float type, entity client, float id, string s, float duration, float countdown_num) +void Send_Notification(float net_type, entity client, float net_name, string s1, string s2, string s3) { - //WriteByte( - if((clienttype(client) == CLIENTTYPE_REAL) && (client.flags & FL_CLIENT)) + if(net_type && net_name) { - msg_entity = client; - WRITESPECTATABLE_MSG_ONE({ - WriteByte(MSG_ONE, SVC_TEMPENTITY); - WriteByte(MSG_ONE, TE_CSQC_NOTIFICATION); - WriteByte(MSG_ONE, id); - WriteString(MSG_ONE, s); - if (id != 0 && s != "") + if(client && (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, net_type); + WriteCoord(MSG_ONE, net_name); + WriteString(MSG_ONE, s1); + WriteString(MSG_ONE, s2); + WriteString(MSG_ONE, s3); + }); + } + + if(!server_is_local && ((net_type == MSG_INFO || net_type == MSG_NOTIFY) || client == world)) + { + switch(net_type) { - WriteByte(MSG_ONE, duration); - WriteByte(MSG_ONE, countdown_num); + case MSG_INFO: + { + #define MSG_INFO_NOTIF(name,args,normal,gentle) \ + { if(min(NOTIF_MAX, name) == net_name) { print(sprintf(CCR(normal_or_gentle(normal, gentle)), args)); } } + + MSG_INFO_NOTIFICATIONS + break; + } + + case MSG_NOTIFY: + { + break; + } } - }); + } } + else { backtrace("Incorrect usage of Send_Notification!\n"); } } // LEGACY NOTIFICATION SYSTEMS diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 16a7193c1..237dc5651 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -1175,6 +1175,7 @@ float autocvar_sv_fraginfo_stats; float autocvar_sv_friction; float autocvar_sv_friction_on_land; float autocvar_sv_gameplayfix_q2airaccelerate; +float autocvar_sv_gentle; #define autocvar_sv_gravity cvar("sv_gravity") string autocvar_sv_intermission_cdtrack; string autocvar_sv_jumpspeedcap_max; diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index b623bd28d..c9da49477 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1286,7 +1286,7 @@ void FixClientCvars(entity e) stuffcmd(e, "cl_cmd settemp cl_movecliptokeyboard 2\n"); if(autocvar_g_antilag == 3) // client side hitscan stuffcmd(e, "cl_cmd settemp cl_prydoncursor_notrace 0\n"); - if(sv_gentle) + if(autocvar_sv_gentle) stuffcmd(e, "cl_cmd settemp cl_gentle 1\n"); /* * we no longer need to stuff this. Remove this comment block if you feel diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index 3e560bd24..4b5bca748 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -536,7 +536,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht { self.pain_finished = time + 0.5; //Supajoe - if(sv_gentle < 1) { + if(autocvar_sv_gentle < 1) { if(self.classname != "body") // pain anim is BORKED on our ZYMs, FIXME remove this once we have good models { if (!self.animstate_override) @@ -644,7 +644,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht if(valid_damage_for_weaponstats) WeaponStats_LogKill(awep, abot, self.weapon, vbot); - if(sv_gentle < 1) // TODO make a "gentle" version? + if(autocvar_sv_gentle < 1) // TODO make a "gentle" version? if(sound_allowed(MSG_BROADCAST, attacker)) { if(deathtype == DEATH_DROWN) @@ -786,7 +786,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht // set up to fade out later SUB_SetFade (self, time + 6 + random (), 1); - if(sv_gentle > 0 || autocvar_ekg) { + if(autocvar_sv_gentle > 0 || autocvar_ekg) { // remove corpse PlayerCorpseDamage (inflictor, attacker, autocvar_sv_gibhealth+1.0, deathtype, hitloc, force); } @@ -1237,7 +1237,7 @@ void FakeGlobalSound(string sample, float chan, float voicetype) break; if(!sv_taunt) break; - if(sv_gentle) + if(autocvar_sv_gentle) break; tauntrand = random(); msg_entity = self; @@ -1255,7 +1255,7 @@ void FakeGlobalSound(string sample, float chan, float voicetype) setanim(self, self.anim_taunt, FALSE, TRUE, TRUE); if(!sv_taunt) break; - if(sv_gentle) + if(autocvar_sv_gentle) break; msg_entity = self; if (msg_entity.cvar_cl_voice_directional >= 1) @@ -1334,7 +1334,7 @@ void GlobalSound(string sample, float chan, float voicetype) break; if(!sv_taunt) break; - if(sv_gentle) + if(autocvar_sv_gentle) break; tauntrand = random(); FOR_EACH_REALCLIENT(msg_entity) @@ -1352,7 +1352,7 @@ void GlobalSound(string sample, float chan, float voicetype) setanim(self, self.anim_taunt, FALSE, TRUE, TRUE); if(!sv_taunt) break; - if(sv_gentle) + if(autocvar_sv_gentle) break; FOR_EACH_REALCLIENT(msg_entity) { diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 26d55068e..6b3b734ed 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -39,7 +39,6 @@ float g_pickup_respawntimejitter_powerup; float g_jetpack; float sv_clones; -float sv_gentle; float sv_foginterval; entity activator; diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index ef8b2bb70..08b06f513 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -1171,7 +1171,6 @@ void readlevelcvars(void) #endif sv_clones = cvar("sv_clones"); - sv_gentle = cvar("sv_gentle"); sv_foginterval = cvar("sv_foginterval"); g_cloaked = cvar("g_cloaked"); if(g_cts) diff --git a/qcsrc/server/mutators/gamemode_ctf.qc b/qcsrc/server/mutators/gamemode_ctf.qc index f453cc22a..7dbf4048d 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qc +++ b/qcsrc/server/mutators/gamemode_ctf.qc @@ -287,11 +287,11 @@ void ctf_Handle_Retrieve(entity flag, entity player) FOR_EACH_REALPLAYER(tmp_player) { if(tmp_player == sender) - centerprint(tmp_player, strcat("You passed the ", flag.netname, " to ", player.netname)); + Send_Notification(MSG_CENTER, tmp_player, CENTER_CTF_EVENT_PASS_SENT, flag.netname, sender.netname, ""); else if(tmp_player == player) - centerprint(tmp_player, strcat("You received the ", flag.netname, " from ", sender.netname)); + Send_Notification(MSG_CENTER, tmp_player, CENTER_CTF_EVENT_PASS_RECEIVED, flag.netname, sender.netname, ""); else if(!IsDifferentTeam(tmp_player, sender)) - centerprint(tmp_player, strcat(sender.netname, " passed the ", flag.netname, " to ", player.netname)); + Send_Notification(MSG_CENTER, tmp_player, CENTER_CTF_EVENT_PASS, sender.netname, flag.netname, player.netname); } // create new waypoint -- 2.39.2