// Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . #include "nel/misc/path.h" #include "nel/misc/file.h" #include "nel/misc/common.h" #include "nel/misc/algo.h" using namespace std; using namespace NLMISC; // *************************************************************************** void buildRaceAnimNames(std::vector &raceAnimNames, const std::string &animName) { if(animName.compare(0, 3, "fy_")!=0) { nlwarning("ERROR: all .anim must begin with fy_"); exit(-1); } raceAnimNames.resize(4); raceAnimNames[0]= animName; raceAnimNames[1]= animName; raceAnimNames[2]= animName; raceAnimNames[3]= animName; raceAnimNames[0].replace(0, 3, "fy_"); raceAnimNames[1].replace(0, 3, "ma_"); raceAnimNames[2].replace(0, 3, "tr_"); raceAnimNames[3].replace(0, 3, "zo_"); // Force "" for(uint i=0;i &raceAnimNames) { // line Must contains Name="filename", else CAN BE A LOAD CHAR ANIMATION!!!! if(lineLwr.find("name=\"filename\"")==string::npos) return -1; // in the animset, the original file can be a "tr_" ... Not necessarily a "fy_" for(uint i=0;i &animSetText, uint startBlock, const vector ©Text, uint nameLineInBlock, uint nameIndexInLine, const string &raceAnimName) { // add empty space animSetText.insert(animSetText.begin()+startBlock, copyText.size(), string()); // Fill line by line for(uint i=0;i", peopleEnum.c_str()); } // copy animSetText[startBlock+i]= line; } } // *************************************************************************** void makeAnimByRace(const std::string &animSetFile, const std::vector &animList) { // *** Read the animset file. CIFile iFile; iFile.open(animSetFile, true); // Read all text static vector animSetText; animSetText.clear(); while(!iFile.eof()) { char tmp[50000]; iFile.getline(tmp, 50000); animSetText.push_back(tmp); } iFile.close(); bool someChangeDone= false; // *** For each possible anim for(uint i=0;i raceAnimNames; raceAnimNames.clear(); buildRaceAnimNames(raceAnimNames, toLower(CFile::getFilename(animList[i]))); // For each line of the animSet uint lastStructLine= 0; bool raceRestrictionFound= false; for(uint j=0;j TAg? => stop if(line.find("")!=string::npos) break; // Find a STRUCT start? if(line.find("")!=string::npos) { lastStructLine= j; raceRestrictionFound= false; } // Find a RaceRestriction? if( line.find("Name=\"Race Restriction\"")!=string::npos ) raceRestrictionFound= true; // Find the anim name? string::size_type nameIndexInLine= findAnimName(lineLwr, raceAnimNames); if(nameIndexInLine!=string::npos) { // Find the enclosing struct nlassert(lastStructLine!=0); uint startBlock= lastStructLine; uint nameLineInBlock= j-startBlock; uint endBlock= 0; for(uint k=j+1;k")!=string::npos) { // endBlock is exclusive endBlock= k+1; break; } } // if not found, abort if(endBlock==0) break; // if a raceRestriction has been found, no op (already done) if(raceRestrictionFound) { j= endBlock; } else { // LOG InfoLog->displayRawNL("%s: Specifying %s by race", CFile::getFilename(animSetFile).c_str(), CFile::getFilename(animList[i]).c_str()); // *** Start a copy paste ^^ // Copy static vector copyText; copyText.clear(); for(uint k=startBlock;k, for race selection node (filled later) if(k==endBlock-1) copyText.push_back(string()); copyText.push_back(animSetText[k]); } // erase this part animSetText.erase(animSetText.begin()+startBlock, animSetText.begin()+endBlock); uint nextBlock= startBlock; // Append for each race for(uint k=0;k files; CPath::getPathContent(animDir, false, false, true, files); // Filter .anim vector animList; InfoLog->displayRawNL(""); InfoLog->displayRawNL("********************"); InfoLog->displayRawNL("**** .anim list ****"); InfoLog->displayRawNL("********************"); for(uint i=0;idisplayRawNL(animList.back().c_str()); } } // Get the list of .animset to make by race files.clear(); CPath::getPathContent(animSetDir, true, false, true, files); vector animSetList; InfoLog->displayRawNL(""); InfoLog->displayRawNL("*****************************"); InfoLog->displayRawNL("**** .animation_set list ****"); InfoLog->displayRawNL("*****************************"); for(uint i=0;idisplayRawNL(animSetList.back().c_str()); } } InfoLog->displayRawNL(""); InfoLog->displayRawNL("**************************"); InfoLog->displayRawNL("**** Starting Process ****"); InfoLog->displayRawNL("**************************"); // For each animset, test if can replace some anim for(uint i=0;i