OpenClonk
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 ()=default
 
 C4NotifyingObjectList (const C4NotifyingObjectList &list)=default
 
 C4NotifyingObjectList (const C4ObjectList &list)
 
 ~C4NotifyingObjectList () override=default
 
iterator begin () const
 
const iterator end () const
 
const ReverseView reverse () const
 
virtual void Default ()
 
virtual void Clear ()
 
void Sort ()
 
void Copy (const C4ObjectList &list)
 
void DrawIfCategory (C4TargetFacet &cgo, int player, uint32_t dwCategory, bool invert)
 
void Draw (C4TargetFacet &cgo, int player, int MinPlane, int MaxPlane)
 
void DrawSelectMark (C4TargetFacet &cgo) const
 
void CloseMenus ()
 
void UpdateGraphics (bool graphics_changed)
 
void UpdateFaces (bool update_shape)
 
void ClearInfo (C4ObjectInfo *info)
 
virtual bool Add (C4Object *new_obj, SortType sort_type, C4ObjectList *sorted_list=nullptr)
 
bool AddSortCustom (C4Object *new_obj, SortProc &pSortProc)
 
virtual bool Remove (C4Object *obj)
 
virtual bool AssignInfo ()
 
virtual bool ValidateOwners ()
 
StdStrBuf GetNameList (C4DefList &defs) const
 
bool IsClear () const
 
bool DenumeratePointers ()
 
bool Write (char *szTarget)
 
void CompileFunc (StdCompiler *pComp, C4ValueNumbers *=nullptr)
 
void CompileFunc (StdCompiler *pComp, bool skip_player_objects, C4ValueNumbers *)
 
void Denumerate (C4ValueNumbers *)
 
bool IsContained (const C4Object *obj) const
 
int ClearPointers (C4Object *obj)
 
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 owner=ANY_OWNER, DWORD dwOCF=OCF_All)
 
C4ObjectFindOther (C4ID id, int owner=ANY_OWNER)
 
const C4ObjectLinkGetLink (const C4Object *obj) const
 
C4ObjectLinkGetLink (const C4Object *obj)
 
C4ID GetListID (int32_t dwCategory, int index) const
 
bool ShiftContents (C4Object *new_first)
 
void DeleteObjects ()
 
void UpdateScriptPointers ()
 
bool CheckSort (C4ObjectList *list)
 
void CheckCategorySort ()
 

Public Attributes

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

Protected Member Functions

void InsertLinkBefore (C4ObjectLink *link, C4ObjectLink *before_link) override
 
void InsertLink (C4ObjectLink *link, C4ObjectLink *after_link) override
 
void RemoveLink (C4ObjectLink *link) override
 
iteratorAddIter (iterator *iter) const
 
void RemoveIter (iterator *iter) const
 

Protected Attributes

iteratorFirstIter {nullptr}
 

Detailed Description

Definition at line 172 of file C4ObjectList.h.

Member Typedef Documentation

◆ SortProc

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

Definition at line 118 of file C4ObjectList.h.

Member Enumeration Documentation

◆ SortType

enum C4ObjectList::SortType
inherited
Enumerator
stNone 
stMain 
stContents 
stReverse 

Definition at line 55 of file C4ObjectList.h.

Constructor & Destructor Documentation

◆ C4NotifyingObjectList() [1/3]

C4NotifyingObjectList::C4NotifyingObjectList ( )
default

◆ C4NotifyingObjectList() [2/3]

C4NotifyingObjectList::C4NotifyingObjectList ( const C4NotifyingObjectList list)
default

◆ C4NotifyingObjectList() [3/3]

C4NotifyingObjectList::C4NotifyingObjectList ( const C4ObjectList list)
inline

Definition at line 177 of file C4ObjectList.h.

177 : C4ObjectList(list) { }

◆ ~C4NotifyingObjectList()

C4NotifyingObjectList::~C4NotifyingObjectList ( )
overridedefault

Member Function Documentation

◆ Add()

bool C4ObjectList::Add ( C4Object new_obj,
SortType  sort_type,
C4ObjectList sorted_list = nullptr 
)
virtualinherited

Definition at line 164 of file C4ObjectList.cpp.

165 {
166  if (!new_obj || !new_obj->Def || !new_obj->Status)
167  {
168  return false;
169  }
170 
171 #ifdef _DEBUG
172  if (sort_type == stMain)
173  {
175  if (sorted_list)
176  {
177  assert(CheckSort(sorted_list));
178  }
179  }
180 #endif
181 
182  // Debug: don't do double links
183  assert(!GetLink(new_obj));
184 
185  // No self-sort
186  assert(sorted_list != this);
187 
188  // Allocate new link
189  C4ObjectLink *new_link = new C4ObjectLink;
190  if (!new_link)
191  {
192  return false;
193  }
194  // Set link
195  new_link->Obj = new_obj;
196 
197  // Search insert position (default: end of list)
198  C4ObjectLink *current = nullptr;
199  C4ObjectLink *previous = Last;
200 
201  // Should sort?
202  if (sort_type == stReverse)
203  {
204  // Reverse sort: Add to beginning of list
205  current = First;
206  previous = nullptr;
207  }
208  else if (sort_type)
209  {
210  // Sort override? Leave default as is.
211  bool is_sorted = !(new_obj->Unsorted);
212  if (is_sorted)
213  {
214  // Sort by master list?
215  if (sorted_list)
216  {
217  previous = nullptr;
218  current = First;
219  while (current && (!current->Obj->Status || current->Obj->Unsorted))
220  {
221  current = current->Next;
222  }
223 
224 #ifndef _DEBUG
225  if (current)
226 #endif
227  {
228  C4ObjectLink* link2;
229  for (link2 = sorted_list->First; link2; link2 = link2->Next)
230  {
231  if (link2->Obj->Status && !link2->Obj->Unsorted)
232  {
233  if (link2->Obj == new_obj)
234  {
235  assert(!current || current->Obj != new_obj);
236  break;
237  }
238 
239  if (current && link2->Obj == current->Obj)
240  {
241  previous = current;
242  current = current->Next;
243  while (current && (!current->Obj->Status || current->Obj->Unsorted))
244  {
245  current = current->Next;
246  }
247 
248 #ifndef _DEBUG
249  if (!current)
250  {
251  break;
252  }
253 #endif
254  }
255  }
256  }
257 
258  assert(link2 != nullptr);
259  }
260  }
261  else
262  {
263  // No master list: Find successor by matching Plane / id
264  // Sort by matching Plane/id is necessary for inventory shifting.
265  // It is not done for static back to allow multiobject outside structure.
266  // Unsorted objects are ignored in comparison.
267  if (!(new_obj->Category & C4D_StaticBack))
268  {
269  for (previous = nullptr, current = First; current; current = current->Next)
270  {
271  if (current->Obj->Status && !current->Obj->Unsorted)
272  {
273  if ((current->Obj->GetPlane() == new_obj->GetPlane())
274  && (current->Obj->id == new_obj->id))
275  {
276  break;
277  }
278  previous = current;
279  }
280  }
281  }
282 
283  // Find successor by relative category
284  if (!current)
285  {
286  for (previous = nullptr, current = First; current; current = current->Next)
287  {
288  if (current->Obj->Status && !current->Obj->Unsorted)
289  {
290  if (current->Obj->GetPlane() <= new_obj->GetPlane())
291  {
292  break;
293  }
294  previous = current;
295  }
296  }
297  }
298  }
299 
300  current = previous ? previous->Next : First;
301  }
302  }
303 
304  assert(!previous || previous->Next == current);
305  assert(!current || current->Prev == previous);
306 
307  // Insert new link after predecessor
308  InsertLink(new_link, previous);
309 
310 #ifdef _DEBUG
311  // Debug: Check sort
312  if (sort_type == stMain)
313  {
315  if (sorted_list)
316  {
317  assert(CheckSort(sorted_list));
318  }
319  }
320 #endif
321 
322  // Add mass
323  Mass += new_obj->Mass;
324 
325  return true;
326 }
const int32_t C4D_StaticBack
Definition: C4Def.h:40
C4ObjectLink * Prev
Definition: C4ObjectList.h:29
C4ObjectLink * Next
Definition: C4ObjectList.h:29
C4Object * Obj
Definition: C4ObjectList.h:28
int32_t Category
Definition: C4Object.h:111
C4ID id
Definition: C4Object.h:106
bool Unsorted
Definition: C4Object.h:127
int32_t GetPlane() const
Definition: C4Object.h:179
int32_t Mass
Definition: C4Object.h:113
C4Def * Def
Definition: C4Object.h:141
C4ObjectLink * First
Definition: C4ObjectList.h:51
const C4ObjectLink * GetLink(const C4Object *obj) const
C4ObjectLink * Last
Definition: C4ObjectList.h:51
virtual void InsertLink(C4ObjectLink *link, C4ObjectLink *after_link)
void CheckCategorySort()
bool CheckSort(C4ObjectList *list)
int32_t Status
Definition: C4PropList.h:173

References C4D_StaticBack, C4Object::Category, C4ObjectList::CheckCategorySort(), C4ObjectList::CheckSort(), C4Object::Def, C4ObjectList::First, C4ObjectList::GetLink(), C4Object::GetPlane(), C4Object::id, C4ObjectList::InsertLink(), C4ObjectList::Last, C4Object::Mass, C4ObjectList::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().

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

◆ AddIter()

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

Definition at line 1238 of file C4ObjectList.cpp.

1239 {
1240  iterator * r = FirstIter;
1241  FirstIter = iter;
1242  return r;
1243 }
friend class iterator
Definition: C4ObjectList.h:169
iterator * FirstIter
Definition: C4ObjectList.h:165

References C4ObjectList::FirstIter.

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

Here is the caller graph for this function:

◆ AddSortCustom()

bool C4ObjectList::AddSortCustom ( C4Object new_obj,
SortProc pSortProc 
)
inherited

◆ AssignInfo()

bool C4ObjectList::AssignInfo ( )
virtualinherited

Reimplemented in C4GameObjects.

Definition at line 732 of file C4ObjectList.cpp.

733 {
734  // the list seems to be traced backwards here, to ensure crew objects are added in correct order
735  // (or semi-correct, because this will work only if the crew order matches the main object list order)
736  // this is obsolete now, because the crew list is stored in the savegame
737  C4ObjectLink *link;
738  for (link = Last; link; link = link->Prev)
739  {
740  if (link->Obj->Status)
741  {
742  link->Obj->AssignInfo();
743  }
744  }
745  return true;
746 }
bool AssignInfo()
Definition: C4Object.cpp:1045

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

Referenced by C4GameObjects::AssignInfo().

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

◆ begin()

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

Definition at line 1230 of file C4ObjectList.cpp.

1231 {
1232  return iterator(*this, First, false);
1233 }

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

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

Here is the caller graph for this function:

◆ CheckCategorySort()

void C4ObjectList::CheckCategorySort ( )
inherited

Definition at line 1126 of file C4ObjectList.cpp.

1127 {
1128  // debug: Check whether object list is sorted correctly
1129  C4ObjectLink *link;
1130  C4ObjectLink *previous = nullptr;
1131  for (link = First; link; link = link->Next)
1132  {
1133  if (!link->Obj->Unsorted && link->Obj->Status)
1134  {
1135  if (previous)
1136  {
1137  assert(previous->Obj->GetPlane() >= link->Obj->GetPlane());
1138  }
1139  previous = link;
1140  }
1141  }
1142 }

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

Referenced by C4ObjectList::Add().

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

◆ CheckSort()

bool C4ObjectList::CheckSort ( C4ObjectList list)
inherited

Definition at line 1091 of file C4ObjectList.cpp.

1092 {
1093  C4ObjectLink *link = First;
1094  C4ObjectLink *compare_link = list->First;
1095  while (link && (!link->Obj->Status || link->Obj->Unsorted))
1096  {
1097  link = link->Next;
1098  }
1099 
1100  while (link)
1101  {
1102  if (!compare_link)
1103  {
1104  Log("CheckSort failure");
1105  C4ValueNumbers numbers;
1106  LogSilent(DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(C4ObjectListDumpHelper(this, &numbers), "SectorList")).getData());
1107  LogSilent(DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(C4ObjectListDumpHelper(list, &numbers), "MainList")).getData());
1108  return false;
1109  }
1110  else
1111  {
1112  if (link->Obj == compare_link->Obj)
1113  {
1114  link = link->Next;
1115  while (link && (!link->Obj->Status || link->Obj->Unsorted))
1116  {
1117  link = link->Next;
1118  }
1119  }
1120  compare_link = compare_link->Next;
1121  }
1122 }
1123  return true;
1124 }
bool LogSilent(const char *szMessage, bool fConsole)
Definition: C4Log.cpp:126
bool Log(const char *szMessage)
Definition: C4Log.cpp:204
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92

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

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

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

◆ Clear()

void C4ObjectList::Clear ( )
virtualinherited

Reimplemented in C4GameObjects.

Definition at line 48 of file C4ObjectList.cpp.

49 {
50  C4ObjectLink *link;
51  C4ObjectLink *next_link;
52  for (link = First; link; link = next_link)
53  {
54  next_link = link->Next;
55  delete link;
56  }
57  First = Last = nullptr;
58  if (pEnumerated)
59  {
60  delete pEnumerated;
61  pEnumerated = nullptr;
62  }
63 
64  for (iterator* it = FirstIter; it; it = it->Next)
65  {
66  it->link = NULL_LINK;
67  }
68 }
std::list< int32_t > * pEnumerated
Definition: C4ObjectList.h:53

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

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

Here is the caller graph for this function:

◆ ClearInfo()

void C4ObjectList::ClearInfo ( C4ObjectInfo info)
inherited

Definition at line 748 of file C4ObjectList.cpp.

749 {
750  C4ObjectLink *link;
751  for (link = First; link; link = link->Next)
752  {
753  if (link->Obj->Status)
754  {
755  link->Obj->ClearInfo(pInfo);
756  }
757  }
758 }
void ClearInfo(C4ObjectInfo *pInfo)
Definition: C4Object.cpp:1075

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

Referenced by C4ObjectInfoList::DetachFromObjects().

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

◆ ClearPointers()

int C4ObjectList::ClearPointers ( C4Object obj)
inherited

Definition at line 481 of file C4ObjectList.cpp.

482 {
483  int removed_amount = 0;
484  // Clear all primary list pointers
485  while (Remove(obj))
486  {
487  removed_amount++;
488  }
489  // Clear all sub pointers
490  C4Object *current_obj;
491  C4ObjectLink *link;
492  for (link = First; link && (current_obj = link->Obj); link = link->Next)
493  {
494  current_obj->ClearPointers(obj);
495  }
496  return removed_amount;
497 }
virtual bool Remove(C4Object *obj)

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

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

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

◆ CloseMenus()

void C4ObjectList::CloseMenus ( )
inherited

Definition at line 933 of file C4ObjectList.cpp.

934 {
935  C4Object *obj;
936  C4ObjectLink *link;
937  for (link = First; link && (obj = link->Obj); link = link->Next)
938  {
939  obj->CloseMenu(true);
940  }
941 }

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

Here is the call graph for this function:

◆ CompileFunc() [1/2]

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

Definition at line 622 of file C4ObjectList.cpp.

623 {
624  // "Object" section count
625  int32_t object_count = ObjectCount();
626  pComp->Value(mkNamingCountAdapt(object_count, "Object"));
627  if (pComp->isSerializer())
628  {
629  // skipping player objects would screw object counting in non-naming compilers
630  assert(!skip_player_objects || pComp->hasNaming());
631  // Decompile all objects in reverse order
632  for (C4ObjectLink *link = Last; link; link = link->Prev)
633  {
634  if (link->Obj->Status && (!skip_player_objects || !link->Obj->IsUserPlayerObject()))
635  {
636  pComp->Value(mkNamingAdapt(mkParAdapt(*link->Obj, numbers), "Object"));
637  }
638  }
639  }
640  else
641  {
642  // FIXME: Check that no PlayerObjects are loaded when skip_player_objects is true
643  // i.e. that loading and saving was done with the same flag.
644  // Remove previous data
645  Clear();
646  // Load objects, add them to the list.
647  for (int i = 0; i < object_count; i++)
648  {
649  C4Object *obj = nullptr;
650  try
651  {
652  pComp->Value(mkNamingAdapt(mkParAdapt(mkPtrAdaptNoNull(obj), numbers), "Object"));
653  Add(obj, stReverse);
654  }
655  catch (StdCompiler::Exception *exception)
656  {
657  // Failsafe object loading: If an error occurs during object loading, just skip that object and load the next one
658  if (!exception->Pos.getLength())
659  {
660  LogF("ERROR: Object loading: %s", exception->Msg.getData());
661  }
662  else
663  {
664  LogF("ERROR: Object loading(%s): %s", exception->Pos.getData(), exception->Msg.getData());
665  }
666  delete exception;
667  }
668  }
669  }
670 }
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:262
StdPtrAdapt< T > mkPtrAdaptNoNull(T *&rpObj)
Definition: StdAdaptors.h:638
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:490
StdNamingCountAdapt< int_t > mkNamingCountAdapt(int_t &iCount, const char *szName)
Definition: StdAdaptors.h:1008
virtual void Clear()
virtual bool Add(C4Object *new_obj, SortType sort_type, C4ObjectList *sorted_list=nullptr)
int ObjectCount(C4ID id=C4ID::None) const
void Value(const T &rStruct)
Definition: StdCompiler.h:161
bool isSerializer()
Definition: StdCompiler.h:54
virtual bool hasNaming()
Definition: StdCompiler.h:58
const char * getData() const
Definition: StdBuf.h:442
size_t getLength() const
Definition: StdBuf.h:445

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

Here is the call graph for this function:

◆ CompileFunc() [2/2]

void C4ObjectList::CompileFunc ( StdCompiler pComp,
C4ValueNumbers numbers = nullptr 
)
inherited

Definition at line 672 of file C4ObjectList.cpp.

673 {
674  // (Re)create list
675  delete pEnumerated;
676  pEnumerated = new std::list<int32_t>();
677  // Decompiling: Build list
678  if (!pComp->isDeserializer())
679  {
680  for (C4ObjectLink *link = First; link; link = link->Next)
681  {
682  if (link->Obj->Status)
683  {
684  pEnumerated->push_back(link->Obj->Number);
685  }
686  }
687  }
688  // Compile list
690  // Decompiling: Delete list
691  if (!pComp->isDeserializer())
692  {
693  delete pEnumerated;
694  pEnumerated = nullptr;
695  }
696  // Compiling: Nothing to do - list will be denumerated later
697 }
StdSTLContainerAdapt< C > mkSTLContainerAdapt(C &rTarget, StdCompiler::Sep eSep=StdCompiler::SEP_SEP)
Definition: StdAdaptors.h:713
virtual bool isDeserializer()
Definition: StdCompiler.h:53

References C4ObjectList::First, StdCompiler::isDeserializer(), mkSTLContainerAdapt(), C4ObjectLink::Next, C4PropListNumbered::Number, C4ObjectLink::Obj, C4ObjectList::pEnumerated, StdCompiler::SEP_SEP2, C4PropList::Status, and StdCompiler::Value().

Here is the call graph for this function:

◆ Copy()

void C4ObjectList::Copy ( const C4ObjectList list)
inherited

Definition at line 943 of file C4ObjectList.cpp.

944 {
945  Clear(); Default();
946  C4ObjectLink *link;
947  for (link = list.First; link; link = link->Next)
948  {
949  Add(link->Obj, C4ObjectList::stNone);
950  }
951 }
virtual void Default()

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().

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

◆ Default()

void C4ObjectList::Default ( )
virtualinherited

Reimplemented in C4GameObjects.

Definition at line 953 of file C4ObjectList.cpp.

954 {
955  First = Last = nullptr;
956  Mass = 0;
957  pEnumerated = nullptr;
958 }

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

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

Here is the caller graph for this function:

◆ DeleteObjects()

void C4ObjectList::DeleteObjects ( )
inherited

Definition at line 986 of file C4ObjectList.cpp.

987 {
988  // Delete links and objects
989  while (First)
990  {
991  C4Object *obj = First->Obj;
992  if (obj->Status)
993  {
994  Game.ClearPointers(obj); // Clear pointers to removed objects that weren't deleted (game end or section change)
995  }
996  obj->Status = C4OS_DELETED;
997  Remove(obj);
998  delete obj;
999  }
1000  // Reset mass
1001  Mass = 0;
1002 }
C4Game Game
Definition: C4Globals.cpp:52
#define C4OS_DELETED
Definition: C4Object.h:34
void ClearPointers(C4Object *obj)
Definition: C4Game.cpp:1125

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

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

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

◆ Denumerate()

void C4ObjectList::Denumerate ( C4ValueNumbers numbers)
inherited

Definition at line 610 of file C4ObjectList.cpp.

611 {
612  C4ObjectLink *link;
613  for (link = First; link; link = link->Next)
614  {
615  if (link->Obj->Status)
616  {
617  link->Obj->Denumerate(numbers);
618  }
619  }
620 }
void Denumerate(C4ValueNumbers *) override
Definition: C4Object.cpp:1007

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

Referenced by C4GameObjects::Denumerate().

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

◆ DenumeratePointers()

bool C4ObjectList::DenumeratePointers ( )
inherited

Definition at line 577 of file C4ObjectList.cpp.

578 {
579  if (!pEnumerated)
580  {
581  return false;
582  }
583  // Denumerate all object pointers
584  for (std::list<int32_t>::const_iterator pNum = pEnumerated->begin(); pNum != pEnumerated->end(); ++pNum)
585  {
586  Add(::Objects.ObjectPointer(*pNum), stNone); // Add to tail, unsorted
587  }
588  // Delete old list
589  delete pEnumerated;
590  pEnumerated = nullptr;
591  return true;
592 }
C4GameObjects Objects
Definition: C4Globals.cpp:48
C4Object * ObjectPointer(int32_t object_number)

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

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

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

◆ Draw()

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

Definition at line 499 of file C4ObjectList.cpp.

500 {
501  C4ObjectLink *link;
502  C4ObjectLink *first;
503  for (first = Last; first; first = first->Prev)
504  {
505  if (first->Obj->GetPlane() >= MinPlane)
506  {
507  break;
508  }
509  }
510  // Draw objects (base)
511  for (link = first; link; link = link->Prev)
512  {
513  if (link->Obj->GetPlane() > MaxPlane)
514  {
515  break;
516  }
517  if (link->Obj->Category & C4D_Foreground)
518  {
519  continue;
520  }
521  link->Obj->Draw(cgo, player);
522  }
523  // Draw objects (top face)
524  for (link = first; link; link = link->Prev)
525  {
526  if (link->Obj->GetPlane() > MaxPlane)
527  {
528  break;
529  }
530  if (link->Obj->Category & C4D_Foreground)
531  {
532  continue;
533  }
534  link->Obj->DrawTopFace(cgo, player);
535  }
536 }
const int32_t C4D_Foreground
Definition: C4Def.h:53
void DrawTopFace(C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
void Draw(C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)

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

Referenced by C4Viewport::Draw().

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

◆ DrawIfCategory()

void C4ObjectList::DrawIfCategory ( C4TargetFacet cgo,
int  player,
uint32_t  dwCategory,
bool  invert 
)
inherited

Definition at line 538 of file C4ObjectList.cpp.

539 {
540  C4ObjectLink *link;
541  // Draw objects (base)
542  for (link = Last; link; link = link->Prev)
543  {
544  if (!(link->Obj->Category & dwCategory) == invert)
545  {
546  link->Obj->Draw(cgo, player);
547  }
548  }
549  // Draw objects (top face)
550  for (link = Last; link; link = link->Prev)
551  {
552  if (!(link->Obj->Category & dwCategory) == invert)
553  {
554  link->Obj->DrawTopFace(cgo, player);
555  }
556  }
557 }

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

Referenced by C4Viewport::Draw().

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

◆ DrawSelectMark()

void C4ObjectList::DrawSelectMark ( C4TargetFacet cgo) const
inherited

Definition at line 924 of file C4ObjectList.cpp.

925 {
926  C4ObjectLink *link;
927  for (link = Last; link; link = link->Prev)
928  {
929  link->Obj->DrawSelectMark(cgo);
930  }
931 }
void DrawSelectMark(C4TargetFacet &cgo) const

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

Referenced by C4MouseControl::Draw().

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

◆ end()

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

Definition at line 1234 of file C4ObjectList.cpp.

1235 {
1236  return iterator(*this, nullptr, false);
1237 }

References C4ObjectList::iterator.

Referenced by C4ObjectListIterator::GetNext().

Here is the caller graph for this function:

◆ Find()

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

Definition at line 383 of file C4ObjectList.cpp.

384 {
385  C4ObjectLink *link;
386  // Find link and object
387  for (link = First; link; link = link->Next)
388  {
389  if ((link->Obj->Status)
390  && (link->Obj->Def == def)
391  && ((owner == ANY_OWNER) || (link->Obj->Owner == owner))
392  && (dwOCF & link->Obj->OCF))
393  {
394  return link->Obj;
395  }
396  }
397  return nullptr;
398 }
const int ANY_OWNER
Definition: C4Constants.h:138
int32_t Owner
Definition: C4Object.h:108
uint32_t OCF
Definition: C4Object.h:132

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().

Here is the caller graph for this function:

◆ FindOther()

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

Definition at line 400 of file C4ObjectList.cpp.

401 {
402  C4ObjectLink *link;
403  // Find link and object
404  for (link = First; link; link = link->Next)
405  {
406  if ((link->Obj->Status)
407  && (link->Obj->Def->id!=id)
408  && ((owner==ANY_OWNER) || (link->Obj->Owner == owner)))
409  {
410  return link->Obj;
411  }
412  }
413  return nullptr;
414 }
C4ID id
Definition: C4Def.h:101

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

◆ GetFirstObject()

C4Object* C4ObjectList::GetFirstObject ( ) const
inlineinherited

Definition at line 141 of file C4ObjectList.h.

141 { return First ? First->Obj : nullptr; }

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

Referenced by C4Player::CheckElimination().

Here is the caller graph for this function:

◆ GetLastObject()

C4Object* C4ObjectList::GetLastObject ( ) const
inlineinherited

Definition at line 142 of file C4ObjectList.h.

142 { return Last ? Last->Obj : nullptr; }

References C4ObjectList::Last, and C4ObjectLink::Obj.

Referenced by C4Object::PutAwayUnusedObject().

Here is the caller graph for this function:

◆ GetLink() [1/2]

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

Definition at line 147 of file C4ObjectList.h.

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

References C4ObjectList::GetLink().

Here is the call graph for this function:

◆ GetLink() [2/2]

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

Definition at line 435 of file C4ObjectList.cpp.

436 {
437  if (!obj)
438  {
439  return nullptr;
440  }
441  C4ObjectLink *link;
442  for (link = First; link; link = link->Next)
443  {
444  if (link->Obj == obj)
445  {
446  return link;
447  }
448  }
449  return nullptr;
450 }

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().

Here is the caller graph for this function:

◆ GetListID()

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

Definition at line 73 of file C4ObjectList.cpp.

74 {
75  C4ObjectLink *link;
76 
77  // Create a temporary list of all id's and counts
78  for (int i = 0; i < MaxTempListID; i++)
79  {
81  }
82  for (link = First; link && link->Obj; link = link->Next)
83  {
84  if (link->Obj->Status)
85  {
86  C4Def *def;
87  if ((dwCategory==C4D_All) || ( (def = C4Id2Def(link->Obj->Def->id)) && (def->Category & dwCategory) ))
88  {
89  for (int i = 0; i < MaxTempListID; i++)
90  {
91  // Already there
92  if (TempListID[i] == link->Obj->Def->id)
93  {
94  break;
95  }
96  // End of list, add id
97  if (TempListID[i] == C4ID::None)
98  {
99  TempListID[i] = link->Obj->Def->id;
100  break;
101  }
102  }
103  }
104  }
105  }
106 
107  // Returns indexed id
108  if (Inside(index, 0, MaxTempListID - 1))
109  {
110  return TempListID[index];
111  }
112 
113  return C4ID::None;
114 }
const int32_t C4D_All
Definition: C4Def.h:39
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:84
const int MaxTempListID
C4ID TempListID[MaxTempListID]
bool Inside(T ival, U lbound, V rbound)
Definition: Standard.h:43
Definition: C4Def.h:99
int32_t Category
Definition: C4Def.h:117
static const C4ID None
Definition: C4Id.h:39

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

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

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

◆ GetNameList()

StdStrBuf C4ObjectList::GetNameList ( C4DefList defs) const
inherited

Definition at line 699 of file C4ObjectList.cpp.

700 {
701  C4ID id;
702  StdStrBuf Buf;
703  for (int i = 0; (id = GetListID(C4D_All, i)); i++)
704  {
705  C4Def *current_def = defs.ID2Def(id);
706  if (current_def)
707  {
708  int idcount = ObjectCount(id);
709  if (i > 0)
710  {
711  Buf.Append(", ");
712  }
713  Buf.AppendFormat("%dx %s", idcount, current_def->GetName());
714  }
715  }
716  return Buf;
717 }
C4Def * ID2Def(C4ID id)
Definition: C4Id.h:26
C4ID GetListID(int32_t dwCategory, int index) const
const char * GetName() const override
Definition: C4PropList.cpp:243
void AppendFormat(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:190
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519

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

Referenced by C4Object::GetDataString().

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

◆ GetObject()

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

Definition at line 416 of file C4ObjectList.cpp.

417 {
418  int cIdx;
419  C4ObjectLink *link;
420  // Find link and object
421  for (link = First, cIdx = 0; link; link = link->Next)
422  {
423  if (link->Obj->Status)
424  {
425  if (cIdx == index)
426  {
427  return link->Obj;
428  }
429  cIdx++;
430  }
431  }
432  return nullptr;
433 }

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().

Here is the caller graph for this function:

◆ InsertLink()

void C4NotifyingObjectList::InsertLink ( C4ObjectLink link,
C4ObjectLink after_link 
)
overrideprotectedvirtual

Reimplemented from C4ObjectList.

Definition at line 888 of file C4ObjectList.cpp.

889 {
890  C4ObjectList::InsertLink(link, after_link);
892 }
C4ObjectListChangeListener & ObjectListChangeListener
virtual void OnObjectAdded(C4ObjectList *list, C4ObjectLink *link)
Definition: C4ObjectList.h:36

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

Here is the call graph for this function:

◆ InsertLinkBefore()

void C4NotifyingObjectList::InsertLinkBefore ( C4ObjectLink link,
C4ObjectLink before_link 
)
overrideprotectedvirtual

Reimplemented from C4ObjectList.

Definition at line 882 of file C4ObjectList.cpp.

883 {
884  C4ObjectList::InsertLinkBefore(link, before_link);
886 }
virtual void InsertLinkBefore(C4ObjectLink *link, C4ObjectLink *before_link)

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

Here is the call graph for this function:

◆ IsClear()

bool C4ObjectList::IsClear ( ) const
inherited

Definition at line 572 of file C4ObjectList.cpp.

573 {
574  return ObjectCount() == 0;
575 }

References C4ObjectList::ObjectCount().

Here is the call graph for this function:

◆ IsContained()

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

Definition at line 559 of file C4ObjectList.cpp.

560 {
561  C4ObjectLink *link;
562  for (link = First; link; link = link->Next)
563  {
564  if (link->Obj == obj)
565  {
566  return true;
567  }
568  }
569  return false;
570 }

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

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

Here is the caller graph for this function:

◆ ListIDCount()

int C4ObjectList::ListIDCount ( int32_t  dwCategory) const
inherited

Definition at line 116 of file C4ObjectList.cpp.

117 {
118  C4ObjectLink *link;
119 
120  // Create a temporary list of all id's and counts
121  for (int clid = 0; clid < MaxTempListID; clid++)
122  {
123  TempListID[clid] = C4ID::None;
124  }
125  for (link = First; link && link->Obj; link = link->Next)
126  {
127  if (link->Obj->Status)
128  {
129  C4Def *def;
130  if ((dwCategory == C4D_All) || ( (def = C4Id2Def(link->Obj->Def->id)) && (def->Category & dwCategory) ))
131  {
132  for (int clid = 0; clid < MaxTempListID; clid++)
133  {
134  // Already there
135  if (TempListID[clid] == link->Obj->Def->id)
136  {
137  break;
138  }
139  // End of list, add id
140  if (TempListID[clid] == C4ID::None)
141  {
142  TempListID[clid] = link->Obj->Def->id;
143  break;
144  }
145  }
146  }
147  }
148  }
149 
150  // Count different id's
151  for (int i = 0; i < MaxTempListID; i++)
152  {
153  if (TempListID[i] == C4ID::None)
154  {
155  return i;
156  }
157  }
158 
159  return MaxTempListID;
160 }

◆ MassCount()

int C4ObjectList::MassCount ( )
inherited

Definition at line 466 of file C4ObjectList.cpp.

467 {
468  C4ObjectLink *link;
469  int mass = 0;
470  for (link = First; link; link = link->Next)
471  {
472  if (link->Obj->Status)
473  {
474  mass += link->Obj->Mass;
475  }
476  }
477  Mass = mass;
478  return mass;
479 }

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

Referenced by C4Object::UpdateMass().

Here is the caller graph for this function:

◆ ObjectCount()

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

Definition at line 452 of file C4ObjectList.cpp.

453 {
454  C4ObjectLink *link;
455  int count = 0;
456  for (link = First; link; link = link->Next)
457  {
458  if (link->Obj->Status && (id == C4ID::None || link->Obj->Def->id == id))
459  {
460  count++;
461  }
462  }
463  return count;
464 }

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().

Here is the caller graph for this function:

◆ Remove()

bool C4ObjectList::Remove ( C4Object obj)
virtualinherited

Reimplemented in C4GameObjects.

Definition at line 328 of file C4ObjectList.cpp.

329 {
330  C4ObjectLink *link;
331 
332  // Find link
333  for (link = First; link; link = link->Next)
334  {
335  if (link->Obj == obj)
336  {
337  break;
338  }
339  }
340  if (!link)
341  {
342  return false;
343  }
344 
345  // Fix iterators
346  for (iterator * it = FirstIter; it; it = it->Next)
347  {
348  // Adjust pointers of internal link field
349  if (it->link.Prev == link)
350  {
351  it->link.Prev = link->Prev;
352  }
353  else if (it->link.Next == link)
354  {
355  it->link.Next = link->Next;
356  }
357  else if (it->link.Obj == link->Obj)
358  {
359  it->link.Obj = nullptr;
360  }
361  }
362 
363  // Remove link from list
364  RemoveLink(link);
365 
366  // Deallocate link
367  delete link;
368 
369  // Remove mass
370  Mass -= obj->Mass;
371  if (Mass < 0)
372  {
373  Mass = 0;
374  }
375 
376 #if defined(_DEBUG)
377  assert(!GetLink(obj));
378 #endif
379 
380  return true;
381 }
virtual void RemoveLink(C4ObjectLink *link)

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

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

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

◆ RemoveIter()

void C4ObjectList::RemoveIter ( iterator iter) const
protectedinherited

Definition at line 1244 of file C4ObjectList.cpp.

1245 {
1246  if (iter == FirstIter)
1247  {
1248  FirstIter = iter->Next;
1249  }
1250  else
1251  {
1252  iterator * i = FirstIter;
1253  while (i->Next && i->Next != iter)
1254  {
1255  i = i->Next;
1256  }
1257  i->Next = iter->Next;
1258  }
1259 }

References C4ObjectList::FirstIter.

◆ RemoveLink()

void C4NotifyingObjectList::RemoveLink ( C4ObjectLink link)
overrideprotectedvirtual

Reimplemented from C4ObjectList.

Definition at line 894 of file C4ObjectList.cpp.

895 {
898 }
virtual void OnObjectRemove(C4ObjectList *list, C4ObjectLink *link)
Definition: C4ObjectList.h:35

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

Here is the call graph for this function:

◆ reverse()

const ReverseView C4ObjectList::reverse ( ) const
inlineinherited

Definition at line 104 of file C4ObjectList.h.

104 { return ReverseView(*this); }

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

Here is the caller graph for this function:

◆ ShiftContents()

bool C4ObjectList::ShiftContents ( C4Object new_first)
inherited

Definition at line 960 of file C4ObjectList.cpp.

961 {
962  // Get link of new first (this ensures list is not empty)
963  C4ObjectLink *new_first_link = GetLink(new_first_obj);
964  if (!new_first_link)
965  {
966  return false;
967  }
968  // Already at front?
969  if (new_first_link == First)
970  {
971  return true;
972  }
973  // Sort it there:
974  // 1. Make cyclic list
975  Last->Next = First;
976  First->Prev = Last;
977  // 2. Re-set first and last
978  First = new_first_link;
979  Last = new_first_link->Prev;
980  // 3. Uncycle list
981  First->Prev = Last->Next = nullptr;
982  // Done, success
983  return true;
984 }

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

Referenced by C4Object::DirectComContents().

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

◆ Sort()

void C4ObjectList::Sort ( )
inherited

Definition at line 760 of file C4ObjectList.cpp.

761 {
762  C4ObjectLink *link;
763  bool is_sorted;
764  // Sort by id
765  do
766  {
767  is_sorted = true;
768  for (link = First; link && link->Next; link = link->Next)
769  {
770  if (link->Obj->id > link->Next->Obj->id)
771  {
772  RemoveLink(link);
773  InsertLink(link, link->Next);
774  is_sorted = false;
775  break;
776  }
777  }
778  }
779  while (!is_sorted);
780 }

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

Here is the call graph for this function:

◆ UpdateFaces()

void C4ObjectList::UpdateFaces ( bool  update_shape)
inherited

Definition at line 912 of file C4ObjectList.cpp.

913 {
914  C4ObjectLink *link;
915  for (link = First; link; link = link->Next)
916  {
917  if (link->Obj->Status)
918  {
919  link->Obj->UpdateFace(update_shapes);
920  }
921  }
922 }
void UpdateFace(bool bUpdateShape, bool fTemp=false)

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

Referenced by C4GameObjects::PostLoad().

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

◆ UpdateGraphics()

void C4ObjectList::UpdateGraphics ( bool  graphics_changed)
inherited

Definition at line 900 of file C4ObjectList.cpp.

901 {
902  C4ObjectLink *link;
903  for (link = First; link; link = link->Next)
904  {
905  if (link->Obj->Status)
906  {
907  link->Obj->UpdateGraphics(graphics_changed);
908  }
909  }
910 }
void UpdateGraphics(bool fGraphicsChanged, bool fTemp=false)

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

Referenced by C4GameObjects::PostLoad().

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

◆ UpdateScriptPointers()

void C4ObjectList::UpdateScriptPointers ( )
inherited

Definition at line 1073 of file C4ObjectList.cpp.

1074 {
1075  for (C4ObjectLink *link = First; link; link = link->Next)
1076  {
1077  link->Obj->UpdateScriptPointers();
1078  }
1079 }

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

Referenced by C4GameObjects::UpdateScriptPointers().

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

◆ ValidateOwners()

bool C4ObjectList::ValidateOwners ( )
virtualinherited

Reimplemented in C4GameObjects.

Definition at line 719 of file C4ObjectList.cpp.

720 {
721  C4ObjectLink *link;
722  for (link = First; link; link = link->Next)
723  {
724  if (link->Obj->Status)
725  {
726  link->Obj->ValidateOwner();
727  }
728  }
729  return true;
730 }
bool ValidateOwner()
Definition: C4Object.cpp:1035

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

Referenced by C4GameObjects::ValidateOwners().

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

◆ Write()

bool C4ObjectList::Write ( char *  szTarget)
inherited

Definition at line 594 of file C4ObjectList.cpp.

595 {
596  char ostr[25];
597  szTarget[0] = 0;
598  C4ObjectLink *link;
599  for (link = First; link && link->Obj; link = link->Next)
600  {
601  if (link->Obj->Status)
602  {
603  sprintf(ostr, "%d;", link->Obj->Number);
604  SAppend(ostr, szTarget);
605  }
606  }
607  return true;
608 }
void SAppend(const char *szSource, char *szTarget, int iMaxL)
Definition: Standard.cpp:263
#define sprintf
Definition: Standard.h:162

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

Here is the call graph for this function:

Member Data Documentation

◆ First

◆ FirstIter

iterator* C4ObjectList::FirstIter {nullptr}
mutableprotectedinherited

◆ Last

◆ Mass

◆ pEnumerated

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

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