fix(Core/Worldsession): add option to prevent logout when AFK in a sanctuary zone (#2205)

This commit is contained in:
mik1893
2019-09-09 22:53:37 +01:00
committed by Stoabrogga
parent ee09fb8f9d
commit 67d180ea77
4 changed files with 21 additions and 2 deletions

View File

@@ -424,6 +424,12 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket & /*recv_data*/)
bool instantLogout = ((GetSecurity() >= 0 && uint32(GetSecurity()) >= sWorld->getIntConfig(CONFIG_INSTANT_LOGOUT))
|| (GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) && !GetPlayer()->IsInCombat())) || GetPlayer()->IsInFlight();
bool preventAfkSanctuaryLogout = sWorld->getIntConfig(CONFIG_AFK_PREVENT_LOGOUT) == 1
&& GetPlayer()->isAFK() && sAreaTableStore.LookupEntry(GetPlayer()->GetAreaId())->IsSanctuary();
bool preventAfkLogout = sWorld->getIntConfig(CONFIG_AFK_PREVENT_LOGOUT) == 2
&& GetPlayer()->isAFK();
/// TODO: Possibly add RBAC permission to log out in combat
bool canLogoutInCombat = GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING);
@@ -432,7 +438,7 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket & /*recv_data*/)
reason = 1;
else if (GetPlayer()->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_FALLING_FAR))
reason = 3; // is jumping or falling
else if (GetPlayer()->duel || GetPlayer()->HasAura(9454)) // is dueling or frozen by GM via freeze command
else if (preventAfkSanctuaryLogout || preventAfkLogout || GetPlayer()->duel || GetPlayer()->HasAura(9454)) // is dueling or frozen by GM via freeze command
reason = 2; // FIXME - Need the correct value
WorldPacket data(SMSG_LOGOUT_RESPONSE, 1+4);

View File

@@ -1323,6 +1323,9 @@ void World::LoadConfigSettings(bool reload)
// Player can join LFG anywhere
m_bool_configs[CONFIG_LFG_LOCATION_ALL] = sConfigMgr->GetBoolDefault("LFG.Location.All", false);
// Prevent players AFK from being logged out
m_int_configs[CONFIG_AFK_PREVENT_LOGOUT] = sConfigMgr->GetIntDefault("PreventAFKLogout", 0);
// call ScriptMgr if we're reloading the configuration
sScriptMgr->OnAfterConfigLoad(reload);
}

View File

@@ -339,6 +339,7 @@ enum WorldIntConfigs
CONFIG_BIRTHDAY_TIME,
CONFIG_SOCKET_TIMEOUTTIME_ACTIVE,
CONFIG_INSTANT_TAXI,
CONFIG_AFK_PREVENT_LOGOUT,
INT_CONFIG_VALUE_COUNT
};