mirror of https://github.com/OpenRCT2/OpenRCT2.git
Make use of std::optional strict
This commit is contained in:
parent
6ffb03dde0
commit
59a6c34db4
|
@ -221,10 +221,10 @@ void TextureCache::GeneratePaletteTexture()
|
|||
GLint y = PaletteToY(static_cast<FilterPaletteID>(i));
|
||||
|
||||
auto g1Index = GetPaletteG1Index(i);
|
||||
if (g1Index)
|
||||
if (g1Index.has_value())
|
||||
{
|
||||
auto element = gfx_get_g1_element(*g1Index);
|
||||
gfx_draw_sprite_software(&dpi, ImageId(*g1Index), { -element->x_offset, y - element->y_offset });
|
||||
auto element = gfx_get_g1_element(g1Index.value());
|
||||
gfx_draw_sprite_software(&dpi, ImageId(g1Index.value()), { -element->x_offset, y - element->y_offset });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -152,11 +152,11 @@ ShortcutInput::ShortcutInput(std::string_view value)
|
|||
else
|
||||
{
|
||||
auto number = String::Parse<int32_t>(rem);
|
||||
if (number)
|
||||
if (number.has_value())
|
||||
{
|
||||
Kind = InputDeviceKind::JoyButton;
|
||||
Modifiers = modifiers;
|
||||
Button = *number - 1;
|
||||
Button = number.value() - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,10 +167,10 @@ void ShortcutManager::ProcessEvent(const InputEvent& e)
|
|||
if (shortcut != nullptr && shortcut->IsSuitableInputEvent(e))
|
||||
{
|
||||
auto shortcutInput = ShortcutInput::FromInputEvent(e);
|
||||
if (shortcutInput)
|
||||
if (shortcutInput.has_value())
|
||||
{
|
||||
shortcut->Current.clear();
|
||||
shortcut->Current.push_back(std::move(*shortcutInput));
|
||||
shortcut->Current.push_back(std::move(shortcutInput.value()));
|
||||
}
|
||||
_pendingShortcutChange.clear();
|
||||
window_close_by_class(WC_CHANGE_KEYBOARD_SHORTCUT);
|
||||
|
@ -273,9 +273,9 @@ void ShortcutManager::LoadLegacyBindings(const fs::path& path)
|
|||
{
|
||||
shortcut->Current.clear();
|
||||
auto input = ConvertLegacyBinding(value);
|
||||
if (input)
|
||||
if (input.has_value())
|
||||
{
|
||||
shortcut->Current.push_back(std::move(*input));
|
||||
shortcut->Current.push_back(std::move(input.value()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,12 +174,12 @@ static void window_game_bottom_toolbar_mouseup(rct_window* w, rct_widgetindex wi
|
|||
|
||||
auto subjectLoc = News::GetSubjectLocation(newsItem->Type, newsItem->Assoc);
|
||||
|
||||
if (subjectLoc == std::nullopt)
|
||||
if (!subjectLoc.has_value())
|
||||
break;
|
||||
|
||||
rct_window* mainWindow = window_get_main();
|
||||
if (mainWindow != nullptr)
|
||||
window_scroll_to_location(mainWindow, *subjectLoc);
|
||||
window_scroll_to_location(mainWindow, subjectLoc.value());
|
||||
}
|
||||
break;
|
||||
case WIDX_RIGHT_OUTSET:
|
||||
|
@ -315,7 +315,7 @@ static void window_game_bottom_toolbar_invalidate(rct_window* w)
|
|||
// Find out if the news item is no longer valid
|
||||
auto subjectLoc = News::GetSubjectLocation(newsItem->Type, newsItem->Assoc);
|
||||
|
||||
if (subjectLoc == std::nullopt)
|
||||
if (!subjectLoc.has_value())
|
||||
w->disabled_widgets |= (1ULL << WIDX_NEWS_LOCATE);
|
||||
|
||||
if (!(newsItem->TypeHasSubject()))
|
||||
|
|
|
@ -286,7 +286,7 @@ static void window_land_rights_tool_update_land_rights(const ScreenCoordsXY& scr
|
|||
|
||||
auto mapTile = screen_get_map_xy(screenCoords, nullptr);
|
||||
|
||||
if (!mapTile)
|
||||
if (!mapTile.has_value())
|
||||
{
|
||||
if (_landRightsCost != MONEY32_UNDEFINED)
|
||||
{
|
||||
|
|
|
@ -1187,7 +1187,7 @@ static void window_map_set_land_rights_tool_update(const ScreenCoordsXY& screenC
|
|||
map_invalidate_selection_rect();
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
|
||||
auto mapCoords = screen_get_map_xy(screenCoords, &viewport);
|
||||
if (!mapCoords)
|
||||
if (!mapCoords.has_value())
|
||||
return;
|
||||
|
||||
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
||||
|
|
|
@ -110,9 +110,9 @@ public:
|
|||
{
|
||||
static rct_window* _mainWindow;
|
||||
auto subjectLoc = News::GetSubjectLocation(newsItem.Type, newsItem.Assoc);
|
||||
if (subjectLoc != std::nullopt && (_mainWindow = window_get_main()) != nullptr)
|
||||
if (subjectLoc.has_value() && (_mainWindow = window_get_main()) != nullptr)
|
||||
{
|
||||
window_scroll_to_location(_mainWindow, *subjectLoc);
|
||||
window_scroll_to_location(_mainWindow, subjectLoc.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -610,7 +610,7 @@ static void window_player_update_viewport(rct_window* w, bool scroll)
|
|||
if (coord.x != 0 || coord.y != 0 || coord.z != 0)
|
||||
{
|
||||
auto centreLoc = centre_2d_coordinates(coord, viewport);
|
||||
if (!centreLoc)
|
||||
if (!centreLoc.has_value())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -620,13 +620,13 @@ static void window_player_update_viewport(rct_window* w, bool scroll)
|
|||
scroll = false;
|
||||
}
|
||||
|
||||
if (!scroll || w->savedViewPos != centreLoc)
|
||||
if (!scroll || w->savedViewPos != centreLoc.value())
|
||||
{
|
||||
w->flags |= WF_SCROLLING_TO_LOCATION;
|
||||
w->savedViewPos = *centreLoc;
|
||||
w->savedViewPos = centreLoc.value();
|
||||
if (!scroll)
|
||||
{
|
||||
w->viewport->viewPos = *centreLoc;
|
||||
w->viewport->viewPos = centreLoc.value();
|
||||
}
|
||||
widget_invalidate(w, WIDX_VIEWPORT);
|
||||
}
|
||||
|
|
|
@ -5009,9 +5009,9 @@ static std::optional<size_t> GetMusicStyleOrder(ObjectEntryIndex musicObjectInde
|
|||
|
||||
// Get the index in the order list
|
||||
auto originalStyleId = musicObj->GetOriginalStyleId();
|
||||
if (originalStyleId)
|
||||
if (originalStyleId.has_value())
|
||||
{
|
||||
auto it = std::find(std::begin(MusicStyleOrder), std::end(MusicStyleOrder), *originalStyleId);
|
||||
auto it = std::find(std::begin(MusicStyleOrder), std::end(MusicStyleOrder), originalStyleId.value());
|
||||
if (it != std::end(MusicStyleOrder))
|
||||
{
|
||||
return std::distance(std::begin(MusicStyleOrder), it);
|
||||
|
@ -5046,7 +5046,8 @@ static void window_ride_music_mousedown(rct_window* w, rct_widgetindex widgetInd
|
|||
{
|
||||
// Hide custom music if the WAV file does not exist
|
||||
auto originalStyleId = musicObj->GetOriginalStyleId();
|
||||
if (originalStyleId == MUSIC_STYLE_CUSTOM_MUSIC_1 || originalStyleId == MUSIC_STYLE_CUSTOM_MUSIC_2)
|
||||
if (originalStyleId.has_value()
|
||||
&& (originalStyleId == MUSIC_STYLE_CUSTOM_MUSIC_1 || originalStyleId == MUSIC_STYLE_CUSTOM_MUSIC_2))
|
||||
{
|
||||
auto numTracks = musicObj->GetTrackCount();
|
||||
if (numTracks != 0)
|
||||
|
|
|
@ -1889,7 +1889,7 @@ static void window_ride_construction_mouseup_demolish(rct_window* w)
|
|||
track_type_t type = _currentTrackPieceType;
|
||||
auto newCoords = GetTrackElementOriginAndApplyChanges(
|
||||
{ _currentTrackBegin, static_cast<Direction>(direction & 3) }, type, 0, &tileElement, 0);
|
||||
if (newCoords == std::nullopt)
|
||||
if (!newCoords.has_value())
|
||||
{
|
||||
window_ride_construction_update_active_elements();
|
||||
return;
|
||||
|
@ -1921,7 +1921,7 @@ static void window_ride_construction_mouseup_demolish(rct_window* w)
|
|||
newCoords = GetTrackElementOriginAndApplyChanges(
|
||||
{ _currentTrackBegin, static_cast<Direction>(direction & 3) }, type, 0, &tileElement, 0);
|
||||
|
||||
if (newCoords == std::nullopt)
|
||||
if (!newCoords.has_value())
|
||||
{
|
||||
window_ride_construction_update_active_elements();
|
||||
return;
|
||||
|
@ -2178,9 +2178,9 @@ static std::optional<CoordsXY> ride_get_place_position_from_screen_position(Scre
|
|||
{
|
||||
auto mapZ = _trackPlaceCtrlZ;
|
||||
auto mapXYCoords = screen_get_map_xy_with_z(screenCoords, mapZ);
|
||||
if (mapXYCoords)
|
||||
if (mapXYCoords.has_value())
|
||||
{
|
||||
mapCoords = *mapXYCoords;
|
||||
mapCoords = mapXYCoords.value();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2604,7 +2604,7 @@ void UpdateGhostTrackAndArrow()
|
|||
: TRACK_ELEMENT_SET_HIGHLIGHT_FALSE;
|
||||
auto newCoords = GetTrackElementOriginAndApplyChanges(
|
||||
{ _currentTrackBegin, static_cast<Direction>(direction) }, type, 0, nullptr, flags);
|
||||
if (newCoords == std::nullopt)
|
||||
if (!newCoords.has_value())
|
||||
{
|
||||
ride_construction_remove_ghosts();
|
||||
_rideConstructionState = RideConstructionState::State0;
|
||||
|
|
|
@ -1232,10 +1232,10 @@ static void window_tile_inspector_tool_update(rct_window* w, rct_widgetindex wid
|
|||
if (clickedElement == nullptr)
|
||||
{
|
||||
auto mouseCoords = screen_pos_to_map_pos(screenCoords, nullptr);
|
||||
if (mouseCoords)
|
||||
if (mouseCoords.has_value())
|
||||
{
|
||||
mouseOnViewport = true;
|
||||
mapCoords = *mouseCoords;
|
||||
mapCoords = mouseCoords.value();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1285,12 +1285,12 @@ static void window_tile_inspector_update_selected_tile(rct_window* w, const Scre
|
|||
{
|
||||
auto mouseCoords = screen_pos_to_map_pos(screenCoords, nullptr);
|
||||
|
||||
if (!mouseCoords)
|
||||
if (!mouseCoords.has_value())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mapCoords = *mouseCoords;
|
||||
mapCoords = mouseCoords.value();
|
||||
// Tile is already selected
|
||||
if (windowTileInspectorTileSelected && mapCoords.x == windowTileInspectorToolMap.x
|
||||
&& mapCoords.y == windowTileInspectorToolMap.y)
|
||||
|
|
|
@ -1267,12 +1267,12 @@ static void sub_6E1F34_small_scenery(
|
|||
if (!gSceneryCtrlPressed)
|
||||
{
|
||||
auto gridCoords = screen_get_map_xy_quadrant(screenPos, &quadrant);
|
||||
if (!gridCoords)
|
||||
if (!gridCoords.has_value())
|
||||
{
|
||||
gridPos.SetNull();
|
||||
return;
|
||||
}
|
||||
gridPos = *gridCoords;
|
||||
gridPos = gridCoords.value();
|
||||
|
||||
gSceneryPlaceZ = 0;
|
||||
|
||||
|
@ -1300,12 +1300,12 @@ static void sub_6E1F34_small_scenery(
|
|||
int16_t z = gSceneryCtrlPressZ;
|
||||
|
||||
auto mapCoords = screen_get_map_xy_quadrant_with_z(screenPos, z, &quadrant);
|
||||
if (!mapCoords)
|
||||
if (!mapCoords.has_value())
|
||||
{
|
||||
gridPos.SetNull();
|
||||
return;
|
||||
}
|
||||
gridPos = *mapCoords;
|
||||
gridPos = mapCoords.value();
|
||||
|
||||
// If SHIFT pressed
|
||||
if (gSceneryShiftPressed)
|
||||
|
@ -1382,7 +1382,7 @@ static void sub_6E1F34_small_scenery(
|
|||
{
|
||||
int16_t z = gSceneryCtrlPressZ;
|
||||
auto coords = screen_get_map_xy_with_z(screenPos, z);
|
||||
if (coords)
|
||||
if (coords.has_value())
|
||||
{
|
||||
gridPos = *coords;
|
||||
}
|
||||
|
@ -1485,12 +1485,12 @@ static void sub_6E1F34_wall(
|
|||
if (!gSceneryCtrlPressed)
|
||||
{
|
||||
auto gridCoords = screen_get_map_xy_side(screenPos, &edge);
|
||||
if (!gridCoords)
|
||||
if (!gridCoords.has_value())
|
||||
{
|
||||
gridPos.SetNull();
|
||||
return;
|
||||
}
|
||||
gridPos = *gridCoords;
|
||||
gridPos = gridCoords.value();
|
||||
|
||||
gSceneryPlaceZ = 0;
|
||||
|
||||
|
@ -1517,12 +1517,12 @@ static void sub_6E1F34_wall(
|
|||
{
|
||||
int16_t z = gSceneryCtrlPressZ;
|
||||
auto mapCoords = screen_get_map_xy_side_with_z(screenPos, z, &edge);
|
||||
if (!mapCoords)
|
||||
if (!mapCoords.has_value())
|
||||
{
|
||||
gridPos.SetNull();
|
||||
return;
|
||||
}
|
||||
gridPos = *mapCoords;
|
||||
gridPos = mapCoords.value();
|
||||
|
||||
// If SHIFT pressed
|
||||
if (gSceneryShiftPressed)
|
||||
|
@ -1608,7 +1608,7 @@ static void sub_6E1F34_large_scenery(
|
|||
{
|
||||
int16_t z = gSceneryCtrlPressZ;
|
||||
auto coords = screen_get_map_xy_with_z(screenPos, z);
|
||||
if (coords)
|
||||
if (coords.has_value())
|
||||
{
|
||||
gridPos = *coords;
|
||||
}
|
||||
|
@ -2005,7 +2005,7 @@ static uint8_t top_toolbar_tool_update_land_paint(const ScreenCoordsXY& screenPo
|
|||
|
||||
auto mapTile = screen_get_map_xy(screenPos, nullptr);
|
||||
|
||||
if (!mapTile)
|
||||
if (!mapTile.has_value())
|
||||
{
|
||||
if (gClearSceneryCost != MONEY64_UNDEFINED)
|
||||
{
|
||||
|
@ -2124,7 +2124,7 @@ static void top_toolbar_tool_update_land(const ScreenCoordsXY& screenPos)
|
|||
screen_pos_to_map_pos(screenPos, &selectionType);
|
||||
mapTile = screen_get_map_xy_side(screenPos, &side);
|
||||
|
||||
if (!mapTile)
|
||||
if (!mapTile.has_value())
|
||||
{
|
||||
money64 lower_cost = MONEY64_UNDEFINED;
|
||||
money64 raise_cost = MONEY64_UNDEFINED;
|
||||
|
@ -2201,7 +2201,7 @@ static void top_toolbar_tool_update_land(const ScreenCoordsXY& screenPos)
|
|||
// Get map coordinates and the side of the tile that is being hovered over
|
||||
mapTile = screen_get_map_xy_side(screenPos, &side);
|
||||
|
||||
if (!mapTile)
|
||||
if (!mapTile.has_value())
|
||||
{
|
||||
money64 lower_cost = MONEY64_UNDEFINED;
|
||||
money64 raise_cost = MONEY64_UNDEFINED;
|
||||
|
|
|
@ -303,12 +303,12 @@ static void window_view_clipping_tool_update(rct_window* w, rct_widgetindex widg
|
|||
|
||||
int32_t direction;
|
||||
auto mapCoords = screen_pos_to_map_pos(screenCoords, &direction);
|
||||
if (mapCoords)
|
||||
if (mapCoords.has_value())
|
||||
{
|
||||
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
||||
map_invalidate_tile_full(gMapSelectPositionA);
|
||||
gMapSelectPositionA = gMapSelectPositionB = *mapCoords;
|
||||
map_invalidate_tile_full(*mapCoords);
|
||||
gMapSelectPositionA = gMapSelectPositionB = mapCoords.value();
|
||||
map_invalidate_tile_full(mapCoords.value());
|
||||
gMapSelectType = MAP_SELECT_TYPE_FULL;
|
||||
}
|
||||
}
|
||||
|
@ -317,10 +317,10 @@ static void window_view_clipping_tool_down(rct_window* w, rct_widgetindex widget
|
|||
{
|
||||
int32_t direction;
|
||||
auto mapCoords = screen_pos_to_map_pos(screenCoords, &direction);
|
||||
if (mapCoords)
|
||||
if (mapCoords.has_value())
|
||||
{
|
||||
_dragging = true;
|
||||
_selectionStart = *mapCoords;
|
||||
_selectionStart = mapCoords.value();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -545,7 +545,7 @@ int32_t cmdline_for_sprite(const char** argv, int32_t argc)
|
|||
}
|
||||
|
||||
auto importResult = SpriteImageImport(imagePath, x_offset, y_offset, false, false, gSpriteMode);
|
||||
if (importResult == std::nullopt)
|
||||
if (!importResult.has_value())
|
||||
return -1;
|
||||
|
||||
auto spriteFile = SpriteFile::Open(spriteFilePath);
|
||||
|
|
|
@ -821,7 +821,7 @@ namespace String
|
|||
{
|
||||
return trunc.substr(0, i);
|
||||
}
|
||||
i += *length;
|
||||
i += length.value();
|
||||
}
|
||||
|
||||
return trunc;
|
||||
|
|
|
@ -131,12 +131,12 @@ public:
|
|||
{
|
||||
std::vector<uint8_t> result;
|
||||
auto index = GetIndexFromPath(path);
|
||||
if (index)
|
||||
if (index.has_value())
|
||||
{
|
||||
auto dataSize = GetFileSize(*index);
|
||||
auto dataSize = GetFileSize(index.value());
|
||||
if (dataSize > 0 && dataSize < SIZE_MAX)
|
||||
{
|
||||
auto zipFile = zip_fopen_index(_zip, *index, 0);
|
||||
auto zipFile = zip_fopen_index(_zip, index.value(), 0);
|
||||
if (zipFile != nullptr)
|
||||
{
|
||||
result.resize(static_cast<size_t>(dataSize));
|
||||
|
@ -155,9 +155,9 @@ public:
|
|||
std::unique_ptr<IStream> GetFileStream(std::string_view path) const override
|
||||
{
|
||||
auto index = GetIndexFromPath(path);
|
||||
if (index)
|
||||
if (index.has_value())
|
||||
{
|
||||
return std::make_unique<ZipItemStream>(_zip, *index);
|
||||
return std::make_unique<ZipItemStream>(_zip, index.value());
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -171,9 +171,9 @@ public:
|
|||
|
||||
auto source = zip_source_buffer(_zip, writeBuffer.data(), writeBuffer.size(), 0);
|
||||
auto index = GetIndexFromPath(path);
|
||||
if (index)
|
||||
if (index.has_value())
|
||||
{
|
||||
zip_replace(_zip, *index, source);
|
||||
zip_replace(_zip, index.value(), source);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -184,9 +184,9 @@ public:
|
|||
void DeleteFile(std::string_view path) override
|
||||
{
|
||||
auto index = GetIndexFromPath(path);
|
||||
if (index)
|
||||
if (index.has_value())
|
||||
{
|
||||
zip_delete(_zip, *index);
|
||||
zip_delete(_zip, index.value());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -378,25 +378,27 @@ static std::optional<PaletteMap> FASTCALL gfx_draw_sprite_get_palette(ImageId im
|
|||
{
|
||||
paletteMap = PaletteMap(gOtherPalette);
|
||||
auto tertiaryPaletteMap = GetPaletteMapForColour(imageId.GetTertiary());
|
||||
if (tertiaryPaletteMap)
|
||||
if (tertiaryPaletteMap.has_value())
|
||||
{
|
||||
paletteMap.Copy(
|
||||
PALETTE_OFFSET_REMAP_TERTIARY, *tertiaryPaletteMap, PALETTE_OFFSET_REMAP_PRIMARY, PALETTE_LENGTH_REMAP);
|
||||
PALETTE_OFFSET_REMAP_TERTIARY, tertiaryPaletteMap.value(), PALETTE_OFFSET_REMAP_PRIMARY,
|
||||
PALETTE_LENGTH_REMAP);
|
||||
}
|
||||
}
|
||||
|
||||
auto primaryPaletteMap = GetPaletteMapForColour(imageId.GetPrimary());
|
||||
if (primaryPaletteMap)
|
||||
if (primaryPaletteMap.has_value())
|
||||
{
|
||||
paletteMap.Copy(
|
||||
PALETTE_OFFSET_REMAP_PRIMARY, *primaryPaletteMap, PALETTE_OFFSET_REMAP_PRIMARY, PALETTE_LENGTH_REMAP);
|
||||
PALETTE_OFFSET_REMAP_PRIMARY, primaryPaletteMap.value(), PALETTE_OFFSET_REMAP_PRIMARY, PALETTE_LENGTH_REMAP);
|
||||
}
|
||||
|
||||
auto secondaryPaletteMap = GetPaletteMapForColour(imageId.GetSecondary());
|
||||
if (secondaryPaletteMap)
|
||||
if (secondaryPaletteMap.has_value())
|
||||
{
|
||||
paletteMap.Copy(
|
||||
PALETTE_OFFSET_REMAP_SECONDARY, *secondaryPaletteMap, PALETTE_OFFSET_REMAP_PRIMARY, PALETTE_LENGTH_REMAP);
|
||||
PALETTE_OFFSET_REMAP_SECONDARY, secondaryPaletteMap.value(), PALETTE_OFFSET_REMAP_PRIMARY,
|
||||
PALETTE_LENGTH_REMAP);
|
||||
}
|
||||
|
||||
return paletteMap;
|
||||
|
|
|
@ -57,7 +57,7 @@ int32_t gfx_get_string_width_new_lined(std::string_view text, FontSpriteBase fon
|
|||
if (token.kind == FormatToken::Newline || token.kind == FormatToken::NewlineSmall)
|
||||
{
|
||||
auto width = gfx_get_string_width(buffer, fontSpriteBase);
|
||||
if (!maxWidth || maxWidth > width)
|
||||
if (!maxWidth.has_value() || maxWidth.value() > width)
|
||||
{
|
||||
maxWidth = width;
|
||||
}
|
||||
|
@ -68,11 +68,11 @@ int32_t gfx_get_string_width_new_lined(std::string_view text, FontSpriteBase fon
|
|||
buffer.append(token.text);
|
||||
}
|
||||
}
|
||||
if (!maxWidth)
|
||||
if (!maxWidth.has_value())
|
||||
{
|
||||
maxWidth = gfx_get_string_width(buffer, fontSpriteBase);
|
||||
}
|
||||
return *maxWidth;
|
||||
return maxWidth.value();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -829,11 +829,11 @@ static void ttf_process_string_literal(rct_drawpixelinfo* dpi, std::string_view
|
|||
auto codepoint = *it;
|
||||
if (ShouldUseSpriteForCodepoint(codepoint))
|
||||
{
|
||||
if (ttfRunIndex)
|
||||
if (ttfRunIndex.has_value())
|
||||
{
|
||||
// Draw the TTF run
|
||||
auto len = it.GetIndex() - *ttfRunIndex;
|
||||
ttf_draw_string_raw_ttf(dpi, text.substr(*ttfRunIndex, len), info);
|
||||
auto len = it.GetIndex() - ttfRunIndex.value();
|
||||
ttf_draw_string_raw_ttf(dpi, text.substr(ttfRunIndex.value(), len), info);
|
||||
ttfRunIndex = std::nullopt;
|
||||
}
|
||||
|
||||
|
@ -842,18 +842,18 @@ static void ttf_process_string_literal(rct_drawpixelinfo* dpi, std::string_view
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!ttfRunIndex)
|
||||
if (!ttfRunIndex.has_value())
|
||||
{
|
||||
ttfRunIndex = it.GetIndex();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ttfRunIndex)
|
||||
if (ttfRunIndex.has_value())
|
||||
{
|
||||
// Final TTF run
|
||||
auto len = text.size() - *ttfRunIndex;
|
||||
ttf_draw_string_raw_ttf(dpi, text.substr(*ttfRunIndex, len), info);
|
||||
ttf_draw_string_raw_ttf(dpi, text.substr(ttfRunIndex.value(), len), info);
|
||||
}
|
||||
}
|
||||
#endif // NO_TTF
|
||||
|
|
|
@ -750,9 +750,9 @@ std::optional<uint32_t> GetPaletteG1Index(colour_t paletteId)
|
|||
std::optional<PaletteMap> GetPaletteMapForColour(colour_t paletteId)
|
||||
{
|
||||
auto g1Index = GetPaletteG1Index(paletteId);
|
||||
if (g1Index)
|
||||
if (g1Index.has_value())
|
||||
{
|
||||
auto g1 = gfx_get_g1_element(*g1Index);
|
||||
auto g1 = gfx_get_g1_element(g1Index.value());
|
||||
if (g1 != nullptr)
|
||||
{
|
||||
return PaletteMap(g1->offset, g1->height, g1->width);
|
||||
|
|
|
@ -703,8 +703,9 @@ void X8DrawingContext::FilterRect(FilterPaletteID palette, int32_t left, int32_t
|
|||
|
||||
// Find colour in colour table?
|
||||
auto paletteMap = GetPaletteMapForColour(EnumValue(palette));
|
||||
if (paletteMap)
|
||||
if (paletteMap.has_value())
|
||||
{
|
||||
const auto& paletteEntries = paletteMap.value();
|
||||
const int32_t scaled_width = width / dpi->zoom_level;
|
||||
const int32_t step = ((dpi->width / dpi->zoom_level) + dpi->pitch);
|
||||
|
||||
|
@ -716,7 +717,7 @@ void X8DrawingContext::FilterRect(FilterPaletteID palette, int32_t left, int32_t
|
|||
for (int32_t j = 0; j < scaled_width; j++)
|
||||
{
|
||||
auto index = *(nextdst + j);
|
||||
*(nextdst + j) = (*paletteMap)[index];
|
||||
*(nextdst + j) = paletteEntries[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,14 +161,14 @@ std::string screenshot_dump_png(rct_drawpixelinfo* dpi)
|
|||
// Get a free screenshot path
|
||||
auto path = screenshot_get_next_path();
|
||||
|
||||
if (path == std::nullopt)
|
||||
if (!path.has_value())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
if (WriteDpiToFile(path->c_str(), dpi, gPalette))
|
||||
if (WriteDpiToFile(path.value(), dpi, gPalette))
|
||||
{
|
||||
return *path;
|
||||
return path.value();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -180,7 +180,7 @@ std::string screenshot_dump_png_32bpp(int32_t width, int32_t height, const void*
|
|||
{
|
||||
auto path = screenshot_get_next_path();
|
||||
|
||||
if (path == std::nullopt)
|
||||
if (!path.has_value())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
@ -196,8 +196,8 @@ std::string screenshot_dump_png_32bpp(int32_t width, int32_t height, const void*
|
|||
image.Depth = 32;
|
||||
image.Stride = width * 4;
|
||||
image.Pixels = std::vector<uint8_t>(pixels8, pixels8 + pixelsLen);
|
||||
Imaging::WriteToFile(path->c_str(), image, IMAGE_FORMAT::PNG_32);
|
||||
return *path;
|
||||
Imaging::WriteToFile(path.value(), image, IMAGE_FORMAT::PNG_32);
|
||||
return path.value();
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
|
@ -384,7 +384,7 @@ void screenshot_giant()
|
|||
try
|
||||
{
|
||||
auto path = screenshot_get_next_path();
|
||||
if (path == std::nullopt)
|
||||
if (!path.has_value())
|
||||
{
|
||||
throw std::runtime_error("Giant screenshot failed, unable to find a suitable destination path.");
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ void screenshot_giant()
|
|||
dpi = CreateDPI(viewport);
|
||||
|
||||
RenderViewport(nullptr, viewport, dpi);
|
||||
WriteDpiToFile(path->c_str(), &dpi, gPalette);
|
||||
WriteDpiToFile(path.value(), &dpi, gPalette);
|
||||
|
||||
// Show user that screenshot saved successfully
|
||||
Formatter ft;
|
||||
|
@ -792,7 +792,7 @@ static std::string ResolveFilenameForCapture(const fs::path& filename)
|
|||
void CaptureImage(const CaptureOptions& options)
|
||||
{
|
||||
rct_viewport viewport{};
|
||||
if (options.View)
|
||||
if (options.View.has_value())
|
||||
{
|
||||
viewport.width = options.View->Width;
|
||||
viewport.height = options.View->Height;
|
||||
|
|
|
@ -186,7 +186,7 @@ void viewport_create(
|
|||
}
|
||||
|
||||
auto centreLoc = centre_2d_coordinates(centrePos, viewport);
|
||||
if (!centreLoc)
|
||||
if (!centreLoc.has_value())
|
||||
{
|
||||
log_error("Invalid location for viewport.");
|
||||
return;
|
||||
|
@ -597,9 +597,9 @@ void viewport_update_position(rct_window* window)
|
|||
if (at_map_edge)
|
||||
{
|
||||
auto centreLoc = centre_2d_coordinates({ mapCoord, 0 }, viewport);
|
||||
if (centreLoc)
|
||||
if (centreLoc.has_value())
|
||||
{
|
||||
window->savedViewPos = *centreLoc;
|
||||
window->savedViewPos = centreLoc.value();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -658,7 +658,7 @@ void viewport_update_sprite_follow(rct_window* window)
|
|||
viewport_set_underground_flag(underground, window, window->viewport);
|
||||
|
||||
auto centreLoc = centre_2d_coordinates({ sprite->x, sprite->y, sprite->z }, window->viewport);
|
||||
if (centreLoc)
|
||||
if (centreLoc.has_value())
|
||||
{
|
||||
window->savedViewPos = *centreLoc;
|
||||
viewport_move(*centreLoc, window, window->viewport);
|
||||
|
@ -1080,7 +1080,7 @@ static void viewport_paint_weather_gloom(rct_drawpixelinfo* dpi)
|
|||
std::optional<CoordsXY> screen_pos_to_map_pos(const ScreenCoordsXY& screenCoords, int32_t* direction)
|
||||
{
|
||||
auto mapCoords = screen_get_map_xy(screenCoords, nullptr);
|
||||
if (!mapCoords)
|
||||
if (!mapCoords.has_value())
|
||||
return std::nullopt;
|
||||
|
||||
int32_t my_direction;
|
||||
|
@ -1613,9 +1613,9 @@ static bool is_sprite_interacted_with(rct_drawpixelinfo* dpi, int32_t imageId, c
|
|||
{
|
||||
index &= 0x1F;
|
||||
}
|
||||
if (auto pm = GetPaletteMapForColour(index))
|
||||
if (auto pm = GetPaletteMapForColour(index); pm.has_value())
|
||||
{
|
||||
paletteMap = *pm;
|
||||
paletteMap = pm.value();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1865,7 +1865,7 @@ std::optional<CoordsXY> screen_get_map_xy_with_z(const ScreenCoordsXY& screenCoo
|
|||
std::optional<CoordsXY> screen_get_map_xy_quadrant(const ScreenCoordsXY& screenCoords, uint8_t* quadrant)
|
||||
{
|
||||
auto mapCoords = screen_get_map_xy(screenCoords, nullptr);
|
||||
if (!mapCoords)
|
||||
if (!mapCoords.has_value())
|
||||
return std::nullopt;
|
||||
|
||||
*quadrant = map_get_tile_quadrant(*mapCoords);
|
||||
|
@ -1879,7 +1879,7 @@ std::optional<CoordsXY> screen_get_map_xy_quadrant(const ScreenCoordsXY& screenC
|
|||
std::optional<CoordsXY> screen_get_map_xy_quadrant_with_z(const ScreenCoordsXY& screenCoords, int32_t z, uint8_t* quadrant)
|
||||
{
|
||||
auto mapCoords = screen_get_map_xy_with_z(screenCoords, z);
|
||||
if (!mapCoords)
|
||||
if (!mapCoords.has_value())
|
||||
return std::nullopt;
|
||||
|
||||
*quadrant = map_get_tile_quadrant(*mapCoords);
|
||||
|
@ -1893,7 +1893,7 @@ std::optional<CoordsXY> screen_get_map_xy_quadrant_with_z(const ScreenCoordsXY&
|
|||
std::optional<CoordsXY> screen_get_map_xy_side(const ScreenCoordsXY& screenCoords, uint8_t* side)
|
||||
{
|
||||
auto mapCoords = screen_get_map_xy(screenCoords, nullptr);
|
||||
if (!mapCoords)
|
||||
if (!mapCoords.has_value())
|
||||
return std::nullopt;
|
||||
|
||||
*side = map_get_tile_side(*mapCoords);
|
||||
|
@ -1907,7 +1907,7 @@ std::optional<CoordsXY> screen_get_map_xy_side(const ScreenCoordsXY& screenCoord
|
|||
std::optional<CoordsXY> screen_get_map_xy_side_with_z(const ScreenCoordsXY& screenCoords, int32_t z, uint8_t* side)
|
||||
{
|
||||
auto mapCoords = screen_get_map_xy_with_z(screenCoords, z);
|
||||
if (!mapCoords)
|
||||
if (!mapCoords.has_value())
|
||||
return std::nullopt;
|
||||
|
||||
*side = map_get_tile_side(*mapCoords);
|
||||
|
|
|
@ -909,7 +909,7 @@ void window_rotate_camera(rct_window* w, int32_t direction)
|
|||
|
||||
// other != viewport probably triggers on viewports in ride or guest window?
|
||||
// naoXYCoords is nullopt if middle of viewport is obstructed by another window?
|
||||
if (!mapXYCoords || other != viewport)
|
||||
if (!mapXYCoords.has_value() || other != viewport)
|
||||
{
|
||||
auto viewPos = ScreenCoordsXY{ (viewport->view_width >> 1), (viewport->view_height >> 1) } + viewport->viewPos;
|
||||
|
||||
|
@ -926,9 +926,9 @@ void window_rotate_camera(rct_window* w, int32_t direction)
|
|||
|
||||
auto centreLoc = centre_2d_coordinates(coords, viewport);
|
||||
|
||||
if (centreLoc)
|
||||
if (centreLoc.has_value())
|
||||
{
|
||||
w->savedViewPos = *centreLoc;
|
||||
w->savedViewPos = centreLoc.value();
|
||||
viewport->viewPos = *centreLoc;
|
||||
}
|
||||
|
||||
|
@ -976,7 +976,7 @@ void window_viewport_centre_tile_around_cursor(rct_window* w, int32_t map_x, int
|
|||
int32_t z = tile_element_height({ map_x, map_y });
|
||||
auto centreLoc = centre_2d_coordinates({ map_x, map_y, z }, w->viewport);
|
||||
|
||||
if (!centreLoc)
|
||||
if (!centreLoc.has_value())
|
||||
{
|
||||
log_error("Invalid location.");
|
||||
return;
|
||||
|
|
|
@ -1416,7 +1416,7 @@ std::vector<uint8_t> NetworkBase::save_for_network(const std::vector<const Objec
|
|||
int32_t size = ms.GetLength();
|
||||
|
||||
auto compressed = util_zlib_deflate(static_cast<const uint8_t*>(data), size);
|
||||
if (compressed != std::nullopt)
|
||||
if (compressed.has_value())
|
||||
{
|
||||
std::string headerString = "open2_sv6_zlib";
|
||||
header.resize(headerString.size() + 1 + compressed->size());
|
||||
|
|
|
@ -196,9 +196,9 @@ uint64_t ObjectAsset::GetSize() const
|
|||
if (zipArchive != nullptr)
|
||||
{
|
||||
auto index = zipArchive->GetIndexFromPath(_path);
|
||||
if (index)
|
||||
if (index.has_value())
|
||||
{
|
||||
auto size = zipArchive->GetFileSize(*index);
|
||||
auto size = zipArchive->GetFileSize(index.value());
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -372,17 +372,17 @@ private:
|
|||
{
|
||||
slot = FindSpareSlot(objectType);
|
||||
}
|
||||
if (slot)
|
||||
if (slot.has_value())
|
||||
{
|
||||
auto* object = GetOrLoadObject(ori);
|
||||
if (object != nullptr)
|
||||
{
|
||||
if (_loadedObjects.size() <= static_cast<size_t>(*slot))
|
||||
{
|
||||
_loadedObjects.resize(*slot + 1);
|
||||
_loadedObjects.resize(slot.value() + 1);
|
||||
}
|
||||
loadedObject = object;
|
||||
_loadedObjects[*slot] = object;
|
||||
_loadedObjects[slot.value()] = object;
|
||||
UpdateSceneryGroupIndexes();
|
||||
ResetTypeToRideEntryIndexMap();
|
||||
}
|
||||
|
|
|
@ -85,9 +85,9 @@ void SceneryGroupObject::UpdateEntryIndexes()
|
|||
Guard::Assert(entryIndex != OBJECT_ENTRY_INDEX_NULL, GUARD_LINE);
|
||||
|
||||
auto sceneryType = ori->ObjectEntry.GetSceneryType();
|
||||
if (sceneryType != std::nullopt)
|
||||
if (sceneryType.has_value())
|
||||
{
|
||||
_legacyType.scenery_entries[_legacyType.entry_count] = { *sceneryType, entryIndex };
|
||||
_legacyType.scenery_entries[_legacyType.entry_count] = { sceneryType.value(), entryIndex };
|
||||
_legacyType.entry_count++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3411,7 +3411,7 @@ void Guest::UpdateRideAtEntrance()
|
|||
if (DestinationTolerance != 0)
|
||||
{
|
||||
int16_t xy_distance;
|
||||
if (auto loc = UpdateAction(xy_distance))
|
||||
if (auto loc = UpdateAction(xy_distance); loc.has_value())
|
||||
{
|
||||
int16_t actionZ = z;
|
||||
if (xy_distance < 16)
|
||||
|
@ -3419,7 +3419,7 @@ void Guest::UpdateRideAtEntrance()
|
|||
auto entrance = ride_get_entrance_location(ride, CurrentRideStation).ToCoordsXYZ();
|
||||
actionZ = entrance.z + 2;
|
||||
}
|
||||
MoveTo({ *loc, actionZ });
|
||||
MoveTo({ loc.value(), actionZ });
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3600,7 +3600,7 @@ void Guest::UpdateRideAdvanceThroughEntrance()
|
|||
|
||||
auto ride_entry = ride->GetRideEntry();
|
||||
|
||||
if (auto loc = UpdateAction(xy_distance))
|
||||
if (auto loc = UpdateAction(xy_distance); loc.has_value())
|
||||
{
|
||||
uint16_t distanceThreshold = 16;
|
||||
if (ride_entry != nullptr)
|
||||
|
@ -3626,7 +3626,7 @@ void Guest::UpdateRideAdvanceThroughEntrance()
|
|||
actionZ += ride->GetRideTypeDescriptor().Heights.PlatformHeight;
|
||||
}
|
||||
|
||||
MoveTo({ *loc, actionZ });
|
||||
MoveTo({ loc.value(), actionZ });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3978,9 +3978,9 @@ void Guest::UpdateRideFreeVehicleCheck()
|
|||
|
||||
void Guest::UpdateRideApproachVehicle()
|
||||
{
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
MoveTo({ *loc, z });
|
||||
MoveTo({ loc.value(), z });
|
||||
return;
|
||||
}
|
||||
RideSubState = PeepRideSubState::EnterVehicle;
|
||||
|
@ -4310,9 +4310,9 @@ static void peep_update_ride_prepare_for_exit(Peep* peep)
|
|||
*/
|
||||
void Guest::UpdateRideApproachExit()
|
||||
{
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
MoveTo({ *loc, z });
|
||||
MoveTo({ loc.value(), z });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4331,19 +4331,19 @@ void Guest::UpdateRideInExit()
|
|||
|
||||
int16_t xy_distance;
|
||||
|
||||
if (auto loc = UpdateAction(xy_distance))
|
||||
if (auto loc = UpdateAction(xy_distance); loc.has_value())
|
||||
{
|
||||
if (xy_distance >= 16)
|
||||
{
|
||||
int16_t actionZ = ride->stations[CurrentRideStation].GetBaseZ();
|
||||
|
||||
actionZ += ride->GetRideTypeDescriptor().Heights.PlatformHeight;
|
||||
MoveTo({ *loc, actionZ });
|
||||
MoveTo({ loc.value(), actionZ });
|
||||
return;
|
||||
}
|
||||
|
||||
SwitchToSpecialSprite(0);
|
||||
MoveTo({ *loc, z });
|
||||
MoveTo({ loc.value(), z });
|
||||
}
|
||||
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_RIDE_PHOTO)
|
||||
|
@ -4370,7 +4370,7 @@ void Guest::UpdateRideApproachVehicleWaypoints()
|
|||
int16_t xy_distance;
|
||||
uint8_t waypoint = Var37 & 3;
|
||||
|
||||
if (auto loc = UpdateAction(xy_distance))
|
||||
if (auto loc = UpdateAction(xy_distance); loc.has_value())
|
||||
{
|
||||
int16_t actionZ;
|
||||
// Motion simulators have steps this moves the peeps up the steps
|
||||
|
@ -4394,7 +4394,7 @@ void Guest::UpdateRideApproachVehicleWaypoints()
|
|||
{
|
||||
actionZ = z;
|
||||
}
|
||||
MoveTo({ *loc, actionZ });
|
||||
MoveTo({ loc.value(), actionZ });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4448,7 +4448,7 @@ void Guest::UpdateRideApproachExitWaypoints()
|
|||
|
||||
int16_t xy_distance;
|
||||
|
||||
if (auto loc = UpdateAction(xy_distance))
|
||||
if (auto loc = UpdateAction(xy_distance); loc.has_value())
|
||||
{
|
||||
int16_t actionZ;
|
||||
if (ride->type == RIDE_TYPE_MOTION_SIMULATOR)
|
||||
|
@ -4467,7 +4467,7 @@ void Guest::UpdateRideApproachExitWaypoints()
|
|||
{
|
||||
actionZ = z;
|
||||
}
|
||||
MoveTo({ *loc, actionZ });
|
||||
MoveTo({ loc.value(), actionZ });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4543,9 +4543,9 @@ void Guest::UpdateRideApproachSpiralSlide()
|
|||
if (ride == nullptr)
|
||||
return;
|
||||
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
MoveTo({ *loc, z });
|
||||
MoveTo({ loc.value(), z });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4676,9 +4676,9 @@ void Guest::UpdateRideOnSpiralSlide()
|
|||
}
|
||||
}
|
||||
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
MoveTo({ *loc, z });
|
||||
MoveTo({ loc.value(), z });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4702,9 +4702,9 @@ void Guest::UpdateRideLeaveSpiralSlide()
|
|||
{
|
||||
// Iterates through the spiral slide waypoints until it reaches
|
||||
// waypoint 0. Then it readies to leave the ride by the entrance.
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
MoveTo({ *loc, z });
|
||||
MoveTo({ loc.value(), z });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4775,9 +4775,9 @@ static constexpr const uint8_t _MazeCurrentDirectionToOpenHedge[][4] = {
|
|||
*/
|
||||
void Guest::UpdateRideMazePathfinding()
|
||||
{
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
MoveTo({ *loc, z });
|
||||
MoveTo({ loc.value(), z });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4897,9 +4897,9 @@ void Guest::UpdateRideMazePathfinding()
|
|||
break;
|
||||
}
|
||||
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
MoveTo({ *loc, z });
|
||||
MoveTo({ loc.value(), z });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -4912,11 +4912,11 @@ void Guest::UpdateRideLeaveExit()
|
|||
{
|
||||
auto ride = get_ride(CurrentRide);
|
||||
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
if (ride != nullptr)
|
||||
{
|
||||
MoveTo({ *loc, ride->stations[CurrentRideStation].GetBaseZ() });
|
||||
MoveTo({ loc.value(), ride->stations[CurrentRideStation].GetBaseZ() });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -4961,9 +4961,9 @@ void Guest::UpdateRideLeaveExit()
|
|||
*/
|
||||
void Guest::UpdateRideShopApproach()
|
||||
{
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
MoveTo({ *loc, z });
|
||||
MoveTo({ loc.value(), z });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5027,9 +5027,9 @@ void Guest::UpdateRideShopInteract()
|
|||
*/
|
||||
void Guest::UpdateRideShopLeave()
|
||||
{
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
MoveTo({ *loc, z });
|
||||
MoveTo({ loc.value(), z });
|
||||
|
||||
if ((x & 0xFFE0) != NextLoc.x)
|
||||
return;
|
||||
|
@ -5577,9 +5577,9 @@ void Guest::UpdateEnteringPark()
|
|||
}
|
||||
return;
|
||||
}
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
MoveTo({ *loc, z });
|
||||
MoveTo({ loc.value(), z });
|
||||
return;
|
||||
}
|
||||
SetState(PeepState::Falling);
|
||||
|
@ -5608,9 +5608,9 @@ void Guest::UpdateLeavingPark()
|
|||
return;
|
||||
}
|
||||
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
MoveTo({ *loc, z });
|
||||
MoveTo({ loc.value(), z });
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -2297,7 +2297,7 @@ void Peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result)
|
|||
}
|
||||
|
||||
std::optional<CoordsXY> loc;
|
||||
if (!(loc = UpdateAction()))
|
||||
if (loc = UpdateAction(); !loc.has_value())
|
||||
{
|
||||
pathing_result |= PATHING_DESTINATION_REACHED;
|
||||
uint8_t result = 0;
|
||||
|
@ -2315,7 +2315,7 @@ void Peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result)
|
|||
if (result != 0)
|
||||
return;
|
||||
|
||||
if (!(loc = UpdateAction()))
|
||||
if (loc = UpdateAction(); !loc.has_value())
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1150,10 +1150,10 @@ void Staff::UpdateMowing()
|
|||
|
||||
while (true)
|
||||
{
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
int16_t checkZ = tile_element_height(*loc);
|
||||
MoveTo({ *loc, checkZ });
|
||||
MoveTo({ loc.value(), checkZ });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1348,10 +1348,10 @@ void Staff::UpdateSweeping()
|
|||
StaffLitterSwept++;
|
||||
WindowInvalidateFlags |= PEEP_INVALIDATE_STAFF_STATS;
|
||||
}
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
int16_t actionZ = GetZOnSlope((*loc).x, (*loc).y);
|
||||
MoveTo({ *loc, actionZ });
|
||||
MoveTo({ loc.value(), actionZ });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1453,7 +1453,7 @@ void Staff::UpdateHeadingToInspect()
|
|||
}
|
||||
|
||||
int16_t delta_y = abs(GetLocation().y - GetDestination().y);
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
int32_t newZ = ride->stations[CurrentRideStation].GetBaseZ();
|
||||
|
||||
|
@ -1462,7 +1462,7 @@ void Staff::UpdateHeadingToInspect()
|
|||
newZ += ride->GetRideTypeDescriptor().Heights.PlatformHeight;
|
||||
}
|
||||
|
||||
MoveTo({ *loc, newZ });
|
||||
MoveTo({ loc.value(), newZ });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1562,7 +1562,7 @@ void Staff::UpdateAnswering()
|
|||
}
|
||||
|
||||
int16_t delta_y = abs(y - GetDestination().y);
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
int32_t newZ = ride->stations[CurrentRideStation].GetBaseZ();
|
||||
|
||||
|
@ -1571,7 +1571,7 @@ void Staff::UpdateAnswering()
|
|||
newZ += ride->GetRideTypeDescriptor().Heights.PlatformHeight;
|
||||
}
|
||||
|
||||
MoveTo({ *loc, newZ });
|
||||
MoveTo({ loc.value(), newZ });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2155,9 +2155,9 @@ bool Staff::UpdateFixingMoveToBrokenDownVehicle(bool firstRun, const Ride* ride)
|
|||
SetDestination(destination, 2);
|
||||
}
|
||||
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
MoveTo({ *loc, z });
|
||||
MoveTo({ loc.value(), z });
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2305,9 +2305,9 @@ bool Staff::UpdateFixingMoveToStationEnd(bool firstRun, const Ride* ride)
|
|||
SetDestination(stationPos, 2);
|
||||
}
|
||||
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
MoveTo({ *loc, z });
|
||||
MoveTo({ loc.value(), z });
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2411,9 +2411,9 @@ bool Staff::UpdateFixingMoveToStationStart(bool firstRun, const Ride* ride)
|
|||
SetDestination(destination, 2);
|
||||
}
|
||||
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
MoveTo({ *loc, z });
|
||||
MoveTo({ loc.value(), z });
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2524,9 +2524,9 @@ bool Staff::UpdateFixingMoveToStationExit(bool firstRun, const Ride* ride)
|
|||
SetDestination(stationPosition, 2);
|
||||
}
|
||||
|
||||
if (auto loc = UpdateAction())
|
||||
if (auto loc = UpdateAction(); loc.has_value())
|
||||
{
|
||||
MoveTo({ *loc, z });
|
||||
MoveTo({ loc.value(), z });
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
@ -2608,7 +2608,7 @@ bool Staff::UpdateFixingLeaveByEntranceExit(bool firstRun, const Ride* ride)
|
|||
}
|
||||
|
||||
int16_t xy_distance;
|
||||
if (auto loc = UpdateAction(xy_distance))
|
||||
if (auto loc = UpdateAction(xy_distance); loc.has_value())
|
||||
{
|
||||
uint16_t stationHeight = ride->stations[CurrentRideStation].GetBaseZ();
|
||||
|
||||
|
@ -2617,7 +2617,7 @@ bool Staff::UpdateFixingLeaveByEntranceExit(bool firstRun, const Ride* ride)
|
|||
stationHeight += ride->GetRideTypeDescriptor().Heights.PlatformHeight;
|
||||
}
|
||||
|
||||
MoveTo({ *loc, stationHeight });
|
||||
MoveTo({ loc.value(), stationHeight });
|
||||
return false;
|
||||
}
|
||||
SetState(PeepState::Falling);
|
||||
|
|
|
@ -85,9 +85,9 @@ static bool UploadMinidump(const std::map<std::wstring, std::wstring>& files, in
|
|||
}
|
||||
|
||||
auto assertMsg = Guard::GetLastAssertMessage();
|
||||
if (assertMsg)
|
||||
if (assertMsg.has_value())
|
||||
{
|
||||
parameters[L"assert_failure"] = String::ToWideChar(*assertMsg);
|
||||
parameters[L"assert_failure"] = String::ToWideChar(assertMsg.value());
|
||||
}
|
||||
|
||||
int timeout = 10000;
|
||||
|
|
|
@ -869,9 +869,9 @@ namespace RCT1
|
|||
{
|
||||
// Original RCT had no music settings, take default style
|
||||
auto style = GetStyleFromMusicIdentifier(GetRideTypeDescriptor(dst->type).DefaultMusic);
|
||||
if (style)
|
||||
if (style.has_value())
|
||||
{
|
||||
dst->music = *style;
|
||||
dst->music = style.value();
|
||||
}
|
||||
|
||||
// Only merry-go-round and dodgems had music and used
|
||||
|
|
|
@ -612,9 +612,9 @@ void S6Exporter::ExportParkName()
|
|||
{
|
||||
auto& park = OpenRCT2::GetContext()->GetGameState()->GetPark();
|
||||
auto stringId = AllocateUserString(park.Name);
|
||||
if (stringId != std::nullopt)
|
||||
if (stringId.has_value())
|
||||
{
|
||||
_s6.park_name = *stringId;
|
||||
_s6.park_name = stringId.value();
|
||||
_s6.park_name_args = 0;
|
||||
}
|
||||
else
|
||||
|
@ -672,9 +672,9 @@ void S6Exporter::ExportRide(rct2_ride* dst, const Ride* src)
|
|||
{
|
||||
// Custom name, allocate user string for ride
|
||||
auto stringId = AllocateUserString(src->custom_name);
|
||||
if (stringId != std::nullopt)
|
||||
if (stringId.has_value())
|
||||
{
|
||||
dst->name = *stringId;
|
||||
dst->name = stringId.value();
|
||||
dst->name_arguments = 0;
|
||||
useDefaultName = false;
|
||||
}
|
||||
|
@ -1426,9 +1426,9 @@ void S6Exporter::ExportEntityPeep(RCT2SpritePeep* dst, const Peep* src)
|
|||
if (src->Name != nullptr)
|
||||
{
|
||||
auto stringId = AllocateUserString(src->Name);
|
||||
if (stringId != std::nullopt)
|
||||
if (stringId.has_value())
|
||||
{
|
||||
dst->name_string_idx = *stringId;
|
||||
dst->name_string_idx = stringId.value();
|
||||
generateName = false;
|
||||
}
|
||||
else
|
||||
|
@ -1718,9 +1718,9 @@ void S6Exporter::ExportBanner(RCT12Banner& dst, const Banner& src)
|
|||
bannerText.append(src.text);
|
||||
|
||||
auto stringId = AllocateUserString(bannerText);
|
||||
if (stringId != std::nullopt)
|
||||
if (stringId.has_value())
|
||||
{
|
||||
dst.string_idx = *stringId;
|
||||
dst.string_idx = stringId.value();
|
||||
}
|
||||
|
||||
if (src.flags & BANNER_FLAG_LINKED_TO_RIDE)
|
||||
|
|
|
@ -2868,8 +2868,8 @@ static void ride_set_boat_hire_return_point(Ride* ride, CoordsXYE* startElement)
|
|||
trackType = trackBeginEnd.begin_element->AsTrack()->GetTrackType();
|
||||
auto newCoords = GetTrackElementOriginAndApplyChanges(
|
||||
{ trackCoords, static_cast<Direction>(direction) }, trackType, 0, &returnPos.element, 0);
|
||||
returnPos = newCoords == std::nullopt ? CoordsXYE{ trackCoords, returnPos.element }
|
||||
: CoordsXYE{ *newCoords, returnPos.element };
|
||||
returnPos = !newCoords.has_value() ? CoordsXYE{ trackCoords, returnPos.element }
|
||||
: CoordsXYE{ *newCoords, returnPos.element };
|
||||
};
|
||||
|
||||
trackType = returnPos.element->AsTrack()->GetTrackType();
|
||||
|
@ -4855,7 +4855,7 @@ static std::optional<int32_t> ride_get_smallest_station_length(Ride* ride)
|
|||
{
|
||||
if (!station.Start.IsNull())
|
||||
{
|
||||
if (!result.has_value() || station.Length < *result)
|
||||
if (!result.has_value() || station.Length < result.value())
|
||||
{
|
||||
result = station.Length;
|
||||
}
|
||||
|
@ -4968,7 +4968,7 @@ void Ride::UpdateMaxVehicles()
|
|||
if (!stationNumTiles.has_value())
|
||||
return;
|
||||
|
||||
auto stationLength = (*stationNumTiles * 0x44180) - 0x16B2A;
|
||||
auto stationLength = (stationNumTiles.value() * 0x44180) - 0x16B2A;
|
||||
int32_t maxMass = GetRideTypeDescriptor().MaxMass << 8;
|
||||
int32_t maxCarsPerTrain = 1;
|
||||
for (int32_t numCars = rideEntry->max_cars_in_train; numCars > 0; numCars--)
|
||||
|
|
|
@ -752,7 +752,7 @@ void ride_select_next_section()
|
|||
TileElement* tileElement;
|
||||
auto newCoords = GetTrackElementOriginAndApplyChanges(
|
||||
{ _currentTrackBegin, static_cast<Direction>(direction & 3) }, type, 0, &tileElement, 0);
|
||||
if (newCoords == std::nullopt)
|
||||
if (!newCoords.has_value())
|
||||
{
|
||||
_rideConstructionState = RideConstructionState::State0;
|
||||
window_ride_construction_update_active_elements();
|
||||
|
@ -1037,12 +1037,12 @@ bool ride_modify(CoordsXYE* input)
|
|||
auto direction = tileElement.element->GetDirection();
|
||||
auto type = tileElement.element->AsTrack()->GetTrackType();
|
||||
auto newCoords = GetTrackElementOriginAndApplyChanges({ tileCoords, direction }, type, 0, nullptr, 0);
|
||||
if (newCoords == std::nullopt)
|
||||
if (!newCoords.has_value())
|
||||
return false;
|
||||
|
||||
_currentRideIndex = rideIndex;
|
||||
_rideConstructionState = RideConstructionState::Selected;
|
||||
_currentTrackBegin = *newCoords;
|
||||
_currentTrackBegin = newCoords.value();
|
||||
_currentTrackPieceDirection = direction;
|
||||
_currentTrackPieceType = type;
|
||||
_currentTrackSelectionFlags = 0;
|
||||
|
@ -1281,7 +1281,7 @@ CoordsXYZD ride_get_entrance_or_exit_position_from_screen_position(const ScreenC
|
|||
auto stationBaseZ = ride->stations[gRideEntranceExitPlaceStationIndex].GetBaseZ();
|
||||
|
||||
auto coordsAtHeight = screen_get_map_xy_with_z(screenCoords, stationBaseZ);
|
||||
if (!coordsAtHeight)
|
||||
if (!coordsAtHeight.has_value())
|
||||
{
|
||||
entranceExitCoords.SetNull();
|
||||
return entranceExitCoords;
|
||||
|
|
|
@ -179,7 +179,7 @@ rct_string_id TrackDesign::CreateTrackDesignTrack(const Ride& ride)
|
|||
auto newCoords = GetTrackElementOriginAndApplyChanges(
|
||||
{ trackElement, z, direction }, trackType, 0, &trackElement.element, 0);
|
||||
|
||||
if (newCoords == std::nullopt)
|
||||
if (!newCoords.has_value())
|
||||
{
|
||||
return STR_TRACK_TOO_LARGE_OR_TOO_MUCH_SCENERY;
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ rct_string_id TrackDesign::CreateTrackDesignTrack(const Ride& ride)
|
|||
newCoords = GetTrackElementOriginAndApplyChanges(
|
||||
{ trackElement, z, direction }, trackType, 0, &trackElement.element, 0);
|
||||
|
||||
if (newCoords == std::nullopt)
|
||||
if (!newCoords.has_value())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -246,7 +246,7 @@ static void track_design_save_add_large_scenery(const CoordsXY& loc, LargeScener
|
|||
|
||||
auto sceneryOrigin = map_large_scenery_get_origin(
|
||||
{ loc.x, loc.y, z << 3, static_cast<Direction>(direction) }, sequence, nullptr);
|
||||
if (!sceneryOrigin)
|
||||
if (!sceneryOrigin.has_value())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -2340,7 +2340,7 @@ void Vehicle::UpdateWaitingForPassengers()
|
|||
}
|
||||
|
||||
auto trainIndex = ride_get_train_index_from_vehicle(curRide, sprite_index);
|
||||
if (!trainIndex)
|
||||
if (!trainIndex.has_value())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -2348,7 +2348,7 @@ void Vehicle::UpdateWaitingForPassengers()
|
|||
if (curRide->stations[current_station].TrainAtStation != RideStation::NO_TRAIN)
|
||||
return;
|
||||
|
||||
curRide->stations[current_station].TrainAtStation = *trainIndex;
|
||||
curRide->stations[current_station].TrainAtStation = trainIndex.value();
|
||||
sub_state = 1;
|
||||
time_waiting = 0;
|
||||
|
||||
|
@ -3607,12 +3607,12 @@ void Vehicle::UpdateCollisionSetup()
|
|||
{
|
||||
auto frontVehicle = GetHead();
|
||||
auto trainIndex = ride_get_train_index_from_vehicle(curRide, frontVehicle->sprite_index);
|
||||
if (!trainIndex)
|
||||
if (!trainIndex.has_value())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
curRide->Crash(*trainIndex);
|
||||
curRide->Crash(trainIndex.value());
|
||||
|
||||
if (curRide->status != RideStatus::Closed)
|
||||
{
|
||||
|
@ -5382,12 +5382,12 @@ void Vehicle::CrashOnLand()
|
|||
{
|
||||
auto frontVehicle = GetHead();
|
||||
auto trainIndex = ride_get_train_index_from_vehicle(curRide, frontVehicle->sprite_index);
|
||||
if (!trainIndex)
|
||||
if (!trainIndex.has_value())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
curRide->Crash(*trainIndex);
|
||||
curRide->Crash(trainIndex.value());
|
||||
|
||||
if (curRide->status != RideStatus::Closed)
|
||||
{
|
||||
|
@ -5448,12 +5448,12 @@ void Vehicle::CrashOnWater()
|
|||
{
|
||||
auto frontVehicle = GetHead();
|
||||
auto trainIndex = ride_get_train_index_from_vehicle(curRide, frontVehicle->sprite_index);
|
||||
if (!trainIndex)
|
||||
if (!trainIndex.has_value())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
curRide->Crash(*trainIndex);
|
||||
curRide->Crash(trainIndex.value());
|
||||
|
||||
if (curRide->status != RideStatus::Closed)
|
||||
{
|
||||
|
|
|
@ -83,10 +83,10 @@ void MoneyEffect::Create(money64 value, const CoordsXYZ& loc)
|
|||
rct_viewport* mainViewport = window_get_viewport(mainWindow);
|
||||
auto mapPositionXY = screen_get_map_xy(
|
||||
{ mainViewport->pos.x + (mainViewport->width / 2), mainViewport->pos.y + (mainViewport->height / 2) }, nullptr);
|
||||
if (!mapPositionXY)
|
||||
if (!mapPositionXY.has_value())
|
||||
return;
|
||||
|
||||
offsetLoc = { *mapPositionXY, tile_element_height(*mapPositionXY) };
|
||||
offsetLoc = { mapPositionXY.value(), tile_element_height(*mapPositionXY) };
|
||||
}
|
||||
offsetLoc.z += 10;
|
||||
CreateAt(-value, offsetLoc, false);
|
||||
|
|
Loading…
Reference in New Issue