-
Notifications
You must be signed in to change notification settings - Fork 174
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
Little rewrite sbpp_checker. #575
base: v1.x
Are you sure you want to change the base?
Conversation
Optimization code. Strip useless or duplicated strings of code. More dynamically code. Replaced #define to static const. No more failstate, just idle. Prevent spam errors (as an example if you db under maintenance).
Oh wow, that's some horribly unreadable brace style there. |
It's horrible and does not following the coding style of the project. |
I have to agree with @geominorai, the coding style becomes quite hard to read, especially when multiple closing brackets are placed on the same line. For example here: sourcebans-pp/game/addons/sourcemod/scripting/sbpp_checker.sp Lines 199 to 205 in dfcced2
The current programming style for SourceBans++ plugins is based on the style of the original first party Sourcemod plugins and that is probably also the most commonly used programming style in sourcepawn. So to avoid confusion (especially for people who just start with sourcepawn coding) and maintaining a singular programming style in the SourceBans++ plugins, I would appreciate it, if you could reformat the code into the existing programming style of SourceBans++. |
I can just PrettyPrint that code. Better now?
|
Posting too big sourcecode in issue comment - bad idea. It was better to arrange then a commit or link on pastebin/gist. |
ENG: I know. But I just proposed a variant to test PrettyPrint settings. Just for example and feedback. https://gist.github.com/TheByKotik/d0ca355d977960fe2a63846c21b4783a |
i'm did PrettyPrint commit. This options of PrettyPrint follow the coding style of the project? |
return; | ||
|
||
char query[512], ip[30]; | ||
GetClientIP(client, ip, sizeof(ip)); |
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.
GetClientIP ( http://sourcemod.net/new-api/clients/GetClientIP ) returns a bool, i would recommend an check if it's true.
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.
GetClientIP ( http://sourcemod.net/new-api/clients/GetClientIP ) returns a bool, i would recommend an check if it's true.
Having collected some test data, I can answer next:
First, the query works fine even if there is no IP, as we also pass SteamID of player.
Second, even if this function ever breaks, we no need cancel query. It will still be correct and working.
It is possible to log an error (no trown error), but since this is a Sourcemod function, it hardly makes sense since the server operator is unlikely can to fix sourcemod.
/* Do not check bots nor check player with lan steamid. */ | ||
char szIP[30], szQuery[320 + sizeof g_DatabasePrefix * 2 + sizeof szIP]; | ||
GetClientIP( iClient, szIP, sizeof szIP ); | ||
FormatEx( szQuery, sizeof szQuery, "SELECT COUNT(bid) FROM %s_bans WHERE ((type = 0 AND authid REGEXP '^STEAM_[0-9]:%s$') OR (type = 1 AND ip = '%s')) UNION SELECT COUNT(bid) FROM %s_comms WHERE authid REGEXP '^STEAM_[0-9]:%s$'", g_DatabasePrefix, szAuth[8], szIP, g_DatabasePrefix, szAuth[8] ); |
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.
Instead of FormatEx you could use Database.Format ( http://sourcemod.net/new-api/dbi/Database/Format ) for escaping this/all query strings (just to stay safe).
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.
Unable to pass unsafe values to a function. I think it's excess.
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.
Unable to pass unsafe values to a function.
You sure?
You can use !
for passing "unsafe values".
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.
Unable to pass unsafe values to a function.
You sure?
You can use!
for passing "unsafe values".
Thanks. I'm absolute forgot update query string. Now must be fixed. See: 72f3aaf
if ( GetClientAuthId( iTarget, AuthId_Steam2, szAuth, sizeof szAuth ) && szAuth[0] != 'B' && szAuth[9] != 'L' ) | ||
{ | ||
char szQuery[1024], szTargetName[MAX_NAME_LENGTH]; | ||
GetClientName( iTarget, szTargetName, sizeof szTargetName ); |
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.
GetClientName ( http://sourcemod.net/new-api/clients/GetClientName ) returns a bool, i would recommend an check if it's true.
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.
This value does not affect the workable and absolutely nothing will break if it is empty.
Description
Optimization code.
Strip useless or duplicated strings of code.
More dynamically code.
Replaced #define to static const.
No more failstate, just idle.
Prevent spam errors (as an example if you db under maintenance).
Motivation and Context
How Has This Been Tested?
Last SM and MM. Last SBPP. CSGO.
Types of changes
Checklist: