1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-09 07:13:54 +02:00

prawie całe zaczytywanie budynków (zostały już tylko nazwy dwellingów)

This commit is contained in:
mateuszb 2007-06-10 20:14:37 +00:00
parent eb7ef1d52c
commit 6ed3c85f72
2 changed files with 310 additions and 4 deletions

View File

@ -248,6 +248,7 @@ void CBuildingHandler::loadBuildings()
buildings.push_back(nbu);
}
loadNames();
loadNeutNames();
}
void CBuildingHandler::loadNames()
@ -309,7 +310,7 @@ void CBuildingHandler::loadNames()
graal.type = EbuildingType(ii+1);
graal.wood = graal.mercury = graal.ore = graal.sulfur = graal.crystal = graal.gems = graal.gold = 0;
graal.isDwelling = false;
graals.push_back(graal);
grails.push_back(graal);
}
else //for resource silos
{
@ -339,4 +340,299 @@ void CBuildingHandler::loadNames()
}
}
}
///////////////reading artifact merchant
int befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
artMerchant.name = buf.substr(befi, i-befi);
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\r')
break;
}
artMerchant.description = buf.substr(befi, i-befi);
i+=2;
//////////////////////reading level1 creature horde
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
l1horde.name = buf.substr(befi, i-befi);
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\r')
break;
}
l1horde.description = buf.substr(befi, i-befi);
i+=2;
//////////////////////reading level2 creature horde
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
l2horde.name = buf.substr(befi, i-befi);
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\r')
break;
}
l2horde.description = buf.substr(befi, i-befi);
i+=2;
//////////////////////reading shipyard
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
shipyard.name = buf.substr(befi, i-befi);
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\r')
break;
}
shipyard.description = buf.substr(befi, i-befi);
i+=2;
//////////////////////omitting rubbish
int hmcr = 0;
for(i; i<andame; ++i) //omitting rubbish
{
if(buf[i]=='\r')
++hmcr;
if(hmcr==2)
break;
}
i+=2;
//////////////////////reading level3 creature horde
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
l3horde.name = buf.substr(befi, i-befi);
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\r')
break;
}
l3horde.description = buf.substr(befi, i-befi);
i+=2;
//////////////////////reading level4 creature horde
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
l4horde.name = buf.substr(befi, i-befi);
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\r')
break;
}
l4horde.description = buf.substr(befi, i-befi);
i+=2;
//////////////////////reading level5 creature horde
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
l5horde.name = buf.substr(befi, i-befi);
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\r')
break;
}
l5horde.description = buf.substr(befi, i-befi);
i+=2;
//////////////////////reading grail
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
grail.name = buf.substr(befi, i-befi);
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\r')
break;
}
grail.description = buf.substr(befi, i-befi);
i+=2;
//////////////////////reading resource silo
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
resSilo.name = buf.substr(befi, i-befi);
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\r')
break;
}
resSilo.description = buf.substr(befi, i-befi);
i+=2;
}
void CBuildingHandler::loadNeutNames()
{
std::ifstream inp("H3bitmap.lod\\BLDGNEUT.TXT", std::ios::in | std::ios::binary);
inp.seekg(0,std::ios::end); // na koniec
int andame = inp.tellg(); // read length
inp.seekg(0,std::ios::beg); // wracamy na poczatek
char * bufor = new char[andame]; // allocate memory
inp.read((char*)bufor, andame); // read map file to buffer
std::string buf = std::string(bufor);
delete [andame] bufor;
int i=0; //buf iterator
for(int q=0; q<15; ++q)
{
int befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
buildings[81+q].name = buf.substr(befi, i-befi);
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\r')
break;
}
buildings[81+q].description = buf.substr(befi, i-befi);
i+=2;
}
for(i; i<andame; ++i)
{
if(buf[i]=='\r')
break;
}
i+=2;
////////////////////////////reading blacksmith
int befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
CBuilding b1;
b1.type = EbuildingType(0);
b1.name = buf.substr(befi, i-befi);
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\r')
break;
}
b1.description = buf.substr(befi, i-befi);
i+=2;
blacksmith = b1;
//////////////////////////////reading moat
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
b1.name = buf.substr(befi, i-befi);
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\r')
break;
}
b1.description = buf.substr(befi, i-befi);
i+=2;
moat = b1;
/////////////////////////reading shipyard with ship
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
b1.name = buf.substr(befi, i-befi);
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\r')
break;
}
b1.description = buf.substr(befi, i-befi);
i+=2;
shipyardWithShip = b1;
/////////////////////////reading blacksmiths
for(int q=0; q<9; ++q)
{
CBuilding black; //
int befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
black.name = buf.substr(befi, i-befi);
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\r')
break;
}
black.description = buf.substr(befi, i-befi);
i+=2;
black.type = EbuildingType(q+1);
blacksmiths.push_back(black);
}
}

View File

@ -22,9 +22,19 @@ class CBuildingHandler
public:
std::vector<CBuilding> buildings; //vector of buildings
std::vector<CBuilding> resourceSilos; //vector with resource silos only - for castle profiled descriptions
std::vector<CBuilding> graals; //vector with graal - type buildings only - for castle profiled descriptions
void loadBuildings();
void loadNames();
std::vector<CBuilding> grails; //vector with grail - type buildings only - for castle profiled descriptions
std::vector<CBuilding> blacksmiths; //vector with names and descriptions for blacksmith (castle - dependent)
CBuilding blacksmith; //global name and description for blacksmiths
CBuilding moat; //description and name of moat
CBuilding shipyard; //castle - independent name and description of shipyard
CBuilding shipyardWithShip; //name and description for shipyard with ship
CBuilding artMerchant; //name and description of artifact merchant
CBuilding l1horde, l2horde, l3horde, l4horde, l5horde; //castle - independent horde names and descriptions
CBuilding grail; //castle - independent grail description
CBuilding resSilo; //castle - independent resource silo name and description
void loadBuildings(); //main loader, calls loading functions below
void loadNames(); //loads castle - specufuc names and descriptoins
void loadNeutNames(); //loads castle independent names and descriptions
};
#endif //CBUILDINGHANDLER_H