Codechange: Use null pointer literal instead of the NULL macro
This commit is contained in:

committed by
Michael Lutz

parent
3b4f224c0b
commit
7c8e7c6b6e
@@ -29,7 +29,7 @@
|
||||
/* static */ bool ScriptVehicle::IsValidVehicle(VehicleID vehicle_id)
|
||||
{
|
||||
const Vehicle *v = ::Vehicle::GetIfValid(vehicle_id);
|
||||
return v != NULL && (v->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) && (v->IsPrimaryVehicle() || (v->type == VEH_TRAIN && ::Train::From(v)->IsFreeWagon()));
|
||||
return v != nullptr && (v->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) && (v->IsPrimaryVehicle() || (v->type == VEH_TRAIN && ::Train::From(v)->IsFreeWagon()));
|
||||
}
|
||||
|
||||
/* static */ ScriptCompany::CompanyID ScriptVehicle::GetOwner(VehicleID vehicle_id)
|
||||
@@ -46,8 +46,8 @@
|
||||
int num = 1;
|
||||
|
||||
const Train *v = ::Train::GetIfValid(vehicle_id);
|
||||
if (v != NULL) {
|
||||
while ((v = v->GetNextUnit()) != NULL) num++;
|
||||
if (v != nullptr) {
|
||||
while ((v = v->GetNextUnit()) != nullptr) num++;
|
||||
}
|
||||
|
||||
return num;
|
||||
@@ -71,7 +71,7 @@
|
||||
|
||||
EnforcePreconditionCustomError(VEHICLE_INVALID, !ScriptGameSettings::IsDisabledVehicleType((ScriptVehicle::VehicleType)type), ScriptVehicle::ERR_VEHICLE_BUILD_DISABLED);
|
||||
|
||||
if (!ScriptObject::DoCommand(depot, engine_id | (cargo << 24), 0, ::GetCmdBuildVeh(type), NULL, &ScriptInstance::DoCommandReturnVehicleID)) return VEHICLE_INVALID;
|
||||
if (!ScriptObject::DoCommand(depot, engine_id | (cargo << 24), 0, ::GetCmdBuildVeh(type), nullptr, &ScriptInstance::DoCommandReturnVehicleID)) return VEHICLE_INVALID;
|
||||
|
||||
/* In case of test-mode, we return VehicleID 0 */
|
||||
return 0;
|
||||
@@ -104,7 +104,7 @@
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
|
||||
EnforcePrecondition(false, IsValidVehicle(vehicle_id));
|
||||
|
||||
if (!ScriptObject::DoCommand(depot, vehicle_id, share_orders, CMD_CLONE_VEHICLE, NULL, &ScriptInstance::DoCommandReturnVehicleID)) return VEHICLE_INVALID;
|
||||
if (!ScriptObject::DoCommand(depot, vehicle_id, share_orders, CMD_CLONE_VEHICLE, nullptr, &ScriptInstance::DoCommandReturnVehicleID)) return VEHICLE_INVALID;
|
||||
|
||||
/* In case of test-mode, we return VehicleID 0 */
|
||||
return 0;
|
||||
@@ -120,13 +120,13 @@
|
||||
|
||||
const Train *v = ::Train::Get(source_vehicle_id);
|
||||
while (source_wagon-- > 0) v = v->GetNextUnit();
|
||||
const Train *w = NULL;
|
||||
const Train *w = nullptr;
|
||||
if (dest_vehicle_id != -1) {
|
||||
w = ::Train::Get(dest_vehicle_id);
|
||||
while (dest_wagon-- > 0) w = w->GetNextUnit();
|
||||
}
|
||||
|
||||
return ScriptObject::DoCommand(0, v->index | (move_attached_wagons ? 1 : 0) << 20, w == NULL ? ::INVALID_VEHICLE : w->index, CMD_MOVE_RAIL_VEHICLE);
|
||||
return ScriptObject::DoCommand(0, v->index | (move_attached_wagons ? 1 : 0) << 20, w == nullptr ? ::INVALID_VEHICLE : w->index, CMD_MOVE_RAIL_VEHICLE);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptVehicle::MoveWagon(VehicleID source_vehicle_id, int source_wagon, int dest_vehicle_id, int dest_wagon)
|
||||
@@ -243,7 +243,7 @@
|
||||
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
|
||||
EnforcePrecondition(false, IsValidVehicle(vehicle_id));
|
||||
EnforcePrecondition(false, name != NULL);
|
||||
EnforcePrecondition(false, name != nullptr);
|
||||
const char *text = name->GetDecodedText();
|
||||
EnforcePreconditionEncodedText(false, text);
|
||||
EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_VEHICLE_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
|
||||
@@ -293,7 +293,7 @@
|
||||
|
||||
/* static */ char *ScriptVehicle::GetName(VehicleID vehicle_id)
|
||||
{
|
||||
if (!IsValidVehicle(vehicle_id)) return NULL;
|
||||
if (!IsValidVehicle(vehicle_id)) return nullptr;
|
||||
|
||||
::SetDParam(0, vehicle_id);
|
||||
return GetString(STR_VEHICLE_NAME);
|
||||
@@ -410,7 +410,7 @@
|
||||
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
||||
|
||||
uint32 amount = 0;
|
||||
for (const Vehicle *v = ::Vehicle::Get(vehicle_id); v != NULL; v = v->Next()) {
|
||||
for (const Vehicle *v = ::Vehicle::Get(vehicle_id); v != nullptr; v = v->Next()) {
|
||||
if (v->cargo_type == cargo) amount += v->cargo_cap;
|
||||
}
|
||||
|
||||
@@ -423,7 +423,7 @@
|
||||
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
||||
|
||||
uint32 amount = 0;
|
||||
for (const Vehicle *v = ::Vehicle::Get(vehicle_id); v != NULL; v = v->Next()) {
|
||||
for (const Vehicle *v = ::Vehicle::Get(vehicle_id); v != nullptr; v = v->Next()) {
|
||||
if (v->cargo_type == cargo) amount += v->cargo.StoredCount();
|
||||
}
|
||||
|
||||
@@ -455,7 +455,7 @@
|
||||
if (!IsValidVehicle(vehicle_id)) return false;
|
||||
|
||||
Vehicle *v = ::Vehicle::Get(vehicle_id);
|
||||
return v->orders.list != NULL && v->orders.list->GetNumVehicles() > 1;
|
||||
return v->orders.list != nullptr && v->orders.list->GetNumVehicles() > 1;
|
||||
}
|
||||
|
||||
/* static */ int ScriptVehicle::GetReliability(VehicleID vehicle_id)
|
||||
|
Reference in New Issue
Block a user