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

Handle nil/non-bool returns for keyHandlers #329

Merged
merged 2 commits into from
May 15, 2016
Merged

Conversation

PabstMirror
Copy link
Contributor

When user added key handler returns bad data, arma throws a generic unhelpful error.

Error in expression <#line 1 "x\cba\addons\events\fnc_keyHand>
 Error position: <#line 1 "x\cba\addons\events\fnc_keyHand>
 Error Type Script, expected Bool

_blockInput is returned at bottom of our function, so if a handler returns bad data, our function will return it as well.

LOG( won't show under normal debug; we could swap to WARNING( if we want to give feedback (this is what we had before #284)?

keyHandlerUp is similar, but doesn't return the results, so it shouldn't matter there.

@PabstMirror PabstMirror added this to the 2.3.2 milestone May 14, 2016
@Killswitch00
Copy link
Contributor

If a WARNING could show enough info to help indicate which handler (read: which addon/mod component) that's broken, that would be useful.

@commy2
Copy link
Contributor

commy2 commented May 15, 2016

I think it would be better if we replace L:70
_blockInput
with:
!isNil "_blockInput" && {_blockInput isEqualType true}

Benefits:

  • it's closer to all other event handlers that use a boolean true to overwrite something - if you return anything else than a boolean or nil, it is treadted just like false
  • no RPT spam for addons that probably won't be updated (ever again or soon)
  • you don't have to check this condition multiple times (for every active keybinding) every frame you hold down at least one key.

@PabstMirror
Copy link
Contributor Author

PabstMirror commented May 15, 2016

@Killswitch00 the logging would work like this:

["A", "B", ["C", "D"], { systemChat "x";}, {}, [16, [false, false, false]]] call cba_fnc_addKeybind;
->
...keyHandlerDown.sqf:54","Keybind Handler returned nil or non-bool:  _x=a_b_down,  _blockInput=any"]

a_b should make it easy to id the mod. But I agree with commy2, and I don't think it's worth throwing an rpt for each keypress when an addon returns nil. I left the logging in, but it would only run with DEBUG_MODE_FULL

@Killswitch00
Copy link
Contributor

Yeah, commy2 made good points and I agree with his no-spam suggestion

@Killswitch00 Killswitch00 merged commit 3fd22f5 into master May 15, 2016
@thojkooi thojkooi deleted the fixBadKeybindReturn branch June 16, 2016 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants