Loading

town growth

  1. +/**
  2. + * Calculates town growth rate in normal conditions (custom growth rate not set).
  3. + * @param town The town to calculate growth rate for
  4. + * @returns Calculated growth rate
  5. + */
  6. +static uint GetNormalGrowthRate(Town *t)
  7. +{
  8. +   /**
  9. +    * Towns are processed every TOWN_GROWTH_TICKS ticks, and this is the
  10. +    * number of times towns are processed before a new building is built.
  11. +    */
  12. +   static const uint16 _grow_count_values[2][6] = {
  13. +       { 120, 120, 120, 100,  80,  60 }, // Fund new buildings has been activated
  14. +       { 320, 420, 300, 220, 160, 100 }  // Normal values
  15. +   };
  16. +
  17. +   int n = CountActiveStations(t);
  18. +   uint16 m = _grow_count_values[t->fund_buildings_months != 0 ? 0 : 1][min(n, 5)];
  19. +
  20. +   /* Use the normal growth rate values if new buildings have been funded in
  21. +    * this town and the growth rate is set to none. */
  22. +   uint growth_multiplier = _settings_game.economy.town_growth_rate != 0 ? _settings_game.economy.town_growth_rate - 1 : 1;
  23. +
  24. +   m >>= growth_multiplier;
  25. +   if (t->larger_town) m /= 2;
  26. +
  27. +   return m / (t->cache.num_houses / 50 + 1);
  28. +}

Comments