forked from Mirrors/openclonk
Allow CNAT_* constants in VertexCNAT definition of DefCore (#1307)
Also fix decompiling of none-values in bitfields.stable-6.1
parent
b1b8fedb25
commit
6699cd3712
|
@ -426,6 +426,9 @@ struct StdArrayDefaultArrayAdapt
|
||||||
template <class T, class D>
|
template <class T, class D>
|
||||||
inline StdArrayDefaultArrayAdapt<T, D> mkArrayAdaptDefArr(T *pArray, size_t iSize, const D &rDefault) { return StdArrayDefaultArrayAdapt<T, D>(pArray, iSize, rDefault); }
|
inline StdArrayDefaultArrayAdapt<T, D> mkArrayAdaptDefArr(T *pArray, size_t iSize, const D &rDefault) { return StdArrayDefaultArrayAdapt<T, D>(pArray, iSize, rDefault); }
|
||||||
#define mkArrayAdaptDMA(A, D) mkArrayAdaptDefArr(A, sizeof(A) / sizeof(*(A)), D)
|
#define mkArrayAdaptDMA(A, D) mkArrayAdaptDefArr(A, sizeof(A) / sizeof(*(A)), D)
|
||||||
|
template <class T, class D, class M>
|
||||||
|
inline StdArrayDefaultArrayAdapt<T, D, M> mkArrayAdaptDefArrMap(T *pArray, size_t iSize, const D &rDefault, const M &map) { return StdArrayDefaultArrayAdapt<T, D, M>(pArray, iSize, rDefault, map); }
|
||||||
|
#define mkArrayAdaptDMAM(A, D, M) mkArrayAdaptDefArrMap(A, sizeof(A) / sizeof(*(A)), D, M)
|
||||||
|
|
||||||
// * Insertion Adaptor
|
// * Insertion Adaptor
|
||||||
// Compile a value before / after another
|
// Compile a value before / after another
|
||||||
|
@ -934,12 +937,14 @@ struct StdBitfieldAdapt
|
||||||
// writing?
|
// writing?
|
||||||
if (!pComp->isCompiler())
|
if (!pComp->isCompiler())
|
||||||
{
|
{
|
||||||
T val = rVal;
|
T val = rVal, orig_val = rVal;
|
||||||
// Write until value is comsumed
|
// Write until value is comsumed
|
||||||
bool fFirst = true;
|
bool fFirst = true;
|
||||||
for (const Entry *pName = pNames; val && pName->Name; pName++)
|
for (const Entry *pName = pNames; pName->Name; pName++)
|
||||||
if ((pName->Val & val) == pName->Val)
|
if ((pName->Val & val) == pName->Val)
|
||||||
{
|
{
|
||||||
|
// Avoid writing meaningless none-values (e.g. Category=C4D_None|C4D_Object)
|
||||||
|
if (orig_val && !pName->Val) continue;
|
||||||
// Put "|"
|
// Put "|"
|
||||||
if (!fFirst) pComp->Separator(StdCompiler::SEP_VLINE);
|
if (!fFirst) pComp->Separator(StdCompiler::SEP_VLINE);
|
||||||
// Put name
|
// Put name
|
||||||
|
|
|
@ -528,6 +528,21 @@ void C4Shape::CreateOwnOriginalCopy(C4Shape &rFrom)
|
||||||
|
|
||||||
void C4Shape::CompileFunc(StdCompiler *pComp, const C4Shape *default_shape)
|
void C4Shape::CompileFunc(StdCompiler *pComp, const C4Shape *default_shape)
|
||||||
{
|
{
|
||||||
|
const StdBitfieldEntry<int32_t> ContactDirections[] =
|
||||||
|
{
|
||||||
|
|
||||||
|
{ "CNAT_None", CNAT_None },
|
||||||
|
{ "CNAT_Left", CNAT_Left },
|
||||||
|
{ "CNAT_Right", CNAT_Right },
|
||||||
|
{ "CNAT_Top", CNAT_Top },
|
||||||
|
{ "CNAT_Bottom", CNAT_Bottom },
|
||||||
|
{ "CNAT_Center", CNAT_Center },
|
||||||
|
{ "CNAT_MultiAttach", CNAT_MultiAttach },
|
||||||
|
{ "CNAT_NoCollision", CNAT_NoCollision },
|
||||||
|
|
||||||
|
{ NULL, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
// a default shape is given in object compilation context only
|
// a default shape is given in object compilation context only
|
||||||
bool fRuntime = !!default_shape;
|
bool fRuntime = !!default_shape;
|
||||||
C4Shape default_def_shape;
|
C4Shape default_def_shape;
|
||||||
|
@ -540,7 +555,7 @@ void C4Shape::CompileFunc(StdCompiler *pComp, const C4Shape *default_shape)
|
||||||
pComp->Value(mkNamingAdapt( VtxNum, "Vertices", default_shape->VtxNum));
|
pComp->Value(mkNamingAdapt( VtxNum, "Vertices", default_shape->VtxNum));
|
||||||
pComp->Value(mkNamingAdapt( mkArrayAdaptDMA(VtxX, default_shape->VtxX), "VertexX", default_shape->VtxX));
|
pComp->Value(mkNamingAdapt( mkArrayAdaptDMA(VtxX, default_shape->VtxX), "VertexX", default_shape->VtxX));
|
||||||
pComp->Value(mkNamingAdapt( mkArrayAdaptDMA(VtxY, default_shape->VtxY), "VertexY", default_shape->VtxY));
|
pComp->Value(mkNamingAdapt( mkArrayAdaptDMA(VtxY, default_shape->VtxY), "VertexY", default_shape->VtxY));
|
||||||
pComp->Value(mkNamingAdapt( mkArrayAdaptDMA(VtxCNAT, default_shape->VtxCNAT), "VertexCNAT", default_shape->VtxCNAT));
|
pComp->Value(mkNamingAdapt( mkArrayAdaptDMAM(VtxCNAT, default_shape->VtxCNAT, [&](decltype(*VtxCNAT) &elem){ return mkBitfieldAdapt<int32_t>(elem, ContactDirections); }), "VertexCNAT", default_shape->VtxCNAT));
|
||||||
pComp->Value(mkNamingAdapt( mkArrayAdaptDMA(VtxFriction, default_shape->VtxFriction), "VertexFriction", default_shape->VtxFriction));
|
pComp->Value(mkNamingAdapt( mkArrayAdaptDMA(VtxFriction, default_shape->VtxFriction), "VertexFriction", default_shape->VtxFriction));
|
||||||
pComp->Value(mkNamingAdapt( ContactDensity, "ContactDensity", default_shape->ContactDensity));
|
pComp->Value(mkNamingAdapt( ContactDensity, "ContactDensity", default_shape->ContactDensity));
|
||||||
pComp->Value(mkNamingAdapt( FireTop, "FireTop", default_shape->FireTop));
|
pComp->Value(mkNamingAdapt( FireTop, "FireTop", default_shape->FireTop));
|
||||||
|
|
Loading…
Reference in New Issue