mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +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 - ??/??/????
|
# 0.0.4 - ??/??/????
|
||||||
Queries now support DNS resolve.
|
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.
|
[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](https://store.steampowered.com/app/222880/Insurgency/) implementation.
|
||||||
[Insurgency: Sandstorm](https://store.steampowered.com/app/581320/Insurgency_Sandstorm/) 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
|
# 0.0.3 - 22/10/2022
|
||||||
Valve protocol now properly supports multi-packet responses (compressed ones not tested).
|
Valve protocol now properly supports multi-packet responses (compressed ones not tested).
|
||||||
|
|
|
||||||
3
GAMES.md
3
GAMES.md
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
# Supported games:
|
# Supported games:
|
||||||
| ID | Name | Protocol | Notes |
|
| ID | Name | Protocol | Notes |
|
||||||
|--------|-------------------------------------|----------------|------------------------------------------------------------------------------|
|
|--------|------------------------------------|----------------|------------------------------------------------------------------------------|
|
||||||
| TF2 | Team Fortress 2 | Valve Protocol | |
|
| TF2 | Team Fortress 2 | Valve Protocol | |
|
||||||
| TS | The Ship | 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. |
|
| CSGO | Counter-Strike: Global Offensive | Valve Protocol | The server wouldn't respond the to Rules query since the 21 Feb 2014 update. |
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
| ASRD | Alien Swarm: Reactive Drop | Valve Protocol | |
|
| ASRD | Alien Swarm: Reactive Drop | Valve Protocol | |
|
||||||
| INS | Insurgency | Valve Protocol | |
|
| INS | Insurgency | Valve Protocol | |
|
||||||
| INSS | Insurgency: Sandstorm | Valve Protocol | Here you need to use the query port, not the server port. |
|
| 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:
|
## Planned to add support:
|
||||||
All Valve titles.
|
All Valve titles.
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
# Supported protocols:
|
# Supported protocols:
|
||||||
| Name | Documentation reference | Used by | Notes |
|
| 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. |
|
| 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:
|
## Planned to add support:
|
||||||
Minecraft protocol
|
Minecraft protocol
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
use std::env;
|
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() {
|
fn main() {
|
||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
|
|
@ -31,6 +31,7 @@ fn main() {
|
||||||
"gm" => println!("{:?}", gm::query(ip, port)),
|
"gm" => println!("{:?}", gm::query(ip, port)),
|
||||||
"hl2dm" => println!("{:?}", hl2dm::query(ip, port)),
|
"hl2dm" => println!("{:?}", hl2dm::query(ip, port)),
|
||||||
"tf2" => println!("{:?}", tf2::query(ip, port)),
|
"tf2" => println!("{:?}", tf2::query(ip, port)),
|
||||||
|
"insmic" => println!("{:?}", insmic::query(ip, port)),
|
||||||
"ins" => println!("{:?}", ins::query(ip, port)),
|
"ins" => println!("{:?}", ins::query(ip, port)),
|
||||||
"inss" => println!("{:?}", inss::query(ip, port)),
|
"inss" => println!("{:?}", inss::query(ip, port)),
|
||||||
"l4d" => println!("{:?}", l4d::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;
|
pub mod ins;
|
||||||
/// Insurgency: Sandstorm
|
/// Insurgency: Sandstorm
|
||||||
pub mod inss;
|
pub mod inss;
|
||||||
|
/// Insurgency: Modern Infantry Combat
|
||||||
|
pub mod insmic;
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,8 @@ pub enum App {
|
||||||
TS = 2400,
|
TS = 2400,
|
||||||
/// Garry's Mod
|
/// Garry's Mod
|
||||||
GM = 4000,
|
GM = 4000,
|
||||||
|
/// Insurgency: Modern Infantry Combat
|
||||||
|
INSMIC = 17700,
|
||||||
/// Insurgency
|
/// Insurgency
|
||||||
INS = 222880,
|
INS = 222880,
|
||||||
/// Insurgency: Sandstorm
|
/// Insurgency: Sandstorm
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue