MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / TownGenerateCargoOriginal

Function TownGenerateCargoOriginal

src/town_cmd.cpp:559–570  ·  view source on GitHub ↗

* Generate cargo for a house using the original algorithm. * @param t The current town. * @param tpe The town production effect. * @param rate The town's product rate for this production. * @param stations Available stations for this house. */

Source from the content-addressed store, hash-verified

557 * @param stations Available stations for this house.
558 */
559static void TownGenerateCargoOriginal(Town *t, TownProductionEffect tpe, uint8_t rate, StationFinder &stations)
560{
561 for (const CargoSpec *cs : CargoSpec::town_production_cargoes[tpe]) {
562 uint32_t r = Random();
563 if (GB(r, 0, 8) < rate) {
564 CargoType cargo_type = cs->Index();
565 uint amt = (GB(r, 0, 8) * cs->town_production_multiplier / TOWN_PRODUCTION_DIVISOR) / 8 + 1;
566
567 TownGenerateCargo(t, cargo_type, amt, stations, true);
568 }
569 }
570}
571
572/**
573 * Generate cargo for a house using the binomial algorithm.

Callers 1

TileLoop_TownFunction · 0.85

Calls 4

GBFunction · 0.85
TownGenerateCargoFunction · 0.85
RandomFunction · 0.50
IndexMethod · 0.45

Tested by

no test coverage detected