mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-05-18 09:35:50 +00:00
[Protocol] Fix an instance of unwrapping in The Ship
This commit is contained in:
parent
7e028ce97d
commit
a8fc67412c
2 changed files with 8 additions and 5 deletions
|
|
@ -4,6 +4,7 @@ use crate::{
|
|||
valve::{self, get_optional_extracted_data, Server, ServerPlayer, SteamApp},
|
||||
GenericResponse,
|
||||
},
|
||||
GDErrorKind::PacketBad,
|
||||
GDResult,
|
||||
};
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
|
|
@ -90,12 +91,12 @@ impl CommonResponse for Response {
|
|||
}
|
||||
|
||||
impl Response {
|
||||
pub fn new_from_valve_response(response: valve::Response) -> Self {
|
||||
pub fn new_from_valve_response(response: valve::Response) -> GDResult<Self> {
|
||||
let (port, steam_id, tv_port, tv_name, keywords) = get_optional_extracted_data(response.info.extra_data);
|
||||
|
||||
let the_unwrapped_ship = response.info.the_ship.unwrap(); // TODO! Err here!
|
||||
let the_unwrapped_ship = response.info.the_ship.ok_or(PacketBad)?;
|
||||
|
||||
Self {
|
||||
Ok(Self {
|
||||
protocol_version: response.info.protocol_version,
|
||||
name: response.info.name,
|
||||
map: response.info.map,
|
||||
|
|
@ -122,7 +123,7 @@ impl Response {
|
|||
mode: the_unwrapped_ship.mode,
|
||||
witnesses: the_unwrapped_ship.witnesses,
|
||||
duration: the_unwrapped_ship.duration,
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -140,5 +141,5 @@ pub fn query_with_timeout(
|
|||
timeout_settings,
|
||||
)?;
|
||||
|
||||
Ok(Response::new_from_valve_response(valve_response))
|
||||
Response::new_from_valve_response(valve_response)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue