Fixed instance reset when high server uptime, thx Wowka321
--HG-- branch : trunk
This commit is contained in:
@@ -535,10 +535,12 @@ void InstanceSaveManager::LoadResetTimes()
|
|||||||
// schedule the global reset/warning
|
// schedule the global reset/warning
|
||||||
uint8 type = 1;
|
uint8 type = 1;
|
||||||
static int tim[4] = {3600, 900, 300, 60};
|
static int tim[4] = {3600, 900, 300, 60};
|
||||||
for (; type < 4; type++)
|
for(type; type < 4; type++)
|
||||||
if(t - tim[type-1] > now)
|
if(t - tim[type-1] > now)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
ScheduleReset(true, t - tim[type-1], InstResetEvent(type, mapid, difficulty, -1));
|
||||||
|
|
||||||
for(ResetTimeMapDiffInstances::const_iterator in_itr = mapDiffResetInstances.lower_bound(map_diff_pair);
|
for(ResetTimeMapDiffInstances::const_iterator in_itr = mapDiffResetInstances.lower_bound(map_diff_pair);
|
||||||
in_itr != mapDiffResetInstances.upper_bound(map_diff_pair); ++in_itr)
|
in_itr != mapDiffResetInstances.upper_bound(map_diff_pair); ++in_itr)
|
||||||
{
|
{
|
||||||
@@ -643,7 +645,8 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b
|
|||||||
if (!mapEntry->Instanceable())
|
if (!mapEntry->Instanceable())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint64 now = (uint64)time(NULL);
|
time_t now = time(NULL);
|
||||||
|
time_t today = (now / DAY) * DAY;
|
||||||
|
|
||||||
if(!warn)
|
if(!warn)
|
||||||
{
|
{
|
||||||
@@ -672,10 +675,12 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b
|
|||||||
|
|
||||||
// calculate the next reset time
|
// calculate the next reset time
|
||||||
uint32 diff = sWorld.getConfig(CONFIG_INSTANCE_RESET_TIME_HOUR) * HOUR;
|
uint32 diff = sWorld.getConfig(CONFIG_INSTANCE_RESET_TIME_HOUR) * HOUR;
|
||||||
uint32 period = mapDiff->resetTime * DAY;
|
uint32 period = (mapDiff->resetTime / DAY * sWorld.getRate(RATE_INSTANCE_RESET_TIME)) * DAY;
|
||||||
uint64 next_reset = ((now + timeLeft + MINUTE) / DAY * DAY) + period + diff;
|
time_t next_reset = today + period + diff;
|
||||||
// update it in the DB
|
// update it in the DB
|
||||||
CharacterDatabase.PExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%d' AND difficulty = '%d'", next_reset, mapid, difficulty);
|
CharacterDatabase.PExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%d' AND difficulty = '%d'", (uint64)next_reset, mapid, difficulty);
|
||||||
|
SetResetTimeFor(mapid,difficulty,(uint64)next_reset);
|
||||||
|
ScheduleReset(true, next_reset-3600, InstResetEvent(1, mapid, difficulty, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// note: this isn't fast but it's meant to be executed very rarely
|
// note: this isn't fast but it's meant to be executed very rarely
|
||||||
|
|||||||
@@ -1491,6 +1491,22 @@ void WorldSession::HandleSetDungeonDifficultyOpcode( WorldPacket & recv_data )
|
|||||||
{
|
{
|
||||||
if(pGroup->IsLeader(_player->GetGUID()))
|
if(pGroup->IsLeader(_player->GetGUID()))
|
||||||
{
|
{
|
||||||
|
for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||||
|
{
|
||||||
|
Player* pGroupGuy = itr->getSource();
|
||||||
|
if(!pGroupGuy)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(!pGroupGuy->IsInMap(pGroupGuy))
|
||||||
|
return;
|
||||||
|
|
||||||
|
map = pGroupGuy->GetMap();
|
||||||
|
if(map && map->IsRaidOrHeroicDungeon())
|
||||||
|
{
|
||||||
|
sLog.outError("WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while inside!", _player->GetGUIDLow());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
// the difficulty is set even if the instances can't be reset
|
// the difficulty is set even if the instances can't be reset
|
||||||
//_player->SendDungeonDifficulty(true);
|
//_player->SendDungeonDifficulty(true);
|
||||||
pGroup->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY, false, _player);
|
pGroup->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY, false, _player);
|
||||||
@@ -1531,10 +1547,27 @@ void WorldSession::HandleSetRaidDifficultyOpcode( WorldPacket & recv_data )
|
|||||||
if(_player->getLevel() < LEVELREQUIREMENT_HEROIC)
|
if(_player->getLevel() < LEVELREQUIREMENT_HEROIC)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(Group *pGroup = _player->GetGroup())
|
Group *pGroup = _player->GetGroup();
|
||||||
|
if(pGroup)
|
||||||
{
|
{
|
||||||
if(pGroup->IsLeader(_player->GetGUID()))
|
if(pGroup->IsLeader(_player->GetGUID()))
|
||||||
{
|
{
|
||||||
|
for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||||
|
{
|
||||||
|
Player* pGroupGuy = itr->getSource();
|
||||||
|
if(!pGroupGuy)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(!pGroupGuy->IsInMap(pGroupGuy))
|
||||||
|
return;
|
||||||
|
|
||||||
|
map = pGroupGuy->GetMap();
|
||||||
|
if(map && map->IsRaidOrHeroicDungeon())
|
||||||
|
{
|
||||||
|
sLog.outError("WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while inside!", _player->GetGUIDLow());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
// the difficulty is set even if the instances can't be reset
|
// the difficulty is set even if the instances can't be reset
|
||||||
//_player->SendDungeonDifficulty(true);
|
//_player->SendDungeonDifficulty(true);
|
||||||
pGroup->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY, true, _player);
|
pGroup->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY, true, _player);
|
||||||
|
|||||||
@@ -19177,6 +19177,7 @@ void Player::UpdateHomebindTime(uint32 time)
|
|||||||
if (time >= m_HomebindTimer)
|
if (time >= m_HomebindTimer)
|
||||||
{
|
{
|
||||||
// teleport to nearest graveyard
|
// teleport to nearest graveyard
|
||||||
|
SetPhaseMask(1,true);
|
||||||
RepopAtGraveyard();
|
RepopAtGraveyard();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -19192,6 +19193,7 @@ void Player::UpdateHomebindTime(uint32 time)
|
|||||||
data << uint32(1);
|
data << uint32(1);
|
||||||
GetSession()->SendPacket(&data);
|
GetSession()->SendPacket(&data);
|
||||||
sLog.outDebug("PLAYER: Player '%s' (GUID: %u) will be teleported to homebind in 60 seconds", GetName(),GetGUIDLow());
|
sLog.outDebug("PLAYER: Player '%s' (GUID: %u) will be teleported to homebind in 60 seconds", GetName(),GetGUIDLow());
|
||||||
|
SetPhaseMask(2,true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user