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