199 case 0x40: |
199 case 0x40: |
200 case 0x41: |
200 case 0x41: |
201 case 0x42: { // waiting cargo, but only if those two callback flags are set |
201 case 0x42: { // waiting cargo, but only if those two callback flags are set |
202 uint16 callback = indspec->callback_flags; |
202 uint16 callback = indspec->callback_flags; |
203 if (HasBit(callback, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(callback, CBM_IND_PRODUCTION_256_TICKS)) { |
203 if (HasBit(callback, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(callback, CBM_IND_PRODUCTION_256_TICKS)) { |
204 return min(industry->incoming_cargo_waiting[variable - 0x40], (uint16)0xFFFF); |
204 if ((indspec->behaviour & INDUSTRYBEH_PROD_MULTI_HNDLING) != 0) { |
|
205 return min(industry->incoming_cargo_waiting[variable - 0x40] / industry->prod_level, (uint16)0xFFFF); |
|
206 } else { |
|
207 return min(industry->incoming_cargo_waiting[variable - 0x40], (uint16)0xFFFF); |
|
208 } |
205 } else { |
209 } else { |
206 return 0; |
210 return 0; |
207 } |
211 } |
208 } |
212 } |
209 |
213 |
503 { |
507 { |
504 const IndustrySpec *spec = GetIndustrySpec(ind->type); |
508 const IndustrySpec *spec = GetIndustrySpec(ind->type); |
505 ResolverObject object; |
509 ResolverObject object; |
506 NewIndustryResolver(&object, ind->xy, ind); |
510 NewIndustryResolver(&object, ind->xy, ind); |
507 if ((spec->behaviour & INDUSTRYBEH_PRODCALLBACK_RANDOM) != 0) object.callback_param1 = Random(); |
511 if ((spec->behaviour & INDUSTRYBEH_PRODCALLBACK_RANDOM) != 0) object.callback_param1 = Random(); |
|
512 int multiplier = 1; |
|
513 if ((spec->behaviour & INDUSTRYBEH_PROD_MULTI_HNDLING) != 0) multiplier = ind->prod_level; |
508 object.callback_param2 = reason; |
514 object.callback_param2 = reason; |
509 |
515 |
510 for (uint loop = 0;; loop++) { |
516 for (uint loop = 0;; loop++) { |
511 SB(object.callback_param2, 8, 16, loop); |
517 SB(object.callback_param2, 8, 16, loop); |
512 const SpriteGroup *group = Resolve(spec->grf_prop.spritegroup, &object); |
518 const SpriteGroup *group = Resolve(spec->grf_prop.spritegroup, &object); |
513 if (group == NULL || group->type != SGT_INDUSTRY_PRODUCTION) break; |
519 if (group == NULL || group->type != SGT_INDUSTRY_PRODUCTION) break; |
514 |
520 |
515 bool deref = (group->g.indprod.version == 1); |
521 bool deref = (group->g.indprod.version == 1); |
516 |
522 |
517 for (uint i = 0; i < 3; i++) { |
523 for (uint i = 0; i < 3; i++) { |
518 ind->incoming_cargo_waiting[i] = Clamp(ind->incoming_cargo_waiting[i] - DerefIndProd(group->g.indprod.substract_input[i], deref), 0, 0xFFFF); |
524 ind->incoming_cargo_waiting[i] = Clamp(ind->incoming_cargo_waiting[i] - DerefIndProd(group->g.indprod.substract_input[i], deref) * multiplier, 0, 0xFFFF); |
519 } |
525 } |
520 for (uint i = 0; i < 2; i++) { |
526 for (uint i = 0; i < 2; i++) { |
521 ind->produced_cargo_waiting[i] = Clamp(ind->produced_cargo_waiting[i] + DerefIndProd(group->g.indprod.add_output[i], deref), 0, 0xFFFF); |
527 ind->produced_cargo_waiting[i] = Clamp(ind->produced_cargo_waiting[i] + max(DerefIndProd(group->g.indprod.add_output[i], deref), 0) * multiplier, 0, 0xFFFF); |
522 } |
528 } |
523 |
529 |
524 int32 again = DerefIndProd(group->g.indprod.again, deref); |
530 int32 again = DerefIndProd(group->g.indprod.again, deref); |
525 if (again == 0) break; |
531 if (again == 0) break; |
526 |
532 |