fixed: quick-play feature flags + missing version_type template
two related bugs surfaced by manual testing on 1.20.6 vanilla and fabric:
1. FeatureSet missing has_quick_plays_support / is_quick_play_singleplayer /
is_quick_play_multiplayer / is_quick_play_realms. mojang's profiles gate
the quick-play arguments behind these features. serde silently dropped
the unknown fields during deserialization, leaving an empty FeatureSet
that matched any context, so the conditional arguments emitted raw
${quickPlay*} placeholders to the JVM that template substitution then
warned about. add the fields explicitly and extend features_match to
reject any required feature the context doesn't set.
2. TemplateContext missing version_type. ${version_type} is an
unconditional template in modern vanilla's arguments.game (renders the
profile's "type" field, e.g. "release"). without it, the substitution
emitted a literal ${version_type} to minecraft and warned. add the
field, plumb the merged profile's type_ value through, default to
"release" when absent.
This commit is contained in:
1 parent
d88ab085b5
commit
f45351841c
4 files changed
+38
-18
No files matched your search
@@ -95,6 +95,7 @@ mod tests {
|
||||
library_directory,
|
||||
classpath_separator: ":",
|
||||
version_name: "1.20.1",
|
||||
version_type: "release",
|
||||
natives_directory,
|
||||
classpath: "a.jar:b.jar",
|
||||
game_directory,
|
||||
|
||||
+33
-14
@@ -27,6 +27,15 @@ pub struct OsCondition {
|
||||
pub struct FeatureSet {
|
||||
pub is_demo_user: Option<bool>,
|
||||
pub has_custom_resolution: Option<bool>,
|
||||
// quick-play feature flags (1.20+). rmcl never sets these, so any rule
|
||||
// gated on them is filtered out by features_match. listing them
|
||||
// explicitly is what makes that filter work: without the fields,
|
||||
// serde would silently drop them during deserialization, leaving a
|
||||
// FeatureSet::default that matches everything.
|
||||
pub has_quick_plays_support: Option<bool>,
|
||||
pub is_quick_play_singleplayer: Option<bool>,
|
||||
pub is_quick_play_multiplayer: Option<bool>,
|
||||
pub is_quick_play_realms: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
|
||||
@@ -102,17 +111,27 @@ fn os_version_matches(pattern: &str, host_version: &str) -> bool {
|
||||
}
|
||||
|
||||
fn features_match(required: &FeatureSet, current: &FeatureSet) -> bool {
|
||||
if let Some(want) = required.is_demo_user
|
||||
&& current.is_demo_user.unwrap_or(false) != want
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if let Some(want) = required.has_custom_resolution
|
||||
&& current.has_custom_resolution.unwrap_or(false) != want
|
||||
{
|
||||
return false;
|
||||
}
|
||||
true
|
||||
let pairs = [
|
||||
(required.is_demo_user, current.is_demo_user),
|
||||
(required.has_custom_resolution, current.has_custom_resolution),
|
||||
(
|
||||
required.has_quick_plays_support,
|
||||
current.has_quick_plays_support,
|
||||
),
|
||||
(
|
||||
required.is_quick_play_singleplayer,
|
||||
current.is_quick_play_singleplayer,
|
||||
),
|
||||
(
|
||||
required.is_quick_play_multiplayer,
|
||||
current.is_quick_play_multiplayer,
|
||||
),
|
||||
(required.is_quick_play_realms, current.is_quick_play_realms),
|
||||
];
|
||||
pairs.iter().all(|(req, cur)| match req {
|
||||
Some(want) => cur.unwrap_or(false) == *want,
|
||||
None => true,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -263,12 +282,12 @@ mod tests {
|
||||
os: None,
|
||||
features: Some(FeatureSet {
|
||||
is_demo_user: Some(true),
|
||||
has_custom_resolution: None,
|
||||
..Default::default()
|
||||
}),
|
||||
}];
|
||||
let demo_features = FeatureSet {
|
||||
is_demo_user: Some(true),
|
||||
has_custom_resolution: None,
|
||||
..Default::default()
|
||||
};
|
||||
let ctx = RuleContext {
|
||||
os_name: "linux",
|
||||
@@ -286,7 +305,7 @@ mod tests {
|
||||
os: None,
|
||||
features: Some(FeatureSet {
|
||||
is_demo_user: Some(true),
|
||||
has_custom_resolution: None,
|
||||
..Default::default()
|
||||
}),
|
||||
}];
|
||||
let features = FeatureSet::default();
|
||||
|
||||
@@ -14,6 +14,7 @@ pub struct TemplateContext<'a> {
|
||||
pub library_directory: &'a Path,
|
||||
pub classpath_separator: &'a str,
|
||||
pub version_name: &'a str,
|
||||
pub version_type: &'a str,
|
||||
pub natives_directory: &'a Path,
|
||||
pub classpath: &'a str,
|
||||
pub game_directory: &'a Path,
|
||||
@@ -76,6 +77,7 @@ fn lookup(name: &str, ctx: &TemplateContext) -> Option<String> {
|
||||
"library_directory" => ctx.library_directory.display().to_string(),
|
||||
"classpath_separator" => ctx.classpath_separator.to_string(),
|
||||
"version_name" => ctx.version_name.to_string(),
|
||||
"version_type" => ctx.version_type.to_string(),
|
||||
"natives_directory" => ctx.natives_directory.display().to_string(),
|
||||
"classpath" => ctx.classpath.to_string(),
|
||||
"game_directory" => ctx.game_directory.display().to_string(),
|
||||
@@ -109,6 +111,7 @@ mod tests {
|
||||
library_directory,
|
||||
classpath_separator: ":",
|
||||
version_name: "1.20.1",
|
||||
version_type: "release",
|
||||
natives_directory,
|
||||
classpath: "a.jar:b.jar",
|
||||
game_directory,
|
||||
@@ -237,6 +240,7 @@ mod tests {
|
||||
launcher_name: "rmcl",
|
||||
launcher_version: "0.3.0",
|
||||
clientid: "0",
|
||||
version_type: "release",
|
||||
};
|
||||
assert_eq!(substitute("${user_properties}", &ctx), "${version_name}");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user