summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2007-05-18 00:33:47 +0000
committerbelugas <belugas@openttd.org>2007-05-18 00:33:47 +0000
commit380d18fb69b0318f9c442526572ebf589b8e5d54 (patch)
tree0f4edac96e152260deb0ea541ace05ad039c8170
parent44ddf033ed4915d533420be8cadadeec91ed323c (diff)
downloadopenttd-380d18fb69b0318f9c442526572ebf589b8e5d54.tar.xz
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
-rw-r--r--src/ai/default/default.cpp25
-rw-r--r--src/ai/trolly/trolly.cpp31
-rw-r--r--src/economy.cpp22
-rw-r--r--src/industry.h2
-rw-r--r--src/industry_cmd.cpp75
-rw-r--r--src/industry_gui.cpp64
-rw-r--r--src/industry_map.h40
-rw-r--r--src/oldloader.cpp7
8 files changed, 109 insertions, 157 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp
index e61f3a635..8533e6eba 100644
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -543,6 +543,7 @@ static void AiFindSubsidyPassengerRoute(FoundRoute *fr)
static void AiFindRandomIndustryRoute(FoundRoute *fr)
{
Industry* i;
+ const IndustrySpec *indsp;
uint32 r;
CargoID cargo;
@@ -556,8 +557,9 @@ static void AiFindRandomIndustryRoute(FoundRoute *fr)
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 @@ static void AiFindRandomIndustryRoute(FoundRoute *fr)
if (cargo != CT_GOODS && cargo != CT_FOOD) {
// pick a dest, and see if it can receive
Industry* i2 = AiFindRandomIndustry();
+ if (i2 == NULL) {
+ return;
+ }
+
+ indsp = GetIndustrySpec(i2->type);
- if (i2 == NULL || i == i2 || (
- i2->accepts_cargo[0] != cargo &&
- i2->accepts_cargo[1] != cargo &&
- i2->accepts_cargo[2] != cargo)
- ) {
+ if (i == i2 ||
+ (indsp->accepts_cargo[0] != cargo &&
+ indsp->accepts_cargo[1] != cargo &&
+ indsp->accepts_cargo[2] != cargo)) {
return;
}
@@ -664,9 +670,10 @@ static bool AiCheckIfRouteIsGood(Player *p, FoundRoute *fr, byte bitmask)
}
} else {
const Industry* i = (const Industry*)fr->from;
+ const IndustrySpec *indsp = GetIndustrySpec(i->type);
- if (i->pct_transported[fr->cargo != i->produced_cargo[0]] > 0x99 ||
- i->total_production[fr->cargo != i->produced_cargo[0]] == 0) {
+ if (i->pct_transported[fr->cargo != indsp->produced_cargo[0]] > 0x99 ||
+ i->total_production[fr->cargo != indsp->produced_cargo[0]] == 0) {
return false;
}
}
diff --git a/src/ai/trolly/trolly.cpp b/src/ai/trolly/trolly.cpp
index 7e888f629..f509afa7e 100644
--- a/src/ai/trolly/trolly.cpp
+++ b/src/ai/trolly/trolly.cpp
@@ -271,6 +271,7 @@ static bool AiNew_Check_City_or_Industry(Player *p, int ic, byte type)
}
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 @@ static bool AiNew_Check_City_or_Industry(Player *p, int ic, byte type)
// 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 @@ static bool AiNew_Check_City_or_Industry(Player *p, int ic, byte type)
// 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 @@ static void AiNew_State_LocateRoute(Player *p)
}
} 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 @@ static void AiNew_State_LocateRoute(Player *p)
}
}
}
- 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 @@ static void AiNew_State_LocateRoute(Player *p)
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;
diff --git a/src/economy.cpp b/src/economy.cpp
index 25b99892b..c68fe5672 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -957,6 +957,7 @@ static void FindSubsidyPassengerRoute(FoundRoute *fr)
static void FindSubsidyCargoRoute(FoundRoute *fr)
{
Industry *i;
+ const IndustrySpec *ind;
int trans, total;
CargoID cargo;
@@ -964,14 +965,15 @@ static void FindSubsidyCargoRoute(FoundRoute *fr)
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 @@ static void FindSubsidyCargoRoute(FoundRoute *fr)
} 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;
}
diff --git a/src/industry.h b/src/industry.h
index ab3081d71..873bc23d9 100644
--- a/src/industry.h
+++ b/src/industry.h
@@ -67,10 +67,8 @@ struct Industry {
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
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 79bbbeeb0..1fa12d0fd 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -55,26 +55,16 @@ DEFINE_OLD_POOL(Industry, Industry, IndustryPoolNewBlock, NULL)
* 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 @@ static void TransportIndustryGoods(TileIndex tile)
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 @@ static void TransportIndustryGoods(TileIndex tile)
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 uint32 GetTileTrackStatus_Industry(TileIndex tile, TransportType mode)
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 @@ static bool CheckIfTooCloseToIndustry(TileIndex tile, int type)
/* 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 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const Ind
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 @@ static void ExtChangeIndustryProduction(Industry *i)
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 @@ static void ExtChangeIndustryProduction(Industry *i)
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 @@ static void UpdateIndustryStatistics(Industry *i)
{
byte pct;
bool refresh = false;
-
- 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;
+ const IndustrySpec *indsp = GetIndustrySpec(i->type);
+
+ 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;
- }
-
- 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->total_transported[j] = i->last_mo_transported[j];
+ i->last_mo_transported[j] = 0;
+ refresh = true;
}
- 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 @@ static const SaveLoad _industry_desc[] = {
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),
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 18eaff5df..f46cd651d 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -287,8 +287,9 @@ static inline bool isProductionMaximum(const Industry *i, int pt) {
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 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
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 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
!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 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
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 IndustryViewWndProc(Window *w, WindowEvent *e)
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 @@ static int CDECL GeneralIndustrySorter(const void *a, const void *b)
{
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 @@ static int CDECL GeneralIndustrySorter(const void *a, const void *b)
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 @@ static int CDECL GeneralIndustrySorter(const void *a, const void *b)
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 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e)
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);
diff --git a/src/industry_map.h b/src/industry_map.h
index f9d9846ed..dd3cf1b11 100644
--- a/src/industry_map.h
+++ b/src/industry_map.h
@@ -207,46 +207,6 @@ struct IndustryTypeSolver {
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
diff --git a/src/oldloader.cpp b/src/oldloader.cpp
index da2dd4836..37e178261 100644
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -651,8 +651,7 @@ static const OldChunks industry_chunk[] = {
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 @@ static const OldChunks industry_chunk[] = {
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 ),