diff --git a/nel/tools/ligo/unbuild_flora/unbuild_flora.cpp b/nel/tools/ligo/unbuild_flora/unbuild_flora.cpp index 1b718ca94..1537c09ce 100644 --- a/nel/tools/ligo/unbuild_flora/unbuild_flora.cpp +++ b/nel/tools/ligo/unbuild_flora/unbuild_flora.cpp @@ -26,26 +26,18 @@ #include #include -//#include #include #include -//#include #include #include #include #include -//#include -//#include -//#include -//#include -//#include -//#include #include -//#include - +#include +#include #include #include #include @@ -178,7 +170,7 @@ bool loadLeveldesign() for (std::vector::iterator it(plants.begin()), end(plants.end()); it != end; ++it) { - printf("%s\n", (*it).c_str()); + printf("%s\n", nlUtf8ToMbcs(*it)); CSmartPtr form = formLoader->loadForm(*it); if (!form) continue; @@ -193,11 +185,11 @@ bool loadLeveldesign() } if (plant.Shape.empty()) continue; - plant.Shape.c_str(); - (void)toLowerAscii(&plant.Shape[0]); + (void)plant.Shape.c_str(); + toLowerAscii(&plant.Shape[0]); if (!form->getRootNode().getValueByName(plant.Radius, "3D.Bounding Radius")) continue; - printf(" = '%s', %f\n", plant.Shape.c_str(), plant.Radius); + printf(" = '%s', %f\n", nlUtf8ToMbcs(plant.Shape), plant.Radius); s_ShapeToForm[plant.Shape] = plant; } @@ -213,7 +205,7 @@ bool loadInstances() { if (CFile::getExtension(*it) != nlstr("ig")) continue; - printf("%s\n", (*it).c_str()); + printf("%s\n", nlUtf8ToMbcs(*it)); CInstanceGroup ig; CIFile inputStream; if (!inputStream.open(*it)) @@ -237,14 +229,14 @@ bool loadInstances() instance.Angle = info.Rot.getAngle(); instance.Scale = info.Scale.z; instance.Shape = toLowerAscii(info.Name); - printf("%s\n", instance.Shape.c_str()); + printf("%s\n", nlUtf8ToMbcs(instance.Shape)); std::map::iterator formIt = s_ShapeToForm.find(instance.Shape); if (formIt != s_ShapeToForm.end()) { instance.Form = formIt->second.Form; instance.Name = CFile::getFilenameWithoutExtension(instance.Form) + nlstr("_") + zoneLwr + nlstr("_") + toString(i); instance.Radius = instance.Scale * formIt->second.Radius; - printf(" = %f, %f, %f, %f, %f, '%s', '%s', %f\n", instance.Pos.x, instance.Pos.y, instance.Pos.z, instance.Angle, instance.Scale, instance.Form .c_str(), instance.Name.c_str(), instance.Radius); + printf(" = %f, %f, %f, %f, %f, '%s', '%s', %f\n", instance.Pos.x, instance.Pos.y, instance.Pos.z, instance.Angle, instance.Scale, nlUtf8ToMbcs(instance.Form), nlUtf8ToMbcs(instance.Name), instance.Radius); instance.Plant = true; } else @@ -267,7 +259,7 @@ bool eraseReference() { if (CFile::getExtension(*it) != nlstr("ig")) continue; - printf("%s\n", (*it).c_str()); + printf("%s\n", nlUtf8ToMbcs(*it)); CInstanceGroup ig; CIFile inputStream; if (!inputStream.open(*it)) @@ -287,7 +279,7 @@ bool eraseReference() { CInstanceGroup::CInstance &info = ig._InstancesInfos[i]; string shape = toLowerAscii(info.Name); - printf("%s\n", shape.c_str()); + printf("%s\n", nlUtf8ToMbcs(shape)); bool erased = false; for (std::list::iterator it(s_Instances.begin()), end(s_Instances.end()); it != end; ++it) { @@ -317,7 +309,7 @@ bool eraseNonPlants() const CPoint &instance = *it; if (!instance.Plant) { - printf("Erase '%s' because it's not a plant!\n", instance.Shape.c_str()); + printf("Erase '%s' because it's not a plant!\n", nlUtf8ToMbcs(instance.Shape)); std::list::iterator nextIt = it; ++nextIt; s_Instances.erase(it); @@ -332,6 +324,62 @@ bool eraseNonPlants() return true; } +bool writeFlora() +{ + ofstream fo; + fo.open(utf8ToWide(s_PrimitiveFile)); + fo << "\n"; + fo << "\n"; + fo << " \n"; + fo << " \n"; + fo << " \n"; + fo << " \n"; + fo << " class\n"; + fo << " flora\n"; + fo << " \n"; + fo << " \n"; + fo << " name\n"; + fo << " " << CFile::getFilenameWithoutExtension(s_PrimitiveFile) << "_flora\n"; + fo << " \n"; + for (std::list::iterator it(s_Instances.begin()), end(s_Instances.end()); it != end; ++it) + { + const CPoint &instance = *it; + fo << " \n"; + fo << " \n"; + fo << " \n"; + fo << " \n"; + fo << " class\n"; + fo << " prim\n"; + fo << " \n"; + fo << " \n"; + fo << " form\n"; + fo << " " << CFile::getFilenameWithoutExtension(instance.Form) << "\n"; + fo << " \n"; + fo << " \n"; + fo << " layer\n"; + fo << " 0\n"; + fo << " \n"; + fo << " \n"; + fo << " name\n"; + fo << " " << instance.Name << "\n"; + fo << " \n"; + fo << " \n"; + fo << " radius\n"; + fo << " " << instance.Radius << "\n"; + fo << " \n"; + fo << " \n"; + fo << " scale\n"; + fo << " " << instance.Scale << "\n"; + fo << " \n"; + fo << " \n"; + } + fo << " \n"; + fo << " \n"; + fo << "\n"; + printf("Generated:\n%s\n", nlUtf8ToMbcs(s_PrimitiveFile)); + return true; +} + bool unbuildFlora() { CPath::addSearchPath(s_DfnDir, true, false); @@ -340,7 +388,8 @@ bool unbuildFlora() return loadLeveldesign() && loadInstances() && eraseReference() - && eraseNonPlants(); + && eraseNonPlants() + && writeFlora(); } bool unbuildFlora(NLMISC::CCmdArgs &args)