summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-11-14 21:40:39 +0000
committerrubidium <rubidium@openttd.org>2011-11-14 21:40:39 +0000
commit4ae8bbea0706aa6c878d713489056ef634aa2d6d (patch)
tree366dec593752264fe905cd51d2478d88caaba56e /src
parent387e410f3e7898cadec041f2849bc949810544bb (diff)
downloadopenttd-4ae8bbea0706aa6c878d713489056ef634aa2d6d.tar.xz
(svn r23222) -Codechange: reduce tar scanning calls to the bare minimum
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_core.cpp8
-rw-r--r--src/console_cmds.cpp2
-rw-r--r--src/network/network_content_gui.cpp4
-rw-r--r--src/newgrf_config.cpp1
-rw-r--r--src/newgrf_gui.cpp1
-rw-r--r--src/openttd.cpp4
6 files changed, 12 insertions, 8 deletions
diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp
index 18eeef3b0..0e7667ba4 100644
--- a/src/ai/ai_core.cpp
+++ b/src/ai/ai_core.cpp
@@ -17,6 +17,7 @@
#include "../network/network.h"
#include "../window_func.h"
#include "../command_func.h"
+#include "../fileio_func.h"
#include "ai_scanner.hpp"
#include "ai_instance.hpp"
#include "ai_config.hpp"
@@ -136,7 +137,10 @@
if (AI::ai_scanner != NULL) AI::Uninitialize(true);
AI::frame_counter = 0;
- if (AI::ai_scanner == NULL) AI::ai_scanner = new AIScanner();
+ if (AI::ai_scanner == NULL) {
+ TarScanner::DoScan(TarScanner::AI);
+ AI::ai_scanner = new AIScanner();
+ }
}
/* static */ void AI::Uninitialize(bool keepConfig)
@@ -325,6 +329,8 @@ void CcAI(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
/* static */ void AI::Rescan()
{
+ TarScanner::DoScan(TarScanner::AI);
+
AI::ai_scanner->RescanAIDir();
ResetConfig();
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 043d43b0c..85731de43 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -1251,7 +1251,6 @@ DEF_CONSOLE_CMD(ConRescanAI)
return true;
}
- TarScanner::DoScan(TarScanner::AI);
AI::Rescan();
return true;
@@ -1265,7 +1264,6 @@ DEF_CONSOLE_CMD(ConRescanNewGRF)
return true;
}
- TarScanner::DoScan(TarScanner::NEWGRF);
ScanNewGRFFiles(NULL);
return true;
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index 782f3d52c..5a7b0c281 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -91,7 +91,7 @@ public:
switch (*iter) {
case CONTENT_TYPE_AI:
case CONTENT_TYPE_AI_LIBRARY:
- mode |= TarScanner::AI;
+ /* AI::Rescan calls the scanner. */
break;
case CONTENT_TYPE_BASE_GRAPHICS:
@@ -101,7 +101,7 @@ public:
break;
case CONTENT_TYPE_NEWGRF:
- mode |= TarScanner::NEWGRF;
+ /* ScanNewGRFFiles calls the scanner. */
break;
case CONTENT_TYPE_SCENARIO:
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index d62ab8b9b..93190cbc9 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -635,6 +635,7 @@ void DoScanNewGRFFiles(void *callback)
_modal_progress_work_mutex->BeginCritical();
ClearGRFConfigList(&_all_grfs);
+ TarScanner::DoScan(TarScanner::NEWGRF);
DEBUG(grf, 1, "Scanning for NewGRFs");
uint num = GRFFileScanner::DoScan();
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index f0a430d73..b00b70540 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -1172,7 +1172,6 @@ struct NewGRFWindow : public QueryStringBaseWindow, NewGRFScanCallback {
case SNGRFS_RESCAN_FILES:
case SNGRFS_RESCAN_FILES2:
- TarScanner::DoScan(TarScanner::NEWGRF);
ScanNewGRFFiles(this);
break;
}
diff --git a/src/openttd.cpp b/src/openttd.cpp
index c82d7d823..5033eff35 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -621,7 +621,7 @@ int ttd_main(int argc, char *argv[])
* The next two functions are needed to list the graphics sets. We can't do them earlier
* because then we cannot show it on the debug console as that hasn't been configured yet. */
DeterminePaths(argv[0]);
- TarScanner::DoScan(TarScanner::AI | TarScanner::BASESET);
+ TarScanner::DoScan(TarScanner::BASESET);
BaseGraphics::FindSets();
BaseSounds::FindSets();
BaseMusic::FindSets();
@@ -636,7 +636,7 @@ int ttd_main(int argc, char *argv[])
#endif
DeterminePaths(argv[0]);
- TarScanner::DoScan(TarScanner::ALL);
+ TarScanner::DoScan(TarScanner::BASESET | TarScanner::SCENARIO);
BaseGraphics::FindSets();
BaseSounds::FindSets();
BaseMusic::FindSets();