mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-05-06 07:17:27 +00:00
Insurgency: Modern Infantry Combat implementation.
This commit is contained in:
parent
88a4c82158
commit
8e2d76ecfb
7 changed files with 106 additions and 19 deletions
|
|
@ -3,10 +3,11 @@ Who knows what the future holds...
|
|||
|
||||
# 0.0.4 - ??/??/????
|
||||
Queries now support DNS resolve.
|
||||
[Alien Swarm](https://store.steampowered.com/app/630/Alien_Swarm/) implementation.
|
||||
[Alien Swarm](https://store.steampowered.com/app/630/Alien_Swarm/) implementation (not tested).
|
||||
[Alien Swarm: Reactive Drop](https://store.steampowered.com/app/563560/Alien_Swarm_Reactive_Drop/) implementation.
|
||||
[Insurgency](https://store.steampowered.com/app/222880/Insurgency/) implementation.
|
||||
[Insurgency: Sandstorm](https://store.steampowered.com/app/581320/Insurgency_Sandstorm/) implementation.
|
||||
[Insurgency: Modern Infantry Combat](https://store.steampowered.com/app/17700/INSURGENCY_Modern_Infantry_Combat/) implementation (not tested).
|
||||
|
||||
# 0.0.3 - 22/10/2022
|
||||
Valve protocol now properly supports multi-packet responses (compressed ones not tested).
|
||||
|
|
|
|||
29
GAMES.md
29
GAMES.md
|
|
@ -1,19 +1,20 @@
|
|||
|
||||
# Supported games:
|
||||
| ID | Name | Protocol | Notes |
|
||||
|--------|-------------------------------------|----------------|------------------------------------------------------------------------------|
|
||||
| TF2 | Team Fortress 2 | Valve Protocol | |
|
||||
| TS | The Ship | Valve Protocol | |
|
||||
| CSGO | Counter-Strike: Global Offensive | Valve Protocol | The server wouldn't respond the to Rules query since the 21 Feb 2014 update. |
|
||||
| CSS | Counter-Strike: Source | Valve Protocol | If protocol is 7, queries with multi-packet responses will crash. |
|
||||
| DODS | Day of Defeat: Source | Valve Protocol | |
|
||||
| L4D | Left 4 Dead | Valve Protocol | |
|
||||
| L4D2 | Left 4 Dead 2 | Valve Protocol | |
|
||||
| HL2DM | Half-Life 2 Deathmatch | Valve Protocol | |
|
||||
| ALIENS | Alien Swarm | Valve Protocol | Not tested. |
|
||||
| ASRD | Alien Swarm: Reactive Drop | Valve Protocol | |
|
||||
| INS | Insurgency | Valve Protocol | |
|
||||
| INSS | Insurgency: Sandstorm | Valve Protocol | Here you need to use the query port, not the server port. |
|
||||
| ID | Name | Protocol | Notes |
|
||||
|--------|------------------------------------|----------------|------------------------------------------------------------------------------|
|
||||
| TF2 | Team Fortress 2 | Valve Protocol | |
|
||||
| TS | The Ship | Valve Protocol | |
|
||||
| CSGO | Counter-Strike: Global Offensive | Valve Protocol | The server wouldn't respond the to Rules query since the 21 Feb 2014 update. |
|
||||
| CSS | Counter-Strike: Source | Valve Protocol | If protocol is 7, queries with multi-packet responses will crash. |
|
||||
| DODS | Day of Defeat: Source | Valve Protocol | |
|
||||
| L4D | Left 4 Dead | Valve Protocol | |
|
||||
| L4D2 | Left 4 Dead 2 | Valve Protocol | |
|
||||
| HL2DM | Half-Life 2 Deathmatch | Valve Protocol | |
|
||||
| ALIENS | Alien Swarm | Valve Protocol | Not tested. |
|
||||
| ASRD | Alien Swarm: Reactive Drop | Valve Protocol | |
|
||||
| INS | Insurgency | Valve Protocol | |
|
||||
| INSS | Insurgency: Sandstorm | Valve Protocol | Here you need to use the query port, not the server port. |
|
||||
| INSMIC | Insurgency: Modern Infantry Combat | Valve Protocol | Not tested. |
|
||||
|
||||
## Planned to add support:
|
||||
All Valve titles.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
# Supported protocols:
|
||||
| Name | Documentation reference | Used by | Notes |
|
||||
|----------------|---------------------------------------------------------------------------|--------------------------------------------------------------|----------------------------------------|
|
||||
| Valve Protocol | [Server Queries](https://developer.valvesoftware.com/wiki/Server_queries) | TF2, CSGO, TS, CSS, DODS, GM, HL2DM, L4D, L4D2, ALIENS, ASRD | Multi-packet decompression not tested. |
|
||||
| Name | Documentation reference | Used by | Notes |
|
||||
|----------------|---------------------------------------------------------------------------|---------------------------------------------------------------------------------|----------------------------------------|
|
||||
| Valve Protocol | [Server Queries](https://developer.valvesoftware.com/wiki/Server_queries) | TF2, CSGO, TS, CSS, DODS, GM, HL2DM, L4D, L4D2, ALIENS, ASRD, INS, INSS, INSMIC | Multi-packet decompression not tested. |
|
||||
|
||||
## Planned to add support:
|
||||
Minecraft protocol
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
use std::env;
|
||||
use gamedig::{aliens, asrd, csgo, css, dods, gm, hl2dm, ins, inss, l4d, l4d2, tf2, ts};
|
||||
use gamedig::{aliens, asrd, csgo, css, dods, gm, hl2dm, ins, insmic, inss, l4d, l4d2, tf2, ts};
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
|
|
@ -31,6 +31,7 @@ fn main() {
|
|||
"gm" => println!("{:?}", gm::query(ip, port)),
|
||||
"hl2dm" => println!("{:?}", hl2dm::query(ip, port)),
|
||||
"tf2" => println!("{:?}", tf2::query(ip, port)),
|
||||
"insmic" => println!("{:?}", insmic::query(ip, port)),
|
||||
"ins" => println!("{:?}", ins::query(ip, port)),
|
||||
"inss" => println!("{:?}", inss::query(ip, port)),
|
||||
"l4d" => println!("{:?}", l4d::query(ip, port)),
|
||||
|
|
|
|||
80
src/games/insmic.rs
Normal file
80
src/games/insmic.rs
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
use crate::{GDResult, valve};
|
||||
use crate::valve::{ValveProtocol, App, Server, ServerRule, ServerPlayer};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Player {
|
||||
pub name: String,
|
||||
pub score: u32,
|
||||
pub duration: f32
|
||||
}
|
||||
|
||||
impl Player {
|
||||
fn from_valve_response(player: &ServerPlayer) -> Self {
|
||||
Self {
|
||||
name: player.name.clone(),
|
||||
score: player.score,
|
||||
duration: player.duration
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Response {
|
||||
pub protocol: u8,
|
||||
pub name: String,
|
||||
pub map: String,
|
||||
pub game: String,
|
||||
pub players: u8,
|
||||
pub players_details: Vec<Player>,
|
||||
pub max_players: u8,
|
||||
pub bots: u8,
|
||||
pub server_type: Server,
|
||||
pub has_password: bool,
|
||||
pub vac_secured: bool,
|
||||
pub version: String,
|
||||
pub port: Option<u16>,
|
||||
pub steam_id: Option<u64>,
|
||||
pub tv_port: Option<u16>,
|
||||
pub tv_name: Option<String>,
|
||||
pub keywords: Option<String>,
|
||||
pub rules: Vec<ServerRule>
|
||||
}
|
||||
|
||||
impl Response {
|
||||
pub fn new_from_valve_response(response: valve::Response) -> Self {
|
||||
let (port, steam_id, tv_port, tv_name, keywords) = match response.info.extra_data {
|
||||
None => (None, None, None, None, None),
|
||||
Some(ed) => (ed.port, ed.steam_id, ed.tv_port, ed.tv_name, ed.keywords)
|
||||
};
|
||||
|
||||
Self {
|
||||
protocol: response.info.protocol,
|
||||
name: response.info.name,
|
||||
map: response.info.map,
|
||||
game: response.info.game,
|
||||
players: response.info.players,
|
||||
players_details: response.players.unwrap().iter().map(|p| Player::from_valve_response(p)).collect(),
|
||||
max_players: response.info.max_players,
|
||||
bots: response.info.bots,
|
||||
server_type: response.info.server_type,
|
||||
has_password: response.info.has_password,
|
||||
vac_secured: response.info.vac_secured,
|
||||
version: response.info.version,
|
||||
port,
|
||||
steam_id,
|
||||
tv_port,
|
||||
tv_name,
|
||||
keywords,
|
||||
rules: response.rules.unwrap()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn query(address: &str, port: Option<u16>) -> GDResult<Response> {
|
||||
let valve_response = ValveProtocol::query(App::INSMIC, address, match port {
|
||||
None => 27015,
|
||||
Some(port) => port
|
||||
}, None)?;
|
||||
|
||||
Ok(Response::new_from_valve_response(valve_response))
|
||||
}
|
||||
|
|
@ -27,3 +27,5 @@ pub mod asrd;
|
|||
pub mod ins;
|
||||
/// Insurgency: Sandstorm
|
||||
pub mod inss;
|
||||
/// Insurgency: Modern Infantry Combat
|
||||
pub mod insmic;
|
||||
|
|
|
|||
|
|
@ -146,6 +146,8 @@ pub enum App {
|
|||
TS = 2400,
|
||||
/// Garry's Mod
|
||||
GM = 4000,
|
||||
/// Insurgency: Modern Infantry Combat
|
||||
INSMIC = 17700,
|
||||
/// Insurgency
|
||||
INS = 222880,
|
||||
/// Insurgency: Sandstorm
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue