| 671 | } |
| 672 | |
| 673 | static void TileLoop_Object(TileIndex tile) |
| 674 | { |
| 675 | const ObjectSpec *spec = ObjectSpec::GetByTile(tile); |
| 676 | if (spec->flags.Test(ObjectFlag::Animation)) { |
| 677 | Object *o = Object::GetByTile(tile); |
| 678 | TriggerObjectTileAnimation(o, tile, ObjectAnimationTrigger::TileLoop, spec); |
| 679 | if (o->location.tile == tile) TriggerObjectAnimation(o, ObjectAnimationTrigger::TileLoopNorth, spec); |
| 680 | } |
| 681 | |
| 682 | if (IsTileOnWater(tile)) TileLoop_Water(tile); |
| 683 | |
| 684 | if (!IsObjectType(tile, OBJECT_HQ)) return; |
| 685 | |
| 686 | /* HQ accepts passenger and mail; but we have to divide the values |
| 687 | * between 4 tiles it occupies! */ |
| 688 | |
| 689 | /* HQ level (depends on company performance) in the range 1..5. */ |
| 690 | uint level = GetCompanyHQSize(tile) + 1; |
| 691 | assert(level < 6); |
| 692 | |
| 693 | StationFinder stations(TileArea(tile, 2, 2)); |
| 694 | |
| 695 | uint r = Random(); |
| 696 | /* Top town buildings generate 250, so the top HQ type makes 256. */ |
| 697 | CargoType pass = GetCargoTypeByLabel(CT_PASSENGERS); |
| 698 | if (IsValidCargoType(pass) && GB(r, 0, 8) < (256 / 4 / (6 - level))) { |
| 699 | uint amt = GB(r, 0, 8) / 8 / 4 + 1; |
| 700 | |
| 701 | /* Production is halved during recessions. */ |
| 702 | if (EconomyIsInRecession()) amt = (amt + 1) >> 1; |
| 703 | |
| 704 | /* Scale by cargo scale setting. */ |
| 705 | amt = ScaleByCargoScale(amt, true); |
| 706 | |
| 707 | MoveGoodsToStation(pass, amt, {GetTileOwner(tile), SourceType::Headquarters}, stations.GetStations()); |
| 708 | } |
| 709 | |
| 710 | /* Top town building generates 90, HQ can make up to 196. The |
| 711 | * proportion passengers:mail is about the same as in the acceptance |
| 712 | * equations. */ |
| 713 | CargoType mail = GetCargoTypeByLabel(CT_MAIL); |
| 714 | if (IsValidCargoType(mail) && GB(r, 8, 8) < (196 / 4 / (6 - level))) { |
| 715 | uint amt = GB(r, 8, 8) / 8 / 4 + 1; |
| 716 | |
| 717 | /* Production is halved during recessions. */ |
| 718 | if (EconomyIsInRecession()) amt = (amt + 1) >> 1; |
| 719 | |
| 720 | /* Scale by cargo scale setting. */ |
| 721 | amt = ScaleByCargoScale(amt, true); |
| 722 | |
| 723 | MoveGoodsToStation(mail, amt, {GetTileOwner(tile), SourceType::Headquarters}, stations.GetStations()); |
| 724 | } |
| 725 | } |
| 726 | |
| 727 | |
| 728 | static TrackStatus GetTileTrackStatus_Object(TileIndex, TransportType, uint, DiagDirection) |
nothing calls this directly
no test coverage detected