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
|
||||
- Functional group-system with exp-sharing and disabled damage to group members
|
||||
|
||||
|
||||
### Changed
|
||||
|
||||
- Improved camera aiming
|
||||
|
@ -21,9 +21,9 @@ use common::{
|
||||
InventoryManip, InventoryUpdateEvent,
|
||||
},
|
||||
msg::{
|
||||
validate_chat_msg, ChatMsgValidationError, ClientMsg, ClientState, Notification,
|
||||
PlayerInfo, PlayerListUpdate, RegisterError, RequestStateError, ServerInfo, ServerMsg,
|
||||
MAX_BYTES_CHAT_MSG, InviteAnswer,
|
||||
validate_chat_msg, ChatMsgValidationError, ClientMsg, ClientState, InviteAnswer,
|
||||
Notification, PlayerInfo, PlayerListUpdate, RegisterError, RequestStateError, ServerInfo,
|
||||
ServerMsg, MAX_BYTES_CHAT_MSG,
|
||||
},
|
||||
recipe::RecipeBook,
|
||||
state::State,
|
||||
@ -135,7 +135,8 @@ impl Client {
|
||||
let mut stream = block_on(participant.open(10, PROMISES_ORDERED | PROMISES_CONSISTENCY))?;
|
||||
|
||||
// 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 {
|
||||
match stream.recv().await? {
|
||||
ServerMsg::InitialSync {
|
||||
@ -149,8 +150,8 @@ impl Client {
|
||||
// TODO: Display that versions don't match in Voxygen
|
||||
if &server_info.git_hash != *common::util::GIT_HASH {
|
||||
warn!(
|
||||
"Server is running {}[{}], you are running {}[{}], versions might \
|
||||
be incompatible!",
|
||||
"Server is running {}[{}], you are running {}[{}], versions \
|
||||
might be incompatible!",
|
||||
server_info.git_hash,
|
||||
server_info.git_date,
|
||||
common::util::GIT_HASH.to_string(),
|
||||
@ -203,7 +204,8 @@ impl Client {
|
||||
},
|
||||
}
|
||||
}
|
||||
})?;
|
||||
},
|
||||
)?;
|
||||
|
||||
stream.send(ClientMsg::Ping)?;
|
||||
|
||||
@ -443,7 +445,9 @@ impl Client {
|
||||
|
||||
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)> {
|
||||
self.group_leader.map(|l| ("Group".into(), l)) // TODO
|
||||
@ -772,7 +776,10 @@ impl Client {
|
||||
|
||||
// 3) Update client local data
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -1029,10 +1036,13 @@ impl Client {
|
||||
// Check if this is a newly formed group by looking for absence of
|
||||
// other non pet group members
|
||||
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(
|
||||
"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) {
|
||||
@ -1079,10 +1089,13 @@ impl Client {
|
||||
if !self.pending_invites.insert(uid) {
|
||||
warn!("Received message about pending invite that was already pending");
|
||||
}
|
||||
}
|
||||
},
|
||||
ServerMsg::InviteComplete { target, answer } => {
|
||||
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
|
||||
// through the chat
|
||||
@ -1093,7 +1106,7 @@ impl Client {
|
||||
InviteAnswer::TimedOut => "Invite timed out",
|
||||
};
|
||||
frontend_events.push(Event::Chat(comp::ChatType::Meta.chat_msg(msg)));
|
||||
}
|
||||
},
|
||||
ServerMsg::Ping => {
|
||||
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
|
||||
let groups = state.ecs().read_storage::<Group>();
|
||||
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_info(*group)
|
||||
.map_or(false, |g| g.leader == entity)
|
||||
&& groups.get(invitee) == Some(group)
|
||||
}) {
|
||||
});
|
||||
if already_in_same_group {
|
||||
// Inform of failure
|
||||
if let Some(client) = clients.get_mut(entity) {
|
||||
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
|
||||
// Adding the current number of pending invites
|
||||
if state
|
||||
let group_size_limit_reached = state
|
||||
.ecs()
|
||||
.read_storage()
|
||||
.get(entity)
|
||||
@ -88,8 +89,8 @@ pub fn handle_group(server: &mut Server, entity: specs::Entity, manip: GroupMani
|
||||
})
|
||||
.unwrap_or(1) as usize
|
||||
+ 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
|
||||
if let Some(client) = clients.get_mut(entity) {
|
||||
client.notify(
|
||||
@ -161,13 +162,11 @@ pub fn handle_group(server: &mut Server, entity: specs::Entity, manip: GroupMani
|
||||
}
|
||||
} else if agents.contains(invitee) {
|
||||
send_invite();
|
||||
} else {
|
||||
if let Some(client) = clients.get_mut(entity) {
|
||||
} else if let Some(client) = clients.get_mut(entity) {
|
||||
client.notify(
|
||||
ChatType::Meta.server_msg("Can't invite, not a player or npc".to_owned()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Notify inviter that the invite is pending
|
||||
if invite_sent {
|
||||
|
@ -509,13 +509,18 @@ impl Server {
|
||||
.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 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
|
||||
.state
|
||||
.ecs()
|
||||
.read_resource::<sys::PersistenceTimer>()
|
||||
.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
|
||||
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: Always send health, energy, level and position of group members to the
|
||||
// client
|
||||
#[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 {
|
||||
let widget::UpdateArgs { state, ui, .. } = args;
|
||||
|
||||
@ -326,11 +326,11 @@ impl<'a> Widget for Group<'a> {
|
||||
21..=40 => LOW_HP_COLOR,
|
||||
_ => HP_COLOR,
|
||||
};
|
||||
let lead = if uid == leader { true } else { false };
|
||||
let is_leader = uid == leader;
|
||||
// Don't show panel for the player!
|
||||
// Panel BG
|
||||
back.w_h(152.0, 36.0)
|
||||
.color(if lead {
|
||||
.color(if is_leader {
|
||||
Some(ERROR_COLOR)
|
||||
} else {
|
||||
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)
|
||||
.font_size(20)
|
||||
.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
|
||||
.set(state.ids.member_panels_txt[i], ui);
|
||||
if let Some(energy) = energy {
|
||||
|
@ -1186,7 +1186,8 @@ impl<'a> Widget for Skillbar<'a> {
|
||||
if let BarNumbers::Values = bar_values {
|
||||
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
|
||||
);
|
||||
let mut energy_text = format!(
|
||||
|
Loading…
x
Reference in New Issue
Block a user