Merge remote-tracking branch 'upstream/master' into 13.0

This commit is contained in:
dP
2023-01-19 04:08:55 +04:00
336 changed files with 13062 additions and 8849 deletions
+62
View File
@@ -2988,3 +2988,65 @@ void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8 num_vehicles)
}
}
}
/**
* Calculates the maximum weight of the ground vehicle when loaded.
* @return Weight in tonnes
*/
uint32 Vehicle::GetDisplayMaxWeight() const
{
uint32 max_weight = 0;
for (const Vehicle* u = this; u != nullptr; u = u->Next()) {
max_weight += u->GetMaxWeight();
}
return max_weight;
}
/**
* Calculates the minimum power-to-weight ratio using the maximum weight of the ground vehicle
* @return power-to-weight ratio in 10ths of hp(I) per tonne
*/
uint32 Vehicle::GetDisplayMinPowerToWeight() const
{
uint32 max_weight = GetDisplayMaxWeight();
if (max_weight == 0) return 0;
return GetGroundVehicleCache()->cached_power * 10u / max_weight;
}
/**
* Checks if two vehicle chains have the same list of engines.
* @param v1 First vehicle chain.
* @param v1 Second vehicle chain.
* @return True if same, false if different.
*/
bool VehiclesHaveSameEngineList(const Vehicle *v1, const Vehicle *v2)
{
while (true) {
if (v1 == nullptr && v2 == nullptr) return true;
if (v1 == nullptr || v2 == nullptr) return false;
if (v1->GetEngine() != v2->GetEngine()) return false;
v1 = v1->GetNextVehicle();
v2 = v2->GetNextVehicle();
}
}
/**
* Checks if two vehicles have the same list of orders.
* @param v1 First vehicles.
* @param v1 Second vehicles.
* @return True if same, false if different.
*/
bool VehiclesHaveSameOrderList(const Vehicle *v1, const Vehicle *v2)
{
const Order *o1 = v1->GetFirstOrder();
const Order *o2 = v2->GetFirstOrder();
while (true) {
if (o1 == nullptr && o2 == nullptr) return true;
if (o1 == nullptr || o2 == nullptr) return false;
if (!o1->Equals(*o2)) return false;
o1 = o1->next;
o2 = o2->next;
}
}