Skip to content

Commit 3f7d14a

Browse files
committed
✨ Add KnownBadLayerLintError, use for XRNeckSafer and OpenXR Toolkit
Fixed by disablign the layer
1 parent e4ea5a4 commit 3f7d14a

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

src/Linter.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,28 @@ std::vector<APILayer> OrderingLintError::Fix(
104104
return newLayers;
105105
}
106106

107+
KnownBadLayerLintError::KnownBadLayerLintError(
108+
const std::string& description,
109+
const std::filesystem::path& layer)
110+
: FixableLintError(description, {layer}) {
111+
}
112+
113+
std::vector<APILayer> KnownBadLayerLintError::Fix(
114+
const std::vector<APILayer>& allLayers) {
115+
const auto affected = this->GetAffectedLayers();
116+
assert(affected.size() == 1);
117+
const auto& path = *affected.begin();
118+
119+
auto newLayers = allLayers;
120+
auto it = std::ranges::find_if(
121+
newLayers, [&path](const auto& layer) { return layer.mJSONPath == path; });
122+
123+
if (it != newLayers.end()) {
124+
it->mValue = APILayer::Value::Disabled;
125+
}
126+
return newLayers;
127+
}
128+
107129
InvalidLayerLintError::InvalidLayerLintError(
108130
const std::string& description,
109131
const std::filesystem::path& layer)

src/Linter.hpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,18 @@ class OrderingLintError final : public FixableLintError {
6464
std::filesystem::path mRelativeTo;
6565
};
6666

67-
// A lint error that is fixed by removing the layer
67+
/// A lint error that is fixed by disabling the layer
68+
class KnownBadLayerLintError final : public FixableLintError {
69+
public:
70+
KnownBadLayerLintError(
71+
const std::string& description,
72+
const std::filesystem::path& layer);
73+
74+
~KnownBadLayerLintError() override = default;
75+
std::vector<APILayer> Fix(const std::vector<APILayer>&) override;
76+
};
77+
78+
/// A lint error that is fixed by removing the layer
6879
class InvalidLayerLintError final : public FixableLintError {
6980
public:
7081
InvalidLayerLintError(

src/linters/windows/OpenXRToolkitLinter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ class OpenXRToolkitLinter final : public Linter {
2929
if (details.mName != "XR_APILAYER_MBUCCHIA_toolkit") {
3030
continue;
3131
}
32-
errors.push_back(std::make_shared<LintError>(
32+
errors.push_back(std::make_shared<KnownBadLayerLintError>(
3333
"OpenXR Toolkit is unsupported, and is known to cause crashes and "
3434
"other issues in modern games; you should disable it if you encounter "
3535
"problems.",
36-
PathSet { layer.mJSONPath }));
36+
layer.mJSONPath));
3737
}
3838
return errors;
3939
}

src/linters/windows/XRNeckSaferLinter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ class XRNeckSaferLinter final : public Linter {
3333
continue;
3434
}
3535
errors.push_back(
36-
std::make_shared<LintError>(
36+
std::make_shared<KnownBadLayerLintError>(
3737
"XRNeckSafer has bugs that can cause issues include game crashes, and "
3838
"crashes in other API layers. Disable or uninstall it if you have any "
3939
"issues.",
40-
PathSet {layer.mJSONPath}));
40+
layer.mJSONPath));
4141
}
4242
return errors;
4343
}

0 commit comments

Comments
 (0)