Add an AddField() override to PClass that extends the default instance

This commit is contained in:
Randy Heit 2016-04-03 16:18:59 -05:00
parent 3357af32e5
commit 806d9d7a95
2 changed files with 20 additions and 1 deletions

View File

@ -2501,6 +2501,24 @@ unsigned int PClass::Extend(unsigned int extension, unsigned int alignment)
return padto;
}
//==========================================================================
//
// PClass :: AddField
//
//==========================================================================
PField *PClass::AddField(FName name, PType *type, DWORD flags)
{
unsigned oldsize = Size;
PField *field = Super::AddField(name, type, flags);
if (field != NULL)
{
Defaults = (BYTE *)M_Realloc(Defaults, Size);
memset(Defaults + oldsize, 0, Size - oldsize);
}
return field;
}
//==========================================================================
//
// PClass :: FindClassTentative

View File

@ -585,7 +585,7 @@ public:
TArray<PField *> Fields;
PField *AddField(FName name, PType *type, DWORD flags=0);
virtual PField *AddField(FName name, PType *type, DWORD flags=0);
size_t PropagateMark();
protected:
@ -672,6 +672,7 @@ public:
PClass *CreateDerivedClass(FName name, unsigned int size);
unsigned int Extend(unsigned int extension, unsigned int alignment);
unsigned int Extend(const PType *type) { return Extend(type->Size, type->Align); }
PField *AddField(FName name, PType *type, DWORD flags=0) override;
void InitializeActorInfo();
void BuildFlatPointers();
const PClass *NativeClass() const;