Skip to content
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

show_activity() functions overhaul #505

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
22 changes: 10 additions & 12 deletions plugins/include/amxmisc.inc
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,13 @@ stock show_activity(id, const name[], const fmt[], any:...)
if(!activity_init())
return;

static players[MAX_PLAYERS], pnum;
new players[MAX_PLAYERS], pnum;
get_players(players, pnum, "ch");

if(!pnum)
return;

static buffer[192], prefix[10], player;
new buffer[192], prefix[10], player;
vformat(buffer, charsmax(buffer), fmt, 4);
get_activity_prefix(id, prefix, charsmax(prefix));

Expand Down Expand Up @@ -256,7 +256,7 @@ stock show_activity_id(idtarget, idadmin, const name[], const fmt[], any:...)
if(!is_user_connected(idtarget) || !activity_init())
return;

static buffer[192], prefix[10];
new buffer[192], prefix[10];
vformat(buffer, charsmax(buffer), fmt, 5);
get_activity_prefix(idadmin, prefix, charsmax(prefix));

Expand Down Expand Up @@ -288,13 +288,13 @@ stock show_activity_key(const KeyWithoutName[], const KeyWithName[], const ___Ad
if(!activity_init())
return;

static players[MAX_PLAYERS], pnum;
new players[MAX_PLAYERS], pnum;
get_players(players, pnum, "ch");

if(!pnum)
return;

static buffer[192], key[192], player;
new buffer[192], key[192], player;

for(new i; i < pnum; i++)
{
Expand Down Expand Up @@ -337,20 +337,18 @@ stock show_activity_custom(id, const name[], const fmt[], any:...)
if(!activity_init())
return;

static buffer[192];
new buffer[192];
vformat(buffer, charsmax(buffer), fmt, 4);

if(!id)
{
static players[MAX_PLAYERS], pnum;
new players[MAX_PLAYERS], pnum;
get_players(players, pnum);

if(!pnum)
return

static player;

for(new i; i < pnum; i++)
for(new i, player; i < pnum; i++)
{
player = players[i];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new should be here.

Copy link
Contributor Author

@OciXCrom OciXCrom Aug 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm? It's already new.
// Nvm, that's the outdated review.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OciXCrom I mean inside for-loop block.

new player = players[i];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WPMGPRoSToTeMa It's declared inside the for-loop body.

for(new i, player; i < pnum; i++)

I think you're viewing the old version of the code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OciXCrom I mean its declaration should be moved to its first assignment.

Copy link
Member

@Arkshine Arkshine Aug 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You fool, never quote me! But yes, it doesn't matter much here as said KlIPPy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rsKliPPy That's exactly what I did. I declared the variable before the ";" in the loop like I always do, so I don't see a problem. I've always been told that declaring them in the actual loop is bad.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OciXCrom look the difference diffchecker/mergely/gist.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OciXCrom have you looked into this assembly? Do you have any questions/thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WPMGPRoSToTeMa I can't say that I understand much what that even means. Maybe you can explain? If it's not something extremely important, let's just keep it declared in the for() body for the sake of everyone knowing that that is the better way to do it.


Expand Down Expand Up @@ -441,12 +439,12 @@ stock replace_activity_data(id, const name[], buffer[], len)
{
if(contain(buffer, activity_ph_prefix) != -1)
{
static prefix[10];
new prefix[10];
get_activity_prefix(id, prefix, charsmax(prefix));
replace_all(buffer, len, activity_ph_prefix, prefix);
}

static cansee; cansee = can_see_admin_name(id);
new cansee = can_see_admin_name(id);

if(cansee != -1)
replace_all(buffer, len, activity_ph_name, cansee ? name : "");
Expand Down