-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/resource manager #97
Conversation
WalkthroughThis pull request introduces a new Changes
TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 5
Files selected for processing (19)
- .github/workflows/release.yml (1 hunks)
- CMakeLists.txt (3 hunks)
- deps/boost/CMakeLists.txt (1 hunks)
- docs/user-guide/installation/source/windows.md (1 hunks)
- scripts/bundle-linux.sh (1 hunks)
- scripts/bundle-macos.sh (1 hunks)
- scripts/bundle-windows.ps1 (1 hunks)
- scripts/compil.sh (1 hunks)
- scripts/install-deps-windows.ps1 (1 hunks)
- src/Client/Raylib/Audio/Audio.cpp (4 hunks)
- src/Client/Raylib/Audio/Audio.hpp (2 hunks)
- src/Client/Raylib/Graphics/Graphics.cpp (3 hunks)
- src/ECS/CMakeLists.txt (2 hunks)
- src/ECS/Json.cpp (7 hunks)
- src/ECS/Json.hpp (3 hunks)
- src/ECS/ResourcesManager.cpp (1 hunks)
- src/ECS/ResourcesManager.hpp (1 hunks)
- src/main_client.cpp (2 hunks)
- src/main_server.cpp (2 hunks)
Files skipped from review due to trivial changes (5)
- deps/boost/CMakeLists.txt
- docs/user-guide/installation/source/windows.md
- scripts/bundle-windows.ps1
- scripts/compil.sh
- src/ECS/CMakeLists.txt
Additional comments (Suppressed): 28
scripts/install-deps-windows.ps1 (1)
- 3-20: The new hunks introduce an interactive mode for installing LLVM and CMake if the
--interactive
argument is passed to the script. This is a good addition as it allows users to manually intervene during the installation process if necessary. However, it's important to ensure that this change is documented in the script's usage instructions so that users are aware of this new feature.scripts/bundle-macos.sh (1)
- 8-8: The new flags
-DPACKAGED=1 -DNO_USE_CLANG_TIDY=true
have been added to the cmake command. Ensure that these flags are properly handled in the CMakeLists.txt files and that they have the intended effect on the build process. The-DPACKAGED=1
flag seems to indicate a packaged build, and-DNO_USE_CLANG_TIDY=true
appears to disable the use of Clang-Tidy. Verify that these assumptions are correct.scripts/bundle-linux.sh (1)
- 8-8: The new flags
-DPACKAGED=1 -DNO_USE_CLANG_TIDY=true
have been added to thecmake
command. Ensure that these flags are properly handled in the CMakeLists.txt files and that they have the intended effect on the build process. The-DPACKAGED=1
flag seems to be related to enabling packaging, and-DNO_USE_CLANG_TIDY=true
appears to disable the use of Clang-Tidy. Verify that these changes are intentional and correctly implemented.src/ECS/ResourcesManager.hpp (1)
- 1-16: The
ResourcesManager
class has been introduced with two static methodsconvertPath
andinit
. TheconvertPath
method is used to convert a given path by appending it to the_resourcePath
. Theinit
method is used to initialize the_resourcePath
based on theexecPath
parameter. The_resourcePath
is a static private member of theResourcesManager
class.The use of a static private member variable
_resourcePath
might lead to issues if multiple threads are trying to access or modify it at the same time. Consider using a mutex or other synchronization mechanism to prevent data races if this class is intended to be used in a multithreaded context.Also, the
init
method seems to be a one-time setup function. If theexecPath
can change during the runtime of the application, it would be better to handle that scenario as well.Lastly, the
convertPath
method takes a const reference to a string but returns a new string. If the conversion is not complex, consider returning a const reference to avoid unnecessary copies..github/workflows/release.yml (1)
- 163-168: The new hunk has added the
--recurse-submodules
flag to thegit clone
command. This flag is used to clone not only theraylib
repository but also its submodules. This change implies that theraylib
repository has submodules that are necessary for the build process. Please ensure that the submodules do not introduce any unwanted dependencies or security vulnerabilities.- git clone https://github.com/raysan5/raylib.git raylib-repo + git clone --recurse-submodules https://github.com/raysan5/raylib.git raylib-reposrc/main_client.cpp (2)
25-31: The
ResourcesManager.hpp
header file has been included. This is in line with the changes mentioned in the PR summary.58-64: The
ResourcesManager::init
function is called withav[0]
as the argument. Ensure thatav[0]
(which typically contains the path of the executable) is the intended argument for this function. Also, verify that theinit
function handles potential errors appropriately, as any issues with resource path initialization could impact the entire application.src/main_server.cpp (2)
4-7: The inclusion of the
ResourcesManager.hpp
header file is new. Ensure that the file exists and is in the correct location.46-52: The
ResourcesManager::init
function is called withav[0]
as the argument. This is typically the execution path of the program. Ensure that this is the intended use and that theinit
function can handle this input correctly.src/Client/Raylib/Audio/Audio.hpp (2)
37-47: The
Sound
class now includes a_realPath
member variable and a correspondinggetRealPath
method. Ensure that the_realPath
is correctly initialized and updated whenever_path
changes. Also, consider the implications of having two separate path variables. If they can get out of sync, it might lead to confusion and bugs.65-75: Similar to the
Sound
class, theMusic
class now includes a_realPath
member variable and a correspondinggetRealPath
method. As with theSound
class, ensure that the_realPath
is correctly initialized and updated whenever_path
changes. Also, consider the implications of having two separate path variables. If they can get out of sync, it might lead to confusion and bugs.src/ECS/Json.hpp (3)
39-39: The
isDataExist
function has been changed from a non-static to a static function. Ensure that all calls to this function throughout the codebase have been updated to match the new usage.59-59: The constructor of the
Json
class has been changed from a non-default to a default constructor. This change is in line with the Singleton design pattern, which requires that the constructor be private and default to prevent instantiation from outside the class.73-73: The
loadJsonData
function has been changed from a non-static to a static function. Ensure that all calls to this function throughout the codebase have been updated to match the new usage.src/Client/Raylib/Graphics/Graphics.cpp (3)
7-13: The
ResourcesManager
header file is included to use itsconvertPath
function for file path conversion. This change is consistent with the PR summary.380-383: The
LoadImage
function now uses theResourcesManager::convertPath
function to convert the file path. Ensure that theResourcesManager
has been properly initialized before this point, otherwise, theconvertPath
function might not work as expected.440-443: The
LoadTexture
function now uses theResourcesManager::convertPath
function to convert the file path. As with the previous comment, ensure that theResourcesManager
has been properly initialized before this point.src/Client/Raylib/Audio/Audio.cpp (5)
8-9: The inclusion of the
ResourcesManager.hpp
is a new addition to the file. Ensure that the file exists and is in the correct location.36-42: The
Sound
constructor now uses theResourcesManager::convertPath
function to convert the file path before loading the sound. This change could affect how file paths are handled throughout the application. Ensure that all file paths passed to theSound
constructor are compatible with theResourcesManager::convertPath
function.106-112: The
Sound
class now includes agetRealPath
method, which returns the converted file path. This is a new addition to the class's interface. Ensure that this method is used correctly throughout the application.116-122: The
Music
constructor now uses theResourcesManager::convertPath
function to convert the file path before loading the music. This change could affect how file paths are handled throughout the application. Ensure that all file paths passed to theMusic
constructor are compatible with theResourcesManager::convertPath
function.200-207: The
Music
class now includes agetRealPath
method, which returns the converted file path. This is a new addition to the class's interface. Ensure that this method is used correctly throughout the application.CMakeLists.txt (2)
100-115: The
PACKAGED
compile definition is being added conditionally based on thePACKAGED
variable. Ensure that this variable is being set correctly in all build configurations and that the implications of this definition are well understood throughout the codebase.119-119: No changes have been made in this hunk. The
if(MSVC)
check is still present as before.src/ECS/Json.cpp (4)
20-20: The
loadJsonData
function now uses theResourcesManager::convertPath
function to convert the file path. This change is consistent with the PR summary and should help ensure that file paths are handled correctly across different platforms. However, it's important to verify that theResourcesManager::convertPath
function is correctly implemented and that it returns the expected results in all cases.38-38: The
indexes
variable is now being accessed usingconst auto &key
instead ofauto &key
. This change is a good practice as it prevents accidental modification of theindexes
elements within the loop.83-87: The
getDatasFromList
function now supports nested arrays, as mentioned in the PR summary. This is a useful feature, but it's important to ensure that it's implemented correctly. In particular, make sure that the recursion doesn't lead to stack overflow errors for deeply nested arrays.150-154: The
getInstance
method now initializes the_jsonDatas
member if it's empty. This is a significant change from the previous implementation, where_jsonDatas
was initialized in the constructor. This change could improve performance by delaying the loading of JSON data until it's actually needed. However, it's important to ensure that this change doesn't introduce any race conditions in multithreaded environments.
… feat/resource-manager
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Files selected for processing (8)
- .gitignore (1 hunks)
- CMakeLists.txt (3 hunks)
- src/Client/Raylib/Graphics/Graphics.cpp (3 hunks)
- src/ECS/Json.cpp (7 hunks)
- src/ECS/Json.hpp (3 hunks)
- src/ECS/ResourcesManager.cpp (1 hunks)
- src/ECS/ResourcesManager.hpp (1 hunks)
- src/main_server.cpp (2 hunks)
Files skipped from review due to trivial changes (3)
- .gitignore
- src/ECS/ResourcesManager.cpp
- src/ECS/ResourcesManager.hpp
Additional comments (Suppressed): 18
src/main_server.cpp (2)
2-8: The inclusion of
ResourcesManager.hpp
is new. Ensure that the file exists and is in the correct location.46-52: The
ECS::ResourcesManager::init(av[0]);
line is new. This function initializes the resource path based on the executable path. Ensure that the executable path is always passed as the first argument (av[0]
) when the program is run.src/ECS/Json.hpp (3)
41-41: The
isDataExist
function has been made static. Ensure that all calls to this function throughout the codebase have been updated to match the new usage.61-61: The constructor of
Json
class has been made private and default. This change enforces the Singleton pattern more strictly by preventing the creation ofJson
objects using the constructor.75-75: The
loadJsonData
function has been made static. Ensure that all calls to this function throughout the codebase have been updated to match the new usage.src/Client/Raylib/Graphics/Graphics.cpp (3)
7-13: The
ResourcesManager
header file is included in the new hunk. This is likely to use theconvertPath
function from theResourcesManager
class in theECS
namespace. This change is consistent with the PR summary.380-384: The
LoadImage
function now uses theconvertPath
function from theResourcesManager
class to convert the file path. This change is consistent with the PR summary. However, ensure that theconvertPath
function correctly handles all possible path formats that theLoadImage
function might receive.439-445: The
LoadTexture
function now uses theconvertPath
function from theResourcesManager
class to convert the file path. This change is consistent with the PR summary. However, ensure that theconvertPath
function correctly handles all possible path formats that theLoadTexture
function might receive.CMakeLists.txt (3)
34-40: The destination for the installed assets directory has been changed from "share/${PROJECT_NAME_CLIENT}" to "share/${PROJECT_NAME}". Ensure that this change does not affect the expected location of the assets in the application.
61-86: The condition for using Clang-Tidy has been modified. Previously, Clang-Tidy was disabled if
NO_USE_CLANG_TIDY
was defined and the compiler was MSVC. Now, Clang-Tidy is disabled ifNO_USE_CLANG_TIDY
is defined, regardless of the compiler. This change makes the use of Clang-Tidy more consistent across different compilers.102-114: A new compile definition
PACKAGED
has been added for both the client and server targets whenPACKAGED
is defined. This could be used to conditionally compile code based on whether the application is being packaged or not. Ensure that this new compile definition is used appropriately in the codebase.src/ECS/Json.cpp (7)
20-20: The
loadJsonData
function now uses theResourcesManager::convertPath
function to convert the path before opening the file. This change is likely to improve the portability of the code by ensuring that the path is always an absolute path based on the initialized resource path. However, it's important to ensure that theResourcesManager
has been properly initialized before this function is called.38-38: The
indexes
variable is now being iterated over as a const reference, which prevents unnecessary copies and improves performance. This is a good practice when the elements of the container are not being modified.76-76: The
list
variable is now being iterated over as a const reference, which prevents unnecessary copies and improves performance. This is a good practice when the elements of the container are not being modified.95-95: The
list
variable is now being iterated over as a const reference, which prevents unnecessary copies and improves performance. This is a good practice when the elements of the container are not being modified.113-113: The
list
variable is now being iterated over as a const reference, which prevents unnecessary copies and improves performance. This is a good practice when the elements of the container are not being modified.145-145: The
indexes
variable is now being iterated over as a const reference, which prevents unnecessary copies and improves performance. This is a good practice when the elements of the container are not being modified.164-168: The
getInstance
function has been modified to load JSON data only if_jsonDatas
is empty. This change improves performance by avoiding unnecessary loading of JSON data. However, it's important to ensure that thepathToJson
variable is properly initialized before this function is called.
What is the current behavior? (link an issue based on the kind of change this pr introduce)
What is the new behavior (if this is a feature change)?
https://x-r-g-b.atlassian.net/browse/RB-128?atlOrigin=eyJpIjoiMTlhNjFlYTMzM2Q3NGY0YjlmZjBiNjgxMzZiZjQwODIiLCJwIjoiaiJ9
Summary by CodeRabbit
ResourcesManager
class to manage and convert file paths, improving the handling of resources across the application.Audio
,Graphics
, andJson
classes to use the newResourcesManager
, ensuring consistent path handling.filesystem
library to the project, enhancing file and path operations..gitignore
to ignore the "r-type-linux.tar.gz" file, keeping the repository clean.