summaryrefslogtreecommitdiff
path: root/src/industry_cmd.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2014-08-13 19:31:45 +0000
committeralberth <alberth@openttd.org>2014-08-13 19:31:45 +0000
commit87dd209784d44a60805ef071423f8de9052cec97 (patch)
tree657b28d304dd7a1010419b1d865b1d190eb67e3d /src/industry_cmd.cpp
parentaaf44731fb60114fd1670a36d17c0c6d14e592a4 (diff)
downloadopenttd-87dd209784d44a60805ef071423f8de9052cec97.tar.xz
(svn r26729) -Feature: Warn about missing industries after generating a map.
Diffstat (limited to 'src/industry_cmd.cpp')
-rw-r--r--src/industry_cmd.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 9deb04363..34bf1ffcb 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -40,6 +40,7 @@
#include "core/backup_type.hpp"
#include "object_base.h"
#include "game/game.hpp"
+#include "error.h"
#include "table/strings.h"
#include "table/industry_land.h"
@@ -2741,6 +2742,26 @@ void InitializeIndustries()
_industry_builder.Reset();
}
+/** Verify whether the generated industries are complete, and warn the user if not. */
+void CheckIndustries()
+{
+ int count = 0;
+ for (IndustryType it = 0; it < NUM_INDUSTRYTYPES; it++) {
+ if (Industry::GetIndustryTypeCount(it) > 0) continue; // Types of existing industries can be skipped.
+
+ bool force_at_least_one;
+ uint32 chance = GetScaledIndustryGenerationProbability(it, &force_at_least_one);
+ if (chance == 0 || !force_at_least_one) continue; // Types that are not available can be skipped.
+
+ const IndustrySpec *is = GetIndustrySpec(it);
+ SetDParam(0, is->name);
+ ShowErrorMessage(STR_ERROR_NO_SUITABLE_PLACES_FOR_INDUSTRIES, STR_ERROR_NO_SUITABLE_PLACES_FOR_INDUSTRIES_EXPLANATION, WL_WARNING);
+
+ count++;
+ if (count >= 3) break; // Don't swamp the user with errors.
+ }
+}
+
/**
* Is an industry with the spec a raw industry?
* @return true if it should be handled as a raw industry