@@ -211,8 +211,9 @@ bool TMXMapInfo::parseXMLFile(const std::string& xmlFilename)
211211 }
212212
213213 parser.setDelegator (this );
214-
215- return parser.parse (FileUtils::getInstance ()->fullPathForFilename (xmlFilename));
214+ auto fullPath = FileUtils::getInstance ()->fullPathForFilename (xmlFilename);
215+ CCASSERT (FileUtils::getInstance ()->isFileExist (fullPath), " TMXMapInfo::parseXMLFile xml file not exists" );
216+ return parser.parse (fullPath);
216217}
217218
218219// the XML parser calls here with all the elements
@@ -314,7 +315,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
314315 _currentFirstGID = 0 ;
315316 }
316317 _recordFirstGID = false ;
317-
318+ _externalTilesetFullPath = externalTilesetFilename;
318319 tmxMapInfo->parseXMLFile (externalTilesetFilename);
319320 }
320321 else
@@ -431,7 +432,12 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
431432 std::string imagename = attributeDict[" source" ].asString ();
432433 tileset->_originSourceImage = imagename;
433434
434- if (_TMXFileName.find_last_of (" /" ) != string::npos)
435+ if (!_externalTilesetFullPath.empty ())
436+ {
437+ string dir = _externalTilesetFullPath.substr (0 , _externalTilesetFullPath.find_last_of (" /" ) + 1 );
438+ tileset->_sourceImage = dir + imagename;
439+ }
440+ else if (_TMXFileName.find_last_of (" /" ) != string::npos)
435441 {
436442 string dir = _TMXFileName.substr (0 , _TMXFileName.find_last_of (" /" ) + 1 );
437443 tileset->_sourceImage = dir + imagename;
0 commit comments