在房间创建Google Play游戏服务后,SEGV_ACCERR

时间:2017-01-11 17:44:49

标签: android c++ cocos2d-x google-play-games

我正在用Cocos2d-x和Google Play游戏服务为网络编写游戏。 我正在用这段代码创建一个实时房间:

 auto scene = BattleScene::createScene();
    BattleScene *layer;
    if (scene->getChildByName("layer")) {
      layer = static_cast<BattleScene *>(scene->getChildByName("layer"));
    } else {
      log("Cannot get layer!");
      return;
    }
    log("Creating room...");
    auto gameServices = StateManager::getGameServices();
    gpg::RealTimeRoomConfig config = gpg::RealTimeRoomConfig::Builder()
                                         .SetMinimumAutomatchingPlayers(1)
                                         .SetMaximumAutomatchingPlayers(1)
                                         .Create();
    log("config created");
    gameServices->RealTimeMultiplayer().CreateRealTimeRoom(
        config, layer,
        [&](gpg::RealTimeMultiplayerManager::RealTimeRoomResponse const
                &response) {
          log("created a room %d", response.status);
          if (gpg::IsSuccess(response.status)) {
            gameServices->RealTimeMultiplayer().ShowWaitingRoomUI(
                response.room, 1,
                [&](gpg::RealTimeMultiplayerManager::
                        WaitingRoomUIResponse const &wait_response) {
                  log("WaitingRoomUIResponse");
                  if (IsSuccess(wait_response.status)) {
                    log("Game started");
                    Director::getInstance()->replaceScene(scene);
                  }
                });
          } else
            log("Error1");
        });

但是(当第二个玩家连接时)应用程序失败并显示该日志:

signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 00584918
Stack frame #00  pc 00584918  [heap]
Stack frame #01  pc 004d4526  /data/data/com.railon.luck/lib/libMyGame.so: Routine std::_Function_handler<void (gpg::RealTimeRoom const&, gpg::MultiplayerParticipant const&), gpg::RealTimeEventListenerHelperImpl::RealTimeEventListenerHelperImpl(gpg::IRealTimeEventListener*)::{lambda(gpg::RealTimeRoom const&, gpg::MultiplayerParticipant const&)#5}>::_M_invoke(std::_Any_data const&, gpg::RealTimeRoom const&, gpg::MultiplayerParticipant const&) at libgcc2.c:?
Stack frame #02  pc 004ec9c8  /data/data/com.railon.luck/lib/libMyGame.so (_ZNKSt8functionIFvRKN3gpg12RealTimeRoomERKNS0_22MultiplayerParticipantEEEclES3_S6_): Routine std::function<void (gpg::RealTimeRoom const&, gpg::MultiplayerParticipant const&)>::operator()(gpg::RealTimeRoom const&, gpg::MultiplayerParticipant const&) const at ??:?
Stack frame #03  pc 004eca08  /data/data/com.railon.luck/lib/libMyGame.so: Routine std::_Function_handler<void (), gpg::RealTimeEventListenerHelperImpl::WrappedRealTimeEventListener::OnParticipantStatusChanged(gpg::RealTimeRoom const&, gpg::MultiplayerParticipant const&)::{lambda()#1}>::_M_invoke(std::_Any_data const&) at libgcc2.c:?
Stack frame #04  pc 00509f6a  /data/data/com.railon.luck/lib/libMyGame.so: Routine gpg::PlatformExecuteOperation(std::function<void ()> const&) at libgcc2.c:?

问题似乎出现在OnParticipantStatusChanged的{​​{1}} func中,但即使此func为空也有错误 你有什么想法吗? 是的,BattleSceneClass在父母身上有BattleScene

0 个答案:

没有答案