Codechange: Use IsValidCargoID/IsValidCargoType.
IsValidCargoType() is used only for unmapped IDs.
This commit is contained in:
@@ -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 (::IsValidCargoID(cargo_id)) {
|
||||
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 (::IsValidCargoID(cargo_id)) {
|
||||
this->AddItem(cargo_id);
|
||||
}
|
||||
}
|
||||
|
@@ -234,7 +234,7 @@
|
||||
Industry *i = Industry::GetIfValid(industry_id);
|
||||
if (i == nullptr) return ScriptDate::DATE_INVALID;
|
||||
|
||||
if (cargo_type == CT_INVALID) {
|
||||
if (!::IsValidCargoID(cargo_type)) {
|
||||
return (ScriptDate::Date)std::accumulate(std::begin(i->last_cargo_accepted_at), std::end(i->last_cargo_accepted_at), 0, [](TimerGameCalendar::Date a, TimerGameCalendar::Date b) { return std::max(a, b); });
|
||||
} else {
|
||||
int index = i->GetCargoAcceptedIndex(cargo_type);
|
||||
|
@@ -72,7 +72,7 @@
|
||||
|
||||
ScriptList *list = new ScriptList();
|
||||
for (size_t i = 0; i < lengthof(ins->produced_cargo); i++) {
|
||||
if (ins->produced_cargo[i] != CT_INVALID) list->AddItem(ins->produced_cargo[i]);
|
||||
if (::IsValidCargoID(ins->produced_cargo[i])) list->AddItem(ins->produced_cargo[i]);
|
||||
}
|
||||
|
||||
return list;
|
||||
@@ -86,7 +86,7 @@
|
||||
|
||||
ScriptList *list = new ScriptList();
|
||||
for (size_t i = 0; i < lengthof(ins->accepts_cargo); i++) {
|
||||
if (ins->accepts_cargo[i] != CT_INVALID) list->AddItem(ins->accepts_cargo[i]);
|
||||
if (::IsValidCargoID(ins->accepts_cargo[i])) list->AddItem(ins->accepts_cargo[i]);
|
||||
}
|
||||
|
||||
return list;
|
||||
|
@@ -86,7 +86,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) cargo_accepts = true;
|
||||
if (::IsValidCargoID(i->accepts_cargo[j])) cargo_accepts = true;
|
||||
}
|
||||
if (!cargo_accepts) return;
|
||||
}
|
||||
@@ -104,7 +104,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 (::IsValidCargoID(i->accepts_cargo[j]) && acceptance[i->accepts_cargo[j]] != 0) cargo_accepts = true;
|
||||
}
|
||||
if (!cargo_accepts) continue;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ ScriptTileList_IndustryProducing::ScriptTileList_IndustryProducing(IndustryID in
|
||||
/* Check if this industry produces anything */
|
||||
bool cargo_produces = false;
|
||||
for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
|
||||
if (i->produced_cargo[j] != CT_INVALID) cargo_produces = true;
|
||||
if (::IsValidCargoID(i->produced_cargo[j])) cargo_produces = true;
|
||||
}
|
||||
if (!cargo_produces) return;
|
||||
|
||||
|
@@ -75,7 +75,7 @@
|
||||
{
|
||||
EnforceCompanyModeValid(VEHICLE_INVALID);
|
||||
EnforcePrecondition(VEHICLE_INVALID, ScriptEngine::IsBuildable(engine_id));
|
||||
EnforcePrecondition(VEHICLE_INVALID, cargo == CT_INVALID || ScriptCargo::IsValidCargo(cargo));
|
||||
EnforcePrecondition(VEHICLE_INVALID, !::IsValidCargoID(cargo) || ScriptCargo::IsValidCargo(cargo));
|
||||
|
||||
::VehicleType type = ::Engine::Get(engine_id)->type;
|
||||
|
||||
|
Reference in New Issue
Block a user