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 }

◆ ~C4TransferZones()

C4TransferZones::~C4TransferZones ( )

Definition at line 44 of file C4TransferZone.cpp.

45 {
46  Clear();
47 }

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.

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

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
C4TransferZone * First
C4Object * Object
Here is the call graph for this function:

◆ Clear()

void C4TransferZones::Clear ( )

Definition at line 54 of file C4TransferZone.cpp.

References C4TransferZone::Next.

Referenced by C4Game::Clear(), and C4Game::LoadScenarioSection().

55 {
56  C4TransferZone *pZone,*pNext;
57  for (pZone=First; pZone; pZone=pNext) { pNext=pZone->Next; delete pZone; }
58  First=nullptr;
59 }
C4TransferZone * Next
C4TransferZone * First
Here is the caller graph for this function:

◆ ClearPointers()

void C4TransferZones::ClearPointers ( C4Object pObj)

Definition at line 61 of file C4TransferZone.cpp.

References C4TransferZone::Next.

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

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 }
C4TransferZone * Next
int32_t RemoveNullZones()
C4TransferZone * First
Here is the caller graph for this function:

◆ ClearUsed()

void C4TransferZones::ClearUsed ( )

Definition at line 202 of file C4TransferZone.cpp.

References C4TransferZone::Next.

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

◆ Default()

void C4TransferZones::Default ( )

Definition at line 49 of file C4TransferZone.cpp.

Referenced by C4Game::Default().

50 {
51  First=nullptr;
52 }
C4TransferZone * First
Here is the caller graph for this function:

◆ Draw()

void C4TransferZones::Draw ( C4TargetFacet cgo)

Definition at line 118 of file C4TransferZone.cpp.

References C4TransferZone::Next.

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

◆ Find() [1/2]

C4TransferZone * C4TransferZones::Find ( C4Object pObj)

Definition at line 208 of file C4TransferZone.cpp.

References C4TransferZone::Next.

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

209 {
210  for (C4TransferZone *pZone=First; pZone; pZone=pZone->Next)
211  if (pZone->Object==pObj)
212  return pZone;
213  return nullptr;
214 }
C4TransferZone * Next
C4TransferZone * First
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.

References C4TransferZone::Next.

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 }
C4TransferZone * Next
C4TransferZone * First

◆ RemoveNullZones()

int32_t C4TransferZones::RemoveNullZones ( )
protected

Definition at line 138 of file C4TransferZone.cpp.

References AdjustMoveToTarget(), iResult, C4TransferZone::Next, and C4TransferZone::Object.

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 }
C4TransferZone * Next
int iResult
Definition: C4GroupMain.cpp:39
C4TransferZone * First
C4Object * Object
Here is the call 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.

References C4TransferZone::Hgt, C4TransferZone::Wdt, C4TransferZone::X, and C4TransferZone::Y.

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)
bool Add(int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, C4Object *pObj)
C4TransferZone * Find(C4Object *pObj)

◆ Synchronize()

void C4TransferZones::Synchronize ( )

Definition at line 103 of file C4TransferZone.cpp.

References Objects, and C4GameObjects::OnSynchronized().

Referenced by C4Game::Synchronize().

104 {
105  Clear();
107 }
C4GameObjects Objects
Definition: C4Globals.cpp:48
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.


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