Skip to content
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

Dragging - Code cleanup #9271

Merged
merged 8 commits into from Jul 23, 2023
Merged

Conversation

johnb432
Copy link
Contributor

When merged this pull request will:

IMPORTANT

  • If the contribution affects the documentation, please include your changes in this pull request so the documentation will appear on the website.
  • Development Guidelines are read, understood and applied.
  • Title of this PR uses our standard template Component - Add|Fix|Improve|Change|Make|Remove {changes}.

Copy link
Contributor

@LinkIsGrim LinkIsGrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will have merge conflicts with #9225. Gonna try and finish that first.

addons/dragging/XEH_preInit.sqf Outdated Show resolved Hide resolved
addons/dragging/functions/fnc_canCarry.sqf Outdated Show resolved Hide resolved
addons/dragging/functions/fnc_canDrag.sqf Outdated Show resolved Hide resolved
addons/dragging/functions/fnc_carryObject.sqf Outdated Show resolved Hide resolved
addons/dragging/functions/fnc_dragObject.sqf Outdated Show resolved Hide resolved
addons/dragging/functions/fnc_getWeight.sqf Outdated Show resolved Hide resolved
["ACE3 Common", QGVAR(drag), LLSTRING(DragKeybind), {
private _player = ACE_player;

if (!alive _player) exitWith {false};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!alive _player) exitWith {false};
if !(alive _player) exitWith {false};

Edit: Disregard, see below.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the opposite of the ACE Coding Guidelines (although I know both are used in the code) inconsistently

https://ace3.acemod.org/wiki/development/coding-guidelines.html#55-brackets-around-code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My rule of thumb is: If it's one statement that is easily readable (such as the above), I add it inside the brackets.

But then we have lines such as these. I'm not sure how to interpret the ACE guidelines here - are these fine or should these types of statements be corrected?

@LinkIsGrim LinkIsGrim added the kind/enhancement Release Notes: **IMPROVED:** label Jul 22, 2023
johnb432 and others added 5 commits July 22, 2023 00:32
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
Copy link
Contributor

@LinkIsGrim LinkIsGrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not of fan of ==/!= instead of isEqualTo/isNotEqualTo in conditions and PFHs, though.

*
* Public: No
*/

//IGNORE_PRIVATE_WARNING ["_thisArgs", "_thisID"]; // From CBA_fnc_addBISEventHandler;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sqf_linter will use these hints to reduce false positives
tool hasn't been updated in a long time so it's not that useful
but going forward there really isn't any reason to remove these lines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I add them back?

@johnb432
Copy link
Contributor Author

johnb432 commented Jul 23, 2023

I'm not of fan of ==/!= instead of isEqualTo/isNotEqualTo in conditions and PFHs, though.

The reason is readability for me.
isEqualTo might be less prone to throwing errors, but it will fail just as much as == if the comparison contains a variable that is nil, which, I'd argue, is the most common type of problem.

I can change it though, it's not a problem.

@rautamiekka
Copy link
Contributor

if the comparison contains a variable that is nil

That's why isNil, documentation & testing, exists. It ain't iET's fault.

@johnb432
Copy link
Contributor Author

It ain't iET's fault.

Never claimed it to be...?
I was merely pointing out that both operators/commands were limited in the same way when it comes to variables that are nil.

@PabstMirror
Copy link
Contributor

probably won't be an issue, but iet also handles nulls a little differently

_unit = objNull;
(vehicle _unit) == _unit; // false
(vehicle _unit) isEqualTo _unit; // true

@LinkIsGrim
Copy link
Contributor

I'm not of fan of ==/!= instead of isEqualTo/isNotEqualTo in conditions and PFHs, though.

The reason is readability for me. isEqualTo might be less prone to throwing errors, but it will fail just as much as == if the comparison contains a variable that is nil, which, I'd argue, is the most common type of problem.

I can change it though, it's not a problem.

I'm just a fan of saving nanoseconds in things that run every frame.

@johnb432
Copy link
Contributor Author

I'm just a fan of saving nanoseconds in things that run every frame.

Understandable.

Any further opinions on the matter? isEqualTo seems to be favored atm, will change to that in a couple of days if nobody disagrees.

@jonpas
Copy link
Member

jonpas commented Jul 23, 2023

isEqualTo is so minisculy faster it is pointless to discuss. Just use what is more appropriate in this case. Comparing numbers / same types, == is completely fine.

@LinkIsGrim
Copy link
Contributor

== it is!

@LinkIsGrim LinkIsGrim merged commit dbe372c into acemod:master Jul 23, 2023
5 checks passed
@LinkIsGrim LinkIsGrim added this to the 3.16.0 milestone Jul 23, 2023
@johnb432 johnb432 deleted the drag-carry-code-cleanup branch January 14, 2024 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Release Notes: **IMPROVED:**
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants