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:29
void Set(C4LSectors *pSectors, const C4Rect &rect)
Definition: C4Sector.cpp:246

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:246

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:246

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 293 of file C4Sector.cpp.

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

Referenced by C4LSectors::Update().

294 {
295  assert(pSct);
296  // no area
297  if (!pFirst) return false;
298  // outside?
299  if (pSct == pOut) return true;
300  if (pFirst == pOut) return false;
301  // check bounds
302  return (pSct->x>=pFirst->x && pSct->y>=pFirst->y && pSct->x<=xL && pSct->y<=yL);
303 }
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 333 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().

334 {
335  C4RCArea rc;
336  rc.op = cMarker;
337  rc.obj = pObj ? pObj->Number : -1;
338  rc.x1 = pFirst ? pFirst->x : -1;
339  rc.y1 = pFirst ? pFirst->x /* 2do: y */ : -1;
340  rc.xL = xL;
341  rc.yL = yL;
342  rc.dpitch = dpitch;
343  rc.out = !!pOut;
344  AddDbgRec(RCT_Area, &rc, sizeof(C4RCArea));
345 }
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:36
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:305

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:319

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 278 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().

279 {
280  // the outside-sector is the last sector that is returned
281  if (pPrev == pOut)
282  return nullptr;
283  // within one line?
284  if (pPrev->x<xL)
285  return pPrev+1;
286  // within the area?
287  if (pPrev->y<yL)
288  return pPrev+dpitch;
289  // end reached - return outside-sector if applicable
290  return pOut;
291 }
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 305 of file C4Sector.cpp.

References First(), and Next().

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

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

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 319 of file C4Sector.cpp.

References First(), and Next().

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

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

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 238 of file C4Sector.cpp.

References pFirst, pOut, xL, and yL.

239 {
240  return pFirst == Area.pFirst &&
241  xL == Area.xL &&
242  yL == Area.yL &&
243  pOut == Area.pOut;
244 }
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 246 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().

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

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

273 {
274  // set to object facet rect
275  Set(pSectors, C4Rect(pObj->Left(), pObj->Top(), pObj->Width(), pObj->Height()));
276 }
int32_t Height() const
Definition: C4Object.h:285
int32_t Left() const
Definition: C4Object.h:282
Definition: C4Rect.h:29
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:246

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: