update toolchain to 2022-09-23

This commit is contained in:
Marcel Märtens 2022-09-24 00:15:24 +02:00
parent c2b453f6f1
commit cf6a764aa4
33 changed files with 75 additions and 105 deletions

View File

@ -33,7 +33,7 @@ struct Cli {
fn armor_stats() -> Result<(), Box<dyn Error>> {
let mut wtr = csv::Writer::from_path("armorstats.csv")?;
wtr.write_record(&[
wtr.write_record([
"Path",
"Kind",
"Name",
@ -74,7 +74,7 @@ fn armor_stats() -> Result<(), Box<dyn Error>> {
let crit_power = armor.stats(msm).crit_power.unwrap_or(0.0).to_string();
let stealth = armor.stats(msm).stealth.unwrap_or(0.0).to_string();
wtr.write_record(&[
wtr.write_record([
item.item_definition_id()
.itemdef_id()
.expect("All items from asset glob should be simple items"),
@ -100,7 +100,7 @@ fn armor_stats() -> Result<(), Box<dyn Error>> {
fn weapon_stats() -> Result<(), Box<dyn Error>> {
let mut wtr = csv::Writer::from_path("weaponstats.csv")?;
wtr.write_record(&[
wtr.write_record([
"Path",
"Kind",
"Name",
@ -135,7 +135,7 @@ fn weapon_stats() -> Result<(), Box<dyn Error>> {
let kind = get_tool_kind(&tool.kind);
let hands = get_tool_hands(tool);
wtr.write_record(&[
wtr.write_record([
item.item_definition_id()
.itemdef_id()
.expect("All items from asset glob should be simple items"),
@ -207,12 +207,12 @@ fn get_armor_kind(kind: &ArmorKind) -> String {
fn all_items() -> Result<(), Box<dyn Error>> {
let mut wtr = csv::Writer::from_path("items.csv")?;
wtr.write_record(&["Path", "Name"])?;
wtr.write_record(["Path", "Name"])?;
for item in
Item::new_from_asset_glob("common.items.*").expect("Failed to iterate over item folders!")
{
wtr.write_record(&[
wtr.write_record([
item.item_definition_id()
.itemdef_id()
.expect("All items in asset glob should be simple items"),
@ -226,7 +226,7 @@ fn all_items() -> Result<(), Box<dyn Error>> {
fn loot_table(loot_table: &str) -> Result<(), Box<dyn Error>> {
let mut wtr = csv::Writer::from_path("loot_table.csv")?;
wtr.write_record(&[
wtr.write_record([
"Relative Chance",
"Kind",
"Item",
@ -256,8 +256,8 @@ fn loot_table(loot_table: &str) -> Result<(), Box<dyn Error>> {
};
match item {
LootSpec::Item(item) => wtr.write_record(&[&chance, "Item", item, "", ""])?,
LootSpec::ItemQuantity(item, lower, upper) => wtr.write_record(&[
LootSpec::Item(item) => wtr.write_record([&chance, "Item", item, "", ""])?,
LootSpec::ItemQuantity(item, lower, upper) => wtr.write_record([
&chance,
"Item",
item,
@ -265,14 +265,14 @@ fn loot_table(loot_table: &str) -> Result<(), Box<dyn Error>> {
&upper.to_string(),
])?,
LootSpec::LootTable(table) => {
wtr.write_record(&[&chance, "LootTable", table, "", ""])?
wtr.write_record([&chance, "LootTable", table, "", ""])?
},
LootSpec::Nothing => wtr.write_record(&[&chance, "Nothing", "", ""])?,
LootSpec::Nothing => wtr.write_record([&chance, "Nothing", "", ""])?,
LootSpec::ModularWeapon {
tool,
material,
hands,
} => wtr.write_record(&[
} => wtr.write_record([
&chance,
"Modular Weapon",
&get_tool_kind(tool),
@ -283,7 +283,7 @@ fn loot_table(loot_table: &str) -> Result<(), Box<dyn Error>> {
tool,
material,
hands,
} => wtr.write_record(&[
} => wtr.write_record([
&chance,
"Modular Weapon Primary Component",
&get_tool_kind(tool),
@ -299,7 +299,7 @@ fn loot_table(loot_table: &str) -> Result<(), Box<dyn Error>> {
fn entity_drops(entity_config: &str) -> Result<(), Box<dyn Error>> {
let mut wtr = csv::Writer::from_path("drop_table.csv")?;
wtr.write_record(&[
wtr.write_record([
"Entity Name",
"Entity Path",
"Percent Chance",
@ -314,7 +314,7 @@ fn entity_drops(entity_config: &str) -> Result<(), Box<dyn Error>> {
let entity_config = EntityConfig::load_expect(asset_path).read();
let entity_info = EntityInfo::at(Vec3::new(0.0, 0.0, 0.0))
.with_asset_expect(asset_path, &mut rand::thread_rng());
let name = entity_info.name.unwrap_or_else(|| "".to_string());
let name = entity_info.name.unwrap_or_default();
// Create initial entry in drop table
let entry: (f32, LootSpec<String>) = (1.0, entity_config.loot.clone());

View File

@ -342,9 +342,9 @@ lazy_static! {
} else {
return;
};
let entry = component_pool
let entry: &mut Vec<_> = component_pool
.entry((*toolkind, String::from(material)))
.or_insert(Vec::new());
.or_default();
entry.push((component, hand_restriction));
},
);
@ -371,7 +371,7 @@ lazy_static! {
},
) = comp_def.kind
{
let entry = component_pool.entry(toolkind).or_insert(Vec::new());
let entry: &mut Vec<_> = component_pool.entry(toolkind).or_default();
entry.push((Arc::clone(&comp_def), hand_restriction));
}
});

View File

@ -279,7 +279,7 @@ lazy_static! {
.for_each(|(ComponentKey { toolkind, material, .. }, recipe)| {
let component = recipe.itemdef_output();
let hand_restriction = None; // once there exists a hand restriction add the logic here - for a slight price correction
let entry = component_pool.entry((*toolkind, String::from(material))).or_insert(Vec::new());
let entry: &mut Vec<_> = component_pool.entry((*toolkind, String::from(material))).or_default();
entry.push((component, hand_restriction));
});
@ -306,7 +306,7 @@ lazy_static! {
) = asset_path.kind
{
let component = ItemDefinitionIdOwned::Simple(asset_path.id().into());
let entry = component_pool.entry((toolkind, String::new())).or_insert(Vec::new());
let entry: &mut Vec<_> = component_pool.entry((toolkind, String::new())).or_default();
entry.push((component, hand_restriction));
}});
@ -790,7 +790,7 @@ impl TradePricing {
{
secondaries
.entry(toolkind)
.or_insert(Vec::new())
.or_default()
.push(ItemDefinitionIdOwned::Simple(asset_path.id().into()));
}
ordered_recipes.push(RememberedRecipe {
@ -822,7 +822,7 @@ impl TradePricing {
for (key, recipe) in comp_book.iter() {
primaries
.entry(key.toolkind)
.or_insert(Vec::new())
.or_default()
.push(recipe.itemdef_output());
ordered_recipes.push(RememberedRecipe {
output: recipe.itemdef_output(),

View File

@ -478,7 +478,7 @@ impl SkillSet {
C: BorrowMut<SkillSet>,
{
if let Some(skill_group_kind) = skill.skill_group_kind() {
let this = (&*this_).borrow();
let this = (*this_).borrow();
let next_level = this.next_skill_level(skill);
let prerequisites_met = this.prerequisites_met(skill);
// Check that skill is not yet at max level

View File

@ -12,7 +12,6 @@
type_alias_impl_trait,
extend_one,
arbitrary_enum_discriminant,
generic_associated_types,
arbitrary_self_types
)]
#![feature(hash_drain_filter)]

View File

@ -521,7 +521,7 @@ where
if is_walkable(&test_pos) {
return Some(test_pos);
}
z_incr = -z_incr + if z_incr <= 0 { 1 } else { 0 };
z_incr = -z_incr + i32::from(z_incr <= 0);
}
None
};

View File

@ -470,7 +470,7 @@ impl<'a> MapConfig<'a> {
light_direction.y,
0.0, // we currently ignore light_direction.z.
);
let light_shadow_dir = if light_direction.x >= 0.0 { 0 } else { 1 };
let light_shadow_dir = usize::from(light_direction.x < 0.0);
let horizon_map = horizons.map(|horizons| &horizons[light_shadow_dir]);
let light = light_direction.normalized();
let /*mut */quads = [[0u32; QUADRANTS]; QUADRANTS];

View File

@ -123,7 +123,7 @@ impl<V, S: VolSize, M> Chunk<V, S, M> {
{
// First, construct a HashMap with max capacity equal to GROUP_COUNT (since each
// filled group can have at most one slot).
let mut map = HashMap::with_capacity(Self::GROUP_COUNT_TOTAL as usize);
let mut map: HashMap<_, Vec<_>> = HashMap::with_capacity(Self::GROUP_COUNT_TOTAL as usize);
let vox = &self.vox;
let default = &self.default;
self.indices
@ -139,11 +139,11 @@ impl<V, S: VolSize, M> Chunk<V, S, M> {
if group.all(|block| block == first) {
// All blocks in the group were the same, so add our position to this entry
// in the HashMap.
map.entry(first).or_insert(vec![]).push(grp_idx);
map.entry(first).or_default().push(grp_idx);
}
} else {
// This slot is empty (i.e. has the default value).
map.entry(default).or_insert(vec![]).push(grp_idx);
map.entry(default).or_default().push(grp_idx);
}
});
// Now, find the block with max frequency in the HashMap and make that our new

View File

@ -1,4 +1,4 @@
#![feature(let_else, btree_drain_filter)]
#![feature(btree_drain_filter)]
#![allow(clippy::option_map_unit_fn)]
mod aura;

View File

@ -1 +1 @@
nightly-2022-09-08
nightly-2022-09-23

View File

@ -5,7 +5,6 @@
box_patterns,
drain_filter,
let_chains,
let_else,
never_type,
option_zip,
unwrap_infallible

View File

@ -26,7 +26,7 @@ pub struct Entity {
pub brain: Brain,
}
#[derive(Clone, Copy, strum::EnumIter, PartialEq)]
#[derive(Clone, Copy, strum::EnumIter, PartialEq, Eq)]
pub enum RtSimEntityKind {
Wanderer,
Cultist,

View File

@ -488,11 +488,7 @@ pub fn handle_inbox_update_pending_trade(bdata: &mut BehaviorData) -> bool {
if let Some(AgentEvent::UpdatePendingTrade(boxval)) = agent.inbox.pop_front() {
let (tradeid, pending, prices, inventories) = *boxval;
if agent.behavior.is(BehaviorState::TRADING) {
let who: usize = if agent.behavior.is(BehaviorState::TRADING_ISSUER) {
0
} else {
1
};
let who = usize::from(!agent.behavior.is(BehaviorState::TRADING_ISSUER));
let balance0: f32 = prices.balance(&pending.offers, &inventories, 1 - who, true);
let balance1: f32 = prices.balance(&pending.offers, &inventories, who, false);
if balance0 >= balance1 {

View File

@ -293,10 +293,7 @@ impl Default for DeletedEntities {
impl DeletedEntities {
pub fn record_deleted_entity(&mut self, uid: Uid, region_key: Vec2<i32>) {
self.map
.entry(region_key)
.or_insert(Vec::new())
.push(uid.into());
self.map.entry(region_key).or_default().push(uid.into());
}
pub fn take_deleted_in_region(&mut self, key: Vec2<i32>) -> Vec<u64> {

View File

@ -1,4 +1,3 @@
#![feature(generic_associated_types)]
#![allow(incomplete_features)]
#![allow(clippy::single_match)]
#[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))]

View File

@ -340,7 +340,7 @@ pub fn complete(line: &str, client: &Client, cmd_prefix: char) -> Vec<String> {
let line = line.strip_prefix(cmd_prefix).unwrap_or(line);
let mut iter = line.split_whitespace();
let cmd = iter.next().unwrap_or("");
let i = iter.count() + if word.is_empty() { 1 } else { 0 };
let i = iter.count() + usize::from(word.is_empty());
if i == 0 {
// Completing chat command name. This is the start of the line so the prefix
// will be part of it

View File

@ -164,15 +164,11 @@ impl<'a> Ingameable for Overhead<'a> {
0
}
+ if info.health.map_or(false, should_show_healthbar) {
5 + if info.energy.is_some() { 1 } else { 0 }
} else {
0
}
+ if info.health.map_or(false, decayed_health_displayed) {
1
5 + usize::from(info.energy.is_some())
} else {
0
}
+ usize::from(info.health.map_or(false, decayed_health_displayed))
+ (!self.interaction_options.is_empty()) as usize * 2
}) + if self.bubble.is_some() { 13 } else { 0 }
}

View File

@ -150,7 +150,7 @@ impl Profile {
match character_id {
Some(character_id) => self.servers
.entry(server.to_string())
.or_insert(ServerProfile::default())
.or_default()
// Get or update the CharacterProfile.
.characters
.entry(character_id)
@ -191,7 +191,7 @@ impl Profile {
) {
self.servers
.entry(server.to_string())
.or_insert(ServerProfile::default())
.or_default()
.selected_character = selected_character;
}
@ -226,7 +226,7 @@ impl Profile {
) {
self.servers
.entry(server.to_string())
.or_insert(ServerProfile::default())
.or_default()
.spectate_position = spectate_position;
}

View File

@ -17,7 +17,7 @@ impl Vertex {
.enumerate()
.find(|(_i, e)| **e != 0.0)
.unwrap_or((0, &1.0));
let norm_bits = ((norm_axis << 1) | if *norm_dir > 0.0 { 1 } else { 0 }) as u32;
let norm_bits = ((norm_axis << 1) | usize::from(*norm_dir > 0.0)) as u32;
const EXTRA_NEG_Z: f32 = 65536.0;

View File

@ -18,6 +18,7 @@ pub struct Vertex {
impl Vertex {
#[allow(clippy::collapsible_else_if)]
pub fn new(pos: Vec3<f32>, norm: Vec3<f32>) -> Self {
#[allow(clippy::bool_to_int_with_if)]
let norm_bits = if norm.x != 0.0 {
if norm.x < 0.0 { 0 } else { 1 }
} else if norm.y != 0.0 {

View File

@ -44,6 +44,7 @@ impl Vertex {
pub fn new(atlas_pos: Vec2<u16>, pos: Vec3<f32>, norm: Vec3<f32>) -> Self {
const VERT_EXTRA_NEG_Z: i32 = 128; // NOTE: change if number of bits changes below, also we might not need this if meshing always produces positives values for sprites (I have no idea)
#[allow(clippy::bool_to_int_with_if)]
let norm_bits = if norm.x != 0.0 {
if norm.x < 0.0 { 0 } else { 1 }
} else if norm.y != 0.0 {

View File

@ -15,6 +15,7 @@ impl Vertex {
pub fn new(atlas_pos: Vec2<u16>, pos: Vec3<f32>, norm: Vec3<f32>, meta: bool) -> Self {
const EXTRA_NEG_Z: f32 = 32768.0;
#[allow(clippy::bool_to_int_with_if)]
let norm_bits = if norm.x != 0.0 {
if norm.x < 0.0 { 0 } else { 1 }
} else if norm.y != 0.0 {
@ -28,18 +29,14 @@ impl Vertex {
pos_norm: ((pos.x as u32) & 0x003F) << 0
| ((pos.y as u32) & 0x003F) << 6
| (((pos + EXTRA_NEG_Z).z.max(0.0).min((1 << 16) as f32) as u32) & 0xFFFF) << 12
| if meta { 1 } else { 0 } << 28
| u32::from(meta) << 28
| (norm_bits & 0x7) << 29,
atlas_pos: ((atlas_pos.x as u32) & 0xFFFF) << 0 | ((atlas_pos.y as u32) & 0xFFFF) << 16,
}
}
pub fn new_figure(atlas_pos: Vec2<u16>, pos: Vec3<f32>, norm: Vec3<f32>, bone_idx: u8) -> Self {
let norm_bits = if norm.x.min(norm.y).min(norm.z) < 0.0 {
0
} else {
1
};
let norm_bits = u32::from(norm.x.min(norm.y).min(norm.z) >= 0.0);
let axis_bits = if norm.x != 0.0 {
0
} else if norm.y != 0.0 {

View File

@ -234,11 +234,9 @@ fn create_lod_terrain_mesh(detail: u32) -> Mesh<LodTerrainVertex> {
Vertex::new(Vec2::new(x + 1, y + 1).map(transform)),
Vertex::new(Vec2::new(x, y + 1).map(transform)),
)
.rotated_by(if (x > detail as i32 / 2) ^ (y > detail as i32 / 2) {
0
} else {
1
})
.rotated_by(usize::from(
!((x > detail as i32 / 2) ^ (y > detail as i32 / 2)),
))
})
.collect()
}

View File

@ -1079,11 +1079,7 @@ impl ParticleMgr {
} => {
let num_particles = aura.radius.powi(2) * dt / 250.0;
let num_particles = num_particles.floor() as usize
+ if rng.gen_bool(f64::from(num_particles % 1.0)) {
1
} else {
0
};
+ usize::from(rng.gen_bool(f64::from(num_particles % 1.0)));
self.particles
.resize_with(self.particles.len() + num_particles, || {
let rand_pos = {

View File

@ -48,7 +48,7 @@ fn unlz4_with_dictionary(data: &[u8], dictionary: &[u8]) -> Option<Vec<u8>> {
r.into_read_with_dictionary(dictionary)
.read_to_end(&mut uncompressed)
.ok()?;
bincode::deserialize(&*uncompressed).ok()
bincode::deserialize(&uncompressed).ok()
})
}
@ -201,7 +201,7 @@ impl VoxelImageEncoding for PngEncoding {
FilterType::Up,
);
png.write_image(
&*ws.as_raw(),
ws.as_raw(),
ws.width(),
ws.height(),
image::ColorType::Rgba8,
@ -300,7 +300,7 @@ impl VoxelImageEncoding for MixedEncoding {
CompressionType::Rle,
FilterType::Up,
);
png.write_image(&*x.as_raw(), x.width(), x.height(), image::ColorType::L8)
png.write_image(x.as_raw(), x.width(), x.height(), image::ColorType::L8)
.ok()?;
indices[i] = buf.len();
Some(())
@ -407,7 +407,7 @@ impl VoxelImageEncoding for MixedEncodingSparseSprites {
FilterType::Up,
);
png.write_image(
&*ws.0.as_raw(),
ws.0.as_raw(),
ws.0.width(),
ws.0.height(),
image::ColorType::L8,
@ -471,14 +471,14 @@ impl VoxelImageEncoding for MixedEncodingDenseSprites {
CompressionType::Fast,
FilterType::Up,
);
png.write_image(&*x.as_raw(), x.width(), x.height(), image::ColorType::L8)
png.write_image(x.as_raw(), x.width(), x.height(), image::ColorType::L8)
.ok()?;
indices[i] = buf.len();
Some(())
};
f(&ws.0, 0)?;
let mut g = |x: &[u8], i| {
buf.extend_from_slice(&*CompressedData::compress(&x, 4).data);
buf.extend_from_slice(&CompressedData::compress(&x, 4).data);
indices[i] = buf.len();
};
@ -533,7 +533,7 @@ lazy_static::lazy_static! {
static ref PALETTE_RTREE: HashMap<BlockKind, RTree<ColorPoint, TestParams>> = {
let ron_bytes = include_bytes!("palettes.ron");
let palettes: HashMap<BlockKind, Vec<Rgb<u8>>> =
ron::de::from_bytes(&*ron_bytes).expect("palette should parse");
ron::de::from_bytes(ron_bytes).expect("palette should parse");
palettes
.into_iter()
.map(|(k, v)| {
@ -549,7 +549,7 @@ lazy_static::lazy_static! {
pub static ref PALETTE_KDTREE: HashMap<BlockKind, KdTree<f32, u8, 3>> = {
let ron_bytes = include_bytes!("palettes.ron");
let palettes: HashMap<BlockKind, Vec<Rgb<u8>>> =
ron::de::from_bytes(&*ron_bytes).expect("palette should parse");
ron::de::from_bytes(ron_bytes).expect("palette should parse");
palettes
.into_iter()
.map(|(k, v)| {
@ -637,7 +637,7 @@ impl<'a, NN: NearestNeighbor, const N: u32> VoxelImageEncoding for PaletteEncodi
CompressionType::Rle,
FilterType::Up,
);
png.write_image(&*x.as_raw(), x.width(), x.height(), image::ColorType::L8)
png.write_image(x.as_raw(), x.width(), x.height(), image::ColorType::L8)
.ok()?;
indices[i] = buf.len();
Some(())
@ -921,8 +921,8 @@ fn main() {
histogram_to_dictionary(&histogram2, &mut dictionary2);
}
}
let lz4_dyna = lz4_with_dictionary(&*ser_dyna, &[]);
let deflate_dyna = do_deflate_flate2::<5>(&*ser_dyna);
let lz4_dyna = lz4_with_dictionary(&ser_dyna, &[]);
let deflate_dyna = do_deflate_flate2::<5>(&ser_dyna);
let deflate_channeled_dyna = do_deflate_flate2::<5>(
&bincode::serialize(&channelize_dyna(&dyna)).unwrap(),
);
@ -936,7 +936,7 @@ fn main() {
),
]);
if HISTOGRAMS {
let lz4_dict_dyna = lz4_with_dictionary(&*ser_dyna, &dictionary2);
let lz4_dict_dyna = lz4_with_dictionary(&ser_dyna, &dictionary2);
sizes.push(("lz4_dict_dyna", lz4_dict_dyna.len() as f32 / n as f32));
}
}
@ -954,7 +954,7 @@ fn main() {
spiralpos.x, spiralpos.y
))
.unwrap();
f.write_all(&*jpegchonkgrid).unwrap();
f.write_all(&jpegchonkgrid).unwrap();
}
let jpegchonktall_pre = Instant::now();
@ -1199,7 +1199,7 @@ fn main() {
.unwrap();
let jpeg_volgrid =
image_terrain_volgrid(&JpegEncoding, GridLtrPacking, &volgrid).unwrap();
f.write_all(&*jpeg_volgrid).unwrap();
f.write_all(&jpeg_volgrid).unwrap();
let mixedgrid_pre = Instant::now();
let (mixed_volgrid, indices) =

View File

@ -179,8 +179,8 @@ impl ExportVol {
for (index, (model_pos, _)) in self.models.iter().enumerate() {
// Transform node
let pos = model_pos
.map(|p| p * Self::CHUNK_SIZE + Self::CHUNK_SIZE / 2 + if p < 0 { 0 } else { 1 });
let pos =
model_pos.map(|p| p * Self::CHUNK_SIZE + Self::CHUNK_SIZE / 2 + i32::from(p >= 0));
let pos = pos - Vec3::new(self.width / 2, self.width / 2, 0);
let transform_node_id = index as i32 * 2 + 2;
let shape_node_id = index as i32 * 2 + 3;

View File

@ -84,14 +84,14 @@ fn image_from_function<F: FnMut(u32, u32) -> [u8; 3]>(
let png =
PngEncoder::new_with_quality(&mut heightmap_png, CompressionType::Best, FilterType::Paeth);
png.write_image(
&*heightmap.as_raw(),
heightmap.as_raw(),
heightmap.width(),
heightmap.height(),
image::ColorType::Rgb8,
)
.unwrap();
let mut f = File::create(name).unwrap();
f.write_all(&*heightmap_png).unwrap();
f.write_all(&heightmap_png).unwrap();
}
fn image_with_autorange<F: Fn(f32, f32, f32) -> [u8; 3], G: FnMut(u32, u32) -> f32>(

View File

@ -274,7 +274,7 @@ fn main() -> Result<(), Box<dyn Error>> {
},
Some(("palette", matches)) => {
let conn =
Connection::open(&matches.value_of("database").expect("database is required"))?;
Connection::open(matches.value_of("database").expect("database is required"))?;
palette(conn)?;
},
_ => {

View File

@ -7,7 +7,7 @@
)]
#![allow(clippy::branches_sharing_code)] // TODO: evaluate
#![deny(clippy::clone_on_ref_ptr)]
#![feature(option_zip, arbitrary_enum_discriminant, let_else)]
#![feature(option_zip, arbitrary_enum_discriminant)]
mod all;
mod block;

View File

@ -237,12 +237,7 @@ fn tick(index: &mut Index, dt: f32, _env: &mut Environment) {
// distribute orders (travelling merchants)
for (_id, site) in index.sites.iter_mut() {
for (i, mut v) in site.economy.orders.drain() {
index
.trade
.orders
.entry(i)
.or_insert(Vec::new())
.append(&mut v);
index.trade.orders.entry(i).or_default().append(&mut v);
}
}
// trade at sites

View File

@ -192,12 +192,7 @@ impl Archetype for Keep {
};
let ridge_x = (center_offset.map(|e| e.abs()).reduce_min() + 2) % 8;
let width = locus
+ if ridge_x < 4 && attr.ridged && !attr.rounded {
1
} else {
0
};
let width = locus + i32::from(ridge_x < 4 && attr.ridged && !attr.rounded);
let rampart_width = 2 + width;
let storey_height = 9;
let roof_height = attr.storeys * storey_height;

View File

@ -222,7 +222,7 @@ impl Room {
.map(|e| e.rem_euclid(pillar_space) == 0)
.reduce_and()
});
let enemy_spawn_tile = enemy_spawn_tile + if enemy_tile_is_pillar { 1 } else { 0 };
let enemy_spawn_tile = enemy_spawn_tile + i32::from(enemy_tile_is_pillar);
// Toss mobs in the center of the room
if tile_pos == enemy_spawn_tile && wpos2d == tile_wcenter.xy() {
@ -281,7 +281,7 @@ impl Room {
.map(|e| e.rem_euclid(pillar_space) == 0)
.reduce_and()
});
let miniboss_spawn_tile = miniboss_spawn_tile + if miniboss_tile_is_pillar { 1 } else { 0 };
let miniboss_spawn_tile = miniboss_spawn_tile + i32::from(miniboss_tile_is_pillar);
if tile_pos == miniboss_spawn_tile && tile_wcenter.xy() == wpos2d {
let entities = match self.difficulty {
@ -314,7 +314,7 @@ impl Room {
.map(|e| e.rem_euclid(pillar_space) == 0)
.reduce_and()
});
let boss_spawn_tile = boss_spawn_tile + if boss_tile_is_pillar { 1 } else { 0 };
let boss_spawn_tile = boss_spawn_tile + i32::from(boss_tile_is_pillar);
if tile_pos == boss_spawn_tile && wpos2d == tile_wcenter.xy() {
let entities = match self.difficulty {

View File

@ -42,6 +42,7 @@ impl House {
min: site.tile_wpos(tile_aabr.min),
max: site.tile_wpos(tile_aabr.max),
};
#[allow(clippy::bool_to_int_with_if)]
let front = if door_dir.y < 0 {
2
} else if door_dir.x < 0 {