OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4LArea Class Reference

#include <C4Sector.h>

Collaboration diagram for C4LArea:
[legend]

Public Member Functions

 C4LArea ()
 
 C4LArea (C4LSectors *pSectors, int ix, int iy, int iwdt, int ihgt)
 
 C4LArea (C4LSectors *pSectors, const C4Rect &rect)
 
 C4LArea (C4LSectors *pSectors, C4Object *pObj)
 
void Clear ()
 
bool operator== (const C4LArea &Area) const
 
bool IsNull () const
 
void Set (C4LSectors *pSectors, const C4Rect &rect)
 
void Set (C4LSectors *pSectors, C4Object *pObj)
 
C4LSectorFirst () const
 
C4LSectorNext (C4LSector *pPrev) const
 
bool Contains (C4LSector *pSct) const
 
C4ObjectListFirstObjects (C4LSector **ppSct)
 
C4ObjectListNextObjects (C4ObjectList *pPrev, C4LSector **ppSct)
 
C4ObjectListFirstObjectShapes (C4LSector **ppSct)
 
C4ObjectListNextObjectShapes (C4ObjectList *pPrev, C4LSector **ppSct)
 
void DebugRec (class C4Object *pObj, char cMarker)
 

Public Attributes

C4LSectorpFirst
 
int xL
 
int yL
 
int dpitch
 
C4LSectorpOut
 

Detailed Description

Definition at line 86 of file C4Sector.h.

Constructor & Destructor Documentation

C4LArea::C4LArea ( )
inline

Definition at line 93 of file C4Sector.h.

References Clear().

93 { Clear(); } // default constructor
void Clear()
Definition: C4Sector.h:102

Here is the call graph for this function:

C4LArea::C4LArea ( C4LSectors pSectors,
int  ix,
int  iy,
int  iwdt,
int  ihgt 
)
inline

Definition at line 94 of file C4Sector.h.

References Set().

95  { Set(pSectors, C4Rect(ix, iy, iwdt, ihgt)); }
Definition: C4Rect.h:27
void Set(C4LSectors *pSectors, const C4Rect &rect)
Definition: C4Sector.cpp:244

Here is the call graph for this function:

C4LArea::C4LArea ( C4LSectors pSectors,
const C4Rect rect 
)
inline

Definition at line 96 of file C4Sector.h.

References Set().

97  { Set(pSectors, rect); }
void Set(C4LSectors *pSectors, const C4Rect &rect)
Definition: C4Sector.cpp:244

Here is the call graph for this function:

C4LArea::C4LArea ( C4LSectors pSectors,
C4Object pObj 
)
inline

Definition at line 99 of file C4Sector.h.

References Set().

100  { Set(pSectors, pObj); }
void Set(C4LSectors *pSectors, const C4Rect &rect)
Definition: C4Sector.cpp:244

Here is the call graph for this function:

Member Function Documentation

void C4LArea::Clear ( )
inline

Definition at line 102 of file C4Sector.h.

Referenced by C4LArea().

102 { pFirst=pOut=nullptr; } // zero sector
C4LSector * pOut
Definition: C4Sector.h:91
C4LSector * pFirst
Definition: C4Sector.h:89

Here is the caller graph for this function:

bool C4LArea::Contains ( C4LSector pSct) const

Definition at line 291 of file C4Sector.cpp.

References pFirst, pOut, C4LSector::x, xL, C4LSector::y, and yL.

Referenced by C4LSectors::Update().

292 {
293  assert(pSct);
294  // no area
295  if (!pFirst) return false;
296  // outside?
297  if (pSct == pOut) return true;
298  if (pFirst == pOut) return false;
299  // check bounds
300  return (pSct->x>=pFirst->x && pSct->y>=pFirst->y && pSct->x<=xL && pSct->y<=yL);
301 }
int y
Definition: C4Sector.h:46
int xL
Definition: C4Sector.h:90
C4LSector * pOut
Definition: C4Sector.h:91
C4LSector * pFirst
Definition: C4Sector.h:89
int yL
Definition: C4Sector.h:90
int x
Definition: C4Sector.h:46

Here is the caller graph for this function:

void C4LArea::DebugRec ( class C4Object pObj,
char  cMarker 
)

Definition at line 331 of file C4Sector.cpp.

References AddDbgRec(), dpitch, C4RCArea::dpitch, C4PropListNumbered::Number, C4RCArea::obj, C4RCArea::op, C4RCArea::out, pFirst, pOut, RCT_Area, C4LSector::x, C4RCArea::x1, xL, C4RCArea::xL, C4RCArea::y1, yL, and C4RCArea::yL.

Referenced by C4LSectors::Add(), C4LSectors::Remove(), and C4LSectors::Update().

332 {
333  C4RCArea rc;
334  rc.op = cMarker;
335  rc.obj = pObj ? pObj->Number : -1;
336  rc.x1 = pFirst ? pFirst->x : -1;
337  rc.y1 = pFirst ? pFirst->x /* 2do: y */ : -1;
338  rc.xL = xL;
339  rc.yL = yL;
340  rc.dpitch = dpitch;
341  rc.out = !!pOut;
342  AddDbgRec(RCT_Area, &rc, sizeof(C4RCArea));
343 }
int32_t xL
Definition: C4Record.h:204
int32_t y1
Definition: C4Record.h:204
bool out
Definition: C4Record.h:205
int xL
Definition: C4Sector.h:90
int dpitch
Definition: C4Sector.h:90
C4LSector * pOut
Definition: C4Sector.h:91
char op
Definition: C4Record.h:202
void AddDbgRec(C4RecordChunkType eType, const void *pData, int iSize)
Definition: C4Record.cpp:32
int32_t yL
Definition: C4Record.h:204
int32_t dpitch
Definition: C4Record.h:204
C4LSector * pFirst
Definition: C4Sector.h:89
int yL
Definition: C4Sector.h:90
int x
Definition: C4Sector.h:46
int32_t obj
Definition: C4Record.h:203
int32_t x1
Definition: C4Record.h:204

Here is the call graph for this function:

Here is the caller graph for this function:

C4LSector* C4LArea::First ( ) const
inline

Definition at line 111 of file C4Sector.h.

References pFirst.

Referenced by C4LSectors::Add(), NextObjects(), NextObjectShapes(), C4LSectors::Remove(), and C4LSectors::Update().

111 { return pFirst; } // get first sector
C4LSector * pFirst
Definition: C4Sector.h:89

Here is the caller graph for this function:

C4ObjectList* C4LArea::FirstObjects ( C4LSector **  ppSct)
inline

Definition at line 118 of file C4Sector.h.

References NextObjects().

Referenced by C4FindObject::Count(), C4GameObjects::CrossCheck(), C4FindObject::Find(), and C4FindObject::FindMany().

119  { *ppSct=nullptr; return NextObjects(nullptr, ppSct); }
C4ObjectList * NextObjects(C4ObjectList *pPrev, C4LSector **ppSct)
Definition: C4Sector.cpp:303

Here is the call graph for this function:

Here is the caller graph for this function:

C4ObjectList* C4LArea::FirstObjectShapes ( C4LSector **  ppSct)
inline

Definition at line 122 of file C4Sector.h.

References NextObjectShapes().

Referenced by C4FindObject::Count(), C4FindObject::Find(), C4Game::FindConstuctionSiteBlock(), C4FindObject::FindMany(), and C4SolidMask::Remove().

123  { *ppSct=nullptr; return NextObjectShapes(nullptr, ppSct); }
C4ObjectList * NextObjectShapes(C4ObjectList *pPrev, C4LSector **ppSct)
Definition: C4Sector.cpp:317

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4LArea::IsNull ( ) const
inline

Definition at line 106 of file C4Sector.h.

References pFirst.

Referenced by C4LSectors::Update().

106 { return !pFirst; }
C4LSector * pFirst
Definition: C4Sector.h:89

Here is the caller graph for this function:

C4LSector * C4LArea::Next ( C4LSector pPrev) const

Definition at line 276 of file C4Sector.cpp.

References dpitch, pOut, C4LSector::x, xL, C4LSector::y, and yL.

Referenced by C4LSectors::Add(), C4FindObject::Count(), C4FindObject::FindMany(), NextObjects(), NextObjectShapes(), C4LSectors::Remove(), and C4LSectors::Update().

277 {
278  // the outside-sector is the last sector that is returned
279  if (pPrev == pOut)
280  return nullptr;
281  // within one line?
282  if (pPrev->x<xL)
283  return pPrev+1;
284  // within the area?
285  if (pPrev->y<yL)
286  return pPrev+dpitch;
287  // end reached - return outside-sector if applicable
288  return pOut;
289 }
int y
Definition: C4Sector.h:46
int xL
Definition: C4Sector.h:90
int dpitch
Definition: C4Sector.h:90
C4LSector * pOut
Definition: C4Sector.h:91
int yL
Definition: C4Sector.h:90
int x
Definition: C4Sector.h:46

Here is the caller graph for this function:

C4ObjectList * C4LArea::NextObjects ( C4ObjectList pPrev,
C4LSector **  ppSct 
)

Definition at line 303 of file C4Sector.cpp.

References First(), and Next().

Referenced by C4FindObject::Count(), C4GameObjects::CrossCheck(), C4FindObject::Find(), C4FindObject::FindMany(), and FirstObjects().

304 {
305  // get next sector
306  if (!*ppSct)
307  *ppSct = First();
308  else
309  *ppSct = Next(*ppSct);
310  // nothing left?
311  if (!*ppSct)
312  return nullptr;
313  // return object list
314  return &(*ppSct)->Objects;
315 }
C4LSector * First() const
Definition: C4Sector.h:111
C4LSector * Next(C4LSector *pPrev) const
Definition: C4Sector.cpp:276

Here is the call graph for this function:

Here is the caller graph for this function:

C4ObjectList * C4LArea::NextObjectShapes ( C4ObjectList pPrev,
C4LSector **  ppSct 
)

Definition at line 317 of file C4Sector.cpp.

References First(), and Next().

Referenced by C4FindObject::Count(), C4FindObject::Find(), C4Game::FindConstuctionSiteBlock(), C4FindObject::FindMany(), FirstObjectShapes(), and C4SolidMask::Remove().

318 {
319  // get next sector
320  if (!*ppSct)
321  *ppSct = First();
322  else
323  *ppSct = Next(*ppSct);
324  // nothing left?
325  if (!*ppSct)
326  return nullptr;
327  // return object list
328  return &(*ppSct)->ObjectShapes;
329 }
C4LSector * First() const
Definition: C4Sector.h:111
C4LSector * Next(C4LSector *pPrev) const
Definition: C4Sector.cpp:276

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4LArea::operator== ( const C4LArea Area) const

Definition at line 236 of file C4Sector.cpp.

References pFirst, pOut, xL, and yL.

237 {
238  return pFirst == Area.pFirst &&
239  xL == Area.xL &&
240  yL == Area.yL &&
241  pOut == Area.pOut;
242 }
int xL
Definition: C4Sector.h:90
C4LSector * pOut
Definition: C4Sector.h:91
C4LSector * pFirst
Definition: C4Sector.h:89
int yL
Definition: C4Sector.h:90
void C4LArea::Set ( C4LSectors pSectors,
const C4Rect rect 
)

Definition at line 244 of file C4Sector.cpp.

References C4LSectorHgt, C4LSectorWdt, C4Rect::Contains(), dpitch, pFirst, pOut, C4LSectors::PxHgt, C4LSectors::PxWdt, C4LSectors::SectorAt(), C4LSectors::SectorOut, C4LSectors::Wdt, xL, and yL.

Referenced by C4LSectors::Add(), C4LArea(), and Set().

245 {
246  // default: no area
247  pFirst=nullptr; pOut=nullptr;
248  // check bounds
249  C4Rect ClippedRect(Rect),
250  Bounds(0, 0, pSectors->PxWdt, pSectors->PxHgt);
251  ClippedRect.Normalize();
252  if (!Bounds.Contains(ClippedRect))
253  {
254  ClippedRect.Intersect(Bounds);
255  pOut = &pSectors->SectorOut;
256  }
257  // calc first sector
258  pFirst = pSectors->SectorAt(ClippedRect.x, ClippedRect.y);
259  // assert the rect isn't degenerated for the following calculations
260  // (note this will associate areas that are above landscape bounds with sectors inside)
261  if (!ClippedRect.Wdt) ClippedRect.Wdt = 1;
262  if (!ClippedRect.Hgt) ClippedRect.Hgt = 1;
263  // calc bounds
264  xL = (ClippedRect.x + ClippedRect.Wdt - 1) / C4LSectorWdt;
265  yL = (ClippedRect.y + ClippedRect.Hgt - 1) / C4LSectorHgt;
266  // calc pitch
267  dpitch = pSectors->Wdt - (ClippedRect.x + ClippedRect.Wdt - 1) / C4LSectorWdt + ClippedRect.x / C4LSectorWdt;
268 }
C4LSector SectorOut
Definition: C4Sector.h:65
int Wdt
Definition: C4Sector.h:63
C4LSector * SectorAt(int ix, int iy)
Definition: C4Sector.cpp:82
Definition: C4Rect.h:27
int PxHgt
Definition: C4Sector.h:62
int xL
Definition: C4Sector.h:90
const int32_t C4LSectorWdt
Definition: C4Sector.h:31
int dpitch
Definition: C4Sector.h:90
C4LSector * pOut
Definition: C4Sector.h:91
const int32_t C4LSectorHgt
Definition: C4Sector.h:32
C4LSector * pFirst
Definition: C4Sector.h:89
int yL
Definition: C4Sector.h:90
int PxWdt
Definition: C4Sector.h:62

Here is the call graph for this function:

Here is the caller graph for this function:

void C4LArea::Set ( C4LSectors pSectors,
C4Object pObj 
)

Definition at line 270 of file C4Sector.cpp.

References C4Object::Height(), C4Object::Left(), Set(), C4Object::Top(), and C4Object::Width().

271 {
272  // set to object facet rect
273  Set(pSectors, C4Rect(pObj->Left(), pObj->Top(), pObj->Width(), pObj->Height()));
274 }
int32_t Height() const
Definition: C4Object.h:285
int32_t Left() const
Definition: C4Object.h:282
Definition: C4Rect.h:27
int32_t Top() const
Definition: C4Object.h:283
int32_t Width() const
Definition: C4Object.h:284
void Set(C4LSectors *pSectors, const C4Rect &rect)
Definition: C4Sector.cpp:244

Here is the call graph for this function:

Member Data Documentation

int C4LArea::dpitch

Definition at line 90 of file C4Sector.h.

Referenced by DebugRec(), Next(), and Set().

C4LSector* C4LArea::pFirst

Definition at line 89 of file C4Sector.h.

Referenced by Contains(), DebugRec(), First(), IsNull(), operator==(), and Set().

C4LSector* C4LArea::pOut

Definition at line 91 of file C4Sector.h.

Referenced by Contains(), DebugRec(), Next(), operator==(), and Set().

int C4LArea::xL

Definition at line 90 of file C4Sector.h.

Referenced by Contains(), DebugRec(), Next(), operator==(), and Set().

int C4LArea::yL

Definition at line 90 of file C4Sector.h.

Referenced by Contains(), DebugRec(), Next(), operator==(), and Set().


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