#define VCMI_DLL #include "../stdafx.h" #include "../lib/VCMI_Lib.h" #include "CGeneralTextHandler.h" #include "CLodHandler.h" #include #include #include #include /* * 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); } void CGeneralTextHandler::load() { std::string buf1 = bitmaph->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 = bitmaph->getTextFile("VCDESC.TXT"); int andame = buf.size(); int i=0; //buf iterator for(int gg=0; gg<14; ++gg) { int befi=i; for(; igetTextFile("LCDESC.TXT"); andame = buf.size(); i=0; //buf iterator for(int gg=0; gg<4; ++gg) { int befi=i; for(; igetTextFile("HEROSPEC.TXT"); i=0; std::string dump; for(int iii=0; iii<2; ++iii) { loadToIt(dump,buf,i,3); } for (int iii=0;iiigetTextFile("HEROBIOS.TXT"); i=0; for (int iii=0;iiigetTextFile("BLDGNEUT.TXT"); andame = buf.size(), it=0; for(int b=0;b<15;b++) { std::string name = readTo(buf,it,'\t'), description = readTo(buf,it,'\n'); for(int fi=0;figetTextFile("BLDGSPEC.TXT"); andame = buf.size(), it=0; for(int f=0;fgetTextFile("DWELLING.TXT"); andame = buf.size(), it=0; for(int f=0;f > >::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 = bitmaph->getTextFile("TCOMMAND.TXT"); itr=0; while(itrgetTextFile("HALLINFO.TXT"); itr=0; while(itrgetTextFile("CASTINFO.TXT"); itr=0; while(itrgetTextFile("TOWNTYPE.TXT")); namess.str(bitmaph->getTextFile("TOWNNAME.TXT")); int si=0; char bufname[75]; while (!ins.eof()) { ins.getline(bufname,50); townTypes.push_back(std::string(bufname).substr(0,strlen(bufname)-1)); townNames.resize(si+1); for (int i=0; igetTextFile("OBJNAMES.TXT"); it=0; //hope that -1 will not break this while (itgetTextFile("ADVEVENT.TXT"); it=0; std::string temp; while (itgetTextFile("XTRAINFO.TXT"); it=0; while (itgetTextFile("MINENAME.TXT"); it=0; while (it(temp,"")); } tlog5 << "\t\tReading MINEEVNT \n"; buf = bitmaph->getTextFile("MINEEVNT.TXT"); it=0; i=0; while (itgetTextFile("RESTYPES.TXT"); it=0; while (itgetTextFile("TERRNAME.TXT"); it=0; while (itgetTextFile("RANDSIGN.TXT"); it=0; while (itgetTextFile("ZCRGN1.TXT"); it=0; while (itgetTextFile("CRGEN4.TXT"); it=0; while (itgetTextFile("GENRLTXT.TXT"); std::string tmp; andame = buf.size(); i=0; //buf iterator for(; igetTextFile("Overview.txt"); itr=0; while(itrgetTextFile("PLCOLORS.TXT"); itr=0; while(itrgetTextFile("ARRAYTXT.TXT"); itr=0; while(itrgetTextFile("PRISKILL.TXT"); for(int hh=0; hh<4; ++hh) { loadToIt(tmp, strin, itr, 3); primarySkillNames.push_back(tmp); } itr = 0; strin = bitmaph->getTextFile("JKTEXT.TXT"); for(int hh=0; hh<45; ++hh) { loadToIt(tmp, strin, itr, 3); trimQuotation(tmp); jktexts.push_back(tmp); } itr = 0; strin = bitmaph->getTextFile("TVRNINFO.TXT"); for(int hh=0; hh<8; ++hh) { loadToIt(tmp, strin, itr, 3); tavernInfo.push_back(tmp); } itr = 0; strin = bitmaph->getTextFile("TURNDUR.TXT"); for(int hh=0; hh<11; ++hh) { loadToIt(tmp, strin, itr, 3); turnDurations.push_back(tmp); } itr = 0; strin = bitmaph->getTextFile("HEROSCRN.TXT"); for(int hh=0; hh<33; ++hh) { loadToIt(tmp, strin, itr, 3); heroscrn.push_back(tmp); } itr = 0; strin = bitmaph->getTextFile("ARTEVENT.TXT"); for(; itrgetTextFile("SSTRAITS.TXT"); it=0; for(int i=0; i<2; ++i) loadToIt(dump,buf,it,3); skillName.resize(SKILL_QUANTITY); skillInfoTexts.resize(SKILL_QUANTITY); for (int i=0; igetTextFile("SKILLLEV.TXT"); it=0; for(int i=0; i<6; ++i) { std::string buffo; loadToIt(buffo,buf,it,3); levels.push_back(buffo); } buf = bitmaph->getTextFile ("SEERHUT.TXT"); it = 0; loadToIt (dump, buf, it, 3); loadToIt (dump, buf, it, 4); //dump description seerEmpty.resize(6); for (i = 0; i < 5; ++i) { loadToIt(seerEmpty[i], buf, it, 4); trimQuotation (seerEmpty[i]); } loadToIt (seerEmpty[5], buf, it, 3); trimQuotation (seerEmpty[5]); int j,k; quests.resize(10); for (i = 0; i < 9; ++i) //9 types of quests { quests[i].resize(5); for (j = 0; j < 5; ++j) { loadToIt (dump, buf, it, 4); //front description quests[i][j].resize(6); for (k = 0; k < 5; ++k) { loadToIt (quests[i][j][k], buf, it, 4); trimQuotation (quests[i][j][k]); } loadToIt (quests[i][j][5], buf, it, 3); trimQuotation (quests[i][j][5]); } } quests[9].resize(1); quests[9][0].resize(6); for (k = 0; k < 5; ++k) //Time limit { loadToIt (quests[9][0][k], buf, it, 4); } loadToIt (quests[9][0][k], buf, it, 3); for (i = 0; i < 2; ++i) //gap description loadToIt(dump,buf,it,3); seerNames.resize(48); for (i = 0; i < 48; ++i) loadToIt(seerNames[i], buf, it, 3); //campaigns buf = bitmaph->getTextFile ("CAMPTEXT.TXT"); it = 0; loadToIt (dump, buf, it, 3); //comment std::string nameBuf; do //map names { loadToIt(nameBuf, buf, it, 3); if(nameBuf.size()) { campaignMapNames.push_back(nameBuf); } } while (nameBuf.size()); campaignRegionNames.resize(campaignMapNames.size()); //allocating space for(int g=0; ggetTextFile ("ZCREXP.TXT"); it = 0; loadToIt (dump, buf, it, 3); //comment for (int i = 0; i < 459; ++i) //some texts seem to be empty { loadToIt(dump, buf, it, 4); //description, usually useless loadToIt(nameBuf, buf, it, 3); zcrexp.push_back(nameBuf); } std::ifstream ifs(DATA_DIR "/config/threatlevel.txt", std::ios::in | std::ios::binary); getline(ifs, buf); //skip 1st line for (int i = 0; i < 13; ++i) { getline(ifs, buf); threat.push_back(buf); } } std::string CGeneralTextHandler::getTitle(const std::string & text) { std::string ret; int i=0; while ((text[i++]!='{')); while ((text[i]!='}') && (i