MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / launchInstance

Method launchInstance

launcher/LaunchController.cpp:334–399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332}
333
334void LaunchController::launchInstance()
335{
336 Q_ASSERT_X(m_instance != NULL, "launchInstance", "instance is NULL");
337 Q_ASSERT_X(m_session.get() != nullptr, "launchInstance", "session is NULL");
338
339 if(!m_instance->reloadSettings())
340 {
341 QMessageBox::critical(m_parentWidget, tr("Error!"), tr("Couldn't load the instance profile."));
342 emitFailed(tr("Couldn't load the instance profile."));
343 return;
344 }
345
346 m_launcher = m_instance->createLaunchTask(m_session, m_serverToJoin);
347 if (!m_launcher)
348 {
349 emitFailed(tr("Couldn't instantiate a launcher."));
350 return;
351 }
352
353 auto console = qobject_cast<InstanceWindow *>(m_parentWidget);
354 auto showConsole = m_instance->settings()->get("ShowConsole").toBool();
355 if(!console && showConsole)
356 {
357 APPLICATION->showInstanceWindow(m_instance);
358 }
359 connect(m_launcher.get(), &LaunchTask::readyForLaunch, this, &LaunchController::readyForLaunch);
360 connect(m_launcher.get(), &LaunchTask::succeeded, this, &LaunchController::onSucceeded);
361 connect(m_launcher.get(), &LaunchTask::failed, this, &LaunchController::onFailed);
362 connect(m_launcher.get(), &LaunchTask::requestProgress, this, &LaunchController::onProgressRequested);
363
364 // Prepend Online and Auth Status
365 QString online_mode;
366 if(m_session->wants_online) {
367 online_mode = "online";
368
369 // Prepend Server Status
370 QStringList servers = {"authserver.mojang.com", "session.minecraft.net", "textures.minecraft.net", "api.mojang.com"};
371 QString resolved_servers = "";
372 QHostInfo host_info;
373
374 for(QString server : servers) {
375 host_info = QHostInfo::fromName(server);
376 resolved_servers = resolved_servers + server + " resolves to:\n [";
377 if(!host_info.addresses().isEmpty()) {
378 for(QHostAddress address : host_info.addresses()) {
379 resolved_servers = resolved_servers + address.toString();
380 if(!host_info.addresses().endsWith(address)) {
381 resolved_servers = resolved_servers + ", ";
382 }
383 }
384 } else {
385 resolved_servers = resolved_servers + "N/A";
386 }
387 resolved_servers = resolved_servers + "]\n\n";
388 }
389 m_launcher->prependStep(new TextPrint(m_launcher.get(), resolved_servers, MessageLevel::Launcher));
390 } else {
391 online_mode = m_demo ? "demo" : "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