From 81476df8260546e6f9603ba7a9aa7f89d6d4d1ea Mon Sep 17 00:00:00 2001 From: joep van der velden Date: Mon, 23 Dec 2019 17:38:18 +0100 Subject: [PATCH] Added more options --- SQL/paradise_schema.sql | 3 ++- SQL/paradise_schema_prefixed.sql | 3 ++- SQL/updates/9-10.sql | 6 ++++++ code/controllers/configuration.dm | 8 +------- code/controllers/subsystem/afk.dm | 19 +++++++++--------- code/modules/client/preference/preferences.dm | 20 ++++++++++++++++--- .../client/preference/preferences_mysql.dm | 14 ++++++++----- config/example/config.txt | 8 +------- config/example/dbconfig.txt | 2 +- 9 files changed, 49 insertions(+), 34 deletions(-) create mode 100644 SQL/updates/9-10.sql 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 += "

General Settings

" if(user.client.holder) dat += "Adminhelp sound: [(sound & SOUND_ADMINHELP)?"On":"Off"]
" - dat += "AFK Cryoing: [(afk_watch) ? "Yes" : "No"]
" + dat += "AFK Cryoing: [(AFK_WATCH_warn_minutes) ? "On ([AFK_WATCH_warn_minutes], [AFK_WATCH_cryo_minutes])" : "Off"]
" + dat += "Ambient Occlusion: [toggles & AMBIENT_OCCLUSION ? "Enabled" : "Disabled"]
" dat += "Attack Animations: [(show_ghostitem_attack) ? "Yes" : "No"]
" if(unlock_content) @@ -2000,7 +2002,19 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts windowflashing = !windowflashing if("afk_watch") - afk_watch = !afk_watch + var/afk_new = input(user, "Select a new amount of minutes after which you get warned for being AFK, between 0 and 10 (0 will deactivate)", UI_style_alpha) as num + if(afk_new == 0) + // deactivate the system + AFK_WATCH_warn_minutes = 0 + AFK_WATCH_cryo_minutes = 0 + else + if(!afk_new | !(afk_new <= 10 && afk_new >= 1)) return + AFK_WATCH_warn_minutes = afk_new + afk_new = input(user, "Select a new amount of minutes after which you get cryod for being AFK, between 1 and 5", UI_style_alpha) as num + if(!afk_new | !(afk_new <= 5 && afk_new >= 1)) + AFK_WATCH_cryo_minutes = AFK_WATCH_cryo_minutes ? AFK_WATCH_cryo_minutes : 2 // Return to prior value or default to 2 + else + AFK_WATCH_cryo_minutes = afk_new if("UIcolor") var/UI_style_color_new = input(user, "Choose your UI color, dark colors are not recommended!", UI_style_color) as color|null diff --git a/code/modules/client/preference/preferences_mysql.dm b/code/modules/client/preference/preferences_mysql.dm index 6090538f2b3..20fe3514c8d 100644 --- a/code/modules/client/preference/preferences_mysql.dm +++ b/code/modules/client/preference/preferences_mysql.dm @@ -20,7 +20,8 @@ clientfps, atklog, fuid, - afk_watch, + AFK_WATCH_warn_minutes, + AFK_WATCH_cryo_minutes, parallax FROM [format_table_name("player")] WHERE ckey='[C.ckey]'"} @@ -54,8 +55,9 @@ clientfps = text2num(query.item[17]) atklog = text2num(query.item[18]) fuid = text2num(query.item[19]) - afk_watch = text2num(query.item[20]) - parallax = text2num(query.item[21]) + AFK_WATCH_warn_minutes = text2num(query.item[20]) + AFK_WATCH_cryo_minutes = text2num(query.item[21]) + parallax = text2num(query.item[22]) //Sanitize ooccolor = sanitize_hexcolor(ooccolor, initial(ooccolor)) @@ -76,7 +78,8 @@ clientfps = sanitize_integer(clientfps, 0, 1000, initial(clientfps)) atklog = sanitize_integer(atklog, 0, 100, initial(atklog)) fuid = sanitize_integer(fuid, 0, 10000000, initial(fuid)) - afk_watch = sanitize_integer(afk_watch, 0, 1, initial(afk_watch)) + AFK_WATCH_warn_minutes = sanitize_integer(AFK_WATCH_warn_minutes, 0, 10, initial(AFK_WATCH_warn_minutes)) + AFK_WATCH_cryo_minutes = sanitize_integer(AFK_WATCH_cryo_minutes, 0, 5, initial(AFK_WATCH_cryo_minutes)) parallax = sanitize_integer(parallax, 0, 16, initial(parallax)) return 1 @@ -108,7 +111,8 @@ ghost_anonsay='[ghost_anonsay]', clientfps='[clientfps]', atklog='[atklog]', - afk_watch='[afk_watch]', + AFK_WATCH_warn_minutes='[AFK_WATCH_warn_minutes]', + AFK_WATCH_cryo_minutes='[AFK_WATCH_cryo_minutes]', parallax='[parallax]' WHERE ckey='[C.ckey]'"} ) diff --git a/config/example/config.txt b/config/example/config.txt index 7dfdc1e413a..dbf7b0be050 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -88,13 +88,7 @@ LOG_ADMINWARN ## Amount of minutes that a person has to be AFK before he'll be listed on the "List AFK players" verb #LIST_AFK_MINIMUM 5 -## Amount of minutes that a person has to be AFK before he will be warned by the AFK subsystem. Leave this 0 to prevent the subsystem from activating -WARN_AFK_MINIMUM 0 - -## Amount of minutes that a person has to be AFK before he will be cryod by the AFK subsystem. Leave this 0 to prevent the subsystem from activating -AUTO_CRYO_AFK 0 - -## Amount of minutes that a person has to be AFK before he will be despawned by the AFK subsystem. Leave this 0 to prevent the subsystem from activating +## Number of minutes that a person has to be AFK in the cryo tubes before he will be despawned by the AFK subsystem. Leave this 0 to prevent the subsystem from activating AUTO_DESPAWN_AFK 0 ## probablities for game modes chosen in "secret" and "random" modes diff --git a/config/example/dbconfig.txt b/config/example/dbconfig.txt index ad859d92543..654a7e348d5 100644 --- a/config/example/dbconfig.txt +++ b/config/example/dbconfig.txt @@ -9,7 +9,7 @@ ## This value must be set to the version of the paradise schema in use. ## If this value does not match, the SQL database will not be loaded and an error will be generated. ## Roundstart will be delayed. -DB_VERSION 9 +DB_VERSION 10 ## Server the MySQL database can be found at. # Examples: localhost, 200.135.5.43, www.mysqldb.com, etc.