inline void JPSPlus::ExploreFromParentLeft(PathfindingNode * currentNode, DistantJumpPoints * distantJumpPoints) { if (distantJumpPoints->jumpDistance[Up] != 0) SearchUp(currentNode, distantJumpPoints->jumpDistance[Up]); if (distantJumpPoints->jumpDistance[UpLeft] != 0) SearchUpLeft(currentNode, distantJumpPoints->jumpDistance[UpLeft]); if (distantJumpPoints->jumpDistance[Left] != 0) SearchLeft(currentNode, distantJumpPoints->jumpDistance[Left]); if (distantJumpPoints->jumpDistance[DownLeft] != 0) SearchDownLeft(currentNode, distantJumpPoints->jumpDistance[DownLeft]); if (distantJumpPoints->jumpDistance[Down] != 0) SearchDown(currentNode, distantJumpPoints->jumpDistance[Down]); }
inline void JPSPlus::ExploreFromParentAllDirections(PathfindingNode * currentNode, DistantJumpPoints * distantJumpPoints) { SearchDown(currentNode, distantJumpPoints->jumpDistance[Down]); SearchDownRight(currentNode, distantJumpPoints->jumpDistance[DownRight]); SearchRight(currentNode, distantJumpPoints->jumpDistance[Right]); SearchUpRight(currentNode, distantJumpPoints->jumpDistance[UpRight]); SearchUp(currentNode, distantJumpPoints->jumpDistance[Up]); SearchUpLeft(currentNode, distantJumpPoints->jumpDistance[UpLeft]); SearchLeft(currentNode, distantJumpPoints->jumpDistance[Left]); SearchDownLeft(currentNode, distantJumpPoints->jumpDistance[DownLeft]); }
// Hleda vsechny predky (Pro vypocet hodnot do matice) void CKerNamesMain::SearchUp(CKerName *n, char * Matrix) { // +2 CKerNameList *p= n->parents; int mp; while (p) { mp = p->name->MatrixPos; if (Matrix[mp]==0||Matrix[mp]==1) { if (Matrix[mp]==1) { if (KerMain) KerMain->Errors->LogError(eKRTEcyclusInKSID,0,p->name->GetNameString()); NameInCycle = p->name; } Matrix[mp]+=2; SearchUp(p->name,Matrix); } p=p->next; } }
// Vytvori Matici // Matice = Pole o velikosti MatrixSize (=Numbers+1) pointeru na ruzne velka pole charu // Slouzi k rychlemu porovnani dvou jmen // Kdyz jsou jmena ve stejnych komponentach, tak informace o jejich vztahu bude v // Matrix[jm1->numer][jm2->MatrixPos]. Viz Funkce Compare void CKerNamesMain::CreateMatrix() { int f; CKerNameList *p; CKerName *root; int size; ClearMatrix(); MatrixSize=Numbers+1; // vytvorim prvni rozmer matice Matrix = new char*[MatrixSize]; for (f=0;f<MatrixSize;f++) Matrix[f]=0; // Smazu informaci o komponente u vsech jmen p=Names; while (p) { p->name->Component=0; p=p->next; } p=Names; // pro vsechny jmena while (p) { root = p->name; if (root->Component==0) { // jmeno dosud nebylo v zadne komponente. Najdu tuto komponenu. // spocitam jeji velikost, jmenum priradim poradova cisla a pridam je do komponenty size = 0; FindComponent(root,root,size); root->matrixsize=size; // nastavim velikost komponenty } else size = root->Component->matrixsize; // prectu si velikost komponenty Matrix[root->number] = new char[size]; // pridam sloupec do matice for (f=0;f<size;f++) Matrix[root->number][f] = 0; SearchDown(root,Matrix[root->number]); SearchUp(root,Matrix[root->number]); // a spocitam jeho hodnoty p=p->next; } MatrixesCalculated = 1; FindMethodsAndParams(); }
inline void JPSPlus::ExploreFromParentUpRight(PathfindingNode * currentNode, DistantJumpPoints * distantJumpPoints) { if (distantJumpPoints->jumpDistance[Right] != 0) SearchRight(currentNode, distantJumpPoints->jumpDistance[Right]); if (distantJumpPoints->jumpDistance[UpRight] != 0) SearchUpRight(currentNode, distantJumpPoints->jumpDistance[UpRight]); if (distantJumpPoints->jumpDistance[Up] != 0) SearchUp(currentNode, distantJumpPoints->jumpDistance[Up]); }