mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
Reduce game implementation repetition (#122)
* [Games] Add macro to replace valve game query implementations This somewhat reduces repeated code (#120), and also adds auto-generated doc comments to all valve game query functions. * [Games] Add macro to replace gamespy game query implementations This somewhat reduces repeated code (#120), and also adds auto-generated doc comments to all gamespy game query functions. * [Games] Add macro to replace quake game query implementations This somewhat reduces repeated code (#120), and also adds auto-generated doc comments to all quake game query functions. * [Games] Move all valve game modules into a single file using macros Vastly reduces the number of files. However does break the game definition-per-file test, so that was removed. * [Games] Move all quake game modules into a single file using macros * [Games] Move all gamespy game modules into a single file using macros * [Docs] Update CHANGELOG * [Docs] Improve game query function generation macro documentation * [Games] Add missed Halo: Combat Evolved to gamespy
This commit is contained in:
parent
c8a93357cf
commit
3b9c784e70
61 changed files with 250 additions and 872 deletions
|
|
@ -89,31 +89,3 @@ pub static GAMES: Map<&'static str, Game> = phf_map! {
|
|||
"jc2m" => game!("Just Cause 2: Multiplayer", 7777, Protocol::PROPRIETARY(ProprietaryProtocol::JC2M)),
|
||||
"warsow" => game!("Warsow", 44400, Protocol::Quake(QuakeVersion::Three)),
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::GAMES;
|
||||
use std::fs;
|
||||
|
||||
#[test]
|
||||
fn check_game_files_match_defs() {
|
||||
let ignore = [
|
||||
"mod", // Module file
|
||||
"definitions", // This file
|
||||
"minecraft", // Has various defs
|
||||
"sd2d", // Module names cannot start with numbers
|
||||
];
|
||||
|
||||
for file in fs::read_dir("./src/games/").unwrap() {
|
||||
let file = file.unwrap();
|
||||
let metadata = file.metadata().unwrap();
|
||||
if metadata.is_file() {
|
||||
if let Some(file_name) = file.file_name().into_string().unwrap().strip_suffix(".rs") {
|
||||
if !ignore.contains(&file_name) && !GAMES.contains_key(file_name) {
|
||||
panic!("Expected GAMES to contain a definition to match {file_name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue