Fix typo. cargo fmt.

This commit is contained in:
Imbris 2022-02-23 20:31:21 -05:00
parent e52159f638
commit e6c2239744
2 changed files with 20 additions and 14 deletions

View File

@ -347,25 +347,31 @@ pub fn handle_possess(server: &mut Server, possessor_uid: Uid, possesse_uid: Uid
// Sync the player's character data to the database. This must be done before // Sync the player's character data to the database. This must be done before
// moving any components from the entity. // moving any components from the entity.
// //
// NOTE: Below we delete old entity (if PresenceKind::Character) as if logging out. This is // NOTE: Below we delete old entity (if PresenceKind::Character) as if logging
// to prevent any potential for item duplication (although it would only be possible if the // out. This is to prevent any potential for item duplication (although
// player could repossess their entity, hand off some items, and then crash the server in a // it would only be possible if the player could repossess their entity,
// particular time window, and only admins should have access to the item with this ability // hand off some items, and then crash the server in a particular time
// in the first place (though that isn't foolproof)). We could potentially fix this but it // window, and only admins should have access to the item with this ability
// would require some tweaks to the CharacterUpdater code (to be able to deque the pending // in the first place (though that isn't foolproof)). We could potentially fix
// persistence request issued here if repossesing the original character), and it seems // this but it would require some tweaks to the CharacterUpdater code
// prudent to be more conservative with making changes there to support this feature. // (to be able to deque the pending persistence request issued here if
// repossesing the original character), and it seems prudent to be more
// conservative with making changes there to support this feature.
let possessor = persist_entity(state, possessor); let possessor = persist_entity(state, possessor);
let ecs = state.ecs(); let ecs = state.ecs();
let mut clients = ecs.write_storage::<Client>(); let mut clients = ecs.write_storage::<Client>();
// Transfer client component. Note: we require this component for possession. // Transfer client component. Note: we require this component for possession.
let client = clients.remove(possessor).expect("Checked client component was present above!"); let client = clients
.remove(possessor)
.expect("Checked client component was present above!");
client.send_fallible(ServerGeneral::SetPlayerEntity(possesse_uid)); client.send_fallible(ServerGeneral::SetPlayerEntity(possesse_uid));
// Note: we check that the `possessor` and `possesse` entities exist above, so // Note: we check that the `possessor` and `possesse` entities exist above, so
// this should never panic. // this should never panic.
clients.insert(possesse, client).expect("Checked entity was alive!"); clients
.insert(possesse, client)
.expect("Checked entity was alive!");
// Other components to transfer if they exist. // Other components to transfer if they exist.
fn transfer_component<C: specs::Component>( fn transfer_component<C: specs::Component>(
@ -483,9 +489,9 @@ pub fn handle_possess(server: &mut Server, possessor_uid: Uid, possesse_uid: Uid
} }
} }
// Outside block above to prevent borrow conflicts (i.e. convenient to let everything drop at // Outside block above to prevent borrow conflicts (i.e. convenient to let
// the end of the block rather than doing it manually for this). // everything drop at the end of the block rather than doing it manually for
// See note on `persist_entity` call above for why we do this. // this). See note on `persist_entity` call above for why we do this.
if let Some(entity) = delete_entity { if let Some(entity) = delete_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) {

View File

@ -57,7 +57,7 @@ impl Default for ServerProfile {
#[serde(default)] #[serde(default)]
pub struct Profile { pub struct Profile {
pub servers: HashMap<String, ServerProfile>, pub servers: HashMap<String, ServerProfile>,
/// Temporary character profiler, used when it should /// Temporary character profile, used when it should
/// not be persisted to the disk. /// not be persisted to the disk.
#[serde(skip)] #[serde(skip)]
pub transient_character: Option<CharacterProfile>, pub transient_character: Option<CharacterProfile>,