mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
[11123] Move respawn data to InstanceSave.
This make prev commit more useful. In future InstanceSave also planned store local pools state.
This commit is contained in:
parent
852c4ddf32
commit
6cfa64db97
13 changed files with 258 additions and 191 deletions
|
|
@ -1618,90 +1618,6 @@ void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data
|
|||
}
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadCreatureRespawnTimes()
|
||||
{
|
||||
// remove outdated data
|
||||
CharacterDatabase.DirectExecute("DELETE FROM creature_respawn WHERE respawntime <= UNIX_TIMESTAMP(NOW())");
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, instance FROM creature_respawn");
|
||||
|
||||
if(!result)
|
||||
{
|
||||
barGoLink bar(1);
|
||||
|
||||
bar.step();
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString(">> Loaded 0 creature respawn time.");
|
||||
return;
|
||||
}
|
||||
|
||||
barGoLink bar((int)result->GetRowCount());
|
||||
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
bar.step();
|
||||
|
||||
uint32 loguid = fields[0].GetUInt32();
|
||||
uint64 respawn_time = fields[1].GetUInt64();
|
||||
uint32 instance = fields[2].GetUInt32();
|
||||
|
||||
mCreatureRespawnTimes[MAKE_PAIR64(loguid,instance)] = time_t(respawn_time);
|
||||
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
delete result;
|
||||
|
||||
sLog.outString( ">> Loaded %lu creature respawn times", (unsigned long)mCreatureRespawnTimes.size() );
|
||||
sLog.outString();
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadGameobjectRespawnTimes()
|
||||
{
|
||||
// remove outdated data
|
||||
CharacterDatabase.DirectExecute("DELETE FROM gameobject_respawn WHERE respawntime <= UNIX_TIMESTAMP(NOW())");
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, instance FROM gameobject_respawn");
|
||||
|
||||
if(!result)
|
||||
{
|
||||
barGoLink bar(1);
|
||||
|
||||
bar.step();
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString(">> Loaded 0 gameobject respawn time.");
|
||||
return;
|
||||
}
|
||||
|
||||
barGoLink bar((int)result->GetRowCount());
|
||||
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
bar.step();
|
||||
|
||||
uint32 loguid = fields[0].GetUInt32();
|
||||
uint64 respawn_time = fields[1].GetUInt64();
|
||||
uint32 instance = fields[2].GetUInt32();
|
||||
|
||||
mGORespawnTimes[MAKE_PAIR64(loguid,instance)] = time_t(respawn_time);
|
||||
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
delete result;
|
||||
|
||||
sLog.outString( ">> Loaded %lu gameobject respawn times", (unsigned long)mGORespawnTimes.size() );
|
||||
sLog.outString();
|
||||
}
|
||||
|
||||
// name must be checked to correctness (if received) before call this function
|
||||
uint64 ObjectMgr::GetPlayerGUIDByName(std::string name) const
|
||||
{
|
||||
|
|
@ -6840,17 +6756,6 @@ void ObjectMgr::LoadWeatherZoneChances()
|
|||
sLog.outString(">> Loaded %u weather definitions", count);
|
||||
}
|
||||
|
||||
void ObjectMgr::SaveCreatureRespawnTime(uint32 loguid, uint32 instance, time_t t)
|
||||
{
|
||||
mCreatureRespawnTimes[MAKE_PAIR64(loguid,instance)] = t;
|
||||
|
||||
CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabase.PExecute("DELETE FROM creature_respawn WHERE guid = '%u' AND instance = '%u'", loguid, instance);
|
||||
if(t)
|
||||
CharacterDatabase.PExecute("INSERT INTO creature_respawn VALUES ( '%u', '" UI64FMTD "', '%u' )", loguid, uint64(t), instance);
|
||||
CharacterDatabase.CommitTransaction();
|
||||
}
|
||||
|
||||
void ObjectMgr::DeleteCreatureData(uint32 guid)
|
||||
{
|
||||
// remove mapid*cellid -> guid_set map
|
||||
|
|
@ -6861,45 +6766,6 @@ void ObjectMgr::DeleteCreatureData(uint32 guid)
|
|||
mCreatureDataMap.erase(guid);
|
||||
}
|
||||
|
||||
void ObjectMgr::SaveGORespawnTime(uint32 loguid, uint32 instance, time_t t)
|
||||
{
|
||||
mGORespawnTimes[MAKE_PAIR64(loguid,instance)] = t;
|
||||
|
||||
CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabase.PExecute("DELETE FROM gameobject_respawn WHERE guid = '%u' AND instance = '%u'", loguid, instance);
|
||||
if(t)
|
||||
CharacterDatabase.PExecute("INSERT INTO gameobject_respawn VALUES ( '%u', '" UI64FMTD "', '%u' )", loguid, uint64(t), instance);
|
||||
CharacterDatabase.CommitTransaction();
|
||||
}
|
||||
|
||||
void ObjectMgr::DeleteRespawnTimeForInstance(uint32 instance)
|
||||
{
|
||||
RespawnTimes::iterator next;
|
||||
|
||||
for(RespawnTimes::iterator itr = mGORespawnTimes.begin(); itr != mGORespawnTimes.end(); itr = next)
|
||||
{
|
||||
next = itr;
|
||||
++next;
|
||||
|
||||
if (PAIR64_HIPART(itr->first)==instance)
|
||||
mGORespawnTimes.erase(itr);
|
||||
}
|
||||
|
||||
for(RespawnTimes::iterator itr = mCreatureRespawnTimes.begin(); itr != mCreatureRespawnTimes.end(); itr = next)
|
||||
{
|
||||
next = itr;
|
||||
++next;
|
||||
|
||||
if (PAIR64_HIPART(itr->first)==instance)
|
||||
mCreatureRespawnTimes.erase(itr);
|
||||
}
|
||||
|
||||
CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabase.PExecute("DELETE FROM creature_respawn WHERE instance = '%u'", instance);
|
||||
CharacterDatabase.PExecute("DELETE FROM gameobject_respawn WHERE instance = '%u'", instance);
|
||||
CharacterDatabase.CommitTransaction();
|
||||
}
|
||||
|
||||
void ObjectMgr::DeleteGOData(uint32 guid)
|
||||
{
|
||||
// remove mapid*cellid -> guid_set map
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue