mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Further fixes of unreleased objects.
This commit is contained in:
parent
59e4b9ad7c
commit
f795981dd9
@ -42,6 +42,7 @@ extern void InitializeTasks();
|
||||
extern void InitializeRoutines();
|
||||
extern void TerminateAreas();
|
||||
extern void TerminateTasks();
|
||||
extern void TerminatePrivileges();
|
||||
extern void TerminateRoutines();
|
||||
extern void TerminateCommands();
|
||||
extern void TerminateSignals();
|
||||
@ -493,6 +494,8 @@ void Core::Terminate(bool shutdown)
|
||||
TerminateSignals();
|
||||
// Release all managed areas
|
||||
TerminateAreas();
|
||||
// Release privilege managers
|
||||
TerminatePrivileges();
|
||||
// In case there's a payload for reload
|
||||
m_ReloadPayload.Release();
|
||||
// Release null objects in case any reference to valid objects is stored in them
|
||||
|
@ -14,6 +14,9 @@ SQMODE_DECL_TYPENAME(ManagerTn, _SC("SqPrivilegeManager"))
|
||||
// Helper value used to identify an index that doesn't exist.
|
||||
static constexpr size_t BAD_POS = ~static_cast< size_t >(0);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
PvManagers PvManager::s_Managers;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
PvManager & PvUnit::GetManager() const
|
||||
{
|
||||
@ -319,6 +322,10 @@ std::pair< PvUnit *, LightObj > PvManager::CreateUnitImpl(SQInteger id, PvClass
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void TerminatePrivileges()
|
||||
{
|
||||
PvManager::Terminate();
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_Privilege(HSQUIRRELVM vm)
|
||||
|
@ -39,6 +39,8 @@ typedef std::vector< std::pair< SQInteger, PvUnit * > > PvUnitList;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
typedef std::vector< std::pair< SQInteger, SQInteger > > PvStatusList;
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
typedef std::vector< PvManager * > PvManagers;
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* An individual unit/entity that inherits the privileges of a class/group and can
|
||||
@ -154,6 +156,18 @@ public:
|
||||
bool operator <= (const PvUnit & o) const { return m_ID <= o.m_ID; }
|
||||
bool operator >= (const PvUnit & o) const { return m_ID >= o.m_ID; }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Release all script resources. Recursively forward request.
|
||||
*/
|
||||
void Release()
|
||||
{
|
||||
m_OnQuery.Release();
|
||||
m_OnGained.Release();
|
||||
m_OnLost.Release();
|
||||
m_Tag.Release();
|
||||
m_Data.Release();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the identifier associated with this unit.
|
||||
*/
|
||||
@ -439,6 +453,18 @@ public:
|
||||
bool operator <= (const PvClass & o) const { return m_ID <= o.m_ID; }
|
||||
bool operator >= (const PvClass & o) const { return m_ID >= o.m_ID; }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Release all script resources. Recursively forward request.
|
||||
*/
|
||||
void Release()
|
||||
{
|
||||
m_OnQuery.Release();
|
||||
m_OnGained.Release();
|
||||
m_OnLost.Release();
|
||||
m_Tag.Release();
|
||||
m_Data.Release();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the identifier associated with this manager.
|
||||
*/
|
||||
@ -745,6 +771,20 @@ public:
|
||||
bool operator <= (const PvEntry & o) const { return m_ID <= o.m_ID; }
|
||||
bool operator >= (const PvEntry & o) const { return m_ID >= o.m_ID; }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Release all script resources. Recursively forward request.
|
||||
*/
|
||||
void Release()
|
||||
{
|
||||
m_Tag.Release();
|
||||
m_OnQuery.Release();
|
||||
m_OnGained.Release();
|
||||
m_OnLost.Release();
|
||||
m_Data.Release();
|
||||
m_Brief.Release();
|
||||
m_Info.Release();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the manager associated with this unit.
|
||||
*/
|
||||
@ -980,6 +1020,11 @@ private:
|
||||
*/
|
||||
LightObj m_Data;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* List of active privilege managers.
|
||||
*/
|
||||
static PvManagers s_Managers;
|
||||
|
||||
public:
|
||||
|
||||
/* -------------------------------------------------------------------------------------------
|
||||
@ -990,6 +1035,7 @@ public:
|
||||
, m_OnQuery(), m_OnGained(), m_OnLost()
|
||||
, m_Tag(), m_Data()
|
||||
{
|
||||
s_Managers.push_back(this);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------------------------
|
||||
@ -1000,6 +1046,7 @@ public:
|
||||
, m_OnQuery(), m_OnGained(), m_OnLost()
|
||||
, m_Tag(std::move(tag)), m_Data()
|
||||
{
|
||||
s_Managers.push_back(this);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------------------------
|
||||
@ -1017,6 +1064,7 @@ public:
|
||||
*/
|
||||
~PvManager()
|
||||
{
|
||||
s_Managers.erase(std::remove(s_Managers.begin(), s_Managers.end(), this), s_Managers.end());
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------------------------
|
||||
@ -1231,6 +1279,46 @@ public:
|
||||
{
|
||||
return m_OnGained;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Release all script resources. Recursively forward request to all classes, units and entries.
|
||||
*/
|
||||
void Release()
|
||||
{
|
||||
// Release objects from entries
|
||||
for (auto & pve : m_Entries)
|
||||
{
|
||||
pve.second->Release();
|
||||
}
|
||||
// Release objects from classes
|
||||
for (auto & pvc : m_Classes)
|
||||
{
|
||||
pvc.second->Release();
|
||||
}
|
||||
// Release objects from units
|
||||
for (auto & pvu : m_Units)
|
||||
{
|
||||
pvu.second->Release();
|
||||
}
|
||||
// Release objects from this instance
|
||||
m_OnQuery.Release();
|
||||
m_OnGained.Release();
|
||||
m_OnLost.Release();
|
||||
m_Tag.Release();
|
||||
m_Data.Release();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Terminate the all managers by releasing their classes and units and callbacks.
|
||||
*/
|
||||
static void Terminate()
|
||||
{
|
||||
for (auto & pvm : s_Managers)
|
||||
{
|
||||
pvm->Release();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
Loading…
Reference in New Issue
Block a user