summaryrefslogtreecommitdiff
path: root/src/console_cmds.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2011-01-03 14:52:30 +0000
committeryexo <yexo@openttd.org>2011-01-03 14:52:30 +0000
commit8e3e93b96ff0e575c798ed443825c39ff192aa58 (patch)
treea905c62e1fe00581214ec95247ff4578052bd7d0 /src/console_cmds.cpp
parent37b9c311184c21dda3da165c18933b707d2a227b (diff)
downloadopenttd-8e3e93b96ff0e575c798ed443825c39ff192aa58.tar.xz
(svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
Diffstat (limited to 'src/console_cmds.cpp')
-rw-r--r--src/console_cmds.cpp34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 4012c1c8a..a7d855ab2 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -995,21 +995,40 @@ DEF_CONSOLE_CMD(ConRestart)
}
#ifdef ENABLE_AI
-DEF_CONSOLE_CMD(ConListAI)
+/**
+ * Print a text buffer line by line to the console. Lines are seperated by '\n'.
+ * @param buf The buffer to print.
+ * @note All newlines are replace by '\0' characters.
+ */
+static void PrintLineByLine(char *buf)
{
- char buf[4096];
- char *p = &buf[0];
- p = AI::GetConsoleList(p, lastof(buf));
-
- p = &buf[0];
+ char *p = buf;
/* Print output line by line */
- for (char *p2 = &buf[0]; *p2 != '\0'; p2++) {
+ for (char *p2 = buf; *p2 != '\0'; p2++) {
if (*p2 == '\n') {
*p2 = '\0';
IConsolePrintF(CC_DEFAULT, "%s", p);
p = p2 + 1;
}
}
+}
+
+DEF_CONSOLE_CMD(ConListAILibs)
+{
+ char buf[4096];
+ AI::GetConsoleLibraryList(buf, lastof(buf));
+
+ PrintLineByLine(buf);
+
+ return true;
+}
+
+DEF_CONSOLE_CMD(ConListAI)
+{
+ char buf[4096];
+ AI::GetConsoleList(buf, lastof(buf));
+
+ PrintLineByLine(buf);
return true;
}
@@ -1780,6 +1799,7 @@ void IConsoleStdLibRegister()
IConsoleAliasRegister("developer", "setting developer %+");
#ifdef ENABLE_AI
+ IConsoleCmdRegister("list_ai_libs", ConListAILibs);
IConsoleCmdRegister("list_ai", ConListAI);
IConsoleCmdRegister("reload_ai", ConReloadAI);
IConsoleCmdRegister("rescan_ai", ConRescanAI);