// called from ---GUI--- thread bool NetPlay::StartGame(const std::string &path) { if (m_is_running) { PanicAlertT("Game is already running!"); return false; } m_dialog->AppendChat(" -- STARTING GAME -- "); m_is_running = true; NetPlay_Enable(this); ClearBuffers(); // boot game m_dialog->BootGame(path); // temporary NetWiimote nw; for (unsigned int i = 0; i<4; ++i) for (unsigned int f = 0; f<2; ++f) m_wiimote_buffer[i].Push(nw); return true; }
// called from ---GUI--- thread bool NetPlayClient::StartGame(const std::string& path) { std::lock_guard<std::recursive_mutex> lkg(m_crit.game); SendStartGamePacket(); if (m_is_running.IsSet()) { PanicAlertT("Game is already running!"); return false; } m_timebase_frame = 0; m_is_running.Set(); NetPlay_Enable(this); ClearBuffers(); if (m_dialog->IsRecording()) { if (Movie::IsReadOnly()) Movie::SetReadOnly(false); u8 controllers_mask = 0; for (unsigned int i = 0; i < 4; ++i) { if (m_pad_map[i] > 0) controllers_mask |= (1 << i); if (m_wiimote_map[i] > 0) controllers_mask |= (1 << (i + 4)); } Movie::BeginRecordingInput(controllers_mask); } // boot game m_dialog->BootGame(path); if (SConfig::GetInstance().bWii) { for (unsigned int i = 0; i < 4; ++i) WiimoteReal::ChangeWiimoteSource(i, m_wiimote_map[i] > 0 ? WIIMOTE_SRC_EMU : WIIMOTE_SRC_NONE); } UpdateDevices(); return true; }
// called from ---GUI--- thread bool NetPlayClient::StartGame(const std::string &path) { std::lock_guard<std::recursive_mutex> lkg(m_crit.game); // tell server i started the game sf::Packet* spac = new sf::Packet; *spac << (MessageId)NP_MSG_START_GAME; *spac << m_current_game; *spac << (char *)&g_NetPlaySettings; SendAsync(spac); if (m_is_running.load()) { PanicAlertT("Game is already running!"); return false; } m_dialog->AppendChat(" -- STARTING GAME -- "); m_timebase_frame = 0; m_is_running.store(true); NetPlay_Enable(this); ClearBuffers(); if (m_dialog->IsRecording()) { if (Movie::IsReadOnly()) Movie::SetReadOnly(false); u8 controllers_mask = 0; for (unsigned int i = 0; i < 4; ++i) { if (m_pad_map[i] > 0) controllers_mask |= (1 << i); if (m_wiimote_map[i] > 0) controllers_mask |= (1 << (i + 4)); } Movie::BeginRecordingInput(controllers_mask); } // boot game m_dialog->BootGame(path); UpdateDevices(); if (SConfig::GetInstance().bWii) { for (unsigned int i = 0; i < 4; ++i) WiimoteReal::ChangeWiimoteSource(i, m_wiimote_map[i] > 0 ? WIIMOTE_SRC_EMU : WIIMOTE_SRC_NONE); // Needed to prevent locking up at boot if (when) the wiimotes connect out of order. NetWiimote nw; nw.resize(4, 0); for (unsigned int w = 0; w < 4; ++w) { if (m_wiimote_map[w] != -1) // probably overkill, but whatever for (unsigned int i = 0; i < 7; ++i) m_wiimote_buffer[w].Push(nw); } } return true; }