[Respawns] Convert Respawn Times to Repositories (#3949)

* [Respawns] Convert Respawn Times to Repositories

- Convert `respawn_times` based methods to repositories.

* Missed some.

* Comments
This commit is contained in:
Alex King
2024-01-12 23:38:31 -05:00
committed by GitHub
parent 818f833d04
commit 71f78b757e
7 changed files with 108 additions and 94 deletions
+18 -14
View File
@@ -3090,35 +3090,39 @@ void QuestManager::removeitem(uint32 item_id, uint32 quantity) {
initiator->RemoveItem(item_id, quantity);
}
void QuestManager::UpdateSpawnTimer(uint32 id, uint32 newTime)
void QuestManager::UpdateSpawnTimer(uint32 spawn2_id, uint32 new_time)
{
bool found = false;
database.UpdateRespawnTime(id, 0, (newTime/1000));
database.UpdateRespawnTime(spawn2_id, 0, (new_time / 1000));
LinkedListIterator<Spawn2*> iterator(zone->spawn2_list);
iterator.Reset();
while (iterator.MoreElements())
{
if(iterator.GetData()->GetID() == id)
{
if(!iterator.GetData()->NPCPointerValid())
{
iterator.GetData()->SetTimer(newTime);
while (iterator.MoreElements()) {
if (iterator.GetData()->GetID() == spawn2_id) {
if (!iterator.GetData()->NPCPointerValid()) {
iterator.GetData()->SetTimer(new_time);
}
found = true;
break;
}
iterator.Advance();
}
if(!found)
{
if (!found) {
//Spawn wasn't in this zone...
//Tell the other zones to update their spawn time for this spawn point
auto pack = new ServerPacket(ServerOP_UpdateSpawn, sizeof(UpdateSpawnTimer_Struct));
UpdateSpawnTimer_Struct *ust = (UpdateSpawnTimer_Struct*) pack->pBuffer;
ust->id = id;
ust->duration = newTime;
auto ust = (UpdateSpawnTimer_Struct*) pack->pBuffer;
ust->id = spawn2_id;
ust->duration = new_time;
worldserver.SendPacket(pack);
safe_delete(pack);
}