mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Post-cleaning
This commit is contained in:
parent
faeac0eef3
commit
13324700ba
@ -276,6 +276,7 @@ mod entity_v2 {
|
||||
pub type Config = EntityConfig;
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum LoadoutKindNew {
|
||||
FromBody,
|
||||
Asset(String),
|
||||
@ -363,7 +364,7 @@ mod entity_v2 {
|
||||
Self {
|
||||
loadout: LoadoutKindNew::Inline(LoadoutSpecNew {
|
||||
inherit: loadout.map(|asset| match asset {
|
||||
LoadoutAsset::Loadout(s) => Base::Asset(s.to_owned()),
|
||||
LoadoutAsset::Loadout(s) => Base::Asset(s),
|
||||
LoadoutAsset::Choice(bases) => Base::Choice(
|
||||
bases
|
||||
.iter()
|
||||
@ -408,11 +409,11 @@ mod entity_v2 {
|
||||
}
|
||||
|
||||
mod old {
|
||||
pub type Config = super::loadout_v1::Config;
|
||||
pub type Config = super::entity_v1::Config;
|
||||
}
|
||||
|
||||
mod new {
|
||||
pub type Config = super::loadout_v2::Config;
|
||||
pub type Config = super::entity_v2::Config;
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -465,12 +466,10 @@ where
|
||||
// Grab all comments from old file
|
||||
let source = fs::File::open(from.join(&path))?;
|
||||
let mut comments = Vec::new();
|
||||
for line in BufReader::new(source).lines() {
|
||||
if let Ok(line) = line {
|
||||
if let Some(idx) = line.find("//") {
|
||||
let comment = &line[idx..line.len()];
|
||||
comments.push(comment.to_owned());
|
||||
}
|
||||
for line in BufReader::new(source).lines().flatten() {
|
||||
if let Some(idx) = line.find("//") {
|
||||
let comment = &line[idx..line.len()];
|
||||
comments.push(comment.to_owned());
|
||||
}
|
||||
}
|
||||
// Parse the file
|
||||
@ -488,7 +487,7 @@ where
|
||||
} else {
|
||||
let mut comments = comments.join("\n");
|
||||
// insert newline for other config content
|
||||
comments.push_str("\n");
|
||||
comments.push('\n');
|
||||
comments
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![warn(clippy::pedantic)]
|
||||
//#![warn(clippy::pedantic)]
|
||||
//#![warn(clippy::nursery)]
|
||||
use crate::{
|
||||
assets::{self, AssetExt},
|
||||
@ -37,13 +37,13 @@ pub enum ValidationError {
|
||||
}
|
||||
|
||||
// TODO: serde un-tag?
|
||||
// <https://serde.rs/enum-representations.html>
|
||||
//
|
||||
// Pros:
|
||||
// + less noise
|
||||
//
|
||||
// Cons:
|
||||
// - limits us to using different types for each variant
|
||||
// - doesn't work with some serde feature I don't remember
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
enum ItemSpec {
|
||||
Item(String),
|
||||
@ -196,6 +196,7 @@ impl Base {
|
||||
|
||||
// TODO: remove clone
|
||||
#[derive(Debug, Deserialize, Clone, Default)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct LoadoutSpec {
|
||||
// Meta fields
|
||||
inherit: Option<Base>,
|
||||
@ -754,7 +755,6 @@ impl LoadoutBuilder {
|
||||
Self::from_asset(asset_specifier, rng).expect("failed to load loadut config")
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
/// Construct new `LoadoutBuilder` from `asset_specifier`
|
||||
pub fn from_asset(asset_specifier: &str, rng: &mut impl Rng) -> Result<Self, SpecError> {
|
||||
let loadout = Self::empty();
|
||||
@ -773,7 +773,6 @@ impl LoadoutBuilder {
|
||||
.with_default_equipment(body)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
/// Construct new `LoadoutBuilder` from `asset_specifier`
|
||||
pub fn from_loadout_spec(
|
||||
loadout_spec: LoadoutSpec,
|
||||
@ -1173,7 +1172,6 @@ mod tests {
|
||||
//
|
||||
// Things that will be catched - invalid assets paths
|
||||
#[test]
|
||||
#[ignore = "UNIGNORE BEFORE MERGE!!!"]
|
||||
fn test_loadout_presets() {
|
||||
for preset in Preset::iter() {
|
||||
std::mem::drop(LoadoutBuilder::empty().with_preset(preset));
|
||||
@ -1187,7 +1185,6 @@ mod tests {
|
||||
// we will check some loadout assets at least two times.
|
||||
// One for asset itself and second if it serves as a base for other asset.
|
||||
#[test]
|
||||
#[ignore = "UNIGNORE BEFORE MERGE!!!"]
|
||||
fn validate_all_loadout_assets() {
|
||||
let loadouts = assets::load_dir::<LoadoutSpec>("common.loadout", true)
|
||||
.expect("failed to load loadout directory");
|
||||
|
@ -38,6 +38,7 @@ impl Default for AlignmentMark {
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum LoadoutKind {
|
||||
FromBody,
|
||||
Asset(String),
|
||||
@ -90,6 +91,7 @@ pub enum Meta {
|
||||
/// EntityInfo::at(dummy_position).with_asset_expect("common.entity.template", &mut dummy_rng);
|
||||
/// ```
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct EntityConfig {
|
||||
/// Name of Entity
|
||||
/// Can be Name(String) with given name
|
||||
@ -518,7 +520,7 @@ mod tests {
|
||||
let loadout =
|
||||
LoadoutSpec::load_cloned(&asset).expect("failed to load loadout asset");
|
||||
loadout
|
||||
.validate(vec![asset.to_owned()])
|
||||
.validate(vec![asset])
|
||||
.unwrap_or_else(|e| panic!("Config {config_asset} is broken: {e:?}"));
|
||||
},
|
||||
LoadoutKind::Inline(spec) => {
|
||||
|
Loading…
Reference in New Issue
Block a user