diff --git a/.travis.yml b/.travis.yml index bfdbffb..0be1dc0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ sudo: required dist: trusty rust: - nightly - - nightly-2018-10-24 + - beta matrix: allow_failures: - rust: nightly diff --git a/README.md b/README.md index 2a584a9..3c03c34 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Feel free to pop in to say hi, [Webchat can be found here](https://irc.spi.gt/ir ## Building For more detailed info and platform specific instructions check the [wiki](https://github.com/Thinkofname/steven-rust/wiki/Compiling-and-or-running). -Currently requires SDL2, OpenSSL and **nightly** rust to build. +Currently requires SDL2, OpenSSL and **beta or nightly** Rust to build. `cargo build --release` diff --git a/src/main.rs b/src/main.rs index 778729b..5ef4f3f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,6 @@ // limitations under the License. #![recursion_limit="300"] -#![feature(const_fn)] extern crate sdl2; extern crate zip; diff --git a/src/types/metadata.rs b/src/types/metadata.rs index 0cf30be..59ea64d 100644 --- a/src/types/metadata.rs +++ b/src/types/metadata.rs @@ -29,7 +29,7 @@ pub struct MetadataKey { impl MetadataKey { #[allow(dead_code)] - const fn new(index: i32) -> MetadataKey { + fn new(index: i32) -> MetadataKey { MetadataKey { index: index, ty: PhantomData, diff --git a/src/world/biome.rs b/src/world/biome.rs index 9472bc4..7eb9415 100644 --- a/src/world/biome.rs +++ b/src/world/biome.rs @@ -4,12 +4,12 @@ use image::Rgba; #[derive(Clone, Copy)] pub struct Biome { pub id: usize, - pub temperature: f64, - pub moisture: f64, + pub temperature: i16, + pub moisture: i16, } impl Biome { - const fn new(id: usize, t: f64, m: f64) -> Biome { + const fn new(id: usize, t: i16, m: i16) -> Biome { Biome { id: id, temperature: t, @@ -22,8 +22,8 @@ impl Biome { } pub fn get_color_index(self) -> usize { - let t = self.temperature.min(1.0).max(0.0); - let m = self.moisture.min(1.0).max(0.0); + let t = (self.temperature as f64 / 100f64) .min(1.0).max(0.0); + let m = (self.moisture as f64 / 100f64).min(1.0).max(0.0); (((1.0 - t) * 255.0) as usize) | ((((1.0 - (m*t)) * 255.0) as usize) << 8) } @@ -64,68 +64,68 @@ macro_rules! define_biomes { } define_biomes! { -pub const OCEAN: Biome = Biome::new(0, 0.5, 0.5); -pub const PLAINS: Biome = Biome::new(1, 0.8, 0.4); -pub const DESERT: Biome = Biome::new(2, 2.0, 0.0); -pub const EXTREME_HILLS: Biome = Biome::new(3, 0.2, 0.3); -pub const FOREST: Biome = Biome::new(4, 0.7, 0.8); -pub const TAIGA: Biome = Biome::new(5, 0.05, 0.8); -pub const SWAMPLAND: Biome = Biome::new(6, 0.8, 0.9); -pub const RIVER: Biome = Biome::new(7, 0.5, 0.5); -pub const HELL: Biome = Biome::new(8, 2.0, 0.0); -pub const THE_END: Biome = Biome::new(9, 0.5, 0.5); -pub const FROZEN_OCEAN: Biome = Biome::new(10, 0.0, 0.5); -pub const FROZEN_RIVER: Biome = Biome::new(11, 0.0, 0.5); -pub const ICE_PLAINS: Biome = Biome::new(12, 0.0, 0.5); -pub const ICE_MOUNTAINS: Biome = Biome::new(13, 0.0, 0.5); -pub const MUSHROOM_ISLAND: Biome = Biome::new(14, 0.9, 1.0); -pub const MUSHROOM_ISLAND_SHORE: Biome = Biome::new(15, 0.9, 1.0); -pub const BEACH: Biome = Biome::new(16, 0.8, 0.4); -pub const DESERT_HILLS: Biome = Biome::new(17, 2.0, 0.0); -pub const FOREST_HILLS: Biome = Biome::new(18, 0.7, 0.8); -pub const TAIGA_HILLS: Biome = Biome::new(19, 0.2, 0.7); -pub const EXTREME_HILLS_EDGE: Biome = Biome::new(20, 0.2, 0.3); -pub const JUNGLE: Biome = Biome::new(21, 1.2, 0.9); -pub const JUNGLE_HILLS: Biome = Biome::new(22, 1.2, 0.9); -pub const JUNGLE_EDGE: Biome = Biome::new(23, 0.95, 0.8); -pub const DEEP_OCEAN: Biome = Biome::new(24, 0.5, 0.5); -pub const STONE_BEACH: Biome = Biome::new(25, 0.2, 0.3); -pub const COLD_BEACH: Biome = Biome::new(26, 0.05, 0.3); -pub const BIRCH_FOREST: Biome = Biome::new(27, 0.6, 0.6); -pub const BIRCH_FOREST_HILLS: Biome = Biome::new(28, 0.6, 0.6); -pub const ROOFED_FOREST: Biome = Biome::new(29, 0.7, 0.8); -pub const COLD_TAIGA: Biome = Biome::new(30, -0.5, 0.4); -pub const COLD_TAIGA_HILLS: Biome = Biome::new(31, -0.5, 0.4); -pub const MEGA_TAIGA: Biome = Biome::new(32, 0.3, 0.8); -pub const MEGA_TAIGA_HILLS: Biome = Biome::new(33, 0.3, 0.8); -pub const EXTREME_HILLS_PLUS: Biome = Biome::new(34, 0.2, 0.3); -pub const SAVANNA: Biome = Biome::new(35, 1.2, 0.0); -pub const SAVANNA_PLATEAU: Biome = Biome::new(36, 1.0, 0.0); -pub const MESA: Biome = Biome::new(37, 2.0, 0.0); -pub const MESA_PLATEAU_FOREST: Biome = Biome::new(38, 2.0, 0.0); -pub const MESA_PLATEAU: Biome = Biome::new(39, 2.0, 0.0); +pub const OCEAN: Biome = Biome::new(0, 50, 50); +pub const PLAINS: Biome = Biome::new(1, 80, 40); +pub const DESERT: Biome = Biome::new(2, 200, 0); +pub const EXTREME_HILLS: Biome = Biome::new(3, 20, 30); +pub const FOREST: Biome = Biome::new(4, 70, 80); +pub const TAIGA: Biome = Biome::new(5, 5, 80); +pub const SWAMPLAND: Biome = Biome::new(6, 80, 90); +pub const RIVER: Biome = Biome::new(7, 50, 50); +pub const HELL: Biome = Biome::new(8, 200, 0); +pub const THE_END: Biome = Biome::new(9, 50, 50); +pub const FROZEN_OCEAN: Biome = Biome::new(10, 0, 50); +pub const FROZEN_RIVER: Biome = Biome::new(11, 0, 50); +pub const ICE_PLAINS: Biome = Biome::new(12, 0, 50); +pub const ICE_MOUNTAINS: Biome = Biome::new(13, 0, 50); +pub const MUSHROOM_ISLAND: Biome = Biome::new(14, 90, 100); +pub const MUSHROOM_ISLAND_SHORE: Biome = Biome::new(15, 90, 100); +pub const BEACH: Biome = Biome::new(16, 80, 40); +pub const DESERT_HILLS: Biome = Biome::new(17, 200, 0); +pub const FOREST_HILLS: Biome = Biome::new(18, 70, 80); +pub const TAIGA_HILLS: Biome = Biome::new(19, 20, 70); +pub const EXTREME_HILLS_EDGE: Biome = Biome::new(20, 20, 30); +pub const JUNGLE: Biome = Biome::new(21, 120, 90); +pub const JUNGLE_HILLS: Biome = Biome::new(22, 120, 90); +pub const JUNGLE_EDGE: Biome = Biome::new(23, 95, 80); +pub const DEEP_OCEAN: Biome = Biome::new(24, 50, 50); +pub const STONE_BEACH: Biome = Biome::new(25, 20, 30); +pub const COLD_BEACH: Biome = Biome::new(26, 5, 30); +pub const BIRCH_FOREST: Biome = Biome::new(27, 60, 60); +pub const BIRCH_FOREST_HILLS: Biome = Biome::new(28, 60, 60); +pub const ROOFED_FOREST: Biome = Biome::new(29, 70, 80); +pub const COLD_TAIGA: Biome = Biome::new(30, -50, 40); +pub const COLD_TAIGA_HILLS: Biome = Biome::new(31, -50, 40); +pub const MEGA_TAIGA: Biome = Biome::new(32, 30, 80); +pub const MEGA_TAIGA_HILLS: Biome = Biome::new(33, 30, 80); +pub const EXTREME_HILLS_PLUS: Biome = Biome::new(34, 20, 30); +pub const SAVANNA: Biome = Biome::new(35, 120, 0); +pub const SAVANNA_PLATEAU: Biome = Biome::new(36, 100, 0); +pub const MESA: Biome = Biome::new(37, 200, 0); +pub const MESA_PLATEAU_FOREST: Biome = Biome::new(38, 200, 0); +pub const MESA_PLATEAU: Biome = Biome::new(39, 200, 0); -pub const SUNFLOWER_PLAINS: Biome = Biome::new(129, 0.8, 0.4); -pub const DESERT_MOUNTAIN: Biome = Biome::new(130, 2.0, 0.0); -pub const EXTREME_HILLS_MOUNTAINS: Biome = Biome::new(131, 0.2, 0.3); -pub const FLOWER_FOREST: Biome = Biome::new(132, 0.7, 0.8); -pub const TAIGA_M: Biome = Biome::new(133, 0.05, 0.8); -pub const SWAMPLAND_MOUNTAINS: Biome = Biome::new(134, 0.8, 0.9); -pub const ICE_PLAINS_SPIKES: Biome = Biome::new(140, 0.0, 0.5); -pub const JUNGLE_MOUNTAINS: Biome = Biome::new(149, 1.2, 0.9); -pub const JUNGLE_EDGE_MOUNTAINS: Biome = Biome::new(151, 0.95, 0.8); -pub const BIRCH_FOREST_MOUNTAINS: Biome = Biome::new(155, 0.6, 0.6); -pub const BIRCH_FOREST_HILLS_MOUNTAINS: Biome = Biome::new(156, 0.6, 0.6); -pub const ROOFED_FOREST_MOUNTAINS: Biome = Biome::new(157, 0.7, 0.8); -pub const COLD_TAIGA_MOUNTAINS: Biome = Biome::new(158, -0.5, 0.4); -pub const MEGA_SPRUCE_TAIGA: Biome = Biome::new(160, 0.25, 0.8); -pub const MEGA_SPRUCE_TAIGA_HILLS: Biome = Biome::new(161, 0.3, 0.8); -pub const EXTREME_HILLS_PLUS_MOUNTAINS: Biome = Biome::new(162, 0.2, 0.3); -pub const SAVANNA_MOUNTAINS: Biome = Biome::new(163, 1.2, 0.0); -pub const SAVANNA_PLATEAU_MOUNTAINS: Biome = Biome::new(164, 1.0, 0.0); -pub const MESA_BRYCE: Biome = Biome::new(165, 2.0, 0.0); -pub const MESA_PLATEAU_FOREST_MOUNTAINS: Biome = Biome::new(166, 2.0, 0.0); -pub const MESA_PLATEAU_MOUNTAINS: Biome = Biome::new(167, 2.0, 0.0); +pub const SUNFLOWER_PLAINS: Biome = Biome::new(129, 80, 40); +pub const DESERT_MOUNTAIN: Biome = Biome::new(130, 200, 0); +pub const EXTREME_HILLS_MOUNTAINS: Biome = Biome::new(131, 20, 30); +pub const FLOWER_FOREST: Biome = Biome::new(132, 70, 80); +pub const TAIGA_M: Biome = Biome::new(133, 5, 80); +pub const SWAMPLAND_MOUNTAINS: Biome = Biome::new(134, 80, 90); +pub const ICE_PLAINS_SPIKES: Biome = Biome::new(140, 0, 50); +pub const JUNGLE_MOUNTAINS: Biome = Biome::new(149, 120, 90); +pub const JUNGLE_EDGE_MOUNTAINS: Biome = Biome::new(151, 95, 80); +pub const BIRCH_FOREST_MOUNTAINS: Biome = Biome::new(155, 60, 60); +pub const BIRCH_FOREST_HILLS_MOUNTAINS: Biome = Biome::new(156, 60, 60); +pub const ROOFED_FOREST_MOUNTAINS: Biome = Biome::new(157, 70, 80); +pub const COLD_TAIGA_MOUNTAINS: Biome = Biome::new(158, -50, 40); +pub const MEGA_SPRUCE_TAIGA: Biome = Biome::new(160, 25, 80); +pub const MEGA_SPRUCE_TAIGA_HILLS: Biome = Biome::new(161, 30, 80); +pub const EXTREME_HILLS_PLUS_MOUNTAINS: Biome = Biome::new(162, 20, 30); +pub const SAVANNA_MOUNTAINS: Biome = Biome::new(163, 120, 0); +pub const SAVANNA_PLATEAU_MOUNTAINS: Biome = Biome::new(164, 100, 0); +pub const MESA_BRYCE: Biome = Biome::new(165, 200, 0); +pub const MESA_PLATEAU_FOREST_MOUNTAINS: Biome = Biome::new(166, 200, 0); +pub const MESA_PLATEAU_MOUNTAINS: Biome = Biome::new(167, 200, 0); -pub const INVALID: Biome = Biome::new(255, 0.0, 0.0); +pub const INVALID: Biome = Biome::new(255, 0, 0); }