2007-06-09 16:28:03 +03:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "CSpellHandler.h"
|
|
|
|
|
|
|
|
void CSpellHandler::loadSpells()
|
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
std::ifstream inp("H3bitmap.lod\\SPTRAITS.TXT", std::ios::in | std::ios::binary);
|
2007-06-09 23:23:44 +03:00
|
|
|
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
|
2007-06-22 16:50:16 +03:00
|
|
|
inp.close();
|
2007-06-09 23:23:44 +03:00
|
|
|
std::string buf = std::string(bufor);
|
|
|
|
delete [andame] bufor;
|
|
|
|
int i=0; //buf iterator
|
|
|
|
int hmcr=0;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\r')
|
|
|
|
++hmcr;
|
|
|
|
if(hmcr==5)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i+=2;
|
|
|
|
bool combSpells=false; //true, if we are reading combat spells
|
|
|
|
while(i<andame)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
CSpell nsp; //new currently being read spell
|
|
|
|
int befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.name = buf.substr(befi, i-befi);
|
|
|
|
++i;
|
|
|
|
|
|
|
|
if(nsp.name == std::string(""))
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
combSpells = true;
|
|
|
|
int hmcr=0;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\r')
|
|
|
|
++hmcr;
|
2007-06-16 23:12:08 +03:00
|
|
|
if(hmcr==3)
|
2007-06-09 23:23:44 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
++i;
|
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
nsp.name = buf.substr(befi, i-befi);
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.abbName = buf.substr(befi, i-befi);
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.level = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.earth = buf.substr(befi, i-befi)[0]=='x' ? true : false;
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.water = buf.substr(befi, i-befi)[0]=='x' ? true : false;
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.fire = buf.substr(befi, i-befi)[0]=='x' ? true : false;
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.air = buf.substr(befi, i-befi)[0]=='x' ? true : false;
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.costNone = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.costBas = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.costAdv = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.costExp = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.power = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.powerNone = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.powerBas = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.powerAdv = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.powerExp = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.castle = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.rampart = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.tower = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.inferno = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.necropolis = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.dungeon = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.stronghold = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.fortress = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.conflux = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.none2 = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.bas2 = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.adv2 = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.exp2 = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.noneTip = buf.substr(befi, i-befi).c_str();
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.basTip = buf.substr(befi, i-befi).c_str();
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.advTip = buf.substr(befi, i-befi).c_str();
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
nsp.expTip = buf.substr(befi, i-befi).c_str();
|
|
|
|
++i;
|
2007-06-09 16:28:03 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\r')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
nsp.attributes = buf.substr(befi, i-befi).c_str();
|
|
|
|
++i;
|
|
|
|
++i;
|
|
|
|
|
|
|
|
nsp.combatSpell = combSpells;
|
2007-06-09 16:28:03 +03:00
|
|
|
spells.push_back(nsp);
|
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
}
|