From f32a5d95d42392706ef66fbd7b0ba35ba8b8ac87 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 28 Mar 2020 15:42:21 +0800 Subject: [PATCH] Export zones as part of the R2 islands xml --- .../screenshot_islands.cpp | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/code/ryzom/tools/client/r2_islands_textures/screenshot_islands.cpp b/code/ryzom/tools/client/r2_islands_textures/screenshot_islands.cpp index ef852ab78..03cc6bd81 100644 --- a/code/ryzom/tools/client/r2_islands_textures/screenshot_islands.cpp +++ b/code/ryzom/tools/client/r2_islands_textures/screenshot_islands.cpp @@ -290,27 +290,18 @@ bool CScreenshotIslands::getPosFromZoneName(const std::string &name, NLMISC::CVe //------------------------------------------------------------------------------------------------- void CScreenshotIslands::searchIslandsBorders() { - vector filenames; - list zonelFiles; - - map< CVector2f, bool> islandsMap; + vector zonelFiles; + map islandsMap; TContinentsData::iterator itCont(_ContinentsData.begin()), lastCont(_ContinentsData.end()); for( ; itCont != lastCont ; ++itCont) { // for each continent we recover a map of zonel files whith position of // left/bottom point of each zone for keys - filenames.clear(); zonelFiles.clear(); + CPath::getFileList("zonel", zonelFiles); // MAYBE FIXME: Constrain to continent (although we only build one continent at a time...) - CPath::getFileList("zonel", filenames); - - for(uint i=0; i::iterator itZonel(zonelFiles.begin()), lastZonel(zonelFiles.end()); + vector::iterator itZonel(zonelFiles.begin()), lastZonel(zonelFiles.end()); for( ; itZonel != lastZonel ; ++itZonel) { CVector2f position; @@ -1203,6 +1194,16 @@ void CScreenshotIslands::loadIslands() CScenarioEntryPoints::TCompleteIslands completeIslands; // Copy (empty if using separate xml files) completeIslands.reserve(entryPoints.size()); + vector zonelFiles; + CPath::getFileList("zonel", zonelFiles); + map zonePosMap; + for (vector::iterator it(zonelFiles.begin()), end(zonelFiles.end()); it != end; ++it) + { + CVector2f pos; + if (getPosFromZoneName(*it, pos)) + zonePosMap[CFile::getFilenameWithoutExtension(*it)] = pos; + } + for (uint e = 0; e < entryPoints.size(); e++) { const CScenarioEntryPoints::CEntryPoint &entry = entryPoints[e]; @@ -1234,8 +1235,16 @@ void CScreenshotIslands::loadIslands() island.XMax = islandIt->second.getBoundXMax(); island.YMax = islandIt->second.getBoundYMax(); - // TODO: - // FIXME: island.Zones + sint32 zonelXMin = ((uint)(island.XMin / 160)) * 160; + sint32 zonelYMin = ((uint)(island.YMin / 160) - 1) * 160; + sint32 zonelXMax = ((uint)(island.XMax / 160)) * 160; + sint32 zonelYMax = ((uint)(island.YMax / 160) - 1) * 160; + + // List all zones + for (map::iterator it(zonePosMap.begin()), end(zonePosMap.end()); it != end; ++it) + if (it->second.x >= zonelXMin && it->second.x <= zonelXMax + && it->second.y >= zonelYMin && it->second.y <= zonelYMax) + island.Zones.push_back(NLMISC::toUpper(it->first)); } break; }