Skip to content

Commit

Permalink
shouldn't have to manually count the hints array size!
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronkirkham committed Aug 17, 2019
1 parent d6efdce commit ee03403
Show file tree
Hide file tree
Showing 3 changed files with 619 additions and 621 deletions.
38 changes: 19 additions & 19 deletions src/commands/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,6 @@
class EventCommand : public ICommand
{
public:
std::array<const char*, 15> m_Hints = {
"__showfps",
"__reload_world",
"ply.invulnerable",
"ply.vulnerable",
"ply.unlimitedammo.enable",
"ply.unlimitedammo.disable",
"ply.ammo.givemax",
"ply.pause",
"ply.unpause",
"ply.vehicle.burn",
"moon_gravity_on",
"moon_gravity_off",
"debug.vehicle.incrementtint",
"vocals.rico.enable",
"vocals.rico.disable",
};

virtual const char* GetCommand() override
{
return "event";
Expand All @@ -40,8 +22,26 @@ class EventCommand : public ICommand

virtual std::vector<std::string> GetHints(const std::string& arguments) override
{
static std::array hints{
"__showfps",
"__reload_world",
"ply.invulnerable",
"ply.vulnerable",
"ply.unlimitedammo.enable",
"ply.unlimitedammo.disable",
"ply.ammo.givemax",
"ply.pause",
"ply.unpause",
"ply.vehicle.burn",
"moon_gravity_on",
"moon_gravity_off",
"debug.vehicle.incrementtint",
"vocals.rico.enable",
"vocals.rico.disable",
};

std::vector<std::string> result;
std::copy_if(m_Hints.begin(), m_Hints.end(), std::back_inserter(result),
std::copy_if(hints.begin(), hints.end(), std::back_inserter(result),
[&](const std::string& item) { return item.find(arguments) != std::string::npos; });

return result;
Expand Down
Loading

0 comments on commit ee03403

Please sign in to comment.