OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4NotifyingObjectList Class Reference

#include <C4ObjectList.h>

Inheritance diagram for C4NotifyingObjectList:
[legend]
Collaboration diagram for C4NotifyingObjectList:
[legend]

Public Types

enum  SortType { stNone =0, stMain, stContents, stReverse }
 
typedef int SortProc (C4Object *, C4Object *)
 

Public Member Functions

 C4NotifyingObjectList ()
 
 C4NotifyingObjectList (const C4NotifyingObjectList &List)
 
 C4NotifyingObjectList (const C4ObjectList &List)
 
virtual ~C4NotifyingObjectList ()
 
iterator begin () const
 
const iterator end () const
 
const ReverseView reverse () const
 
virtual void Default ()
 
virtual void Clear ()
 
void Sort ()
 
void Copy (const C4ObjectList &rList)
 
void DrawIfCategory (C4TargetFacet &cgo, int iPlayer, uint32_t dwCat, bool fInvert)
 
void Draw (C4TargetFacet &cgo, int iPlayer, int MinPlane, int MaxPlane)
 
void DrawSelectMark (C4TargetFacet &cgo) const
 
void CloseMenus ()
 
void UpdateGraphics (bool fGraphicsChanged)
 
void UpdateFaces (bool bUpdateShape)
 
void ClearInfo (C4ObjectInfo *pInfo)
 
virtual bool Add (C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted=nullptr)
 
bool AddSortCustom (C4Object *nObj, SortProc &pSortProc)
 
virtual bool Remove (C4Object *pObj)
 
virtual bool AssignInfo ()
 
virtual bool ValidateOwners ()
 
StdStrBuf GetNameList (C4DefList &rDefs) const
 
bool IsClear () const
 
bool DenumeratePointers ()
 
bool Write (char *szTarget)
 
void CompileFunc (StdCompiler *pComp, C4ValueNumbers *=0)
 
void CompileFunc (StdCompiler *pComp, bool fSkipPlayerObjects, C4ValueNumbers *)
 
void Denumerate (C4ValueNumbers *)
 
bool IsContained (const C4Object *pObj) const
 
int ClearPointers (C4Object *pObj)
 
int ObjectCount (C4ID id=C4ID::None) const
 
int MassCount ()
 
int ListIDCount (int32_t dwCategory) const
 
C4ObjectGetObject (int Index=0) const
 
C4ObjectGetFirstObject () const
 
C4ObjectGetLastObject () const
 
C4ObjectFind (C4Def *def, int iOwner=ANY_OWNER, DWORD dwOCF=OCF_All)
 
C4ObjectFindOther (C4ID id, int iOwner=ANY_OWNER)
 
const C4ObjectLinkGetLink (const C4Object *pObj) const
 
C4ObjectLinkGetLink (const C4Object *pObj)
 
C4ID GetListID (int32_t dwCategory, int Index) const
 
bool ShiftContents (C4Object *pNewFirst)
 
void DeleteObjects ()
 
void UpdateScriptPointers ()
 
bool CheckSort (C4ObjectList *pList)
 
void CheckCategorySort ()
 

Public Attributes

C4ObjectLinkFirst
 
C4ObjectLinkLast
 
int Mass
 
std::list< int32_t > * pEnumerated
 

Protected Member Functions

virtual void InsertLinkBefore (C4ObjectLink *pLink, C4ObjectLink *pBefore)
 
virtual void InsertLink (C4ObjectLink *pLink, C4ObjectLink *pAfter)
 
virtual void RemoveLink (C4ObjectLink *pLnk)
 
iteratorAddIter (iterator *iter) const
 
void RemoveIter (iterator *iter) const
 

Protected Attributes

iteratorFirstIter
 

Detailed Description

Definition at line 172 of file C4ObjectList.h.

Member Typedef Documentation

typedef int C4ObjectList::SortProc(C4Object *, C4Object *)
inherited

Definition at line 118 of file C4ObjectList.h.

Member Enumeration Documentation

enum C4ObjectList::SortType
inherited
Enumerator
stNone 
stMain 
stContents 
stReverse 

Definition at line 55 of file C4ObjectList.h.

Constructor & Destructor Documentation

C4NotifyingObjectList::C4NotifyingObjectList ( )
inline

Definition at line 175 of file C4ObjectList.h.

175 { }
C4NotifyingObjectList::C4NotifyingObjectList ( const C4NotifyingObjectList List)
inline

Definition at line 176 of file C4ObjectList.h.

176 : C4ObjectList(List) { }
C4NotifyingObjectList::C4NotifyingObjectList ( const C4ObjectList List)
inline

Definition at line 177 of file C4ObjectList.h.

177 : C4ObjectList(List) { }
virtual C4NotifyingObjectList::~C4NotifyingObjectList ( )
inlinevirtual

Definition at line 178 of file C4ObjectList.h.

178 { }

Member Function Documentation

bool C4ObjectList::Add ( C4Object nObj,
SortType  eSort,
C4ObjectList pLstSorted = nullptr 
)
virtualinherited

Definition at line 124 of file C4ObjectList.cpp.

References C4D_StaticBack, C4Object::Category, C4ObjectList::CheckCategorySort(), C4ObjectList::CheckSort(), C4Object::Def, C4ObjectList::First, C4ObjectList::GetLink(), C4Object::GetPlane(), C4Object::id, C4ObjectList::InsertLink(), C4ObjectList::Last, C4ObjectList::Mass, C4Object::Mass, C4ObjectLink::Next, C4ObjectLink::Obj, C4ObjectLink::Prev, C4PropList::Status, C4ObjectList::stMain, C4ObjectList::stReverse, and C4Object::Unsorted.

Referenced by C4GameObjects::Add(), C4LSectors::Add(), C4ObjectList::CompileFunc(), C4ObjectList::Copy(), C4ObjectList::DenumeratePointers(), C4Object::Enter(), C4Player::MakeCrewMember(), C4Player::PlaceReadyCrew(), C4GameObjects::PostLoad(), C4Object::StatusDeactivate(), C4LSectors::Update(), and C4MouseControl::UpdateSingleSelection().

125 {
126  C4ObjectLink *nLnk;
127  if (!nObj || !nObj->Def || !nObj->Status) return false;
128 
129 #ifdef _DEBUG
130  if (eSort==stMain)
131  {
133  if (pLstSorted)
134  assert(CheckSort(pLstSorted));
135  }
136 #endif
137 
138  // dbg: don't do double links
139  assert (!GetLink(nObj));
140 
141  // no self-sort
142  assert(pLstSorted != this);
143 
144  // Allocate new link
145  if (!(nLnk=new C4ObjectLink)) return false;
146  // Set link
147  nLnk->Obj=nObj;
148 
149  // Search insert position (default: end of list)
150  C4ObjectLink *cLnk = nullptr, *cPrev = Last;
151 
152  // Should sort?
153  if (eSort == stReverse)
154  {
155  // reverse sort: Add to beginning of list
156  cLnk = First; cPrev = nullptr;
157  }
158  else if (eSort)
159  {
160  // Sort override? Leave default as is.
161  bool fUnsorted = nObj->Unsorted;
162  if (!fUnsorted)
163  {
164  // Sort by master list?
165  if (pLstSorted)
166  {
167  cPrev = nullptr; cLnk = First;
168  while(cLnk && (!cLnk->Obj->Status || cLnk->Obj->Unsorted)) cLnk = cLnk->Next;
169 
170 #ifndef _DEBUG
171  if(cLnk)
172 #endif
173  {
174  C4ObjectLink* cLnk2;
175  for(cLnk2 = pLstSorted->First; cLnk2; cLnk2 = cLnk2->Next)
176  {
177  if(cLnk2->Obj->Status && !cLnk2->Obj->Unsorted)
178  {
179  if(cLnk2->Obj == nObj)
180  {
181  assert(!cLnk || cLnk->Obj != nObj);
182  break;
183  }
184 
185  if(cLnk && cLnk2->Obj == cLnk->Obj)
186  {
187  cPrev = cLnk;
188  cLnk = cLnk->Next;
189  while(cLnk && (!cLnk->Obj->Status || cLnk->Obj->Unsorted)) cLnk = cLnk->Next;
190 
191 #ifndef _DEBUG
192  if(!cLnk) break;
193 #endif
194  }
195  }
196  }
197 
198  assert(cLnk2 != nullptr);
199  }
200  }
201  else
202  {
203  // No master list: Find successor by matching Plane / id
204  // Sort by matching Plane/id is necessary for inventory shifting.
205  // It is not done for static back to allow multiobject outside structure.
206  // Unsorted objects are ignored in comparison.
207  if (!(nObj->Category & C4D_StaticBack))
208  for (cPrev=nullptr,cLnk=First; cLnk; cLnk=cLnk->Next)
209  if (cLnk->Obj->Status && !cLnk->Obj->Unsorted)
210  {
211  if (cLnk->Obj->GetPlane() == nObj->GetPlane())
212  if (cLnk->Obj->id == nObj->id)
213  break;
214  cPrev=cLnk;
215  }
216 
217  // Find successor by relative category
218  if(!cLnk)
219  for (cPrev=nullptr, cLnk=First; cLnk; cLnk=cLnk->Next)
220  if (cLnk->Obj->Status && !cLnk->Obj->Unsorted)
221  {
222  if (cLnk->Obj->GetPlane() <= nObj->GetPlane())
223  break;
224  cPrev=cLnk;
225  }
226  }
227 
228  cLnk = cPrev ? cPrev->Next : First;
229  }
230  }
231 
232  assert(!cPrev || cPrev->Next == cLnk);
233  assert(!cLnk || cLnk->Prev == cPrev);
234 
235  // Insert new link after predecessor
236  InsertLink(nLnk, cPrev);
237 
238 #ifdef _DEBUG
239  // Debug: Check sort
240  if (eSort == stMain)
241  {
243  if (pLstSorted)
244  assert(CheckSort(pLstSorted));
245  }
246 #endif
247 
248  // Add mass
249  Mass+=nObj->Mass;
250 
251  return true;
252 }
C4ID id
Definition: C4Object.h:108
int32_t Mass
Definition: C4Object.h:115
C4ObjectLink * First
Definition: C4ObjectList.h:51
int32_t GetPlane() const
Definition: C4Object.h:180
const C4ObjectLink * GetLink(const C4Object *pObj) const
C4ObjectLink * Next
Definition: C4ObjectList.h:29
C4Def * Def
Definition: C4Object.h:143
void CheckCategorySort()
virtual void InsertLink(C4ObjectLink *pLink, C4ObjectLink *pAfter)
int32_t Status
Definition: C4PropList.h:170
const int32_t C4D_StaticBack
Definition: C4Def.h:42
C4ObjectLink * Prev
Definition: C4ObjectList.h:29
bool Unsorted
Definition: C4Object.h:129
int32_t Category
Definition: C4Object.h:113
C4ObjectLink * Last
Definition: C4ObjectList.h:51
bool CheckSort(C4ObjectList *pList)
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the call graph for this function:

Here is the caller graph for this function:

C4ObjectList::iterator * C4ObjectList::AddIter ( iterator iter) const
protectedinherited

Definition at line 953 of file C4ObjectList.cpp.

References C4ObjectList::FirstIter.

Referenced by C4ObjectList::iterator::iterator().

954 {
955  iterator * r = FirstIter;
956  FirstIter = iter;
957  return r;
958 }
iterator * FirstIter
Definition: C4ObjectList.h:165
friend class iterator
Definition: C4ObjectList.h:169

Here is the caller graph for this function:

bool C4ObjectList::AddSortCustom ( C4Object nObj,
SortProc pSortProc 
)
inherited
bool C4ObjectList::AssignInfo ( )
virtualinherited

Reimplemented in C4GameObjects.

Definition at line 550 of file C4ObjectList.cpp.

References C4Object::AssignInfo(), C4ObjectList::Last, C4ObjectLink::Obj, C4ObjectLink::Prev, and C4PropList::Status.

Referenced by C4GameObjects::AssignInfo().

551 {
552  // the list seems to be traced backwards here, to ensure crew objects are added in correct order
553  // (or semi-correct, because this will work only if the crew order matches the main object list order)
554  // this is obsolete now, because the crew list is stored in the savegame
555  C4ObjectLink *cLnk;
556  for (cLnk=Last; cLnk; cLnk=cLnk->Prev)
557  if (cLnk->Obj->Status)
558  cLnk->Obj->AssignInfo();
559  return true;
560 }
int32_t Status
Definition: C4PropList.h:170
C4ObjectLink * Prev
Definition: C4ObjectList.h:29
C4ObjectLink * Last
Definition: C4ObjectList.h:51
bool AssignInfo()
Definition: C4Object.cpp:2401
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the call graph for this function:

Here is the caller graph for this function:

C4ObjectList::iterator C4ObjectList::begin ( ) const
inherited

Definition at line 945 of file C4ObjectList.cpp.

References C4ObjectList::First, and C4ObjectList::iterator.

Referenced by C4GameObjects::PostLoad(), and C4Object::ShiftContents().

946 {
947  return iterator(*this, First, false);
948 }
C4ObjectLink * First
Definition: C4ObjectList.h:51
friend class iterator
Definition: C4ObjectList.h:169

Here is the caller graph for this function:

void C4ObjectList::CheckCategorySort ( )
inherited

Definition at line 847 of file C4ObjectList.cpp.

References C4ObjectList::First, C4Object::GetPlane(), C4ObjectLink::Next, C4ObjectLink::Obj, C4PropList::Status, and C4Object::Unsorted.

Referenced by C4ObjectList::Add().

848 {
849  // debug: Check whether object list is sorted correctly
850  C4ObjectLink *cLnk, *cPrev=nullptr;
851  for (cLnk=First; cLnk; cLnk=cLnk->Next)
852  if (!cLnk->Obj->Unsorted && cLnk->Obj->Status)
853  {
854  if (cPrev) assert(cPrev->Obj->GetPlane() >= cLnk->Obj->GetPlane());
855  cPrev = cLnk;
856  }
857 }
C4ObjectLink * First
Definition: C4ObjectList.h:51
int32_t GetPlane() const
Definition: C4Object.h:180
C4ObjectLink * Next
Definition: C4ObjectList.h:29
int32_t Status
Definition: C4PropList.h:170
bool Unsorted
Definition: C4Object.h:129
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ObjectList::CheckSort ( C4ObjectList pList)
inherited

Definition at line 821 of file C4ObjectList.cpp.

References C4ObjectList::First, Log(), LogSilent(), mkNamingAdapt(), C4ObjectLink::Next, C4ObjectLink::Obj, C4PropList::Status, and C4Object::Unsorted.

Referenced by C4ObjectList::Add(), and C4LSectors::CheckSort().

822 {
823  C4ObjectLink *cLnk = First, *cLnk2 = pList->First;
824  while (cLnk && (!cLnk->Obj->Status || cLnk->Obj->Unsorted)) cLnk = cLnk->Next;
825 
826  while (cLnk)
827  if (!cLnk2)
828  {
829  Log("CheckSort failure");
830  C4ValueNumbers numbers;
831  LogSilent(DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(C4ObjectListDumpHelper(this, &numbers), "SectorList")).getData());
832  LogSilent(DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(C4ObjectListDumpHelper(pList, &numbers), "MainList")).getData());
833  return false;
834  }
835  else
836  {
837  if (cLnk->Obj == cLnk2->Obj)
838  {
839  cLnk = cLnk->Next;
840  while (cLnk && (!cLnk->Obj->Status || cLnk->Obj->Unsorted)) cLnk = cLnk->Next;
841  }
842  cLnk2 = cLnk2->Next;
843  }
844  return true;
845 }
bool LogSilent(const char *szMessage, bool fConsole)
Definition: C4Log.cpp:117
C4ObjectLink * First
Definition: C4ObjectList.h:51
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
C4ObjectLink * Next
Definition: C4ObjectList.h:29
int32_t Status
Definition: C4PropList.h:170
bool Unsorted
Definition: C4Object.h:129
bool Log(const char *szMessage)
Definition: C4Log.cpp:195
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ObjectList::Clear ( )
virtualinherited

Reimplemented in C4GameObjects.

Definition at line 49 of file C4ObjectList.cpp.

References C4ObjectList::First, C4ObjectList::FirstIter, C4ObjectList::Last, C4ObjectLink::Next, and C4ObjectList::pEnumerated.

Referenced by C4GameObjects::Clear(), C4MouseControl::Clear(), C4LSector::ClearObjects(), C4ObjectList::CompileFunc(), C4ObjectList::Copy(), C4GameObjects::DeleteObjects(), C4MouseControl::LeftUpDragNone(), C4GameObjects::PostLoad(), C4MouseControl::UpdateSingleSelection(), and C4ObjectList::~C4ObjectList().

50 {
51  C4ObjectLink *cLnk,*nextLnk;
52  for (cLnk=First; cLnk; cLnk=nextLnk)
53  { nextLnk=cLnk->Next; delete cLnk; }
54  First=Last=nullptr;
55  if (pEnumerated)
56  {
57  delete pEnumerated;
58  pEnumerated=nullptr;
59  }
60 
61  for (iterator* it = FirstIter; it; it = it->Next)
62  {
63  it->link = NULL_LINK;
64  }
65 }
iterator * FirstIter
Definition: C4ObjectList.h:165
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Next
Definition: C4ObjectList.h:29
friend class iterator
Definition: C4ObjectList.h:169
C4ObjectLink * Last
Definition: C4ObjectList.h:51
std::list< int32_t > * pEnumerated
Definition: C4ObjectList.h:53

Here is the caller graph for this function:

void C4ObjectList::ClearInfo ( C4ObjectInfo pInfo)
inherited

Definition at line 562 of file C4ObjectList.cpp.

References C4Object::ClearInfo(), C4ObjectList::First, C4ObjectLink::Next, C4ObjectLink::Obj, and C4PropList::Status.

Referenced by C4ObjectInfoList::DetachFromObjects().

563 {
564  C4ObjectLink *cLnk;
565  for (cLnk=First; cLnk; cLnk=cLnk->Next)
566  if (cLnk->Obj->Status)
567  cLnk->Obj->ClearInfo(pInfo);
568 }
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Next
Definition: C4ObjectList.h:29
int32_t Status
Definition: C4PropList.h:170
C4Object * Obj
Definition: C4ObjectList.h:28
void ClearInfo(C4ObjectInfo *pInfo)
Definition: C4Object.cpp:2439

Here is the call graph for this function:

Here is the caller graph for this function:

int C4ObjectList::ClearPointers ( C4Object pObj)
inherited

Definition at line 367 of file C4ObjectList.cpp.

References C4ObjectList::First, C4ObjectLink::Next, C4ObjectLink::Obj, and C4ObjectList::Remove().

Referenced by C4MouseControl::ClearPointers(), and C4Game::ClearPointers().

368 {
369  int rval=0;
370  // Clear all primary list pointers
371  while (Remove(pObj)) rval++;
372  // Clear all sub pointers
373  C4Object *cobj; C4ObjectLink *clnk;
374  for (clnk=First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
375  cobj->ClearPointers(pObj);
376  return rval;
377 }
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Next
Definition: C4ObjectList.h:29
C4Object * Obj
Definition: C4ObjectList.h:28
virtual bool Remove(C4Object *pObj)

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ObjectList::CloseMenus ( )
inherited

Definition at line 698 of file C4ObjectList.cpp.

References C4ObjectList::First, C4ObjectLink::Next, and C4ObjectLink::Obj.

699 {
700  C4Object *cobj; C4ObjectLink *clnk;
701  for (clnk=First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
702  cobj->CloseMenu(true);
703 }
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Next
Definition: C4ObjectList.h:29
C4Object * Obj
Definition: C4ObjectList.h:28
void C4ObjectList::CompileFunc ( StdCompiler pComp,
C4ValueNumbers numbers = 0 
)
inherited

Definition at line 508 of file C4ObjectList.cpp.

References C4ObjectList::First, StdCompiler::isDeserializer(), mkSTLContainerAdapt(), C4ObjectLink::Next, C4ObjectList::pEnumerated, StdCompiler::SEP_SEP2, and StdCompiler::Value().

509 {
510  // (Re)create list
511  delete pEnumerated; pEnumerated = new std::list<int32_t>();
512  // Decompiling: Build list
513  if (!pComp->isDeserializer())
514  for (C4ObjectLink *pPos = First; pPos; pPos = pPos->Next)
515  if (pPos->Obj->Status)
516  pEnumerated->push_back(pPos->Obj->Number);
517  // Compile list
519  // Decompiling: Delete list
520  if (!pComp->isDeserializer())
521  { delete pEnumerated; pEnumerated = nullptr; }
522  // Compiling: Nothing to do - list will be denumerated later
523 }
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Next
Definition: C4ObjectList.h:29
void Value(const T &rStruct)
Definition: StdCompiler.h:171
virtual bool isDeserializer()
Definition: StdCompiler.h:63
StdSTLContainerAdapt< C > mkSTLContainerAdapt(C &rTarget, StdCompiler::Sep eSep=StdCompiler::SEP_SEP)
Definition: StdAdaptors.h:679
std::list< int32_t > * pEnumerated
Definition: C4ObjectList.h:53

Here is the call graph for this function:

void C4ObjectList::CompileFunc ( StdCompiler pComp,
bool  fSkipPlayerObjects,
C4ValueNumbers numbers 
)
inherited

Definition at line 465 of file C4ObjectList.cpp.

References C4ObjectList::Add(), C4ObjectList::Clear(), StdStrBuf::getData(), StdStrBuf::getLength(), StdCompiler::hasNaming(), StdCompiler::isSerializer(), C4ObjectList::Last, LogF(), mkNamingAdapt(), mkNamingCountAdapt(), mkParAdapt(), mkPtrAdaptNoNull(), StdCompiler::Exception::Msg, C4ObjectList::ObjectCount(), StdCompiler::Exception::Pos, C4ObjectLink::Prev, C4ObjectList::stReverse, and StdCompiler::Value().

466 {
467  // "Object" section count
468  int32_t iObjCnt = ObjectCount();
469  pComp->Value(mkNamingCountAdapt(iObjCnt, "Object"));
470  if (pComp->isSerializer())
471  {
472  // skipping player objects would screw object counting in non-naming compilers
473  assert(!fSkipPlayerObjects || pComp->hasNaming());
474  // Decompile all objects in reverse order
475  for (C4ObjectLink *pPos = Last; pPos; pPos = pPos->Prev)
476  if (pPos->Obj->Status)
477  if (!fSkipPlayerObjects || !pPos->Obj->IsUserPlayerObject())
478  pComp->Value(mkNamingAdapt(mkParAdapt(*pPos->Obj, numbers), "Object"));
479  }
480  else
481  {
482  // FIXME: Check that no PlayerObjects are loaded when fSkipPlayerObjects is true
483  // i.e. that loading and saving was done with the same flag.
484  // Remove previous data
485  Clear();
486  // Load objects, add them to the list.
487  for (int i = 0; i < iObjCnt; i++)
488  {
489  C4Object *pObj = nullptr;
490  try
491  {
492  pComp->Value(mkNamingAdapt(mkParAdapt(mkPtrAdaptNoNull(pObj), numbers), "Object"));
493  Add(pObj, stReverse);
494  }
495  catch (StdCompiler::Exception *pExc)
496  {
497  // Failsafe object loading: If an error occurs during object loading, just skip that object and load the next one
498  if (!pExc->Pos.getLength())
499  LogF("ERROR: Object loading: %s", pExc->Msg.getData());
500  else
501  LogF("ERROR: Object loading(%s): %s", pExc->Pos.getData(), pExc->Msg.getData());
502  delete pExc;
503  }
504  }
505  }
506 }
const char * getData() const
Definition: StdBuf.h:450
virtual bool hasNaming()
Definition: StdCompiler.h:68
virtual bool Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted=nullptr)
StdNamingCountAdapt< int_t > mkNamingCountAdapt(int_t &iCount, const char *szName)
Definition: StdAdaptors.h:974
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
bool isSerializer()
Definition: StdCompiler.h:64
StdPtrAdapt< T > mkPtrAdaptNoNull(T *&rpObj)
Definition: StdAdaptors.h:604
void Value(const T &rStruct)
Definition: StdCompiler.h:171
C4ObjectLink * Prev
Definition: C4ObjectList.h:29
int ObjectCount(C4ID id=C4ID::None) const
C4ObjectLink * Last
Definition: C4ObjectList.h:51
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:456
size_t getLength() const
Definition: StdBuf.h:453
virtual void Clear()
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:253

Here is the call graph for this function:

void C4ObjectList::Copy ( const C4ObjectList rList)
inherited

Definition at line 705 of file C4ObjectList.cpp.

References C4ObjectList::Add(), C4ObjectList::Clear(), C4ObjectList::Default(), C4ObjectList::First, C4ObjectLink::Next, C4ObjectLink::Obj, and C4ObjectList::stNone.

Referenced by C4ObjectList::C4ObjectList(), C4Object::GrabContents(), and C4GameObjects::PostLoad().

706 {
707  Clear(); Default();
708  C4ObjectLink *cLnk;
709  for (cLnk=rList.First; cLnk; cLnk=cLnk->Next) Add(cLnk->Obj, C4ObjectList::stNone);
710 }
virtual bool Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted=nullptr)
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Next
Definition: C4ObjectList.h:29
virtual void Default()
virtual void Clear()
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ObjectList::Default ( )
virtualinherited

Reimplemented in C4GameObjects.

Definition at line 712 of file C4ObjectList.cpp.

References C4ObjectList::First, C4ObjectList::Last, C4ObjectList::Mass, and C4ObjectList::pEnumerated.

Referenced by C4ObjectList::C4ObjectList(), C4Player::C4Player(), C4ObjectList::Copy(), C4GameObjects::Default(), C4MouseControl::Default(), and C4Object::Default().

713 {
714  First=Last=nullptr;
715  Mass=0;
716  pEnumerated=nullptr;
717 }
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Last
Definition: C4ObjectList.h:51
std::list< int32_t > * pEnumerated
Definition: C4ObjectList.h:53

Here is the caller graph for this function:

void C4ObjectList::DeleteObjects ( )
inherited

Definition at line 738 of file C4ObjectList.cpp.

References C4OS_DELETED, C4Game::ClearPointers(), C4ObjectList::First, Game, C4ObjectList::Mass, C4ObjectLink::Obj, C4ObjectList::Remove(), and C4PropList::Status.

Referenced by C4GameObjects::Clear(), and C4GameObjects::DeleteObjects().

739 {
740  // delete links and objects
741  while (First)
742  {
743  C4Object *pObj = First->Obj;
744  if (pObj->Status) Game.ClearPointers(pObj); // clear pointers to removed objects that weren't deleted (game end or section change)
745  pObj->Status = C4OS_DELETED;
746  Remove(pObj);
747  delete pObj;
748  }
749  // reset mass
750  Mass=0;
751 }
C4Game Game
Definition: C4Globals.cpp:52
C4ObjectLink * First
Definition: C4ObjectList.h:51
#define C4OS_DELETED
Definition: C4Object.h:34
int32_t Status
Definition: C4PropList.h:170
void ClearPointers(C4Object *cobj)
Definition: C4Game.cpp:925
C4Object * Obj
Definition: C4ObjectList.h:28
virtual bool Remove(C4Object *pObj)

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ObjectList::Denumerate ( C4ValueNumbers numbers)
inherited

Definition at line 457 of file C4ObjectList.cpp.

References C4Object::Denumerate(), C4ObjectList::First, C4ObjectLink::Next, C4ObjectLink::Obj, and C4PropList::Status.

Referenced by C4GameObjects::Denumerate().

458 {
459  C4ObjectLink *cLnk;
460  for (cLnk=First; cLnk; cLnk=cLnk->Next)
461  if (cLnk->Obj->Status)
462  cLnk->Obj->Denumerate(numbers);
463 }
virtual void Denumerate(C4ValueNumbers *)
Definition: C4Object.cpp:2323
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Next
Definition: C4ObjectList.h:29
int32_t Status
Definition: C4PropList.h:170
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ObjectList::DenumeratePointers ( )
inherited

Definition at line 432 of file C4ObjectList.cpp.

References C4ObjectList::Add(), C4GameObjects::ObjectPointer(), Objects, C4ObjectList::pEnumerated, and C4ObjectList::stNone.

Referenced by C4Object::Denumerate(), and C4Player::DenumeratePointers().

433 {
434  if (!pEnumerated) return false;
435  // Denumerate all object pointers
436  for (std::list<int32_t>::const_iterator pNum = pEnumerated->begin(); pNum != pEnumerated->end(); ++pNum)
437  Add(::Objects.ObjectPointer(*pNum), stNone); // Add to tail, unsorted
438  // Delete old list
439  delete pEnumerated; pEnumerated = nullptr;
440  return true;
441 }
virtual bool Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted=nullptr)
std::list< int32_t > * pEnumerated
Definition: C4ObjectList.h:53
C4Object * ObjectPointer(int32_t iNumber)
C4GameObjects Objects
Definition: C4Globals.cpp:48

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ObjectList::Draw ( C4TargetFacet cgo,
int  iPlayer,
int  MinPlane,
int  MaxPlane 
)
inherited

Definition at line 379 of file C4ObjectList.cpp.

References C4D_Foreground, C4Object::Category, C4Object::Draw(), C4Object::DrawTopFace(), C4Object::GetPlane(), C4ObjectList::Last, C4ObjectLink::Obj, and C4ObjectLink::Prev.

Referenced by C4Viewport::Draw().

380 {
381  C4ObjectLink * clnk, * first;
382  for (first=Last; first; first=first->Prev)
383  if (first->Obj->GetPlane() >= MinPlane)
384  break;
385  // Draw objects (base)
386  for (clnk=first; clnk; clnk=clnk->Prev)
387  {
388  if (clnk->Obj->GetPlane() > MaxPlane)
389  break;
390  if (clnk->Obj->Category & C4D_Foreground)
391  continue;
392  clnk->Obj->Draw(cgo, iPlayer);
393  }
394  // Draw objects (top face)
395  for (clnk=first; clnk; clnk=clnk->Prev)
396  {
397  if (clnk->Obj->GetPlane() > MaxPlane)
398  break;
399  if (clnk->Obj->Category & C4D_Foreground)
400  continue;
401  clnk->Obj->DrawTopFace(cgo, iPlayer);
402  }
403 }
void Draw(C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
Definition: C4Object.cpp:1800
int32_t GetPlane() const
Definition: C4Object.h:180
void DrawTopFace(C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
Definition: C4Object.cpp:2060
C4ObjectLink * Prev
Definition: C4ObjectList.h:29
int32_t Category
Definition: C4Object.h:113
C4ObjectLink * Last
Definition: C4ObjectList.h:51
C4Object * Obj
Definition: C4ObjectList.h:28
const int32_t C4D_Foreground
Definition: C4Def.h:55

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ObjectList::DrawIfCategory ( C4TargetFacet cgo,
int  iPlayer,
uint32_t  dwCat,
bool  fInvert 
)
inherited

Definition at line 405 of file C4ObjectList.cpp.

References C4Object::Category, C4Object::Draw(), C4Object::DrawTopFace(), C4ObjectList::Last, C4ObjectLink::Obj, and C4ObjectLink::Prev.

Referenced by C4Viewport::Draw().

406 {
407  C4ObjectLink *clnk;
408  // Draw objects (base)
409  for (clnk=Last; clnk; clnk=clnk->Prev)
410  if (!(clnk->Obj->Category & dwCat) == fInvert)
411  clnk->Obj->Draw(cgo, iPlayer);
412  // Draw objects (top face)
413  for (clnk=Last; clnk; clnk=clnk->Prev)
414  if (!(clnk->Obj->Category & dwCat) == fInvert)
415  clnk->Obj->DrawTopFace(cgo, iPlayer);
416 }
void Draw(C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
Definition: C4Object.cpp:1800
void DrawTopFace(C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
Definition: C4Object.cpp:2060
C4ObjectLink * Prev
Definition: C4ObjectList.h:29
int32_t Category
Definition: C4Object.h:113
C4ObjectLink * Last
Definition: C4ObjectList.h:51
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ObjectList::DrawSelectMark ( C4TargetFacet cgo) const
inherited

Definition at line 691 of file C4ObjectList.cpp.

References C4Object::DrawSelectMark(), C4ObjectList::Last, C4ObjectLink::Obj, and C4ObjectLink::Prev.

Referenced by C4MouseControl::Draw().

692 {
693  C4ObjectLink *cLnk;
694  for (cLnk=Last; cLnk; cLnk=cLnk->Prev)
695  cLnk->Obj->DrawSelectMark(cgo);
696 }
void DrawSelectMark(C4TargetFacet &cgo) const
Definition: C4Object.cpp:2525
C4ObjectLink * Prev
Definition: C4ObjectList.h:29
C4ObjectLink * Last
Definition: C4ObjectList.h:51
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the call graph for this function:

Here is the caller graph for this function:

const C4ObjectList::iterator C4ObjectList::end ( ) const
inherited

Definition at line 949 of file C4ObjectList.cpp.

References C4ObjectList::iterator.

Referenced by C4ObjectListIterator::GetNext().

950 {
951  return iterator(*this, nullptr, false);
952 }
friend class iterator
Definition: C4ObjectList.h:169

Here is the caller graph for this function:

C4Object * C4ObjectList::Find ( C4Def def,
int  iOwner = ANY_OWNER,
DWORD  dwOCF = OCF_All 
)
inherited

Definition at line 297 of file C4ObjectList.cpp.

References ANY_OWNER, C4Object::Def, C4ObjectList::First, C4ObjectLink::Next, C4ObjectLink::Obj, C4Object::OCF, C4Object::Owner, and C4PropList::Status.

Referenced by C4Command::Acquire(), C4ObjectMenu::DoRefillInternal(), C4RoundResults::EvaluateGoals(), C4Command::Get(), C4MainMenu::MenuCommand(), and C4Command::Put().

298 {
299  C4ObjectLink *cLnk;
300  // Find link and object
301  for (cLnk=First; cLnk; cLnk=cLnk->Next)
302  if (cLnk->Obj->Status)
303  if (cLnk->Obj->Def==def)
304  if ((owner==ANY_OWNER) || (cLnk->Obj->Owner==owner))
305  if (dwOCF & cLnk->Obj->OCF)
306  return cLnk->Obj;
307  return nullptr;
308 }
C4ObjectLink * First
Definition: C4ObjectList.h:51
const int ANY_OWNER
Definition: C4Constants.h:139
C4ObjectLink * Next
Definition: C4ObjectList.h:29
C4Def * Def
Definition: C4Object.h:143
int32_t Owner
Definition: C4Object.h:110
int32_t Status
Definition: C4PropList.h:170
uint32_t OCF
Definition: C4Object.h:134
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the caller graph for this function:

C4Object * C4ObjectList::FindOther ( C4ID  id,
int  iOwner = ANY_OWNER 
)
inherited

Definition at line 310 of file C4ObjectList.cpp.

References ANY_OWNER, C4Object::Def, C4ObjectList::First, C4Def::id, C4ObjectLink::Next, C4ObjectLink::Obj, C4Object::Owner, and C4PropList::Status.

311 {
312  C4ObjectLink *cLnk;
313  // Find link and object
314  for (cLnk=First; cLnk; cLnk=cLnk->Next)
315  if (cLnk->Obj->Status)
316  if (cLnk->Obj->Def->id!=id)
317  if ((owner==ANY_OWNER) || (cLnk->Obj->Owner==owner))
318  return cLnk->Obj;
319  return nullptr;
320 }
C4ID id
Definition: C4Def.h:103
C4ObjectLink * First
Definition: C4ObjectList.h:51
const int ANY_OWNER
Definition: C4Constants.h:139
C4ObjectLink * Next
Definition: C4ObjectList.h:29
C4Def * Def
Definition: C4Object.h:143
int32_t Owner
Definition: C4Object.h:110
int32_t Status
Definition: C4PropList.h:170
C4Object * Obj
Definition: C4ObjectList.h:28
C4Object* C4ObjectList::GetFirstObject ( ) const
inlineinherited

Definition at line 141 of file C4ObjectList.h.

References C4ObjectLink::Obj.

Referenced by C4Player::CheckElimination().

141 { return First ? First->Obj : nullptr; }
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the caller graph for this function:

C4Object* C4ObjectList::GetLastObject ( ) const
inlineinherited

Definition at line 142 of file C4ObjectList.h.

References C4ObjectLink::Obj.

Referenced by C4Object::PutAwayUnusedObject().

142 { return Last ? Last->Obj : nullptr; }
C4ObjectLink * Last
Definition: C4ObjectList.h:51
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the caller graph for this function:

const C4ObjectLink * C4ObjectList::GetLink ( const C4Object pObj) const
inherited

Definition at line 336 of file C4ObjectList.cpp.

References C4ObjectList::First, C4ObjectLink::Next, and C4ObjectLink::Obj.

Referenced by C4ObjectList::Add(), C4Object::AssignInfo(), C4Command::Drop(), C4ObjectList::GetLink(), C4Player::MakeCrewMember(), C4GameObjects::PostLoad(), C4Command::Put(), C4ObjectList::Remove(), C4ObjectList::ShiftContents(), and C4Command::Throw().

337 {
338  if (!pObj) return nullptr;
339  C4ObjectLink *cLnk;
340  for (cLnk=First; cLnk; cLnk=cLnk->Next)
341  if (cLnk->Obj==pObj)
342  return cLnk;
343  return nullptr;
344 }
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Next
Definition: C4ObjectList.h:29
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the caller graph for this function:

C4ObjectLink* C4ObjectList::GetLink ( const C4Object pObj)
inlineinherited

Definition at line 147 of file C4ObjectList.h.

References C4ObjectList::GetLink().

148  { return const_cast<C4ObjectLink*>(const_cast<const C4ObjectList*>(this)->GetLink(pObj)); }
const C4ObjectLink * GetLink(const C4Object *pObj) const

Here is the call graph for this function:

C4ID C4ObjectList::GetListID ( int32_t  dwCategory,
int  Index 
) const
inherited

Definition at line 70 of file C4ObjectList.cpp.

References C4D_All, C4Id2Def(), C4Def::Category, C4Object::Def, C4ObjectList::First, C4Def::id, Inside(), MaxTempListID, C4ObjectLink::Next, C4ID::None, C4ObjectLink::Obj, and C4PropList::Status.

Referenced by C4MainMenu::ActivateRules(), C4RoundResults::EvaluateGoals(), and C4ObjectList::GetNameList().

71 {
72  int clid;
73  C4ObjectLink *clnk;
74  C4Def *cdef;
75 
76  // Create a temporary list of all id's and counts
77  for (clid=0; clid<MaxTempListID; clid++) TempListID[clid]=C4ID::None;
78  for (clnk=First; clnk && clnk->Obj; clnk=clnk->Next)
79  if (clnk->Obj->Status)
80  if ((dwCategory==C4D_All) || ( (cdef=C4Id2Def(clnk->Obj->Def->id)) && (cdef->Category & dwCategory) ))
81  for (clid=0; clid<MaxTempListID; clid++)
82  {
83  // Already there
84  if (TempListID[clid]==clnk->Obj->Def->id) break;
85  // End of list, add id
86  if (TempListID[clid]==C4ID::None) { TempListID[clid]=clnk->Obj->Def->id; break; }
87  }
88 
89  // Returns indexed id
90  if (Inside(Index,0,MaxTempListID-1)) return TempListID[Index];
91 
92  return C4ID::None;
93 }
C4ID id
Definition: C4Def.h:103
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Next
Definition: C4ObjectList.h:29
C4Def * Def
Definition: C4Object.h:143
static const C4ID None
Definition: C4Id.h:42
const int MaxTempListID
const int32_t C4D_All
Definition: C4Def.h:41
Definition: C4Def.h:100
int32_t Status
Definition: C4PropList.h:170
C4ID TempListID[MaxTempListID]
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:80
int32_t Category
Definition: C4Def.h:119
C4Object * Obj
Definition: C4ObjectList.h:28
bool Inside(T ival, U lbound, V rbound)
Definition: Standard.h:45

Here is the call graph for this function:

Here is the caller graph for this function:

StdStrBuf C4ObjectList::GetNameList ( C4DefList rDefs) const
inherited

Definition at line 525 of file C4ObjectList.cpp.

References StdStrBuf::Append(), StdStrBuf::AppendFormat(), C4D_All, C4ObjectList::GetListID(), C4PropListStatic::GetName(), C4DefList::ID2Def(), and C4ObjectList::ObjectCount().

Referenced by C4Object::GetDataString().

526 {
527  int cpos,idcount;
528  C4ID c_id;
529  C4Def *cdef;
530  StdStrBuf Buf;
531  for (cpos=0; (c_id=GetListID(C4D_All,cpos)); cpos++)
532  if ((cdef=rDefs.ID2Def(c_id)))
533  {
534  idcount=ObjectCount(c_id);
535  if (cpos>0) Buf.Append(", ");
536  Buf.AppendFormat("%dx %s",idcount,cdef->GetName());
537  }
538  return Buf;
539 }
C4Def * ID2Def(C4ID id)
virtual const char * GetName() const
Definition: C4PropList.cpp:267
void AppendFormat(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:197
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:527
const int32_t C4D_All
Definition: C4Def.h:41
Definition: C4Def.h:100
Definition: C4Id.h:28
int ObjectCount(C4ID id=C4ID::None) const
C4ID GetListID(int32_t dwCategory, int Index) const

Here is the call graph for this function:

Here is the caller graph for this function:

C4Object * C4ObjectList::GetObject ( int  Index = 0) const
inherited

Definition at line 322 of file C4ObjectList.cpp.

References C4ObjectList::First, C4ObjectLink::Next, C4ObjectLink::Obj, and C4PropList::Status.

Referenced by C4Object::AssignDeath(), C4Object::DirectComContents(), C4Object::DoCon(), C4MouseControl::LeftUpDragNone(), ObjectActionThrow(), ObjectComDrop(), ObjectComPut(), ObjectComPutTake(), ObjectComThrow(), C4Command::Put(), C4Player::RemoveCrewObjects(), C4MouseControl::RightUpDragNone(), C4Object::ShiftContents(), and C4MouseControl::UpdateSingleSelection().

323 {
324  int cIdx;
325  C4ObjectLink *cLnk;
326  // Find link and object
327  for (cLnk=First,cIdx=0; cLnk; cLnk=cLnk->Next)
328  if (cLnk->Obj->Status)
329  {
330  if (cIdx==Index) return cLnk->Obj;
331  cIdx++;
332  }
333  return nullptr;
334 }
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Next
Definition: C4ObjectList.h:29
int32_t Status
Definition: C4PropList.h:170
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the caller graph for this function:

void C4NotifyingObjectList::InsertLink ( C4ObjectLink pLink,
C4ObjectLink pAfter 
)
protectedvirtual

Reimplemented from C4ObjectList.

Definition at line 663 of file C4ObjectList.cpp.

References C4ObjectList::InsertLink(), ObjectListChangeListener, and C4ObjectListChangeListener::OnObjectAdded().

664 {
665  C4ObjectList::InsertLink(pLink, pAfter);
667 }
virtual void OnObjectAdded(C4ObjectList *pList, C4ObjectLink *pLnk)
Definition: C4ObjectList.h:36
virtual void InsertLink(C4ObjectLink *pLink, C4ObjectLink *pAfter)
C4ObjectListChangeListener & ObjectListChangeListener

Here is the call graph for this function:

void C4NotifyingObjectList::InsertLinkBefore ( C4ObjectLink pLink,
C4ObjectLink pBefore 
)
protectedvirtual

Reimplemented from C4ObjectList.

Definition at line 657 of file C4ObjectList.cpp.

References C4ObjectList::InsertLinkBefore(), ObjectListChangeListener, and C4ObjectListChangeListener::OnObjectAdded().

658 {
659  C4ObjectList::InsertLinkBefore(pLink, pBefore);
661 }
virtual void InsertLinkBefore(C4ObjectLink *pLink, C4ObjectLink *pBefore)
virtual void OnObjectAdded(C4ObjectList *pList, C4ObjectLink *pLnk)
Definition: C4ObjectList.h:36
C4ObjectListChangeListener & ObjectListChangeListener

Here is the call graph for this function:

bool C4ObjectList::IsClear ( ) const
inherited

Definition at line 427 of file C4ObjectList.cpp.

References C4ObjectList::ObjectCount().

428 {
429  return (ObjectCount()==0);
430 }
int ObjectCount(C4ID id=C4ID::None) const

Here is the call graph for this function:

bool C4ObjectList::IsContained ( const C4Object pObj) const
inherited

Definition at line 418 of file C4ObjectList.cpp.

References C4ObjectList::First, C4ObjectLink::Next, and C4ObjectLink::Obj.

Referenced by C4LSectors::AssertObjectNotInList(), C4Object::IsPlayerObject(), C4Player::NotifyOwnedObjects(), and C4Player::SetObjectCrewStatus().

419 {
420  C4ObjectLink *cLnk;
421  for (cLnk=First; cLnk; cLnk=cLnk->Next)
422  if (cLnk->Obj==pObj)
423  return true;
424  return false;
425 }
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Next
Definition: C4ObjectList.h:29
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the caller graph for this function:

int C4ObjectList::ListIDCount ( int32_t  dwCategory) const
inherited

Definition at line 95 of file C4ObjectList.cpp.

References C4D_All, C4Id2Def(), C4Def::Category, C4Object::Def, C4ObjectList::First, C4Def::id, MaxTempListID, C4ObjectLink::Next, C4ID::None, C4ObjectLink::Obj, and C4PropList::Status.

96 {
97  int clid;
98  C4ObjectLink *clnk;
99  C4Def *cdef;
100 
101  // Create a temporary list of all id's and counts
102  for (clid=0; clid<MaxTempListID; clid++) TempListID[clid]=C4ID::None;
103  for (clnk=First; clnk && clnk->Obj; clnk=clnk->Next)
104  if (clnk->Obj->Status)
105  if ((dwCategory==C4D_All) || ( (cdef=C4Id2Def(clnk->Obj->Def->id)) && (cdef->Category & dwCategory) ))
106  for (clid=0; clid<MaxTempListID; clid++)
107  {
108  // Already there
109  if (TempListID[clid]==clnk->Obj->Def->id) break;
110  // End of list, add id
111  if (TempListID[clid]==C4ID::None) { TempListID[clid]=clnk->Obj->Def->id; break; }
112  }
113 
114  // Count different id's
115  for (clid=0; clid<MaxTempListID; clid++)
116  if (TempListID[clid]==C4ID::None)
117  return clid;
118 
119  return MaxTempListID;
120 }
C4ID id
Definition: C4Def.h:103
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Next
Definition: C4ObjectList.h:29
C4Def * Def
Definition: C4Object.h:143
static const C4ID None
Definition: C4Id.h:42
const int MaxTempListID
const int32_t C4D_All
Definition: C4Def.h:41
Definition: C4Def.h:100
int32_t Status
Definition: C4PropList.h:170
C4ID TempListID[MaxTempListID]
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:80
int32_t Category
Definition: C4Def.h:119
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the call graph for this function:

int C4ObjectList::MassCount ( )
inherited

Definition at line 356 of file C4ObjectList.cpp.

References C4ObjectList::First, C4ObjectList::Mass, C4Object::Mass, C4ObjectLink::Next, C4ObjectLink::Obj, and C4PropList::Status.

Referenced by C4Object::UpdateMass().

357 {
358  C4ObjectLink *cLnk;
359  int iMass=0;
360  for (cLnk=First; cLnk; cLnk=cLnk->Next)
361  if (cLnk->Obj->Status)
362  iMass+=cLnk->Obj->Mass;
363  Mass=iMass;
364  return iMass;
365 }
int32_t Mass
Definition: C4Object.h:115
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Next
Definition: C4ObjectList.h:29
int32_t Status
Definition: C4PropList.h:170
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the caller graph for this function:

int C4ObjectList::ObjectCount ( C4ID  id = C4ID::None) const
inherited

Definition at line 346 of file C4ObjectList.cpp.

References C4Object::Def, C4ObjectList::First, C4Def::id, C4ObjectLink::Next, C4ID::None, C4ObjectLink::Obj, and C4PropList::Status.

Referenced by C4Object::AssignDeath(), C4ObjectList::CompileFunc(), C4Game::CompileRuntimeData(), C4FindObject::Count(), C4EditCursor::DoContextMenu(), C4ObjectMenu::DoRefillInternal(), C4ObjectMenu::Execute(), C4Network2Stats::ExecuteFrame(), C4Object::GetDataString(), C4ObjectList::GetNameList(), C4Game::InitGameFinal(), C4ObjectList::IsClear(), C4GameObjects::PostLoad(), C4ControlSyncCheck::Set(), and C4MouseControl::UpdateSingleSelection().

347 {
348  C4ObjectLink *cLnk;
349  int iCount=0;
350  for (cLnk=First; cLnk; cLnk=cLnk->Next)
351  if (cLnk->Obj->Status && (id==C4ID::None || cLnk->Obj->Def->id==id))
352  iCount++;
353  return iCount;
354 }
C4ID id
Definition: C4Def.h:103
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Next
Definition: C4ObjectList.h:29
C4Def * Def
Definition: C4Object.h:143
static const C4ID None
Definition: C4Id.h:42
int32_t Status
Definition: C4PropList.h:170
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the caller graph for this function:

bool C4ObjectList::Remove ( C4Object pObj)
virtualinherited

Reimplemented in C4GameObjects.

Definition at line 254 of file C4ObjectList.cpp.

References BREAKPOINT_HERE, C4ObjectList::First, C4ObjectList::FirstIter, C4ObjectList::GetLink(), C4ObjectList::Mass, C4Object::Mass, C4ObjectLink::Next, C4ObjectLink::Obj, C4ObjectLink::Prev, and C4ObjectList::RemoveLink().

Referenced by C4Object::AssignInfo(), C4Object::AssignRemoval(), C4ObjectList::ClearPointers(), C4Player::ClearPointers(), C4Object::ClearPointers(), C4ObjectList::DeleteObjects(), C4Object::Exit(), C4GameObjects::PostLoad(), C4GameObjects::Remove(), C4LSectors::Remove(), C4Player::SetObjectCrewStatus(), C4Object::StatusActivate(), and C4LSectors::Update().

255 {
256  C4ObjectLink *cLnk;
257 
258  // Find link
259  for (cLnk=First; cLnk; cLnk=cLnk->Next)
260  if (cLnk->Obj==pObj) break;
261  if (!cLnk) return false;
262 
263  // Fix iterators
264  for (iterator * i = FirstIter; i; i = i->Next)
265  {
266  // adjust pointers of internal link field
267  if (i->link.Prev == cLnk)
268  {
269  i->link.Prev = cLnk->Prev;
270  }
271  else if (i->link.Next == cLnk)
272  {
273  i->link.Next = cLnk->Next;
274  }
275  else if (i->link.Obj == cLnk->Obj)
276  {
277  i->link.Obj = nullptr;
278  }
279  }
280 
281  // Remove link from list
282  RemoveLink(cLnk);
283 
284  // Deallocate link
285  delete cLnk;
286 
287  // Remove mass
288  Mass-=pObj->Mass; if (Mass<0) Mass=0;
289 
290 #if defined(_DEBUG)
291  if (GetLink(pObj)) BREAKPOINT_HERE;
292 #endif
293 
294  return true;
295 }
int32_t Mass
Definition: C4Object.h:115
virtual void RemoveLink(C4ObjectLink *pLnk)
iterator * FirstIter
Definition: C4ObjectList.h:165
C4ObjectLink * First
Definition: C4ObjectList.h:51
const C4ObjectLink * GetLink(const C4Object *pObj) const
C4ObjectLink * Next
Definition: C4ObjectList.h:29
#define BREAKPOINT_HERE
C4ObjectLink * Prev
Definition: C4ObjectList.h:29
friend class iterator
Definition: C4ObjectList.h:169
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ObjectList::RemoveIter ( iterator iter) const
protectedinherited

Definition at line 959 of file C4ObjectList.cpp.

References C4ObjectList::FirstIter.

Referenced by C4ObjectList::iterator::~iterator().

960 {
961  if (iter == FirstIter)
962  FirstIter = iter->Next;
963  else
964  {
965  iterator * i = FirstIter;
966  while (i->Next && i->Next != iter)
967  i = i->Next;
968  i->Next = iter->Next;
969  }
970 }
iterator * FirstIter
Definition: C4ObjectList.h:165
friend class iterator
Definition: C4ObjectList.h:169

Here is the caller graph for this function:

void C4NotifyingObjectList::RemoveLink ( C4ObjectLink pLnk)
protectedvirtual

Reimplemented from C4ObjectList.

Definition at line 669 of file C4ObjectList.cpp.

References ObjectListChangeListener, C4ObjectListChangeListener::OnObjectRemove(), and C4ObjectList::RemoveLink().

670 {
673 }
virtual void RemoveLink(C4ObjectLink *pLnk)
C4ObjectListChangeListener & ObjectListChangeListener
virtual void OnObjectRemove(C4ObjectList *pList, C4ObjectLink *pLnk)
Definition: C4ObjectList.h:35

Here is the call graph for this function:

const ReverseView C4ObjectList::reverse ( ) const
inlineinherited

Definition at line 104 of file C4ObjectList.h.

Referenced by C4GameObjects::AssignLightRange(), C4Game::ExecObjects(), C4ObjectList::iterator::operator==(), C4GameObjects::PostLoad(), and C4Object::ShiftContents().

104 { return ReverseView(*this); }

Here is the caller graph for this function:

bool C4ObjectList::ShiftContents ( C4Object pNewFirst)
inherited

Definition at line 719 of file C4ObjectList.cpp.

References C4ObjectList::First, C4ObjectList::GetLink(), C4ObjectList::Last, C4ObjectLink::Next, and C4ObjectLink::Prev.

Referenced by C4Object::DirectComContents().

720 {
721  // get link of new first (this ensures list is not empty)
722  C4ObjectLink *pNewFirstLnk = GetLink(pNewFirst);
723  if (!pNewFirstLnk) return false;
724  // already at front?
725  if (pNewFirstLnk == First) return true;
726  // sort it there:
727  // 1. Make cyclic list
728  Last->Next = First; First->Prev = Last;
729  // 2. Re-set first and last
730  First = pNewFirstLnk;
731  Last = pNewFirstLnk->Prev;
732  // 3. Uncycle list
733  First->Prev = Last->Next = nullptr;
734  // done, success
735  return true;
736 }
C4ObjectLink * First
Definition: C4ObjectList.h:51
const C4ObjectLink * GetLink(const C4Object *pObj) const
C4ObjectLink * Next
Definition: C4ObjectList.h:29
C4ObjectLink * Prev
Definition: C4ObjectList.h:29
C4ObjectLink * Last
Definition: C4ObjectList.h:51

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ObjectList::Sort ( )
inherited

Definition at line 570 of file C4ObjectList.cpp.

References C4ObjectList::First, C4Object::id, C4ObjectList::InsertLink(), C4ObjectLink::Next, C4ObjectLink::Obj, and C4ObjectList::RemoveLink().

571 {
572  C4ObjectLink *cLnk;
573  bool fSorted;
574  // Sort by id
575  do
576  {
577  fSorted = true;
578  for (cLnk=First; cLnk && cLnk->Next; cLnk=cLnk->Next)
579  if (cLnk->Obj->id > cLnk->Next->Obj->id)
580  {
581  RemoveLink(cLnk);
582  InsertLink(cLnk,cLnk->Next);
583  fSorted = false;
584  break;
585  }
586  }
587  while (!fSorted);
588 }
C4ID id
Definition: C4Object.h:108
virtual void RemoveLink(C4ObjectLink *pLnk)
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Next
Definition: C4ObjectList.h:29
virtual void InsertLink(C4ObjectLink *pLink, C4ObjectLink *pAfter)
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the call graph for this function:

void C4ObjectList::UpdateFaces ( bool  bUpdateShape)
inherited

Definition at line 683 of file C4ObjectList.cpp.

References C4ObjectList::First, C4ObjectLink::Next, C4ObjectLink::Obj, C4PropList::Status, and C4Object::UpdateFace().

Referenced by C4GameObjects::PostLoad().

684 {
685  C4ObjectLink *cLnk;
686  for (cLnk=First; cLnk; cLnk=cLnk->Next)
687  if (cLnk->Obj->Status)
688  cLnk->Obj->UpdateFace(bUpdateShapes);
689 }
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Next
Definition: C4ObjectList.h:29
int32_t Status
Definition: C4PropList.h:170
void UpdateFace(bool bUpdateShape, bool fTemp=false)
Definition: C4Object.cpp:381
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ObjectList::UpdateGraphics ( bool  fGraphicsChanged)
inherited

Definition at line 675 of file C4ObjectList.cpp.

References C4ObjectList::First, C4ObjectLink::Next, C4ObjectLink::Obj, C4PropList::Status, and C4Object::UpdateGraphics().

Referenced by C4GameObjects::PostLoad().

676 {
677  C4ObjectLink *cLnk;
678  for (cLnk=First; cLnk; cLnk=cLnk->Next)
679  if (cLnk->Obj->Status)
680  cLnk->Obj->UpdateGraphics(fGraphicsChanged);
681 }
C4ObjectLink * First
Definition: C4ObjectList.h:51
void UpdateGraphics(bool fGraphicsChanged, bool fTemp=false)
Definition: C4Object.cpp:407
C4ObjectLink * Next
Definition: C4ObjectList.h:29
int32_t Status
Definition: C4PropList.h:170
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ObjectList::UpdateScriptPointers ( )
inherited

Definition at line 805 of file C4ObjectList.cpp.

References C4ObjectList::First, and C4ObjectLink::Next.

Referenced by C4GameObjects::UpdateScriptPointers().

806 {
807  for (C4ObjectLink *cLnk=First; cLnk; cLnk=cLnk->Next)
808  cLnk->Obj->UpdateScriptPointers();
809 }
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Next
Definition: C4ObjectList.h:29

Here is the caller graph for this function:

bool C4ObjectList::ValidateOwners ( )
virtualinherited

Reimplemented in C4GameObjects.

Definition at line 541 of file C4ObjectList.cpp.

References C4ObjectList::First, C4ObjectLink::Next, C4ObjectLink::Obj, C4PropList::Status, and C4Object::ValidateOwner().

Referenced by C4GameObjects::ValidateOwners().

542 {
543  C4ObjectLink *cLnk;
544  for (cLnk=First; cLnk; cLnk=cLnk->Next)
545  if (cLnk->Obj->Status)
546  cLnk->Obj->ValidateOwner();
547  return true;
548 }
C4ObjectLink * First
Definition: C4ObjectList.h:51
bool ValidateOwner()
Definition: C4Object.cpp:2391
C4ObjectLink * Next
Definition: C4ObjectList.h:29
int32_t Status
Definition: C4PropList.h:170
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ObjectList::Write ( char *  szTarget)
inherited

Definition at line 443 of file C4ObjectList.cpp.

References C4ObjectList::First, C4ObjectLink::Next, C4PropListNumbered::Number, C4ObjectLink::Obj, SAppend(), sprintf, and C4PropList::Status.

444 {
445  char ostr[25];
446  szTarget[0]=0;
447  C4ObjectLink *cLnk;
448  for (cLnk=First; cLnk && cLnk->Obj; cLnk=cLnk->Next)
449  if (cLnk->Obj->Status)
450  {
451  sprintf(ostr,"%d;",cLnk->Obj->Number);
452  SAppend(ostr,szTarget);
453  }
454  return true;
455 }
void SAppend(const char *szSource, char *szTarget, int iMaxL)
Definition: Standard.cpp:227
#define sprintf
Definition: Standard.h:171
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Next
Definition: C4ObjectList.h:29
int32_t Status
Definition: C4PropList.h:170
C4Object * Obj
Definition: C4ObjectList.h:28

Here is the call graph for this function:

Member Data Documentation

std::list<int32_t>* C4ObjectList::pEnumerated
inherited

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