mirror of https://github.com/OpenTTD/OpenTTD
(svn r21166) -Codechange: Move MaybeNewIndustry() to IndustryBuildData::TryBuildNewIndustry().
parent
d46a2ef122
commit
1bf94674df
|
@ -143,4 +143,13 @@ void ReleaseDisastersTargetingIndustry(IndustryID);
|
||||||
#define FOR_ALL_INDUSTRIES_FROM(var, start) FOR_ALL_ITEMS_FROM(Industry, industry_index, var, start)
|
#define FOR_ALL_INDUSTRIES_FROM(var, start) FOR_ALL_ITEMS_FROM(Industry, industry_index, var, start)
|
||||||
#define FOR_ALL_INDUSTRIES(var) FOR_ALL_INDUSTRIES_FROM(var, 0)
|
#define FOR_ALL_INDUSTRIES(var) FOR_ALL_INDUSTRIES_FROM(var, 0)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data for managing the number and type of industries in the game.
|
||||||
|
*/
|
||||||
|
struct IndustryBuildData {
|
||||||
|
void TryBuildNewIndustry();
|
||||||
|
};
|
||||||
|
|
||||||
|
extern IndustryBuildData _industry_builder;
|
||||||
|
|
||||||
#endif /* INDUSTRY_H */
|
#endif /* INDUSTRY_H */
|
||||||
|
|
|
@ -59,6 +59,7 @@ uint16 Industry::counts[NUM_INDUSTRYTYPES];
|
||||||
|
|
||||||
IndustrySpec _industry_specs[NUM_INDUSTRYTYPES];
|
IndustrySpec _industry_specs[NUM_INDUSTRYTYPES];
|
||||||
IndustryTileSpec _industry_tile_specs[NUM_INDUSTRYTILES];
|
IndustryTileSpec _industry_tile_specs[NUM_INDUSTRYTILES];
|
||||||
|
IndustryBuildData _industry_builder; ///< In-game manager of industries.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function initialize the spec arrays of both
|
* This function initialize the spec arrays of both
|
||||||
|
@ -2051,7 +2052,7 @@ struct ProbabilityHelper {
|
||||||
/**
|
/**
|
||||||
* Try to create a random industry, during gameplay
|
* Try to create a random industry, during gameplay
|
||||||
*/
|
*/
|
||||||
static void MaybeNewIndustry()
|
void IndustryBuildData::TryBuildNewIndustry()
|
||||||
{
|
{
|
||||||
uint num = 0;
|
uint num = 0;
|
||||||
ProbabilityHelper cumulative_probs[NUM_INDUSTRYTYPES]; // probability collector
|
ProbabilityHelper cumulative_probs[NUM_INDUSTRYTYPES]; // probability collector
|
||||||
|
@ -2454,7 +2455,7 @@ void IndustryDailyLoop()
|
||||||
for (uint16 j = 0; j < change_loop; j++) {
|
for (uint16 j = 0; j < change_loop; j++) {
|
||||||
/* 3% chance that we start a new industry */
|
/* 3% chance that we start a new industry */
|
||||||
if (Chance16(3, 100)) {
|
if (Chance16(3, 100)) {
|
||||||
MaybeNewIndustry();
|
_industry_builder.TryBuildNewIndustry();
|
||||||
} else {
|
} else {
|
||||||
Industry *i = Industry::GetRandom();
|
Industry *i = Industry::GetRandom();
|
||||||
if (i != NULL) {
|
if (i != NULL) {
|
||||||
|
|
Loading…
Reference in New Issue