forked from rosebudai/OpenRCT2-Web
Merge pull request #24481 from ZehMatt/code-fixes
Some code maintenance
This commit is contained in:
21 files changed
+35
-25
No files matched your search
@@ -296,7 +296,7 @@ namespace OpenRCT2
|
||||
{
|
||||
case InputState::Reset:
|
||||
WindowTooltipReset(screenCoords);
|
||||
// fall-through
|
||||
[[fallthrough]];
|
||||
case InputState::Normal:
|
||||
switch (state)
|
||||
{
|
||||
|
||||
@@ -322,7 +322,7 @@ namespace OpenRCT2::Scripting
|
||||
auto importMode = getImportModeFromPalette(pixelData.Palette);
|
||||
auto pngData = DukGetDataFromBufferLikeObject(pixelData.Data);
|
||||
auto image = Imaging::ReadFromBuffer(pngData, imageFormat);
|
||||
uint8_t flags = EnumToFlag(ImportFlags::RLE);
|
||||
constexpr uint8_t flags = EnumToFlag(ImportFlags::RLE);
|
||||
ImageImportMeta meta = { { 0, 0 }, palette, flags, importMode };
|
||||
|
||||
ImageImporter importer;
|
||||
|
||||
@@ -328,7 +328,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
void DrawLeftButtonBack(RenderTarget& rt)
|
||||
{
|
||||
auto previousWidget = widgets[WIDX_PREVIOUS_IMAGE];
|
||||
const auto& previousWidget = widgets[WIDX_PREVIOUS_IMAGE];
|
||||
auto leftTop = windowPos + ScreenCoordsXY{ previousWidget.left, previousWidget.top };
|
||||
auto rightBottom = windowPos + ScreenCoordsXY{ previousWidget.right, previousWidget.bottom };
|
||||
GfxFilterRect(rt, { leftTop, rightBottom }, FilterPaletteID::Palette51);
|
||||
|
||||
@@ -1139,7 +1139,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (!tabWidgetsInitialised)
|
||||
{
|
||||
tabWidgetsInitialised = true;
|
||||
auto tabWidget = widgets[WIDX_TAB_1];
|
||||
const auto& tabWidget = widgets[WIDX_TAB_1];
|
||||
for (size_t i = 1; i < std::size(ObjectSelectionPages); i++)
|
||||
{
|
||||
widgets.insert(widgets.end() - 1, tabWidget);
|
||||
|
||||
@@ -612,9 +612,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
void OnDraw(RenderTarget& rt) override
|
||||
{
|
||||
auto leftWidget = widgets[WIDX_LEFT_OUTSET];
|
||||
auto rightWidget = widgets[WIDX_RIGHT_OUTSET];
|
||||
auto middleWidget = widgets[WIDX_MIDDLE_OUTSET];
|
||||
const auto& leftWidget = widgets[WIDX_LEFT_OUTSET];
|
||||
const auto& rightWidget = widgets[WIDX_RIGHT_OUTSET];
|
||||
const auto& middleWidget = widgets[WIDX_MIDDLE_OUTSET];
|
||||
|
||||
// Draw panel grey backgrounds
|
||||
auto leftTop = windowPos + ScreenCoordsXY{ leftWidget.left, leftWidget.top };
|
||||
|
||||
@@ -619,9 +619,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
if (viewport != nullptr)
|
||||
{
|
||||
auto widget = widgets[WIDX_VIEWPORT];
|
||||
auto reqViewportWidth = widget.width() - 1;
|
||||
auto reqViewportHeight = widget.height() - 1;
|
||||
const auto& widget = widgets[WIDX_VIEWPORT];
|
||||
const auto reqViewportWidth = widget.width() - 1;
|
||||
const auto reqViewportHeight = widget.height() - 1;
|
||||
viewport->pos = windowPos + ScreenCoordsXY{ widget.left + 1, widget.top + 1 };
|
||||
if (viewport->width != reqViewportWidth || viewport->height != reqViewportHeight)
|
||||
{
|
||||
|
||||
@@ -1192,7 +1192,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
constexpr auto numItems = EnumValue(CurrencyType::Count) + 1;
|
||||
|
||||
// All the currencies except custom currency
|
||||
size_t numOrdinaryCurrencies = EnumValue(CurrencyType::Count) - 1;
|
||||
constexpr size_t numOrdinaryCurrencies = EnumValue(CurrencyType::Count) - 1;
|
||||
|
||||
for (size_t i = 0; i < numOrdinaryCurrencies; i++)
|
||||
{
|
||||
|
||||
@@ -71,12 +71,12 @@ namespace OpenRCT2::Ui::Windows
|
||||
private:
|
||||
CloseCallback _onClose = nullptr;
|
||||
|
||||
StringId _progressFormat;
|
||||
StringId _progressFormat{ kStringIdEmpty };
|
||||
std::string _progressTitle;
|
||||
std::string _currentCaption;
|
||||
|
||||
uint32_t _currentProgress;
|
||||
uint32_t _totalCount;
|
||||
uint32_t _currentProgress{};
|
||||
uint32_t _totalCount{};
|
||||
int8_t style = -1;
|
||||
|
||||
public:
|
||||
|
||||
@@ -4850,7 +4850,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
else
|
||||
{
|
||||
auto typeDescriptor = ride->getRideTypeDescriptor();
|
||||
const auto& typeDescriptor = ride->getRideTypeDescriptor();
|
||||
int32_t spriteIndex = typeDescriptor.ColourPreview.Track;
|
||||
if (spriteIndex != 0)
|
||||
{
|
||||
@@ -5552,7 +5552,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
_lastSceneryX = screenCoords.x;
|
||||
_lastSceneryY = screenCoords.y;
|
||||
|
||||
auto interactionFlags = EnumsToFlags(
|
||||
constexpr auto interactionFlags = EnumsToFlags(
|
||||
ViewportInteractionItem::Scenery, ViewportInteractionItem::Footpath, ViewportInteractionItem::Wall,
|
||||
ViewportInteractionItem::LargeScenery);
|
||||
auto info = GetMapCoordinatesFromPos(screenCoords, interactionFlags);
|
||||
|
||||
@@ -1503,6 +1503,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
case TrackElemType::BlockBrakes:
|
||||
case TrackElemType::DiagBlockBrakes:
|
||||
_currentBrakeSpeed = kRCT2DefaultBlockBrakeSpeed;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -2994,7 +2995,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
if (im.IsModifierKeyPressed(ModifierKey::ctrl))
|
||||
{
|
||||
auto interactionFlags = EnumsToFlags(
|
||||
constexpr auto interactionFlags = EnumsToFlags(
|
||||
ViewportInteractionItem::Terrain, ViewportInteractionItem::Ride, ViewportInteractionItem::Footpath,
|
||||
ViewportInteractionItem::PathAddition, ViewportInteractionItem::LargeScenery,
|
||||
ViewportInteractionItem::Label, ViewportInteractionItem::Banner);
|
||||
|
||||
@@ -2237,7 +2237,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
*/
|
||||
void RepaintSceneryToolDown(const ScreenCoordsXY& screenCoords, WidgetIndex widgetIndex)
|
||||
{
|
||||
auto flag = EnumsToFlags(
|
||||
constexpr auto flag = EnumsToFlags(
|
||||
ViewportInteractionItem::Scenery, ViewportInteractionItem::Wall, ViewportInteractionItem::LargeScenery,
|
||||
ViewportInteractionItem::Banner);
|
||||
auto info = GetMapCoordinatesFromPos(screenCoords, flag);
|
||||
@@ -2314,7 +2314,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
void SceneryEyedropperToolDown(const ScreenCoordsXY& screenCoords, WidgetIndex widgetIndex)
|
||||
{
|
||||
auto flag = EnumsToFlags(
|
||||
constexpr auto flag = EnumsToFlags(
|
||||
ViewportInteractionItem::Scenery, ViewportInteractionItem::Wall, ViewportInteractionItem::LargeScenery,
|
||||
ViewportInteractionItem::Banner, ViewportInteractionItem::PathAddition);
|
||||
auto info = GetMapCoordinatesFromPos(screenCoords, flag);
|
||||
|
||||
@@ -733,6 +733,7 @@ static uint64_t PageDisabledWidgets[] = {
|
||||
windowTileInspectorSelectedIndex, !tileElement->AsWall()->AnimationIsBackwards());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -225,6 +225,7 @@ void CheatsSerialise(DataSerialiser& ds)
|
||||
break;
|
||||
case CheatType::SetForcedParkRating:
|
||||
ds << gameState.cheats.forcedParkRating;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -497,7 +497,7 @@ int32_t CommandLineForSprite(const char** argv, int32_t argc)
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t importFlags = EnumToFlag(ImportFlags::RLE);
|
||||
constexpr uint8_t importFlags = EnumToFlag(ImportFlags::RLE);
|
||||
ImageImportMeta meta = { { xOffset, yOffset }, Palette::OpenRCT2, importFlags, gSpriteMode };
|
||||
auto importResult = SpriteImageImport(imagePath, meta);
|
||||
if (!importResult.has_value())
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace OpenRCT2
|
||||
CompressionType Compression{};
|
||||
uint64_t CompressedSize{};
|
||||
std::array<uint8_t, 8> FNV1a{};
|
||||
uint8_t padding[20];
|
||||
uint8_t padding[20]{};
|
||||
};
|
||||
static_assert(sizeof(Header) == 64, "Header should be 64 bytes");
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ bool MarketingIsCampaignTypeApplicable(int32_t campaignType)
|
||||
if (!Park::RidePricesUnlocked())
|
||||
return false;
|
||||
|
||||
// fall-through
|
||||
[[fallthrough]];
|
||||
case ADVERTISING_CAMPAIGN_RIDE:
|
||||
// Check if any rides exist
|
||||
for (auto& ride : GetRideManager())
|
||||
|
||||
@@ -88,6 +88,8 @@ void DiscordService::RefreshPresence() const
|
||||
|
||||
std::string state;
|
||||
std::string details;
|
||||
std::string partyId;
|
||||
|
||||
switch (gLegacyScene)
|
||||
{
|
||||
default:
|
||||
@@ -116,8 +118,9 @@ void DiscordService::RefreshPresence() const
|
||||
}
|
||||
state = serverName;
|
||||
|
||||
partyId = NetworkGetServerName();
|
||||
// NOTE: the party size is displayed next to state
|
||||
discordPresence.partyId = NetworkGetServerName().c_str();
|
||||
discordPresence.partyId = partyId.c_str();
|
||||
discordPresence.partySize = NetworkGetNumPlayers();
|
||||
discordPresence.partyMax = 256;
|
||||
|
||||
|
||||
@@ -961,6 +961,7 @@ void Vehicle::UpdateMeasurements()
|
||||
{
|
||||
curRide->specialTrackElements.set(SpecialElement::splash);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1345,6 +1346,7 @@ void Vehicle::Update()
|
||||
break;
|
||||
case Vehicle::Status::DoingCircusShow:
|
||||
UpdateDoingCircusShow();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -181,6 +181,7 @@ namespace OpenRCT2
|
||||
{
|
||||
auto& context = GetContext();
|
||||
context.SetActiveScene(context.GetTitleScene());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -24,8 +24,8 @@ constexpr T AddClamp(T value, T valueToAdd)
|
||||
{
|
||||
static_assert(sizeof(money64) == sizeof(int64_t));
|
||||
}
|
||||
auto maxCap = std::numeric_limits<T>::max();
|
||||
auto minCap = std::numeric_limits<T>::lowest();
|
||||
constexpr auto maxCap = std::numeric_limits<T>::max();
|
||||
constexpr auto minCap = std::numeric_limits<T>::lowest();
|
||||
if ((valueToAdd > 0) && (value > (maxCap - (valueToAdd))))
|
||||
{
|
||||
return maxCap;
|
||||
|
||||
@@ -2322,6 +2322,7 @@ void ShiftMap(const TileCoordsXY& amount)
|
||||
fountain->TargetX += amountToMove.x;
|
||||
fountain->TargetY += amountToMove.y;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user