Skip to content

Commit

Permalink
expose config-less patcher as opt-in
Browse files Browse the repository at this point in the history
  • Loading branch information
moonshadow565 committed Aug 8, 2023
1 parent c128777 commit d2f4c12
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 15 deletions.
5 changes: 3 additions & 2 deletions cslol-tools/lib/lol/patcher/patcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ namespace lol::patcher {
extern auto run(std::function<void(Message, char const*)> update,
fs::path const& profile_path,
fs::path const& config_path,
fs::path const& game_path) -> void;
fs::path const& game_path,
fs::names const& opts) -> void;

struct PatcherTimeout : std::runtime_error {
using std::runtime_error::runtime_error;
Expand All @@ -42,4 +43,4 @@ namespace lol::patcher {
struct PatcherAborted : std::runtime_error {
PatcherAborted() : std::runtime_error("Aborted as expected") {}
};
}
}
4 changes: 3 additions & 1 deletion cslol-tools/lib/lol/patcher/patcher_dummy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ using namespace std::chrono_literals;
auto patcher::run(std::function<void(Message, char const*)> update,
fs::path const& profile_path,
fs::path const& config_path,
fs::path const& game_path) -> void {
fs::path const& game_path,
fs::names const& opts) -> void {
(void)profile_path;
(void)config_path;
(void)game_path;
(void)opts;
for (;;) {
update(M_WAIT_START, "");
sleep_ms(250);
Expand Down
4 changes: 3 additions & 1 deletion cslol-tools/lib/lol/patcher/patcher_macos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@ struct Context {
auto patcher::run(std::function<void(Message, char const*)> update,
fs::path const& profile_path,
fs::path const& config_path,
fs::path const& game_path) -> void {
fs::path const& game_path,
fs::names const& opts) -> void {
auto ctx = Context{};
ctx.set_prefix(profile_path);
(void)config_path;
(void)game_path;
(void)opts;
for (;;) {
auto pid = Process::FindPid("/LeagueofLegends");
if (!pid) {
Expand Down
17 changes: 14 additions & 3 deletions cslol-tools/lib/lol/patcher/patcher_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,15 @@ static auto skinhack_detected() -> char const* {
auto patcher::run(std::function<void(Message, char const*)> update,
fs::path const& profile_path,
fs::path const& config_path,
fs::path const& game_path) -> void {
fs::path const& game_path,
fs::names const& opts) -> void {
auto is_configless = false;
for (auto const& o: opts) {
if (o == "configless") {
is_configless = true;
}
}

lol_throw_if(skinhack_detected());
auto ctx = Context{};
ctx.set_prefix(profile_path);
Expand Down Expand Up @@ -423,8 +431,11 @@ auto patcher::run(std::function<void(Message, char const*)> update,
update(M_SCAN, "");
auto checksum = ctx.scan_file(process, game_path);

// fallback for config based patcher if it ever becomes necessary
ctx.kernel32.ptr_CreateFileA_iat = {};
// fallback for config based patcher unless explicitly told
if (!is_configless) {
ctx.kernel32.ptr_CreateFileA_iat = {};
}

if (!ctx.kernel32.ptr_CreateFileA_iat.storage) [[unlikely]] {
if (!ctx.config.check() || ctx.config.get<"checksum">() != checksum) {
process.WaitInitialized((std::uint32_t)-1);
Expand Down
9 changes: 5 additions & 4 deletions cslol-tools/src/main_mod_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static auto mod_mkoverlay(fs::path src, fs::path dst, fs::path game, fs::names m
overlay_index.cleanup_in_directory(dst);
}

static auto mod_runoverlay(fs::path overlay, fs::path config_file, fs::path game) -> void {
static auto mod_runoverlay(fs::path overlay, fs::path config_file, fs::path game, fs::names opts) -> void {
lol_trace_func(lol_trace_var("{}", overlay), lol_trace_var("{}", config_file), lol_trace_var("{}", game));
lol_throw_if(overlay.empty());
lol_throw_if(config_file.empty());
Expand Down Expand Up @@ -269,7 +269,8 @@ static auto mod_runoverlay(fs::path overlay, fs::path config_file, fs::path game
},
overlay,
config_file,
game);
game,
opts);
} catch (patcher::PatcherAborted const&) {
// nothing to see here, lol
lol::error::stack().clear();
Expand All @@ -286,7 +287,7 @@ static auto help(fs::path cmd) -> void {
"export <src> <dst> --game:<path> --noTFT",
"import <src> <dst> --game:<path> --noTFT",
"mkoverlay <modsdir> <overlay> --game:<path> --mods:<name1>/<name2>/<name3>... --noTFT --ignoreConflict",
"runoverlay <overlay> <configfile> --game:<path>",
"runoverlay <overlay> <configfile> --game:<path> --opts:<none/configless>...",
"help");
lol_throw_msg("Bad command: {}", cmd);
}
Expand Down Expand Up @@ -315,7 +316,7 @@ int main(int argc, char** argv) {
flags.contains("--noTFT"),
flags.contains("--ignoreConflict"));
} else if (cmd == "runoverlay") {
mod_runoverlay(src, dst, flags["--game:"]);
mod_runoverlay(src, dst, flags["--game:"], flags["--opts"]);
} else {
help(cmd);
}
Expand Down
2 changes: 1 addition & 1 deletion src/CSLOLTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CSLOLTools : public QObject {
void deleteMod(QString name);
void exportMod(QString name, QString dest);
void installFantomeZip(QString path);
void saveProfile(QString name, QJsonObject mods, bool run, bool skipConflict);
void saveProfile(QString name, QJsonObject mods, bool run, bool skipConflict, bool experimentalConfigLess);
void loadProfile(QString name);
void deleteProfile(QString name);
void stopProfile();
Expand Down
3 changes: 2 additions & 1 deletion src/CSLOLToolsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ void CSLOLToolsImpl::doUpdate(QString urls) {
}
}

void CSLOLToolsImpl::saveProfile(QString name, QJsonObject mods, bool run, bool skipConflict) {
void CSLOLToolsImpl::saveProfile(QString name, QJsonObject mods, bool run, bool skipConflict, bool experimentalConfigLess) {
if (state_ == CSLOLState::StateIdle) {
setState(CSLOLState::StateBusy);

Expand Down Expand Up @@ -541,6 +541,7 @@ void CSLOLToolsImpl::saveProfile(QString name, QJsonObject mods, bool run, bool
prog_ + "/profiles/" + name,
prog_ + "/profiles/" + name + ".config",
"--game:" + game_,
"--opts:" + QString(experimentalConfigLess ? "configless" : "none"),
});
} else {
setState(CSLOLState::StateIdle);
Expand Down
2 changes: 1 addition & 1 deletion src/CSLOLToolsImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public slots:
void deleteMod(QString name);
void exportMod(QString name, QString dest);
void installFantomeZip(QString path);
void saveProfile(QString name, QJsonObject mods, bool run, bool skipConflict);
void saveProfile(QString name, QJsonObject mods, bool run, bool skipConflict, bool experimentalConfigLess);
void loadProfile(QString name);
void deleteProfile(QString name);
void stopProfile();
Expand Down
7 changes: 7 additions & 0 deletions src/qml/CSLOLDialogSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Dialog {
property alias enableSystray: enableSystrayCheck.checked
property alias enableAutoRun: enableAutoRunCheck.checked
property alias updateUrls: updateUrlsTextArea.text
property alias experimentalConfigLess: experimentalConfigLessCheck.checked

property var colors_LIST: [
"Red",
Expand Down Expand Up @@ -115,6 +116,12 @@ Dialog {
checked: false
Layout.fillWidth: true
}
Switch {
id: experimentalConfigLessCheck
text: qsTr("Experimental config-less patcher(might result in bans)")
checked: false
Layout.fillWidth: true
}
}

ColumnLayout {
Expand Down
3 changes: 2 additions & 1 deletion src/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ApplicationWindow {
property alias themeDarkMode: cslolDialogSettings.themeDarkMode
property alias themePrimaryColor: cslolDialogSettings.themePrimaryColor
property alias themeAccentColor: cslolDialogSettings.themeAccentColor
property alias experimentalConfigLess: cslolDialogSettings.experimentalConfigLess

property alias removeUnknownNames: cslolDialogEditMod.removeUnknownNames
property alias lastZipDirectory: cslolDialogOpenZipFantome.folder
Expand Down Expand Up @@ -97,7 +98,7 @@ ApplicationWindow {
let name = cslolToolBar.profilesCurrentName
let mods = cslolModsView.saveProfile()
if (checkGamePath()) {
cslolTools.saveProfile(name, mods, run, settings.suppressInstallConflicts)
cslolTools.saveProfile(name, mods, run, settings.suppressInstallConflicts, settings.experimentalConfigLess)
}
}

Expand Down

0 comments on commit d2f4c12

Please sign in to comment.