protocol: fix build with MSRV
This commit is contained in:
parent
33d6d19bb4
commit
ed4591559f
@ -146,8 +146,8 @@ impl<T> Entry<T> {
|
||||
}
|
||||
|
||||
impl Entry<ServerInfo> {
|
||||
fn matches<Addr: AddrExt>(&self, addr: Addr, region: Region, filter: &Filter) -> bool {
|
||||
self.region == region && filter.matches(addr.wrap(), &self.value)
|
||||
fn matches(&self, region: Region, filter: &Filter) -> bool {
|
||||
self.region == region && filter.matches(&self.value)
|
||||
}
|
||||
}
|
||||
|
||||
@ -448,9 +448,9 @@ impl<Addr: AddrExt> MasterServer<Addr> {
|
||||
self.filtered_servers_nat.clear();
|
||||
self.servers
|
||||
.iter()
|
||||
.filter(|(addr, info)| {
|
||||
.filter(|(_addr, info)| {
|
||||
info.is_valid(now, self.timeout.server)
|
||||
&& info.matches(**addr, p.region, &p.filter)
|
||||
&& info.matches(p.region, &p.filter)
|
||||
})
|
||||
.for_each(|(addr, info)| {
|
||||
self.filtered_servers.push(*addr);
|
||||
|
@ -15,7 +15,7 @@ repository = "https://git.mentality.rip/numas13/xash3d-master"
|
||||
default = ["std", "net"]
|
||||
std = ["alloc"]
|
||||
alloc = []
|
||||
net = []
|
||||
net = ["std"]
|
||||
|
||||
[dependencies]
|
||||
log = "0.4.18"
|
||||
|
@ -49,7 +49,8 @@ impl fmt::Display for CursorError {
|
||||
}
|
||||
}
|
||||
|
||||
impl core::error::Error for CursorError {}
|
||||
#[cfg(feature = "std")]
|
||||
impl std::error::Error for CursorError {}
|
||||
|
||||
pub type Result<T, E = CursorError> = core::result::Result<T, E>;
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
//! * Do not have bots
|
||||
//! * Is not protected by a password
|
||||
|
||||
use core::{fmt, net::SocketAddr, str::FromStr};
|
||||
use core::{fmt, str::FromStr};
|
||||
|
||||
use bitflags::bitflags;
|
||||
|
||||
@ -203,11 +203,10 @@ impl Filter<'_> {
|
||||
}
|
||||
|
||||
/// Returns `true` if a server matches the filter.
|
||||
pub fn matches<T>(&self, _addr: SocketAddr, info: &ServerInfo<T>) -> bool
|
||||
pub fn matches<T>(&self, info: &ServerInfo<T>) -> bool
|
||||
where
|
||||
T: AsRef<[u8]>,
|
||||
{
|
||||
// TODO: match addr
|
||||
!((info.flags & self.flags_mask) != self.flags
|
||||
|| self.gamedir.map_or(false, |s| *s != info.gamedir.as_ref())
|
||||
|| self.map.map_or(false, |s| *s != info.map.as_ref())
|
||||
@ -498,7 +497,7 @@ mod match_tests {
|
||||
let iter = servers
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, (addr, server))| filter.matches(*addr, &server))
|
||||
.filter(|(_, (_addr, server))| filter.matches(&server))
|
||||
.map(|(i, _)| i);
|
||||
assert_eq!(iter.collect::<Vec<_>>(), [$($expected),*])
|
||||
);
|
||||
|
@ -85,7 +85,8 @@ impl fmt::Display for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl core::error::Error for Error {}
|
||||
#[cfg(feature = "std")]
|
||||
impl std::error::Error for Error {}
|
||||
|
||||
impl From<CursorError> for Error {
|
||||
fn from(source: CursorError) -> Self {
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
//! Game client packets.
|
||||
|
||||
use core::{fmt, net::SocketAddr};
|
||||
use std::{fmt, net::SocketAddr};
|
||||
|
||||
use crate::{
|
||||
cursor::{Cursor, CursorMut},
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
//! Master server packets.
|
||||
|
||||
use core::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
|
||||
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
|
||||
|
||||
use crate::{
|
||||
cursor::{Cursor, CursorMut},
|
||||
|
Reference in New Issue
Block a user