(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.

This commit is contained in:
truelight
2006-08-22 21:14:45 +00:00
parent cea8546a86
commit a21b2750bd
7 changed files with 63 additions and 20 deletions

View File

@@ -3,11 +3,11 @@
#include "stdafx.h"
#include "openttd.h"
#include "clear_map.h"
#include "functions.h"
#include "industry_map.h"
#include "station_map.h"
#include "table/strings.h"
#include "table/sprites.h"
#include "functions.h"
#include "map.h"
#include "tile.h"
#include "viewport.h"
@@ -1879,8 +1879,8 @@ void IndustryMonthlyLoop(void)
if (CHANCE16(3, 100)) {
MaybeNewIndustry(Random());
} else if (!_patches.smooth_economy && GetIndustryArraySize() > 0) {
i = GetIndustry(RandomRange(GetIndustryArraySize()));
if (IsValidIndustry(i)) ChangeIndustryProduction(i);
i = GetRandomIndustry();
if (i != NULL) ChangeIndustryProduction(i);
}
_current_player = old_player;