add option to require item descriptions instead of data
This commit is contained in:
+7
-1
@@ -16,16 +16,22 @@ ItemData::ItemData(const ItemData& other) {
|
|||||||
this->data2d = other.data2d;
|
this->data2d = other.data2d;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemData::ItemData(const string& desc) {
|
ItemData::ItemData(const string& desc, bool allow_raw_data) {
|
||||||
|
this->clear();
|
||||||
try {
|
try {
|
||||||
this->parse(desc, false);
|
this->parse(desc, false);
|
||||||
return;
|
return;
|
||||||
} catch (const exception&) {
|
} catch (const exception&) {
|
||||||
|
this->clear();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this->parse(desc, true);
|
this->parse(desc, true);
|
||||||
return;
|
return;
|
||||||
} catch (const exception&) {
|
} catch (const exception&) {
|
||||||
|
if (!allow_raw_data) {
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
this->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
string data = parse_data_string(desc);
|
string data = parse_data_string(desc);
|
||||||
|
|||||||
+1
-1
@@ -96,7 +96,7 @@ struct ItemData { // 0x14 bytes
|
|||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
ItemData();
|
ItemData();
|
||||||
explicit ItemData(const std::string& orig_description);
|
explicit ItemData(const std::string& orig_description, bool allow_raw_data = true);
|
||||||
ItemData(const ItemData& other);
|
ItemData(const ItemData& other);
|
||||||
ItemData& operator=(const ItemData& other);
|
ItemData& operator=(const ItemData& other);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1333,7 +1333,7 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case Behavior::ENCODE_ITEM: {
|
case Behavior::ENCODE_ITEM: {
|
||||||
ItemData item(input_filename);
|
ItemData item(input_filename, false);
|
||||||
string desc = item.name(false);
|
string desc = item.name(false);
|
||||||
log_info("Data: %02hhX%02hhX%02hhX%02hhX %02hhX%02hhX%02hhX%02hhX %02hhX%02hhX%02hhX%02hhX -------- %02hhX%02hhX%02hhX%02hhX",
|
log_info("Data: %02hhX%02hhX%02hhX%02hhX %02hhX%02hhX%02hhX%02hhX %02hhX%02hhX%02hhX%02hhX -------- %02hhX%02hhX%02hhX%02hhX",
|
||||||
item.data1[0], item.data1[1], item.data1[2], item.data1[3],
|
item.data1[0], item.data1[1], item.data1[2], item.data1[3],
|
||||||
|
|||||||
Reference in New Issue
Block a user