Changeset - r28491:779a44bc4e9e
[Not reviewed]
master
0 11 0
Patric Stout - 11 months ago 2024-01-16 19:38:42
truebrain@openttd.org
Codechange: switch our codebase to C++20
11 files changed with 18 insertions and 18 deletions:
0 comments (0 inline, 0 general)
.github/workflows/ci-build.yml
Show inline comments
 
@@ -71,18 +71,18 @@ jobs:
 
  linux:
 
    strategy:
 
      fail-fast: false
 
      matrix:
 
        include:
 
        - name: Clang - Debug
 
          compiler: clang
 
          cxxcompiler: clang++
 
          compiler: clang-15
 
          cxxcompiler: clang++-15
 
          libraries: libsdl2-dev
 
        - name: Clang - Release
 
          compiler: clang
 
          cxxcompiler: clang++
 
          compiler: clang-15
 
          cxxcompiler: clang++-15
 
          libraries: libsdl2-dev
 
          extra-cmake-parameters: -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPTION_USE_ASSERTS=OFF
 
        - name: GCC - SDL2
 
          compiler: gcc
 
          cxxcompiler: g++
 
          libraries: libsdl2-dev
CMakeLists.txt
Show inline comments
 
@@ -39,13 +39,13 @@ include(Options)
 
set_options()
 
set_directory_options()
 

	
 
include(Static)
 
set_static_if_needed()
 

	
 
set(CMAKE_CXX_STANDARD 17)
 
set(CMAKE_CXX_STANDARD 20)
 
set(CMAKE_CXX_STANDARD_REQUIRED YES)
 
set(CMAKE_CXX_EXTENSIONS NO)
 

	
 
set(CMAKE_EXPORT_COMPILE_COMMANDS YES)
 

	
 
# An empty target for the tools
src/blitter/32bpp_anim_sse4.cpp
Show inline comments
 
@@ -28,13 +28,13 @@ static FBlitter_32bppSSE4_Anim iFBlitter
 
 * @param bp further blitting parameters
 
 * @param zoom zoom level at which we are drawing
 
 */
 
IGNORE_UNINITIALIZED_WARNING_START
 
template <BlitterMode mode, Blitter_32bppSSE2::ReadMode read_mode, Blitter_32bppSSE2::BlockType bt_last, bool translucent, bool animated>
 
GNU_TARGET("sse4.1")
 
inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
 
inline void Blitter_32bppSSE4_Anim::Draw(const BlitterParams *bp, ZoomLevel zoom)
 
{
 
	const byte * const remap = bp->remap;
 
	Colour *dst_line = (Colour *) bp->dst + bp->top * bp->pitch + bp->left;
 
	uint16_t *anim_line = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left;
 
	int effective_width = bp->width;
 

	
src/direction_func.h
Show inline comments
 
@@ -68,13 +68,13 @@ inline Direction ReverseDir(Direction d)
 
inline DirDiff DirDifference(Direction d0, Direction d1)
 
{
 
	assert(IsValidDirection(d0));
 
	assert(IsValidDirection(d1));
 
	/* Cast to uint so compiler can use bitmask. If the difference is negative
 
	 * and we used int instead of uint, further "+ 8" would have to be added. */
 
	return (DirDiff)((uint)(d0 - d1) % 8);
 
	return static_cast<DirDiff>(static_cast<uint>(d0) - static_cast<uint>(d1) % 8);
 
}
 

	
 
/**
 
 * Applies two differences together
 
 *
 
 * This function adds two differences together and returns the resulting
 
@@ -85,13 +85,13 @@ inline DirDiff DirDifference(Direction d
 
 * @param delta The second difference to add on
 
 * @return The resulting difference
 
 */
 
inline DirDiff ChangeDirDiff(DirDiff d, DirDiff delta)
 
{
 
	/* Cast to uint so compiler can use bitmask. Result can never be negative. */
 
	return (DirDiff)((uint)(d + delta) % 8);
 
	return static_cast<DirDiff>((static_cast<uint>(d) + static_cast<uint>(delta)) % 8);
 
}
 

	
 
/**
 
 * Change a direction by a given difference
 
 *
 
 * This functions returns a new direction of the given direction
 
@@ -102,13 +102,13 @@ inline DirDiff ChangeDirDiff(DirDiff d, 
 
 * @return The new direction
 
 */
 
inline Direction ChangeDir(Direction d, DirDiff delta)
 
{
 
	assert(IsValidDirection(d));
 
	/* Cast to uint so compiler can use bitmask. Result can never be negative. */
 
	return (Direction)((uint)(d + delta) % 8);
 
	return static_cast<Direction>((static_cast<uint>(d) + static_cast<uint>(delta)) % 8);
 
}
 

	
 

	
 
/**
 
 * Returns the reverse direction of the given DiagDirection
 
 *
 
@@ -147,13 +147,13 @@ inline DiagDirDiff DiagDirDifference(Dia
 
 * @return The new direction which was calculated
 
 */
 
inline DiagDirection ChangeDiagDir(DiagDirection d, DiagDirDiff delta)
 
{
 
	assert(IsValidDiagDirection(d));
 
	/* Cast to uint so compiler can use bitmask. Result can never be negative. */
 
	return (DiagDirection)((uint)(d + delta) % 4);
 
	return static_cast<DiagDirection>((static_cast<uint>(d) + static_cast<uint>(delta)) % 4);
 
}
 

	
 
/**
 
 * Convert a Direction to a DiagDirection.
 
 *
 
 * This function can be used to convert the 8-way Direction to
src/fileio_type.h
Show inline comments
 
@@ -86,13 +86,13 @@ enum FiosType {
 
 * Extract the abstract file type from a #FiosType.
 
 * @param fios_type Type to query.
 
 * @return The Abstract file type of the \a fios_type.
 
 */
 
inline AbstractFileType GetAbstractFileType(FiosType fios_type)
 
{
 
	return static_cast<AbstractFileType>(fios_type & FT_MASK);
 
	return static_cast<AbstractFileType>(static_cast<uint>(fios_type) & FT_MASK);
 
}
 

	
 
/**
 
 * Extract the detailed file type from a #FiosType.
 
 * @param fios_type Type to query.
 
 * @return The Detailed file type of the \a fios_type.
src/script/api/script_rail.cpp
Show inline comments
 
@@ -247,13 +247,13 @@
 

	
 
/* static */ bool ScriptRail::BuildRailTrack(TileIndex tile, RailTrack rail_track)
 
{
 
	EnforceCompanyModeValid(false);
 
	EnforcePrecondition(false, ::IsValidTile(tile));
 
	EnforcePrecondition(false, rail_track != 0);
 
	EnforcePrecondition(false, (rail_track & ~::TRACK_BIT_ALL) == 0);
 
	EnforcePrecondition(false, (static_cast<uint>(rail_track) & ~static_cast<uint>(::TRACK_BIT_ALL)) == 0);
 
	EnforcePrecondition(false, KillFirstBit((uint)rail_track) == 0);
 
	EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType()));
 

	
 
	return ScriptObject::Command<CMD_BUILD_RAILROAD_TRACK>::Do(tile, tile, (::RailType)GetCurrentRailType(), FindFirstTrack((::TrackBits)rail_track), false, false);
 
}
 

	
src/script/api/script_station.cpp
Show inline comments
 
@@ -200,13 +200,13 @@ template<bool Tfrom, bool Tvia>
 

	
 
/* static */ bool ScriptStation::HasStationType(StationID station_id, StationType station_type)
 
{
 
	if (!IsValidStation(station_id)) return false;
 
	if (!HasExactlyOneBit(station_type)) return false;
 

	
 
	return (::Station::Get(station_id)->facilities & station_type) != 0;
 
	return (::Station::Get(station_id)->facilities & static_cast<StationFacility>(station_type)) != 0;
 
}
 

	
 
/* static */ bool ScriptStation::HasRoadType(StationID station_id, ScriptRoad::RoadType road_type)
 
{
 
	if (!IsValidStation(station_id)) return false;
 
	if (!ScriptRoad::IsRoadTypeAvailable(road_type)) return false;
src/script/api/script_stationlist.cpp
Show inline comments
 
@@ -20,13 +20,13 @@ ScriptStationList::ScriptStationList(Scr
 
{
 
	EnforceDeityOrCompanyModeValid_Void();
 
	bool is_deity = ScriptCompanyMode::IsDeity();
 
	CompanyID owner = ScriptObject::GetCompany();
 
	ScriptList::FillList<Station>(this,
 
		[is_deity, owner, station_type](const Station *st) {
 
			return (is_deity || st->owner == owner) && (st->facilities & station_type) != 0;
 
			return (is_deity || st->owner == owner) && (st->facilities & static_cast<StationFacility>(station_type)) != 0;
 
		}
 
	);
 
}
 

	
 
ScriptStationList_Vehicle::ScriptStationList_Vehicle(VehicleID vehicle_id)
 
{
src/script/api/script_waypoint.cpp
Show inline comments
 
@@ -31,8 +31,8 @@
 

	
 
/* static */ bool ScriptWaypoint::HasWaypointType(StationID waypoint_id, WaypointType waypoint_type)
 
{
 
	if (!IsValidWaypoint(waypoint_id)) return false;
 
	if (!HasExactlyOneBit(waypoint_type)) return false;
 

	
 
	return (::Waypoint::Get(waypoint_id)->facilities & waypoint_type) != 0;
 
	return (::Waypoint::Get(waypoint_id)->facilities & static_cast<StationFacility>(waypoint_type)) != 0;
 
}
src/script/api/script_waypointlist.cpp
Show inline comments
 
@@ -20,13 +20,13 @@ ScriptWaypointList::ScriptWaypointList(S
 
	EnforceDeityOrCompanyModeValid_Void();
 

	
 
	bool is_deity = ScriptCompanyMode::IsDeity();
 
	CompanyID owner = ScriptObject::GetCompany();
 
	ScriptList::FillList<Waypoint>(this,
 
		[is_deity, owner, waypoint_type](const Waypoint *wp) {
 
			return (is_deity || wp->owner == owner || wp->owner == OWNER_NONE) && (wp->facilities & waypoint_type) != 0;
 
			return (is_deity || wp->owner == owner || wp->owner == OWNER_NONE) && (wp->facilities & static_cast<StationFacility>(waypoint_type)) != 0;
 
		}
 
	);
 
}
 

	
 
ScriptWaypointList_Vehicle::ScriptWaypointList_Vehicle(VehicleID vehicle_id)
 
{
src/slope_func.h
Show inline comments
 
@@ -388,25 +388,25 @@ inline Foundation InclinedFoundation(Axi
 
 * @param corner The #Corner with the track.
 
 * @return       The wanted #Foundation.
 
 */
 
inline Foundation HalftileFoundation(Corner corner)
 
{
 
	assert(IsValidCorner(corner));
 
	return (Foundation)(FOUNDATION_HALFTILE_W + corner);
 
	return static_cast<Foundation>(static_cast<uint>(FOUNDATION_HALFTILE_W) + static_cast<uint>(corner));
 
}
 

	
 
/**
 
 * Returns the special rail foundation for single horizontal/vertical track.
 
 *
 
 * @param corner The #Corner with the track.
 
 * @return       The wanted #Foundation.
 
 */
 
inline Foundation SpecialRailFoundation(Corner corner)
 
{
 
	assert(IsValidCorner(corner));
 
	return (Foundation)(FOUNDATION_RAIL_W + corner);
 
	return static_cast<Foundation>(static_cast<uint>(FOUNDATION_RAIL_W) + static_cast<uint>(corner));
 
}
 

	
 
/**
 
 * Returns the #Sprite offset for a given #Slope.
 
 *
 
 * @param s The #Slope to get the offset for.
0 comments (0 inline, 0 general)