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