mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
* minor change
This commit is contained in:
@@ -322,130 +322,49 @@ void CHeroHandler::loadHeroes()
|
|||||||
}
|
}
|
||||||
void CHeroHandler::loadHeroClasses()
|
void CHeroHandler::loadHeroClasses()
|
||||||
{
|
{
|
||||||
std::string buf = bitmaph->getTextFile("HCTRAITS.TXT");
|
std::istringstream str(bitmaph->getTextFile("HCTRAITS.TXT")); //we'll be reading from it
|
||||||
int andame = buf.size();
|
const int BUFFER_SIZE = 5000;
|
||||||
for(int y=0; y<andame; ++y)
|
char buffer[BUFFER_SIZE+1];
|
||||||
if(buf[y]==',')
|
|
||||||
buf[y]='.';
|
for(int i=0; i<3; ++i) str.getline(buffer, BUFFER_SIZE); //omiting rubbish
|
||||||
int i = 0; //buf iterator
|
|
||||||
int hmcr = 0;
|
|
||||||
for(i; i<andame; ++i) //omitting rubbish
|
|
||||||
{
|
|
||||||
if(buf[i]=='\r')
|
|
||||||
++hmcr;
|
|
||||||
if(hmcr==2)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i+=2;
|
|
||||||
for(int ss=0; ss<18; ++ss) //18 classes of hero (including conflux)
|
for(int ss=0; ss<18; ++ss) //18 classes of hero (including conflux)
|
||||||
{
|
{
|
||||||
CHeroClass * hc = new CHeroClass;
|
CHeroClass * hc = new CHeroClass;
|
||||||
int befi=i;
|
|
||||||
for(i; i<andame; ++i)
|
|
||||||
{
|
|
||||||
if(buf[i]=='\t')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
hc->name = buf.substr(befi, i-befi);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
befi=i;
|
char name[BUFFER_SIZE+1];
|
||||||
for(i; i<andame; ++i)
|
str.get(name, BUFFER_SIZE, '\t');
|
||||||
{
|
hc->name = name;
|
||||||
if(buf[i]=='\t')
|
str >> hc->aggression;
|
||||||
break;
|
str >> hc->initialAttack;
|
||||||
}
|
str >> hc->initialDefence;
|
||||||
hc->aggression = atof(buf.substr(befi, i-befi).c_str());
|
str >> hc->initialPower;
|
||||||
++i;
|
str >> hc->initialKnowledge;
|
||||||
|
|
||||||
befi=i;
|
|
||||||
for(i; i<andame; ++i)
|
|
||||||
{
|
|
||||||
if(buf[i]=='\t')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
hc->initialAttack = atoi(buf.substr(befi, i-befi).c_str());
|
|
||||||
++i;
|
|
||||||
|
|
||||||
befi=i;
|
|
||||||
for(i; i<andame; ++i)
|
|
||||||
{
|
|
||||||
if(buf[i]=='\t')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
hc->initialDefence = atoi(buf.substr(befi, i-befi).c_str());
|
|
||||||
++i;
|
|
||||||
|
|
||||||
befi=i;
|
|
||||||
for(i; i<andame; ++i)
|
|
||||||
{
|
|
||||||
if(buf[i]=='\t')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
hc->initialPower = atoi(buf.substr(befi, i-befi).c_str());
|
|
||||||
++i;
|
|
||||||
|
|
||||||
befi=i;
|
|
||||||
for(i; i<andame; ++i)
|
|
||||||
{
|
|
||||||
if(buf[i]=='\t')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
hc->initialKnowledge = atoi(buf.substr(befi, i-befi).c_str());
|
|
||||||
++i;
|
|
||||||
|
|
||||||
hc->primChance.resize(PRIMARY_SKILLS);
|
hc->primChance.resize(PRIMARY_SKILLS);
|
||||||
for(int x=0;x<PRIMARY_SKILLS;x++)
|
for(int x=0; x<PRIMARY_SKILLS; ++x)
|
||||||
{
|
{
|
||||||
befi=i;
|
str >> hc->primChance[x].first;
|
||||||
for(i; i<andame; ++i)
|
|
||||||
{
|
|
||||||
if(buf[i]=='\t')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
hc->primChance[x].first = atoi(buf.substr(befi, i-befi).c_str());
|
|
||||||
++i;
|
|
||||||
}
|
}
|
||||||
for(int x=0;x<PRIMARY_SKILLS;x++)
|
for(int x=0; x<PRIMARY_SKILLS; ++x)
|
||||||
{
|
{
|
||||||
befi=i;
|
str >> hc->primChance[x].second;
|
||||||
for(i; i<andame; ++i)
|
|
||||||
{
|
|
||||||
if(buf[i]=='\t')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
hc->primChance[x].second = atoi(buf.substr(befi, i-befi).c_str());
|
|
||||||
++i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//CHero kkk = heroes[0];
|
hc->proSec.resize(SKILL_QUANTITY);
|
||||||
|
|
||||||
for(int dd=0; dd<SKILL_QUANTITY; ++dd)
|
for(int dd=0; dd<SKILL_QUANTITY; ++dd)
|
||||||
{
|
{
|
||||||
befi=i;
|
str >> hc->proSec[dd];
|
||||||
for(i; i<andame; ++i)
|
|
||||||
{
|
|
||||||
if(buf[i]=='\t')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
int buff = atoi(buf.substr(befi, i-befi).c_str());
|
|
||||||
++i;
|
|
||||||
hc->proSec.push_back(buff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int dd=0; dd<9; ++dd)
|
for(int dd=0; dd<ARRAY_COUNT(hc->selectionProbability); ++dd)
|
||||||
{
|
{
|
||||||
befi=i;
|
str >> hc->selectionProbability[dd];
|
||||||
for(i; i<andame; ++i)
|
|
||||||
{
|
|
||||||
if(buf[i]=='\t' || buf[i]=='\r')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
hc->selectionProbability[dd] = atoi(buf.substr(befi, i-befi).c_str());
|
|
||||||
++i;
|
|
||||||
}
|
}
|
||||||
++i;
|
|
||||||
heroClasses.push_back(hc);
|
heroClasses.push_back(hc);
|
||||||
|
str.getline(buffer, BUFFER_SIZE); //removing end of line characters
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user