- Removed the old meta data system. All meta data is now stored in subclasses of PClass. This
should simplify scripting, since it means that meta fields can be treated (mostly) the same as normal fields. SVN r2242 (scripting)
This commit is contained in:
parent
f88f601230
commit
604b5ef673
62 changed files with 902 additions and 802 deletions
128
src/dobject.cpp
128
src/dobject.cpp
|
|
@ -60,134 +60,6 @@ ClassReg DObject::RegistrationInfo =
|
|||
};
|
||||
_DECLARE_TI(DObject)
|
||||
|
||||
FMetaTable::~FMetaTable ()
|
||||
{
|
||||
FreeMeta ();
|
||||
}
|
||||
|
||||
FMetaTable::FMetaTable (const FMetaTable &other)
|
||||
{
|
||||
Meta = NULL;
|
||||
CopyMeta (&other);
|
||||
}
|
||||
|
||||
FMetaTable &FMetaTable::operator = (const FMetaTable &other)
|
||||
{
|
||||
CopyMeta (&other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void FMetaTable::FreeMeta ()
|
||||
{
|
||||
while (Meta != NULL)
|
||||
{
|
||||
FMetaData *meta = Meta;
|
||||
|
||||
switch (meta->Type)
|
||||
{
|
||||
case META_String:
|
||||
delete[] meta->Value.String;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Meta = meta->Next;
|
||||
delete meta;
|
||||
}
|
||||
}
|
||||
|
||||
void FMetaTable::CopyMeta (const FMetaTable *other)
|
||||
{
|
||||
const FMetaData *meta_src;
|
||||
FMetaData **meta_dest;
|
||||
|
||||
FreeMeta ();
|
||||
|
||||
meta_src = other->Meta;
|
||||
meta_dest = &Meta;
|
||||
while (meta_src != NULL)
|
||||
{
|
||||
FMetaData *newmeta = new FMetaData (meta_src->Type, meta_src->ID);
|
||||
switch (meta_src->Type)
|
||||
{
|
||||
case META_String:
|
||||
newmeta->Value.String = copystring (meta_src->Value.String);
|
||||
break;
|
||||
default:
|
||||
newmeta->Value = meta_src->Value;
|
||||
break;
|
||||
}
|
||||
*meta_dest = newmeta;
|
||||
meta_dest = &newmeta->Next;
|
||||
meta_src = meta_src->Next;
|
||||
}
|
||||
*meta_dest = NULL;
|
||||
}
|
||||
|
||||
FMetaData *FMetaTable::FindMeta (EMetaType type, DWORD id) const
|
||||
{
|
||||
FMetaData *meta = Meta;
|
||||
|
||||
while (meta != NULL)
|
||||
{
|
||||
if (meta->ID == id && meta->Type == type)
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
meta = meta->Next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FMetaData *FMetaTable::FindMetaDef (EMetaType type, DWORD id)
|
||||
{
|
||||
FMetaData *meta = FindMeta (type, id);
|
||||
if (meta == NULL)
|
||||
{
|
||||
meta = new FMetaData (type, id);
|
||||
meta->Next = Meta;
|
||||
meta->Value.String = NULL;
|
||||
Meta = meta;
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
|
||||
void FMetaTable::SetMetaInt (DWORD id, int parm)
|
||||
{
|
||||
FMetaData *meta = FindMetaDef (META_Int, id);
|
||||
meta->Value.Int = parm;
|
||||
}
|
||||
|
||||
int FMetaTable::GetMetaInt (DWORD id, int def) const
|
||||
{
|
||||
FMetaData *meta = FindMeta (META_Int, id);
|
||||
return meta != NULL ? meta->Value.Int : def;
|
||||
}
|
||||
|
||||
void FMetaTable::SetMetaFixed (DWORD id, fixed_t parm)
|
||||
{
|
||||
FMetaData *meta = FindMetaDef (META_Fixed, id);
|
||||
meta->Value.Fixed = parm;
|
||||
}
|
||||
|
||||
fixed_t FMetaTable::GetMetaFixed (DWORD id, fixed_t def) const
|
||||
{
|
||||
FMetaData *meta = FindMeta (META_Fixed, id);
|
||||
return meta != NULL ? meta->Value.Fixed : def;
|
||||
}
|
||||
|
||||
void FMetaTable::SetMetaString (DWORD id, const char *parm)
|
||||
{
|
||||
FMetaData *meta = FindMetaDef (META_String, id);
|
||||
ReplaceString (&meta->Value.String, parm);
|
||||
}
|
||||
|
||||
const char *FMetaTable::GetMetaString (DWORD id) const
|
||||
{
|
||||
FMetaData *meta = FindMeta (META_String, id);
|
||||
return meta != NULL ? meta->Value.String : NULL;
|
||||
}
|
||||
|
||||
CCMD (dumpclasses)
|
||||
{
|
||||
// This is by no means speed-optimized. But it's an informational console
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue