|
@@ -2,9 +2,11 @@
|
|
|
#include "CGeneralTextHandler.h"
|
|
|
|
|
|
#include "Filesystem/CResourceLoader.h"
|
|
|
-#include "VCMI_Lib.h"
|
|
|
+#include "Filesystem/CInputStream.h"
|
|
|
#include "GameConstants.h"
|
|
|
|
|
|
+// #include <locale> //needed?
|
|
|
+
|
|
|
/*
|
|
|
* CGeneralTextHandler.cpp, part of VCMI engine
|
|
|
*
|
|
@@ -15,561 +17,419 @@
|
|
|
*
|
|
|
*/
|
|
|
|
|
|
-std::string readTo(const std::string &in, int &it, char end)
|
|
|
+//Helper for string -> float conversion
|
|
|
+class LocaleWithComma: public std::numpunct<char>
|
|
|
+{
|
|
|
+protected:
|
|
|
+ char do_decimal_point() const
|
|
|
+ {
|
|
|
+ return ',';
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+CLegacyConfigParser::CLegacyConfigParser(std::string URI)
|
|
|
{
|
|
|
- int pom = it;
|
|
|
- int last = in.find_first_of(end,it);
|
|
|
- it+=(1+last-it);
|
|
|
- return in.substr(pom,last-pom);
|
|
|
+ init(CResourceHandler::get()->load(ResourceID(URI, EResType::TEXT)));
|
|
|
}
|
|
|
|
|
|
-void trimQuotation(std::string &op)
|
|
|
+CLegacyConfigParser::CLegacyConfigParser(const std::unique_ptr<CInputStream> & input)
|
|
|
{
|
|
|
- if(op.length() && op[0] == '\"' && op[op.size()-1] == '\"')
|
|
|
- op = op.substr(1,op.size()-2);
|
|
|
+ init(input);
|
|
|
}
|
|
|
|
|
|
-std::string getTextFile(std::string filename)
|
|
|
+void CLegacyConfigParser::init(const std::unique_ptr<CInputStream> & input)
|
|
|
{
|
|
|
- auto file = CResourceHandler::get()->loadData(
|
|
|
- ResourceID(std::string("DATA/") + filename, EResType::TEXT));
|
|
|
+ data.reset(new char[input->getSize()]);
|
|
|
+ input->read((ui8*)data.get(), input->getSize());
|
|
|
|
|
|
- return std::string((char*)file.first.get(), file.second);
|
|
|
+ curr = data.get();
|
|
|
+ end = curr + input->getSize();
|
|
|
}
|
|
|
|
|
|
-void CGeneralTextHandler::load()
|
|
|
+std::string CLegacyConfigParser::extractQuotedPart()
|
|
|
{
|
|
|
- std::string buf1 = getTextFile("ZELP.TXT");
|
|
|
- int itr=0, eol=-1, eolnext=-1, pom;
|
|
|
- eolnext = buf1.find_first_of('\r',itr);
|
|
|
- while(itr<buf1.size())
|
|
|
- {
|
|
|
- eol = eolnext; //end of this line
|
|
|
- eolnext = buf1.find_first_of('\r',eol+1); //end of the next line
|
|
|
- pom=buf1.find_first_of('\t',itr); //upcoming tab
|
|
|
- if(eol<0 || pom<0)
|
|
|
- break;
|
|
|
- if(pom>eol) //in current line there is not tab
|
|
|
- zelp.push_back(std::pair<std::string,std::string>());
|
|
|
- else
|
|
|
- {
|
|
|
- zelp.push_back
|
|
|
- (std::pair<std::string,std::string>
|
|
|
- (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<andame; ++i)
|
|
|
- {
|
|
|
- if(buf[i]=='\r')
|
|
|
- break;
|
|
|
- }
|
|
|
- victoryConditions[gg] = buf.substr(befi, i-befi);
|
|
|
- i+=2;
|
|
|
- }
|
|
|
- buf = getTextFile("LCDESC.TXT");
|
|
|
- andame = buf.size();
|
|
|
- i=0; //buf iterator
|
|
|
- for(int gg=0; gg<4; ++gg)
|
|
|
- {
|
|
|
- int befi=i;
|
|
|
- for(; i<andame; ++i)
|
|
|
- {
|
|
|
- if(buf[i]=='\r')
|
|
|
- break;
|
|
|
- }
|
|
|
- lossCondtions[gg] = buf.substr(befi, i-befi);
|
|
|
- i+=2;
|
|
|
- }
|
|
|
+ assert(*curr == '\"');
|
|
|
|
|
|
- hTxts.resize(GameConstants::HEROES_QUANTITY);
|
|
|
+ curr++; // skip quote
|
|
|
+ char * begin = curr;
|
|
|
|
|
|
- buf = getTextFile("HEROSPEC.TXT");
|
|
|
- i=0;
|
|
|
- std::string dump;
|
|
|
- for(int iii=0; iii<2; ++iii)
|
|
|
- {
|
|
|
- loadToIt(dump,buf,i,3);
|
|
|
- }
|
|
|
- for (int iii=0;iii<hTxts.size();iii++)
|
|
|
- {
|
|
|
- loadToIt(hTxts[iii].bonusName,buf,i,4);
|
|
|
- loadToIt(hTxts[iii].shortBonus,buf,i,4);
|
|
|
- loadToIt(hTxts[iii].longBonus,buf,i,3);
|
|
|
- trimQuotation(hTxts[iii].longBonus);
|
|
|
- }
|
|
|
+ while (curr != end && *curr != '\"')
|
|
|
+ curr++;
|
|
|
|
|
|
- buf = getTextFile("HEROBIOS.TXT");
|
|
|
- i=0;
|
|
|
- for (int iii=0;iii<hTxts.size();iii++)
|
|
|
- {
|
|
|
- loadToIt(hTxts[iii].biography,buf,i,3);
|
|
|
- trimQuotation(hTxts[iii].biography);
|
|
|
- }
|
|
|
+ return std::string(begin, curr++); //increment curr to close quote
|
|
|
+}
|
|
|
|
|
|
- int it;
|
|
|
- buf = getTextFile("BLDGNEUT.TXT");
|
|
|
- andame = buf.size(), it=0;
|
|
|
+std::string CLegacyConfigParser::extractQuotedString()
|
|
|
+{
|
|
|
+ assert(*curr == '\"');
|
|
|
|
|
|
- for(int b=0;b<15;b++)
|
|
|
- {
|
|
|
- std::string name = readTo(buf,it,'\t'),
|
|
|
- description = readTo(buf,it,'\n');
|
|
|
- for(int fi=0;fi<GameConstants::F_NUMBER;fi++)
|
|
|
- {
|
|
|
- buildings[fi][b].first = name;
|
|
|
- buildings[fi][b].second = description;
|
|
|
- }
|
|
|
- }
|
|
|
- buf1 = readTo(buf,it,'\n');buf1 = readTo(buf,it,'\n');buf1 = readTo(buf,it,'\n');//silo,blacksmith,moat - useless???
|
|
|
- //shipyard with the ship
|
|
|
- std::string name = readTo(buf,it,'\t'),
|
|
|
- description = readTo(buf,it,'\n');
|
|
|
- for(int fi=0;fi<GameConstants::F_NUMBER;fi++)
|
|
|
+ std::string ret;
|
|
|
+ while (true)
|
|
|
{
|
|
|
- buildings[fi][20].first = name;
|
|
|
- buildings[fi][20].second = description;
|
|
|
- }
|
|
|
+ ret += extractQuotedPart();
|
|
|
|
|
|
- for(int fi=0;fi<GameConstants::F_NUMBER;fi++)
|
|
|
- {
|
|
|
- buildings[fi][16].first = readTo(buf,it,'\t'),
|
|
|
- buildings[fi][16].second = readTo(buf,it,'\n');
|
|
|
+ if (curr < end && *curr == '\"') //double quote - add it to string and continue
|
|
|
+ ret += '\"';
|
|
|
+ else // end of string
|
|
|
+ return ret;
|
|
|
}
|
|
|
- /////done reading "BLDGNEUT.TXT"******************************
|
|
|
+}
|
|
|
+
|
|
|
+std::string CLegacyConfigParser::extractNormalString()
|
|
|
+{
|
|
|
+ char * begin = curr;
|
|
|
+
|
|
|
+ while (curr < end && *curr != '\t' && *curr != '\r')//find end of string
|
|
|
+ curr++;
|
|
|
+
|
|
|
+ return std::string(begin, curr);
|
|
|
+}
|
|
|
+
|
|
|
+std::string CLegacyConfigParser::readString()
|
|
|
+{
|
|
|
+ if (curr >= end || *curr == '\n')
|
|
|
+ return "";
|
|
|
+
|
|
|
+ std::string ret;
|
|
|
+
|
|
|
+ if (*curr == '\"')
|
|
|
+ ret = extractQuotedString();// quoted text - find closing quote
|
|
|
+ else
|
|
|
+ ret = extractNormalString();//string without quotes - copy till \t or \r
|
|
|
+
|
|
|
+ curr++;
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+float CLegacyConfigParser::readNumber()
|
|
|
+{
|
|
|
+ std::string input = readString();
|
|
|
+
|
|
|
+ std::istringstream stream(input);
|
|
|
+
|
|
|
+ if (input.find(',') != std::string::npos) // code to handle conversion with comma as decimal separator
|
|
|
+ stream.imbue(std::locale(std::locale(), new LocaleWithComma));
|
|
|
+
|
|
|
+ int result;
|
|
|
+ if ( !(stream >> result) )
|
|
|
+ return 0;
|
|
|
+ return result;
|
|
|
+}
|
|
|
|
|
|
- buf = getTextFile("BLDGSPEC.TXT");
|
|
|
- andame = buf.size(), it=0;
|
|
|
- for(int f=0;f<GameConstants::F_NUMBER;f++)
|
|
|
+bool CLegacyConfigParser::isNextEntryEmpty()
|
|
|
+{
|
|
|
+ return curr >= end || *curr == '\n' || *curr == '\r' || *curr == '\t';
|
|
|
+}
|
|
|
+
|
|
|
+bool CLegacyConfigParser::endLine()
|
|
|
+{
|
|
|
+ while (curr < end && *curr != '\n')
|
|
|
+ readString();
|
|
|
+
|
|
|
+ curr++;
|
|
|
+
|
|
|
+ return curr < end;
|
|
|
+}
|
|
|
+
|
|
|
+void readToVector(std::string sourceName, std::vector<std::string> & dest)
|
|
|
+{
|
|
|
+ CLegacyConfigParser parser(sourceName);
|
|
|
+ do
|
|
|
{
|
|
|
- for(int b=0;b<9;b++)
|
|
|
- {
|
|
|
- buildings[f][17+b].first = readTo(buf,it,'\t');
|
|
|
- buildings[f][17+b].second = readTo(buf,it,'\n');
|
|
|
- }
|
|
|
- buildings[f][26].first = readTo(buf,it,'\t');
|
|
|
- buildings[f][26].second = readTo(buf,it,'\n');
|
|
|
- buildings[f][15].first = readTo(buf,it,'\t'); //resource silo
|
|
|
- buildings[f][15].second = readTo(buf,it,'\n');//resource silo
|
|
|
+ dest.push_back(parser.readString());
|
|
|
}
|
|
|
- /////done reading BLDGSPEC.TXT*********************************
|
|
|
+ while (parser.endLine());
|
|
|
+}
|
|
|
|
|
|
- buf = getTextFile("DWELLING.TXT");
|
|
|
- andame = buf.size(), it=0;
|
|
|
- for(int f=0;f<GameConstants::F_NUMBER;f++)
|
|
|
- {
|
|
|
- for(int b=0;b<14;b++)
|
|
|
+void CGeneralTextHandler::load()
|
|
|
+{
|
|
|
+ readToVector("DATA/VCDESC.TXT", victoryConditions);
|
|
|
+ readToVector("DATA/LCDESC.TXT", lossCondtions);
|
|
|
+ readToVector("DATA/TCOMMAND.TXT", tcommands);
|
|
|
+ readToVector("DATA/HALLINFO.TXT", hcommands);
|
|
|
+ readToVector("DATA/CASTINFO.TXT", fcommands);
|
|
|
+ readToVector("DATA/ADVEVENT.TXT", advobtxt);
|
|
|
+ readToVector("DATA/XTRAINFO.TXT", xtrainfo);
|
|
|
+ readToVector("DATA/RESTYPES.TXT", restypes);
|
|
|
+ readToVector("DATA/TERRNAME.TXT", terrainNames);
|
|
|
+ readToVector("DATA/RANDSIGN.TXT", randsign);
|
|
|
+ readToVector("DATA/ZCRGN1.TXT", creGens);
|
|
|
+ readToVector("DATA/CRGEN4.TXT", creGens4);
|
|
|
+ readToVector("DATA/OVERVIEW.TXT", overview);
|
|
|
+ readToVector("DATA/ARRAYTXT.TXT", arraytxt);
|
|
|
+ readToVector("DATA/PRISKILL.TXT", primarySkillNames);
|
|
|
+ readToVector("DATA/JKTEXT.TXT", jktexts);
|
|
|
+ readToVector("DATA/TVRNINFO.TXT", tavernInfo);
|
|
|
+ readToVector("DATA/TURNDUR.TXT", turnDurations);
|
|
|
+ readToVector("DATA/HEROSCRN.TXT", heroscrn);
|
|
|
+ readToVector("DATA/ARTEVENT.TXT", artifEvents);
|
|
|
+ readToVector("DATA/TENTCOLR.TXT", tentColors);
|
|
|
+ readToVector("DATA/SKILLLEV.TXT", levels);
|
|
|
+ readToVector("DATA/OBJNAMES.TXT", names);
|
|
|
+
|
|
|
+ {
|
|
|
+ CLegacyConfigParser parser("DATA/GENRLTXT.TXT");
|
|
|
+ parser.endLine();
|
|
|
+ do
|
|
|
{
|
|
|
- buildings[f][30+b].first = readTo(buf,it,'\t');
|
|
|
- buildings[f][30+b].second = readTo(buf,it,'\n');
|
|
|
+ allTexts.push_back(parser.readString());
|
|
|
}
|
|
|
+ while (parser.endLine());
|
|
|
}
|
|
|
-
|
|
|
- //remove prceeding / trailing whitespaces nad quoation marks from buildings descriptions
|
|
|
- for(std::map<int, std::map<int, std::pair<std::string, std::string> > >::iterator i = buildings.begin(); i != buildings.end(); i++)
|
|
|
{
|
|
|
- for(std::map<int, std::pair<std::string, std::string> >::iterator j = i->second.begin(); j != i->second.end(); j++)
|
|
|
+ CLegacyConfigParser parser("DATA/ZELP.TXT");
|
|
|
+ do
|
|
|
{
|
|
|
- std::string &str = j->second.second;
|
|
|
- boost::algorithm::trim(str);
|
|
|
- trimQuotation(str);
|
|
|
+ std::string first = parser.readString();
|
|
|
+ std::string second = parser.readString();
|
|
|
+ zelp.push_back(std::make_pair(first, second));
|
|
|
}
|
|
|
+ while (parser.endLine());
|
|
|
}
|
|
|
-
|
|
|
- buf = getTextFile("TCOMMAND.TXT");
|
|
|
- itr=0;
|
|
|
- while(itr<buf.length()-1)
|
|
|
{
|
|
|
- std::string tmp;
|
|
|
- loadToIt(tmp, buf, itr, 3);
|
|
|
- tcommands.push_back(tmp);
|
|
|
- }
|
|
|
+ CLegacyConfigParser parser("DATA/HEROSPEC.TXT");
|
|
|
+ CLegacyConfigParser bioParser("DATA/HEROBIOS.TXT");
|
|
|
|
|
|
- buf = getTextFile("HALLINFO.TXT");
|
|
|
- itr=0;
|
|
|
- while(itr<buf.length()-1)
|
|
|
- {
|
|
|
- std::string tmp;
|
|
|
- loadToIt(tmp, buf, itr, 3);
|
|
|
- hcommands.push_back(tmp);
|
|
|
- }
|
|
|
+ //skip header
|
|
|
+ parser.endLine();
|
|
|
+ parser.endLine();
|
|
|
|
|
|
- buf = getTextFile("CASTINFO.TXT");
|
|
|
- itr=0;
|
|
|
- while(itr<buf.length()-1)
|
|
|
- {
|
|
|
- std::string tmp;
|
|
|
- loadToIt(tmp, buf, itr, 3);
|
|
|
- fcommands.push_back(tmp);
|
|
|
+ do
|
|
|
+ {
|
|
|
+ HeroTexts texts;
|
|
|
+ texts.bonusName = parser.readString();
|
|
|
+ texts.shortBonus = parser.readString();
|
|
|
+ texts.longBonus = parser.readString();
|
|
|
+ texts.biography = bioParser.readString();
|
|
|
+ hTxts.push_back(texts);
|
|
|
+ }
|
|
|
+ while (parser.endLine() && bioParser.endLine());
|
|
|
}
|
|
|
-
|
|
|
- std::istringstream ins, namess;
|
|
|
- ins.str(getTextFile("TOWNTYPE.TXT"));
|
|
|
- namess.str(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);
|
|
|
+ CLegacyConfigParser parser("DATA/BLDGNEUT.TXT");
|
|
|
|
|
|
- for (int i=0; i<GameConstants::NAMES_PER_TOWN; i++)
|
|
|
+ for(int i=0; i<15; i++)
|
|
|
{
|
|
|
- namess.getline(bufname,50);
|
|
|
- townNames[si].push_back(std::string(bufname).substr(0,strlen(bufname)-1));
|
|
|
+ std::string name = parser.readString();
|
|
|
+ std::string descr = parser.readString();
|
|
|
+ parser.endLine();
|
|
|
+
|
|
|
+ for(int j=0; j<GameConstants::F_NUMBER; j++)
|
|
|
+ {
|
|
|
+ buildings[j][i].first = name;
|
|
|
+ buildings[j][i].second = descr;
|
|
|
+ }
|
|
|
}
|
|
|
- si++;
|
|
|
- }
|
|
|
+ parser.endLine(); // silo
|
|
|
+ parser.endLine(); // blacksmith //unused entries
|
|
|
+ parser.endLine(); // moat
|
|
|
|
|
|
- tlog5 << "\t\tReading OBJNAMES \n";
|
|
|
- buf = getTextFile("OBJNAMES.TXT");
|
|
|
- it=0; //hope that -1 will not break this
|
|
|
- while (it<buf.length()-1)
|
|
|
- {
|
|
|
- std::string nobj;
|
|
|
- loadToIt(nobj, buf, it, 3);
|
|
|
- if(nobj.size() && (nobj[nobj.size()-1]==(char)10 || nobj[nobj.size()-1]==(char)13 || nobj[nobj.size()-1]==(char)9))
|
|
|
+ //shipyard with the ship
|
|
|
+ std::string name = parser.readString();
|
|
|
+ std::string descr = parser.readString();
|
|
|
+ parser.endLine();
|
|
|
+
|
|
|
+ for(int j=0; j<GameConstants::F_NUMBER; j++)
|
|
|
{
|
|
|
- nobj = nobj.substr(0, nobj.size()-1);
|
|
|
+ buildings[j][20].first = name;
|
|
|
+ buildings[j][20].second = descr;
|
|
|
}
|
|
|
- names.push_back(nobj);
|
|
|
- }
|
|
|
|
|
|
- tlog5 << "\t\tReading ADVEVENT \n";
|
|
|
- buf = getTextFile("ADVEVENT.TXT");
|
|
|
- it=0;
|
|
|
- std::string temp;
|
|
|
- while (it<buf.length()-1)
|
|
|
- {
|
|
|
- loadToIt(temp,buf,it,3);
|
|
|
- if (temp[0]=='\"')
|
|
|
+ //blacksmith
|
|
|
+ for(int j=0; j<GameConstants::F_NUMBER; j++)
|
|
|
{
|
|
|
- temp = temp.substr(1,temp.length()-2);
|
|
|
+ buildings[j][16].first = parser.readString();
|
|
|
+ buildings[j][16].second = parser.readString();
|
|
|
+ parser.endLine();
|
|
|
}
|
|
|
- boost::algorithm::replace_all(temp,"\"\"","\"");
|
|
|
- advobtxt.push_back(temp);
|
|
|
- }
|
|
|
-
|
|
|
- tlog5 << "\t\tReading XTRAINFO \n";
|
|
|
- buf = getTextFile("XTRAINFO.TXT");
|
|
|
- it=0;
|
|
|
- while (it<buf.length()-1)
|
|
|
- {
|
|
|
- loadToIt(temp,buf,it,3);
|
|
|
- xtrainfo.push_back(temp);
|
|
|
}
|
|
|
-
|
|
|
- tlog5 << "\t\tReading MINENAME \n";
|
|
|
- buf = getTextFile("MINENAME.TXT");
|
|
|
- it=0;
|
|
|
- while (it<buf.length()-1)
|
|
|
{
|
|
|
- loadToIt(temp,buf,it,3);
|
|
|
- mines.push_back(std::pair<std::string,std::string>(temp,""));
|
|
|
- }
|
|
|
+ CLegacyConfigParser parser("DATA/BLDGSPEC.TXT");
|
|
|
|
|
|
- tlog5 << "\t\tReading MINEEVNT \n";
|
|
|
- buf = getTextFile("MINEEVNT.TXT");
|
|
|
- it=0;
|
|
|
- i=0;
|
|
|
- while (it<buf.length()-1)
|
|
|
- {
|
|
|
- loadToIt(temp,buf,it,3);
|
|
|
- temp = temp.substr(1,temp.length()-2);
|
|
|
- if(i < mines.size())
|
|
|
- mines[i++].second = temp;
|
|
|
- else
|
|
|
- tlog2 << "Warning - too much entries in MINEEVNT. Omitting this one: " << temp << std::endl;
|
|
|
- }
|
|
|
-
|
|
|
- tlog5 << "\t\tReading RESTYPES \n";
|
|
|
- buf = getTextFile("RESTYPES.TXT");
|
|
|
- it=0;
|
|
|
- while (it<buf.length()-1)
|
|
|
- {
|
|
|
- loadToIt(temp,buf,it,3);
|
|
|
- restypes.push_back(temp);
|
|
|
- }
|
|
|
+ for(int town=0; town<GameConstants::F_NUMBER; town++)
|
|
|
+ {
|
|
|
+ for(int build=0; build<9; build++)
|
|
|
+ {
|
|
|
+ buildings[town][17+build].first = parser.readString();
|
|
|
+ buildings[town][17+build].second = parser.readString();
|
|
|
+ parser.endLine();
|
|
|
+ }
|
|
|
+ buildings[town][26].first = parser.readString(); // Grail
|
|
|
+ buildings[town][26].second = parser.readString();
|
|
|
+ parser.endLine();
|
|
|
|
|
|
- tlog5 << "\t\tReading TERRNAME \n";
|
|
|
- buf = getTextFile("TERRNAME.TXT");
|
|
|
- it=0;
|
|
|
- while (it<buf.length()-1)
|
|
|
- {
|
|
|
- loadToIt(temp,buf,it,3);
|
|
|
- terrainNames.push_back(temp);
|
|
|
+ buildings[town][15].first = parser.readString(); // Resource silo
|
|
|
+ buildings[town][15].second = parser.readString();
|
|
|
+ parser.endLine();
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- tlog5 << "\t\tReading RANDSIGN \n";
|
|
|
- buf = getTextFile("RANDSIGN.TXT");
|
|
|
- it=0;
|
|
|
- while (it<buf.length()-1)
|
|
|
- {
|
|
|
- loadToIt(temp,buf,it,3);
|
|
|
- randsign.push_back(temp);
|
|
|
- }
|
|
|
-
|
|
|
- tlog5 << "\t\tReading ZCRGN1 \n";
|
|
|
- buf = getTextFile("ZCRGN1.TXT");
|
|
|
- it=0;
|
|
|
- while (it<buf.length()-1)
|
|
|
{
|
|
|
- loadToIt(temp,buf,it,3);
|
|
|
- creGens.push_back(temp);
|
|
|
- }
|
|
|
+ CLegacyConfigParser parser("DATA/DWELLING.TXT");
|
|
|
|
|
|
- tlog5 << "\t\tReading CRGN4 \n";
|
|
|
- buf = getTextFile("CRGEN4.TXT");
|
|
|
- it=0;
|
|
|
- while (it<buf.length()-1)
|
|
|
- {
|
|
|
- loadToIt(temp,buf,it,3);
|
|
|
- creGens4.push_back(temp);
|
|
|
+ for(int town=0; town<GameConstants::F_NUMBER; town++)
|
|
|
+ {
|
|
|
+ for(int build=0; build<14; build++)
|
|
|
+ {
|
|
|
+ buildings[town][30+build].first = parser.readString();
|
|
|
+ buildings[town][30+build].second = parser.readString();
|
|
|
+ parser.endLine();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- buf = getTextFile("GENRLTXT.TXT");
|
|
|
- std::string tmp;
|
|
|
- andame = buf.size();
|
|
|
- i=0; //buf iterator
|
|
|
- for(; i<andame; ++i)
|
|
|
{
|
|
|
- if(buf[i]=='\r')
|
|
|
- break;
|
|
|
- }
|
|
|
+ CLegacyConfigParser typeParser("DATA/TOWNTYPE.TXT");
|
|
|
+ CLegacyConfigParser nameParser("DATA/TOWNNAME.TXT");
|
|
|
+ do
|
|
|
+ {
|
|
|
+ townTypes.push_back(typeParser.readString());
|
|
|
|
|
|
- i+=2;
|
|
|
- std::string buflet;
|
|
|
- for(int jj=0; jj<764; ++jj)
|
|
|
- {
|
|
|
- loadToIt(buflet, buf, i, 2);
|
|
|
- trimQuotation(buflet);
|
|
|
- boost::algorithm::replace_all(buflet,"\"\"","\"");
|
|
|
- allTexts.push_back(buflet);
|
|
|
+ townNames.push_back(std::vector<std::string>());
|
|
|
+ for (int i=0; i<GameConstants::NAMES_PER_TOWN; i++)
|
|
|
+ {
|
|
|
+ townNames.back().push_back(nameParser.readString());
|
|
|
+ nameParser.endLine();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ while (typeParser.endLine());
|
|
|
}
|
|
|
-
|
|
|
- std::string stro = getTextFile("Overview.txt");
|
|
|
- itr=0;
|
|
|
- while(itr<stro.length()-1)
|
|
|
{
|
|
|
- loadToIt(tmp, stro, itr, 3);
|
|
|
- trimQuotation(tmp);
|
|
|
- overview.push_back(tmp);
|
|
|
- }
|
|
|
+ CLegacyConfigParser nameParser("DATA/MINENAME.TXT");
|
|
|
+ CLegacyConfigParser eventParser("DATA/MINEEVNT.TXT");
|
|
|
|
|
|
- std::string strc = getTextFile("PLCOLORS.TXT");
|
|
|
- itr=0;
|
|
|
- while(itr<strc.length()-1)
|
|
|
- {
|
|
|
- loadToIt(tmp, strc, itr, 3);
|
|
|
- colors.push_back(tmp);
|
|
|
- tmp[0] = toupper(tmp[0]);
|
|
|
- capColors.push_back(tmp);
|
|
|
+ do
|
|
|
+ {
|
|
|
+ std::string name = nameParser.readString();
|
|
|
+ std::string event = eventParser.readString();
|
|
|
+ mines.push_back(std::make_pair(name, event));
|
|
|
+ }
|
|
|
+ while (nameParser.endLine() && eventParser.endLine());
|
|
|
}
|
|
|
-
|
|
|
- std::string strs = getTextFile("ARRAYTXT.TXT");
|
|
|
-
|
|
|
- itr=0;
|
|
|
- while(itr<strs.length()-1)
|
|
|
{
|
|
|
- loadToIt(tmp, strs, itr, 3);
|
|
|
- trimQuotation(tmp);
|
|
|
- arraytxt.push_back(tmp);
|
|
|
- }
|
|
|
+ CLegacyConfigParser parser("DATA/PLCOLORS.TXT");
|
|
|
+ do
|
|
|
+ {
|
|
|
+ std::string color = parser.readString();
|
|
|
+ colors.push_back(color);
|
|
|
|
|
|
- itr = 0;
|
|
|
- std::string strin = getTextFile("PRISKILL.TXT");
|
|
|
- for(int hh=0; hh<4; ++hh)
|
|
|
- {
|
|
|
- loadToIt(tmp, strin, itr, 3);
|
|
|
- primarySkillNames.push_back(tmp);
|
|
|
+ color[0] = toupper(color[0]);
|
|
|
+ capColors.push_back(color);
|
|
|
+ }
|
|
|
+ while (parser.endLine());
|
|
|
}
|
|
|
-
|
|
|
- itr = 0;
|
|
|
- strin = getTextFile("JKTEXT.TXT");
|
|
|
- for(int hh=0; hh<45; ++hh)
|
|
|
{
|
|
|
- loadToIt(tmp, strin, itr, 3);
|
|
|
- trimQuotation(tmp);
|
|
|
- jktexts.push_back(tmp);
|
|
|
- }
|
|
|
+ CLegacyConfigParser parser("DATA/SSTRAITS.TXT");
|
|
|
|
|
|
- itr = 0;
|
|
|
- strin = getTextFile("TVRNINFO.TXT");
|
|
|
- for(int hh=0; hh<8; ++hh)
|
|
|
- {
|
|
|
- loadToIt(tmp, strin, itr, 3);
|
|
|
- tavernInfo.push_back(tmp);
|
|
|
- }
|
|
|
+ //skip header
|
|
|
+ parser.endLine();
|
|
|
+ parser.endLine();
|
|
|
|
|
|
- itr = 0;
|
|
|
- strin = getTextFile("TURNDUR.TXT");
|
|
|
- for(int hh=0; hh<11; ++hh)
|
|
|
- {
|
|
|
- loadToIt(tmp, strin, itr, 3);
|
|
|
- turnDurations.push_back(tmp);
|
|
|
- }
|
|
|
+ do
|
|
|
+ {
|
|
|
+ skillName.push_back(parser.readString());
|
|
|
|
|
|
- itr = 0;
|
|
|
- strin = getTextFile("HEROSCRN.TXT");
|
|
|
- for(int hh=0; hh<33; ++hh)
|
|
|
- {
|
|
|
- loadToIt(tmp, strin, itr, 3);
|
|
|
- heroscrn.push_back(tmp);
|
|
|
+ skillInfoTexts.push_back(std::vector<std::string>());
|
|
|
+ for(int j = 0; j < 3; j++)
|
|
|
+ skillInfoTexts.back().push_back(parser.readString());
|
|
|
+ }
|
|
|
+ while (parser.endLine());
|
|
|
}
|
|
|
-
|
|
|
- itr = 0;
|
|
|
- strin = getTextFile("ARTEVENT.TXT");
|
|
|
- for(; itr<strin.size();)
|
|
|
{
|
|
|
- loadToIt(tmp, strin, itr, 2);
|
|
|
- // boost::algorithm::trim(tmp);
|
|
|
- trimQuotation(tmp);
|
|
|
- boost::algorithm::replace_all(tmp,"\"\"","\"");
|
|
|
- artifEvents.push_back(tmp);
|
|
|
- }
|
|
|
+ CLegacyConfigParser parser("DATA/SEERHUT.TXT");
|
|
|
|
|
|
- buf = getTextFile("SSTRAITS.TXT");
|
|
|
- it=0;
|
|
|
+ //skip header
|
|
|
+ parser.endLine();
|
|
|
|
|
|
- for(int i=0; i<2; ++i)
|
|
|
- loadToIt(dump,buf,it,3);
|
|
|
+ while (parser.endLine());
|
|
|
|
|
|
- skillName.resize(GameConstants::SKILL_QUANTITY);
|
|
|
- skillInfoTexts.resize(GameConstants::SKILL_QUANTITY);
|
|
|
- for (int i=0; i<GameConstants::SKILL_QUANTITY; i++)
|
|
|
- {
|
|
|
- skillInfoTexts[i].resize(3);
|
|
|
- loadToIt(skillName[i],buf,it,4);
|
|
|
- loadToIt(skillInfoTexts[i][0],buf,it,4);
|
|
|
- loadToIt(skillInfoTexts[i][1],buf,it,4);
|
|
|
- loadToIt(skillInfoTexts[i][2],buf,it,3);
|
|
|
- for(int j = 0; j < 3; j++)
|
|
|
- trimQuotation(skillInfoTexts[i][j]);
|
|
|
- }
|
|
|
- buf = getTextFile("SKILLLEV.TXT");
|
|
|
- it=0;
|
|
|
- for(int i=0; i<6; ++i)
|
|
|
- {
|
|
|
- std::string buffo;
|
|
|
- loadToIt(buffo,buf,it,3);
|
|
|
- levels.push_back(buffo);
|
|
|
- }
|
|
|
+ for (int i = 0; i < 6; ++i)
|
|
|
+ seerEmpty.push_back(parser.readString());
|
|
|
|
|
|
- buf = 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)
|
|
|
+ quests.resize(10);
|
|
|
+ for (int i = 0; i < 9; ++i) //9 types of quests
|
|
|
{
|
|
|
- loadToIt (dump, buf, it, 4); //front description
|
|
|
- quests[i][j].resize(6);
|
|
|
- for (k = 0; k < 5; ++k)
|
|
|
+ quests[i].resize(5);
|
|
|
+ for (int j = 0; j < 5; ++j)
|
|
|
{
|
|
|
- loadToIt (quests[i][j][k], buf, it, 4);
|
|
|
- trimQuotation (quests[i][j][k]);
|
|
|
+ parser.readString(); //front description
|
|
|
+ for (int k = 0; k < 6; ++k)
|
|
|
+ quests[i][j].push_back(parser.readString());
|
|
|
+
|
|
|
+ parser.endLine();
|
|
|
}
|
|
|
- loadToIt (quests[i][j][5], buf, it, 3);
|
|
|
- trimQuotation (quests[i][j][5]);
|
|
|
}
|
|
|
- }
|
|
|
- quests[9].resize(1);
|
|
|
- quests[9][0].resize(6);
|
|
|
+ quests[9].resize(1);
|
|
|
|
|
|
- for (k = 0; k < 5; ++k) //Time limit
|
|
|
- {
|
|
|
- loadToIt (quests[9][0][k], buf, it, 4);
|
|
|
+ for (int k = 0; k < 6; ++k) //Time limit
|
|
|
+ {
|
|
|
+ quests[9][0].push_back(parser.readString());
|
|
|
+ }
|
|
|
+ parser.endLine();
|
|
|
+
|
|
|
+ parser.endLine(); // empty line
|
|
|
+ parser.endLine(); // header
|
|
|
+
|
|
|
+ for (int i = 0; i < 48; ++i)
|
|
|
+ {
|
|
|
+ seerNames.push_back(parser.readString());
|
|
|
+ parser.endLine();
|
|
|
+ }
|
|
|
}
|
|
|
- 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);
|
|
|
-
|
|
|
- buf = getTextFile("TENTCOLR.TXT");
|
|
|
- itr=0;
|
|
|
- while(itr<buf.length()-1)
|
|
|
{
|
|
|
- std::string tmp;
|
|
|
- loadToIt(tmp, buf, itr, 3);
|
|
|
- tentColors.push_back(tmp);
|
|
|
- }
|
|
|
+ CLegacyConfigParser parser("DATA/CAMPTEXT.TXT");
|
|
|
|
|
|
- //campaigns
|
|
|
- buf = 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())
|
|
|
+ //skip header
|
|
|
+ parser.endLine();
|
|
|
+
|
|
|
+ std::string text;
|
|
|
+ do
|
|
|
{
|
|
|
- campaignMapNames.push_back(nameBuf);
|
|
|
+ text = parser.readString();
|
|
|
+ parser.endLine();
|
|
|
+ if (!text.empty())
|
|
|
+ campaignMapNames.push_back(parser.readString());
|
|
|
}
|
|
|
- } while (nameBuf.size());
|
|
|
+ while (parser.endLine() && !text.empty());
|
|
|
|
|
|
- campaignRegionNames.resize(campaignMapNames.size()); //allocating space
|
|
|
- for(int g=0; g<campaignMapNames.size(); ++g) //region names
|
|
|
- {
|
|
|
- do //dump comments and empty lines
|
|
|
- {
|
|
|
- loadToIt(nameBuf, buf, it, 3);
|
|
|
- } while (!nameBuf.size() || nameBuf[0] != '/');
|
|
|
- do //actual names
|
|
|
+ for (size_t i=0; i<campaignMapNames.size(); i++)
|
|
|
{
|
|
|
- loadToIt(nameBuf, buf, it, 3);
|
|
|
- if(nameBuf.size())
|
|
|
+ do // skip empty space and header
|
|
|
{
|
|
|
- campaignRegionNames[g].push_back(nameBuf);
|
|
|
+ text = parser.readString();
|
|
|
}
|
|
|
- } while (nameBuf.size());
|
|
|
- }
|
|
|
+ while (parser.endLine() && text.empty());
|
|
|
|
|
|
- buf = getTextFile ("ZCREXP.TXT");
|
|
|
- it = 0;
|
|
|
- loadToIt (dump, buf, it, 3); //comment
|
|
|
- for (int i = 0; i < 459; ++i) //some texts seem to be empty
|
|
|
+ campaignRegionNames.push_back(std::vector<std::string>());
|
|
|
+ do
|
|
|
+ {
|
|
|
+ text = parser.readString();
|
|
|
+ parser.endLine();
|
|
|
+ if (!text.empty())
|
|
|
+ campaignRegionNames.back().push_back(parser.readString());
|
|
|
+ }
|
|
|
+ while (parser.endLine() && !text.empty());
|
|
|
+ }
|
|
|
+ }
|
|
|
{
|
|
|
- loadToIt(dump, buf, it, 4); //description, usually useless
|
|
|
- loadToIt(nameBuf, buf, it, 3);
|
|
|
- zcrexp.push_back(nameBuf);
|
|
|
+ CLegacyConfigParser parser("DATA/ZCREXP.TXT");
|
|
|
+ parser.endLine();//header
|
|
|
+ do
|
|
|
+ {
|
|
|
+ parser.readString(); //ignore 1st column with description
|
|
|
+ zcrexp.push_back(parser.readString());
|
|
|
+ }
|
|
|
+ while (parser.endLine());
|
|
|
}
|
|
|
|
|
|
+ std::string buffer;
|
|
|
std::ifstream ifs(CResourceHandler::get()->getResourceName(ResourceID("config/threatlevel.txt")), std::ios::binary);
|
|
|
- getline(ifs, buf); //skip 1st line
|
|
|
+ getline(ifs, buffer); //skip 1st line
|
|
|
for (int i = 0; i < 13; ++i)
|
|
|
{
|
|
|
- getline(ifs, buf);
|
|
|
- threat.push_back(buf);
|
|
|
+ getline(ifs, buffer);
|
|
|
+ threat.push_back(buffer);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
std::string CGeneralTextHandler::getTitle(const std::string & text)
|
|
|
{
|
|
|
std::string ret;
|