From cecbca26c5c94bf563535e85512a29083d4e3d41 Mon Sep 17 00:00:00 2001 From: Kah Wei Date: Thu, 8 Sep 2022 20:55:56 +0800 Subject: [PATCH] Fixed some warnings in ResourceLibrary and SparseSet --- SHADE_Engine/src/Resource/Handle.h | 2 +- SHADE_Engine/src/Resource/ResourceLibrary.h | 2 +- SHADE_Engine/src/Resource/ResourceLibrary.hpp | 8 ++++---- SHADE_Engine/src/Resource/SparseSet.hpp | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/SHADE_Engine/src/Resource/Handle.h b/SHADE_Engine/src/Resource/Handle.h index 34662112..afaec8e1 100644 --- a/SHADE_Engine/src/Resource/Handle.h +++ b/SHADE_Engine/src/Resource/Handle.h @@ -139,7 +139,7 @@ namespace SHADE /*-----------------------------------------------------------------------------*/ /* Data Members */ /*-----------------------------------------------------------------------------*/ - ResourceLibrary* library; + ResourceLibrary* library = nullptr; /*-----------------------------------------------------------------------------*/ /* Friend Declarations */ diff --git a/SHADE_Engine/src/Resource/ResourceLibrary.h b/SHADE_Engine/src/Resource/ResourceLibrary.h index b05dc499..01a78d16 100644 --- a/SHADE_Engine/src/Resource/ResourceLibrary.h +++ b/SHADE_Engine/src/Resource/ResourceLibrary.h @@ -69,7 +69,7 @@ namespace SHADE /* Helper Functions */ /*-----------------------------------------------------------------------------*/ void assertHandleValid(Handle handle) const; - int getAvailableFreeIndex(); + uint32_t getAvailableFreeIndex(); }; /// diff --git a/SHADE_Engine/src/Resource/ResourceLibrary.hpp b/SHADE_Engine/src/Resource/ResourceLibrary.hpp index 2ad856c6..9aa72ead 100644 --- a/SHADE_Engine/src/Resource/ResourceLibrary.hpp +++ b/SHADE_Engine/src/Resource/ResourceLibrary.hpp @@ -35,13 +35,13 @@ namespace SHADE } else { - handle.id.Data.Version = 0; - versionCounts.insert(handle.id.Data.Index, handle.id.Data.Version); + handle.id.Data.Version = 0U; + versionCounts.insert(static_cast(handle.id.Data.Index), handle.id.Data.Version); } handle.library = this; // Create the resource - [[maybe_unused]] T& obj = objects.insert(handle.id.Data.Index, std::forward(args) ...); + [[maybe_unused]] T& obj = objects.insert(static_cast(handle.id.Data.Index), std::forward(args) ...); // Handling SelfHandle assignment if constexpr (std::is_base_of_v, T>) @@ -89,7 +89,7 @@ namespace SHADE } template - inline int ResourceLibrary::getAvailableFreeIndex() + inline uint32_t ResourceLibrary::getAvailableFreeIndex() { // Get from the free list if present if (!freeList.empty()) diff --git a/SHADE_Engine/src/Resource/SparseSet.hpp b/SHADE_Engine/src/Resource/SparseSet.hpp index 70e15f29..ec89790b 100644 --- a/SHADE_Engine/src/Resource/SparseSet.hpp +++ b/SHADE_Engine/src/Resource/SparseSet.hpp @@ -56,7 +56,7 @@ namespace SHADE throw std::invalid_argument("An element at this index does not exist!"); // Swap with the last element - const int BACK_IDX = denseArray.size() - 1; + const auto BACK_IDX = denseArray.size() - 1; std::swap(denseArray[sparseArray[idx]], denseArray.back()); denseArray.pop_back(); // Update the sparse set by swapping the indices @@ -110,7 +110,7 @@ namespace SHADE // We need to resize the array if (idx >= sparseArray.size()) { - const int NEW_SIZE = idx + 1; + const auto NEW_SIZE = idx + 1; sparseArray.resize(NEW_SIZE, INVALID); inverseSparseArray.resize(NEW_SIZE, INVALID); } @@ -123,7 +123,7 @@ namespace SHADE auto& insertedElem = denseArray.emplace_back(std::forward(args) ...); // Update sparse and inverse sparse arrays - const index_type DENSE_IDX = denseArray.size() - 1; + const auto DENSE_IDX = denseArray.size() - 1; sparseArray[idx] = DENSE_IDX; inverseSparseArray[DENSE_IDX] = idx;