mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Address MR 2126 comments.
This commit is contained in:
parent
bf6ac56eb0
commit
2fb7575d60
@ -48,7 +48,7 @@
|
||||
"hud.settings.free_look_behavior": "Free look behavior",
|
||||
"hud.settings.auto_walk_behavior": "Auto walk behavior",
|
||||
"hud.settings.camera_clamp_behavior": "Camera clamp behavior",
|
||||
"hud.settings.player_physics_behavior": "Player physics behavior",
|
||||
"hud.settings.player_physics_behavior": "Player physics (experimental)",
|
||||
"hud.settings.stop_auto_walk_on_input": "Stop auto walk on movement",
|
||||
"hud.settings.auto_camera": "Auto camera",
|
||||
"hud.settings.reset_gameplay": "Reset to Defaults",
|
||||
|
@ -33,27 +33,27 @@ pub enum GameMode {
|
||||
#[derive(Copy, Clone, Default, Debug)]
|
||||
pub struct PlayerEntity(pub Option<Entity>);
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct PlayerPhysicsSetting {
|
||||
/// true if the client wants server-authoratative physics (e.g. to use
|
||||
/// airships properly)
|
||||
pub client_optin: bool,
|
||||
/// true if the server is forcing server-authoratative physics (e.g. as
|
||||
/// punishment for wallhacking)
|
||||
pub server_optout: bool,
|
||||
pub server_force: bool,
|
||||
}
|
||||
|
||||
impl Default for PlayerPhysicsSetting {
|
||||
fn default() -> PlayerPhysicsSetting {
|
||||
PlayerPhysicsSetting {
|
||||
client_optin: false,
|
||||
server_optout: false,
|
||||
server_force: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PlayerPhysicsSetting {
|
||||
pub fn server_authoritative(&self) -> bool { self.client_optin || self.server_optout }
|
||||
pub fn server_authoritative(&self) -> bool { self.client_optin || self.server_force }
|
||||
|
||||
pub fn client_authoritative(&self) -> bool { !self.server_authoritative() }
|
||||
}
|
||||
|
@ -205,25 +205,24 @@ impl<'a> System<'a> for Sys {
|
||||
for (client, _, client_entity, client_pos) in &mut subscribers {
|
||||
let mut comp_sync_package = CompSyncPackage::new();
|
||||
|
||||
for (_, entity, &uid, (&pos, last_pos), vel, ori, force_update, collider, player) in
|
||||
(
|
||||
region.entities(),
|
||||
&entities,
|
||||
&uids,
|
||||
(&positions, last_pos.mask().maybe()),
|
||||
(&velocities, last_vel.mask().maybe()).maybe(),
|
||||
(&orientations, last_vel.mask().maybe()).maybe(),
|
||||
force_updates.mask().maybe(),
|
||||
colliders.maybe(),
|
||||
players.maybe(),
|
||||
)
|
||||
.join()
|
||||
for (_, entity, &uid, (&pos, last_pos), vel, ori, force_update, collider) in (
|
||||
region.entities(),
|
||||
&entities,
|
||||
&uids,
|
||||
(&positions, last_pos.mask().maybe()),
|
||||
(&velocities, last_vel.mask().maybe()).maybe(),
|
||||
(&orientations, last_vel.mask().maybe()).maybe(),
|
||||
force_updates.mask().maybe(),
|
||||
colliders.maybe(),
|
||||
)
|
||||
.join()
|
||||
{
|
||||
let player_physics_setting = player
|
||||
.and_then(|p| player_physics_settings.settings.get(&p.uuid()).cloned())
|
||||
.unwrap_or_default();
|
||||
// Decide how regularly to send physics updates.
|
||||
let send_now = if client_entity == &entity {
|
||||
let player_physics_setting = players
|
||||
.get(entity)
|
||||
.and_then(|p| player_physics_settings.settings.get(&p.uuid()).copied())
|
||||
.unwrap_or_default();
|
||||
// Don't send client physics updates about itself unless force update is set
|
||||
// or the client is subject to server-authoritative physics
|
||||
force_update.is_some() || player_physics_setting.server_authoritative()
|
||||
|
@ -45,12 +45,6 @@ impl Sys {
|
||||
return Ok(());
|
||||
},
|
||||
};
|
||||
let player_physics_setting = maybe_player.map(|p| {
|
||||
player_physics_settings
|
||||
.settings
|
||||
.entry(p.uuid())
|
||||
.or_default()
|
||||
});
|
||||
match msg {
|
||||
// Go back to registered state (char selection screen)
|
||||
ClientGeneral::ExitInGame => {
|
||||
@ -104,6 +98,12 @@ impl Sys {
|
||||
}
|
||||
},
|
||||
ClientGeneral::PlayerPhysics { pos, vel, ori } => {
|
||||
let player_physics_setting = maybe_player.map(|p| {
|
||||
player_physics_settings
|
||||
.settings
|
||||
.entry(p.uuid())
|
||||
.or_default()
|
||||
});
|
||||
if matches!(presence.kind, PresenceKind::Character(_))
|
||||
&& force_updates.get(entity).is_none()
|
||||
&& healths.get(entity).map_or(true, |h| !h.is_dead)
|
||||
@ -119,8 +119,8 @@ impl Sys {
|
||||
// live server (and also mitigates some floating-point overflow crashes)
|
||||
if let Some(prev_pos) = positions.get(entity) {
|
||||
let value_squared = prev_pos.0.distance_squared(pos.0);
|
||||
if value_squared > (500.0f32).powf(2.0) {
|
||||
setting.server_optout = true;
|
||||
if value_squared > (5000.0f32).powf(2.0) {
|
||||
setting.server_force = true;
|
||||
reject_update = true;
|
||||
warn!(
|
||||
"PlayerPhysics position exceeded {:?} {:?} {:?}",
|
||||
@ -132,7 +132,7 @@ impl Sys {
|
||||
}
|
||||
|
||||
if vel.0.magnitude_squared() > (500.0f32).powf(2.0) {
|
||||
setting.server_optout = true;
|
||||
setting.server_force = true;
|
||||
reject_update = true;
|
||||
warn!(
|
||||
"PlayerPhysics velocity exceeded {:?} {:?}",
|
||||
@ -211,6 +211,12 @@ impl Sys {
|
||||
ClientGeneral::RequestPlayerPhysics {
|
||||
server_authoritative,
|
||||
} => {
|
||||
let player_physics_setting = maybe_player.map(|p| {
|
||||
player_physics_settings
|
||||
.settings
|
||||
.entry(p.uuid())
|
||||
.or_default()
|
||||
});
|
||||
if let Some(setting) = player_physics_setting {
|
||||
setting.client_optin = server_authoritative;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user