diff --git a/sp/src/responserules/runtime/response_system.cpp b/sp/src/responserules/runtime/response_system.cpp index 7867bda0..968f856d 100644 --- a/sp/src/responserules/runtime/response_system.cpp +++ b/sp/src/responserules/runtime/response_system.cpp @@ -246,7 +246,12 @@ void CResponseSystem::Clear() { m_Responses.RemoveAll(); m_Criteria.RemoveAll(); +#ifdef MAPBASE + // Must purge to avoid issues with reloading the system + m_RulePartitions.PurgeAndDeleteElements(); +#else m_RulePartitions.RemoveAll(); +#endif m_Enumerations.RemoveAll(); } diff --git a/sp/src/responserules/runtime/response_types_internal.cpp b/sp/src/responserules/runtime/response_types_internal.cpp index 72e7eca5..fe6d7fd0 100644 --- a/sp/src/responserules/runtime/response_types_internal.cpp +++ b/sp/src/responserules/runtime/response_types_internal.cpp @@ -88,6 +88,20 @@ void ResponseRulePartition::RemoveAll( void ) } } +#ifdef MAPBASE +void ResponseRulePartition::PurgeAndDeleteElements() +{ + for ( int bukkit = 0 ; bukkit < N_RESPONSE_PARTITIONS ; ++bukkit ) + { + for ( int i = m_RuleParts[bukkit].FirstInorder(); i != m_RuleParts[bukkit].InvalidIndex(); i = m_RuleParts[bukkit].NextInorder( i ) ) + { + delete m_RuleParts[bukkit][ i ]; + } + m_RuleParts[bukkit].Purge(); + } +} +#endif + // don't bucket "subject" criteria that prefix with operators, since stripping all that out again would // be a big pain, and the most important rules that need subjects are tlk_remarks anyway. static inline bool CanBucketBySubject( const char * RESTRICT pszSubject ) diff --git a/sp/src/responserules/runtime/response_types_internal.h b/sp/src/responserules/runtime/response_types_internal.h index 20cc9d54..25b6f2d1 100644 --- a/sp/src/responserules/runtime/response_types_internal.h +++ b/sp/src/responserules/runtime/response_types_internal.h @@ -433,6 +433,9 @@ namespace ResponseRules // dump everything. void RemoveAll(); +#ifdef MAPBASE + void PurgeAndDeleteElements(); +#endif inline Rule &operator[]( tIndex idx ); int Count( void ); // number of elements inside, but you can't iterate from 0 to this