vehicle.c
changeset 2591 76a053785b35
parent 2590 5603f43c8cd3
child 2592 bec1bf2313df
equal deleted inserted replaced
2590:5603f43c8cd3 2591:76a053785b35
  1614 static void MaybeReplaceVehicle(Vehicle *v)
  1614 static void MaybeReplaceVehicle(Vehicle *v)
  1615 {
  1615 {
  1616 	Vehicle *w;
  1616 	Vehicle *w;
  1617 	const Player *p = GetPlayer(v->owner);
  1617 	const Player *p = GetPlayer(v->owner);
  1618 	byte flags = 0;
  1618 	byte flags = 0;
  1619 	int32 cost = 0, temp_cost = 0;
  1619 	int32 cost, temp_cost = 0;
  1620 	bool stopped = false;
  1620 	bool stopped = false;
  1621 
  1621 
  1622 	_current_player = v->owner;
  1622 	_current_player = v->owner;
  1623 
  1623 
  1624 	assert(v->type == VEH_Train || v->type == VEH_Road || v->type == VEH_Ship || v->type == VEH_Aircraft);
  1624 	assert(v->type == VEH_Train || v->type == VEH_Road || v->type == VEH_Ship || v->type == VEH_Aircraft);
  1630 		// we need to store this info as the engine might be replaced and lose this info
  1630 		// we need to store this info as the engine might be replaced and lose this info
  1631 		stopped = true;
  1631 		stopped = true;
  1632 	}
  1632 	}
  1633 
  1633 
  1634 	while (true) {
  1634 	while (true) {
       
  1635 		cost = 0;
  1635 		w = v;
  1636 		w = v;
  1636 		do {
  1637 		do {
  1637 			// check if the vehicle should be replaced
  1638 			// check if the vehicle should be replaced
  1638 			if (!p->engine_renew || w->age - w->max_age < (p->engine_renew_months * 30)		//replace if engine is too old
  1639 			if (!p->engine_renew || w->age - w->max_age < (p->engine_renew_months * 30)		//replace if engine is too old
  1639 				|| (w->max_age == 0)) {														// rail cars got a max age of 0
  1640 				|| (w->max_age == 0)) {														// rail cars got a max age of 0