-
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?
Conversation
Dolly132
commented
Oct 3, 2025
- Gets rid of the hardcoding 1d bool array and instead use 2d for client and target
- Untested
- Gets rid of the hardcoding 1d bool array and instead use 2d for client and target
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.
Pull Request Overview
This PR refactors the chat ignore functionality in the CustomChatColors plugin by replacing a 1D boolean array with a 2D array for better organization and introducing a new native API function. The change improves the API design by providing granular control over ignore settings between specific client-target pairs.
Key changes:
- Replaces the hardcoded 1D boolean array
g_Ignored
with a more intuitive 2D array structure - Introduces
CCC_SetIgnored
native function to replace the previousCCC_UpdateIgnoredArray
approach - Updates version number from 7.4.21 to 7.4.22
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
ccc.inc | Updates API definition with new CCC_SetIgnored native and increments patch version |
CustomChatColors.sp | Implements 2D array structure and new native function with client/target validation |
if (!client || client > MaxClients) | ||
{ | ||
ThrowNativeError(SP_ERROR_PARAM, "Invalid client or client is not in game"); | ||
return 0; | ||
} |
Copilot
AI
Oct 11, 2025
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 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 IsClientInGame(client)
for the validation or update the error message to 'Invalid client index'.
Copilot uses AI. Check for mistakes.
if (!target || target > MaxClients) | ||
{ | ||
ThrowNativeError(SP_ERROR_PARAM, "Invalid target or target is not in game"); | ||
return 0; | ||
} |
Copilot
AI
Oct 11, 2025
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 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 IsClientInGame(target)
for the validation or update the error message to 'Invalid target index'.
Copilot uses AI. Check for mistakes.
|
||
int client = GetNativeCell(1); | ||
|
||
if (!client || client > MaxClients) |
Copilot
AI
Oct 11, 2025
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 using client < 1
instead of !client
if console should be excluded, or client < 0
if console should be allowed.
Copilot uses AI. Check for mistakes.
|
||
int target = GetNativeCell(2); | ||
|
||
if (!target || target > MaxClients) |
Copilot
AI
Oct 11, 2025
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 using client < 1
instead of !client
if console should be excluded, or client < 0
if console should be allowed.
if (!target || target > MaxClients) | |
if (target < 0 || target > MaxClients) |
Copilot uses AI. Check for mistakes.