]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
IT'S ALIVEEEEE... for 3 messages. :D
authorSamual Lenks <samual@xonotic.org>
Tue, 25 Sep 2012 22:06:16 +0000 (18:06 -0400)
committerSamual Lenks <samual@xonotic.org>
Tue, 25 Sep 2012 22:06:16 +0000 (18:06 -0400)
qcsrc/common/notifications.qc
qcsrc/server/autocvars.qh
qcsrc/server/cl_client.qc
qcsrc/server/cl_player.qc
qcsrc/server/defs.qh
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/gamemode_ctf.qc

index a75f4baba2387c5b473bb2d095ddd53b38a29c90..673a8e1829497d60e63add3e2de5a8a453acc858 100644 (file)
@@ -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
index 16a7193c13710903da8cd9ed2db5143802504508..237dc56513f95ee41117b58b86273daef35b42f8 100644 (file)
@@ -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;
index b623bd28d54cae53bd0ef3a3fa2d1f0259af994c..c9da49477595999a7d50cf7495401e15427d28d4 100644 (file)
@@ -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
index 3e560bd2452a71020d339d7ed22830a76b212ec8..4b5bca748c54dd5e39597525325f961b9838eef3 100644 (file)
@@ -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)
                        {
index 26d55068e21bcdd24da30136eee9621b24aa6fbf..6b3b734ed8580b3ab63d216399a997da850f076a 100644 (file)
@@ -39,7 +39,6 @@ float g_pickup_respawntimejitter_powerup;
 float g_jetpack;
 
 float sv_clones;
-float sv_gentle;
 float sv_foginterval;
 
 entity activator;
index ef8b2bb70a184603121cdad4d1daadffe5a2f0a3..08b06f513804b35f018c41a4e6dcad638091d241 100644 (file)
@@ -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)
index f453cc22ad727ea81b78f276ff3958aed207bde2..7dbf4048dff15befaba1bccd501be6437c76b85a 100644 (file)
@@ -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