All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
Go to the documentation of this file.
1 /*
2  * OpenClonk,
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH,
6  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
18 /* Object definition */
20 #ifndef INC_C4Def
21 #define INC_C4Def
23 #include "object/C4Shape.h"
24 #include "object/C4InfoCore.h"
25 #include "object/C4IDList.h"
26 #include "script/C4ValueMap.h"
27 #include "graphics/C4Facet.h"
29 #include "script/C4PropList.h"
31 #include "script/C4ScriptHost.h"
32 #include "object/C4DefGraphics.h"
34 #include "lib/C4InputValidation.h"
36 #include <functional>
37 #include <set>
39 const int32_t
41 C4D_All = ~0,
44 C4D_Vehicle = 1<<2,
45 C4D_Living = 1<<3,
46 C4D_Object = 1<<4,
48 C4D_Goal = 1<<5,
49 C4D_Rule = 1<<6,
53 C4D_Parallax = 1<<13,
57 C4D_IgnoreFoW = 1<<17,
62 const int32_t C4Plane_Structure = 200;
64 const int32_t C4D_Grab_Put = 1,
78 const int32_t C4D_VehicleControl_None = 0,
82 const DWORD C4D_Load_None = 0,
96 #define C4D_Blit_Normal 0
97 #define C4D_Blit_Additive 1
98 #define C4D_Blit_ModAdd 2
100 class C4Def: public C4PropListStatic
101 {
102 public:
104  int32_t rC4XVer[2];
113  int32_t GrowthType;
114  int32_t CrewMember;
115  int32_t NativeCrew;
116  int32_t Mass;
117  int32_t Value;
118  int32_t Exclusive;
119  int32_t Category;
120  int32_t Constructable;
121  int32_t Rotateable;
122  int32_t Float;
123  int32_t ColorByOwner;
125  int32_t LiftTop;
126  int32_t GrabPutGet;
127  int32_t UprightAttach;
128  int32_t Line;
129  int32_t LineIntersect;
132  int32_t Oversize;
133  int32_t Fragile;
134  int32_t Projectile;
135  int32_t NoPushEnter;
136  int32_t VehicleControl;
137  int32_t Pathfinder;
138  int32_t MoveToRange;
140  int32_t NoStabilize;
141  int32_t ClosedContainer; // if set, contained objects are not damaged by lava/acid etc. 1: Contained objects can't view out; 2: They can
142  int32_t SilentCommands; // if set, no command failure messages are printed
143  int32_t TemporaryCrew; // if set, info objects are not written into regular player files
144  int32_t BlitMode; // special blit mode for objects of this def. C4D_Blit_X
145  int32_t NoBreath; // object does not need to breath, although it's living
146  int32_t ConSizeOff; // number of pixels to be subtracted from the needed height for this building
147  int32_t NoGet; // if set, object can't be taken out of a containers manually (doesn't appear in get/activate-menus)
148  int32_t RotatedEntrance; // 0 entrance not rotateable, 1 entrance always, 2-360 entrance within this rotation
150  int32_t AllowPictureStack; // allow stacking of multiple items in menus even if some attributes do not match. APS_*-values
151  bool HideInCreator; // If true, the definition is not visible in the object creator of the editor
152 public:
153  void DefaultDefCore();
154  bool LoadDefCore(C4Group &hGroup);
155  bool Save(C4Group &hGroup);
156  void CompileFunc(StdCompiler *pComp);
157 protected:
158  bool Compile(const char *szSource, const char *szName);
159  bool Decompile(StdStrBuf *pOut, const char *szName);
160 private:
161  void LoadMeshMaterials(C4Group &hGroup, C4DefGraphicsPtrBackup *gfx_backup);
162  bool LoadParticleDef(C4Group &hGroup);
163  bool LoadSolidMask(C4Group &hGroup);
164  bool LoadGraphics(C4Group &hGroup, StdMeshSkeletonLoader &loader);
165  void LoadScript(C4Group &hGroup, const char* szLanguage);
166  void LoadClonkNames(C4Group &hGroup, C4ComponentHost* pClonkNames, const char* szLanguage);
167  void LoadRankNames(C4Group &hGroup, const char* szLanguage);
168  void LoadRankFaces(C4Group &hGroup);
169  void LoadSounds(C4Group &hGroup, C4SoundSystem* pSoundSystem);
171  std::set<StdCopyStrBuf> mesh_materials;
173 // Here begins the C4Def
174  friend class C4DefList;
175 public:
176  C4Def();
177  ~C4Def();
178 public:
180  StdCopyStrBuf ConsoleGroupPath; // file path as used in the definition list viewer in the console. Only initialized in editor mode.
181  int32_t Creation;
182  int32_t Count; // number of instanciations
187  // clonknames are simply not needed in frontend
190  // neither are ranknames nor the symbols...yet!
193  int32_t iNumRankSymbols; // number of rank symbols available, if loaded
194  C4DefGraphics Graphics; // base graphics. points to additional graphics
195  CSurface8 *pSolidMask; // SolidMask-bitmap. Nonzero pixels are solid.
197 protected:
200 protected:
202  bool Temporary;
203 public:
204  void Clear();
205  void Default();
206  bool Load(C4Group &hGroup,
207  StdMeshSkeletonLoader &loader,
208  DWORD dwLoadWhat, const char *szLanguage,
209  class C4SoundSystem *pSoundSystem = nullptr,
210  C4DefGraphicsPtrBackup *gfx_backup = nullptr);
211  void Draw(C4Facet &cgo, bool fSelected=false, DWORD iColor=0, C4Object *pObj=nullptr, int32_t iPhaseX=0, int32_t iPhaseY=0, C4DrawTransform* trans=nullptr, const char * graphicsName=nullptr);
213  inline C4Facet &GetMainFace(C4DefGraphics *pGraphics, DWORD dwClr=0) { MainFace.Surface=pGraphics->GetBitmap(dwClr); return MainFace; }
214  int32_t GetPlane() { return GetPropertyInt(P_Plane); }
215  int32_t GetValue(C4Object *pInBase, int32_t iBuyPlayer); // get value of def; calling script functions if defined
216  void Synchronize();
217  virtual C4Def const * GetDef() const { return this; }
218  virtual C4Def * GetDef() { return this; }
219  virtual bool Delete() { return false; }
220 protected:
221  bool LoadActMap(C4Group &hGroup);
222  void CrossMapActMap();
223 public:
224  void IncludeDefinition(C4Def *pIncludeDef); // inherit components from other definition
225  void ResetIncludeDependencies(); // resets all pointers into foreign definitions caused by include chains
227  C4PropList *GetActionByName(const char *actname);
229 };
231 #endif
int32_t Pathfinder
Definition: C4Def.h:137
bool Load(C4Group &hGroup, StdMeshSkeletonLoader &loader, DWORD dwLoadWhat, const char *szLanguage, class C4SoundSystem *pSoundSystem=nullptr, C4DefGraphicsPtrBackup *gfx_backup=nullptr)
void DefaultDefCore()
Definition: C4Def.cpp:93
int32_t Line
Definition: C4Def.h:128
int32_t Exclusive
Definition: C4Def.h:118
C4ID id
Definition: C4Def.h:103
int32_t iNumRankSymbols
Definition: C4Def.h:193
int32_t UprightAttach
Definition: C4Def.h:127
int32_t Creation
Definition: C4Def.h:181
const int32_t C4D_Environment
Definition: C4Def.h:50
int32_t AttractLightning
Definition: C4Def.h:131
const int32_t C4D_Vehicle
Definition: C4Def.h:44
int32_t NoTransferZones
Definition: C4Def.h:149
const int32_t C4Plane_Structure
Definition: C4Def.h:62
const DWORD C4D_Load_RankNames
Definition: C4Def.h:90
bool Decompile(StdStrBuf *pOut, const char *szName)
Definition: C4Def.cpp:179
int32_t Float
Definition: C4Def.h:122
C4Rect PictureRect
Definition: C4Def.h:109
int32_t LineIntersect
Definition: C4Def.h:129
bool Compile(const char *szSource, const char *szName)
Definition: C4Def.cpp:174
int32_t Projectile
Definition: C4Def.h:134
int32_t GetPlane()
Definition: C4Def.h:214
CSurface8 * pSolidMask
Definition: C4Def.h:195
C4Facet & GetMainFace(C4DefGraphics *pGraphics, DWORD dwClr=0)
Definition: C4Def.h:213
const int32_t C4D_VehicleControl_Inside
Definition: C4Def.h:80
void CrossMapActMap()
const int32_t C4D_Border_Sides
Definition: C4Def.h:67
void CompileFunc(StdCompiler *pComp)
Definition: C4Def.cpp:184
Definition: C4Rect.h:29
int32_t NativeCrew
Definition: C4Def.h:115
bool Save(C4Group &hGroup)
Definition: C4Def.cpp:166
C4Def * Next
Definition: C4Def.h:201
virtual C4Def * GetDef()
Definition: C4Def.h:218
const DWORD C4D_Load_Script
Definition: C4Def.h:85
C4ComponentHost * pClonkNames
Definition: C4Def.h:188
const int32_t C4D_Place_BothSurface
Definition: C4Def.h:76
void IncludeDefinition(C4Def *pIncludeDef)
Definition: C4Def.cpp:635
const int32_t C4D_Border_Top
Definition: C4Def.h:68
bool fRankSymbolsOwned
Definition: C4Def.h:192
int32_t Mass
Definition: C4Def.h:116
void Default()
Definition: C4Def.cpp:302
int32_t SilentCommands
Definition: C4Def.h:142
int32_t NoHorizontalMove
Definition: C4Def.h:124
const DWORD C4D_Load_RankFaces
Definition: C4Def.h:91
bool fRankNamesOwned
Definition: C4Def.h:191
const int32_t C4D_Grab_Get
Definition: C4Def.h:65
const DWORD C4D_Load_Picture
Definition: C4Def.h:83
bool LoadDefCore(C4Group &hGroup)
Definition: C4Def.cpp:144
int32_t Rotateable
Definition: C4Def.h:121
bool Temporary
Definition: C4Def.h:202
int32_t NoPushEnter
Definition: C4Def.h:135
const DWORD C4D_Load_RX
Definition: C4Def.h:93
C4ID BurnTurnTo
Definition: C4Def.h:112
const int32_t C4D_IgnoreFoW
Definition: C4Def.h:57
const int32_t C4D_MouseSelect
Definition: C4Def.h:54
const DWORD C4D_Load_None
Definition: C4Def.h:82
void ResetIncludeDependencies()
Definition: C4Def.cpp:643
const int32_t C4D_Grab_Put
Definition: C4Def.h:64
const int32_t C4D_Border_Bottom
Definition: C4Def.h:69
const int32_t C4D_Object
Definition: C4Def.h:46
void Clear()
Definition: C4Def.cpp:326
int32_t GrowthType
Definition: C4Def.h:113
C4Shape Shape
Definition: C4Def.h:106
int32_t VehicleControl
Definition: C4Def.h:136
bool LoadActMap(C4Group &hGroup)
bool HideInCreator
Definition: C4Def.h:151
int32_t Count
Definition: C4Def.h:182
C4Surface * GetBitmap(DWORD dwClr=0)
C4Rect Collection
Definition: C4Def.h:108
const int32_t C4D_Place_Subsurface
Definition: C4Def.h:75
int32_t Constructable
Definition: C4Def.h:120
C4Facet MainFace
Definition: C4Def.h:198
int32_t NoMassFromContents
Definition: C4Def.h:139
const int32_t C4D_Place_Air
Definition: C4Def.h:74
int32_t ClosedContainer
Definition: C4Def.h:141
int32_t Value
Definition: C4Def.h:117
void Draw(C4Facet &cgo, bool fSelected=false, DWORD iColor=0, C4Object *pObj=nullptr, int32_t iPhaseX=0, int32_t iPhaseY=0, C4DrawTransform *trans=nullptr, const char *graphicsName=nullptr)
Definition: C4Def.cpp:601
const int32_t C4D_All
Definition: C4Def.h:41
Definition: C4Def.h:100
const int32_t C4D_Background
Definition: C4Def.h:52
const int32_t C4D_VehicleControl_Outside
Definition: C4Def.h:79
const int32_t C4D_StaticBack
Definition: C4Def.h:42
int32_t LiftTop
Definition: C4Def.h:125
#define _MAX_FNAME
int32_t rC4XVer[2]
Definition: C4Def.h:104
const int32_t C4D_Rule
Definition: C4Def.h:49
Definition: C4Id.h:28
C4TargetRect SolidMask
Definition: C4Def.h:110
int32_t Oversize
Definition: C4Def.h:132
void Synchronize()
Definition: C4Def.cpp:631
int32_t CrewMember
Definition: C4Def.h:114
const int32_t C4D_Place_Liquid
Definition: C4Def.h:73
C4TargetRect TopFace
Definition: C4Def.h:111
C4PropList * GetActionByName(const char *actname)
Definition: C4Def.cpp:651
C4FacetSurface * pRankSymbols
Definition: C4Def.h:192
virtual C4Def const * GetDef() const
Definition: C4Def.h:217
const int32_t C4D_Structure
Definition: C4Def.h:43
int32_t GetValue(C4Object *pInBase, int32_t iBuyPlayer)
Definition: C4Def.cpp:615
C4IDList RequireDef
Definition: C4Def.h:105
int32_t ColorByOwner
Definition: C4Def.h:123
StdCopyStrBuf ConsoleGroupPath
Definition: C4Def.h:180
int32_t IncompleteActivity
Definition: C4Def.h:130
const int32_t C4D_Border_Layer
Definition: C4Def.h:70
const DWORD C4D_Load_FE
Definition: C4Def.h:92
const int32_t C4D_MouseIgnore
Definition: C4Def.h:56
const DWORD C4D_Load_Bitmap
Definition: C4Def.h:84
virtual bool Delete()
Definition: C4Def.h:219
const int32_t C4D_Living
Definition: C4Def.h:45
C4LangStringTable StringTable
Definition: C4Def.h:185
int32_t NoStabilize
Definition: C4Def.h:140
int32_t NoBreath
Definition: C4Def.h:145
const DWORD C4D_Load_ClonkNames
Definition: C4Def.h:89
C4DefScriptHost Script
Definition: C4Def.h:184
const DWORD C4D_Load_Image
Definition: C4Def.h:87
int32_t MoveToRange
Definition: C4Def.h:138
int32_t GrabPutGet
Definition: C4Def.h:126
int32_t Category
Definition: C4Def.h:119
int32_t AllowPictureStack
Definition: C4Def.h:150
int32_t BlitMode
Definition: C4Def.h:144
const int32_t C4D_Goal
Definition: C4Def.h:48
int32_t NoGet
Definition: C4Def.h:147
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:863
char Filename[_MAX_FNAME+1]
Definition: C4Def.h:179
const int32_t C4D_Parallax
Definition: C4Def.h:53
C4Rect Entrance
Definition: C4Def.h:107
const int32_t C4D_Place_Surface
Definition: C4Def.h:72
int32_t TemporaryCrew
Definition: C4Def.h:143
int32_t Fragile
Definition: C4Def.h:133
C4RankSystem * pRankNames
Definition: C4Def.h:191
const int32_t C4D_None
Definition: C4Def.h:40
const DWORD C4D_Load_Temporary
Definition: C4Def.h:94
C4Surface * Surface
Definition: C4Facet.h:119
int32_t RotatedEntrance
Definition: C4Def.h:148
const DWORD C4D_Load_Sounds
Definition: C4Def.h:88
uint32_t DWORD
int32_t ConSizeOff
Definition: C4Def.h:146
const int32_t C4D_SortLimit
Definition: C4Def.h:59
C4DefGraphics Graphics
Definition: C4Def.h:194
const int32_t C4D_VehicleControl_None
Definition: C4Def.h:78
const int32_t C4D_Foreground
Definition: C4Def.h:55
bool fClonkNamesOwned
Definition: C4Def.h:188