src/newgrf_industries.cpp
changeset 8110 120abf2bfe82
parent 8106 9f527cc360cf
child 8117 6f265223b5fa
equal deleted inserted replaced
8109:6bd72fb7d645 8110:120abf2bfe82
   460  * @param ind    the industry this callback has to be called for
   460  * @param ind    the industry this callback has to be called for
   461  * @param reason the reason it is called (0 = incoming cargo, 1 = periodic tick callback)
   461  * @param reason the reason it is called (0 = incoming cargo, 1 = periodic tick callback)
   462  */
   462  */
   463 void IndustryProductionCallback(Industry *ind, int reason)
   463 void IndustryProductionCallback(Industry *ind, int reason)
   464 {
   464 {
       
   465 	const IndustrySpec *spec = GetIndustrySpec(ind->type);
   465 	ResolverObject object;
   466 	ResolverObject object;
   466 	NewIndustryResolver(&object, ind->xy, ind);
   467 	NewIndustryResolver(&object, ind->xy, ind);
       
   468 	if ((spec->behaviour & INDUSTRYBEH_PRODCALLBACK_RANDOM) != 0) object.callback_param1 = Random();
   467 	object.callback_param2 = reason;
   469 	object.callback_param2 = reason;
   468 
   470 
   469 	for (uint loop = 0;; loop++) {
   471 	for (uint loop = 0;; loop++) {
   470 		SB(object.callback_param2, 8, 16, loop);
   472 		SB(object.callback_param2, 8, 16, loop);
   471 		const SpriteGroup *group = Resolve(GetIndustrySpec(ind->type)->grf_prop.spritegroup, &object);
   473 		const SpriteGroup *group = Resolve(spec->grf_prop.spritegroup, &object);
   472 		if (group == NULL || group->type != SGT_INDUSTRY_PRODUCTION) break;
   474 		if (group == NULL || group->type != SGT_INDUSTRY_PRODUCTION) break;
   473 
   475 
   474 		bool deref = (group->g.indprod.version == 1);
   476 		bool deref = (group->g.indprod.version == 1);
   475 
   477 
   476 		for (uint i = 0; i < 3; i++) {
   478 		for (uint i = 0; i < 3; i++) {