mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fmt, fixed chat-cli problem
This commit is contained in:
parent
d9cd37056d
commit
1cca7bf4a8
@ -94,7 +94,7 @@ fn main() {
|
||||
|
||||
println!("{}", message)
|
||||
},
|
||||
Event::Notification(_) => {}, // TODO?
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,11 +245,7 @@ impl ChatCommand {
|
||||
"Set player Level",
|
||||
true,
|
||||
),
|
||||
ChatCommand::SetMotd => cmd(
|
||||
vec![Message],
|
||||
"Set the server description",
|
||||
true,
|
||||
),
|
||||
ChatCommand::SetMotd => cmd(vec![Message], "Set the server description", true),
|
||||
ChatCommand::Spawn => cmd(
|
||||
vec![
|
||||
Enum("alignment", ALIGNMENTS.clone(), Required),
|
||||
|
@ -174,12 +174,12 @@ fn handle_motd(
|
||||
server: &mut Server,
|
||||
client: EcsEntity,
|
||||
_target: EcsEntity,
|
||||
args: String,
|
||||
action: &ChatCommand,
|
||||
_args: String,
|
||||
_action: &ChatCommand,
|
||||
) {
|
||||
server.notify_client(
|
||||
client,
|
||||
ServerMsg::broadcast(format!("{}", server.settings().server_description)),
|
||||
ServerMsg::broadcast(server.settings().server_description.clone()),
|
||||
);
|
||||
}
|
||||
|
||||
@ -201,12 +201,10 @@ fn handle_set_motd(
|
||||
);
|
||||
},
|
||||
Err(_) => {
|
||||
server
|
||||
.settings_mut()
|
||||
.edit(|s| s.server_description.clear());
|
||||
server.settings_mut().edit(|s| s.server_description.clear());
|
||||
server.notify_client(
|
||||
client,
|
||||
ServerMsg::broadcast("Removed server description".to_string()),
|
||||
ServerMsg::private("Removed server description".to_string()),
|
||||
);
|
||||
},
|
||||
}
|
||||
|
@ -1,8 +1,4 @@
|
||||
use crate::{
|
||||
sys,
|
||||
Server,
|
||||
StateExt,
|
||||
};
|
||||
use crate::{sys, Server, StateExt};
|
||||
use common::{
|
||||
comp::{
|
||||
self, Agent, Alignment, Body, Gravity, Item, ItemDrop, LightEmitter, Loadout, Pos,
|
||||
@ -22,7 +18,9 @@ pub fn handle_loaded_character_data(
|
||||
entity: EcsEntity,
|
||||
loaded_components: (comp::Body, comp::Stats, comp::Inventory, comp::Loadout),
|
||||
) {
|
||||
server.state.update_character_data(entity, loaded_components);
|
||||
server
|
||||
.state
|
||||
.update_character_data(entity, loaded_components);
|
||||
sys::subscription::initialize_region_subscription(server.state.ecs(), entity);
|
||||
}
|
||||
|
||||
|
@ -43,9 +43,9 @@ use persistence::character::{CharacterLoader, CharacterLoaderResponseType, Chara
|
||||
use specs::{join::Join, Builder, Entity as EcsEntity, RunNow, SystemData, WorldExt};
|
||||
use std::{
|
||||
i32,
|
||||
ops::{Deref, DerefMut},
|
||||
sync::Arc,
|
||||
time::{Duration, Instant},
|
||||
ops::{Deref, DerefMut},
|
||||
};
|
||||
#[cfg(not(feature = "worldgen"))]
|
||||
use test_world::{World, WORLD_SIZE};
|
||||
@ -274,12 +274,12 @@ impl Server {
|
||||
}
|
||||
|
||||
/// Get a reference to the server's settings
|
||||
pub fn settings(&self) -> impl Deref<Target=ServerSettings> + '_ {
|
||||
pub fn settings(&self) -> impl Deref<Target = ServerSettings> + '_ {
|
||||
self.state.ecs().fetch::<ServerSettings>()
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the server's settings
|
||||
pub fn settings_mut(&mut self) -> impl DerefMut<Target=ServerSettings> + '_ {
|
||||
pub fn settings_mut(&mut self) -> impl DerefMut<Target = ServerSettings> + '_ {
|
||||
self.state.ecs_mut().fetch_mut::<ServerSettings>()
|
||||
}
|
||||
|
||||
@ -586,7 +586,7 @@ impl Server {
|
||||
login_msg_sent: false,
|
||||
};
|
||||
|
||||
if self.state.ecs().fetch::<ServerSettings>().max_players
|
||||
if self.settings().max_players
|
||||
<= self.state.ecs().read_storage::<Client>().join().count()
|
||||
{
|
||||
// Note: in this case the client is dropped
|
||||
|
@ -97,8 +97,7 @@ impl ServerSettings {
|
||||
|
||||
let s: &str = &ron::ser::to_string_pretty(self, ron::ser::PrettyConfig::default())
|
||||
.expect("Failed serialize settings.");
|
||||
config_file
|
||||
.write_all(s.as_bytes())?;
|
||||
config_file.write_all(s.as_bytes())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -137,8 +136,7 @@ impl ServerSettings {
|
||||
|
||||
pub fn edit<R>(&mut self, f: impl FnOnce(&mut Self) -> R) -> R {
|
||||
let r = f(self);
|
||||
self
|
||||
.save_to_file()
|
||||
self.save_to_file()
|
||||
.unwrap_or_else(|err| warn!("Failed to save settings: {:?}", err));
|
||||
r
|
||||
}
|
||||
|
@ -38,11 +38,7 @@ pub trait StateExt {
|
||||
projectile: comp::Projectile,
|
||||
) -> EcsEntityBuilder;
|
||||
/// Insert common/default components for a new character joining the server
|
||||
fn initialize_character_data(
|
||||
&mut self,
|
||||
entity: EcsEntity,
|
||||
character_id: i32,
|
||||
);
|
||||
fn initialize_character_data(&mut self, entity: EcsEntity, character_id: i32);
|
||||
/// Update the components associated with the entity's current character.
|
||||
/// Performed after loading component data from the database
|
||||
fn update_character_data(&mut self, entity: EcsEntity, components: PersistedComponents);
|
||||
@ -156,11 +152,7 @@ impl StateExt for State {
|
||||
.with(comp::Sticky)
|
||||
}
|
||||
|
||||
fn initialize_character_data(
|
||||
&mut self,
|
||||
entity: EcsEntity,
|
||||
character_id: i32,
|
||||
) {
|
||||
fn initialize_character_data(&mut self, entity: EcsEntity, character_id: i32) {
|
||||
let spawn_point = self.ecs().read_resource::<SpawnPoint>().0;
|
||||
|
||||
self.write_component(entity, comp::Energy::new(1000));
|
||||
|
@ -1,8 +1,7 @@
|
||||
use super::SysTimer;
|
||||
use crate::{
|
||||
auth_provider::AuthProvider, client::Client, persistence::character::CharacterLoader,
|
||||
ServerSettings,
|
||||
CLIENT_TIMEOUT,
|
||||
ServerSettings, CLIENT_TIMEOUT,
|
||||
};
|
||||
use common::{
|
||||
comp::{
|
||||
@ -249,10 +248,9 @@ impl<'a> System<'a> for Sys {
|
||||
|
||||
// Give the player a welcome message
|
||||
if settings.server_description.len() > 0 {
|
||||
client.notify(ServerMsg::broadcast(format!(
|
||||
"{}",
|
||||
settings.server_description
|
||||
)));
|
||||
client.notify(ServerMsg::broadcast(
|
||||
settings.server_description.clone(),
|
||||
));
|
||||
}
|
||||
|
||||
// Only send login message if it wasn't already
|
||||
|
Loading…
Reference in New Issue
Block a user