MCPcopy Create free account
hub / github.com/MultiMC/Launcher / launchInstance

Method launchInstance

launcher/LaunchController.cpp:233–298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231}
232
233void LaunchController::launchInstance()
234{
235 Q_ASSERT_X(m_instance != NULL, "launchInstance", "instance is NULL");
236 Q_ASSERT_X(m_session.get() != nullptr, "launchInstance", "session is NULL");
237
238 if(!m_instance->reloadSettings())
239 {
240 QMessageBox::critical(m_parentWidget, tr("Error!"), tr("Couldn't load the instance profile."));
241 emitFailed(tr("Couldn't load the instance profile."));
242 return;
243 }
244
245 m_launcher = m_instance->createLaunchTask(m_session, m_serverToJoin);
246 if (!m_launcher)
247 {
248 emitFailed(tr("Couldn't instantiate a launcher."));
249 return;
250 }
251
252 auto console = qobject_cast<InstanceWindow *>(m_parentWidget);
253 auto showConsole = m_instance->settings()->get("ShowConsole").toBool();
254 if(!console && showConsole)
255 {
256 APPLICATION->showInstanceWindow(m_instance);
257 }
258 connect(m_launcher.get(), &LaunchTask::readyForLaunch, this, &LaunchController::readyForLaunch);
259 connect(m_launcher.get(), &LaunchTask::succeeded, this, &LaunchController::onSucceeded);
260 connect(m_launcher.get(), &LaunchTask::failed, this, &LaunchController::onFailed);
261 connect(m_launcher.get(), &LaunchTask::requestProgress, this, &LaunchController::onProgressRequested);
262
263 // Prepend Online and Auth Status
264 QString online_mode;
265 if(m_session->wants_online) {
266 online_mode = "online";
267
268 // Prepend Server Status
269 QStringList servers = {"authserver.mojang.com", "session.minecraft.net", "textures.minecraft.net", "api.mojang.com"};
270 QString resolved_servers = "";
271 QHostInfo host_info;
272
273 for(QString server : servers) {
274 host_info = QHostInfo::fromName(server);
275 resolved_servers = resolved_servers + server + " resolves to:\n [";
276 if(!host_info.addresses().isEmpty()) {
277 for(QHostAddress address : host_info.addresses()) {
278 resolved_servers = resolved_servers + address.toString();
279 if(!host_info.addresses().endsWith(address)) {
280 resolved_servers = resolved_servers + ", ";
281 }
282 }
283 } else {
284 resolved_servers = resolved_servers + "N/A";
285 }
286 resolved_servers = resolved_servers + "]\n\n";
287 }
288 m_launcher->prependStep(new TextPrint(m_launcher.get(), resolved_servers, MessageLevel::Launcher));
289 } else {
290 online_mode = "offline";

Callers

nothing calls this directly

Calls 9

reloadSettingsMethod · 0.80
showInstanceWindowMethod · 0.80
isEmptyMethod · 0.80
prependStepMethod · 0.80
getMethod · 0.45
createLaunchTaskMethod · 0.45
settingsMethod · 0.45
toStringMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected