1
0

feat: add new rule in BMapInspector

This commit is contained in:
2026-03-04 11:01:14 +08:00
parent 4c71a20935
commit 3f6d131d0d
6 changed files with 98 additions and 21 deletions

View File

@@ -30,6 +30,7 @@ namespace BMapInspector::Rule {
rules.emplace_back(new Ruleset::YYCRule2());
rules.emplace_back(new Ruleset::YYCRule3());
rules.emplace_back(new Ruleset::YYCRule4());
rules.emplace_back(new Ruleset::YYCRule5());
rules.emplace_back(new Ruleset::BBugRule1());
rules.emplace_back(new Ruleset::BBugRule2());
rules.emplace_back(new Ruleset::BBugRule3());
@@ -59,4 +60,4 @@ namespace BMapInspector::Rule {
#pragma endregion
} // namespace BMapInspector::RuleCollection
} // namespace BMapInspector::Rule

View File

@@ -54,9 +54,9 @@ namespace BMapInspector::Ruleset {
void BBugRule3::Check(Reporter::Reporter& reporter, Map::Level& level) const {
// TODO:
// This function is already presented in Ballance Blender Plugin,
// so I don't want write it in there now.
// Write this if I have spare time in future.
// This rule is complex and can be done by Ballance Blender Plugin.
// So we are not urgently to implement it in there.
// Just make a rule placeholder in there and may finish it in future.
}
#pragma endregion

View File

@@ -23,8 +23,9 @@ namespace BMapInspector::Ruleset {
void GpRule1::Check(Reporter::Reporter& reporter, Map::Level& level) const {
// TODO:
// Finish this rule.
// It is so complex that I don't want to implement it now.
// This rule is complex and can be done by Ballance Blender Plugin.
// So we are not urgently to implement it in there.
// Just make a rule placeholder in there and may finish it in future.
}
#pragma endregion

View File

@@ -0,0 +1,3 @@
#include "Name.hpp"
namespace BMapInspector::Ruleset::Shared::Name {}

View File

@@ -262,13 +262,13 @@ namespace BMapInspector::Ruleset {
auto lower_tex_filename = strop::to_lower(tex_filename.value());
if (opaque_texs.contains(lower_tex_filename)) {
if (tex->GetVideoFormat() != V::VX_PIXELFORMAT::_16_ARGB1555) {
reporter.FormatWarning(u8"Texture %s is Ballance opaque texture. But its video format is not ARGB1555. "
reporter.FormatInfo(u8"Texture %s is Ballance opaque texture. But its video format is not ARGB1555. "
u8"This is mismatched with vanilla Ballance.",
Shared::Utility::QuoteObjectName(tex).c_str());
}
} else if (transparent_texs.contains(lower_tex_filename)) {
if (tex->GetVideoFormat() != V::VX_PIXELFORMAT::_32_ARGB8888) {
reporter.FormatWarning(u8"Texture %s is Ballance transparent texture. But its video format is not ARGB8888. "
reporter.FormatInfo(u8"Texture %s is Ballance transparent texture. But its video format is not ARGB8888. "
u8"This is mismatched with vanilla Ballance.",
Shared::Utility::QuoteObjectName(tex).c_str());
}
@@ -278,13 +278,13 @@ namespace BMapInspector::Ruleset {
// Do nothing.
break;
case V::VX_PIXELFORMAT::_32_ARGB8888:
reporter.FormatWarning(u8"Texture %s is not Ballance texture. Its video format is ARGB8888. "
reporter.FormatInfo(u8"Texture %s is not Ballance texture. Its video format is ARGB8888. "
u8"This may cause useless performance consumption if there is no transparent inside it. "
u8"Please check whether this is essential.",
Shared::Utility::QuoteObjectName(tex).c_str());
break;
default:
reporter.FormatWarning(
reporter.FormatInfo(
u8"Texture %s is not Ballance texture. Its video format is not ARGB1555 or ARGB8888. "
u8"This is mismatched with vanilla Ballance. "
u8"Please set it to ARGB1555 for opaque texture, or ARGB8888 for transaprent texture, except special scenario.",
@@ -295,4 +295,60 @@ namespace BMapInspector::Ruleset {
}
}
#pragma endregion
#pragma region YYC Rule 5
YYCRule5::YYCRule5() : Rule::IRule() {}
YYCRule5::~YYCRule5() {}
std::u8string_view YYCRule5::GetRuleName() const {
return u8"YYC5";
}
void YYCRule5::Check(Reporter::Reporter& reporter, Map::Level& level) const {
// Build lowercase texture name set first.
std::set<std::u8string> texs;
for (const auto* tex_name : Shared::Name::Texture::ALL) {
texs.emplace(strop::to_lower(tex_name));
}
// Check texture one by one
for (auto& tex : level.GetTextures()) {
auto tex_filename = Shared::Utility::ExtractTextureFileName(tex);
if (!tex_filename.has_value()) continue;
auto lower_tex_filename = strop::to_lower(tex_filename.value());
bool is_ballance_tex = texs.contains(lower_tex_filename);
using C::CK_TEXTURE_SAVEOPTIONS;
switch (tex->GetUnderlyingData().GetSaveOptions()) {
case CK_TEXTURE_SAVEOPTIONS::CKTEXTURE_USEGLOBAL:
reporter.FormatInfo(u8"The save option of texture %s rely on global Virtools settings. "
u8"This cause ambiguity and different behavior on different Virtools by different user settings. "
u8"Please consider change it to explicit option, such as External or Raw Data.",
Shared::Utility::QuoteObjectName(tex).c_str());
break;
case CK_TEXTURE_SAVEOPTIONS::CKTEXTURE_EXTERNAL:
if (!is_ballance_tex) {
reporter.FormatWarning(u8"Texture %s is not Ballance texture, but its save option is External. "
u8"This may cause texture loss when rendering in game. Please consider store it inside map.",
Shared::Utility::QuoteObjectName(tex).c_str());
}
break;
default:
if (is_ballance_tex) {
reporter.FormatInfo(u8"Texture %s is Ballance texture, but its save option is not External. "
u8"Please consider storing it as External to reduce the final size of map file, "
u8"and let user specified texture pack work.",
Shared::Utility::QuoteObjectName(tex).c_str());
}
break;
}
}
}
#pragma endregion
} // namespace BMapInspector::Ruleset

View File

@@ -56,9 +56,8 @@ namespace BMapInspector::Ruleset {
/**
* @brief YYC12345 Rule 4
* @details
* \li Check the video format for opaque and transparent texture respectively.
* \li Warning for video format which is not used by vanilla Ballance.
* \li Warning for transparent used video format in non-Ballance textures to conserve resources.
* Check the video format for Ballance and user-defined texture respectively.
* Report if there is non-vanilla Ballance settings.
*/
class YYCRule4 : public Rule::IRule {
public:
@@ -71,4 +70,21 @@ namespace BMapInspector::Ruleset {
void Check(Reporter::Reporter& reporter, Map::Level& level) const override;
};
/**
* @brief YYC12345 Rule 5
* @details
* Check the save options for Ballance and user-defined texture respectively
* for reducing map size and avoid ambiguity.
*/
class YYCRule5 : public Rule::IRule {
public:
YYCRule5();
virtual ~YYCRule5();
YYCC_DELETE_COPY_MOVE(YYCRule5)
public:
std::u8string_view GetRuleName() const override;
void Check(Reporter::Reporter& reporter, Map::Level& level) const override;
};
}