OpenClonk
C4TransferZones Class Reference

#include <C4TransferZone.h>

Collaboration diagram for C4TransferZones:
[legend]

Public Member Functions

 C4TransferZones ()
 
 ~C4TransferZones ()
 
void Default ()
 
void Clear ()
 
void ClearUsed ()
 
void ClearPointers (C4Object *pObj)
 
void Draw (C4TargetFacet &cgo)
 
void Synchronize ()
 
C4TransferZoneFind (C4Object *pObj)
 
C4TransferZoneFind (int32_t iX, int32_t iY)
 
bool Add (int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, C4Object *pObj)
 
bool Set (int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, C4Object *pObj)
 

Protected Member Functions

int32_t RemoveNullZones ()
 

Protected Attributes

C4TransferZoneFirst
 

Detailed Description

Definition at line 41 of file C4TransferZone.h.

Constructor & Destructor Documentation

◆ C4TransferZones()

C4TransferZones::C4TransferZones ( )

Definition at line 39 of file C4TransferZone.cpp.

40 {
41  Default();
42 }

References Default().

Here is the call graph for this function:

◆ ~C4TransferZones()

C4TransferZones::~C4TransferZones ( )

Definition at line 44 of file C4TransferZone.cpp.

45 {
46  Clear();
47 }

References Clear().

Here is the call graph for this function:

Member Function Documentation

◆ Add()

bool C4TransferZones::Add ( int32_t  iX,
int32_t  iY,
int32_t  iWdt,
int32_t  iHgt,
C4Object pObj 
)

Definition at line 89 of file C4TransferZone.cpp.

90 {
91  C4TransferZone *pZone;
92  // Allocate and add new zone
93  pZone = new C4TransferZone;
94  pZone->X=iX; pZone->Y=iY;
95  pZone->Wdt=iWdt; pZone->Hgt=iHgt;
96  pZone->Object=pObj;
97  pZone->Next=First;
98  First=pZone;
99  // Success
100  return true;
101 }
C4TransferZone * Next
C4Object * Object
C4TransferZone * First

References First, C4TransferZone::Hgt, C4TransferZone::Next, C4TransferZone::Object, C4TransferZone::Wdt, C4TransferZone::X, and C4TransferZone::Y.

Referenced by Set().

Here is the caller graph for this function:

◆ Clear()

void C4TransferZones::Clear ( )

Definition at line 54 of file C4TransferZone.cpp.

55 {
56  C4TransferZone *pZone,*pNext;
57  for (pZone=First; pZone; pZone=pNext) { pNext=pZone->Next; delete pZone; }
58  First=nullptr;
59 }

References First, and C4TransferZone::Next.

Referenced by C4Game::Clear(), C4Game::LoadScenarioSection(), Synchronize(), and ~C4TransferZones().

Here is the caller graph for this function:

◆ ClearPointers()

void C4TransferZones::ClearPointers ( C4Object pObj)

Definition at line 61 of file C4TransferZone.cpp.

62 {
63  // Clear object pointers
64  for (C4TransferZone *pZone=First; pZone; pZone=pZone->Next)
65  if (pZone->Object==pObj)
66  pZone->Object=nullptr;
67  // Remove cleared zones immediately
69 }
int32_t RemoveNullZones()

References First, C4TransferZone::Next, and RemoveNullZones().

Referenced by C4Game::ClearPointers(), Set(), and C4Object::StatusDeactivate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearUsed()

void C4TransferZones::ClearUsed ( )

Definition at line 202 of file C4TransferZone.cpp.

203 {
204  for (C4TransferZone *pZone=First; pZone; pZone=pZone->Next)
205  pZone->Used=false;
206 }

References First, and C4TransferZone::Next.

◆ Default()

void C4TransferZones::Default ( )

Definition at line 49 of file C4TransferZone.cpp.

50 {
51  First=nullptr;
52 }

References First.

Referenced by C4TransferZones(), and C4Game::Default().

Here is the caller graph for this function:

◆ Draw()

void C4TransferZones::Draw ( C4TargetFacet cgo)

Definition at line 118 of file C4TransferZone.cpp.

119 {
120  for (C4TransferZone *pZone=First; pZone; pZone=pZone->Next)
121  pZone->Draw(cgo);
122 }

References First, and C4TransferZone::Next.

Referenced by C4PathFinder::Draw().

Here is the caller graph for this function:

◆ Find() [1/2]

C4TransferZone * C4TransferZones::Find ( C4Object pObj)

Definition at line 208 of file C4TransferZone.cpp.

209 {
210  for (C4TransferZone *pZone=First; pZone; pZone=pZone->Next)
211  if (pZone->Object==pObj)
212  return pZone;
213  return nullptr;
214 }

References First, and C4TransferZone::Next.

Referenced by C4PathFinderRay::Execute(), C4PathFinderRay::PathFree(), Set(), and C4Command::Transfer().

Here is the caller graph for this function:

◆ Find() [2/2]

C4TransferZone * C4TransferZones::Find ( int32_t  iX,
int32_t  iY 
)

Definition at line 109 of file C4TransferZone.cpp.

110 {
111  for (C4TransferZone *pZone=First; pZone; pZone=pZone->Next)
112  if (Inside<int32_t>(iX-pZone->X,0,pZone->Wdt-1))
113  if (Inside<int32_t>(iY-pZone->Y,0,pZone->Hgt-1))
114  return pZone;
115  return nullptr;
116 }

References First, and C4TransferZone::Next.

◆ RemoveNullZones()

int32_t C4TransferZones::RemoveNullZones ( )
protected

Definition at line 138 of file C4TransferZone.cpp.

139 {
140  int32_t iResult=0;
141  C4TransferZone *pZone,*pNext,*pPrev=nullptr;
142  for (pZone=First; pZone; pZone=pNext)
143  {
144  pNext=pZone->Next;
145  if (!pZone->Object)
146  {
147  delete pZone;
148  if (pPrev) pPrev->Next=pNext;
149  else First=pNext;
150  iResult++;
151  }
152  else
153  pPrev=pZone;
154  }
155  return iResult;
156 }
int iResult
Definition: C4GroupMain.cpp:40

References First, iResult, C4TransferZone::Next, and C4TransferZone::Object.

Referenced by ClearPointers().

Here is the caller graph for this function:

◆ Set()

bool C4TransferZones::Set ( int32_t  iX,
int32_t  iY,
int32_t  iWdt,
int32_t  iHgt,
C4Object pObj 
)

Definition at line 71 of file C4TransferZone.cpp.

72 {
73  C4TransferZone *pZone;
74  // Empty zone: clear existing object zones
75  if (!iWdt || !iHgt) { ClearPointers(pObj); return true; }
76  // Update existing zone
77  if ((pZone=Find(pObj)))
78  {
79  pZone->X=iX; pZone->Y=iY;
80  pZone->Wdt=iWdt; pZone->Hgt=iHgt;
81  }
82  // Allocate and add new zone
83  else
84  Add(iX,iY,iWdt,iHgt,pObj);
85  // Success
86  return true;
87 }
void ClearPointers(C4Object *pObj)
C4TransferZone * Find(C4Object *pObj)
bool Add(int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, C4Object *pObj)

References Add(), ClearPointers(), Find(), C4TransferZone::Hgt, C4TransferZone::Wdt, C4TransferZone::X, and C4TransferZone::Y.

Here is the call graph for this function:

◆ Synchronize()

void C4TransferZones::Synchronize ( )

Definition at line 103 of file C4TransferZone.cpp.

104 {
105  Clear();
107 }
C4GameObjects Objects
Definition: C4Globals.cpp:48

References Clear(), Objects, and C4GameObjects::OnSynchronized().

Referenced by C4Game::Synchronize().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ First

C4TransferZone* C4TransferZones::First
protected

Definition at line 48 of file C4TransferZone.h.

Referenced by Add(), Clear(), ClearPointers(), ClearUsed(), Default(), Draw(), Find(), and RemoveNullZones().


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