Skip to content

Commit

Permalink
fix path mangling error
Browse files Browse the repository at this point in the history
also provide more robust logging
  • Loading branch information
ab9rf committed Jan 14, 2025
1 parent 211ab81 commit f00381d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ContentBuildingReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,15 @@ bool includeFile(SpriteNode* node, TiXmlElement* includeNode, SpriteTile* &oldSi
std::filesystem::path documentRef = getDocument(includeNode);

std::filesystem::path configfilepath = getLocalFilename(includeNode->Attribute("file"), documentRef);
std::filesystem::path incpath = configfilepath / "include";
std::filesystem::path incpath = configfilepath.remove_filename() / "include" / configfilepath.filename();
TiXmlDocument doc( incpath.string().c_str() );
bool loadOkay = doc.LoadFile();
TiXmlHandle hDoc(&doc);
TiXmlElement* elemParent;
if(!loadOkay) {
contentError("Include failed",includeNode);
LogError("File load failed: %s\n", configfilepath.string().c_str());
LogError("Line %d: %s\n",doc.ErrorRow(),doc.ErrorDesc());
LogError("File load failed: %s\n", incpath.string().c_str());
LogError("Line %d: %s\n",doc.ErrorRow(),doc.ErrorDesc() ? doc.ErrorDesc() : "(null)");
return false;
}
elemParent = hDoc.FirstChildElement("include").Element();
Expand Down
8 changes: 7 additions & 1 deletion ContentLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,13 @@ const char* getDocument(TiXmlNode* element)

void contentError(const string& message, TiXmlNode* element)
{
LogError("%s: %s: %s (Line %d)\n",getDocument(element),message.c_str(), element->Value(), element->Row());
auto safeStr = [](const char* s)->const char* {return s ? s : "(unknown)"; };

LogError("%s: %s: %s (Line %d)\n",
safeStr(getDocument(element)),
message.c_str(),
element ? safeStr(element->Value()) : "(no element)",
element ? element->Row() : -1);
}
void contentWarning(const string& message, TiXmlNode* element)
{
Expand Down

0 comments on commit f00381d

Please sign in to comment.