1
0
Fork 0

(svn r19907) -Fix: [NewGRF] Call callbacks 14A, 14B and 14C after all industry variables have been assigned, so more variables are valid during the callbacks.

release/1.1
frosch 2010-05-30 12:26:32 +00:00
parent cf060d16ec
commit 0960e0c4f2
1 changed files with 16 additions and 12 deletions

View File

@ -1619,6 +1619,21 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
i->last_month_production[1] = i->production_rate[1] * 8; i->last_month_production[1] = i->production_rate[1] * 8;
i->founder = founder; i->founder = founder;
i->construction_date = _date;
i->construction_type = (_game_mode == GM_EDITOR) ? ICT_SCENARIO_EDITOR :
(_generating_world ? ICT_MAP_GENERATION : ICT_NORMAL_GAMEPLAY);
/* Adding 1 here makes it conform to specs of var44 of varaction2 for industries
* 0 = created prior of newindustries
* else, chosen layout + 1 */
i->selected_layout = layout + 1;
if (!_generating_world) i->last_month_production[0] = i->last_month_production[1] = 0;
i->prod_level = PRODLEVEL_DEFAULT;
/* Call callbacks after the regular fields got initialised. */
if (HasBit(indspec->callback_mask, CBM_IND_DECIDE_COLOUR)) { if (HasBit(indspec->callback_mask, CBM_IND_DECIDE_COLOUR)) {
uint16 res = GetIndustryCallback(CBID_INDUSTRY_DECIDE_COLOUR, 0, 0, i, type, INVALID_TILE); uint16 res = GetIndustryCallback(CBID_INDUSTRY_DECIDE_COLOUR, 0, 0, i, type, INVALID_TILE);
if (res != CALLBACK_FAILED) i->random_colour = GB(res, 0, 4); if (res != CALLBACK_FAILED) i->random_colour = GB(res, 0, 4);
@ -1642,18 +1657,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
} }
} }
i->construction_date = _date; /* Plant the tiles */
i->construction_type = (_game_mode == GM_EDITOR) ? ICT_SCENARIO_EDITOR :
(_generating_world ? ICT_MAP_GENERATION : ICT_NORMAL_GAMEPLAY);
/* Adding 1 here makes it conform to specs of var44 of varaction2 for industries
* 0 = created prior of newindustries
* else, chosen layout + 1 */
i->selected_layout = layout + 1;
if (!_generating_world) i->last_month_production[0] = i->last_month_production[1] = 0;
i->prod_level = PRODLEVEL_DEFAULT;
do { do {
TileIndex cur_tile = tile + ToTileIndexDiff(it->ti); TileIndex cur_tile = tile + ToTileIndexDiff(it->ti);