diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index 7877a79db..fdb85a892 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -1414,11 +1414,12 @@ PStruct::PStruct(FName name, DObject *outer) // // PStruct :: AddField // -// Appends a new field to the end of a struct. +// Appends a new field to the end of a struct. Returns either the new field +// or NULL if a symbol by that name already exists. // //========================================================================== -PField *PStruct::AddField(FName name, PType *type) +PField *PStruct::AddField(FName name, PType *type, DWORD flags) { PField *field = new PField(name, type); @@ -1432,8 +1433,12 @@ PField *PStruct::AddField(FName name, PType *type) // its fields. Align = MAX(Align, type->Align); + if (Symbols.AddSymbol(field) == NULL) + { // name is already in use + delete field; + return NULL; + } Fields.Push(field); - Symbols.AddSymbol(field); return field; } diff --git a/src/dobjtype.h b/src/dobjtype.h index c4fdf48b0..0018d38c4 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -467,7 +467,7 @@ public: TArray Fields; PSymbolTable Symbols; - PField *AddField(FName name, PType *type); + PField *AddField(FName name, PType *type, DWORD flags=0); size_t PropagateMark(); protected: