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

Add Feature Camera Player EH #982

Merged
merged 6 commits into from
Sep 17, 2018
Merged

Add Feature Camera Player EH #982

merged 6 commits into from
Sep 17, 2018

Conversation

jonpas
Copy link
Member

@jonpas jonpas commented Sep 14, 2018

When merged this pull request will:

  • Port feature camera checker from ACE3
  • Add "featureCamera" Player Event Handler
  • Allow registering custom feature cameras

---------------------------------------------------------------------------- */
SCRIPT(registerFeatureCamera);

GVAR(featureCameras) pushBackUnique _this;
Copy link
Member Author

Choose a reason for hiding this comment

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

Should probably add argument checking.

@@ -192,6 +200,12 @@ if (_id != -1) then {
GVAR(oldCameraView) = _data;
[QGVAR(cameraViewEvent), [_player, _data]] call CBA_fnc_localEvent;
};

_data = call CBA_fnc_getActiveFeatureCamera;
Copy link
Contributor

Choose a reason for hiding this comment

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

performance?
We might want to only add this when it's actually needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's just a bunch of null checks (7 in vanilla). Aren't all Player EHs only added when they are needed already?

Copy link
Member Author

@jonpas jonpas Sep 14, 2018

Choose a reason for hiding this comment

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

0.0301 - 0.031 ms on 10k/10k cycles.

Copy link
Contributor

Choose a reason for hiding this comment

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

0.03 ouhhhh.
How about a check whether either the array of eventhandlers is not empty (by using the CBA internal variable name of the array)
Or check that GVAR(oldFeatureCamera is not nil? and set it to non nil once a Eventhandler is added in line 92?

Copy link
Member Author

Choose a reason for hiding this comment

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

That wouldn't work for cases where we might want to use internal variable (ref ACE PR).

@PabstMirror
Copy link
Contributor

https://github.com/CBATeam/CBA_A3/compare/camera-playerEH...featureCamOpti?expand=1
Split arrays, simplify main loop:
0.0297 ms vs 0.0195 ms

Copy link
Contributor

@commy2 commy2 left a comment

Choose a reason for hiding this comment

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

Check should be every .5 seconds, like it was in ACE.

@commy2
Copy link
Contributor

commy2 commented Sep 17, 2018

Comments on the commits, not the PR :x

@jonpas
Copy link
Member Author

jonpas commented Sep 17, 2018

Well yes, they were made before that code was merged into this branch with the PR. How are you supposed to comment on the PR if it doesn't exist?

@jonpas
Copy link
Member Author

jonpas commented Sep 17, 2018

@commy2 is this good or should it be completely split from GVAR(playerEHInfo)?

GVAR(oldFeatureCamera) = _data;
[QGVAR(featureCameraEvent), [call CBA_fnc_currentUnit, _data]] call CBA_fnc_localEvent;
};
}] call CBA_fnc_compileFinal;
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no reason to compileFinal this. It is only done for Map, because it is a mission event handler and therefore affected by the recompiled-every-execution-bug. That however does not apply to CBA PFH.

Copy link
Contributor

@commy2 commy2 left a comment

Choose a reason for hiding this comment

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

lgtm, needs testing

@jonpas
Copy link
Member Author

jonpas commented Sep 17, 2018

I have tested it, works perfectly fine with ACE3 (with acemod/ACE3#6573) and ACRE2 (with IDI-Systems/acre2#582).

@commy2 commy2 merged commit b2058d2 into master Sep 17, 2018
@commy2 commy2 deleted the camera-playerEH branch September 17, 2018 21:28
@@ -214,6 +222,15 @@ if (_id != -1) then {
};
} call CBA_fnc_directCall;
};

GVAR(playerEHInfo) pushBack ([{
Copy link
Contributor

Choose a reason for hiding this comment

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

The handler is still always added even if noone is listening for it.
Seems to be fairly easy to just add it in L92 instead.

Copy link
Member Author

@jonpas jonpas Sep 18, 2018

Choose a reason for hiding this comment

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

We could do this since acemod/ACE3@922774d. Unsure how worth it is though, ACE3 is already set to use it and that covers a pretty big range of CBA users.

ViperMaul added a commit that referenced this pull request Sep 19, 2018
* master:
  Add Feature Camera Player EH (#982)
  German brands for JR and JAM components (#988)
  veteran29 Polish translation updates master (#986)
  German translation, part 3 (#981)
  German translation, part 2 (#980)
  German translation, part 1 (#979)
  add Joint Ammo Magazines A3 (#928)
  CBA_fnc_getVolume not calculating volume correctly (#984)
  ProjectileTracking - Stop tracking stationary objects (#985)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants