OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4PathFinderRay Class Reference
Collaboration diagram for C4PathFinderRay:
[legend]

Public Member Functions

 C4PathFinderRay ()
 
 ~C4PathFinderRay ()
 
void Clear ()
 
void Default ()
 

Protected Member Functions

void SetCompletePath ()
 
void TurnAttach (int32_t &rAttach, int32_t iDirection)
 
void CrawlToAttach (int32_t &rX, int32_t &rY, int32_t iAttach)
 
void CrawlByAttach (int32_t &rX, int32_t &rY, int32_t iAttach, int32_t iDirection)
 
void Draw (C4TargetFacet &cgo)
 
int32_t FindCrawlAttachDiagonal (int32_t iX, int32_t iY, int32_t iDirection)
 
int32_t FindCrawlAttach (int32_t iX, int32_t iY)
 
bool IsCrawlAttach (int32_t iX, int32_t iY, int32_t iAttach)
 
bool CheckBackRayShorten ()
 
bool Execute ()
 
bool CrawlTargetFree (int32_t iX, int32_t iY, int32_t iAttach, int32_t iDirection)
 
bool PointFree (int32_t iX, int32_t iY)
 
bool Crawl ()
 
bool PathFree (int32_t &rX, int32_t &rY, int32_t iToX, int32_t iToY, C4TransferZone **ppZone=nullptr)
 

Protected Attributes

int32_t Status
 
int32_t X
 
int32_t Y
 
int32_t X2
 
int32_t Y2
 
int32_t TargetX
 
int32_t TargetY
 
int32_t CrawlStartX
 
int32_t CrawlStartY
 
int32_t CrawlAttach
 
int32_t CrawlLength
 
int32_t CrawlStartAttach
 
int32_t Direction
 
int32_t Depth
 
C4TransferZoneUseZone
 
C4PathFinderRayFrom
 
C4PathFinderRayNext
 
C4PathFinderpPathFinder
 

Friends

class C4PathFinder
 

Detailed Description

Definition at line 74 of file C4PathFinder.cpp.

Constructor & Destructor Documentation

C4PathFinderRay::C4PathFinderRay ( )

Definition at line 109 of file C4PathFinder.cpp.

References Default().

110 {
111  Default();
112 }

Here is the call graph for this function:

C4PathFinderRay::~C4PathFinderRay ( )

Definition at line 114 of file C4PathFinder.cpp.

References Clear().

115 {
116  Clear();
117 }

Here is the call graph for this function:

Member Function Documentation

bool C4PathFinderRay::CheckBackRayShorten ( )
protected

Definition at line 508 of file C4PathFinder.cpp.

References C4PF_Ray_Deleted, From, PathFree(), Status, UseZone, X, X2, Y, and Y2.

Referenced by SetCompletePath().

509 {
510  C4PathFinderRay *pRay,*pRay2;
511  int32_t iX,iY;
512  for (pRay=From; pRay; pRay=pRay->From)
513  {
514  // Don't shorten transfer over zones
515  if (pRay->UseZone) return false;
516  // Skip self
517  if (pRay==From) continue;
518  // Check shortcut
519  iX=X; iY=Y;
520  if (PathFree(iX,iY,pRay->X,pRay->Y))
521  {
522  // Delete jumped rays
523  for (pRay2=From; pRay2!=pRay; pRay2=pRay2->From)
524  pRay2->Status=C4PF_Ray_Deleted;
525  // Shorten pRay to this
526  pRay->X2=X; pRay->Y2=Y;
527  From=pRay;
528  // Success
529  return true;
530  }
531  }
532  return false;
533 }
bool PathFree(int32_t &rX, int32_t &rY, int32_t iToX, int32_t iToY, C4TransferZone **ppZone=nullptr)
const int32_t C4PF_Ray_Deleted
C4TransferZone * UseZone
C4PathFinderRay * From

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PathFinderRay::Clear ( )

Definition at line 132 of file C4PathFinder.cpp.

Referenced by ~C4PathFinderRay().

133 {
134 
135 }

Here is the caller graph for this function:

bool C4PathFinderRay::Crawl ( )
protected

Definition at line 366 of file C4PathFinder.cpp.

References CrawlAttach, CrawlByAttach(), CrawlLength, CrawlTargetFree(), CrawlToAttach(), Direction, IsCrawlAttach(), TurnAttach(), X2, and Y2.

Referenced by Execute().

367 {
368 
369  // No attach: crawl failure (shouldn't ever get here)
370  if (!CrawlAttach)
371  return false;
372 
373  // Last attach lost (don't check on first crawl for that might be a diagonal attach)
374  if (CrawlLength)
376  {
377  // Crawl corner by last attach
380  // Safety: new attach not found - unexpected failure
382  return false;
383  // Corner okay
384  return true;
385  }
386 
387  // Check crawl target by attach
388  int32_t iTurned=0;
390  {
391  // Crawl target not free: turn attach
392  TurnAttach(CrawlAttach,Direction); iTurned++;
393  // Turned four times: all enclosed, crawl failure
394  if (iTurned==4)
395  return false;
396  }
397 
398  // Crawl by attach
400 
401  // Success
402  return true;
403 
404 }
void CrawlToAttach(int32_t &rX, int32_t &rY, int32_t iAttach)
void TurnAttach(int32_t &rAttach, int32_t iDirection)
bool CrawlTargetFree(int32_t iX, int32_t iY, int32_t iAttach, int32_t iDirection)
void CrawlByAttach(int32_t &rX, int32_t &rY, int32_t iAttach, int32_t iDirection)
bool IsCrawlAttach(int32_t iX, int32_t iY, int32_t iAttach)

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PathFinderRay::CrawlByAttach ( int32_t &  rX,
int32_t &  rY,
int32_t  iAttach,
int32_t  iDirection 
)
protected

Definition at line 435 of file C4PathFinder.cpp.

References C4PF_Crawl_Bottom, C4PF_Crawl_Left, C4PF_Crawl_Right, and C4PF_Crawl_Top.

Referenced by Crawl(), and CrawlTargetFree().

436 {
437  switch (iAttach)
438  {
439  case C4PF_Crawl_Top: rX+=iDirection; break;
440  case C4PF_Crawl_Bottom: rX-=iDirection; break;
441  case C4PF_Crawl_Left: rY-=iDirection; break;
442  case C4PF_Crawl_Right: rY+=iDirection; break;
443  }
444 }
const int32_t C4PF_Crawl_Top
const int32_t C4PF_Crawl_Right
const int32_t C4PF_Crawl_Left
const int32_t C4PF_Crawl_Bottom

Here is the caller graph for this function:

bool C4PathFinderRay::CrawlTargetFree ( int32_t  iX,
int32_t  iY,
int32_t  iAttach,
int32_t  iDirection 
)
protected

Definition at line 429 of file C4PathFinder.cpp.

References CrawlByAttach(), and PointFree().

Referenced by Crawl().

430 {
431  CrawlByAttach(iX,iY,iAttach,iDirection);
432  return PointFree(iX,iY);
433 }
bool PointFree(int32_t iX, int32_t iY)
void CrawlByAttach(int32_t &rX, int32_t &rY, int32_t iAttach, int32_t iDirection)

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PathFinderRay::CrawlToAttach ( int32_t &  rX,
int32_t &  rY,
int32_t  iAttach 
)
protected

Definition at line 462 of file C4PathFinder.cpp.

References C4PF_Crawl_Bottom, C4PF_Crawl_Left, C4PF_Crawl_Right, and C4PF_Crawl_Top.

Referenced by Crawl(), Draw(), and IsCrawlAttach().

463 {
464  switch (iAttach)
465  {
466  case C4PF_Crawl_Top: rY--; break;
467  case C4PF_Crawl_Bottom: rY++; break;
468  case C4PF_Crawl_Left: rX--; break;
469  case C4PF_Crawl_Right: rX++; break;
470  }
471 }
const int32_t C4PF_Crawl_Top
const int32_t C4PF_Crawl_Right
const int32_t C4PF_Crawl_Left
const int32_t C4PF_Crawl_Bottom

Here is the caller graph for this function:

void C4PathFinderRay::Default ( )

Definition at line 119 of file C4PathFinder.cpp.

References C4PF_Ray_Launch, CrawlAttach, CrawlStartX, CrawlStartY, Depth, Direction, From, Next, pPathFinder, Status, TargetX, TargetY, UseZone, X, X2, Y, and Y2.

Referenced by C4PathFinderRay().

120 {
122  X=Y=X2=Y2=TargetX=TargetY=0;
123  Direction=0;
124  Depth=0;
125  UseZone=nullptr;
126  From=nullptr;
127  Next=nullptr;
128  pPathFinder=nullptr;
130 }
const int32_t C4PF_Ray_Launch
C4PathFinder * pPathFinder
C4TransferZone * UseZone
C4PathFinderRay * From
C4PathFinderRay * Next

Here is the caller graph for this function:

void C4PathFinderRay::Draw ( C4TargetFacet cgo)
protected

Definition at line 273 of file C4PathFinder.cpp.

References C4PF_Direction_Left, C4PF_Ray_Crawl, C4PF_Ray_Deleted, C4PF_Ray_Failure, C4PF_Ray_Still, C4RGB, CrawlAttach, CrawlToAttach(), Direction, C4Draw::DrawFrameDw(), C4Draw::DrawLineDw(), pDraw, Status, C4Facet::Surface, TargetX, C4TargetFacet::TargetX, TargetY, C4TargetFacet::TargetY, UseZone, X, C4Facet::X, X2, Y, C4Facet::Y, and Y2.

274 {
275  uint32_t Color=0xffff0000;
276  switch (Status)
277  {
278  case C4PF_Ray_Crawl: Color=C4RGB(0xff, 0, 0); break;
279  case C4PF_Ray_Still: Color=C4RGB(0x50, 0, 0); break;
280  case C4PF_Ray_Failure: Color=C4RGB(0xff, 0xff, 0); break;
281  case C4PF_Ray_Deleted: Color=C4RGB(0x59, 0x59, 0x59); break;
282  }
283  if (UseZone) Color=C4RGB(0, 0, 0xff);
284 
285  // Crawl attachment
286  if (Status==C4PF_Ray_Crawl)
287  {
288  int32_t iX=0,iY=0; CrawlToAttach(iX,iY,CrawlAttach);
289  pDraw->DrawLineDw(cgo.Surface,
290  cgo.X+X2-cgo.TargetX,cgo.Y+Y2-cgo.TargetY,
291  cgo.X+X2-cgo.TargetX+7*iX,cgo.Y+Y2-cgo.TargetY+7*iY,
292  C4RGB(0xff, 0, 0));
293  }
294 
295  // Ray line
296  pDraw->DrawLineDw(cgo.Surface,
297  cgo.X+X-cgo.TargetX,cgo.Y+Y-cgo.TargetY,
298  cgo.X+X2-cgo.TargetX,cgo.Y+Y2-cgo.TargetY,
299  Color);
300 
301  // Crawler point
303  cgo.X+X2-cgo.TargetX-1,cgo.Y+Y2-cgo.TargetY-1,
304  cgo.X+X2-cgo.TargetX+1,cgo.Y+Y2-cgo.TargetY+1,
305  (Status==C4PF_Ray_Crawl) ? ((Direction==C4PF_Direction_Left) ? C4RGB(0, 0xff, 0) : C4RGB(0, 0, 0xff)) : Color);
306 
307  // Search target point
309  cgo.X+TargetX-cgo.TargetX-2,cgo.Y+TargetY-cgo.TargetY-2,
310  cgo.X+TargetX-cgo.TargetX+2,cgo.Y+TargetY-cgo.TargetY+2,
311  C4RGB(0xff, 0xff, 0));
312 
313 }
float Y
Definition: C4Facet.h:120
const int32_t C4PF_Ray_Failure
void CrawlToAttach(int32_t &rX, int32_t &rY, int32_t iAttach)
void DrawLineDw(C4Surface *sfcTarget, float x1, float y1, float x2, float y2, DWORD dwClr, float width=1.0f)
Definition: C4Draw.cpp:617
void DrawFrameDw(C4Surface *sfcDest, int x1, int y1, int x2, int y2, DWORD dwClr, float width=1.0f)
Definition: C4Draw.cpp:644
const int32_t C4PF_Ray_Crawl
C4Draw * pDraw
Definition: C4Draw.cpp:45
#define C4RGB(r, g, b)
Definition: StdColors.h:28
float TargetX
Definition: C4Facet.h:167
C4Surface * Surface
Definition: C4Facet.h:119
float TargetY
Definition: C4Facet.h:167
const int32_t C4PF_Ray_Deleted
float X
Definition: C4Facet.h:120
const int32_t C4PF_Ray_Still
C4TransferZone * UseZone
const int32_t C4PF_Direction_Left

Here is the call graph for this function:

bool C4PathFinderRay::Execute ( )
protected

Definition at line 137 of file C4PathFinder.cpp.

References C4TransferZone::At(), C4PF_Direction_Left, C4PF_Direction_Right, C4PF_MaxCrawl, C4PF_Ray_Crawl, C4PF_Ray_Deleted, C4PF_Ray_Failure, C4PF_Ray_Launch, C4PF_Ray_Still, C4PF_Threshold, Crawl(), CrawlAttach, CrawlLength, CrawlStartAttach, CrawlStartX, CrawlStartY, Depth, Direction, Distance(), C4TransferZones::Find(), FindCrawlAttach(), FindCrawlAttachDiagonal(), C4TransferZone::GetEntryPoint(), PathFree(), pPathFinder, SetCompletePath(), Status, TargetX, TargetY, C4TransferZone::Used, UseZone, X, X2, Y, and Y2.

138 {
139  C4TransferZone *pZone = nullptr;
140  int32_t iX,iY,iLastX,iLastY;
141  switch (Status)
142  {
143  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
144  case C4PF_Ray_Launch:
145  // In zone: use zone
146  if (UseZone)
147  {
148  // Mark zone used
149  UseZone->Used=true;
150  // Target in transfer zone: success
151  if (UseZone->At(TargetX,TargetY))
152  {
153  // Set end point
154  X2=TargetX; Y2=TargetY;
155  // Set complete path
156  SetCompletePath();
157  // Done
158  pPathFinder->Success=true;
160  }
161  // Continue from other end of zone
162  else
163  {
164  // Find exit point
166  { Status=C4PF_Ray_Failure; break; }
167  // Launch new ray (continue direction of entrance ray)
168  if (!pPathFinder->AddRay(X2,Y2,TargetX,TargetY,Depth+1,Direction,this))
169  { Status=C4PF_Ray_Failure; break; }
170  // Still
172  }
173  return true;
174  }
175  // Not in zone: check path to target
176  // Path free: success
177  else if (PathFree(X2,Y2,TargetX,TargetY,&pZone))
178  {
179  // Set complete path
180  SetCompletePath();
181  // Done
182  pPathFinder->Success=true;
184  return true;
185  }
186  // Path intersected by transfer zone
187  else if (pZone)
188  {
189  // Zone entry point adjust (if not already in zone)
190  if (!pZone->At(X,Y))
191  pZone->GetEntryPoint(X2,Y2,X2,Y2);
192  // Add use-zone ray
193  if (!pPathFinder->AddRay(X2,Y2,TargetX,TargetY,Depth+1,Direction,this,pZone))
194  { Status=C4PF_Ray_Failure; break; }
195  // Still
197  // Continue
198  return true;
199  }
200  // Path intersected by solid
201  else
202  {
203  // Start crawling
207  CrawlLength=0;
210  // Intersected but no attach found: unexpected failure
211  if (!CrawlAttach) { Status=C4PF_Ray_Failure; break; }
212  // Continue
213  return true;
214  }
215  break;
216  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
217  case C4PF_Ray_Crawl:
218  // Crawl
219  iLastX=X2; iLastY=Y2;
220  if (!Crawl())
221  { Status=C4PF_Ray_Failure; break; }
222  // Back at crawl starting position: done and still
224  { Status=C4PF_Ray_Still; break; }
225  // Check unused zone intersection
226  if (pPathFinder->TransferZonesEnabled)
227  if (pPathFinder->TransferZones)
228  if ((pZone = pPathFinder->TransferZones->Find(X2,Y2)))
229  if (!pZone->Used)
230  {
231  // Add use-zone ray (with zone entry point adjust)
232  iX=X2; iY=Y2; if (pZone->GetEntryPoint(iX,iY,X2,Y2))
233  if (!pPathFinder->AddRay(iX,iY,TargetX,TargetY,Depth+1,Direction,this,pZone))
234  { Status=C4PF_Ray_Failure; break; }
235  // Continue crawling
236  return true;
237  }
238  // Crawl length
239  CrawlLength++;
240  if (CrawlLength >= C4PF_MaxCrawl * pPathFinder->Level)
241  { Status=C4PF_Ray_Still; break; }
242  // Check back path intersection
243  iX=X; iY=Y;
244  if (!PathFree(iX,iY,X2,Y2))
245  // Insert split ray
246  if (!pPathFinder->SplitRay(this,iLastX,iLastY))
247  { Status=C4PF_Ray_Failure; break; }
248  // Try new ray at target
249  iX=X2; iY=Y2;
250  // If has been crawling for a while
252  // If all free...
253  if ( PathFree(iX,iY,TargetX,TargetY)
254  // ...or at least beyond threshold and not backwards toward crawl start
256  {
257  // Still
259  // Launch new rays
262  { Status=C4PF_Ray_Failure; break; }
263  }
264  break;
265  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
267  return false;
268  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
269  }
270  return true;
271 }
const int32_t C4PF_Ray_Failure
C4TransferZone * Find(C4Object *pObj)
int32_t Distance(int32_t iX1, int32_t iY1, int32_t iX2, int32_t iY2)
Definition: Standard.cpp:24
const int32_t C4PF_Direction_Right
bool GetEntryPoint(int32_t &rX, int32_t &rY, int32_t iToX, int32_t iToY)
int32_t FindCrawlAttach(int32_t iX, int32_t iY)
const int32_t C4PF_Ray_Crawl
const int32_t C4PF_Ray_Launch
const int32_t C4PF_MaxCrawl
int32_t FindCrawlAttachDiagonal(int32_t iX, int32_t iY, int32_t iDirection)
bool At(int32_t iX, int32_t iY)
bool PathFree(int32_t &rX, int32_t &rY, int32_t iToX, int32_t iToY, C4TransferZone **ppZone=nullptr)
int32_t CrawlStartAttach
C4PathFinder * pPathFinder
const int32_t C4PF_Threshold
const int32_t C4PF_Ray_Deleted
const int32_t C4PF_Ray_Still
C4TransferZone * UseZone
const int32_t C4PF_Direction_Left

Here is the call graph for this function:

int32_t C4PathFinderRay::FindCrawlAttach ( int32_t  iX,
int32_t  iY 
)
protected

Definition at line 453 of file C4PathFinder.cpp.

References C4PF_Crawl_Bottom, C4PF_Crawl_Left, C4PF_Crawl_NoAttach, C4PF_Crawl_Right, C4PF_Crawl_Top, and PointFree().

Referenced by Execute().

454 {
455  if (!PointFree(iX,iY-1)) return C4PF_Crawl_Top;
456  if (!PointFree(iX,iY+1)) return C4PF_Crawl_Bottom;
457  if (!PointFree(iX-1,iY)) return C4PF_Crawl_Left;
458  if (!PointFree(iX+1,iY)) return C4PF_Crawl_Right;
459  return C4PF_Crawl_NoAttach;
460 }
const int32_t C4PF_Crawl_NoAttach
const int32_t C4PF_Crawl_Top
const int32_t C4PF_Crawl_Right
const int32_t C4PF_Crawl_Left
bool PointFree(int32_t iX, int32_t iY)
const int32_t C4PF_Crawl_Bottom

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t C4PathFinderRay::FindCrawlAttachDiagonal ( int32_t  iX,
int32_t  iY,
int32_t  iDirection 
)
protected

Definition at line 479 of file C4PathFinder.cpp.

References C4PF_Crawl_Bottom, C4PF_Crawl_Left, C4PF_Crawl_NoAttach, C4PF_Crawl_Right, C4PF_Crawl_Top, C4PF_Direction_Left, C4PF_Direction_Right, and PointFree().

Referenced by Execute().

480 {
481  // Going left
482  if (iDirection==C4PF_Direction_Left)
483  {
484  // Top Left
485  if (!PointFree(iX-1,iY-1)) return C4PF_Crawl_Top;
486  // Bottom left
487  if (!PointFree(iX-1,iY+1)) return C4PF_Crawl_Left;
488  // Top right
489  if (!PointFree(iX+1,iY-1)) return C4PF_Crawl_Right;
490  // Bottom right
491  if (!PointFree(iX+1,iY+1)) return C4PF_Crawl_Bottom;
492  }
493  // Going right
494  if (iDirection==C4PF_Direction_Right)
495  {
496  // Top Left
497  if (!PointFree(iX-1,iY-1)) return C4PF_Crawl_Left;
498  // Bottom left
499  if (!PointFree(iX-1,iY+1)) return C4PF_Crawl_Bottom;
500  // Top right
501  if (!PointFree(iX+1,iY-1)) return C4PF_Crawl_Top;
502  // Bottom right
503  if (!PointFree(iX+1,iY+1)) return C4PF_Crawl_Right;
504  }
505  return C4PF_Crawl_NoAttach;
506 }
const int32_t C4PF_Crawl_NoAttach
const int32_t C4PF_Crawl_Top
const int32_t C4PF_Crawl_Right
const int32_t C4PF_Direction_Right
const int32_t C4PF_Crawl_Left
bool PointFree(int32_t iX, int32_t iY)
const int32_t C4PF_Crawl_Bottom
const int32_t C4PF_Direction_Left

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4PathFinderRay::IsCrawlAttach ( int32_t  iX,
int32_t  iY,
int32_t  iAttach 
)
protected

Definition at line 473 of file C4PathFinder.cpp.

References CrawlToAttach(), and PointFree().

Referenced by Crawl().

474 {
475  CrawlToAttach(iX,iY,iAttach);
476  return !PointFree(iX,iY);
477 }
void CrawlToAttach(int32_t &rX, int32_t &rY, int32_t iAttach)
bool PointFree(int32_t iX, int32_t iY)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4PathFinderRay::PathFree ( int32_t &  rX,
int32_t &  rY,
int32_t  iToX,
int32_t  iToY,
C4TransferZone **  ppZone = nullptr 
)
protected

Definition at line 315 of file C4PathFinder.cpp.

References Abs(), C4TransferZones::Find(), PointFree(), and pPathFinder.

Referenced by CheckBackRayShorten(), and Execute().

316 {
317  int32_t d,dx,dy,aincr,bincr,xincr,yincr,x,y;
318  // Y based
319  if (Abs(iToX-rX)<Abs(iToY-rY))
320  {
321  xincr=(iToX>rX) ? +1 : -1; yincr=(iToY>rY) ? +1 : -1;
322  dy=Abs(iToY-rY); dx=Abs(iToX-rX);
323  d=2*dx-dy; aincr=2*(dx-dy); bincr=2*dx; x=rX; y=rY;
324  for (y=rY; y!=iToY; y+=yincr)
325  {
326  // Check point free
327  if (PointFree(x,y)) { rY=y; rX=x; }
328  else return false;
329  // Check transfer zone intersection
330  if (ppZone)
331  if (pPathFinder->TransferZonesEnabled)
332  if (pPathFinder->TransferZones)
333  if ((*ppZone = pPathFinder->TransferZones->Find(rX,rY)))
334  return false;
335  // Advance
336  if (d>=0) { x+=xincr; d+=aincr; }
337  else d+=bincr;
338  }
339  }
340  // X based
341  else
342  {
343  yincr=(iToY>rY) ? +1 : -1; xincr=(iToX>rX) ? +1 : -1;
344  dx=Abs(iToX-rX); dy=Abs(iToY-rY);
345  d=2*dy-dx; aincr=2*(dy-dx); bincr=2*dy; x=rX; y=rY;
346  for (x=rX; x!=iToX; x+=xincr)
347  {
348  // Check point free
349  if (PointFree(x,y)) { rY=y; rX=x; }
350  else return false;
351  // Check transfer zone intersection
352  if (ppZone)
353  if (pPathFinder->TransferZonesEnabled)
354  if (pPathFinder->TransferZones)
355  if ((*ppZone = pPathFinder->TransferZones->Find(rX,rY)))
356  return false;
357  // Advance
358  if (d>=0) { y+=yincr; d+=aincr; }
359  else d+=bincr;
360  }
361  }
362 
363  return true;
364 }
C4TransferZone * Find(C4Object *pObj)
C4PathFinder * pPathFinder
bool PointFree(int32_t iX, int32_t iY)
T Abs(T val)
Definition: Standard.h:44

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4PathFinderRay::PointFree ( int32_t  iX,
int32_t  iY 
)
protected

Definition at line 424 of file C4PathFinder.cpp.

References pPathFinder.

Referenced by CrawlTargetFree(), FindCrawlAttach(), FindCrawlAttachDiagonal(), IsCrawlAttach(), and PathFree().

425 {
426  return pPathFinder->PointFree(iX,iY);
427 }
C4PathFinder * pPathFinder

Here is the caller graph for this function:

void C4PathFinderRay::SetCompletePath ( )
protected

Definition at line 406 of file C4PathFinder.cpp.

References CheckBackRayShorten(), From, C4TransferZone::Object, pPathFinder, UseZone, X2, and Y2.

Referenced by Execute().

407 {
408  C4PathFinderRay *pRay;
409  // Back shorten
410  for (pRay=this; pRay->From; pRay=pRay->From)
411  while (pRay->CheckBackRayShorten()) {}
412  // Set all waypoints
413  for (pRay=this; pRay->From; pRay=pRay->From)
414  {
415  // Transfer waypoint
416  if (pRay->UseZone)
417  pPathFinder->SetWaypoint(pRay->X2,pRay->Y2,pRay->UseZone->Object);
418  // MoveTo waypoint
419  else
420  pPathFinder->SetWaypoint(pRay->From->X2,pRay->From->Y2,nullptr);
421  }
422 }
C4Object * Object
bool CheckBackRayShorten()
C4PathFinder * pPathFinder
C4TransferZone * UseZone
C4PathFinderRay * From

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PathFinderRay::TurnAttach ( int32_t &  rAttach,
int32_t  iDirection 
)
protected

Definition at line 446 of file C4PathFinder.cpp.

References C4PF_Crawl_Left, and C4PF_Crawl_Top.

Referenced by Crawl().

447 {
448  rAttach+=iDirection;
449  if (rAttach>C4PF_Crawl_Left) rAttach=C4PF_Crawl_Top;
450  if (rAttach<C4PF_Crawl_Top) rAttach=C4PF_Crawl_Left;
451 }
const int32_t C4PF_Crawl_Top
const int32_t C4PF_Crawl_Left

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class C4PathFinder
friend

Definition at line 76 of file C4PathFinder.cpp.

Member Data Documentation

int32_t C4PathFinderRay::CrawlAttach
protected

Definition at line 86 of file C4PathFinder.cpp.

Referenced by Crawl(), Default(), Draw(), and Execute().

int32_t C4PathFinderRay::CrawlLength
protected

Definition at line 86 of file C4PathFinder.cpp.

Referenced by Crawl(), and Execute().

int32_t C4PathFinderRay::CrawlStartAttach
protected

Definition at line 86 of file C4PathFinder.cpp.

Referenced by Execute().

int32_t C4PathFinderRay::CrawlStartX
protected

Definition at line 86 of file C4PathFinder.cpp.

Referenced by Default(), and Execute().

int32_t C4PathFinderRay::CrawlStartY
protected

Definition at line 86 of file C4PathFinder.cpp.

Referenced by Default(), and Execute().

int32_t C4PathFinderRay::Depth
protected

Definition at line 87 of file C4PathFinder.cpp.

Referenced by Default(), and Execute().

int32_t C4PathFinderRay::Direction
protected

Definition at line 87 of file C4PathFinder.cpp.

Referenced by Crawl(), Default(), Draw(), and Execute().

C4PathFinderRay* C4PathFinderRay::From
protected

Definition at line 89 of file C4PathFinder.cpp.

Referenced by CheckBackRayShorten(), Default(), and SetCompletePath().

C4PathFinderRay* C4PathFinderRay::Next
protected

Definition at line 90 of file C4PathFinder.cpp.

Referenced by C4PathFinder::Clear(), Default(), and C4PathFinder::Draw().

C4PathFinder* C4PathFinderRay::pPathFinder
protected

Definition at line 91 of file C4PathFinder.cpp.

Referenced by Default(), Execute(), PathFree(), PointFree(), and SetCompletePath().

int32_t C4PathFinderRay::Status
protected

Definition at line 84 of file C4PathFinder.cpp.

Referenced by CheckBackRayShorten(), Default(), Draw(), and Execute().

int32_t C4PathFinderRay::TargetX
protected

Definition at line 85 of file C4PathFinder.cpp.

Referenced by Default(), Draw(), and Execute().

int32_t C4PathFinderRay::TargetY
protected

Definition at line 85 of file C4PathFinder.cpp.

Referenced by Default(), Draw(), and Execute().

C4TransferZone* C4PathFinderRay::UseZone
protected

Definition at line 88 of file C4PathFinder.cpp.

Referenced by CheckBackRayShorten(), Default(), Draw(), Execute(), and SetCompletePath().

int32_t C4PathFinderRay::X
protected

Definition at line 85 of file C4PathFinder.cpp.

Referenced by CheckBackRayShorten(), Default(), Draw(), and Execute().

int32_t C4PathFinderRay::X2
protected

Definition at line 85 of file C4PathFinder.cpp.

Referenced by CheckBackRayShorten(), Crawl(), Default(), Draw(), Execute(), and SetCompletePath().

int32_t C4PathFinderRay::Y
protected

Definition at line 85 of file C4PathFinder.cpp.

Referenced by CheckBackRayShorten(), Default(), Draw(), and Execute().

int32_t C4PathFinderRay::Y2
protected

Definition at line 85 of file C4PathFinder.cpp.

Referenced by CheckBackRayShorten(), Crawl(), Default(), Draw(), Execute(), and SetCompletePath().


The documentation for this class was generated from the following file: