Merge branch 'master' into jgrpp
# Conflicts: # src/company_cmd.cpp # src/core/overflowsafe_type.hpp # src/economy.cpp # src/engine_base.h # src/ground_vehicle.cpp # src/group_gui.cpp # src/industry_cmd.cpp # src/industry_gui.cpp # src/newgrf_commons.cpp # src/newgrf_engine.cpp # src/newgrf_industries.cpp # src/newgrf_object.cpp # src/newgrf_roadstop.cpp # src/newgrf_station.cpp # src/rail_gui.cpp # src/road_cmd.h # src/road_gui.cpp # src/saveload/afterload.cpp # src/script/api/script_log.cpp # src/script/api/script_log.hpp # src/settings_gui.cpp # src/settingsgen/settingsgen.cpp # src/station_cmd.cpp # src/station_cmd.h # src/station_gui.cpp # src/strgen/strgen.cpp # src/string_func.h # src/string_type.h # src/table/settings/network_private_settings.ini # src/tests/math_func.cpp # src/textfile_gui.cpp # src/timetable_gui.cpp # src/town_cmd.cpp # src/vehicle.cpp # src/waypoint_cmd.cpp # src/waypoint_cmd.h # src/widgets/dropdown.cpp
This commit is contained in:
@@ -660,7 +660,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
{
|
||||
const Vehicle *w = v->Next();
|
||||
assert(w != nullptr);
|
||||
uint16 altitude = ClampToU16(v->z_pos - w->z_pos); // Aircraft height - shadow height
|
||||
uint16 altitude = ClampTo<uint16_t>(v->z_pos - w->z_pos); // Aircraft height - shadow height
|
||||
byte airporttype = ATP_TTDP_LARGE;
|
||||
|
||||
const Station *st = GetTargetAirportIfValid(Aircraft::From(v));
|
||||
@@ -669,7 +669,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
airporttype = st->airport.GetSpec()->ttd_airport_type;
|
||||
}
|
||||
|
||||
return (Clamp(altitude, 0, 0xFF) << 8) | airporttype;
|
||||
return (ClampTo<uint8_t>(altitude) << 8) | airporttype;
|
||||
}
|
||||
|
||||
case 0x45: { // Curvature info
|
||||
@@ -925,8 +925,8 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
}
|
||||
return (variable - 0x80) == 0x10 ? ticks : GB(ticks, 8, 8);
|
||||
}
|
||||
case 0x12: return Clamp(v->date_of_last_service - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 0xFFFF);
|
||||
case 0x13: return GB(Clamp(v->date_of_last_service - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 0xFFFF), 8, 8);
|
||||
case 0x12: return ClampTo<uint16_t>(v->date_of_last_service - DAYS_TILL_ORIGINAL_BASE_YEAR);
|
||||
case 0x13: return GB(ClampTo<uint16_t>(v->date_of_last_service - DAYS_TILL_ORIGINAL_BASE_YEAR), 8, 8);
|
||||
case 0x14: return v->GetServiceInterval();
|
||||
case 0x15: return GB(v->GetServiceInterval(), 8, 8);
|
||||
case 0x16: return v->last_station_visited;
|
||||
@@ -979,14 +979,14 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
case 0x39: return v->cargo_type;
|
||||
case 0x3A: return v->cargo_cap;
|
||||
case 0x3B: return GB(v->cargo_cap, 8, 8);
|
||||
case 0x3C: return ClampToU16(v->cargo.StoredCount());
|
||||
case 0x3D: return GB(ClampToU16(v->cargo.StoredCount()), 8, 8);
|
||||
case 0x3C: return ClampTo<uint16_t>(v->cargo.StoredCount());
|
||||
case 0x3D: return GB(ClampTo<uint16_t>(v->cargo.StoredCount()), 8, 8);
|
||||
case 0x3E: return v->cargo.Source();
|
||||
case 0x3F: return ClampU(v->cargo.DaysInTransit(), 0, 0xFF);
|
||||
case 0x40: return ClampToU16(v->age);
|
||||
case 0x41: return GB(ClampToU16(v->age), 8, 8);
|
||||
case 0x42: return ClampToU16(v->max_age);
|
||||
case 0x43: return GB(ClampToU16(v->max_age), 8, 8);
|
||||
case 0x3F: return ClampTo<uint8_t>(v->cargo.DaysInTransit());
|
||||
case 0x40: return ClampTo<uint16_t>(v->age);
|
||||
case 0x41: return GB(ClampTo<uint16_t>(v->age), 8, 8);
|
||||
case 0x42: return ClampTo<uint16_t>(v->max_age);
|
||||
case 0x43: return GB(ClampTo<uint16_t>(v->max_age), 8, 8);
|
||||
case 0x44: return Clamp(v->build_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR;
|
||||
case 0x45: return v->unitnumber;
|
||||
case 0x46: return v->GetEngine()->grf_prop.local_id;
|
||||
@@ -1004,20 +1004,20 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
case 0x4F: return GB(v->reliability, 8, 8);
|
||||
case 0x50: return v->reliability_spd_dec;
|
||||
case 0x51: return GB(v->reliability_spd_dec, 8, 8);
|
||||
case 0x52: return ClampToI32(v->GetDisplayProfitThisYear());
|
||||
case 0x53: return GB(ClampToI32(v->GetDisplayProfitThisYear()), 8, 24);
|
||||
case 0x54: return GB(ClampToI32(v->GetDisplayProfitThisYear()), 16, 16);
|
||||
case 0x55: return GB(ClampToI32(v->GetDisplayProfitThisYear()), 24, 8);
|
||||
case 0x56: return ClampToI32(v->GetDisplayProfitLastYear());
|
||||
case 0x57: return GB(ClampToI32(v->GetDisplayProfitLastYear()), 8, 24);
|
||||
case 0x58: return GB(ClampToI32(v->GetDisplayProfitLastYear()), 16, 16);
|
||||
case 0x59: return GB(ClampToI32(v->GetDisplayProfitLastYear()), 24, 8);
|
||||
case 0x52: return ClampTo<int32_t>(v->GetDisplayProfitThisYear());
|
||||
case 0x53: return GB(ClampTo<int32_t>(v->GetDisplayProfitThisYear()), 8, 24);
|
||||
case 0x54: return GB(ClampTo<int32_t>(v->GetDisplayProfitThisYear()), 16, 16);
|
||||
case 0x55: return GB(ClampTo<int32_t>(v->GetDisplayProfitThisYear()), 24, 8);
|
||||
case 0x56: return ClampTo<int32_t>(v->GetDisplayProfitLastYear());
|
||||
case 0x57: return GB(ClampTo<int32_t>(v->GetDisplayProfitLastYear()), 8, 24);
|
||||
case 0x58: return GB(ClampTo<int32_t>(v->GetDisplayProfitLastYear()), 16, 16);
|
||||
case 0x59: return GB(ClampTo<int32_t>(v->GetDisplayProfitLastYear()), 24, 8);
|
||||
case 0x5A: return v->Next() == nullptr ? INVALID_VEHICLE : v->Next()->index;
|
||||
case 0x5B: break; // not implemented
|
||||
case 0x5C: return ClampToI32(v->value);
|
||||
case 0x5D: return GB(ClampToI32(v->value), 8, 24);
|
||||
case 0x5E: return GB(ClampToI32(v->value), 16, 16);
|
||||
case 0x5F: return GB(ClampToI32(v->value), 24, 8);
|
||||
case 0x5C: return ClampTo<int32_t>(v->value);
|
||||
case 0x5D: return GB(ClampTo<int32_t>(v->value), 8, 24);
|
||||
case 0x5E: return GB(ClampTo<int32_t>(v->value), 16, 16);
|
||||
case 0x5F: return GB(ClampTo<int32_t>(v->value), 24, 8);
|
||||
case 0x60: break; // not implemented
|
||||
case 0x61: break; // not implemented
|
||||
case 0x62: break; // vehicle specific, see below
|
||||
@@ -1132,8 +1132,8 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
case 0x48: return Engine::Get(this->self_type)->flags; // Vehicle Type Info
|
||||
case 0x49: return _cur_year; // 'Long' format build year
|
||||
case 0x4B: return _date; // Long date of last service
|
||||
case 0x92: return Clamp(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 0xFFFF); // Date of last service
|
||||
case 0x93: return GB(Clamp(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 0xFFFF), 8, 8);
|
||||
case 0x92: return ClampTo<uint16>(_date - DAYS_TILL_ORIGINAL_BASE_YEAR); // Date of last service
|
||||
case 0x93: return GB(ClampTo<uint16>(_date - DAYS_TILL_ORIGINAL_BASE_YEAR), 8, 8);
|
||||
case 0xC4: return Clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; // Build year
|
||||
case 0xC6: return Engine::Get(this->self_type)->grf_prop.local_id;
|
||||
case 0xC7: return GB(Engine::Get(this->self_type)->grf_prop.local_id, 8, 8);
|
||||
|
||||
Reference in New Issue
Block a user