ice_iix 2018-09-30 19:05:20 -07:00
parent c688836a16
commit d2b59fbd10
7 changed files with 61 additions and 15 deletions

30
Cargo.lock generated
View File

@ -78,6 +78,14 @@ dependencies = [
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cloudabi"
version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "collision"
version = "0.5.1"
@ -654,6 +662,23 @@ dependencies = [
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_core"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rayon"
version = "1.0.2"
@ -782,7 +807,7 @@ dependencies = [
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"sdl2 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1021,6 +1046,7 @@ dependencies = [
"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16"
"checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3"
"checksum cgmath 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75e93b3eb66e74ffb946a69ff54c6026c1399960241c843f249ea0127b96b9f6"
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
"checksum collision 0.5.1 (git+https://github.com/TheUnnamedDude/collision-rs?rev=f80825e)" = "<none>"
"checksum color_quant 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0dbbb57365263e881e805dc77d94697c9118fd94d8da011240555aa7b23445bd"
"checksum cookie 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0e3d6405328b6edb412158b3b7710e2634e23f3614b9bb1c412df7952489a626"
@ -1090,6 +1116,8 @@ dependencies = [
"checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5"
"checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1"
"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd"
"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c"
"checksum rand_core 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "edecf0f94da5551fc9b492093e30b041a891657db7940ee221f9d2f66e82eef2"
"checksum rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "df7a791f788cb4c516f0e091301a29c2b71ef680db5e644a7d68835c8ae6dbfa"
"checksum rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b055d1e92aba6877574d8fe604a63c8b5df60f60e5982bf7ccbb1338ea527356"
"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1"

View File

@ -19,7 +19,7 @@ serde_json = "0.7.0"
flate2 = "1.0.2"
zip = "0.4.2"
image = "0.20.0"
rand = "0.3.14"
rand = "0.5.5"
hex = "0.3.2"
base64 = "0.9.3"
log = "0.4.5"

View File

@ -109,7 +109,7 @@ struct BuildReply {
}
fn build_func(id: usize, models: Arc<RwLock<model::Factory>>, work_recv: mpsc::Receiver<BuildReq>, built_send: mpsc::Sender<(usize, BuildReply)>) {
use rand::{self, Rng, SeedableRng};
use rand::{self, SeedableRng, Rng};
loop {
let BuildReq {
snapshot,
@ -122,10 +122,25 @@ fn build_func(id: usize, models: Arc<RwLock<model::Factory>>, work_recv: mpsc::R
};
let mut rng = rand::XorShiftRng::from_seed([
position.0 as u32,
position.1 as u32,
position.2 as u32,
(position.0 as u32 ^ position.2 as u32) | 1,
((position.0 as u32) & 0xff) as u8,
(((position.0 as u32) >> 8) & 0xff) as u8,
(((position.0 as u32) >> 16) & 0xff) as u8,
((position.0 as u32) >> 24) as u8,
((position.1 as u32) & 0xff) as u8,
(((position.1 as u32) >> 8) & 0xff) as u8,
(((position.1 as u32) >> 16) & 0xff) as u8,
((position.1 as u32) >> 24) as u8,
((position.2 as u32) & 0xff) as u8,
(((position.2 as u32) >> 8) & 0xff) as u8,
(((position.2 as u32) >> 16) & 0xff) as u8,
((position.2 as u32) >> 24) as u8,
(((position.0 as u32 ^ position.2 as u32) | 1) & 0xff) as u8,
((((position.0 as u32 ^ position.2 as u32) | 1) >> 8) & 0xff) as u8,
((((position.0 as u32 ^ position.2 as u32) | 1) >> 16) & 0xff) as u8,
(((position.0 as u32 ^ position.2 as u32) | 1) >> 24) as u8,
]);
let mut solid_count = 0;
@ -140,7 +155,7 @@ fn build_func(id: usize, models: Arc<RwLock<model::Factory>>, work_recv: mpsc::R
// Use one step of the rng so that
// if a block is placed in an empty
// location is variant doesn't change
rng.next_u32();
let _: u32 = rng.gen();
continue;
}

View File

@ -170,7 +170,10 @@ impl super::Screen for Login {
elements.login_btn_text.borrow_mut().text = "Logging in...".into();
let mut client_token = self.vars.get(auth::AUTH_CLIENT_TOKEN).clone();
if client_token.is_empty() {
client_token = rand::thread_rng().gen_ascii_chars().take(20).collect::<String>();
client_token = std::iter::repeat(()).map(|()| rand::thread_rng()
.sample(&rand::distributions::Alphanumeric))
.take(20)
.collect();
self.vars.set(auth::AUTH_CLIENT_TOKEN, client_token);
}
let client_token = self.vars.get(auth::AUTH_CLIENT_TOKEN).clone();

View File

@ -496,10 +496,10 @@ impl super::Screen for ServerList {
s.version.borrow_mut().set_text(msg);
}
if let Some(favicon) = res.favicon {
let name: String = rand::thread_rng()
.gen_ascii_chars()
.take(30)
.collect();
let name: String = std::iter::repeat(()).map(|()| rand::thread_rng()
.sample(&rand::distributions::Alphanumeric))
.take(30)
.collect();
let tex = renderer.get_textures_ref();
s.icon_texture = Some(name.clone());
let icon_tex = tex.write()

View File

@ -216,7 +216,7 @@ impl Server {
}
server.world.set_block(Position::new(x, h, z), block::Grass{ snowy: false });
if x*x + z*z > 16*16 && rng.gen_weighted_bool(80) {
if x*x + z*z > 16*16 && rng.gen_bool(1.0 / 80.0) {
for i in 0 .. 5 {
server.world.set_block(Position::new(x, h + 1 + i, z), block::Log{ axis: Axis::Y, variant: block::TreeVariant::Oak });
}

View File

@ -101,7 +101,7 @@ impl Logo {
text_strings.push(line.to_owned().replace("\r", ""));
}
}
let mut r: rand::XorShiftRng = rand::SeedableRng::from_seed([45, 64, 32, 12]);
let mut r: rand::XorShiftRng = rand::SeedableRng::from_seed([45, 0, 0, 0, 64, 0, 0, 0, 32, 0, 0, 0, 12, 0, 0, 0]);
r.shuffle(&mut text_strings[..]);
}