mirror of
https://github.com/Tribufu/rust-gamedig
synced 2026-08-09 15:11:07 +00:00
feat: Add GatheringSettings on Valve macros (#128)
* Initial macro modification for gathering settings * Initial Valheim support * Remove unused use * Fix macro Thanks bunch @Douile * docs: Add Valheim to CHANGELOG and GAMES * Add commentary regarding gathering settings comment generation * Add GatheringSettings to game! * Remove unused stuff * Fix tests and add comment regarding the game argument
This commit is contained in:
parent
1ca6e6e85c
commit
501524b0da
8 changed files with 89 additions and 21 deletions
|
|
@ -10,14 +10,25 @@ use crate::protocols::{
|
|||
use crate::Game;
|
||||
|
||||
use crate::protocols::types::ProprietaryProtocol;
|
||||
use crate::protocols::valve::GatheringSettings;
|
||||
use phf::{phf_map, Map};
|
||||
|
||||
macro_rules! game {
|
||||
($name: literal, $default_port: literal, $protocol: expr) => {
|
||||
game!(
|
||||
$name,
|
||||
$default_port,
|
||||
$protocol,
|
||||
GatheringSettings::default().into_extra()
|
||||
)
|
||||
};
|
||||
|
||||
($name: literal, $default_port: literal, $protocol: expr, $extra_request_settings: expr) => {
|
||||
Game {
|
||||
name: $name,
|
||||
default_port: $default_port,
|
||||
protocol: $protocol,
|
||||
request_settings: $extra_request_settings,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -86,6 +97,11 @@ pub static GAMES: Map<&'static str, Game> = phf_map! {
|
|||
"theship" => game!("The Ship", 27015, Protocol::PROPRIETARY(ProprietaryProtocol::TheShip)),
|
||||
"unturned" => game!("Unturned", 27015, Protocol::Valve(SteamApp::UNTURNED)),
|
||||
"unrealtournament" => game!("Unreal Tournament", 7778, Protocol::Gamespy(GameSpyVersion::One)),
|
||||
"valheim" => game!("Valheim", 2457, Protocol::Valve(SteamApp::VALHEIM), GatheringSettings {
|
||||
players: true,
|
||||
rules: false,
|
||||
check_app_id: true,
|
||||
}.into_extra()),
|
||||
"vrising" => game!("V Rising", 27016, Protocol::Valve(SteamApp::VRISING)),
|
||||
"jc2m" => game!("Just Cause 2: Multiplayer", 7777, Protocol::PROPRIETARY(ProprietaryProtocol::JC2M)),
|
||||
"warsow" => game!("Warsow", 44400, Protocol::Quake(QuakeVersion::Three)),
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ pub struct Game {
|
|||
pub default_port: u16,
|
||||
/// The protocol the game's query uses
|
||||
pub protocol: Protocol,
|
||||
/// Request settings.
|
||||
pub request_settings: ExtraRequestSettings,
|
||||
}
|
||||
|
||||
#[cfg(feature = "game_defs")]
|
||||
|
|
@ -78,7 +80,9 @@ pub fn query_with_timeout_and_extra_settings(
|
|||
protocols::valve::query(
|
||||
&socket_addr,
|
||||
steam_app.as_engine(),
|
||||
extra_settings.map(ExtraRequestSettings::into),
|
||||
extra_settings
|
||||
.or(Option::from(game.request_settings.clone()))
|
||||
.map(ExtraRequestSettings::into),
|
||||
timeout_settings,
|
||||
)
|
||||
.map(Box::new)?
|
||||
|
|
|
|||
|
|
@ -53,4 +53,15 @@ game_query_mod!(teamfortress2, "Team Fortress 2", TEAMFORTRESS2, 27015);
|
|||
game_query_mod!(tfc, "Team Fortress Classic", TFC, 27015);
|
||||
game_query_mod!(theforest, "The Forest", THEFOREST, 27016);
|
||||
game_query_mod!(unturned, "Unturned", UNTURNED, 27015);
|
||||
game_query_mod!(
|
||||
valheim,
|
||||
"Valheim",
|
||||
VALHEIM,
|
||||
2457,
|
||||
GatheringSettings {
|
||||
players: true,
|
||||
rules: false,
|
||||
check_app_id: true,
|
||||
}
|
||||
);
|
||||
game_query_mod!(vrising, "V Rising", VRISING, 27016);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue