Add support for aliases

This commit is contained in:
mtkennerly 2023-12-26 04:56:24 +08:00
parent c051a7fda3
commit d9bb3616a6
No known key found for this signature in database
GPG key ID: E764BE00BE6E6408
5 changed files with 1596 additions and 0 deletions

View file

@ -104,6 +104,8 @@ Tools may also:
then ideally a tool should only need to check that entry when running on Windows; then ideally a tool should only need to check that entry when running on Windows;
however, it is a reality of the data set that it may simply be the only confirmed occurrence of the file, however, it is a reality of the data set that it may simply be the only confirmed occurrence of the file,
and it may in fact occur on other operating systems as well. and it may in fact occur on other operating systems as well.
* Reject/ignore recursive aliases or set a recursion limit.
The primary manifest will never contain a recursive alias.
For authors of secondary manifests bundled with games: For authors of secondary manifests bundled with games:

File diff suppressed because it is too large Load diff

View file

@ -118,3 +118,5 @@ additionalProperties:
type: array type: array
items: items:
type: integer type: integer
alias:
type: string

View file

@ -99,3 +99,9 @@ additionalProperties:
type: array type: array
items: items:
type: integer type: integer
alias:
description: |
When this field is populated with another game's title,
the current entry's title can be used as a nickname to look up the other game.
The other fields in the current entry should be ignored.
type: string

View file

@ -128,6 +128,18 @@ impl Manifest {
let mut game = Game::default(); let mut game = Game::default();
game.integrate_wiki(info, title); game.integrate_wiki(info, title);
for rename in &info.renamed_from {
if rename.to_lowercase() == title.to_lowercase() || self.0.contains_key(rename) {
continue;
}
self.0.insert(
rename.to_string(),
Game {
alias: Some(title.to_string()),
..Default::default()
},
);
}
if let Some(id) = game.steam.id { if let Some(id) = game.steam.id {
if let Some(info) = steam_cache.0.get(&id) { if let Some(info) = steam_cache.0.get(&id) {
game.integrate_steam(info); game.integrate_steam(info);
@ -150,6 +162,8 @@ impl Manifest {
#[derive(Clone, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[derive(Clone, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
pub struct Game { pub struct Game {
#[serde(skip_serializing_if = "Option::is_none")]
pub alias: Option<String>,
#[serde(skip_serializing_if = "BTreeMap::is_empty")] #[serde(skip_serializing_if = "BTreeMap::is_empty")]
pub files: BTreeMap<String, GameFileEntry>, pub files: BTreeMap<String, GameFileEntry>,
#[serde(skip_serializing_if = "GogMetadata::is_empty")] #[serde(skip_serializing_if = "GogMetadata::is_empty")]