fix(Core/Worldsession): add option to prevent logout when AFK in a sanctuary zone (#2205)
This commit is contained in:
@@ -424,6 +424,12 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket & /*recv_data*/)
|
|||||||
bool instantLogout = ((GetSecurity() >= 0 && uint32(GetSecurity()) >= sWorld->getIntConfig(CONFIG_INSTANT_LOGOUT))
|
bool instantLogout = ((GetSecurity() >= 0 && uint32(GetSecurity()) >= sWorld->getIntConfig(CONFIG_INSTANT_LOGOUT))
|
||||||
|| (GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) && !GetPlayer()->IsInCombat())) || GetPlayer()->IsInFlight();
|
|| (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
|
/// TODO: Possibly add RBAC permission to log out in combat
|
||||||
bool canLogoutInCombat = GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING);
|
bool canLogoutInCombat = GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING);
|
||||||
|
|
||||||
@@ -432,7 +438,7 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket & /*recv_data*/)
|
|||||||
reason = 1;
|
reason = 1;
|
||||||
else if (GetPlayer()->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_FALLING_FAR))
|
else if (GetPlayer()->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_FALLING_FAR))
|
||||||
reason = 3; // is jumping or falling
|
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
|
reason = 2; // FIXME - Need the correct value
|
||||||
|
|
||||||
WorldPacket data(SMSG_LOGOUT_RESPONSE, 1+4);
|
WorldPacket data(SMSG_LOGOUT_RESPONSE, 1+4);
|
||||||
|
|||||||
@@ -1323,6 +1323,9 @@ void World::LoadConfigSettings(bool reload)
|
|||||||
// Player can join LFG anywhere
|
// Player can join LFG anywhere
|
||||||
m_bool_configs[CONFIG_LFG_LOCATION_ALL] = sConfigMgr->GetBoolDefault("LFG.Location.All", false);
|
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
|
// call ScriptMgr if we're reloading the configuration
|
||||||
sScriptMgr->OnAfterConfigLoad(reload);
|
sScriptMgr->OnAfterConfigLoad(reload);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -339,6 +339,7 @@ enum WorldIntConfigs
|
|||||||
CONFIG_BIRTHDAY_TIME,
|
CONFIG_BIRTHDAY_TIME,
|
||||||
CONFIG_SOCKET_TIMEOUTTIME_ACTIVE,
|
CONFIG_SOCKET_TIMEOUTTIME_ACTIVE,
|
||||||
CONFIG_INSTANT_TAXI,
|
CONFIG_INSTANT_TAXI,
|
||||||
|
CONFIG_AFK_PREVENT_LOGOUT,
|
||||||
INT_CONFIG_VALUE_COUNT
|
INT_CONFIG_VALUE_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1162,6 +1162,15 @@ RecruitAFriend.MaxDifference = 4
|
|||||||
|
|
||||||
InstantLogout = 1
|
InstantLogout = 1
|
||||||
|
|
||||||
|
#
|
||||||
|
# PreventAFKLogout
|
||||||
|
# Description: Prevent players AFK from being logged out
|
||||||
|
# Default: 0 - (Disabled)
|
||||||
|
# 1 - (Enabled, prevent players AFK from being logged out in Sanctuary zones)
|
||||||
|
# 2 - (Enabled, prevent players AFK from being logged out in all zones)
|
||||||
|
|
||||||
|
PreventAFKLogout = 0
|
||||||
|
|
||||||
#
|
#
|
||||||
# DisableWaterBreath
|
# DisableWaterBreath
|
||||||
# Description: Required security level for water breathing.
|
# Description: Required security level for water breathing.
|
||||||
|
|||||||
Reference in New Issue
Block a user