#include "command.h" #include "commands.h" #include "digest/digest.h" #include "runtime.h" #include "version.h" #include "l2su.h" #include "macros.h" #include "args.h" #include "assets.h" #include "launch.h" #include "instance.h" #include #include #include unsigned cmd_version_list_remote(struct l2_context_node *ctx, char **args) { unsigned res; L2_UNUSED(ctx); if (*args) { CMD_FATAL(CMD_MSG_UNKNOWN_ARGUMENT, *args); } res = l2_version_load_remote(); if (res != VERSION_SUCCESS) { CMD_FATAL("Failed to load versions: %s", l2_version_strerror(res)); } for (struct l2_version_remote *rv = l2_state.ver_remote_head; rv; rv = rv->next) { printf("%s\n", rv->id); } return CMD_RESULT_SUCCESS; } unsigned cmd_version_list_local(struct l2_context_node *ctx, char **args) { json_t *manifest; if (l2_runtime_load_manifest(&manifest) < 0) { CMD_FATAL0("Failed to load manifest"); } json_dumpf(manifest, stdout, JSON_INDENT(4)); putchar('\n'); char *jrepath = NULL; if (l2_runtime_install_component(manifest, "jre-legacy", &jrepath) < 0) { CMD_FATAL0("Failed to install component"); } CMD_DEBUG("JRE path: %s", jrepath); free(jrepath); json_decref(manifest); return CMD_RESULT_SUCCESS; } bool feat_match_cb(const char *name, json_t *js, void *unused) { L2_UNUSED(name); L2_UNUSED(js); L2_UNUSED(unused); return false; } unsigned cmd_version_install(struct l2_context_node *ctx, char **args) { unsigned res = l2_version_load_remote(); if (res != VERSION_SUCCESS) { CMD_FATAL("Failed to load versions: %s", l2_version_strerror(res)); } if ((res = l2_instance_load_all()) != INSTANCE_SUCCESS) { CMD_FATAL("Failed to load instances: %s", l2_instance_errormsg[res]); } struct l2_launch launch = { 0 }; if (l2_launch_init(&launch, *args, l2_state.instance_head) < 0) { CMD_FATAL0("Failed to launch the game"); } if (l2_launch_init_substitutor(&launch) < 0) { CMD_FATAL0("Failed to initialize argument substitutor"); } if (l2_launch_init_args(&launch) < 0) { CMD_FATAL0("Failed to set JVM and game arguments"); } if (l2_launch_jni(&launch) < 0) { CMD_FATAL0("Failed to launch the game."); } l2_launch_free_contents(&launch); return CMD_RESULT_SUCCESS; }