#define VCMI_DLL #include "../stdafx.h" #include "CBuildingHandler.h" #include "CLodHandler.h" #include #include extern CLodHandler * bitmaph; std::string readTo(std::string &in, unsigned 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); } unsigned int readNr(std::string &in, unsigned int &it) { int last=it; for(;last> last; return last; } CBuilding * readBg(std::string &buf, unsigned int& it) { CBuilding * nb = new CBuilding(); nb->resources.resize(RESOURCE_QUANTITY); for(int res=0;res<7;res++) nb->resources[res] = readNr(buf,it); nb->refName = readTo(buf,it,'\n'); return nb; } void CBuildingHandler::loadBuildings() { std::string buf = bitmaph->getTextFile("BUILDING.TXT"), temp; unsigned int andame = buf.size(), it=0; //buf iterator temp = readTo(buf,it,'\n');temp = readTo(buf,it,'\n');//read 2 lines of file info //read 9 special buildings for every faction for(int i=0;igetTextFile("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;finame = name; buildings[fi][b]->description = description; } } temp = readTo(buf,it,'\n');temp = readTo(buf,it,'\n');temp = 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;finame = name; buildings[fi][20]->description = description; } for(int fi=0;finame = readTo(buf,it,'\t'), buildings[fi][16]->description = readTo(buf,it,'\n'); } /////done reading "BLDGNEUT.TXT"****************************** buf = bitmaph->getTextFile("BLDGSPEC.TXT"); andame = buf.size(), it=0; for(int f=0;fname = readTo(buf,it,'\t'); buildings[f][17+b]->description = readTo(buf,it,'\n'); } buildings[f][26] = new CBuilding();//grail buildings[f][26]->name = readTo(buf,it,'\t'); buildings[f][26]->description = readTo(buf,it,'\n'); buildings[f][15]->name = readTo(buf,it,'\t'); //resource silo buildings[f][15]->description = readTo(buf,it,'\n');//resource silo } /////done reading BLDGSPEC.TXT********************************* buf = bitmaph->getTextFile("DWELLING.TXT"); andame = buf.size(), it=0; for(int f=0;fname = readTo(buf,it,'\t'); buildings[f][30+b]->description = readTo(buf,it,'\n'); } } char line[100]; //bufor std::ifstream ofs("config/hall.txt"); int castles; ofs>>castles; for(int i=0;i> tid >> pom; hall[tid].first = pom; (hall[tid].second).resize(5); //rows for(int j=0;j<5;j++) { box = it = 0; ofs.getline(line,100); if(!line[0]) ofs.getline(line,100); std::string linia(line); bool areboxes=true; while(areboxes) //read all boxes { (hall[tid].second)[j].push_back(std::vector()); //push new box int seppos = linia.find_first_of('|',it); //position of end of this box data if(seppos<0) seppos = linia.length(); while(it> last; (hall[tid].second)[j][box].push_back(last); areboxes = it; //wyzeruje jak nie znajdzie kolejnej spacji = koniec linii if(!it) it = seppos+1; } box++; it+=2; } } } }