mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
Changed uses to have a better structure
This commit is contained in:
parent
c0d07cf6f9
commit
3ac6a8b603
18 changed files with 113 additions and 97 deletions
|
|
@ -3,7 +3,8 @@ Who knows what the future holds...
|
||||||
|
|
||||||
# 0.0.4 - ??/??/????
|
# 0.0.4 - ??/??/????
|
||||||
Queries now support DNS resolve.
|
Queries now support DNS resolve.
|
||||||
Changed Valve Protocol parameters to (ip, port, app, gather_settings), changes include:
|
Changed uses a bit, from `use gamedig::valve::ValveProtocol::query` to `use gamedig::protocols::valve::query`.
|
||||||
|
Changed Valve Protocol Query parameters to (ip, port, app, gather_settings), changes include:
|
||||||
- the app is now optional, being None means to anonymously query the server.
|
- the app is now optional, being None means to anonymously query the server.
|
||||||
- gather_settings is now also an optional, being None means all query settings.
|
- gather_settings is now also an optional, being None means all query settings.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use gamedig::{aliens, asrd, csgo, css, dods, gm, hl2dm, ins, insmic, inss, l4d, l4d2, tf2, ts};
|
use gamedig::{aliens, asrd, csgo, css, dods, gm, hl2dm, ins, insmic, inss, l4d, l4d2, tf2, ts};
|
||||||
use gamedig::valve::ValveProtocol;
|
use gamedig::protocols::valve;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
|
|
@ -38,7 +38,7 @@ fn main() {
|
||||||
"l4d" => println!("{:?}", l4d::query(ip, port)),
|
"l4d" => println!("{:?}", l4d::query(ip, port)),
|
||||||
"l4d2" => println!("{:?}", l4d2::query(ip, port)),
|
"l4d2" => println!("{:?}", l4d2::query(ip, port)),
|
||||||
"ts" => println!("{:?}", ts::query(ip, port)),
|
"ts" => println!("{:?}", ts::query(ip, port)),
|
||||||
"_" => println!("{:?}", ValveProtocol::query(ip, 27015, None, None)),
|
"_" => println!("{:?}", valve::query(ip, 27015, None, None)),
|
||||||
_ => panic!("Undefined game: {}", args[1])
|
_ => panic!("Undefined game: {}", args[1])
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::{GDResult, valve};
|
use crate::GDResult;
|
||||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
use crate::protocols::valve;
|
||||||
|
use crate::protocols::valve::{App, Server, ServerRule, ServerPlayer};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
|
|
@ -71,7 +72,7 @@ impl Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
||||||
let valve_response = ValveProtocol::query(address, match port {
|
let valve_response = valve::query(address, match port {
|
||||||
None => 27015,
|
None => 27015,
|
||||||
Some(port) => port
|
Some(port) => port
|
||||||
}, Some(App::ALIENS), None)?;
|
}, Some(App::ALIENS), None)?;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::{GDResult, valve};
|
use crate::GDResult;
|
||||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
use crate::protocols::valve;
|
||||||
|
use crate::protocols::valve::{App, Server, ServerRule, ServerPlayer};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
|
|
@ -71,7 +72,7 @@ impl Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
||||||
let valve_response = ValveProtocol::query(address, match port {
|
let valve_response = valve::query(address, match port {
|
||||||
None => 27015,
|
None => 27015,
|
||||||
Some(port) => port
|
Some(port) => port
|
||||||
}, Some(App::ASRD), None)?;
|
}, Some(App::ASRD), None)?;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::{GDResult, valve};
|
use crate::GDResult;
|
||||||
use crate::valve::{ValveProtocol, App, GatheringSettings, ServerPlayer, Server};
|
use crate::protocols::valve;
|
||||||
|
use crate::protocols::valve::{App, Server, ServerPlayer, GatheringSettings};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
|
|
@ -69,7 +70,7 @@ impl Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
||||||
let valve_response = ValveProtocol::query(address, match port {
|
let valve_response = valve::query(address, match port {
|
||||||
None => 27015,
|
None => 27015,
|
||||||
Some(port) => port
|
Some(port) => port
|
||||||
}, Some(App::CSGO), Some(GatheringSettings {
|
}, Some(App::CSGO), Some(GatheringSettings {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::{GDResult, valve};
|
use crate::GDResult;
|
||||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
use crate::protocols::valve;
|
||||||
|
use crate::protocols::valve::{App, Server, ServerRule, ServerPlayer};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
|
|
@ -71,7 +72,7 @@ impl Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
||||||
let valve_response = ValveProtocol::query(address, match port {
|
let valve_response = valve::query(address, match port {
|
||||||
None => 27015,
|
None => 27015,
|
||||||
Some(port) => port
|
Some(port) => port
|
||||||
}, Some(App::CSS), None)?;
|
}, Some(App::CSS), None)?;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::{GDResult, valve};
|
use crate::GDResult;
|
||||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
use crate::protocols::valve;
|
||||||
|
use crate::protocols::valve::{App, Server, ServerRule, ServerPlayer};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
|
|
@ -71,7 +72,7 @@ impl Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
||||||
let valve_response = ValveProtocol::query(address, match port {
|
let valve_response = valve::query(address, match port {
|
||||||
None => 27015,
|
None => 27015,
|
||||||
Some(port) => port
|
Some(port) => port
|
||||||
}, Some(App::DODS), None)?;
|
}, Some(App::DODS), None)?;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::{GDResult, valve};
|
use crate::GDResult;
|
||||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
use crate::protocols::valve;
|
||||||
|
use crate::protocols::valve::{App, Server, ServerRule, ServerPlayer};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
|
|
@ -71,7 +72,7 @@ impl Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
||||||
let valve_response = ValveProtocol::query(address, match port {
|
let valve_response = valve::query(address, match port {
|
||||||
None => 27015,
|
None => 27015,
|
||||||
Some(port) => port
|
Some(port) => port
|
||||||
}, Some(App::GM), None)?;
|
}, Some(App::GM), None)?;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::{GDResult, valve};
|
use crate::GDResult;
|
||||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
use crate::protocols::valve;
|
||||||
|
use crate::protocols::valve::{App, Server, ServerRule, ServerPlayer};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
|
|
@ -71,7 +72,7 @@ impl Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
||||||
let valve_response = ValveProtocol::query(address, match port {
|
let valve_response = valve::query(address, match port {
|
||||||
None => 27015,
|
None => 27015,
|
||||||
Some(port) => port
|
Some(port) => port
|
||||||
}, Some(App::HL2DM), None)?;
|
}, Some(App::HL2DM), None)?;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::{GDResult, valve};
|
use crate::GDResult;
|
||||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
use crate::protocols::valve;
|
||||||
|
use crate::protocols::valve::{App, Server, ServerRule, ServerPlayer};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
|
|
@ -71,7 +72,7 @@ impl Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
||||||
let valve_response = ValveProtocol::query(address, match port {
|
let valve_response = valve::query(address, match port {
|
||||||
None => 27015,
|
None => 27015,
|
||||||
Some(port) => port
|
Some(port) => port
|
||||||
}, Some(App::INS), None)?;
|
}, Some(App::INS), None)?;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::{GDResult, valve};
|
use crate::GDResult;
|
||||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
use crate::protocols::valve;
|
||||||
|
use crate::protocols::valve::{App, Server, ServerRule, ServerPlayer};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
|
|
@ -71,7 +72,7 @@ impl Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
||||||
let valve_response = ValveProtocol::query(address, match port {
|
let valve_response = valve::query(address, match port {
|
||||||
None => 27015,
|
None => 27015,
|
||||||
Some(port) => port
|
Some(port) => port
|
||||||
}, Some(App::INSMIC), None)?;
|
}, Some(App::INSMIC), None)?;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::{GDResult, valve};
|
use crate::GDResult;
|
||||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
use crate::protocols::valve;
|
||||||
|
use crate::protocols::valve::{App, Server, ServerRule, ServerPlayer};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
|
|
@ -71,7 +72,7 @@ impl Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
||||||
let valve_response = ValveProtocol::query(address, match port {
|
let valve_response = valve::query(address, match port {
|
||||||
None => 27131,
|
None => 27131,
|
||||||
Some(port) => port
|
Some(port) => port
|
||||||
}, Some(App::INSS), None)?;
|
}, Some(App::INSS), None)?;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::{GDResult, valve};
|
use crate::GDResult;
|
||||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
use crate::protocols::valve;
|
||||||
|
use crate::protocols::valve::{App, Server, ServerRule, ServerPlayer};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
|
|
@ -71,7 +72,7 @@ impl Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
||||||
let valve_response = ValveProtocol::query(address, match port {
|
let valve_response = valve::query(address, match port {
|
||||||
None => 27015,
|
None => 27015,
|
||||||
Some(port) => port
|
Some(port) => port
|
||||||
}, Some(App::L4D), None)?;
|
}, Some(App::L4D), None)?;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::{GDResult, valve};
|
use crate::GDResult;
|
||||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
use crate::protocols::valve;
|
||||||
|
use crate::protocols::valve::{App, Server, ServerRule, ServerPlayer};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
|
|
@ -71,7 +72,7 @@ impl Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
||||||
let valve_response = ValveProtocol::query(address, match port {
|
let valve_response = valve::query(address, match port {
|
||||||
None => 27015,
|
None => 27015,
|
||||||
Some(port) => port
|
Some(port) => port
|
||||||
}, Some(App::L4D2), None)?;
|
}, Some(App::L4D2), None)?;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::{GDResult, valve};
|
use crate::GDResult;
|
||||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
use crate::protocols::valve;
|
||||||
|
use crate::protocols::valve::{App, Server, ServerRule, ServerPlayer};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
|
|
@ -71,7 +72,7 @@ impl Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
||||||
let valve_response = ValveProtocol::query(address, match port {
|
let valve_response = valve::query(address, match port {
|
||||||
None => 27015,
|
None => 27015,
|
||||||
Some(port) => port
|
Some(port) => port
|
||||||
}, Some(App::TF2), None)?;
|
}, Some(App::TF2), None)?;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::{GDResult, valve};
|
use crate::GDResult;
|
||||||
use crate::valve::{ValveProtocol, App, ServerPlayer, Server, ServerRule};
|
use crate::protocols::valve;
|
||||||
|
use crate::protocols::valve::{App, Server, ServerRule, ServerPlayer};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
|
|
@ -83,7 +84,7 @@ impl Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
||||||
let valve_response = ValveProtocol::query(address, match port {
|
let valve_response = valve::query(address, match port {
|
||||||
None => 27015,
|
None => 27015,
|
||||||
Some(port) => port
|
Some(port) => port
|
||||||
}, Some(App::TS), None)?;
|
}, Some(App::TS), None)?;
|
||||||
|
|
|
||||||
|
|
@ -21,5 +21,4 @@ pub mod games;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
pub use errors::*;
|
pub use errors::*;
|
||||||
pub use protocols::*;
|
|
||||||
pub use games::*;
|
pub use games::*;
|
||||||
|
|
|
||||||
|
|
@ -162,13 +162,6 @@ pub struct GatheringSettings {
|
||||||
pub rules: bool
|
pub rules: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ValveProtocol {
|
|
||||||
socket: UdpSocket,
|
|
||||||
complete_address: String
|
|
||||||
}
|
|
||||||
|
|
||||||
static DEFAULT_PACKET_SIZE: usize = 2048;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct Packet {
|
struct Packet {
|
||||||
pub header: u32,
|
pub header: u32,
|
||||||
|
|
@ -298,6 +291,13 @@ impl SplitPacket {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ValveProtocol {
|
||||||
|
socket: UdpSocket,
|
||||||
|
complete_address: String
|
||||||
|
}
|
||||||
|
|
||||||
|
static DEFAULT_PACKET_SIZE: usize = 2048;
|
||||||
|
|
||||||
impl ValveProtocol {
|
impl ValveProtocol {
|
||||||
fn new(address: &str, port: u16) -> GDResult<Self> {
|
fn new(address: &str, port: u16) -> GDResult<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
|
@ -342,7 +342,7 @@ impl ValveProtocol {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ask for a specific request only.
|
/// Ask for a specific request only.
|
||||||
pub fn get_request_data(&self, appid: u32, kind: Request) -> GDResult<Vec<u8>> {
|
fn get_request_data(&self, appid: u32, kind: Request) -> GDResult<Vec<u8>> {
|
||||||
let request_initial_packet = Packet::initial(kind.clone()).to_bytes();
|
let request_initial_packet = Packet::initial(kind.clone()).to_bytes();
|
||||||
|
|
||||||
self.send(&request_initial_packet)?;
|
self.send(&request_initial_packet)?;
|
||||||
|
|
@ -360,7 +360,7 @@ impl ValveProtocol {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the server information's.
|
/// Get the server information's.
|
||||||
pub fn get_server_info(&self, initial_appid: u32) -> GDResult<ServerInfo> {
|
fn get_server_info(&self, initial_appid: u32) -> GDResult<ServerInfo> {
|
||||||
let buf = self.get_request_data(initial_appid, Request::INFO)?;
|
let buf = self.get_request_data(initial_appid, Request::INFO)?;
|
||||||
let mut pos = 0;
|
let mut pos = 0;
|
||||||
|
|
||||||
|
|
@ -452,7 +452,7 @@ impl ValveProtocol {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the server player's.
|
/// Get the server player's.
|
||||||
pub fn get_server_players(&self, appid: u32) -> GDResult<Vec<ServerPlayer>> {
|
fn get_server_players(&self, appid: u32) -> GDResult<Vec<ServerPlayer>> {
|
||||||
let buf = self.get_request_data(appid, Request::PLAYERS)?;
|
let buf = self.get_request_data(appid, Request::PLAYERS)?;
|
||||||
let mut pos = 0;
|
let mut pos = 0;
|
||||||
|
|
||||||
|
|
@ -480,7 +480,7 @@ impl ValveProtocol {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the server rules's.
|
/// Get the server rules's.
|
||||||
pub fn get_server_rules(&self, appid: u32) -> GDResult<Option<Vec<ServerRule>>> {
|
fn get_server_rules(&self, appid: u32) -> GDResult<Option<Vec<ServerRule>>> {
|
||||||
if appid == App::CSGO as u32 { //cause csgo wont respond to this since feb 21 2014 update
|
if appid == App::CSGO as u32 { //cause csgo wont respond to this since feb 21 2014 update
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
@ -500,44 +500,46 @@ impl ValveProtocol {
|
||||||
|
|
||||||
Ok(Some(rules))
|
Ok(Some(rules))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/// Query any app.
|
|
||||||
pub fn query(address: &str, port: u16, app: Option<App>, gather_settings: Option<GatheringSettings>) -> Result<Response, GDError> {
|
/// Query a server, you need to provide the address, the port and optionally, the app and the
|
||||||
let client = ValveProtocol::new(address, port)?;
|
/// gather settings, the app being *None* means to anonymously query the server, and the gather
|
||||||
|
/// settings being *None* means to get the players and the rules.
|
||||||
let mut query_app_id = match app {
|
pub fn query(address: &str, port: u16, app: Option<App>, gather_settings: Option<GatheringSettings>) -> Result<Response, GDError> {
|
||||||
None => 0,
|
let client = ValveProtocol::new(address, port)?;
|
||||||
Some(app) => app as u32
|
|
||||||
};
|
let mut query_app_id = match app {
|
||||||
|
None => 0,
|
||||||
let info = client.get_server_info(query_app_id)?;
|
Some(app) => app as u32
|
||||||
|
};
|
||||||
if query_app_id != 0 {
|
|
||||||
if info.appid != query_app_id {
|
let info = client.get_server_info(query_app_id)?;
|
||||||
return Err(GDError::BadGame(format!("Expected {}, found {} instead!", query_app_id, info.appid)));
|
|
||||||
}
|
if query_app_id != 0 {
|
||||||
} else {
|
if info.appid != query_app_id {
|
||||||
query_app_id = info.appid;
|
return Err(GDError::BadGame(format!("Expected {}, found {} instead!", query_app_id, info.appid)));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
let (gather_players, gather_rules) = match gather_settings.is_some() {
|
query_app_id = info.appid;
|
||||||
false => (true, true),
|
}
|
||||||
true => {
|
|
||||||
let settings = gather_settings.unwrap();
|
let (gather_players, gather_rules) = match gather_settings.is_some() {
|
||||||
(settings.players, settings.rules)
|
false => (true, true),
|
||||||
}
|
true => {
|
||||||
};
|
let settings = gather_settings.unwrap();
|
||||||
|
(settings.players, settings.rules)
|
||||||
Ok(Response {
|
}
|
||||||
info,
|
};
|
||||||
players: match gather_players {
|
|
||||||
false => None,
|
Ok(Response {
|
||||||
true => Some(client.get_server_players(query_app_id)?)
|
info,
|
||||||
},
|
players: match gather_players {
|
||||||
rules: match gather_rules {
|
false => None,
|
||||||
false => None,
|
true => Some(client.get_server_players(query_app_id)?)
|
||||||
true => client.get_server_rules(query_app_id)?
|
},
|
||||||
}
|
rules: match gather_rules {
|
||||||
})
|
false => None,
|
||||||
}
|
true => client.get_server_rules(query_app_id)?
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue