OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4GameObjects.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 // game object lists
17 
18 #ifndef INC_C4GameObjects
19 #define INC_C4GameObjects
20 
21 #include "object/C4ObjectList.h"
22 #include "object/C4FindObject.h"
23 #include "object/C4Sector.h"
24 
25 // main object list class
27 {
28 public:
29  C4GameObjects(); // constructor
30  ~C4GameObjects(); // destructor
31  void Default();
32  void Init(int32_t iWidth, int32_t iHeight);
33  void Clear(bool fClearInactive); // clear objects
34  // don't use default parameters so we get a correct vtbl entry
35  // don't clear internal objects, because they should not be cleared on section load
36  void Clear() { Clear(false); }
37 
38 private:
39  uint32_t LastUsedMarker; // last used value for C4Object::Marker
40 
41 public:
42  C4LSectors Sectors; // section object lists
43  C4ObjectList InactiveObjects; // inactive objects (Status=2)
44  C4ObjectList ForeObjects; // objects in foreground (C4D_Foreground)
45 
46  using C4ObjectList::Add;
47  bool Add(C4Object *nObj); // add object
48  bool Remove(C4Object *pObj); // clear pointers to object
49 
50  C4ObjectList &ObjectsAt(int ix, int iy); // get object list for map pos
51 
52  void CrossCheck(); // various collision-checks
53  C4Object *AtObject(int ctx, int cty, DWORD &ocf, C4Object *exclude=nullptr); // find object at ctx/cty
54  void Synchronize(); // network synchronization
55  void UpdateSolidMasks();
56 
57  C4Object *ObjectPointer(int32_t iNumber); // object pointer by number
58  C4Object* SafeObjectPointer(int32_t iNumber);
59 
60  int PostLoad(bool fKeepInactive, C4ValueNumbers *);
61  void Denumerate(C4ValueNumbers *);
62 
63  void UpdateScriptPointers(); // update pointers to C4AulScript *
64  C4Value GRBroadcast(const char *szFunction, C4AulParSet *pPars, bool fPassError, bool fRejectTest); // call function in all goals/rules/environment objects
65 
66  void UpdatePos(C4Object *pObj);
67  void UpdatePosResort(C4Object *pObj);
68 
69  void FixObjectOrder(); // Called after loading: Resort any objects that are out of order
70  void ResortUnsorted(); // resort any objects with unsorted-flag set into lists
71 
72  void DeleteObjects(bool fDeleteInactive); // delete all objects and links
73 
74  bool ValidateOwners();
75  bool AssignInfo();
76  void AssignLightRange();
77  void SyncClearance();
78  void ResetAudibility();
79  void OnSynchronized();
80  void SetOCF();
81 
82  uint32_t GetNextMarker(); // Get a new marker. If all markers are exceeded (LastUsedMarker is 0xffffffff), restart marker at 1 and reset all object markers to zero.
83 };
84 
85 extern C4GameObjects Objects;
86 
87 #endif
virtual bool Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted=nullptr)
bool Add(C4Object *nObj)
void UpdatePosResort(C4Object *pObj)
void ResetAudibility()
C4Value GRBroadcast(const char *szFunction, C4AulParSet *pPars, bool fPassError, bool fRejectTest)
void DeleteObjects()
C4ObjectList InactiveObjects
Definition: C4GameObjects.h:43
C4Object * AtObject(int ctx, int cty, DWORD &ocf, C4Object *exclude=nullptr)
uint32_t GetNextMarker()
void Denumerate(C4ValueNumbers *)
C4LSectors Sectors
Definition: C4GameObjects.h:42
C4ObjectList ForeObjects
Definition: C4GameObjects.h:44
C4Object * SafeObjectPointer(int32_t iNumber)
void UpdateScriptPointers()
void Init(int32_t iWidth, int32_t iHeight)
bool Remove(C4Object *pObj)
void AssignLightRange()
int PostLoad(bool fKeepInactive, C4ValueNumbers *)
C4GameObjects Objects
Definition: C4Globals.cpp:48
uint32_t DWORD
void UpdateSolidMasks()
C4Object * ObjectPointer(int32_t iNumber)
void UpdatePos(C4Object *pObj)
C4ObjectList & ObjectsAt(int ix, int iy)