(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
authorbelugas
Fri, 18 May 2007 00:33:47 +0000
changeset 6636 fec086b5c340
parent 6635 73064d1771ed
child 6637 5a8e524c14f4
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
src/ai/default/default.cpp
src/ai/trolly/trolly.cpp
src/economy.cpp
src/industry.h
src/industry_cmd.cpp
src/industry_gui.cpp
src/industry_map.h
src/oldloader.cpp
--- a/src/ai/default/default.cpp	Thu May 17 20:19:55 2007 +0000
+++ b/src/ai/default/default.cpp	Fri May 18 00:33:47 2007 +0000
@@ -543,6 +543,7 @@
 static void AiFindRandomIndustryRoute(FoundRoute *fr)
 {
 	Industry* i;
+	const IndustrySpec *indsp;
 	uint32 r;
 	CargoID cargo;
 
@@ -556,8 +557,9 @@
 	if (i == NULL) return;
 
 	// pick a random produced cargo
-	cargo = i->produced_cargo[0];
-	if (r & 1 && i->produced_cargo[1] != CT_INVALID) cargo = i->produced_cargo[1];
+	indsp = GetIndustrySpec(i->type);
+	cargo = indsp->produced_cargo[0];
+	if (r & 1 && indsp->produced_cargo[1] != CT_INVALID) cargo = indsp->produced_cargo[1];
 
 	fr->cargo = cargo;
 
@@ -567,12 +569,16 @@
 	if (cargo != CT_GOODS && cargo != CT_FOOD) {
 		// pick a dest, and see if it can receive
 		Industry* i2 = AiFindRandomIndustry();
-
-		if (i2 == NULL || i == i2 || (
-					i2->accepts_cargo[0] != cargo &&
-					i2->accepts_cargo[1] != cargo &&
-					i2->accepts_cargo[2] != cargo)
-				) {
+		if (i2 == NULL) {
+			return;
+		}
+
+		indsp = GetIndustrySpec(i2->type);
+
+		if (i == i2 ||
+				(indsp->accepts_cargo[0] != cargo &&
+				indsp->accepts_cargo[1] != cargo &&
+				indsp->accepts_cargo[2] != cargo)) {
 			return;
 		}
 
@@ -664,9 +670,10 @@
 		}
 	} else {
 		const Industry* i = (const Industry*)fr->from;
-
-		if (i->pct_transported[fr->cargo != i->produced_cargo[0]] > 0x99 ||
-				i->total_production[fr->cargo != i->produced_cargo[0]] == 0) {
+		const IndustrySpec *indsp = GetIndustrySpec(i->type);
+
+		if (i->pct_transported[fr->cargo != indsp->produced_cargo[0]] > 0x99 ||
+				i->total_production[fr->cargo != indsp->produced_cargo[0]] == 0) {
 			return false;
 		}
 	}
--- a/src/ai/trolly/trolly.cpp	Thu May 17 20:19:55 2007 +0000
+++ b/src/ai/trolly/trolly.cpp	Fri May 18 00:33:47 2007 +0000
@@ -271,6 +271,7 @@
 	}
 	if (type == AI_INDUSTRY) {
 		const Industry* i = GetIndustry(ic);
+		const IndustrySpec *indsp = GetIndustrySpec(i->type);
 		const Station* st;
 		int count = 0;
 		int j = 0;
@@ -279,7 +280,7 @@
 
 		// No limits on delevering stations!
 		//  Or for industry that does not give anything yet
-		if (i->produced_cargo[0] == CT_INVALID || i->total_production[0] == 0) return true;
+		if (indsp->produced_cargo[0] == CT_INVALID || i->total_production[0] == 0) return true;
 
 		if (i->total_production[0] - i->total_transported[0] < AI_CHECKCITY_NEEDED_CARGO) return false;
 
@@ -302,13 +303,13 @@
 				//  we want to know if this station gets the same good. If so,
 				//  we want to know its rating. If it is too high, we are not going
 				//  to build there
-				if (i->produced_cargo[0] == CT_INVALID) continue;
+				if (indsp->produced_cargo[0] == CT_INVALID) continue;
 				// It does not take this cargo
-				if (!st->goods[i->produced_cargo[0]].last_speed) continue;
+				if (!st->goods[indsp->produced_cargo[0]].last_speed) continue;
 				// Is it around our industry
 				if (DistanceManhattan(st->xy, i->xy) > 5) continue;
 				// It does take this cargo.. what is his rating?
-				if (st->goods[i->produced_cargo[0]].rating < AI_CHECKCITY_CARGO_RATING) continue;
+				if (st->goods[indsp->produced_cargo[0]].rating < AI_CHECKCITY_CARGO_RATING) continue;
 				j++;
 				// The rating is high.. a little chance that we still continue
 				//  But if there are 2 stations of this size, we never go on...
@@ -458,17 +459,19 @@
 			}
 		} else if (p->ainew.tbt == AI_TRUCK) {
 			const Industry* ind_from = GetIndustry(p->ainew.from_ic);
+			const IndustrySpec *indsp_from = GetIndustrySpec(ind_from->type);
 			const Industry* ind_temp = GetIndustry(p->ainew.temp);
+			const IndustrySpec *indsp_temp = GetIndustrySpec(ind_temp->type);
 			bool found = false;
 			int max_cargo = 0;
 			uint i;
 
 			// TODO: in max_cargo, also check other cargo (beside [0])
 			// First we check if the from_ic produces cargo that this ic accepts
-			if (ind_from->produced_cargo[0] != CT_INVALID && ind_from->total_production[0] != 0) {
-				for (i = 0; i < lengthof(ind_temp->accepts_cargo); i++) {
-					if (ind_temp->accepts_cargo[i] == CT_INVALID) break;
-					if (ind_from->produced_cargo[0] == ind_temp->accepts_cargo[i]) {
+			if (indsp_from->produced_cargo[0] != CT_INVALID && ind_from->total_production[0] != 0) {
+				for (i = 0; i < lengthof(indsp_temp->accepts_cargo); i++) {
+					if (indsp_temp->accepts_cargo[i] == CT_INVALID) break;
+					if (indsp_from->produced_cargo[0] == indsp_temp->accepts_cargo[i]) {
 						// Found a compatible industry
 						max_cargo = ind_from->total_production[0] - ind_from->total_transported[0];
 						found = true;
@@ -478,11 +481,11 @@
 					}
 				}
 			}
-			if (!found && ind_temp->produced_cargo[0] != CT_INVALID && ind_temp->total_production[0] != 0) {
+			if (!found && indsp_temp->produced_cargo[0] != CT_INVALID && ind_temp->total_production[0] != 0) {
 				// If not check if the current ic produces cargo that the from_ic accepts
-				for (i = 0; i < lengthof(ind_from->accepts_cargo); i++) {
-					if (ind_from->accepts_cargo[i] == CT_INVALID) break;
-					if (ind_temp->produced_cargo[0] == ind_from->accepts_cargo[i]) {
+				for (i = 0; i < lengthof(indsp_from->accepts_cargo); i++) {
+					if (indsp_from->accepts_cargo[i] == CT_INVALID) break;
+					if (indsp_from->produced_cargo[0] == indsp_from->accepts_cargo[i]) {
 						// Found a compatbiel industry
 						found = true;
 						max_cargo = ind_temp->total_production[0] - ind_temp->total_transported[0];
@@ -501,9 +504,9 @@
 						distance <= max_cargo * AI_LOCATEROUTE_TRUCK_CARGO_DISTANCE) {
 					p->ainew.to_ic = p->ainew.temp;
 					if (p->ainew.from_deliver) {
-						p->ainew.cargo = ind_from->produced_cargo[0];
+						p->ainew.cargo = indsp_from->produced_cargo[0];
 					} else {
-						p->ainew.cargo = ind_temp->produced_cargo[0];
+						p->ainew.cargo = indsp_temp->produced_cargo[0];
 					}
 					p->ainew.state = AI_STATE_FIND_STATION;
 
--- a/src/economy.cpp	Thu May 17 20:19:55 2007 +0000
+++ b/src/economy.cpp	Fri May 18 00:33:47 2007 +0000
@@ -957,6 +957,7 @@
 static void FindSubsidyCargoRoute(FoundRoute *fr)
 {
 	Industry *i;
+	const IndustrySpec *ind;
 	int trans, total;
 	CargoID cargo;
 
@@ -964,14 +965,15 @@
 
 	fr->from = i = GetRandomIndustry();
 	if (i == NULL) return;
+	ind = GetIndustrySpec(i->type);
 
 	/* Randomize cargo type */
-	if (Random()&1 && i->produced_cargo[1] != CT_INVALID) {
-		cargo = i->produced_cargo[1];
+	if (HASBIT(Random(), 0) && ind->produced_cargo[1] != CT_INVALID) {
+		cargo = ind->produced_cargo[1];
 		trans = i->pct_transported[1];
 		total = i->total_production[1];
 	} else {
-		cargo = i->produced_cargo[0];
+		cargo = ind->produced_cargo[0];
 		trans = i->pct_transported[0];
 		total = i->total_production[0];
 	}
@@ -998,13 +1000,19 @@
 	} else {
 		/* The destination is an industry */
 		Industry *i2 = GetRandomIndustry();
+		if (i2 == NULL) {
+			return;
+		}
+
+		ind = GetIndustrySpec(i2->type);
 
 		/* The industry must accept the cargo */
-		if (i == i2 || i == NULL ||
-				(cargo != i2->accepts_cargo[0] &&
-				cargo != i2->accepts_cargo[1] &&
-				cargo != i2->accepts_cargo[2]))
+		if (i == i2 ||
+				(cargo != ind->accepts_cargo[0] &&
+				cargo != ind->accepts_cargo[1] &&
+				cargo != ind->accepts_cargo[2])) {
 			return;
+		}
 		fr->distance = DistanceManhattan(i->xy, i2->xy);
 		fr->to = i2;
 	}
--- a/src/industry.h	Thu May 17 20:19:55 2007 +0000
+++ b/src/industry.h	Fri May 18 00:33:47 2007 +0000
@@ -67,10 +67,8 @@
 	byte width;
 	byte height;
 	const Town* town;               ///< Nearest town
-	CargoID produced_cargo[2];      ///< 2 production cargo slots
 	uint16 cargo_waiting[2];        ///< amount of cargo produced per cargo
 	byte production_rate[2];        ///< production rate for each cargo
-	CargoID accepts_cargo[3];       ///< 3 input cargo slots
 	byte prod_level;                ///< general production level
 	uint16 last_mo_production[2];   ///< stats of last month production per cargo
 	uint16 last_mo_transported[2];  ///< stats of last month transport per cargo
--- a/src/industry_cmd.cpp	Thu May 17 20:19:55 2007 +0000
+++ b/src/industry_cmd.cpp	Fri May 18 00:33:47 2007 +0000
@@ -55,26 +55,16 @@
  * Retrieve the type for this industry.  Although it is accessed by a tile,
  * it will return the general type of industry, and not the sprite index
  * as would do GetIndustryGfx.
- * The same information can be accessed by looking at Industry->type
  * @param tile that is queried
  * @pre IsTileType(tile, MP_INDUSTRY)
  * @return general type for this industry, as defined in industry.h
  **/
 IndustryType GetIndustryType(TileIndex tile)
 {
-	IndustryGfx this_type = GetIndustryGfx(tile);
-	IndustryType iloop;
-
 	assert(IsTileType(tile, MP_INDUSTRY));
 
-	for (iloop = IT_COAL_MINE; iloop < NUM_INDUSTRYTYPES; iloop += 1) {
-		if (IS_BYTE_INSIDE(this_type, industry_gfx_Solver[iloop].MinGfx,
-				industry_gfx_Solver[iloop].MaxGfx + 1)) {
-			return iloop;
-		}
-	}
-
-	return IT_INVALID;  //we have not found equivalent, whatever the reason
+	const Industry *ind = GetIndustry(GetIndustryIndex(tile));
+	return IsValidIndustry(ind) ? ind->type : IT_INVALID;
 }
 
 /**
@@ -355,7 +345,7 @@
 
 		i->last_mo_production[0] += cw;
 
-		am = MoveGoodsToStation(i->xy, i->width, i->height, i->produced_cargo[0], cw);
+		am = MoveGoodsToStation(i->xy, i->width, i->height, indspec->produced_cargo[0], cw);
 		i->last_mo_transported[0] += am;
 		if (am != 0) {
 			uint newgfx = GetIndustryTileSpec(GetIndustryGfx(tile))->anim_production;
@@ -377,7 +367,7 @@
 
 		i->last_mo_production[1] += cw;
 
-		am = MoveGoodsToStation(i->xy, i->width, i->height, i->produced_cargo[1], cw);
+		am = MoveGoodsToStation(i->xy, i->width, i->height, indspec->produced_cargo[1], cw);
 		i->last_mo_transported[1] += am;
 	}
 }
@@ -752,7 +742,7 @@
 
 static void GetProducedCargo_Industry(TileIndex tile, CargoID *b)
 {
-	const Industry *i = GetIndustryByTile(tile);
+	const IndustrySpec *i = GetIndustrySpec(GetIndustryByTile(tile)->type);
 
 	b[0] = i->produced_cargo[0];
 	b[1] = i->produced_cargo[1];
@@ -1333,7 +1323,7 @@
 		/* check if an industry that accepts the same goods is nearby */
 		if (DistanceMax(tile, i->xy) <= 14 &&
 				indspec->accepts_cargo[0] != CT_INVALID &&
-				indspec->accepts_cargo[0] == i->accepts_cargo[0] && (
+				indspec->accepts_cargo[0] == indspec->accepts_cargo[0] && (
 					_game_mode != GM_EDITOR ||
 					!_patches.same_industry_close ||
 					!_patches.multiple_industry_per_town
@@ -1384,11 +1374,6 @@
 	i->width = i->height = 0;
 	i->type = type;
 
-	i->produced_cargo[0] = indspec->produced_cargo[0];
-	i->produced_cargo[1] = indspec->produced_cargo[1];
-	i->accepts_cargo[0] = indspec->accepts_cargo[0];
-	i->accepts_cargo[1] = indspec->accepts_cargo[1];
-	i->accepts_cargo[2] = indspec->accepts_cargo[2];
 	i->production_rate[0] = indspec->production_rate[0];
 	i->production_rate[1] = indspec->production_rate[1];
 
@@ -1638,7 +1623,7 @@
 			break;
 
 		default: /* INDUSTRY_PRODUCTION */
-			for (j = 0; j < 2 && i->produced_cargo[j] != CT_INVALID; j++){
+			for (j = 0; j < 2 && indspec->produced_cargo[j] != CT_INVALID; j++){
 				uint32 r = Random();
 				int old_prod, new_prod, percent;
 				int mag;
@@ -1664,7 +1649,7 @@
 				mag = abs(percent);
 				if (mag >= 10) {
 					SetDParam(2, mag);
-					SetDParam(0, GetCargo(i->produced_cargo[j])->name);
+					SetDParam(0, GetCargo(indspec->produced_cargo[j])->name);
 					SetDParam(1, i->index);
 					AddNewsItem(
 						percent >= 0 ? STR_INDUSTRY_PROD_GOUP : STR_INDUSTRY_PROD_GODOWN,
@@ -1693,40 +1678,26 @@
 {
 	byte pct;
 	bool refresh = false;
+	const IndustrySpec *indsp = GetIndustrySpec(i->type);
 
-	if (i->produced_cargo[0] != CT_INVALID) {
-		pct = 0;
-		if (i->last_mo_production[0] != 0) {
-			i->last_prod_year = _cur_year;
-			pct = min(i->last_mo_transported[0] * 256 / i->last_mo_production[0], 255);
-		}
-		i->pct_transported[0] = pct;
+	for (byte j = 0; j < lengthof(indsp->produced_cargo); j++) {
+		if (indsp->produced_cargo[j] != CT_INVALID) {
+			pct = 0;
+			if (i->last_mo_production[j] != 0) {
+				i->last_prod_year = _cur_year;
+				pct = min(i->last_mo_transported[j] * 256 / i->last_mo_production[j], 255);
+			}
+			i->pct_transported[j] = pct;
 
 		i->total_production[0] = i->last_mo_production[0];
 		i->last_mo_production[0] = 0;
 
-		i->total_transported[0] = i->last_mo_transported[0];
-		i->last_mo_transported[0] = 0;
-		refresh = true;
+			i->total_transported[j] = i->last_mo_transported[j];
+			i->last_mo_transported[j] = 0;
+			refresh = true;
+		}
 	}
 
-	if (i->produced_cargo[1] != CT_INVALID) {
-		pct = 0;
-		if (i->last_mo_production[1] != 0) {
-			i->last_prod_year = _cur_year;
-			pct = min(i->last_mo_transported[1] * 256 / i->last_mo_production[1], 255);
-		}
-		i->pct_transported[1] = pct;
-
-		i->total_production[1] = i->last_mo_production[1];
-		i->last_mo_production[1] = 0;
-
-		i->total_transported[1] = i->last_mo_transported[1];
-		i->last_mo_transported[1] = 0;
-		refresh = true;
-	}
-
-
 	if (refresh)
 		InvalidateWindow(WC_INDUSTRY_VIEW, i->index);
 
@@ -1920,10 +1891,10 @@
 	    SLE_VAR(Industry, width,               SLE_UINT8),
 	    SLE_VAR(Industry, height,              SLE_UINT8),
 	    SLE_REF(Industry, town,                REF_TOWN),
-	    SLE_ARR(Industry, produced_cargo,      SLE_UINT8,  2),
+	SLE_CONDNULL( 2, 2, 60),       ///< used to be industry's produced_cargo
 	    SLE_ARR(Industry, cargo_waiting,       SLE_UINT16, 2),
 	    SLE_ARR(Industry, production_rate,     SLE_UINT8,  2),
-	    SLE_ARR(Industry, accepts_cargo,       SLE_UINT8,  3),
+	SLE_CONDNULL( 3, 2, 60),       ///< used to be industry's accepts_cargo
 	    SLE_VAR(Industry, prod_level,          SLE_UINT8),
 	    SLE_ARR(Industry, last_mo_production,  SLE_UINT16, 2),
 	    SLE_ARR(Industry, last_mo_transported, SLE_UINT16, 2),
--- a/src/industry_gui.cpp	Thu May 17 20:19:55 2007 +0000
+++ b/src/industry_gui.cpp	Fri May 18 00:33:47 2007 +0000
@@ -287,8 +287,9 @@
 
 static inline bool IsProductionAlterable(const Industry *i)
 {
+	const IndustrySpec *ind = GetIndustrySpec(i->type);
 	return ((_game_mode == GM_EDITOR || _cheats.setup_prod.value) &&
-		     (i->accepts_cargo[0] == CT_INVALID || i->accepts_cargo[0] == CT_VALUABLES));
+			(ind->accepts_cargo[0] == CT_INVALID || ind->accepts_cargo[0] == CT_VALUABLES));
 }
 
 static void IndustryViewWndProc(Window *w, WindowEvent *e)
@@ -300,30 +301,31 @@
 	switch (e->event) {
 	case WE_PAINT: {
 		const Industry *i = GetIndustry(w->window_number);
+		const IndustrySpec *ind = GetIndustrySpec(i->type);
 
 		SetDParam(0, w->window_number);
 		DrawWindowWidgets(w);
 
-		if (i->accepts_cargo[0] != CT_INVALID) {
+		if (ind->accepts_cargo[0] != CT_INVALID) {
 			StringID str;
 
-			SetDParam(0, GetCargo(i->accepts_cargo[0])->name);
+			SetDParam(0, GetCargo(ind->accepts_cargo[0])->name);
 			str = STR_4827_REQUIRES;
-			if (i->accepts_cargo[1] != CT_INVALID) {
-				SetDParam(1, GetCargo(i->accepts_cargo[1])->name);
+			if (ind->accepts_cargo[1] != CT_INVALID) {
+				SetDParam(1, GetCargo(ind->accepts_cargo[1])->name);
 				str = STR_4828_REQUIRES;
-				if (i->accepts_cargo[2] != CT_INVALID) {
-					SetDParam(2, GetCargo(i->accepts_cargo[2])->name);
+				if (ind->accepts_cargo[2] != CT_INVALID) {
+					SetDParam(2, GetCargo(ind->accepts_cargo[2])->name);
 					str = STR_4829_REQUIRES;
 				}
 			}
 			DrawString(2, 107, str, 0);
 		}
 
-		if (i->produced_cargo[0] != CT_INVALID) {
+		if (ind->produced_cargo[0] != CT_INVALID) {
 			DrawString(2, 117, STR_482A_PRODUCTION_LAST_MONTH, 0);
 
-			SetDParam(0, i->produced_cargo[0]);
+			SetDParam(0, ind->produced_cargo[0]);
 			SetDParam(1, i->total_production[0]);
 
 			SetDParam(2, i->pct_transported[0] * 100 >> 8);
@@ -334,8 +336,8 @@
 						!isProductionMinimum(i, 0), !isProductionMaximum(i, 0));
 			}
 
-			if (i->produced_cargo[1] != CT_INVALID) {
-				SetDParam(0, i->produced_cargo[1]);
+			if (ind->produced_cargo[1] != CT_INVALID) {
+				SetDParam(0, ind->produced_cargo[1]);
 				SetDParam(1, i->total_production[1]);
 				SetDParam(2, i->pct_transported[1] * 100 >> 8);
 				DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 137, STR_482B_TRANSPORTED, 0);
@@ -365,7 +367,8 @@
 
 			x = e->we.click.pt.x;
 			line = (e->we.click.pt.y - 127) / 10;
-			if (e->we.click.pt.y >= 127 && IS_INT_INSIDE(line, 0, 2) && i->produced_cargo[line] != CT_INVALID) {
+			if (e->we.click.pt.y >= 127 && IS_INT_INSIDE(line, 0, 2) &&
+					GetIndustrySpec(i->type)->produced_cargo[line] != CT_INVALID) {
 				if (IS_INT_INSIDE(x, 5, 25) ) {
 					/* Clicked buttons, decrease or increase production */
 					if (x < 15) {
@@ -416,11 +419,13 @@
 
 static void UpdateIndustryProduction(Industry *i)
 {
-	if (i->produced_cargo[0] != CT_INVALID)
-		i->total_production[0] = 8 * i->production_rate[0];
+	const IndustrySpec *ind = GetIndustrySpec(i->type);
 
-	if (i->produced_cargo[1] != CT_INVALID)
-		i->total_production[1] = 8 * i->production_rate[1];
+	for (byte j = 0; j < lengthof(ind->produced_cargo); j++) {
+		if (ind->produced_cargo[j] != CT_INVALID) {
+			i->total_production[j] = 8 * i->production_rate[j];
+		}
+	}
 }
 
 static const Widget _industry_view_widgets[] = {
@@ -482,6 +487,8 @@
 {
 	const Industry* i = *(const Industry**)a;
 	const Industry* j = *(const Industry**)b;
+	const IndustrySpec *ind_i = GetIndustrySpec(i->type);
+	const IndustrySpec *ind_j = GetIndustrySpec(j->type);
 	int r;
 
 	switch (_industry_sort_order >> 1) {
@@ -495,10 +502,10 @@
 			break;
 
 		case 2: /* Sort by Production */
-			if (i->produced_cargo[0] == CT_INVALID) {
-				r = (j->produced_cargo[0] == CT_INVALID ? 0 : -1);
+			if (ind_i->produced_cargo[0] == CT_INVALID) {
+				r = (ind_j->produced_cargo[0] == CT_INVALID ? 0 : -1);
 			} else {
-				if (j->produced_cargo[0] == CT_INVALID) {
+				if (ind_j->produced_cargo[0] == CT_INVALID) {
 					r = 1;
 				} else {
 					r =
@@ -509,23 +516,23 @@
 			break;
 
 		case 3: /* Sort by transported fraction */
-			if (i->produced_cargo[0] == CT_INVALID) {
-				r = (j->produced_cargo[0] == CT_INVALID ? 0 : -1);
+			if (ind_i->produced_cargo[0] == CT_INVALID) {
+				r = (ind_j->produced_cargo[0] == CT_INVALID ? 0 : -1);
 			} else {
-				if (j->produced_cargo[0] == CT_INVALID) {
+				if (ind_j->produced_cargo[0] == CT_INVALID) {
 					r = 1;
 				} else {
 					int pi;
 					int pj;
 
 					pi = i->pct_transported[0] * 100 >> 8;
-					if (i->produced_cargo[1] != CT_INVALID) {
+					if (ind_i->produced_cargo[1] != CT_INVALID) {
 						int p = i->pct_transported[1] * 100 >> 8;
 						if (p < pi) pi = p;
 					}
 
 					pj = j->pct_transported[0] * 100 >> 8;
-					if (j->produced_cargo[1] != CT_INVALID) {
+					if (ind_j->produced_cargo[1] != CT_INVALID) {
 						int p = j->pct_transported[1] * 100 >> 8;
 						if (p < pj) pj = p;
 					}
@@ -606,14 +613,15 @@
 
 		while (p < _num_industry_sort) {
 			const Industry* i = _industry_sort[p];
+			const IndustrySpec *ind = GetIndustrySpec(i->type);
 
 			SetDParam(0, i->index);
-			if (i->produced_cargo[0] != CT_INVALID) {
-				SetDParam(1, i->produced_cargo[0]);
+			if (ind->produced_cargo[0] != CT_INVALID) {
+				SetDParam(1, ind->produced_cargo[0]);
 				SetDParam(2, i->total_production[0]);
 
-				if (i->produced_cargo[1] != CT_INVALID) {
-					SetDParam(3, i->produced_cargo[1]);
+				if (ind->produced_cargo[1] != CT_INVALID) {
+					SetDParam(3, ind->produced_cargo[1]);
 					SetDParam(4, i->total_production[1]);
 					SetDParam(5, i->pct_transported[0] * 100 >> 8);
 					SetDParam(6, i->pct_transported[1] * 100 >> 8);
--- a/src/industry_map.h	Thu May 17 20:19:55 2007 +0000
+++ b/src/industry_map.h	Fri May 18 00:33:47 2007 +0000
@@ -207,46 +207,6 @@
 	IndustryGfx MaxGfx; ///< The last gfx index for the industry type
 };
 
-/** Mapping of industry gfx to industry type */
-static const IndustryTypeSolver industry_gfx_Solver[IT_END] = {
-	{  0,   6}, ///< IT_COAL_MINE
-	{  7,  10}, ///< IT_POWER_STATION,
-	{ 11,  15}, ///< IT_SAWMILL,
-	{ 16,  17}, ///< IT_FOREST,
-	{ 18,  23}, ///< IT_OIL_REFINERY,
-	{ 24,  28}, ///< IT_OIL_RIG,
-	{ 29,  31}, ///< IT_OIL_WELL,
-	{ 32,  38}, ///< IT_FARM,
-	{ 39,  42}, ///< IT_FACTORY,
-	{ 43,  46}, ///< IT_PRINTING_WORKS,
-	{ 47,  51}, ///< IT_COPPER_MINE,
-	{ 52,  57}, ///< IT_STEEL_MILL,
-	{ 58,  59}, ///< IT_BANK_TEMP,
-	{ 60,  63}, ///< IT_FOOD_PROCESS,
-	{ 64,  71}, ///< IT_PAPER_MILL,
-	{ 72,  88}, ///< IT_GOLD_MINE,
-	{ 89,  90}, ///< IT_BANK_TROPIC_ARCTIC,
-	{ 91,  99}, ///< IT_DIAMOND_MINE,
-	{100, 115}, ///< IT_IRON_MINE,
-	{116, 116}, ///< IT_FRUIT_PLANTATION,
-	{117, 117}, ///< IT_RUBBER_PLANTATION,
-	{118, 119}, ///< IT_WATER_SUPPLY,
-	{120, 120}, ///< IT_WATER_TOWER,
-	{121, 124}, ///< IT_FACTORY_2,
-	{125, 128}, ///< IT_LUMBER_MILL,
-	{129, 130}, ///< IT_COTTON_CANDY,
-	{131, 134}, ///< IT_CANDY_FACTORY or sweet factory
-	{135, 136}, ///< IT_BATTERY_FARM,
-	{137, 137}, ///< IT_COLA_WELLS,
-	{138, 141}, ///< IT_TOY_SHOP,
-	{142, 147}, ///< IT_TOY_FACTORY,
-	{148, 155}, ///< IT_PLASTIC_FOUNTAINS,
-	{156, 159}, ///< IT_FIZZY_DRINK_FACTORY,
-	{160, 163}, ///< IT_BUBBLE_GENERATOR,
-	{164, 166}, ///< IT_TOFFEE_QUARRY,
-	{167, 174}  ///< IT_SUGAR_MINE,
-};
-
 /**
  * Get the animation loop number
  * @param tile the tile to get the animation loop number of
--- a/src/oldloader.cpp	Thu May 17 20:19:55 2007 +0000
+++ b/src/oldloader.cpp	Fri May 18 00:33:47 2007 +0000
@@ -651,8 +651,7 @@
 	OCL_VAR ( OC_UINT32,   1, &_old_town_index ),
 	OCL_SVAR(  OC_UINT8, Industry, width ),
 	OCL_SVAR(  OC_UINT8, Industry, height ),
-	OCL_SVAR(  OC_UINT8, Industry, produced_cargo[0] ),
-	OCL_SVAR(  OC_UINT8, Industry, produced_cargo[1] ),
+	OCL_NULL( 2 ),  ///< used to be industry's produced_cargo
 
 	OCL_SVAR( OC_UINT16, Industry, cargo_waiting[0] ),
 	OCL_SVAR( OC_UINT16, Industry, cargo_waiting[1] ),
@@ -660,9 +659,7 @@
 	OCL_SVAR(  OC_UINT8, Industry, production_rate[0] ),
 	OCL_SVAR(  OC_UINT8, Industry, production_rate[1] ),
 
-	OCL_SVAR(  OC_UINT8, Industry, accepts_cargo[0] ),
-	OCL_SVAR(  OC_UINT8, Industry, accepts_cargo[1] ),
-	OCL_SVAR(  OC_UINT8, Industry, accepts_cargo[2] ),
+	OCL_NULL( 3 ),  ///< used to be industry's accepts_cargo
 
 	OCL_SVAR(  OC_UINT8, Industry, prod_level ),