CObjectHandler.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. #define VCMI_DLL
  2. #include "../stdafx.h"
  3. #include "CObjectHandler.h"
  4. #include "CDefObjInfoHandler.h"
  5. #include "CLodHandler.h"
  6. #include "CDefObjInfoHandler.h"
  7. #include "CHeroHandler.h"
  8. #include "CSpellHandler.h"
  9. #include <boost/algorithm/string/replace.hpp>
  10. #include <boost/random/linear_congruential.hpp>
  11. #include "CTownHandler.h"
  12. #include "CArtHandler.h"
  13. #include "../lib/VCMI_Lib.h"
  14. DLL_EXPORT void loadToIt(std::string &dest, std::string &src, int &iter, int mode);
  15. extern CLodHandler * bitmaph;
  16. extern boost::rand48 ran;
  17. void CObjectHandler::loadObjects()
  18. {
  19. VLC->objh = this;
  20. int ID=0;
  21. tlog5 << "\t\tReading OBJNAMES \n";
  22. std::string buf = bitmaph->getTextFile("OBJNAMES.TXT");
  23. int it=0;
  24. while (it<buf.length()-1)
  25. {
  26. std::string nobj;
  27. loadToIt(nobj,buf,it,3);
  28. if(nobj.size() && (nobj[nobj.size()-1]==(char)10 || nobj[nobj.size()-1]==(char)13 || nobj[nobj.size()-1]==(char)9))
  29. nobj = nobj.substr(0, nobj.size()-1);
  30. names.push_back(nobj);
  31. }
  32. tlog5 << "\t\tReading ADVEVENT \n";
  33. buf = bitmaph->getTextFile("ADVEVENT.TXT");
  34. it=0;
  35. std::string temp;
  36. while (it<buf.length()-1)
  37. {
  38. loadToIt(temp,buf,it,3);
  39. if (temp[0]=='\"')
  40. temp = temp.substr(1,temp.length()-2);
  41. boost::algorithm::replace_all(temp,"\"\"","\"");
  42. advobtxt.push_back(temp);
  43. }
  44. tlog5 << "\t\tReading XTRAINFO \n";
  45. buf = bitmaph->getTextFile("XTRAINFO.TXT");
  46. it=0;
  47. while (it<buf.length()-1)
  48. {
  49. loadToIt(temp,buf,it,3);
  50. xtrainfo.push_back(temp);
  51. }
  52. tlog5 << "\t\tReading MINENAME \n";
  53. buf = bitmaph->getTextFile("MINENAME.TXT");
  54. it=0;
  55. while (it<buf.length()-1)
  56. {
  57. loadToIt(temp,buf,it,3);
  58. mines.push_back(std::pair<std::string,std::string>(temp,""));
  59. }
  60. tlog5 << "\t\tReading MINEEVNT \n";
  61. buf = bitmaph->getTextFile("MINEEVNT.TXT");
  62. it=0;
  63. int i=0;
  64. while (it<buf.length()-1)
  65. {
  66. loadToIt(temp,buf,it,3);
  67. temp = temp.substr(1,temp.length()-2);
  68. mines[i++].second = temp;
  69. }
  70. tlog5 << "\t\tReading RESTYPES \n";
  71. buf = bitmaph->getTextFile("RESTYPES.TXT");
  72. it=0;
  73. while (it<buf.length()-1)
  74. {
  75. loadToIt(temp,buf,it,3);
  76. restypes.push_back(temp);
  77. }
  78. tlog5 << "\t\tReading cregens \n";
  79. cregens.resize(110); //TODO: hardcoded value - change
  80. for(int i=0; i<cregens.size();i++)
  81. cregens[i]=-1;
  82. std::ifstream ifs("config/cregens.txt");
  83. while(!ifs.eof())
  84. {
  85. int dw, cr;
  86. ifs >> dw >> cr;
  87. cregens[dw]=cr;
  88. }
  89. ifs.close();
  90. ifs.clear();
  91. tlog5 << "\t\tReading ZCRGN1 \n";
  92. buf = bitmaph->getTextFile("ZCRGN1.TXT");
  93. it=0;
  94. while (it<buf.length()-1)
  95. {
  96. loadToIt(temp,buf,it,3);
  97. creGens.push_back(temp);
  98. }
  99. tlog5 << "\t\tDone loading objects!\n";
  100. }
  101. bool CGObjectInstance::isHero() const
  102. {
  103. return false;
  104. }
  105. int CGObjectInstance::getOwner() const
  106. {
  107. //if (state)
  108. // return state->owner;
  109. //else
  110. return tempOwner; //won't have owner
  111. }
  112. void CGObjectInstance::setOwner(int ow)
  113. {
  114. //if (state)
  115. // state->owner = ow;
  116. //else
  117. tempOwner = ow;
  118. }
  119. int CGObjectInstance::getWidth() const//returns width of object graphic in tiles
  120. {
  121. return defInfo->width;
  122. }
  123. int CGObjectInstance::getHeight() const //returns height of object graphic in tiles
  124. {
  125. return defInfo->width;
  126. }
  127. bool CGObjectInstance::visitableAt(int x, int y) const //returns true if object is visitable at location (x, y) form left top tile of image (x, y in tiles)
  128. {
  129. if(x<0 || y<0 || x>=getWidth() || y>=getHeight() || defInfo==NULL)
  130. return false;
  131. if((defInfo->visitMap[y+6-getHeight()] >> (7-(8-getWidth()+x) )) & 1)
  132. return true;
  133. return false;
  134. }
  135. bool CGObjectInstance::blockingAt(int x, int y) const
  136. {
  137. if(x<0 || y<0 || x>=getWidth() || y>=getHeight() || defInfo==NULL)
  138. return false;
  139. if((defInfo->blockMap[y+6-getHeight()] >> (7-(8-getWidth()+x) )) & 1)
  140. return true;
  141. return false;
  142. }
  143. bool CGObjectInstance::operator<(const CGObjectInstance & cmp) const //screen printing priority comparing
  144. {
  145. if(defInfo->printPriority==1 && cmp.defInfo->printPriority==0)
  146. return true;
  147. if(cmp.defInfo->printPriority==1 && defInfo->printPriority==0)
  148. return false;
  149. if(this->pos.y<cmp.pos.y)
  150. return true;
  151. if(this->pos.y>cmp.pos.y)
  152. return false;
  153. if(cmp.ID==34 && ID!=34)
  154. return true;
  155. if(cmp.ID!=34 && ID==34)
  156. return false;
  157. if(!defInfo->isVisitable() && cmp.defInfo->isVisitable())
  158. return true;
  159. if(!cmp.defInfo->isVisitable() && defInfo->isVisitable())
  160. return false;
  161. if(this->pos.x<cmp.pos.x)
  162. return true;
  163. return false;
  164. }
  165. bool CGHeroInstance::isHero() const
  166. {
  167. return true;
  168. }
  169. unsigned int CGHeroInstance::getTileCost(const EterrainType & ttype, const Eroad & rdtype, const Eriver & rvtype) const
  170. {
  171. unsigned int ret = type->heroClass->terrCosts[ttype];
  172. //applying pathfinding skill
  173. switch(getSecSkillLevel(0))
  174. {
  175. case 1: //basic
  176. switch(ttype)
  177. {
  178. case rough:
  179. ret = 100;
  180. break;
  181. case sand: case snow:
  182. if(ret>125)
  183. ret = 125;
  184. break;
  185. case swamp:
  186. if(ret>150)
  187. ret = 150;
  188. break;
  189. }
  190. break;
  191. case 2: //advanced
  192. switch(ttype)
  193. {
  194. case rough: case sand: case snow:
  195. ret = 100;
  196. break;
  197. case swamp:
  198. if(ret>125)
  199. ret = 125;
  200. break;
  201. }
  202. break;
  203. case 3: //expert
  204. ret = 100;
  205. break;
  206. }
  207. //calculating road influence
  208. switch(rdtype)
  209. {
  210. case dirtRoad:
  211. ret*=0.75;
  212. break;
  213. case grazvelRoad:
  214. ret*=0.667;
  215. break;
  216. case cobblestoneRoad:
  217. ret*=0.5;
  218. break;
  219. }
  220. return ret;
  221. }
  222. unsigned int CGHeroInstance::getLowestCreatureSpeed()
  223. {
  224. unsigned int sl = 100;
  225. for(int h=0; h<army.slots.size(); ++h)
  226. {
  227. if(VLC->creh->creatures[army.slots[h].first].speed<sl)
  228. sl = VLC->creh->creatures[army.slots[h].first].speed;
  229. }
  230. return sl;
  231. }
  232. int3 CGHeroInstance::convertPosition(int3 src, bool toh3m) //toh3m=true: manifest->h3m; toh3m=false: h3m->manifest
  233. {
  234. if (toh3m)
  235. {
  236. src.x+=1;
  237. return src;
  238. }
  239. else
  240. {
  241. src.x-=1;
  242. return src;
  243. }
  244. }
  245. int3 CGHeroInstance::getPosition(bool h3m) const //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation'
  246. {
  247. if (h3m)
  248. return pos;
  249. else return convertPosition(pos,false);
  250. }
  251. int CGHeroInstance::getSightDistance() const //returns sight distance of this hero
  252. {
  253. return 6 + getSecSkillLevel(3); //default + scouting
  254. }
  255. int CGHeroInstance::manaLimit() const
  256. {
  257. double modifier = 1.0;
  258. switch(getSecSkillLevel(24)) //intelligence level
  259. {
  260. case 1: modifier+=0.25; break;
  261. case 2: modifier+=0.5; break;
  262. case 3: modifier+=1.0; break;
  263. }
  264. return 10*getPrimSkillLevel(3)*modifier;
  265. }
  266. //void CGHeroInstance::setPosition(int3 Pos, bool h3m) //as above, but sets position
  267. //{
  268. // if (h3m)
  269. // pos = Pos;
  270. // else
  271. // pos = convertPosition(Pos,true);
  272. //}
  273. bool CGHeroInstance::canWalkOnSea() const
  274. {
  275. //TODO: write it - it should check if hero is flying, or something similiar
  276. return false;
  277. }
  278. int CGHeroInstance::getCurrentLuck() const
  279. {
  280. //TODO: write it
  281. return 0;
  282. }
  283. int CGHeroInstance::getCurrentMorale() const
  284. {
  285. //TODO: write it
  286. return 0;
  287. }
  288. int CGHeroInstance::getPrimSkillLevel(int id) const
  289. {
  290. return primSkills[id];
  291. }
  292. int CGHeroInstance::getSecSkillLevel(const int & ID) const
  293. {
  294. for(int i=0;i<secSkills.size();i++)
  295. if(secSkills[i].first==ID)
  296. return secSkills[i].second;
  297. return 0;
  298. }
  299. int lowestSpeed(const CGHeroInstance * chi)
  300. {
  301. if(!chi->army.slots.size())
  302. {
  303. tlog1 << "Error! Hero " << chi->id << " ("<<chi->name<<") has no army!\n";
  304. return 20;
  305. }
  306. std::map<si32,std::pair<ui32,si32> >::const_iterator i = chi->army.slots.begin();
  307. int ret = VLC->creh->creatures[(*i++).second.first].speed;
  308. for (;i!=chi->army.slots.end();i++)
  309. {
  310. ret = std::min(ret,VLC->creh->creatures[(*i).second.first].speed);
  311. }
  312. return ret;
  313. }
  314. int CGHeroInstance::maxMovePoints(bool onLand) const
  315. {
  316. int ret = 1270+70*lowestSpeed(this);
  317. if (ret>2000)
  318. ret=2000;
  319. if(onLand)
  320. {
  321. //logistics:
  322. switch(getSecSkillLevel(2))
  323. {
  324. case 1:
  325. ret *= 1.1f;
  326. break;
  327. case 2:
  328. ret *= 1.2f;
  329. break;
  330. case 3:
  331. ret *= 1.3f;
  332. break;
  333. }
  334. }
  335. else
  336. {
  337. //navigation:
  338. switch(getSecSkillLevel(2))
  339. {
  340. case 1:
  341. ret *= 1.5f;
  342. break;
  343. case 2:
  344. ret *= 2.0f;
  345. break;
  346. case 3:
  347. ret *= 2.5f;
  348. break;
  349. }
  350. }
  351. return ret;
  352. }
  353. ui32 CGHeroInstance::getArtAtPos(ui16 pos) const
  354. {
  355. if(pos<19)
  356. if(vstd::contains(artifWorn,pos))
  357. return artifWorn.find(pos)->second;
  358. else
  359. return -1;
  360. else
  361. if(pos-19 < artifacts.size())
  362. return artifacts[pos-19];
  363. else
  364. return -1;
  365. }
  366. void CGHeroInstance::setArtAtPos(ui16 pos, int art)
  367. {
  368. if(art<0)
  369. {
  370. if(pos<19)
  371. artifWorn.erase(pos);
  372. else
  373. artifacts -= artifacts[pos-19];
  374. }
  375. else
  376. {
  377. if(pos<19)
  378. artifWorn[pos] = art;
  379. else
  380. if(pos-19 < artifacts.size())
  381. artifacts[pos-19] = art;
  382. else
  383. artifacts.push_back(art);
  384. }
  385. }
  386. const CArtifact * CGHeroInstance::getArt(int pos) const
  387. {
  388. int id = getArtAtPos(pos);
  389. if(id>=0)
  390. return &VLC->arth->artifacts[id];
  391. else
  392. return NULL;
  393. }
  394. int CGHeroInstance::getSpellSecLevel(int spell) const
  395. {
  396. int bestslvl = 0;
  397. if(VLC->spellh->spells[spell].air)
  398. if(getSecSkillLevel(15) >= bestslvl)
  399. {
  400. bestslvl = getSecSkillLevel(15);
  401. }
  402. if(VLC->spellh->spells[spell].fire)
  403. if(getSecSkillLevel(14) >= bestslvl)
  404. {
  405. bestslvl = getSecSkillLevel(14);
  406. }
  407. if(VLC->spellh->spells[spell].water)
  408. if(getSecSkillLevel(16) >= bestslvl)
  409. {
  410. bestslvl = getSecSkillLevel(16);
  411. }
  412. if(VLC->spellh->spells[spell].earth)
  413. if(getSecSkillLevel(17) >= bestslvl)
  414. {
  415. bestslvl = getSecSkillLevel(17);
  416. }
  417. return bestslvl;
  418. }
  419. int CGTownInstance::getSightDistance() const //returns sight distance
  420. {
  421. return 10;
  422. }
  423. int CGTownInstance::fortLevel() const //0 - none, 1 - fort, 2 - citadel, 3 - castle
  424. {
  425. if((builtBuildings.find(9))!=builtBuildings.end())
  426. return 3;
  427. if((builtBuildings.find(8))!=builtBuildings.end())
  428. return 2;
  429. if((builtBuildings.find(7))!=builtBuildings.end())
  430. return 1;
  431. return 0;
  432. }
  433. int CGTownInstance::hallLevel() const // -1 - none, 0 - village, 1 - town, 2 - city, 3 - capitol
  434. {
  435. if ((builtBuildings.find(13))!=builtBuildings.end())
  436. return 3;
  437. if ((builtBuildings.find(12))!=builtBuildings.end())
  438. return 2;
  439. if ((builtBuildings.find(11))!=builtBuildings.end())
  440. return 1;
  441. if ((builtBuildings.find(10))!=builtBuildings.end())
  442. return 0;
  443. return -1;
  444. }
  445. int CGTownInstance::mageGuildLevel() const
  446. {
  447. if ((builtBuildings.find(4))!=builtBuildings.end())
  448. return 5;
  449. if ((builtBuildings.find(3))!=builtBuildings.end())
  450. return 4;
  451. if ((builtBuildings.find(2))!=builtBuildings.end())
  452. return 3;
  453. if ((builtBuildings.find(1))!=builtBuildings.end())
  454. return 2;
  455. if ((builtBuildings.find(0))!=builtBuildings.end())
  456. return 1;
  457. return 0;
  458. }
  459. bool CGTownInstance::creatureDwelling(const int & level, bool upgraded) const
  460. {
  461. return builtBuildings.find(30+level+upgraded*7)!=builtBuildings.end();
  462. }
  463. int CGTownInstance::getHordeLevel(const int & HID) const//HID - 0 or 1; returns creature level or -1 if that horde structure is not present
  464. {
  465. return town->hordeLvl[HID];
  466. }
  467. int CGTownInstance::creatureGrowth(const int & level) const
  468. {
  469. int ret = VLC->creh->creatures[town->basicCreatures[level]].growth;
  470. switch(fortLevel())
  471. {
  472. case 3:
  473. ret*=2;break;
  474. case 2:
  475. ret*=(1.5); break;
  476. }
  477. if(builtBuildings.find(26)!=builtBuildings.end()) //grail
  478. ret+=VLC->creh->creatures[town->basicCreatures[level]].growth;
  479. if(getHordeLevel(0)==level)
  480. if((builtBuildings.find(18)!=builtBuildings.end()) || (builtBuildings.find(19)!=builtBuildings.end()))
  481. ret+=VLC->creh->creatures[town->basicCreatures[level]].hordeGrowth;
  482. if(getHordeLevel(1)==level)
  483. if((builtBuildings.find(24)!=builtBuildings.end()) || (builtBuildings.find(25)!=builtBuildings.end()))
  484. ret+=VLC->creh->creatures[town->basicCreatures[level]].hordeGrowth;
  485. return ret;
  486. }
  487. int CGTownInstance::dailyIncome() const
  488. {
  489. int ret = 0;
  490. if ((builtBuildings.find(26))!=builtBuildings.end())
  491. ret+=5000;
  492. if ((builtBuildings.find(13))!=builtBuildings.end())
  493. ret+=4000;
  494. else if ((builtBuildings.find(12))!=builtBuildings.end())
  495. ret+=2000;
  496. else if ((builtBuildings.find(11))!=builtBuildings.end())
  497. ret+=1000;
  498. else if ((builtBuildings.find(10))!=builtBuildings.end())
  499. ret+=500;
  500. return ret;
  501. }
  502. bool CGTownInstance::hasFort() const
  503. {
  504. return (builtBuildings.find(7))!=builtBuildings.end();
  505. }
  506. bool CGTownInstance::hasCapitol() const
  507. {
  508. return (builtBuildings.find(13))!=builtBuildings.end();
  509. }
  510. CGTownInstance::CGTownInstance()
  511. {
  512. builded=-1;
  513. destroyed=-1;
  514. garrisonHero=NULL;
  515. town=NULL;
  516. visitingHero = NULL;
  517. }
  518. CGObjectInstance::CGObjectInstance(): animPhaseShift(rand()%0xff)
  519. {
  520. pos = int3(-1,-1,-1);
  521. //std::cout << "Tworze obiekt "<<this<<std::endl;
  522. //state = new CLuaObjectScript();
  523. ID = subID = id = -1;
  524. defInfo = NULL;
  525. state = NULL;
  526. info = NULL;
  527. tempOwner = 254;
  528. blockVisit = false;
  529. }
  530. CGObjectInstance::~CGObjectInstance()
  531. {
  532. //std::cout << "Usuwam obiekt "<<this<<std::endl;
  533. //if (state)
  534. // delete state;
  535. //state=NULL;
  536. }
  537. CGHeroInstance::CGHeroInstance()
  538. {
  539. ID = 34;
  540. tacticFormationEnabled = inTownGarrison = false;
  541. mana = movement = portrait = level = -1;
  542. isStanding = true;
  543. moveDir = 4;
  544. exp = 0xffffffff;
  545. visitedTown = NULL;
  546. type = NULL;
  547. secSkills.push_back(std::make_pair(-1, -1));
  548. }
  549. void CGHeroInstance::initHero(int SUBID)
  550. {
  551. subID = SUBID;
  552. initHero();
  553. }
  554. void CGHeroInstance::initHero()
  555. {
  556. if(!defInfo)
  557. {
  558. defInfo = new CGDefInfo();
  559. defInfo->id = 34;
  560. defInfo->subid = subID;
  561. defInfo->printPriority = 0;
  562. defInfo->visitDir = 0xff;
  563. }
  564. if(!type)
  565. type = VLC->heroh->heroes[subID];
  566. for(int i=0;i<6;i++)
  567. {
  568. defInfo->blockMap[i]=255;
  569. defInfo->visitMap[i]=0;
  570. }
  571. defInfo->handler=NULL;
  572. defInfo->blockMap[5] = 253;
  573. defInfo->visitMap[5] = 2;
  574. artifWorn[16] = 3;
  575. if(type->heroType % 2 == 1) //it's a magical hero
  576. {
  577. artifWorn[17] = 0; //give him spellbook
  578. }
  579. if(portrait < 0)
  580. portrait = subID;
  581. if((!primSkills.size()) || (getPrimSkillLevel(0)<0))
  582. {
  583. primSkills.resize(4);
  584. primSkills[0] = type->heroClass->initialAttack;
  585. primSkills[1] = type->heroClass->initialDefence;
  586. primSkills[2] = type->heroClass->initialPower;
  587. primSkills[3] = type->heroClass->initialKnowledge;
  588. }
  589. if(secSkills.size() == 1 && secSkills[0] == std::make_pair(-1, -1)) //set secondary skills to default
  590. secSkills = type->secSkillsInit;
  591. if(mana < 0)
  592. mana = manaLimit();
  593. if (!name.length())
  594. name = type->name;
  595. if (!biography.length())
  596. biography = type->biography;
  597. if (exp == 0xffffffff)
  598. {
  599. exp=40+ (ran()) % 50;
  600. level = 1;
  601. }
  602. else
  603. {
  604. level = VLC->heroh->level(exp);
  605. }
  606. if (!army.slots.size()) //standard army//initial army
  607. {
  608. int pom, pom2=0;
  609. for(int x=0;x<3;x++)
  610. {
  611. pom = (VLC->creh->nameToID[type->refTypeStack[x]]);
  612. if(pom>=145 && pom<=149) //war machine
  613. {
  614. pom2++;
  615. switch (pom)
  616. {
  617. case 145: //catapult
  618. artifWorn[16] = 3;
  619. break;
  620. default:
  621. artifWorn[9+CArtHandler::convertMachineID(pom,true)] = CArtHandler::convertMachineID(pom,true);
  622. break;
  623. }
  624. continue;
  625. }
  626. army.slots[x-pom2].first = pom;
  627. if((pom = (type->highStack[x]-type->lowStack[x])) > 0)
  628. army.slots[x-pom2].second = (ran()%pom)+type->lowStack[x];
  629. else
  630. army.slots[x-pom2].second = +type->lowStack[x];
  631. army.formation = false;
  632. }
  633. }
  634. }
  635. CGHeroInstance::~CGHeroInstance()
  636. {
  637. }
  638. bool CGHeroInstance::needsLastStack() const
  639. {
  640. return true;
  641. }
  642. CGTownInstance::~CGTownInstance()
  643. {}
  644. int CGTownInstance::spellsAtLevel(int level, bool checkGuild) const
  645. {
  646. if(checkGuild && mageGuildLevel() < level)
  647. return 0;
  648. int ret = 6 - level; //how many spells are available at this level
  649. if(subID == 2 && vstd::contains(builtBuildings,22)) //magic library in Tower
  650. ret++;
  651. return ret;
  652. }
  653. bool CGTownInstance::needsLastStack() const
  654. {
  655. if(garrisonHero)
  656. return true;
  657. else return false;
  658. }
  659. CGObjectInstance::CGObjectInstance(const CGObjectInstance & right)
  660. {
  661. pos = right.pos;
  662. ID = right.ID;
  663. subID = right.subID;
  664. id = right.id;
  665. defInfo = right.defInfo;
  666. info = right.info;
  667. blockVisit = right.blockVisit;
  668. //state = new CLuaObjectScript(right.state->);
  669. //*state = *right.state;
  670. //state = right.state;
  671. tempOwner = right.tempOwner;
  672. }
  673. CGObjectInstance& CGObjectInstance::operator=(const CGObjectInstance & right)
  674. {
  675. pos = right.pos;
  676. ID = right.ID;
  677. subID = right.subID;
  678. id = right.id;
  679. defInfo = right.defInfo;
  680. info = right.info;
  681. blockVisit = right.blockVisit;
  682. //state = new CLuaObjectScript();
  683. //*state = *right.state;
  684. tempOwner = right.tempOwner;
  685. return *this;
  686. }