mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 02:32:36 +01:00
patch manager: avoid patch import inconsistencies
Save the original patch value instead of the interpreted value
This commit is contained in:
parent
2323cd2a2d
commit
591624b96c
@ -359,8 +359,9 @@ bool patch_engine::add_patch_data(YAML::Node node, patch_info& info, u32 modifie
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct patch_data p_data{};
|
struct patch_data p_data{};
|
||||||
p_data.type = type;
|
p_data.type = type;
|
||||||
p_data.offset = addr_node.as<u32>(0) + modifier;
|
p_data.offset = addr_node.as<u32>(0) + modifier;
|
||||||
|
p_data.original_value = value_node.IsScalar() ? value_node.Scalar() : "";
|
||||||
|
|
||||||
// Use try/catch instead of YAML::Node::as<T>(fallback) in order to get an error message
|
// Use try/catch instead of YAML::Node::as<T>(fallback) in order to get an error message
|
||||||
try
|
try
|
||||||
@ -385,7 +386,7 @@ bool patch_engine::add_patch_data(YAML::Node node, patch_info& info, u32 modifie
|
|||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
const std::string error_message = fmt::format("Skipping patch data entry: [ %s, 0x%.8x, %s ] (key: %s) %s",
|
const std::string error_message = fmt::format("Skipping patch data entry: [ %s, 0x%.8x, %s ] (key: %s) %s",
|
||||||
p_data.type, p_data.offset, value_node.IsScalar() && value_node.Scalar().size() ? value_node.Scalar() : "?", info.hash, e.what());
|
p_data.type, p_data.offset, p_data.original_value.empty() ? "?" : p_data.original_value, info.hash, e.what());
|
||||||
append_log_message(log_messages, error_message);
|
append_log_message(log_messages, error_message);
|
||||||
patch_log.error("%s", error_message);
|
patch_log.error("%s", error_message);
|
||||||
return false;
|
return false;
|
||||||
@ -736,25 +737,7 @@ bool patch_engine::save_patches(const patch_map& patches, const std::string& pat
|
|||||||
out << YAML::BeginSeq;
|
out << YAML::BeginSeq;
|
||||||
out << fmt::format("%s", data.type);
|
out << fmt::format("%s", data.type);
|
||||||
out << fmt::format("0x%.8x", data.offset);
|
out << fmt::format("0x%.8x", data.offset);
|
||||||
|
out << data.original_value;
|
||||||
switch (data.type)
|
|
||||||
{
|
|
||||||
case patch_type::lef32:
|
|
||||||
case patch_type::bef32:
|
|
||||||
case patch_type::lef64:
|
|
||||||
case patch_type::bef64:
|
|
||||||
{
|
|
||||||
// Using YAML formatting seems good enough for now
|
|
||||||
out << data.value.double_value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
out << fmt::format("0x%.8x", data.value.long_value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
out << YAML::EndSeq;
|
out << YAML::EndSeq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ public:
|
|||||||
{
|
{
|
||||||
patch_type type = patch_type::load;
|
patch_type type = patch_type::load;
|
||||||
u32 offset = 0;
|
u32 offset = 0;
|
||||||
|
std::string original_value; // Used for import consistency (avoid rounding etc.)
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
u64 long_value;
|
u64 long_value;
|
||||||
|
Loading…
Reference in New Issue
Block a user