Skip to content

Added team color synchronization#185

Merged
Killswitch00 merged 7 commits intoCBATeam:masterfrom
BaerMitUmlaut:synch-team-colors
Oct 30, 2015
Merged

Added team color synchronization#185
Killswitch00 merged 7 commits intoCBATeam:masterfrom
BaerMitUmlaut:synch-team-colors

Conversation

@BaerMitUmlaut
Copy link
Copy Markdown
Contributor

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
Copy link
Copy Markdown
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"

@BaerMitUmlaut
Copy link
Copy Markdown
Contributor Author

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
Copy link
Copy Markdown
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.

@BaerMitUmlaut
Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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...

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants