Merge branch 'master' into jgrpp
# Conflicts: # src/autoreplace_cmd.cpp # src/build_vehicle_gui.cpp # src/cargotype.cpp # src/economy.cpp # src/engine_gui.cpp # src/industry_cmd.cpp # src/industry_gui.cpp # src/linkgraph/linkgraph_gui.h # src/linkgraph/refresh.cpp # src/linkgraph/refresh.h # src/newgrf.cpp # src/newgrf_airporttiles.h # src/newgrf_roadstop.cpp # src/newgrf_station.cpp # src/newgrf_station.h # src/order_base.h # src/order_cmd.cpp # src/order_func.h # src/order_gui.cpp # src/pathfinder/pathfinder_type.h # src/saveload/afterload.cpp # src/subsidy_base.h # src/vehicle_cmd.cpp # src/vehicle_gui.cpp # src/vehicle_gui_base.h
This commit is contained in:
@@ -56,9 +56,9 @@ public:
|
||||
*/
|
||||
enum SpecialCargoID {
|
||||
/* Note: these values represent part of the in-game CargoTypes enum */
|
||||
CT_AUTO_REFIT = ::CT_AUTO_REFIT, ///< Automatically choose cargo type when doing auto-refitting.
|
||||
CT_NO_REFIT = ::CT_NO_REFIT, ///< Do not refit cargo of a vehicle.
|
||||
CT_INVALID = ::CT_INVALID, ///< An invalid cargo type.
|
||||
CT_AUTO_REFIT = ::CARGO_AUTO_REFIT, ///< Automatically choose cargo type when doing auto-refitting.
|
||||
CT_NO_REFIT = ::CARGO_NO_REFIT, ///< Do not refit cargo of a vehicle.
|
||||
CT_INVALID = ::INVALID_CARGO, ///< An invalid cargo type.
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -31,7 +31,7 @@ ScriptCargoList_IndustryAccepting::ScriptCargoList_IndustryAccepting(IndustryID
|
||||
Industry *ind = ::Industry::Get(industry_id);
|
||||
for (uint i = 0; i < lengthof(ind->accepts_cargo); i++) {
|
||||
CargoID cargo_id = ind->accepts_cargo[i];
|
||||
if (cargo_id != CT_INVALID) {
|
||||
if (cargo_id != INVALID_CARGO) {
|
||||
this->AddItem(cargo_id);
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ ScriptCargoList_IndustryProducing::ScriptCargoList_IndustryProducing(IndustryID
|
||||
Industry *ind = ::Industry::Get(industry_id);
|
||||
for (uint i = 0; i < lengthof(ind->produced_cargo); i++) {
|
||||
CargoID cargo_id = ind->produced_cargo[i];
|
||||
if (cargo_id != CT_INVALID) {
|
||||
if (cargo_id != INVALID_CARGO) {
|
||||
this->AddItem(cargo_id);
|
||||
}
|
||||
}
|
||||
|
@@ -50,12 +50,12 @@
|
||||
|
||||
/* static */ CargoID ScriptEngine::GetCargoType(EngineID engine_id)
|
||||
{
|
||||
if (!IsValidEngine(engine_id)) return CT_INVALID;
|
||||
if (!IsValidEngine(engine_id)) return INVALID_CARGO;
|
||||
|
||||
CargoArray cap = ::GetCapacityOfArticulatedParts(engine_id);
|
||||
|
||||
auto it = std::max_element(std::cbegin(cap), std::cend(cap));
|
||||
if (*it == 0) return CT_INVALID;
|
||||
if (*it == 0) return INVALID_CARGO;
|
||||
|
||||
return CargoID(std::distance(std::cbegin(cap), it));
|
||||
}
|
||||
|
@@ -37,11 +37,11 @@ std::optional<std::string> ScriptEventEnginePreview::GetName()
|
||||
|
||||
CargoID ScriptEventEnginePreview::GetCargoType()
|
||||
{
|
||||
if (!this->IsEngineValid()) return CT_INVALID;
|
||||
if (!this->IsEngineValid()) return INVALID_CARGO;
|
||||
CargoArray cap = ::GetCapacityOfArticulatedParts(this->engine);
|
||||
|
||||
auto it = std::max_element(std::cbegin(cap), std::cend(cap));
|
||||
if (*it == 0) return CT_INVALID;
|
||||
if (*it == 0) return INVALID_CARGO;
|
||||
|
||||
return CargoID(std::distance(std::cbegin(cap), it));
|
||||
}
|
||||
|
@@ -229,7 +229,7 @@
|
||||
Industry *i = Industry::GetIfValid(industry_id);
|
||||
if (i == nullptr) return ScriptDate::DATE_INVALID;
|
||||
|
||||
if (cargo_type == CT_INVALID) {
|
||||
if (cargo_type == INVALID_CARGO) {
|
||||
return (ScriptDate::Date)std::accumulate(std::begin(i->last_cargo_accepted_at), std::end(i->last_cargo_accepted_at), Date(0), [](Date a, Date b) { return std::max(a, b); }).base();
|
||||
} else {
|
||||
int index = i->GetCargoAcceptedIndex(cargo_type);
|
||||
|
@@ -258,9 +258,9 @@ public:
|
||||
/**
|
||||
* Get the last date this industry accepted any cargo delivery.
|
||||
* @param industry_id The index of the industry.
|
||||
* @param cargo_type The cargo to query, or CT_INVALID to query latest of all accepted cargoes.
|
||||
* @param cargo_type The cargo to query, or INVALID_CARGO to query latest of all accepted cargoes.
|
||||
* @pre IsValidIndustry(industry_id).
|
||||
* @pre IsValidCargo(cargo_type) || cargo_type == CT_INVALID.
|
||||
* @pre IsValidCargo(cargo_type) || cargo_type == INVALID_CARGO.
|
||||
* @return Date the industry last received cargo from a delivery, or ScriptDate::DATE_INVALID on error.
|
||||
* @api -ai
|
||||
*/
|
||||
|
@@ -376,11 +376,11 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||
|
||||
/* static */ CargoID ScriptOrder::GetOrderRefit(VehicleID vehicle_id, OrderPosition order_position)
|
||||
{
|
||||
if (!IsValidVehicleOrder(vehicle_id, order_position)) return CT_NO_REFIT;
|
||||
if (order_position != ORDER_CURRENT && !IsGotoStationOrder(vehicle_id, order_position) && !IsGotoDepotOrder(vehicle_id, order_position)) return CT_NO_REFIT;
|
||||
if (!IsValidVehicleOrder(vehicle_id, order_position)) return CARGO_NO_REFIT;
|
||||
if (order_position != ORDER_CURRENT && !IsGotoStationOrder(vehicle_id, order_position) && !IsGotoDepotOrder(vehicle_id, order_position)) return CARGO_NO_REFIT;
|
||||
|
||||
const Order *order = ::ResolveOrder(vehicle_id, order_position);
|
||||
return order->IsRefit() ? order->GetRefitCargo() : (CargoID)CT_NO_REFIT;
|
||||
return order->IsRefit() ? order->GetRefitCargo() : CARGO_NO_REFIT;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptOrder::SetOrderJumpTo(VehicleID vehicle_id, OrderPosition order_position, OrderPosition jump_to)
|
||||
@@ -446,8 +446,8 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||
{
|
||||
EnforceCompanyModeValid(false);
|
||||
EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_position));
|
||||
EnforcePrecondition(false, IsGotoStationOrder(vehicle_id, order_position) || (IsGotoDepotOrder(vehicle_id, order_position) && refit_cargo != CT_AUTO_REFIT));
|
||||
EnforcePrecondition(false, ScriptCargo::IsValidCargo(refit_cargo) || refit_cargo == CT_AUTO_REFIT || refit_cargo == CT_NO_REFIT);
|
||||
EnforcePrecondition(false, IsGotoStationOrder(vehicle_id, order_position) || (IsGotoDepotOrder(vehicle_id, order_position) && refit_cargo != CARGO_AUTO_REFIT));
|
||||
EnforcePrecondition(false, ScriptCargo::IsValidCargo(refit_cargo) || refit_cargo == CARGO_AUTO_REFIT || refit_cargo == CARGO_NO_REFIT);
|
||||
|
||||
uint32_t p1 = vehicle_id;
|
||||
uint32_t p2 = refit_cargo | ScriptOrderPositionToRealOrderPosition(vehicle_id, ScriptOrder::ResolveOrderPosition(vehicle_id, order_position)) << 16;
|
||||
|
@@ -66,7 +66,7 @@
|
||||
|
||||
/* static */ CargoID ScriptSubsidy::GetCargoType(SubsidyID subsidy_id)
|
||||
{
|
||||
if (!IsValidSubsidy(subsidy_id)) return CT_INVALID;
|
||||
if (!IsValidSubsidy(subsidy_id)) return INVALID_CARGO;
|
||||
|
||||
return ::Subsidy::Get(subsidy_id)->cargo_type;
|
||||
}
|
||||
|
@@ -98,7 +98,7 @@ ScriptTileList_IndustryAccepting::ScriptTileList_IndustryAccepting(IndustryID in
|
||||
{
|
||||
bool cargo_accepts = false;
|
||||
for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
|
||||
if (i->accepts_cargo[j] != CT_INVALID && acceptance[i->accepts_cargo[j]] != 0) cargo_accepts = true;
|
||||
if (i->accepts_cargo[j] != INVALID_CARGO && acceptance[i->accepts_cargo[j]] != 0) cargo_accepts = true;
|
||||
}
|
||||
if (!cargo_accepts) continue;
|
||||
}
|
||||
|
@@ -72,7 +72,7 @@
|
||||
{
|
||||
EnforceCompanyModeValid(VEHICLE_INVALID);
|
||||
EnforcePrecondition(VEHICLE_INVALID, ScriptEngine::IsBuildable(engine_id));
|
||||
EnforcePrecondition(VEHICLE_INVALID, cargo == CT_INVALID || ScriptCargo::IsValidCargo(cargo));
|
||||
EnforcePrecondition(VEHICLE_INVALID, cargo == INVALID_CARGO || ScriptCargo::IsValidCargo(cargo));
|
||||
|
||||
::VehicleType type = ::Engine::Get(engine_id)->type;
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
|
||||
/* static */ VehicleID ScriptVehicle::BuildVehicle(TileIndex depot, EngineID engine_id)
|
||||
{
|
||||
return _BuildVehicleInternal(depot, engine_id, CT_INVALID);
|
||||
return _BuildVehicleInternal(depot, engine_id, INVALID_CARGO);
|
||||
}
|
||||
|
||||
/* static */ VehicleID ScriptVehicle::BuildVehicleWithRefit(TileIndex depot, EngineID engine_id, CargoID cargo)
|
||||
|
Reference in New Issue
Block a user