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

Added team color synchronization #185

Merged
merged 7 commits into from Oct 30, 2015

Conversation

Projects
None yet
4 participants
@BaerMitUmlaut
Contributor

BaerMitUmlaut commented Oct 18, 2015

This synchronizes fireteam colors across the network. Other addons can either call the "CBA_teamColorChanged" event or indirectly trigger that event by remote calling assignTeam on the squad leaders machine.

See issue #94.

@PabstMirror

This comment has been minimized.

Show comment
Hide comment
@PabstMirror

PabstMirror Oct 18, 2015

Contributor

In my opinion, checking each frame might be overkill, 1-3 seconds should be fine.

Why not have the group leader call setVariable. I think if there is network traffic delays, the client could raise that event multiple times before it gets the updated variable back from the server. (really only an issue if checking each frame)

This doesn't throw script error, so nothing probably needs to be done, just an oddity to be aware of.
When zeusing into a unit, assignedTeam player can return nil:

{
    _assignedTeam = assignedTeam _x;
    diag_log text format ["%1's team is [%2](%3)", _x, _assignedTeam, (isNil "_assignedTeam")];
    if (_assignedTeam != "MAIN") then {diag_log text "A";} else {diag_log text "B";};
    true
} count units player;
//Returns `zee's team is [<null>](true)` //Note neither A or B run

Debug:

[player, ace_player] = [zee,pp_2]
assignedTeam zee = nil
assignedTeam pp_2 = "RED"
Contributor

PabstMirror commented Oct 18, 2015

In my opinion, checking each frame might be overkill, 1-3 seconds should be fine.

Why not have the group leader call setVariable. I think if there is network traffic delays, the client could raise that event multiple times before it gets the updated variable back from the server. (really only an issue if checking each frame)

This doesn't throw script error, so nothing probably needs to be done, just an oddity to be aware of.
When zeusing into a unit, assignedTeam player can return nil:

{
    _assignedTeam = assignedTeam _x;
    diag_log text format ["%1's team is [%2](%3)", _x, _assignedTeam, (isNil "_assignedTeam")];
    if (_assignedTeam != "MAIN") then {diag_log text "A";} else {diag_log text "B";};
    true
} count units player;
//Returns `zee's team is [<null>](true)` //Note neither A or B run

Debug:

[player, ace_player] = [zee,pp_2]
assignedTeam zee = nil
assignedTeam pp_2 = "RED"
@BaerMitUmlaut

This comment has been minimized.

Show comment
Hide comment
@BaerMitUmlaut

BaerMitUmlaut Oct 18, 2015

Contributor

Why not have the group leader call setVariable

Because then if I call the event through another addon the setVariable would never be called with the third parameter being true, thus it wouldn't be JIP safe. Unless I missed something?

Contributor

BaerMitUmlaut commented Oct 18, 2015

Why not have the group leader call setVariable

Because then if I call the event through another addon the setVariable would never be called with the third parameter being true, thus it wouldn't be JIP safe. Unless I missed something?

@PabstMirror

This comment has been minimized.

Show comment
Hide comment
@PabstMirror

PabstMirror Oct 19, 2015

Contributor

Start Local MP Server
Change group member's team to "RED"
Event will fire each frame forever on all machines besides the server.
The variable will never be set because remoteEvent doesn't happen locally and all other machines will fail the isServer check.

What I am thinking of is changing remote to globalEvent
And then in the event do:
if (local (leader _unit)) then {
Which should be the group leader who triggered the event.

Contributor

PabstMirror commented Oct 19, 2015

Start Local MP Server
Change group member's team to "RED"
Event will fire each frame forever on all machines besides the server.
The variable will never be set because remoteEvent doesn't happen locally and all other machines will fail the isServer check.

What I am thinking of is changing remote to globalEvent
And then in the event do:
if (local (leader _unit)) then {
Which should be the group leader who triggered the event.

@BaerMitUmlaut

This comment has been minimized.

Show comment
Hide comment
@BaerMitUmlaut

BaerMitUmlaut Oct 19, 2015

Contributor

Fixed. I also set the PFH to run every second instead of every frame, but I could increase the delay further. ACE3 synchs them every 5 seconds, however I think that is a bit too much. It's not a very demanding function.

Contributor

BaerMitUmlaut commented Oct 19, 2015

Fixed. I also set the PFH to run every second instead of every frame, but I could increase the delay further. ACE3 synchs them every 5 seconds, however I think that is a bit too much. It's not a very demanding function.

{
if ((assignedTeam _x) != (_x getVariable [QGVAR(synchedTeam), "MAIN"])) then {
//Local team != currently synched team, so we need to synchronize them again
["CBA_teamColorChanged", [_x, assignedTeam _x]] call CBA_fnc_globalEvent;

This comment has been minimized.

@thojkooi

thojkooi Oct 20, 2015

Contributor

Why a globalEvent and not a targetEvent? Is this color necessary to be synced on all clients?

@thojkooi

thojkooi Oct 20, 2015

Contributor

Why a globalEvent and not a targetEvent? Is this color necessary to be synced on all clients?

This comment has been minimized.

@BaerMitUmlaut

BaerMitUmlaut Oct 20, 2015

Contributor

Yes, in case another player joins the squad he needs to know the assigned colors as well.

@BaerMitUmlaut

BaerMitUmlaut Oct 20, 2015

Contributor

Yes, in case another player joins the squad he needs to know the assigned colors as well.

This comment has been minimized.

@thojkooi

thojkooi Oct 20, 2015

Contributor

Doesn't that mean you want to sync them up upon joining the team instead?

@thojkooi

thojkooi Oct 20, 2015

Contributor

Doesn't that mean you want to sync them up upon joining the team instead?

This comment has been minimized.

@BaerMitUmlaut

BaerMitUmlaut Oct 20, 2015

Contributor

That's possible too, but would require extension of the PFH (unless there's a CBA event for it? there's no doc for default events and I didn't see any either) and it would ofc have a delay. Without that delay it would be great for triggering a CBA event though.

Either options aren't perfect in my opinion. Choose your poison...

@BaerMitUmlaut

BaerMitUmlaut Oct 20, 2015

Contributor

That's possible too, but would require extension of the PFH (unless there's a CBA event for it? there's no doc for default events and I didn't see any either) and it would ofc have a delay. Without that delay it would be great for triggering a CBA event though.

Either options aren't perfect in my opinion. Choose your poison...

Show outdated Hide outdated addons/common/fnc_synchTeamColors.sqf
Internal Function: CBA_fnc_synchTeamColors
Description:
Synchs the team colors every second. Does not need to be called manually.

This comment has been minimized.

@thojkooi

thojkooi Oct 20, 2015

Contributor

There is no time delay in this function, but rather in the PFH calling this function. I'd remove the every second part from the description.

@thojkooi

thojkooi Oct 20, 2015

Contributor

There is no time delay in this function, but rather in the PFH calling this function. I'd remove the every second part from the description.

Show outdated Hide outdated addons/common/fnc_onTeamColorChanged.sqf
Internal Function: CBA_fnc_onTeamColorChanged
Description:
Assigns the units team color if it changed on another machine.

This comment has been minimized.

@thojkooi

thojkooi Oct 20, 2015

Contributor

Only if it changed on the leaders machine?

@thojkooi

thojkooi Oct 20, 2015

Contributor

Only if it changed on the leaders machine?

Killswitch00 added a commit that referenced this pull request Oct 30, 2015

@Killswitch00 Killswitch00 merged commit 354f1b1 into CBATeam:master Oct 30, 2015

@PabstMirror PabstMirror added this to the 2.2 milestone Nov 24, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment