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