From 42861541cfa845f149607619a9504b3381d3db58 Mon Sep 17 00:00:00 2001 From: tommy Date: Fri, 12 Jul 2019 17:16:07 -0400 Subject: [PATCH 01/21] Updates based on code review #183 --- server/src/cmd.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 9ed396771b..f8536da0fd 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -118,6 +118,12 @@ lazy_static! { "/build : Toggles build mode on and off", handle_build, ), + ChatCommand::new( + "killnpcs", + "{}", + "/killnpcs : Kill the NPCs", + handle_killnpcs, + ), ]; } @@ -407,3 +413,26 @@ fn kind_to_body(kind: NpcKind) -> comp::Body { NpcKind::Wolf => comp::Body::QuadrupedMedium(comp::quadruped_medium::Body::random()), } } + +fn handle_killnpcs(server: &mut Server, entity: EcsEntity, _args: String, _action: &ChatCommand) { + let ecs = server.state.ecs(); + let mut npclist=Vec::new(); + { + // get the npc list, scope read access to prevent + // 'Already borrowed: InvalidBorrow' error when setting health stat + let entities = ecs.entities(); + let stats = ecs.read_storage::(); + let players = ecs.read_storage::(); + for (npc,stat,()) in (&entities,&stats,!&players).join() { + npclist.push((npc,stat.name.clone())); + } + } + for npc in npclist { + let mut text = npc.1.clone(); + text += " is no more."; + server.clients.notify(entity, ServerMsg::Chat(text)); + ecs.write_storage::() + .get_mut(npc.0) + .map(|s| s.health.set_to(0, comp::HealthSource::Command)); + } +} From 3c9046c5d036d8793a8700145735f44e5cd617ae Mon Sep 17 00:00:00 2001 From: tommy Date: Fri, 12 Jul 2019 17:43:20 -0400 Subject: [PATCH 02/21] rustfmt updates --- server/src/cmd.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/src/cmd.rs b/server/src/cmd.rs index f8536da0fd..5e09c63459 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -416,15 +416,15 @@ fn kind_to_body(kind: NpcKind) -> comp::Body { fn handle_killnpcs(server: &mut Server, entity: EcsEntity, _args: String, _action: &ChatCommand) { let ecs = server.state.ecs(); - let mut npclist=Vec::new(); + let mut npclist = Vec::new(); { // get the npc list, scope read access to prevent // 'Already borrowed: InvalidBorrow' error when setting health stat let entities = ecs.entities(); let stats = ecs.read_storage::(); let players = ecs.read_storage::(); - for (npc,stat,()) in (&entities,&stats,!&players).join() { - npclist.push((npc,stat.name.clone())); + for (npc, stat, ()) in (&entities, &stats, !&players).join() { + npclist.push((npc, stat.name.clone())); } } for npc in npclist { @@ -432,7 +432,7 @@ fn handle_killnpcs(server: &mut Server, entity: EcsEntity, _args: String, _actio text += " is no more."; server.clients.notify(entity, ServerMsg::Chat(text)); ecs.write_storage::() - .get_mut(npc.0) - .map(|s| s.health.set_to(0, comp::HealthSource::Command)); + .get_mut(npc.0) + .map(|s| s.health.set_to(0, comp::HealthSource::Command)); } } From f15194b6f8100fea1ecbf098fb8be1a8543c2f0d Mon Sep 17 00:00:00 2001 From: tommy Date: Fri, 12 Jul 2019 20:26:17 -0400 Subject: [PATCH 03/21] Save the server index when it changes #187 --- voxygen/src/menu/main/ui.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/voxygen/src/menu/main/ui.rs b/voxygen/src/menu/main/ui.rs index a5a53d11af..df366f802a 100644 --- a/voxygen/src/menu/main/ui.rs +++ b/voxygen/src/menu/main/ui.rs @@ -309,7 +309,7 @@ impl MainMenuUi { .w_h(400.0, 300.0) .set(self.ids.servers_frame, ui_widgets); - let net_settings = &global_state.settings.networking; + let ref mut net_settings = global_state.settings.networking; // TODO: Draw scroll bar or remove it. let (mut items, _scrollbar) = List::flow_down(net_settings.servers.len()) @@ -346,6 +346,7 @@ impl MainMenuUi { { // TODO: Set as current server address self.server_address = net_settings.servers[item.i].clone(); + net_settings.default_server = item.i; } } From 19ff8366767dbb15a6b7239b1af9244e4fc78e0d Mon Sep 17 00:00:00 2001 From: tommy Date: Sat, 13 Jul 2019 08:41:50 -0400 Subject: [PATCH 04/21] Remove TODO --- voxygen/src/menu/main/ui.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/voxygen/src/menu/main/ui.rs b/voxygen/src/menu/main/ui.rs index df366f802a..5af6f9326f 100644 --- a/voxygen/src/menu/main/ui.rs +++ b/voxygen/src/menu/main/ui.rs @@ -344,7 +344,6 @@ impl MainMenuUi { ) .was_clicked() { - // TODO: Set as current server address self.server_address = net_settings.servers[item.i].clone(); net_settings.default_server = item.i; } From ff6a72bc406cdcbc2f09ce584725d9d885cc8d65 Mon Sep 17 00:00:00 2001 From: Monty Marz Date: Sun, 14 Jul 2019 14:34:47 +0000 Subject: [PATCH 05/21] New orc head models --- assets/voxygen/element/icons/orc_f.png | 4 ++-- assets/voxygen/element/icons/orc_m.png | 4 ++-- .../voxygen/voxel/figure/head/head_dwarf_female.vox | 4 ++-- .../voxygen/voxel/figure/head/head_human_female.vox | 4 ++-- assets/voxygen/voxel/figure/head/head_human_male.vox | 4 ++-- assets/voxygen/voxel/figure/head/head_orc_female.vox | 4 ++-- assets/voxygen/voxel/figure/head/head_orc_male.vox | 4 ++-- voxygen/src/anim/mod.rs | 12 ++++++------ voxygen/src/scene/figure.rs | 6 +++--- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/assets/voxygen/element/icons/orc_f.png b/assets/voxygen/element/icons/orc_f.png index bd155430df..15ecba956f 100644 --- a/assets/voxygen/element/icons/orc_f.png +++ b/assets/voxygen/element/icons/orc_f.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:73efdffea6355bcebce5c4e5380d77cfe764b4765dde3b3a484cead7ff2ba2d9 -size 17556 +oid sha256:5efae53235c444df2b8002b82bb10bd9df2d9473c82f2018dd5715c7bdffa96b +size 18594 diff --git a/assets/voxygen/element/icons/orc_m.png b/assets/voxygen/element/icons/orc_m.png index 846dd9a672..2036e0e2fb 100644 --- a/assets/voxygen/element/icons/orc_m.png +++ b/assets/voxygen/element/icons/orc_m.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1f68b55eabff3fcdd914e07dbb6db112cbe019a814d536bab1be456cfbc69bae -size 19128 +oid sha256:e6dd5c5dc7a04233a70b55ba6f48b0e062aebbc1fcaf7ebde1edeeac366cd3d4 +size 15053 diff --git a/assets/voxygen/voxel/figure/head/head_dwarf_female.vox b/assets/voxygen/voxel/figure/head/head_dwarf_female.vox index 3a2f18e355..27c0fbd36f 100644 --- a/assets/voxygen/voxel/figure/head/head_dwarf_female.vox +++ b/assets/voxygen/voxel/figure/head/head_dwarf_female.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:70424ea32cc20f5101ce5d6877a37ceb67a1ae47509ef2710cab2c29b15c3109 -size 4392 +oid sha256:4140c55f76e6dad281b7bbe76037e0b0951caf375098892a1d1e59521e2d0514 +size 47499 diff --git a/assets/voxygen/voxel/figure/head/head_human_female.vox b/assets/voxygen/voxel/figure/head/head_human_female.vox index 9a33854f2d..9efc0277a4 100644 --- a/assets/voxygen/voxel/figure/head/head_human_female.vox +++ b/assets/voxygen/voxel/figure/head/head_human_female.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:808c77d7ed81aab362bc92a3d5273d1f836043127e3c0d8db7a5864aa58f44b7 -size 5168 +oid sha256:16c2d3311840711fbcacb9db74e1c2fba9c18703112e63717160be4d7ed85be1 +size 48275 diff --git a/assets/voxygen/voxel/figure/head/head_human_male.vox b/assets/voxygen/voxel/figure/head/head_human_male.vox index 8e42300a24..8b2d8c9dd9 100644 --- a/assets/voxygen/voxel/figure/head/head_human_male.vox +++ b/assets/voxygen/voxel/figure/head/head_human_male.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2ec795ccc978ba4ea8e35b0c585673dd89fe5b609f4b639808118fe7720203a9 -size 47244 +oid sha256:feb06650ac93a63318391a930fa6d6e2a07bec7300d8b9d76731259613cc4e65 +size 47204 diff --git a/assets/voxygen/voxel/figure/head/head_orc_female.vox b/assets/voxygen/voxel/figure/head/head_orc_female.vox index 31eb6b37b9..ffd88e1bf4 100644 --- a/assets/voxygen/voxel/figure/head/head_orc_female.vox +++ b/assets/voxygen/voxel/figure/head/head_orc_female.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cca256ad0e5e99dc97b5d6a0e3ad65f5a55a97417be4686a31122ca7539b988a -size 46891 +oid sha256:cb6052b4aff4df32ac57192332229ad0b740346e654c0d663d11fe4c6306dbb1 +size 47209 diff --git a/assets/voxygen/voxel/figure/head/head_orc_male.vox b/assets/voxygen/voxel/figure/head/head_orc_male.vox index 49e36869b0..98c1daa965 100644 --- a/assets/voxygen/voxel/figure/head/head_orc_male.vox +++ b/assets/voxygen/voxel/figure/head/head_orc_male.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:de5333722f1c5e018f6cffa3abd40283fd4dda574e50a5e8a7851a3a344633ae -size 46831 +oid sha256:88da79a8e2c9086e116721b23e823e75aae72ed05dceaa125177332f3836b2ae +size 46680 diff --git a/voxygen/src/anim/mod.rs b/voxygen/src/anim/mod.rs index 43fcb38fca..cb756fea9e 100644 --- a/voxygen/src/anim/mod.rs +++ b/voxygen/src/anim/mod.rs @@ -104,10 +104,10 @@ impl<'a> From<&'a comp::humanoid::Body> for SkeletonAttr { }, neck_height: match (body.race, body.body_type) { (Orc, Male) => -2.0, - (Orc, Female) => -2.0, - (Human, Male) => -0.5, + (Orc, Female) => 0.0, + (Human, Male) => -0.75, (Human, Female) => -2.0, - (Elf, Male) => -0.5, + (Elf, Male) => -0.75, (Elf, Female) => -1.25, (Dwarf, Male) => -0.0, (Dwarf, Female) => -1.0, @@ -117,11 +117,11 @@ impl<'a> From<&'a comp::humanoid::Body> for SkeletonAttr { (Danari, Female) => -0.5, }, neck_forward: match (body.race, body.body_type) { - (Orc, Male) => 1.0, - (Orc, Female) => -1.0, + (Orc, Male) => 0.0, + (Orc, Female) => -2.0, (Human, Male) => 0.0, (Human, Female) => -1.0, - (Elf, Male) => 1.25, + (Elf, Male) => 0.0, (Elf, Female) => -0.5, (Dwarf, Male) => 2.0, (Dwarf, Female) => 0.0, diff --git a/voxygen/src/scene/figure.rs b/voxygen/src/scene/figure.rs index 22a657da71..3107744615 100644 --- a/voxygen/src/scene/figure.rs +++ b/voxygen/src/scene/figure.rs @@ -153,7 +153,7 @@ impl FigureModelCache { let (name, offset) = match (race, body_type) { (Human, Male) => ( "figure/head/head_human_male.vox", - Vec3::new(-7.0, -5.5, -2.25), + Vec3::new(-7.0, -5.0, -2.25), ), (Human, Female) => ( "figure/head/head_human_female.vox", @@ -177,11 +177,11 @@ impl FigureModelCache { ), (Orc, Male) => ( "figure/head/head_orc_male.vox", - Vec3::new(-8.0, -6.0, -2.75), + Vec3::new(-8.0, -5.0, -2.50), ), (Orc, Female) => ( "figure/head/head_orc_female.vox", - Vec3::new(-8.0, -5.5, -2.75), + Vec3::new(-8.0, -8.0, -3.5), ), (Undead, Male) => ( "figure/head/head_undead_male.vox", From 52b65d5938cecffaf4367fa04d4fddae4104581e Mon Sep 17 00:00:00 2001 From: tommy Date: Sun, 14 Jul 2019 13:30:02 -0400 Subject: [PATCH 06/21] Stopped 'spammy' output --- server/src/cmd.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 5e09c63459..c8d44254a9 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -418,7 +418,7 @@ fn handle_killnpcs(server: &mut Server, entity: EcsEntity, _args: String, _actio let ecs = server.state.ecs(); let mut npclist = Vec::new(); { - // get the npc list, scope read access to prevent + // Get the npc list, scope read access to prevent // 'Already borrowed: InvalidBorrow' error when setting health stat let entities = ecs.entities(); let stats = ecs.read_storage::(); @@ -427,12 +427,16 @@ fn handle_killnpcs(server: &mut Server, entity: EcsEntity, _args: String, _actio npclist.push((npc, stat.name.clone())); } } - for npc in npclist { - let mut text = npc.1.clone(); - text += " is no more."; - server.clients.notify(entity, ServerMsg::Chat(text)); + for npc in &npclist { ecs.write_storage::() .get_mut(npc.0) .map(|s| s.health.set_to(0, comp::HealthSource::Command)); } + let text = if npclist.len() > 0 { + format!("Destroyed {} NPCs.",npclist.len()) + } + else { + "No NPCs on server.".to_string() + }; + server.clients.notify(entity, ServerMsg::Chat(text)); } From 6d8eea5085a379d3345685cbaa369e0d22c25810 Mon Sep 17 00:00:00 2001 From: tommy Date: Sun, 14 Jul 2019 13:39:27 -0400 Subject: [PATCH 07/21] rustfmt issues --- server/src/cmd.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/server/src/cmd.rs b/server/src/cmd.rs index c8d44254a9..5191111f6b 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -433,9 +433,8 @@ fn handle_killnpcs(server: &mut Server, entity: EcsEntity, _args: String, _actio .map(|s| s.health.set_to(0, comp::HealthSource::Command)); } let text = if npclist.len() > 0 { - format!("Destroyed {} NPCs.",npclist.len()) - } - else { + format!("Destroyed {} NPCs.", npclist.len()) + } else { "No NPCs on server.".to_string() }; server.clients.notify(entity, ServerMsg::Chat(text)); From bfa42dd33b1f3cd73d52920d8c4c76bb63e9d19b Mon Sep 17 00:00:00 2001 From: tommy Date: Sun, 14 Jul 2019 16:35:22 -0400 Subject: [PATCH 08/21] Incorporated changes from Imbris --- server/src/cmd.rs | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 5191111f6b..179aad9718 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -416,24 +416,15 @@ fn kind_to_body(kind: NpcKind) -> comp::Body { fn handle_killnpcs(server: &mut Server, entity: EcsEntity, _args: String, _action: &ChatCommand) { let ecs = server.state.ecs(); - let mut npclist = Vec::new(); - { - // Get the npc list, scope read access to prevent - // 'Already borrowed: InvalidBorrow' error when setting health stat - let entities = ecs.entities(); - let stats = ecs.read_storage::(); - let players = ecs.read_storage::(); - for (npc, stat, ()) in (&entities, &stats, !&players).join() { - npclist.push((npc, stat.name.clone())); - } + let mut stats = ecs.write_storage::(); + let players = ecs.write_storage::(); + let mut count = 0; + for (npc, ()) in (&mut stats, !&players).join() { + count += 1; + npc.health.set_to(0, comp::HealthSource::Command); } - for npc in &npclist { - ecs.write_storage::() - .get_mut(npc.0) - .map(|s| s.health.set_to(0, comp::HealthSource::Command)); - } - let text = if npclist.len() > 0 { - format!("Destroyed {} NPCs.", npclist.len()) + let text = if count > 0 { + format!("Destroyed {} NPCs.", count) } else { "No NPCs on server.".to_string() }; From 732eb9a0e8b1a5b66fe0b88df0c079b4c9178a95 Mon Sep 17 00:00:00 2001 From: tommy Date: Mon, 15 Jul 2019 13:10:24 -0400 Subject: [PATCH 09/21] Code review updates --- server/src/cmd.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 179aad9718..36de3bd704 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -417,11 +417,11 @@ fn kind_to_body(kind: NpcKind) -> comp::Body { fn handle_killnpcs(server: &mut Server, entity: EcsEntity, _args: String, _action: &ChatCommand) { let ecs = server.state.ecs(); let mut stats = ecs.write_storage::(); - let players = ecs.write_storage::(); + let players = ecs.read_storage::(); let mut count = 0; - for (npc, ()) in (&mut stats, !&players).join() { + for (stats, ()) in (&mut stats, !&players).join() { count += 1; - npc.health.set_to(0, comp::HealthSource::Command); + stats.health.set_to(0, comp::HealthSource::Command); } let text = if count > 0 { format!("Destroyed {} NPCs.", count) From 242cdbe6e577e7335f53c4a9c260babfcf67e7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Mon, 15 Jul 2019 19:42:13 +0200 Subject: [PATCH 10/21] Change the default port for the veloren server because the original server is unanvailable for a few days and the secondary server cannot use the default veloren port --- voxygen/src/settings.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index 3b5e5fdd85..fdee8ca795 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -101,7 +101,7 @@ impl Default for NetworkingSettings { fn default() -> Self { Self { username: "Username".to_string(), - servers: vec!["server.veloren.net".to_string()], + servers: vec!["server.veloren.net:38889".to_string()], default_server: 0, } } From b11bc46e09d117fa66a9f026c9d423f2e347e338 Mon Sep 17 00:00:00 2001 From: Acrimon Date: Mon, 15 Jul 2019 22:11:18 +0200 Subject: [PATCH 11/21] Update uvth in lockfile. --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b8cd8b3d56..463af2c31a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2688,7 +2688,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "uvth" -version = "3.1.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2731,7 +2731,7 @@ dependencies = [ "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "specs 0.14.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uvth 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "uvth 3.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "vek 0.9.8 (registry+https://github.com/rust-lang/crates.io-index)", "veloren-common 0.2.0", ] @@ -2768,7 +2768,7 @@ dependencies = [ "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "scan_fmt 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "specs 0.14.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uvth 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "uvth 3.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "vek 0.9.8 (registry+https://github.com/rust-lang/crates.io-index)", "veloren-common 0.2.0", "veloren-world 0.2.0", @@ -3329,7 +3329,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47" "checksum utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9d50aa7650df78abf942826607c62468ce18d9019673d4a2ebe1865dbb96ffde" -"checksum uvth 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "58dde8b476ec1613a6a233a0a472a1b9e4f61e779022028d795f7a49dcd0c311" +"checksum uvth 3.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e59a167890d173eb0fcd7a1b99b84dc05c521ae8d76599130b8e19bef287abbf" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum vek 0.9.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1c95e5c5c123ecdb4a1a27a590f053a6c6de4b6ea696f4f0ef99054ead450258" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" From 1213d9844b328528693092f060b8db34f25b0099 Mon Sep 17 00:00:00 2001 From: Songtronix Date: Sat, 29 Jun 2019 18:41:26 +0200 Subject: [PATCH 12/21] add customizable port and worldseed --- Cargo.lock | 5 +++- server-cli/Cargo.toml | 2 +- server-cli/src/main.rs | 9 +++++-- server/Cargo.toml | 4 +++ server/src/lib.rs | 16 +++++++----- server/src/settings.rs | 52 +++++++++++++++++++++++++++++++++++++ voxygen/src/singleplayer.rs | 4 +-- 7 files changed, 79 insertions(+), 13 deletions(-) create mode 100644 server/src/settings.rs diff --git a/Cargo.lock b/Cargo.lock index 463af2c31a..2e207bd8b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2765,8 +2765,11 @@ name = "veloren-server" version = "0.2.0" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "ron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "scan_fmt 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", "specs 0.14.3 (registry+https://github.com/rust-lang/crates.io-index)", "uvth 3.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "vek 0.9.8 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/server-cli/Cargo.toml b/server-cli/Cargo.toml index 62ad0c6368..7e32d07f5f 100644 --- a/server-cli/Cargo.toml +++ b/server-cli/Cargo.toml @@ -9,4 +9,4 @@ server = { package = "veloren-server", path = "../server" } common = { package = "veloren-common", path = "../common" } log = "0.4" -pretty_env_logger = "0.3" +pretty_env_logger = "0.3" \ No newline at end of file diff --git a/server-cli/src/main.rs b/server-cli/src/main.rs index d53aca5d91..41f4949812 100644 --- a/server-cli/src/main.rs +++ b/server-cli/src/main.rs @@ -1,6 +1,6 @@ use common::clock::Clock; use log::info; -use server::{Event, Input, Server}; +use server::{Event, Input, Server, ServerSettings}; use std::time::Duration; const TPS: u64 = 30; @@ -13,9 +13,12 @@ fn main() { // Set up an fps clock let mut clock = Clock::start(); + + // Load settings + let settings = ServerSettings::load(); // Create server - let mut server = Server::new().expect("Failed to create server instance!"); + let mut server = Server::new(settings).expect("Failed to create server instance!"); loop { let events = server @@ -36,4 +39,6 @@ fn main() { // Wait for the next tick. clock.tick(Duration::from_millis(1000 / TPS)); } + + //settings.save_to_file().expect("failed to save the settings!"); } diff --git a/server/Cargo.toml b/server/Cargo.toml index bd5ab709cc..7fed15056d 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -14,3 +14,7 @@ vek = "0.9" uvth = "3.1.0" lazy_static = "1.3.0" scan_fmt = "0.1.3" + +ron = "0.5.1" +serde = "1.0" +serde_derive = "1.0" \ No newline at end of file diff --git a/server/src/lib.rs b/server/src/lib.rs index a0afc058c2..3ba39b0c29 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -4,9 +4,10 @@ pub mod client; pub mod cmd; pub mod error; pub mod input; +pub mod settings; // Reexports -pub use crate::{error::Error, input::Input}; +pub use crate::{error::Error, input::Input, settings::ServerSettings}; use crate::{ client::{Client, Clients}, @@ -36,8 +37,6 @@ use world::World; const CLIENT_TIMEOUT: f64 = 20.0; // Seconds -const DEFAULT_WORLD_SEED: u32 = 1337; - pub enum Event { ClientConnected { entity: EcsEntity, @@ -66,19 +65,20 @@ pub struct Server { chunk_rx: mpsc::Receiver<(Vec2, TerrainChunk)>, pending_chunks: HashSet>, + server_settings: ServerSettings, server_info: ServerInfo, } impl Server { /// Create a new `Server` bound to the default socket. #[allow(dead_code)] - pub fn new() -> Result { - Self::bind(SocketAddr::from(([0; 4], 59003))) + pub fn new(settings: ServerSettings) -> Result { + Self::bind(settings.address, settings) } /// Create a new server bound to the given socket. #[allow(dead_code)] - pub fn bind>(addrs: A) -> Result { + pub fn bind>(addrs: A, settings: ServerSettings) -> Result { let (chunk_tx, chunk_rx) = mpsc::channel(); let mut state = State::default(); @@ -88,7 +88,7 @@ impl Server { let this = Self { state, - world: Arc::new(World::generate(DEFAULT_WORLD_SEED)), + world: Arc::new(World::generate(settings.world_seed)), postoffice: PostOffice::bind(addrs.into())?, clients: Clients::empty(), @@ -100,7 +100,9 @@ impl Server { chunk_rx, pending_chunks: HashSet::new(), + server_settings: settings, server_info: ServerInfo { + // TODO: get from settings name: "Server name".to_owned(), description: "This is the best Veloren server.".to_owned(), }, diff --git a/server/src/settings.rs b/server/src/settings.rs new file mode 100644 index 0000000000..41f32902b2 --- /dev/null +++ b/server/src/settings.rs @@ -0,0 +1,52 @@ +use serde_derive::{Deserialize, Serialize}; +use std::{fs, io::prelude::*, path::PathBuf, net::SocketAddr}; + +/// `ControlSettings` contains keybindings. +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(default)] +pub struct ServerSettings { + pub address: SocketAddr, + //pub max_players: u64, + pub world_seed: u32, + //pub pvp_enabled: bool, + //pub serverinfo: whatever + //pub login_server: whatever +} + +impl Default for ServerSettings { + fn default() -> Self { + Self { + address: SocketAddr::from(([0; 4], 59003)), + world_seed: 1337, + } + } +} + +impl ServerSettings { + pub fn load() -> Self { + let path = ServerSettings::get_settings_path(); + + // If file doesn't exist, use the default settings. + if let Ok(file) = fs::File::open(path) { + // TODO: Replace expect with returning default? + ron::de::from_reader(file).expect("Error parsing settings") + } else { + // TODO: temporary + Self::default().save_to_file().unwrap(); + Self::default() + } + } + + pub fn save_to_file(&self) -> std::io::Result<()> { + let path = ServerSettings::get_settings_path(); + let mut config_file = fs::File::create(path)?; + + let s: &str = &ron::ser::to_string_pretty(self, ron::ser::PrettyConfig::default()).unwrap(); + config_file.write_all(s.as_bytes()).unwrap(); + Ok(()) + } + + fn get_settings_path() -> PathBuf { + PathBuf::from(r"settings.ron") + } +} \ No newline at end of file diff --git a/voxygen/src/singleplayer.rs b/voxygen/src/singleplayer.rs index ce300a3d5b..18975ad6d9 100644 --- a/voxygen/src/singleplayer.rs +++ b/voxygen/src/singleplayer.rs @@ -2,7 +2,7 @@ use client::Client; use common::clock::Clock; use log::info; use portpicker::pick_unused_port; -use server::{Event, Input, Server}; +use server::{Event, Input, Server, ServerSettings}; use std::{ net::SocketAddr, sync::mpsc::{channel, Receiver, Sender, TryRecvError}, @@ -36,7 +36,7 @@ impl Singleplayer { )); // Create server - let server = Server::bind(sock.clone()).expect("Failed to create server instance!"); + let server = Server::bind(sock.clone(), ServerSettings::default()).expect("Failed to create server instance!"); let server = match client { Some(client) => server.with_thread_pool(client.thread_pool().clone()), From bbb024224d649c5f9f457dfaa9c222676bad6a72 Mon Sep 17 00:00:00 2001 From: Songtronix Date: Mon, 1 Jul 2019 11:37:17 +0200 Subject: [PATCH 13/21] add configureable server info --- .gitignore | 1 + server-cli/src/main.rs | 2 +- server/src/lib.rs | 7 +++---- server/src/settings.rs | 11 +++++++---- voxygen/src/singleplayer.rs | 3 ++- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 7851bea8dc..f926d8500e 100644 --- a/.gitignore +++ b/.gitignore @@ -31,5 +31,6 @@ # Veloren *.rar *.log +*.ron run.sh screenshots diff --git a/server-cli/src/main.rs b/server-cli/src/main.rs index 41f4949812..010a0aefe7 100644 --- a/server-cli/src/main.rs +++ b/server-cli/src/main.rs @@ -39,6 +39,6 @@ fn main() { // Wait for the next tick. clock.tick(Duration::from_millis(1000 / TPS)); } - + //settings.save_to_file().expect("failed to save the settings!"); } diff --git a/server/src/lib.rs b/server/src/lib.rs index 3ba39b0c29..7872c887d0 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -100,12 +100,11 @@ impl Server { chunk_rx, pending_chunks: HashSet::new(), - server_settings: settings, server_info: ServerInfo { - // TODO: get from settings - name: "Server name".to_owned(), - description: "This is the best Veloren server.".to_owned(), + name: settings.server_name.clone(), + description: settings.server_description.clone(), }, + server_settings: settings, }; Ok(this) diff --git a/server/src/settings.rs b/server/src/settings.rs index 41f32902b2..7dd157611f 100644 --- a/server/src/settings.rs +++ b/server/src/settings.rs @@ -1,5 +1,5 @@ use serde_derive::{Deserialize, Serialize}; -use std::{fs, io::prelude::*, path::PathBuf, net::SocketAddr}; +use std::{fs, io::prelude::*, net::SocketAddr, path::PathBuf}; /// `ControlSettings` contains keybindings. #[derive(Clone, Debug, Serialize, Deserialize)] @@ -9,7 +9,8 @@ pub struct ServerSettings { //pub max_players: u64, pub world_seed: u32, //pub pvp_enabled: bool, - //pub serverinfo: whatever + pub server_name: String, + pub server_description: String, //pub login_server: whatever } @@ -18,9 +19,11 @@ impl Default for ServerSettings { Self { address: SocketAddr::from(([0; 4], 59003)), world_seed: 1337, + server_name: "Server name".to_owned(), + server_description: "This is the best Veloren server.".to_owned(), } } -} +} impl ServerSettings { pub fn load() -> Self { @@ -49,4 +52,4 @@ impl ServerSettings { fn get_settings_path() -> PathBuf { PathBuf::from(r"settings.ron") } -} \ No newline at end of file +} diff --git a/voxygen/src/singleplayer.rs b/voxygen/src/singleplayer.rs index 18975ad6d9..0b294b02f6 100644 --- a/voxygen/src/singleplayer.rs +++ b/voxygen/src/singleplayer.rs @@ -36,7 +36,8 @@ impl Singleplayer { )); // Create server - let server = Server::bind(sock.clone(), ServerSettings::default()).expect("Failed to create server instance!"); + let server = Server::bind(sock.clone(), ServerSettings::default()) + .expect("Failed to create server instance!"); let server = match client { Some(client) => server.with_thread_pool(client.thread_pool().clone()), From b6c8bdc2237666f08d8a4da57ce9f4c3c516de16 Mon Sep 17 00:00:00 2001 From: Songtronix Date: Mon, 1 Jul 2019 13:19:26 +0200 Subject: [PATCH 14/21] add configurable max player count --- client/src/error.rs | 1 + client/src/lib.rs | 2 ++ common/src/msg/server.rs | 1 + server/src/client.rs | 4 ++++ server/src/lib.rs | 21 +++++++++++++-------- server/src/settings.rs | 4 ++-- voxygen/src/menu/main/client_init.rs | 5 +++++ voxygen/src/menu/main/mod.rs | 1 + 8 files changed, 29 insertions(+), 10 deletions(-) diff --git a/client/src/error.rs b/client/src/error.rs index 1f74ae62b9..754ed38d0e 100644 --- a/client/src/error.rs +++ b/client/src/error.rs @@ -6,6 +6,7 @@ pub enum Error { ServerWentMad, ServerTimeout, ServerShutdown, + TooManyPlayers, Other(String), } diff --git a/client/src/lib.rs b/client/src/lib.rs index 977829a722..febc4c2de7 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -73,6 +73,7 @@ impl Client { .ok_or(Error::ServerWentMad)?; (state, entity, server_info) } + Some(ServerMsg::TooManyPlayers) => return Err(Error::TooManyPlayers), _ => return Err(Error::ServerWentMad), }; @@ -362,6 +363,7 @@ impl Client { for msg in new_msgs { match msg { ServerMsg::InitialSync { .. } => return Err(Error::ServerWentMad), + ServerMsg::TooManyPlayers => return Err(Error::ServerWentMad), ServerMsg::Shutdown => return Err(Error::ServerShutdown), ServerMsg::Ping => self.postbox.send_message(ClientMsg::Pong), ServerMsg::Pong => { diff --git a/common/src/msg/server.rs b/common/src/msg/server.rs index 0fadce7afa..7f5af07832 100644 --- a/common/src/msg/server.rs +++ b/common/src/msg/server.rs @@ -41,6 +41,7 @@ pub enum ServerMsg { key: Vec2, chunk: Box, }, + TooManyPlayers, Disconnect, Shutdown, } diff --git a/server/src/client.rs b/server/src/client.rs index e22d8d2e95..fb43465ebb 100644 --- a/server/src/client.rs +++ b/server/src/client.rs @@ -41,6 +41,10 @@ impl Clients { } } + pub fn len(&mut self) -> usize { + self.clients.len() + } + pub fn add(&mut self, entity: EcsEntity, client: Client) { self.clients.insert(entity, client); } diff --git a/server/src/lib.rs b/server/src/lib.rs index 7872c887d0..3d7fc69e58 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -357,16 +357,21 @@ impl Server { last_ping: self.state.get_time(), }; - // Return the state of the current world (all of the components that Sphynx tracks). - client.notify(ServerMsg::InitialSync { - ecs_state: self.state.ecs().gen_state_package(), - entity_uid: self.state.ecs().uid_from_entity(entity).unwrap().into(), // Can't fail. - server_info: self.server_info.clone(), - }); + // TODO: Figure out if this if/else if correct + if self.server_settings.max_players <= self.clients.len() { + client.notify(ServerMsg::TooManyPlayers); + } else { + // Return the state of the current world (all of the components that Sphynx tracks). + client.notify(ServerMsg::InitialSync { + ecs_state: self.state.ecs().gen_state_package(), + entity_uid: self.state.ecs().uid_from_entity(entity).unwrap().into(), // Can't fail. + server_info: self.server_info.clone(), + }); + + frontend_events.push(Event::ClientConnected { entity }); + } self.clients.add(entity, client); - - frontend_events.push(Event::ClientConnected { entity }); } Ok(frontend_events) diff --git a/server/src/settings.rs b/server/src/settings.rs index 7dd157611f..3ba8482cc3 100644 --- a/server/src/settings.rs +++ b/server/src/settings.rs @@ -1,12 +1,11 @@ use serde_derive::{Deserialize, Serialize}; use std::{fs, io::prelude::*, net::SocketAddr, path::PathBuf}; -/// `ControlSettings` contains keybindings. #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(default)] pub struct ServerSettings { pub address: SocketAddr, - //pub max_players: u64, + pub max_players: usize, pub world_seed: u32, //pub pvp_enabled: bool, pub server_name: String, @@ -21,6 +20,7 @@ impl Default for ServerSettings { world_seed: 1337, server_name: "Server name".to_owned(), server_description: "This is the best Veloren server.".to_owned(), + max_players: 16, } } } diff --git a/voxygen/src/menu/main/client_init.rs b/voxygen/src/menu/main/client_init.rs index 86ab1af88a..ee07025a55 100644 --- a/voxygen/src/menu/main/client_init.rs +++ b/voxygen/src/menu/main/client_init.rs @@ -20,6 +20,7 @@ pub enum Error { // Parsing/host name resolution successful but could not connect. ConnectionFailed(ClientError), ClientCrashed, + ServerIsFull, } // Used to asynchronously parse the server address, resolve host names, @@ -76,6 +77,10 @@ impl ClientInit { ClientError::Network(_) => { last_err = Some(Error::ConnectionFailed(err)) } + ClientError::TooManyPlayers => { + last_err = Some(Error::ServerIsFull); + break; + } // TODO: Handle errors? _ => panic!( "Unexpected non-network error when creating client: {:?}", diff --git a/voxygen/src/menu/main/mod.rs b/voxygen/src/menu/main/mod.rs index b46b076e69..ed27a97ea6 100644 --- a/voxygen/src/menu/main/mod.rs +++ b/voxygen/src/menu/main/mod.rs @@ -64,6 +64,7 @@ impl PlayState for MainMenuState { self.main_menu_ui.login_error( match err { InitError::BadAddress(_) | InitError::NoAddress => "Server not found", + InitError::ServerIsFull => "Server is Full!", InitError::ConnectionFailed(_) => "Connection failed", InitError::ClientCrashed => "Client crashed", } From e2b83883f38a7fd7a9e26834853d30a0731509f9 Mon Sep 17 00:00:00 2001 From: Songtronix Date: Thu, 4 Jul 2019 11:38:17 +0200 Subject: [PATCH 15/21] fmt --- server-cli/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server-cli/src/main.rs b/server-cli/src/main.rs index 010a0aefe7..d45038ab96 100644 --- a/server-cli/src/main.rs +++ b/server-cli/src/main.rs @@ -13,7 +13,7 @@ fn main() { // Set up an fps clock let mut clock = Clock::start(); - + // Load settings let settings = ServerSettings::load(); From b41508f025127ee6343cd7cf4cf6946cfc1cde36 Mon Sep 17 00:00:00 2001 From: Songtronix Date: Thu, 4 Jul 2019 18:14:45 +0200 Subject: [PATCH 16/21] generalise errors based on zests suggestion --- client/src/error.rs | 1 + client/src/lib.rs | 13 +++++++++---- common/src/msg/mod.rs | 2 +- common/src/msg/server.rs | 8 +++++++- server/src/lib.rs | 5 ++--- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/client/src/error.rs b/client/src/error.rs index 754ed38d0e..2d22c5781e 100644 --- a/client/src/error.rs +++ b/client/src/error.rs @@ -7,6 +7,7 @@ pub enum Error { ServerTimeout, ServerShutdown, TooManyPlayers, + InvalidAlias, Other(String), } diff --git a/client/src/lib.rs b/client/src/lib.rs index febc4c2de7..cd99b590cb 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -9,7 +9,7 @@ pub use specs::Entity as EcsEntity; use common::{ comp, - msg::{ClientMsg, ClientState, ServerInfo, ServerMsg}, + msg::{ClientMsg, ClientState, ServerError, ServerInfo, ServerMsg}, net::PostBox, state::State, terrain::{block::Block, chonk::ChonkMetrics, TerrainChunk, TerrainChunkSize}, @@ -73,7 +73,9 @@ impl Client { .ok_or(Error::ServerWentMad)?; (state, entity, server_info) } - Some(ServerMsg::TooManyPlayers) => return Err(Error::TooManyPlayers), + Some(ServerMsg::Error(ServerError::TooManyPlayers)) => { + return Err(Error::TooManyPlayers) + } _ => return Err(Error::ServerWentMad), }; @@ -362,9 +364,12 @@ impl Client { if new_msgs.len() > 0 { for msg in new_msgs { match msg { - ServerMsg::InitialSync { .. } => return Err(Error::ServerWentMad), - ServerMsg::TooManyPlayers => return Err(Error::ServerWentMad), + ServerMsg::Error(e) => match e { + ServerError::TooManyPlayers => return Err(Error::ServerWentMad), + ServerError::InvalidAlias => return Err(Error::InvalidAlias), + }, ServerMsg::Shutdown => return Err(Error::ServerShutdown), + ServerMsg::InitialSync { .. } => return Err(Error::ServerWentMad), ServerMsg::Ping => self.postbox.send_message(ClientMsg::Pong), ServerMsg::Pong => { self.last_ping_delta = Instant::now() diff --git a/common/src/msg/mod.rs b/common/src/msg/mod.rs index 2cad42a63c..25644b36de 100644 --- a/common/src/msg/mod.rs +++ b/common/src/msg/mod.rs @@ -5,7 +5,7 @@ pub mod server; // Reexports pub use self::client::ClientMsg; pub use self::ecs_packet::{EcsCompPacket, EcsResPacket}; -pub use self::server::{RequestStateError, ServerInfo, ServerMsg}; +pub use self::server::{RequestStateError, ServerError, ServerInfo, ServerMsg}; #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] pub enum ClientState { diff --git a/common/src/msg/server.rs b/common/src/msg/server.rs index 7f5af07832..f42258fb2e 100644 --- a/common/src/msg/server.rs +++ b/common/src/msg/server.rs @@ -41,7 +41,13 @@ pub enum ServerMsg { key: Vec2, chunk: Box, }, - TooManyPlayers, + Error(ServerError), Disconnect, Shutdown, } + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub enum ServerError { + TooManyPlayers, + InvalidAlias, +} diff --git a/server/src/lib.rs b/server/src/lib.rs index 3d7fc69e58..9cb99c23ea 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -15,7 +15,7 @@ use crate::{ }; use common::{ comp, - msg::{ClientMsg, ClientState, RequestStateError, ServerInfo, ServerMsg}, + msg::{ClientMsg, ClientState, RequestStateError, ServerError, ServerInfo, ServerMsg}, net::PostOffice, state::{State, TerrainChange, Uid}, terrain::{block::Block, TerrainChunk, TerrainChunkSize, TerrainMap}, @@ -357,9 +357,8 @@ impl Server { last_ping: self.state.get_time(), }; - // TODO: Figure out if this if/else if correct if self.server_settings.max_players <= self.clients.len() { - client.notify(ServerMsg::TooManyPlayers); + client.notify(ServerMsg::Error(ServerError::TooManyPlayers)); } else { // Return the state of the current world (all of the components that Sphynx tracks). client.notify(ServerMsg::InitialSync { From bf82f5925d23531ffe1fbf1a66568379ff701217 Mon Sep 17 00:00:00 2001 From: Songtronix Date: Thu, 4 Jul 2019 19:37:56 +0200 Subject: [PATCH 17/21] maybe improved setting file handling --- server/src/settings.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/server/src/settings.rs b/server/src/settings.rs index 3ba8482cc3..ef168b3266 100644 --- a/server/src/settings.rs +++ b/server/src/settings.rs @@ -29,14 +29,22 @@ impl ServerSettings { pub fn load() -> Self { let path = ServerSettings::get_settings_path(); - // If file doesn't exist, use the default settings. if let Ok(file) = fs::File::open(path) { - // TODO: Replace expect with returning default? - ron::de::from_reader(file).expect("Error parsing settings") + match ron::de::from_reader(file) { + Ok(x) => x, + Err(e) => { + log::warn!("Failed to parse setting file! Fallback to default. {}", e); + Self::default() + } + } } else { - // TODO: temporary - Self::default().save_to_file().unwrap(); - Self::default() + let default_settings = Self::default(); + + match default_settings.save_to_file() { + Err(e) => log::error!("Failed to create default setting file! {}", e), + _ => {} + } + default_settings } } From ed0d842e57515cee7132ce808b48a70aed2a3d74 Mon Sep 17 00:00:00 2001 From: Songtronix Date: Fri, 5 Jul 2019 14:16:08 +0200 Subject: [PATCH 18/21] Mark InvalidAlias Message as to be done --- .gitignore | 1 - client/src/error.rs | 2 +- client/src/lib.rs | 2 +- common/src/comp/player.rs | 1 - common/src/msg/server.rs | 2 +- 5 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index f926d8500e..7851bea8dc 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,5 @@ # Veloren *.rar *.log -*.ron run.sh screenshots diff --git a/client/src/error.rs b/client/src/error.rs index 2d22c5781e..20f3319649 100644 --- a/client/src/error.rs +++ b/client/src/error.rs @@ -7,7 +7,7 @@ pub enum Error { ServerTimeout, ServerShutdown, TooManyPlayers, - InvalidAlias, + //TODO: InvalidAlias, Other(String), } diff --git a/client/src/lib.rs b/client/src/lib.rs index cd99b590cb..720d4022b2 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -366,7 +366,7 @@ impl Client { match msg { ServerMsg::Error(e) => match e { ServerError::TooManyPlayers => return Err(Error::ServerWentMad), - ServerError::InvalidAlias => return Err(Error::InvalidAlias), + //TODO: ServerError::InvalidAlias => return Err(Error::InvalidAlias), }, ServerMsg::Shutdown => return Err(Error::ServerShutdown), ServerMsg::InitialSync { .. } => return Err(Error::ServerWentMad), diff --git a/common/src/comp/player.rs b/common/src/comp/player.rs index 0761273cf7..e9b7a1d5c7 100644 --- a/common/src/comp/player.rs +++ b/common/src/comp/player.rs @@ -19,7 +19,6 @@ impl Player { pub fn is_valid(&self) -> bool { self.alias.chars().all(|c| c.is_alphanumeric() || c == '_') && self.alias.len() <= MAX_ALIAS_LEN - // TODO: Check view distance here based on server config too } } diff --git a/common/src/msg/server.rs b/common/src/msg/server.rs index f42258fb2e..e48423fca4 100644 --- a/common/src/msg/server.rs +++ b/common/src/msg/server.rs @@ -49,5 +49,5 @@ pub enum ServerMsg { #[derive(Debug, Clone, Serialize, Deserialize)] pub enum ServerError { TooManyPlayers, - InvalidAlias, + //TODO: InvalidAlias, } From 1215ced121c7b80abbfe9c32b9155b2c9dd8ad09 Mon Sep 17 00:00:00 2001 From: Songtronix Date: Sun, 7 Jul 2019 07:41:58 +0200 Subject: [PATCH 19/21] ignore settings file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7851bea8dc..153d29e4a5 100644 --- a/.gitignore +++ b/.gitignore @@ -31,5 +31,6 @@ # Veloren *.rar *.log +settings.ron run.sh screenshots From bfa6a2e2a26452014f1b5c174b1b13d2b11470ae Mon Sep 17 00:00:00 2001 From: Songtronix Date: Fri, 12 Jul 2019 15:03:35 +0200 Subject: [PATCH 20/21] add configurable TimeOfDay --- Cargo.lock | 2 +- server/src/lib.rs | 5 ++++- server/src/settings.rs | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2e207bd8b0..a1c93e5cbb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2765,7 +2765,7 @@ name = "veloren-server" version = "0.2.0" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "ron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "scan_fmt 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/server/src/lib.rs b/server/src/lib.rs index 9cb99c23ea..f9da79dbc1 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -17,7 +17,7 @@ use common::{ comp, msg::{ClientMsg, ClientState, RequestStateError, ServerError, ServerInfo, ServerMsg}, net::PostOffice, - state::{State, TerrainChange, Uid}, + state::{State, TerrainChange, TimeOfDay, Uid}, terrain::{block::Block, TerrainChunk, TerrainChunkSize, TerrainMap}, vol::VolSize, vol::Vox, @@ -86,6 +86,9 @@ impl Server { .ecs_mut() .add_resource(SpawnPoint(Vec3::new(16_384.0, 16_384.0, 380.0))); + // Set starting time for the server. + state.ecs_mut().write_resource::().0 = settings.start_time; + let this = Self { state, world: Arc::new(World::generate(settings.world_seed)), diff --git a/server/src/settings.rs b/server/src/settings.rs index ef168b3266..4187648bd2 100644 --- a/server/src/settings.rs +++ b/server/src/settings.rs @@ -11,6 +11,7 @@ pub struct ServerSettings { pub server_name: String, pub server_description: String, //pub login_server: whatever + pub start_time: f64, } impl Default for ServerSettings { @@ -21,6 +22,7 @@ impl Default for ServerSettings { server_name: "Server name".to_owned(), server_description: "This is the best Veloren server.".to_owned(), max_players: 16, + start_time: 0.0, } } } From 5b31c7c1f9958384646a5eae89f1294af7be9606 Mon Sep 17 00:00:00 2001 From: Songtronix Date: Wed, 17 Jul 2019 19:03:37 +0200 Subject: [PATCH 21/21] little cleanup --- server-cli/src/main.rs | 2 -- server/Cargo.toml | 1 - 2 files changed, 3 deletions(-) diff --git a/server-cli/src/main.rs b/server-cli/src/main.rs index d45038ab96..952c7c3152 100644 --- a/server-cli/src/main.rs +++ b/server-cli/src/main.rs @@ -39,6 +39,4 @@ fn main() { // Wait for the next tick. clock.tick(Duration::from_millis(1000 / TPS)); } - - //settings.save_to_file().expect("failed to save the settings!"); } diff --git a/server/Cargo.toml b/server/Cargo.toml index 7fed15056d..b0b4738783 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -14,7 +14,6 @@ vek = "0.9" uvth = "3.1.0" lazy_static = "1.3.0" scan_fmt = "0.1.3" - ron = "0.5.1" serde = "1.0" serde_derive = "1.0" \ No newline at end of file