From d6e1ca7c6c64aa572a7f0110c092852cf8318d50 Mon Sep 17 00:00:00 2001 From: shweet Date: Thu, 19 Nov 2026 22:31:16 -0500 Subject: [PATCH] data.h: resource_path (lowercased, as the game normalizes); .anm2 files are Anm2Ed JSON documents The import tool now writes every .anm2 as Anm2Ed's JSON document under its own name (anm2ed convert --format json), as isaac-classic does; other XML keeps the generic {tag, attrs, children, text} mapping. Co-Authored-By: Claude Opus 5.5 --- src/data.cpp | 14 ++++++++++---- src/data.h | 4 +++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/data.cpp b/src/data.cpp index f0e22d2..ef978c0 100644 --- a/src/data.cpp +++ b/src/data.cpp @@ -3,13 +3,19 @@ std::string dataDirectory = "resources/"; -// Where a game path lives once imported: its converted JSON under the data directory. -// Paths are lowercased with forward slashes, as the game does before every lookup. -std::string data_path(std::string_view path) +// Where a game path lives once imported: under the data directory, lowercased with forward slashes, as the game +// normalizes every path before a lookup. +std::string resource_path(std::string_view path) { std::string normalized(path); for (char& letter : normalized) letter = letter == '\\' ? '/' : (char)std::tolower((unsigned char)letter); - return dataDirectory + normalized + ".json"; + return dataDirectory + normalized; +} + +// Where a converted XML document lives: its resource path with ".json" appended. +std::string data_path(std::string_view path) +{ + return resource_path(path) + ".json"; } // Loads a converted document, leaving isLoaded false when it is missing or unreadable. diff --git a/src/data.h b/src/data.h index 2475915..83e53d0 100644 --- a/src/data.h +++ b/src/data.h @@ -4,7 +4,8 @@ #include #include -// A game document the import tool converted from XML (items.xml, an .anm2 ...) into resources/.json. +// A game document the import tool converted from XML (items.xml, entities2.xml ...) into resources/.json. +// (.anm2 files are Anm2Ed's own JSON documents under their own names instead.) // Each element is {"tag", "attrs", "children", "text"}, with every attribute value kept as the string the XML held, // so loaders read it the way the game read its rapidxml nodes. struct Data @@ -18,6 +19,7 @@ using DataNode = simdjson::dom::element; void data_load(Data& data, std::string_view path); std::string data_path(std::string_view path); +std::string resource_path(std::string_view path); std::string_view node_tag(DataNode node); std::string_view node_attr(DataNode node, std::string_view name);