mgr: added `yb exec` command for debugging purposes
This commit is contained in:
parent
7b7ae7020b
commit
259dd18330
4 changed files with 37 additions and 10 deletions
|
|
@ -31,11 +31,12 @@ public:
|
||||||
struct BotCmd {
|
struct BotCmd {
|
||||||
String name, format, help;
|
String name, format, help;
|
||||||
Handler handler = nullptr;
|
Handler handler = nullptr;
|
||||||
|
bool visible = true;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BotCmd () = default;
|
explicit BotCmd () = default;
|
||||||
|
|
||||||
BotCmd (StringRef name, StringRef format, StringRef help, Handler handler) : name (name), format (format), help (help), handler (cr::move (handler))
|
BotCmd (StringRef name, StringRef format, StringRef help, Handler handler, bool visible = true) : name (name), format (format), help (help), handler (cr::move (handler)), visible (visible)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -100,6 +101,7 @@ private:
|
||||||
int cmdList ();
|
int cmdList ();
|
||||||
int cmdCvars ();
|
int cmdCvars ();
|
||||||
int cmdShowCustom ();
|
int cmdShowCustom ();
|
||||||
|
int cmdExec ();
|
||||||
int cmdNode ();
|
int cmdNode ();
|
||||||
int cmdNodeOn ();
|
int cmdNodeOn ();
|
||||||
int cmdNodeOff ();
|
int cmdNodeOff ();
|
||||||
|
|
@ -125,7 +127,7 @@ private:
|
||||||
int cmdNodeIterateCamp ();
|
int cmdNodeIterateCamp ();
|
||||||
int cmdNodeShowStats ();
|
int cmdNodeShowStats ();
|
||||||
int cmdNodeFileInfo ();
|
int cmdNodeFileInfo ();
|
||||||
int cmdAdjustHeight ();
|
int cmdNodeAdjustHeight ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int menuMain (int item);
|
int menuMain (int item);
|
||||||
|
|
|
||||||
|
|
@ -776,6 +776,9 @@ public:
|
||||||
debugMsgInternal (strings.format (fmt, cr::forward <Args> (args)...));
|
debugMsgInternal (strings.format (fmt, cr::forward <Args> (args)...));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// execute client command helper
|
||||||
|
template <typename ...Args> void issueCommand (const char *fmt, Args &&...args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// returns true if bot is using a sniper rifle
|
// returns true if bot is using a sniper rifle
|
||||||
bool usesSniper () const {
|
bool usesSniper () const {
|
||||||
|
|
@ -826,9 +829,6 @@ private:
|
||||||
bool usesKnife () const {
|
bool usesKnife () const {
|
||||||
return m_weaponType == WeaponType::Melee;
|
return m_weaponType == WeaponType::Melee;
|
||||||
}
|
}
|
||||||
|
|
||||||
// execute client command helper
|
|
||||||
template <typename ...Args> void issueCommand (const char *fmt, Args &&...args);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
|
||||||
|
|
@ -320,6 +320,27 @@ int BotControl::cmdShowCustom () {
|
||||||
return BotCommandResult::Handled;
|
return BotCommandResult::Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int BotControl::cmdExec () {
|
||||||
|
enum args { alias = 1, target, command };
|
||||||
|
|
||||||
|
if (!hasArg (target) || !hasArg (command)) {
|
||||||
|
return BotCommandResult::BadFormat;
|
||||||
|
}
|
||||||
|
const auto userId = intValue (target);
|
||||||
|
|
||||||
|
// find our little target
|
||||||
|
auto bot = bots.findBotByIndex (userId);
|
||||||
|
|
||||||
|
// bailout if not bot
|
||||||
|
if (!bot) {
|
||||||
|
msg ("Bot with #%d not found or not a bot.", userId);
|
||||||
|
return BotCommandResult::Handled;
|
||||||
|
}
|
||||||
|
bot->issueCommand (strValue (command).chars ());
|
||||||
|
|
||||||
|
return BotCommandResult::Handled;
|
||||||
|
}
|
||||||
|
|
||||||
int BotControl::cmdNode () {
|
int BotControl::cmdNode () {
|
||||||
enum args { root, alias, cmd, cmd2 };
|
enum args { root, alias, cmd, cmd2 };
|
||||||
|
|
||||||
|
|
@ -383,7 +404,7 @@ int BotControl::cmdNode () {
|
||||||
addGraphCmd ("upload", "upload", "Uploads created graph to graph database.", &BotControl::cmdNodeUpload);
|
addGraphCmd ("upload", "upload", "Uploads created graph to graph database.", &BotControl::cmdNodeUpload);
|
||||||
addGraphCmd ("stats", "stats [noarguments]", "Shows the stats about node types on the map.", &BotControl::cmdNodeShowStats);
|
addGraphCmd ("stats", "stats [noarguments]", "Shows the stats about node types on the map.", &BotControl::cmdNodeShowStats);
|
||||||
addGraphCmd ("fileinfo", "fileinfo [noarguments]", "Shows basic information about graph file.", &BotControl::cmdNodeFileInfo);
|
addGraphCmd ("fileinfo", "fileinfo [noarguments]", "Shows basic information about graph file.", &BotControl::cmdNodeFileInfo);
|
||||||
addGraphCmd ("adjust_height", "adjust_height [height offset]", "Modifies all the graph nodes height (z-component) with specified offset.", &BotControl::cmdAdjustHeight);
|
addGraphCmd ("adjust_height", "adjust_height [height offset]", "Modifies all the graph nodes height (z-component) with specified offset.", &BotControl::cmdNodeAdjustHeight);
|
||||||
|
|
||||||
// add path commands
|
// add path commands
|
||||||
addGraphCmd ("path_create", "path_create [noarguments]", "Opens and displays path creation menu.", &BotControl::cmdNodePathCreate);
|
addGraphCmd ("path_create", "path_create [noarguments]", "Opens and displays path creation menu.", &BotControl::cmdNodePathCreate);
|
||||||
|
|
@ -961,7 +982,7 @@ int BotControl::cmdNodeFileInfo () {
|
||||||
return BotCommandResult::Handled;
|
return BotCommandResult::Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BotControl::cmdAdjustHeight () {
|
int BotControl::cmdNodeAdjustHeight () {
|
||||||
enum args { graph_cmd = 1, cmd, offset };
|
enum args { graph_cmd = 1, cmd, offset };
|
||||||
|
|
||||||
if (!hasArg (offset)) {
|
if (!hasArg (offset)) {
|
||||||
|
|
@ -1876,6 +1897,9 @@ bool BotControl::executeCommands () {
|
||||||
msg ("valid commands are: ");
|
msg ("valid commands are: ");
|
||||||
|
|
||||||
for (auto &item : m_cmds) {
|
for (auto &item : m_cmds) {
|
||||||
|
if (!item.visible) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
msg (" %-14.11s - %s", item.name.split ("/").first (), String (conf.translate (item.help)).lowercase ());
|
msg (" %-14.11s - %s", item.name.split ("/").first (), String (conf.translate (item.help)).lowercase ());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -2151,7 +2175,8 @@ BotControl::BotControl () {
|
||||||
m_cmds.emplace ("list/listbots", "list [noarguments]", "Lists the bots currently playing on server.", &BotControl::cmdList);
|
m_cmds.emplace ("list/listbots", "list [noarguments]", "Lists the bots currently playing on server.", &BotControl::cmdList);
|
||||||
m_cmds.emplace ("graph/g/wp/wpt/waypoint", "graph [help]", "Handles graph operations.", &BotControl::cmdNode);
|
m_cmds.emplace ("graph/g/wp/wpt/waypoint", "graph [help]", "Handles graph operations.", &BotControl::cmdNode);
|
||||||
m_cmds.emplace ("cvars", "cvars [save|save_map|cvar|defaults]", "Display all the cvars with their descriptions.", &BotControl::cmdCvars);
|
m_cmds.emplace ("cvars", "cvars [save|save_map|cvar|defaults]", "Display all the cvars with their descriptions.", &BotControl::cmdCvars);
|
||||||
m_cmds.emplace ("show_custom", "show_custom [noarguments]", "Shows the current values from custom.cfg.", &BotControl::cmdShowCustom);
|
m_cmds.emplace ("show_custom", "show_custom [noarguments]", "Shows the current values from custom.cfg.", &BotControl::cmdShowCustom, false);
|
||||||
|
m_cmds.emplace ("exec", "exec [user_id] [command]", "Executes a client command on bot entity.", &BotControl::cmdExec);
|
||||||
|
|
||||||
// declare the menus
|
// declare the menus
|
||||||
createMenus ();
|
createMenus ();
|
||||||
|
|
|
||||||
|
|
@ -980,8 +980,8 @@ void Game::applyGameModes () {
|
||||||
static ConVarRef zp_delay ("zp_delay");
|
static ConVarRef zp_delay ("zp_delay");
|
||||||
|
|
||||||
// update our ignore timer if zp_elay exists
|
// update our ignore timer if zp_elay exists
|
||||||
if (zp_delay.exists () && zp_delay.value () > 0.0f && cv_ignore_enemies_after_spawn_time.float_ () < 1.0f) {
|
if (zp_delay.exists () && zp_delay.value () > 0.0f) {
|
||||||
cv_ignore_enemies_after_spawn_time.set (zp_delay.value () + 2.0f);
|
cv_ignore_enemies_after_spawn_time.set (zp_delay.value () + 3.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue