// Property 文件(`.prb` Building / `.prt` Tree / `.pre` Effect / `.prd` DungeonBlock / // `.pra` Ambience)+ CRC 注册表。SHINSOO §5.6 / §9-W0 / BACKLOG E13。 // // 文件格式(文本): // 行1: YPRT // 行2: 十进制 uint32 // 行3+: \t"" (key 小写,value 去引号) // // AreaData 的 property_crc 指向这里的 crc。W0 只建 crc -> Property 索引,不做实例化。 #pragma once #include #include #include #include namespace fmt { enum class PropertyType { Unknown, Tree, Building, Effect, Ambience, DungeonBlock }; struct Property { uint32_t crc = 0; PropertyType type = PropertyType::Unknown; std::string name; // propertyname std::string type_str; // propertytype 原字符串 std::map kv; // 全部键值(含 buildingfile / treefile / ...) std::string source_path; // 来源文件(诊断用) std::string get(const std::string& key, const std::string& def = "") const; }; PropertyType property_type_from_string(const std::string& s); bool parse_property(const std::string& text, Property& out, std::string* err); bool parse_property_file(const std::string& path, Property& out, std::string* err); // 扫一个目录树,收集所有 property 文件,按 crc 索引。 struct PropertyRegistry { std::map by_crc; int files_scanned = 0; int parse_failed = 0; int crc_collisions = 0; // 同 crc 出现多次(保留第一个) std::vector failed_paths; std::map type_counts; // "Tree" -> N ... const Property* find(uint32_t crc) const; // root 通常是 `/Property`。递归找 *.prb/*.prt/*.pre/*.prd/*.pra(std::filesystem)。 bool scan(const std::string& root, std::string* err); // 同上,但文件清单外部给(PCK 里没法 recursive_directory_iterator)。 // rel_paths 里挑属性扩展名的,逐个 read_file(root + "/" + rel) 解析。 bool scan_list(const std::string& root, const std::vector& rel_paths, std::string* err); }; } // namespace fmt