2008-01-09 19:21:31 +02:00
|
|
|
#include "../stdafx.h"
|
2007-08-30 13:11:53 +03:00
|
|
|
#include "../CGameInfo.h"
|
2008-01-09 19:21:31 +02:00
|
|
|
#include "CDefHandler.h"
|
2007-06-08 22:56:35 +03:00
|
|
|
#include "CCreatureHandler.h"
|
2007-08-29 15:18:31 +03:00
|
|
|
#include "CLodHandler.h"
|
2007-10-15 23:59:17 +03:00
|
|
|
#include <sstream>
|
|
|
|
#include <boost/assign/std/vector.hpp>
|
|
|
|
#include <boost/algorithm/string.hpp>
|
2008-04-14 21:24:46 +03:00
|
|
|
#include <boost/algorithm/string/find.hpp>
|
2007-10-15 23:59:17 +03:00
|
|
|
#include <boost/algorithm/string/replace.hpp>
|
2008-03-10 01:06:35 +02:00
|
|
|
#include "../SDL_Extensions.h"
|
2008-02-25 01:06:27 +02:00
|
|
|
|
|
|
|
int CCreature::getQuantityID(int quantity)
|
|
|
|
{
|
|
|
|
if (quantity<5)
|
|
|
|
return 0;
|
|
|
|
if (quantity<10)
|
|
|
|
return 1;
|
|
|
|
if (quantity<20)
|
|
|
|
return 2;
|
|
|
|
if (quantity<50)
|
|
|
|
return 3;
|
|
|
|
if (quantity<100)
|
|
|
|
return 4;
|
|
|
|
if (quantity<250)
|
|
|
|
return 5;
|
|
|
|
if (quantity<500)
|
|
|
|
return 5;
|
|
|
|
if (quantity<1000)
|
|
|
|
return 6;
|
|
|
|
if (quantity<4000)
|
|
|
|
return 7;
|
|
|
|
return 8;
|
|
|
|
}
|
|
|
|
|
2008-04-14 21:24:46 +03:00
|
|
|
bool CCreature::isDoubleWide()
|
|
|
|
{
|
|
|
|
return boost::algorithm::find_first(abilityRefs, "DOUBLE_WIDE");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CCreature::isFlying()
|
|
|
|
{
|
|
|
|
return boost::algorithm::find_first(abilityRefs, "FLYING_ARMY");
|
|
|
|
}
|
2008-05-12 08:46:04 +03:00
|
|
|
int CCreature::maxAmount(const std::vector<int> &res) const //how many creatures can be bought
|
|
|
|
{
|
|
|
|
int ret = 2147483645;
|
|
|
|
int resAmnt = std::min(res.size(),cost.size());
|
|
|
|
for(int i=0;i<resAmnt;i++)
|
|
|
|
if(cost[i])
|
|
|
|
ret = std::min(ret,res[i]/cost[i]);
|
|
|
|
return ret;
|
|
|
|
}
|
2008-04-14 21:24:46 +03:00
|
|
|
|
2007-06-08 22:56:35 +03:00
|
|
|
void CCreatureHandler::loadCreatures()
|
|
|
|
{
|
2007-07-16 17:42:44 +03:00
|
|
|
std::string buf = CGameInfo::mainObj->bitmaph->getTextFile("ZCRTRAIT.TXT");
|
|
|
|
int andame = buf.size();
|
2007-06-10 21:04:15 +03:00
|
|
|
int i=0; //buf iterator
|
|
|
|
int hmcr=0;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\r')
|
|
|
|
++hmcr;
|
|
|
|
if(hmcr==2)
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
i+=2;
|
|
|
|
|
|
|
|
while(i<buf.size())
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
CCreature ncre;
|
2008-04-04 20:30:53 +03:00
|
|
|
ncre.cost.resize(RESOURCE_QUANTITY);
|
2008-02-05 05:56:45 +02:00
|
|
|
ncre.level=0;
|
2007-06-10 21:04:15 +03:00
|
|
|
int befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.nameSing = buf.substr(befi, i-befi);
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.namePl = buf.substr(befi, i-befi);
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2008-04-04 20:30:53 +03:00
|
|
|
ncre.cost[0] = atoi(buf.substr(befi, i-befi).c_str());
|
2007-06-10 21:04:15 +03:00
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2008-04-04 20:30:53 +03:00
|
|
|
ncre.cost[1] = atoi(buf.substr(befi, i-befi).c_str());
|
2007-06-10 21:04:15 +03:00
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2008-04-04 20:30:53 +03:00
|
|
|
ncre.cost[2] = atoi(buf.substr(befi, i-befi).c_str());
|
2007-06-10 21:04:15 +03:00
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2008-04-04 20:30:53 +03:00
|
|
|
ncre.cost[3] = atoi(buf.substr(befi, i-befi).c_str());
|
2007-06-10 21:04:15 +03:00
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2008-04-04 20:30:53 +03:00
|
|
|
ncre.cost[4] = atoi(buf.substr(befi, i-befi).c_str());
|
2007-06-10 21:04:15 +03:00
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2008-04-04 20:30:53 +03:00
|
|
|
ncre.cost[5] = atoi(buf.substr(befi, i-befi).c_str());
|
2007-06-10 21:04:15 +03:00
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2008-04-04 20:30:53 +03:00
|
|
|
ncre.cost[6] = atoi(buf.substr(befi, i-befi).c_str());
|
2007-06-10 21:04:15 +03:00
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.fightValue = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.AIValue = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.growth = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.hordeGrowth = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.hitPoints = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.speed = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.attack = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.defence = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2008-05-23 22:50:11 +03:00
|
|
|
ncre.damageMin = atoi(buf.substr(befi, i-befi).c_str());
|
2007-06-10 21:04:15 +03:00
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2008-05-23 22:50:11 +03:00
|
|
|
ncre.damageMax = atoi(buf.substr(befi, i-befi).c_str());
|
2007-06-10 21:04:15 +03:00
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.shots = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.spells = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2008-05-23 22:50:11 +03:00
|
|
|
ncre.ammMin = atoi(buf.substr(befi, i-befi).c_str());
|
2007-06-10 21:04:15 +03:00
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2008-05-23 22:50:11 +03:00
|
|
|
ncre.ammMax = atoi(buf.substr(befi, i-befi).c_str());
|
2007-06-10 21:04:15 +03:00
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.abilityText = buf.substr(befi, i-befi);
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\r')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.abilityRefs = buf.substr(befi, i-befi);
|
|
|
|
i+=2;
|
2007-06-13 23:17:48 +03:00
|
|
|
if(ncre.nameSing!=std::string("") && ncre.namePl!=std::string(""))
|
|
|
|
{
|
|
|
|
ncre.idNumber = creatures.size();
|
2007-07-12 21:04:02 +03:00
|
|
|
ncre.isDefinite = true;
|
2007-06-13 23:17:48 +03:00
|
|
|
creatures.push_back(ncre);
|
|
|
|
}
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-07-12 21:04:02 +03:00
|
|
|
for(int bb=1; bb<8; ++bb)
|
|
|
|
{
|
|
|
|
CCreature ncre;
|
|
|
|
ncre.isDefinite = false;
|
|
|
|
ncre.indefLevel = bb;
|
|
|
|
ncre.indefUpgraded = false;
|
|
|
|
creatures.push_back(ncre);
|
|
|
|
ncre.indefUpgraded = true;
|
|
|
|
creatures.push_back(ncre);
|
|
|
|
}
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-10-17 01:39:11 +03:00
|
|
|
//loading reference names
|
|
|
|
std::ifstream ifs("config/crerefnam.txt");
|
2007-10-15 23:59:17 +03:00
|
|
|
int tempi;
|
|
|
|
std::string temps;
|
|
|
|
for (;;)
|
2007-06-18 13:49:06 +03:00
|
|
|
{
|
2007-10-15 23:59:17 +03:00
|
|
|
ifs >> tempi >> temps;
|
|
|
|
if (tempi>=creatures.size())
|
2007-06-18 13:49:06 +03:00
|
|
|
break;
|
2007-10-15 23:59:17 +03:00
|
|
|
boost::assign::insert(nameToID)(temps,tempi);
|
|
|
|
creatures[tempi].nameRef=temps;
|
2007-06-18 13:49:06 +03:00
|
|
|
}
|
2007-10-15 23:59:17 +03:00
|
|
|
ifs.close();
|
2008-02-05 05:56:45 +02:00
|
|
|
ifs.clear();
|
|
|
|
for(int i=1;i<=10;i++)
|
|
|
|
levelCreatures.insert(std::pair<int,std::vector<CCreature*> >(i,std::vector<CCreature*>()));
|
|
|
|
ifs.open("config/monsters.txt");
|
|
|
|
{
|
|
|
|
while(!ifs.eof())
|
|
|
|
{
|
|
|
|
int id, lvl;
|
|
|
|
ifs >> id >> lvl;
|
|
|
|
if(lvl>0)
|
|
|
|
{
|
|
|
|
creatures[id].level = lvl;
|
|
|
|
levelCreatures[lvl].push_back(&(creatures[id]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-04-04 20:30:53 +03:00
|
|
|
ifs.close();
|
|
|
|
ifs.clear();
|
|
|
|
|
|
|
|
|
|
|
|
ifs.open("config/cr_bgs.txt");
|
|
|
|
while(!ifs.eof())
|
|
|
|
{
|
|
|
|
int id;
|
|
|
|
std::string name;
|
|
|
|
ifs >> id >> name;
|
|
|
|
backgrounds[id]=CGI->bitmaph->loadBitmap(name);
|
|
|
|
}
|
|
|
|
ifs.close();
|
|
|
|
ifs.clear();
|
|
|
|
|
|
|
|
|
|
|
|
ifs.open("config/cr_factions.txt");
|
|
|
|
while(!ifs.eof())
|
|
|
|
{
|
|
|
|
int id, fact;
|
|
|
|
ifs >> id >> fact;
|
|
|
|
creatures[id].faction = fact;
|
|
|
|
}
|
|
|
|
ifs.close();
|
|
|
|
ifs.clear();
|
2007-10-17 01:39:11 +03:00
|
|
|
|
2008-05-31 23:37:54 +03:00
|
|
|
ifs.open("config/cr_upgrade_list.txt");
|
|
|
|
while(!ifs.eof())
|
|
|
|
{
|
|
|
|
int id, up;
|
|
|
|
ifs >> id >> up;
|
|
|
|
creatures[id].upgrades.insert(up);
|
|
|
|
}
|
|
|
|
ifs.close();
|
|
|
|
ifs.clear();
|
|
|
|
|
2007-10-17 01:39:11 +03:00
|
|
|
//loading 32x32px imgs
|
|
|
|
CDefHandler *smi = CGI->spriteh->giveDef("CPRSMALL.DEF");
|
|
|
|
smi->notFreeImgs = true;
|
|
|
|
for (int i=0; i<smi->ourImages.size(); i++)
|
|
|
|
{
|
|
|
|
boost::assign::insert(smallImgs)(i-2,smi->ourImages[i].bitmap);
|
|
|
|
}
|
|
|
|
delete smi;
|
2008-01-12 13:32:40 +02:00
|
|
|
smi = CGI->spriteh->giveDef("TWCRPORT.DEF");
|
|
|
|
smi->notFreeImgs = true;
|
|
|
|
for (int i=0; i<smi->ourImages.size(); i++)
|
|
|
|
{
|
|
|
|
boost::assign::insert(bigImgs)(i-2,smi->ourImages[i].bitmap);
|
|
|
|
}
|
|
|
|
delete smi;
|
2008-03-05 19:01:41 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
//loading unit animation def names
|
|
|
|
std::ifstream inp("config/CREDEFS.TXT", std::ios::in | std::ios::binary); //this file is not in lod
|
|
|
|
inp.seekg(0,std::ios::end); // na koniec
|
|
|
|
int andame2 = inp.tellg(); // read length
|
|
|
|
inp.seekg(0,std::ios::beg); // wracamy na poczatek
|
|
|
|
char * bufor = new char[andame2]; // allocate memory
|
|
|
|
inp.read((char*)bufor, andame2); // read map file to buffer
|
|
|
|
inp.close();
|
|
|
|
buf = std::string(bufor);
|
|
|
|
delete [andame2] bufor;
|
|
|
|
|
|
|
|
i = 0; //buf iterator
|
|
|
|
hmcr = 0;
|
|
|
|
for(i; i<andame2; ++i) //omitting rubbish
|
|
|
|
{
|
|
|
|
if(buf[i]=='\r')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i+=2;
|
|
|
|
for(int s=0; s<creatures.size()-16; ++s)
|
|
|
|
{
|
|
|
|
int befi=i;
|
|
|
|
std::string rub;
|
|
|
|
for(i; i<andame2; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]==' ')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
rub = buf.substr(befi, i-befi);
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<andame2; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\r')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
std::string defName = buf.substr(befi, i-befi);
|
|
|
|
creatures[s].animDefName = defName;
|
|
|
|
}
|
|
|
|
loadAnimationInfo();
|
2007-10-15 23:59:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCreatureHandler::loadAnimationInfo()
|
|
|
|
{
|
2008-03-05 19:01:41 +02:00
|
|
|
std::string buf = CGameInfo::mainObj->bitmaph->getTextFile("CRANIM.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==2)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i+=2;
|
|
|
|
for(int dd=0; dd<creatures.size()-16; ++dd)
|
|
|
|
{
|
|
|
|
loadUnitAnimInfo(creatures[dd], buf, i);
|
|
|
|
}
|
2007-06-18 13:49:06 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCreatureHandler::loadUnitAnimInfo(CCreature & unit, std::string & src, int & i)
|
|
|
|
{
|
|
|
|
int befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.timeBetweenFidgets = atof(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
while(unit.timeBetweenFidgets == 0.0)
|
|
|
|
{
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\r')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i+=2;
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.timeBetweenFidgets = atof(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.walkAnimationTime = atof(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.attackAnimationTime = atof(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.flightAnimationDistance = atof(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
///////////////////////
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.upperRightMissleOffsetX = atoi(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.upperRightMissleOffsetY = atoi(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.rightMissleOffsetX = atoi(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.rightMissleOffsetY = atoi(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.lowerRightMissleOffsetX = atoi(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.lowerRightMissleOffsetY = atoi(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
///////////////////////
|
|
|
|
|
|
|
|
for(int jjj=0; jjj<12; ++jjj)
|
|
|
|
{
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.missleFrameAngles[jjj] = atof(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.troopCountLocationOffset= atoi(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.attackClimaxFrame = atoi(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\r')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i+=2;
|
2008-06-07 20:16:52 +03:00
|
|
|
}
|