回合制配对在iOS 10中不起作用

时间:2017-01-29 00:30:49

标签: ios objective-c gamekit gkturnbasedmatch

我的游戏在iOS 10之前运行良好。现在,iOS 10的每个人都无法邀请和玩他们想要的人。

当用户说他们想玩多人游戏时,我会像这样创建一个@echo off setlocal EnableExtensions DisableDelayedExpansion rem // Define constants here: set "_FILEI=%~1" & rem // (specify input file by first command line argument) set "_FILEO=%~2" & rem // (specify output file by second command line argument) set "_SEPAR=," & rem // (character to use as separator) rem // Get character with code `0xA0`: for /F %%N in ('forfiles /P "%~dp0." /M "%~nx0" /C "cmd /C echo 0xA0"') do ( set "$A0=%%N" ) rem // Process input file in sub-routine, write output file: > "%_FILEO%" call :PROCESS "%_FILEI%" TEMPF rem /* Variable `TEMPF` is usually empty, so the following code does not run; rem however, if the first block in the input file is invalid/incomplete, rem the output header is assembled belatedly, so it is stored in a temporary rem file and put together with the collected data at the end: */ if defined TEMPF ( if exist "%TEMPF%" ( > nul ( copy /Y /B "%TEMPF%"+"%_FILEO%" "%TEMPF%" move /Y "%TEMPF%" "%_FILEO%" ) ) else ( >&2 echo ERROR: no valid data block encountered, could not built header! exit /B 1 ) ) endlocal exit /B :PROCESS val_file rtn_temp_file setlocal DisableDelayedExpansion rem // Initialise variables (flags and buffers): set "DONE=" & set "NEXT=" & set "TMPF=" set "HEAD=%_SEPAR%" & set "COLL=%_SEPAR%" rem /* Read input file line by line, split at first `=` sign; rem let us call the left part key and the right one value: */ for /F "usebackq eol== tokens=1,* delims==" %%K in ("%~1") do ( set "KEY=%%K" set "VALUE=%%L" setlocal EnableDelayedExpansion rem // Remove potential trailing space from key: if "!KEY:~-1!"==" " set "KEY=!KEY:~,-1!" rem // Remove potential trailing character with code `0xA0` from key: if "!KEY:~-1!"=="!$A0!" set "KEY=!KEY:~,-1!" if defined VALUE ( rem // Remove potential trailing spaces from value: for %%N in (" " " " " ") do ( set "VALUE=!VALUE:%%~N=!" ) if "!VALUE:~-1!"==" " set "VALUE=!VALUE:~,-1!" rem // Remove potential leading space from value: if "!VALUE:~,1!"==" " set "VALUE=!VALUE:~1!" rem /* Build output lines by concatenating values and also rem header lines out of keys; toggle delayed expansion rem in order to not lose exclamation marks; use `for /F` rem loop to transport values over `endlocal` barrier: */ for /F "delims=" %%M in ("!COLL!!VALUE!!_SEPAR!") do ( if defined DONE ( rem // Header has alread y been built: endlocal set "COLL=%%M" setlocal EnableDelayedExpansion ) else ( rem // Header has not yet been built, so do it: for /F "delims=" %%N in ("!HEAD!!KEY!!_SEPAR!") do ( endlocal set "HEAD=%%N" & set "COLL=%%M" setlocal EnableDelayedExpansion ) ) ) ) else ( rem /* The value is empty, so there are two possibilities: rem either the `.` separator line, or an error message: */ if "!KEY:.=!"=="" ( rem // Line consists of `.` only (separator line): if not defined DONE ( rem // Header has not yet been written: if not defined NEXT ( rem // Header is not postponed: if defined TMPF ( rem // Write belated header to temporary file: > "!TMPF!" ((echo(!HEAD:~1,-1!) & echo/ ) ) else ( rem // Normally, return header immediately: ((echo(!HEAD:~1,-1!) & echo/ ) ) ) ) rem // Write collected output data line: echo(!COLL:~1,-1! endlocal rem // Indicate by a flag that header has been completed: if not defined NEXT set "DONE=#" rem // Reset variables (flags and buffers): set "NEXT=" & set "HEAD=%_SEPAR%" & set "COLL=%_SEPAR%" setlocal EnableDelayedExpansion ) else if defined KEY ( rem // Line contains error message (no `=` sign found): for /F "delims=" %%M in ("!COLL!!KEY!!_SEPAR!") do ( for /F "delims=" %%N in ("!HEAD!!KEY!!_SEPAR!") do ( endlocal rem /* Header cannot be written immediately, so create rem path to temporary file to receive the header: */ if not defined DONE set "TMPF=%TEMP%\%~n0_%RANDOM%-1.tmp" set "NEXT=#" & set "HEAD=%%N" & set "COLL=%%M" setlocal EnableDelayedExpansion ) ) ) ) endlocal ) rem // If applicable, transport temporary file path over `endlocal` barrier: ( endlocal set "%~2=%TMPF%" ) exit /B

GKMatchRequest

我使用GKMatchRequest *request = [[GKMatchRequest alloc] init]; request.minPlayers = 2; request.maxPlayers = 4; request.defaultNumberOfPlayers = 2; 来处理邀请等。用户看到一个界面,可以让他们更改比赛中的玩家数量并邀请玩家。让我们说他们只想要2名球员,所以他们离开了,他们想和他们的朋友一起玩。因此,他们使用界面向他们的朋友发送邀请。结果是GKTurnBasedMatchmakerViewController在我的委托上被调用,didFindMatch有4个参与者。它应该只有2个!第一个参与者是本地玩家,另外3个具有状态"匹配"。所以,他们的朋友甚至不在名单中。有没有人有任何解决这个问题的建议?这个相同的代码在iOS 10之前的iOS版本中运行良好。

1 个答案:

答案 0 :(得分:0)

看来,对于IOS10,defaultNumberOfPlayers并没有被尊重。

请注意,GKTurnBasedMatch在给定的匹配中有三种类型的玩家:

  • 创建比赛的发起人
  • 特别邀请参加比赛的球员
  • 自动匹配比赛的玩家

如果您查看比赛中所有4名球员的球员状态(使用您的示例),我怀疑您会看到以下结果

  1. 活跃(发起人)
  2. 邀请(您邀请的1人)
  3. 匹配
  4. 匹配
  5. 如果是这样,那表示忽略了defaultNumberOfPlayers,并且最多创建了4个玩家(1个发起者,1个被邀请者和2个自动匹配插槽)。

    解决方法似乎是在创建匹配时将maxNumberOfPlayers设置为所需的上限,在本例中为2。