equal
deleted
inserted
replaced
105 * the next safe value we are sure about everything is below. |
105 * the next safe value we are sure about everything is below. |
106 */ |
106 */ |
107 return _total_industries + 1; |
107 return _total_industries + 1; |
108 } |
108 } |
109 |
109 |
|
110 /** |
|
111 * Return a random valid town. |
|
112 */ |
|
113 static inline Industry *GetRandomIndustry(void) |
|
114 { |
|
115 uint num = RandomRange(GetIndustryArraySize()); |
|
116 uint index = 0; |
|
117 |
|
118 if (GetIndustryArraySize() == 0) return NULL; |
|
119 |
|
120 while (num > 0) { |
|
121 num--; |
|
122 |
|
123 index++; |
|
124 /* Make sure we have a valid industry */ |
|
125 while (GetIndustry(index) == NULL) { |
|
126 index++; |
|
127 if (index == GetIndustryArraySize()) index = 0; |
|
128 } |
|
129 } |
|
130 |
|
131 return GetIndustry(index); |
|
132 } |
|
133 |
110 #define FOR_ALL_INDUSTRIES_FROM(i, start) for (i = GetIndustry(start); i != NULL; i = (i->index + 1 < GetIndustryPoolSize()) ? GetIndustry(i->index + 1) : NULL) if (IsValidIndustry(i)) |
134 #define FOR_ALL_INDUSTRIES_FROM(i, start) for (i = GetIndustry(start); i != NULL; i = (i->index + 1 < GetIndustryPoolSize()) ? GetIndustry(i->index + 1) : NULL) if (IsValidIndustry(i)) |
111 #define FOR_ALL_INDUSTRIES(i) FOR_ALL_INDUSTRIES_FROM(i, 0) |
135 #define FOR_ALL_INDUSTRIES(i) FOR_ALL_INDUSTRIES_FROM(i, 0) |
112 |
136 |
113 VARDEF const Industry** _industry_sort; |
137 VARDEF const Industry** _industry_sort; |
114 VARDEF bool _industry_sort_dirty; |
138 VARDEF bool _industry_sort_dirty; |