From 2c4cf49fb1588c49ec207973b86deb2e12346e72 Mon Sep 17 00:00:00 2001 From: Ted John Date: Fri, 24 Apr 2020 21:18:58 +0100 Subject: [PATCH] Add more const --- src/openrct2-ui/scripting/ScUi.hpp | 10 ++--- src/openrct2-ui/scripting/ScViewport.hpp | 22 +++++----- src/openrct2-ui/scripting/ScWidget.hpp | 26 ++++++------ src/openrct2-ui/scripting/ScWindow.hpp | 22 +++++----- src/openrct2/scripting/ScConfiguration.hpp | 20 ++++----- src/openrct2/scripting/ScContext.hpp | 4 +- src/openrct2/scripting/ScDate.hpp | 14 +++---- src/openrct2/scripting/ScDisposable.hpp | 2 +- src/openrct2/scripting/ScEntity.hpp | 16 ++++---- src/openrct2/scripting/ScMap.hpp | 18 ++++---- src/openrct2/scripting/ScNetwork.hpp | 32 +++++++-------- src/openrct2/scripting/ScObject.hpp | 16 ++++---- src/openrct2/scripting/ScPark.hpp | 10 ++--- src/openrct2/scripting/ScRide.hpp | 16 ++++---- src/openrct2/scripting/ScTile.hpp | 48 +++++++++++----------- 15 files changed, 138 insertions(+), 138 deletions(-) diff --git a/src/openrct2-ui/scripting/ScUi.hpp b/src/openrct2-ui/scripting/ScUi.hpp index 1377acaa9e..d1b2f5094c 100644 --- a/src/openrct2-ui/scripting/ScUi.hpp +++ b/src/openrct2-ui/scripting/ScUi.hpp @@ -50,16 +50,16 @@ namespace OpenRCT2::Scripting { return context_get_width(); } - int32_t height_get() + int32_t height_get() const { return context_get_height(); } - int32_t windows_get() + int32_t windows_get() const { return static_cast(g_window_list.size()); } - std::shared_ptr mainViewport_get() + std::shared_ptr mainViewport_get() const { return std::make_shared(WC_MAIN_WINDOW); } @@ -101,7 +101,7 @@ namespace OpenRCT2::Scripting window_close_all(); } - std::shared_ptr getWindow(DukValue a) + std::shared_ptr getWindow(DukValue a) const { if (a.type() == DukValue::Type::NUMBER) { @@ -150,7 +150,7 @@ namespace OpenRCT2::Scripting } private: - rct_windowclass GetClassification(const std::string& key) + rct_windowclass GetClassification(const std::string& key) const { return WC_NULL; } diff --git a/src/openrct2-ui/scripting/ScViewport.hpp b/src/openrct2-ui/scripting/ScViewport.hpp index 100c6ab670..4fee253028 100644 --- a/src/openrct2-ui/scripting/ScViewport.hpp +++ b/src/openrct2-ui/scripting/ScViewport.hpp @@ -37,7 +37,7 @@ namespace OpenRCT2::Scripting } private: - int32_t left_get() + int32_t left_get() const { auto viewport = GetViewport(); if (viewport != nullptr) @@ -55,7 +55,7 @@ namespace OpenRCT2::Scripting } } - int32_t top_get() + int32_t top_get() const { auto viewport = GetViewport(); if (viewport != nullptr) @@ -73,7 +73,7 @@ namespace OpenRCT2::Scripting } } - int32_t right_get() + int32_t right_get() const { auto viewport = GetViewport(); if (viewport != nullptr) @@ -91,7 +91,7 @@ namespace OpenRCT2::Scripting } } - int32_t bottom_get() + int32_t bottom_get() const { auto viewport = GetViewport(); if (viewport != nullptr) @@ -109,7 +109,7 @@ namespace OpenRCT2::Scripting } } - int32_t rotation_get() + int32_t rotation_get() const { return get_current_rotation(); } @@ -128,7 +128,7 @@ namespace OpenRCT2::Scripting } } - int32_t zoom_get() + int32_t zoom_get() const { auto viewport = GetViewport(); if (viewport != nullptr) @@ -146,7 +146,7 @@ namespace OpenRCT2::Scripting } } - uint32_t visibilityFlags_get() + uint32_t visibilityFlags_get() const { auto viewport = GetViewport(); if (viewport != nullptr) @@ -172,7 +172,7 @@ namespace OpenRCT2::Scripting } } - DukValue getCentrePosition() + DukValue getCentrePosition() const { auto viewport = GetViewport(); if (viewport != nullptr) @@ -242,7 +242,7 @@ namespace OpenRCT2::Scripting } private: - rct_window* GetWindow() + rct_window* GetWindow() const { if (_class == WC_MAIN_WINDOW) return window_get_main(); @@ -250,7 +250,7 @@ namespace OpenRCT2::Scripting return window_find_by_number(_class, _number); } - rct_viewport* GetViewport() + rct_viewport* GetViewport() const { auto w = GetWindow(); if (w != nullptr) @@ -277,7 +277,7 @@ namespace OpenRCT2::Scripting } } - std::optional GetCoordsFromObject(DukValue position) + std::optional GetCoordsFromObject(DukValue position) const { if (position.type() == DukValue::Type::OBJECT) { diff --git a/src/openrct2-ui/scripting/ScWidget.hpp b/src/openrct2-ui/scripting/ScWidget.hpp index e28f2ff9c0..2a6efecc57 100644 --- a/src/openrct2-ui/scripting/ScWidget.hpp +++ b/src/openrct2-ui/scripting/ScWidget.hpp @@ -40,7 +40,7 @@ namespace OpenRCT2::Scripting } private: - std::string type_get() + std::string type_get() const { auto widget = GetWidget(); if (widget != nullptr) @@ -86,7 +86,7 @@ namespace OpenRCT2::Scripting return "unknown"; } - int32_t x_get() + int32_t x_get() const { auto widget = GetWidget(); if (widget != nullptr) @@ -106,7 +106,7 @@ namespace OpenRCT2::Scripting } } - int32_t y_get() + int32_t y_get() const { auto widget = GetWidget(); if (widget != nullptr) @@ -126,7 +126,7 @@ namespace OpenRCT2::Scripting } } - int32_t width_get() + int32_t width_get() const { auto widget = GetWidget(); if (widget != nullptr) @@ -146,7 +146,7 @@ namespace OpenRCT2::Scripting } } - int32_t height_get() + int32_t height_get() const { auto widget = GetWidget(); if (widget != nullptr) @@ -166,7 +166,7 @@ namespace OpenRCT2::Scripting } } - bool isDisabled_get() + bool isDisabled_get() const { auto w = GetWindow(); if (w != nullptr) @@ -188,7 +188,7 @@ namespace OpenRCT2::Scripting } } - bool isChecked_get() + bool isChecked_get() const { auto w = GetWindow(); if (w != nullptr) @@ -206,7 +206,7 @@ namespace OpenRCT2::Scripting } } - uint32_t image_get() + uint32_t image_get() const { if (IsCustomWindow()) { @@ -227,7 +227,7 @@ namespace OpenRCT2::Scripting } } - std::string text_get() + std::string text_get() const { if (IsCustomWindow()) { @@ -248,7 +248,7 @@ namespace OpenRCT2::Scripting } } - std::shared_ptr viewport_get() + std::shared_ptr viewport_get() const { auto w = GetWindow(); if (w != nullptr && IsCustomWindow()) @@ -281,7 +281,7 @@ namespace OpenRCT2::Scripting } private: - rct_window* GetWindow() + rct_window* GetWindow() const { if (_class == WC_MAIN_WINDOW) return window_get_main(); @@ -289,7 +289,7 @@ namespace OpenRCT2::Scripting return window_find_by_number(_class, _number); } - rct_widget* GetWidget() + rct_widget* GetWidget() const { auto w = GetWindow(); if (w != nullptr) @@ -299,7 +299,7 @@ namespace OpenRCT2::Scripting return nullptr; } - bool IsCustomWindow() + bool IsCustomWindow() const { auto w = GetWindow(); if (w != nullptr) diff --git a/src/openrct2-ui/scripting/ScWindow.hpp b/src/openrct2-ui/scripting/ScWindow.hpp index e885072e32..1dfd629bb1 100644 --- a/src/openrct2-ui/scripting/ScWindow.hpp +++ b/src/openrct2-ui/scripting/ScWindow.hpp @@ -41,17 +41,17 @@ namespace OpenRCT2::Scripting { } - int32_t classification_get() + int32_t classification_get() const { return static_cast(_class); } - int32_t number_get() + int32_t number_get() const { return static_cast(_number); } - int32_t x_get() + int32_t x_get() const { return GetWindow()->windowPos.x; } @@ -60,7 +60,7 @@ namespace OpenRCT2::Scripting auto w = GetWindow(); window_set_position(w, { value, w->windowPos.y }); } - int32_t y_get() + int32_t y_get() const { return GetWindow()->windowPos.y; } @@ -69,21 +69,21 @@ namespace OpenRCT2::Scripting auto w = GetWindow(); window_set_position(w, { w->windowPos.x, value }); } - int32_t width_get() + int32_t width_get() const { return GetWindow()->width; } - int32_t height_get() + int32_t height_get() const { return GetWindow()->height; } - bool isSticky_get() + bool isSticky_get() const { auto flags = GetWindow()->flags; return (flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT)) != 0; } - std::vector> widgets_get() + std::vector> widgets_get() const { std::vector> result; auto w = GetWindow(); @@ -99,7 +99,7 @@ namespace OpenRCT2::Scripting return result; } - std::vector colours_get() + std::vector colours_get() const { std::vector result; auto w = GetWindow(); @@ -126,7 +126,7 @@ namespace OpenRCT2::Scripting } } - std::string title_get() + std::string title_get() const { auto w = GetWindow(); if (w != nullptr && w->classification == WC_CUSTOM) @@ -153,7 +153,7 @@ namespace OpenRCT2::Scripting } } - std::shared_ptr findWidget(std::string name) + std::shared_ptr findWidget(std::string name) const { auto w = GetWindow(); if (w != nullptr) diff --git a/src/openrct2/scripting/ScConfiguration.hpp b/src/openrct2/scripting/ScConfiguration.hpp index 15ca10d16d..4dc295a65c 100644 --- a/src/openrct2/scripting/ScConfiguration.hpp +++ b/src/openrct2/scripting/ScConfiguration.hpp @@ -41,7 +41,7 @@ namespace OpenRCT2::Scripting } private: - std::pair GetNextNamespace(const std::string_view& input) + std::pair GetNextNamespace(const std::string_view& input) const { auto pos = input.find('.'); if (pos == std::string_view::npos) @@ -54,14 +54,14 @@ namespace OpenRCT2::Scripting } } - std::pair GetNamespaceAndKey(const std::string_view& input) + std::pair GetNamespaceAndKey(const std::string_view& input) const { auto pos = input.find_last_of('.'); return pos == std::string_view::npos ? std::make_pair(std::string_view(), input) : std::make_pair(input.substr(0, pos), input.substr(pos + 1)); } - std::optional GetNamespaceObject(const std::string_view& ns) + std::optional GetNamespaceObject(const std::string_view& ns) const { auto store = _backingObject; auto k = ns; @@ -76,7 +76,7 @@ namespace OpenRCT2::Scripting return store.type() == DukValue::OBJECT ? std::make_optional(store) : std::nullopt; } - DukValue GetOrCreateNamespaceObject(duk_context* ctx, const std::string_view& ns) + DukValue GetOrCreateNamespaceObject(duk_context* ctx, const std::string_view& ns) const { auto store = _backingObject; if (!ns.empty()) @@ -106,7 +106,7 @@ namespace OpenRCT2::Scripting return store; } - bool IsValidNamespace(const std::string_view& ns) + bool IsValidNamespace(const std::string_view& ns) const { if (ns.empty() || ns[0] == '.' || ns[ns.size() - 1] == '.') { @@ -122,12 +122,12 @@ namespace OpenRCT2::Scripting return true; } - bool IsValidKey(const std::string_view& key) + bool IsValidKey(const std::string_view& key) const { return !key.empty() && key.find('.') == std::string_view::npos; } - DukValue getAll(const std::string& ns) + DukValue getAll(const std::string& ns) const { DukValue result; auto ctx = GetContext()->GetScriptEngine().GetContext(); @@ -155,7 +155,7 @@ namespace OpenRCT2::Scripting return result; } - DukValue get(const std::string& key, const DukValue& defaultValue) + DukValue get(const std::string& key, const DukValue& defaultValue) const { auto ctx = GetContext()->GetScriptEngine().GetContext(); if (_isUserConfig) @@ -193,7 +193,7 @@ namespace OpenRCT2::Scripting return defaultValue; } - void set(const std::string& key, const DukValue& value) + void set(const std::string& key, const DukValue& value) const { auto& scriptEngine = GetContext()->GetScriptEngine(); auto ctx = scriptEngine.GetContext(); @@ -246,7 +246,7 @@ namespace OpenRCT2::Scripting } } - bool has(const std::string& key) + bool has(const std::string& key) const { auto val = get(key, DukValue()); return val.type() != DukValue::Type::UNDEFINED; diff --git a/src/openrct2/scripting/ScContext.hpp b/src/openrct2/scripting/ScContext.hpp index 2ca39eef1a..0b9994621b 100644 --- a/src/openrct2/scripting/ScContext.hpp +++ b/src/openrct2/scripting/ScContext.hpp @@ -64,7 +64,7 @@ namespace OpenRCT2::Scripting } } - DukValue getObject(const std::string& typez, int32_t index) + DukValue getObject(const std::string& typez, int32_t index) const { auto ctx = GetContext()->GetScriptEngine().GetContext(); auto& objManager = GetContext()->GetObjectManager(); @@ -85,7 +85,7 @@ namespace OpenRCT2::Scripting return {}; } - std::vector getAllObjects(const std::string& typez) + std::vector getAllObjects(const std::string& typez) const { auto ctx = GetContext()->GetScriptEngine().GetContext(); auto& objManager = GetContext()->GetObjectManager(); diff --git a/src/openrct2/scripting/ScDate.hpp b/src/openrct2/scripting/ScDate.hpp index 6aefa99a1b..f746e7d6b9 100644 --- a/src/openrct2/scripting/ScDate.hpp +++ b/src/openrct2/scripting/ScDate.hpp @@ -37,7 +37,7 @@ namespace OpenRCT2::Scripting } private: - uint32_t monthsElapsed_get() + uint32_t monthsElapsed_get() const { const auto& date = GetDate(); return date.GetMonthsElapsed(); @@ -49,7 +49,7 @@ namespace OpenRCT2::Scripting gDateMonthsElapsed = value; } - uint32_t monthProgress_get() + uint32_t monthProgress_get() const { const auto& date = GetDate(); return date.GetMonthTicks(); @@ -61,7 +61,7 @@ namespace OpenRCT2::Scripting gDateMonthTicks = value; } - uint32_t yearsElapsed_get() + uint32_t yearsElapsed_get() const { const auto& date = GetDate(); return date.GetMonthsElapsed() / 8; @@ -72,26 +72,26 @@ namespace OpenRCT2::Scripting return gCurrentTicks; } - int32_t day_get() + int32_t day_get() const { const auto& date = GetDate(); return date.GetDay() + 1; } - int32_t month_get() + int32_t month_get() const { const auto& date = GetDate(); return date.GetMonth(); } - int32_t year_get() + int32_t year_get() const { const auto& date = GetDate(); return date.GetYear() + 1; } private: - const Date& GetDate() + const Date& GetDate() const { auto gameState = GetContext()->GetGameState(); return gameState->GetDate(); diff --git a/src/openrct2/scripting/ScDisposable.hpp b/src/openrct2/scripting/ScDisposable.hpp index 3b57e83ceb..c3c11450c9 100644 --- a/src/openrct2/scripting/ScDisposable.hpp +++ b/src/openrct2/scripting/ScDisposable.hpp @@ -28,7 +28,7 @@ namespace OpenRCT2::Scripting { } - void dispose() + void dispose() const { if (_onDispose) { diff --git a/src/openrct2/scripting/ScEntity.hpp b/src/openrct2/scripting/ScEntity.hpp index b386ed4b99..c304198435 100644 --- a/src/openrct2/scripting/ScEntity.hpp +++ b/src/openrct2/scripting/ScEntity.hpp @@ -30,7 +30,7 @@ namespace OpenRCT2::Scripting } private: - std::string type_get() + std::string type_get() const { auto entity = GetEntity(); if (entity != nullptr) @@ -58,7 +58,7 @@ namespace OpenRCT2::Scripting } // x getter and setter - int32_t x_get() + int32_t x_get() const { auto entity = GetEntity(); return entity != nullptr ? entity->x : 0; @@ -74,7 +74,7 @@ namespace OpenRCT2::Scripting } // y getter and setter - int32_t y_get() + int32_t y_get() const { auto entity = GetEntity(); return entity != nullptr ? entity->y : 0; @@ -90,7 +90,7 @@ namespace OpenRCT2::Scripting } // z getter and setter - int16_t z_get() + int16_t z_get() const { auto entity = GetEntity(); return entity != nullptr ? entity->z : 0; @@ -105,7 +105,7 @@ namespace OpenRCT2::Scripting } } - SpriteBase* GetEntity() + SpriteBase* GetEntity() const { return &get_sprite(_id)->generic; } @@ -129,7 +129,7 @@ namespace OpenRCT2::Scripting } private: - uint8_t tshirtColour_get() + uint8_t tshirtColour_get() const { auto peep = GetPeep(); return peep != nullptr ? peep->tshirt_colour : 0; @@ -143,7 +143,7 @@ namespace OpenRCT2::Scripting peep->tshirt_colour = value; } } - uint8_t trousersColour_get() + uint8_t trousersColour_get() const { auto peep = GetPeep(); return peep != nullptr ? peep->trousers_colour : 0; @@ -158,7 +158,7 @@ namespace OpenRCT2::Scripting } } - Peep* GetPeep() + Peep* GetPeep() const { return get_sprite(_id)->AsPeep(); } diff --git a/src/openrct2/scripting/ScMap.hpp b/src/openrct2/scripting/ScMap.hpp index df1c2d00e4..bd549b8f8d 100644 --- a/src/openrct2/scripting/ScMap.hpp +++ b/src/openrct2/scripting/ScMap.hpp @@ -32,7 +32,7 @@ namespace OpenRCT2::Scripting { } - DukValue size_get() + DukValue size_get() const { auto ctx = _context; auto objIdx = duk_push_object(ctx); @@ -43,17 +43,17 @@ namespace OpenRCT2::Scripting return DukValue::take_from_stack(ctx); } - int32_t numRides_get() + int32_t numRides_get() const { return static_cast(GetRideManager().size()); } - int32_t numEntities_get() + int32_t numEntities_get() const { return MAX_SPRITES; } - std::vector> rides_get() + std::vector> rides_get() const { std::vector> result; auto rideManager = GetRideManager(); @@ -64,7 +64,7 @@ namespace OpenRCT2::Scripting return result; } - std::shared_ptr getRide(int32_t id) + std::shared_ptr getRide(int32_t id) const { auto rideManager = GetRideManager(); if (id >= 0 && id < static_cast(rideManager.size())) @@ -78,13 +78,13 @@ namespace OpenRCT2::Scripting return {}; } - std::shared_ptr getTile(int32_t x, int32_t y) + std::shared_ptr getTile(int32_t x, int32_t y) const { auto coords = TileCoordsXY(x, y).ToCoordsXY(); return std::make_shared(coords); } - DukValue getEntity(int32_t id) + DukValue getEntity(int32_t id) const { if (id >= 0 && id < MAX_SPRITES) { @@ -99,7 +99,7 @@ namespace OpenRCT2::Scripting return DukValue::take_from_stack(_context); } - std::vector getAllEntities(const std::string& type) + std::vector getAllEntities(const std::string& type) const { SPRITE_LIST targetList{}; uint8_t targetType{}; @@ -189,7 +189,7 @@ namespace OpenRCT2::Scripting } private: - DukValue GetEntityAsDukValue(const rct_sprite* sprite) + DukValue GetEntityAsDukValue(const rct_sprite* sprite) const { auto spriteId = sprite->generic.sprite_index; switch (sprite->generic.sprite_identifier) diff --git a/src/openrct2/scripting/ScNetwork.hpp b/src/openrct2/scripting/ScNetwork.hpp index 25215c17f1..94e5ab47a0 100644 --- a/src/openrct2/scripting/ScNetwork.hpp +++ b/src/openrct2/scripting/ScNetwork.hpp @@ -36,7 +36,7 @@ namespace OpenRCT2::Scripting return _id; } - std::string name_get() + std::string name_get() const { # ifndef DISABLE_NETWORK auto index = network_get_group_index(_id); @@ -55,7 +55,7 @@ namespace OpenRCT2::Scripting # endif } - std::vector permissions_get() + std::vector permissions_get() const { # ifndef DISABLE_NETWORK auto index = network_get_group_index(_id); @@ -129,7 +129,7 @@ namespace OpenRCT2::Scripting } private: - std::string TransformPermissionKeyToJS(const std::string& s) + static std::string TransformPermissionKeyToJS(const std::string& s) { auto result = s.substr(sizeof("PERMISSION_") - 1); for (auto& c : result) @@ -139,7 +139,7 @@ namespace OpenRCT2::Scripting return result; } - std::string TransformPermissionKeyToInternal(const std::string& s) + static std::string TransformPermissionKeyToInternal(const std::string& s) { auto result = "PERMISSION_" + s; for (auto& c : result) @@ -161,12 +161,12 @@ namespace OpenRCT2::Scripting { } - int32_t id_get() + int32_t id_get() const { return _id; } - std::string name_get() + std::string name_get() const { # ifndef DISABLE_NETWORK auto index = network_get_player_index(_id); @@ -178,7 +178,7 @@ namespace OpenRCT2::Scripting # endif } - int32_t group_get() + int32_t group_get() const { # ifndef DISABLE_NETWORK auto index = network_get_player_index(_id); @@ -197,7 +197,7 @@ namespace OpenRCT2::Scripting # endif } - int32_t ping_get() + int32_t ping_get() const { # ifndef DISABLE_NETWORK auto index = network_get_player_index(_id); @@ -209,7 +209,7 @@ namespace OpenRCT2::Scripting # endif } - int32_t commandsRan_get() + int32_t commandsRan_get() const { # ifndef DISABLE_NETWORK auto index = network_get_player_index(_id); @@ -221,7 +221,7 @@ namespace OpenRCT2::Scripting # endif } - int32_t moneySpent_get() + int32_t moneySpent_get() const { # ifndef DISABLE_NETWORK auto index = network_get_player_index(_id); @@ -258,7 +258,7 @@ namespace OpenRCT2::Scripting { } - std::string mode_get() + std::string mode_get() const { # ifndef DISABLE_NETWORK switch (network_get_mode()) @@ -271,7 +271,7 @@ namespace OpenRCT2::Scripting # endif return "none"; } - int32_t players_get() + int32_t players_get() const { # ifndef DISABLE_NETWORK return network_get_num_players(); @@ -279,7 +279,7 @@ namespace OpenRCT2::Scripting return 0; # endif } - int32_t groups_get() + int32_t groups_get() const { # ifndef DISABLE_NETWORK return network_get_num_groups(); @@ -287,7 +287,7 @@ namespace OpenRCT2::Scripting return 0; # endif } - int32_t defaultGroup_get() + int32_t defaultGroup_get() const { # ifndef DISABLE_NETWORK return network_get_default_group(); @@ -303,7 +303,7 @@ namespace OpenRCT2::Scripting # endif } - std::shared_ptr getPlayer(int32_t index) + std::shared_ptr getPlayer(int32_t index) const { # ifndef DISABLE_NETWORK auto numPlayers = network_get_num_players(); @@ -316,7 +316,7 @@ namespace OpenRCT2::Scripting return nullptr; } - std::shared_ptr getGroup(int32_t index) + std::shared_ptr getGroup(int32_t index) const { # ifndef DISABLE_NETWORK auto numGroups = network_get_num_groups(); diff --git a/src/openrct2/scripting/ScObject.hpp b/src/openrct2/scripting/ScObject.hpp index c5cd7db835..38cc49b2c5 100644 --- a/src/openrct2/scripting/ScObject.hpp +++ b/src/openrct2/scripting/ScObject.hpp @@ -67,17 +67,17 @@ namespace OpenRCT2::Scripting } private: - std::string type_get() + std::string type_get() const { return std::string(ObjectTypeToString(_type)); } - int32_t index_get() + int32_t index_get() const { return _index; } - std::string identifier_get() + std::string identifier_get() const { auto obj = GetObject(); if (obj != nullptr) @@ -87,7 +87,7 @@ namespace OpenRCT2::Scripting return {}; } - std::string name_get() + std::string name_get() const { auto obj = GetObject(); if (obj != nullptr) @@ -98,7 +98,7 @@ namespace OpenRCT2::Scripting } protected: - Object* GetObject() + Object* GetObject() const { auto& objManager = GetContext()->GetObjectManager(); return objManager.GetLoadedObject(_type, _index); @@ -121,7 +121,7 @@ namespace OpenRCT2::Scripting } private: - std::string description_get() + std::string description_get() const { auto obj = GetObject(); if (obj != nullptr) @@ -131,7 +131,7 @@ namespace OpenRCT2::Scripting return {}; } - std::string capacity_get() + std::string capacity_get() const { auto obj = GetObject(); if (obj != nullptr) @@ -142,7 +142,7 @@ namespace OpenRCT2::Scripting } protected: - RideObject* GetObject() + RideObject* GetObject() const { return static_cast(ScObject::GetObject()); } diff --git a/src/openrct2/scripting/ScPark.hpp b/src/openrct2/scripting/ScPark.hpp index 9476df9596..74bd8f2e7e 100644 --- a/src/openrct2/scripting/ScPark.hpp +++ b/src/openrct2/scripting/ScPark.hpp @@ -27,7 +27,7 @@ namespace OpenRCT2::Scripting class ScPark { public: - money32 cash_get() + money32 cash_get() const { return gCash; } @@ -39,7 +39,7 @@ namespace OpenRCT2::Scripting context_broadcast_intent(&intent); } - int32_t rating_get() + int32_t rating_get() const { return gParkRating; } @@ -51,7 +51,7 @@ namespace OpenRCT2::Scripting context_broadcast_intent(&intent); } - money32 bankLoan_get() + money32 bankLoan_get() const { return gBankLoan; } @@ -63,7 +63,7 @@ namespace OpenRCT2::Scripting context_broadcast_intent(&intent); } - money32 maxBankLoan_get() + money32 maxBankLoan_get() const { return gMaxBankLoan; } @@ -109,7 +109,7 @@ namespace OpenRCT2::Scripting } private: - uint8_t GetParkMessageType(const std::string& key) + static uint8_t GetParkMessageType(const std::string& key) { static auto keys = { "attraction", "peep_on_attraction", "peep", "money", "blank", "research", "guests", "award", "chart" }; diff --git a/src/openrct2/scripting/ScRide.hpp b/src/openrct2/scripting/ScRide.hpp index 35dde8054e..b9c030a147 100644 --- a/src/openrct2/scripting/ScRide.hpp +++ b/src/openrct2/scripting/ScRide.hpp @@ -31,7 +31,7 @@ namespace OpenRCT2::Scripting } private: - int32_t id_get() + int32_t id_get() const { return _rideId; } @@ -50,13 +50,13 @@ namespace OpenRCT2::Scripting return nullptr; } - int32_t type_get() + int32_t type_get() const { auto ride = GetRide(); return ride != nullptr ? ride->type : 0; } - std::string name_get() + std::string name_get() const { auto ride = GetRide(); return ride != nullptr ? ride->GetName() : std::string(); @@ -71,7 +71,7 @@ namespace OpenRCT2::Scripting } } - int32_t excitement_get() + int32_t excitement_get() const { auto ride = GetRide(); return ride != nullptr ? ride->excitement : 0; @@ -86,7 +86,7 @@ namespace OpenRCT2::Scripting } } - int32_t intensity_get() + int32_t intensity_get() const { auto ride = GetRide(); return ride != nullptr ? ride->intensity : 0; @@ -101,7 +101,7 @@ namespace OpenRCT2::Scripting } } - int32_t nausea_get() + int32_t nausea_get() const { auto ride = GetRide(); return ride != nullptr ? ride->nausea : 0; @@ -116,7 +116,7 @@ namespace OpenRCT2::Scripting } } - int32_t totalCustomers_get() + int32_t totalCustomers_get() const { auto ride = GetRide(); return ride != nullptr ? ride->total_customers : 0; @@ -131,7 +131,7 @@ namespace OpenRCT2::Scripting } } - Ride* GetRide() + Ride* GetRide() const { return get_ride(_rideId); } diff --git a/src/openrct2/scripting/ScTile.hpp b/src/openrct2/scripting/ScTile.hpp index df9530b815..512338a9bf 100644 --- a/src/openrct2/scripting/ScTile.hpp +++ b/src/openrct2/scripting/ScTile.hpp @@ -149,7 +149,7 @@ namespace OpenRCT2::Scripting } } - uint32_t surfaceStyle_get() + uint32_t surfaceStyle_get() const { auto el = _element->AsSurface(); if (el != nullptr) @@ -166,7 +166,7 @@ namespace OpenRCT2::Scripting } } - uint32_t edgeStyle_get() + uint32_t edgeStyle_get() const { auto el = _element->AsSurface(); if (el != nullptr) @@ -183,7 +183,7 @@ namespace OpenRCT2::Scripting } } - uint8_t grassLength_get() + uint8_t grassLength_get() const { auto el = _element->AsSurface(); if (el != nullptr) @@ -201,7 +201,7 @@ namespace OpenRCT2::Scripting } } - bool hasOwnership_get() + bool hasOwnership_get() const { auto el = _element->AsSurface(); if (el != nullptr) @@ -220,7 +220,7 @@ namespace OpenRCT2::Scripting return false; } - uint8_t ownership_get() + uint8_t ownership_get() const { auto el = _element->AsSurface(); if (el != nullptr) @@ -237,7 +237,7 @@ namespace OpenRCT2::Scripting } } - uint8_t parkFences_get() + uint8_t parkFences_get() const { auto el = _element->AsSurface(); if (el != nullptr) @@ -254,7 +254,7 @@ namespace OpenRCT2::Scripting } } - uint8_t trackType_get() + uint8_t trackType_get() const { auto el = _element->AsTrack(); if (el != nullptr) @@ -271,7 +271,7 @@ namespace OpenRCT2::Scripting } } - uint8_t sequence_get() + uint8_t sequence_get() const { switch (_element->GetType()) { @@ -308,7 +308,7 @@ namespace OpenRCT2::Scripting } } - uint8_t ride_get() + uint8_t ride_get() const { switch (_element->GetType()) { @@ -356,7 +356,7 @@ namespace OpenRCT2::Scripting } } - uint8_t station_get() + uint8_t station_get() const { switch (_element->GetType()) { @@ -404,7 +404,7 @@ namespace OpenRCT2::Scripting } } - bool hasChainLift_get() + bool hasChainLift_get() const { auto el = _element->AsTrack(); if (el != nullptr) @@ -421,7 +421,7 @@ namespace OpenRCT2::Scripting } } - uint32_t object_get() + uint32_t object_get() const { switch (_element->GetType()) { @@ -491,7 +491,7 @@ namespace OpenRCT2::Scripting } } - uint8_t age_get() + uint8_t age_get() const { auto el = _element->AsSmallScenery(); if (el != nullptr) @@ -508,7 +508,7 @@ namespace OpenRCT2::Scripting } } - uint8_t primaryColour_get() + uint8_t primaryColour_get() const { switch (_element->GetType()) { @@ -545,7 +545,7 @@ namespace OpenRCT2::Scripting } } - uint8_t secondaryColour_get() + uint8_t secondaryColour_get() const { switch (_element->GetType()) { @@ -802,7 +802,7 @@ namespace OpenRCT2::Scripting } } - uint8_t footpathObject_get() + uint8_t footpathObject_get() const { auto el = _element->AsEntrance(); if (el != nullptr) @@ -903,23 +903,23 @@ namespace OpenRCT2::Scripting } private: - int32_t x_get() + int32_t x_get() const { return _coords.x / COORDS_XY_STEP; } - int32_t y_get() + int32_t y_get() const { return _coords.y / COORDS_XY_STEP; } - size_t numElements_get() + size_t numElements_get() const { auto first = GetFirstElement(); return GetNumElements(first); } - std::vector> elements_get() + std::vector> elements_get() const { std::vector> result; auto first = GetFirstElement(); @@ -935,7 +935,7 @@ namespace OpenRCT2::Scripting return result; } - DukValue data_get() + DukValue data_get() const { auto ctx = GetDukContext(); auto first = map_get_first_element_at(_coords); @@ -998,7 +998,7 @@ namespace OpenRCT2::Scripting } } - std::shared_ptr getElement(size_t index) + std::shared_ptr getElement(size_t index) const { auto first = GetFirstElement(); if (index < GetNumElements(first)) @@ -1069,7 +1069,7 @@ namespace OpenRCT2::Scripting } } - TileElement* GetFirstElement() + TileElement* GetFirstElement() const { return map_get_first_element_at(_coords); } @@ -1088,7 +1088,7 @@ namespace OpenRCT2::Scripting return count; } - duk_context* GetDukContext() + duk_context* GetDukContext() const { auto& scriptEngine = GetContext()->GetScriptEngine(); auto ctx = scriptEngine.GetContext();