mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Removed panic sources from server event handling
This commit is contained in:
parent
115c09120d
commit
fe7f73bf62
@ -23,6 +23,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed a bug that would cause a server crash when a player levelled up or fired
|
||||||
|
a projectile in very specific circumstances
|
||||||
|
|
||||||
## [0.8.0] - 2020-11-28
|
## [0.8.0] - 2020-11-28
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -118,12 +118,11 @@ pub fn handle_shoot(
|
|||||||
) {
|
) {
|
||||||
let state = server.state_mut();
|
let state = server.state_mut();
|
||||||
|
|
||||||
let mut pos = state
|
let mut pos = if let Some(pos) = state.ecs().read_storage::<Pos>().get(entity) {
|
||||||
.ecs()
|
pos.0
|
||||||
.read_storage::<Pos>()
|
} else {
|
||||||
.get(entity)
|
return;
|
||||||
.expect("Failed to fetch entity")
|
};
|
||||||
.0;
|
|
||||||
|
|
||||||
let vel = *dir * speed;
|
let vel = *dir * speed;
|
||||||
|
|
||||||
|
@ -721,23 +721,18 @@ pub fn handle_explosion(
|
|||||||
|
|
||||||
pub fn handle_level_up(server: &mut Server, entity: EcsEntity, new_level: u32) {
|
pub fn handle_level_up(server: &mut Server, entity: EcsEntity, new_level: u32) {
|
||||||
let ecs = &server.state.ecs();
|
let ecs = &server.state.ecs();
|
||||||
let uids = server.state.ecs().read_storage::<Uid>();
|
if let Some((uid, pos)) = ecs
|
||||||
let uid = uids
|
.read_storage::<Uid>()
|
||||||
.get(entity)
|
.get(entity)
|
||||||
.expect("Failed to fetch uid component for entity.");
|
.copied()
|
||||||
let pos = server
|
.zip(ecs.read_storage::<Pos>().get(entity).map(|p| p.0))
|
||||||
.state
|
{
|
||||||
.ecs()
|
ecs.write_resource::<Vec<Outcome>>()
|
||||||
.read_storage::<Pos>()
|
.push(Outcome::LevelUp { pos });
|
||||||
.get(entity)
|
server.state.notify_players(ServerGeneral::PlayerListUpdate(
|
||||||
.expect("Failed to fetch position component for the entity.")
|
PlayerListUpdate::LevelChange(uid, new_level),
|
||||||
.0;
|
));
|
||||||
|
}
|
||||||
server.state.notify_players(ServerGeneral::PlayerListUpdate(
|
|
||||||
PlayerListUpdate::LevelChange(*uid, new_level),
|
|
||||||
));
|
|
||||||
ecs.write_resource::<Vec<Outcome>>()
|
|
||||||
.push(Outcome::LevelUp { pos });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_aura(server: &mut Server, entity: EcsEntity, aura_change: aura::AuraChange) {
|
pub fn handle_aura(server: &mut Server, entity: EcsEntity, aura_change: aura::AuraChange) {
|
||||||
|
Loading…
Reference in New Issue
Block a user