CAdvmapInterface.cpp 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133
  1. #include "stdafx.h"
  2. #include "CAdvmapInterface.h"
  3. #include "client/CBitmapHandler.h"
  4. #include "CPlayerInterface.h"
  5. #include "CCastleInterface.h"
  6. #include "hch/CPreGameTextHandler.h"
  7. #include "hch/CGeneralTextHandler.h"
  8. #include "hch/CDefHandler.h"
  9. #include "hch/CTownHandler.h"
  10. #include "CPathfinder.h"
  11. #include "CGameInfo.h"
  12. #include "SDL_Extensions.h"
  13. #include "CCallback.h"
  14. #include <boost/assign/std/vector.hpp>
  15. #include "mapHandler.h"
  16. #include "CMessage.h"
  17. #include <boost/algorithm/string.hpp>
  18. #include <boost/algorithm/string/replace.hpp>
  19. #include "hch/CHeroHandler.h"
  20. #include <sstream>
  21. #include "AdventureMapButton.h"
  22. #include "CHeroWindow.h"
  23. #include "client/Graphics.h"
  24. #include "hch/CObjectHandler.h"
  25. #include <boost/thread.hpp>
  26. #include "map.h"
  27. #pragma warning (disable : 4355)
  28. extern TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX; //fonts
  29. using namespace boost::logic;
  30. using namespace boost::assign;
  31. using namespace CSDL_Ext;
  32. CAdvMapInt::~CAdvMapInt()
  33. {
  34. SDL_FreeSurface(bg);
  35. delete heroWindow;
  36. }
  37. CMinimap::CMinimap(bool draw)
  38. {
  39. statusbarTxt = CGI->preth->zelp[291].first;
  40. rcText = CGI->preth->zelp[291].second;
  41. pos.x=630;
  42. pos.y=26;
  43. pos.h=pos.w=144;
  44. int rx = (((float)19)/(CGI->mh->sizes.x))*((float)pos.w),
  45. ry = (((float)18)/(CGI->mh->sizes.y))*((float)pos.h);
  46. radar = newSurface(rx,ry);
  47. temps = newSurface(144,144);
  48. SDL_FillRect(radar,NULL,0x00FFFF);
  49. for (int i=0; i<radar->w; i++)
  50. {
  51. if (i%4 || (i==0))
  52. {
  53. SDL_PutPixel(radar,i,0,255,75,125);
  54. SDL_PutPixel(radar,i,radar->h-1,255,75,125);
  55. }
  56. }
  57. for (int i=0; i<radar->h; i++)
  58. {
  59. if ((i%4) || (i==0))
  60. {
  61. SDL_PutPixel(radar,0,i,255,75,125);
  62. SDL_PutPixel(radar,radar->w-1,i,255,75,125);
  63. }
  64. }
  65. SDL_SetColorKey(radar,SDL_SRCCOLORKEY,SDL_MapRGB(radar->format,0,255,255));
  66. //radar = CDefHandler::giveDef("RADAR.DEF");
  67. std::ifstream is("config/minimap.txt",std::ifstream::in);
  68. for (int i=0;i<TERRAIN_TYPES;i++)
  69. {
  70. std::pair<int,SDL_Color> vinya;
  71. std::pair<int,SDL_Color> vinya2;
  72. int pom;
  73. is >> pom;
  74. vinya2.first=vinya.first=pom;
  75. is >> pom;
  76. vinya.second.r=pom;
  77. is >> pom;
  78. vinya.second.g=pom;
  79. is >> pom;
  80. vinya.second.b=pom;
  81. is >> pom;
  82. vinya2.second.r=pom;
  83. is >> pom;
  84. vinya2.second.g=pom;
  85. is >> pom;
  86. vinya2.second.b=pom;
  87. vinya.second.unused=vinya2.second.unused=255;
  88. colors.insert(vinya);
  89. colorsBlocked.insert(vinya2);
  90. }
  91. is.close();
  92. if (draw)
  93. redraw();
  94. }
  95. void CMinimap::draw()
  96. {
  97. //draw terrain
  98. blitAt(map[LOCPLINT->adventureInt->position.z],0,0,temps);
  99. //draw heroes
  100. std::vector <const CGHeroInstance *> hh = LOCPLINT->cb->getHeroesInfo(false);
  101. int mw = map[0]->w, mh = map[0]->h,
  102. wo = mw/CGI->mh->sizes.x, ho = mh/CGI->mh->sizes.y;
  103. for (int i=0; i<hh.size();i++)
  104. {
  105. int3 hpos = hh[i]->getPosition(false);
  106. if(hpos.z!=LOCPLINT->adventureInt->position.z)
  107. continue;
  108. //float zawx = ((float)hpos.x/CGI->mh->sizes.x), zawy = ((float)hpos.y/CGI->mh->sizes.y);
  109. int3 maplgp ( (hpos.x*mw)/CGI->mh->sizes.x, (hpos.y*mh)/CGI->mh->sizes.y, hpos.z );
  110. for (int ii=0; ii<wo; ii++)
  111. {
  112. for (int jj=0; jj<ho; jj++)
  113. {
  114. SDL_PutPixel(temps,maplgp.x+ii,maplgp.y+jj,graphics->playerColors[hh[i]->getOwner()].r,graphics->playerColors[hh[i]->getOwner()].g,graphics->playerColors[hh[i]->getOwner()].b);
  115. }
  116. }
  117. }
  118. blitAt(FoW[LOCPLINT->adventureInt->position.z],0,0,temps);
  119. //draw radar
  120. int bx = (((float)LOCPLINT->adventureInt->position.x)/(((float)CGI->mh->sizes.x)))*pos.w,
  121. by = (((float)LOCPLINT->adventureInt->position.y)/(((float)CGI->mh->sizes.y)))*pos.h;
  122. blitAt(radar,bx,by,temps);
  123. blitAt(temps,pos.x,pos.y);
  124. //SDL_UpdateRect(screen,pos.x,pos.y,pos.w,pos.h);
  125. }
  126. void CMinimap::redraw(int level)// (level==-1) => redraw all levels
  127. {
  128. (CGI);
  129. for (int i=0; i<CGI->mh->sizes.z; i++)
  130. {
  131. SDL_Surface * pom ;
  132. if ((level>=0) && (i!=level))
  133. continue;
  134. if (map.size()<i+1)
  135. pom = CSDL_Ext::newSurface(pos.w,pos.h,screen);
  136. else pom = map[i];
  137. for (int x=0;x<pos.w;x++)
  138. {
  139. for (int y=0;y<pos.h;y++)
  140. {
  141. int mx=(CGI->mh->sizes.x*x)/pos.w;
  142. int my=(CGI->mh->sizes.y*y)/pos.h;
  143. if (CGI->mh->ttiles[mx][my][i].tileInfo->blocked && (!CGI->mh->ttiles[mx][my][i].tileInfo->visitable))
  144. SDL_PutPixel(pom,x,y,colorsBlocked[CGI->mh->ttiles[mx][my][i].tileInfo->tertype].r,colorsBlocked[CGI->mh->ttiles[mx][my][i].tileInfo->tertype].g,colorsBlocked[CGI->mh->ttiles[mx][my][i].tileInfo->tertype].b);
  145. else SDL_PutPixel(pom,x,y,colors[CGI->mh->ttiles[mx][my][i].tileInfo->tertype].r,colors[CGI->mh->ttiles[mx][my][i].tileInfo->tertype].g,colors[CGI->mh->ttiles[mx][my][i].tileInfo->tertype].b);
  146. }
  147. }
  148. map.push_back(pom);
  149. }
  150. //FoW
  151. int mw = map[0]->w, mh = map[0]->h,
  152. wo = mw/CGI->mh->sizes.x, ho = mh/CGI->mh->sizes.y;
  153. for(int d=0; d<CGI->mh->map->twoLevel+1; ++d)
  154. {
  155. if(level>=0 && d!=level)
  156. continue;
  157. SDL_Surface * pt = CSDL_Ext::newSurface(pos.w, pos.h, CSDL_Ext::std32bppSurface);
  158. for (int i=0; i<mw; i++)
  159. {
  160. for (int j=0; j<mh; j++)
  161. {
  162. int3 pp( ((i*CGI->mh->sizes.x)/mw), ((j*CGI->mh->sizes.y)/mh), d );
  163. if ( !LOCPLINT->cb->isVisible(pp) )
  164. {
  165. CSDL_Ext::SDL_PutPixelWithoutRefresh(pt,i,j,0,0,0);
  166. }
  167. }
  168. }
  169. CSDL_Ext::update(pt);
  170. FoW.push_back(pt);
  171. }
  172. //FoW end
  173. }
  174. void CMinimap::updateRadar()
  175. {}
  176. void CMinimap::clickRight (tribool down)
  177. {
  178. LOCPLINT->adventureInt->handleRightClick(rcText,down,this);
  179. }
  180. void CMinimap::clickLeft (tribool down)
  181. {
  182. if (down && (!pressedL))
  183. MotionInterested::activate();
  184. else if (!down)
  185. {
  186. if (std::find(LOCPLINT->motioninterested.begin(),LOCPLINT->motioninterested.end(),this)!=LOCPLINT->motioninterested.end())
  187. MotionInterested::deactivate();
  188. }
  189. ClickableL::clickLeft(down);
  190. if (!((bool)down))
  191. return;
  192. float dx=((float)(LOCPLINT->current->motion.x-pos.x))/((float)pos.w),
  193. dy=((float)(LOCPLINT->current->motion.y-pos.y))/((float)pos.h);
  194. int3 newCPos;
  195. newCPos.x = (CGI->mh->sizes.x*dx);
  196. newCPos.y = (CGI->mh->sizes.y*dy);
  197. newCPos.z = LOCPLINT->adventureInt->position.z;
  198. LOCPLINT->adventureInt->centerOn(newCPos);
  199. }
  200. void CMinimap::hover (bool on)
  201. {
  202. Hoverable::hover(on);
  203. if (on)
  204. LOCPLINT->adventureInt->statusbar.print(statusbarTxt);
  205. else if (LOCPLINT->adventureInt->statusbar.current==statusbarTxt)
  206. LOCPLINT->adventureInt->statusbar.clear();
  207. }
  208. void CMinimap::mouseMoved (SDL_MouseMotionEvent & sEvent)
  209. {
  210. if (pressedL)
  211. {
  212. clickLeft(true);
  213. }
  214. }
  215. void CMinimap::activate()
  216. {
  217. ClickableL::activate();
  218. ClickableR::activate();
  219. Hoverable::activate();
  220. if (pressedL)
  221. MotionInterested::activate();
  222. }
  223. void CMinimap::deactivate()
  224. {
  225. if (pressedL)
  226. MotionInterested::deactivate();
  227. ClickableL::deactivate();
  228. ClickableR::deactivate();
  229. Hoverable::deactivate();
  230. }
  231. void CMinimap::showTile(int3 pos)
  232. {
  233. int mw = map[0]->w, mh = map[0]->h;
  234. double wo = ((double)mw)/CGI->mh->sizes.x, ho = ((double)mh)/CGI->mh->sizes.y;
  235. for (int ii=0; ii<wo; ii++)
  236. {
  237. for (int jj=0; jj<ho; jj++)
  238. {
  239. if ((pos.x*wo+ii<this->pos.w) && (pos.y*ho+jj<this->pos.h))
  240. CSDL_Ext::SDL_PutPixel(FoW[pos.z],pos.x*wo+ii,pos.y*ho+jj,0,0,0,0,0);
  241. }
  242. }
  243. }
  244. void CMinimap::hideTile(int3 pos)
  245. {
  246. }
  247. CTerrainRect::CTerrainRect():currentPath(NULL)
  248. {
  249. tilesw=19;
  250. tilesh=18;
  251. pos.x=7;
  252. pos.y=6;
  253. pos.w=593;
  254. pos.h=547;
  255. arrows = CDefHandler::giveDef("ADAG.DEF");
  256. for(int y=0; y<arrows->ourImages.size(); ++y)
  257. {
  258. arrows->ourImages[y].bitmap = CSDL_Ext::alphaTransform(arrows->ourImages[y].bitmap);
  259. }
  260. }
  261. void CTerrainRect::activate()
  262. {
  263. ClickableL::activate();
  264. ClickableR::activate();
  265. Hoverable::activate();
  266. KeyInterested::activate();
  267. MotionInterested::activate();
  268. };
  269. void CTerrainRect::deactivate()
  270. {
  271. ClickableL::deactivate();
  272. ClickableR::deactivate();
  273. Hoverable::deactivate();
  274. KeyInterested::deactivate();
  275. MotionInterested::deactivate();
  276. };
  277. void CTerrainRect::clickLeft(tribool down)
  278. {
  279. if ((down==false) || indeterminate(down))
  280. return;
  281. if (LOCPLINT->adventureInt->selection.type != HEROI_TYPE)
  282. {
  283. if (currentPath)
  284. {
  285. delete currentPath;
  286. currentPath = NULL;
  287. }
  288. return;
  289. }
  290. int3 mp = whichTileIsIt();
  291. if ((mp.x<0) || (mp.y<0))
  292. return;
  293. bool mres =true;
  294. if (currentPath)
  295. {
  296. if ( (currentPath->endPos()) == mp)
  297. { //move
  298. CPath sended(*currentPath); //temporary path - engine will operate on it
  299. LOCPLINT->pim->unlock();
  300. mres = LOCPLINT->cb->moveHero( ((const CGHeroInstance*)LOCPLINT->adventureInt->selection.selected)->type->ID,&sended,1,0);
  301. LOCPLINT->pim->lock();
  302. if(mres)
  303. {
  304. delete currentPath;
  305. currentPath = NULL;
  306. int i=0;
  307. for(;i<LOCPLINT->adventureInt->heroList.items.size();i++)
  308. {
  309. if(LOCPLINT->adventureInt->heroList.items[i].first->subID == ((const CGHeroInstance*)LOCPLINT->adventureInt->selection.selected)->type->ID)
  310. {
  311. LOCPLINT->adventureInt->heroList.items[i].second = NULL;
  312. break;
  313. }
  314. }
  315. }
  316. }
  317. else
  318. {
  319. delete currentPath;
  320. currentPath=NULL;
  321. }
  322. }
  323. const CGHeroInstance * currentHero = (LOCPLINT->adventureInt->heroList.items.size())?(LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].first):(NULL);
  324. if(!currentHero)
  325. return;
  326. int3 bufpos = currentHero->getPosition(false);
  327. //bufpos.x-=1;
  328. if (mres)
  329. {
  330. vector<Coordinate>* p;
  331. p = CGI->pathf->GetPath(Coordinate(bufpos),Coordinate(mp),currentHero);
  332. //Convert to old format.
  333. currentPath = LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].second = CGI->pathf->ConvertToOldFormat(p);
  334. delete p;
  335. //currentPath = LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].second = CGI->pathf->getPath(bufpos,mp,currentHero,1);
  336. }
  337. }
  338. void CTerrainRect::clickRight(tribool down)
  339. {
  340. }
  341. void CTerrainRect::mouseMoved (SDL_MouseMotionEvent & sEvent)
  342. {
  343. int3 pom=LOCPLINT->adventureInt->verifyPos(whichTileIsIt(sEvent.x,sEvent.y));
  344. if (pom!=curHoveredTile)
  345. curHoveredTile=pom;
  346. else
  347. return;
  348. std::vector<std::string> temp = LOCPLINT->cb->getObjDescriptions(pom);
  349. if (temp.size())
  350. {
  351. LOCPLINT->adventureInt->statusbar.print((*((temp.end())-1)));
  352. }
  353. else
  354. {
  355. LOCPLINT->adventureInt->statusbar.clear();
  356. }
  357. }
  358. void CTerrainRect::keyPressed (SDL_KeyboardEvent & key){}
  359. void CTerrainRect::hover(bool on)
  360. {
  361. if (!on)
  362. LOCPLINT->adventureInt->statusbar.clear();
  363. }
  364. void CTerrainRect::showPath()
  365. {
  366. for (int i=0;i<currentPath->nodes.size()-1;i++)
  367. {
  368. int pn=-1;//number of picture
  369. if (i==0) //last tile
  370. {
  371. int x = 32*(currentPath->nodes[i].coord.x-LOCPLINT->adventureInt->position.x)+7,
  372. y = 32*(currentPath->nodes[i].coord.y-LOCPLINT->adventureInt->position.y)+6;
  373. if (x<0 || y<0 || x>pos.w || y>pos.h)
  374. continue;
  375. pn=0;
  376. }
  377. else
  378. {
  379. std::vector<CPathNode> & cv = currentPath->nodes;
  380. if (cv[i+1].coord.x == cv[i].coord.x-1 && cv[i+1].coord.y == cv[i].coord.y-1)
  381. {
  382. if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y)
  383. {
  384. pn = 3;
  385. }
  386. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1)
  387. {
  388. pn = 12;
  389. }
  390. else if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y+1)
  391. {
  392. pn = 21;
  393. }
  394. else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1)
  395. {
  396. pn = 22;
  397. }
  398. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1)
  399. {
  400. pn = 2;
  401. }
  402. }
  403. else if (cv[i+1].coord.x == cv[i].coord.x && cv[i+1].coord.y == cv[i].coord.y-1)
  404. {
  405. if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1)
  406. {
  407. pn = 4;
  408. }
  409. else if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y+1)
  410. {
  411. pn = 13;
  412. }
  413. else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1)
  414. {
  415. pn = 22;
  416. }
  417. }
  418. else if (cv[i+1].coord.x == cv[i].coord.x+1 && cv[i+1].coord.y == cv[i].coord.y-1)
  419. {
  420. if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y+1)
  421. {
  422. pn = 5;
  423. }
  424. else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1)
  425. {
  426. pn = 14;
  427. }
  428. else if(cv[i-1].coord.x+1 == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y)
  429. {
  430. pn = 23;
  431. }
  432. else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1)
  433. {
  434. pn = 24;
  435. }
  436. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1)
  437. {
  438. pn = 4;
  439. }
  440. }
  441. else if (cv[i+1].coord.x == cv[i].coord.x+1 && cv[i+1].coord.y == cv[i].coord.y)
  442. {
  443. if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1)
  444. {
  445. pn = 6;
  446. }
  447. else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y)
  448. {
  449. pn = 15;
  450. }
  451. else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1)
  452. {
  453. pn = 24;
  454. }
  455. }
  456. else if (cv[i+1].coord.x == cv[i].coord.x+1 && cv[i+1].coord.y == cv[i].coord.y+1)
  457. {
  458. if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y)
  459. {
  460. pn = 7;
  461. }
  462. else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1)
  463. {
  464. pn = 16;
  465. }
  466. else if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y-1)
  467. {
  468. pn = 17;
  469. }
  470. else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1)
  471. {
  472. pn = 6;
  473. }
  474. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1)
  475. {
  476. pn = 18;
  477. }
  478. }
  479. else if (cv[i+1].coord.x == cv[i].coord.x && cv[i+1].coord.y == cv[i].coord.y+1)
  480. {
  481. if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1)
  482. {
  483. pn = 8;
  484. }
  485. else if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y-1)
  486. {
  487. pn = 9;
  488. }
  489. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1)
  490. {
  491. pn = 18;
  492. }
  493. }
  494. else if (cv[i+1].coord.x == cv[i].coord.x-1 && cv[i+1].coord.y == cv[i].coord.y+1)
  495. {
  496. if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y-1)
  497. {
  498. pn = 1;
  499. }
  500. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1)
  501. {
  502. pn = 10;
  503. }
  504. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y)
  505. {
  506. pn = 19;
  507. }
  508. else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1)
  509. {
  510. pn = 8;
  511. }
  512. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1)
  513. {
  514. pn = 20;
  515. }
  516. }
  517. else if (cv[i+1].coord.x == cv[i].coord.x-1 && cv[i+1].coord.y == cv[i].coord.y)
  518. {
  519. if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1)
  520. {
  521. pn = 2;
  522. }
  523. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y)
  524. {
  525. pn = 11;
  526. }
  527. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1)
  528. {
  529. pn = 20;
  530. }
  531. }
  532. }
  533. if ( ((currentPath->nodes[i].dist)-(*(currentPath->nodes.end()-1)).dist) > ((const CGHeroInstance*)(LOCPLINT->adventureInt->selection.selected))->movement)
  534. pn+=25;
  535. if (pn>=0)
  536. {
  537. int x = 32*(currentPath->nodes[i].coord.x-LOCPLINT->adventureInt->position.x)+7,
  538. y = 32*(currentPath->nodes[i].coord.y-LOCPLINT->adventureInt->position.y)+6;
  539. if (x<0 || y<0 || x>pos.w || y>pos.h)
  540. continue;
  541. int hvx = (x+arrows->ourImages[pn].bitmap->w)-(pos.x+pos.w),
  542. hvy = (y+arrows->ourImages[pn].bitmap->h)-(pos.y+pos.h);
  543. if (hvx<0 && hvy<0)
  544. {
  545. CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, NULL, screen, &genRect(32, 32, x, y));
  546. }
  547. else if(hvx<0)
  548. {
  549. CSDL_Ext::blit8bppAlphaTo24bpp
  550. (arrows->ourImages[pn].bitmap,&genRect(arrows->ourImages[pn].bitmap->h-hvy,arrows->ourImages[pn].bitmap->w,0,0),
  551. screen,&genRect(arrows->ourImages[pn].bitmap->h-hvy,arrows->ourImages[pn].bitmap->w,x,y));
  552. }
  553. else if (hvy<0)
  554. {
  555. CSDL_Ext::blit8bppAlphaTo24bpp
  556. (arrows->ourImages[pn].bitmap,&genRect(arrows->ourImages[pn].bitmap->h,arrows->ourImages[pn].bitmap->w-hvx,0,0),
  557. screen,&genRect(arrows->ourImages[pn].bitmap->h,arrows->ourImages[pn].bitmap->w-hvx,x,y));
  558. }
  559. else
  560. {
  561. CSDL_Ext::blit8bppAlphaTo24bpp
  562. (arrows->ourImages[pn].bitmap,&genRect(arrows->ourImages[pn].bitmap->h-hvy,arrows->ourImages[pn].bitmap->w-hvx,0,0),
  563. screen,&genRect(arrows->ourImages[pn].bitmap->h-hvy,arrows->ourImages[pn].bitmap->w-hvx,x,y));
  564. }
  565. }
  566. } //for (int i=0;i<currentPath->nodes.size()-1;i++)
  567. }
  568. void CTerrainRect::show()
  569. {
  570. SDL_Surface * teren = CGI->mh->terrainRect
  571. (LOCPLINT->adventureInt->position.x,LOCPLINT->adventureInt->position.y,
  572. tilesw,tilesh,LOCPLINT->adventureInt->position.z,LOCPLINT->adventureInt->anim,
  573. &LOCPLINT->cb->getVisibilityMap(), true, LOCPLINT->adventureInt->heroAnim,
  574. screen,&genRect(547,594,7,6)
  575. );
  576. //SDL_BlitSurface(teren,&genRect(pos.h,pos.w,0,0),screen,&genRect(547,594,7,6));
  577. //SDL_FreeSurface(teren);
  578. if (currentPath && LOCPLINT->adventureInt->position.z==currentPath->startPos().z) //drawing path
  579. {
  580. showPath();
  581. }
  582. }
  583. int3 CTerrainRect::whichTileIsIt(int x, int y)
  584. {
  585. int3 ret;
  586. ret.x = LOCPLINT->adventureInt->position.x + ((LOCPLINT->current->motion.x-pos.x)/32);
  587. ret.y = LOCPLINT->adventureInt->position.y + ((LOCPLINT->current->motion.y-pos.y)/32);
  588. ret.z = LOCPLINT->adventureInt->position.z;
  589. return ret;
  590. }
  591. int3 CTerrainRect::whichTileIsIt()
  592. {
  593. return whichTileIsIt(LOCPLINT->current->motion.x,LOCPLINT->current->motion.y);
  594. }
  595. void CResDataBar::clickRight (tribool down)
  596. {
  597. }
  598. void CResDataBar::activate()
  599. {
  600. ClickableR::activate();
  601. }
  602. void CResDataBar::deactivate()
  603. {
  604. ClickableR::deactivate();
  605. }
  606. CResDataBar::CResDataBar()
  607. {
  608. bg = BitmapHandler::loadBitmap("ZRESBAR.bmp");
  609. SDL_SetColorKey(bg,SDL_SRCCOLORKEY,SDL_MapRGB(bg->format,0,255,255));
  610. graphics->blueToPlayersAdv(bg,LOCPLINT->playerID);
  611. pos = genRect(bg->h,bg->w,3,575);
  612. txtpos += (std::pair<int,int>(35,577)),(std::pair<int,int>(120,577)),(std::pair<int,int>(205,577)),
  613. (std::pair<int,int>(290,577)),(std::pair<int,int>(375,577)),(std::pair<int,int>(460,577)),
  614. (std::pair<int,int>(545,577)),(std::pair<int,int>(620,577));
  615. datetext = CGI->generaltexth->allTexts[62]+": %s, " + CGI->generaltexth->allTexts[63] + ": %s, " +
  616. CGI->generaltexth->allTexts[64] + ": %s";
  617. }
  618. CResDataBar::~CResDataBar()
  619. {
  620. SDL_FreeSurface(bg);
  621. }
  622. void CResDataBar::draw()
  623. {
  624. blitAt(bg,pos.x,pos.y);
  625. char * buf = new char[15];
  626. for (int i=0;i<7;i++)
  627. {
  628. SDL_itoa(LOCPLINT->cb->getResourceAmount(i),buf,10);
  629. printAt(buf,txtpos[i].first,txtpos[i].second,GEOR13,zwykly);
  630. }
  631. std::vector<std::string> temp;
  632. SDL_itoa(LOCPLINT->cb->getDate(3),buf,10); temp+=std::string(buf);
  633. SDL_itoa(LOCPLINT->cb->getDate(2),buf,10); temp+=std::string(buf);
  634. SDL_itoa(LOCPLINT->cb->getDate(1),buf,10); temp+=std::string(buf);
  635. printAt(processStr(datetext,temp),txtpos[7].first,txtpos[7].second,GEOR13,zwykly);
  636. temp.clear();
  637. //updateRect(&pos,screen);
  638. delete[] buf;
  639. }
  640. CInfoBar::CInfoBar()
  641. {
  642. toNextTick = mode = pom = -1;
  643. pos.x=605;
  644. pos.y=389;
  645. pos.w=194;
  646. pos.h=186;
  647. day = CDefHandler::giveDef("NEWDAY.DEF");
  648. week1 = CDefHandler::giveDef("NEWWEEK1.DEF");
  649. week2 = CDefHandler::giveDef("NEWWEEK2.DEF");
  650. week3 = CDefHandler::giveDef("NEWWEEK3.DEF");
  651. week4 = CDefHandler::giveDef("NEWWEEK4.DEF");
  652. }
  653. CInfoBar::~CInfoBar()
  654. {
  655. delete day;
  656. delete week1;
  657. delete week2;
  658. delete week3;
  659. delete week4;
  660. }
  661. void CInfoBar::draw(const CGObjectInstance * specific)
  662. {
  663. if ((mode>=0) && mode<5)
  664. {
  665. blitAnim(mode);
  666. return;
  667. }
  668. else if (mode==5)
  669. {
  670. mode = -1;
  671. if(!LOCPLINT->adventureInt->selection.selected)
  672. {
  673. if (LOCPLINT->adventureInt->heroList.items.size())
  674. {
  675. LOCPLINT->adventureInt->heroList.select(0);
  676. }
  677. }
  678. draw((const CGObjectInstance *)LOCPLINT->adventureInt->selection.selected);
  679. }
  680. if (!specific)
  681. specific = (const CGObjectInstance *)LOCPLINT->adventureInt->selection.selected;
  682. //TODO: to rzutowanie wyglada groznie, ale dziala. Ale nie powinno wygladac groznie.
  683. if(!specific)
  684. return;
  685. if(specific->ID == 34) //hero
  686. {
  687. if(graphics->heroWins.find(specific->subID)!=graphics->heroWins.end())
  688. blitAt(graphics->heroWins[specific->subID],pos.x,pos.y);
  689. }
  690. else if (specific->ID == 98)
  691. {
  692. const CGTownInstance * t = static_cast<const CGTownInstance*>(specific);
  693. if(graphics->townWins.find(t->id)!=graphics->townWins.end())
  694. blitAt(graphics->townWins[t->id],pos.x,pos.y);
  695. }
  696. //SDL_Surface * todr = LOCPLINT->infoWin(specific);
  697. //if (!todr)
  698. // return;
  699. //blitAt(todr,pos.x,pos.y);
  700. //SDL_FreeSurface(todr);
  701. }
  702. CDefHandler * CInfoBar::getAnim(int mode)
  703. {
  704. switch(mode)
  705. {
  706. case 0:
  707. return day;
  708. break;
  709. case 1:
  710. return week1;
  711. break;
  712. case 2:
  713. return week2;
  714. break;
  715. case 3:
  716. return week3;
  717. break;
  718. case 4:
  719. return week4;
  720. break;
  721. default:
  722. return NULL;
  723. break;
  724. }
  725. }
  726. void CInfoBar::blitAnim(int mode)//0 - day, 1 - week
  727. {
  728. CDefHandler * anim = NULL;
  729. std::stringstream txt;
  730. anim = getAnim(mode);
  731. if(mode) //new week animation
  732. {
  733. txt << CGI->generaltexth->allTexts[63] << " " << LOCPLINT->cb->getDate(2);
  734. }
  735. else //new day
  736. {
  737. txt << CGI->generaltexth->allTexts[64] << " " << LOCPLINT->cb->getDate(1);
  738. }
  739. blitAt(anim->ourImages[pom].bitmap,pos.x+9,pos.y+10);
  740. printAtMiddle(txt.str(),700,420,TNRB16,zwykly);
  741. if (pom == anim->ourImages.size()-1)
  742. toNextTick+=750;
  743. }
  744. void CInfoBar::newDay(int Day)
  745. {
  746. if(LOCPLINT->cb->getDate(1) != 1)
  747. {
  748. mode = 0; //showing day
  749. }
  750. else
  751. {
  752. switch(LOCPLINT->cb->getDate(2))
  753. {
  754. case 1:
  755. mode = 1;
  756. break;
  757. case 2:
  758. mode = 2;
  759. break;
  760. case 3:
  761. mode = 3;
  762. break;
  763. case 4:
  764. mode = 4;
  765. break;
  766. default:
  767. mode = -1;
  768. break;
  769. }
  770. }
  771. pom = 0;
  772. TimeInterested::activate();
  773. toNextTick = 500;
  774. blitAnim(mode);
  775. //blitAt(day->ourImages[pom].bitmap,pos.x+10,pos.y+10);
  776. }
  777. void CInfoBar::showComp(SComponent * comp, int time)
  778. {
  779. SDL_Surface * b = BitmapHandler::loadBitmap("ADSTATOT.bmp");
  780. blitAt(b,pos.x+8,pos.y+11);
  781. blitAt(comp->getImg(),pos.x+52,pos.y+54);
  782. printAtMiddle(comp->subtitle,pos.x+91,pos.y+158,GEOR13,zwykly);
  783. printAtMiddleWB(comp->description,pos.x+94,pos.y+31,GEOR13,26,zwykly);
  784. SDL_FreeSurface(b);
  785. TimeInterested::activate();
  786. mode = 6;
  787. toNextTick = time;
  788. }
  789. void CInfoBar::tick()
  790. {
  791. if((mode >= 0) && (mode < 5))
  792. {
  793. pom++;
  794. if (pom >= getAnim(mode)->ourImages.size())
  795. {
  796. TimeInterested::deactivate();
  797. toNextTick = -1;
  798. mode = 5;
  799. draw();
  800. return;
  801. }
  802. toNextTick = 150;
  803. blitAnim(mode);
  804. }
  805. else if (mode == 6)
  806. {
  807. TimeInterested::deactivate();
  808. toNextTick = -1;
  809. mode = 5;
  810. draw();
  811. }
  812. }
  813. CAdvMapInt::CAdvMapInt(int Player)
  814. :player(Player),
  815. statusbar(7,556),
  816. kingOverview(CGI->preth->zelp[293].first,CGI->preth->zelp[293].second,
  817. boost::bind(&CAdvMapInt::fshowOverview,this), 679, 196, "IAM002.DEF", false,NULL,true),
  818. underground(CGI->preth->zelp[294].first,CGI->preth->zelp[294].second,
  819. boost::bind(&CAdvMapInt::fswitchLevel,this), 711, 196, "IAM010.DEF", false, new std::vector<std::string>(1,std::string("IAM003.DEF")),true),
  820. questlog(CGI->preth->zelp[295].first,CGI->preth->zelp[295].second,
  821. boost::bind(&CAdvMapInt::fshowQuestlog,this), 679, 228, "IAM004.DEF", false,NULL,true),
  822. sleepWake(CGI->preth->zelp[296].first,CGI->preth->zelp[296].second,
  823. boost::bind(&CAdvMapInt::fsleepWake,this), 711, 228, "IAM005.DEF", false,NULL,true),
  824. moveHero(CGI->preth->zelp[297].first,CGI->preth->zelp[297].second,
  825. boost::bind(&CAdvMapInt::fmoveHero,this), 679, 260, "IAM006.DEF", false,NULL,true),
  826. spellbook(CGI->preth->zelp[298].first,CGI->preth->zelp[298].second,
  827. boost::bind(&CAdvMapInt::fshowSpellbok,this), 711, 260, "IAM007.DEF", false,NULL,true),
  828. advOptions(CGI->preth->zelp[299].first,CGI->preth->zelp[299].second,
  829. boost::bind(&CAdvMapInt::fadventureOPtions,this), 679, 292, "IAM008.DEF", false,NULL,true),
  830. sysOptions(CGI->preth->zelp[300].first,CGI->preth->zelp[300].second,
  831. boost::bind(&CAdvMapInt::fsystemOptions,this), 711, 292, "IAM009.DEF", false,NULL,true),
  832. nextHero(CGI->preth->zelp[301].first,CGI->preth->zelp[301].second,
  833. boost::bind(&CAdvMapInt::fnextHero,this), 679, 324, "IAM000.DEF", false,NULL,true),
  834. endTurn(CGI->preth->zelp[302].first,CGI->preth->zelp[302].second,
  835. boost::bind(&CAdvMapInt::fendTurn,this), 679, 356, "IAM001.DEF", false,NULL,true),
  836. townList(5,&genRect(192,48,747,196),747,196,747,372)
  837. {
  838. townList.fun = boost::bind(&CAdvMapInt::selectionChanged,this);
  839. LOCPLINT->adventureInt=this;
  840. bg = BitmapHandler::loadBitmap("ADVMAP.bmp");
  841. graphics->blueToPlayersAdv(bg,player);
  842. scrollingLeft = false;
  843. scrollingRight = false;
  844. scrollingUp = false ;
  845. scrollingDown = false ;
  846. updateScreen = false;
  847. anim=0;
  848. animValHitCount=0; //animation frame
  849. heroAnim=0;
  850. heroAnimValHitCount=0; // hero animation frame
  851. heroList.init();
  852. heroList.genList();
  853. //townList.init();
  854. townList.genList();
  855. heroWindow = new CHeroWindow(this->player);
  856. gems.push_back(CDefHandler::giveDef("agemLL.def"));
  857. gems.push_back(CDefHandler::giveDef("agemLR.def"));
  858. gems.push_back(CDefHandler::giveDef("agemUL.def"));
  859. gems.push_back(CDefHandler::giveDef("agemUR.def"));
  860. }
  861. void CAdvMapInt::fshowOverview()
  862. {
  863. }
  864. void CAdvMapInt::fswitchLevel()
  865. {
  866. if(!CGI->mh->map->twoLevel)
  867. return;
  868. if (position.z)
  869. {
  870. position.z--;
  871. underground.curimg=0;
  872. underground.show();
  873. }
  874. else
  875. {
  876. underground.curimg=1;
  877. position.z++;
  878. underground.show();
  879. }
  880. updateScreen = true;
  881. minimap.draw();
  882. }
  883. void CAdvMapInt::fshowQuestlog()
  884. {
  885. }
  886. void CAdvMapInt::fsleepWake()
  887. {
  888. }
  889. void CAdvMapInt::fmoveHero()
  890. {
  891. if (selection.type!=HEROI_TYPE)
  892. return;
  893. if (!terrain.currentPath)
  894. return;
  895. CPath sended(*(terrain.currentPath)); //temporary path - engine will operate on it
  896. LOCPLINT->cb->moveHero( ((const CGHeroInstance*)LOCPLINT->adventureInt->selection.selected)->type->ID,&sended,1,0);
  897. }
  898. void CAdvMapInt::fshowSpellbok()
  899. {
  900. }
  901. void CAdvMapInt::fadventureOPtions()
  902. {
  903. }
  904. void CAdvMapInt::fsystemOptions()
  905. {
  906. }
  907. void CAdvMapInt::fnextHero()
  908. {
  909. }
  910. void CAdvMapInt::fendTurn()
  911. {
  912. LOCPLINT->makingTurn = false;
  913. }
  914. void CAdvMapInt::activate()
  915. {
  916. if(subInt == heroWindow)
  917. {
  918. heroWindow->activate();
  919. return;
  920. }
  921. LOCPLINT->curint = this;
  922. LOCPLINT->statusbar = &statusbar;
  923. kingOverview.activate();
  924. underground.activate();
  925. questlog.activate();
  926. sleepWake.activate();
  927. moveHero.activate();
  928. spellbook.activate();
  929. sysOptions.activate();
  930. advOptions.activate();
  931. nextHero.activate();
  932. endTurn.activate();
  933. minimap.activate();
  934. heroList.activate();
  935. townList.activate();
  936. terrain.activate();
  937. show();
  938. }
  939. void CAdvMapInt::deactivate()
  940. {
  941. if(subInt == heroWindow)
  942. {
  943. heroWindow->deactivate();
  944. return;
  945. }
  946. hide();
  947. }
  948. void CAdvMapInt::show(SDL_Surface *to)
  949. {
  950. blitAt(bg,0,0);
  951. kingOverview.show();
  952. underground.show();
  953. questlog.show();
  954. sleepWake.show();
  955. moveHero.show();
  956. spellbook.show();
  957. advOptions.show();
  958. sysOptions.show();
  959. nextHero.show();
  960. endTurn.show();
  961. minimap.draw();
  962. heroList.draw();
  963. townList.draw();
  964. update();
  965. resdatabar.draw();
  966. statusbar.show();
  967. infoBar.draw();
  968. CSDL_Ext::update(screen);
  969. }
  970. void CAdvMapInt::hide()
  971. {
  972. kingOverview.deactivate();
  973. underground.deactivate();
  974. questlog.deactivate();
  975. sleepWake.deactivate();
  976. moveHero.deactivate();
  977. spellbook.deactivate();
  978. advOptions.deactivate();
  979. sysOptions.deactivate();
  980. nextHero.deactivate();
  981. endTurn.deactivate();
  982. minimap.deactivate();
  983. heroList.deactivate();
  984. townList.deactivate();
  985. terrain.deactivate();
  986. if(std::find(LOCPLINT->timeinterested.begin(),LOCPLINT->timeinterested.end(),&infoBar)!=LOCPLINT->timeinterested.end())
  987. LOCPLINT->timeinterested.erase(std::find(LOCPLINT->timeinterested.begin(),LOCPLINT->timeinterested.end(),&infoBar));
  988. infoBar.mode=-1;
  989. }
  990. void CAdvMapInt::update()
  991. {
  992. terrain.show();
  993. blitAt(gems[2]->ourImages[LOCPLINT->playerID].bitmap,6,6);
  994. blitAt(gems[0]->ourImages[LOCPLINT->playerID].bitmap,6,508);
  995. blitAt(gems[1]->ourImages[LOCPLINT->playerID].bitmap,556,508);
  996. blitAt(gems[3]->ourImages[LOCPLINT->playerID].bitmap,556,6);
  997. //updateRect(&genRect(550,600,6,6));
  998. }
  999. void CAdvMapInt::selectionChanged()
  1000. {
  1001. const CGTownInstance *to = townList.items[townList.selected];
  1002. centerOn(to->pos);
  1003. selection.type = TOWNI_TYPE;
  1004. selection.selected = to;
  1005. terrain.currentPath = NULL;
  1006. townList.draw();
  1007. heroList.draw();
  1008. infoBar.draw(NULL);
  1009. }
  1010. void CAdvMapInt::centerOn(int3 on)
  1011. {
  1012. on.x -= (LOCPLINT->adventureInt->terrain.tilesw/2);
  1013. on.y -= (LOCPLINT->adventureInt->terrain.tilesh/2);
  1014. if (on.x<0)
  1015. on.x=-(Woff/2);
  1016. else if((on.x+LOCPLINT->adventureInt->terrain.tilesw) > (CGI->mh->sizes.x))
  1017. on.x=CGI->mh->sizes.x-LOCPLINT->adventureInt->terrain.tilesw+(Woff/2);
  1018. if (on.y<0)
  1019. on.y = -(Hoff/2);
  1020. else if((on.y+LOCPLINT->adventureInt->terrain.tilesh) > (CGI->mh->sizes.y))
  1021. on.y = CGI->mh->sizes.y-LOCPLINT->adventureInt->terrain.tilesh+(Hoff/2);
  1022. LOCPLINT->adventureInt->position.x=on.x;
  1023. LOCPLINT->adventureInt->position.y=on.y;
  1024. LOCPLINT->adventureInt->position.z=on.z;
  1025. LOCPLINT->adventureInt->updateScreen=true;
  1026. updateMinimap=true;
  1027. }
  1028. CAdvMapInt::CurrentSelection::CurrentSelection()
  1029. {
  1030. type=-1;
  1031. selected=NULL;
  1032. }
  1033. void CAdvMapInt::handleRightClick(std::string text, tribool down, CIntObject * client)
  1034. {
  1035. if (down)
  1036. {
  1037. boost::algorithm::erase_all(text,"\"");
  1038. CSimpleWindow * temp = CMessage::genWindow(text,LOCPLINT->playerID);
  1039. temp->pos.x=300-(temp->pos.w/2);
  1040. temp->pos.y=300-(temp->pos.h/2);
  1041. temp->owner = client;
  1042. LOCPLINT->objsToBlit.push_back(temp);
  1043. }
  1044. else
  1045. {
  1046. for (int i=0;i<LOCPLINT->objsToBlit.size();i++)
  1047. {
  1048. //TODO: pewnie da sie to zrobic lepiej, ale nie chce mi sie. Wolajacy obiekt powinien informowac kogo spodziewa sie odwolac (null jesli down)
  1049. CSimpleWindow * pom = dynamic_cast<CSimpleWindow*>(LOCPLINT->objsToBlit[i]);
  1050. if (!pom)
  1051. continue;
  1052. if (pom->owner==client)
  1053. {
  1054. LOCPLINT->objsToBlit.erase(LOCPLINT->objsToBlit.begin()+(i));
  1055. delete pom;
  1056. if((LOCPLINT->curint == LOCPLINT->castleInt) && !LOCPLINT->castleInt->subInt)
  1057. LOCPLINT->castleInt->showAll(0,true);
  1058. }
  1059. }
  1060. }
  1061. }
  1062. int3 CAdvMapInt::verifyPos(int3 ver)
  1063. {
  1064. if (ver.x<0)
  1065. ver.x=0;
  1066. if (ver.y<0)
  1067. ver.y=0;
  1068. if (ver.z<0)
  1069. ver.z=0;
  1070. if (ver.x>=CGI->mh->sizes.x)
  1071. ver.x=CGI->mh->sizes.x-1;
  1072. if (ver.y>=CGI->mh->sizes.y)
  1073. ver.y=CGI->mh->sizes.y-1;
  1074. if (ver.z>=CGI->mh->sizes.z)
  1075. ver.z=CGI->mh->sizes.z-1;
  1076. return ver;
  1077. }