Skip to content

Commit

Permalink
WIP rustup
Browse files Browse the repository at this point in the history
  • Loading branch information
bfops committed May 21, 2017
1 parent bf71fd5 commit f1b6a0c
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 70 deletions.
32 changes: 16 additions & 16 deletions client/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ name = "client_lib"
path = "src/mod.rs"

[dependencies]
bincode = "*"
cgmath = "0.12.*"
collision = "*"
fnv = "*"
gl = "0.5.*"
hound = "*"
libc = "*"
log = "*"
num = "*"
portaudio = "*"
rand = "*"
rustc-serialize = "*"
sdl2 = "0.22.*"
sdl2-sys = "0.22.*"
thread-scoped = "*"
time = "*"
bincode = "*"
cgmath = "0.12.*"
collision = "0.10.*"
fnv = "*"
gl = "0.5.*"
hound = "*"
libc = "*"
log = "*"
num = "*"
portaudio = "*"
rand = "*"
sdl2 = "0.22.*"
sdl2-sys = "0.22.*"
serde = "*"
thread-scoped = "*"
time = "*"

[dependencies.image]
version = "*"
Expand Down
9 changes: 4 additions & 5 deletions client/lib/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ pub mod send {

impl T {
pub fn tell(&self, msg: &protocol::ClientToServer) {
use bincode::rustc_serialize::encode;
use bincode::SizeLimit;
let msg = encode(msg, SizeLimit::Infinite).unwrap();
use bincode::serialize;
let msg = serialize(msg, bincode::Infinite).unwrap();
*self.bytes_sent.lock().unwrap() += msg.len() as u64;
self.sender.send(msg).unwrap();
}
Expand All @@ -50,7 +49,7 @@ pub mod recv {
impl T {
pub fn try(&self) -> Option<protocol::ServerToClient> {
match self.0.try_recv() {
Ok(msg) => Some(bincode::rustc_serialize::decode(&msg).unwrap()),
Ok(msg) => Some(bincode::deserialize(&msg).unwrap()),
Err(TryRecvError::Empty) => None,
e => {
e.unwrap();
Expand All @@ -61,7 +60,7 @@ pub mod recv {

pub fn wait(&self) -> protocol::ServerToClient {
let msg = self.0.recv().unwrap();
bincode::rustc_serialize::decode(msg.as_ref()).unwrap()
bincode::deserialize(msg.as_ref()).unwrap()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/lib/src/terrain_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use terrain_mesh;
use view;
use view::chunked_terrain;

#[derive(Debug, Copy, Clone, RustcEncodable, RustcDecodable)]
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
/// [T; 3], but serializable.
pub struct Triangle<T> {
#[allow(missing_docs)]
Expand Down
2 changes: 1 addition & 1 deletion client/lib/src/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl ColoredVertex {
}
}

#[derive(Debug, Clone, Copy, PartialEq, RustcEncodable, RustcDecodable)]
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
/// A point in the world with corresponding texture data.
///
/// The texture position is [0, 1].
Expand Down
4 changes: 2 additions & 2 deletions client/lib/src/view/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
mod types {
#[allow(missing_docs)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct Terrain;

#[allow(missing_docs)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct Grass;
}

Expand Down
16 changes: 8 additions & 8 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ name = "common"
path = "mod.rs"

[dependencies]
cgmath = "0.12.*"
collision = "*"
fnv = "*"
log = "*"
nanomsg = "*"
num = "*"
rustc-serialize = "*"
time = "*"
cgmath = "0.12.*"
collision = "0.10.*"
fnv = "*"
log = "*"
nanomsg = "*"
num = "*"
serde = "*"
time = "*"

[dependencies.stopwatch]
git = "https://github.com/bfops/stopwatch-rs"
Expand Down
6 changes: 3 additions & 3 deletions common/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
/// Phantom types to use with `id`.
mod types {
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct Player;

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct Mob;
}

Expand All @@ -14,7 +14,7 @@ pub mod id {
use std;

#[allow(missing_docs)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct T<U> {
units: std::marker::PhantomData<U>,
value: u32,
Expand Down
10 changes: 5 additions & 5 deletions common/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::ops::Add;
use entity;
use voxel;

#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)]
/// Unique client ID.
pub struct ClientId(u32);

Expand All @@ -27,7 +27,7 @@ impl Add<u32> for ClientId {
}
}

#[derive(Debug, Clone, RustcEncodable, RustcDecodable)]
#[derive(Debug, Clone, Serialize, Deserialize)]
/// Messages the client sends to the server.
pub enum ClientToServer {
/// Notify the server that the client exists, and provide a "return address".
Expand Down Expand Up @@ -60,7 +60,7 @@ pub enum ClientToServer {
}

/// Why a block is being sent to a client.
#[derive(Debug, Clone, RustcEncodable, RustcDecodable)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum VoxelReason {
/// The client asked for it.
Requested {
Expand All @@ -71,15 +71,15 @@ pub enum VoxelReason {
Updated,
}

#[derive(Debug, Clone, RustcEncodable, RustcDecodable)]
#[derive(Debug, Clone, Serialize, Deserialize)]
/// Collision events. First ID is "collider", rest of IDs are collidee(s).
#[allow(missing_docs)]
pub enum Collision {
PlayerTerrain(entity::id::Player),
PlayerMisc(entity::id::Player),
}

#[derive(Debug, Clone, RustcEncodable, RustcDecodable)]
#[derive(Debug, Clone, Serialize, Deserialize)]
/// Messages the server sends to the client.
pub enum ServerToClient {
/// Provide the client a unique id to tag its messages.
Expand Down
2 changes: 1 addition & 1 deletion common/voxel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub use voxel_data::impls::surface_vertex::unwrap;
#[allow(missing_docs)]
pub type T = voxel_data::impls::surface_vertex::T<Material>;

#[derive(Debug, Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[allow(missing_docs)]
/// Terrain materials
pub enum Material {
Expand Down
20 changes: 10 additions & 10 deletions server/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ name = "server_lib"
path = "./src/mod.rs"

[dependencies]
bincode = "*"
cgmath = "0.12.*"
collision = "*"
log = "*"
nanomsg = "*"
num = "*"
rand = "*"
rustc-serialize = "*"
thread-scoped = "*"
time = "*"
bincode = "*"
cgmath = "0.12.*"
collision = "0.10.*"
log = "*"
nanomsg = "*"
num = "*"
rand = "*"
serde = "*"
thread-scoped = "*"
time = "*"

[dependencies.playform-common]
path = "../../common"
Expand Down
4 changes: 2 additions & 2 deletions server/lib/src/entity.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
mod types {
#[allow(missing_docs)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct Terrain;

#[allow(missing_docs)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct Misc;
}

Expand Down
2 changes: 1 addition & 1 deletion server/lib/src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use update_world::load_placeholders;
const MAX_JUMP_FUEL: u32 = 4;
const MAX_STEP_HEIGHT: f32 = 1.0;

#[derive(Debug, Clone, RustcEncodable, RustcDecodable)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Collision {
Terrain(entity::id::Terrain),
Misc(entity::id::Misc),
Expand Down
10 changes: 5 additions & 5 deletions server/lib/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ fn network_listen<'a, ToGaia>(
common::socket::Result::Empty => closure_series::Continue,
common::socket::Result::Terminating => closure_series::Quit,
common::socket::Result::Success(up) => {
let up = bincode::rustc_serialize::decode(up.as_ref()).unwrap();
let up = bincode::deserialize(up.as_ref()).unwrap();
apply_client_update(server, &mut to_gaia, up);
closure_series::Restart
},
Expand Down Expand Up @@ -182,9 +182,9 @@ fn load_terrain(terrain: &terrain::T, path: &std::path::Path) {
Ok(file) => file,
};
let loaded =
bincode::rustc_serialize::decode_from(
bincode::deserialize_from(
&mut file,
bincode::SizeLimit::Infinite,
bincode::Infinite,
);
let loaded =
match loaded {
Expand All @@ -199,10 +199,10 @@ fn load_terrain(terrain: &terrain::T, path: &std::path::Path) {

fn save_terrain(terrain: &terrain::T, path: &std::path::Path) {
let mut file = std::fs::File::create(path).unwrap();
bincode::rustc_serialize::encode_into(
bincode::serialize_into(
&*terrain.voxels.lock().unwrap(),
&mut file,
bincode::SizeLimit::Infinite,
bincode::Infinite,
).unwrap();
}

Expand Down
4 changes: 2 additions & 2 deletions server/lib/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ pub struct Client {
impl Client {
pub fn send(&mut self, msg: protocol::ServerToClient) {
use bincode::SizeLimit;
use bincode::rustc_serialize::encode;
let msg = encode(&msg, SizeLimit::Infinite).unwrap();
use bincode::serialize;
let msg = serialize(&msg, SizeLimit::Infinite).unwrap();
match self.socket.write(msg.as_ref()) {
Ok(()) => {},
Err(err) => warn!("Error sending to client: {:?}", err),
Expand Down
16 changes: 8 additions & 8 deletions server/lib/terrain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ name = "terrain"
path = "mod.rs"

[dependencies]
cgmath = "0.12.*"
collision = "*"
fnv = "*"
log = "*"
cgmath = "0.12.*"
collision = "0.10.*"
fnv = "*"
log = "*"
lru-cache = "*"
rand = "*"
time = "*"
noise = "0.1.5"
num = "*"
rand = "*"
time = "*"
noise = "0.1.5"
num = "*"

[dependencies.playform-common]
path = "../../../common"
Expand Down

0 comments on commit f1b6a0c

Please sign in to comment.