src/industry_cmd.cpp
changeset 7646 dc8c0fa95dae
parent 7645 efa25fcf7917
child 7650 780f1f477317
equal deleted inserted replaced
7645:efa25fcf7917 7646:dc8c0fa95dae
  1412 
  1412 
  1413 static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const IndustryTileTable *it, byte layout, const Town *t, Owner owner)
  1413 static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const IndustryTileTable *it, byte layout, const Town *t, Owner owner)
  1414 {
  1414 {
  1415 	const IndustrySpec *indspec = GetIndustrySpec(type);
  1415 	const IndustrySpec *indspec = GetIndustrySpec(type);
  1416 	uint32 r;
  1416 	uint32 r;
  1417 	int j;
  1417 	uint j;
  1418 
  1418 
  1419 	i->xy = tile;
  1419 	i->xy = tile;
  1420 	i->width = i->height = 0;
  1420 	i->width = i->height = 0;
  1421 	i->type = type;
  1421 	i->type = type;
  1422 	IncIndustryTypeCount(type);
  1422 	IncIndustryTypeCount(type);
  1456 	i->was_cargo_delivered = false;
  1456 	i->was_cargo_delivered = false;
  1457 	i->last_prod_year = _cur_year;
  1457 	i->last_prod_year = _cur_year;
  1458 	i->last_month_production[0] = i->production_rate[0] * 8;
  1458 	i->last_month_production[0] = i->production_rate[0] * 8;
  1459 	i->last_month_production[1] = i->production_rate[1] * 8;
  1459 	i->last_month_production[1] = i->production_rate[1] * 8;
  1460 	i->founder = _current_player;
  1460 	i->founder = _current_player;
       
  1461 
       
  1462 	if (HASBIT(indspec->callback_flags, CBM_IND_INPUT_CARGO_TYPES)) {
       
  1463 		for (j = 0; j < lengthof(i->accepts_cargo); j++) i->accepts_cargo[j] = CT_INVALID;
       
  1464 		for (j = 0; j < lengthof(i->accepts_cargo); j++) {
       
  1465 			uint16 res = GetIndustryCallback(CBID_INDUSTRY_INPUT_CARGO_TYPES, j, 0, i, type, INVALID_TILE);
       
  1466 			if (res == CALLBACK_FAILED || GB(res, 0, 8) == CT_INVALID) break;
       
  1467 			i->accepts_cargo[j] = GetCargoTranslation(GB(res, 0, 8), indspec->grf_prop.grffile);
       
  1468 		}
       
  1469 	}
       
  1470 
       
  1471 	if (HASBIT(indspec->callback_flags, CBM_IND_OUTPUT_CARGO_TYPES)) {
       
  1472 		for (j = 0; j < lengthof(i->produced_cargo); j++) i->produced_cargo[j] = CT_INVALID;
       
  1473 		for (j = 0; j < lengthof(i->produced_cargo); j++) {
       
  1474 			uint16 res = GetIndustryCallback(CBID_INDUSTRY_OUTPUT_CARGO_TYPES, j, 0, i, type, INVALID_TILE);
       
  1475 			if (res == CALLBACK_FAILED || GB(res, 0, 8) == CT_INVALID) break;
       
  1476 			i->produced_cargo[j] = GetCargoTranslation(GB(res, 0, 8), indspec->grf_prop.grffile);
       
  1477 		}
       
  1478 	}
       
  1479 
  1461 	i->construction_date = _date;
  1480 	i->construction_date = _date;
  1462 	i->construction_type = (_game_mode == GM_EDITOR) ? ICT_SCENARIO_EDITOR :
  1481 	i->construction_type = (_game_mode == GM_EDITOR) ? ICT_SCENARIO_EDITOR :
  1463 			(_generating_world ? ICT_MAP_GENERATION : ICT_NORMAL_GAMEPLAY);
  1482 			(_generating_world ? ICT_MAP_GENERATION : ICT_NORMAL_GAMEPLAY);
  1464 
  1483 
  1465 	/* Adding 1 here makes it conform to specs of var44 of varaction2 for industries
  1484 	/* Adding 1 here makes it conform to specs of var44 of varaction2 for industries