mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Send ability map from the server to the client on connection instead of loading from the assets
This commit is contained in:
parent
2c2e4813fd
commit
2072929a5a
@ -199,6 +199,7 @@ impl Client {
|
||||
client_timeout,
|
||||
world_map,
|
||||
recipe_book,
|
||||
ability_map,
|
||||
} => {
|
||||
// Initialize `State`
|
||||
let mut state = State::default();
|
||||
@ -209,6 +210,7 @@ impl Client {
|
||||
|
||||
let entity = state.ecs_mut().apply_entity_package(entity_package);
|
||||
*state.ecs_mut().write_resource() = time_of_day;
|
||||
state.ecs_mut().insert(ability_map);
|
||||
|
||||
let map_size_lg = common::terrain::MapSizeLg::new(world_map.dimensions_lg)
|
||||
.map_err(|_| {
|
||||
|
@ -21,7 +21,7 @@ pub enum ServerMsg {
|
||||
/// Basic info about server, send ONCE, clients need it to Register
|
||||
Info(ServerInfo),
|
||||
/// Initial data package, send BEFORE Register ONCE. Not Register relevant
|
||||
Init(ServerInit),
|
||||
Init(Box<ServerInit>),
|
||||
/// Result to `ClientMsg::Register`. send ONCE
|
||||
RegisterAnswer(ServerRegisterAnswer),
|
||||
///Msg that can be send ALWAYS as soon as client is registered, e.g. `Chat`
|
||||
@ -54,6 +54,7 @@ pub enum ServerInit {
|
||||
client_timeout: Duration,
|
||||
world_map: crate::msg::world_msg::WorldMapMsg,
|
||||
recipe_book: RecipeBook,
|
||||
ability_map: crate::comp::item::tool::AbilityMap,
|
||||
},
|
||||
}
|
||||
|
||||
@ -245,7 +246,7 @@ impl Into<ServerMsg> for ServerInfo {
|
||||
}
|
||||
|
||||
impl Into<ServerMsg> for ServerInit {
|
||||
fn into(self) -> ServerMsg { ServerMsg::Init(self) }
|
||||
fn into(self) -> ServerMsg { ServerMsg::Init(Box::new(self)) }
|
||||
}
|
||||
|
||||
impl Into<ServerMsg> for ServerRegisterAnswer {
|
||||
|
@ -1,5 +1,4 @@
|
||||
use crate::{
|
||||
assets::Asset,
|
||||
comp,
|
||||
event::{EventBus, LocalEvent, ServerEvent},
|
||||
metrics::{PhysicsMetrics, SysMetrics},
|
||||
@ -181,9 +180,6 @@ impl State {
|
||||
ecs.insert(BlockChange::default());
|
||||
ecs.insert(TerrainChanges::default());
|
||||
ecs.insert(EventBus::<LocalEvent>::default());
|
||||
ecs.insert(comp::item::tool::AbilityMap::load_expect_cloned(
|
||||
"common.abilities.weapon_ability_manifest",
|
||||
));
|
||||
// TODO: only register on the server
|
||||
ecs.insert(EventBus::<ServerEvent>::default());
|
||||
ecs.insert(comp::group::GroupManager::default());
|
||||
|
@ -45,6 +45,7 @@ use crate::{
|
||||
sys::sentinel::{DeletedEntities, TrackedComps},
|
||||
};
|
||||
use common::{
|
||||
assets::Asset,
|
||||
cmd::ChatCommand,
|
||||
comp::{self, ChatType},
|
||||
event::{EventBus, ServerEvent},
|
||||
@ -160,8 +161,13 @@ impl Server {
|
||||
.ecs_mut()
|
||||
.insert(CharacterUpdater::new(&persistence_db_dir)?);
|
||||
|
||||
let character_loader = CharacterLoader::new(&persistence_db_dir, &*state.ability_map());
|
||||
state.ecs_mut().insert(character_loader?);
|
||||
let ability_map = comp::item::tool::AbilityMap::load_expect_cloned(
|
||||
"common.abilities.weapon_ability_manifest",
|
||||
);
|
||||
state
|
||||
.ecs_mut()
|
||||
.insert(CharacterLoader::new(&persistence_db_dir, &ability_map)?);
|
||||
state.ecs_mut().insert(ability_map);
|
||||
state.ecs_mut().insert(Vec::<Outcome>::new());
|
||||
|
||||
// System timers for performance monitoring
|
||||
@ -872,6 +878,11 @@ impl Server {
|
||||
client_timeout: self.settings().client_timeout,
|
||||
world_map: self.map.clone(),
|
||||
recipe_book: (&*default_recipe_book()).clone(),
|
||||
ability_map: (&*self
|
||||
.state
|
||||
.ecs()
|
||||
.read_resource::<comp::item::tool::AbilityMap>())
|
||||
.clone(),
|
||||
})?;
|
||||
Ok(Some(entity))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user