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

Add base CommandIterator implementation #819

Merged
merged 2 commits into from Jul 10, 2018
Merged

Add base CommandIterator implementation #819

merged 2 commits into from Jul 10, 2018

Conversation

@Headline
Copy link
Member

@Headline Headline commented May 26, 2018

Closes #742

Essentially this adds a methodmap for the existing command iterator, but in the more accepted iteration style that we're using nowadays which allows us to add more info as we see fit, without breaking older plugins. Related to this, I also added an IPlugin* to ConCmdInfo so we're able to track which plugin made what command, and this plugin handle is exposed through the iterator.

My test script for this PR is as follows

public void OnPluginStart()
{
	CommandIterator it = new CommandIterator();
	
	while (it.Next())
	{
		char name[128];
		it.GetName(name, sizeof(name));
		char desc[128];
		it.GetDescription(desc, sizeof(desc));
		
		int flags = it.Flags;
		char plugin[128];		
		GetPluginFilename(it.Plugin, plugin, sizeof(plugin));
		PrintToServer("%s - %s (created by %s) - flagbits: %08b", name, desc, plugin, flags);
	}
}

And the beautiful output given can be seen here

sm plugins load test
ff -  (created by basetriggers.smx) - flagbits: 00000000
listmaps -  (created by nextmap.smx) - flagbits: 00000000
motd -  (created by basetriggers.smx) - flagbits: 00000000
nextmap -  (created by basetriggers.smx) - flagbits: 00000000
sm_abortban - sm_abortban (created by basebans.smx) - flagbits: 00000000
sm_addban - sm_addban <time> <steamid> [reason] (created by basebans.smx) - flagbits: 00000000
sm_addweapon - A command to add map weapons (created by hl_weaponspawner.smx) - flagbits: 00100000
sm_addweapons - A command to add map weapons (created by hl_weaponspawner.smx) - flagbits: 00100000
sm_admin - Displays the admin menu (created by adminmenu.smx) - flagbits: 00000010
sm_ban - sm_ban <#userid|name> <minutes|0> [reason] (created by basebans.smx) - flagbits: 00001000
sm_banip - sm_banip <ip|#userid|name> <time> [reason] (created by basebans.smx) - flagbits: 00001000
sm_beacon - sm_beacon <#userid|name> [0/1] (created by funcommands.smx) - flagbits: 00100000
sm_blind - sm_blind <#userid|name> [amount] - Leave amount off to reset. (created by funcommands.smx) - flagbits: 00100000
sm_burn - sm_burn <#userid|name> [time] (created by funcommands.smx) - flagbits: 00100000
sm_cancelvote - sm_cancelvote (created by basecommands.smx) - flagbits: 00000000
sm_chat - sm_chat <message> - sends message to admins (created by basechat.smx) - flagbits: 00000000
sm_cookies - sm_cookies <name> [value] (created by clientprefs.smx) - flagbits: 00000000
sm_csay - sm_csay <message> - sends centered message to all players (created by basechat.smx) - flagbits: 00000000
sm_cvar - sm_cvar <cvar> [value] (created by basecommands.smx) - flagbits: 10000000
sm_drug - sm_drug <#userid|name> [0/1] (created by funcommands.smx) - flagbits: 00100000
sm_execcfg - sm_execcfg <filename> (created by basecommands.smx) - flagbits: 00000000
sm_firebomb - sm_firebomb <#userid|name> [0/1] (created by funcommands.smx) - flagbits: 00100000
sm_freeze - sm_freeze <#userid|name> [time] (created by funcommands.smx) - flagbits: 00100000
sm_freezebomb - sm_freezebomb <#userid|name> [0/1] (created by funcommands.smx) - flagbits: 00100000
sm_gag - sm_gag <player> - Removes a player's ability to use chat. (created by basecomm.smx) - flagbits: 00000000
sm_gravity - sm_gravity <#userid|name> [amount] - Leave amount off to reset. Amount is 0.0 through 5.0 (created by funcommands.smx) - flagbits: 00100000
sm_help - Displays SourceMod commands and descriptions (created by adminhelp.smx) - flagbits: 00000000
sm_hsay - sm_hsay <message> - sends hint message to all players (created by basechat.smx) - flagbits: 00000000
sm_kick - sm_kick <#userid|name> [reason] (created by basecommands.smx) - flagbits: 00000100
sm_map - sm_map <map> (created by basecommands.smx) - flagbits: 01000000
sm_maphistory - Shows the most recent maps played (created by nextmap.smx) - flagbits: 01000000
sm_msay - sm_msay <message> - sends message as a menu panel (created by basechat.smx) - flagbits: 00000000
sm_mute - sm_mute <player> - Removes a player's ability to use voice. (created by basecomm.smx) - flagbits: 00000000
sm_noclip - sm_noclip <#userid|name> (created by funcommands.smx) - flagbits: 00100000
sm_play - sm_play <#userid|name> <filename> (created by sounds.smx) - flagbits: 00000010
sm_psay - sm_psay <name or #userid> <message> - sends private message (created by basechat.smx) - flagbits: 00000000
sm_rcon - sm_rcon <args> (created by basecommands.smx) - flagbits: 00000000
sm_reloadadmins - sm_reloadadmins (created by basecommands.smx) - flagbits: 00001000
sm_rename - sm_rename <#userid|name> (created by playercommands.smx) - flagbits: 00100000
sm_resetcvar - sm_resetcvar <cvar> (created by basecommands.smx) - flagbits: 10000000
sm_revote -  (created by basecommands.smx) - flagbits: 00000000
sm_say - sm_say <message> - sends message to all players (created by basechat.smx) - flagbits: 00000000
sm_searchcmd - Searches SourceMod commands (created by adminhelp.smx) - flagbits: 00000000
sm_settings -  (created by clientprefs.smx) - flagbits: 00000000
sm_silence - sm_silence <player> - Removes a player's ability to use voice or chat. (created by basecomm.smx) - flagbits: 00000000
sm_slap - sm_slap <#userid|name> [damage] (created by playercommands.smx) - flagbits: 00100000
sm_slay - sm_slay <#userid|name> (created by playercommands.smx) - flagbits: 00100000
sm_timebomb - sm_timebomb <#userid|name> [0/1] (created by funcommands.smx) - flagbits: 00100000
sm_tsay - sm_tsay [color] <message> - sends top-left message to all players (created by basechat.smx) - flagbits: 00000000
sm_unban - sm_unban <steamid|ip> (created by basebans.smx) - flagbits: 00010000
sm_ungag - sm_ungag <player> - Restores a player's ability to use chat. (created by basecomm.smx) - flagbits: 00000000
sm_unmute - sm_unmute <player> - Restores a player's ability to use voice. (created by basecomm.smx) - flagbits: 00000000
sm_unsilence - sm_unsilence <player> - Restores a player's ability to use voice and chat. (created by basecomm.smx) - flagbits: 00000000
sm_vote - sm_vote <question> [Answer1] [Answer2] ... [Answer5] (created by basevotes.smx) - flagbits: 00000000
sm_votealltalk - sm_votealltalk (created by funvotes.smx) - flagbits: 00000000
sm_voteban - sm_voteban <player> [reason] (created by basevotes.smx) - flagbits: 00001000
sm_voteburn - sm_voteburn <player> (created by funvotes.smx) - flagbits: 00100000
sm_voteff - sm_voteff (created by funvotes.smx) - flagbits: 00000000
sm_votegravity - sm_votegravity <amount> [amount2] ... [amount5] (created by funvotes.smx) - flagbits: 00000000
sm_votekick - sm_votekick <player> [reason] (created by basevotes.smx) - flagbits: 00000100
sm_votemap - sm_votemap <mapname> [mapname2] ... [mapname5]  (created by basevotes.smx) - flagbits: 01000000
sm_voteslay - sm_voteslay <player> (created by funvotes.smx) - flagbits: 00100000
sm_who - sm_who [#userid|name] (created by basecommands.smx) - flagbits: 00000010
[SM] Loaded plugin test.smx successfully.
@KyleSanderson
Copy link
Member

@KyleSanderson KyleSanderson commented Jun 16, 2018

Defensively I'd store the plugin handle instead of the ptr but it's released in OnPluginDestroyed so it's probably fine?

I think this is okay.

@Headline
Copy link
Member Author

@Headline Headline commented Jun 19, 2018

@KyleSanderson Yeah I think it's okay :p

@psychonic psychonic merged commit 28f1ea8 into alliedmodders:master Jul 10, 2018
2 checks passed
@Headline Headline deleted the cmd-iter branch Jul 10, 2018
@alliedmodders alliedmodders deleted a comment from Headline Oct 29, 2018
@InvexByte
Copy link
Contributor

@InvexByte InvexByte commented Jul 12, 2019

Late but nice work @Headline 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants