Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kip Info fix #131

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions source/hex_funcs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ std::string findCurrentKip(const std::string& jsonPath, const std::string& offse
auto jsonData = readJsonFromFile(jsonPath);

if (jsonData && json_is_array(jsonData)) {
log("jsonData is gotten");
// log("jsonData is gotten");
size_t arraySize = json_array_size(jsonData);
log("arraySize = %ld", arraySize);
// log("arraySize = %ld", arraySize);
if (arraySize < 2) {
return "\u25B6";
}
Expand All @@ -408,8 +408,8 @@ std::string findCurrentKip(const std::string& jsonPath, const std::string& offse
json_t* hexValue = json_object_get(item, "hex");
json_t* decValue = json_object_get(item, "dec");
int hexLength = 0;
if (hexValue) {log("hexvalue");}
if (decValue) {log("decValue");}
// if (hexValue) {log("hexvalue");}
// if (decValue) {log("decValue");}
if ((hexValue && json_is_string(hexValue))) {
valueStr = json_string_value(hexValue);
searchKey = "hex";
Expand All @@ -422,16 +422,16 @@ std::string findCurrentKip(const std::string& jsonPath, const std::string& offse
} else {
return "\u25B6";
}
log("hexLength = %d", hexLength);
log("searchKey = %s", searchKey.c_str());
// log("hexLength = %d", hexLength);
// log("searchKey = %s", searchKey.c_str());
std::string currentHex;
try {
const std::string CUST = "43555354";
currentHex = readHexDataAtOffset(kipFile, CUST, std::stoul(offset), hexLength, custOffset);
} catch (const std::invalid_argument& ex) {
log("ERROR - %s:%d - invalid offset value: \"%s\" in \"%s\"", __func__, __LINE__, offset.c_str(), jsonPath.c_str());
}
log("currentHex = %s", currentHex.c_str());
// log("currentHex = %s", currentHex.c_str());
if (!currentHex.empty()) {
if (searchKey == "dec") {
currentHex = std::to_string(reversedHexToInt(currentHex));
Expand Down
4 changes: 3 additions & 1 deletion source/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ std::pair<std::string, int> dispCustData(const std::string& jsonPath, const std:
} else {
currentHex = findCurrentKip(ref, std::to_string(offset), file, custOffset);
if (currentHex == "\u25B6") {
ref = "";
currentHex = readHexDataAtOffsetF(file, offset, length); // Read the data from kip with offset starting from 'C' in 'CUST'
}
}
Expand All @@ -915,12 +916,13 @@ std::pair<std::string, int> dispCustData(const std::string& jsonPath, const std:
} else {
currentHex = findCurrentKip(ref, offsetStr, file, custOffset);
if (currentHex == "\u25B6") {
ref = "";
const size_t offset = custOffset + std::stoul(offsetStr);
currentHex = readHexDataAtOffsetF(file, offset, length); // Read the data from kip with offset starting from 'C' in 'CUST'
}
}
}
if (ref != "") {
if (ref == "") {
int intValue = reversedHexToInt(currentHex);
if (j_increment) { // Add increment value from the JSON to the displayed value
intValue += std::stoi(json_string_value(j_increment));
Expand Down