# HG changeset patch # User Adam Kaminski # Date 1613328069 18000 # Sun Feb 14 13:41:09 2021 -0500 # Node ID caff3b4e9dc31194fda7f98f18e6756241cd483f # Parent 358c6c5419b60b138d43e7c3128a0f65148e3da9 Fixed user variables not being reset for actors that aren't respawned during a map reset. diff -r 358c6c5419b6 -r caff3b4e9dc3 src/dobject.cpp --- a/src/dobject.cpp Sat Feb 13 01:13:43 2021 -0500 +++ b/src/dobject.cpp Sun Feb 14 13:41:09 2021 -0500 @@ -538,6 +538,33 @@ return changed; } +// [AK] +void DObject::ResetUserVars() +{ + PSymbolTable *symt = &GetClass()->Symbols; + DWORD count; + + for (; symt != NULL; symt = symt->ParentSymbolTable) + { + for (unsigned i = 0; i < symt->Symbols.Size(); i++) + { + PSymbol *sym = symt->Symbols[i]; + if (sym->SymbolType == SYM_Variable) + { + PSymbolVariable *var = static_cast(sym); + if (var->bUserVar) + { + count = var->ValueType.Type == VAL_Array ? var->ValueType.size : 1; + for (DWORD j = 0; j < count; j++) + { + ((int *)(reinterpret_cast(this) + var->offset))[j] = 0; + } + } + } + } + } +} + void DObject::SerializeUserVars(FArchive &arc) { PSymbolTable *symt; diff -r 358c6c5419b6 -r caff3b4e9dc3 src/dobject.h --- a/src/dobject.h Sat Feb 13 01:13:43 2021 -0500 +++ b/src/dobject.h Sun Feb 14 13:41:09 2021 -0500 @@ -459,6 +459,7 @@ inline bool IsKindOf (const PClass *base) const; inline bool IsA (const PClass *type) const; + void ResetUserVars (); // [AK] void SerializeUserVars(FArchive &arc); virtual void Serialize (FArchive &arc); diff -r 358c6c5419b6 -r caff3b4e9dc3 src/g_game.cpp --- a/src/g_game.cpp Sat Feb 13 01:13:43 2021 -0500 +++ b/src/g_game.cpp Sun Feb 14 13:41:09 2021 -0500 @@ -3934,6 +3934,9 @@ if ( pActor->args[i] != pActor->SavedArgs[i] ) pActor->args[i] = pActor->SavedArgs[i]; + // [AK] User variables must be reset too. + pActor->ResetUserVars(); + // [BB] This is a valid monster on the map, count it. if ( pActor->CountsAsKill( ) && !(pActor->flags & MF_FRIENDLY) ) level.total_monsters++;