-
Notifications
You must be signed in to change notification settings - Fork 4
feat(api): replace Ignored native to use a 2d bool array #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -110,7 +110,7 @@ char g_msgText[MAX_CHAT_LENGTH]; | |||||
char g_msgFinal[255]; | ||||||
bool g_msgIsTeammate; | ||||||
|
||||||
bool g_Ignored[(MAXPLAYERS + 1) * (MAXPLAYERS + 1)] = {false, ...}; | ||||||
bool g_Ignored[MAXPLAYERS + 1][MAXPLAYERS + 1]; | ||||||
|
||||||
int g_bSQLSelectReplaceRetry = 0; | ||||||
int g_bSQLInsertReplaceRetry[MAXPLAYERS + 1] = { 0, ... }; | ||||||
|
@@ -164,7 +164,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max | |||||
CreateNative("CCC_ResetColor", Native_ResetColor); | ||||||
CreateNative("CCC_ResetTag", Native_ResetTag); | ||||||
|
||||||
CreateNative("CCC_UpdateIgnoredArray", Native_UpdateIgnoredArray); | ||||||
CreateNative("CCC_SetIgnored", Native_SetIgnored); | ||||||
CreateNative("CCC_IsClientEnabled", Native_IsClientEnabled); | ||||||
|
||||||
RegPluginLibrary("ccc"); | ||||||
|
@@ -4299,7 +4299,7 @@ public Action Event_PlayerSay(Handle event, const char[] name, bool dontBroadcas | |||||
{ | ||||||
if (IsClientInGame(client) && GetClientTeam(client) == team) | ||||||
{ | ||||||
if (!g_Ignored[client * (MAXPLAYERS + 1) + g_msgAuthor]) | ||||||
if (!g_Ignored[client][g_msgAuthor]) | ||||||
players[playersNum++] = client; | ||||||
} | ||||||
} | ||||||
|
@@ -4310,7 +4310,7 @@ public Action Event_PlayerSay(Handle event, const char[] name, bool dontBroadcas | |||||
{ | ||||||
if (IsClientInGame(client)) | ||||||
{ | ||||||
if (!g_Ignored[client * (MAXPLAYERS + 1) + g_msgAuthor]) | ||||||
if (!g_Ignored[client][g_msgAuthor]) | ||||||
players[playersNum++] = client; | ||||||
} | ||||||
} | ||||||
|
@@ -4751,10 +4751,26 @@ public int Native_ResetTag(Handle plugin, int numParams) | |||||
return 1; | ||||||
} | ||||||
|
||||||
public int Native_UpdateIgnoredArray(Handle plugin, int numParams) | ||||||
public int Native_SetIgnored(Handle plugin, int numParams) | ||||||
{ | ||||||
GetNativeArray(1, g_Ignored, sizeof(g_Ignored)); | ||||||
|
||||||
int client = GetNativeCell(1); | ||||||
|
||||||
if (!client || client > MaxClients) | ||||||
{ | ||||||
ThrowNativeError(SP_ERROR_PARAM, "Invalid client or client is not in game"); | ||||||
return 0; | ||||||
} | ||||||
Comment on lines
+4758
to
+4762
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error message mentions 'client is not in game' but the validation only checks if the client index is valid, not if the client is actually in game. Consider using Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
|
||||||
int target = GetNativeCell(2); | ||||||
|
||||||
if (!target || target > MaxClients) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The validation logic
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
{ | ||||||
ThrowNativeError(SP_ERROR_PARAM, "Invalid target or target is not in game"); | ||||||
return 0; | ||||||
} | ||||||
Comment on lines
+4766
to
+4770
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error message mentions 'target is not in game' but the validation only checks if the target index is valid, not if the target is actually in game. Consider using Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
|
||||||
bool value = view_as<bool>(GetNativeCell(3)); | ||||||
g_Ignored[client][target] = value; | ||||||
return 1; | ||||||
} | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation logic
!client
will reject client index 0, but in SourceMod, client index 0 typically represents the server console which might be a valid use case for ignore functionality. Consider usingclient < 1
instead of!client
if console should be excluded, orclient < 0
if console should be allowed.Copilot uses AI. Check for mistakes.