mirror of
https://github.com/Tribufu/rust-gamedig
synced 2026-08-20 12:21:05 +00:00
feat: minetest support (#218)
* feat: initial minetest support * move player to master, remove comments * add markdown lines * oops, change player namespace * fix some edge cases * add entry to responses, tweak field names
This commit is contained in:
parent
30ae60e4dc
commit
bcc92d17df
10 changed files with 246 additions and 59 deletions
23
crates/lib/src/games/minetest/protocol.rs
Normal file
23
crates/lib/src/games/minetest/protocol.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
use crate::minetest::Response;
|
||||
use crate::{minetest_master_server, GDErrorKind, GDResult, TimeoutSettings};
|
||||
use std::net::IpAddr;
|
||||
|
||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> { query_with_timeout(address, port, &None) }
|
||||
|
||||
pub fn query_with_timeout(
|
||||
address: &IpAddr,
|
||||
port: Option<u16>,
|
||||
timeout_settings: &Option<TimeoutSettings>,
|
||||
) -> GDResult<Response> {
|
||||
let address = address.to_string();
|
||||
let port = port.unwrap_or(30000);
|
||||
|
||||
let servers = minetest_master_server::query(timeout_settings.unwrap_or_default())?;
|
||||
for server in servers.list {
|
||||
if server.ip == address && server.port == port {
|
||||
return Ok(server.into());
|
||||
}
|
||||
}
|
||||
|
||||
Err(GDErrorKind::AutoQuery.context("Server not found in the master query list."))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue