Change: Reorganise industry accept/produce arrays. (#10853)

Use a array of struct for each cargo instead of an array for each statistic.
This makes iterating for acceptance and production much simpler.
pct_transported is now calculated when needed.
This commit is contained in:
PeterN
2023-05-25 21:25:46 +01:00
committed by GitHub
parent db3b086a52
commit 584faaf064
16 changed files with 527 additions and 355 deletions

View File

@@ -795,30 +795,29 @@ static const OldChunks industry_chunk[] = {
OCL_SVAR( OC_FILE_U8 | OC_VAR_U16, Industry, location.h ),
OCL_NULL( 2 ), ///< used to be industry's produced_cargo
OCL_SVAR( OC_TTD | OC_UINT16, Industry, produced_cargo_waiting[0] ),
OCL_SVAR( OC_TTD | OC_UINT16, Industry, produced_cargo_waiting[1] ),
OCL_SVAR( OC_TTO | OC_FILE_U8 | OC_VAR_U16, Industry, produced_cargo_waiting[0] ),
OCL_SVAR( OC_TTO | OC_FILE_U8 | OC_VAR_U16, Industry, produced_cargo_waiting[1] ),
OCL_SVAR( OC_TTD | OC_UINT16, Industry, produced[0].waiting ),
OCL_SVAR( OC_TTD | OC_UINT16, Industry, produced[1].waiting ),
OCL_SVAR( OC_TTO | OC_FILE_U8 | OC_VAR_U16, Industry, produced[0].waiting ),
OCL_SVAR( OC_TTO | OC_FILE_U8 | OC_VAR_U16, Industry, produced[1].waiting ),
OCL_SVAR( OC_UINT8, Industry, production_rate[0] ),
OCL_SVAR( OC_UINT8, Industry, production_rate[1] ),
OCL_SVAR( OC_UINT8, Industry, produced[0].rate ),
OCL_SVAR( OC_UINT8, Industry, produced[1].rate ),
OCL_NULL( 3 ), ///< used to be industry's accepts_cargo
OCL_SVAR( OC_UINT8, Industry, prod_level ),
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_UINT16, Industry, produced[0].history[THIS_MONTH].production ),
OCL_SVAR( OC_UINT16, Industry, produced[1].history[THIS_MONTH].production ),
OCL_SVAR( OC_UINT16, Industry, produced[0].history[THIS_MONTH].transported ),
OCL_SVAR( OC_UINT16, Industry, produced[1].history[THIS_MONTH].transported ),
OCL_SVAR( OC_UINT8, Industry, last_month_pct_transported[0] ),
OCL_SVAR( OC_UINT8, Industry, last_month_pct_transported[1] ),
OCL_NULL( 2 ), ///< last_month_pct_transported, now computed on the fly
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_UINT16, Industry, produced[0].history[LAST_MONTH].production ),
OCL_SVAR( OC_UINT16, Industry, produced[1].history[LAST_MONTH].production ),
OCL_SVAR( OC_UINT16, Industry, produced[0].history[LAST_MONTH].transported ),
OCL_SVAR( OC_UINT16, Industry, produced[1].history[LAST_MONTH].transported ),
OCL_SVAR( OC_UINT8, Industry, type ),
OCL_SVAR( OC_TTO | OC_FILE_U8 | OC_VAR_U16, Industry, counter ),