diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql index 1e4692b7e3b..4162607d7c4 100644 --- a/SQL/paradise_schema.sql +++ b/SQL/paradise_schema.sql @@ -268,7 +268,8 @@ CREATE TABLE `player` ( `atklog` smallint(4) DEFAULT '0', `fuid` bigint(20) NULL DEFAULT NULL, `fupdate` smallint(4) NULL DEFAULT '0', - `afk_watch` tinyint(1) NOT NULL DEFAULT '0', + `AFK_WATCH_warn_minutes` tinyint(2) NOT NULL DEFAULT '0', + `AFK_WATCH_cryo_minutes` tinyint(1) NOT NULL DEFAULT '0', `parallax` tinyint(1) DEFAULT '8', PRIMARY KEY (`id`), UNIQUE KEY `ckey` (`ckey`) diff --git a/SQL/paradise_schema_prefixed.sql b/SQL/paradise_schema_prefixed.sql index aa5d5895e56..af36f520cd9 100644 --- a/SQL/paradise_schema_prefixed.sql +++ b/SQL/paradise_schema_prefixed.sql @@ -267,7 +267,8 @@ CREATE TABLE `SS13_player` ( `atklog` smallint(4) DEFAULT '0', `fuid` bigint(20) NULL DEFAULT NULL, `fupdate` smallint(4) NULL DEFAULT '0', - `afk_watch` tinyint(1) NOT NULL DEFAULT '0', + `AFK_WATCH_warn_minutes` tinyint(2) NOT NULL DEFAULT '0', + `AFK_WATCH_cryo_minutes` tinyint(1) NOT NULL DEFAULT '0', `parallax` tinyint(1) DEFAULT '8', PRIMARY KEY (`id`), UNIQUE KEY `ckey` (`ckey`) diff --git a/SQL/updates/9-10.sql b/SQL/updates/9-10.sql new file mode 100644 index 00000000000..cb2c9c79279 --- /dev/null +++ b/SQL/updates/9-10.sql @@ -0,0 +1,6 @@ +# Change afk_watch to AFK_WATCH_warn_minutes and AFK_WATCH_cryo_minutes which gives users the option to make use of the AFK watcher subsystem +ALTER TABLE `player` ADD `AFK_WATCH_warn_minutes` tinyint(1) NOT NULL DEFAULT '0' AFTER `afk_watch`; +UPDATE `player` SET `AFK_WATCH_warn_minutes` = 5 WHERE `afk_watch` = 1; +ALTER TABLE `player` ADD `AFK_WATCH_cryo_minutes` tinyint(1) NOT NULL DEFAULT '0' AFTER `AFK_WATCH_warn_minutes`; +UPDATE `player` SET `AFK_WATCH_cryo_minutes` = 2 WHERE `afk_watch` = 1; +ALTER TABLE `player` DROP COLUMN `afk_watch`; \ No newline at end of file diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 8ae35d52179..497bcefd4f4 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -72,9 +72,7 @@ var/assistantlimit = 0 //enables assistant limiting var/assistantratio = 2 //how many assistants to security members - // The AFK subsystem will not be activated if any of the below config values are equal or less than 0 - var/warn_afk_minimum = 0 // How long till you get a warning while being AFK - var/auto_cryo_afk = 0 // How long till you get put into cryo when you're AFK + // The AFK subsystem will not be activated if the below config values are equal or less than 0 var/auto_despawn_afk = 0 // How long till you actually despawn in cryo when you're AFK (Not ssd so not automatic) var/auto_cryo_ssd_mins = 0 @@ -318,10 +316,6 @@ if("shadowling_max_age") config.shadowling_max_age = text2num(value) - if("warn_afk_minimum") - config.warn_afk_minimum = text2num(value) - if("auto_cryo_afk") - config.auto_cryo_afk = text2num(value) if("auto_despawn_afk") config.auto_despawn_afk = text2num(value) diff --git a/code/controllers/subsystem/afk.dm b/code/controllers/subsystem/afk.dm index 9f409fd35b4..4a092f3fed4 100644 --- a/code/controllers/subsystem/afk.dm +++ b/code/controllers/subsystem/afk.dm @@ -9,7 +9,7 @@ SUBSYSTEM_DEF(afk) /datum/controller/subsystem/afk/Initialize() - if(config.warn_afk_minimum <= 0 || config.auto_cryo_afk <= 0 || config.auto_despawn_afk <= 0) + if(config.auto_despawn_afk <= 0) flags |= SS_NO_FIRE /datum/controller/subsystem/afk/fire() @@ -19,28 +19,29 @@ SUBSYSTEM_DEF(afk) continue var/turf/T + var/afk_warn_min // Only players and players with the AFK watch enabled // No dead, unconcious, restrained, people without jobs, people on other Z levels than the station or antags - if(!H.client || !H.client.prefs.afk_watch || !H.mind || \ + if(!H.client || !(afk_warn_min = H.client.prefs.AFK_WATCH_warn_minutes) || !H.mind || \ H.stat || H.restrained() || !H.job || H.mind.special_role || \ !is_station_level((T = get_turf(H)).z)) // Assign the turf as last. Small optimization if(afk_players[H.ckey]) toRemove += H.ckey continue - + var/mins_afk = round(H.client.inactivity / 600) - if(mins_afk < config.warn_afk_minimum) + if(mins_afk < afk_warn_min) if(afk_players[H.ckey]) toRemove += H.ckey continue - + var/afk_cryo_min = H.client.prefs.AFK_WATCH_cryo_minutes + afk_warn_min if(!afk_players[H.ckey]) afk_players[H.ckey] = AFK_WARNED - warn(H, "You are AFK for [mins_afk] minutes. You will be cryod after [config.auto_cryo_afk] total minutes and fully despawned after [config.auto_despawn_afk] total minutes. Please move or click in game if you want to avoid being despawned.") + warn(H, "You are AFK for [mins_afk] minutes. You will be cryod after [afk_cryo_min] total minutes and fully despawned after another [config.auto_despawn_afk] minutes. Please move or click in game if you want to avoid being despawned.") else var/area/A = T.loc // Turfs loc is the area if(afk_players[H.ckey] == AFK_WARNED) - if(mins_afk >= config.auto_cryo_afk && A.can_get_auto_cryod) + if(mins_afk >= afk_cryo_min && A.can_get_auto_cryod) if(A.fast_despawn) toRemove += H.ckey warn(H, "You are have been despawned after being AFK for [mins_afk] minutes. You have been despawned instantly due to you being in a secure area.") @@ -49,9 +50,9 @@ SUBSYSTEM_DEF(afk) else if(cryo_ssd(H)) afk_players[H.ckey] = AFK_CRYOD msg_admins(H, mins_afk, T, "put into cryostorage") - warn(H, "You are AFK for [mins_afk] minutes and have been moved to cryostorage. After being AFK for [config.auto_despawn_afk] total minutes you will be fully despawned. Please eject yourself (right click, eject) out of the cryostorage if you want to avoid being despawned.") + warn(H, "You are AFK for [mins_afk] minutes and have been moved to cryostorage. After being AFK for another [config.auto_despawn_afk] minutes you will be fully despawned. Please eject yourself (right click, eject) out of the cryostorage if you want to avoid being despawned.") - else if(mins_afk >= config.auto_despawn_afk) + else if(mins_afk >= config.auto_despawn_afk + afk_cryo_min) var/obj/machinery/cryopod/P = H.loc msg_admins(H, mins_afk, T, "forcefully despawned") warn(H, "You are have been despawned after being AFK for [mins_afk] minutes.") diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm index 11eb454a241..0eb93a7404b 100644 --- a/code/modules/client/preference/preferences.dm +++ b/code/modules/client/preference/preferences.dm @@ -93,7 +93,8 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts var/clientfps = 0 var/atklog = ATKLOG_ALL var/fuid // forum userid - var/afk_watch = FALSE // If the player wants to be kept track of by the AFK system + var/AFK_WATCH_warn_minutes = 0 // Number of minutes after which the player gets warned + var/AFK_WATCH_cryo_minutes = 0 // Number of minutes after (after the warning) which the player gets cryod //ghostly preferences var/ghost_anonsay = 0 @@ -442,7 +443,8 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts dat += "