diff options
author | rubidium <rubidium@openttd.org> | 2010-11-18 23:31:06 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-11-18 23:31:06 +0000 |
commit | 924a924907c608cb168fdf3265f6e6f2e883fcf6 (patch) | |
tree | 443a0351c39c12094063f0cf0de9966122bc7cce /src | |
parent | 40258d927fecaf3c2e6683718ae7dfa6c0443212 (diff) | |
download | openttd-924a924907c608cb168fdf3265f6e6f2e883fcf6.tar.xz |
(svn r21250) -Fix [FS#3952]: Rescanning AIs didn't "forget" removed AIs
Diffstat (limited to 'src')
-rw-r--r-- | src/ai/ai_gui.cpp | 3 | ||||
-rw-r--r-- | src/ai/ai_scanner.cpp | 13 | ||||
-rw-r--r-- | src/ai/ai_scanner.hpp | 5 | ||||
-rw-r--r-- | src/console_cmds.cpp | 1 |
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; } |