summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-07-10 10:55:16 +0000
committerfrosch <frosch@openttd.org>2010-07-10 10:55:16 +0000
commit9060a7ac00075e506a9745356a674e55c0b53c2b (patch)
tree576edf39c06aff36d20fea7f7807304138c8cd56 /src
parent969c059feae435ff5cabb2f33d10d939b318ec02 (diff)
downloadopenttd-9060a7ac00075e506a9745356a674e55c0b53c2b.tar.xz
(svn r20108) -Change: [NewGRF] Report substitute industry type in AI railstation selection callback.
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_generic.cpp13
-rw-r--r--src/newgrf_generic.h3
-rw-r--r--src/newgrf_spritegroup.h4
3 files changed, 18 insertions, 2 deletions
diff --git a/src/newgrf_generic.cpp b/src/newgrf_generic.cpp
index 462db6a2d..36136a981 100644
--- a/src/newgrf_generic.cpp
+++ b/src/newgrf_generic.cpp
@@ -13,6 +13,7 @@
#include "debug.h"
#include "newgrf.h"
#include "newgrf_spritegroup.h"
+#include "industrytype.h"
#include "core/bitmath_func.hpp"
#include <list>
@@ -170,6 +171,18 @@ uint16 GetAiPurchaseCallbackResult(uint8 feature, CargoID cargo_type, uint8 defa
NewGenericResolver(&object, *file);
+ if (src_industry != IT_AI_UNKNOWN && src_industry != IT_AI_TOWN) {
+ const IndustrySpec *is = GetIndustrySpec(src_industry);
+ /* If this is no original industry, use the substitute type */
+ if (is->grf_prop.subst_id != INVALID_INDUSTRYTYPE) src_industry = is->grf_prop.subst_id;
+ }
+
+ if (dst_industry != IT_AI_UNKNOWN && dst_industry != IT_AI_TOWN) {
+ const IndustrySpec *is = GetIndustrySpec(dst_industry);
+ /* If this is no original industry, use the substitute type */
+ if (is->grf_prop.subst_id != INVALID_INDUSTRYTYPE) dst_industry = is->grf_prop.subst_id;
+ }
+
object.callback = CBID_GENERIC_AI_PURCHASE_SELECTION;
object.u.generic.cargo_type = cargo_type;
object.u.generic.default_selection = default_selection;
diff --git a/src/newgrf_generic.h b/src/newgrf_generic.h
index c461a8f30..f079efac8 100644
--- a/src/newgrf_generic.h
+++ b/src/newgrf_generic.h
@@ -39,6 +39,9 @@ enum AIConstructionEvent {
AICE_STATION_GET_STATION_ID = 0x00, ///< Get a station ID to build
};
+static const IndustryType IT_AI_UNKNOWN = 0xFE; ///< The AI has no specific industry in mind.
+static const IndustryType IT_AI_TOWN = 0xFF; ///< The AI actually wants to transport to/from a town, not an industry.
+
void ResetGenericCallbacks();
void AddGenericCallback(uint8 feature, const struct GRFFile *file, const struct SpriteGroup *group);
diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h
index a2d94fe97..4ee77a29a 100644
--- a/src/newgrf_spritegroup.h
+++ b/src/newgrf_spritegroup.h
@@ -334,8 +334,8 @@ struct ResolverObject {
struct {
CargoID cargo_type;
uint8 default_selection;
- IndustryType src_industry;
- IndustryType dst_industry;
+ uint8 src_industry; ///< Source industry substitute type. 0xFF for "town", 0xFE for "unknown".
+ uint8 dst_industry; ///< Destination industry substitute type. 0xFF for "town", 0xFE for "unknown".
uint8 distance;
AIConstructionEvent event;
uint8 count;