fix legacy SCUM RCON runtime profile resolution

This commit is contained in:
npc0-hue
2026-08-24 11:27:08 +08:00
parent b69939a5ce
commit dc9b0eaf2a
4 changed files with 64 additions and 8 deletions
+20 -2
View File
@@ -102,6 +102,23 @@ func runtimeLifecycleProfile(profiles domain.GamePluginRuntimeProfiles, key stri
return profile, true
}
}
// Older persisted bindings used "local" for the only local-process profile.
// Infer that legacy key only when the plugin has one unambiguous candidate.
if key != "local" {
return domain.RuntimeLifecycleProfile{}, false
}
var candidate domain.RuntimeLifecycleProfile
count := 0
for _, profile := range profiles.LifecycleProfiles {
if profile.Mode != "local-process" {
continue
}
candidate = profile
count++
}
if count == 1 {
return candidate, true
}
return domain.RuntimeLifecycleProfile{}, false
}
@@ -152,10 +169,11 @@ func runtimeBindingKeys(profiles domain.GamePluginRuntimeProfiles, profile domai
}
func normalizeRuntimeBinding(plugin domain.GamePlugin, binding domain.RuntimeBinding) (domain.RuntimeBinding, error) {
profile, _ := runtimeLifecycleProfile(plugin.RuntimeProfiles, binding.ProfileKey)
if profile.Key == "" {
profile, ok := runtimeLifecycleProfile(plugin.RuntimeProfiles, binding.ProfileKey)
if !ok {
return domain.RuntimeBinding{}, validationError("runtime profile is no longer declared")
}
binding.ProfileKey = profile.Key
required, allowed := runtimeBindingKeys(plugin.RuntimeProfiles, profile)
for key := range binding.Bindings {
if _, ok := allowed[key]; !ok {