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) .with(uid)
.build(); .build();
let ecs = state.ecs();
// Ensure IdMaps maps this uid to the new entity // Ensure IdMaps maps this uid to the new entity
ecs.write_resource::<IdMaps>().remap_entity(uid, 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 // Group component will be removed below, that prevents
// `delete_entity_recorded` from making any changes to the group. // `delete_entity_recorded` from making any changes to the group.
if let Some(group) = maybe_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 if group_manager
.group_info(group) .group_info(group)
.map(|info| info.leader == entity) .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( group_manager.assign_leader(
new_entity, new_entity,
&state.ecs().read_storage(), &ecs.read_storage(),
&state.ecs().entities(), &ecs.entities(),
&state.ecs().read_storage(), &ecs.read_storage(),
&state.ecs().read_storage(), &ecs.read_storage(),
// Nothing actually changing since Uid is transferred // 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 // 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 // Delete old entity
if let Err(e) = state.delete_entity_recorded(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>(), state.ecs().fetch_mut::<BattleModeBuffer>(),
) { ) {
match presence.kind { 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) => { PresenceKind::Character(char_id) => {
let waypoint = state let waypoint = state
.ecs() .ecs()

View File

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

View File

@ -9,6 +9,7 @@ use common::{
}; };
use common_ecs::{Job, Origin, Phase, System}; use common_ecs::{Job, Origin, Phase, System};
use specs::{Join, ReadStorage, Write, WriteExpect}; use specs::{Join, ReadStorage, Write, WriteExpect};
use tracing::error;
#[derive(Default)] #[derive(Default)]
pub struct Sys; pub struct Sys;
@ -74,6 +75,14 @@ impl<'a> System<'a> for Sys {
active_abilities, active_abilities,
map_marker, map_marker,
)| match presence.kind { )| 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) => { PresenceKind::Character(id) => {
let pets = (&alignments, &bodies, &stats, &pets) let pets = (&alignments, &bodies, &stats, &pets)
.join() .join()

View File

@ -1350,6 +1350,7 @@ impl Hud {
let character_id = match client.presence().unwrap() { let character_id = match client.presence().unwrap() {
PresenceKind::Character(id) => Some(id), PresenceKind::Character(id) => Some(id),
PresenceKind::LoadingCharacter(id) => Some(id),
PresenceKind::Spectator => None, PresenceKind::Spectator => None,
PresenceKind::Possessor => 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. // If we are changing the hotbar state this CANNOT be None.
let character_id = match client.presence().unwrap() { let character_id = match client.presence().unwrap() {
PresenceKind::Character(id) => Some(id), PresenceKind::Character(id) => Some(id),
PresenceKind::LoadingCharacter(id) => Some(id),
PresenceKind::Spectator => { PresenceKind::Spectator => {
unreachable!("HUD adaption in Spectator mode!") unreachable!("HUD adaption in Spectator mode!")
}, },