| 815 | } |
| 816 | |
| 817 | shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin) |
| 818 | { |
| 819 | // FIXME: get rid of shared_from_this ... |
| 820 | auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(shared_from_this())); |
| 821 | auto pptr = process.get(); |
| 822 | |
| 823 | APPLICATION->icons()->saveIcon(iconKey(), FS::PathCombine(gameRoot(), "icon.png"), "PNG"); |
| 824 | |
| 825 | // print a header |
| 826 | { |
| 827 | process->appendStep(new TextPrint(pptr, "Minecraft folder is:\n" + gameRoot() + "\n\n", MessageLevel::Launcher)); |
| 828 | } |
| 829 | |
| 830 | // check java |
| 831 | { |
| 832 | process->appendStep(new CheckJava(pptr)); |
| 833 | } |
| 834 | |
| 835 | // check launch method |
| 836 | QStringList validMethods = {"LauncherPart", "DirectJava"}; |
| 837 | QString method = launchMethod(); |
| 838 | if(!validMethods.contains(method)) |
| 839 | { |
| 840 | process->appendStep(new TextPrint(pptr, "Selected launch method \"" + method + "\" is not valid.\n", MessageLevel::Fatal)); |
| 841 | return process; |
| 842 | } |
| 843 | |
| 844 | // create the .minecraft folder and server-resource-packs (workaround for Minecraft bug MCL-3732) |
| 845 | { |
| 846 | process->appendStep(new CreateGameFolders(pptr)); |
| 847 | } |
| 848 | |
| 849 | if (!serverToJoin && m_settings->get("JoinServerOnLaunch").toBool()) |
| 850 | { |
| 851 | QString fullAddress = m_settings->get("JoinServerOnLaunchAddress").toString(); |
| 852 | serverToJoin.reset(new MinecraftServerTarget(MinecraftServerTarget::parse(fullAddress))); |
| 853 | } |
| 854 | |
| 855 | if(serverToJoin && serverToJoin->port == 25565) |
| 856 | { |
| 857 | // Resolve server address to join on launch |
| 858 | auto *step = new LookupServerAddress(pptr); |
| 859 | step->setLookupAddress(serverToJoin->address); |
| 860 | step->setOutputAddressPtr(serverToJoin); |
| 861 | process->appendStep(step); |
| 862 | } |
| 863 | |
| 864 | // run pre-launch command if that's needed |
| 865 | if(getPreLaunchCommand().size()) |
| 866 | { |
| 867 | auto step = new PreLaunchCommand(pptr); |
| 868 | step->setWorkingDirectory(gameRoot()); |
| 869 | process->appendStep(step); |
| 870 | } |
| 871 | |
| 872 | // if we aren't in offline mode,. |
| 873 | if(session->status != AuthSession::PlayableOffline) |
| 874 | { |
nothing calls this directly
no test coverage detected