(svn r11177) -Codechange: add support for newgrf callbacks 14B and 14C
authorglx
Thu, 27 Sep 2007 21:47:38 +0000
changeset 7646 dc8c0fa95dae
parent 7645 efa25fcf7917
child 7647 6a1162b442ce
(svn r11177) -Codechange: add support for newgrf callbacks 14B and 14C
src/industry_cmd.cpp
src/newgrf_callbacks.h
--- a/src/industry_cmd.cpp	Thu Sep 27 21:39:13 2007 +0000
+++ b/src/industry_cmd.cpp	Thu Sep 27 21:47:38 2007 +0000
@@ -1414,7 +1414,7 @@
 {
 	const IndustrySpec *indspec = GetIndustrySpec(type);
 	uint32 r;
-	int j;
+	uint j;
 
 	i->xy = tile;
 	i->width = i->height = 0;
@@ -1458,6 +1458,25 @@
 	i->last_month_production[0] = i->production_rate[0] * 8;
 	i->last_month_production[1] = i->production_rate[1] * 8;
 	i->founder = _current_player;
+
+	if (HASBIT(indspec->callback_flags, CBM_IND_INPUT_CARGO_TYPES)) {
+		for (j = 0; j < lengthof(i->accepts_cargo); j++) i->accepts_cargo[j] = CT_INVALID;
+		for (j = 0; j < lengthof(i->accepts_cargo); j++) {
+			uint16 res = GetIndustryCallback(CBID_INDUSTRY_INPUT_CARGO_TYPES, j, 0, i, type, INVALID_TILE);
+			if (res == CALLBACK_FAILED || GB(res, 0, 8) == CT_INVALID) break;
+			i->accepts_cargo[j] = GetCargoTranslation(GB(res, 0, 8), indspec->grf_prop.grffile);
+		}
+	}
+
+	if (HASBIT(indspec->callback_flags, CBM_IND_OUTPUT_CARGO_TYPES)) {
+		for (j = 0; j < lengthof(i->produced_cargo); j++) i->produced_cargo[j] = CT_INVALID;
+		for (j = 0; j < lengthof(i->produced_cargo); j++) {
+			uint16 res = GetIndustryCallback(CBID_INDUSTRY_OUTPUT_CARGO_TYPES, j, 0, i, type, INVALID_TILE);
+			if (res == CALLBACK_FAILED || GB(res, 0, 8) == CT_INVALID) break;
+			i->produced_cargo[j] = GetCargoTranslation(GB(res, 0, 8), indspec->grf_prop.grffile);
+		}
+	}
+
 	i->construction_date = _date;
 	i->construction_type = (_game_mode == GM_EDITOR) ? ICT_SCENARIO_EDITOR :
 			(_generating_world ? ICT_MAP_GENERATION : ICT_NORMAL_GAMEPLAY);
--- a/src/newgrf_callbacks.h	Thu Sep 27 21:39:13 2007 +0000
+++ b/src/newgrf_callbacks.h	Thu Sep 27 21:47:38 2007 +0000
@@ -196,10 +196,10 @@
 	CBID_INDUSTRY_DECIDE_COLOUR          = 0x14A, // not implemented
 
 	/** Customize the input cargo types of a newly build industry. */
-	CBID_INDUSTRY_INPUT_CARGO_TYPES      = 0x14B, // not implemented
+	CBID_INDUSTRY_INPUT_CARGO_TYPES      = 0x14B,
 
 	/** Customize the output cargo types of a newly build industry. */
-	CBID_INDUSTRY_OUTPUT_CARGO_TYPES     = 0x14C, // not implemented
+	CBID_INDUSTRY_OUTPUT_CARGO_TYPES     = 0x14C,
 };
 
 /**