mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Make clippy happy, fmt even though it is set to fmt on save in my
editor...."
This commit is contained in:
parent
2faa1cd6c1
commit
2608217e83
@ -52,7 +52,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Add detection of entities under the cursor
|
- Add detection of entities under the cursor
|
||||||
- Functional group-system with exp-sharing and disabled damage to group members
|
- Functional group-system with exp-sharing and disabled damage to group members
|
||||||
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Improved camera aiming
|
- Improved camera aiming
|
||||||
|
@ -21,9 +21,9 @@ use common::{
|
|||||||
InventoryManip, InventoryUpdateEvent,
|
InventoryManip, InventoryUpdateEvent,
|
||||||
},
|
},
|
||||||
msg::{
|
msg::{
|
||||||
validate_chat_msg, ChatMsgValidationError, ClientMsg, ClientState, Notification,
|
validate_chat_msg, ChatMsgValidationError, ClientMsg, ClientState, InviteAnswer,
|
||||||
PlayerInfo, PlayerListUpdate, RegisterError, RequestStateError, ServerInfo, ServerMsg,
|
Notification, PlayerInfo, PlayerListUpdate, RegisterError, RequestStateError, ServerInfo,
|
||||||
MAX_BYTES_CHAT_MSG, InviteAnswer,
|
ServerMsg, MAX_BYTES_CHAT_MSG,
|
||||||
},
|
},
|
||||||
recipe::RecipeBook,
|
recipe::RecipeBook,
|
||||||
state::State,
|
state::State,
|
||||||
@ -135,7 +135,8 @@ impl Client {
|
|||||||
let mut stream = block_on(participant.open(10, PROMISES_ORDERED | PROMISES_CONSISTENCY))?;
|
let mut stream = block_on(participant.open(10, PROMISES_ORDERED | PROMISES_CONSISTENCY))?;
|
||||||
|
|
||||||
// Wait for initial sync
|
// Wait for initial sync
|
||||||
let (state, entity, server_info, world_map, recipe_book, max_group_size) = block_on(async {
|
let (state, entity, server_info, world_map, recipe_book, max_group_size) = block_on(
|
||||||
|
async {
|
||||||
loop {
|
loop {
|
||||||
match stream.recv().await? {
|
match stream.recv().await? {
|
||||||
ServerMsg::InitialSync {
|
ServerMsg::InitialSync {
|
||||||
@ -149,8 +150,8 @@ impl Client {
|
|||||||
// TODO: Display that versions don't match in Voxygen
|
// TODO: Display that versions don't match in Voxygen
|
||||||
if &server_info.git_hash != *common::util::GIT_HASH {
|
if &server_info.git_hash != *common::util::GIT_HASH {
|
||||||
warn!(
|
warn!(
|
||||||
"Server is running {}[{}], you are running {}[{}], versions might \
|
"Server is running {}[{}], you are running {}[{}], versions \
|
||||||
be incompatible!",
|
might be incompatible!",
|
||||||
server_info.git_hash,
|
server_info.git_hash,
|
||||||
server_info.git_date,
|
server_info.git_date,
|
||||||
common::util::GIT_HASH.to_string(),
|
common::util::GIT_HASH.to_string(),
|
||||||
@ -203,7 +204,8 @@ impl Client {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})?;
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
stream.send(ClientMsg::Ping)?;
|
stream.send(ClientMsg::Ping)?;
|
||||||
|
|
||||||
@ -443,7 +445,9 @@ impl Client {
|
|||||||
|
|
||||||
pub fn max_group_size(&self) -> u32 { self.max_group_size }
|
pub fn max_group_size(&self) -> u32 { self.max_group_size }
|
||||||
|
|
||||||
pub fn group_invite(&self) -> Option<(Uid, std::time::Instant, std::time::Duration)> { self.group_invite }
|
pub fn group_invite(&self) -> Option<(Uid, std::time::Instant, std::time::Duration)> {
|
||||||
|
self.group_invite
|
||||||
|
}
|
||||||
|
|
||||||
pub fn group_info(&self) -> Option<(String, Uid)> {
|
pub fn group_info(&self) -> Option<(String, Uid)> {
|
||||||
self.group_leader.map(|l| ("Group".into(), l)) // TODO
|
self.group_leader.map(|l| ("Group".into(), l)) // TODO
|
||||||
@ -772,7 +776,10 @@ impl Client {
|
|||||||
|
|
||||||
// 3) Update client local data
|
// 3) Update client local data
|
||||||
// Check if the group invite has timed out and remove if so
|
// Check if the group invite has timed out and remove if so
|
||||||
if self.group_invite.map_or(false, |(_, timeout, dur)| timeout.elapsed() > dur) {
|
if self
|
||||||
|
.group_invite
|
||||||
|
.map_or(false, |(_, timeout, dur)| timeout.elapsed() > dur)
|
||||||
|
{
|
||||||
self.group_invite = None;
|
self.group_invite = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1029,10 +1036,13 @@ impl Client {
|
|||||||
// Check if this is a newly formed group by looking for absence of
|
// Check if this is a newly formed group by looking for absence of
|
||||||
// other non pet group members
|
// other non pet group members
|
||||||
if !matches!(role, group::Role::Pet)
|
if !matches!(role, group::Role::Pet)
|
||||||
&& !self.group_members.values().any(|r| !matches!(r, group::Role::Pet))
|
&& !self
|
||||||
|
.group_members
|
||||||
|
.values()
|
||||||
|
.any(|r| !matches!(r, group::Role::Pet))
|
||||||
{
|
{
|
||||||
frontend_events.push(Event::Chat(comp::ChatType::Meta.chat_msg(
|
frontend_events.push(Event::Chat(comp::ChatType::Meta.chat_msg(
|
||||||
"Type /g or /group to chat with your group members"
|
"Type /g or /group to chat with your group members",
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
if self.group_members.insert(uid, role) == Some(role) {
|
if self.group_members.insert(uid, role) == Some(role) {
|
||||||
@ -1079,10 +1089,13 @@ impl Client {
|
|||||||
if !self.pending_invites.insert(uid) {
|
if !self.pending_invites.insert(uid) {
|
||||||
warn!("Received message about pending invite that was already pending");
|
warn!("Received message about pending invite that was already pending");
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
ServerMsg::InviteComplete { target, answer } => {
|
ServerMsg::InviteComplete { target, answer } => {
|
||||||
if !self.pending_invites.remove(&target) {
|
if !self.pending_invites.remove(&target) {
|
||||||
warn!("Received completed invite message for invite that was not in the list of pending invites")
|
warn!(
|
||||||
|
"Received completed invite message for invite that was not in the \
|
||||||
|
list of pending invites"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
// TODO: expose this as a new event variant instead of going
|
// TODO: expose this as a new event variant instead of going
|
||||||
// through the chat
|
// through the chat
|
||||||
@ -1093,7 +1106,7 @@ impl Client {
|
|||||||
InviteAnswer::TimedOut => "Invite timed out",
|
InviteAnswer::TimedOut => "Invite timed out",
|
||||||
};
|
};
|
||||||
frontend_events.push(Event::Chat(comp::ChatType::Meta.chat_msg(msg)));
|
frontend_events.push(Event::Chat(comp::ChatType::Meta.chat_msg(msg)));
|
||||||
}
|
},
|
||||||
ServerMsg::Ping => {
|
ServerMsg::Ping => {
|
||||||
self.singleton_stream.send(ClientMsg::Pong)?;
|
self.singleton_stream.send(ClientMsg::Pong)?;
|
||||||
},
|
},
|
||||||
|
@ -54,12 +54,13 @@ pub fn handle_group(server: &mut Server, entity: specs::Entity, manip: GroupMani
|
|||||||
// Disallow inviting entity that is already in your group
|
// Disallow inviting entity that is already in your group
|
||||||
let groups = state.ecs().read_storage::<Group>();
|
let groups = state.ecs().read_storage::<Group>();
|
||||||
let group_manager = state.ecs().read_resource::<GroupManager>();
|
let group_manager = state.ecs().read_resource::<GroupManager>();
|
||||||
if groups.get(entity).map_or(false, |group| {
|
let already_in_same_group = groups.get(entity).map_or(false, |group| {
|
||||||
group_manager
|
group_manager
|
||||||
.group_info(*group)
|
.group_info(*group)
|
||||||
.map_or(false, |g| g.leader == entity)
|
.map_or(false, |g| g.leader == entity)
|
||||||
&& groups.get(invitee) == Some(group)
|
&& groups.get(invitee) == Some(group)
|
||||||
}) {
|
});
|
||||||
|
if already_in_same_group {
|
||||||
// Inform of failure
|
// Inform of failure
|
||||||
if let Some(client) = clients.get_mut(entity) {
|
if let Some(client) = clients.get_mut(entity) {
|
||||||
client.notify(ChatType::Meta.server_msg(
|
client.notify(ChatType::Meta.server_msg(
|
||||||
@ -73,7 +74,7 @@ pub fn handle_group(server: &mut Server, entity: specs::Entity, manip: GroupMani
|
|||||||
|
|
||||||
// Check if group max size is already reached
|
// Check if group max size is already reached
|
||||||
// Adding the current number of pending invites
|
// Adding the current number of pending invites
|
||||||
if state
|
let group_size_limit_reached = state
|
||||||
.ecs()
|
.ecs()
|
||||||
.read_storage()
|
.read_storage()
|
||||||
.get(entity)
|
.get(entity)
|
||||||
@ -88,8 +89,8 @@ pub fn handle_group(server: &mut Server, entity: specs::Entity, manip: GroupMani
|
|||||||
})
|
})
|
||||||
.unwrap_or(1) as usize
|
.unwrap_or(1) as usize
|
||||||
+ pending_invites.get(entity).map_or(0, |p| p.0.len())
|
+ pending_invites.get(entity).map_or(0, |p| p.0.len())
|
||||||
>= max_group_size as usize
|
>= max_group_size as usize;
|
||||||
{
|
if group_size_limit_reached {
|
||||||
// Inform inviter that they have reached the group size limit
|
// Inform inviter that they have reached the group size limit
|
||||||
if let Some(client) = clients.get_mut(entity) {
|
if let Some(client) = clients.get_mut(entity) {
|
||||||
client.notify(
|
client.notify(
|
||||||
@ -161,13 +162,11 @@ pub fn handle_group(server: &mut Server, entity: specs::Entity, manip: GroupMani
|
|||||||
}
|
}
|
||||||
} else if agents.contains(invitee) {
|
} else if agents.contains(invitee) {
|
||||||
send_invite();
|
send_invite();
|
||||||
} else {
|
} else if let Some(client) = clients.get_mut(entity) {
|
||||||
if let Some(client) = clients.get_mut(entity) {
|
|
||||||
client.notify(
|
client.notify(
|
||||||
ChatType::Meta.server_msg("Can't invite, not a player or npc".to_owned()),
|
ChatType::Meta.server_msg("Can't invite, not a player or npc".to_owned()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Notify inviter that the invite is pending
|
// Notify inviter that the invite is pending
|
||||||
if invite_sent {
|
if invite_sent {
|
||||||
|
@ -509,13 +509,18 @@ impl Server {
|
|||||||
.nanos as i64;
|
.nanos as i64;
|
||||||
let terrain_nanos = self.state.ecs().read_resource::<sys::TerrainTimer>().nanos as i64;
|
let terrain_nanos = self.state.ecs().read_resource::<sys::TerrainTimer>().nanos as i64;
|
||||||
let waypoint_nanos = self.state.ecs().read_resource::<sys::WaypointTimer>().nanos as i64;
|
let waypoint_nanos = self.state.ecs().read_resource::<sys::WaypointTimer>().nanos as i64;
|
||||||
let invite_timeout_nanos = self.state.ecs().read_resource::<sys::InviteTimeoutTimer>().nanos as i64;
|
let invite_timeout_nanos = self
|
||||||
|
.state
|
||||||
|
.ecs()
|
||||||
|
.read_resource::<sys::InviteTimeoutTimer>()
|
||||||
|
.nanos as i64;
|
||||||
let stats_persistence_nanos = self
|
let stats_persistence_nanos = self
|
||||||
.state
|
.state
|
||||||
.ecs()
|
.ecs()
|
||||||
.read_resource::<sys::PersistenceTimer>()
|
.read_resource::<sys::PersistenceTimer>()
|
||||||
.nanos as i64;
|
.nanos as i64;
|
||||||
let total_sys_ran_in_dispatcher_nanos = terrain_nanos + waypoint_nanos + invite_timeout_nanos;
|
let total_sys_ran_in_dispatcher_nanos =
|
||||||
|
terrain_nanos + waypoint_nanos + invite_timeout_nanos;
|
||||||
|
|
||||||
// Report timing info
|
// Report timing info
|
||||||
self.tick_metrics
|
self.tick_metrics
|
||||||
|
@ -118,13 +118,13 @@ impl<'a> Widget for Group<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::blocks_in_if_conditions)] // TODO: Pending review in #587
|
fn style(&self) -> Self::Style {}
|
||||||
fn style(&self) -> Self::Style { () }
|
|
||||||
|
|
||||||
//TODO: Disband groups when there's only one member in them
|
//TODO: Disband groups when there's only one member in them
|
||||||
//TODO: Always send health, energy, level and position of group members to the
|
//TODO: Always send health, energy, level and position of group members to the
|
||||||
// client
|
// client
|
||||||
#[allow(clippy::unused_unit)] // TODO: Pending review in #587
|
#[allow(clippy::unused_unit)] // TODO: Pending review in #587
|
||||||
|
#[allow(clippy::blocks_in_if_conditions)] // TODO: Pending review in #587
|
||||||
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
|
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
|
||||||
let widget::UpdateArgs { state, ui, .. } = args;
|
let widget::UpdateArgs { state, ui, .. } = args;
|
||||||
|
|
||||||
@ -326,11 +326,11 @@ impl<'a> Widget for Group<'a> {
|
|||||||
21..=40 => LOW_HP_COLOR,
|
21..=40 => LOW_HP_COLOR,
|
||||||
_ => HP_COLOR,
|
_ => HP_COLOR,
|
||||||
};
|
};
|
||||||
let lead = if uid == leader { true } else { false };
|
let is_leader = uid == leader;
|
||||||
// Don't show panel for the player!
|
// Don't show panel for the player!
|
||||||
// Panel BG
|
// Panel BG
|
||||||
back.w_h(152.0, 36.0)
|
back.w_h(152.0, 36.0)
|
||||||
.color(if lead {
|
.color(if is_leader {
|
||||||
Some(ERROR_COLOR)
|
Some(ERROR_COLOR)
|
||||||
} else {
|
} else {
|
||||||
Some(TEXT_COLOR)
|
Some(TEXT_COLOR)
|
||||||
@ -396,7 +396,7 @@ impl<'a> Widget for Group<'a> {
|
|||||||
.bottom_left_with_margins_on(state.ids.member_panels_txt_bg[i], 2.0, 2.0)
|
.bottom_left_with_margins_on(state.ids.member_panels_txt_bg[i], 2.0, 2.0)
|
||||||
.font_size(20)
|
.font_size(20)
|
||||||
.font_id(self.fonts.cyri.conrod_id)
|
.font_id(self.fonts.cyri.conrod_id)
|
||||||
.color(if lead { ERROR_COLOR } else { GROUP_COLOR })
|
.color(if is_leader { ERROR_COLOR } else { GROUP_COLOR })
|
||||||
.w(300.0) // limit name length display
|
.w(300.0) // limit name length display
|
||||||
.set(state.ids.member_panels_txt[i], ui);
|
.set(state.ids.member_panels_txt[i], ui);
|
||||||
if let Some(energy) = energy {
|
if let Some(energy) = energy {
|
||||||
|
@ -1186,7 +1186,8 @@ impl<'a> Widget for Skillbar<'a> {
|
|||||||
if let BarNumbers::Values = bar_values {
|
if let BarNumbers::Values = bar_values {
|
||||||
let mut hp_text = format!(
|
let mut hp_text = format!(
|
||||||
"{}/{}",
|
"{}/{}",
|
||||||
(self.stats.health.current() / 10).max(1) as u32, // Don't show 0 health for living players
|
(self.stats.health.current() / 10).max(1) as u32, /* Don't show 0 health for
|
||||||
|
* living players */
|
||||||
(self.stats.health.maximum() / 10) as u32
|
(self.stats.health.maximum() / 10) as u32
|
||||||
);
|
);
|
||||||
let mut energy_text = format!(
|
let mut energy_text = format!(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user