Build R2 islands xml separately per continent, and build it properly

ryzomclassic-develop
kaetemi 5 years ago
parent f39a7fe349
commit 5f3675446c

@ -46,6 +46,7 @@ printLog(log, "")
# Setup build directories
printLog(log, ">>> Setup build directories <<<")
mkPath(log, ExportBuildDirectory + "/" + CartographerBuildDirectory)
mkPath(log, ExportBuildDirectory + "/" + CartographerMapBuildDirectory)
# Setup lookup directories
printLog(log, ">>> Setup lookup directories <<<")
@ -65,6 +66,7 @@ for dir in PropertiesExportBuildSearchPaths:
# Setup client directories
printLog(log, ">>> Setup install directories <<<")
mkPath(log, InstallDirectory + "/" + CartographerInstallDirectory)
mkPath(log, InstallDirectory + "/" + IslandsInstallDirectory)
# Setup client directories
printLog(log, ">>> Setup configuration <<<")
@ -103,7 +105,7 @@ cfg.write("InverseZTest = true;\n")
cfg.write("Vegetation = true;\n")
cfg.write("MeterPixelSize = 2;\n")
cfg.write("\n")
cfg.write("CompleteIslandsFile = \"r2_islands.xml\";\n")
cfg.write("CompleteIslandsFile = \"" + ExportBuildDirectory + "/" + CartographerBuildDirectory + "/" + IslandsXmlFile + "\";\n")
cfg.write("EntryPointsFile = \"r2_entry_points.txt\";\n")
cfg.write("\n")
cfg.close()

@ -45,6 +45,7 @@ printLog(log, "")
# Find tools
R2IslandsTextures = findTool(log, ToolDirectories, R2IslandsTexturesTool, ToolSuffix)
TgaToDds = findTool(log, ToolDirectories, TgaToDdsTool, ToolSuffix)
if R2IslandsTextures == "":
toolLogFail(log, R2IslandsTexturesTool, ToolSuffix)
@ -53,9 +54,33 @@ else:
cfgPath = ActiveProjectDirectory + "/generated/island_screenshots.cfg"
shutil.copy(cfgPath, "island_screenshots.cfg")
printLog(log, ">>> Build cartographer <<<")
mkPath(log, ExportBuildDirectory + "/" + CartographerBuildDirectory)
subprocess.call([ R2IslandsTextures ])
printLog(log, "")
printLog(log, ">>> Compress cartographer maps to DDS <<<")
if TgaToDds == "":
toolLogFail(log, TgaToDdsTool, ToolSuffix)
else:
destPath = ExportBuildDirectory + "/" + CartographerMapBuildDirectory
mkPath(log, destPath)
sourcePath = ExportBuildDirectory + "/" + CartographerBuildDirectory
mkPath(log, sourcePath)
files = os.listdir(sourcePath)
len_tga_png = len(".tga")
len_dds = len(".dds")
for fileName in files:
if isLegalFileName(fileName):
sourceFile = sourcePath + "/" + fileName
if os.path.isfile(sourceFile):
if (fileName[-len_tga_png:].lower() == ".tga") or (fileName[-len_tga_png:].lower() == ".png"):
destFile = destPath + "/" + os.path.basename(fileName)[0:-len_tga_png] + ".dds"
if needUpdateLogRemoveDest(log, sourceFile, destFile):
subprocess.call([ TgaToDds, sourceFile, "-o", destFile, "-m" ])
elif not os.path.isdir(sourceFile):
printLog(log, "FAIL ?! file not dir or file ?! " + sourceFile)
printLog(log, "")
log.close()

@ -43,12 +43,21 @@ printLog(log, "-------")
printLog(log, time.strftime("%Y-%m-%d %H:%MGMT", time.gmtime(time.time())))
printLog(log, "")
installPath = InstallDirectory + "/" + CartographerInstallDirectory
mkPath(log, installPath)
islandsInstallPath = InstallDirectory + "/" + IslandsInstallDirectory
printLog(log, ">>> Install cartographer <<<")
mkPath(log, ExportBuildDirectory + "/" + CartographerMapBuildDirectory)
mkPath(log, installPath)
copyFilesExtNoTreeIfNeeded(log, ExportBuildDirectory + "/" + CartographerMapBuildDirectory, installPath, ".dds")
mkPath(log, ExportBuildDirectory + "/" + CartographerBuildDirectory)
copyFilesNoTreeIfNeeded(log, ExportBuildDirectory + "/" + CartographerBuildDirectory, installPath)
mkPath(log, islandsInstallPath)
copyFilesExtNoTreeIfNeeded(log, ExportBuildDirectory + "/" + CartographerBuildDirectory, islandsInstallPath, ".xml")
printLog(log, "")
log.close()

@ -53,6 +53,7 @@ mkPath(log, ExportBuildDirectory + "/" + PackedZoneBuildDirectory)
printLog(log, ">>> Setup lookup directories <<<")
mkPath(log, ExportBuildDirectory + "/" + AiWmapBuildDirectory)
mkPath(log, ExportBuildDirectory + "/" + ZoneLightBuildDirectory)
mkPath(log, ExportBuildDirectory + "/" + CartographerBuildDirectory)
mkPath(log, LeveldesignDataCommonDirectory)
# Setup client directories
@ -69,6 +70,7 @@ cfg.write("\n")
cfg.write("SearchPaths = {\n")
cfg.write("\t\"" + ExportBuildDirectory + "/" + AiWmapBuildDirectory + "\", \n")
cfg.write("\t\"" + ExportBuildDirectory + "/" + ZoneLightBuildDirectory + "\", \n")
cfg.write("\t\"" + ExportBuildDirectory + "/" + CartographerBuildDirectory + "\", \n")
cfg.write("\t\"" + LeveldesignDataCommonDirectory + "\", \n")
cfg.write("};\n")
cfg.write("\n")
@ -76,7 +78,8 @@ cfg.write("CachePath = \"" + ExportBuildDirectory + "/" + PackedZoneCacheBuildDi
cfg.write("CWMapCachePath = \"" + ExportBuildDirectory + "/" + PackedZoneCWMapCacheBuildDirectory + "\";\n")
cfg.write("OutputPath = \"" + ExportBuildDirectory + "/" + PackedZoneBuildDirectory + "\";\n")
cfg.write("\n")
cfg.write("EntryPointsFile = \"r2_islands.xml\";\n")
cfg.write("CompleteIslandsFile = \"" + IslandsXmlFile + "\";\n")
cfg.write("EntryPointsFile = \"r2_entry_points.txt\";\n")
cfg.write("\n")
cfg.write("CWMapList = {\n")
cfg.write("\t\"" + PackedZoneCWMap + "\", \n")

@ -59,7 +59,13 @@ CScenarioEntryPoints::CScenarioEntryPoints()
void CScenarioEntryPoints::init()
{
_CompleteIslandsFilename = "r2_islands.xml";
_HardIslandsPath = false;
_CompleteIslandsFilenames.clear();
_CompleteIslandsFilenames.push_back("r2_desert_islands.xml");
_CompleteIslandsFilenames.push_back("r2_lakes_islands.xml");
_CompleteIslandsFilenames.push_back("r2_jungle_islands.xml");
_CompleteIslandsFilenames.push_back("r2_forest_islands.xml");
_CompleteIslandsFilenames.push_back("r2_roots_islands.xml");
_EntryPointsFilename = "r2_entry_points.txt";
}
//-----------------------------------------------------------------------------
@ -98,6 +104,26 @@ const CScenarioEntryPoints::TEntryPoints& CScenarioEntryPoints::getEntryPoints()
return _EntryPoints;
}
void CScenarioEntryPoints::setFiles(const std::string &completeIslandsFilename, const std::string &entryPointsFilename)
{
if (_CompleteIslandsFilenames.size() != 1
|| _CompleteIslandsFilenames[0] != completeIslandsFilename
|| _EntryPointsFilename != entryPointsFilename)
{
_HardIslandsPath = completeIslandsFilename.find('/') != std::string::npos
|| completeIslandsFilename.find('\\') != std::string::npos;
_CompleteIslandsFilenames.clear();
_CompleteIslandsFilenames.push_back(completeIslandsFilename);
_EntryPointsFilename = entryPointsFilename;
_CompleteIslands.clear();
_CompleteIslandsLoaded = false;
_EntryPoints.clear();
_IsLoaded = false;
_LastFoundIsland = NULL;
}
}
//-----------------------------------------------------------------------------
// TEMP
uint32 CScenarioEntryPoints::getIslandId(const CSString& island)
@ -224,7 +250,18 @@ void CScenarioEntryPoints::loadFromFile()
CScenarioEntryPoints::CCompleteIsland *CScenarioEntryPoints::getCompleteIslandFromCoords(const NLMISC::CVector2f &pos)
{
loadCompleteIslands();
if (fabs((double) pos.x - _LastTestedCoords.x) > 20.f ||
if (_LastFoundIsland)
{
if (pos.x >= (float) _LastFoundIsland->XMin &&
pos.x <= (float) _LastFoundIsland->XMax &&
pos.y >= (float) _LastFoundIsland->YMin &&
pos.y <= (float) _LastFoundIsland->YMax)
{
return _LastFoundIsland;
}
}
if (!_LastFoundIsland ||
fabs((double) pos.x - _LastTestedCoords.x) > 20.f ||
fabs((double) pos.y - _LastTestedCoords.y) > 20.f)
{
_LastTestedCoords = pos;
@ -293,153 +330,160 @@ void CScenarioEntryPoints::loadFromXMLFile()
// clear out the entry point vector before we begin
_CompleteIslands.clear();
_LastFoundIsland = NULL;
// File stream
CIFile file;
// setup the file name
std::string pathFileName = CPath::lookup(_CompleteIslandsFilename.c_str());
// Open the file
if (!file.open(pathFileName.c_str()))
for (size_t i = 0; i < _CompleteIslandsFilenames.size(); ++i)
{
nlinfo("Can't open the file for reading : %s", pathFileName.c_str());
}
// File stream
CIFile file;
// Create the XML stream
CIXml input;
// setup the file name
std::string pathFileName = _HardIslandsPath
? _CompleteIslandsFilenames[i]
: CPath::lookup(_CompleteIslandsFilenames[i]);
// Init
if(input.init(file))
{
xmlNodePtr islands = input.getRootNode();
xmlNodePtr islandNode = input.getFirstChildNode(islands, "complete_island");
// Open the file
if (!file.open(pathFileName.c_str()))
{
nlinfo("Can't open the file for reading : %s", pathFileName.c_str());
if (_HardIslandsPath)
continue;
}
// Create the XML stream
CIXml input;
while (islandNode != 0)
// Init
if (input.init(file))
{
CCompleteIsland completeIsland;
xmlNodePtr islands = input.getRootNode();
xmlNodePtr islandNode = input.getFirstChildNode(islands, "complete_island");
// island name
const char *island = (const char*) xmlGetProp(islandNode, (xmlChar*) "island");
if(island == 0)
{
nlinfo("no 'island' tag in %s", _CompleteIslandsFilename.c_str());
continue;
}
else
completeIsland.Island = CSString(island);
// package
/*
const char *package = (const char*) xmlGetProp(islandNode, (xmlChar*) "package");
if(package == 0)
nlinfo("no 'package' tag in %s island", island);
else
completeIsland.Package = CSString(package);
*/
// continent
const char *continent = (const char*) xmlGetProp(islandNode, (xmlChar*) "continent");
if(continent == 0)
nlinfo("no 'continent' tag in %s island", island);
else
completeIsland.Continent = CSString(continent);
// xmin
const char *xmin = (const char*) xmlGetProp(islandNode, (xmlChar*) "xmin");
if(xmin == 0)
nlinfo("no 'xmin' tag in %s island", island);
else
fromString(xmin, completeIsland.XMin);
// ymin
const char *ymin = (const char*) xmlGetProp(islandNode, (xmlChar*) "ymin");
if(ymin == 0)
nlinfo("no 'ymin' tag in %s island", island);
else
fromString(ymin, completeIsland.YMin);
// xmax
const char *xmax = (const char*) xmlGetProp(islandNode, (xmlChar*) "xmax");
if(xmax == 0)
nlinfo("no 'xmax' tag in %s island", island);
else
fromString(xmax, completeIsland.XMax);
// ymax
const char *ymax = (const char*) xmlGetProp(islandNode, (xmlChar*) "ymax");
if(ymax == 0)
nlinfo("no 'ymax' tag in %s island", island);
else
fromString(ymax, completeIsland.YMax);
//entry points and package
TShortEntryPoints entryPoints;
std::string package;
for(uint e=0; e<_EntryPoints.size(); e++)
while (islandNode != 0)
{
const CEntryPoint & entryPoint = _EntryPoints[e];
CShortEntryPoint shortEntryPoint;
CCompleteIsland completeIsland;
if(entryPoint.Island == island)
// island name
const char *island = (const char *)xmlGetProp(islandNode, (xmlChar *)"island");
if (island == 0)
{
shortEntryPoint.Location = entryPoint.Location;
shortEntryPoint.X = entryPoint.X;
shortEntryPoint.Y = entryPoint.Y;
entryPoints.push_back(shortEntryPoint);
if(package.empty())
package=entryPoint.Package;
else if(package!=entryPoint.Package)
nlinfo("Different packages for island '%s' in file %s", island, _EntryPointsFilename.c_str());
nlinfo("no 'island' tag in %s", _CompleteIslandsFilenames[i].c_str());
continue;
}
}
if(package.empty())
nlinfo("no 'package' tag in %s island", island);
else
completeIsland.Package = CSString(package);
else
completeIsland.Island = CSString(island);
// package
/*
const char *package = (const char*) xmlGetProp(islandNode, (xmlChar*) "package");
if(package == 0)
nlinfo("no 'package' tag in %s island", island);
else
completeIsland.Package = CSString(package);
*/
// zones
xmlNodePtr zoneNode = input.getFirstChildNode(islandNode, "zone");
// continent
const char *continent = (const char *)xmlGetProp(islandNode, (xmlChar *)"continent");
if (continent == 0)
nlinfo("no 'continent' tag in %s island", island);
else
completeIsland.Continent = CSString(continent);
while(zoneNode != 0)
{
// island name
const char *zoneName = (const char*) xmlGetProp(zoneNode, (xmlChar*) "name");
if(zoneName == 0)
// xmin
const char *xmin = (const char *)xmlGetProp(islandNode, (xmlChar *)"xmin");
if (xmin == 0)
nlinfo("no 'xmin' tag in %s island", island);
else
fromString(xmin, completeIsland.XMin);
// ymin
const char *ymin = (const char *)xmlGetProp(islandNode, (xmlChar *)"ymin");
if (ymin == 0)
nlinfo("no 'ymin' tag in %s island", island);
else
fromString(ymin, completeIsland.YMin);
// xmax
const char *xmax = (const char *)xmlGetProp(islandNode, (xmlChar *)"xmax");
if (xmax == 0)
nlinfo("no 'xmax' tag in %s island", island);
else
fromString(xmax, completeIsland.XMax);
// ymax
const char *ymax = (const char *)xmlGetProp(islandNode, (xmlChar *)"ymax");
if (ymax == 0)
nlinfo("no 'ymax' tag in %s island", island);
else
fromString(ymax, completeIsland.YMax);
//entry points and package
TShortEntryPoints entryPoints;
std::string package;
for (uint e = 0; e < _EntryPoints.size(); e++)
{
nlinfo("no 'zone name' tag in %s", _CompleteIslandsFilename.c_str());
const CEntryPoint &entryPoint = _EntryPoints[e];
CShortEntryPoint shortEntryPoint;
if (entryPoint.Island == island)
{
shortEntryPoint.Location = entryPoint.Location;
shortEntryPoint.X = entryPoint.X;
shortEntryPoint.Y = entryPoint.Y;
entryPoints.push_back(shortEntryPoint);
if (package.empty())
package = entryPoint.Package;
else if (package != entryPoint.Package)
nlinfo("Different packages for island '%s' in file %s", island, _EntryPointsFilename.c_str());
}
}
if (package.empty())
nlinfo("no 'package' tag in %s island", island);
else
completeIsland.Zones.push_back(std::string(zoneName));
completeIsland.Package = CSString(package);
zoneNode = input.getNextChildNode(zoneNode, "zone");
}
// zones
xmlNodePtr zoneNode = input.getFirstChildNode(islandNode, "zone");
// compute zones ids from zone names
for(std::list<std::string>::iterator it = completeIsland.Zones.begin(); it != completeIsland.Zones.end(); ++it)
{
sint x, y;
if (getZonePosFromZoneName(*it, x, y))
while (zoneNode != 0)
{
completeIsland.ZoneIDs.push_back(((uint16) x&255)+((uint16) (-y - 1)<<8));
// island name
const char *zoneName = (const char *)xmlGetProp(zoneNode, (xmlChar *)"name");
if (zoneName == 0)
{
nlinfo("no 'zone name' tag in %s", _CompleteIslandsFilenames[i].c_str());
}
else
completeIsland.Zones.push_back(std::string(zoneName));
zoneNode = input.getNextChildNode(zoneNode, "zone");
}
}
// compute zones ids from zone names
for (std::list<std::string>::iterator it = completeIsland.Zones.begin(); it != completeIsland.Zones.end(); ++it)
{
sint x, y;
if (getZonePosFromZoneName(*it, x, y))
{
completeIsland.ZoneIDs.push_back(((uint16)x & 255) + ((uint16)(-y - 1) << 8));
}
}
if(!entryPoints.empty())
{
completeIsland.EntryPoints = entryPoints;
_CompleteIslands.push_back(completeIsland);
}
if (!entryPoints.empty())
{
completeIsland.EntryPoints = entryPoints;
_CompleteIslands.push_back(completeIsland);
_LastFoundIsland = NULL;
}
islandNode = input.getNextChildNode(islandNode, "complete_island");
islandNode = input.getNextChildNode(islandNode, "complete_island");
}
}
}
// Close the file
file.close ();
// Close the file
file.close();
}
_CompleteIslandsLoaded = true;
}
@ -470,7 +514,8 @@ void CScenarioEntryPoints::saveXMLFile(const TCompleteIslands & completeIslands,
COFile file;
// setup the file name
std::string pathFilename = CPath::lookup(fileName.c_str());
std::string pathFilename = (fileName.find('/') != std::string::npos || fileName.find('\\') != std::string::npos)
? fileName : CPath::lookup(fileName.c_str());
// Open the file
if (!file.open(pathFilename.c_str()))

@ -135,6 +135,8 @@ namespace R2
// get the vector of complete islands
const TCompleteIslands& getCompleteIslands();
void setFiles(const std::string &completeIslandsFilename, const std::string &entryPointsFilename);
private:
//-------------------------------------------------------------------------
// this is a singleton so prevent instantiation
@ -184,7 +186,8 @@ namespace R2
NLMISC::CVector2f _LastTestedCoords;
CCompleteIsland *_LastFoundIsland;
std::string _CompleteIslandsFilename;
bool _HardIslandsPath;
std::vector<std::string> _CompleteIslandsFilenames;
std::string _EntryPointsFilename;
};

@ -116,10 +116,15 @@ void CScreenshotIslands::init()
CPath::remapExtension("dds", "png", true);
// get the scenario entry points file
CConfigFile::CVar * epFile = cf.getVarPtr("CompleteIslandsFile");
CConfigFile::CVar * ciFile = cf.getVarPtr("CompleteIslandsFile");
if(ciFile)
{
_CompleteIslandsFile = ciFile->asString();
}
CConfigFile::CVar * epFile = cf.getVarPtr("EntryPointsFile");
if(epFile)
{
_CompleteIslandsFile = epFile->asString();
_EntryPointsFile = epFile->asString();
}
// get the out directory path
@ -298,15 +303,11 @@ void CScreenshotIslands::searchIslandsBorders()
filenames.clear();
zonelFiles.clear();
string bnpFileName = itCont->first + ".bnp";
CBigFile::getInstance().list(bnpFileName.c_str(), filenames); // FIXME FIXME NOT READING FROM BNP!
CPath::getFileList("zonel", filenames);
for(uint i=0; i<filenames.size(); i++)
{
if(CFile::getExtension(filenames[i]) == "zonel")
{
zonelFiles.push_back(filenames[i]);
}
zonelFiles.push_back(filenames[i]);
}
list<string>::iterator itZonel(zonelFiles.begin()), lastZonel(zonelFiles.end());
@ -1105,7 +1106,9 @@ void CScreenshotIslands::loadIslands()
{
// load entryPoints
map< string, CVector2f > islands;
CScenarioEntryPoints scenarioEntryPoints = CScenarioEntryPoints::getInstance();
CScenarioEntryPoints &scenarioEntryPoints = CScenarioEntryPoints::getInstance();
scenarioEntryPoints.setFiles(_CompleteIslandsFile, _EntryPointsFile);
scenarioEntryPoints.loadFromFile();
const CScenarioEntryPoints::TEntryPoints& entryPoints = scenarioEntryPoints.getEntryPoints();
@ -1197,43 +1200,50 @@ void CScreenshotIslands::loadIslands()
}
}
CScenarioEntryPoints::TCompleteIslands completeIslands; // Copy (empty if using separate xml files)
completeIslands.reserve(entryPoints.size());
CScenarioEntryPoints::TCompleteIslands completeIslands(entryPoints.size());
uint completeIslandsNb = 0;
for(uint e=0; e<entryPoints.size(); e++)
for (uint e = 0; e < entryPoints.size(); e++)
{
const CScenarioEntryPoints::CEntryPoint & entry = entryPoints[e];
const CScenarioEntryPoints::CEntryPoint &entry = entryPoints[e];
CScenarioEntryPoints::CCompleteIsland completeIsland;
completeIsland.Island = entry.Island;
completeIsland.Package = entry.Package;
for(itCont=_ContinentsData.begin(); itCont!=_ContinentsData.end(); ++itCont)
for (itCont = _ContinentsData.begin(); itCont != _ContinentsData.end(); ++itCont) // Look through all continents
{
list< string >::const_iterator itIsland(itCont->second.Islands.begin()), lastIsland(itCont->second.Islands.end());
for( ; itIsland != lastIsland ; ++itIsland)
list<string>::const_iterator itIsland(itCont->second.Islands.begin()), lastIsland(itCont->second.Islands.end()); // Look through all islands
for (; itIsland != lastIsland; ++itIsland)
{
if(*itIsland == entry.Island)
if (*itIsland == entry.Island)
{
completeIsland.Continent = CSString(itCont->first);
if(_IslandsData.find(entry.Island)!=_IslandsData.end())
TIslandsData::iterator islandIt = _IslandsData.find(entry.Island);
if (islandIt != _IslandsData.end())
{
completeIsland.XMin = _IslandsData[entry.Island].getBoundXMin();
completeIsland.YMin = _IslandsData[entry.Island].getBoundYMin();
completeIsland.XMax = _IslandsData[entry.Island].getBoundXMax();
completeIsland.YMax = _IslandsData[entry.Island].getBoundYMax();
completeIslands[completeIslandsNb] = completeIsland;
completeIslandsNb++;
// Island found in the current build context
completeIslands.resize(completeIslands.size() + 1);
CScenarioEntryPoints::CCompleteIsland &island = completeIslands[completeIslands.size() - 1];
// Update data from r2_entry_points.txt
island.Island = entry.Island;
// island.Package = entry.Package; // Loaded from txt
// Update from _ContinentsData
island.Continent = CSString(itCont->first);
// Update from _IslandsData
island.XMin = islandIt->second.getBoundXMin();
island.YMin = islandIt->second.getBoundYMin();
island.XMax = islandIt->second.getBoundXMax();
island.YMax = islandIt->second.getBoundYMax();
// TODO:
// FIXME: island.Zones
}
break;
}
}
}
}
completeIslands.resize(completeIslandsNb);
CScenarioEntryPoints::getInstance().saveXMLFile(completeIslands, _CompleteIslandsFile);
scenarioEntryPoints.saveXMLFile(completeIslands, _CompleteIslandsFile);
}
//--------------------------------------------------------------------------------

@ -132,6 +132,7 @@ private:
NLMISC::CRGBA _BackColor;
NLMISC::CBitmap _BackBitmap;
std::string _CompleteIslandsFile;
std::string _EntryPointsFile;
};

Loading…
Cancel
Save