- changed handling of duplicate classes in DECORATE.

Instead of replacing the original, the second class will get renamed now, using the originating file as an identifier. In the vast majority of cases this should do exactly what is needed: Create an unconflicting second class that can coexist with the original. Unless the class is used by name this should eliminate all problems with this, but so far I haven't seen anything that used them by name.

This is choosing the lesser of two evils. While some mod out there may get broken, the old setup meant that the first class of a given name could not be written out to a savegame because it was not retrievable when loading it back.
This commit is contained in:
Christoph Oelckers 2016-10-07 15:28:25 +02:00
commit d819aafcf3
4 changed files with 72 additions and 16 deletions

View file

@ -2985,9 +2985,11 @@ static bool LoadDehSupp ()
void FinishDehPatch ()
{
unsigned int touchedIndex;
unsigned int nameindex = 0;
for (touchedIndex = 0; touchedIndex < TouchedActors.Size(); ++touchedIndex)
{
PClassActor *subclass;
PClassActor *type = TouchedActors[touchedIndex];
AActor *defaults1 = GetDefaultByType (type);
if (!(defaults1->flags & MF_SPECIAL))
@ -2997,9 +2999,16 @@ void FinishDehPatch ()
// Create a new class that will serve as the actual pickup
char typeNameBuilder[32];
mysnprintf (typeNameBuilder, countof(typeNameBuilder), "DehackedPickup%d", touchedIndex);
PClassActor *subclass = static_cast<PClassActor *>(RUNTIME_CLASS(ADehackedPickup)->
CreateDerivedClass(typeNameBuilder, sizeof(ADehackedPickup)));
//
do
{
// Retry until we find a free name. This is unlikely to happen but not impossible.
mysnprintf(typeNameBuilder, countof(typeNameBuilder), "DehackedPickup%d", nameindex++);
subclass = static_cast<PClassActor *>(RUNTIME_CLASS(ADehackedPickup)->
CreateDerivedClass(typeNameBuilder, sizeof(ADehackedPickup)));
}
while (subclass == nullptr);
AActor *defaults2 = GetDefaultByType (subclass);
memcpy ((void *)defaults2, (void *)defaults1, sizeof(AActor));