summaryrefslogtreecommitdiff
path: root/ai_new.c
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2004-11-13 15:15:41 +0000
committercelestar <celestar@openttd.org>2004-11-13 15:15:41 +0000
commitb8327e0457a8f40d98a8bd5a6889166d4a4afd02 (patch)
tree0c2c138ef5956ca627597a893d78d83cf457ec1c /ai_new.c
parent6db750373a806f77aa096e6eb5665d7ddfb8de6b (diff)
downloadopenttd-b8327e0457a8f40d98a8bd5a6889166d4a4afd02.tar.xz
(svn r562) newgrf: Merge most of the road vehicle info to a single
road_vehicle_info table, like it already is for trains and ships. Needed for GRF custom override support. (pasky)
Diffstat (limited to 'ai_new.c')
-rw-r--r--ai_new.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/ai_new.c b/ai_new.c
index c0a8c661a..57f25643a 100644
--- a/ai_new.c
+++ b/ai_new.c
@@ -516,9 +516,6 @@ static bool AiNew_CheckVehicleStation(Player *p, Station *st) {
return true;
}
-extern const byte _roadveh_speed[88];
-extern const byte _roadveh_capacity[88];
-
// This function finds a good spot for a station
static void AiNew_State_FindStation(Player *p) {
TileIndex tile;
@@ -570,7 +567,7 @@ static void AiNew_State_FindStation(Player *p) {
if (p->ainew.tbt == AI_BUS && (FACIL_BUS_STOP & st->facilities) == FACIL_BUS_STOP) {
if (st->town == town) {
// Check how much cargo there is left in the station
- if ((st->goods[p->ainew.cargo].waiting_acceptance & 0xFFF) > _roadveh_capacity[i-ROAD_ENGINES_INDEX] * AI_STATION_REUSE_MULTIPLER) {
+ if ((st->goods[p->ainew.cargo].waiting_acceptance & 0xFFF) > road_vehicle_info(i)->capacity * AI_STATION_REUSE_MULTIPLER) {
if (AiNew_CheckVehicleStation(p, st)) {
// We did found a station that was good enough!
new_tile = st->xy;
@@ -829,8 +826,7 @@ static int AiNew_HowManyVehicles(Player *p) {
// Passenger run.. how long is the route?
length = p->ainew.path_info.route_length;
// Calculating tiles a day a vehicle moves is not easy.. this is how it must be done!
- // ROAD_ENGINES_INDEX is because the first roadveh engine is ROAD_ENGINES_INDEX, and _roadveh_speed starts from 0
- tiles_a_day = _roadveh_speed[i-ROAD_ENGINES_INDEX] * DAY_TICKS / 256 / 16;
+ tiles_a_day = road_vehicle_info(i)->max_speed * DAY_TICKS / 256 / 16;
// We want a vehicle in a station once a month at least, so, calculate it!
// (the * 2 is because we have 2 stations ;))
amount = ((int)(((float)length / (float)tiles_a_day / 30 * 2))) * 2;
@@ -845,8 +841,7 @@ static int AiNew_HowManyVehicles(Player *p) {
// Passenger run.. how long is the route?
length = p->ainew.path_info.route_length;
// Calculating tiles a day a vehicle moves is not easy.. this is how it must be done!
- // ROAD_ENGINES_INDEX is because the first roadveh engine is ROAD_ENGINES_INDEX, and _roadveh_speed starts from 0
- tiles_a_day = _roadveh_speed[i-ROAD_ENGINES_INDEX] * DAY_TICKS / 256 / 16;
+ tiles_a_day = road_vehicle_info(i)->max_speed * DAY_TICKS / 256 / 16;
if (p->ainew.from_deliver)
max_cargo = DEREF_INDUSTRY(p->ainew.from_ic)->total_production[0];
else
@@ -857,7 +852,7 @@ static int AiNew_HowManyVehicles(Player *p) {
// We want all the cargo to be gone in a month.. so, we know the cargo it delivers
// we know what the vehicle takes with him, and we know the time it takes him
// to get back here.. now let's do some math!
- amount = (int)(((float)length / (float)tiles_a_day / 30 * 2) * ((float)max_cargo / (float)_roadveh_capacity[i-ROAD_ENGINES_INDEX]));
+ amount = (int)(((float)length / (float)tiles_a_day / 30 * 2) * ((float)max_cargo / (float)road_vehicle_info(i)->capacity));
amount += 1;
return amount;
} else {