Update to spice2x-26-02-17 (pre-apply)
> broken commit
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
#include "patch_manager.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <fstream>
|
||||
#include <shellapi.h>
|
||||
#include <winhttp.h>
|
||||
#include <psapi.h>
|
||||
#include <format>
|
||||
#include "external/fmt/include/fmt/chrono.h"
|
||||
#include "external/rapidjson/document.h"
|
||||
#include "external/rapidjson/prettywriter.h"
|
||||
#include "external/rapidjson/stringbuffer.h"
|
||||
@@ -40,7 +42,6 @@
|
||||
|
||||
using namespace rapidjson;
|
||||
|
||||
|
||||
namespace overlay::windows {
|
||||
|
||||
|
||||
@@ -288,6 +289,12 @@ namespace overlay::windows {
|
||||
this->reload_local_patches();
|
||||
}
|
||||
|
||||
if (avs::game::DLL_NAME == "kamunity.dll") {
|
||||
ImGui::TextColored(ImVec4(1.f, 0.f, 0.f, 1.f), "Patches are not supported for Unity-based games.");
|
||||
ImGui::TextColored(ImVec4(1.f, 0.f, 0.f, 1.f), "Instead, look for downloads of pre-patched DLLs.");
|
||||
return;
|
||||
}
|
||||
|
||||
// game code info
|
||||
std::string identifiers;
|
||||
identifiers += avs::game::get_identifier() + "\n\n";
|
||||
@@ -714,7 +721,7 @@ namespace overlay::windows {
|
||||
if (style_color_pushed) {
|
||||
ImGui::PopStyleColor(style_color_pushed);
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
|
||||
show_patch_tooltip(patch);
|
||||
}
|
||||
|
||||
@@ -755,7 +762,7 @@ namespace overlay::windows {
|
||||
patch.last_status = is_patch_active(patch);
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
if (ImGui::IsItemHovered()) {
|
||||
if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
|
||||
show_patch_tooltip(patch);
|
||||
}
|
||||
|
||||
@@ -784,7 +791,7 @@ namespace overlay::windows {
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
|
||||
show_patch_tooltip(patch);
|
||||
}
|
||||
} else if (patch.type == PatchType::Integer) {
|
||||
@@ -800,7 +807,7 @@ namespace overlay::windows {
|
||||
apply_patch(patch, true);
|
||||
config_dirty = true;
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
|
||||
show_patch_tooltip(patch);
|
||||
}
|
||||
}
|
||||
@@ -817,7 +824,7 @@ namespace overlay::windows {
|
||||
ImGui::InputInt("##dummy_int_input", &patch.patch_number.value);
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
if (ImGui::IsItemHovered()) {
|
||||
if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
|
||||
show_patch_tooltip(patch);
|
||||
}
|
||||
}
|
||||
@@ -923,6 +930,13 @@ namespace overlay::windows {
|
||||
}
|
||||
}
|
||||
|
||||
// match on model and ext, ignoring dest/spec/rev
|
||||
// sample: LDJ:J:E:A:2025011400
|
||||
bool PatchManager::is_game_id_wildcard_matched(const std::string& id_from_config) {
|
||||
return ((id_from_config.compare(0, 3, avs::game::MODEL) == 0) &&
|
||||
(id_from_config.compare(10, 10, avs::game::EXT) == 0));
|
||||
}
|
||||
|
||||
void PatchManager::config_load() {
|
||||
log_info("patchmanager", "loading config");
|
||||
|
||||
@@ -937,7 +951,7 @@ namespace overlay::windows {
|
||||
// check parse error
|
||||
auto error = doc.GetParseError();
|
||||
if (error) {
|
||||
log_warning("patchmanager", "config file parse error: {}", error);
|
||||
log_warning("patchmanager", "config file parse error: {}", static_cast<uint32_t>(error));
|
||||
}
|
||||
|
||||
// verify root is a dict
|
||||
@@ -948,7 +962,7 @@ namespace overlay::windows {
|
||||
if (auto_apply != doc.MemberEnd() && auto_apply->value.IsArray()) {
|
||||
|
||||
// get game id
|
||||
auto game_id = avs::game::get_identifier();
|
||||
const auto game_id = avs::game::get_identifier();
|
||||
|
||||
// iterate entries
|
||||
setting_auto_apply = false;
|
||||
@@ -957,15 +971,37 @@ namespace overlay::windows {
|
||||
if (entry.IsString()) {
|
||||
|
||||
// check if this is our game identifier
|
||||
std::string entry_id = entry.GetString();
|
||||
if (game_id == entry_id) {
|
||||
setting_auto_apply = true;
|
||||
const std::string entry_id = entry.GetString();
|
||||
|
||||
if (!setting_auto_apply) {
|
||||
if (game_id == entry_id) {
|
||||
// exact match
|
||||
setting_auto_apply = true;
|
||||
log_misc(
|
||||
"patchmanager",
|
||||
"matched auto apply entry by full game identifier: {}",
|
||||
entry_id);
|
||||
|
||||
} else if (is_game_id_wildcard_matched(entry_id)) {
|
||||
// match on model and ext, ignoring dest/spec/rev
|
||||
// sample: LDJ:J:E:A:2025011400
|
||||
setting_auto_apply = true;
|
||||
log_misc(
|
||||
"patchmanager",
|
||||
"matched auto apply entry by partial game identifier: {}:?:?:?:{}",
|
||||
avs::game::MODEL, avs::game::EXT);
|
||||
}
|
||||
}
|
||||
|
||||
// move to list
|
||||
setting_auto_apply_list.emplace_back(entry_id);
|
||||
}
|
||||
}
|
||||
if (!setting_auto_apply) {
|
||||
log_misc(
|
||||
"patchmanager",
|
||||
"no auto apply entry matched, patches will not load automatically");
|
||||
}
|
||||
}
|
||||
|
||||
// read enabled patches
|
||||
@@ -1045,7 +1081,7 @@ namespace overlay::windows {
|
||||
// check parse error
|
||||
auto error = doc.GetParseError();
|
||||
if (error) {
|
||||
log_warning("patchmanager", "template parse error: {}", error);
|
||||
log_warning("patchmanager", "template parse error: {}", static_cast<uint32_t>(error));
|
||||
}
|
||||
|
||||
// auto apply setting
|
||||
@@ -1053,7 +1089,7 @@ namespace overlay::windows {
|
||||
auto game_id = avs::game::get_identifier();
|
||||
bool game_id_added = false;
|
||||
for (auto &entry : setting_auto_apply_list) {
|
||||
if (entry == game_id) {
|
||||
if (entry == game_id || is_game_id_wildcard_matched(entry)) {
|
||||
if (!setting_auto_apply) {
|
||||
continue;
|
||||
}
|
||||
@@ -1145,7 +1181,7 @@ namespace overlay::windows {
|
||||
}
|
||||
}
|
||||
|
||||
std::string get_game_identifier(const std::filesystem::path& dll_path) {
|
||||
std::string get_game_identifier(const std::filesystem::path& dll_path, bool print_info) {
|
||||
uint32_t time_date_stamp = 0;
|
||||
uint32_t address_of_entry_point = 0;
|
||||
|
||||
@@ -1154,7 +1190,7 @@ namespace overlay::windows {
|
||||
if (!result) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
// concatenate TimeDateStamp and AddressOfEntryPoint
|
||||
std::string identifier =
|
||||
fmt::format(
|
||||
@@ -1163,6 +1199,16 @@ namespace overlay::windows {
|
||||
time_date_stamp,
|
||||
address_of_entry_point);
|
||||
|
||||
if (print_info) {
|
||||
const auto time = std::chrono::system_clock::from_time_t(time_date_stamp);
|
||||
log_info(
|
||||
"patchmanager",
|
||||
"file: {}, patch id: {}, build timestamp of dll: {:%Y-%m-%d %H:%M}",
|
||||
dll_path.has_filename() ? dll_path.filename().string() : dll_path.string(),
|
||||
identifier,
|
||||
time);
|
||||
}
|
||||
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@@ -1177,7 +1223,7 @@ namespace overlay::windows {
|
||||
// check parse error
|
||||
auto error = doc.GetParseError();
|
||||
if (error) {
|
||||
log_warning("patchmanager", "embedded patches json file parse error: {}", error);
|
||||
log_warning("patchmanager", "embedded patches json file parse error: {}", static_cast<uint32_t>(error));
|
||||
}
|
||||
|
||||
// iterate patches
|
||||
@@ -1509,7 +1555,7 @@ namespace overlay::windows {
|
||||
}
|
||||
case PatchType::Unknown:
|
||||
default:
|
||||
log_warning("patchmanager", "unknown patch type: {}", patch_data.type);
|
||||
log_warning("patchmanager", "unknown patch type: {}", static_cast<uint32_t>(patch_data.type));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1652,14 +1698,12 @@ namespace overlay::windows {
|
||||
ACTIVE_JSON_FILE = "";
|
||||
|
||||
std::string firstDll = avs::game::DLL_NAME;
|
||||
std::string first_id = get_game_identifier(MODULE_PATH / firstDll);
|
||||
std::string first_id = get_game_identifier(MODULE_PATH / firstDll, true);
|
||||
std::filesystem::path firstPath = fmt::format("patches/{}.json", first_id);
|
||||
|
||||
log_misc("patchmanager", "patch identifier of {}: {}", firstDll, first_id);
|
||||
|
||||
auto extraDlls = getExtraDlls(firstDll);
|
||||
std::erase_if(extraDlls, [](const std::string& dll) {
|
||||
auto identifier = get_game_identifier(MODULE_PATH / dll);
|
||||
auto identifier = get_game_identifier(MODULE_PATH / dll, true);
|
||||
return identifier.empty() || !fileutils::file_exists(fmt::format("patches/{}.json", identifier));
|
||||
});
|
||||
|
||||
@@ -1731,7 +1775,7 @@ namespace overlay::windows {
|
||||
"patchmanager",
|
||||
"patches file parse error at offset {}: {} ({})",
|
||||
error_offset,
|
||||
error,
|
||||
static_cast<uint32_t>(error),
|
||||
rapidjson::GetParseError_En(error));
|
||||
}
|
||||
|
||||
@@ -2239,7 +2283,7 @@ namespace overlay::windows {
|
||||
}
|
||||
case PatchType::Unknown:
|
||||
default:
|
||||
log_warning("patchmanager", "unknown patch type: {}", patch_data.type);
|
||||
log_warning("patchmanager", "unknown patch type: {}", static_cast<uint32_t>(patch_data.type));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user