mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 16:38:42 +01:00
Core/DBLayer: Replace some asynchronous queries to synchronous ones in instance loading to prevent corruption in some cases
--HG-- branch : trunk
This commit is contained in:
@@ -241,7 +241,7 @@ void InstanceSaveManager::_DelHelper(const char *fields, const char *table, cons
|
||||
CharacterDatabase.escape_string(fieldValue);
|
||||
ss << (i != 0 ? " AND " : "") << fieldTokens[i] << " = '" << fieldValue << "'";
|
||||
}
|
||||
CharacterDatabase.PExecute("DELETE FROM %s WHERE %s", table, ss.str().c_str());
|
||||
CharacterDatabase.PQuery("DELETE FROM %s WHERE %s", table, ss.str().c_str());
|
||||
} while (result->NextRow());
|
||||
}
|
||||
}
|
||||
@@ -431,7 +431,7 @@ void InstanceSaveManager::LoadResetTimes()
|
||||
InstResetTimeMapDiffType::iterator itr = instResetTime.find(instance);
|
||||
if (itr != instResetTime.end() && itr->second.second != resettime)
|
||||
{
|
||||
CharacterDatabase.PExecute("UPDATE instance SET resettime = '"UI64FMTD"' WHERE id = '%u'", uint64(resettime), instance);
|
||||
CharacterDatabase.PQuery("UPDATE instance SET resettime = '"UI64FMTD"' WHERE id = '%u'", uint64(resettime), instance);
|
||||
itr->second.second = resettime;
|
||||
}
|
||||
}
|
||||
@@ -460,14 +460,14 @@ void InstanceSaveManager::LoadResetTimes()
|
||||
if (!mapDiff)
|
||||
{
|
||||
sLog.outError("InstanceSaveManager::LoadResetTimes: invalid mapid(%u)/difficulty(%u) pair in instance_reset!", mapid, difficulty);
|
||||
CharacterDatabase.PExecute("DELETE FROM instance_reset WHERE mapid = '%u' AND difficulty = '%u'", mapid,difficulty);
|
||||
CharacterDatabase.PQuery("DELETE FROM instance_reset WHERE mapid = '%u' AND difficulty = '%u'", mapid,difficulty);
|
||||
continue;
|
||||
}
|
||||
|
||||
// update the reset time if the hour in the configs changes
|
||||
uint64 newresettime = (oldresettime / DAY) * DAY + diff;
|
||||
if (oldresettime != newresettime)
|
||||
CharacterDatabase.PExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u' AND difficulty = '%u'", newresettime, mapid, difficulty);
|
||||
CharacterDatabase.PQuery("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u' AND difficulty = '%u'", newresettime, mapid, difficulty);
|
||||
|
||||
SetResetTimeFor(mapid,difficulty,newresettime);
|
||||
} while (result->NextRow());
|
||||
@@ -498,7 +498,7 @@ void InstanceSaveManager::LoadResetTimes()
|
||||
{
|
||||
// initialize the reset time
|
||||
t = today + period + diff;
|
||||
CharacterDatabase.PExecute("INSERT INTO instance_reset VALUES ('%u','%u','"UI64FMTD"')", mapid, difficulty, (uint64)t);
|
||||
CharacterDatabase.PQuery("INSERT INTO instance_reset VALUES ('%u','%u','"UI64FMTD"')", mapid, difficulty, (uint64)t);
|
||||
}
|
||||
|
||||
if (t < now)
|
||||
@@ -507,7 +507,7 @@ void InstanceSaveManager::LoadResetTimes()
|
||||
// calculate the next reset time
|
||||
t = (t / DAY) * DAY;
|
||||
t += ((today - t) / period + 1) * period + diff;
|
||||
CharacterDatabase.PExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u' AND difficulty= '%u'", (uint64)t, mapid, difficulty);
|
||||
CharacterDatabase.PQuery("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u' AND difficulty= '%u'", (uint64)t, mapid, difficulty);
|
||||
}
|
||||
|
||||
SetResetTimeFor(mapid,difficulty,t);
|
||||
|
||||
Reference in New Issue
Block a user