Afk fixup (#412)

This commit is contained in:
CitadelStationBot
2017-04-15 14:45:29 -05:00
committed by TalkingCactus
parent f510bf2a03
commit 2373e2e485
6 changed files with 24 additions and 15 deletions

View File

@@ -313,10 +313,10 @@
// Will return a list of active candidates. It increases the buffer 5 times until it finds a candidate which is active within the buffer. // Will return a list of active candidates. It increases the buffer 5 times until it finds a candidate which is active within the buffer.
/proc/get_candidates(be_special_type, afk_bracket=3000, var/jobbanType) /proc/get_candidates(be_special_type, afk_bracket = config.inactivity_period, jobbanType)
var/list/candidates = list() var/list/candidates = list()
// Keep looping until we find a non-afk candidate within the time bracket (we limit the bracket to 10 minutes (6000)) // Keep looping until we find a non-afk candidate within the time bracket (we limit the bracket to 10 minutes (6000))
while(!candidates.len && afk_bracket < 6000) while(!candidates.len && afk_bracket < config.afk_period)
for(var/mob/dead/observer/G in GLOB.player_list) for(var/mob/dead/observer/G in GLOB.player_list)
if(G.client != null) if(G.client != null)
if(!(G.mind && G.mind.current && G.mind.current.stat != DEAD)) if(!(G.mind && G.mind.current && G.mind.current.stat != DEAD))

View File

@@ -20,8 +20,6 @@
#define BACKGROUND_ENABLED 0 // The default value for all uses of set background. Set background can cause gradual lag and is recommended you only turn this on if necessary. #define BACKGROUND_ENABLED 0 // The default value for all uses of set background. Set background can cause gradual lag and is recommended you only turn this on if necessary.
// 1 will enable set background. 0 will disable set background. // 1 will enable set background. 0 will disable set background.
#define INACTIVITY_KICK 6000 //10 minutes in ticks (approx.)
//ADMIN STUFF //ADMIN STUFF
#define ROUNDSTART_LOGOUT_REPORT_TIME 6000 //Amount of time (in deciseconds) after the rounds starts, that the player disconnect report is issued. #define ROUNDSTART_LOGOUT_REPORT_TIME 6000 //Amount of time (in deciseconds) after the rounds starts, that the player disconnect report is issued.

View File

@@ -66,7 +66,9 @@
var/respawn = 1 var/respawn = 1
var/guest_jobban = 1 var/guest_jobban = 1
var/usewhitelist = 0 var/usewhitelist = 0
var/kick_inactive = 0 //force disconnect for inactive players var/inactivity_period = 3000 //time in ds until a player is considered inactive
var/afk_period = 6000 //time in ds until a player is considered afk and kickable
var/kick_inactive = FALSE //force disconnect for inactive players
var/load_jobs_from_txt = 0 var/load_jobs_from_txt = 0
var/automute_on = 0 //enables automuting/spam prevention var/automute_on = 0 //enables automuting/spam prevention
var/minimal_access_threshold = 0 //If the number of players is larger than this threshold, minimal access will be turned on. var/minimal_access_threshold = 0 //If the number of players is larger than this threshold, minimal access will be turned on.
@@ -408,10 +410,12 @@
usewhitelist = TRUE usewhitelist = TRUE
if("allow_metadata") if("allow_metadata")
allow_Metadata = 1 allow_Metadata = 1
if("inactivity_period")
inactivity_period = text2num(value) * 10 //documented as seconds in config.txt
if("afk_period")
afk_period = text2num(value) * 10 // ^^^
if("kick_inactive") if("kick_inactive")
if(value < 1) kick_inactive = TRUE
value = INACTIVITY_KICK
kick_inactive = value
if("load_jobs_from_txt") if("load_jobs_from_txt")
load_jobs_from_txt = 1 load_jobs_from_txt = 1
if("forbid_singulo_possession") if("forbid_singulo_possession")

View File

@@ -10,12 +10,13 @@ SUBSYSTEM_DEF(server_maint)
/datum/controller/subsystem/server_maint/fire() /datum/controller/subsystem/server_maint/fire()
//handle kicking inactive players //handle kicking inactive players
if(config.kick_inactive > 0) if(config.kick_inactive)
for(var/client/C in GLOB.clients) for(var/client/C in GLOB.clients)
if(C.is_afk(INACTIVITY_KICK)) if(C.is_afk(config.afk_period))
if(!istype(C.mob, /mob/dead)) var/cmob = C.mob
if(!(istype(cmob, /mob/dead/observer) || (istype(cmob, /mob/dead) && C.holder)))
log_access("AFK: [key_name(C)]") log_access("AFK: [key_name(C)]")
to_chat(C, "<span class='danger'>You have been inactive for more than 10 minutes and have been disconnected.</span>") to_chat(C, "<span class='danger'>You have been inactive for more than [config.afk_period / 600] minutes and have been disconnected.</span>")
qdel(C) qdel(C)
if(config.sql_enabled) if(config.sql_enabled)

View File

@@ -549,10 +549,10 @@ GLOBAL_LIST(external_rsc_urls)
//checks if a client is afk //checks if a client is afk
//3000 frames = 5 minutes //3000 frames = 5 minutes
/client/proc/is_afk(duration=3000) /client/proc/is_afk(duration = config.inactivity_period)
if(inactivity > duration) if(inactivity > duration)
return inactivity return inactivity
return 0 return FALSE
// Byond seemingly calls stat, each tick. // Byond seemingly calls stat, each tick.
// Calling things each tick can get expensive real quick. // Calling things each tick can get expensive real quick.

View File

@@ -90,7 +90,13 @@ LOG_LAW
## As an example of how this could be """useful""" look towards Poly (https://twitter.com/Poly_the_Parrot) ## As an example of how this could be """useful""" look towards Poly (https://twitter.com/Poly_the_Parrot)
# LOG_TWITTER # LOG_TWITTER
## disconnect players who did nothing during 10 minutes ## period of time in seconds for players to be considered inactive
# INACTIVITY_PERIOD 300
## period of time in seconds for players to be considered afk and kickable
# AFK_PERIOD 600
## disconnect players who are considered afk
# KICK_INACTIVE # KICK_INACTIVE
## Comment this out to stop admins being able to choose their personal ooccolor ## Comment this out to stop admins being able to choose their personal ooccolor