summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-02-07 09:51:16 +0000
committerrubidium <rubidium@openttd.org>2011-02-07 09:51:16 +0000
commit79fd8a362bf2776256c4065414015c575b58fa3e (patch)
tree268802d0f468383f140aef73101578aa4a2aabf4
parent64cba95fbedc66c1da8802380e9eb85d6ad6abe4 (diff)
downloadopenttd-79fd8a362bf2776256c4065414015c575b58fa3e.tar.xz
(svn r22007) -Change: only show one AI per unique ID instead of all versions in the output of "openttd -h"
-rw-r--r--src/ai/ai.hpp2
-rw-r--r--src/ai/ai_core.cpp4
-rw-r--r--src/ai/ai_scanner.cpp7
-rw-r--r--src/ai/ai_scanner.hpp2
-rw-r--r--src/openttd.cpp2
5 files changed, 9 insertions, 8 deletions
diff --git a/src/ai/ai.hpp b/src/ai/ai.hpp
index 67ce470cd..1c61d917f 100644
--- a/src/ai/ai.hpp
+++ b/src/ai/ai.hpp
@@ -125,7 +125,7 @@ public:
static int GetStartNextTime();
/** Wrapper function for AIScanner::GetAIConsoleList */
- static char *GetConsoleList(char *p, const char *last);
+ static char *GetConsoleList(char *p, const char *last, bool newest_only = false);
/** Wrapper function for AIScanner::GetAIConsoleLibraryList */
static char *GetConsoleLibraryList(char *p, const char *last);
/** Wrapper function for AIScanner::GetAIInfoList */
diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp
index f2bfc4292..1c7005b74 100644
--- a/src/ai/ai_core.cpp
+++ b/src/ai/ai_core.cpp
@@ -289,9 +289,9 @@ void CcAI(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
return DAYS_IN_YEAR;
}
-/* static */ char *AI::GetConsoleList(char *p, const char *last)
+/* static */ char *AI::GetConsoleList(char *p, const char *last, bool newest_only)
{
- return AI::ai_scanner->GetAIConsoleList(p, last);
+ return AI::ai_scanner->GetAIConsoleList(p, last, newest_only);
}
/* static */ char *AI::GetConsoleLibraryList(char *p, const char *last)
diff --git a/src/ai/ai_scanner.cpp b/src/ai/ai_scanner.cpp
index 90bdd99c7..9eb018b3a 100644
--- a/src/ai/ai_scanner.cpp
+++ b/src/ai/ai_scanner.cpp
@@ -330,11 +330,12 @@ AIInfo *AIScanner::FindInfo(const char *nameParam, int versionParam, bool force_
return info;
}
-char *AIScanner::GetAIConsoleList(char *p, const char *last) const
+char *AIScanner::GetAIConsoleList(char *p, const char *last, bool newest_only) const
{
p += seprintf(p, last, "List of AIs:\n");
- AIInfoList::const_iterator it = this->info_list.begin();
- for (; it != this->info_list.end(); it++) {
+ const AIInfoList &list = newest_only ? this->info_single_list : this->info_list;
+ AIInfoList::const_iterator it = list.begin();
+ for (; it != list.end(); it++) {
AIInfo *i = (*it).second;
p += seprintf(p, last, "%10s (v%d): %s\n", i->GetName(), i->GetVersion(), i->GetDescription());
}
diff --git a/src/ai/ai_scanner.hpp b/src/ai/ai_scanner.hpp
index cc183d887..fee16d608 100644
--- a/src/ai/ai_scanner.hpp
+++ b/src/ai/ai_scanner.hpp
@@ -53,7 +53,7 @@ public:
/**
* Get the list of available AIs for the console.
*/
- char *GetAIConsoleList(char *p, const char *last) const;
+ char *GetAIConsoleList(char *p, const char *last, bool newest_only) const;
/**
* Get the list of available AI Libraries for the console.
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 1a7fa7c8b..7d41cfb3f 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -204,7 +204,7 @@ static void ShowHelp()
/* We need to initialize the AI, so it finds the AIs */
TarScanner::DoScan();
AI::Initialize();
- p = AI::GetConsoleList(p, lastof(buf));
+ p = AI::GetConsoleList(p, lastof(buf), true);
AI::Uninitialize(true);
/* ShowInfo put output to stderr, but version information should go