Fixed i16 underflow

This commit is contained in:
Joshua Barretto 2022-05-09 11:53:59 +01:00
parent 1db7cc7fde
commit 3881d2ea38

View File

@ -484,20 +484,27 @@ impl World {
.filter(|col| layer::tree::tree_valid_at(col, attr.seed)) .filter(|col| layer::tree::tree_valid_at(col, attr.seed))
.zip(Some(attr)) .zip(Some(attr))
}) })
.map(|(col, tree)| lod::Object { .filter_map(|(col, tree)| Some(lod::Object {
kind: match tree.forest_kind { kind: match tree.forest_kind {
all::ForestKind::Oak => lod::ObjectKind::Oak, all::ForestKind::Oak => lod::ObjectKind::Oak,
all::ForestKind::Pine all::ForestKind::Pine
| all::ForestKind::Frostpine=> lod::ObjectKind::Pine, | all::ForestKind::Frostpine=> lod::ObjectKind::Pine,
_ => lod::ObjectKind::Oak, _ => lod::ObjectKind::Oak,
}, },
pos: (tree.pos - min_wpos) pos: {
.map(|e| e as u16) let rpos = tree.pos - min_wpos;
.with_z(self.sim().get_alt_approx(tree.pos).unwrap_or(0.0) as u16), if rpos.is_any_negative() {
return None
} else {
rpos
.map(|e| e as u16)
.with_z(self.sim().get_alt_approx(tree.pos).unwrap_or(0.0) as u16)
}
},
flags: lod::Flags::empty() flags: lod::Flags::empty()
| if col.snow_cover { lod::Flags::SNOW_COVERED } else { lod::Flags::empty() } | if col.snow_cover { lod::Flags::SNOW_COVERED } else { lod::Flags::empty() }
, ,
}) }))
.collect()); .collect());
lod::Zone { objects } lod::Zone { objects }