Merge pull request #24089 from Gymnasiast/refactor/screaming-enums-4

Refactor screaming enums 4
This commit is contained in:
Michael Steenbeek authored and GitHub committed 2025-03-26 23:13:25 +01:00
commit ff6e8c69fa
93 files changed
+440 -477

No files matched your search

+4 -4
View File
@@ -180,7 +180,7 @@ public:
return _scaleQuality;
}
void SetFullscreenMode(FULLSCREEN_MODE mode) override
void SetFullscreenMode(FullscreenMode mode) override
{
static constexpr int32_t kSDLFullscreenFlags[] = {
0,
@@ -190,7 +190,7 @@ public:
uint32_t windowFlags = kSDLFullscreenFlags[EnumValue(mode)];
// HACK Changing window size when in fullscreen usually has no effect
if (mode == FULLSCREEN_MODE::FULLSCREEN)
if (mode == FullscreenMode::fullscreen)
{
SDL_SetWindowFullscreen(_window, 0);
@@ -200,7 +200,7 @@ public:
Config::Get().general.FullscreenWidth, Config::Get().general.FullscreenHeight);
SDL_SetWindowSize(_window, resolution.Width, resolution.Height);
}
else if (mode == FULLSCREEN_MODE::WINDOWED)
else if (mode == FullscreenMode::windowed)
{
SDL_SetWindowSize(_window, Config::Get().general.WindowWidth, Config::Get().general.WindowHeight);
}
@@ -820,7 +820,7 @@ private:
UpdateFullscreenResolutions();
SetFullscreenMode(static_cast<FULLSCREEN_MODE>(Config::Get().general.FullscreenMode));
SetFullscreenMode(static_cast<FullscreenMode>(Config::Get().general.FullscreenMode));
TriggerResize();
}
+2 -2
View File
@@ -32,7 +32,7 @@ namespace OpenRCT2::Ui
// TODO Bitmaps aren't very complicated to read so we should probably just write our
// own implementation in libopenrct2 and spare the AOT implementation registration.
static Image ReadBitmap(std::istream& istream, IMAGE_FORMAT format)
static Image ReadBitmap(std::istream& istream, ImageFormat format)
{
auto buffer = ReadToVector(istream);
auto sdlStream = SDL_RWFromConstMem(buffer.data(), static_cast<int>(buffer.size()));
@@ -101,6 +101,6 @@ namespace OpenRCT2::Ui
void RegisterBitmapReader()
{
Imaging::SetReader(IMAGE_FORMAT::BITMAP, ReadBitmap);
Imaging::SetReader(ImageFormat::bitmap, ReadBitmap);
}
} // namespace OpenRCT2::Ui
@@ -358,9 +358,9 @@ public:
return &_bitsDPI;
}
DRAWING_ENGINE_FLAGS GetFlags() override
DrawingEngineFlags GetFlags() override
{
return DEF_NONE;
return {};
}
void InvalidateImage(uint32_t image) override
+22 -22
View File
@@ -122,7 +122,7 @@ namespace OpenRCT2
GameHandleInputMouse(screenCoords, state);
}
if (_inputFlags & INPUT_FLAG_5)
if (gInputFlags.has(InputFlag::unk5))
{
GameHandleInputMouse(screenCoords, state);
}
@@ -392,11 +392,11 @@ namespace OpenRCT2
break;
}
if (!InputTestFlag(INPUT_FLAG_4))
if (!gInputFlags.has(InputFlag::unk4))
break;
if (w->classification != _dragWidget.window_classification || w->number != _dragWidget.window_number
|| !(_inputFlags & INPUT_FLAG_TOOL_ACTIVE))
|| !(gInputFlags.has(InputFlag::toolActive)))
{
break;
}
@@ -413,7 +413,7 @@ namespace OpenRCT2
_inputState = InputState::Reset;
if (_dragWidget.window_number == w->number)
{
if ((_inputFlags & INPUT_FLAG_TOOL_ACTIVE))
if (gInputFlags.has(InputFlag::toolActive))
{
w = windowMgr->FindByNumber(
gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
@@ -422,7 +422,7 @@ namespace OpenRCT2
w->OnToolUp(gCurrentToolWidget.widget_index, screenCoords);
}
}
else if (!(_inputFlags & INPUT_FLAG_4))
else if (!gInputFlags.has(InputFlag::unk4))
{
ViewportInteractionLeftClick(screenCoords);
}
@@ -552,7 +552,7 @@ namespace OpenRCT2
}
WindowUnfollowSprite(w);
// gInputFlags |= INPUT_FLAG_5;
// gInputFlags.set(InputFlag::unk5);
}
static void InputViewportDragContinue()
@@ -1084,12 +1084,12 @@ namespace OpenRCT2
gInputDragLast = screenCoords;
_dragWidget.window_classification = windowClass;
_dragWidget.window_number = windowNumber;
if (_inputFlags & INPUT_FLAG_TOOL_ACTIVE)
if (gInputFlags.has(InputFlag::toolActive))
{
w = windowMgr->FindByNumber(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
if (w != nullptr)
{
InputSetFlag(INPUT_FLAG_4, true);
gInputFlags.set(InputFlag::unk4);
w->OnToolDown(gCurrentToolWidget.widget_index, screenCoords);
}
}
@@ -1130,7 +1130,7 @@ namespace OpenRCT2
gPressedWidget.window_classification = windowClass;
gPressedWidget.window_number = windowNumber;
gPressedWidget.widget_index = widgetIndex;
_inputFlags |= INPUT_FLAG_WIDGET_PRESSED;
gInputFlags.set(InputFlag::widgetPressed);
_inputState = InputState::WidgetPressed;
_clickRepeatTicks = gCurrentRealTimeTicks;
@@ -1163,7 +1163,7 @@ namespace OpenRCT2
switch (window->widgets[widgetId].type)
{
case WindowWidgetType::Viewport:
if (!(_inputFlags & INPUT_FLAG_TOOL_ACTIVE))
if (!gInputFlags.has(InputFlag::toolActive))
{
if (ViewportInteractionLeftOver(screenCoords))
{
@@ -1225,7 +1225,7 @@ namespace OpenRCT2
*/
void ProcessMouseTool(const ScreenCoordsXY& screenCoords)
{
if (_inputFlags & INPUT_FLAG_TOOL_ACTIVE)
if (gInputFlags.has(InputFlag::toolActive))
{
auto* windowMgr = GetWindowManager();
WindowBase* w = windowMgr->FindByNumber(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
@@ -1314,7 +1314,7 @@ namespace OpenRCT2
}
}
if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED)
if (gInputFlags.has(InputFlag::widgetPressed))
{
if (_inputState == InputState::DropdownActive)
{
@@ -1324,7 +1324,7 @@ namespace OpenRCT2
return;
}
_inputFlags |= INPUT_FLAG_WIDGET_PRESSED;
gInputFlags.set(InputFlag::widgetPressed);
windowMgr->InvalidateWidgetByNumber(cursor_w_class, cursor_w_number, widgetIndex);
return;
case MouseState::LeftRelease:
@@ -1356,11 +1356,11 @@ namespace OpenRCT2
else
{
dropdown_index = -1;
if (_inputFlags & INPUT_FLAG_DROPDOWN_STAY_OPEN)
if (gInputFlags.has(InputFlag::dropdownStayOpen))
{
if (!(_inputFlags & INPUT_FLAG_DROPDOWN_MOUSE_UP))
if (!gInputFlags.has(InputFlag::dropdownMouseUp))
{
_inputFlags |= INPUT_FLAG_DROPDOWN_MOUSE_UP;
gInputFlags.set(InputFlag::dropdownMouseUp);
return;
}
}
@@ -1377,9 +1377,9 @@ namespace OpenRCT2
else
{
cursor_w = windowMgr->FindByNumber(cursor_w_class, cursor_w_number);
if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED)
if (gInputFlags.has(InputFlag::widgetPressed))
{
_inputFlags &= ~INPUT_FLAG_WIDGET_PRESSED;
gInputFlags.unset(InputFlag::widgetPressed);
windowMgr->InvalidateWidgetByNumber(cursor_w_class, cursor_w_number, cursor_widgetIndex);
}
@@ -1439,9 +1439,9 @@ namespace OpenRCT2
if (_inputState != InputState::DropdownActive)
{
// Hold down widget and drag outside of area??
if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED)
if (gInputFlags.has(InputFlag::widgetPressed))
{
_inputFlags &= ~INPUT_FLAG_WIDGET_PRESSED;
gInputFlags.unset(InputFlag::widgetPressed);
windowMgr->InvalidateWidgetByNumber(cursor_w_class, cursor_w_number, cursor_widgetIndex);
}
return;
@@ -1681,12 +1681,12 @@ namespace OpenRCT2
}
mainWindow->savedViewPos.x += dx;
_inputFlags |= INPUT_FLAG_VIEWPORT_SCROLLING;
gInputFlags.set(InputFlag::viewportScrolling);
}
if (scrollScreenCoords.y != 0)
{
mainWindow->savedViewPos.y += dy;
_inputFlags |= INPUT_FLAG_VIEWPORT_SCROLLING;
gInputFlags.set(InputFlag::viewportScrolling);
}
}
} // namespace OpenRCT2
+1 -1
View File
@@ -773,7 +773,7 @@ void ShortcutManager::RegisterDefaultShortcuts()
{
windowMgr->Close(*window);
}
else if (InputTestFlag(INPUT_FLAG_TOOL_ACTIVE))
else if (gInputFlags.has(InputFlag::toolActive))
{
ToolCancel();
}
@@ -465,7 +465,7 @@ namespace OpenRCT2::Ui
break;
}
if (!(InputTestFlag(INPUT_FLAG_6)) || !(InputTestFlag(INPUT_FLAG_TOOL_ACTIVE)))
if (!gInputFlags.has(InputFlag::unk6) || !gInputFlags.has(InputFlag::toolActive))
{
auto* windowMgr = GetWindowManager();
if (windowMgr->FindByClass(WindowClass::RideConstruction) == nullptr
+1 -1
View File
@@ -900,7 +900,7 @@ namespace OpenRCT2::Ui
if (InputGetState() == InputState::WidgetPressed || InputGetState() == InputState::DropdownActive)
{
if (!(InputTestFlag(INPUT_FLAG_WIDGET_PRESSED)))
if (!gInputFlags.has(InputFlag::widgetPressed))
return false;
if (gPressedWidget.window_classification != w.classification)
return false;
+1 -1
View File
@@ -273,7 +273,7 @@ namespace OpenRCT2
return;
// Check window cursor is over
if (!(InputTestFlag(INPUT_FLAG_5)))
if (!gInputFlags.has(InputFlag::unk5))
{
auto* windowMgr = GetWindowManager();
WindowBase* w = windowMgr->FindFromPoint(cursorState->position);
+1 -1
View File
@@ -317,7 +317,7 @@ namespace OpenRCT2::Scripting
}
case PixelDataKind::Png:
{
auto imageFormat = pixelData.Palette == PixelDataPaletteKind::Keep ? IMAGE_FORMAT::PNG : IMAGE_FORMAT::PNG_32;
auto imageFormat = pixelData.Palette == PixelDataPaletteKind::Keep ? ImageFormat::png : ImageFormat::png32;
auto palette = pixelData.Palette == PixelDataPaletteKind::Keep ? Palette::KeepIndices : Palette::OpenRCT2;
auto importMode = getImportModeFromPalette(pixelData.Palette);
auto pngData = DukGetDataFromBufferLikeObject(pixelData.Data);
+1 -1
View File
@@ -153,7 +153,7 @@ namespace OpenRCT2::Scripting
std::shared_ptr<ScTool> tool_get() const
{
if (InputTestFlag(INPUT_FLAG_TOOL_ACTIVE))
if (gInputFlags.has(InputFlag::toolActive))
{
return std::make_shared<ScTool>(_scriptEngine.GetContext());
}
+1 -1
View File
@@ -401,7 +401,7 @@ namespace OpenRCT2::Ui::Windows
ShowGridlines();
auto* toolWindow = ContextOpenWindow(WindowClass::ClearScenery);
ToolSet(*toolWindow, WIDX_BACKGROUND, Tool::bulldozer);
InputSetFlag(INPUT_FLAG_6, true);
gInputFlags.set(InputFlag::unk6);
}
}
} // namespace OpenRCT2::Ui::Windows
+4 -4
View File
@@ -357,9 +357,9 @@ namespace OpenRCT2::Ui::Windows
const ScreenCoordsXY& screenPos, int32_t extray, ColourWithFlags colour, uint8_t customItemHeight, uint8_t flags,
size_t num_items, int32_t width, size_t prefRowsPerColumn)
{
InputSetFlag(static_cast<INPUT_FLAGS>(INPUT_FLAG_DROPDOWN_STAY_OPEN | INPUT_FLAG_DROPDOWN_MOUSE_UP), false);
gInputFlags.unset(InputFlag::dropdownStayOpen, InputFlag::dropdownMouseUp);
if (flags & Dropdown::Flag::StayOpen || Config::Get().interface.TouchEnhancements)
InputSetFlag(INPUT_FLAG_DROPDOWN_STAY_OPEN, true);
gInputFlags.set(InputFlag::dropdownStayOpen);
WindowDropdownClose();
@@ -392,9 +392,9 @@ namespace OpenRCT2::Ui::Windows
int32_t x, int32_t y, int32_t extray, ColourWithFlags colour, uint8_t flags, int32_t numItems, int32_t itemWidth,
int32_t itemHeight, int32_t numColumns)
{
InputSetFlag(static_cast<INPUT_FLAGS>(INPUT_FLAG_DROPDOWN_STAY_OPEN | INPUT_FLAG_DROPDOWN_MOUSE_UP), false);
gInputFlags.unset(InputFlag::dropdownStayOpen, InputFlag::dropdownMouseUp);
if (flags & Dropdown::Flag::StayOpen || Config::Get().interface.TouchEnhancements)
InputSetFlag(INPUT_FLAG_DROPDOWN_STAY_OPEN, true);
gInputFlags.set(InputFlag::dropdownStayOpen);
// Close existing dropdown
WindowDropdownClose();
@@ -187,7 +187,7 @@ namespace OpenRCT2::Ui::Windows
#pragma region Widgets
enum WINDOW_EDITOR_OBJECT_SELECTION_WIDGET_IDX
enum WindowEditorObjectSelectionWidgetIndex
{
WIDX_BACKGROUND,
WIDX_TITLE,
@@ -253,7 +253,7 @@ namespace OpenRCT2::Ui::Windows
pressed_widgets |= 1LL << WIDX_TAB;
ToolSet(*this, WIDX_LIST, Tool::entranceDown);
InputSetFlag(INPUT_FLAG_6, true);
gInputFlags.set(InputFlag::unk6);
}
void OnMouseUp(WidgetIndex widgetIndex) override
+3 -3
View File
@@ -222,7 +222,7 @@ namespace OpenRCT2::Ui::Windows
ToolCancel();
_footpathConstructionMode = PATH_CONSTRUCTION_MODE_LAND;
ToolSet(*this, WIDX_CONSTRUCT_ON_LAND, Tool::pathDown);
InputSetFlag(INPUT_FLAG_6, true);
gInputFlags.set(InputFlag::unk6);
_footpathErrorOccured = false;
WindowFootpathSetEnabledAndPressedWidgets();
@@ -333,7 +333,7 @@ namespace OpenRCT2::Ui::Windows
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
_footpathConstructionMode = PATH_CONSTRUCTION_MODE_LAND;
ToolSet(*this, WIDX_CONSTRUCT_ON_LAND, Tool::pathDown);
InputSetFlag(INPUT_FLAG_6, true);
gInputFlags.set(InputFlag::unk6);
_footpathErrorOccured = false;
WindowFootpathSetEnabledAndPressedWidgets();
break;
@@ -350,7 +350,7 @@ namespace OpenRCT2::Ui::Windows
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
_footpathConstructionMode = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL_TOOL;
ToolSet(*this, WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL, Tool::crosshair);
InputSetFlag(INPUT_FLAG_6, true);
gInputFlags.set(InputFlag::unk6);
_footpathErrorOccured = false;
WindowFootpathSetEnabledAndPressedWidgets();
break;
+1 -1
View File
@@ -890,7 +890,7 @@ namespace OpenRCT2::Ui::Windows
ShowGridlines();
auto* toolWindow = ContextOpenWindow(WindowClass::Land);
ToolSet(*toolWindow, WIDX_BACKGROUND, Tool::digDown);
InputSetFlag(INPUT_FLAG_6, true);
gInputFlags.set(InputFlag::unk6);
}
}
} // namespace OpenRCT2::Ui::Windows
+1 -1
View File
@@ -108,7 +108,7 @@ namespace OpenRCT2::Ui::Windows
_landRightsMode = mode;
ToolSet(*this, widgetIndex, Tool::upArrow);
InputSetFlag(INPUT_FLAG_6, true);
gInputFlags.set(InputFlag::unk6);
if (kLandRightsVisibleByMode[EnumValue(mode)])
ShowLandRights();
+1 -1
View File
@@ -86,7 +86,7 @@ namespace OpenRCT2::Ui::Windows
// Check for cursor movement
_cursorHoldDuration++;
if (abs(cursorChange.x) > 5 || abs(cursorChange.y) > 5 || (InputTestFlag(INPUT_FLAG_5))
if (abs(cursorChange.x) > 5 || abs(cursorChange.y) > 5 || (gInputFlags.has(InputFlag::unk5))
|| InputGetState() == InputState::ViewportRight)
_cursorHoldDuration = 0;
+1 -1
View File
@@ -316,7 +316,7 @@ namespace OpenRCT2::Ui::Windows
: ENTRANCE_TYPE_RIDE_EXIT;
gRideEntranceExitPlaceRideIndex = rideId;
gRideEntranceExitPlaceStationIndex = StationIndex::FromUnderlying(0);
InputSetFlag(INPUT_FLAG_6, true);
gInputFlags.set(InputFlag::unk6);
RideConstructionInvalidateCurrentTrack();
+3 -3
View File
@@ -838,8 +838,8 @@ namespace OpenRCT2::Ui::Windows
Config::Get().general.FullscreenHeight = resolution.Height;
if (Config::Get().general.FullscreenMode
== static_cast<int32_t>(OpenRCT2::Ui::FULLSCREEN_MODE::FULLSCREEN))
ContextSetFullscreenMode(static_cast<int32_t>(OpenRCT2::Ui::FULLSCREEN_MODE::FULLSCREEN));
== static_cast<int32_t>(OpenRCT2::Ui::FullscreenMode::fullscreen))
ContextSetFullscreenMode(static_cast<int32_t>(OpenRCT2::Ui::FullscreenMode::fullscreen));
Config::Save();
GfxInvalidateScreen();
@@ -879,7 +879,7 @@ namespace OpenRCT2::Ui::Windows
ft.Add<uint16_t>(static_cast<uint16_t>(Config::Get().general.FullscreenHeight));
// Disable resolution dropdown on "Windowed" and "Fullscreen (desktop)"
if (Config::Get().general.FullscreenMode != static_cast<int32_t>(OpenRCT2::Ui::FULLSCREEN_MODE::FULLSCREEN))
if (Config::Get().general.FullscreenMode != static_cast<int32_t>(OpenRCT2::Ui::FullscreenMode::fullscreen))
{
disabled_widgets |= (1uLL << WIDX_RESOLUTION_DROPDOWN);
disabled_widgets |= (1uLL << WIDX_RESOLUTION);
+1 -1
View File
@@ -251,7 +251,7 @@ namespace OpenRCT2::Ui::Windows
if (!ToolSet(*this, 0, Tool::walkDown))
{
ShowGridlines();
InputSetFlag(INPUT_FLAG_6, true);
gInputFlags.set(InputFlag::unk6);
SetPatrolAreaToRender(_staffId);
GfxInvalidateScreen();
}
+3 -3
View File
@@ -2444,7 +2444,7 @@ namespace OpenRCT2::Ui::Windows
gRideEntranceExitPlaceType = ENTRANCE_TYPE_RIDE_ENTRANCE;
gRideEntranceExitPlaceRideIndex = _currentRideIndex;
gRideEntranceExitPlaceStationIndex = StationIndex::FromUnderlying(0);
InputSetFlag(INPUT_FLAG_6, true);
gInputFlags.set(InputFlag::unk6);
RideConstructionInvalidateCurrentTrack();
if (_rideConstructionState != RideConstructionState::EntranceExit)
{
@@ -2470,7 +2470,7 @@ namespace OpenRCT2::Ui::Windows
gRideEntranceExitPlaceType = ENTRANCE_TYPE_RIDE_EXIT;
gRideEntranceExitPlaceRideIndex = _currentRideIndex;
gRideEntranceExitPlaceStationIndex = StationIndex::FromUnderlying(0);
InputSetFlag(INPUT_FLAG_6, true);
gInputFlags.set(InputFlag::unk6);
RideConstructionInvalidateCurrentTrack();
if (_rideConstructionState != RideConstructionState::EntranceExit)
{
@@ -3671,7 +3671,7 @@ namespace OpenRCT2::Ui::Windows
if (w != nullptr)
{
ToolSet(*w, WIDX_CONSTRUCT, Tool::crosshair);
InputSetFlag(INPUT_FLAG_6, true);
gInputFlags.set(InputFlag::unk6);
_trackPlaceCtrlState = false;
_trackPlaceShiftState = false;
}
+1 -1
View File
@@ -3300,7 +3300,7 @@ namespace OpenRCT2::Ui::Windows
{
auto* toolWindow = ContextOpenWindow(WindowClass::Scenery);
ToolSet(*toolWindow, WIDX_SCENERY_BACKGROUND, Tool::arrow);
InputSetFlag(INPUT_FLAG_6, true);
gInputFlags.set(InputFlag::unk6);
}
}
} // namespace OpenRCT2::Ui::Windows
+1 -1
View File
@@ -150,7 +150,7 @@ namespace OpenRCT2::Ui::Windows
gTooltipCloseTimeout = 0;
gTooltipWidget.window_classification = WindowClass::Null;
InputSetState(InputState::Normal);
InputSetFlag(INPUT_FLAG_4, false);
gInputFlags.unset(InputFlag::unk4);
}
void WindowTooltipShow(const OpenRCT2String& message, ScreenCoordsXY screenCoords)
+1 -1
View File
@@ -104,7 +104,7 @@ namespace OpenRCT2::Ui::Windows
SetWidgets(_trackPlaceWidgets);
WindowInitScrollWidgets(*this);
ToolSet(*this, WIDX_PRICE, Tool::crosshair);
InputSetFlag(INPUT_FLAG_6, true);
gInputFlags.set(InputFlag::unk6);
WindowPushOthersRight(*this);
ShowGridlines();
_miniPreview.resize(TRACK_MINI_PREVIEW_SIZE);
+1 -1
View File
@@ -29,7 +29,7 @@
namespace OpenRCT2::Ui::Windows
{
enum WINDOW_TRANSPARENCY_WIDGET_IDX
enum WindowTransparencyWidgetIndex
{
WIDX_BACKGROUND,
WIDX_TITLE,
+1 -1
View File
@@ -447,7 +447,7 @@ namespace OpenRCT2::Ui::Windows
ShowGridlines();
auto* toolWindow = ContextOpenWindow(WindowClass::Water);
ToolSet(*toolWindow, WIDX_BACKGROUND, Tool::waterDown);
InputSetFlag(INPUT_FLAG_6, true);
gInputFlags.set(InputFlag::unk6);
}
}
} // namespace OpenRCT2::Ui::Windows
+2 -2
View File
@@ -42,7 +42,7 @@ void AssetPack::SetEnabled(bool value)
void AssetPack::Fetch()
{
auto archive = Zip::Open(Path.u8string(), ZIP_ACCESS::READ);
auto archive = Zip::Open(Path.u8string(), ZipAccess::read);
if (!archive->Exists(ManifestFileName))
{
throw std::runtime_error("Manifest does not exist.");
@@ -160,7 +160,7 @@ public:
void AssetPack::Load()
{
auto path = Path.u8string();
auto archive = Zip::Open(path, ZIP_ACCESS::READ);
auto archive = Zip::Open(path, ZipAccess::read);
if (!archive->Exists(ManifestFileName))
{
throw std::runtime_error("Manifest does not exist.");
+3 -3
View File
@@ -216,7 +216,7 @@ static bool SpriteImageExport(const G1Element& spriteElement, u8string_view outP
image.Stride = dpi.LineStride();
image.Palette = StandardPalette;
image.Pixels = std::vector<uint8_t>(pixels8, pixels8 + pixelsLen);
Imaging::WriteToFile(outPath, image, IMAGE_FORMAT::PNG);
Imaging::WriteToFile(outPath, image, ImageFormat::png);
return true;
}
catch (const std::exception& e)
@@ -230,10 +230,10 @@ static std::optional<ImageImporter::ImportResult> SpriteImageImport(u8string_vie
{
try
{
auto format = IMAGE_FORMAT::PNG_32;
auto format = ImageFormat::png32;
if (meta.palette == Palette::KeepIndices)
{
format = IMAGE_FORMAT::PNG;
format = ImageFormat::png;
}
ImageImporter importer;
+1 -1
View File
@@ -1663,7 +1663,7 @@ void ContextTriggerResize()
void ContextSetFullscreenMode(int32_t mode)
{
return GetContext()->GetUiContext()->SetFullscreenMode(static_cast<FULLSCREEN_MODE>(mode));
return GetContext()->GetUiContext()->SetFullscreenMode(static_cast<FullscreenMode>(mode));
}
void ContextRecreateWindow()
+6 -6
View File
@@ -417,7 +417,7 @@ void GameNotifyMapChange()
auto& scriptEngine = GetContext()->GetScriptEngine();
auto& hookEngine = scriptEngine.GetHookEngine();
hookEngine.Call(HOOK_TYPE::MAP_CHANGE, false);
hookEngine.Call(HookType::mapChange, false);
_mapChangedExpected = true;
#endif
}
@@ -429,7 +429,7 @@ void GameNotifyMapChanged()
auto& scriptEngine = GetContext()->GetScriptEngine();
auto& hookEngine = scriptEngine.GetHookEngine();
hookEngine.Call(HOOK_TYPE::MAP_CHANGED, false);
hookEngine.Call(HookType::mapChanged, false);
_mapChangedExpected = false;
#endif
}
@@ -677,9 +677,9 @@ void GameLoadOrQuitNoSavePrompt()
auto loadOrQuitAction = LoadOrQuitAction(LoadOrQuitModes::CloseSavePrompt);
GameActions::Execute(&loadOrQuitAction);
ToolCancel();
if (InputTestFlag(INPUT_FLAG_5))
if (gInputFlags.has(InputFlag::unk5))
{
InputSetFlag(INPUT_FLAG_5, false);
gInputFlags.unset(InputFlag::unk5);
}
GameResetSpeed();
gFirstTimeSaving = true;
@@ -757,9 +757,9 @@ void PrepareMapForSave()
#ifdef ENABLE_SCRIPTING
auto& scriptEngine = GetContext()->GetScriptEngine();
auto& hookEngine = scriptEngine.GetHookEngine();
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HOOK_TYPE::MAP_SAVE))
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::mapSave))
{
hookEngine.Call(OpenRCT2::Scripting::HOOK_TYPE::MAP_SAVE, false);
hookEngine.Call(OpenRCT2::Scripting::HookType::mapSave, false);
}
#endif
}
+5 -5
View File
@@ -190,9 +190,9 @@ namespace OpenRCT2
{
if (InputGetState() == InputState::Reset || InputGetState() == InputState::Normal)
{
if (InputTestFlag(INPUT_FLAG_VIEWPORT_SCROLLING))
if (gInputFlags.has(InputFlag::viewportScrolling))
{
InputSetFlag(INPUT_FLAG_VIEWPORT_SCROLLING, false);
gInputFlags.unset(InputFlag::viewportScrolling);
break;
}
}
@@ -211,7 +211,7 @@ namespace OpenRCT2
if (!gOpenRCT2Headless)
{
InputSetFlag(INPUT_FLAG_VIEWPORT_SCROLLING, false);
gInputFlags.unset(InputFlag::viewportScrolling);
}
// Always perform autosave check, even when paused
@@ -351,11 +351,11 @@ namespace OpenRCT2
#ifdef ENABLE_SCRIPTING
auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine();
hookEngine.Call(HOOK_TYPE::INTERVAL_TICK, true);
hookEngine.Call(HookType::intervalTick, true);
if (day != gameState.date.GetDay())
{
hookEngine.Call(HOOK_TYPE::INTERVAL_DAY, true);
hookEngine.Call(HookType::intervalDay, true);
}
#endif
+1 -23
View File
@@ -15,7 +15,7 @@
namespace OpenRCT2
{
InputState _inputState;
uint8_t _inputFlags;
InputFlags gInputFlags;
WidgetRef gHoverWidget;
WidgetRef gPressedWidget;
@@ -40,28 +40,6 @@ namespace OpenRCT2
ContextInputHandleKeyboard(false);
}
void InputSetFlag(INPUT_FLAGS flag, bool on)
{
if (on)
{
_inputFlags |= flag;
}
else
{
_inputFlags &= ~flag;
}
}
bool InputTestFlag(INPUT_FLAGS flag)
{
return _inputFlags & flag;
}
void InputResetFlags()
{
_inputFlags = 0;
}
void InputSetState(InputState state)
{
_inputState = state;
+15 -17
View File
@@ -9,34 +9,36 @@
#pragma once
#include "core/FlagHolder.hpp"
#include "interface/Window.h"
namespace OpenRCT2
{
enum INPUT_FLAGS
enum InputFlag
{
INPUT_FLAG_WIDGET_PRESSED = (1 << 0),
widgetPressed,
// The dropdown can stay open if the mouse is released, set on flag Dropdown::Flag::StayOpen
INPUT_FLAG_DROPDOWN_STAY_OPEN = (1 << 1),
// The dropdown can stay open if the mouse is released, set on flag Dropdown::Flag::StayOpen.
dropdownStayOpen,
// The mouse has been released and the dropdown is still open
// INPUT_FLAG_DROPDOWN_STAY_OPEN is already set if this happens
INPUT_FLAG_DROPDOWN_MOUSE_UP = (1 << 2),
// The mouse has been released and the dropdown is still open.
// InputFlag::dropdownStayOpen is already set if this happens.
dropdownMouseUp,
INPUT_FLAG_TOOL_ACTIVE = (1 << 3),
toolActive,
// Left click on a viewport
INPUT_FLAG_4 = (1 << 4),
unk4,
INPUT_FLAG_5 = (1 << 5),
unk5,
// Some of the map tools (clear, footpath, scenery)
// never read as far as I know.
INPUT_FLAG_6 = (1 << 6),
unk6,
INPUT_FLAG_VIEWPORT_SCROLLING = (1 << 7)
viewportScrolling,
};
using InputFlags = FlagHolder<uint8_t, InputFlag>;
enum class InputState
{
@@ -61,16 +63,12 @@ namespace OpenRCT2
// TODO: Move to openrct2-ui and make static again
extern InputState _inputState;
extern uint8_t _inputFlags;
extern InputFlags gInputFlags;
extern uint32_t _tooltipNotShownTimeout;
void TitleHandleKeyboardInput();
void GameHandleKeyboardInput();
void InputSetFlag(INPUT_FLAGS flag, bool on);
bool InputTestFlag(INPUT_FLAGS flag);
void InputResetFlags();
void InputSetState(InputState state);
InputState InputGetState();
+3 -3
View File
@@ -227,9 +227,9 @@ std::unique_ptr<IPlatformEnvironment> OpenRCT2::CreatePlatformEnvironment()
// Set default paths
std::string basePaths[kDirBaseCount];
basePaths[EnumValue(DirBase::openrct2)] = Platform::GetInstallPath();
basePaths[EnumValue(DirBase::user)] = Path::Combine(Platform::GetFolderPath(SPECIAL_FOLDER::USER_DATA), subDirectory);
basePaths[EnumValue(DirBase::config)] = Path::Combine(Platform::GetFolderPath(SPECIAL_FOLDER::USER_CONFIG), subDirectory);
basePaths[EnumValue(DirBase::cache)] = Path::Combine(Platform::GetFolderPath(SPECIAL_FOLDER::USER_CACHE), subDirectory);
basePaths[EnumValue(DirBase::user)] = Path::Combine(Platform::GetFolderPath(SpecialFolder::userData), subDirectory);
basePaths[EnumValue(DirBase::config)] = Path::Combine(Platform::GetFolderPath(SpecialFolder::userConfig), subDirectory);
basePaths[EnumValue(DirBase::cache)] = Path::Combine(Platform::GetFolderPath(SpecialFolder::userCache), subDirectory);
basePaths[EnumValue(DirBase::documentation)] = Platform::GetDocsPath();
// Override paths that have been specified via the command line
+2 -2
View File
@@ -479,7 +479,7 @@ bool GameAction::LocationValid(const CoordsXY& coords) const
return false;
#ifdef ENABLE_SCRIPTING
auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine();
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HOOK_TYPE::ACTION_LOCATION))
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::actionLocation))
{
auto ctx = GetContext()->GetScriptEngine().GetContext();
@@ -496,7 +496,7 @@ bool GameAction::LocationValid(const CoordsXY& coords) const
// Call the subscriptions
auto e = obj.Take();
hookEngine.Call(OpenRCT2::Scripting::HOOK_TYPE::ACTION_LOCATION, e, true);
hookEngine.Call(OpenRCT2::Scripting::HookType::actionLocation, e, true);
auto scriptResult = OpenRCT2::Scripting::AsOrDefault(e["result"], true);
+1 -1
View File
@@ -147,7 +147,7 @@ GameActions::Result PeepPickupAction::Execute() const
if (_owner == NetworkGetCurrentPlayerId())
{
// prevent tool_cancel()
InputSetFlag(INPUT_FLAG_TOOL_ACTIVE, false);
gInputFlags.unset(InputFlag::toolActive);
}
}
+2 -2
View File
@@ -755,7 +755,7 @@ namespace OpenRCT2::Config
}
}
auto discordPath = Platform::GetFolderPath(SPECIAL_FOLDER::RCT2_DISCORD);
auto discordPath = Platform::GetFolderPath(SpecialFolder::rct2Discord);
if (!discordPath.empty() && Platform::OriginalGameDataExists(discordPath))
{
return discordPath;
@@ -777,7 +777,7 @@ namespace OpenRCT2::Config
desc.Filters.emplace_back(LanguageGetString(STR_GOG_INSTALLER), "*.exe");
desc.Filters.emplace_back(LanguageGetString(STR_ALL_FILES), "*");
const auto userHomePath = Platform::GetFolderPath(SPECIAL_FOLDER::USER_HOME);
const auto userHomePath = Platform::GetFolderPath(SpecialFolder::userHome);
desc.InitialDirectory = userHomePath;
return ContextOpenCommonFileDialog(desc);
+11 -11
View File
@@ -29,15 +29,15 @@
using namespace OpenRCT2;
enum class DIRECTORY_CHILD_TYPE
enum class DirectoryChildType
{
DC_DIRECTORY,
DC_FILE,
directory,
file,
};
struct DirectoryChild
{
DIRECTORY_CHILD_TYPE Type;
DirectoryChildType Type;
std::string Name;
// Files only
@@ -122,7 +122,7 @@ public:
else
{
const DirectoryChild* child = &state->Listing[state->Index];
if (child->Type == DIRECTORY_CHILD_TYPE::DC_DIRECTORY)
if (child->Type == DirectoryChildType::directory)
{
if (_recurse)
{
@@ -233,11 +233,11 @@ private:
result.Name = String::toUtf8(child->cFileName);
if (child->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
result.Type = DIRECTORY_CHILD_TYPE::DC_DIRECTORY;
result.Type = DirectoryChildType::directory;
}
else
{
result.Type = DIRECTORY_CHILD_TYPE::DC_FILE;
result.Type = DirectoryChildType::file;
result.Size = (static_cast<uint64_t>(child->nFileSizeHigh) << 32uLL) | static_cast<uint64_t>(child->nFileSizeLow);
result.LastModified = (static_cast<uint64_t>(child->ftLastWriteTime.dwHighDateTime) << 32uLL)
| static_cast<uint64_t>(child->ftLastWriteTime.dwLowDateTime);
@@ -289,11 +289,11 @@ private:
result.Name = std::string(node->d_name);
if (node->d_type == DT_DIR)
{
result.Type = DIRECTORY_CHILD_TYPE::DC_DIRECTORY;
result.Type = DirectoryChildType::directory;
}
else
{
result.Type = DIRECTORY_CHILD_TYPE::DC_FILE;
result.Type = DirectoryChildType::file;
// Get the full path of the file
auto path = Path::Combine(directory, node->d_name);
@@ -307,7 +307,7 @@ private:
if (S_ISDIR(statInfo.st_mode))
{
result.Type = DIRECTORY_CHILD_TYPE::DC_DIRECTORY;
result.Type = DirectoryChildType::directory;
}
}
}
@@ -354,7 +354,7 @@ std::vector<std::string> Path::GetDirectories(const std::string& path)
std::vector<std::string> subDirectories;
for (const auto& c : children)
{
if (c.Type == DIRECTORY_CHILD_TYPE::DC_DIRECTORY)
if (c.Type == DirectoryChildType::directory)
{
subDirectories.push_back(c.Name);
}
+8 -8
View File
@@ -30,11 +30,11 @@ namespace OpenRCT2::Guard
static constexpr const utf8* kAssertionMessage = "An assertion failed, please report this to the OpenRCT2 developers.";
// The default behaviour when an assertion is raised.
static ASSERT_BEHAVIOUR _assertBehaviour =
static AssertBehaviour _assertBehaviour =
#ifdef _WIN32
ASSERT_BEHAVIOUR::MESSAGE_BOX
AssertBehaviour::messageBox
#else
ASSERT_BEHAVIOUR::CASSERT
AssertBehaviour::cAssert
#endif
;
@@ -45,12 +45,12 @@ namespace OpenRCT2::Guard
static void ForceCrash();
#endif
ASSERT_BEHAVIOUR GetAssertBehaviour()
AssertBehaviour GetAssertBehaviour()
{
return _assertBehaviour;
}
void SetAssertBehaviour(ASSERT_BEHAVIOUR behaviour)
void SetAssertBehaviour(AssertBehaviour behaviour)
{
_assertBehaviour = behaviour;
}
@@ -99,14 +99,14 @@ namespace OpenRCT2::Guard
switch (_assertBehaviour)
{
case ASSERT_BEHAVIOUR::ABORT:
case AssertBehaviour::abort:
abort();
default:
case ASSERT_BEHAVIOUR::CASSERT:
case AssertBehaviour::cAssert:
assert(false);
break;
#ifdef _WIN32
case ASSERT_BEHAVIOUR::MESSAGE_BOX:
case AssertBehaviour::messageBox:
{
// Show message box if we are not building for testing
auto buffer = CreateDialogAssertMessage(formattedMessage);
+6 -6
View File
@@ -16,11 +16,11 @@
#include <stdbool.h>
#include <string>
enum class ASSERT_BEHAVIOUR
enum class AssertBehaviour
{
ABORT,
CASSERT,
MESSAGE_BOX,
abort,
cAssert,
messageBox,
};
/**
@@ -28,8 +28,8 @@ enum class ASSERT_BEHAVIOUR
*/
namespace OpenRCT2::Guard
{
ASSERT_BEHAVIOUR GetAssertBehaviour();
void SetAssertBehaviour(ASSERT_BEHAVIOUR behaviour);
AssertBehaviour GetAssertBehaviour();
void SetAssertBehaviour(AssertBehaviour behaviour);
void Assert(bool expression, const std::source_location& location = std::source_location::current());
void Assert(bool expression, const char* message, ...);
+17 -17
View File
@@ -36,7 +36,7 @@ namespace OpenRCT2::Imaging
{
static constexpr auto kExceptionImageFormatUnknown = "Unknown image format.";
static std::unordered_map<IMAGE_FORMAT, ImageReaderFunc> _readerImplementations;
static std::unordered_map<ImageFormat, ImageReaderFunc> _readerImplementations;
static void PngReadData(png_structp png_ptr, png_bytep data, png_size_t length)
{
@@ -259,22 +259,22 @@ namespace OpenRCT2::Imaging
}
}
IMAGE_FORMAT GetImageFormatFromPath(std::string_view path)
ImageFormat GetImageFormatFromPath(std::string_view path)
{
if (String::endsWith(path, ".png", true))
{
return IMAGE_FORMAT::PNG;
return ImageFormat::png;
}
if (String::endsWith(path, ".bmp", true))
{
return IMAGE_FORMAT::BITMAP;
return ImageFormat::bitmap;
}
return IMAGE_FORMAT::UNKNOWN;
return ImageFormat::unknown;
}
static ImageReaderFunc GetReader(IMAGE_FORMAT format)
static ImageReaderFunc GetReader(ImageFormat format)
{
auto result = _readerImplementations.find(format);
if (result != _readerImplementations.end())
@@ -284,20 +284,20 @@ namespace OpenRCT2::Imaging
return {};
}
void SetReader(IMAGE_FORMAT format, ImageReaderFunc impl)
void SetReader(ImageFormat format, ImageReaderFunc impl)
{
_readerImplementations[format] = impl;
}
static Image ReadFromStream(std::istream& istream, IMAGE_FORMAT format)
static Image ReadFromStream(std::istream& istream, ImageFormat format)
{
switch (format)
{
case IMAGE_FORMAT::PNG:
case ImageFormat::png:
return ReadPng(istream, false);
case IMAGE_FORMAT::PNG_32:
case ImageFormat::png32:
return ReadPng(istream, true);
case IMAGE_FORMAT::AUTOMATIC:
case ImageFormat::automatic:
throw std::invalid_argument("format can not be automatic.");
default:
{
@@ -311,11 +311,11 @@ namespace OpenRCT2::Imaging
}
}
Image ReadFromFile(std::string_view path, IMAGE_FORMAT format)
Image ReadFromFile(std::string_view path, ImageFormat format)
{
switch (format)
{
case IMAGE_FORMAT::AUTOMATIC:
case ImageFormat::automatic:
return ReadFromFile(path, GetImageFormatFromPath(path));
default:
{
@@ -325,20 +325,20 @@ namespace OpenRCT2::Imaging
}
}
Image ReadFromBuffer(const std::vector<uint8_t>& buffer, IMAGE_FORMAT format)
Image ReadFromBuffer(const std::vector<uint8_t>& buffer, ImageFormat format)
{
ivstream<uint8_t> istream(buffer);
return ReadFromStream(istream, format);
}
void WriteToFile(std::string_view path, const Image& image, IMAGE_FORMAT format)
void WriteToFile(std::string_view path, const Image& image, ImageFormat format)
{
switch (format)
{
case IMAGE_FORMAT::AUTOMATIC:
case ImageFormat::automatic:
WriteToFile(path, image, GetImageFormatFromPath(path));
break;
case IMAGE_FORMAT::PNG:
case ImageFormat::png:
{
#ifndef __EMSCRIPTEN__
std::ofstream fs(fs::u8path(path), std::ios::binary);
+12 -12
View File
@@ -20,13 +20,13 @@
struct DrawPixelInfo;
enum class IMAGE_FORMAT
enum class ImageFormat
{
UNKNOWN,
AUTOMATIC, // Automatically detect from file extension
BITMAP,
PNG,
PNG_32, // Force load to 32bpp buffer
unknown,
automatic, // Automatically detect from file extension
bitmap,
png,
png32, // Force load to 32bpp buffer
};
struct Image
@@ -42,14 +42,14 @@ struct Image
uint32_t Stride{};
};
using ImageReaderFunc = std::function<Image(std::istream&, IMAGE_FORMAT)>;
using ImageReaderFunc = std::function<Image(std::istream&, ImageFormat)>;
namespace OpenRCT2::Imaging
{
IMAGE_FORMAT GetImageFormatFromPath(std::string_view path);
Image ReadFromFile(std::string_view path, IMAGE_FORMAT format = IMAGE_FORMAT::AUTOMATIC);
Image ReadFromBuffer(const std::vector<uint8_t>& buffer, IMAGE_FORMAT format = IMAGE_FORMAT::AUTOMATIC);
void WriteToFile(std::string_view path, const Image& image, IMAGE_FORMAT format = IMAGE_FORMAT::AUTOMATIC);
ImageFormat GetImageFormatFromPath(std::string_view path);
Image ReadFromFile(std::string_view path, ImageFormat format = ImageFormat::automatic);
Image ReadFromBuffer(const std::vector<uint8_t>& buffer, ImageFormat format = ImageFormat::automatic);
void WriteToFile(std::string_view path, const Image& image, ImageFormat format = ImageFormat::automatic);
void SetReader(IMAGE_FORMAT format, ImageReaderFunc impl);
void SetReader(ImageFormat format, ImageReaderFunc impl);
} // namespace OpenRCT2::Imaging
+5 -5
View File
@@ -70,14 +70,14 @@ class ZipArchive final : public IZipArchive
{
private:
zip_t* _zip;
ZIP_ACCESS _access;
ZipAccess _access;
std::vector<std::vector<uint8_t>> _writeBuffers;
public:
ZipArchive(std::string_view path, ZIP_ACCESS access)
ZipArchive(std::string_view path, ZipAccess access)
{
auto zipOpenMode = ZIP_RDONLY;
if (access == ZIP_ACCESS::WRITE)
if (access == ZipAccess::write)
{
zipOpenMode = ZIP_CREATE;
}
@@ -378,12 +378,12 @@ private:
namespace OpenRCT2::Zip
{
std::unique_ptr<IZipArchive> Open(std::string_view path, ZIP_ACCESS access)
std::unique_ptr<IZipArchive> Open(std::string_view path, ZipAccess access)
{
return std::make_unique<ZipArchive>(path, access);
}
std::unique_ptr<IZipArchive> TryOpen(std::string_view path, ZIP_ACCESS access)
std::unique_ptr<IZipArchive> TryOpen(std::string_view path, ZipAccess access)
{
std::unique_ptr<IZipArchive> result;
try
+5 -5
View File
@@ -49,14 +49,14 @@ struct IZipArchive
[[nodiscard]] bool Exists(std::string_view path) const;
};
enum class ZIP_ACCESS
enum class ZipAccess
{
READ,
WRITE,
read,
write,
};
namespace OpenRCT2::Zip
{
[[nodiscard]] std::unique_ptr<IZipArchive> Open(std::string_view path, ZIP_ACCESS zipAccess);
[[nodiscard]] std::unique_ptr<IZipArchive> TryOpen(std::string_view path, ZIP_ACCESS zipAccess);
[[nodiscard]] std::unique_ptr<IZipArchive> Open(std::string_view path, ZipAccess zipAccess);
[[nodiscard]] std::unique_ptr<IZipArchive> TryOpen(std::string_view path, ZipAccess zipAccess);
} // namespace OpenRCT2::Zip
+3 -3
View File
@@ -28,7 +28,7 @@ private:
jobject _zip;
public:
ZipArchive(std::string_view path, ZIP_ACCESS access)
ZipArchive(std::string_view path, ZipAccess access)
{
// retrieve the JNI environment.
JNIEnv* env = (JNIEnv*)SDL_AndroidGetJNIEnv();
@@ -139,12 +139,12 @@ public:
namespace OpenRCT2::Zip
{
std::unique_ptr<IZipArchive> Open(std::string_view path, ZIP_ACCESS access)
std::unique_ptr<IZipArchive> Open(std::string_view path, ZipAccess access)
{
return std::make_unique<ZipArchive>(path, access);
}
std::unique_ptr<IZipArchive> TryOpen(std::string_view path, ZIP_ACCESS access)
std::unique_ptr<IZipArchive> TryOpen(std::string_view path, ZipAccess access)
{
std::unique_ptr<IZipArchive> result;
try
+7 -7
View File
@@ -9,8 +9,9 @@
#pragma once
#include "./Weather.h"
#include "../core/FlagHolder.hpp"
#include "ColourPalette.h"
#include "Weather.h"
#include <memory>
#include <string>
@@ -24,20 +25,19 @@ enum class DrawingEngine : int32_t
Count,
};
enum DRAWING_ENGINE_FLAGS
enum DrawingEngineFlag
{
DEF_NONE = 0,
/**
* Whether or not the engine will only draw changed blocks of the screen each frame.
*/
DEF_DIRTY_OPTIMISATIONS = 1 << 0,
dirtyOptimisations,
/**
* The drawing engine is capable of processing the drawing in parallel.
*/
DEF_PARALLEL_DRAWING = 1 << 1,
parallelDrawing = 1 << 1,
};
using DrawingEngineFlags = FlagHolder<uint8_t, DrawingEngineFlag>;
struct DrawPixelInfo;
@@ -73,7 +73,7 @@ namespace OpenRCT2::Drawing
virtual IDrawingContext* GetDrawingContext() = 0;
virtual DrawPixelInfo* GetDrawingPixelInfo() = 0;
virtual DRAWING_ENGINE_FLAGS GetFlags() = 0;
virtual DrawingEngineFlags GetFlags() = 0;
virtual void InvalidateImage(uint32_t image) = 0;
};
+1 -1
View File
@@ -128,7 +128,7 @@ bool DrawingEngineHasDirtyOptimisations()
auto drawingEngine = GetDrawingEngine();
if (drawingEngine != nullptr)
{
result = (drawingEngine->GetFlags() & DEF_DIRTY_OPTIMISATIONS);
result = drawingEngine->GetFlags().has(DrawingEngineFlag::dirtyOptimisations);
}
return result;
}
+2 -2
View File
@@ -273,9 +273,9 @@ DrawPixelInfo* X8DrawingEngine::GetDrawingPixelInfo()
return &_bitsDPI;
}
DRAWING_ENGINE_FLAGS X8DrawingEngine::GetFlags()
DrawingEngineFlags X8DrawingEngine::GetFlags()
{
return static_cast<DRAWING_ENGINE_FLAGS>(DEF_DIRTY_OPTIMISATIONS | DEF_PARALLEL_DRAWING);
return { DrawingEngineFlag::dirtyOptimisations, DrawingEngineFlag::parallelDrawing };
}
void X8DrawingEngine::InvalidateImage([[maybe_unused]] uint32_t image)
+1 -1
View File
@@ -108,7 +108,7 @@ namespace OpenRCT2
std::string Screenshot() override;
IDrawingContext* GetDrawingContext() override;
DrawPixelInfo* GetDrawingPixelInfo() override;
DRAWING_ENGINE_FLAGS GetFlags() override;
DrawingEngineFlags GetFlags() override;
void InvalidateImage(uint32_t image) override;
DrawPixelInfo* GetDPI();
+2 -2
View File
@@ -7311,7 +7311,7 @@ Guest* Guest::Generate(const CoordsXYZ& coords)
#ifdef ENABLE_SCRIPTING
auto& hookEngine = OpenRCT2::GetContext()->GetScriptEngine().GetHookEngine();
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HOOK_TYPE::GUEST_GENERATION))
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::guestGeneration))
{
auto ctx = OpenRCT2::GetContext()->GetScriptEngine().GetContext();
@@ -7321,7 +7321,7 @@ Guest* Guest::Generate(const CoordsXYZ& coords)
// Call the subscriptions
auto e = obj.Take();
hookEngine.Call(OpenRCT2::Scripting::HOOK_TYPE::GUEST_GENERATION, e, true);
hookEngine.Call(OpenRCT2::Scripting::HookType::guestGeneration, e, true);
}
#endif
+1 -1
View File
@@ -65,7 +65,7 @@ static bool WriteDpiToFile(std::string_view path, const DrawPixelInfo& dpi, cons
image.Stride = dpi.LineStride();
image.Palette = palette;
image.Pixels = std::vector<uint8_t>(pixels8, pixels8 + pixelsLen);
Imaging::WriteToFile(path, image, IMAGE_FORMAT::PNG);
Imaging::WriteToFile(path, image, ImageFormat::png);
return true;
}
catch (const std::exception& e)
+2 -2
View File
@@ -102,7 +102,7 @@ namespace OpenRCT2
WindowInitAll();
// ?
InputResetFlags();
gInputFlags.clearAll();
InputSetState(InputState::Reset);
gPressedWidget.window_classification = WindowClass::Null;
gPickupPeepImage = ImageId();
@@ -1009,7 +1009,7 @@ namespace OpenRCT2
}
bool useParallelDrawing = false;
if (useMultithreading && (dpi.DrawingEngine->GetFlags() & DEF_PARALLEL_DRAWING))
if (useMultithreading && dpi.DrawingEngine->GetFlags().has(DrawingEngineFlag::parallelDrawing))
{
useParallelDrawing = true;
}
+7 -7
View File
@@ -629,7 +629,7 @@ static constexpr float kWindowScrollLocations[][2] = {
bool isToolActive(WindowClass cls)
{
return InputTestFlag(INPUT_FLAG_TOOL_ACTIVE) && gCurrentToolWidget.window_classification == cls;
return gInputFlags.has(InputFlag::toolActive) && gCurrentToolWidget.window_classification == cls;
}
bool isToolActive(WindowClass cls, rct_windownumber number)
@@ -662,7 +662,7 @@ static constexpr float kWindowScrollLocations[][2] = {
*/
bool ToolSet(const WindowBase& w, WidgetIndex widgetIndex, Tool tool)
{
if (InputTestFlag(INPUT_FLAG_TOOL_ACTIVE))
if (gInputFlags.has(InputFlag::toolActive))
{
if (w.classification == gCurrentToolWidget.window_classification && w.number == gCurrentToolWidget.window_number
&& widgetIndex == gCurrentToolWidget.widget_index)
@@ -674,9 +674,9 @@ static constexpr float kWindowScrollLocations[][2] = {
ToolCancel();
}
InputSetFlag(INPUT_FLAG_TOOL_ACTIVE, true);
InputSetFlag(INPUT_FLAG_4, false);
InputSetFlag(INPUT_FLAG_6, false);
gInputFlags.set(InputFlag::toolActive);
gInputFlags.unset(InputFlag::unk4);
gInputFlags.unset(InputFlag::unk6);
gCurrentToolId = tool;
gCurrentToolWidget.window_classification = w.classification;
gCurrentToolWidget.window_number = w.number;
@@ -690,9 +690,9 @@ static constexpr float kWindowScrollLocations[][2] = {
*/
void ToolCancel()
{
if (InputTestFlag(INPUT_FLAG_TOOL_ACTIVE))
if (gInputFlags.has(InputFlag::toolActive))
{
InputSetFlag(INPUT_FLAG_TOOL_ACTIVE, false);
gInputFlags.unset(InputFlag::toolActive);
MapInvalidateSelectionRect();
MapInvalidateMapSelectionTiles();
+8 -8
View File
@@ -1823,7 +1823,7 @@ static bool ProcessPlayerAuthenticatePluginHooks(
using namespace OpenRCT2::Scripting;
auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine();
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HOOK_TYPE::NETWORK_AUTHENTICATE))
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::networkAuthenticate))
{
auto ctx = GetContext()->GetScriptEngine().GetContext();
@@ -1836,7 +1836,7 @@ static bool ProcessPlayerAuthenticatePluginHooks(
auto e = eObj.Take();
// Call the subscriptions
hookEngine.Call(OpenRCT2::Scripting::HOOK_TYPE::NETWORK_AUTHENTICATE, e, false);
hookEngine.Call(OpenRCT2::Scripting::HookType::networkAuthenticate, e, false);
// Check if any hook has cancelled the join
if (AsOrDefault(e["cancel"], false))
@@ -1854,7 +1854,7 @@ static void ProcessPlayerJoinedPluginHooks(uint8_t playerId)
using namespace OpenRCT2::Scripting;
auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine();
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HOOK_TYPE::NETWORK_JOIN))
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::networkJoin))
{
auto ctx = GetContext()->GetScriptEngine().GetContext();
@@ -1864,7 +1864,7 @@ static void ProcessPlayerJoinedPluginHooks(uint8_t playerId)
auto e = eObj.Take();
// Call the subscriptions
hookEngine.Call(OpenRCT2::Scripting::HOOK_TYPE::NETWORK_JOIN, e, false);
hookEngine.Call(OpenRCT2::Scripting::HookType::networkJoin, e, false);
}
#endif
}
@@ -1875,7 +1875,7 @@ static void ProcessPlayerLeftPluginHooks(uint8_t playerId)
using namespace OpenRCT2::Scripting;
auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine();
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HOOK_TYPE::NETWORK_LEAVE))
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::networkLeave))
{
auto ctx = GetContext()->GetScriptEngine().GetContext();
@@ -1885,7 +1885,7 @@ static void ProcessPlayerLeftPluginHooks(uint8_t playerId)
auto e = eObj.Take();
// Call the subscriptions
hookEngine.Call(OpenRCT2::Scripting::HOOK_TYPE::NETWORK_LEAVE, e, false);
hookEngine.Call(OpenRCT2::Scripting::HookType::networkLeave, e, false);
}
#endif
}
@@ -2898,7 +2898,7 @@ static bool ProcessChatMessagePluginHooks(uint8_t playerId, std::string& text)
{
#ifdef ENABLE_SCRIPTING
auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine();
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HOOK_TYPE::NETWORK_CHAT))
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::networkChat))
{
auto ctx = GetContext()->GetScriptEngine().GetContext();
@@ -2911,7 +2911,7 @@ static bool ProcessChatMessagePluginHooks(uint8_t playerId, std::string& text)
auto e = DukValue::take_from_stack(ctx);
// Call the subscriptions
hookEngine.Call(OpenRCT2::Scripting::HOOK_TYPE::NETWORK_CHAT, e, false);
hookEngine.Call(OpenRCT2::Scripting::HookType::networkChat, e, false);
// Update text from object if subscriptions changed it
if (e["message"].type() != DukValue::Type::STRING)
@@ -59,7 +59,7 @@ private:
std::unique_ptr<IUdpSocket> _lanListener;
uint32_t _lastListenTime{};
ADVERTISE_STATUS _status = ADVERTISE_STATUS::UNREGISTERED;
AdvertiseStatus _status = AdvertiseStatus::unregistered;
#ifndef DISABLE_HTTP
uint32_t _lastAdvertiseTime = 0;
@@ -85,7 +85,7 @@ public:
#endif
}
ADVERTISE_STATUS GetStatus() const override
AdvertiseStatus GetStatus() const override
{
return _status;
}
@@ -147,7 +147,7 @@ private:
{
switch (_status)
{
case ADVERTISE_STATUS::UNREGISTERED:
case AdvertiseStatus::unregistered:
if (_lastAdvertiseTime == 0 || Platform::GetTicks() > _lastAdvertiseTime + kMasterServerRegisterTime)
{
if (_lastAdvertiseTime == 0)
@@ -157,14 +157,14 @@ private:
SendRegistration(_forceIPv4);
}
break;
case ADVERTISE_STATUS::REGISTERED:
case AdvertiseStatus::registered:
if (Platform::GetTicks() > _lastHeartbeatTime + kMasterServerHeartbeatTime)
{
SendHeartbeat();
}
break;
// exhaust enum values to satisfy clang
case ADVERTISE_STATUS::DISABLED:
case AdvertiseStatus::disabled:
break;
}
}
@@ -246,7 +246,7 @@ private:
if (jsonToken.is_string())
{
_token = Json::GetString(jsonToken);
_status = ADVERTISE_STATUS::REGISTERED;
_status = AdvertiseStatus::registered;
}
}
else
@@ -288,7 +288,7 @@ private:
}
else if (status == MasterServerStatus::InvalidToken)
{
_status = ADVERTISE_STATUS::UNREGISTERED;
_status = AdvertiseStatus::unregistered;
_lastAdvertiseTime = 0;
Console::Error::WriteLine("Master server heartbeat failed: Invalid Token");
}
@@ -11,11 +11,11 @@
#include <memory>
enum class ADVERTISE_STATUS
enum class AdvertiseStatus
{
DISABLED,
UNREGISTERED,
REGISTERED,
disabled,
unregistered,
registered,
};
struct INetworkServerAdvertiser
@@ -24,7 +24,7 @@ struct INetworkServerAdvertiser
{
}
virtual ADVERTISE_STATUS GetStatus() const = 0;
virtual AdvertiseStatus GetStatus() const = 0;
virtual void Update() = 0;
};
+1 -1
View File
@@ -512,7 +512,7 @@ std::vector<std::pair<std::string, Image>> ImageTable::GetImageSources(IReadObje
if (itSource == result.end())
{
auto imageData = context->GetData(path);
auto imageFormat = keepPalette ? IMAGE_FORMAT::PNG : IMAGE_FORMAT::PNG_32;
auto imageFormat = keepPalette ? ImageFormat::png : ImageFormat::png32;
auto image = Imaging::ReadFromBuffer(imageData, imageFormat);
auto pair = std::make_pair<std::string, Image>(std::move(path), std::move(image));
result.push_back(std::move(pair));
+4 -4
View File
@@ -311,7 +311,7 @@ bool ObjectAsset::IsAvailable() const
return File::Exists(_path);
}
auto zipArchive = Zip::TryOpen(_zipPath, ZIP_ACCESS::READ);
auto zipArchive = Zip::TryOpen(_zipPath, ZipAccess::read);
return zipArchive != nullptr && zipArchive->Exists(_path);
}
@@ -322,7 +322,7 @@ uint64_t ObjectAsset::GetSize() const
return File::GetSize(_path);
}
auto zipArchive = Zip::TryOpen(_zipPath, ZIP_ACCESS::READ);
auto zipArchive = Zip::TryOpen(_zipPath, ZipAccess::read);
if (zipArchive != nullptr)
{
auto index = zipArchive->GetIndexFromPath(_path);
@@ -342,7 +342,7 @@ std::vector<uint8_t> ObjectAsset::GetData() const
return File::ReadAllBytes(_path);
}
auto zipArchive = Zip::TryOpen(_zipPath, ZIP_ACCESS::READ);
auto zipArchive = Zip::TryOpen(_zipPath, ZipAccess::read);
if (zipArchive != nullptr)
{
return zipArchive->GetFileData(_path);
@@ -359,7 +359,7 @@ std::unique_ptr<IStream> ObjectAsset::GetStream() const
return std::make_unique<FileStream>(_path, FileMode::open);
}
auto zipArchive = Zip::TryOpen(_zipPath, ZIP_ACCESS::READ);
auto zipArchive = Zip::TryOpen(_zipPath, ZipAccess::read);
if (zipArchive != nullptr)
{
auto stream = zipArchive->GetFileStream(_path);
+1 -1
View File
@@ -433,7 +433,7 @@ namespace OpenRCT2::ObjectFactory
{
try
{
auto archive = Zip::Open(path, ZIP_ACCESS::READ);
auto archive = Zip::Open(path, ZipAccess::read);
auto jsonBytes = archive->GetFileData("object.json");
if (jsonBytes.empty())
{
+6 -7
View File
@@ -1012,12 +1012,12 @@ namespace OpenRCT2
});
for (int i = 0; i < kParkRatingHistorySize; i++)
{
if (smallHistory[i] == RCT12ParkHistoryUndefined)
if (smallHistory[i] == kRCT12ParkHistoryUndefined)
gameState.park.RatingHistory[i] = kParkRatingHistoryUndefined;
else
{
gameState.park.RatingHistory[i] = static_cast<uint16_t>(
smallHistory[i] * RCT12ParkRatingHistoryFactor);
smallHistory[i] * kRCT12ParkRatingHistoryFactor);
}
}
}
@@ -1027,11 +1027,11 @@ namespace OpenRCT2
for (int i = 0; i < kParkRatingHistorySize; i++)
{
if (gameState.park.RatingHistory[i] == kParkRatingHistoryUndefined)
smallHistory[i] = RCT12ParkHistoryUndefined;
smallHistory[i] = kRCT12ParkHistoryUndefined;
else
{
smallHistory[i] = static_cast<uint8_t>(
gameState.park.RatingHistory[i] / RCT12ParkRatingHistoryFactor);
gameState.park.RatingHistory[i] / kRCT12ParkRatingHistoryFactor);
}
}
cs.ReadWriteArray(smallHistory, [&cs](uint8_t& value) {
@@ -1237,12 +1237,11 @@ namespace OpenRCT2
// Previous formats stored the needs supports flag in the primary colour
// We have moved it into a flags field to support extended colour sets
bool needsSupports = sceneryElement->GetPrimaryColour()
& RCT12_SMALL_SCENERY_ELEMENT_NEEDS_SUPPORTS_FLAG;
& kRCT12SmallSceneryElementNeedsSupportsFlag;
if (needsSupports)
{
sceneryElement->SetPrimaryColour(
sceneryElement->GetPrimaryColour()
& ~RCT12_SMALL_SCENERY_ELEMENT_NEEDS_SUPPORTS_FLAG);
sceneryElement->GetPrimaryColour() & ~kRCT12SmallSceneryElementNeedsSupportsFlag);
sceneryElement->SetNeedsSupports();
}
}
+5 -5
View File
@@ -35,15 +35,15 @@ static std::shared_ptr<AndroidClassLoader> acl;
namespace OpenRCT2::Platform
{
std::string GetFolderPath(SPECIAL_FOLDER folder)
std::string GetFolderPath(SpecialFolder folder)
{
// Android builds currently only read from /sdcard/openrct2*
switch (folder)
{
case SPECIAL_FOLDER::USER_CACHE:
case SPECIAL_FOLDER::USER_CONFIG:
case SPECIAL_FOLDER::USER_DATA:
case SPECIAL_FOLDER::USER_HOME:
case SpecialFolder::userCache:
case SpecialFolder::userConfig:
case SpecialFolder::userData:
case SpecialFolder::userHome:
return "/sdcard";
default:
return std::string();
+6 -6
View File
@@ -77,23 +77,23 @@ namespace OpenRCT2::Platform
}
}
std::string GetFolderPath(SPECIAL_FOLDER folder)
std::string GetFolderPath(SpecialFolder folder)
{
switch (folder)
{
case SPECIAL_FOLDER::USER_CACHE:
case SPECIAL_FOLDER::USER_CONFIG:
case SPECIAL_FOLDER::USER_DATA:
case SpecialFolder::userCache:
case SpecialFolder::userConfig:
case SpecialFolder::userData:
{
auto path = GetEnvironmentPath("XDG_CONFIG_HOME");
if (path.empty())
{
auto home = GetFolderPath(SPECIAL_FOLDER::USER_HOME);
auto home = GetFolderPath(SpecialFolder::userHome);
path = Path::Combine(home, u8".config");
}
return path;
}
case SPECIAL_FOLDER::USER_HOME:
case SpecialFolder::userHome:
return GetHomePath();
default:
return std::string();
+7 -7
View File
@@ -90,23 +90,23 @@ namespace OpenRCT2::Platform
return result;
}
std::string GetFolderPath(SPECIAL_FOLDER folder)
std::string GetFolderPath(SpecialFolder folder)
{
switch (folder)
{
// We currently store everything under Documents/OpenRCT2
case SPECIAL_FOLDER::USER_CACHE:
case SPECIAL_FOLDER::USER_CONFIG:
case SPECIAL_FOLDER::USER_DATA:
case SpecialFolder::userCache:
case SpecialFolder::userConfig:
case SpecialFolder::userData:
{
auto path = WIN32_GetKnownFolderPath(FOLDERID_Documents);
if (path.empty())
{
path = GetFolderPath(SPECIAL_FOLDER::USER_HOME);
path = GetFolderPath(SpecialFolder::userHome);
}
return path;
}
case SPECIAL_FOLDER::USER_HOME:
case SpecialFolder::userHome:
{
auto path = WIN32_GetKnownFolderPath(FOLDERID_Profile);
if (path.empty())
@@ -119,7 +119,7 @@ namespace OpenRCT2::Platform
}
return path;
}
case SPECIAL_FOLDER::RCT2_DISCORD:
case SpecialFolder::rct2Discord:
{
auto path = WIN32_GetKnownFolderPath(FOLDERID_LocalAppData);
if (!path.empty())
+7 -7
View File
@@ -35,14 +35,14 @@
static_assert(
std::endian::native == std::endian::little, "OpenRCT2 is known to be broken on big endian. Proceed with caution!");
enum class SPECIAL_FOLDER
enum class SpecialFolder
{
USER_CACHE,
USER_CONFIG,
USER_DATA,
USER_HOME,
userCache,
userConfig,
userData,
userHome,
RCT2_DISCORD,
rct2Discord,
};
struct RealWorldDate;
@@ -52,7 +52,7 @@ struct TTFFontDescriptor;
namespace OpenRCT2::Platform
{
std::string GetEnvironmentVariable(std::string_view name);
std::string GetFolderPath(SPECIAL_FOLDER folder);
std::string GetFolderPath(SpecialFolder folder);
std::string GetInstallPath();
std::string GetDocsPath();
std::string GetCurrentExecutablePath();
+6 -6
View File
@@ -30,19 +30,19 @@
namespace OpenRCT2::Platform
{
std::string GetFolderPath(SPECIAL_FOLDER folder)
std::string GetFolderPath(SpecialFolder folder)
{
// macOS stores everything in ~/Library/Application Support/OpenRCT2
switch (folder)
{
case SPECIAL_FOLDER::USER_CACHE:
case SPECIAL_FOLDER::USER_CONFIG:
case SPECIAL_FOLDER::USER_DATA:
case SpecialFolder::userCache:
case SpecialFolder::userConfig:
case SpecialFolder::userData:
{
auto home = GetFolderPath(SPECIAL_FOLDER::USER_HOME);
auto home = GetFolderPath(SpecialFolder::userHome);
return Path::Combine(home, "Library/Application Support");
}
case SPECIAL_FOLDER::USER_HOME:
case SpecialFolder::userHome:
return GetHomePath();
default:
return std::string();
+1 -1
View File
@@ -505,7 +505,7 @@ namespace OpenRCT2::RCT1
uint8_t GetTrackDirection() const
{
return TrackTypeAndDirection & RCT12VehicleTrackDirectionMask;
return TrackTypeAndDirection & kRCT12VehicleTrackDirectionMask;
}
};
+7 -7
View File
@@ -1229,7 +1229,7 @@ namespace OpenRCT2::RCT1
{
for (const auto& src : _s4.RideMeasurements)
{
if (src.RideIndex != RCT12_RIDE_ID_NULL)
if (src.RideIndex != kRCT12RideIdNull)
{
auto ride = GetRide(RCT12RideIdToOpenRCT2RideId(src.RideIndex));
if (ride != nullptr)
@@ -1464,7 +1464,7 @@ namespace OpenRCT2::RCT1
gameState.peepSpawns.clear();
for (size_t i = 0; i < Limits::kMaxPeepSpawns; i++)
{
if (_s4.PeepSpawn[i].x != RCT12_PEEP_SPAWN_UNDEFINED)
if (_s4.PeepSpawn[i].x != kRCT12PeepSpawnUndefined)
{
PeepSpawn spawn = { _s4.PeepSpawn[i].x, _s4.PeepSpawn[i].y, _s4.PeepSpawn[i].z * 16,
_s4.PeepSpawn[i].direction };
@@ -2245,16 +2245,16 @@ namespace OpenRCT2::RCT1
Park::ResetHistories(gameState);
for (size_t i = 0; i < std::size(_s4.ParkRatingHistory); i++)
{
if (_s4.ParkRatingHistory[i] != RCT12ParkHistoryUndefined)
if (_s4.ParkRatingHistory[i] != kRCT12ParkHistoryUndefined)
{
gameState.park.RatingHistory[i] = _s4.ParkRatingHistory[i] * RCT12ParkRatingHistoryFactor;
gameState.park.RatingHistory[i] = _s4.ParkRatingHistory[i] * kRCT12ParkRatingHistoryFactor;
}
}
for (size_t i = 0; i < std::size(_s4.GuestsInParkHistory); i++)
{
if (_s4.GuestsInParkHistory[i] != RCT12ParkHistoryUndefined)
if (_s4.GuestsInParkHistory[i] != kRCT12ParkHistoryUndefined)
{
gameState.guestsInParkHistory[i] = _s4.GuestsInParkHistory[i] * RCT12GuestsInParkHistoryFactor;
gameState.guestsInParkHistory[i] = _s4.GuestsInParkHistory[i] * kRCT12GuestsInParkHistoryFactor;
}
}
@@ -2944,7 +2944,7 @@ namespace OpenRCT2::RCT1
auto srcThought = &src->Thoughts[i];
auto dstThought = &dst->Thoughts[i];
dstThought->type = static_cast<PeepThoughtType>(srcThought->Type);
if (srcThought->Item == RCT12PeepThoughtItemNone)
if (srcThought->Item == kRCT12PeepThoughtItemNone)
dstThought->item = kPeepThoughtItemNone;
else
dstThought->item = srcThought->Item;
+21 -21
View File
@@ -83,7 +83,7 @@ uint8_t RCT12SurfaceElement::GetSlope() const
uint32_t RCT12SurfaceElement::GetSurfaceStyle() const
{
uint32_t retVal = (Terrain >> 5) & 7;
retVal |= (Type & RCT12_SURFACE_ELEMENT_TYPE_SURFACE_MASK) << 3;
retVal |= (Type & kRCT12SurfaceElementTypeSurfaceMask) << 3;
return retVal;
}
@@ -107,7 +107,7 @@ uint8_t RCT12SurfaceElement::GetOwnership() const
uint32_t RCT12SurfaceElement::GetWaterHeight() const
{
return (Terrain & RCT12_TILE_ELEMENT_SURFACE_WATER_HEIGHT_MASK) * kWaterHeightStep;
return (Terrain & kRCT12SurfaceElementWaterHeightMask) * kWaterHeightStep;
}
uint8_t RCT12SurfaceElement::GetParkFences() const
@@ -234,7 +234,7 @@ uint8_t RCT12TrackElement::GetStationIndex() const
bool RCT12TrackElement::HasChain() const
{
return Type & RCT12_TRACK_ELEMENT_TYPE_FLAG_CHAIN_LIFT;
return Type & kRCT12TrackElementTypeFlagChainLift;
}
bool RCT12TrackElement::HasCableLift() const
@@ -260,7 +260,7 @@ bool RCT12TrackElement::HasGreenLight() const
{
if (TrackTypeIsStation(TrackType))
{
return (Sequence & MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT) != 0;
return (Sequence & kRCT12TrackElementSequenceGreenLight) != 0;
}
return false;
}
@@ -316,22 +316,22 @@ uint8_t RCT12SmallSceneryElement::GetSceneryQuadrant() const
colour_t RCT12SmallSceneryElement::GetPrimaryColour() const
{
return Colour1 & RCT12_TILE_ELEMENT_COLOUR_MASK;
return Colour1 & kRCT12TileElementColourMask;
}
colour_t RCT12SmallSceneryElement::GetSecondaryColour() const
{
return Colour2 & RCT12_TILE_ELEMENT_COLOUR_MASK;
return Colour2 & kRCT12TileElementColourMask;
}
bool RCT12SmallSceneryElement::NeedsSupports() const
{
return Colour1 & RCT12_SMALL_SCENERY_ELEMENT_NEEDS_SUPPORTS_FLAG;
return Colour1 & kRCT12SmallSceneryElementNeedsSupportsFlag;
}
uint32_t RCT12LargeSceneryElement::GetEntryIndex() const
{
return EntryIndex & RCT12_TILE_ELEMENT_LARGE_TYPE_MASK;
return EntryIndex & kRCT12TileElementLargeTypeMask;
}
uint16_t RCT12LargeSceneryElement::GetSequenceIndex() const
@@ -340,18 +340,18 @@ uint16_t RCT12LargeSceneryElement::GetSequenceIndex() const
}
colour_t RCT12LargeSceneryElement::GetPrimaryColour() const
{
return Colour[0] & RCT12_TILE_ELEMENT_COLOUR_MASK;
return Colour[0] & kRCT12TileElementColourMask;
}
colour_t RCT12LargeSceneryElement::GetSecondaryColour() const
{
return Colour[1] & RCT12_TILE_ELEMENT_COLOUR_MASK;
return Colour[1] & kRCT12TileElementColourMask;
}
uint8_t RCT12LargeSceneryElement::GetBannerIndex() const
{
return (Type & 0xC0) | (((Colour[0]) & ~RCT12_TILE_ELEMENT_COLOUR_MASK) >> 2)
| (((Colour[1]) & ~RCT12_TILE_ELEMENT_COLOUR_MASK) >> 5);
return (Type & 0xC0) | (((Colour[0]) & ~kRCT12TileElementColourMask) >> 2)
| (((Colour[1]) & ~kRCT12TileElementColourMask) >> 5);
}
uint8_t RCT12WallElement::GetEntryIndex() const
@@ -366,19 +366,19 @@ uint8_t RCT12WallElement::GetSlope() const
colour_t RCT12WallElement::GetPrimaryColour() const
{
return Colour1 & RCT12_TILE_ELEMENT_COLOUR_MASK;
return Colour1 & kRCT12TileElementColourMask;
}
colour_t RCT12WallElement::GetSecondaryColour() const
{
uint8_t secondaryColour = (Colour1 & ~RCT12_TILE_ELEMENT_COLOUR_MASK) >> 5;
uint8_t secondaryColour = (Colour1 & ~kRCT12TileElementColourMask) >> 5;
secondaryColour |= (Flags & 0x60) >> 2;
return secondaryColour;
}
colour_t RCT12WallElement::GetTertiaryColour() const
{
return Colour3 & RCT12_TILE_ELEMENT_COLOUR_MASK;
return Colour3 & kRCT12TileElementColourMask;
}
uint8_t RCT12WallElement::GetAnimationFrame() const
@@ -496,17 +496,17 @@ bool RCT12TrackElement::BlockBrakeClosed() const
bool RCT12ResearchItem::IsInventedEndMarker() const
{
return RawValue == RCT12_RESEARCHED_ITEMS_SEPARATOR;
return RawValue == kRCT12ResearchedItemsSeparator;
}
bool RCT12ResearchItem::IsUninventedEndMarker() const
{
return RawValue == RCT12_RESEARCHED_ITEMS_END;
return RawValue == kRCT12ResearchedItemsEnd;
}
bool RCT12ResearchItem::IsRandomEndMarker() const
{
return RawValue == RCT12_RESEARCHED_ITEMS_END_2;
return RawValue == kRCT12ResearchedItemsEnd2;
}
ObjectEntryIndex RCTEntryIndexToOpenRCT2EntryIndex(const RCT12ObjectEntryIndex index)
@@ -519,7 +519,7 @@ ObjectEntryIndex RCTEntryIndexToOpenRCT2EntryIndex(const RCT12ObjectEntryIndex i
RideId RCT12RideIdToOpenRCT2RideId(const RCT12RideId rideId)
{
if (rideId == RCT12_RIDE_ID_NULL)
if (rideId == kRCT12RideIdNull)
return RideId::GetNull();
return RideId::FromUnderlying(rideId);
@@ -527,11 +527,11 @@ RideId RCT12RideIdToOpenRCT2RideId(const RCT12RideId rideId)
static bool RCT12IsFormatChar(codepoint_t c)
{
if (c >= RCT2_STRING_FORMAT_ARG_START && c <= RCT2_STRING_FORMAT_ARG_END)
if (c >= kRCT12StringFormatArgStart && c <= kRCT12StringFormatArgEnd)
{
return true;
}
if (c >= RCT2_STRING_FORMAT_COLOUR_START && c <= RCT2_STRING_FORMAT_COLOUR_END)
if (c >= kRCT12StringFormatColourStart && c <= kRCT12StringFormatColourEnd)
{
return true;
}
+31 -42
View File
@@ -320,54 +320,54 @@ namespace OpenRCT2::RCT12
};
} // namespace OpenRCT2::RCT12
enum
{
MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT = (1 << 7),
};
constexpr uint8_t kRCT12StringFormatArgStart = 123;
constexpr uint8_t kRCT12StringFormatArgEnd = 141;
constexpr uint8_t kRCT12StringFormatColourStart = 142;
constexpr uint8_t kRCT12StringFormatColourEnd = 156;
constexpr uint8_t RCT2_STRING_FORMAT_ARG_START = 123;
constexpr uint8_t RCT2_STRING_FORMAT_ARG_END = 141;
constexpr uint8_t RCT2_STRING_FORMAT_COLOUR_START = 142;
constexpr uint8_t RCT2_STRING_FORMAT_COLOUR_END = 156;
constexpr uint8_t RCT12_SOUND_ID_NULL = 0xFF;
constexpr uint8_t kRCT12SoundIdNull = 0xFF;
using RCT12RideId = uint8_t;
constexpr RCT12RideId RCT12_RIDE_ID_NULL = 255;
constexpr RCT12RideId kRCT12RideIdNull = 255;
constexpr uint8_t RCT12_BANNER_INDEX_NULL = std::numeric_limits<uint8_t>::max();
constexpr uint8_t kRCT12BannerIndexNull = std::numeric_limits<uint8_t>::max();
constexpr uint8_t RCT12_TILE_ELEMENT_SURFACE_EDGE_STYLE_MASK = 0xE0; // in RCT12TileElement.properties.surface.slope
constexpr uint8_t RCT12_TILE_ELEMENT_SURFACE_WATER_HEIGHT_MASK = 0x1F; // in RCT12TileElement.properties.surface.terrain
constexpr uint8_t RCT12_TILE_ELEMENT_SURFACE_TERRAIN_MASK = 0xE0; // in RCT12TileElement.properties.surface.terrain
constexpr uint8_t kRCT12SurfaceElementEdgeStyleMask = 0xE0; // in RCT12TileElement.properties.surface.slope
constexpr uint8_t kRCT12SurfaceElementWaterHeightMask = 0x1F; // in RCT12TileElement.properties.surface.terrain
constexpr uint8_t kRCT12SurfaceElementTerrainMask = 0xE0; // in RCT12TileElement.properties.surface.terrain
constexpr uint8_t kRCT12SurfaceElementTypeSurfaceMask = 0b00000011; // in RCT12TileElement.properties.surface.type
constexpr uint8_t kRCT12SurfaceElementTypeEdgeMask = 0b01000000; // in RCT12TileElement.properties.surface.type
constexpr uint8_t RCT12_SMALL_SCENERY_ELEMENT_NEEDS_SUPPORTS_FLAG = 0x20;
constexpr uint8_t RCT12_TILE_ELEMENT_COLOUR_MASK = 0b0001'1111;
constexpr uint8_t kRCT12SmallSceneryElementNeedsSupportsFlag = 0x20;
constexpr uint8_t kRCT12TileElementColourMask = 0b0001'1111;
constexpr uint16_t RCT12_TILE_ELEMENT_LARGE_TYPE_MASK = 0x3FF;
constexpr uint16_t kRCT12TileElementLargeTypeMask = 0x3FF;
constexpr uint16_t const RCT12_XY8_UNDEFINED = 0xFFFF;
constexpr uint8_t kRCT12TrackElementTypeFlagChainLift = 1 << 7;
constexpr uint8_t kRCT12TrackElementSequenceGreenLight = 1 << 7;
constexpr uint16_t const kRCT12xy8Undefined = 0xFFFF;
using RCT12ObjectEntryIndex = uint8_t;
constexpr RCT12ObjectEntryIndex kRCT12ObjectEntryIndexNull = 255;
// Everything before this point has been researched
constexpr uint32_t RCT12_RESEARCHED_ITEMS_SEPARATOR = 0xFFFFFFFF;
constexpr uint32_t kRCT12ResearchedItemsSeparator = 0xFFFFFFFF;
// Everything before this point and after separator still requires research
constexpr uint32_t RCT12_RESEARCHED_ITEMS_END = 0xFFFFFFFE;
constexpr uint32_t kRCT12ResearchedItemsEnd = 0xFFFFFFFE;
// Extra end of list entry. Leftover from RCT1.
constexpr uint32_t RCT12_RESEARCHED_ITEMS_END_2 = 0xFFFFFFFD;
constexpr uint32_t kRCT12ResearchedItemsEnd2 = 0xFFFFFFFD;
constexpr uint16_t RCT12_PEEP_SPAWN_UNDEFINED = 0xFFFF;
constexpr uint16_t kRCT12PeepSpawnUndefined = 0xFFFF;
constexpr uint16_t RCT12VehicleTrackDirectionMask = 0b0000000000000011;
constexpr uint16_t RCT12VehicleTrackTypeMask = 0b1111111111111100;
constexpr uint16_t kRCT12VehicleTrackDirectionMask = 0b0000000000000011;
constexpr uint16_t kRCT12VehicleTrackTypeMask = 0b1111111111111100;
constexpr uint8_t RCT12PeepThoughtItemNone = std::numeric_limits<uint8_t>::max();
constexpr uint8_t kRCT12PeepThoughtItemNone = std::numeric_limits<uint8_t>::max();
constexpr uint8_t RCT12GuestsInParkHistoryFactor = 20;
constexpr uint8_t RCT12ParkRatingHistoryFactor = 4;
constexpr uint8_t RCT12ParkHistoryUndefined = std::numeric_limits<uint8_t>::max();
constexpr uint8_t kRCT12GuestsInParkHistoryFactor = 20;
constexpr uint8_t kRCT12ParkRatingHistoryFactor = 4;
constexpr uint8_t kRCT12ParkHistoryUndefined = std::numeric_limits<uint8_t>::max();
constexpr uint8_t kTD46RatingsMultiplier = 10;
constexpr uint8_t kTD46GForcesMultiplier = 32;
@@ -387,12 +387,6 @@ enum class RCT12TrackDesignVersion : uint8_t
unknown
};
enum
{
RCT12_SURFACE_ELEMENT_TYPE_SURFACE_MASK = 0b00000011,
RCT12_SURFACE_ELEMENT_TYPE_EDGE_MASK = 0b01000000,
};
enum
{
RCT12_TILE_ELEMENT_FLAG_GHOST = (1 << 4),
@@ -404,11 +398,6 @@ enum
RCT12_TILE_ELEMENT_FLAG_LAST_TILE = (1 << 7)
};
enum
{
RCT12_TRACK_ELEMENT_TYPE_FLAG_CHAIN_LIFT = 1 << 7,
};
enum
{
RCT12_TRACK_ELEMENT_SEQUENCE_STATION_INDEX_MASK = 0b01110000,
@@ -506,12 +495,12 @@ struct RCT12xy8
bool IsNull() const
{
return xy == RCT12_XY8_UNDEFINED;
return xy == kRCT12xy8Undefined;
}
void SetNull()
{
xy = RCT12_XY8_UNDEFINED;
xy = kRCT12xy8Undefined;
}
};
static_assert(sizeof(RCT12xy8) == 2);
+1 -1
View File
@@ -13,7 +13,7 @@
namespace OpenRCT2
{
SawyerChunk::SawyerChunk(SAWYER_ENCODING encoding, MemoryStream&& data)
SawyerChunk::SawyerChunk(SawyerEncoding encoding, MemoryStream&& data)
: _data(std::move(data))
, _encoding(encoding)
{
+8 -8
View File
@@ -18,12 +18,12 @@ namespace OpenRCT2
/**
* The type of encoding / compression for a sawyer encoded chunk.
*/
enum class SAWYER_ENCODING : uint8_t
enum class SawyerEncoding : uint8_t
{
NONE,
RLE,
RLECOMPRESSED,
ROTATE,
none,
rle,
rleCompressed,
rotate,
};
/**
@@ -33,7 +33,7 @@ namespace OpenRCT2
{
private:
OpenRCT2::MemoryStream _data;
SAWYER_ENCODING _encoding = SAWYER_ENCODING::NONE;
SawyerEncoding _encoding = SawyerEncoding::none;
public:
const void* GetData() const
@@ -44,11 +44,11 @@ namespace OpenRCT2
{
return _data.GetLength();
}
SAWYER_ENCODING GetEncoding() const
SawyerEncoding GetEncoding() const
{
return _encoding;
}
SawyerChunk(SAWYER_ENCODING encoding, OpenRCT2::MemoryStream&& data);
SawyerChunk(SawyerEncoding encoding, OpenRCT2::MemoryStream&& data);
};
} // namespace OpenRCT2
+2 -2
View File
@@ -75,7 +75,7 @@ namespace OpenRCT2
throw SawyerChunkException(EXCEPTION_MSG_ZERO_SIZED_CHUNK);
}
return std::make_shared<SawyerChunk>(static_cast<SAWYER_ENCODING>(header.encoding), std::move(buffer));
return std::make_shared<SawyerChunk>(static_cast<SawyerEncoding>(header.encoding), std::move(buffer));
}
default:
throw SawyerChunkException(EXCEPTION_MSG_INVALID_CHUNK_ENCODING);
@@ -114,7 +114,7 @@ namespace OpenRCT2
{
throw SawyerChunkException(EXCEPTION_MSG_ZERO_SIZED_CHUNK);
}
return std::make_shared<SawyerChunk>(SAWYER_ENCODING::RLE, std::move(buffer));
return std::make_shared<SawyerChunk>(SawyerEncoding::rle, std::move(buffer));
}
catch (const std::exception&)
{
+1 -1
View File
@@ -28,7 +28,7 @@ namespace OpenRCT2
WriteChunk(chunk->GetData(), chunk->GetLength(), chunk->GetEncoding());
}
void SawyerChunkWriter::WriteChunk(const void* src, size_t length, SAWYER_ENCODING encoding)
void SawyerChunkWriter::WriteChunk(const void* src, size_t length, SawyerEncoding encoding)
{
SawyerCoding::ChunkHeader header;
header.encoding = static_cast<uint8_t>(encoding);
+2 -2
View File
@@ -39,7 +39,7 @@ namespace OpenRCT2
* @param src The source buffer.
* @param length The size of the source buffer.
*/
void WriteChunk(const void* src, size_t length, SAWYER_ENCODING encoding);
void WriteChunk(const void* src, size_t length, SawyerEncoding encoding);
/**
* Writes a track chunk to the stream containing the given buffer.
@@ -52,7 +52,7 @@ namespace OpenRCT2
* Writes a chunk to the stream containing the given type.
*/
template<typename T>
void WriteChunk(const T* src, SAWYER_ENCODING encoding)
void WriteChunk(const T* src, SawyerEncoding encoding)
{
WriteChunk(src, sizeof(T), encoding);
}
+4 -5
View File
@@ -314,7 +314,6 @@ namespace OpenRCT2::RCT2
uint8_t SecondaryColour; // 0x15
colour_t getTertiaryWallColour() const;
void setTertiaryWallColour(colour_t colour);
};
static_assert(sizeof(TD6SceneryElement) == 0x16);
@@ -511,19 +510,19 @@ namespace OpenRCT2::RCT2
}
uint8_t GetTrackDirection() const
{
return TrackTypeAndDirection & RCT12VehicleTrackDirectionMask;
return TrackTypeAndDirection & kRCT12VehicleTrackDirectionMask;
}
void SetTrackType(OpenRCT2::RCT12::TrackElemType trackType)
{
// set the upper 14 bits to 0
TrackTypeAndDirection &= ~RCT12VehicleTrackTypeMask;
TrackTypeAndDirection &= ~kRCT12VehicleTrackTypeMask;
TrackTypeAndDirection |= EnumValue(trackType) << 2;
}
void SetTrackDirection(uint8_t trackDirection)
{
// set the lower 2 bits only
TrackTypeAndDirection &= ~RCT12VehicleTrackDirectionMask;
TrackTypeAndDirection |= trackDirection & RCT12VehicleTrackDirectionMask;
TrackTypeAndDirection &= ~kRCT12VehicleTrackDirectionMask;
TrackTypeAndDirection |= trackDirection & kRCT12VehicleTrackDirectionMask;
}
};
static_assert(sizeof(Vehicle) == 0xDA);
+12 -12
View File
@@ -436,29 +436,29 @@ namespace OpenRCT2::RCT2
Park::ResetHistories(gameState);
for (size_t i = 0; i < std::size(_s6.ParkRatingHistory); i++)
{
if (_s6.ParkRatingHistory[i] != RCT12ParkHistoryUndefined)
if (_s6.ParkRatingHistory[i] != kRCT12ParkHistoryUndefined)
{
gameState.park.RatingHistory[i] = _s6.ParkRatingHistory[i] * RCT12ParkRatingHistoryFactor;
gameState.park.RatingHistory[i] = _s6.ParkRatingHistory[i] * kRCT12ParkRatingHistoryFactor;
}
}
for (size_t i = 0; i < std::size(_s6.GuestsInParkHistory); i++)
{
if (_s6.GuestsInParkHistory[i] != RCT12ParkHistoryUndefined)
if (_s6.GuestsInParkHistory[i] != kRCT12ParkHistoryUndefined)
{
gameState.guestsInParkHistory[i] = _s6.GuestsInParkHistory[i] * RCT12GuestsInParkHistoryFactor;
gameState.guestsInParkHistory[i] = _s6.GuestsInParkHistory[i] * kRCT12GuestsInParkHistoryFactor;
}
}
gameState.researchPriorities = _s6.ActiveResearchTypes;
gameState.researchProgressStage = _s6.ResearchProgressStage;
if (_s6.LastResearchedItemSubject != RCT12_RESEARCHED_ITEMS_SEPARATOR)
if (_s6.LastResearchedItemSubject != kRCT12ResearchedItemsSeparator)
gameState.researchLastItem = RCT12ResearchItem{ _s6.LastResearchedItemSubject,
EnumValue(ResearchCategory::Transport) }
.ToResearchItem();
else
gameState.researchLastItem = std::nullopt;
// Pad01357CF8
if (_s6.NextResearchItem != RCT12_RESEARCHED_ITEMS_SEPARATOR)
if (_s6.NextResearchItem != kRCT12ResearchedItemsSeparator)
gameState.researchNextItem = RCT12ResearchItem{ _s6.NextResearchItem, _s6.NextResearchCategory }
.ToResearchItem();
else
@@ -707,7 +707,7 @@ namespace OpenRCT2::RCT2
bool IsFlatRide(const uint8_t rct12RideIndex)
{
if (rct12RideIndex == RCT12_RIDE_ID_NULL)
if (rct12RideIndex == kRCT12RideIdNull)
return false;
return _isFlatRide[rct12RideIndex];
}
@@ -1060,7 +1060,7 @@ namespace OpenRCT2::RCT2
{
for (const auto& src : _s6.RideMeasurements)
{
if (src.RideIndex != RCT12_RIDE_ID_NULL)
if (src.RideIndex != kRCT12RideIdNull)
{
const auto rideId = RideId::FromUnderlying(src.RideIndex);
auto ride = GetRide(rideId);
@@ -1159,14 +1159,14 @@ namespace OpenRCT2::RCT2
|| String::equals(_s6.ScenarioFilename, "South America - Rio Carnival.SC6"))
{
_s6.PeepSpawns[0] = { 2160, 3167, 6, 1 };
_s6.PeepSpawns[1].x = RCT12_PEEP_SPAWN_UNDEFINED;
_s6.PeepSpawns[1].x = kRCT12PeepSpawnUndefined;
}
// In this park, peep_spawns[0] is correct. Just clear the other.
else if (
String::equals(_s6.ScenarioFilename, "Great Wall of China Tourism Enhancement.SC6")
|| String::equals(_s6.ScenarioFilename, "Asia - Great Wall of China Tourism Enhancement.SC6"))
{
_s6.PeepSpawns[1].x = RCT12_PEEP_SPAWN_UNDEFINED;
_s6.PeepSpawns[1].x = kRCT12PeepSpawnUndefined;
}
// Amity Airfield has peeps entering from the corner of the tile, instead of the middle.
else if (String::equals(_s6.ScenarioFilename, "Amity Airfield.SC6"))
@@ -1183,7 +1183,7 @@ namespace OpenRCT2::RCT2
gameState.peepSpawns.clear();
for (size_t i = 0; i < Limits::kMaxPeepSpawns; i++)
{
if (_s6.PeepSpawns[i].x != RCT12_PEEP_SPAWN_UNDEFINED)
if (_s6.PeepSpawns[i].x != kRCT12PeepSpawnUndefined)
{
PeepSpawn spawn = { _s6.PeepSpawns[i].x, _s6.PeepSpawns[i].y, _s6.PeepSpawns[i].z * 16,
_s6.PeepSpawns[i].direction };
@@ -2098,7 +2098,7 @@ namespace OpenRCT2::RCT2
auto srcThought = &src->Thoughts[i];
auto dstThought = &dst->Thoughts[i];
dstThought->type = static_cast<PeepThoughtType>(srcThought->Type);
if (srcThought->Item == RCT12PeepThoughtItemNone)
if (srcThought->Item == kRCT12PeepThoughtItemNone)
dstThought->item = kPeepThoughtItemNone;
else
dstThought->item = srcThought->Item;
+2 -2
View File
@@ -883,7 +883,7 @@ static bool ride_modify_entrance_or_exit(const CoordsXYE& tileElement)
gRideEntranceExitPlaceType = entranceType;
gRideEntranceExitPlaceRideIndex = rideIndex;
gRideEntranceExitPlaceStationIndex = stationIndex;
InputSetFlag(INPUT_FLAG_6, true);
gInputFlags.set(InputFlag::unk6);
if (_rideConstructionState != RideConstructionState::EntranceExit)
{
gRideEntranceExitPlacePreviousRideConstructionState = _rideConstructionState;
@@ -1073,7 +1073,7 @@ int32_t RideInitialiseConstructionWindow(Ride& ride)
w = ride_create_or_find_construction_window(ride.id);
ToolSet(*w, WC_RIDE_CONSTRUCTION__WIDX_CONSTRUCT, Tool::crosshair);
InputSetFlag(INPUT_FLAG_6, true);
gInputFlags.set(InputFlag::unk6);
_currentlySelectedTrack = ride.getRideTypeDescriptor().StartTrackPiece;
_currentTrackPitchEnd = TrackPitch::None;
+2 -2
View File
@@ -1069,7 +1069,7 @@ static void RideRatingsCalculate(RideRatingUpdateState& state, Ride& ride)
if (ride.lifecycleFlags & RIDE_LIFECYCLE_TESTED)
{
auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine();
if (hookEngine.HasSubscriptions(HOOK_TYPE::RIDE_RATINGS_CALCULATE))
if (hookEngine.HasSubscriptions(HookType::rideRatingsCalculate))
{
auto ctx = GetContext()->GetScriptEngine().GetContext();
auto originalRatings = ride.ratings;
@@ -1083,7 +1083,7 @@ static void RideRatingsCalculate(RideRatingUpdateState& state, Ride& ride)
// Call the subscriptions
auto e = obj.Take();
hookEngine.Call(HOOK_TYPE::RIDE_RATINGS_CALCULATE, e, true);
hookEngine.Call(HookType::rideRatingsCalculate, e, true);
auto scriptExcitement = AsOrDefault(e["excitement"], static_cast<int32_t>(originalRatings.excitement));
auto scriptIntensity = AsOrDefault(e["intensity"], static_cast<int32_t>(originalRatings.intensity));
+2 -2
View File
@@ -469,7 +469,7 @@ bool EntityBase::Is<Vehicle>() const
static void InvokeVehicleCrashHook(const EntityId vehicleId, const std::string_view crashId)
{
auto& hookEngine = OpenRCT2::GetContext()->GetScriptEngine().GetHookEngine();
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HOOK_TYPE::VEHICLE_CRASH))
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::vehicleCrash))
{
auto ctx = OpenRCT2::GetContext()->GetScriptEngine().GetContext();
@@ -480,7 +480,7 @@ static void InvokeVehicleCrashHook(const EntityId vehicleId, const std::string_v
// Call the subscriptions
auto e = obj.Take();
hookEngine.Call(OpenRCT2::Scripting::HOOK_TYPE::VEHICLE_CRASH, e, true);
hookEngine.Call(OpenRCT2::Scripting::HookType::vehicleCrash, e, true);
}
}
#endif
+1 -1
View File
@@ -158,7 +158,7 @@ void TitleScene::Tick()
// update_weather_animation();
}
InputSetFlag(INPUT_FLAG_VIEWPORT_SCROLLING, false);
gInputFlags.unset(InputFlag::viewportScrolling);
ContextHandleInput();
+6 -6
View File
@@ -59,7 +59,7 @@ namespace OpenRCT2::Title
auto ext = Path::GetExtension(path);
if (String::equals(ext, TITLE_SEQUENCE_EXTENSION))
{
auto zip = Zip::TryOpen(path, ZIP_ACCESS::READ);
auto zip = Zip::TryOpen(path, ZipAccess::read);
if (zip == nullptr)
{
Console::Error::WriteLine("Unable to open '%s'", path.c_str());
@@ -109,7 +109,7 @@ namespace OpenRCT2::Title
const auto& filename = seq.Saves[index];
if (seq.IsZip)
{
auto zip = Zip::TryOpen(seq.Path, ZIP_ACCESS::READ);
auto zip = Zip::TryOpen(seq.Path, ZipAccess::read);
if (zip != nullptr)
{
auto data = zip->GetFileData(filename);
@@ -159,7 +159,7 @@ namespace OpenRCT2::Title
if (seq.IsZip)
{
auto fdata = std::vector<uint8_t>(script.begin(), script.end());
auto zip = Zip::Open(seq.Path, ZIP_ACCESS::WRITE);
auto zip = Zip::Open(seq.Path, ZipAccess::write);
zip->SetFileData("script.txt", std::move(fdata));
}
else
@@ -189,7 +189,7 @@ namespace OpenRCT2::Title
try
{
auto fdata = File::ReadAllBytes(path);
auto zip = Zip::TryOpen(seq.Path, ZIP_ACCESS::WRITE);
auto zip = Zip::TryOpen(seq.Path, ZipAccess::write);
if (zip == nullptr)
{
Console::Error::WriteLine("Unable to open '%s'", seq.Path.c_str());
@@ -222,7 +222,7 @@ namespace OpenRCT2::Title
auto& oldRelativePath = seq.Saves[index];
if (seq.IsZip)
{
auto zip = Zip::TryOpen(seq.Path, ZIP_ACCESS::WRITE);
auto zip = Zip::TryOpen(seq.Path, ZipAccess::write);
if (zip == nullptr)
{
Console::Error::WriteLine("Unable to open '%s'", seq.Path.c_str());
@@ -252,7 +252,7 @@ namespace OpenRCT2::Title
auto& relativePath = seq.Saves[index];
if (seq.IsZip)
{
auto zip = Zip::TryOpen(seq.Path, ZIP_ACCESS::WRITE);
auto zip = Zip::TryOpen(seq.Path, ZipAccess::write);
if (zip == nullptr)
{
Console::Error::WriteLine("Unable to open '%s'", seq.Path.c_str());
+32 -32
View File
@@ -18,42 +18,42 @@
using namespace OpenRCT2::Scripting;
static const EnumMap<HOOK_TYPE> HooksLookupTable({
{ "action.query", HOOK_TYPE::ACTION_QUERY },
{ "action.execute", HOOK_TYPE::ACTION_EXECUTE },
{ "interval.tick", HOOK_TYPE::INTERVAL_TICK },
{ "interval.day", HOOK_TYPE::INTERVAL_DAY },
{ "network.chat", HOOK_TYPE::NETWORK_CHAT },
{ "network.authenticate", HOOK_TYPE::NETWORK_AUTHENTICATE },
{ "network.join", HOOK_TYPE::NETWORK_JOIN },
{ "network.leave", HOOK_TYPE::NETWORK_LEAVE },
{ "ride.ratings.calculate", HOOK_TYPE::RIDE_RATINGS_CALCULATE },
{ "action.location", HOOK_TYPE::ACTION_LOCATION },
{ "guest.generation", HOOK_TYPE::GUEST_GENERATION },
{ "vehicle.crash", HOOK_TYPE::VEHICLE_CRASH },
{ "map.change", HOOK_TYPE::MAP_CHANGE },
{ "map.changed", HOOK_TYPE::MAP_CHANGED },
{ "map.save", HOOK_TYPE::MAP_SAVE },
{ "park.guest.softcap.calculate", HOOK_TYPE::PARK_CALCULATE_GUEST_CAP },
static const EnumMap<HookType> HooksLookupTable({
{ "action.query", HookType::actionQuery },
{ "action.execute", HookType::actionExecute },
{ "interval.tick", HookType::intervalTick },
{ "interval.day", HookType::intervalDay },
{ "network.chat", HookType::networkChat },
{ "network.authenticate", HookType::networkAuthenticate },
{ "network.join", HookType::networkJoin },
{ "network.leave", HookType::networkLeave },
{ "ride.ratings.calculate", HookType::rideRatingsCalculate },
{ "action.location", HookType::actionLocation },
{ "guest.generation", HookType::guestGeneration },
{ "vehicle.crash", HookType::vehicleCrash },
{ "map.change", HookType::mapChange },
{ "map.changed", HookType::mapChanged },
{ "map.save", HookType::mapSave },
{ "park.guest.softcap.calculate", HookType::parkCalculateGuestCap },
});
HOOK_TYPE OpenRCT2::Scripting::GetHookType(const std::string& name)
HookType OpenRCT2::Scripting::GetHookType(const std::string& name)
{
auto result = HooksLookupTable.find(name);
return (result != HooksLookupTable.end()) ? result->second : HOOK_TYPE::UNDEFINED;
return (result != HooksLookupTable.end()) ? result->second : HookType::notDefined;
}
HookEngine::HookEngine(ScriptEngine& scriptEngine)
: _scriptEngine(scriptEngine)
{
_hookMap.resize(NUM_HOOK_TYPES);
for (size_t i = 0; i < NUM_HOOK_TYPES; i++)
_hookMap.resize(NUM_HookTypeS);
for (size_t i = 0; i < NUM_HookTypeS; i++)
{
_hookMap[i].Type = static_cast<HOOK_TYPE>(i);
_hookMap[i].Type = static_cast<HookType>(i);
}
}
uint32_t HookEngine::Subscribe(HOOK_TYPE type, std::shared_ptr<Plugin> owner, const DukValue& function)
uint32_t HookEngine::Subscribe(HookType type, std::shared_ptr<Plugin> owner, const DukValue& function)
{
auto& hookList = GetHookList(type);
auto cookie = _nextCookie++;
@@ -61,7 +61,7 @@ uint32_t HookEngine::Subscribe(HOOK_TYPE type, std::shared_ptr<Plugin> owner, co
return cookie;
}
void HookEngine::Unsubscribe(HOOK_TYPE type, uint32_t cookie)
void HookEngine::Unsubscribe(HookType type, uint32_t cookie)
{
auto& hookList = GetHookList(type);
auto& hooks = hookList.Hooks;
@@ -94,22 +94,22 @@ void HookEngine::UnsubscribeAll()
}
}
bool HookEngine::HasSubscriptions(HOOK_TYPE type) const
bool HookEngine::HasSubscriptions(HookType type) const
{
auto& hookList = GetHookList(type);
return !hookList.Hooks.empty();
}
bool HookEngine::IsValidHookForPlugin(HOOK_TYPE type, Plugin& plugin) const
bool HookEngine::IsValidHookForPlugin(HookType type, Plugin& plugin) const
{
if (type == HOOK_TYPE::MAP_CHANGED && plugin.GetMetadata().Type != PluginType::Intransient)
if (type == HookType::mapChanged && plugin.GetMetadata().Type != PluginType::Intransient)
{
return false;
}
return true;
}
void HookEngine::Call(HOOK_TYPE type, bool isGameStateMutable)
void HookEngine::Call(HookType type, bool isGameStateMutable)
{
auto& hookList = GetHookList(type);
for (auto& hook : hookList.Hooks)
@@ -118,7 +118,7 @@ void HookEngine::Call(HOOK_TYPE type, bool isGameStateMutable)
}
}
void HookEngine::Call(HOOK_TYPE type, const DukValue& arg, bool isGameStateMutable)
void HookEngine::Call(HookType type, const DukValue& arg, bool isGameStateMutable)
{
auto& hookList = GetHookList(type);
for (auto& hook : hookList.Hooks)
@@ -128,7 +128,7 @@ void HookEngine::Call(HOOK_TYPE type, const DukValue& arg, bool isGameStateMutab
}
void HookEngine::Call(
HOOK_TYPE type, const std::initializer_list<std::pair<std::string_view, std::any>>& args, bool isGameStateMutable)
HookType type, const std::initializer_list<std::pair<std::string_view, std::any>>& args, bool isGameStateMutable)
{
auto& hookList = GetHookList(type);
for (auto& hook : hookList.Hooks)
@@ -162,13 +162,13 @@ void HookEngine::Call(
}
}
HookList& HookEngine::GetHookList(HOOK_TYPE type)
HookList& HookEngine::GetHookList(HookType type)
{
auto index = static_cast<size_t>(type);
return _hookMap[index];
}
const HookList& HookEngine::GetHookList(HOOK_TYPE type) const
const HookList& HookEngine::GetHookList(HookType type) const
{
auto index = static_cast<size_t>(type);
return _hookMap[index];
+31 -31
View File
@@ -25,29 +25,29 @@ namespace OpenRCT2::Scripting
class ScriptExecutionInfo;
class Plugin;
enum class HOOK_TYPE
enum class HookType
{
ACTION_QUERY,
ACTION_EXECUTE,
INTERVAL_TICK,
INTERVAL_DAY,
NETWORK_CHAT,
NETWORK_AUTHENTICATE,
NETWORK_JOIN,
NETWORK_LEAVE,
RIDE_RATINGS_CALCULATE,
ACTION_LOCATION,
GUEST_GENERATION,
VEHICLE_CRASH,
MAP_CHANGE,
MAP_CHANGED,
MAP_SAVE,
PARK_CALCULATE_GUEST_CAP,
COUNT,
UNDEFINED = -1,
actionQuery,
actionExecute,
intervalTick,
intervalDay,
networkChat,
networkAuthenticate,
networkJoin,
networkLeave,
rideRatingsCalculate,
actionLocation,
guestGeneration,
vehicleCrash,
mapChange,
mapChanged,
mapSave,
parkCalculateGuestCap,
count,
notDefined = -1,
};
constexpr size_t NUM_HOOK_TYPES = static_cast<size_t>(HOOK_TYPE::COUNT);
HOOK_TYPE GetHookType(const std::string& name);
constexpr size_t NUM_HookTypeS = static_cast<size_t>(HookType::count);
HookType GetHookType(const std::string& name);
struct Hook
{
@@ -66,7 +66,7 @@ namespace OpenRCT2::Scripting
struct HookList
{
HOOK_TYPE Type{};
HookType Type{};
std::vector<Hook> Hooks;
HookList() = default;
@@ -84,20 +84,20 @@ namespace OpenRCT2::Scripting
public:
HookEngine(ScriptEngine& scriptEngine);
HookEngine(const HookEngine&) = delete;
uint32_t Subscribe(HOOK_TYPE type, std::shared_ptr<Plugin> owner, const DukValue& function);
void Unsubscribe(HOOK_TYPE type, uint32_t cookie);
uint32_t Subscribe(HookType type, std::shared_ptr<Plugin> owner, const DukValue& function);
void Unsubscribe(HookType type, uint32_t cookie);
void UnsubscribeAll(std::shared_ptr<const Plugin> owner);
void UnsubscribeAll();
bool HasSubscriptions(HOOK_TYPE type) const;
bool IsValidHookForPlugin(HOOK_TYPE type, Plugin& plugin) const;
void Call(HOOK_TYPE type, bool isGameStateMutable);
void Call(HOOK_TYPE type, const DukValue& arg, bool isGameStateMutable);
bool HasSubscriptions(HookType type) const;
bool IsValidHookForPlugin(HookType type, Plugin& plugin) const;
void Call(HookType type, bool isGameStateMutable);
void Call(HookType type, const DukValue& arg, bool isGameStateMutable);
void Call(
HOOK_TYPE type, const std::initializer_list<std::pair<std::string_view, std::any>>& args, bool isGameStateMutable);
HookType type, const std::initializer_list<std::pair<std::string_view, std::any>>& args, bool isGameStateMutable);
private:
HookList& GetHookList(HOOK_TYPE type);
const HookList& GetHookList(HOOK_TYPE type) const;
HookList& GetHookList(HookType type);
const HookList& GetHookList(HookType type) const;
};
} // namespace OpenRCT2::Scripting
+1 -1
View File
@@ -1460,7 +1460,7 @@ void ScriptEngine::RunGameActionHooks(const GameAction& action, GameActions::Res
{
DukStackFrame frame(_context);
auto hookType = isExecute ? HOOK_TYPE::ACTION_EXECUTE : HOOK_TYPE::ACTION_QUERY;
auto hookType = isExecute ? HookType::actionExecute : HookType::actionQuery;
if (_hookEngine.HasSubscriptions(hookType))
{
DukObject obj(_context);
@@ -273,7 +273,7 @@ namespace OpenRCT2::Scripting
__declspec(noinline)
#endif
std::shared_ptr<ScDisposable>
CreateSubscription(HOOK_TYPE hookType, const DukValue& callback)
CreateSubscription(HookType hookType, const DukValue& callback)
{
auto owner = _execInfo.GetCurrentPlugin();
auto cookie = _hookEngine.Subscribe(hookType, owner, callback);
@@ -286,7 +286,7 @@ namespace OpenRCT2::Scripting
auto ctx = scriptEngine.GetContext();
auto hookType = GetHookType(hook);
if (hookType == HOOK_TYPE::UNDEFINED)
if (hookType == HookType::notDefined)
{
duk_error(ctx, DUK_ERR_ERROR, "Unknown hook type");
}
+1 -1
View File
@@ -59,7 +59,7 @@ namespace OpenRCT2::Ui
{
return ScaleQuality::NearestNeighbour;
}
void SetFullscreenMode(FULLSCREEN_MODE /*mode*/) override
void SetFullscreenMode(FullscreenMode /*mode*/) override
{
}
const std::vector<Resolution>& GetFullscreenResolutions() override
+5 -5
View File
@@ -36,11 +36,11 @@ namespace OpenRCT2
{
struct IWindowManager;
enum class FULLSCREEN_MODE
enum class FullscreenMode
{
WINDOWED,
FULLSCREEN,
FULLSCREEN_DESKTOP,
windowed,
fullscreen,
fullscreenDesktop,
};
inline bool operator<(const Resolution& lhs, const Resolution& rhs)
@@ -110,7 +110,7 @@ namespace OpenRCT2
virtual int32_t GetWidth() = 0;
virtual int32_t GetHeight() = 0;
virtual ScaleQuality GetScaleQuality() = 0;
virtual void SetFullscreenMode(FULLSCREEN_MODE mode) = 0;
virtual void SetFullscreenMode(FullscreenMode mode) = 0;
virtual const std::vector<Resolution>& GetFullscreenResolutions() = 0;
virtual bool HasFocus() = 0;
virtual bool IsMinimised() = 0;
+2 -2
View File
@@ -160,13 +160,13 @@ namespace OpenRCT2::Park
#ifdef ENABLE_SCRIPTING
auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine();
if (hookEngine.HasSubscriptions(HOOK_TYPE::PARK_CALCULATE_GUEST_CAP))
if (hookEngine.HasSubscriptions(HookType::parkCalculateGuestCap))
{
auto ctx = GetContext()->GetScriptEngine().GetContext();
auto obj = DukObject(ctx);
obj.Set("suggestedGuestMaximum", suggestedMaxGuests);
auto e = obj.Take();
hookEngine.Call(HOOK_TYPE::PARK_CALCULATE_GUEST_CAP, e, true);
hookEngine.Call(HookType::parkCalculateGuestCap, e, true);
suggestedMaxGuests = AsOrDefault(e["suggestedGuestMaximum"], static_cast<int32_t>(suggestedMaxGuests));
suggestedMaxGuests = std::clamp<uint16_t>(suggestedMaxGuests, 0, UINT16_MAX);
@@ -40,10 +40,10 @@ namespace OpenRCT2::World::MapGenerator
bool LoadHeightmapImage(const utf8* path)
{
auto format = Imaging::GetImageFormatFromPath(path);
if (format == IMAGE_FORMAT::PNG)
if (format == ImageFormat::png)
{
// Promote to 32-bit
format = IMAGE_FORMAT::PNG_32;
format = ImageFormat::png32;
}
try
@@ -79,10 +79,10 @@ namespace OpenRCT2::World::MapGenerator
{
switch (format)
{
case IMAGE_FORMAT::BITMAP:
case ImageFormat::bitmap:
ContextShowError(STR_HEIGHT_MAP_ERROR, STR_ERROR_READING_BITMAP, {});
break;
case IMAGE_FORMAT::PNG_32:
case ImageFormat::png32:
ContextShowError(STR_HEIGHT_MAP_ERROR, STR_ERROR_READING_PNG, {});
break;
default:
+1 -1
View File
@@ -41,7 +41,7 @@ TEST_F(ImageImporterTests, Import_Logo)
auto logoPath = GetImagePath("logo.png");
ImageImporter importer;
auto image = Imaging::ReadFromFile(logoPath, IMAGE_FORMAT::PNG_32);
auto image = Imaging::ReadFromFile(logoPath, ImageFormat::png32);
auto meta = ImageImportMeta{ .offset = { 3, 5 } };
auto result = importer.Import(image, meta);
+1 -1
View File
@@ -36,7 +36,7 @@ TEST(FetchAndApplyScenarioPatch, expected_json_format)
std::error_code ec;
OpenRCT2::RCT12::SetDryRun(true);
OpenRCT2::Guard::SetAssertBehaviour(ASSERT_BEHAVIOUR::ABORT);
OpenRCT2::Guard::SetAssertBehaviour(AssertBehaviour::abort);
static const u8string dummySHA;
for (const fs::directory_entry& entry : fs::directory_iterator(scenarioPatches, ec))
{
+1 -1
View File
@@ -17,7 +17,7 @@
int main(int argc, char** argv)
{
// Abort on an assertions so the tests do not hang
OpenRCT2::Guard::SetAssertBehaviour(ASSERT_BEHAVIOUR::ABORT);
OpenRCT2::Guard::SetAssertBehaviour(AssertBehaviour::abort);
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();