mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
Codechange: switch our codebase to C++20
This commit is contained in:
parent
fd59393899
commit
bb49112784
8
.github/workflows/ci-build.yml
vendored
8
.github/workflows/ci-build.yml
vendored
@ -74,12 +74,12 @@ jobs:
|
||||
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
|
||||
|
@ -42,7 +42,7 @@ 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)
|
||||
|
||||
|
@ -31,7 +31,7 @@ static FBlitter_32bppSSE4_Anim iFBlitter_32bppSSE4_Anim;
|
||||
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;
|
||||
|
@ -71,7 +71,7 @@ inline DirDiff DirDifference(Direction d0, Direction d1)
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,7 +88,7 @@ inline DirDiff DirDifference(Direction d0, Direction d1)
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,7 +105,7 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
@ -150,7 +150,7 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,7 +89,7 @@ enum FiosType {
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -250,7 +250,7 @@
|
||||
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()));
|
||||
|
||||
|
@ -203,7 +203,7 @@ template<bool Tfrom, bool Tvia>
|
||||
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)
|
||||
|
@ -23,7 +23,7 @@ ScriptStationList::ScriptStationList(ScriptStation::StationType station_type)
|
||||
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;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -34,5 +34,5 @@
|
||||
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;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ ScriptWaypointList::ScriptWaypointList(ScriptWaypoint::WaypointType waypoint_typ
|
||||
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;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ inline Foundation InclinedFoundation(Axis axis)
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -403,7 +403,7 @@ inline Foundation HalftileFoundation(Corner corner)
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user