summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/console_cmds.cpp1
-rw-r--r--src/network/network_content_gui.cpp3
-rw-r--r--src/newgrf_config.cpp46
-rw-r--r--src/newgrf_gui.cpp2
4 files changed, 25 insertions, 27 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index e5b8ad7e5..cf2444aac 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -1269,7 +1269,6 @@ DEF_CONSOLE_CMD(ConRescanNewGRF)
TarScanner::DoScan();
ScanNewGRFFiles();
- InvalidateWindowData(WC_GAME_OPTIONS, 0, GOID_NEWGRF_RESCANNED);
return true;
}
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index 50bb8cd14..498ef4918 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -115,9 +115,6 @@ public:
case CONTENT_TYPE_NEWGRF:
ScanNewGRFFiles();
- /* Yes... these are the NewGRF windows */
- InvalidateWindowClassesData(WC_SAVELOAD);
- InvalidateWindowData(WC_GAME_OPTIONS, 0, GOID_NEWGRF_RESCANNED);
break;
case CONTENT_TYPE_SCENARIO:
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index 1cde3ab24..88d1c9128 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -605,33 +605,37 @@ void ScanNewGRFFiles()
uint num = GRFFileScanner::DoScan();
DEBUG(grf, 1, "Scan complete, found %d files", num);
- if (num == 0 || _all_grfs == NULL) return;
-
- /* Sort the linked list using quicksort.
- * For that we first have to make an array, then sort and
- * then remake the linked list. */
- GRFConfig **to_sort = MallocT<GRFConfig*>(num);
-
- uint i = 0;
- for (GRFConfig *p = _all_grfs; p != NULL; p = p->next, i++) {
- to_sort[i] = p;
- }
- /* Number of files is not necessarily right */
- num = i;
+ if (num != 0 && _all_grfs != NULL) {
+ /* Sort the linked list using quicksort.
+ * For that we first have to make an array, then sort and
+ * then remake the linked list. */
+ GRFConfig **to_sort = MallocT<GRFConfig*>(num);
+
+ uint i = 0;
+ for (GRFConfig *p = _all_grfs; p != NULL; p = p->next, i++) {
+ to_sort[i] = p;
+ }
+ /* Number of files is not necessarily right */
+ num = i;
- QSortT(to_sort, num, &GRFSorter);
+ QSortT(to_sort, num, &GRFSorter);
- for (i = 1; i < num; i++) {
- to_sort[i - 1]->next = to_sort[i];
- }
- to_sort[num - 1]->next = NULL;
- _all_grfs = to_sort[0];
+ for (i = 1; i < num; i++) {
+ to_sort[i - 1]->next = to_sort[i];
+ }
+ to_sort[num - 1]->next = NULL;
+ _all_grfs = to_sort[0];
- free(to_sort);
+ free(to_sort);
#ifdef ENABLE_NETWORK
- NetworkAfterNewGRFScan();
+ NetworkAfterNewGRFScan();
#endif
+ }
+
+ /* Yes... these are the NewGRF windows */
+ InvalidateWindowClassesData(WC_SAVELOAD);
+ InvalidateWindowData(WC_GAME_OPTIONS, 0, GOID_NEWGRF_RESCANNED);
}
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index 1623e271e..9978a2f15 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -989,9 +989,7 @@ struct NewGRFWindow : public QueryStringBaseWindow {
this->avail_sel = NULL;
this->avail_pos = -1;
this->avails.ForceRebuild();
- this->InvalidateData(GOID_NEWGRF_RESCANNED);
this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window
- InvalidateWindowClassesData(WC_SAVELOAD);
break;
}
}