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

(repair) - isRepairVehicle handling values according to wiki #6278

Merged
merged 2 commits into from
Apr 27, 2018

Conversation

Cuel
Copy link
Contributor

@Cuel Cuel commented Apr 16, 2018

The wiki states that ACE_isRepairVehicle is a boolean but this function only checked for integer values, resulting in a script error for whoever used the wiki value.

When merged this pull request will:

  • Make isRepairVehicle handle both types

@jonpas
Copy link
Member

jonpas commented Apr 16, 2018

Hmh, I'd rather change wiki, that leaves open possibilities for repair levels or something.

@dedmen
Copy link
Contributor

dedmen commented Apr 16, 2018

So does adding the numbering back when we want repair levels.
a isRepairVehicle being a boolean makes much more sense. If it was a repair level it should be called differently anyway

@BaerMitUmlaut
Copy link
Member

I may be nitpicking here, but why the outer parenthesis? Why the // return comment? It's the last statement, this being the return value should be clear for somebody who knows SQF.
Additionally, right now it's a 160 character line. Please consider splitting it.

Disregarding that, I agree with dedmen. The is prefix implies that it's a boolean and it's fully backwards compatible. I don't see us moving to multiple repair levels this late into A3.

@Cuel
Copy link
Contributor Author

Cuel commented Apr 16, 2018

In CBA //return comments have been popping up here and there (for clarification?) so I figured I'd add it. If that doesn't apply to ace I'll remove it. I just left the parenthesis since it was there earlier.

@commy2
Copy link
Contributor

commy2 commented Apr 17, 2018

I do that whenever it's not clear what a return value is. It's debateable here, because on the one hand, this expression is huge, on the other, it is the last line of the script.

What bugs me more about this PR is:

[false, true] select 

@PabstMirror
Copy link
Contributor

in [1, true] might be safer as it can handle any input

@PabstMirror PabstMirror added this to the 3.13.0 milestone Apr 17, 2018
@PabstMirror PabstMirror added the kind/bug-fix Release Notes: **FIXED:** label Apr 17, 2018
@Cuel
Copy link
Contributor Author

Cuel commented Apr 17, 2018

That's what I had at first, with a small edit to cover > 1 numbers
Cuel@74f5b99

@kymckay
Copy link
Member

kymckay commented Apr 17, 2018

[false, true] select

😱 heresy!

@Cuel
Copy link
Contributor Author

Cuel commented Apr 18, 2018

So would you guys prefer 74f5b99 or something else or current

@kymckay
Copy link
Member

kymckay commented Apr 18, 2018

Nah it's best as is because the getVariable can return an index. I was just being silly 😉

@Cuel
Copy link
Contributor Author

Cuel commented Apr 18, 2018

Yeah I was talking to everyone who's commenting here 👍

@dedmen
Copy link
Contributor

dedmen commented Apr 18, 2018

My preference would be a slightly modified variant of Cuel@74f5b99

private _value = _vehicle getVariable ["ACE_isRepairVehicle", -1];
if (_value == -1) exitWith { getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(canRepair)) > 0 };
(_value isEqualTo true || {value > 0})  // return

Shorter and faster.
And also is better than current version. Because it only does the config lookup when necessary instead of always doing it.

@Dystopian
Copy link
Contributor

@dedmen
to handle false in _value
(_value isEqualTo true || {value > 0}) // return
->
if (_value isEqualType true) then {_value} else {value > 0}

@dedmen
Copy link
Contributor

dedmen commented Apr 18, 2018

^ That is slower though...
4 command calls vs 6.

@Cuel
Copy link
Contributor Author

Cuel commented Apr 18, 2018

But you'd be checking if {false > 0}

@Cuel
Copy link
Contributor Author

Cuel commented Apr 27, 2018

Any decision?

@kymckay
Copy link
Member

kymckay commented Apr 27, 2018

Honestly I don't think we need to handle values greater than one for the time being. The variable name doesn't imply that anyway and I really don't foresee a need for us to add it.

If we want to add repair levels in future we can PR it separately. I say keep this code simple in [1, true]

Copy link
Member

@kymckay kymckay left a comment

Choose a reason for hiding this comment

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

I hate the ``// return`, but will approve anyway 😄

@Cuel
Copy link
Contributor Author

Cuel commented Apr 27, 2018

:(

@PabstMirror PabstMirror merged commit 265bc62 into acemod:master Apr 27, 2018
@PabstMirror PabstMirror modified the milestones: 3.13.0, 3.12.3 Jul 5, 2018
BaerMitUmlaut pushed a commit that referenced this pull request Aug 5, 2019
* handle boolean and integer

* check if value is 1 or true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug-fix Release Notes: **FIXED:**
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants