-
Notifications
You must be signed in to change notification settings - Fork 737
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
Cargo - Support of object without ace_cargo_size
defined in config or -1
config value
#6364
Cargo - Support of object without ace_cargo_size
defined in config or -1
config value
#6364
Conversation
- use of ace_cargo_fnc_getSizeItem to determine size of item - prefer the config way instead of manually set size - This will also take into account object manually added to the cargo system with ace_cargo_fnc_setsize - use the cargo object for ace_cargo_fnc_unloadItem.
private _itemSize = if (isNumber (configFile >> "CfgVehicles" >> _typeOfCargo >> QEGVAR(cargo,size))) then { | ||
getNumber (configFile >> "CfgVehicles" >> _typeOfCargo >> QEGVAR(cargo,size)); | ||
} else { | ||
[_cargo] call EFUNC(cargo,getSizeItem); |
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.
there is error here if cargo module is no loaded
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.
[[_cargo] call EFUNC(cargo,getSizeItem)] param [0, _radiusOfItem];
could resolve that issue.
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.
I meant if cargo module is not loaded there is no EFUNC(cargo,getSizeItem)
and you call non-existing function
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.
I just learned in scheduled EFUNC(cargo,getSizeItem)
will trow an undefined variables error which is not the case in unscheduled.
If you guys are using an other approach, let me know, I will use it for consistency.
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.
if (["ace_backpacks"] call EFUNC(common,isModLoaded)) then { |
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.
Thanks!
For safety we could take the |
This fix handle the case when cargo module is not loaded for scheduled and unscheduled environnement.
if (isNumber (configFile >> "CfgVehicles" >> _typeOfCargo >> QEGVAR(cargo,size))) then { | ||
_radiusOfItem = (((getNumber (configFile >> "CfgVehicles" >> _typeOfCargo >> QEGVAR(cargo,size))) ^ 0.35) max 0.75); | ||
private _typeOfCargo = if (_cargo isEqualType "") then {_cargo} else {typeOf _cargo}; | ||
private _itemSize = if (isNumber (configFile >> "CfgVehicles" >> _typeOfCargo >> QEGVAR(cargo,size))) then { |
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.
this code piece already exists in EFUNC(cargo,getSizeItem)
, so can be optimized well
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.
I did a choice here as explain in the PR description:
Prefer the config way instead to determine the size of
_cargo
directly withace_cargo_fnc_getSizeItem
(this avoid inconsistency when playerace_cargo_fnc_setsize
of an object lower from theace_cargo_size
defined in config)
I can add a parameter in EFUNC(cargo,getSizeItem)
to prefer the config if exist or prefer varaible if exist
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.
I am supposing that ace_cargo_size
in config is correct so if I am calling EFUNC(cargo,getSizeItem)
and if player has ace_cargo_fnc_setsize
an other value (a smaller one for exemple) the function will return a bad position base on a wrong value changed by player. This avoid that case and also cover the objective of this PR where ace_cargo_size
in config is not defined.
private _itemSize = if (isNumber (configFile >> "CfgVehicles" >> _typeOfCargo >> QEGVAR(cargo,size))) then { | ||
getNumber (configFile >> "CfgVehicles" >> _typeOfCargo >> QEGVAR(cargo,size)); | ||
} else { | ||
if (["ace_cargo"] call EFUNC(common,isModLoaded)) then { |
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.
EFUNC(common,isModLoaded)
-> FUNC(isModLoaded)
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.
EFUNC(common,isModLoaded)
-> ace_common_fnc_isModload
FUNC(isModLoaded)
-> ace_cargo_fnc_isModload
Because the second doesn't exist I am using the first one as suggested by @jonpas here: #6364 (comment)
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.
here we are in common
module (addons/common/functions/fnc_findUnloadPosition
) so FUNC is ace_common_fnc
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.
woups!!!
_radiusOfItem; | ||
}; | ||
}; | ||
if !(_itemSize isEqualTo -1) then { |
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.
just _itemSize != -1
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.
With isEqualTo
you can compare different type like: nil isEqualTo -1
so the function will never fail
It doesn't throw error when comparing different types, i.e. ("eleven" isEqualTo 11)
But, if ace use it as convention I will change it.
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.
_itemSize
here is always number
}; | ||
}; | ||
if !(_itemSize isEqualTo -1) then { | ||
_radiusOfItem = (_itemSize ^ 0.35) max 0.75; |
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.
most significant change: before this PR if cargo module is not loaded _radiusOfItem
was 1 and now it becomes (1 ^ 0.35) max 0.75
.
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.
Ahah! I didn't know we could make joke in review!
Thanks a lot for the time you take to review this :-), I appreciate your feedback!
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.
(1 ^ 0.35) max 0.75 = 1 max 0.75 = 1
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.
Sorry I thought you were ironical :/
- _itemSize here is always number - here we are in common module (addons/common/functions/fnc_findUnloadPosition) so FUNC is ace_common_fnc
@PabstMirror The value give by user should only be use if no config value is available. |
- this is correcting the unloading position with the ace_cargo_size define as variable - this can be removed when: acemod/ACE3#6364 is merged
- if the config value is -1, get the `ace_cargo_size` from the `ace_cargo_fnc_getSizeItem - #6357 (comment)
ace_cargo_size
defined in configace_cargo_size
defined in config or -1
config value
looks good, it does require that people set reasonable cargo sizes for items they load |
…or `-1` config value (#6364) * Add: Now findUnloadPosition support also cargo object - use of ace_cargo_fnc_getSizeItem to determine size of item - prefer the config way instead of manually set size - This will also take into account object manually added to the cargo system with ace_cargo_fnc_setsize - use the cargo object for ace_cargo_fnc_unloadItem. * FIX: old work around * FIX: error when cargo module is not loaded * As suggested by @orbis2358 This fix handle the case when cargo module is not loaded for scheduled and unscheduled environnement. * Use ACE framework to check if module is present * FIX: EFUNC and isEqualto - _itemSize here is always number - here we are in common module (addons/common/functions/fnc_findUnloadPosition) so FUNC is ace_common_fnc * FIX case where config value is `-1` - if the config value is -1, get the `ace_cargo_size` from the `ace_cargo_fnc_getSizeItem - #6357 (comment)
close #6357
Actually, if
_typeofcargo
does not haveace_cargo_size
define in config, the_radiusOfItem
of the object is1
. This inconsistency can be avoid by using theace_cargo_fnc_getSizeItem
which take an object as parameter and get the size of the object defined manually by user (ace_cargo_fnc_setsize
).By having a
_radiusOfItem
more accurate, theace_common_fnc_findUnloadPosition
will find better position for unloading and avoid vehicle explosion when big objects, withoutace_cargo_size
defined in config, are unloaded.I don't know if it is the best way to handle this case but at least it is a work around. Cheers.
When merged this pull request will:
ace_common_fnc_findUnloadPosition
can take object as parameter_cargo
directly withace_cargo_fnc_getSizeItem
(this avoid inconsistency when playerace_cargo_fnc_setsize
of an object lower from theace_cargo_size
defined in config)-1
to avoid the issue: Offest for large containers too small when being unloaded from trucks #6357 (comment)ace_cargo_size
is not define in config, use theace_cargo_fnc_getSizeItem
to get object size set by player withace_cargo_fnc_setsize
ace_cargo_fnc_unloadItem
accordingly (use the cargo object instead of the class name).