mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Add condition field to plugin cleaning data metadata
This commit is contained in:
@@ -80,7 +80,8 @@ public:
|
||||
const std::vector<MessageContent>& detail,
|
||||
unsigned int itm,
|
||||
unsigned int ref,
|
||||
unsigned int nav);
|
||||
unsigned int nav,
|
||||
std::string_view condition);
|
||||
|
||||
/**
|
||||
* Get the CRC that identifies the plugin that the cleaning data is for.
|
||||
@@ -122,6 +123,12 @@ public:
|
||||
*/
|
||||
LOOT_API std::vector<MessageContent> GetDetail() const;
|
||||
|
||||
/**
|
||||
* Get the condition string.
|
||||
* @return The cleaning data's condition string.
|
||||
*/
|
||||
LOOT_API std::string GetCondition() const;
|
||||
|
||||
private:
|
||||
uint32_t crc_{0};
|
||||
unsigned int itm_{0};
|
||||
@@ -129,6 +136,7 @@ private:
|
||||
unsigned int nav_{0};
|
||||
std::string utility_;
|
||||
std::vector<MessageContent> detail_;
|
||||
std::string condition_;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -106,7 +106,8 @@ loot::PluginCleaningData convert(const loot::rust::PluginCleaningData& data) {
|
||||
convert<loot::MessageContent>(data.detail()),
|
||||
data.itm_count(),
|
||||
data.deleted_reference_count(),
|
||||
data.deleted_navmesh_count());
|
||||
data.deleted_navmesh_count(),
|
||||
convert(data.condition()));
|
||||
}
|
||||
|
||||
loot::Location convert(const loot::rust::Location& location) {
|
||||
@@ -221,7 +222,8 @@ loot::rust::MessageType convert(loot::MessageType messageType) {
|
||||
convert<loot::rust::MessageContent>(data.GetDetail()),
|
||||
data.GetITMCount(),
|
||||
data.GetDeletedReferenceCount(),
|
||||
data.GetDeletedNavmeshCount());
|
||||
data.GetDeletedNavmeshCount(),
|
||||
data.GetCondition());
|
||||
} catch (const ::rust::Error& e) {
|
||||
std::rethrow_exception(mapError(e));
|
||||
}
|
||||
|
||||
@@ -34,13 +34,15 @@ PluginCleaningData::PluginCleaningData(
|
||||
const std::vector<MessageContent>& detail,
|
||||
unsigned int itm,
|
||||
unsigned int ref,
|
||||
unsigned int nav) :
|
||||
unsigned int nav,
|
||||
std::string_view condition) :
|
||||
crc_(crc),
|
||||
itm_(itm),
|
||||
ref_(ref),
|
||||
nav_(nav),
|
||||
utility_(utility),
|
||||
detail_(detail) {}
|
||||
detail_(detail),
|
||||
condition_(condition) {}
|
||||
|
||||
uint32_t PluginCleaningData::GetCRC() const { return crc_; }
|
||||
|
||||
@@ -58,12 +60,15 @@ std::vector<MessageContent> PluginCleaningData::GetDetail() const {
|
||||
return detail_;
|
||||
}
|
||||
|
||||
std::string PluginCleaningData::GetCondition() const { return condition_; }
|
||||
|
||||
bool operator==(const PluginCleaningData& lhs, const PluginCleaningData& rhs) {
|
||||
return lhs.GetCRC() == rhs.GetCRC() &&
|
||||
lhs.GetITMCount() == rhs.GetITMCount() &&
|
||||
lhs.GetDeletedReferenceCount() == rhs.GetDeletedReferenceCount() &&
|
||||
lhs.GetDeletedNavmeshCount() == rhs.GetDeletedNavmeshCount() &&
|
||||
lhs.GetCleaningUtility() == rhs.GetCleaningUtility() &&
|
||||
lhs.GetCondition() == rhs.GetCondition() &&
|
||||
lhs.GetDetail() == rhs.GetDetail();
|
||||
}
|
||||
|
||||
@@ -112,6 +117,14 @@ bool operator<(const PluginCleaningData& lhs, const PluginCleaningData& rhs) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lhs.GetCondition() < rhs.GetCondition()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (rhs.GetCondition() < lhs.GetCondition()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return lhs.GetDetail() < rhs.GetDetail();
|
||||
}
|
||||
|
||||
|
||||
@@ -612,6 +612,7 @@ mod ffi {
|
||||
itm_count: u32,
|
||||
deleted_reference_count: u32,
|
||||
deleted_navmesh_count: u32,
|
||||
condition: String,
|
||||
) -> Result<Box<PluginCleaningData>>;
|
||||
|
||||
pub fn crc(&self) -> u32;
|
||||
@@ -626,6 +627,8 @@ mod ffi {
|
||||
|
||||
pub fn detail(&self) -> &[MessageContent];
|
||||
|
||||
pub fn condition(&self) -> &str;
|
||||
|
||||
pub fn boxed_clone(&self) -> Box<PluginCleaningData>;
|
||||
}
|
||||
|
||||
|
||||
@@ -585,6 +585,7 @@ pub fn new_plugin_cleaning_data(
|
||||
itm_count: u32,
|
||||
deleted_reference_count: u32,
|
||||
deleted_navmesh_count: u32,
|
||||
condition: String,
|
||||
) -> Result<Box<PluginCleaningData>, VerboseError> {
|
||||
let mut data = libloot::metadata::PluginCleaningData::new(crc, cleaning_utility)
|
||||
.with_itm_count(itm_count)
|
||||
@@ -595,6 +596,10 @@ pub fn new_plugin_cleaning_data(
|
||||
data = data.with_detail(to_vec_of_unwrapped(detail))?;
|
||||
}
|
||||
|
||||
if !condition.is_empty() {
|
||||
data = data.with_condition(condition);
|
||||
}
|
||||
|
||||
Ok(Box::new(PluginCleaningData(data)))
|
||||
}
|
||||
|
||||
@@ -603,6 +608,10 @@ impl PluginCleaningData {
|
||||
MessageContent::wrap_slice(self.0.detail())
|
||||
}
|
||||
|
||||
pub fn condition(&self) -> &str {
|
||||
self.0.condition().unwrap_or("")
|
||||
}
|
||||
|
||||
pub fn boxed_clone(&self) -> Box<Self> {
|
||||
Box::new(Self(self.0.clone()))
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -205,8 +205,8 @@ TEST_F(PluginMetadataTest, mergeMetadataShouldMergeTags) {
|
||||
TEST_F(PluginMetadataTest, mergeMetadataShouldMergeDirtyInfoData) {
|
||||
PluginMetadata plugin1;
|
||||
PluginMetadata plugin2;
|
||||
PluginCleaningData info1(0x5, "utility", info_, 1, 2, 3);
|
||||
PluginCleaningData info2(0xA, "utility", info_, 1, 2, 3);
|
||||
PluginCleaningData info1(0x5, "utility", info_, 1, 2, 3, "condition");
|
||||
PluginCleaningData info2(0xA, "utility", info_, 1, 2, 3, "condition");
|
||||
|
||||
plugin1.SetDirtyInfo({info1});
|
||||
plugin2.SetDirtyInfo({info1, info2});
|
||||
@@ -314,7 +314,8 @@ TEST_F(PluginMetadataTest, hasNameOnlyShouldBeFalseIfTagsExist) {
|
||||
|
||||
TEST_F(PluginMetadataTest, hasNameOnlyShouldBeFalseIfDirtyInfoExists) {
|
||||
PluginMetadata plugin(blankEsp);
|
||||
plugin.SetDirtyInfo({PluginCleaningData(5, "utility", info_, 0, 1, 2)});
|
||||
plugin.SetDirtyInfo(
|
||||
{PluginCleaningData(5, "utility", info_, 0, 1, 2, "condition")});
|
||||
|
||||
EXPECT_FALSE(plugin.HasNameOnly());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user