diff -r 76282d3b748d -r ca3fd1fbe311 src/ai/default/default.cpp --- a/src/ai/default/default.cpp Thu Sep 06 19:42:48 2007 +0000 +++ b/src/ai/default/default.cpp Sat Oct 06 21:16:00 2007 +0000 @@ -305,7 +305,7 @@ static void AiHandleReplaceTrain(Player *p) { const Vehicle* v = p->ai.cur_veh; - BackuppedOrders orderbak[1]; + BackuppedOrders orderbak; EngineID veh; // wait until the vehicle reaches the depot. @@ -318,13 +318,13 @@ if (veh != INVALID_ENGINE) { TileIndex tile; - BackupVehicleOrders(v, orderbak); + BackupVehicleOrders(v, &orderbak); tile = v->tile; if (CmdSucceeded(DoCommand(0, v->index, 2, DC_EXEC, CMD_SELL_RAIL_WAGON)) && CmdSucceeded(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_RAIL_VEHICLE))) { VehicleID veh = _new_vehicle_id; - AiRestoreVehicleOrders(GetVehicle(veh), orderbak); + AiRestoreVehicleOrders(GetVehicle(veh), &orderbak); DoCommand(0, veh, 0, DC_EXEC, CMD_START_STOP_TRAIN); DoCommand(0, veh, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT); @@ -533,7 +533,6 @@ static void AiFindRandomIndustryRoute(FoundRoute *fr) { Industry* i; - const IndustrySpec *indsp; uint32 r; CargoID cargo; @@ -547,9 +546,8 @@ if (i == NULL) return; // pick a random produced cargo - indsp = GetIndustrySpec(i->type); - cargo = indsp->produced_cargo[0]; - if (r & 1 && indsp->produced_cargo[1] != CT_INVALID) cargo = indsp->produced_cargo[1]; + cargo = i->produced_cargo[0]; + if (r & 1 && i->produced_cargo[1] != CT_INVALID) cargo = i->produced_cargo[1]; fr->cargo = cargo; @@ -559,16 +557,10 @@ if (cargo != CT_GOODS && cargo != CT_FOOD) { // pick a dest, and see if it can receive Industry* i2 = AiFindRandomIndustry(); - if (i2 == NULL) { - return; - } - - indsp = GetIndustrySpec(i2->type); - - if (i == i2 || - (indsp->accepts_cargo[0] != cargo && - indsp->accepts_cargo[1] != cargo && - indsp->accepts_cargo[2] != cargo)) { + if (i2 == NULL || i == i2 || + (i2->accepts_cargo[0] != cargo && + i2->accepts_cargo[1] != cargo && + i2->accepts_cargo[2] != cargo)) { return; } @@ -671,10 +663,9 @@ } } else { const Industry* i = (const Industry*)fr->from; - const IndustrySpec *indsp = GetIndustrySpec(i->type); - - if (i->last_month_pct_transported[fr->cargo != indsp->produced_cargo[0]] > 0x99 || - i->last_month_production[fr->cargo != indsp->produced_cargo[0]] == 0) { + + if (i->last_month_pct_transported[fr->cargo != i->produced_cargo[0]] > 0x99 || + i->last_month_production[fr->cargo != i->produced_cargo[0]] == 0) { return false; } }