diff options
author | peter1138 <peter1138@openttd.org> | 2009-02-09 22:49:28 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2009-02-09 22:49:28 +0000 |
commit | ad30a3c4caaad54f1b0b279bb0fc78254016efe3 (patch) | |
tree | 5980ebeefe7c6c93c1f872cad92d616b259b03dc /src/ai/api | |
parent | d846eef0b68474970d7ffe5f1d667d866ddff7a8 (diff) | |
download | openttd-ad30a3c4caaad54f1b0b279bb0fc78254016efe3.tar.xz |
(svn r15436) -Codechange: Return index of station spec within station class as a return parameter of GetCustomStationSpecByGrf(), as the index is already known. Saves on an extra loop and an extern...
Diffstat (limited to 'src/ai/api')
-rw-r--r-- | src/ai/api/ai_rail.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/ai/api/ai_rail.cpp b/src/ai/api/ai_rail.cpp index 5d08690d9..9ef1c4f53 100644 --- a/src/ai/api/ai_rail.cpp +++ b/src/ai/api/ai_rail.cpp @@ -155,16 +155,9 @@ uint16 res = GetAiPurchaseCallbackResult(GSF_STATION, cargo_id, 0, source_industry, goal_industry, min(255, distance / 2), AICE_STATION_GET_STATION_ID, source_station ? 0 : 1, min(15, num_platforms) << 4 | min(15, platform_length), &file); uint32 p2 = INVALID_STATION << 16; if (res != CALLBACK_FAILED) { - extern StationClass _station_classes[STAT_CLASS_MAX]; - const StationSpec *spec = GetCustomStationSpecByGrf(file->grfid, res); - int index = -1; - for (uint j = 0; j < _station_classes[spec->sclass].stations; j++) { - if (spec == _station_classes[spec->sclass].spec[j]) { - index = j; - break; - } - } - if (index == -1) { + int index = 0; + const StationSpec *spec = GetCustomStationSpecByGrf(file->grfid, res, &index); + if (spec == NULL) { DEBUG(grf, 1, "%s returned an invalid station ID for 'AI construction/purchase selection (18)' callback", file->filename); } else { p2 |= spec->sclass | index << 8; |