Fix compilation errors from recent changes

This commit is contained in:
Imbris 2023-05-30 23:13:13 -04:00
parent c60f994c7f
commit a8fbfc026a
5 changed files with 25 additions and 10 deletions

View File

@ -105,6 +105,7 @@ pub fn handle_exit_ingame(server: &mut Server, entity: EcsEntity, skip_persisten
.with(uid)
.build();
let ecs = state.ecs();
// Ensure IdMaps maps this uid to the new entity
ecs.write_resource::<IdMaps>().remap_entity(uid, new_entity);
@ -112,7 +113,7 @@ pub fn handle_exit_ingame(server: &mut Server, entity: EcsEntity, skip_persisten
// Group component will be removed below, that prevents
// `delete_entity_recorded` from making any changes to the group.
if let Some(group) = maybe_group {
let mut group_manager = state.ecs().write_resource::<group::GroupManager>();
let mut group_manager = ecs.write_resource::<group::GroupManager>();
if group_manager
.group_info(group)
.map(|info| info.leader == entity)
@ -120,10 +121,10 @@ pub fn handle_exit_ingame(server: &mut Server, entity: EcsEntity, skip_persisten
{
group_manager.assign_leader(
new_entity,
&state.ecs().read_storage(),
&state.ecs().entities(),
&state.ecs().read_storage(),
&state.ecs().read_storage(),
&ecs.read_storage(),
&ecs.entities(),
&ecs.read_storage(),
&ecs.read_storage(),
// Nothing actually changing since Uid is transferred
|_, _| {},
);
@ -131,7 +132,7 @@ pub fn handle_exit_ingame(server: &mut Server, entity: EcsEntity, skip_persisten
}
// Erase group component to avoid group restructure when deleting the entity
state.ecs().write_storage::<group::Group>().remove(entity);
ecs.write_storage::<group::Group>().remove(entity);
}
// Delete old entity
if let Err(e) = state.delete_entity_recorded(entity) {
@ -264,6 +265,9 @@ fn persist_entity(state: &mut State, entity: EcsEntity) -> EcsEntity {
state.ecs().fetch_mut::<BattleModeBuffer>(),
) {
match presence.kind {
PresenceKind::LoadingCharacter(_char_id) => {
error!("Unexpected state when persist_entity is called! Some of the components required above should only be present after a character is loaded!");
},
PresenceKind::Character(char_id) => {
let waypoint = state
.ecs()

View File

@ -702,7 +702,7 @@ impl StateExt for State {
let result =
if let Some(presence) = self.ecs().write_storage::<Presence>().get_mut(entity) {
if let PresenceKind::LoadingCharacter(id) = presence.kind {
*presence.kind = PresenceKind::Character(id);
presence.kind = PresenceKind::Character(id);
Ok(())
} else {
Err("PresenceKind is not LoadingCharacter")
@ -1196,14 +1196,14 @@ impl StateExt for State {
self.ecs().write_resource::<IdMaps>().remove_entity(
Some(entity),
uid,
maybe_presence.and_then(|p| match p.kind {
maybe_presence.and_then(|p| match p {
PresenceKind::Spectator
| PresenceKind::Possessed
| PresenceKind::Possessor
| PresenceKind::LoadingCharacter(_) => None,
PresenceKind::Character(id) => Some(id),
}),
maybe_rtsim_entity,
)
);
} else {
error!("Deleting entity without Uid component");
}

View File

@ -9,6 +9,7 @@ use common::{
};
use common_ecs::{Job, Origin, Phase, System};
use specs::{Join, ReadStorage, Write, WriteExpect};
use tracing::error;
#[derive(Default)]
pub struct Sys;
@ -74,6 +75,14 @@ impl<'a> System<'a> for Sys {
active_abilities,
map_marker,
)| match presence.kind {
PresenceKind::LoadingCharacter(_char_id) => {
error!(
"Unexpected state when persisting characters! Some of the \
components required above should only be present after a \
character is loaded!"
);
None
},
PresenceKind::Character(id) => {
let pets = (&alignments, &bodies, &stats, &pets)
.join()

View File

@ -1350,6 +1350,7 @@ impl Hud {
let character_id = match client.presence().unwrap() {
PresenceKind::Character(id) => Some(id),
PresenceKind::LoadingCharacter(id) => Some(id),
PresenceKind::Spectator => None,
PresenceKind::Possessor => None,
};

View File

@ -1678,6 +1678,7 @@ impl PlayState for SessionState {
// If we are changing the hotbar state this CANNOT be None.
let character_id = match client.presence().unwrap() {
PresenceKind::Character(id) => Some(id),
PresenceKind::LoadingCharacter(id) => Some(id),
PresenceKind::Spectator => {
unreachable!("HUD adaption in Spectator mode!")
},