-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Soft dependency support for resources #2920
base: master
Are you sure you want to change the base?
Conversation
Adds support for soft dependencies, indicated by the manifest entries `soft_dependency` and `soft_dependencies`. Soft dependencies only get started if they exist, making it possible to add optional dependencies to a resource.
Okay I wanted to rename the branch on my repo, but github doesn't seem to like it. |
Thank you for the contribution! I understand the motivation behind this PR and the code looks reasonable. But I don't have enough context to make the final call on if it's actually needed. @prikolium-cfx WDYT? |
Should be discussed together with team. Can't say right now pros and cons of such decision |
Adds single quotes around resource names in dependency loading traces to clarify what is part of the resource name.
Sounds good! I added some quotes around the resource names to clarify what is and what is not part of the resource names. This also makes it match the other traces in the dependency loader. |
@prikolium-cfx any updates on this? |
Goal of this PR
This PR adds support for soft dependencies, indicated by the manifest entries
soft_dependency
andsoft_dependencies
. Soft dependencies only get started if they exist, making it possible to add optional dependencies to a resource. This is useful when a resource can work fine without a dependency, but can benefit from having access to that dependency.See the proposal on the forum for more details: https://forum.cfx.re/t/soft-dependencies-for-resources/5281288/1
How is this PR achieving the goal
This PR implements soft dependencies by loading them the same way as normal dependencies, but if one is missing or fails to start it skips it and continues to the next one. It also still prints the same information as with regular dependencies, and only tries to load the soft dependencies after the hard dependencies have been checked and loaded to prevent starting them when the resource can't start anyway.
This PR specifically adds the
const bool soft = false
parameter to theloadDeps
function. The paramter has a default value of false, to remain backwards compatible. Whensoft
is set totrue
the following things are different as opposed to loading hard dependencies:false
early to stop the resource from loading.resourceDependants
, as stopping the soft dependency should not prevent the resource from running.false
early to stop the resource from loading and storing the dependency inresourceDependencies
to start it later.This PR applies to the following area(s)
This applies to the server and clients. The changes were made in
citizen-resources-core
.Successfully tested on
The changes were tested on the server and FiveM client.
Game builds: b3095
Platforms: Windows
Checklist
Fixes issues
None.