mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-26 08:41:13 +02:00
360 lines
5.8 KiB
C++
360 lines
5.8 KiB
C++
#include "../stdafx.h"
|
|
#include "CSpellHandler.h"
|
|
#include "../CGameInfo.h"
|
|
#include "CLodHandler.h"
|
|
|
|
void CSpellHandler::loadSpells()
|
|
{
|
|
std::string buf = CGameInfo::mainObj->bitmaph->getTextFile("SPTRAITS.TXT");
|
|
int andame = buf.size();
|
|
int i=0; //buf iterator
|
|
int hmcr=0;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\r')
|
|
++hmcr;
|
|
if(hmcr==5)
|
|
break;
|
|
}
|
|
i+=2;
|
|
bool combSpells=false; //true, if we are reading combat spells
|
|
while(i<andame)
|
|
{
|
|
if(spells.size()==81)
|
|
break;
|
|
CSpell nsp; //new currently being read spell
|
|
int befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.name = buf.substr(befi, i-befi);
|
|
++i;
|
|
|
|
if(nsp.name == std::string(""))
|
|
{
|
|
combSpells = true;
|
|
int hmcr=0;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\r')
|
|
++hmcr;
|
|
if(hmcr==3)
|
|
break;
|
|
}
|
|
++i;
|
|
++i;
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.name = buf.substr(befi, i-befi);
|
|
++i;
|
|
}
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.abbName = buf.substr(befi, i-befi);
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.level = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.earth = buf.substr(befi, i-befi)[0]=='x' ? true : false;
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.water = buf.substr(befi, i-befi)[0]=='x' ? true : false;
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.fire = buf.substr(befi, i-befi)[0]=='x' ? true : false;
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.air = buf.substr(befi, i-befi)[0]=='x' ? true : false;
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.costNone = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.costBas = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.costAdv = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.costExp = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.power = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.powerNone = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.powerBas = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.powerAdv = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.powerExp = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.castle = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.rampart = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.tower = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.inferno = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.necropolis = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.dungeon = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.stronghold = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.fortress = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.conflux = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.none2 = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.bas2 = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.adv2 = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.exp2 = atoi(buf.substr(befi, i-befi).c_str());
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.noneTip = buf.substr(befi, i-befi).c_str();
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.basTip = buf.substr(befi, i-befi).c_str();
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.advTip = buf.substr(befi, i-befi).c_str();
|
|
++i;
|
|
|
|
befi=i;
|
|
for(i; i<andame; ++i)
|
|
{
|
|
if(buf[i]=='\t')
|
|
break;
|
|
}
|
|
nsp.expTip = buf.substr(befi, i-befi).c_str();
|
|
++i;
|
|
|
|
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;
|
|
spells.push_back(nsp);
|
|
}
|
|
}
|