equal
deleted
inserted
replaced
424 |
424 |
425 static void AiStateCheckReplaceVehicle(Player *p) |
425 static void AiStateCheckReplaceVehicle(Player *p) |
426 { |
426 { |
427 const Vehicle* v = p->ai.cur_veh; |
427 const Vehicle* v = p->ai.cur_veh; |
428 |
428 |
429 if (!IsValidVehicle(v) || |
429 if (!v->IsValid() || |
430 v->owner != _current_player || |
430 v->owner != _current_player || |
431 v->type > VEH_SHIP || |
431 v->type > VEH_SHIP || |
432 _veh_check_replace_proc[v->type - VEH_TRAIN](p, v) == INVALID_ENGINE) { |
432 _veh_check_replace_proc[v->type - VEH_TRAIN](p, v) == INVALID_ENGINE) { |
433 p->ai.state = AIS_VEH_LOOP; |
433 p->ai.state = AIS_VEH_LOOP; |
434 } else { |
434 } else { |
441 { |
441 { |
442 const Vehicle* v = p->ai.cur_veh; |
442 const Vehicle* v = p->ai.cur_veh; |
443 |
443 |
444 p->ai.state = AIS_VEH_LOOP; |
444 p->ai.state = AIS_VEH_LOOP; |
445 // vehicle is not owned by the player anymore, something went very wrong. |
445 // vehicle is not owned by the player anymore, something went very wrong. |
446 if (!IsValidVehicle(v) || v->owner != _current_player) return; |
446 if (!v->IsValid() || v->owner != _current_player) return; |
447 _veh_do_replace_proc[v->type - VEH_TRAIN](p); |
447 _veh_do_replace_proc[v->type - VEH_TRAIN](p); |
448 } |
448 } |
449 |
449 |
450 struct FoundRoute { |
450 struct FoundRoute { |
451 int distance; |
451 int distance; |