OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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 ( )

Definition at line 39 of file C4TransferZone.cpp.

References Default().

40 {
41  Default();
42 }

Here is the call graph for this function:

C4TransferZones::~C4TransferZones ( )

Definition at line 44 of file C4TransferZone.cpp.

References Clear().

45 {
46  Clear();
47 }

Here is the call graph for this function:

Member Function Documentation

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 First, C4TransferZone::Hgt, C4TransferZone::Next, C4TransferZone::Object, C4TransferZone::Wdt, C4TransferZone::X, and C4TransferZone::Y.

Referenced by Set().

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 caller graph for this function:

void C4TransferZones::Clear ( )

Definition at line 54 of file C4TransferZone.cpp.

References First, and C4TransferZone::Next.

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

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:

void C4TransferZones::ClearPointers ( C4Object pObj)

Definition at line 61 of file C4TransferZone.cpp.

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

Referenced by C4Game::ClearPointers(), Set(), 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 call graph for this function:

Here is the caller graph for this function:

void C4TransferZones::ClearUsed ( )

Definition at line 202 of file C4TransferZone.cpp.

References First, and C4TransferZone::Next.

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

Definition at line 49 of file C4TransferZone.cpp.

References First.

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

50 {
51  First=nullptr;
52 }
C4TransferZone * First

Here is the caller graph for this function:

void C4TransferZones::Draw ( C4TargetFacet cgo)

Definition at line 118 of file C4TransferZone.cpp.

References First, and C4TransferZone::Next.

Referenced by C4PathFinder::Draw().

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

Here is the caller graph for this function:

C4TransferZone * C4TransferZones::Find ( C4Object pObj)

Definition at line 208 of file C4TransferZone.cpp.

References First, and C4TransferZone::Next.

Referenced by C4PathFinderRay::Execute(), C4PathFinderRay::PathFree(), Set(), 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:

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

Definition at line 109 of file C4TransferZone.cpp.

References First, and 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
int32_t C4TransferZones::RemoveNullZones ( )
protected

Definition at line 138 of file C4TransferZone.cpp.

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

Referenced by ClearPointers().

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 caller graph for this function:

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 Add(), ClearPointers(), Find(), 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)

Here is the call graph for this function:

void C4TransferZones::Synchronize ( )

Definition at line 103 of file C4TransferZone.cpp.

References Clear(), 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

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: