diff --git a/src/openrct2-ui/windows/EditorBottomToolbar.cpp b/src/openrct2-ui/windows/EditorBottomToolbar.cpp index a27718e52a..83202afcce 100644 --- a/src/openrct2-ui/windows/EditorBottomToolbar.cpp +++ b/src/openrct2-ui/windows/EditorBottomToolbar.cpp @@ -188,7 +188,7 @@ static bool window_editor_bottom_toolbar_check_object_selection() if (w != nullptr) { // Click tab with missing object - window_event_mouse_up_call(w, WC_EDITOR_OBJECT_SELECTION__WIDX_TAB_1 + missingObjectType); + window_event_mouse_up_call(w, WC_EDITOR_OBJECT_SELECTION__WIDX_TAB_1 + EnumValue(missingObjectType)); } return false; } diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index 8963d9e684..db2318a19a 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -212,7 +212,7 @@ static constexpr const int32_t window_editor_object_selection_animation_divisor[ static void window_editor_object_set_page(rct_window* w, int32_t page); static void window_editor_object_selection_set_pressed_tab(rct_window* w); -static int32_t get_object_from_object_selection(uint8_t object_type, int32_t y); +static int32_t get_object_from_object_selection(ObjectType object_type, int32_t y); static void window_editor_object_selection_manage_tracks(); static void editor_load_selected_objects(); static bool filter_selected(uint8_t objectFlags); @@ -295,7 +295,7 @@ static void visible_list_refresh(rct_window* w) { uint8_t selectionFlags = _objectSelectionFlags[i]; const ObjectRepositoryItem* item = &items[i]; - uint8_t objectType = item->ObjectEntry.GetType(); + ObjectType objectType = item->ObjectEntry.GetType(); if (objectType == get_selected_object_type(w) && !(selectionFlags & OBJECT_SELECTION_FLAG_6) && filter_source(item) && filter_string(item) && filter_chunks(item) && filter_selected(selectionFlags)) { @@ -999,8 +999,8 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf { auto screenPos = w->windowPos + ScreenCoordsXY{ 3, w->height - 13 }; - int32_t numSelected = _numSelectedObjectsForType[get_selected_object_type(w)]; - int32_t totalSelectable = object_entry_group_counts[get_selected_object_type(w)]; + int32_t numSelected = _numSelectedObjectsForType[EnumValue(get_selected_object_type(w))]; + int32_t totalSelectable = object_entry_group_counts[EnumValue(get_selected_object_type(w))]; if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) totalSelectable = 4; @@ -1256,7 +1256,7 @@ static void window_editor_object_selection_set_pressed_tab(rct_window* w) * * rct2: 0x006AA703 */ -static int32_t get_object_from_object_selection(uint8_t object_type, int32_t y) +static int32_t get_object_from_object_selection(ObjectType object_type, int32_t y) { int32_t listItemIndex = y / SCROLLABLE_ROW_HEIGHT; if (listItemIndex < 0 || static_cast(listItemIndex) >= _listItems.size()) @@ -1502,7 +1502,7 @@ static bool filter_chunks(const ObjectRepositoryItem* item) case ObjectType::Music: case ObjectType::Count: case ObjectType::None: - //This function works only with ObjectType::Ride. + // This function works only with ObjectType::Ride. break; } return true; @@ -1522,8 +1522,8 @@ static void filter_update_counts() const ObjectRepositoryItem* item = &items[i]; if (filter_source(item) && filter_string(item) && filter_chunks(item) && filter_selected(selectionFlags[i])) { - uint8_t objectType = item->ObjectEntry.GetType(); - _filter_object_counts[objectType]++; + ObjectType objectType = item->ObjectEntry.GetType(); + _filter_object_counts[EnumValue(objectType)]++; } } } diff --git a/src/openrct2/Editor.h b/src/openrct2/Editor.h index b9ab678119..60a20a6ade 100644 --- a/src/openrct2/Editor.h +++ b/src/openrct2/Editor.h @@ -11,8 +11,7 @@ #define _EDITOR_H_ #include "common.h" - -#include +#include "object/Object.h" namespace Editor { diff --git a/src/openrct2/object/Object.h b/src/openrct2/object/Object.h index ab4cc42b5d..69bdd5f9e7 100644 --- a/src/openrct2/object/Object.h +++ b/src/openrct2/object/Object.h @@ -42,7 +42,7 @@ enum class ObjectType : uint8_t Music, Count, - None=255 + None = 255 }; enum OBJECT_SELECTION_FLAGS diff --git a/src/openrct2/object/ObjectManager.cpp b/src/openrct2/object/ObjectManager.cpp index fc2e921cd6..021f820a4e 100644 --- a/src/openrct2/object/ObjectManager.cpp +++ b/src/openrct2/object/ObjectManager.cpp @@ -474,7 +474,7 @@ private: case ObjectType::Music: case ObjectType::Count: case ObjectType::None: - //This switch handles only ObjectType for sceneries. + // This switch handles only ObjectType for sceneries. break; } } diff --git a/src/openrct2/object/ObjectRepository.cpp b/src/openrct2/object/ObjectRepository.cpp index 4d5e97934b..bc03c7ca08 100644 --- a/src/openrct2/object/ObjectRepository.cpp +++ b/src/openrct2/object/ObjectRepository.cpp @@ -181,7 +181,7 @@ protected: case ObjectType::Music: case ObjectType::Count: case ObjectType::None: - //Switch processes only ObjectType::Ride and ObjectType::SceneryGroup + // Switch processes only ObjectType::Ride and ObjectType::SceneryGroup break; } } @@ -247,7 +247,7 @@ protected: case ObjectType::Music: case ObjectType::Count: case ObjectType::None: - //Switch processes only ObjectType::Ride and ObjectType::SceneryGroup + // Switch processes only ObjectType::Ride and ObjectType::SceneryGroup break; } return item; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index da7f452283..dcba2e67e5 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -560,7 +560,7 @@ private: case ObjectType::Music: case ObjectType::Count: case ObjectType::None: - //This switch processes only ObjectTypes valid for scenery + // This switch processes only ObjectTypes valid for scenery break; } } @@ -2999,7 +2999,7 @@ private: case ObjectType::Music: case ObjectType::Count: case ObjectType::None: - //This switch processes only ObjectType for for Entries + // This switch processes only ObjectType for for Entries break; } return nullptr; diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index d3b553a985..0a9c6ff716 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -785,7 +785,7 @@ static void track_design_mirror_scenery(TrackDesign* td6) case ObjectType::Music: case ObjectType::Count: case ObjectType::None: - //This switch processes only ObjectType for Scenery items. + // This switch processes only ObjectType for Scenery items. break; } } @@ -900,7 +900,8 @@ static bool TrackDesignPlaceSceneryElementGetEntry( } entry_index = 0; - for (PathSurfaceEntry* path = get_path_surface_entry(0); entry_index < object_entry_group_counts[ObjectType::Paths]; + for (PathSurfaceEntry* path = get_path_surface_entry(0); + entry_index < object_entry_group_counts[EnumValue(ObjectType::Paths)]; path = get_path_surface_entry(entry_index), entry_index++) { if (path == nullptr) @@ -987,7 +988,7 @@ static bool TrackDesignPlaceSceneryElementGetPlaceZ(const TrackDesignSceneryElem _trackDesignPlaceSceneryZ = z; } - uint8_t entry_type; + ObjectType entry_type; ObjectEntryIndex entry_index; TrackDesignPlaceSceneryElementGetEntry(entry_type, entry_index, scenery); @@ -1904,7 +1905,7 @@ static bool track_design_place_preview(TrackDesign* td6, money32* cost, Ride** o *outRide = nullptr; *flags = 0; - uint8_t entry_type; + ObjectType entry_type; ObjectEntryIndex entry_index; if (!find_object_in_entry_group(&td6->vehicle_object, &entry_type, &entry_index)) { diff --git a/src/openrct2/scripting/ScContext.hpp b/src/openrct2/scripting/ScContext.hpp index e75a4953fb..74e414ee63 100644 --- a/src/openrct2/scripting/ScContext.hpp +++ b/src/openrct2/scripting/ScContext.hpp @@ -90,11 +90,11 @@ namespace OpenRCT2::Scripting switch (type) { case ObjectType::Ride: - return GetObjectAsDukValue(ctx, std::make_shared(EnumValue(type), index)); + return GetObjectAsDukValue(ctx, std::make_shared(type, index)); case ObjectType::SmallScenery: - return GetObjectAsDukValue(ctx, std::make_shared(EnumValue(type), index)); + return GetObjectAsDukValue(ctx, std::make_shared(type, index)); default: - return GetObjectAsDukValue(ctx, std::make_shared(EnumValue(type), index)); + return GetObjectAsDukValue(ctx, std::make_shared(type, index)); } } @@ -128,7 +128,7 @@ namespace OpenRCT2::Scripting auto type = ScObject::StringToObjectType(typez); if (type) { - auto count = object_entry_group_counts[*type]; + auto count = object_entry_group_counts[EnumValue(*type)]; for (int32_t i = 0; i < count; i++) { auto obj = objManager.GetLoadedObject(*type, i); diff --git a/src/openrct2/scripting/ScObject.hpp b/src/openrct2/scripting/ScObject.hpp index bee2cebfbb..c8561cf590 100644 --- a/src/openrct2/scripting/ScObject.hpp +++ b/src/openrct2/scripting/ScObject.hpp @@ -26,11 +26,11 @@ namespace OpenRCT2::Scripting class ScObject { protected: - uint8_t _type{}; + ObjectType _type{}; int32_t _index{}; public: - ScObject(uint8_t type, int32_t index) + ScObject(ObjectType type, int32_t index) : _type(type) , _index(index) { @@ -71,7 +71,7 @@ namespace OpenRCT2::Scripting private: std::string type_get() const { - return std::string(ObjectTypeToString(_type)); + return std::string(ObjectTypeToString(EnumValue(_type))); } int32_t index_get() const @@ -641,7 +641,7 @@ namespace OpenRCT2::Scripting class ScRideObject : public ScObject { public: - ScRideObject(uint8_t type, int32_t index) + ScRideObject(ObjectType type, int32_t index) : ScObject(type, index) { } @@ -922,7 +922,7 @@ namespace OpenRCT2::Scripting class ScSmallSceneryObject : public ScObject { public: - ScSmallSceneryObject(uint8_t type, int32_t index) + ScSmallSceneryObject(ObjectType type, int32_t index) : ScObject(type, index) { } diff --git a/src/openrct2/scripting/ScRide.hpp b/src/openrct2/scripting/ScRide.hpp index 43bbadbc21..33adccd4da 100644 --- a/src/openrct2/scripting/ScRide.hpp +++ b/src/openrct2/scripting/ScRide.hpp @@ -199,7 +199,7 @@ namespace OpenRCT2::Scripting auto rideObject = GetContext()->GetObjectManager().GetLoadedObject(ObjectType::Ride, ride->subtype); if (rideObject != nullptr) { - return std::make_shared(EnumValue(ObjectType::Ride), ride->subtype); + return std::make_shared(ObjectType::Ride, ride->subtype); } } return nullptr;