src/vehicle.cpp
changeset 8629 f61bb746249f
parent 8582 601d2fafb775
child 8666 e3ee55ec96bb
equal deleted inserted replaced
8628:2e7e4cdfe96f 8629:f61bb746249f
    91 
    91 
    92 
    92 
    93 /* Initialize the vehicle-pool */
    93 /* Initialize the vehicle-pool */
    94 DEFINE_OLD_POOL_GENERIC(Vehicle, Vehicle)
    94 DEFINE_OLD_POOL_GENERIC(Vehicle, Vehicle)
    95 
    95 
       
    96 /** Function to tell if a vehicle needs to be autorenewed
       
    97  * @param *p The vehicle owner
       
    98  * @return true if the vehicle is old enough for replacement
       
    99  */
       
   100 bool Vehicle::NeedsAutorenewing(const Player *p) const
       
   101 {
       
   102 	/* We can always generate the Player pointer when we have the vehicle.
       
   103 	 * However this takes time and since the Player pointer is often present
       
   104 	 * when this function is called then it's faster to pass the pointer as an
       
   105 	 * argument rather than finding it again. */
       
   106 	assert(p == GetPlayer(this->owner));
       
   107 
       
   108 	if (!p->engine_renew) return false;
       
   109 	if (this->age - this->max_age < (p->engine_renew_months * 30)) return false;
       
   110 
       
   111 	return true;
       
   112 }
       
   113 
    96 void VehicleServiceInDepot(Vehicle *v)
   114 void VehicleServiceInDepot(Vehicle *v)
    97 {
   115 {
    98 	v->date_of_last_service = _date;
   116 	v->date_of_last_service = _date;
    99 	v->breakdowns_since_last_service = 0;
   117 	v->breakdowns_since_last_service = 0;
   100 	v->reliability = GetEngine(v->engine_type)->reliability;
   118 	v->reliability = GetEngine(v->engine_type)->reliability;