From fde8695bbca220e5af85344a7da23bea0f6513b6 Mon Sep 17 00:00:00 2001 From: troido Date: Mon, 27 Jan 2020 23:01:26 +0100 Subject: cleanup! --- src/main.rs | 53 ----------------------------------------------------- 1 file changed, 53 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index b6ec8b7..97283d0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,18 +3,15 @@ use std::thread::sleep; use std::time::Duration; use std::path::Path; -// use std::net::SocketAddr; pub mod server; pub mod gameserver; -// pub mod simpleworld; pub mod room; use self::gameserver::GameServer; use self::server::unixserver::UnixServer; use self::server::tcpserver::TcpServer; use self::server::Server; -// use self::simpleworld::{Room, Pos, GameObject}; use json; @@ -32,57 +29,20 @@ fn main() { let servers: Vec> = vec![Box::new(unixserver), Box::new(inetserver)]; let mut gameserver = GameServer::new(servers); -// println!("listening on {:?}", addr); - -// let mut players: HashMap = HashMap::new(); - -// let (mut world, dispatcher) = room::make_room((32, 32)); - let mut room = room::Room::new((32, 32)); -// dispatcher.dispatch(&mut world); -// world.maintain(); - -// let mut world = generate_world(32, 32); loop { let _actions = gameserver.update(); room.update(); let (field, mapping) = room.view(); let updatemsg = create_update_message(room.get_size(), field, mapping); -// dispatcher.dispatch(&mut world); -// world.maintain(); -// let topview = *world.fetch::(); let _ = gameserver.broadcast_json(updatemsg); -// update(&mut gameserver, &mut world); sleep(Duration::from_millis(100)); } } -// fn generate_world(width: i32, height: i32) -> Room { -// -// let mut world = Room::new((Pos(0,0), Pos(width, height))); -// let grass = GameObject::new("grass1"); -// let wall = GameObject::new("wall"); -// for x in 0..width { -// world.add_obj(Pos(x, 0), wall.clone()); -// world.add_obj(Pos(x, height -1), wall.clone()); -// } -// for y in 1..height { -// world.add_obj(Pos(0, y), wall.clone()); -// world.add_obj(Pos(width -1, y), wall.clone()); -// } -// for x in 10..20 { -// for y in 15 .. 25 { -// let pos = Pos(x, y); -// world.add_obj(pos, grass.clone()); -// } -// } -// world -// } - - fn create_update_message((width, height): (i32, i32), field: Vec, mapping: Vec>) -> json::JsonValue { let mut updatemsg: json::JsonValue = json::array![ "world", @@ -92,8 +52,6 @@ fn create_update_message((width, height): (i32, i32), field: Vec, mapping json::object!{ "width" => width, "height" => height, -// "field" => jfield, -// "mapping" => json::from(mapping) } ] ] @@ -102,14 +60,3 @@ fn create_update_message((width, height): (i32, i32), field: Vec, mapping updatemsg[1][0][1]["mapping"] = json::from(mapping); updatemsg } - -// fn update(gameserver: &mut GameServer, world: &mut Room) { -// let actions = gameserver.update(); -// for action in actions { -// println!("a {:?}", action); -// } -// let (_start, Pos(width, height)) = world.area; -// let (field, mapping) = world.draw(); -// // let jfield = json::from(field); -// let _ = gameserver.broadcast_json(updatemsg); -// } -- cgit