summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_gui.cpp3
-rw-r--r--src/ai/ai_scanner.cpp13
-rw-r--r--src/ai/ai_scanner.hpp5
-rw-r--r--src/console_cmds.cpp1
4 files changed, 21 insertions, 1 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index a29c169eb..bf1357e71 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -191,6 +191,9 @@ struct AIListWindow : public Window {
virtual void OnInvalidateData(int data)
{
this->vscroll->SetCount((int)this->ai_info_list->size() + 1);
+
+ /* selected goes from -1 .. length of ai list - 1. */
+ this->selected = min(this->selected, this->vscroll->GetCount() - 2);
}
};
diff --git a/src/ai/ai_scanner.cpp b/src/ai/ai_scanner.cpp
index 6971a6956..36607c217 100644
--- a/src/ai/ai_scanner.cpp
+++ b/src/ai/ai_scanner.cpp
@@ -22,6 +22,8 @@
void AIScanner::RescanAIDir()
{
+ /* Get rid of information of old AIs. */
+ this->Reset();
this->ScanScriptDir("info.nut", AI_DIR);
this->ScanScriptDir("library.nut", AI_LIBRARY_DIR);
}
@@ -59,7 +61,7 @@ AIScanner::AIScanner() :
AI_CreateAIInfoDummy(this->engine->GetVM());
}
-AIScanner::~AIScanner()
+void AIScanner::Reset()
{
AIInfoList::iterator it = this->info_list.begin();
for (; it != this->info_list.end(); it++) {
@@ -76,6 +78,15 @@ AIScanner::~AIScanner()
delete (*lit).second;
}
+ this->info_list.clear();
+ this->info_single_list.clear();
+ this->library_list.clear();
+}
+
+AIScanner::~AIScanner()
+{
+ this->Reset();
+
delete this->info_dummy;
}
diff --git a/src/ai/ai_scanner.hpp b/src/ai/ai_scanner.hpp
index f88555699..fce07f651 100644
--- a/src/ai/ai_scanner.hpp
+++ b/src/ai/ai_scanner.hpp
@@ -84,6 +84,11 @@ private:
*/
void ScanAIDir();
+ /**
+ * Reset all allocated lists.
+ */
+ void Reset();
+
AIInfo *info_dummy;
AIInfoList info_list;
AIInfoList info_single_list;
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 56cc88edf..8f4cf50b9 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -1160,6 +1160,7 @@ DEF_CONSOLE_CMD(ConRescanAI)
TarScanner::DoScan();
AI::Rescan();
InvalidateWindowData(WC_AI_LIST, 0, 1);
+ SetWindowDirty(WC_AI_SETTINGS, 0);
return true;
}