- Compatibility fix: Classes redefined in DECORATE should cause the newer one to replace the

older one in the type table.

SVN r3913 (scripting)
This commit is contained in:
Randy Heit 2012-10-27 02:04:35 +00:00
parent 5b8a54e5ee
commit 7171281507
2 changed files with 27 additions and 0 deletions

View file

@ -1180,6 +1180,7 @@ void PClass::InsertIntoHash ()
{ // This type has already been inserted
// ... but there is no need whatsoever to make it a fatal error!
Printf (TEXTCOLOR_RED"Tried to register class '%s' more than once.\n", TypeName.GetChars());
TypeTable.ReplaceType(this, found, bucket);
}
else
{
@ -1471,6 +1472,31 @@ PType *FTypeTable::FindType(PClass *metatype, intptr_t parm1, intptr_t parm2, si
return NULL;
}
//==========================================================================
//
// FTypeTable :: ReplaceType
//
// Replaces an existing type in the table with a new version of the same
// type. For use when redefining actors in DECORATE. Does nothing if the
// old version is not in the table.
//
//==========================================================================
void FTypeTable::ReplaceType(PType *newtype, PType *oldtype, size_t bucket)
{
for (PType **type_p = &TypeHash[bucket]; *type_p != NULL; type_p = &(*type_p)->HashNext)
{
PType *type = *type_p;
if (type == oldtype)
{
newtype->HashNext = type->HashNext;
type->HashNext = NULL;
*type_p = newtype;
break;
}
}
}
//==========================================================================
//
// FTypeTable :: AddType - Fully Parameterized Version

View file

@ -561,6 +561,7 @@ struct FTypeTable
PType *TypeHash[HASH_SIZE];
PType *FindType(PClass *metatype, intptr_t parm1, intptr_t parm2, size_t *bucketnum);
void ReplaceType(PType *newtype, PType *oldtype, size_t bucket);
void AddType(PType *type, PClass *metatype, intptr_t parm1, intptr_t parm2, size_t bucket);
void AddType(PType *type);
void Mark();