#include "StdInc.h" #include "CGeneralTextHandler.h" #include "Filesystem/CResourceLoader.h" #include "VCMI_Lib.h" #include "GameConstants.h" /* * CGeneralTextHandler.cpp, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * * License: GNU General Public License v2.0 or later * Full text of license available in license.txt file, in main folder * */ std::string readTo(const std::string &in, int &it, char end) { int pom = it; int last = in.find_first_of(end,it); it+=(1+last-it); return in.substr(pom,last-pom); } void trimQuotation(std::string &op) { if(op.length() && op[0] == '\"' && op[op.size()-1] == '\"') op = op.substr(1,op.size()-2); } std::string getTextFile(std::string filename) { auto file = CResourceHandler::get()->loadData( ResourceID(std::string("DATA/") + filename, EResType::TEXT)); return std::string((char*)file.first.get(), file.second); } void CGeneralTextHandler::load() { std::string buf1 = getTextFile("ZELP.TXT"); int itr=0, eol=-1, eolnext=-1, pom; eolnext = buf1.find_first_of('\r',itr); while(itreol) //in current line there is not tab zelp.push_back(std::pair()); else { zelp.push_back (std::pair (buf1.substr(itr,pom-itr), buf1.substr(pom+1,eol-pom-1))); boost::algorithm::replace_all(zelp[zelp.size()-1].first,"\t",""); boost::algorithm::replace_all(zelp[zelp.size()-1].second,"\t",""); trimQuotation(zelp.back().second); } itr=eol+2; } std::string buf = getTextFile("VCDESC.TXT"); int andame = buf.size(); int i=0; //buf iterator for(int gg=0; gg<14; ++gg) { int befi=i; for(; i > >::iterator i = buildings.begin(); i != buildings.end(); i++) { for(std::map >::iterator j = i->second.begin(); j != i->second.end(); j++) { std::string &str = j->second.second; boost::algorithm::trim(str); trimQuotation(str); } } buf = getTextFile("TCOMMAND.TXT"); itr=0; while(itr(temp,"")); } tlog5 << "\t\tReading MINEEVNT \n"; buf = getTextFile("MINEEVNT.TXT"); it=0; i=0; while (it