From 6ea5b7c1a6b9108f8536446ce986faa38c7fa62f Mon Sep 17 00:00:00 2001 From: joep van der velden Date: Sun, 23 Jun 2019 19:46:01 +0200 Subject: [PATCH] SQL definitions added. Small fixes --- SQL/paradise_schema.sql | 1 + SQL/paradise_schema_prefixed.sql | 1 + SQL/updates/5-6.sql | 3 +++ code/controllers/subsystem/afk.dm | 31 +++++++++++++++++-------------- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql index e0f33226e8c..1ed8a81dcac 100644 --- a/SQL/paradise_schema.sql +++ b/SQL/paradise_schema.sql @@ -268,6 +268,7 @@ 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', PRIMARY KEY (`id`), UNIQUE KEY `ckey` (`ckey`) ) ENGINE=InnoDB AUTO_INCREMENT=32446 DEFAULT CHARSET=latin1; diff --git a/SQL/paradise_schema_prefixed.sql b/SQL/paradise_schema_prefixed.sql index ecb28a867e4..e43cdab78cc 100644 --- a/SQL/paradise_schema_prefixed.sql +++ b/SQL/paradise_schema_prefixed.sql @@ -267,6 +267,7 @@ 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', PRIMARY KEY (`id`), UNIQUE KEY `ckey` (`ckey`) ) ENGINE=InnoDB AUTO_INCREMENT=32446 DEFAULT CHARSET=latin1; diff --git a/SQL/updates/5-6.sql b/SQL/updates/5-6.sql index 91bf4328a2a..d5d17a51271 100644 --- a/SQL/updates/5-6.sql +++ b/SQL/updates/5-6.sql @@ -32,3 +32,6 @@ CREATE TABLE `oauth_tokens` ( #Drop the old 'discord' table that is not used anymore DROP TABLE `discord`; + +# Add afk_watch which gives users the option to make use of the AFK watcher subsystem +ALTER TABLE `player` ADD `afk_watch` tinyint(1) NOT NULL DEFAULT '0'; \ No newline at end of file diff --git a/code/controllers/subsystem/afk.dm b/code/controllers/subsystem/afk.dm index 9ebcd733600..6a02a9f037f 100644 --- a/code/controllers/subsystem/afk.dm +++ b/code/controllers/subsystem/afk.dm @@ -15,36 +15,39 @@ SUBSYSTEM_DEF(afk) /datum/controller/subsystem/afk/fire() var/list/toRemove = list() for(var/mob/living/carbon/human/H in GLOB.living_mob_list) - if(H.client == null || !H.client.prefs.afk_watch || !H.mind) // Only players and players with the AFK watch enabled + if(!H.ckey) // Useless non ckey creatures continue - var/turf/T = get_turf(H) - - if(H.stat || H.restrained() || !H.job || !is_station_level(T.z) || H.mind.special_role) // No dead, unconcious, restrained, people without jobs, people on other Z levels than the station or antags - if(afk_players[H.client]) - toRemove += H.client + var/turf/T + // 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 == null || !H.client.prefs.afk_watch || !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(afk_players[H.client]) - toRemove += H.client + if(afk_players[H.ckey]) + toRemove += H.ckey continue - if(!afk_players[H.client]) - afk_players[H.client] = AFK_WARNED + 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.") else var/area/A = T.loc // Turfs loc is the area - if(afk_players[H.client] == AFK_WARNED) + if(afk_players[H.ckey] == AFK_WARNED) if(mins_afk >= config.auto_cryo_afk && A.can_get_auto_cryod) if(A.fast_despawn) - toRemove += H.client + 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.") msg_admins(H, mins_afk, T, "forcefully despawned", "AFK in a fast despawn area") force_cryo_human(H) else if(cryo_ssd(H)) - afk_players[H.client] = AFK_CRYOD + 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.") @@ -52,7 +55,7 @@ SUBSYSTEM_DEF(afk) 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.") - toRemove += H.client + toRemove += H.ckey P.despawn_occupant() removeFromWatchList(toRemove)