fix db bug; cleanup; better destructors

This commit is contained in:
DarthArgus
2016-12-08 17:23:03 +00:00
parent eab175813d
commit a353c128c3
4 changed files with 50 additions and 30 deletions
@@ -174,15 +174,33 @@ Persister::~Persister()
{
DEBUG_FATAL(taskQueue,("Call shutdown() before deleting Persister.\n"));
ServerSnapshotMap::iterator i;
for (i=m_currentSnapshots.begin(); i!=m_currentSnapshots.end(); ++i)
for (auto i=m_currentSnapshots.begin(); i!=m_currentSnapshots.end(); ++i) {
delete i->second;
for (i=m_newObjectSnapshots.begin(); i!=m_newObjectSnapshots.end(); ++i)
i->second = nullptr;
}
for (auto i=m_newObjectSnapshots.begin(); i!=m_newObjectSnapshots.end(); ++i) {
delete i->second;
i->second = nullptr;
}
for (auto i=m_savingCharacterSnapshots.begin(); i!=m_savingCharacterSnapshots.end(); ++i) {
delete *i;
*i = nullptr;
}
for (auto i=m_savingSnapshots.begin(); i!=m_savingSnapshots.end(); ++i) {
delete *i;
*i = nullptr;
}
m_currentSnapshots.clear();
m_newObjectSnapshots.clear();
m_objectSnapshotMap.clear();
m_savingCharacterSnapshots.clear();
m_savingSnapshots.clear();
m_messageSnapshot = nullptr;
m_commoditiesSnapshot = nullptr;
m_arbitraryGameDataSnapshot = nullptr;
@@ -599,12 +617,14 @@ void Persister::endBaselines(const NetworkId &objectId, uint32 serverId)
void Persister::saveCompleted(Snapshot *completedSnapshot)
{
if (completedSnapshot) {
delete completedSnapshot;
completedSnapshot = nullptr;
}
SnapshotListType::iterator i=std::remove(m_savingSnapshots.begin(),m_savingSnapshots.end(),completedSnapshot);
if (i!=m_savingSnapshots.end())
{
delete completedSnapshot;
completedSnapshot = nullptr;
m_savingSnapshots.erase(i, m_savingSnapshots.end());
if (m_savingSnapshots.empty() && ConfigServerDatabase::getReportSaveTimes())
{
@@ -637,10 +657,8 @@ void Persister::saveCompleted(Snapshot *completedSnapshot)
{
SnapshotListType::iterator j=std::remove(m_savingCharacterSnapshots.begin(),m_savingCharacterSnapshots.end(),completedSnapshot);
DEBUG_FATAL(i==m_savingCharacterSnapshots.end(),("Programmer bug: SaveCompleted() called with a snapshot that wasn't in m_savingSnapshots or m_savingCharacterSnapshots."));
delete completedSnapshot;
completedSnapshot = nullptr;
m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end());
m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end());
DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("New character save completed\n"));
}
}