(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
It isn't the best name, but we couldn't find any better. This unifies the pool-system even more.
This commit is contained in:
@@ -441,13 +441,13 @@ typedef struct FoundRoute {
|
||||
|
||||
static Town *AiFindRandomTown(void)
|
||||
{
|
||||
Town *t = GetTown(RandomRange(_total_towns));
|
||||
Town *t = GetTown(RandomRange(GetTownArraySize()));
|
||||
return IsValidTown(t) ? t : NULL;
|
||||
}
|
||||
|
||||
static Industry *AiFindRandomIndustry(void)
|
||||
{
|
||||
Industry *i = GetIndustry(RandomRange(_total_industries));
|
||||
Industry *i = GetIndustry(RandomRange(GetIndustryArraySize()));
|
||||
return IsValidIndustry(i) ? i : NULL;
|
||||
}
|
||||
|
||||
@@ -3566,8 +3566,8 @@ static void AiStateRemoveStation(Player *p)
|
||||
p->ai.state = AIS_1;
|
||||
|
||||
// Get a list of all stations that are in use by a vehicle
|
||||
in_use = malloc(GetStationPoolSize());
|
||||
memset(in_use, 0, GetStationPoolSize());
|
||||
in_use = malloc(GetStationArraySize());
|
||||
memset(in_use, 0, GetStationArraySize());
|
||||
FOR_ALL_ORDERS(ord) {
|
||||
if (ord->type == OT_GOTO_STATION) in_use[ord->station] = 1;
|
||||
}
|
||||
|
||||
@@ -379,9 +379,9 @@ static void AiNew_State_LocateRoute(Player *p)
|
||||
if (p->ainew.temp == -1) {
|
||||
// First, we pick a random spot to search from
|
||||
if (p->ainew.from_type == AI_CITY) {
|
||||
p->ainew.temp = AI_RandomRange(_total_towns);
|
||||
p->ainew.temp = AI_RandomRange(GetTownArraySize());
|
||||
} else {
|
||||
p->ainew.temp = AI_RandomRange(_total_industries);
|
||||
p->ainew.temp = AI_RandomRange(GetIndustryArraySize());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,9 +391,9 @@ static void AiNew_State_LocateRoute(Player *p)
|
||||
// to try again
|
||||
p->ainew.temp++;
|
||||
if (p->ainew.from_type == AI_CITY) {
|
||||
if (p->ainew.temp >= (int)_total_towns) p->ainew.temp = 0;
|
||||
if (p->ainew.temp >= GetTownArraySize()) p->ainew.temp = 0;
|
||||
} else {
|
||||
if (p->ainew.temp >= _total_industries) p->ainew.temp = 0;
|
||||
if (p->ainew.temp >= GetIndustryArraySize()) p->ainew.temp = 0;
|
||||
}
|
||||
|
||||
// Don't do an attempt if we are trying the same id as the last time...
|
||||
@@ -415,9 +415,9 @@ static void AiNew_State_LocateRoute(Player *p)
|
||||
if (p->ainew.temp == -1) {
|
||||
// First, we pick a random spot to search to
|
||||
if (p->ainew.to_type == AI_CITY) {
|
||||
p->ainew.temp = AI_RandomRange(_total_towns);
|
||||
p->ainew.temp = AI_RandomRange(GetTownArraySize());
|
||||
} else {
|
||||
p->ainew.temp = AI_RandomRange(_total_industries);
|
||||
p->ainew.temp = AI_RandomRange(GetIndustryArraySize());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -531,9 +531,9 @@ static void AiNew_State_LocateRoute(Player *p)
|
||||
// to try again
|
||||
p->ainew.temp++;
|
||||
if (p->ainew.to_type == AI_CITY) {
|
||||
if (p->ainew.temp >= (int)_total_towns) p->ainew.temp = 0;
|
||||
if (p->ainew.temp >= GetTownArraySize()) p->ainew.temp = 0;
|
||||
} else {
|
||||
if (p->ainew.temp >= _total_industries) p->ainew.temp = 0;
|
||||
if (p->ainew.temp >= GetIndustryArraySize()) p->ainew.temp = 0;
|
||||
}
|
||||
|
||||
// Don't do an attempt if we are trying the same id as the last time...
|
||||
|
||||
Reference in New Issue
Block a user