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 41 of file C4TransferZone.cpp.

References Default().

42 {
43  Default();
44 }

Here is the call graph for this function:

C4TransferZones::~C4TransferZones ( )

Definition at line 46 of file C4TransferZone.cpp.

References Clear().

47 {
48  Clear();
49 }

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 91 of file C4TransferZone.cpp.

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

Referenced by Set().

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

Here is the caller graph for this function:

void C4TransferZones::Clear ( )

Definition at line 56 of file C4TransferZone.cpp.

References First, and C4TransferZone::Next.

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

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

Here is the caller graph for this function:

void C4TransferZones::ClearPointers ( C4Object pObj)

Definition at line 63 of file C4TransferZone.cpp.

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

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

64 {
65  // Clear object pointers
66  for (C4TransferZone *pZone=First; pZone; pZone=pZone->Next)
67  if (pZone->Object==pObj)
68  pZone->Object=nullptr;
69  // Remove cleared zones immediately
71 }
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 204 of file C4TransferZone.cpp.

References First, and C4TransferZone::Next.

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

Definition at line 51 of file C4TransferZone.cpp.

References First.

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

52 {
53  First=nullptr;
54 }
C4TransferZone * First

Here is the caller graph for this function:

void C4TransferZones::Draw ( C4TargetFacet cgo)

Definition at line 120 of file C4TransferZone.cpp.

References First, and C4TransferZone::Next.

Referenced by C4PathFinder::Draw().

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

Here is the caller graph for this function:

C4TransferZone * C4TransferZones::Find ( C4Object pObj)

Definition at line 210 of file C4TransferZone.cpp.

References First, and C4TransferZone::Next.

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

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

Here is the caller graph for this function:

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

Definition at line 111 of file C4TransferZone.cpp.

References First, and C4TransferZone::Next.

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

Definition at line 140 of file C4TransferZone.cpp.

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

Referenced by ClearPointers().

141 {
142  int32_t iResult=0;
143  C4TransferZone *pZone,*pNext,*pPrev=nullptr;
144  for (pZone=First; pZone; pZone=pNext)
145  {
146  pNext=pZone->Next;
147  if (!pZone->Object)
148  {
149  delete pZone;
150  if (pPrev) pPrev->Next=pNext;
151  else First=pNext;
152  iResult++;
153  }
154  else
155  pPrev=pZone;
156  }
157  return iResult;
158 }
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 73 of file C4TransferZone.cpp.

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

74 {
75  C4TransferZone *pZone;
76  // Empty zone: clear existing object zones
77  if (!iWdt || !iHgt) { ClearPointers(pObj); return true; }
78  // Update existing zone
79  if ((pZone=Find(pObj)))
80  {
81  pZone->X=iX; pZone->Y=iY;
82  pZone->Wdt=iWdt; pZone->Hgt=iHgt;
83  }
84  // Allocate and add new zone
85  else
86  Add(iX,iY,iWdt,iHgt,pObj);
87  // Success
88  return true;
89 }
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 105 of file C4TransferZone.cpp.

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

Referenced by C4Game::Synchronize().

106 {
107  Clear();
109 }
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: