GKTurnBasedMatch participants are incorrect/duplicates
Asked Answered
H

2

6

I am working on a turn-based GameCenter game. A GKTurnBasedMatch is created with a GKMatchRequest, with minPlayers and maxPlayers set to 2. I get an NSInvalidArgumentException while trying to end the game with endMatchInTurnWithMatchData, telling me that I didn't set matchOutcome on all participants. Logs for the match object right before this point reveal that my match looks like this:

<GKTurnBasedMatch 0x1c1f2af0 - matchID:c9de6e47-0e9a-4dbe-944b-d2fd4ecd3044 bundleID:com.mybundle.wd status:GKTurnBasedMatchStatusEnded message:'Game Over' creationDate:2013-10-08 01:26:12 +0000 currentParticipant:(null) participants:
<GKTurnBasedParticipant 0x1c184820 - playerID:G:128458444 (local player) status:Done matchOutcome:Lost lastTurnDate:2013-10-10 21:54:22 +0000 timeoutDate:(null)>,
<GKTurnBasedParticipant 0x1c1b0a80 - playerID:G:220673962 status:Done matchOutcome:Lost lastTurnDate:2013-10-10 18:26:16 +0000 timeoutDate:(null)>,
<GKTurnBasedParticipant 0x16ef1610 - playerID:G:128458444 (local player) status:Active matchOutcome:None lastTurnDate:(null) timeoutDate:(null)>,
<GKTurnBasedParticipant 0x16ec64f0 - playerID:(null) status:Matching matchOutcome:None lastTurnDate:(null) timeoutDate:(null)> matchData.length:871 matchDataMaximumSize:65536 exchanges:(null)>

I have more than 2 GKTurnBasedParticipants here, and two of them are the same player! I don't do anything extraordinary in the game, except calling the following each turn:

[match endTurnWithNextParticipants:@[nextParticipant] turnTimeout:GKTurnTimeoutDefault matchData:data completionHandler:^(NSError *error){...}]

Does anyone have any idea what's going on here? It's a two-player game, so how am I ending up with a messed-up match object, and how can I prevent this?

Harrow answered 10/10, 2013 at 22:15 Comment(2)
I just encountered this as well. Have you found a cause/solution?Lubricate
Not so far - I submitted it as a bug to Apple, but I have low hopes for this. There are numerous kinds of errors that can result from this, which will prevent you from submitting next turn. So far, I think the only thing to do is to detect this condition and kill the match with an apology.Harrow
R
0

I do the following to end the game

        ((GKTurnBasedParticipant*)[currentMatch.participants objectAtIndex:1]).matchOutcome = GKTurnBasedMatchOutcomeWon;
        ((GKTurnBasedParticipant*)[currentMatch.participants objectAtIndex:0]).matchOutcome = GKTurnBasedMatchOutcomeLost;

then I call

[currentMatch endMatchInTurnWithMatchData:data completionHandler:^(NSError *error)
{
         if (error)
         {
             NSLog(@"%@", error);
         }
         else{


         }
     }];
Reversion answered 31/12, 2013 at 13:12 Comment(1)
Thanks, but that doesn't answer the question. I'd like to know what causes the 2 player match to have 4 or more duplicate participants in the first place.Harrow
H
0

I submitted a bug with Apple and four months later got this in email:

Hello Kirill,

This is a follow-up regarding regarding Bug ID# 15615850.

We believe this issue has been addressed. Please verify with iOS 7.1 beta 4 (11D5134c) release, and update your report with the results.

So - yes, it's confirmed as a bug, I still don't know of a workaround, but once 7.1 comes out, we'll be rid of it.

Harrow answered 23/1, 2014 at 17:15 Comment(2)
I have the same problem under iOS 7.1 (in sandbox environment). It's four participants when it should be two. Each correct one appears (incorrectly) twice.Acridine
Confirmed - still happens. I think it's somehow related to matches that start out as invites to a friend. Can't find any pattern to this still.Harrow

© 2022 - 2024 — McMap. All rights reserved.