Skip to content

Conversation

Dolly132
Copy link

@Dolly132 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
@Rushaway Rushaway requested a review from Copilot October 11, 2025 00:19
Copy link

@Copilot Copilot AI left a 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 previous CCC_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

Comment on lines +4758 to +4762
if (!client || client > MaxClients)
{
ThrowNativeError(SP_ERROR_PARAM, "Invalid client or client is not in game");
return 0;
}
Copy link

Copilot AI Oct 11, 2025

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.

Comment on lines +4766 to +4770
if (!target || target > MaxClients)
{
ThrowNativeError(SP_ERROR_PARAM, "Invalid target or target is not in game");
return 0;
}
Copy link

Copilot AI Oct 11, 2025

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)
Copy link

Copilot AI Oct 11, 2025

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)
Copy link

Copilot AI Oct 11, 2025

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.

Suggested change
if (!target || target > MaxClients)
if (target < 0 || target > MaxClients)

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant