From 9906c2a0a851e365e6093955ee14d0165a1836b7 Mon Sep 17 00:00:00 2001 From: Death Killer <884052+deathkiller@users.noreply.github.com> Date: Thu, 2 Jan 2025 01:39:49 +0100 Subject: [PATCH] Refactoring --- Sources/Jazz2/Actors/ActorBase.cpp | 2 +- Sources/Jazz2/Actors/ActorBase.h | 8 +- .../Actors/Multiplayer/RemotablePlayer.cpp | 4 +- .../Actors/Multiplayer/RemotablePlayer.h | 4 +- .../Jazz2/Actors/Multiplayer/RemoteActor.cpp | 4 +- .../Jazz2/Actors/Multiplayer/RemoteActor.h | 4 +- .../Multiplayer/RemotePlayerOnServer.cpp | 6 +- .../Actors/Multiplayer/RemotePlayerOnServer.h | 6 +- Sources/Jazz2/Actors/Player.cpp | 10 +-- Sources/Jazz2/Actors/Player.h | 10 +-- Sources/Jazz2/Collisions/DynamicTree.cpp | 2 +- Sources/Jazz2/Collisions/DynamicTree.h | 6 +- .../Jazz2/Compatibility/AnimSetMapping.cpp | 4 +- Sources/Jazz2/Compatibility/AnimSetMapping.h | 4 +- Sources/Jazz2/Compatibility/JJ2Level.cpp | 4 +- Sources/Jazz2/Compatibility/JJ2Level.h | 4 +- Sources/Jazz2/ContentResolver.cpp | 22 ++--- Sources/Jazz2/ContentResolver.h | 22 ++--- Sources/Jazz2/ILevelHandler.h | 4 +- Sources/Jazz2/LevelHandler.cpp | 4 +- Sources/Jazz2/LevelHandler.h | 4 +- .../Jazz2/Multiplayer/MultiLevelHandler.cpp | 12 +-- Sources/Jazz2/Multiplayer/MultiLevelHandler.h | 10 +-- Sources/Jazz2/Multiplayer/NetworkManager.cpp | 2 +- Sources/Jazz2/Multiplayer/NetworkManager.h | 2 +- Sources/Jazz2/Rendering/BlurRenderPass.cpp | 2 +- Sources/Jazz2/Rendering/BlurRenderPass.h | 2 +- Sources/Jazz2/Scripting/LevelScriptLoader.cpp | 8 +- Sources/Jazz2/Scripting/LevelScriptLoader.h | 8 +- Sources/Jazz2/Scripting/ScriptLoader.cpp | 6 +- Sources/Jazz2/Scripting/ScriptLoader.h | 10 +-- Sources/Jazz2/Tiles/TileMap.cpp | 4 +- Sources/Jazz2/Tiles/TileMap.h | 4 +- Sources/Jazz2/UI/Canvas.cpp | 6 +- Sources/Jazz2/UI/Canvas.h | 6 +- .../Jazz2/UI/Menu/EpisodeSelectSection.cpp | 2 +- Sources/Jazz2/UI/Menu/EpisodeSelectSection.h | 2 +- Sources/Jazz2/UI/Menu/IMenuContainer.h | 6 +- Sources/Jazz2/UI/Menu/InGameMenu.cpp | 6 +- Sources/Jazz2/UI/Menu/InGameMenu.h | 6 +- Sources/Jazz2/UI/Menu/LoadingSection.cpp | 2 +- Sources/Jazz2/UI/Menu/LoadingSection.h | 2 +- Sources/Jazz2/UI/Menu/MainMenu.cpp | 6 +- Sources/Jazz2/UI/Menu/MainMenu.h | 6 +- .../Jazz2/UI/Menu/SimpleMessageSection.cpp | 2 +- Sources/Jazz2/UI/Menu/SimpleMessageSection.h | 2 +- .../UI/Menu/TouchControlsOptionsSection.cpp | 2 +- .../UI/Menu/TouchControlsOptionsSection.h | 2 +- Sources/Main.cpp | 2 +- Sources/Main.h | 17 +++- Sources/Shared/Base/StackAlloc.h | 3 +- Sources/Shared/Base/TypeInfo.h | 8 +- Sources/Shared/Containers/DateTime.h | 12 ++- Sources/Shared/Containers/GrowableArray.h | 82 ++++++++++++++++++- Sources/Shared/IO/MemoryStream.cpp | 4 +- Sources/Shared/IO/MemoryStream.h | 2 +- Sources/Shared/IO/PakFile.cpp | 2 +- Sources/Shared/Threading/Event.h | 4 +- Sources/nCine/Audio/AudioStreamPlayer.cpp | 2 +- Sources/nCine/Audio/AudioStreamPlayer.h | 2 +- Sources/nCine/Backends/Android/EglGfxDevice.h | 4 +- Sources/nCine/Backends/GlfwGfxDevice.cpp | 2 +- Sources/nCine/Backends/GlfwGfxDevice.h | 4 +- Sources/nCine/Backends/SdlGfxDevice.cpp | 2 +- Sources/nCine/Backends/SdlGfxDevice.h | 4 +- Sources/nCine/Backends/Uwp/UwpGfxDevice.cpp | 2 +- Sources/nCine/Backends/Uwp/UwpGfxDevice.h | 4 +- Sources/nCine/Graphics/AnimatedSprite.cpp | 4 +- Sources/nCine/Graphics/AnimatedSprite.h | 4 +- Sources/nCine/Graphics/BaseSprite.cpp | 2 +- Sources/nCine/Graphics/BaseSprite.h | 4 +- Sources/nCine/Graphics/BinaryShaderCache.cpp | 4 +- Sources/nCine/Graphics/BinaryShaderCache.h | 4 +- Sources/nCine/Graphics/Camera.cpp | 2 +- Sources/nCine/Graphics/Camera.h | 2 +- Sources/nCine/Graphics/DrawableNode.cpp | 2 +- Sources/nCine/Graphics/DrawableNode.h | 4 +- Sources/nCine/Graphics/GL/GLShader.cpp | 4 +- Sources/nCine/Graphics/GL/GLShader.h | 4 +- .../nCine/Graphics/GL/GLUniformBlockCache.cpp | 2 +- .../nCine/Graphics/GL/GLUniformBlockCache.h | 2 +- Sources/nCine/Graphics/IGfxDevice.cpp | 6 +- Sources/nCine/Graphics/IGfxDevice.h | 4 +- Sources/nCine/Graphics/MeshSprite.cpp | 4 +- Sources/nCine/Graphics/MeshSprite.h | 4 +- Sources/nCine/Graphics/ParticleAffectors.h | 14 ++-- .../nCine/Graphics/ParticleInitializer.cpp | 16 ++-- Sources/nCine/Graphics/ParticleInitializer.h | 16 ++-- Sources/nCine/Input/IInputManager.cpp | 2 +- Sources/nCine/Input/IInputManager.h | 4 +- Sources/nCine/Input/JoyMapping.cpp | 2 +- Sources/nCine/Input/JoyMapping.h | 5 +- Sources/nCine/Primitives/AABB.h | 16 ++-- Sources/nCine/Primitives/Color.h | 4 +- Sources/nCine/Primitives/Colorf.h | 4 +- Sources/nCine/Primitives/Matrix4x4.h | 6 +- Sources/nCine/Primitives/Quaternion.h | 12 ++- Sources/nCine/Primitives/Rect.h | 4 +- Sources/nCine/Primitives/Vector2.h | 4 +- Sources/nCine/Primitives/Vector3.h | 4 +- Sources/nCine/Primitives/Vector4.h | 4 +- 101 files changed, 360 insertions(+), 247 deletions(-) diff --git a/Sources/Jazz2/Actors/ActorBase.cpp b/Sources/Jazz2/Actors/ActorBase.cpp index 65f2ae99..fa2a5f93 100644 --- a/Sources/Jazz2/Actors/ActorBase.cpp +++ b/Sources/Jazz2/Actors/ActorBase.cpp @@ -1133,7 +1133,7 @@ namespace Jazz2::Actors } } - bool ActorBase::MoveInstantly(const Vector2f& pos, MoveType type, TileCollisionParams& params) + bool ActorBase::MoveInstantly(Vector2f pos, MoveType type, TileCollisionParams& params) { Vector2f newPos; AABBf aabb; diff --git a/Sources/Jazz2/Actors/ActorBase.h b/Sources/Jazz2/Actors/ActorBase.h index f44e5b6f..2f4ee868 100644 --- a/Sources/Jazz2/Actors/ActorBase.h +++ b/Sources/Jazz2/Actors/ActorBase.h @@ -176,8 +176,8 @@ namespace Jazz2::Actors std::int32_t GetMaxHealth(); void DecreaseHealth(std::int32_t amount = 1, ActorBase* collider = nullptr); - bool MoveInstantly(const Vector2f& pos, MoveType type, Tiles::TileCollisionParams& params); - bool MoveInstantly(const Vector2f& pos, MoveType type) + bool MoveInstantly(Vector2f pos, MoveType type, Tiles::TileCollisionParams& params); + bool MoveInstantly(Vector2f pos, MoveType type) { Tiles::TileCollisionParams params = { Tiles::TileDestructType::None, _speed.Y >= 0.0f }; return MoveInstantly(pos, type, params); @@ -189,11 +189,11 @@ namespace Jazz2::Actors bool IsCollidingWith(const AABBf& aabb); void UpdateAABB(); - const Vector2f& GetPos() { + Vector2f GetPos() { return _pos; } - const Vector2f& GetSpeed() { + Vector2f GetSpeed() { return _speed; } diff --git a/Sources/Jazz2/Actors/Multiplayer/RemotablePlayer.cpp b/Sources/Jazz2/Actors/Multiplayer/RemotablePlayer.cpp index 5b98af76..d9960807 100644 --- a/Sources/Jazz2/Actors/Multiplayer/RemotablePlayer.cpp +++ b/Sources/Jazz2/Actors/Multiplayer/RemotablePlayer.cpp @@ -32,7 +32,7 @@ namespace Jazz2::Actors::Multiplayer } } - void RemotablePlayer::OnWaterSplash(const Vector2f& pos, bool inwards) + void RemotablePlayer::OnWaterSplash(Vector2f pos, bool inwards) { // Already created and broadcasted by the server } @@ -91,7 +91,7 @@ namespace Jazz2::Actors::Multiplayer }); } - void RemotablePlayer::MoveRemotely(const Vector2f& pos, const Vector2f& speed) + void RemotablePlayer::MoveRemotely(Vector2f pos, Vector2f speed) { Vector2f posPrev = _pos; MoveInstantly(pos, MoveType::Absolute | MoveType::Force); diff --git a/Sources/Jazz2/Actors/Multiplayer/RemotablePlayer.h b/Sources/Jazz2/Actors/Multiplayer/RemotablePlayer.h index 54a6736c..7ff2d6fb 100644 --- a/Sources/Jazz2/Actors/Multiplayer/RemotablePlayer.h +++ b/Sources/Jazz2/Actors/Multiplayer/RemotablePlayer.h @@ -17,14 +17,14 @@ namespace Jazz2::Actors::Multiplayer void SetTeamId(std::uint8_t value); void WarpIn(ExitType exitType); - void MoveRemotely(const Vector2f& pos, const Vector2f& speed); + void MoveRemotely(Vector2f pos, Vector2f speed); protected: Task OnActivatedAsync(const ActorActivationDetails& details) override; bool OnPerish(ActorBase* collider) override; void OnUpdate(float timeMult) override; - void OnWaterSplash(const Vector2f& pos, bool inwards) override; + void OnWaterSplash(Vector2f pos, bool inwards) override; bool FireCurrentWeapon(WeaponType weaponType) override; diff --git a/Sources/Jazz2/Actors/Multiplayer/RemoteActor.cpp b/Sources/Jazz2/Actors/Multiplayer/RemoteActor.cpp index d592a609..c6dfb047 100644 --- a/Sources/Jazz2/Actors/Multiplayer/RemoteActor.cpp +++ b/Sources/Jazz2/Actors/Multiplayer/RemoteActor.cpp @@ -67,7 +67,7 @@ namespace Jazz2::Actors::Multiplayer ActorBase::OnUpdate(timeMult); } - void RemoteActor::AssignMetadata(const StringView& path, AnimState anim, ActorState state) + void RemoteActor::AssignMetadata(StringView path, AnimState anim, ActorState state) { constexpr ActorState RemotedFlags = ActorState::Illuminated | ActorState::IsInvulnerable | ActorState::TriggersTNT | ActorState::CollideWithOtherActors | ActorState::CollideWithSolidObjects | ActorState::IsSolidObject | @@ -78,7 +78,7 @@ namespace Jazz2::Actors::Multiplayer SetState((GetState() & ~RemotedFlags) | (state & RemotedFlags)); } - void RemoteActor::SyncWithServer(const Vector2f& pos, AnimState anim, float rotation, bool isVisible, bool isFacingLeft, bool animPaused, Actors::ActorRendererType rendererType) + void RemoteActor::SyncWithServer(Vector2f pos, AnimState anim, float rotation, bool isVisible, bool isFacingLeft, bool animPaused, Actors::ActorRendererType rendererType) { Clock& c = nCine::clock(); std::int64_t now = c.now() * 1000 / c.frequency(); diff --git a/Sources/Jazz2/Actors/Multiplayer/RemoteActor.h b/Sources/Jazz2/Actors/Multiplayer/RemoteActor.h index 08e351e1..d8b4e1ab 100644 --- a/Sources/Jazz2/Actors/Multiplayer/RemoteActor.h +++ b/Sources/Jazz2/Actors/Multiplayer/RemoteActor.h @@ -13,8 +13,8 @@ namespace Jazz2::Actors::Multiplayer public: RemoteActor(); - void AssignMetadata(const StringView& path, AnimState anim, ActorState state); - void SyncWithServer(const Vector2f& pos, AnimState anim, float rotation, bool isVisible, bool isFacingLeft, bool animPaused, Actors::ActorRendererType rendererType); + void AssignMetadata(StringView path, AnimState anim, ActorState state); + void SyncWithServer(Vector2f pos, AnimState anim, float rotation, bool isVisible, bool isFacingLeft, bool animPaused, Actors::ActorRendererType rendererType); protected: struct StateFrame { diff --git a/Sources/Jazz2/Actors/Multiplayer/RemotePlayerOnServer.cpp b/Sources/Jazz2/Actors/Multiplayer/RemotePlayerOnServer.cpp index 7fb4c237..9d2cdb2f 100644 --- a/Sources/Jazz2/Actors/Multiplayer/RemotePlayerOnServer.cpp +++ b/Sources/Jazz2/Actors/Multiplayer/RemotePlayerOnServer.cpp @@ -89,7 +89,7 @@ namespace Jazz2::Actors::Multiplayer return success; } - void RemotePlayerOnServer::SyncWithServer(const Vector2f& pos, const Vector2f& speed, bool isVisible, bool isFacingLeft, bool isActivelyPushing) + void RemotePlayerOnServer::SyncWithServer(Vector2f pos, const Vector2f& speed, bool isVisible, bool isFacingLeft, bool isActivelyPushing) { if (_health <= 0) { // Don't sync dead players to avoid cheating @@ -133,7 +133,7 @@ namespace Jazz2::Actors::Multiplayer _speed = speed; } - void RemotePlayerOnServer::OnHitSpring(const Vector2f& pos, const Vector2f& force, bool keepSpeedX, bool keepSpeedY, bool& removeSpecialMove) + void RemotePlayerOnServer::OnHitSpring(Vector2f pos, Vector2f force, bool keepSpeedX, bool keepSpeedY, bool& removeSpecialMove) { if (!static_cast(_levelHandler)->HandlePlayerSpring(this, pos, force, keepSpeedX, keepSpeedY)) { return; @@ -142,7 +142,7 @@ namespace Jazz2::Actors::Multiplayer PlayerOnServer::OnHitSpring(pos, force, keepSpeedX, keepSpeedY, removeSpecialMove); } - void RemotePlayerOnServer::WarpToPosition(const Vector2f& pos, WarpFlags flags) + void RemotePlayerOnServer::WarpToPosition(Vector2f pos, WarpFlags flags) { PlayerOnServer::WarpToPosition(pos, flags); diff --git a/Sources/Jazz2/Actors/Multiplayer/RemotePlayerOnServer.h b/Sources/Jazz2/Actors/Multiplayer/RemotePlayerOnServer.h index d246dd75..505a4b3e 100644 --- a/Sources/Jazz2/Actors/Multiplayer/RemotePlayerOnServer.h +++ b/Sources/Jazz2/Actors/Multiplayer/RemotePlayerOnServer.h @@ -16,7 +16,7 @@ namespace Jazz2::Actors::Multiplayer bool OnHandleCollision(std::shared_ptr other) override; bool OnLevelChanging(Actors::ActorBase* initiator, ExitType exitType) override; - void SyncWithServer(const Vector2f& pos, const Vector2f& speed, bool isVisible, bool isFacingLeft, bool isActivelyPushing); + void SyncWithServer(Vector2f pos, const Vector2f& speed, bool isVisible, bool isFacingLeft, bool isActivelyPushing); protected: struct StateFrame { @@ -34,9 +34,9 @@ namespace Jazz2::Actors::Multiplayer bool OnPerish(ActorBase* collider) override; void OnUpdate(float timeMult) override; - void OnHitSpring(const Vector2f& pos, const Vector2f& force, bool keepSpeedX, bool keepSpeedY, bool& removeSpecialMove) override; + void OnHitSpring(Vector2f pos, Vector2f force, bool keepSpeedX, bool keepSpeedY, bool& removeSpecialMove) override; - void WarpToPosition(const Vector2f& pos, WarpFlags flags) override; + void WarpToPosition(Vector2f pos, WarpFlags flags) override; bool TakeDamage(std::int32_t amount, float pushForce) override; bool AddAmmo(WeaponType weaponType, std::int16_t count) override; diff --git a/Sources/Jazz2/Actors/Player.cpp b/Sources/Jazz2/Actors/Player.cpp index 70f3b176..625af35a 100644 --- a/Sources/Jazz2/Actors/Player.cpp +++ b/Sources/Jazz2/Actors/Player.cpp @@ -1755,7 +1755,7 @@ namespace Jazz2::Actors } } - void Player::OnHitSpring(const Vector2f& pos, const Vector2f& force, bool keepSpeedX, bool keepSpeedY, bool& removeSpecialMove) + void Player::OnHitSpring(Vector2f pos, Vector2f force, bool keepSpeedX, bool keepSpeedY, bool& removeSpecialMove) { std::int32_t sign = ((force.X + force.Y) > std::numeric_limits::epsilon() ? 1 : -1); if (std::abs(force.X) > 0.0f) { @@ -1832,7 +1832,7 @@ namespace Jazz2::Actors } } - void Player::OnWaterSplash(const Vector2f& pos, bool inwards) + void Player::OnWaterSplash(Vector2f pos, bool inwards) { Explosion::Create(_levelHandler, Vector3i((std::int32_t)pos.X, (std::int32_t)pos.Y, _renderer.layer() + 2), Explosion::Type::WaterSplash); _levelHandler->PlayCommonSfx("WaterSplash"_s, Vector3f(pos.X, pos.Y, 0.0f), inwards ? 0.7f : 1.0f, 0.5f); @@ -2554,7 +2554,7 @@ namespace Jazz2::Actors } } - std::shared_ptr Player::PlayPlayerSfx(const StringView identifier, float gain, float pitch) + std::shared_ptr Player::PlayPlayerSfx(StringView identifier, float gain, float pitch) { #if defined(WITH_AUDIO) auto it = _metadata->Sounds.find(String::nullTerminatedView(identifier)); @@ -3366,7 +3366,7 @@ namespace Jazz2::Actors dest.Write(_weaponUpgradesCheckpoint, sizeof(_weaponUpgradesCheckpoint)); } - void Player::Respawn(const Vector2f& pos) + void Player::Respawn(Vector2f pos) { if ((GetState() & (ActorState::IsInvulnerable | ActorState::ApplyGravitation | ActorState::CollideWithTileset | ActorState::CollideWithOtherActors)) != ActorState::IsInvulnerable) { return; @@ -3382,7 +3382,7 @@ namespace Jazz2::Actors SetState(ActorState::ApplyGravitation | ActorState::CollideWithTileset | ActorState::CollideWithOtherActors, true); } - void Player::WarpToPosition(const Vector2f& pos, WarpFlags flags) + void Player::WarpToPosition(Vector2f pos, WarpFlags flags) { if ((flags & WarpFlags::Fast) == WarpFlags::Fast) { Vector2f posPrev = _pos; diff --git a/Sources/Jazz2/Actors/Player.h b/Sources/Jazz2/Actors/Player.h index 4a9184ed..60b56967 100644 --- a/Sources/Jazz2/Actors/Player.h +++ b/Sources/Jazz2/Actors/Player.h @@ -128,8 +128,8 @@ namespace Jazz2::Actors void InitializeFromStream(ILevelHandler* levelHandler, Stream& src, std::uint16_t version); void SerializeResumableToStream(Stream& dest); - void Respawn(const Vector2f& pos); - virtual void WarpToPosition(const Vector2f& pos, WarpFlags flags); + void Respawn(Vector2f pos); + virtual void WarpToPosition(Vector2f pos, WarpFlags flags); void WarpToCheckpoint(); Modifier GetModifier() const; bool SetModifier(Modifier modifier, const std::shared_ptr& decor = nullptr); @@ -294,10 +294,10 @@ namespace Jazz2::Actors void OnHitCeiling(float timeMult) override; void OnHitWall(float timeMult) override; - virtual void OnHitSpring(const Vector2f& pos, const Vector2f& force, bool keepSpeedX, bool keepSpeedY, bool& removeSpecialMove); - virtual void OnWaterSplash(const Vector2f& pos, bool inwards); + virtual void OnHitSpring(Vector2f pos, Vector2f force, bool keepSpeedX, bool keepSpeedY, bool& removeSpecialMove); + virtual void OnWaterSplash(Vector2f pos, bool inwards); - std::shared_ptr PlayPlayerSfx(const StringView identifier, float gain = 1.0f, float pitch = 1.0f); + std::shared_ptr PlayPlayerSfx(StringView identifier, float gain = 1.0f, float pitch = 1.0f); bool SetPlayerTransition(AnimState state, bool cancellable, bool removeControl, SpecialMoveType specialMove, Function&& callback = {}); bool CanFreefall(); void EndDamagingMove(); diff --git a/Sources/Jazz2/Collisions/DynamicTree.cpp b/Sources/Jazz2/Collisions/DynamicTree.cpp index 816da76a..4b88fba9 100644 --- a/Sources/Jazz2/Collisions/DynamicTree.cpp +++ b/Sources/Jazz2/Collisions/DynamicTree.cpp @@ -130,7 +130,7 @@ namespace Jazz2::Collisions FreeNode(proxyId); } - bool DynamicTree::MoveProxy(std::int32_t proxyId, const AABBf& aabb, const Vector2f& displacement) + bool DynamicTree::MoveProxy(std::int32_t proxyId, const AABBf& aabb, Vector2f displacement) { //b2Assert(0 <= proxyId && proxyId < m_nodeCapacity); diff --git a/Sources/Jazz2/Collisions/DynamicTree.h b/Sources/Jazz2/Collisions/DynamicTree.h index 013760c2..c643cc05 100644 --- a/Sources/Jazz2/Collisions/DynamicTree.h +++ b/Sources/Jazz2/Collisions/DynamicTree.h @@ -40,7 +40,7 @@ namespace Jazz2::Collisions constexpr float AabbMultiplier = 4.0f; /** - @brief A node in the dynamic tree + @brief Node in the dynamic tree The client does not interact with this directly. */ @@ -72,7 +72,7 @@ namespace Jazz2::Collisions }; /** - @brief A dynamic AABB tree broad-phase + @brief Dynamic AABB tree broad-phase A dynamic tree arranges data in a binary tree to accelerate queries such as volume queries and ray casts. Leafs are proxies @@ -101,7 +101,7 @@ namespace Jazz2::Collisions /// then the proxy is removed from the tree and re-inserted. Otherwise /// the function returns immediately. /// @return true if the proxy was re-inserted. - bool MoveProxy(std::int32_t proxyId, const AABBf& aabb1, const Vector2f& displacement); + bool MoveProxy(std::int32_t proxyId, const AABBf& aabb1, Vector2f displacement); /// Get proxy user data. /// @return the proxy user data or 0 if the id is invalid. diff --git a/Sources/Jazz2/Compatibility/AnimSetMapping.cpp b/Sources/Jazz2/Compatibility/AnimSetMapping.cpp index 1e3f4446..f341b9a3 100644 --- a/Sources/Jazz2/Compatibility/AnimSetMapping.cpp +++ b/Sources/Jazz2/Compatibility/AnimSetMapping.cpp @@ -1986,7 +1986,7 @@ namespace Jazz2::Compatibility } } - void AnimSetMapping::Add(JJ2Version appliesTo, const StringView& category, const StringView& name, JJ2DefaultPalette palette, bool skipNormalMap, bool allowRealtimePalette) + void AnimSetMapping::Add(JJ2Version appliesTo, StringView category, StringView name, JJ2DefaultPalette palette, bool skipNormalMap, bool allowRealtimePalette) { if ((_version & appliesTo) != JJ2Version::Unknown) { Entry entry; @@ -2005,7 +2005,7 @@ namespace Jazz2::Compatibility } } - void AnimSetMapping::Add(const StringView& category, const StringView& name, JJ2DefaultPalette palette, bool skipNormalMap, bool allowRealtimePalette) + void AnimSetMapping::Add(StringView category, StringView name, JJ2DefaultPalette palette, bool skipNormalMap, bool allowRealtimePalette) { Entry entry; entry.Category = category; diff --git a/Sources/Jazz2/Compatibility/AnimSetMapping.h b/Sources/Jazz2/Compatibility/AnimSetMapping.h index 6e656138..b4c8ef1d 100644 --- a/Sources/Jazz2/Compatibility/AnimSetMapping.h +++ b/Sources/Jazz2/Compatibility/AnimSetMapping.h @@ -53,7 +53,7 @@ namespace Jazz2::Compatibility void DiscardItems(std::uint32_t advanceBy, JJ2Version appliesTo = JJ2Version::All); void SkipItems(std::uint32_t advanceBy = 1); void NextSet(std::uint32_t advanceBy = 1, JJ2Version appliesTo = JJ2Version::All); - void Add(JJ2Version appliesTo, const StringView& category, const StringView& name, JJ2DefaultPalette palette = JJ2DefaultPalette::Sprite, bool skipNormalMap = false, bool allowRealtimePalette = false); - void Add(const StringView& category, const StringView& name, JJ2DefaultPalette palette = JJ2DefaultPalette::Sprite, bool skipNormalMap = false, bool allowRealtimePalette = false); + void Add(JJ2Version appliesTo, StringView category, StringView name, JJ2DefaultPalette palette = JJ2DefaultPalette::Sprite, bool skipNormalMap = false, bool allowRealtimePalette = false); + void Add(StringView category, StringView name, JJ2DefaultPalette palette = JJ2DefaultPalette::Sprite, bool skipNormalMap = false, bool allowRealtimePalette = false); }; } \ No newline at end of file diff --git a/Sources/Jazz2/Compatibility/JJ2Level.cpp b/Sources/Jazz2/Compatibility/JJ2Level.cpp index 8f4e1dc0..65e2039e 100644 --- a/Sources/Jazz2/Compatibility/JJ2Level.cpp +++ b/Sources/Jazz2/Compatibility/JJ2Level.cpp @@ -337,7 +337,7 @@ namespace Jazz2::Compatibility } } - void JJ2Level::LoadMlleData(JJ2Block& block, std::uint32_t version, const StringView& path, bool strictParser) + void JJ2Level::LoadMlleData(JJ2Block& block, std::uint32_t version, StringView path, bool strictParser) { if (version > 0x106) { LOGW("MLLE stream version 0x%x in level \"%s\" is not supported", version, LevelName.data()); @@ -1076,7 +1076,7 @@ namespace Jazz2::Compatibility } } - bool JJ2Level::StringHasSuffixIgnoreCase(const StringView value, const StringView suffix) + bool JJ2Level::StringHasSuffixIgnoreCase(StringView value, StringView suffix) { const std::size_t size = value.size(); const std::size_t suffixSize = suffix.size(); diff --git a/Sources/Jazz2/Compatibility/JJ2Level.h b/Sources/Jazz2/Compatibility/JJ2Level.h index 594397b6..21254497 100644 --- a/Sources/Jazz2/Compatibility/JJ2Level.h +++ b/Sources/Jazz2/Compatibility/JJ2Level.h @@ -159,9 +159,9 @@ namespace Jazz2::Compatibility void LoadLayerMetadata(JJ2Block& block, bool strictParser); void LoadEvents(JJ2Block& block, bool strictParser); void LoadLayers(JJ2Block& dictBlock, std::int32_t dictLength, JJ2Block& layoutBlock, bool strictParser); - void LoadMlleData(JJ2Block& block, uint32_t version, const StringView& path, bool strictParser); + void LoadMlleData(JJ2Block& block, std::uint32_t version, StringView path, bool strictParser); static void WriteLevelName(Stream& so, MutableStringView value, Function&& levelTokenConversion = {}); - static bool StringHasSuffixIgnoreCase(const StringView value, const StringView suffix); + static bool StringHasSuffixIgnoreCase(StringView value, StringView suffix); }; } \ No newline at end of file diff --git a/Sources/Jazz2/ContentResolver.cpp b/Sources/Jazz2/ContentResolver.cpp index 420fa611..7dfb0145 100644 --- a/Sources/Jazz2/ContentResolver.cpp +++ b/Sources/Jazz2/ContentResolver.cpp @@ -449,13 +449,13 @@ namespace Jazz2 _isLoading = false; } - void ContentResolver::PreloadMetadataAsync(const StringView path) + void ContentResolver::PreloadMetadataAsync(StringView path) { // TODO: Reimplement async preloading RequestMetadata(path); } - Metadata* ContentResolver::RequestMetadata(const StringView path) + Metadata* ContentResolver::RequestMetadata(StringView path) { String pathNormalized = fs::ToNativeSeparators(path); auto it = _cachedMetadata.find(pathNormalized); @@ -653,7 +653,7 @@ namespace Jazz2 return _cachedMetadata.emplace(metadata->Path, std::move(metadata)).first->second.get(); } - GenericGraphicResource* ContentResolver::RequestGraphics(const StringView path, uint16_t paletteOffset) + GenericGraphicResource* ContentResolver::RequestGraphics(StringView path, std::uint16_t paletteOffset) { // First resources are requested, reset _isLoading flag, because palette should be already applied _isLoading = false; @@ -770,7 +770,7 @@ namespace Jazz2 return nullptr; } - GenericGraphicResource* ContentResolver::RequestGraphicsAura(const StringView path, std::uint16_t paletteOffset) + GenericGraphicResource* ContentResolver::RequestGraphicsAura(StringView path, std::uint16_t paletteOffset) { auto s = OpenContentFile(fs::CombinePath("Animations"_s, path)); @@ -945,7 +945,7 @@ namespace Jazz2 } } - std::unique_ptr ContentResolver::RequestTileSet(const StringView path, std::uint16_t captionTileId, bool applyPalette, const std::uint8_t* paletteRemapping) + std::unique_ptr ContentResolver::RequestTileSet(StringView path, std::uint16_t captionTileId, bool applyPalette, const std::uint8_t* paletteRemapping) { // Try "Content" directory first, then "Cache" directory String fullPath = fs::CombinePath({ GetContentPath(), "Tilesets"_s, String(path + ".j2t"_s) }); @@ -1137,14 +1137,14 @@ namespace Jazz2 return std::make_unique(tileCount, std::move(textureDiffuse), std::move(mask), maskSize * 8, std::move(captionTile)); } - bool ContentResolver::LevelExists(const StringView episodeName, const StringView levelName) + bool ContentResolver::LevelExists(StringView episodeName, StringView levelName) { // Try "Content" directory first, then "Cache" directory return (fs::IsReadableFile(fs::CombinePath({ GetContentPath(), "Episodes"_s, episodeName, String(levelName + ".j2l"_s) })) || fs::IsReadableFile(fs::CombinePath({ GetCachePath(), "Episodes"_s, episodeName, String(levelName + ".j2l"_s) }))); } - bool ContentResolver::TryLoadLevel(const StringView path, GameDifficulty difficulty, LevelDescriptor& descriptor) + bool ContentResolver::TryLoadLevel(StringView path, GameDifficulty difficulty, LevelDescriptor& descriptor) { // Try "Content" directory first, then "Cache" directory auto pathNormalized = fs::ToNativeSeparators(path); @@ -1308,7 +1308,7 @@ namespace Jazz2 } } - std::optional ContentResolver::GetEpisode(const StringView name, bool withImages) + std::optional ContentResolver::GetEpisode(StringView name, bool withImages) { String fullPath = fs::CombinePath({ GetContentPath(), "Episodes"_s, String(name + ".j2e"_s) }); if (!fs::IsReadableFile(fullPath)) { @@ -1317,7 +1317,7 @@ namespace Jazz2 return GetEpisodeByPath(fullPath, withImages); } - std::optional ContentResolver::GetEpisodeByPath(const StringView path, bool withImages) + std::optional ContentResolver::GetEpisodeByPath(StringView path, bool withImages) { auto s = fs::Open(path, FileAccess::Read); if (s->GetSize() < 16) { @@ -1382,7 +1382,7 @@ namespace Jazz2 return episode; } - std::unique_ptr ContentResolver::GetMusic(const StringView path) + std::unique_ptr ContentResolver::GetMusic(StringView path) { #if defined(WITH_AUDIO) // Don't load sounds in headless mode @@ -1667,7 +1667,7 @@ namespace Jazz2 } #if defined(DEATH_DEBUG) - void ContentResolver::MigrateGraphics(const StringView path) + void ContentResolver::MigrateGraphics(StringView path) { String auraPath = fs::CombinePath({ GetContentPath(), "Animations"_s, String(path.exceptSuffix(4) + ".aura"_s) }); if (fs::FileExists(auraPath)) { diff --git a/Sources/Jazz2/ContentResolver.h b/Sources/Jazz2/ContentResolver.h index 999d4037..c261e015 100644 --- a/Sources/Jazz2/ContentResolver.h +++ b/Sources/Jazz2/ContentResolver.h @@ -73,18 +73,18 @@ namespace Jazz2 void BeginLoading(); void EndLoading(); - void PreloadMetadataAsync(const StringView path); - Metadata* RequestMetadata(const StringView path); - GenericGraphicResource* RequestGraphics(const StringView path, std::uint16_t paletteOffset); + void PreloadMetadataAsync(StringView path); + Metadata* RequestMetadata(StringView path); + GenericGraphicResource* RequestGraphics(StringView path, std::uint16_t paletteOffset); - std::unique_ptr RequestTileSet(const StringView path, std::uint16_t captionTileId, bool applyPalette, const std::uint8_t* paletteRemapping = nullptr); - bool LevelExists(const StringView episodeName, const StringView levelName); - bool TryLoadLevel(const StringView path, GameDifficulty difficulty, LevelDescriptor& descriptor); + std::unique_ptr RequestTileSet(StringView path, std::uint16_t captionTileId, bool applyPalette, const std::uint8_t* paletteRemapping = nullptr); + bool LevelExists(StringView episodeName, StringView levelName); + bool TryLoadLevel(StringView path, GameDifficulty difficulty, LevelDescriptor& descriptor); void ApplyDefaultPalette(); - std::optional GetEpisode(const StringView name, bool withImages = false); - std::optional GetEpisodeByPath(const StringView path, bool withImages = false); - std::unique_ptr GetMusic(const StringView path); + std::optional GetEpisode(StringView name, bool withImages = false); + std::optional GetEpisodeByPath(StringView path, bool withImages = false); + std::unique_ptr GetMusic(StringView path); UI::Font* GetFont(FontType fontType); Shader* GetShader(PrecompiledShader shader); void CompileShaders(); @@ -109,7 +109,7 @@ namespace Jazz2 void InitializePaths(); - GenericGraphicResource* RequestGraphicsAura(const StringView path, std::uint16_t paletteOffset); + GenericGraphicResource* RequestGraphicsAura(StringView path, std::uint16_t paletteOffset); static void ReadImageFromFile(std::unique_ptr& s, std::uint8_t* data, std::int32_t width, std::int32_t height, std::int32_t channelCount); std::unique_ptr CompileShader(const char* shaderName, Shader::DefaultVertex vertex, const char* fragment, Shader::Introspection introspection = Shader::Introspection::Enabled, std::initializer_list defines = {}); @@ -117,7 +117,7 @@ namespace Jazz2 void RecreateGemPalettes(); #if defined(DEATH_DEBUG) - void MigrateGraphics(const StringView path); + void MigrateGraphics(StringView path); #endif bool _isHeadless; diff --git a/Sources/Jazz2/ILevelHandler.h b/Sources/Jazz2/ILevelHandler.h index db76f6cf..6c184f3e 100644 --- a/Sources/Jazz2/ILevelHandler.h +++ b/Sources/Jazz2/ILevelHandler.h @@ -89,10 +89,10 @@ namespace Jazz2 virtual void BeginLevelChange(Actors::ActorBase* initiator, ExitType exitType, const StringView nextLevel = {}) = 0; virtual void HandleGameOver(Actors::Player* player) = 0; virtual bool HandlePlayerDied(Actors::Player* player, Actors::ActorBase* collider) = 0; - virtual void HandlePlayerWarped(Actors::Player* player, const Vector2f& prevPos, WarpFlags flags) = 0; + virtual void HandlePlayerWarped(Actors::Player* player, Vector2f prevPos, WarpFlags flags) = 0; virtual void HandlePlayerCoins(Actors::Player* player, std::int32_t prevCount, std::int32_t newCount) = 0; virtual void HandlePlayerGems(Actors::Player* player, std::uint8_t gemType, std::int32_t prevCount, std::int32_t newCount) = 0; - virtual void SetCheckpoint(Actors::Player* player, const Vector2f& pos) = 0; + virtual void SetCheckpoint(Actors::Player* player, Vector2f pos) = 0; virtual void RollbackToCheckpoint(Actors::Player* player) = 0; virtual void ActivateSugarRush(Actors::Player* player) = 0; virtual void ShowLevelText(const StringView text, Actors::ActorBase* initiator = nullptr) = 0; diff --git a/Sources/Jazz2/LevelHandler.cpp b/Sources/Jazz2/LevelHandler.cpp index 65564de1..32567911 100644 --- a/Sources/Jazz2/LevelHandler.cpp +++ b/Sources/Jazz2/LevelHandler.cpp @@ -1097,7 +1097,7 @@ namespace Jazz2 return true; } - void LevelHandler::HandlePlayerWarped(Actors::Player* player, const Vector2f& prevPos, WarpFlags flags) + void LevelHandler::HandlePlayerWarped(Actors::Player* player, Vector2f prevPos, WarpFlags flags) { if ((flags & WarpFlags::Fast) == WarpFlags::Fast) { WarpCameraToTarget(player, true); @@ -1141,7 +1141,7 @@ namespace Jazz2 } } - void LevelHandler::SetCheckpoint(Actors::Player* player, const Vector2f& pos) + void LevelHandler::SetCheckpoint(Actors::Player* player, Vector2f pos) { _checkpointFrames = ElapsedFrames(); diff --git a/Sources/Jazz2/LevelHandler.h b/Sources/Jazz2/LevelHandler.h index f9a46884..d2048ddc 100644 --- a/Sources/Jazz2/LevelHandler.h +++ b/Sources/Jazz2/LevelHandler.h @@ -134,10 +134,10 @@ namespace Jazz2 void BeginLevelChange(Actors::ActorBase* initiator, ExitType exitType, const StringView nextLevel = {}) override; void HandleGameOver(Actors::Player* player) override; bool HandlePlayerDied(Actors::Player* player, Actors::ActorBase* collider) override; - void HandlePlayerWarped(Actors::Player* player, const Vector2f& prevPos, WarpFlags flags) override; + void HandlePlayerWarped(Actors::Player* player, Vector2f prevPos, WarpFlags flags) override; void HandlePlayerCoins(Actors::Player* player, std::int32_t prevCount, std::int32_t newCount) override; void HandlePlayerGems(Actors::Player* player, std::uint8_t gemType, std::int32_t prevCount, std::int32_t newCount) override; - void SetCheckpoint(Actors::Player* player, const Vector2f& pos) override; + void SetCheckpoint(Actors::Player* player, Vector2f pos) override; void RollbackToCheckpoint(Actors::Player* player) override; void ActivateSugarRush(Actors::Player* player) override; void ShowLevelText(const StringView text, Actors::ActorBase* initiator = nullptr) override; diff --git a/Sources/Jazz2/Multiplayer/MultiLevelHandler.cpp b/Sources/Jazz2/Multiplayer/MultiLevelHandler.cpp index 39527b30..ec339c17 100644 --- a/Sources/Jazz2/Multiplayer/MultiLevelHandler.cpp +++ b/Sources/Jazz2/Multiplayer/MultiLevelHandler.cpp @@ -782,7 +782,7 @@ namespace Jazz2::Multiplayer } } - bool MultiLevelHandler::HandlePlayerSpring(Actors::Player* player, const Vector2f& pos, const Vector2f& force, bool keepSpeedX, bool keepSpeedY) + bool MultiLevelHandler::HandlePlayerSpring(Actors::Player* player, Vector2f pos, Vector2f force, bool keepSpeedX, bool keepSpeedY) { // TODO: Only called by RemotePlayerOnServer if (_isServer) { @@ -813,7 +813,7 @@ namespace Jazz2::Multiplayer return true; } - void MultiLevelHandler::HandlePlayerBeforeWarp(Actors::Player* player, const Vector2f& pos, WarpFlags flags) + void MultiLevelHandler::HandlePlayerBeforeWarp(Actors::Player* player, Vector2f pos, WarpFlags flags) { if (!_isServer) { return; @@ -927,7 +927,7 @@ namespace Jazz2::Multiplayer } } - void MultiLevelHandler::HandlePlayerWarped(Actors::Player* player, const Vector2f& prevPos, WarpFlags flags) + void MultiLevelHandler::HandlePlayerWarped(Actors::Player* player, Vector2f prevPos, WarpFlags flags) { LevelHandler::HandlePlayerWarped(player, prevPos, flags); @@ -994,7 +994,7 @@ namespace Jazz2::Multiplayer } } - void MultiLevelHandler::SetCheckpoint(Actors::Player* player, const Vector2f& pos) + void MultiLevelHandler::SetCheckpoint(Actors::Player* player, Vector2f pos) { LevelHandler::SetCheckpoint(player, pos); } @@ -2403,7 +2403,7 @@ namespace Jazz2::Multiplayer } }*/ - /*void MultiLevelHandler::OnRemotePlayerPosReceived(PlayerState& playerState, const Vector2f& pos, const Vector2f speed, PlayerFlags flags) + /*void MultiLevelHandler::OnRemotePlayerPosReceived(PlayerState& playerState, Vector2f pos, const Vector2f speed, PlayerFlags flags) { Clock& c = nCine::clock(); std::int64_t now = c.now() * 1000 / c.frequency(); @@ -2547,7 +2547,7 @@ namespace Jazz2::Multiplayer { } - MultiLevelHandler::PlayerState::PlayerState(const Vector2f& pos, const Vector2f& speed) + MultiLevelHandler::PlayerState::PlayerState(Vector2f pos, Vector2f speed) : Flags(PlayerFlags::None), PressedKeys(0), PressedKeysLast(0), UpdatedFrame(0)/*, WarpSeqNum(0), WarpTimeLeft(0.0f)*/ { } diff --git a/Sources/Jazz2/Multiplayer/MultiLevelHandler.h b/Sources/Jazz2/Multiplayer/MultiLevelHandler.h index d6448a59..02f679dd 100644 --- a/Sources/Jazz2/Multiplayer/MultiLevelHandler.h +++ b/Sources/Jazz2/Multiplayer/MultiLevelHandler.h @@ -61,10 +61,10 @@ namespace Jazz2::Multiplayer void BeginLevelChange(Actors::ActorBase* initiator, ExitType exitType, const StringView nextLevel = {}) override; void HandleGameOver(Actors::Player* player) override; bool HandlePlayerDied(Actors::Player* player, Actors::ActorBase* collider) override; - void HandlePlayerWarped(Actors::Player* player, const Vector2f& prevPos, WarpFlags flags) override; + void HandlePlayerWarped(Actors::Player* player, Vector2f prevPos, WarpFlags flags) override; void HandlePlayerCoins(Actors::Player* player, std::int32_t prevCount, std::int32_t newCount) override; void HandlePlayerGems(Actors::Player* player, std::uint8_t gemType, std::int32_t prevCount, std::int32_t newCount) override; - void SetCheckpoint(Actors::Player* player, const Vector2f& pos) override; + void SetCheckpoint(Actors::Player* player, Vector2f pos) override; void RollbackToCheckpoint(Actors::Player* player) override; void ActivateSugarRush(Actors::Player* player) override; void ShowLevelText(const StringView text, Actors::ActorBase* initiator = nullptr) override; @@ -103,8 +103,8 @@ namespace Jazz2::Multiplayer void PrepareNextLevelInitialization(LevelInitialization& levelInit) override; void HandlePlayerLevelChanging(Actors::Player* player, ExitType exitType); - bool HandlePlayerSpring(Actors::Player* player, const Vector2f& pos, const Vector2f& force, bool keepSpeedX, bool keepSpeedY); - void HandlePlayerBeforeWarp(Actors::Player* player, const Vector2f& pos, WarpFlags flags); + bool HandlePlayerSpring(Actors::Player* player, Vector2f pos, Vector2f force, bool keepSpeedX, bool keepSpeedY); + void HandlePlayerBeforeWarp(Actors::Player* player, Vector2f pos, WarpFlags flags); void HandlePlayerTakeDamage(Actors::Player* player, std::int32_t amount, float pushForce); void HandlePlayerRefreshAmmo(Actors::Player* player, WeaponType weaponType); void HandlePlayerRefreshWeaponUpgrades(Actors::Player* player, WeaponType weaponType); @@ -150,7 +150,7 @@ namespace Jazz2::Multiplayer //float WarpTimeLeft; PlayerState(); - PlayerState(const Vector2f& pos, const Vector2f& speed); + PlayerState(Vector2f pos, Vector2f speed); }; struct MultiplayerSpawnPoint { diff --git a/Sources/Jazz2/Multiplayer/NetworkManager.cpp b/Sources/Jazz2/Multiplayer/NetworkManager.cpp index 6448d16a..e4bab191 100644 --- a/Sources/Jazz2/Multiplayer/NetworkManager.cpp +++ b/Sources/Jazz2/Multiplayer/NetworkManager.cpp @@ -43,7 +43,7 @@ namespace Jazz2::Multiplayer ReleaseBackend(); } - bool NetworkManager::CreateClient(INetworkHandler* handler, const StringView& address, std::uint16_t port, std::uint32_t clientData) + bool NetworkManager::CreateClient(INetworkHandler* handler, StringView address, std::uint16_t port, std::uint32_t clientData) { if (_host != nullptr) { return false; diff --git a/Sources/Jazz2/Multiplayer/NetworkManager.h b/Sources/Jazz2/Multiplayer/NetworkManager.h index 1d94d394..dd37cbb6 100644 --- a/Sources/Jazz2/Multiplayer/NetworkManager.h +++ b/Sources/Jazz2/Multiplayer/NetworkManager.h @@ -51,7 +51,7 @@ namespace Jazz2::Multiplayer NetworkManager(const NetworkManager&) = delete; NetworkManager& operator=(const NetworkManager&) = delete; - bool CreateClient(INetworkHandler* handler, const StringView& address, std::uint16_t port, std::uint32_t clientData); + bool CreateClient(INetworkHandler* handler, StringView address, std::uint16_t port, std::uint32_t clientData); bool CreateServer(INetworkHandler* handler, std::uint16_t port); void Dispose(); diff --git a/Sources/Jazz2/Rendering/BlurRenderPass.cpp b/Sources/Jazz2/Rendering/BlurRenderPass.cpp index cbf51eef..1f3f28ed 100644 --- a/Sources/Jazz2/Rendering/BlurRenderPass.cpp +++ b/Sources/Jazz2/Rendering/BlurRenderPass.cpp @@ -5,7 +5,7 @@ namespace Jazz2::Rendering { - void BlurRenderPass::Initialize(Texture* source, std::int32_t width, std::int32_t height, const Vector2f& direction) + void BlurRenderPass::Initialize(Texture* source, std::int32_t width, std::int32_t height, Vector2f direction) { _source = source; _downsampleOnly = (direction.X <= std::numeric_limits::epsilon() && direction.Y <= std::numeric_limits::epsilon()); diff --git a/Sources/Jazz2/Rendering/BlurRenderPass.h b/Sources/Jazz2/Rendering/BlurRenderPass.h index d166c851..48a8abde 100644 --- a/Sources/Jazz2/Rendering/BlurRenderPass.h +++ b/Sources/Jazz2/Rendering/BlurRenderPass.h @@ -16,7 +16,7 @@ namespace Jazz2::Rendering setVisitOrderState(SceneNode::VisitOrderState::Disabled); } - void Initialize(Texture* source, std::int32_t width, std::int32_t height, const Vector2f& direction); + void Initialize(Texture* source, std::int32_t width, std::int32_t height, Vector2f direction); void Register(); bool OnDraw(RenderQueue& renderQueue) override; diff --git a/Sources/Jazz2/Scripting/LevelScriptLoader.cpp b/Sources/Jazz2/Scripting/LevelScriptLoader.cpp index 49ace96b..76365fa0 100644 --- a/Sources/Jazz2/Scripting/LevelScriptLoader.cpp +++ b/Sources/Jazz2/Scripting/LevelScriptLoader.cpp @@ -61,7 +61,7 @@ namespace Jazz2::Scripting return Random().FastFloat(min, max); } - LevelScriptLoader::LevelScriptLoader(LevelHandler* levelHandler, const StringView& scriptPath) + LevelScriptLoader::LevelScriptLoader(LevelHandler* levelHandler, StringView scriptPath) : _levelHandler(levelHandler), _onLevelUpdate(nullptr), _onLevelUpdateLastFrame(-1), _onDrawAmmo(nullptr), _onDrawHealth(nullptr), _onDrawLives(nullptr), _onDrawPlayerTimer(nullptr), _onDrawScore(nullptr), _onDrawGameModeHUD(nullptr), _enabledCallbacks(NoInit, 256) @@ -153,7 +153,7 @@ namespace Jazz2::Scripting } } - String LevelScriptLoader::OnProcessInclude(const StringView& includePath, const StringView& scriptPath) + String LevelScriptLoader::OnProcessInclude(StringView includePath, StringView scriptPath) { // Skip MLLE files, because it's handled natively if (includePath.hasPrefix("MLLE-Include-"_s) && includePath.hasSuffix(".asc"_s)) { @@ -167,7 +167,7 @@ namespace Jazz2::Scripting return fs::FindPathCaseInsensitive(fs::CombinePath(sourcePath, includePath)); } - void LevelScriptLoader::OnProcessPragma(const StringView& content, ScriptContextType& contextType) + void LevelScriptLoader::OnProcessPragma(StringView content, ScriptContextType& contextType) { // #pragma target Jazz² Resurrection - Changes script context type to Standard if (content == "target Jazz² Resurrection"_s || content == "target Jazz2 Resurrection"_s) { @@ -3454,7 +3454,7 @@ namespace Jazz2::Scripting return result->second.get(); } - Actors::ActorBase* LevelScriptLoader::CreateActorInstance(const StringView& typeName) + Actors::ActorBase* LevelScriptLoader::CreateActorInstance(StringView typeName) { auto nullTerminatedTypeName = String::nullTerminatedView(typeName); diff --git a/Sources/Jazz2/Scripting/LevelScriptLoader.h b/Sources/Jazz2/Scripting/LevelScriptLoader.h index 0f8bfa2b..1e7de209 100644 --- a/Sources/Jazz2/Scripting/LevelScriptLoader.h +++ b/Sources/Jazz2/Scripting/LevelScriptLoader.h @@ -31,7 +31,7 @@ namespace Jazz2::Scripting friend class jjPLAYER; public: - LevelScriptLoader(LevelHandler* levelHandler, const StringView& scriptPath); + LevelScriptLoader(LevelHandler* levelHandler, StringView scriptPath); const SmallVectorImpl& GetPlayers() const; @@ -47,8 +47,8 @@ namespace Jazz2::Scripting void OnPlayerDied(Actors::Player* player, Actors::ActorBase* collider); protected: - String OnProcessInclude(const StringView& includePath, const StringView& scriptPath) override; - void OnProcessPragma(const StringView& content, ScriptContextType& contextType) override; + String OnProcessInclude(StringView includePath, StringView scriptPath) override; + void OnProcessPragma(StringView content, ScriptContextType& contextType) override; private: LevelHandler* _levelHandler; @@ -128,7 +128,7 @@ namespace Jazz2::Scripting LevelScriptLoader(const LevelScriptLoader&) = delete; LevelScriptLoader& operator=(const LevelScriptLoader&) = delete; - Actors::ActorBase* CreateActorInstance(const StringView& typeName); + Actors::ActorBase* CreateActorInstance(StringView typeName); static void RegisterBuiltInFunctions(asIScriptEngine* engine); void RegisterLegacyFunctions(asIScriptEngine* engine); diff --git a/Sources/Jazz2/Scripting/ScriptLoader.cpp b/Sources/Jazz2/Scripting/ScriptLoader.cpp index 353232bf..16909e74 100644 --- a/Sources/Jazz2/Scripting/ScriptLoader.cpp +++ b/Sources/Jazz2/Scripting/ScriptLoader.cpp @@ -60,7 +60,7 @@ namespace Jazz2::Scripting } } - ScriptContextType ScriptLoader::AddScriptFromFile(const StringView& path, const HashMap& definedSymbols) + ScriptContextType ScriptLoader::AddScriptFromFile(StringView path, const HashMap& definedSymbols) { String absolutePath = fs::GetAbsolutePath(path); if (absolutePath.empty()) { @@ -663,7 +663,7 @@ namespace Jazz2::Scripting return pos; } - int ScriptLoader::ExtractDeclaration(const StringView& scriptContent, int pos, String& name, String& declaration, MetadataType& type) + int ScriptLoader::ExtractDeclaration(StringView scriptContent, int pos, String& name, String& declaration, MetadataType& type) { int scriptSize = (int)scriptContent.size(); int start = pos; @@ -815,7 +815,7 @@ namespace Jazz2::Scripting return methodIt->second; } - String ScriptLoader::MakeRelativePath(const StringView& path, const StringView& relativeToFile) + String ScriptLoader::MakeRelativePath(StringView path, StringView relativeToFile) { if (path.empty() || path.size() > fs::MaxPathLength) return { }; diff --git a/Sources/Jazz2/Scripting/ScriptLoader.h b/Sources/Jazz2/Scripting/ScriptLoader.h index 1a5154a7..9a2d725f 100644 --- a/Sources/Jazz2/Scripting/ScriptLoader.h +++ b/Sources/Jazz2/Scripting/ScriptLoader.h @@ -51,7 +51,7 @@ namespace Jazz2::Scripting asIScriptModule* _module; ScriptContextType _scriptContextType; - ScriptContextType AddScriptFromFile(const StringView& path, const HashMap& definedSymbols); + ScriptContextType AddScriptFromFile(StringView path, const HashMap& definedSymbols); int Build(); ArrayView GetMetadataForType(int typeId); @@ -60,10 +60,10 @@ namespace Jazz2::Scripting ArrayView GetMetadataForTypeProperty(int typeId, int varIdx); ArrayView GetMetadataForTypeMethod(int typeId, asIScriptFunction* method); - virtual String OnProcessInclude(const StringView& includePath, const StringView& scriptPath) = 0; - virtual void OnProcessPragma(const StringView& content, ScriptContextType& contextType) { } + virtual String OnProcessInclude(StringView includePath, StringView scriptPath) = 0; + virtual void OnProcessPragma(StringView content, ScriptContextType& contextType) { } - static String MakeRelativePath(const StringView& path, const StringView& relativeToFile); + static String MakeRelativePath(StringView path, StringView relativeToFile); private: enum class MetadataType { @@ -103,7 +103,7 @@ namespace Jazz2::Scripting int ExcludeCode(String& scriptContent, int pos); int SkipStatement(String& scriptContent, int pos); int ExtractMetadata(MutableStringView scriptContent, int pos, SmallVectorImpl& metadata); - int ExtractDeclaration(const StringView& scriptContent, int pos, String& name, String& declaration, MetadataType& type); + int ExtractDeclaration(StringView scriptContent, int pos, String& name, String& declaration, MetadataType& type); static asIScriptContext* RequestContextCallback(asIScriptEngine* engine, void* param); static void ReturnContextCallback(asIScriptEngine* engine, asIScriptContext* ctx, void* param); diff --git a/Sources/Jazz2/Tiles/TileMap.cpp b/Sources/Jazz2/Tiles/TileMap.cpp index 87fab8e5..3ad7144c 100644 --- a/Sources/Jazz2/Tiles/TileMap.cpp +++ b/Sources/Jazz2/Tiles/TileMap.cpp @@ -576,7 +576,7 @@ namespace Jazz2::Tiles } } - void TileMap::DrawLayer(RenderQueue& renderQueue, TileMapLayer& layer, const Rectf& cullingRect, const Vector2f& viewCenter) + void TileMap::DrawLayer(RenderQueue& renderQueue, TileMapLayer& layer, const Rectf& cullingRect, Vector2f viewCenter) { ZoneScopedNC("Layer", 0xA09359); @@ -1360,7 +1360,7 @@ namespace Jazz2::Tiles dest.Write(_triggerState.data(), _triggerState.sizeInBytes()); } - void TileMap::RenderTexturedBackground(RenderQueue& renderQueue, const Rectf& cullingRect, const Vector2f& viewCenter, TileMapLayer& layer, float x, float y) + void TileMap::RenderTexturedBackground(RenderQueue& renderQueue, const Rectf& cullingRect, Vector2f viewCenter, TileMapLayer& layer, float x, float y) { auto target = _texturedBackgroundPass._target.get(); if (target == nullptr) { diff --git a/Sources/Jazz2/Tiles/TileMap.h b/Sources/Jazz2/Tiles/TileMap.h index 5955014a..68bef747 100644 --- a/Sources/Jazz2/Tiles/TileMap.h +++ b/Sources/Jazz2/Tiles/TileMap.h @@ -262,7 +262,7 @@ namespace Jazz2::Tiles std::int32_t _texturedBackgroundLayer; TexturedBackgroundPass _texturedBackgroundPass; - void DrawLayer(RenderQueue& renderQueue, TileMapLayer& layer, const Rectf& cullingRect, const Vector2f& viewCenter); + void DrawLayer(RenderQueue& renderQueue, TileMapLayer& layer, const Rectf& cullingRect, Vector2f viewCenter); static float TranslateCoordinate(float coordinate, float speed, float offset, std::int32_t viewSize, bool isY); RenderCommand* RentRenderCommand(LayerRendererType type); @@ -273,7 +273,7 @@ namespace Jazz2::Tiles void UpdateDebris(float timeMult); void DrawDebris(RenderQueue& renderQueue); - void RenderTexturedBackground(RenderQueue& renderQueue, const Rectf& cullingRect, const Vector2f& viewCenter, TileMapLayer& layer, float x, float y); + void RenderTexturedBackground(RenderQueue& renderQueue, const Rectf& cullingRect, Vector2f viewCenter, TileMapLayer& layer, float x, float y); TileSet* ResolveTileSet(std::int32_t& tileId); std::int32_t ResolveTileID(LayerTile& tile); diff --git a/Sources/Jazz2/UI/Canvas.cpp b/Sources/Jazz2/UI/Canvas.cpp index 429c8bad..6ba6c94f 100644 --- a/Sources/Jazz2/UI/Canvas.cpp +++ b/Sources/Jazz2/UI/Canvas.cpp @@ -33,7 +33,7 @@ namespace Jazz2::UI _currentRenderQueue->addCommand(command); } - void Canvas::DrawTexture(const Texture& texture, const Vector2f& pos, std::uint16_t z, const Vector2f& size, const Vector4f& texCoords, const Colorf& color, bool additiveBlending, float angle) + void Canvas::DrawTexture(const Texture& texture, Vector2f pos, std::uint16_t z, Vector2f size, const Vector4f& texCoords, const Colorf& color, bool additiveBlending, float angle) { auto command = RentRenderCommand(); if (command->material().setShaderProgramType(Material::ShaderProgramType::Sprite)) { @@ -72,7 +72,7 @@ namespace Jazz2::UI _currentRenderQueue->addCommand(command); } - void Canvas::DrawSolid(const Vector2f& pos, std::uint16_t z, const Vector2f& size, const Colorf& color, bool additiveBlending) + void Canvas::DrawSolid(Vector2f pos, std::uint16_t z, Vector2f size, const Colorf& color, bool additiveBlending) { auto command = RentRenderCommand(); if (command->material().setShaderProgramType(Material::ShaderProgramType::SpriteNoTexture)) { @@ -98,7 +98,7 @@ namespace Jazz2::UI _currentRenderQueue->addCommand(command); } - Vector2f Canvas::ApplyAlignment(Alignment align, const Vector2f& vec, const Vector2f& size) + Vector2f Canvas::ApplyAlignment(Alignment align, Vector2f vec, Vector2f size) { Vector2f result = vec; diff --git a/Sources/Jazz2/UI/Canvas.h b/Sources/Jazz2/UI/Canvas.h index c76a106a..28bca022 100644 --- a/Sources/Jazz2/UI/Canvas.h +++ b/Sources/Jazz2/UI/Canvas.h @@ -22,9 +22,9 @@ namespace Jazz2::UI void OnUpdate(float timeMult) override; bool OnDraw(RenderQueue& renderQueue) override; - void DrawTexture(const Texture& texture, const Vector2f& pos, std::uint16_t z, const Vector2f& size, const Vector4f& texCoords, const Colorf& color, bool additiveBlending = false, float angle = 0.0f); - void DrawSolid(const Vector2f& pos, std::uint16_t z, const Vector2f& size, const Colorf& color, bool additiveBlending = false); - static Vector2f ApplyAlignment(Alignment align, const Vector2f& vec, const Vector2f& size); + void DrawTexture(const Texture& texture, Vector2f pos, std::uint16_t z, Vector2f size, const Vector4f& texCoords, const Colorf& color, bool additiveBlending = false, float angle = 0.0f); + void DrawSolid(Vector2f pos, std::uint16_t z, Vector2f size, const Colorf& color, bool additiveBlending = false); + static Vector2f ApplyAlignment(Alignment align, Vector2f vec, Vector2f size); RenderCommand* RentRenderCommand(); void DrawRenderCommand(RenderCommand* command); diff --git a/Sources/Jazz2/UI/Menu/EpisodeSelectSection.cpp b/Sources/Jazz2/UI/Menu/EpisodeSelectSection.cpp index 486a6048..1cbb13d2 100644 --- a/Sources/Jazz2/UI/Menu/EpisodeSelectSection.cpp +++ b/Sources/Jazz2/UI/Menu/EpisodeSelectSection.cpp @@ -436,7 +436,7 @@ namespace Jazz2::UI::Menu _root->ChangeLevel(std::move(levelInit)); } - void EpisodeSelectSection::AddEpisode(const StringView& episodeFile) + void EpisodeSelectSection::AddEpisode(StringView episodeFile) { if (fs::GetExtension(episodeFile) != "j2e"_s) { return; diff --git a/Sources/Jazz2/UI/Menu/EpisodeSelectSection.h b/Sources/Jazz2/UI/Menu/EpisodeSelectSection.h index e3226f3f..6664eda5 100644 --- a/Sources/Jazz2/UI/Menu/EpisodeSelectSection.h +++ b/Sources/Jazz2/UI/Menu/EpisodeSelectSection.h @@ -47,6 +47,6 @@ namespace Jazz2::UI::Menu void OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) override; void OnAfterTransition(); - void AddEpisode(const StringView& episodeFile); + void AddEpisode(StringView episodeFile); }; } \ No newline at end of file diff --git a/Sources/Jazz2/UI/Menu/IMenuContainer.h b/Sources/Jazz2/UI/Menu/IMenuContainer.h index 71d25e71..3a7c282d 100644 --- a/Sources/Jazz2/UI/Menu/IMenuContainer.h +++ b/Sources/Jazz2/UI/Menu/IMenuContainer.h @@ -61,9 +61,9 @@ namespace Jazz2::UI::Menu virtual void DrawElement(AnimState state, int32_t frame, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float scaleX = 1.0f, float scaleY = 1.0f, bool additiveBlending = false, bool unaligned = false) = 0; virtual void DrawElement(AnimState state, float x, float y, std::uint16_t z, Alignment align, - const Colorf& color, const Vector2f& size, const Vector4f& texCoords, bool unaligned = false) = 0; - virtual void DrawSolid(float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool additiveBlending = false) = 0; - virtual void DrawTexture(const Texture& texture, float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool unaligned = false) = 0; + const Colorf& color, Vector2f size, const Vector4f& texCoords, bool unaligned = false) = 0; + virtual void DrawSolid(float x, float y, std::uint16_t z, Alignment align, Vector2f size, const Colorf& color, bool additiveBlending = false) = 0; + virtual void DrawTexture(const Texture& texture, float x, float y, std::uint16_t z, Alignment align, Vector2f size, const Colorf& color, bool unaligned = false) = 0; virtual Vector2f MeasureString(const StringView text, float scale = 1.0f, float charSpacing = 1.0f, float lineSpacing = 1.0f) = 0; virtual void DrawStringShadow(const StringView text, std::int32_t& charOffset, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float scale = 1.0f, float angleOffset = 0.0f, float varianceX = 4.0f, float varianceY = 4.0f, diff --git a/Sources/Jazz2/UI/Menu/InGameMenu.cpp b/Sources/Jazz2/UI/Menu/InGameMenu.cpp index 373b71d9..8018fab0 100644 --- a/Sources/Jazz2/UI/Menu/InGameMenu.cpp +++ b/Sources/Jazz2/UI/Menu/InGameMenu.cpp @@ -397,7 +397,7 @@ namespace Jazz2::UI::Menu currentCanvas->DrawTexture(*base->TextureDiffuse.get(), adjustedPos, z, size, texCoords, color, additiveBlending); } - void InGameMenu::DrawElement(AnimState state, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, const Vector2f& size, const Vector4f& texCoords, bool unaligned) + void InGameMenu::DrawElement(AnimState state, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, Vector2f size, const Vector4f& texCoords, bool unaligned) { auto* res = _metadata->FindAnimation(state); if (res == nullptr) { @@ -415,7 +415,7 @@ namespace Jazz2::UI::Menu currentCanvas->DrawTexture(*base->TextureDiffuse.get(), adjustedPos, z, size, texCoords, color, false); } - void InGameMenu::DrawSolid(float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool additiveBlending) + void InGameMenu::DrawSolid(float x, float y, std::uint16_t z, Alignment align, Vector2f size, const Colorf& color, bool additiveBlending) { Canvas* currentCanvas = GetActiveCanvas(); Vector2f adjustedPos = Canvas::ApplyAlignment(align, Vector2f(x, y), size); @@ -425,7 +425,7 @@ namespace Jazz2::UI::Menu currentCanvas->DrawSolid(adjustedPos, z, size, color, additiveBlending); } - void InGameMenu::DrawTexture(const Texture& texture, float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool unaligned) + void InGameMenu::DrawTexture(const Texture& texture, float x, float y, std::uint16_t z, Alignment align, Vector2f size, const Colorf& color, bool unaligned) { Canvas* currentCanvas = GetActiveCanvas(); Vector2f adjustedPos = Canvas::ApplyAlignment(align, Vector2f(x, y), size); diff --git a/Sources/Jazz2/UI/Menu/InGameMenu.h b/Sources/Jazz2/UI/Menu/InGameMenu.h index f7cdcf87..ff40d86b 100644 --- a/Sources/Jazz2/UI/Menu/InGameMenu.h +++ b/Sources/Jazz2/UI/Menu/InGameMenu.h @@ -55,9 +55,9 @@ namespace Jazz2::UI::Menu void DrawElement(AnimState state, std::int32_t frame, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float scaleX = 1.0f, float scaleY = 1.0f, bool additiveBlending = false, bool unaligned = false) override; void DrawElement(AnimState state, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, - const Vector2f& size, const Vector4f& texCoords, bool unaligned = false) override; - void DrawSolid(float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool additiveBlending = false) override; - void DrawTexture(const Texture& texture, float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool unaligned = false) override; + Vector2f size, const Vector4f& texCoords, bool unaligned = false) override; + void DrawSolid(float x, float y, std::uint16_t z, Alignment align, Vector2f size, const Colorf& color, bool additiveBlending = false) override; + void DrawTexture(const Texture& texture, float x, float y, std::uint16_t z, Alignment align, Vector2f size, const Colorf& color, bool unaligned = false) override; Vector2f MeasureString(const StringView text, float scale = 1.0f, float charSpacing = 1.0f, float lineSpacing = 1.0f) override; void DrawStringShadow(const StringView text, std::int32_t& charOffset, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float scale = 1.0f, float angleOffset = 0.0f, float varianceX = 4.0f, float varianceY = 4.0f, diff --git a/Sources/Jazz2/UI/Menu/LoadingSection.cpp b/Sources/Jazz2/UI/Menu/LoadingSection.cpp index 6513d0a4..1ad76b92 100644 --- a/Sources/Jazz2/UI/Menu/LoadingSection.cpp +++ b/Sources/Jazz2/UI/Menu/LoadingSection.cpp @@ -2,7 +2,7 @@ namespace Jazz2::UI::Menu { - LoadingSection::LoadingSection(const StringView& message) + LoadingSection::LoadingSection(StringView message) : _message(message) { } diff --git a/Sources/Jazz2/UI/Menu/LoadingSection.h b/Sources/Jazz2/UI/Menu/LoadingSection.h index c67f0d4e..4d9196f2 100644 --- a/Sources/Jazz2/UI/Menu/LoadingSection.h +++ b/Sources/Jazz2/UI/Menu/LoadingSection.h @@ -7,7 +7,7 @@ namespace Jazz2::UI::Menu class LoadingSection : public MenuSection { public: - LoadingSection(const StringView& message); + LoadingSection(StringView message); LoadingSection(String&& message); void OnUpdate(float timeMult) override; diff --git a/Sources/Jazz2/UI/Menu/MainMenu.cpp b/Sources/Jazz2/UI/Menu/MainMenu.cpp index b9ab6fb6..6b753818 100644 --- a/Sources/Jazz2/UI/Menu/MainMenu.cpp +++ b/Sources/Jazz2/UI/Menu/MainMenu.cpp @@ -482,7 +482,7 @@ namespace Jazz2::UI::Menu currentCanvas->DrawTexture(*base->TextureDiffuse.get(), adjustedPos, z, size, texCoords, color, additiveBlending); } - void MainMenu::DrawElement(AnimState state, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, const Vector2f& size, const Vector4f& texCoords, bool unaligned) + void MainMenu::DrawElement(AnimState state, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, Vector2f size, const Vector4f& texCoords, bool unaligned) { auto* res = _metadata->FindAnimation(state); if (res == nullptr) { @@ -500,7 +500,7 @@ namespace Jazz2::UI::Menu currentCanvas->DrawTexture(*base->TextureDiffuse.get(), adjustedPos, z, size, texCoords, color, false); } - void MainMenu::DrawSolid(float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool additiveBlending) + void MainMenu::DrawSolid(float x, float y, std::uint16_t z, Alignment align, Vector2f size, const Colorf& color, bool additiveBlending) { Canvas* currentCanvas = GetActiveCanvas(); Vector2f adjustedPos = Canvas::ApplyAlignment(align, Vector2f(x, y), size); @@ -510,7 +510,7 @@ namespace Jazz2::UI::Menu currentCanvas->DrawSolid(adjustedPos, z, size, color, additiveBlending); } - void MainMenu::DrawTexture(const Texture& texture, float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool unaligned) + void MainMenu::DrawTexture(const Texture& texture, float x, float y, std::uint16_t z, Alignment align, Vector2f size, const Colorf& color, bool unaligned) { Canvas* currentCanvas = GetActiveCanvas(); Vector2f adjustedPos = Canvas::ApplyAlignment(align, Vector2f(x, y), size); diff --git a/Sources/Jazz2/UI/Menu/MainMenu.h b/Sources/Jazz2/UI/Menu/MainMenu.h index da4fbecf..e298a1e8 100644 --- a/Sources/Jazz2/UI/Menu/MainMenu.h +++ b/Sources/Jazz2/UI/Menu/MainMenu.h @@ -75,9 +75,9 @@ namespace Jazz2::UI::Menu void DrawElement(AnimState state, std::int32_t frame, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float scaleX = 1.0f, float scaleY = 1.0f, bool additiveBlending = false, bool unaligned = false) override; void DrawElement(AnimState state, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, - const Vector2f& size, const Vector4f& texCoords, bool unaligned = false) override; - void DrawSolid(float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool additiveBlending = false) override; - void DrawTexture(const Texture& texture, float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool unaligned = false) override; + Vector2f size, const Vector4f& texCoords, bool unaligned = false) override; + void DrawSolid(float x, float y, std::uint16_t z, Alignment align, Vector2f size, const Colorf& color, bool additiveBlending = false) override; + void DrawTexture(const Texture& texture, float x, float y, std::uint16_t z, Alignment align, Vector2f size, const Colorf& color, bool unaligned = false) override; Vector2f MeasureString(const StringView text, float scale = 1.0f, float charSpacing = 1.0f, float lineSpacing = 1.0f) override; void DrawStringShadow(const StringView text, std::int32_t& charOffset, float x, float y, uint16_t z, Alignment align, const Colorf& color, float scale = 1.0f, float angleOffset = 0.0f, float varianceX = 4.0f, float varianceY = 4.0f, diff --git a/Sources/Jazz2/UI/Menu/SimpleMessageSection.cpp b/Sources/Jazz2/UI/Menu/SimpleMessageSection.cpp index 7396da9b..cd948c0e 100644 --- a/Sources/Jazz2/UI/Menu/SimpleMessageSection.cpp +++ b/Sources/Jazz2/UI/Menu/SimpleMessageSection.cpp @@ -5,7 +5,7 @@ using namespace Jazz2::UI::Menu::Resources; namespace Jazz2::UI::Menu { - SimpleMessageSection::SimpleMessageSection(const StringView& message, bool withTransition) + SimpleMessageSection::SimpleMessageSection(StringView message, bool withTransition) : _message(message), _transitionTime(withTransition ? 0.0f : 1.0f) { } diff --git a/Sources/Jazz2/UI/Menu/SimpleMessageSection.h b/Sources/Jazz2/UI/Menu/SimpleMessageSection.h index a4277380..840a7072 100644 --- a/Sources/Jazz2/UI/Menu/SimpleMessageSection.h +++ b/Sources/Jazz2/UI/Menu/SimpleMessageSection.h @@ -10,7 +10,7 @@ namespace Jazz2::UI::Menu class SimpleMessageSection : public MenuSection { public: - SimpleMessageSection(const StringView& message, bool withTransition = false); + SimpleMessageSection(StringView message, bool withTransition = false); SimpleMessageSection(String&& message, bool withTransition = false); void OnUpdate(float timeMult) override; diff --git a/Sources/Jazz2/UI/Menu/TouchControlsOptionsSection.cpp b/Sources/Jazz2/UI/Menu/TouchControlsOptionsSection.cpp index 9b988b17..8abf81a0 100644 --- a/Sources/Jazz2/UI/Menu/TouchControlsOptionsSection.cpp +++ b/Sources/Jazz2/UI/Menu/TouchControlsOptionsSection.cpp @@ -123,7 +123,7 @@ namespace Jazz2::UI::Menu } } - void TouchControlsOptionsSection::DrawOutlinedSolid(float x, float y, std::uint16_t z, Alignment align, const Vector2f& size) + void TouchControlsOptionsSection::DrawOutlinedSolid(float x, float y, std::uint16_t z, Alignment align, Vector2f size) { _root->DrawSolid(x, y, z, align, size, Colorf(1.0f, 1.0f, 1.0f, 0.5f)); diff --git a/Sources/Jazz2/UI/Menu/TouchControlsOptionsSection.h b/Sources/Jazz2/UI/Menu/TouchControlsOptionsSection.h index 332db576..f85bcc66 100644 --- a/Sources/Jazz2/UI/Menu/TouchControlsOptionsSection.h +++ b/Sources/Jazz2/UI/Menu/TouchControlsOptionsSection.h @@ -26,6 +26,6 @@ namespace Jazz2::UI::Menu std::int32_t _lastPointerId; bool _isDirty; - void DrawOutlinedSolid(float x, float y, std::uint16_t z, Alignment align, const Vector2f& size); + void DrawOutlinedSolid(float x, float y, std::uint16_t z, Alignment align, Vector2f size); }; } \ No newline at end of file diff --git a/Sources/Main.cpp b/Sources/Main.cpp index 555808ae..c1f61a8f 100644 --- a/Sources/Main.cpp +++ b/Sources/Main.cpp @@ -1401,7 +1401,7 @@ void GameEventHandler::CheckUpdates() #endif #if defined(DEATH_TARGET_ANDROID) - auto sanitizeName = [](char* dst, std::size_t dstMaxLength, std::size_t& dstLength, const StringView& name, bool isBrand) { + auto sanitizeName = [](char* dst, std::size_t dstMaxLength, std::size_t& dstLength, StringView name, bool isBrand) { bool wasSpace = true; std::size_t lowercaseLength = 0; diff --git a/Sources/Main.h b/Sources/Main.h index cf6f112c..7351bfff 100644 --- a/Sources/Main.h +++ b/Sources/Main.h @@ -1,18 +1,23 @@ #pragma once // Set default name and version if not provided by CMake +/** @brief Application name */ #if !defined(NCINE_APP) # define NCINE_APP "jazz2" #endif +/** @brief Application full name */ #if !defined(NCINE_APP_NAME) # define NCINE_APP_NAME "Jazz² Resurrection" #endif +/** @brief Application version */ #if !defined(NCINE_VERSION) # define NCINE_VERSION "3.0.0" #endif +/** @brief Application build year */ #if !defined(NCINE_BUILD_YEAR) -# define NCINE_BUILD_YEAR "2024" +# define NCINE_BUILD_YEAR "2025" #endif +/** @brief Application package name */ #if !defined(NCINE_LINUX_PACKAGE) # define NCINE_LINUX_PACKAGE NCINE_APP_NAME #endif @@ -33,17 +38,21 @@ #include -#if !defined(NCINE_INSTALL_PREFIX) && defined(DEATH_TARGET_UNIX) +/** @brief Install prefix on Unix systems */ +#if (!defined(NCINE_INSTALL_PREFIX) && defined(DEATH_TARGET_UNIX)) || defined(DOXYGEN_GENERATING_OUTPUT) # define NCINE_INSTALL_PREFIX "/usr/local" #endif // Check platform-specific capabilities -#if defined(WITH_SDL) || defined(DEATH_TARGET_WINDOWS_RT) +/** @brief Whether the current platform supports a gamepad rumble (see @ref nCine::IInputManager::joystickRumble()) */ +#if defined(WITH_SDL) || defined(DEATH_TARGET_WINDOWS_RT) || defined(DOXYGEN_GENERATING_OUTPUT) # define NCINE_HAS_GAMEPAD_RUMBLE #endif -#if defined(DEATH_TARGET_ANDROID) +/** @brief Whether the current platform has a native (hardware) back button */ +#if defined(DEATH_TARGET_ANDROID) || defined(DOXYGEN_GENERATING_OUTPUT) # define NCINE_HAS_NATIVE_BACK_BUTTON #endif +/** @brief Whether the current platform has non-fullscreen windows */ #if !defined(DEATH_TARGET_ANDROID) && !defined(DEATH_TARGET_IOS) && !defined(DEATH_TARGET_SWITCH) # define NCINE_HAS_WINDOWS #endif diff --git a/Sources/Shared/Base/StackAlloc.h b/Sources/Shared/Base/StackAlloc.h index 5da8e4f2..244453b6 100644 --- a/Sources/Shared/Base/StackAlloc.h +++ b/Sources/Shared/Base/StackAlloc.h @@ -56,7 +56,8 @@ namespace Death { namespace Implementation { @brief Tries to allocate array of specified type on stack with fallback to standard heap allocation. If @p size is bigger than 4024, it will use heap allocation instead. - Please, use following syntax: @cpp auto array = stack_alloc(std::int32_t, 1024); @ce + + @cpp auto array = stack_alloc(std::int32_t, 1024); @ce */ #if defined(DEATH_TARGET_MSVC) # define stack_alloc(type, size) \ diff --git a/Sources/Shared/Base/TypeInfo.h b/Sources/Shared/Base/TypeInfo.h index 4f58cf69..01d7048c 100644 --- a/Sources/Shared/Base/TypeInfo.h +++ b/Sources/Shared/Base/TypeInfo.h @@ -249,7 +249,7 @@ namespace Death { namespace TypeInfo { namespace Implementation { }; }}} -/** @brief Class annotation to enable optimized @ref runtime_cast() functionality */ +/** @brief Class annotation to enable optimized @ref runtime_cast(U*) functionality */ #define DEATH_RUNTIME_OBJECT(...) \ __DEATH_WARNING_PUSH \ __DEATH_NO_OVERRIDE_WARNING \ @@ -261,7 +261,7 @@ namespace Death { namespace TypeInfo { namespace Implementation { } \ __DEATH_WARNING_POP -/** @brief Safely converts pointers to classes up, down, and sideways along the inheritance hierarchy of classes annotated by @ref DEATH_RUNTIME_OBJECT() */ +/** @brief Safely converts pointers to classes up, down, and sideways along the inheritance hierarchy of classes annotated by `DEATH_RUNTIME_OBJECT()` */ template DEATH_ALWAYS_INLINE T runtime_cast(U* u) noexcept { typedef typename std::remove_pointer::type Derived; @@ -291,10 +291,10 @@ DEATH_ALWAYS_INLINE T runtime_cast(const std::unique_ptr& u) noexcept { #else -/** @brief Class annotation to enable optimized @ref runtime_cast() functionality */ +/** @brief Class annotation to enable optimized @ref runtime_cast(U*) functionality */ #define DEATH_RUNTIME_OBJECT(...) -/** @brief Safely converts pointers to classes up, down, and sideways along the inheritance hierarchy of classes annotated by @cpp DEATH_RUNTIME_OBJECT @ce */ +/** @brief Safely converts pointers to classes up, down, and sideways along the inheritance hierarchy of classes annotated by `DEATH_RUNTIME_OBJECT()` */ template DEATH_ALWAYS_INLINE T runtime_cast(U* u) noexcept { return dynamic_cast(u); diff --git a/Sources/Shared/Containers/DateTime.h b/Sources/Shared/Containers/DateTime.h index 7a5be468..6529ee95 100644 --- a/Sources/Shared/Containers/DateTime.h +++ b/Sources/Shared/Containers/DateTime.h @@ -79,7 +79,7 @@ namespace Death { namespace Containers { }; /** - @brief Represents a timezone that can be used by timezone conversions in @ref DateTime + @brief Represents a timezone that can be used in timezone conversions in @ref DateTime */ class TimeZone { @@ -144,7 +144,10 @@ namespace Death { namespace Containers { } /** @brief Creates invalid @ref DateTime structure */ - constexpr DateTime() noexcept : _time(INT64_MIN) { } + constexpr DateTime() noexcept : _time(INT64_MIN) {} + + /** @brief Creates uninitialized @ref DateTime structure */ + explicit DateTime(NoInitT) noexcept {} /** @brief Creates @ref DateTime structure from standard @ref time_t value */ constexpr DateTime(time_t timet) noexcept; @@ -323,8 +326,9 @@ namespace Death { namespace Containers { return FromDays(7 * days); } - constexpr TimeSpan() noexcept : _value(0) { } - constexpr TimeSpan(std::int64_t diff) noexcept : _value(diff) { } + constexpr TimeSpan() noexcept : _value(0) {} + explicit TimeSpan(NoInitT) noexcept {} + constexpr TimeSpan(std::int64_t diff) noexcept : _value(diff) {} constexpr TimeSpan(std::int32_t hours, std::int32_t minutes, std::int64_t seconds = 0, std::int64_t milliseconds = 0) noexcept; diff --git a/Sources/Shared/Containers/GrowableArray.h b/Sources/Shared/Containers/GrowableArray.h index c2d7dd02..a2cc819a 100644 --- a/Sources/Shared/Containers/GrowableArray.h +++ b/Sources/Shared/Containers/GrowableArray.h @@ -316,6 +316,7 @@ namespace Death { namespace Containers { } }; +#ifdef DOXYGEN_GENERATING_OUTPUT /** @brief Allocator for growable arrays @@ -330,7 +331,86 @@ namespace Death { namespace Containers { @ref capacity(), @ref base() and @ref deleter() following the documented semantics. */ - template using ArrayAllocator = typename std::conditional::value, ArrayMallocAllocator, ArrayNewAllocator>::type; + template struct ArrayAllocator { + typedef T Type; /**< Pointer type */ + + /** + * @brief Allocate (but not construct) an array of given capacity + * + * Implementations are expected to store the @p capacity in a way that + * makes it possible to retrieve it later via @ref capacity(). + */ + static T* allocate(std::size_t capacity); + + /** + * @brief Reallocate an array to given capacity + * + * Assumes @p array was returned earlier by @ref allocate() or + * @ref reallocate(). Implementations are expected to either extend + * @p array in-place to @p newCapacity or allocate a new array with + * @p newCapacity, move @p prevSize elements from @p array to it and call + * destructors on their original location, deallocate the @p array and + * update the reference to point to the new memory. + */ + static void reallocate(T*& array, std::size_t prevSize, std::size_t newCapacity); + + /** + * @brief Deallocate (but not destruct) an array + * + * Assumes that @p data was returned earlier by @ref allocate() or + * @ref reallocate(). Implementations are expected to free all memory + * associated with @p data. + */ + static void deallocate(T* data); + + /** + * @brief Grow an array + * + * Assumes that @p array is either @cpp nullptr @ce or was returned earlier + * by @ref allocate() or @ref reallocate(). Implementations are expected to + * return a new capacity with an an optimal tradeoff between reallocation + * count and memory usage, the value then being passed to + * @ref reallocate(). + * + * See documentation of a particular implementation (such as + * @ref ArrayNewAllocator::grow()) for details about growth strategy. + */ + static std::size_t grow(T* array, std::size_t desired); + + /** + * @brief Array capacity + * + * Implementations are expected to retrieve the capacity information from + * @p array. + */ + static std::size_t capacity(T* array); + + /** + * @brief Array base address + * + * Returns base address of the allocation backing @p array. For use by + * Address Sanitizer to annotate which area of the allocation is safe to + * access and which not. + */ + static void* base(T* array); + + /** + * @brief Array deleter + * + * Passed as a function pointer into @ref Array. Calls destructors on + * @p size elements and delegates into @ref deallocate(). The deleter + * function pointer is used to distinguish if given array is using this + * particular allocator --- you might want to turn this function into an + * exported symbol when growing arrays across shared library boundaries to + * avoid each library thinking it's using some other allocator and + * reallocating on each addition. + */ + static void deleter(T* data, std::size_t size); + }; +#else + template using ArrayAllocator = typename std::conditional::value, + ArrayMallocAllocator, ArrayNewAllocator>::type; +#endif /** @brief Reinterpret-cast a growable array diff --git a/Sources/Shared/IO/MemoryStream.cpp b/Sources/Shared/IO/MemoryStream.cpp index 66895e4d..4968d69f 100644 --- a/Sources/Shared/IO/MemoryStream.cpp +++ b/Sources/Shared/IO/MemoryStream.cpp @@ -126,7 +126,7 @@ namespace Death { namespace IO { } } - std::int64_t MemoryStream::FetchFromStream(Stream& s, std::int64_t bytesToRead) + std::int64_t MemoryStream::FetchFromStream(Stream& source, std::int64_t bytesToRead) { std::int64_t bytesReadTotal = 0; if (bytesToRead > 0 && (_mode == AccessMode::Writable || _mode == AccessMode::Growable)) { @@ -140,7 +140,7 @@ namespace Death { namespace IO { } while (bytesToRead > 0) { - std::int64_t bytesRead = s.Read(&_buffer[_pos], bytesToRead); + std::int64_t bytesRead = source.Read(&_buffer[_pos], bytesToRead); if DEATH_UNLIKELY(bytesRead <= 0) { break; } diff --git a/Sources/Shared/IO/MemoryStream.h b/Sources/Shared/IO/MemoryStream.h index e851a74c..019dd3d9 100644 --- a/Sources/Shared/IO/MemoryStream.h +++ b/Sources/Shared/IO/MemoryStream.h @@ -31,7 +31,7 @@ namespace Death { namespace IO { std::int64_t GetSize() const override; void ReserveCapacity(std::int64_t bytes); - std::int64_t FetchFromStream(Stream& s, std::int64_t bytesToRead); + std::int64_t FetchFromStream(Stream& source, std::int64_t bytesToRead); DEATH_ALWAYS_INLINE std::uint8_t* GetBuffer() { return _buffer.data(); diff --git a/Sources/Shared/IO/PakFile.cpp b/Sources/Shared/IO/PakFile.cpp index c1571c4b..5ea85a6a 100644 --- a/Sources/Shared/IO/PakFile.cpp +++ b/Sources/Shared/IO/PakFile.cpp @@ -265,7 +265,7 @@ namespace Death { namespace IO { } // Items are always sorted by PakWriter - Item* foundItem = std::lower_bound(items->begin(), items->end(), name, [](const PakFile::Item& a, const StringView& b) { + Item* foundItem = std::lower_bound(items->begin(), items->end(), name, [](const PakFile::Item& a, StringView b) { return a.Name < b; }); diff --git a/Sources/Shared/Threading/Event.h b/Sources/Shared/Threading/Event.h index b38b074c..97e84ade 100644 --- a/Sources/Shared/Threading/Event.h +++ b/Sources/Shared/Threading/Event.h @@ -19,12 +19,12 @@ namespace Death { namespace Threading { ManualReset, }; - /** @brief An event object */ + /** @brief Lightweight event implementation */ template class Event { public: - Event(bool isSignaled = false) noexcept + explicit Event(bool isSignaled = false) noexcept : _isSignaled(isSignaled ? 1 : 0) { if DEATH_LIKELY(Implementation::IsWaitOnAddressSupported()) { diff --git a/Sources/nCine/Audio/AudioStreamPlayer.cpp b/Sources/nCine/Audio/AudioStreamPlayer.cpp index 0fda388f..eb761470 100644 --- a/Sources/nCine/Audio/AudioStreamPlayer.cpp +++ b/Sources/nCine/Audio/AudioStreamPlayer.cpp @@ -11,7 +11,7 @@ namespace nCine { } - AudioStreamPlayer::AudioStreamPlayer(const StringView& filename) + AudioStreamPlayer::AudioStreamPlayer(StringView filename) : IAudioPlayer(ObjectType::AudioStreamPlayer), audioStream_(filename) { } diff --git a/Sources/nCine/Audio/AudioStreamPlayer.h b/Sources/nCine/Audio/AudioStreamPlayer.h index 3d002f65..d42ddc35 100644 --- a/Sources/nCine/Audio/AudioStreamPlayer.h +++ b/Sources/nCine/Audio/AudioStreamPlayer.h @@ -14,7 +14,7 @@ namespace nCine /// Default constructor AudioStreamPlayer(); /// A constructor creating a player from a file - explicit AudioStreamPlayer(const StringView& filename); + explicit AudioStreamPlayer(StringView filename); ~AudioStreamPlayer() override; /// Default move constructor diff --git a/Sources/nCine/Backends/Android/EglGfxDevice.h b/Sources/nCine/Backends/Android/EglGfxDevice.h index f47e8ad3..4b80b39d 100644 --- a/Sources/nCine/Backends/Android/EglGfxDevice.h +++ b/Sources/nCine/Backends/Android/EglGfxDevice.h @@ -28,8 +28,8 @@ namespace nCine::Backends void update() override; - void setWindowTitle(const StringView& windowTitle) override { } - void setWindowIcon(const StringView& windowIconFilename) override { } + void setWindowTitle(StringView windowTitle) override { } + void setWindowIcon(StringView windowIconFilename) override { } const VideoMode& currentVideoMode(unsigned int monitorIndex) const override; bool setVideoMode(unsigned int modeIndex) override; diff --git a/Sources/nCine/Backends/GlfwGfxDevice.cpp b/Sources/nCine/Backends/GlfwGfxDevice.cpp index 7f81c494..21120b1b 100644 --- a/Sources/nCine/Backends/GlfwGfxDevice.cpp +++ b/Sources/nCine/Backends/GlfwGfxDevice.cpp @@ -125,7 +125,7 @@ namespace nCine::Backends glfwGetFramebufferSize(windowHandle_, &drawableWidth_, &drawableHeight_); } - void GlfwGfxDevice::setWindowIcon(const StringView& windowIconFilename) + void GlfwGfxDevice::setWindowIcon(StringView windowIconFilename) { #if !defined(DEATH_TARGET_EMSCRIPTEN) std::unique_ptr image = ITextureLoader::createFromFile(windowIconFilename); diff --git a/Sources/nCine/Backends/GlfwGfxDevice.h b/Sources/nCine/Backends/GlfwGfxDevice.h index 5fdb154b..04cd7a9d 100644 --- a/Sources/nCine/Backends/GlfwGfxDevice.h +++ b/Sources/nCine/Backends/GlfwGfxDevice.h @@ -49,10 +49,10 @@ namespace nCine::Backends void setWindowPosition(int x, int y) override; void setWindowSize(int width, int height) override; - inline void setWindowTitle(const StringView& windowTitle) override { + inline void setWindowTitle(StringView windowTitle) override { glfwSetWindowTitle(windowHandle_, String::nullTerminatedView(windowTitle).data()); } - void setWindowIcon(const StringView& windowIconFilename) override; + void setWindowIcon(StringView windowIconFilename) override; const Vector2i windowPosition() const override; diff --git a/Sources/nCine/Backends/SdlGfxDevice.cpp b/Sources/nCine/Backends/SdlGfxDevice.cpp index b0dc0331..f013073a 100644 --- a/Sources/nCine/Backends/SdlGfxDevice.cpp +++ b/Sources/nCine/Backends/SdlGfxDevice.cpp @@ -84,7 +84,7 @@ namespace nCine::Backends SDL_SetWindowSize(windowHandle_, width, height); } - void SdlGfxDevice::setWindowIcon(const StringView& windowIconFilename) + void SdlGfxDevice::setWindowIcon(StringView windowIconFilename) { std::unique_ptr image = ITextureLoader::createFromFile(windowIconFilename); const unsigned int bytesPerPixel = image->texFormat().numChannels(); diff --git a/Sources/nCine/Backends/SdlGfxDevice.h b/Sources/nCine/Backends/SdlGfxDevice.h index f6e05077..73f273d1 100644 --- a/Sources/nCine/Backends/SdlGfxDevice.h +++ b/Sources/nCine/Backends/SdlGfxDevice.h @@ -36,10 +36,10 @@ namespace nCine::Backends void setWindowSize(int width, int height) override; - inline void setWindowTitle(const StringView& windowTitle) override { + inline void setWindowTitle(StringView windowTitle) override { SDL_SetWindowTitle(windowHandle_, String::nullTerminatedView(windowTitle).data()); } - void setWindowIcon(const StringView& windowIconFilename) override; + void setWindowIcon(StringView windowIconFilename) override; const Vector2i windowPosition() const override; diff --git a/Sources/nCine/Backends/Uwp/UwpGfxDevice.cpp b/Sources/nCine/Backends/Uwp/UwpGfxDevice.cpp index 86e9dc85..17c33ce6 100644 --- a/Sources/nCine/Backends/Uwp/UwpGfxDevice.cpp +++ b/Sources/nCine/Backends/Uwp/UwpGfxDevice.cpp @@ -287,7 +287,7 @@ namespace nCine::Backends //}); } - void UwpGfxDevice::setWindowTitle(const StringView& windowTitle) + void UwpGfxDevice::setWindowTitle(StringView windowTitle) { // TODO: Disabled for now for Windows RT, because it appends application name // This method is usually called from main thread, but it's required on UI thread diff --git a/Sources/nCine/Backends/Uwp/UwpGfxDevice.h b/Sources/nCine/Backends/Uwp/UwpGfxDevice.h index e24f730a..6da00574 100644 --- a/Sources/nCine/Backends/Uwp/UwpGfxDevice.h +++ b/Sources/nCine/Backends/Uwp/UwpGfxDevice.h @@ -50,8 +50,8 @@ namespace nCine::Backends void setWindowPosition(int x, int y) override { }; void setWindowSize(int width, int height) override; - void setWindowTitle(const StringView& windowTitle) override; - void setWindowIcon(const StringView& iconFilename) override { } + void setWindowTitle(StringView windowTitle) override; + void setWindowIcon(StringView iconFilename) override { } const VideoMode& currentVideoMode(unsigned int monitorIndex) const override { return _currentViewMode; diff --git a/Sources/nCine/Graphics/AnimatedSprite.cpp b/Sources/nCine/Graphics/AnimatedSprite.cpp index 7c81e50d..3705e918 100644 --- a/Sources/nCine/Graphics/AnimatedSprite.cpp +++ b/Sources/nCine/Graphics/AnimatedSprite.cpp @@ -24,7 +24,7 @@ namespace nCine _type = ObjectType::AnimatedSprite; } - AnimatedSprite::AnimatedSprite(SceneNode* parent, Texture* texture, const Vector2f& position) + AnimatedSprite::AnimatedSprite(SceneNode* parent, Texture* texture, Vector2f position) : AnimatedSprite(parent, texture, position.X, position.Y) { } @@ -34,7 +34,7 @@ namespace nCine { } - AnimatedSprite::AnimatedSprite(Texture* texture, const Vector2f& position) + AnimatedSprite::AnimatedSprite(Texture* texture, Vector2f position) : AnimatedSprite(nullptr, texture, position.X, position.Y) { } diff --git a/Sources/nCine/Graphics/AnimatedSprite.h b/Sources/nCine/Graphics/AnimatedSprite.h index 5981e40b..d3649704 100644 --- a/Sources/nCine/Graphics/AnimatedSprite.h +++ b/Sources/nCine/Graphics/AnimatedSprite.h @@ -22,11 +22,11 @@ namespace nCine /// Constructor for an animated sprite with a parent, a texture and a specified relative position AnimatedSprite(SceneNode* parent, Texture* texture, float xx, float yy); /// Constructor for an animated sprite with a parent, a texture and a specified relative position as a vector - AnimatedSprite(SceneNode* parent, Texture* texture, const Vector2f& position); + AnimatedSprite(SceneNode* parent, Texture* texture, Vector2f position); /// Constructor for an animated sprite with a texture and a specified position but no parent AnimatedSprite(Texture* texture, float xx, float yy); /// Constructor for an animated sprite with a texture and a specified position as a vector but no parent - AnimatedSprite(Texture* texture, const Vector2f& position); + AnimatedSprite(Texture* texture, Vector2f position); /// Default move constructor AnimatedSprite(AnimatedSprite&&) = default; diff --git a/Sources/nCine/Graphics/BaseSprite.cpp b/Sources/nCine/Graphics/BaseSprite.cpp index 8ed2233b..2d58a884 100644 --- a/Sources/nCine/Graphics/BaseSprite.cpp +++ b/Sources/nCine/Graphics/BaseSprite.cpp @@ -10,7 +10,7 @@ namespace nCine renderCommand_.material().setBlendingEnabled(true); } - BaseSprite::BaseSprite(SceneNode* parent, Texture* texture, const Vector2f& position) + BaseSprite::BaseSprite(SceneNode* parent, Texture* texture, Vector2f position) : BaseSprite(parent, texture, position.X, position.Y) { } diff --git a/Sources/nCine/Graphics/BaseSprite.h b/Sources/nCine/Graphics/BaseSprite.h index 92db77af..0d3ef471 100644 --- a/Sources/nCine/Graphics/BaseSprite.h +++ b/Sources/nCine/Graphics/BaseSprite.h @@ -21,7 +21,7 @@ namespace nCine /// Sets sprite size void setSize(float width, float height); /// Sets sprite size with a `Vector2f` - inline void setSize(const Vector2f& size) { + inline void setSize(Vector2f size) { setSize(size.X, size.Y); } @@ -70,7 +70,7 @@ namespace nCine /// Protected constructor accessible only by derived sprite classes BaseSprite(SceneNode* parent, Texture* texture, float xx, float yy); /// Protected constructor accessible only by derived sprite classes - BaseSprite(SceneNode* parent, Texture* texture, const Vector2f& position); + BaseSprite(SceneNode* parent, Texture* texture, Vector2f position); /// Protected copy constructor used to clone objects BaseSprite(const BaseSprite& other); diff --git a/Sources/nCine/Graphics/BinaryShaderCache.cpp b/Sources/nCine/Graphics/BinaryShaderCache.cpp index 4fa5a4fc..9802a772 100644 --- a/Sources/nCine/Graphics/BinaryShaderCache.cpp +++ b/Sources/nCine/Graphics/BinaryShaderCache.cpp @@ -19,7 +19,7 @@ namespace nCine std::unique_ptr bufferPtr; } - BinaryShaderCache::BinaryShaderCache(const StringView& path) + BinaryShaderCache::BinaryShaderCache(StringView path) : isAvailable_(false), platformHash_(0) { if (path.empty()) { @@ -193,7 +193,7 @@ namespace nCine return success; } - bool BinaryShaderCache::setPath(const StringView& path) + bool BinaryShaderCache::setPath(StringView path) { if (!fs::DirectoryExists(path) || !fs::IsWritable(path)) { return false; diff --git a/Sources/nCine/Graphics/BinaryShaderCache.h b/Sources/nCine/Graphics/BinaryShaderCache.h index 77c13bcc..38d8214f 100644 --- a/Sources/nCine/Graphics/BinaryShaderCache.h +++ b/Sources/nCine/Graphics/BinaryShaderCache.h @@ -19,7 +19,7 @@ namespace nCine class BinaryShaderCache { public: - BinaryShaderCache(const StringView& path); + BinaryShaderCache(StringView path); inline bool isAvailable() const { return isAvailable_; @@ -44,7 +44,7 @@ namespace nCine return path_; } /// Sets a new directory as the cache for binary shaders - bool setPath(const StringView& path); + bool setPath(StringView path); private: using glGetProgramBinary_t = void(__GLAPIENTRY*)(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, void* binary); diff --git a/Sources/nCine/Graphics/Camera.cpp b/Sources/nCine/Graphics/Camera.cpp index 1a4c1fc9..3c0641c1 100644 --- a/Sources/nCine/Graphics/Camera.cpp +++ b/Sources/nCine/Graphics/Camera.cpp @@ -36,7 +36,7 @@ namespace nCine setOrthoProjection(values.left, values.right, values.top, values.bottom); } - void Camera::setView(const Vector2f& position, float rotation, float scale) + void Camera::setView(Vector2f position, float rotation, float scale) { viewValues_.position = position; viewValues_.rotation = rotation; diff --git a/Sources/nCine/Graphics/Camera.h b/Sources/nCine/Graphics/Camera.h index 9fdc3dce..aa37b266 100644 --- a/Sources/nCine/Graphics/Camera.h +++ b/Sources/nCine/Graphics/Camera.h @@ -58,7 +58,7 @@ namespace nCine void setOrthoProjection(float left, float right, float top, float bottom); void setOrthoProjection(const ProjectionValues& values); - void setView(const Vector2f& pos, float rotation, float scale); + void setView(Vector2f pos, float rotation, float scale); void setView(float x, float y, float rotation, float scale); void setView(const ViewValues& values); diff --git a/Sources/nCine/Graphics/DrawableNode.cpp b/Sources/nCine/Graphics/DrawableNode.cpp index 20a0a389..f5db4fb0 100644 --- a/Sources/nCine/Graphics/DrawableNode.cpp +++ b/Sources/nCine/Graphics/DrawableNode.cpp @@ -69,7 +69,7 @@ namespace nCine renderCommand_.setIdSortKey(id()); } - DrawableNode::DrawableNode(SceneNode* parent, const Vector2f& position) + DrawableNode::DrawableNode(SceneNode* parent, Vector2f position) : DrawableNode(parent, position.X, position.Y) { } diff --git a/Sources/nCine/Graphics/DrawableNode.h b/Sources/nCine/Graphics/DrawableNode.h index 2fbbe7a7..7c0445e1 100644 --- a/Sources/nCine/Graphics/DrawableNode.h +++ b/Sources/nCine/Graphics/DrawableNode.h @@ -53,7 +53,7 @@ namespace nCine /// Constructor for a drawable node with a parent and a specified relative position DrawableNode(SceneNode* parent, float xx, float yy); /// Constructor for a drawable node with a parent and a specified relative position as a vector - DrawableNode(SceneNode* parent, const Vector2f& position); + DrawableNode(SceneNode* parent, Vector2f position); /// Constructor for a drawable node with a parent and positioned in the relative origin explicit DrawableNode(SceneNode* parent); /// Constructor for a drawable node with no parent and positioned in the origin @@ -101,7 +101,7 @@ namespace nCine /// Sets the transformation anchor point void setAnchorPoint(float xx, float yy); /// Sets the transformation anchor point with a `Vector2f` - inline void setAnchorPoint(const Vector2f& point) { + inline void setAnchorPoint(Vector2f point) { setAnchorPoint(point.X, point.Y); } diff --git a/Sources/nCine/Graphics/GL/GLShader.cpp b/Sources/nCine/Graphics/GL/GLShader.cpp index 0c25fd4d..58d81e26 100644 --- a/Sources/nCine/Graphics/GL/GLShader.cpp +++ b/Sources/nCine/Graphics/GL/GLShader.cpp @@ -58,12 +58,12 @@ namespace nCine return loadFromStringsAndFile(arrayView({ string }), {}); } - bool GLShader::loadFromStringAndFile(StringView string, const StringView& filename) + bool GLShader::loadFromStringAndFile(StringView string, StringView filename) { return loadFromStringsAndFile(arrayView({ string }), filename); } - bool GLShader::loadFromStringsAndFile(ArrayView strings, const StringView& filename) + bool GLShader::loadFromStringsAndFile(ArrayView strings, StringView filename) { if (strings.empty() && filename.empty()) { return false; diff --git a/Sources/nCine/Graphics/GL/GLShader.h b/Sources/nCine/Graphics/GL/GLShader.h index 5c8b0805..9894e249 100644 --- a/Sources/nCine/Graphics/GL/GLShader.h +++ b/Sources/nCine/Graphics/GL/GLShader.h @@ -43,11 +43,11 @@ namespace nCine /// Loads a shader from the given string bool loadFromString(StringView string); /// Loads a shader from the given string and then append the specified file - bool loadFromStringAndFile(StringView string, const StringView& filename); + bool loadFromStringAndFile(StringView string, StringView filename); /// Loads a shader by concatenating the given strings in order bool loadFromStrings(ArrayView strings); /// Loads a shader by concatenating the given strings in order, then appending the specified file - bool loadFromStringsAndFile(ArrayView strings, const StringView& filename); + bool loadFromStringsAndFile(ArrayView strings, StringView filename); /// Loads a shader from the specified file bool loadFromFile(StringView filename); diff --git a/Sources/nCine/Graphics/GL/GLUniformBlockCache.cpp b/Sources/nCine/Graphics/GL/GLUniformBlockCache.cpp index 8e0f56b1..39c143ad 100644 --- a/Sources/nCine/Graphics/GL/GLUniformBlockCache.cpp +++ b/Sources/nCine/Graphics/GL/GLUniformBlockCache.cpp @@ -84,7 +84,7 @@ namespace nCine return true; } - GLUniformCache* GLUniformBlockCache::uniform(const StringView& name) + GLUniformCache* GLUniformBlockCache::uniform(StringView name) { return uniformCaches_.find(String::nullTerminatedView(name)); } diff --git a/Sources/nCine/Graphics/GL/GLUniformBlockCache.h b/Sources/nCine/Graphics/GL/GLUniformBlockCache.h index 07561d25..9acdf329 100644 --- a/Sources/nCine/Graphics/GL/GLUniformBlockCache.h +++ b/Sources/nCine/Graphics/GL/GLUniformBlockCache.h @@ -48,7 +48,7 @@ namespace nCine return copyData(0, src, usedSize_); } - GLUniformCache* uniform(const StringView& name); + GLUniformCache* uniform(StringView name); /// Wrapper around `GLUniformBlock::setBlockBinding()` void setBlockBinding(GLuint blockBinding); diff --git a/Sources/nCine/Graphics/IGfxDevice.cpp b/Sources/nCine/Graphics/IGfxDevice.cpp index 82bb68c9..8d39c89c 100644 --- a/Sources/nCine/Graphics/IGfxDevice.cpp +++ b/Sources/nCine/Graphics/IGfxDevice.cpp @@ -143,10 +143,10 @@ namespace nCine float IGfxDevice::windowScalingFactor() const { #if defined(DEATH_TARGET_APPLE) - const float factor = drawableWidth() / static_cast(width()); + float factor = drawableWidth() / static_cast(width()); #else - const Vector2f& scale = monitor().scale; - const float factor = (scale.X > scale.Y ? scale.X : scale.Y); + Vector2f scale = monitor().scale; + float factor = (scale.X > scale.Y ? scale.X : scale.Y); #endif return factor; diff --git a/Sources/nCine/Graphics/IGfxDevice.h b/Sources/nCine/Graphics/IGfxDevice.h index 3466c616..94a84600 100644 --- a/Sources/nCine/Graphics/IGfxDevice.h +++ b/Sources/nCine/Graphics/IGfxDevice.h @@ -122,9 +122,9 @@ namespace nCine setWindowPosition(position.X, position.Y); } /// Sets the application window title - virtual void setWindowTitle(const StringView& windowTitle) = 0; + virtual void setWindowTitle(StringView windowTitle) = 0; /// Sets the application window icon - virtual void setWindowIcon(const StringView& iconFilename) = 0; + virtual void setWindowIcon(StringView iconFilename) = 0; /// Returns the window or video mode width in screen coordinates inline int width() const { return width_; } diff --git a/Sources/nCine/Graphics/MeshSprite.cpp b/Sources/nCine/Graphics/MeshSprite.cpp index b855089b..e03239a9 100644 --- a/Sources/nCine/Graphics/MeshSprite.cpp +++ b/Sources/nCine/Graphics/MeshSprite.cpp @@ -28,7 +28,7 @@ namespace nCine init(); } - MeshSprite::MeshSprite(SceneNode* parent, Texture* texture, const Vector2f& position) + MeshSprite::MeshSprite(SceneNode* parent, Texture* texture, Vector2f position) : MeshSprite(parent, texture, position.X, position.Y) { } @@ -38,7 +38,7 @@ namespace nCine { } - MeshSprite::MeshSprite(Texture* texture, const Vector2f& position) + MeshSprite::MeshSprite(Texture* texture, Vector2f position) : MeshSprite(nullptr, texture, position.X, position.Y) { } diff --git a/Sources/nCine/Graphics/MeshSprite.h b/Sources/nCine/Graphics/MeshSprite.h index 4bb860d6..34e07991 100644 --- a/Sources/nCine/Graphics/MeshSprite.h +++ b/Sources/nCine/Graphics/MeshSprite.h @@ -54,11 +54,11 @@ namespace nCine /// Constructor for a sprite with a parent, a texture and a specified relative position MeshSprite(SceneNode* parent, Texture* texture, float xx, float yy); /// Constructor for a sprite with a parent, a texture and a specified relative position as a vector - MeshSprite(SceneNode* parent, Texture* texture, const Vector2f& position); + MeshSprite(SceneNode* parent, Texture* texture, Vector2f position); /// Constructor for a sprite with a texture and a specified position but no parent MeshSprite(Texture* texture, float xx, float yy); /// Constructor for a sprite with a texture and a specified position as a vector but no parent - MeshSprite(Texture* texture, const Vector2f& position); + MeshSprite(Texture* texture, Vector2f position); /// Default move constructor MeshSprite(MeshSprite&&) = default; diff --git a/Sources/nCine/Graphics/ParticleAffectors.h b/Sources/nCine/Graphics/ParticleAffectors.h index fb0ec1f1..46c6785f 100644 --- a/Sources/nCine/Graphics/ParticleAffectors.h +++ b/Sources/nCine/Graphics/ParticleAffectors.h @@ -111,7 +111,7 @@ namespace nCine : age(newAge), scale(newScale, newScale) {} SizeStep(float newAge, float newScaleX, float newScaleY) : age(newAge), scale(newScaleX, newScaleY) {} - SizeStep(float newAge, const Vector2f& newScale) + SizeStep(float newAge, Vector2f newScale) : age(newAge), scale(newScale) {} }; @@ -125,7 +125,7 @@ namespace nCine SizeAffector(float baseScaleX, float baseScaleY) : ParticleAffector(Type::SIZE), sizeSteps_(StepsInitialSize), baseScale_(baseScaleX, baseScaleY) {} /// Constructs a size affector with a vector base scale factor as a reference - explicit SizeAffector(const Vector2f& baseScale) + explicit SizeAffector(Vector2f baseScale) : SizeAffector(baseScale.X, baseScale.Y) {} /// Default move constructor @@ -144,7 +144,7 @@ namespace nCine addSizeStep(age, scale, scale); } void addSizeStep(float age, float scaleX, float scaleY); - inline void addSizeStep(float age, const Vector2f& scale) { + inline void addSizeStep(float age, Vector2f scale) { addSizeStep(age, scale.X, scale.Y); } @@ -168,13 +168,13 @@ namespace nCine baseScale_.Y = baseScaleY; } - inline const Vector2f& baseScale() const { + inline Vector2f baseScale() const { return baseScale_; } inline void setBaseScale(float baseScale) { baseScale_.Set(baseScale, baseScale); } - inline void setBaseScale(const Vector2f& baseScale) { + inline void setBaseScale(Vector2f baseScale) { baseScale_ = baseScale; } @@ -265,7 +265,7 @@ namespace nCine /// Affects the position of the specified particle void affect(Particle* particle, float normalizedAge) override; void addPositionStep(float age, float posX, float posY); - inline void addPositionStep(float age, const Vector2f& position) { + inline void addPositionStep(float age, Vector2f position) { addPositionStep(age, position.X, position.Y); } @@ -315,7 +315,7 @@ namespace nCine /// Affects the velocity of the specified particle void affect(Particle* particle, float normalizedAge) override; void addVelocityStep(float age, float velX, float velY); - inline void addVelocityStep(float age, const Vector2f& velocity) { + inline void addVelocityStep(float age, Vector2f velocity) { addVelocityStep(age, velocity.X, velocity.Y); } diff --git a/Sources/nCine/Graphics/ParticleInitializer.cpp b/Sources/nCine/Graphics/ParticleInitializer.cpp index 8463bec3..265e8624 100644 --- a/Sources/nCine/Graphics/ParticleInitializer.cpp +++ b/Sources/nCine/Graphics/ParticleInitializer.cpp @@ -47,17 +47,17 @@ namespace nCine rndPositionY.Set(y - radius, y + radius); } - void ParticleInitializer::setPosition(const Vector2f& pos) + void ParticleInitializer::setPosition(Vector2f pos) { setPosition(pos.X, pos.Y); } - void ParticleInitializer::setPosition(const Vector2f& minPos, const Vector2f& maxPos) + void ParticleInitializer::setPosition(Vector2f minPos, Vector2f maxPos) { setPosition(minPos.X, minPos.Y, maxPos.X, maxPos.Y); } - void ParticleInitializer::setPositionAndRadius(const Vector2f& pos, float radius) + void ParticleInitializer::setPositionAndRadius(Vector2f pos, float radius) { setPositionAndRadius(pos.X, pos.Y, radius); } @@ -127,27 +127,27 @@ namespace nCine } } - void ParticleInitializer::setVelocity(const Vector2f& vel) + void ParticleInitializer::setVelocity(Vector2f vel) { setVelocity(vel.X, vel.Y); } - void ParticleInitializer::setVelocity(const Vector2f& minVel, const Vector2f& maxVel) + void ParticleInitializer::setVelocity(Vector2f minVel, Vector2f maxVel) { setVelocity(minVel.X, minVel.Y, maxVel.X, maxVel.Y); } - void ParticleInitializer::setVelocityAndRadius(const Vector2f& vel, float radius) + void ParticleInitializer::setVelocityAndRadius(Vector2f vel, float radius) { setVelocityAndRadius(vel.X, vel.Y, radius); } - void ParticleInitializer::setVelocityAndScale(const Vector2f& vel, float minScale, float maxScale) + void ParticleInitializer::setVelocityAndScale(Vector2f vel, float minScale, float maxScale) { setVelocityAndScale(vel.X, vel.Y, minScale, maxScale); } - void ParticleInitializer::setVelocityAndAngle(const Vector2f& vel, float angle) + void ParticleInitializer::setVelocityAndAngle(Vector2f vel, float angle) { setVelocityAndAngle(vel.X, vel.Y, angle); } diff --git a/Sources/nCine/Graphics/ParticleInitializer.h b/Sources/nCine/Graphics/ParticleInitializer.h index bd5714a1..7236276b 100644 --- a/Sources/nCine/Graphics/ParticleInitializer.h +++ b/Sources/nCine/Graphics/ParticleInitializer.h @@ -26,9 +26,9 @@ namespace nCine void setPosition(float x, float y); void setPosition(float minX, float minY, float maxX, float maxY); void setPositionAndRadius(float x, float y, float radius); - void setPosition(const Vector2f& pos); - void setPosition(const Vector2f& minPos, const Vector2f& maxPos); - void setPositionAndRadius(const Vector2f& pos, float radius); + void setPosition(Vector2f pos); + void setPosition(Vector2f minPos, Vector2f maxPos); + void setPositionAndRadius(Vector2f pos, float radius); void setPositionInDisc(float radius); void setVelocity(float x, float y); @@ -36,11 +36,11 @@ namespace nCine void setVelocityAndRadius(float x, float y, float radius); void setVelocityAndScale(float x, float y, float minScale, float maxScale); void setVelocityAndAngle(float x, float y, float angle); - void setVelocity(const Vector2f& vel); - void setVelocity(const Vector2f& minVel, const Vector2f& maxVel); - void setVelocityAndRadius(const Vector2f& vel, float radius); - void setVelocityAndScale(const Vector2f& vel, float minScale, float maxScale); - void setVelocityAndAngle(const Vector2f& vel, float angle); + void setVelocity(Vector2f vel); + void setVelocity(Vector2f minVel, Vector2f maxVel); + void setVelocityAndRadius(Vector2f vel, float radius); + void setVelocityAndScale(Vector2f vel, float minScale, float maxScale); + void setVelocityAndAngle(Vector2f vel, float angle); void setRotation(float rot); void setRotation(float minRot, float maxRot); diff --git a/Sources/nCine/Input/IInputManager.cpp b/Sources/nCine/Input/IInputManager.cpp index 01fd3e38..59b12989 100644 --- a/Sources/nCine/Input/IInputManager.cpp +++ b/Sources/nCine/Input/IInputManager.cpp @@ -39,7 +39,7 @@ namespace nCine } } - void JoystickGuid::fromString(const StringView& string) + void JoystickGuid::fromString(StringView string) { if (string.empty()) { fromType(JoystickGuidType::Unknown); diff --git a/Sources/nCine/Input/IInputManager.h b/Sources/nCine/Input/IInputManager.h index 8d1e3c7e..89587ed4 100644 --- a/Sources/nCine/Input/IInputManager.h +++ b/Sources/nCine/Input/IInputManager.h @@ -28,11 +28,11 @@ namespace nCine inline JoystickGuid(JoystickGuidType type) { fromType(type); } - inline JoystickGuid(const StringView& string) { + inline JoystickGuid(StringView string) { fromString(string); } void fromType(JoystickGuidType type); - void fromString(const StringView& string); + void fromString(StringView string); bool isValid() const; bool operator==(const JoystickGuid& guid) const; diff --git a/Sources/nCine/Input/JoyMapping.cpp b/Sources/nCine/Input/JoyMapping.cpp index b19b223a..707fd3f1 100644 --- a/Sources/nCine/Input/JoyMapping.cpp +++ b/Sources/nCine/Input/JoyMapping.cpp @@ -638,7 +638,7 @@ namespace nCine } } - JoystickGuid JoyMapping::CreateJoystickGuid(std::uint16_t bus, std::uint16_t vendor, std::uint16_t product, std::uint16_t version, const StringView& name, std::uint8_t driverSignature, std::uint8_t driverData) + JoystickGuid JoyMapping::CreateJoystickGuid(std::uint16_t bus, std::uint16_t vendor, std::uint16_t product, std::uint16_t version, StringView name, std::uint8_t driverSignature, std::uint8_t driverData) { JoystickGuid guid; std::uint16_t* guid16 = reinterpret_cast(guid.data); diff --git a/Sources/nCine/Input/JoyMapping.h b/Sources/nCine/Input/JoyMapping.h index 561fe99c..f2d82c18 100644 --- a/Sources/nCine/Input/JoyMapping.h +++ b/Sources/nCine/Input/JoyMapping.h @@ -1,6 +1,7 @@ #pragma once #include "IInputManager.h" +#include "../Primitives/Vector2.h" #include #include @@ -14,8 +15,6 @@ namespace nCine class JoyAxisEvent; class JoyConnectionEvent; class IInputEventHandler; - template class Vector2; - using Vector2f = Vector2; /// Provides translation layer for gamepads and joysticks to unified layout class JoyMapping @@ -47,7 +46,7 @@ namespace nCine bool IsJoyMapped(std::int32_t joyId) const; const JoyMappedState& GetMappedState(std::int32_t joyId) const; void DeadZoneNormalize(Vector2f& joyVector, float deadZoneValue = IInputManager::LeftStickDeadZone) const; - static JoystickGuid CreateJoystickGuid(std::uint16_t bus, std::uint16_t vendor, std::uint16_t product, std::uint16_t version, const StringView& name, std::uint8_t driverSignature, std::uint8_t driverData); + static JoystickGuid CreateJoystickGuid(std::uint16_t bus, std::uint16_t vendor, std::uint16_t product, std::uint16_t version, StringView name, std::uint8_t driverSignature, std::uint8_t driverData); std::int32_t FindMappingByGuid(const JoystickGuid& guid) const; std::int32_t FindMappingByName(const char* name) const; diff --git a/Sources/nCine/Primitives/AABB.h b/Sources/nCine/Primitives/AABB.h index 29e0abdd..27f831dd 100644 --- a/Sources/nCine/Primitives/AABB.h +++ b/Sources/nCine/Primitives/AABB.h @@ -8,24 +8,26 @@ namespace nCine { + using Death::Containers::NoInitT; + /// Axis-Aligned Bounding Box in a two dimensional space template class AABB { public: - /// Top-left X coordinate as a public property + /// Top-left X coordinate S L; - /// Top-left Y coordinate as a public property + /// Top-left Y coordinate S T; - /// Bottom-right X coordinate as a public property + /// Bottom-right X coordinate S R; - /// Bottom-right Y coordinate as a public property + /// Bottom-right Y coordinate S B; constexpr AABB() noexcept : L(S(0)), T(S(0)), R(S(0)), B(S(0)) {} - explicit AABB(Death::Containers::NoInitT) noexcept + explicit AABB(NoInitT) noexcept {} constexpr AABB(S l, S t, S r, S b) noexcept @@ -63,10 +65,10 @@ namespace nCine /// \returns True if this rect does overlap the other rectangle in any way bool Overlaps(const AABB& aabb) const; - /// Intersects this rectangle with the other rectangle + /// Intersects this AABB with the other AABB static AABB Intersect(const AABB& a, const AABB& b); - /// Combine two AABBs into this one. + /// Combine two AABBs static AABB Combine(const AABB& a, const AABB& b); /// Eqality operator diff --git a/Sources/nCine/Primitives/Color.h b/Sources/nCine/Primitives/Color.h index c9124b94..52e60df3 100644 --- a/Sources/nCine/Primitives/Color.h +++ b/Sources/nCine/Primitives/Color.h @@ -7,6 +7,8 @@ namespace nCine { class Colorf; + using Death::Containers::NoInitT; + /// Four-channels 8-bit color class Color { @@ -33,7 +35,7 @@ namespace nCine { } - explicit Color(Death::Containers::NoInitT) noexcept + explicit Color(NoInitT) noexcept { } diff --git a/Sources/nCine/Primitives/Colorf.h b/Sources/nCine/Primitives/Colorf.h index 44f346f7..f549176e 100644 --- a/Sources/nCine/Primitives/Colorf.h +++ b/Sources/nCine/Primitives/Colorf.h @@ -10,6 +10,8 @@ namespace nCine { class Color; + using Death::Containers::NoInitT; + /// Four-channels normalized float color class Colorf { @@ -35,7 +37,7 @@ namespace nCine : Colorf(1.0f, 1.0f, 1.0f, 1.0f) { } - explicit Colorf(Death::Containers::NoInitT) noexcept + explicit Colorf(NoInitT) noexcept { } /// Three channels constructor diff --git a/Sources/nCine/Primitives/Matrix4x4.h b/Sources/nCine/Primitives/Matrix4x4.h index d0759027..1f3f225d 100644 --- a/Sources/nCine/Primitives/Matrix4x4.h +++ b/Sources/nCine/Primitives/Matrix4x4.h @@ -9,15 +9,17 @@ namespace nCine { + using Death::Containers::NoInitT; + /// Four-by-four matrix template class Matrix4x4 { public: - Matrix4x4() noexcept + constexpr Matrix4x4() noexcept : vecs_{Vector4(T(1), T(0), T(0), T(0)), Vector4(T(0), T(1), T(0), T(0)), Vector4(T(0), T(0), T(1), T(0)), Vector4(T(0), T(0), T(0), T(1))} {} - explicit Matrix4x4(Death::Containers::NoInitT) noexcept + explicit Matrix4x4(NoInitT) noexcept {} Matrix4x4(const Vector4& v0, const Vector4& v1, const Vector4& v2, const Vector4& v3) noexcept; diff --git a/Sources/nCine/Primitives/Quaternion.h b/Sources/nCine/Primitives/Quaternion.h index c01bb707..bca82c3f 100644 --- a/Sources/nCine/Primitives/Quaternion.h +++ b/Sources/nCine/Primitives/Quaternion.h @@ -5,6 +5,8 @@ namespace nCine { + using Death::Containers::NoInitT; + /// Quaternion template class Quaternion @@ -12,13 +14,15 @@ namespace nCine public: T X, Y, Z, W; - Quaternion() + constexpr Quaternion() noexcept : X(T(0)), Y(T(0)), Z(T(0)), W(T(1)) {} - Quaternion(T x, T y, T z, T w) + explicit Quaternion(NoInitT) noexcept + {} + constexprQuaternion(T x, T y, T z, T w) noexcept : X(x), Y(y), Z(z), W(w) {} - explicit Quaternion(const Vector4& v) + explicit Quaternion(const Vector4& v) noexcept : X(v.X), Y(v.Y), Z(v.Z), W(v.W) {} - Quaternion(const Quaternion& other) + constexpr Quaternion(const Quaternion& other) noexcept : X(other.X), Y(other.Y), Z(other.Z), W(other.W) {} Quaternion& operator=(const Quaternion& other); diff --git a/Sources/nCine/Primitives/Rect.h b/Sources/nCine/Primitives/Rect.h index 2acff510..af2993e9 100644 --- a/Sources/nCine/Primitives/Rect.h +++ b/Sources/nCine/Primitives/Rect.h @@ -8,6 +8,8 @@ namespace nCine { + using Death::Containers::NoInitT; + /// Rectangle in a two dimensional space template class Rect @@ -25,7 +27,7 @@ namespace nCine /// Default constructor, all zeros constexpr Rect() noexcept : X(T(0)), Y(T(0)), W(T(0)), H(T(0)) {} - explicit Rect(Death::Containers::NoInitT) noexcept + explicit Rect(NoInitT) noexcept {} /// Constructs a rectangle from top-left point and size constexpr Rect(T x, T y, T w, T h) noexcept diff --git a/Sources/nCine/Primitives/Vector2.h b/Sources/nCine/Primitives/Vector2.h index fc6b6b17..657fe4f5 100644 --- a/Sources/nCine/Primitives/Vector2.h +++ b/Sources/nCine/Primitives/Vector2.h @@ -8,6 +8,8 @@ namespace nCine { + using Death::Containers::NoInitT; + /// Two-component vector template class Vector2 @@ -17,7 +19,7 @@ namespace nCine constexpr Vector2() noexcept : X{T(0)}, Y{T(0)} {} - explicit Vector2(Death::Containers::NoInitT) noexcept + explicit Vector2(NoInitT) noexcept {} explicit constexpr Vector2(T s) noexcept : X(s), Y(s) {} diff --git a/Sources/nCine/Primitives/Vector3.h b/Sources/nCine/Primitives/Vector3.h index d6d60da9..d2435aa8 100644 --- a/Sources/nCine/Primitives/Vector3.h +++ b/Sources/nCine/Primitives/Vector3.h @@ -9,6 +9,8 @@ namespace nCine { + using Death::Containers::NoInitT; + /// Three-component vector template class Vector3 @@ -18,7 +20,7 @@ namespace nCine constexpr Vector3() noexcept : X{T(0)}, Y{T(0)}, Z{T(0)} {} - explicit Vector3(Death::Containers::NoInitT) noexcept + explicit Vector3(NoInitT) noexcept {} explicit constexpr Vector3(T s) noexcept : X(s), Y(s), Z(s) {} diff --git a/Sources/nCine/Primitives/Vector4.h b/Sources/nCine/Primitives/Vector4.h index e59875fd..38a98313 100644 --- a/Sources/nCine/Primitives/Vector4.h +++ b/Sources/nCine/Primitives/Vector4.h @@ -10,6 +10,8 @@ namespace nCine { + using Death::Containers::NoInitT; + /// Four-component vector template class Vector4 @@ -19,7 +21,7 @@ namespace nCine constexpr Vector4() noexcept : X{T(0)}, Y{T(0)}, Z{T(0)}, W{T(0)} {} - explicit Vector4(Death::Containers::NoInitT) noexcept + explicit Vector4(NoInitT) noexcept {} explicit constexpr Vector4(T s) noexcept : X(s), Y(s), Z(s), W(s) {}