summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ai/default/default.cpp4
-rw-r--r--src/ai/trolly/trolly.cpp18
-rw-r--r--src/economy.cpp8
-rw-r--r--src/industry.h38
-rw-r--r--src/industry_cmd.cpp92
-rw-r--r--src/industry_gui.cpp32
-rw-r--r--src/oldloader.cpp24
7 files changed, 108 insertions, 108 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp
index c865729ff..d1435b6a8 100644
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -672,8 +672,8 @@ static bool AiCheckIfRouteIsGood(Player *p, FoundRoute *fr, byte bitmask)
const Industry* i = (const Industry*)fr->from;
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) {
+ if (i->last_month_pct_transported[fr->cargo != indsp->produced_cargo[0]] > 0x99 ||
+ i->last_month_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 7290c7b12..b739c42a8 100644
--- a/src/ai/trolly/trolly.cpp
+++ b/src/ai/trolly/trolly.cpp
@@ -280,9 +280,9 @@ 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 (indsp->produced_cargo[0] == CT_INVALID || i->total_production[0] == 0) return true;
+ if (indsp->produced_cargo[0] == CT_INVALID || i->last_month_production[0] == 0) return true;
- if (i->total_production[0] - i->total_transported[0] < AI_CHECKCITY_NEEDED_CARGO) return false;
+ if (i->last_month_production[0] - i->last_month_transported[0] < AI_CHECKCITY_NEEDED_CARGO) return false;
// Check if we have build a station in this town the last 6 months
// else we don't do it. This is done, because stat updates can be slow
@@ -322,7 +322,7 @@ static bool AiNew_Check_City_or_Industry(Player *p, int ic, byte type)
// We are about to add one...
count++;
// Check if we the city can provide enough cargo for this amount of stations..
- if (count * AI_CHECKCITY_CARGO_PER_STATION > i->total_production[0]) return false;
+ if (count * AI_CHECKCITY_CARGO_PER_STATION > i->last_month_production[0]) return false;
// All check are okay, so we can build here!
return true;
@@ -468,12 +468,12 @@ static void AiNew_State_LocateRoute(Player *p)
// TODO: in max_cargo, also check other cargo (beside [0])
// First we check if the from_ic produces cargo that this ic accepts
- if (indsp_from->produced_cargo[0] != CT_INVALID && ind_from->total_production[0] != 0) {
+ if (indsp_from->produced_cargo[0] != CT_INVALID && ind_from->last_month_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];
+ max_cargo = ind_from->last_month_production[0] - ind_from->last_month_transported[0];
found = true;
p->ainew.from_deliver = true;
p->ainew.to_deliver = false;
@@ -481,14 +481,14 @@ static void AiNew_State_LocateRoute(Player *p)
}
}
}
- if (!found && indsp_temp->produced_cargo[0] != CT_INVALID && ind_temp->total_production[0] != 0) {
+ if (!found && indsp_temp->produced_cargo[0] != CT_INVALID && ind_temp->last_month_production[0] != 0) {
// If not check if the current ic produces cargo that the from_ic accepts
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];
+ max_cargo = ind_temp->last_month_production[0] - ind_temp->last_month_transported[0];
p->ainew.from_deliver = false;
p->ainew.to_deliver = true;
break;
@@ -898,9 +898,9 @@ static int AiNew_HowManyVehicles(Player *p)
// Calculating tiles a day a vehicle moves is not easy.. this is how it must be done!
tiles_a_day = RoadVehInfo(i)->max_speed * DAY_TICKS / 256 / 16;
if (p->ainew.from_deliver) {
- max_cargo = GetIndustry(p->ainew.from_ic)->total_production[0];
+ max_cargo = GetIndustry(p->ainew.from_ic)->last_month_production[0];
} else {
- max_cargo = GetIndustry(p->ainew.to_ic)->total_production[0];
+ max_cargo = GetIndustry(p->ainew.to_ic)->last_month_production[0];
}
// This is because moving 60% is more than we can dream of!
diff --git a/src/economy.cpp b/src/economy.cpp
index dbec59eca..b6966ead0 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -969,12 +969,12 @@ static void FindSubsidyCargoRoute(FoundRoute *fr)
/* Randomize cargo type */
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];
+ trans = i->last_month_pct_transported[1];
+ total = i->last_month_production[1];
} else {
cargo = ind->produced_cargo[0];
- trans = i->pct_transported[0];
- total = i->total_production[0];
+ trans = i->last_month_pct_transported[0];
+ total = i->last_month_production[0];
}
/* Quit if no production in this industry
diff --git a/src/industry.h b/src/industry.h
index 9d2491614..09cb34071 100644
--- a/src/industry.h
+++ b/src/industry.h
@@ -73,27 +73,27 @@ DECLARE_ENUM_AS_BIT_SET(IndustyBehaviour);
* Defines the internal data of a functionnal industry
*/
struct Industry {
- TileIndex xy; ///< coordinates of the primary tile the industry is built one
+ TileIndex xy; ///< coordinates of the primary tile the industry is built one
byte width;
byte height;
- const Town* town; ///< Nearest town
- uint16 cargo_waiting[2]; ///< amount of cargo produced per cargo
- byte production_rate[2]; ///< production rate for each cargo
- 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
- byte pct_transported[2]; ///< percentage transported per cargo
- uint16 total_production[2]; ///< total units produced per cargo
- uint16 total_transported[2]; ///< total units transported per cargo
- uint16 counter; ///< used for animation and/or production (if available cargo)
-
- IndustryType type; ///< type of industry. see IT_COAL_MINE and others
- OwnerByte owner; ///< owner of the industry. Which SHOULD always be (imho) OWNER_NONE
- byte random_color; ///< randomized colour of the industry, for display purpose
- Year last_prod_year; ///< last year of production
- byte was_cargo_delivered; ///< flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry
-
- IndustryID index; ///< index of the industry in the pool of industries
+ const Town *town; ///< Nearest town
+ uint16 cargo_waiting[2]; ///< amount of cargo produced per cargo
+ byte production_rate[2]; ///< production rate for each cargo
+ byte prod_level; ///< general production level
+ uint16 this_month_production[2]; ///< stats of this month's production per cargo
+ uint16 this_month_transported[2]; ///< stats of this month's transport per cargo
+ byte last_month_pct_transported[2]; ///< percentage transported per cargo in the last full month
+ uint16 last_month_production[2]; ///< total units produced per cargo in the last full month
+ uint16 last_month_transported[2]; ///< total units transported per cargo in the last full month
+ uint16 counter; ///< used for animation and/or production (if available cargo)
+
+ IndustryType type; ///< type of industry. see IT_COAL_MINE and others
+ OwnerByte owner; ///< owner of the industry. Which SHOULD always be (imho) OWNER_NONE
+ byte random_color; ///< randomized colour of the industry, for display purpose
+ Year last_prod_year; ///< last year of production
+ byte was_cargo_delivered; ///< flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry
+
+ IndustryID index; ///< index of the industry in the pool of industries
};
struct IndustryTileTable {
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 6c08ca2c5..902e89ba5 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -361,10 +361,10 @@ static void TransportIndustryGoods(TileIndex tile)
/* fluctuating economy? */
if (_economy.fluct <= 0) cw = (cw + 1) / 2;
- i->last_mo_production[0] += cw;
+ i->this_month_production[0] += cw;
am = MoveGoodsToStation(i->xy, i->width, i->height, indspec->produced_cargo[0], cw);
- i->last_mo_transported[0] += am;
+ i->this_month_transported[0] += am;
if (am != 0) {
uint newgfx = GetIndustryTileSpec(GetIndustryGfx(tile))->anim_production;
@@ -383,10 +383,10 @@ static void TransportIndustryGoods(TileIndex tile)
if (_economy.fluct <= 0) cw = (cw + 1) / 2;
- i->last_mo_production[1] += cw;
+ i->this_month_production[1] += cw;
am = MoveGoodsToStation(i->xy, i->width, i->height, indspec->produced_cargo[1], cw);
- i->last_mo_transported[1] += am;
+ i->this_month_transported[1] += am;
}
}
@@ -1368,20 +1368,20 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const Ind
i->counter = GB(r, 0, 12);
i->cargo_waiting[0] = 0;
i->cargo_waiting[1] = 0;
- i->last_mo_production[0] = 0;
- i->last_mo_production[1] = 0;
- i->last_mo_transported[0] = 0;
- i->last_mo_transported[1] = 0;
- i->pct_transported[0] = 0;
- i->pct_transported[1] = 0;
- i->total_transported[0] = 0;
- i->total_transported[1] = 0;
+ i->this_month_production[0] = 0;
+ i->this_month_production[1] = 0;
+ i->this_month_transported[0] = 0;
+ i->this_month_transported[1] = 0;
+ i->last_month_pct_transported[0] = 0;
+ i->last_month_pct_transported[1] = 0;
+ i->last_month_transported[0] = 0;
+ i->last_month_transported[1] = 0;
i->was_cargo_delivered = false;
i->last_prod_year = _cur_year;
- i->total_production[0] = i->production_rate[0] * 8;
- i->total_production[1] = i->production_rate[1] * 8;
+ i->last_month_production[0] = i->production_rate[0] * 8;
+ i->last_month_production[1] = i->production_rate[1] * 8;
- if (!_generating_world) i->total_production[0] = i->total_production[1] = 0;
+ if (!_generating_world) i->last_month_production[0] = i->last_month_production[1] = 0;
i->prod_level = 0x10;
@@ -1615,7 +1615,7 @@ static void ExtChangeIndustryProduction(Industry *i)
new_prod = old_prod = i->production_rate[j];
if (CHANCE16I(20, 1024, r))
new_prod -= ((RandomRange(50) + 10) * old_prod) >> 8;
- if (CHANCE16I(20 + (i->pct_transported[j] * 20 >> 8), 1024, r >> 16))
+ if (CHANCE16I(20 + (i->last_month_pct_transported[j] * 20 >> 8), 1024, r >> 16))
new_prod += ((RandomRange(50) + 10) * old_prod) >> 8;
new_prod = clamp(new_prod, 0, 255);
@@ -1667,17 +1667,17 @@ static void UpdateIndustryStatistics(Industry *i)
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) {
+ if (i->this_month_production[j] != 0) {
i->last_prod_year = _cur_year;
- pct = min(i->last_mo_transported[j] * 256 / i->last_mo_production[j], 255);
+ pct = min(i->this_month_transported[j] * 256 / i->this_month_production[j], 255);
}
- i->pct_transported[j] = pct;
+ i->last_month_pct_transported[j] = pct;
- i->total_production[j] = i->last_mo_production[j];
- i->last_mo_production[j] = 0;
+ i->last_month_production[j] = i->this_month_production[j];
+ i->this_month_production[j] = 0;
- i->total_transported[j] = i->last_mo_transported[j];
- i->last_mo_transported[j] = 0;
+ i->last_month_transported[j] = i->this_month_transported[j];
+ i->this_month_transported[j] = 0;
refresh = true;
}
}
@@ -1767,7 +1767,7 @@ static void ChangeIndustryProduction(Industry *i)
if (only_decrease || CHANCE16(1, 3)) {
/* If you transport > 60%, 66% chance we increase, else 33% chance we increase */
- if (!only_decrease && (i->pct_transported[0] > 153) != CHANCE16(1, 3)) {
+ if (!only_decrease && (i->last_month_pct_transported[0] > 153) != CHANCE16(1, 3)) {
/* Increase production */
if (i->prod_level != 0x80) {
byte b;
@@ -1870,30 +1870,30 @@ extern const TileTypeProcs _tile_type_industry_procs = {
};
static const SaveLoad _industry_desc[] = {
- SLE_CONDVAR(Industry, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
- SLE_CONDVAR(Industry, xy, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_VAR(Industry, width, SLE_UINT8),
- SLE_VAR(Industry, height, SLE_UINT8),
- SLE_REF(Industry, town, REF_TOWN),
+ SLE_CONDVAR(Industry, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
+ SLE_CONDVAR(Industry, xy, SLE_UINT32, 6, SL_MAX_VERSION),
+ SLE_VAR(Industry, width, SLE_UINT8),
+ SLE_VAR(Industry, height, SLE_UINT8),
+ SLE_REF(Industry, town, REF_TOWN),
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, cargo_waiting, SLE_UINT16, 2),
+ SLE_ARR(Industry, production_rate, SLE_UINT8, 2),
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),
- SLE_ARR(Industry, pct_transported, SLE_UINT8, 2),
- SLE_ARR(Industry, total_production, SLE_UINT16, 2),
- SLE_ARR(Industry, total_transported, SLE_UINT16, 2),
-
- SLE_VAR(Industry, counter, SLE_UINT16),
-
- SLE_VAR(Industry, type, SLE_UINT8),
- SLE_VAR(Industry, owner, SLE_UINT8),
- SLE_VAR(Industry, random_color, SLE_UINT8),
- SLE_CONDVAR(Industry, last_prod_year, SLE_FILE_U8 | SLE_VAR_I32, 0, 30),
- SLE_CONDVAR(Industry, last_prod_year, SLE_INT32, 31, SL_MAX_VERSION),
- SLE_VAR(Industry, was_cargo_delivered, SLE_UINT8),
+ SLE_VAR(Industry, prod_level, SLE_UINT8),
+ SLE_ARR(Industry, this_month_production, SLE_UINT16, 2),
+ SLE_ARR(Industry, this_month_transported, SLE_UINT16, 2),
+ SLE_ARR(Industry, last_month_pct_transported, SLE_UINT8, 2),
+ SLE_ARR(Industry, last_month_production, SLE_UINT16, 2),
+ SLE_ARR(Industry, last_month_transported, SLE_UINT16, 2),
+
+ SLE_VAR(Industry, counter, SLE_UINT16),
+
+ SLE_VAR(Industry, type, SLE_UINT8),
+ SLE_VAR(Industry, owner, SLE_UINT8),
+ SLE_VAR(Industry, random_color, SLE_UINT8),
+ SLE_CONDVAR(Industry, last_prod_year, SLE_FILE_U8 | SLE_VAR_I32, 0, 30),
+ SLE_CONDVAR(Industry, last_prod_year, SLE_INT32, 31, SL_MAX_VERSION),
+ SLE_VAR(Industry, was_cargo_delivered, SLE_UINT8),
/* reserve extra space in savegame here. (currently 32 bytes) */
SLE_CONDNULL(32, 2, SL_MAX_VERSION),
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 0ff388b4f..dca4ef7ac 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -326,9 +326,9 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
DrawString(2, 117, STR_482A_PRODUCTION_LAST_MONTH, 0);
SetDParam(0, ind->produced_cargo[0]);
- SetDParam(1, i->total_production[0]);
+ SetDParam(1, i->last_month_production[0]);
- SetDParam(2, i->pct_transported[0] * 100 >> 8);
+ SetDParam(2, i->last_month_pct_transported[0] * 100 >> 8);
DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 127, STR_482B_TRANSPORTED, 0);
/* Let's put out those buttons.. */
if (IsProductionAlterable(i)) {
@@ -338,8 +338,8 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
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);
+ SetDParam(1, i->last_month_production[1]);
+ SetDParam(2, i->last_month_pct_transported[1] * 100 >> 8);
DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 137, STR_482B_TRANSPORTED, 0);
/* Let's put out those buttons.. */
if (IsProductionAlterable(i)) {
@@ -423,7 +423,7 @@ static void UpdateIndustryProduction(Industry *i)
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];
+ i->last_month_production[j] = 8 * i->production_rate[j];
}
}
}
@@ -509,8 +509,8 @@ static int CDECL GeneralIndustrySorter(const void *a, const void *b)
r = 1;
} else {
r =
- (i->total_production[0] + i->total_production[1]) -
- (j->total_production[0] + j->total_production[1]);
+ (i->last_month_production[0] + i->last_month_production[1]) -
+ (j->last_month_production[0] + j->last_month_production[1]);
}
}
break;
@@ -525,15 +525,15 @@ static int CDECL GeneralIndustrySorter(const void *a, const void *b)
int pi;
int pj;
- pi = i->pct_transported[0] * 100 >> 8;
+ pi = i->last_month_pct_transported[0] * 100 >> 8;
if (ind_i->produced_cargo[1] != CT_INVALID) {
- int p = i->pct_transported[1] * 100 >> 8;
+ int p = i->last_month_pct_transported[1] * 100 >> 8;
if (p < pi) pi = p;
}
- pj = j->pct_transported[0] * 100 >> 8;
+ pj = j->last_month_pct_transported[0] * 100 >> 8;
if (ind_j->produced_cargo[1] != CT_INVALID) {
- int p = j->pct_transported[1] * 100 >> 8;
+ int p = j->last_month_pct_transported[1] * 100 >> 8;
if (p < pj) pj = p;
}
@@ -618,16 +618,16 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e)
SetDParam(0, i->index);
if (ind->produced_cargo[0] != CT_INVALID) {
SetDParam(1, ind->produced_cargo[0]);
- SetDParam(2, i->total_production[0]);
+ SetDParam(2, i->last_month_production[0]);
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);
+ SetDParam(4, i->last_month_production[1]);
+ SetDParam(5, i->last_month_pct_transported[0] * 100 >> 8);
+ SetDParam(6, i->last_month_pct_transported[1] * 100 >> 8);
DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM_TWO, 0);
} else {
- SetDParam(3, i->pct_transported[0] * 100 >> 8);
+ SetDParam(3, i->last_month_pct_transported[0] * 100 >> 8);
DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM, 0);
}
} else {
diff --git a/src/oldloader.cpp b/src/oldloader.cpp
index 37e178261..3b36da278 100644
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -663,18 +663,18 @@ static const OldChunks industry_chunk[] = {
OCL_SVAR( OC_UINT8, Industry, prod_level ),
- OCL_SVAR( OC_UINT16, Industry, last_mo_production[0] ),
- OCL_SVAR( OC_UINT16, Industry, last_mo_production[1] ),
- OCL_SVAR( OC_UINT16, Industry, last_mo_transported[0] ),
- OCL_SVAR( OC_UINT16, Industry, last_mo_transported[1] ),
-
- OCL_SVAR( OC_UINT8, Industry, pct_transported[0] ),
- OCL_SVAR( OC_UINT8, Industry, pct_transported[1] ),
-
- OCL_SVAR( OC_UINT16, Industry, total_production[0] ),
- OCL_SVAR( OC_UINT16, Industry, total_production[1] ),
- OCL_SVAR( OC_UINT16, Industry, total_transported[0] ),
- OCL_SVAR( OC_UINT16, Industry, total_transported[1] ),
+ OCL_SVAR( OC_UINT16, Industry, this_month_production[0] ),
+ OCL_SVAR( OC_UINT16, Industry, this_month_production[1] ),
+ OCL_SVAR( OC_UINT16, Industry, this_month_transported[0] ),
+ OCL_SVAR( OC_UINT16, Industry, this_month_transported[1] ),
+
+ OCL_SVAR( OC_UINT8, Industry, last_month_pct_transported[0] ),
+ OCL_SVAR( OC_UINT8, Industry, last_month_pct_transported[1] ),
+
+ OCL_SVAR( OC_UINT16, Industry, last_month_production[0] ),
+ OCL_SVAR( OC_UINT16, Industry, last_month_production[1] ),
+ OCL_SVAR( OC_UINT16, Industry, last_month_transported[0] ),
+ OCL_SVAR( OC_UINT16, Industry, last_month_transported[1] ),
OCL_SVAR( OC_UINT8, Industry, type ),
OCL_SVAR( OC_UINT8, Industry, owner ),