mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #11366 from janisozaur/super-duper-warnings
Super duper warnings
This commit is contained in:
commit
e716250dec
|
@ -69,7 +69,7 @@ endif ()
|
|||
|
||||
# LIST of supported flags, use SET_CHECK_CXX_FLAGS() to apply to target.
|
||||
# Use ADD_CHECK_CXX_COMPILER_FLAG() to add to list.
|
||||
list(APPEND SUPPORTED_CHECK_CXX_COMPILER_FLAGS)
|
||||
set(SUPPORTED_CHECK_CXX_COMPILER_FLAGS "")
|
||||
|
||||
include(cmake/ipo.cmake)
|
||||
list(APPEND IPO_ENABLED_BUILDS RELEASE RELWITHDEBINFO MINSIZEREL)
|
||||
|
@ -122,16 +122,6 @@ if (ENABLE_LIGHTFX)
|
|||
add_definitions(-D__ENABLE_LIGHTFX__)
|
||||
endif ()
|
||||
|
||||
if (CXX_WARN_SUGGEST_FINAL_TYPES)
|
||||
# Disable -Wsuggest-final-types via pragmas where due.
|
||||
add_definitions(-D__WARN_SUGGEST_FINAL_TYPES__)
|
||||
endif ()
|
||||
|
||||
if (CXX_WARN_SUGGEST_FINAL_METHODS)
|
||||
# Disable -Wsuggest-final-methods via pragmas where due.
|
||||
add_definitions(-D__WARN_SUGGEST_FINAL_METHODS__)
|
||||
endif ()
|
||||
|
||||
if (NOT DISABLE_DISCORD_RPC)
|
||||
if(EXISTS "${ROOT_DIR}/discord-rpc")
|
||||
# Don't build discord's examples, some of which are in C and do not honour
|
||||
|
@ -162,7 +152,7 @@ endif()
|
|||
function (ADD_CHECK_CXX_COMPILER_FLAG _CXXFLAGS _CACHE_VAR _FLAG)
|
||||
CHECK_CXX_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
|
||||
if (${_CACHE_VAR})
|
||||
list(APPEND SUPPORTED_CHECK_CXX_COMPILER_FLAGS "${_FLAG}")
|
||||
set(SUPPORTED_CHECK_CXX_COMPILER_FLAGS ${SUPPORTED_CHECK_CXX_COMPILER_FLAGS} ${_FLAG} PARENT_SCOPE)
|
||||
else ()
|
||||
message(STATUS "Unsupported CXXFLAG: ${_FLAG}")
|
||||
endif ()
|
||||
|
@ -201,9 +191,6 @@ if (MSVC)
|
|||
endif ()
|
||||
add_definitions(-DNOMINMAX)
|
||||
else ()
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_NULL_DEREFERENCE -Wnull-dereference)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_SUGGEST_FINAL_TYPES -Wsuggest-final-types)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_SUGGEST_FINAL_METHODS -Wsuggest-final-methods)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_SUGGEST_OVERRIDE -Wsuggest-override)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_DUPLICATED_COND -Wduplicated-cond)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_NON_VIRTUAL_DTOR -Wnon-virtual-dtor)
|
||||
|
@ -215,7 +202,7 @@ else ()
|
|||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_LOGICAL_OP -Wlogical-op)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_RANGE_LOOP_ANALYSIS -Wrange-loop-analysis)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_TAUTOLOGICAL_ZERO_COMPARE -Wtautological-unsigned-zero-compare)
|
||||
ADD_CHECK_CXX_FLAG(CMAKE_CXX_FLAGS CXX_WNO_CLOBBERED -Wno-clobbered)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WNO_CLOBBERED -Wno-clobbered)
|
||||
# Disabled due to problems compiling OpenSSL on macOS.
|
||||
# ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_DOCUMENTATION -Wdocumentation)
|
||||
|
||||
|
@ -223,6 +210,14 @@ else ()
|
|||
if (NOT MINGW)
|
||||
# Do not enable for MinGW, as its headers contain redundant declarations of builtin functions
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_REDUNDANT_DECLS -Wredundant-decls)
|
||||
|
||||
# Currently used MinGW w/GCC 7.2 doesn't provide sane error messages for this
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_NULL_DEREFERENCE -Wnull-dereference)
|
||||
endif ()
|
||||
# These have no workarounds available when building with LTO
|
||||
if (NOT IPO_BUILD_ENABLED)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_SUGGEST_FINAL_TYPES -Wsuggest-final-types)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_SUGGEST_FINAL_METHODS -Wsuggest-final-methods)
|
||||
endif ()
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_IGNORED_QUALIFIERS -Wignored-qualifiers)
|
||||
|
||||
|
@ -254,6 +249,16 @@ else ()
|
|||
endif ()
|
||||
endif ()
|
||||
|
||||
if (CXX_WARN_SUGGEST_FINAL_TYPES)
|
||||
# Disable -Wsuggest-final-types via pragmas where due.
|
||||
add_definitions(-D__WARN_SUGGEST_FINAL_TYPES__)
|
||||
endif ()
|
||||
|
||||
if (CXX_WARN_SUGGEST_FINAL_METHODS)
|
||||
# Disable -Wsuggest-final-methods via pragmas where due.
|
||||
add_definitions(-D__WARN_SUGGEST_FINAL_METHODS__)
|
||||
endif ()
|
||||
|
||||
# Include sub-projects
|
||||
include("${ROOT_DIR}/src/openrct2/CMakeLists.txt" NO_POLICY_SCOPE)
|
||||
include("${ROOT_DIR}/src/openrct2-cli/CMakeLists.txt" NO_POLICY_SCOPE)
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
namespace OpenRCT2::Audio
|
||||
{
|
||||
class AudioContext : public IAudioContext
|
||||
class AudioContext final : public IAudioContext
|
||||
{
|
||||
private:
|
||||
IAudioMixer* _audioMixer = nullptr;
|
||||
|
|
|
@ -130,7 +130,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
virtual void Draw(int32_t x, int32_t y, int32_t width, int32_t height, int32_t xStart, int32_t yStart)
|
||||
virtual void Draw(int32_t x, int32_t y, int32_t width, int32_t height, int32_t xStart, int32_t yStart) override
|
||||
{
|
||||
const uint8_t* pattern = RainPattern;
|
||||
|
||||
|
@ -172,7 +172,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class OpenGLDrawingEngine : public IDrawingEngine
|
||||
class OpenGLDrawingEngine final : public IDrawingEngine
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<IUiContext> const _uiContext;
|
||||
|
|
|
@ -1844,7 +1844,8 @@ static void window_ride_construction_construct(rct_window* w)
|
|||
_currentTrackSelectionFlags |= TRACK_SELECTION_FLAG_TRACK_PLACE_ACTION_QUEUED;
|
||||
}
|
||||
|
||||
if (dynamic_cast<TrackPlaceActionResult*>(res.get())->GroundFlags & TRACK_ELEMENT_LOCATION_IS_UNDERGROUND)
|
||||
auto tpar = dynamic_cast<TrackPlaceActionResult*>(res.get());
|
||||
if (tpar != nullptr && tpar->GroundFlags & TRACK_ELEMENT_LOCATION_IS_UNDERGROUND)
|
||||
{
|
||||
viewport_set_visibility(1);
|
||||
}
|
||||
|
|
|
@ -2559,17 +2559,18 @@ static money32 try_place_ghost_scenery(
|
|||
{ map_tile.x, map_tile.y, gSceneryPlaceZ, rotation }, quadrant, entryIndex, primaryColour, secondaryColour);
|
||||
smallSceneryPlaceAction.SetFlags(GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED);
|
||||
auto res = GameActions::Execute(&smallSceneryPlaceAction);
|
||||
if (res->Error != GA_ERROR::OK)
|
||||
auto sspar = dynamic_cast<SmallSceneryPlaceActionResult*>(res.get());
|
||||
if (sspar == nullptr || res->Error != GA_ERROR::OK)
|
||||
return MONEY32_UNDEFINED;
|
||||
|
||||
gSceneryPlaceRotation = static_cast<uint16_t>(parameter_3 & 0xFF);
|
||||
gSceneryPlaceObject.SceneryType = SCENERY_TYPE_SMALL;
|
||||
gSceneryPlaceObject.EntryIndex = entryIndex;
|
||||
|
||||
tileElement = dynamic_cast<SmallSceneryPlaceActionResult*>(res.get())->tileElement;
|
||||
tileElement = sspar->tileElement;
|
||||
gSceneryGhostPosition = { map_tile, tileElement->GetBaseZ() };
|
||||
gSceneryQuadrant = tileElement->AsSmallScenery()->GetSceneryQuadrant();
|
||||
if (dynamic_cast<SmallSceneryPlaceActionResult*>(res.get())->GroundFlags & ELEMENT_IS_UNDERGROUND)
|
||||
if (sspar->GroundFlags & ELEMENT_IS_UNDERGROUND)
|
||||
{
|
||||
// Set underground on
|
||||
viewport_set_visibility(4);
|
||||
|
@ -2646,15 +2647,16 @@ static money32 try_place_ghost_scenery(
|
|||
sceneryPlaceAction.SetFlags(
|
||||
GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND);
|
||||
auto res = GameActions::Execute(&sceneryPlaceAction);
|
||||
if (res->Error != GA_ERROR::OK)
|
||||
auto lspar = dynamic_cast<LargeSceneryPlaceActionResult*>(res.get());
|
||||
if (lspar == nullptr || res->Error != GA_ERROR::OK)
|
||||
return MONEY32_UNDEFINED;
|
||||
|
||||
gSceneryPlaceRotation = loc.direction;
|
||||
|
||||
tileElement = dynamic_cast<LargeSceneryPlaceActionResult*>(res.get())->tileElement;
|
||||
tileElement = lspar->tileElement;
|
||||
gSceneryGhostPosition = { map_tile, tileElement->GetBaseZ() };
|
||||
|
||||
if (dynamic_cast<LargeSceneryPlaceActionResult*>(res.get())->GroundFlags & ELEMENT_IS_UNDERGROUND)
|
||||
if (lspar->GroundFlags & ELEMENT_IS_UNDERGROUND)
|
||||
{
|
||||
// Set underground on
|
||||
viewport_set_visibility(4);
|
||||
|
|
|
@ -79,7 +79,7 @@ using namespace OpenRCT2::Ui;
|
|||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
class Context : public IContext
|
||||
class Context final : public IContext
|
||||
{
|
||||
private:
|
||||
// Dependencies
|
||||
|
|
|
@ -109,7 +109,7 @@ struct GameStateSnapshot_t
|
|||
}
|
||||
};
|
||||
|
||||
struct GameStateSnapshots : public IGameStateSnapshots
|
||||
struct GameStateSnapshots final : public IGameStateSnapshots
|
||||
{
|
||||
virtual void Reset() override final
|
||||
{
|
||||
|
|
|
@ -297,7 +297,7 @@ namespace GameActions
|
|||
return #cls; \
|
||||
} \
|
||||
}; \
|
||||
struct cls : public GameActionBase<id, res>
|
||||
struct cls final : public GameActionBase<id, res>
|
||||
// clang-format on
|
||||
|
||||
} // namespace GameActions
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
_origin.direction &= 3;
|
||||
}
|
||||
|
||||
uint16_t GetActionFlags() const override
|
||||
uint16_t GetActionFlags() const override final
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,12 @@ enum
|
|||
STREAM_SEEK_END
|
||||
};
|
||||
|
||||
#ifdef __WARN_SUGGEST_FINAL_METHODS__
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wsuggest-final-methods"
|
||||
# pragma GCC diagnostic ignored "-Wsuggest-final-types"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Represents a stream that can be read or written to. Implemented by types such as FileStream, NetworkStream or MemoryStream.
|
||||
*/
|
||||
|
@ -199,6 +205,10 @@ interface IStream
|
|||
void WriteString(const std::string& string);
|
||||
};
|
||||
|
||||
#ifdef __WARN_SUGGEST_FINAL_METHODS__
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
class IOException : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -85,7 +85,16 @@ namespace OpenRCT2
|
|||
|
||||
public:
|
||||
explicit X8DrawingEngine(const std::shared_ptr<Ui::IUiContext>& uiContext);
|
||||
|
||||
#ifdef __WARN_SUGGEST_FINAL_METHODS__
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wsuggest-final-methods"
|
||||
# pragma GCC diagnostic ignored "-Wsuggest-final-types"
|
||||
#endif
|
||||
~X8DrawingEngine() override;
|
||||
#ifdef __WARN_SUGGEST_FINAL_METHODS__
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
void Initialise() override;
|
||||
void Resize(uint32_t width, uint32_t height) override;
|
||||
|
|
|
@ -51,8 +51,6 @@ uint8_t gResearchExpectedMonth;
|
|||
uint8_t gResearchExpectedDay;
|
||||
std::optional<ResearchItem> gResearchNextItem;
|
||||
|
||||
// 0x01358844[500]
|
||||
ResearchItem gResearchItems[MAX_RESEARCH_ITEMS];
|
||||
std::vector<ResearchItem> gResearchItemsUninvented;
|
||||
std::vector<ResearchItem> gResearchItemsInvented;
|
||||
|
||||
|
|
|
@ -3561,7 +3561,6 @@ GameActionResult::Ptr network_modify_groups(
|
|||
default:
|
||||
log_error("Invalid Modify Group Type: %u", static_cast<uint8_t>(type));
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
|
||||
break;
|
||||
}
|
||||
|
||||
gNetwork.SaveGroups();
|
||||
|
|
|
@ -791,5 +791,3 @@ struct RCT12ResearchItem
|
|||
assert_struct_size(RCT12ResearchItem, 5);
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
bool is_user_string_id(rct_string_id stringId);
|
||||
|
|
|
@ -76,9 +76,9 @@ struct map_backup
|
|||
|
||||
TrackDesign* gActiveTrackDesign;
|
||||
bool gTrackDesignSceneryToggle;
|
||||
CoordsXYZ gTrackPreviewMin;
|
||||
CoordsXYZ gTrackPreviewMax;
|
||||
CoordsXYZ gTrackPreviewOrigin;
|
||||
static CoordsXYZ _trackPreviewMin;
|
||||
static CoordsXYZ _trackPreviewMax;
|
||||
static CoordsXYZ _trackPreviewOrigin;
|
||||
|
||||
bool byte_9D8150;
|
||||
static uint8_t _trackDesignPlaceOperation;
|
||||
|
@ -199,7 +199,7 @@ rct_string_id TrackDesign::CreateTrackDesignTrack(const Ride& ride)
|
|||
TileElement* initialMap = trackElement.element;
|
||||
|
||||
CoordsXYZ startPos = { trackElement.x, trackElement.y, z + trackCoordinates->z_begin };
|
||||
gTrackPreviewOrigin = startPos;
|
||||
_trackPreviewOrigin = startPos;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -298,14 +298,14 @@ rct_string_id TrackDesign::CreateTrackDesignTrack(const Ride& ride)
|
|||
TrackDesignEntranceElement entrance{};
|
||||
entrance.direction = entranceDirection;
|
||||
|
||||
mapLocation -= gTrackPreviewOrigin;
|
||||
mapLocation -= _trackPreviewOrigin;
|
||||
|
||||
// Rotate entrance coordinates backwards to the correct direction
|
||||
auto rotatedMapLocation = mapLocation.Rotate(0 - _saveDirection);
|
||||
entrance.x = rotatedMapLocation.x;
|
||||
entrance.y = rotatedMapLocation.y;
|
||||
|
||||
z -= gTrackPreviewOrigin.z;
|
||||
z -= _trackPreviewOrigin.z;
|
||||
z /= 8;
|
||||
|
||||
if (z > 127 || z < -126)
|
||||
|
@ -327,14 +327,14 @@ rct_string_id TrackDesign::CreateTrackDesignTrack(const Ride& ride)
|
|||
place_virtual_track(this, PTD_OPERATION_DRAW_OUTLINES, true, GetOrAllocateRide(0), 4096, 4096, 0);
|
||||
|
||||
// Resave global vars for scenery reasons.
|
||||
gTrackPreviewOrigin = startPos;
|
||||
_trackPreviewOrigin = startPos;
|
||||
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_GREEN;
|
||||
|
||||
space_required_x = ((gTrackPreviewMax.x - gTrackPreviewMin.x) / 32) + 1;
|
||||
space_required_y = ((gTrackPreviewMax.y - gTrackPreviewMin.y) / 32) + 1;
|
||||
space_required_x = ((_trackPreviewMax.x - _trackPreviewMin.x) / 32) + 1;
|
||||
space_required_y = ((_trackPreviewMax.y - _trackPreviewMin.y) / 32) + 1;
|
||||
return STR_NONE;
|
||||
}
|
||||
|
||||
|
@ -347,7 +347,7 @@ rct_string_id TrackDesign::CreateTrackDesignMaze(const Ride& ride)
|
|||
return STR_TRACK_TOO_LARGE_OR_TOO_MUCH_SCENERY;
|
||||
}
|
||||
|
||||
gTrackPreviewOrigin = { startLoc.x, startLoc.y, startLoc.element->GetBaseZ() };
|
||||
_trackPreviewOrigin = { startLoc.x, startLoc.y, startLoc.element->GetBaseZ() };
|
||||
|
||||
// x is defined here as we can start the search
|
||||
// on tile start_x, start_y but then the next row
|
||||
|
@ -442,16 +442,16 @@ rct_string_id TrackDesign::CreateTrackDesignMaze(const Ride& ride)
|
|||
maze_elements.push_back(mazeExit);
|
||||
|
||||
// Save global vars as they are still used by scenery????
|
||||
int32_t startZ = gTrackPreviewOrigin.z;
|
||||
int32_t startZ = _trackPreviewOrigin.z;
|
||||
place_virtual_track(this, PTD_OPERATION_DRAW_OUTLINES, true, GetOrAllocateRide(0), 4096, 4096, 0);
|
||||
gTrackPreviewOrigin = { startLoc.x, startLoc.y, startZ };
|
||||
_trackPreviewOrigin = { startLoc.x, startLoc.y, startZ };
|
||||
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_GREEN;
|
||||
|
||||
space_required_x = ((gTrackPreviewMax.x - gTrackPreviewMin.x) / 32) + 1;
|
||||
space_required_y = ((gTrackPreviewMax.y - gTrackPreviewMin.y) / 32) + 1;
|
||||
space_required_x = ((_trackPreviewMax.x - _trackPreviewMin.x) / 32) + 1;
|
||||
space_required_y = ((_trackPreviewMax.y - _trackPreviewMin.y) / 32) + 1;
|
||||
return STR_NONE;
|
||||
}
|
||||
|
||||
|
@ -531,7 +531,7 @@ rct_string_id TrackDesign::CreateTrackDesignScenery()
|
|||
|
||||
// Cast the value into a uint8_t as this value is not signed yet.
|
||||
auto sceneryPos = TileCoordsXY(static_cast<uint8_t>(scenery.x), static_cast<uint8_t>(scenery.y)).ToCoordsXY();
|
||||
CoordsXY sceneryMapPos = sceneryPos - gTrackPreviewOrigin;
|
||||
CoordsXY sceneryMapPos = sceneryPos - _trackPreviewOrigin;
|
||||
CoordsXY rotatedSceneryMapPos = sceneryMapPos.Rotate(0 - _saveDirection);
|
||||
TileCoordsXY sceneryTilePos{ rotatedSceneryMapPos };
|
||||
|
||||
|
@ -543,7 +543,7 @@ rct_string_id TrackDesign::CreateTrackDesignScenery()
|
|||
scenery.x = static_cast<int8_t>(sceneryTilePos.x);
|
||||
scenery.y = static_cast<int8_t>(sceneryTilePos.y);
|
||||
|
||||
int32_t z = scenery.z * COORDS_Z_STEP - gTrackPreviewOrigin.z;
|
||||
int32_t z = scenery.z * COORDS_Z_STEP - _trackPreviewOrigin.z;
|
||||
z /= COORDS_Z_STEP;
|
||||
if (z > 127 || z < -126)
|
||||
{
|
||||
|
@ -848,12 +848,12 @@ static void track_design_add_selection_tile(int16_t x, int16_t y)
|
|||
|
||||
static void track_design_update_max_min_coordinates(int16_t x, int16_t y, int16_t z)
|
||||
{
|
||||
gTrackPreviewMin.x = std::min(gTrackPreviewMin.x, static_cast<int32_t>(x));
|
||||
gTrackPreviewMax.x = std::max(gTrackPreviewMax.x, static_cast<int32_t>(x));
|
||||
gTrackPreviewMin.y = std::min(gTrackPreviewMin.y, static_cast<int32_t>(y));
|
||||
gTrackPreviewMax.y = std::max(gTrackPreviewMax.y, static_cast<int32_t>(y));
|
||||
gTrackPreviewMin.z = std::min(gTrackPreviewMin.z, static_cast<int32_t>(z));
|
||||
gTrackPreviewMax.z = std::max(gTrackPreviewMax.z, static_cast<int32_t>(z));
|
||||
_trackPreviewMin.x = std::min(_trackPreviewMin.x, static_cast<int32_t>(x));
|
||||
_trackPreviewMax.x = std::max(_trackPreviewMax.x, static_cast<int32_t>(x));
|
||||
_trackPreviewMin.y = std::min(_trackPreviewMin.y, static_cast<int32_t>(y));
|
||||
_trackPreviewMax.y = std::max(_trackPreviewMax.y, static_cast<int32_t>(y));
|
||||
_trackPreviewMin.z = std::min(_trackPreviewMin.z, static_cast<int32_t>(z));
|
||||
_trackPreviewMax.z = std::max(_trackPreviewMax.z, static_cast<int32_t>(z));
|
||||
}
|
||||
|
||||
static bool TrackDesignPlaceSceneryElementGetEntry(
|
||||
|
@ -1491,9 +1491,9 @@ static int32_t track_design_place_maze(TrackDesign* td6, int16_t x, int16_t y, i
|
|||
| GAME_COMMAND_FLAG_GHOST);
|
||||
}
|
||||
|
||||
gTrackPreviewOrigin.x = x;
|
||||
gTrackPreviewOrigin.y = y;
|
||||
gTrackPreviewOrigin.z = z;
|
||||
_trackPreviewOrigin.x = x;
|
||||
_trackPreviewOrigin.y = y;
|
||||
_trackPreviewOrigin.z = z;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1502,9 +1502,9 @@ static bool track_design_place_ride(TrackDesign* td6, int16_t x, int16_t y, int1
|
|||
const rct_preview_track** trackBlockArray = (ride_type_has_flag(td6->type, RIDE_TYPE_FLAG_HAS_TRACK)) ? TrackBlocks
|
||||
: FlatRideTrackBlocks;
|
||||
|
||||
gTrackPreviewOrigin.x = x;
|
||||
gTrackPreviewOrigin.y = y;
|
||||
gTrackPreviewOrigin.z = z;
|
||||
_trackPreviewOrigin.x = x;
|
||||
_trackPreviewOrigin.y = y;
|
||||
_trackPreviewOrigin.z = z;
|
||||
if (_trackDesignPlaceOperation == PTD_OPERATION_DRAW_OUTLINES)
|
||||
{
|
||||
gMapSelectionTiles.clear();
|
||||
|
@ -1676,8 +1676,8 @@ static bool track_design_place_ride(TrackDesign* td6, int16_t x, int16_t y, int1
|
|||
rotation = _currentTrackPieceDirection & 3;
|
||||
CoordsXY entranceMapPos{ entrance.x, entrance.y };
|
||||
auto rotatedEntranceMapPos = entranceMapPos.Rotate(rotation);
|
||||
x = rotatedEntranceMapPos.x + gTrackPreviewOrigin.x;
|
||||
y = rotatedEntranceMapPos.y + gTrackPreviewOrigin.y;
|
||||
x = rotatedEntranceMapPos.x + _trackPreviewOrigin.x;
|
||||
y = rotatedEntranceMapPos.y + _trackPreviewOrigin.y;
|
||||
|
||||
track_design_update_max_min_coordinates(x, y, z);
|
||||
|
||||
|
@ -1696,7 +1696,7 @@ static bool track_design_place_ride(TrackDesign* td6, int16_t x, int16_t y, int1
|
|||
{
|
||||
auto tile = CoordsXY{ x, y } + CoordsDirectionDelta[rotation];
|
||||
TileElement* tile_element = map_get_first_element_at(tile);
|
||||
z = gTrackPreviewOrigin.z / COORDS_Z_STEP;
|
||||
z = _trackPreviewOrigin.z / COORDS_Z_STEP;
|
||||
z += entrance.z;
|
||||
if (tile_element == nullptr)
|
||||
{
|
||||
|
@ -1756,7 +1756,7 @@ static bool track_design_place_ride(TrackDesign* td6, int16_t x, int16_t y, int1
|
|||
else
|
||||
{
|
||||
z = entrance.z * COORDS_Z_STEP;
|
||||
z += gTrackPreviewOrigin.z;
|
||||
z += _trackPreviewOrigin.z;
|
||||
|
||||
auto res = RideEntranceExitPlaceAction::TrackPlaceQuery({ x, y, z }, false);
|
||||
if (res->Error != GA_ERROR::OK)
|
||||
|
@ -1814,12 +1814,12 @@ int32_t place_virtual_track(
|
|||
}
|
||||
_currentRideIndex = ride->id;
|
||||
|
||||
gTrackPreviewMin.x = x;
|
||||
gTrackPreviewMin.y = y;
|
||||
gTrackPreviewMin.z = z;
|
||||
gTrackPreviewMax.x = x;
|
||||
gTrackPreviewMax.y = y;
|
||||
gTrackPreviewMax.z = z;
|
||||
_trackPreviewMin.x = x;
|
||||
_trackPreviewMin.y = y;
|
||||
_trackPreviewMin.z = z;
|
||||
_trackPreviewMax.x = x;
|
||||
_trackPreviewMax.y = y;
|
||||
_trackPreviewMax.z = z;
|
||||
|
||||
_trackDesignPlaceSceneryZ = 0;
|
||||
uint8_t track_place_success = 0;
|
||||
|
@ -1836,7 +1836,7 @@ int32_t place_virtual_track(
|
|||
if (track_place_success)
|
||||
{
|
||||
if (!track_design_place_all_scenery(
|
||||
td6->scenery_elements, gTrackPreviewOrigin.x, gTrackPreviewOrigin.y, gTrackPreviewOrigin.z))
|
||||
td6->scenery_elements, _trackPreviewOrigin.x, _trackPreviewOrigin.y, _trackPreviewOrigin.z))
|
||||
{
|
||||
return _trackDesignPlaceCost;
|
||||
}
|
||||
|
@ -2016,12 +2016,12 @@ void track_design_draw_preview(TrackDesign* td6, uint8_t* pixels)
|
|||
td6->cost = cost;
|
||||
td6->track_flags = flags & 7;
|
||||
|
||||
CoordsXYZ centre = { (gTrackPreviewMin.x + gTrackPreviewMax.x) / 2 + 16, (gTrackPreviewMin.y + gTrackPreviewMax.y) / 2 + 16,
|
||||
(gTrackPreviewMin.z + gTrackPreviewMax.z) / 2 };
|
||||
CoordsXYZ centre = { (_trackPreviewMin.x + _trackPreviewMax.x) / 2 + 16, (_trackPreviewMin.y + _trackPreviewMax.y) / 2 + 16,
|
||||
(_trackPreviewMin.z + _trackPreviewMax.z) / 2 };
|
||||
|
||||
int32_t size_x = gTrackPreviewMax.x - gTrackPreviewMin.x;
|
||||
int32_t size_y = gTrackPreviewMax.y - gTrackPreviewMin.y;
|
||||
int32_t size_z = gTrackPreviewMax.z - gTrackPreviewMin.z;
|
||||
int32_t size_x = _trackPreviewMax.x - _trackPreviewMin.x;
|
||||
int32_t size_y = _trackPreviewMax.y - _trackPreviewMin.y;
|
||||
int32_t size_z = _trackPreviewMax.z - _trackPreviewMin.z;
|
||||
|
||||
// Special case for flat rides - Z-axis info is irrelevant
|
||||
// and must be zeroed out lest the preview be off-centre
|
||||
|
|
|
@ -227,6 +227,12 @@ static void track_design_save_add_large_scenery(const CoordsXY& loc, LargeScener
|
|||
rct_large_scenery_tile *sceneryTiles, *tile;
|
||||
int32_t direction, sequence;
|
||||
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
log_warning("Null tile element");
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t entryType = tileElement->GetEntryIndex();
|
||||
auto entry = object_entry_get_entry(OBJECT_TYPE_LARGE_SCENERY, entryType);
|
||||
sceneryTiles = get_large_scenery_entry(entryType)->large_scenery.tiles;
|
||||
|
@ -404,6 +410,12 @@ static void track_design_save_remove_large_scenery(const CoordsXY& loc, LargeSce
|
|||
rct_large_scenery_tile *sceneryTiles, *tile;
|
||||
int32_t direction, sequence;
|
||||
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
log_warning("Null tile element");
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t entryType = tileElement->GetEntryIndex();
|
||||
auto entry = object_entry_get_entry(OBJECT_TYPE_LARGE_SCENERY, entryType);
|
||||
sceneryTiles = get_large_scenery_entry(entryType)->large_scenery.tiles;
|
||||
|
|
|
@ -87,7 +87,8 @@ money32 place_provisional_track_piece(
|
|||
trackPlaceAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST);
|
||||
// This command must not be sent over the network
|
||||
auto res = GameActions::Execute(&trackPlaceAction);
|
||||
result = res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED;
|
||||
auto tpar = dynamic_cast<TrackPlaceActionResult*>(res.get());
|
||||
result = ((tpar == nullptr) || (res->Error == GA_ERROR::OK)) ? res->Cost : MONEY32_UNDEFINED;
|
||||
if (result == MONEY32_UNDEFINED)
|
||||
return result;
|
||||
|
||||
|
@ -110,8 +111,7 @@ money32 place_provisional_track_piece(
|
|||
_unkF440C5.z = z;
|
||||
_unkF440C5.direction = trackDirection;
|
||||
_currentTrackSelectionFlags |= TRACK_SELECTION_FLAG_TRACK;
|
||||
viewport_set_visibility(
|
||||
(dynamic_cast<TrackPlaceActionResult*>(res.get())->GroundFlags & TRACK_ELEMENT_LOCATION_IS_UNDERGROUND) ? 1 : 3);
|
||||
viewport_set_visibility((tpar->GroundFlags & TRACK_ELEMENT_LOCATION_IS_UNDERGROUND) ? 1 : 3);
|
||||
if (_currentTrackSlopeEnd != 0)
|
||||
viewport_set_visibility(2);
|
||||
|
||||
|
|
|
@ -1480,7 +1480,12 @@ bool map_can_construct_with_clear_at(
|
|||
{
|
||||
*price += res->Cost;
|
||||
}
|
||||
gMapGroundFlags = dynamic_cast<ConstructClearResult*>(res.get())->GroundFlags;
|
||||
auto ccr = dynamic_cast<ConstructClearResult*>(res.get());
|
||||
if (ccr == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
gMapGroundFlags = ccr->GroundFlags;
|
||||
return res->Error == GA_ERROR::OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -177,7 +177,6 @@ const QuarterTile QuarterTile::Rotate(uint8_t amount) const
|
|||
{
|
||||
case 0:
|
||||
return QuarterTile{ *this };
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
auto rotVal1 = _val << 1;
|
||||
|
|
Loading…
Reference in New Issue