diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql index 826e47878c6..34d3fef31be 100644 --- a/SQL/paradise_schema.sql +++ b/SQL/paradise_schema.sql @@ -359,12 +359,12 @@ DROP TABLE IF EXISTS `privacy`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `privacy` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `datetime` datetime NOT NULL, `ckey` varchar(32) NOT NULL, - `option` varchar(128) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=latin1; + `datetime` datetime NOT NULL, + `consent` bit(1) NOT NULL, + PRIMARY KEY (`ckey`), + UNIQUE KEY `ckey_UNIQUE` (`ckey`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- diff --git a/SQL/paradise_schema_prefixed.sql b/SQL/paradise_schema_prefixed.sql index e0056474db3..afc730af8c9 100644 --- a/SQL/paradise_schema_prefixed.sql +++ b/SQL/paradise_schema_prefixed.sql @@ -357,13 +357,13 @@ CREATE TABLE `SS13_poll_vote` ( DROP TABLE IF EXISTS `SS13_privacy`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `SS13_privacy` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `datetime` datetime NOT NULL, +CREATE TABLE `ss13_privacy` ( `ckey` varchar(32) NOT NULL, - `option` varchar(128) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=latin1; + `datetime` datetime NOT NULL, + `consent` bit(1) NOT NULL, + PRIMARY KEY (`ckey`), + UNIQUE KEY `ckey_UNIQUE` (`ckey`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- diff --git a/SQL/updates/2-3.sql b/SQL/updates/2-3.sql new file mode 100644 index 00000000000..d733759bc6e --- /dev/null +++ b/SQL/updates/2-3.sql @@ -0,0 +1,10 @@ +#Updating the SQL from version 2 to version 3. -alffd +#Droping privacy table and recreating for terms of service tracking +DROP TABLE `privacy`; +CREATE TABLE `privacy` ( + `ckey` varchar(32) NOT NULL, + `datetime` datetime NOT NULL, + `consent` bit(1) NOT NULL, + PRIMARY KEY (`ckey`), + UNIQUE KEY `ckey_UNIQUE` (`ckey`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index 66eedbe5b33..adc21f00452 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -347,4 +347,4 @@ #define INVESTIGATE_BOMB "bombs" // The SQL version required by this version of the code -#define SQL_VERSION 2 +#define SQL_VERSION 3 diff --git a/code/_globalvars/configuration.dm b/code/_globalvars/configuration.dm index d26dc711339..1e35e150a25 100644 --- a/code/_globalvars/configuration.dm +++ b/code/_globalvars/configuration.dm @@ -2,6 +2,7 @@ var/datum/configuration/config = null var/host = null var/join_motd = null +GLOBAL_VAR(join_tos) var/game_version = "Custom ParaCode" var/changelog_hash = md5('html/changelog.html') //used to check if the CL changed var/game_year = (text2num(time2text(world.realtime, "YYYY")) + 544) diff --git a/code/game/world.dm b/code/game/world.dm index 7d592864501..ffb9dfb1ecd 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -362,7 +362,7 @@ var/world_topic_spam_protect_time = world.timeofday /world/proc/load_motd() join_motd = file2text("config/motd.txt") - + GLOB.join_tos = file2text("config/tos.txt") /proc/load_configuration() config = new /datum/configuration() diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index fdd9266c128..6d1f856fbd3 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -4,6 +4,7 @@ var/spawning = 0 //Referenced when you want to delete the new_player later on in the code. var/totalPlayers = 0 //Player counts for the Lobby tab var/totalPlayersReady = 0 + var/tos_consent = FALSE universal_speak = 1 invisibility = 101 @@ -19,7 +20,39 @@ /mob/new_player/verb/new_player_panel() set src = usr - new_player_panel_proc() + + if(handle_tos_consent()) + new_player_panel_proc() + +/mob/new_player/proc/handle_tos_consent() + if(!GLOB.join_tos) + return TRUE + + establish_db_connection() + if(!dbcon.IsConnected()) + tos_consent = TRUE + return TRUE + + var/DBQuery/query = dbcon.NewQuery("SELECT * FROM [format_table_name("privacy")] WHERE ckey='[src.ckey]' AND consent=1") + query.Execute() + while(query.NextRow()) + tos_consent = TRUE + return TRUE + + privacy_consent() + return FALSE + +/mob/new_player/proc/privacy_consent() + src << browse(null, "window=playersetup") + var/output = GLOB.join_tos + output += "
I consent" + output += "
I DO NOT consent" + src << browse(output,"window=privacy_consent;size=500x300") + var/datum/browser/popup = new(src, "privacy_consent", "