From 31dd49103304efa6704e0a58efbfe466bec8d725 Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Mon, 14 Nov 2016 01:17:47 -0600 Subject: [PATCH] Replace magic bool argument with enum Make broadcast targets more readable using a SourceTVBroadcastTarget enum. Broadcast to all spectators including proxys or just locally connected spectators. --- sourcetv_test.sp | 6 +++--- sourcetvmanager.inc | 15 +++++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/sourcetv_test.sp b/sourcetv_test.sp index 4abc1c6..a5bb954 100644 --- a/sourcetv_test.sp +++ b/sourcetv_test.sp @@ -218,7 +218,7 @@ public Action:Cmd_SendHintMessage(client, args) GetCmdArgString(sMsg, sizeof(sMsg)); StripQuotes(sMsg); - new bool:bSent = SourceTV_BroadcastScreenMessage(false, "%s", sMsg); + new bool:bSent = SourceTV_BroadcastScreenMessage(BTarget_Everyone, "%s", sMsg); ReplyToCommand(client, "SourceTV sending hint message (success %d): %s", bSent, sMsg); return Plugin_Handled; } @@ -252,7 +252,7 @@ public Action:Cmd_SendChatMessage(client, args) GetCmdArgString(sMsg, sizeof(sMsg)); StripQuotes(sMsg); - new bool:bSent = SourceTV_BroadcastChatMessage(false, "%s", sMsg); + new bool:bSent = SourceTV_BroadcastChatMessage(BTarget_Everyone, "%s", sMsg); ReplyToCommand(client, "SourceTV sending chat message to all spectators (including relays) (success %d): %s", bSent, sMsg); return Plugin_Handled; } @@ -269,7 +269,7 @@ public Action:Cmd_SendChatMessageLocal(client, args) GetCmdArgString(sMsg, sizeof(sMsg)); StripQuotes(sMsg); - new bool:bSent = SourceTV_BroadcastChatMessage(true, "%s", sMsg); + new bool:bSent = SourceTV_BroadcastChatMessage(BTarget_OnlyLocal, "%s", sMsg); ReplyToCommand(client, "SourceTV sending chat message to local spectators (success %d): %s", bSent, sMsg); return Plugin_Handled; } diff --git a/sourcetvmanager.inc b/sourcetvmanager.inc index 97bff67..88e3783 100644 --- a/sourcetvmanager.inc +++ b/sourcetvmanager.inc @@ -8,6 +8,13 @@ #define MAX_SHOT_LENGTH 8.0 // maximum time of a cut (seconds) #define DEF_SHOT_LENGTH 6.0 // average time of a cut (seconds) +enum SourceTVBroadcastTarget { + // Send message to all spectators including proxies. + BTarget_Everyone = 0, + // Send message only to locally connected spectators. + BTarget_OnlyLocal +}; + /** * Get the current amount of running SourceTV instances. * Can usually only be 1 at max except for CSGO, which can have 2. @@ -139,12 +146,12 @@ native Float:SourceTV_GetDelay(); * Print a center message to all SourceTV spectators for ~2 seconds. * Like the tv_msg command. * - * @param bLocalOnly Send only to directly connected spectators or proxies as well? + * @param target Send only to directly connected spectators or proxies as well? * @param format The format string. * @param ... Variable number of format string arguments. * @return True if message was sent, false otherwise. */ -native bool:SourceTV_BroadcastScreenMessage(bool:bLocalOnly, const String:format[], any:...); +native bool:SourceTV_BroadcastScreenMessage(SourceTVBroadcastTarget:target, const String:format[], any:...); /** * Prints text to the console of all connected SourceTV spectators. @@ -158,12 +165,12 @@ native bool:SourceTV_BroadcastConsoleMessage(const String:format[], any:...); /** * Print a chat message to all SourceTV spectators. * - * @param bLocalOnly Send only to directly connected spectators or proxies as well? + * @param target Send only to directly connected spectators or proxies as well? * @param format The format string. * @param ... Variable number of format string arguments. * @return True if message was sent, false otherwise. */ -native bool:SourceTV_BroadcastChatMessage(bool:bLocalOnly, const String:format[], any:...); +native bool:SourceTV_BroadcastChatMessage(SourceTVBroadcastTarget:target, const String:format[], any:...); /********************************************************************************