#define VCMI_DLL #include "../stdafx.h" #include "CCreatureHandler.h" #include "CLodHandler.h" #include #include #include #include #include #include #include "../lib/VCMI_Lib.h" using namespace boost::assign; extern CLodHandler * bitmaph; CCreatureHandler::CCreatureHandler() { VLC->creh = this; } int CCreature::getQuantityID(const 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; } bool CCreature::isDoubleWide() const { return vstd::contains(abilities,DOUBLE_WIDE); } bool CCreature::isFlying() const { return vstd::contains(abilities,FLYING); } bool CCreature::isShooting() const { return vstd::contains(abilities,SHOOTER); } si32 CCreature::maxAmount(const std::vector &res) const //how many creatures can be bought { int ret = 2147483645; int resAmnt = std::min(res.size(),cost.size()); for(int i=0;igetTextFile("ZCRTRAIT.TXT"); int andame = buf.size(); int i=0; //buf iterator int hmcr=0; for(i; i> tempi >> temps; if (tempi>=creatures.size()) break; boost::assign::insert(nameToID)(temps,tempi); creatures[tempi].nameRef=temps; } ifs.close(); ifs.clear(); for(int i=1;i<=10;i++) levelCreatures.insert(std::pair >(i,std::vector())); tlog5 << "\t\tReading config/monsters.txt" << std::endl; 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])); } } } ifs.close(); ifs.clear(); tlog5 << "\t\tReading config/cr_factions.txt" << std::endl; ifs.open("config/cr_factions.txt"); while(!ifs.eof()) { int id, fact; ifs >> id >> fact; creatures[id].faction = fact; } ifs.close(); ifs.clear(); tlog5 << "\t\tReading config/cr_upgrade_list.txt" << std::endl; 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(); //loading unit animation def names tlog5 << "\t\tReading config/CREDEFS.TXT" << std::endl; 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 [] bufor; i = 0; //buf iterator hmcr = 0; for(i; i>id; if(id == -1) break; inp2>>name; idToProjectile[id] = name; inp2>>spin; idToProjectileSpin[id] = spin; } inp2.close(); creatures[115].abilities.insert(DOUBLE_WIDE);//water elemental should be treated as double-wide creatures[123].abilities.insert(DOUBLE_WIDE);//ice elemental should be treated as double-wide creatures[140].abilities.insert(DOUBLE_WIDE);//boar should be treated as double-wide creatures[142].abilities.insert(DOUBLE_WIDE);//nomads should be treated as double-wide creatures[46].abilities -= FLYING; } void CCreatureHandler::loadAnimationInfo() { std::string buf = bitmaph->getTextFile("CRANIM.TXT"); int andame = buf.size(); int i=0; //buf iterator int hmcr=0; for(i; i