mirror of
https://github.com/Auties00/Reboot-Launcher.git
synced 2026-01-14 03:32:23 +01:00
Reboot v3
This commit is contained in:
@@ -3,11 +3,8 @@ import 'dart:convert';
|
||||
import 'package:args/args.dart';
|
||||
|
||||
import '../model/fortnite_version.dart';
|
||||
import '../model/game_type.dart';
|
||||
import '../model/server_type.dart';
|
||||
|
||||
Iterable<String> getGameTypes() => GameType.values.map((entry) => entry.id);
|
||||
|
||||
Iterable<String> getServerTypes() => ServerType.values.map((entry) => entry.id);
|
||||
|
||||
String getDefaultServerType(Map<String, dynamic> json) {
|
||||
@@ -15,15 +12,6 @@ String getDefaultServerType(Map<String, dynamic> json) {
|
||||
return type.id;
|
||||
}
|
||||
|
||||
GameType getGameType(ArgResults result) {
|
||||
var type = GameType.of(result["type"]);
|
||||
if(type == null){
|
||||
throw Exception("Unknown game type: $result. Use --type only with ${getGameTypes().join(", ")}");
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
ServerType getServerType(ArgResults result) {
|
||||
var type = ServerType.of(result["server-type"]);
|
||||
if(type == null){
|
||||
@@ -33,18 +21,6 @@ ServerType getServerType(ArgResults result) {
|
||||
return type;
|
||||
}
|
||||
|
||||
String getDefaultGameType(Map<String, dynamic> json){
|
||||
var type = GameType.values.elementAt(json["type"] ?? 0);
|
||||
switch(type){
|
||||
case GameType.client:
|
||||
return "client";
|
||||
case GameType.server:
|
||||
return "server";
|
||||
case GameType.headlessServer:
|
||||
return "headless_server";
|
||||
}
|
||||
}
|
||||
|
||||
List<FortniteVersion> getVersions(Map<String, dynamic> gameJson) {
|
||||
Iterable iterable = jsonDecode(gameJson["versions"] ?? "[]");
|
||||
return iterable.map((entry) => FortniteVersion.fromJson(entry))
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:process_run/shell.dart';
|
||||
import 'package:reboot_launcher/cli.dart';
|
||||
|
||||
import '../model/fortnite_version.dart';
|
||||
import '../model/game_type.dart';
|
||||
import '../util/injector.dart';
|
||||
import '../util/os.dart';
|
||||
import '../util/process.dart';
|
||||
@@ -32,15 +31,14 @@ Future<void> startGame() async {
|
||||
.path} no longer contains a Fortnite executable, did you delete or move it?");
|
||||
}
|
||||
|
||||
var hosting = type != GameType.client;
|
||||
if (username == null) {
|
||||
username = "Reboot${hosting ? 'Host' : 'Player'}";
|
||||
username = "Reboot${host ? 'Host' : 'Player'}";
|
||||
stdout.writeln("No username was specified, using $username by default. Use --username to specify one");
|
||||
}
|
||||
|
||||
_gameProcess = await Process.start(gamePath, createRebootArgs(username!, type, ""))
|
||||
_gameProcess = await Process.start(gamePath, createRebootArgs(username!, host, ""))
|
||||
..exitCode.then((_) => _onClose())
|
||||
..outLines.forEach((line) => _onGameOutput(line, dll, hosting, verbose));
|
||||
..outLines.forEach((line) => _onGameOutput(line, dll, host, verbose));
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +66,7 @@ void _onGameOutput(String line, String dll, bool hosting, bool verbose) {
|
||||
}
|
||||
|
||||
if(line.contains("Platform has ")){
|
||||
_injectOrShowError("craniumv2.dll");
|
||||
_injectOrShowError("cobalt.dll");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -90,7 +88,7 @@ void _onGameOutput(String line, String dll, bool hosting, bool verbose) {
|
||||
_injectOrShowError("console.dll");
|
||||
}
|
||||
|
||||
_injectOrShowError("leakv2.dll");
|
||||
_injectOrShowError("memoryleak.dll");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +105,7 @@ Future<void> _injectOrShowError(String binary, [bool locate = true]) async {
|
||||
|
||||
try {
|
||||
stdout.writeln("Injecting $binary...");
|
||||
var dll = locate ? await loadBinary(binary, true) : File(binary);
|
||||
var dll = locate ? File("${assetsDirectory.path}\\dlls\\$binary") : File(binary);
|
||||
if(!dll.existsSync()){
|
||||
throw Exception("Cannot inject $dll: missing file");
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:archive/archive_io.dart';
|
||||
import 'package:reboot_launcher/src/util/server.dart';
|
||||
|
||||
import '../util/os.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
const String _baseDownload = "https://cdn.discordapp.com/attachments/1009257632315494520/1051137082766131250/Cranium.dll";
|
||||
const String _consoleDownload = "https://cdn.discordapp.com/attachments/1026121175878881290/1031230848005046373/console.dll";
|
||||
const String _memoryFixDownload = "https://cdn.discordapp.com/attachments/1013220721494863872/1033484506633617500/MemoryLeakFixer.dll";
|
||||
const String _baseDownload = "https://cdn.discordapp.com/attachments/1095351875961901057/1110968021373169674/cobalt.dll";
|
||||
const String _consoleDownload = "https://cdn.discordapp.com/attachments/1095351875961901057/1110968095033524234/console.dll";
|
||||
const String _memoryFixDownload = "https://cdn.discordapp.com/attachments/1095351875961901057/1110968141556756581/memoryleak.dll";
|
||||
const String _embeddedConfigDownload = "https://cdn.discordapp.com/attachments/1026121175878881290/1040679319351066644/embedded.zip";
|
||||
|
||||
Future<void> downloadRequiredDLLs() async {
|
||||
stdout.writeln("Downloading necessary components...");
|
||||
var consoleDll = await loadBinary("console.dll", true);
|
||||
var consoleDll = File("${assetsDirectory.path}\\dlls\\console.dll");
|
||||
if(!consoleDll.existsSync()){
|
||||
var response = await http.get(Uri.parse(_consoleDownload));
|
||||
if(response.statusCode != 200){
|
||||
@@ -22,30 +23,27 @@ Future<void> downloadRequiredDLLs() async {
|
||||
await consoleDll.writeAsBytes(response.bodyBytes);
|
||||
}
|
||||
|
||||
var craniumDll = await loadBinary("craniumv2.dll", true);
|
||||
var craniumDll = File("${assetsDirectory.path}\\dlls\\cobalt.dll");
|
||||
if(!craniumDll.existsSync()){
|
||||
var response = await http.get(Uri.parse(_baseDownload));
|
||||
if(response.statusCode != 200){
|
||||
throw Exception("Cannot download craniumv2.dll");
|
||||
throw Exception("Cannot download cobalt.dll");
|
||||
}
|
||||
|
||||
await craniumDll.writeAsBytes(response.bodyBytes);
|
||||
}
|
||||
|
||||
var memoryFixDll = await loadBinary("leakv2.dll", true);
|
||||
var memoryFixDll = File("${assetsDirectory.path}\\dlls\\memoryleak.dll");
|
||||
if(!memoryFixDll.existsSync()){
|
||||
var response = await http.get(Uri.parse(_memoryFixDownload));
|
||||
if(response.statusCode != 200){
|
||||
throw Exception("Cannot download leakv2.dll");
|
||||
throw Exception("Cannot download memoryleak.dll");
|
||||
}
|
||||
|
||||
await memoryFixDll.writeAsBytes(response.bodyBytes);
|
||||
}
|
||||
|
||||
var config = loadEmbedded("config/");
|
||||
var profiles = loadEmbedded("profiles/");
|
||||
var responses = loadEmbedded("responses/");
|
||||
if(!config.existsSync() || !profiles.existsSync() || !responses.existsSync()){
|
||||
if(!serverDirectory.existsSync()){
|
||||
var response = await http.get(Uri.parse(_embeddedConfigDownload));
|
||||
if(response.statusCode != 200){
|
||||
throw Exception("Cannot download embedded server config");
|
||||
@@ -53,7 +51,6 @@ Future<void> downloadRequiredDLLs() async {
|
||||
|
||||
var tempZip = File("${tempDirectory.path}/reboot_config.zip");
|
||||
await tempZip.writeAsBytes(response.bodyBytes);
|
||||
|
||||
await extractFileToDisk(tempZip.path, "${safeBinariesDirectory.path}\\cli");
|
||||
await extractFileToDisk(tempZip.path, serverDirectory.path);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ Future<bool> startServer(String? host, String? port, ServerType type) async {
|
||||
return true;
|
||||
case ServerType.embedded:
|
||||
stdout.writeln("Starting an embedded server...");
|
||||
await server.startServer();
|
||||
await server.startServer(false);
|
||||
var result = await server.ping(host ?? "127.0.0.1", port ?? "3551");
|
||||
if(result == null){
|
||||
throw Exception("Cannot start embedded server");
|
||||
|
||||
Reference in New Issue
Block a user