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

Method launchInstance

launcher/LaunchController.cpp:266–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264}
265
266void LaunchController::launchInstance()
267{
268 Q_ASSERT_X(m_instance != NULL, "launchInstance", "instance is NULL");
269 Q_ASSERT_X(m_session.get() != nullptr, "launchInstance", "session is NULL");
270
271 if(!m_instance->reloadSettings())
272 {
273 QMessageBox::critical(m_parentWidget, tr("Error!"), tr("Couldn't load the instance profile."));
274 emitFailed(tr("Couldn't load the instance profile."));
275 return;
276 }
277
278 m_launcher = m_instance->createLaunchTask(m_session, m_serverToJoin);
279 if (!m_launcher)
280 {
281 emitFailed(tr("Couldn't instantiate a launcher."));
282 return;
283 }
284
285 auto console = qobject_cast<InstanceWindow *>(m_parentWidget);
286 auto showConsole = m_instance->settings()->get("ShowConsole").toBool();
287 if(!console && showConsole)
288 {
289 APPLICATION->showInstanceWindow(m_instance);
290 }
291 connect(m_launcher.get(), &LaunchTask::readyForLaunch, this, &LaunchController::readyForLaunch);
292 connect(m_launcher.get(), &LaunchTask::succeeded, this, &LaunchController::onSucceeded);
293 connect(m_launcher.get(), &LaunchTask::failed, this, &LaunchController::onFailed);
294 connect(m_launcher.get(), &LaunchTask::requestProgress, this, &LaunchController::onProgressRequested);
295
296 // Prepend Online and Auth Status
297 QString online_mode;
298 if(m_session->wants_online) {
299 online_mode = "online";
300
301 // Prepend Server Status
302 QStringList servers = {"authserver.mojang.com", "session.minecraft.net", "textures.minecraft.net", "api.mojang.com"};
303 QString resolved_servers = "";
304 QHostInfo host_info;
305
306 for(QString server : servers) {
307 host_info = QHostInfo::fromName(server);
308 resolved_servers = resolved_servers + server + " resolves to:\n [";
309 if(!host_info.addresses().isEmpty()) {
310 for(QHostAddress address : host_info.addresses()) {
311 resolved_servers = resolved_servers + address.toString();
312 if(!host_info.addresses().endsWith(address)) {
313 resolved_servers = resolved_servers + ", ";
314 }
315 }
316 } else {
317 resolved_servers = resolved_servers + "N/A";
318 }
319 resolved_servers = resolved_servers + "]\n\n";
320 }
321 m_launcher->prependStep(new TextPrint(m_launcher.get(), resolved_servers, MessageLevel::Launcher));
322 } else {
323 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