/****************************************************************************** @file /common/uComputeBorders.h @brief Zdrojovy kod pro zaplavovy vypocet uzemi. @author PZ @version 0.1 ******************************************************************************/ #include "uComputeBorders.h" using namespace std; bool validCoordinates(int x, int y) { if (((x>=0) && (x=0) && (y chooseNeighbours(int sourX,int sourY) { list rnl; THexOwnership tempsou; tempsou.x=sourX; tempsou.y=sourY+2; if (validCoordinates(tempsou.x,tempsou.y)) { rnl.push_front(tempsou); } tempsou.y-=4; if (validCoordinates(tempsou.x,tempsou.y)) { rnl.push_front(tempsou); } tempsou.y++; if (sourY%2) tempsou.x--; if (validCoordinates(tempsou.x,tempsou.y)) { rnl.push_front(tempsou); } tempsou.x++; if (validCoordinates(tempsou.x,tempsou.y)) { rnl.push_front(tempsou); } tempsou.y+=2; if (validCoordinates(tempsou.x,tempsou.y)) { rnl.push_front(tempsou); } tempsou.x--; if (validCoordinates(tempsou.x,tempsou.y)) { rnl.push_front(tempsou); } return rnl; } void computeBorders(int* entityMask,int height,int width,int entitiesnum,THexOwnership* centers,bool CanHaveSameCenterEntityNumber) throw (E_8K_Editor_InvalidCenters) { mapHeight=height; mapWidth=width; // check validity of kingdom centers int i,j; for(i=0;i HOQueue; HOQueue.clear(); for(i=0;i NeighboursList; NeighboursList.clear(); while (!HOQueue.empty()) { tho=HOQueue.front(); NeighboursList.clear(); NeighboursList=chooseNeighbours(tho.x,tho.y); while (!NeighboursList.empty()) { thonb=NeighboursList.front(); if (entityMask[thonb.x + thonb.y*width]==-1) { tho.x=thonb.x; tho.y=thonb.y; entityMask[tho.x + tho.y*width]=tho.entityNumber; HOQueue.push_back(tho); } NeighboursList.pop_front(); } HOQueue.pop_front(); } }