more elaborate error handling

This commit is contained in:
Christof Petig 2024-03-14 00:32:55 +01:00
parent 166653b355
commit f0194e6d9b
3 changed files with 41 additions and 33 deletions

View File

@ -943,7 +943,7 @@ impl Client {
_ = ping_interval.tick() => ping_stream.send(PingMsg::Ping)?,
}
};
let missing_plugins_set = missing_plugins.iter().collect();
let missing_plugins_set = missing_plugins.iter().cloned().collect();
if !missing_plugins.is_empty() {
stream.send(ClientGeneral::RequestPlugins(missing_plugins))?;
}

View File

@ -279,15 +279,16 @@ impl PlayState for CharSelectionState {
)));
},
client::Event::PluginDataReceived(data) => {
#[cfg(feature = "plugins")]
{
tracing::info!("plugin data {}", data.len());
let mut client = self.client.borrow_mut();
#[cfg(feature = "plugins")]
match client
let hash = client
.state()
.ecs()
.write_resource::<PluginMgr>()
.cache_server_plugin(&global_state.config_dir, data)
{
.cache_server_plugin(&global_state.config_dir, data);
match hash {
Ok(hash) => {
if client.plugin_received(hash) == 0 {
// now load characters (plugins might contain items)
@ -296,6 +297,7 @@ impl PlayState for CharSelectionState {
},
Err(e) => tracing::error!(?e, "cache_server_plugin"),
}
}
},
// TODO: See if we should handle StartSpectate here instead.
_ => {},

View File

@ -223,11 +223,14 @@ impl PlayState for MainMenuState {
// load local plugins needed by the server
#[cfg(feature = "plugins")]
for path in client.take_local_plugins().drain(..) {
client
if let Err(e) = client
.state_mut()
.ecs_mut()
.write_resource::<PluginMgr>()
.load_server_plugin(path);
.load_server_plugin(path)
{
tracing::error!(?e, "load local plugin");
}
}
// Register voxygen components / resources
crate::ecs::init(client.state_mut().ecs_mut());
@ -281,24 +284,27 @@ impl PlayState for MainMenuState {
self.init = InitState::None;
},
client::Event::PluginDataReceived(data) => {
#[cfg(feature = "plugins")]
{
tracing::info!("plugin data {}", data.len());
if let InitState::Pipeline(client) = &mut self.init {
#[cfg(feature = "plugins")]
match client
let hash = client
.state()
.ecs()
.write_resource::<PluginMgr>()
.cache_server_plugin(&global_state.config_dir, data)
{
.cache_server_plugin(&global_state.config_dir, data);
match hash {
Ok(hash) => {
if client.plugin_received(hash) == 0 {
// now load characters (plugins might contain items)
// now load characters (plugins might contain
// items)
client.load_character_list();
}
},
Err(e) => tracing::error!(?e, "cache_server_plugin"),
}
}
}
},
_ => {},
}