]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Lots and lots of work :D
authorSamual Lenks <samual@xonotic.org>
Thu, 27 Sep 2012 23:16:23 +0000 (19:16 -0400)
committerSamual Lenks <samual@xonotic.org>
Thu, 27 Sep 2012 23:16:23 +0000 (19:16 -0400)
qcsrc/client/Main.qc
qcsrc/common/deathtypes.qh
qcsrc/common/notifications.qc
qcsrc/common/util.qh
qcsrc/menu/progs.src
qcsrc/server/g_damage.qc
qcsrc/server/g_world.qc

index a1bd34534220afea04970c35efd055e19b87ecf3..b84fd39ee46a979fd1fe736242abd3af08fd4907 100644 (file)
@@ -154,7 +154,8 @@ void CSQC_Init(void)
        // needs to be done so early because of the constants they create
        CALL_ACCUMULATED_FUNCTION(RegisterWeapons);
        CALL_ACCUMULATED_FUNCTION(RegisterGametypes);
-       CALL_ACCUMULATED_FUNCTION(DecNotifs);
+       CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
+       CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
        
        WaypointSprite_Load();
 
index dc3f42f92bc13762fc6fed4acc25c203c6cf882f..4133d51355327f226cb32b881b801da5a56509db 100644 (file)
@@ -7,18 +7,20 @@ float DT_COUNT;
 float DEATH_VHFIRST = DT_FIRST;
 float DEATH_VHLAST = DT_FIRST;
 
+#define DT_MATCH(a,b) if(min(DT_MAX, a) == b)
+
 #define DEATHTYPE(name,type,notification,first,last) \
        float name; \
        float first; \
        float last; \
-       void DecDeathtype_##name() \
+       void RegisterDeathtype_##name() \
        { \
                SET_FIRST_OR_LAST(first, DT_FIRST, DT_COUNT) \
                SET_FIRST_OR_LAST(last, DT_FIRST, DT_COUNT) \
                SET_FIELD_COUNT(name, DT_FIRST, DT_COUNT) \
                CHECK_MAX_COUNT(name, DT_MAX, DT_COUNT, "deathtypes") \
-       }
-       ACCUMULATE_FUNCTION(DecDeathtypes, DecDeathtype_##name)
+       } \
+       ACCUMULATE_FUNCTION(RegisterDeathtypes, RegisterDeathtype_##name)
 
 #define DEATHTYPES \
        DEATHTYPE(DEATH_FALL, FALSE, FALSE, DEATH_SPECIAL_START, FALSE) \
@@ -91,8 +93,8 @@ float HITTYPE_HEADSHOT = 0x800; // automatically set by Damage (if headshotbonus
 float HITTYPE_RESERVED = 0x1000; // unused yet
 
 // macros to access these
-#define DEATH_ISTURRET(t)            ((t) >= DEATH_TURRET && (t) <= DEATH_TURRET_LAST)
 #define DEATH_ISSPECIAL(t)            ((t) >= DEATH_SPECIAL_START)
+#define DEATH_ISTURRET(t)            ((t) >= DEATH_TURRET && (t) <= DEATH_TURRET_LAST)
 #define DEATH_WEAPONOFWEAPONDEATH(t)  ((t) & DEATH_WEAPONMASK)
 #define DEATH_ISWEAPON(t,w)           (!DEATH_ISSPECIAL(t) && DEATH_WEAPONOFWEAPONDEATH(t) == (w))
 #define DEATH_WEAPONOF(t)             (DEATH_ISSPECIAL(t) ? 0 : DEATH_WEAPONOFWEAPONDEATH(t))
index 1d2adbd41a1c6664b935c40baa5330e7158101df..d5e256a6d45feebf971da949b580f85c9a8e0fac 100644 (file)
@@ -4,15 +4,9 @@
 // ================================================
 
 // main types/groups of notifications
-#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)
-
-// expand multiple arguments into one argument
-#define XPND4(a,b,c,d) a, b, c, d
-#define XPND3(a,b,c) a, b, c
-#define XPND2(a,b) a, b
+#define MSG_INFO 1 // "Global" information messages (sent to console, and notify panel if it has an icon)
+#define MSG_CENTER 2 // "Personal" centerprint messages
+#define MSG_WEAPON 3 // "Personal" weapon messages (like "You got the Nex", sent to weapon notify panel)
 
 // allow sending of notifications to also pass through to spectators (specifically for centerprints)
 #ifdef SVQC
@@ -36,7 +30,7 @@
     Name of notification
     Arguments for sprintf(string, args), if no args needed then use ""
     *Icon/CPID:
-      MSG_NOTIFY: STRING: icon string name for the hud notify panel, "" if no icon is used
+      MSG_INFO: 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
     *Duration/Countdown:
       MSG_CENTER: XPND2(FLOAT, FLOAT): extra arguments for centerprint messages
     Keep the notifications in alphabetical order.
 */
 #define MSG_INFO_NOTIFICATIONS \
-       MSG_INFO_NOTIF(DEATH_MARBLES_LOST, XPND3(s1, s2, s3), _("^F1%s^BG lost their marbles against ^F1%s^BG using the ^F2%s^BG\n"), "") \
+       MSG_INFO_NOTIF(DEATH_MARBLES_LOST2, XPND3(s1, s2, s3), "notify_death", _("^F1%s^BG lost their marbles against ^F1%s^BG using the ^F2%s^BG\n"), "") \
        #undef MSG_INFO_NOTIF
 
-#define MSG_NOTIFY_NOTIFICATIONS \
-       MSG_NOTIFY_NOTIF(DEATH_MARBLES_LOST2, XPND3(s1, s2, s3), "notify_death", _("^F1%s^BG lost their marbles against ^F1%s^BG using the ^F2%s^BG\n"), "") \
-       #undef MSG_NOTIFY_NOTIF
-
 #define MSG_CENTER_NOTIFICATIONS \
        MSG_CENTER_NOTIF(CENTER_CTF_CAPTURESHIELD_SHIELDED,             "",                             CPID_CTF_CAPTURESHIELD, XPND2(0, 0), _("^BGYou are now ^F1shielded^BG from the flag\n^BGfor ^F2too many unsuccessful attempts^BG to capture.\n^BGMake some defensive scores before trying again."), "") \
        MSG_CENTER_NOTIF(CENTER_CTF_CAPTURESHIELD_FREE,                 "",                             CPID_CTF_CAPTURESHIELD, XPND2(0, 0), _("^BGYou are now free.\n^BGFeel free to ^F2try to capture^BG the flag again\n^BGif you think you will succeed."), "") \
@@ -94,47 +84,40 @@ float NOTIF_CENTER_COUNT;
 float NOTIF_WEAPON_COUNT;
 float NOTIF_CPID_COUNT;
 
-#define MSG_INFO_NOTIF(name,args,normal,gentle) \
+#define MSG_INFO_NOTIF(name,args,icon,normal,gentle) \
+       var float autocvar_notification_##name = TRUE; \
        float name; \
-       void DecNotif_##name() \
+       void RegisterNotification_##name() \
        { \
                SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_INFO_COUNT) \
                CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_INFO_COUNT, "notifications") \
        } \
-       ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name)
-
-#define MSG_NOTIFY_NOTIF(name,args,icon,normal,gentle) \
-       float name; \
-       void DecNotif_##name() \
-       { \
-               SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_NOTIFY_COUNT) \
-               CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_NOTIFY_COUNT, "notifications") \
-       } \
-       ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name)
+       ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
 #define MSG_CENTER_NOTIF(name,args,cpid,durcnt,normal,gentle) \
+       var float autocvar_notification_##name = TRUE; \
        float name; \
        float cpid; \
-       void DecNotif_##name() \
+       void RegisterNotification_##name() \
        { \
                SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_CENTER_COUNT) \
                SET_FIELD_COUNT(cpid, NOTIF_FIRST, NOTIF_CPID_COUNT) \
                CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_CENTER_COUNT, "notifications") \
        } \
-       ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name)
+       ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
 #define MSG_WEAPON_NOTIF(name,args,normal,gentle) \
+       var float autocvar_notification_##name = TRUE; \
        float name; \
-       void DecNotif_##name() \
+       void RegisterNotification_##name() \
        { \
                SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_WEAPON_COUNT) \
                CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_WEAPON_COUNT, "notifications") \
        } \
-       ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name)
+       ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
 // NOW we actually activate the declarations
 MSG_INFO_NOTIFICATIONS
-MSG_NOTIFY_NOTIFICATIONS
 MSG_CENTER_NOTIFICATIONS
 MSG_WEAPON_NOTIFICATIONS
 
@@ -163,18 +146,11 @@ string Get_Notif_Name(float net_type, float net_name)
        {
                case MSG_INFO:
                {
-                       #define MSG_INFO_NOTIF(name,args,normal,gentle) \
+                       #define MSG_INFO_NOTIF(name,args,icon,normal,gentle) \
                                { NOTIF_MATCH(name,net_name) { return VAR_TO_TEXT(name); } }
                        MSG_INFO_NOTIFICATIONS
                        break;
                }
-               case MSG_NOTIFY:
-               {
-                       #define MSG_NOTIFY_NOTIF(name,args,icon,normal,gentle) \
-                               { NOTIF_MATCH(name,net_name) { return VAR_TO_TEXT(name); } }
-                       MSG_NOTIFY_NOTIFICATIONS
-                       break;
-               }
                case MSG_CENTER:
                {
                        #define MSG_CENTER_NOTIF(name,args,cpid,durcnt,normal,gentle) \
@@ -219,33 +195,22 @@ void Local_Notification(float net_type, float net_name, string s1, string s2, st
        {
                case MSG_INFO:
                {
-                       #define MSG_INFO_NOTIF(name,args,normal,gentle) \
+                       #define MSG_INFO_NOTIF(name,args,icon,normal,gentle) \
                                { NOTIF_MATCH(name, net_name) { print(sprintf(CCR(normal_or_gentle(normal, gentle)), args)); } }
-
                        MSG_INFO_NOTIFICATIONS
                        break;
                }
-               case MSG_NOTIFY:
-               {
-                       #define MSG_NOTIFY_NOTIF(name,args,icon,normal,gentle) \
-                               { NOTIF_MATCH(name,net_name) { print("unhandled\n"); } }
-                               
-                       MSG_NOTIFY_NOTIFICATIONS
-                       break;
-               }
                case MSG_CENTER:
                {
                        #define MSG_CENTER_NOTIF(name,args,cpid,durcnt,normal,gentle) \
                                { NOTIF_MATCH(name, net_name) { centerprint_generic(HANDLE_CPID(cpid), sprintf(CCR(normal_or_gentle(normal, gentle)), args), durcnt); } }
-
                        MSG_CENTER_NOTIFICATIONS
                        break;
                }
                case MSG_WEAPON:
                {
                        #define MSG_WEAPON_NOTIF(name,args,normal,gentle) \
-                               { NOTIF_MATCH(name,net_name) { print("unhandled\n"); } }
-                               
+                               { NOTIF_MATCH(name, net_name) { print("unhandled\n"); } }
                        MSG_WEAPON_NOTIFICATIONS
                        break;
                }
@@ -291,28 +256,11 @@ void Send_Notification(float net_type, entity client, float net_name, string s1,
                        WriteString(MSG_ALL, s3);
                }
 
-               if(!server_is_local && ((net_type == MSG_INFO || net_type == MSG_NOTIFY) || client == world))
+               if(!server_is_local && (net_type == MSG_INFO))
                {
-                       switch(net_type)
-                       {
-                               case MSG_INFO:
-                               {
-                                       #define MSG_INFO_NOTIF(name,args,normal,gentle) \
-                                               { NOTIF_MATCH(name, net_name) { print(sprintf(CCR(normal_or_gentle(normal, gentle)), args)); } }
-
-                                       MSG_INFO_NOTIFICATIONS
-                                       break;
-                               }
-
-                               case MSG_NOTIFY:
-                               {
-                                       #define MSG_NOTIFY_NOTIF(name,args,icon,normal,gentle) \
-                                               { NOTIF_MATCH(name,net_name) { print("unhandled\n"); } }
-                               
-                                       MSG_NOTIFY_NOTIFICATIONS
-                                       break;
-                               }
-                       }
+                       #define MSG_INFO_NOTIF(name,args,icon,normal,gentle) \
+                               { NOTIF_MATCH(name, net_name) { print(sprintf(CCR(normal_or_gentle(normal, gentle)), args)); } }
+                       MSG_INFO_NOTIFICATIONS
                }
        }
        else { backtrace("Incorrect usage of Send_Notification!\n"); }
@@ -332,7 +280,7 @@ void Send_Notification_ToTeam(float targetteam, entity except, float net_type, f
        }
 }
 
-// use this ONLY if you need exceptions or want to exclude spectators, otherwise use Send_Notification(..., world, ...)
+// WARNING: use this ONLY if you need exceptions or want to exclude spectators, otherwise use Send_Notification(..., world, ...)
 void Send_Notification_ToAll(entity except, float spectators, float net_type, float net_name, string s1, string s2, string s3)
 {
        entity tmp_entity;
@@ -346,7 +294,11 @@ void Send_Notification_ToAll(entity except, float spectators, float net_type, fl
        }
 }
 
-// LEGACY NOTIFICATION SYSTEMS
+
+// =============================
+//  LEGACY NOTIFICATION SYSTEMS
+// =============================
+
 void Send_KillNotification(string s1, string s2, string s3, float msg, float type)
 {
        WriteByte(MSG_ALL, SVC_TEMPENTITY);
index c7dbb561187b95be2891d6d65317a844692b1c13..b3365d59427fc507e1c83cecffb373820869a299 100644 (file)
@@ -41,7 +41,7 @@ void ACCUMULATE_call(string func)
 #endif
 
 // used for simplifying ACCUMULATE_FUNCTIONs
-#define SET_FIRST_OR_LAST(input,first,count) if(input) { input = (first + count); }
+#define SET_FIRST_OR_LAST(input,first,count) if(!input) { input = (first + count); }
 #define SET_FIELD_COUNT(field,first,count) if(!field) { field = (first + count); ++count; }
 #define CHECK_MAX_COUNT(name,max,count,type) if(count == max) { error(strcat("Maximum ", type, " hit: ", VAR_TO_TEXT(name), ": ", ftos(count), ".\n")); }
 
@@ -369,3 +369,8 @@ float cubic_speedfunc_is_sane(float startspeedfactor, float endspeedfactor);
 typedef entity(entity cur, entity near, entity pass) findNextEntityNearFunction_t;
 typedef float(entity a, entity b, entity pass) isConnectedFunction_t;
 void FindConnectedComponent(entity e, .entity fld, findNextEntityNearFunction_t nxt, isConnectedFunction_t iscon, entity pass);
+
+// expand multiple arguments into one argument
+#define XPND4(a,b,c,d) a, b, c, d
+#define XPND3(a,b,c) a, b, c
+#define XPND2(a,b) a, b
index e6493dd114250cdc9e8fb6c5514029b2244222a1..0f545e60cfa368967ca4cb6f694132fff6558fd1 100644 (file)
@@ -15,7 +15,6 @@ oo/base.h
 ../common/mapinfo.qh
 ../common/campaign_common.qh
 ../common/items.qh
-../common/deathtypes.qh
 ../common/command/markup.qh
 ../common/command/rpn.qh
 ../common/command/generic.qh
index 2d5807211b62b850530a9bda82af7402a1d42983..bf479adb6ab850deaca66aebbb3d9cff94eb56f1 100644 (file)
@@ -310,11 +310,14 @@ void LogDeath(string mode, float deathtype, entity killer, entity killed)
 
 void Obituary_Notification(entity notif_target, string s1, string s2, string s3, float deathtype)
 {
-       #define DEATHTYPE(name,type,notification,first,last) \
-               { if((deathtype == max(0, name)) && max(0, type) && max(0, notification)) { Send_Notification(type, notif_target, notification, s1, s2, s3); return; } }
+       if(deathtype)
+       {
+               #define DEATHTYPE(name,type,notification,first,last) \
+                       { if((deathtype == max(0, name)) && max(0, type) && max(0, notification)) { Send_Notification(type, notif_target, notification, s1, s2, s3); return; } }
 
-       DEATHTYPES
-       backtrace("Unhandled deathtype. Please notify Samual!\n");
+               DEATHTYPES
+               backtrace("Unhandled deathtype. Please notify Samual!\n");
+       }
 }
 
 void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
index 0284280b4a225f44b654da8b983f001e3a140096..f7982cf881ae5bd3a6ca8109a0cfa9d6236db0d4 100644 (file)
@@ -553,8 +553,8 @@ void spawnfunc___init_dedicated_server(void)
        // needs to be done so early because of the constants they create
        CALL_ACCUMULATED_FUNCTION(RegisterWeapons);
        CALL_ACCUMULATED_FUNCTION(RegisterGametypes);
-
-       DecNotifs();
+       CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
+       CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
 
        MapInfo_Enumerate();
        MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
@@ -601,7 +601,8 @@ void spawnfunc_worldspawn (void)
        // needs to be done so early because of the constants they create
        CALL_ACCUMULATED_FUNCTION(RegisterWeapons);
        CALL_ACCUMULATED_FUNCTION(RegisterGametypes);
-       CALL_ACCUMULATED_FUNCTION(DecNotifs);
+       CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
+       CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
 
        ServerProgsDB = db_load(strcat("server.db", autocvar_sessionid));