File diff r5298:8fdd01992c6e → r5299:1a5e005aa3e9
industry.h
Show inline comments
 
@@ -87,12 +87,17 @@ DECLARE_OLD_POOL(Industry, Industry, 3, 
 
 */
 
static inline bool IsValidIndustry(const Industry *industry)
 
{
 
	return industry->xy != 0;
 
}
 

	
 
static inline bool IsValidIndustryID(IndustryID index)
 
{
 
	return index < GetIndustryPoolSize() && IsValidIndustry(GetIndustry(index));
 
}
 

	
 
VARDEF int _total_industries;
 

	
 
static inline IndustryID GetMaxIndustryIndex(void)
 
{
 
	/* TODO - This isn't the real content of the function, but
 
	 *  with the new pool-system this will be replaced with one that
 
@@ -105,29 +110,29 @@ static inline IndustryID GetMaxIndustryI
 
static inline uint GetNumIndustries(void)
 
{
 
	return _total_industries;
 
}
 

	
 
/**
 
 * Return a random valid town.
 
 * Return a random valid industry.
 
 */
 
static inline Industry *GetRandomIndustry(void)
 
{
 
	uint num = RandomRange(GetNumIndustries());
 
	uint index = 0;
 
	int num = RandomRange(GetNumIndustries());
 
	IndustryID index = INVALID_INDUSTRY;
 

	
 
	if (GetNumIndustries() == 0) return NULL;
 

	
 
	while (num > 0) {
 
	while (num >= 0) {
 
		num--;
 

	
 
		index++;
 

	
 
		/* Make sure we have a valid industry */
 
		while (GetIndustry(index) == NULL) {
 
		while (!IsValidIndustryID(index)) {
 
			index++;
 
			if (index > GetMaxIndustryIndex()) index = 0;
 
			assert(index <= GetMaxIndustryIndex());
 
		}
 
	}
 

	
 
	return GetIndustry(index);
 
}