mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
1. Added command for runtime toggle 2. Changed where tick time is captured to properly capture per-tick statistics (matching cmangos playerbots)
107 lines
3.4 KiB
C++
107 lines
3.4 KiB
C++
/*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
* option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "BattleGroundTactics.h"
|
|
#include "Chat.h"
|
|
#include "GuildTaskMgr.h"
|
|
#include "PerformanceMonitor.h"
|
|
#include "PlayerbotMgr.h"
|
|
#include "RandomPlayerbotMgr.h"
|
|
#include "ScriptMgr.h"
|
|
|
|
using namespace Acore::ChatCommands;
|
|
|
|
class playerbots_commandscript : public CommandScript
|
|
{
|
|
public:
|
|
playerbots_commandscript() : CommandScript("playerbots_commandscript") {}
|
|
|
|
ChatCommandTable GetCommands() const override
|
|
{
|
|
static ChatCommandTable playerbotsDebugCommandTable = {
|
|
{"bg", HandleDebugBGCommand, SEC_GAMEMASTER, Console::Yes},
|
|
};
|
|
static ChatCommandTable playerbotsCommandTable = {
|
|
{"bot", HandlePlayerbotCommand, SEC_PLAYER, Console::No},
|
|
{"gtask", HandleGuildTaskCommand, SEC_GAMEMASTER, Console::Yes},
|
|
{"pmon", HandlePerfMonCommand, SEC_GAMEMASTER, Console::Yes},
|
|
{"rndbot", HandleRandomPlayerbotCommand, SEC_GAMEMASTER, Console::Yes},
|
|
{"debug", playerbotsDebugCommandTable},
|
|
};
|
|
|
|
static ChatCommandTable commandTable = {
|
|
{"playerbots", playerbotsCommandTable},
|
|
};
|
|
|
|
return commandTable;
|
|
}
|
|
|
|
static bool HandlePlayerbotCommand(ChatHandler* handler, char const* args)
|
|
{
|
|
return PlayerbotMgr::HandlePlayerbotMgrCommand(handler, args);
|
|
}
|
|
|
|
static bool HandleRandomPlayerbotCommand(ChatHandler* handler, char const* args)
|
|
{
|
|
return RandomPlayerbotMgr::HandlePlayerbotConsoleCommand(handler, args);
|
|
}
|
|
|
|
static bool HandleGuildTaskCommand(ChatHandler* handler, char const* args)
|
|
{
|
|
return GuildTaskMgr::HandleConsoleCommand(handler, args);
|
|
}
|
|
|
|
static bool HandlePerfMonCommand(ChatHandler* handler, char const* args)
|
|
{
|
|
if (!strcmp(args, "reset"))
|
|
{
|
|
sPerformanceMonitor->Reset();
|
|
return true;
|
|
}
|
|
|
|
if (!strcmp(args, "tick"))
|
|
{
|
|
sPerformanceMonitor->PrintStats(true, false);
|
|
return true;
|
|
}
|
|
|
|
if (!strcmp(args, "stack"))
|
|
{
|
|
sPerformanceMonitor->PrintStats(false, true);
|
|
return true;
|
|
}
|
|
|
|
if (!strcmp(args, "toggle"))
|
|
{
|
|
sPlayerbotAIConfig->perfMonEnabled = !sPlayerbotAIConfig->perfMonEnabled;
|
|
if (sPlayerbotAIConfig->perfMonEnabled)
|
|
LOG_INFO("playerbots", "Performance monitor enabled");
|
|
else
|
|
LOG_INFO("playerbots", "Performance monitor disabled");
|
|
return true;
|
|
}
|
|
|
|
sPerformanceMonitor->PrintStats();
|
|
return true;
|
|
}
|
|
|
|
static bool HandleDebugBGCommand(ChatHandler* handler, char const* args)
|
|
{
|
|
return BGTactics::HandleConsoleCommand(handler, args);
|
|
}
|
|
};
|
|
|
|
void AddSC_playerbots_commandscript() { new playerbots_commandscript(); }
|