# HG changeset patch # User rubidium # Date 1211451814 0 # Node ID 1bacf27342bd72c1f65e5c7e82ab2b7d8299b5fd # Parent c389705ba89fcd76bb9ddbde06c69c5d30ddda69 (svn r13211) [NoAI] -Codechange: replace a few hardcoded numbers by an API lookup in the WrightAI. diff -r c389705ba89f -r 1bacf27342bd bin/ai/wrightai/main.nut --- a/bin/ai/wrightai/main.nut Tue May 20 16:26:18 2008 +0000 +++ b/bin/ai/wrightai/main.nut Thu May 22 10:23:34 2008 +0000 @@ -7,6 +7,7 @@ distance_of_route = {}; vehicle_to_depot = {}; delay_build_airport_route = 1000; + passenger_cargo_id = -1; function Start(); function Stop(); @@ -15,6 +16,13 @@ this.towns_used = AIList(); this.route_1 = AIList(); this.route_2 = AIList(); + + local list = AICargoList(); + for (local i = list.Begin(); list.HasNext(); i = list.Next()) { + if (AICargo.GetCargoLabel(i) == "PASS") { + this.passenger_cargo_id = i; + } + } } } @@ -108,7 +116,7 @@ engine_list.KeepBelowValue(balance < 300000 ? 50000 : (balance < 1000000 ? 300000 : 1000000)); engine_list.Valuate(AIEngine.GetCargoType) - engine_list.KeepValue(0); // passengers + engine_list.KeepValue(this.passenger_cargo_id); engine_list.Valuate(AIEngine.GetCapacity) engine_list.KeepTop(1); @@ -178,7 +186,7 @@ list.KeepAboveValue(625); } /* Sort on acceptance, remove places that don't have acceptance */ - list.Valuate(AITile.GetCargoAcceptance, 0, airport_x, airport_y, airport_rad); + list.Valuate(AITile.GetCargoAcceptance, this.passenger_cargo_id, airport_x, airport_y, airport_rad); list.RemoveBelowValue(10); /* Couldn't find a suitable place for this town, skip to the next */ @@ -246,7 +254,7 @@ if (!this.HasMoney(50000)) return; list = AIStationList(AIStation.STATION_AIRPORT); - list.Valuate(AIStation.GetCargoWaiting, 0); + list.Valuate(AIStation.GetCargoWaiting, this.passenger_cargo_id); list.KeepAboveValue(250); for (local i = list.Begin(); list.HasNext(); i = list.Next()) { @@ -314,6 +322,11 @@ function WrightAI::Start() { + if (this.passenger_cargo_id == -1) { + AILog.Error("WrightAI could not find the passenger cargo"); + return; + } + /* Sleep 1 tick, as we can't execute anything in tick 0 */ Sleep(1);