From: Samual Lenks <samual@xonotic.org>
Date: Thu, 27 Sep 2012 23:16:23 +0000 (-0400)
Subject: Lots and lots of work :D
X-Git-Tag: xonotic-v0.7.0~62^2~23^2~405
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a16bee2459581c19307581ab39add6dbdf24a1c2;p=xonotic%2Fxonotic-data.pk3dir.git

Lots and lots of work :D
---

diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc
index a1bd345342..b84fd39ee4 100644
--- a/qcsrc/client/Main.qc
+++ b/qcsrc/client/Main.qc
@@ -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();
 
diff --git a/qcsrc/common/deathtypes.qh b/qcsrc/common/deathtypes.qh
index dc3f42f92b..4133d51355 100644
--- a/qcsrc/common/deathtypes.qh
+++ b/qcsrc/common/deathtypes.qh
@@ -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))
diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc
index 1d2adbd41a..d5e256a6d4 100644
--- a/qcsrc/common/notifications.qc
+++ b/qcsrc/common/notifications.qc
@@ -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
@@ -60,13 +54,9 @@
     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);
diff --git a/qcsrc/common/util.qh b/qcsrc/common/util.qh
index c7dbb56118..b3365d5942 100644
--- a/qcsrc/common/util.qh
+++ b/qcsrc/common/util.qh
@@ -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
diff --git a/qcsrc/menu/progs.src b/qcsrc/menu/progs.src
index e6493dd114..0f545e60cf 100644
--- a/qcsrc/menu/progs.src
+++ b/qcsrc/menu/progs.src
@@ -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
diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc
index 2d5807211b..bf479adb6a 100644
--- a/qcsrc/server/g_damage.qc
+++ b/qcsrc/server/g_damage.qc
@@ -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)
diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc
index 0284280b4a..f7982cf881 100644
--- a/qcsrc/server/g_world.qc
+++ b/qcsrc/server/g_world.qc
@@ -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));