11 const std::filesystem::path global_fieldmap_path = project_root_ /
"include" /
"global.fieldmap.h";
13 if (!std::filesystem::exists(global_fieldmap_path)) {
15 "Base game detection failed: '{}' does not exist.",
34 std::ifstream file{global_fieldmap_path};
40 bool has_metatile_attribute_behavior =
false;
41 bool has_metatile_attr_behavior_mask =
false;
42 bool has_mapgrid_metatile_id_shift =
false;
43 bool has_swap_palettes =
false;
46 while (std::getline(file, line)) {
47 if (line.find(
"METATILE_ATTRIBUTE_BEHAVIOR") != std::string::npos) {
48 has_metatile_attribute_behavior =
true;
50 if (line.find(
"METATILE_ATTR_BEHAVIOR_MASK") != std::string::npos) {
51 has_metatile_attr_behavior_mask =
true;
53 if (line.find(
"MAPGRID_METATILE_ID_SHIFT") != std::string::npos) {
54 has_mapgrid_metatile_id_shift =
true;
56 if (line.find(
"swapPalettes") != std::string::npos) {
57 has_swap_palettes =
true;
64 if (has_metatile_attribute_behavior) {
65 if (has_metatile_attr_behavior_mask) {
67 reason =
"Found both METATILE_ATTRIBUTE_BEHAVIOR and METATILE_ATTR_BEHAVIOR_MASK";
71 reason =
"Found METATILE_ATTRIBUTE_BEHAVIOR";
74 else if (has_metatile_attr_behavior_mask) {
75 if (has_mapgrid_metatile_id_shift) {
76 if (has_swap_palettes) {
78 reason =
"Found METATILE_ATTR_BEHAVIOR_MASK, MAPGRID_METATILE_ID_SHIFT, and swapPalettes";
82 reason =
"Found METATILE_ATTR_BEHAVIOR_MASK and MAPGRID_METATILE_ID_SHIFT";
87 reason =
"Found METATILE_ATTR_BEHAVIOR_MASK but no MAPGRID_METATILE_ID_SHIFT";
92 "Base game detection failed: no recognized markers found in '{}'.",
96 constexpr auto tag =
"base-game-detection";
ChainableResult< BaseGame > detect() const
Detects the base game for the project.
A result type that maintains a chainable sequence of errors for debugging and error reporting.
static const Style bold
Bold text formatting.
virtual std::string format(const std::string &format_str, const std::vector< FormatParam > ¶ms) const
Formats a string with styled parameters using fmtlib syntax.
virtual void remark(const std::string &tag, const std::vector< std::string > &lines) const =0
Display a tagged remark message.
virtual void remark_note(const std::string &tag, const std::vector< std::string > &lines) const =0
Display a tagged note message associated with a remark.
BaseGame
Identifies the target base game for a decompilation project.