equal
deleted
inserted
replaced
154 } |
154 } |
155 |
155 |
156 return best_veh_index; |
156 return best_veh_index; |
157 } |
157 } |
158 |
158 |
159 static EngineID AiChooseRoadVehToBuild(byte cargo, int32 money, TileIndex tile) |
159 static EngineID AiChooseRoadVehToBuild(CargoID cargo, int32 money, TileIndex tile) |
160 { |
160 { |
161 EngineID best_veh_index = INVALID_ENGINE; |
161 EngineID best_veh_index = INVALID_ENGINE; |
162 int32 best_veh_cost = 0; |
162 int32 best_veh_cost = 0; |
163 int32 ret; |
163 int32 ret; |
164 |
164 |
429 _veh_do_replace_proc[v->type - VEH_Train](p); |
429 _veh_do_replace_proc[v->type - VEH_Train](p); |
430 } |
430 } |
431 |
431 |
432 typedef struct FoundRoute { |
432 typedef struct FoundRoute { |
433 int distance; |
433 int distance; |
434 byte cargo; |
434 CargoID cargo; |
435 void *from; |
435 void *from; |
436 void *to; |
436 void *to; |
437 } FoundRoute; |
437 } FoundRoute; |
438 |
438 |
439 static Town *AiFindRandomTown(void) |
439 static Town *AiFindRandomTown(void) |
449 } |
449 } |
450 |
450 |
451 static void AiFindSubsidyIndustryRoute(FoundRoute *fr) |
451 static void AiFindSubsidyIndustryRoute(FoundRoute *fr) |
452 { |
452 { |
453 uint i; |
453 uint i; |
454 byte cargo; |
454 CargoID cargo; |
455 Subsidy *s; |
455 Subsidy *s; |
456 Industry *from, *to_ind; |
456 Industry *from, *to_ind; |
457 Town *to_tow; |
457 Town *to_tow; |
458 TileIndex to_xy; |
458 TileIndex to_xy; |
459 |
459 |
466 |
466 |
467 s = &_subsidies[i]; |
467 s = &_subsidies[i]; |
468 |
468 |
469 // Don't want passengers or mail |
469 // Don't want passengers or mail |
470 cargo = s->cargo_type; |
470 cargo = s->cargo_type; |
471 if (cargo == 0xFF || cargo == CT_PASSENGERS || cargo == CT_MAIL || s->age > 7) |
471 if (cargo == CT_INVALID || cargo == CT_PASSENGERS || cargo == CT_MAIL || s->age > 7) |
472 return; |
472 return; |
473 fr->cargo = cargo; |
473 fr->cargo = cargo; |
474 |
474 |
475 fr->from = from = GetIndustry(s->from); |
475 fr->from = from = GetIndustry(s->from); |
476 |
476 |
520 static void AiFindRandomIndustryRoute(FoundRoute *fr) |
520 static void AiFindRandomIndustryRoute(FoundRoute *fr) |
521 { |
521 { |
522 Industry *i,*i2; |
522 Industry *i,*i2; |
523 Town *t; |
523 Town *t; |
524 uint32 r; |
524 uint32 r; |
525 byte cargo; |
525 CargoID cargo; |
526 |
526 |
527 // initially error |
527 // initially error |
528 fr->distance = -1; |
528 fr->distance = -1; |
529 |
529 |
530 r = Random(); |
530 r = Random(); |
533 fr->from = i = AiFindRandomIndustry(); |
533 fr->from = i = AiFindRandomIndustry(); |
534 if (i == NULL) return; |
534 if (i == NULL) return; |
535 |
535 |
536 // pick a random produced cargo |
536 // pick a random produced cargo |
537 cargo = i->produced_cargo[0]; |
537 cargo = i->produced_cargo[0]; |
538 if (r & 1 && i->produced_cargo[1] != 0xFF) cargo = i->produced_cargo[1]; |
538 if (r & 1 && i->produced_cargo[1] != CT_INVALID) cargo = i->produced_cargo[1]; |
539 |
539 |
540 fr->cargo = cargo; |
540 fr->cargo = cargo; |
541 |
541 |
542 // don't allow passengers |
542 // don't allow passengers |
543 if (cargo == 0xFF || cargo == CT_PASSENGERS) return; |
543 if (cargo == 0xFF || cargo == CT_PASSENGERS) return; |