src/industry.h
changeset 6247 7d81e3a5d803
parent 6201 bee01dc45e39
child 6248 e4a2ed7e5613
equal deleted inserted replaced
6246:75451000349d 6247:7d81e3a5d803
   109 	return index < GetIndustryPoolSize() && IsValidIndustry(GetIndustry(index));
   109 	return index < GetIndustryPoolSize() && IsValidIndustry(GetIndustry(index));
   110 }
   110 }
   111 
   111 
   112 VARDEF int _total_industries; //general counter
   112 VARDEF int _total_industries; //general counter
   113 
   113 
   114 static inline IndustryID GetMaxIndustryIndex(void)
   114 static inline IndustryID GetMaxIndustryIndex()
   115 {
   115 {
   116 	/* TODO - This isn't the real content of the function, but
   116 	/* TODO - This isn't the real content of the function, but
   117 	 *  with the new pool-system this will be replaced with one that
   117 	 *  with the new pool-system this will be replaced with one that
   118 	 *  _really_ returns the highest index. Now it just returns
   118 	 *  _really_ returns the highest index. Now it just returns
   119 	 *  the next safe value we are sure about everything is below.
   119 	 *  the next safe value we are sure about everything is below.
   120 	 */
   120 	 */
   121 	return GetIndustryPoolSize() - 1;
   121 	return GetIndustryPoolSize() - 1;
   122 }
   122 }
   123 
   123 
   124 static inline uint GetNumIndustries(void)
   124 static inline uint GetNumIndustries()
   125 {
   125 {
   126 	return _total_industries;
   126 	return _total_industries;
   127 }
   127 }
   128 
   128 
   129 /**
   129 /**
   130  * Return a random valid industry.
   130  * Return a random valid industry.
   131  */
   131  */
   132 static inline Industry *GetRandomIndustry(void)
   132 static inline Industry *GetRandomIndustry()
   133 {
   133 {
   134 	int num = RandomRange(GetNumIndustries());
   134 	int num = RandomRange(GetNumIndustries());
   135 	IndustryID index = INVALID_INDUSTRY;
   135 	IndustryID index = INVALID_INDUSTRY;
   136 
   136 
   137 	if (GetNumIndustries() == 0) return NULL;
   137 	if (GetNumIndustries() == 0) return NULL;