mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
856698bd80
* renamed logging variables to tlogX ('_' in var names looks ugly) * cleaned it improved setting formations * fixed crashbug on maps with random hero
184 lines
3.8 KiB
C++
184 lines
3.8 KiB
C++
#define VCMI_DLL
|
|
#include "../global.h"
|
|
#include "VCMI_Lib.h"
|
|
#include "../hch/CArtHandler.h"
|
|
#include "../hch/CCreatureHandler.h"
|
|
#include "../hch/CDefObjInfoHandler.h"
|
|
#include "../hch/CHeroHandler.h"
|
|
#include "../hch/CObjectHandler.h"
|
|
#include "../hch/CTownHandler.h"
|
|
#include "../hch/CBuildingHandler.h"
|
|
#include "../hch/CSpellHandler.h"
|
|
class CLodHandler;
|
|
LibClasses * VLC = NULL;
|
|
CLodHandler * bitmaph=NULL;
|
|
DLL_EXPORT CLogger<0> tlog0;
|
|
DLL_EXPORT CLogger<1> tlog1;
|
|
DLL_EXPORT CLogger<2> tlog2;
|
|
DLL_EXPORT CLogger<3> tlog3;
|
|
DLL_EXPORT CLogger<4> tlog4;
|
|
DLL_EXPORT CLogger<5> tlog5;
|
|
DLL_EXPORT CConsoleHandler *console = NULL;
|
|
DLL_EXPORT std::ostream *logfile = NULL;
|
|
DLL_EXPORT void initDLL(CLodHandler *b, CConsoleHandler *Console, std::ostream *Logfile)
|
|
{
|
|
console = Console;
|
|
logfile = Logfile;
|
|
timeHandler pomtime;
|
|
bitmaph=b;
|
|
VLC = new LibClasses;
|
|
|
|
CHeroHandler * heroh = new CHeroHandler;
|
|
heroh->loadHeroes();
|
|
heroh->loadPortraits();
|
|
VLC->heroh = heroh;
|
|
tlog0 <<"\tHero handler: "<<pomtime.getDif()<<std::endl;
|
|
|
|
CArtHandler * arth = new CArtHandler;
|
|
arth->loadArtifacts();
|
|
VLC->arth = arth;
|
|
tlog0<<"\tArtifact handler: "<<pomtime.getDif()<<std::endl;
|
|
|
|
CCreatureHandler * creh = new CCreatureHandler();
|
|
creh->loadCreatures();
|
|
VLC->creh = creh;
|
|
tlog0<<"\tCreature handler: "<<pomtime.getDif()<<std::endl;
|
|
|
|
VLC->townh = new CTownHandler;
|
|
VLC->townh->loadNames();
|
|
tlog0<<"\tTown handler: "<<pomtime.getDif()<<std::endl;
|
|
|
|
CObjectHandler * objh = new CObjectHandler;
|
|
objh->loadObjects();
|
|
VLC->objh = objh;
|
|
tlog0<<"\tObject handler: "<<pomtime.getDif()<<std::endl;
|
|
|
|
VLC->dobjinfo = new CDefObjInfoHandler;
|
|
VLC->dobjinfo->load();
|
|
tlog0<<"\tDef information handler: "<<pomtime.getDif()<<std::endl;
|
|
|
|
VLC->buildh = new CBuildingHandler;
|
|
VLC->buildh->loadBuildings();
|
|
tlog0<<"\tBuilding handler: "<<pomtime.getDif()<<std::endl;
|
|
|
|
CSpellHandler * spellh = new CSpellHandler;
|
|
spellh->loadSpells();
|
|
VLC->spellh = spellh;
|
|
tlog0<<"\tSpell handler: "<<pomtime.getDif()<<std::endl;
|
|
}
|
|
|
|
DLL_EXPORT void loadToIt(std::string &dest, std::string &src, int &iter, int mode)
|
|
{
|
|
switch(mode)
|
|
{
|
|
case 0:
|
|
{
|
|
int hmcr = 0;
|
|
for(iter; iter<src.size(); ++iter)
|
|
{
|
|
if(src[iter]=='\t')
|
|
++hmcr;
|
|
if(hmcr==1)
|
|
break;
|
|
}
|
|
++iter;
|
|
|
|
int befi=iter;
|
|
for(iter; iter<src.size(); ++iter)
|
|
{
|
|
if(src[iter]=='\t')
|
|
break;
|
|
}
|
|
dest = src.substr(befi, iter-befi);
|
|
++iter;
|
|
|
|
hmcr = 0;
|
|
for(iter; iter<src.size(); ++iter)
|
|
{
|
|
if(src[iter]=='\r')
|
|
++hmcr;
|
|
if(hmcr==1)
|
|
break;
|
|
}
|
|
iter+=2;
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
int hmcr = 0;
|
|
for(iter; iter<src.size(); ++iter)
|
|
{
|
|
if(src[iter]=='\t')
|
|
++hmcr;
|
|
if(hmcr==1)
|
|
break;
|
|
}
|
|
++iter;
|
|
|
|
int befi=iter;
|
|
for(iter; iter<src.size(); ++iter)
|
|
{
|
|
if(src[iter]=='\r')
|
|
break;
|
|
}
|
|
dest = src.substr(befi, iter-befi);
|
|
iter+=2;
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
int befi=iter;
|
|
for(iter; iter<src.size(); ++iter)
|
|
{
|
|
if(src[iter]=='\t')
|
|
break;
|
|
}
|
|
dest = src.substr(befi, iter-befi);
|
|
++iter;
|
|
|
|
int hmcr = 0;
|
|
for(iter; iter<src.size(); ++iter)
|
|
{
|
|
if(src[iter]=='\r')
|
|
++hmcr;
|
|
if(hmcr==1)
|
|
break;
|
|
}
|
|
iter+=2;
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
int befi=iter;
|
|
for(iter; iter<src.size(); ++iter)
|
|
{
|
|
if(src[iter]=='\r')
|
|
break;
|
|
}
|
|
dest = src.substr(befi, iter-befi);
|
|
iter+=2;
|
|
break;
|
|
}
|
|
case 4:
|
|
{
|
|
int befi=iter;
|
|
for(iter; iter<src.size(); ++iter)
|
|
{
|
|
if(src[iter]=='\t')
|
|
break;
|
|
}
|
|
dest = src.substr(befi, iter-befi);
|
|
iter++;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
DLL_EXPORT void loadToIt(si32 &dest, std::string &src, int &iter, int mode)
|
|
{
|
|
std::string pom;
|
|
loadToIt(pom,src,iter,mode);
|
|
dest = atol(pom.c_str());
|
|
}
|