--- a/hedgewars/uLand.pas Tue Sep 03 11:16:52 2024 +0200
+++ b/hedgewars/uLand.pas Tue Sep 03 13:56:35 2024 +0200
@@ -33,7 +33,7 @@
uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture,
uVariables, uUtils, uCommands, adler32, uDebug, uLandPainted, uTextures,
uLandGenMaze, uPhysFSLayer, uScript, uLandGenPerlin,
- uLandGenTemplateBased, uLandUtils, uRenderUtils;
+ uLandUtils, uRenderUtils;
var digest: shortstring;
maskOnly: boolean;
--- a/hedgewars/uLandOutline.pas Tue Sep 03 11:16:52 2024 +0200
+++ b/hedgewars/uLandOutline.pas Tue Sep 03 13:56:35 2024 +0200
@@ -14,7 +14,7 @@
implementation
-uses uLandGraphics, uDebug, uVariables, uLandTemplates, uLandUtils;
+uses uLandGraphics, uDebug, uVariables, uLandTemplates;
var Stack: record
--- a/rust/landgen/src/outline_template_based/outline.rs Tue Sep 03 11:16:52 2024 +0200
+++ b/rust/landgen/src/outline_template_based/outline.rs Tue Sep 03 13:56:35 2024 +0200
@@ -254,8 +254,12 @@
let mut i = 0;
while i < self.islands[is].edges_count() {
let segment = self.islands[is].get_edge(i);
- if let Some(new_point) = self.divide_edge(segment, distance_divisor, distance_limiting_factor, random_numbers)
- {
+ if let Some(new_point) = self.divide_edge(
+ segment,
+ distance_divisor,
+ distance_limiting_factor,
+ random_numbers,
+ ) {
self.islands[is].split_edge(i, new_point);
i += 2;
} else {
--- a/rust/landgen/src/outline_template_based/outline_template.rs Tue Sep 03 11:16:52 2024 +0200
+++ b/rust/landgen/src/outline_template_based/outline_template.rs Tue Sep 03 13:56:35 2024 +0200
@@ -52,6 +52,14 @@
}
}
+ pub fn cavern(self) -> Self {
+ Self {
+ is_negative: true,
+ can_invert: false,
+ ..self
+ }
+ }
+
pub fn with_fill_points(self, fill_points: Vec<Point>) -> Self {
Self {
fill_points,
--- a/rust/landgen/src/outline_template_based/template_based.rs Tue Sep 03 11:16:52 2024 +0200
+++ b/rust/landgen/src/outline_template_based/template_based.rs Tue Sep 03 13:56:35 2024 +0200
@@ -18,7 +18,15 @@
parameters: &LandGenerationParameters<T>,
random_numbers: &mut I,
) -> Land2D<T> {
- let mut land = Land2D::new(&self.outline_template.size, parameters.basic);
+ let do_invert = self.outline_template.is_negative
+ && (!self.outline_template.can_invert || random_numbers.next().unwrap() & 1 == 0);
+ let (basic, zero) = if do_invert {
+ (parameters.zero, parameters.basic)
+ } else {
+ (parameters.basic, parameters.zero)
+ };
+
+ let mut land = Land2D::new(&self.outline_template.size, basic);
let mut points = OutlinePoints::from_outline_template(
&self.outline_template,
@@ -53,13 +61,13 @@
points.bezierize(5);
}
- points.draw(&mut land, parameters.zero);
+ points.draw(&mut land, zero);
for p in &points.fill_points {
- land.fill(*p, parameters.zero, parameters.zero)
+ land.fill(*p, zero, zero)
}
- points.draw(&mut land, parameters.basic);
+ points.draw(&mut land, basic);
land
}
--- a/rust/landgen/src/wavefront_collapse/generator.rs Tue Sep 03 11:16:52 2024 +0200
+++ b/rust/landgen/src/wavefront_collapse/generator.rs Tue Sep 03 13:56:35 2024 +0200
@@ -58,7 +58,10 @@
impl WavefrontCollapseLandGenerator {
pub fn new(template: TemplateDescription, data_path: &Path) -> Self {
- Self { template, data_path: data_path.to_owned() }
+ Self {
+ template,
+ data_path: data_path.to_owned(),
+ }
}
fn load_image_tiles<T: Copy + PartialEq + Default>(
@@ -69,7 +72,8 @@
let mut result = Vec::new();
let file = File::open(
- self.data_path.join("Tiles")
+ self.data_path
+ .join("Tiles")
.join(&tile_description.name)
.as_path(),
)?;
--- a/rust/lib-hwengine-future/src/lib.rs Tue Sep 03 11:16:52 2024 +0200
+++ b/rust/lib-hwengine-future/src/lib.rs Tue Sep 03 13:56:35 2024 +0200
@@ -1,11 +1,9 @@
use integral_geometry::{Point, Size};
use landgen::{
- wavefront_collapse::generator::{
- TemplateDescription as WfcTemplate,
- },
outline_template_based::outline_template::OutlineTemplate,
- LandGenerationParameters, LandGenerator,
+ wavefront_collapse::generator::TemplateDescription as WfcTemplate, LandGenerationParameters,
+ LandGenerator,
};
use lfprng::LaggedFibonacciPRNG;
use mapgen::{theme::Theme, MapGenerator};
--- a/rust/mapgen/src/lib.rs Tue Sep 03 11:16:52 2024 +0200
+++ b/rust/mapgen/src/lib.rs Tue Sep 03 13:56:35 2024 +0200
@@ -133,7 +133,18 @@
.map(|(size, indices)| {
(
TemplateType(size),
- indices.iter().map(|i| (&templates[*i]).into()).collect(),
+ indices
+ .indices
+ .iter()
+ .map(|i| Into::<OutlineTemplate>::into(&templates[*i]))
+ .map(|o| {
+ if indices.force_invert == Some(true) {
+ o.cavern()
+ } else {
+ o
+ }
+ })
+ .collect(),
)
})
.collect();
--- a/rust/mapgen/src/template/outline.rs Tue Sep 03 11:16:52 2024 +0200
+++ b/rust/mapgen/src/template/outline.rs Tue Sep 03 13:56:35 2024 +0200
@@ -34,9 +34,15 @@
}
#[derive(Deserialize)]
+pub struct TemplateTypeDesc {
+ pub indices: Vec<usize>,
+ pub force_invert: Option<bool>,
+}
+
+#[derive(Deserialize)]
pub struct TemplateCollectionDesc {
pub templates: Vec<TemplateDesc>,
- pub template_types: HashMap<String, Vec<usize>>,
+ pub template_types: HashMap<String, TemplateTypeDesc>,
}
impl From<&TemplateDesc> for OutlineTemplate {
--- a/share/hedgewars/Data/map_templates.yaml Tue Sep 03 11:16:52 2024 +0200
+++ b/share/hedgewars/Data/map_templates.yaml Tue Sep 03 13:56:35 2024 +0200
@@ -2159,8 +2159,14 @@
template_types:
- small: [39, 40, 42]
- medium: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 46]
- large: [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 43]
- cavern: [36, 2, 3, 21, 29, 45]
- wacky: [37, 38, 41, 43, 44]
+ small:
+ indices: [39, 40, 42]
+ medium:
+ indices: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 46]
+ large:
+ indices: [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 43]
+ cavern:
+ indices: [36, 2, 3, 21, 29, 45]
+ force_invert: true
+ wacky:
+ indices: [37, 38, 41, 43, 44]