diff --git a/SQL/lc13_schema.sql b/SQL/lc13_schema.sql new file mode 100644 index 000000000000..3e65a204e7e9 --- /dev/null +++ b/SQL/lc13_schema.sql @@ -0,0 +1,716 @@ +-- MySQL dump 10.13 Distrib 8.0.19, for Win64 (x86_64) +-- +-- Host: localhost Database: lc13_dev +-- ------------------------------------------------------ +-- Server version 11.4.2-MariaDB-ubu2404 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!50503 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `achievement_metadata` +-- + +DROP TABLE IF EXISTS `achievement_metadata`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `achievement_metadata` ( + `achievement_key` varchar(32) NOT NULL, + `achievement_version` smallint(5) unsigned NOT NULL DEFAULT 0, + `achievement_type` enum('achievement','score','award') DEFAULT NULL, + `achievement_name` varchar(64) DEFAULT NULL, + `achievement_description` varchar(512) DEFAULT NULL, + PRIMARY KEY (`achievement_key`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `achievements` +-- + +DROP TABLE IF EXISTS `achievements`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `achievements` ( + `ckey` varchar(32) NOT NULL, + `achievement_key` varchar(32) NOT NULL, + `value` int(11) DEFAULT NULL, + `last_updated` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + PRIMARY KEY (`ckey`,`achievement_key`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `admin` +-- + +DROP TABLE IF EXISTS `admin`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `admin` ( + `ckey` varchar(32) NOT NULL, + `rank` varchar(32) NOT NULL, + `feedback` varchar(255) DEFAULT NULL, + PRIMARY KEY (`ckey`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `admin_log` +-- + +DROP TABLE IF EXISTS `admin_log`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `admin_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `datetime` datetime NOT NULL, + `round_id` int(11) unsigned NOT NULL, + `adminckey` varchar(32) NOT NULL, + `adminip` int(10) unsigned NOT NULL, + `operation` enum('add admin','remove admin','change admin rank','add rank','remove rank','change rank flags') NOT NULL, + `target` varchar(32) NOT NULL, + `log` varchar(1000) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `admin_ranks` +-- + +DROP TABLE IF EXISTS `admin_ranks`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `admin_ranks` ( + `rank` varchar(32) NOT NULL, + `flags` smallint(5) unsigned NOT NULL, + `exclude_flags` smallint(5) unsigned NOT NULL, + `can_edit_flags` smallint(5) unsigned NOT NULL, + PRIMARY KEY (`rank`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `ban` +-- + +DROP TABLE IF EXISTS `ban`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `ban` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `bantime` datetime NOT NULL, + `server_ip` int(10) unsigned NOT NULL, + `server_port` smallint(5) unsigned NOT NULL, + `round_id` int(11) unsigned NOT NULL, + `role` varchar(32) DEFAULT NULL, + `expiration_time` datetime DEFAULT NULL, + `applies_to_admins` tinyint(1) unsigned NOT NULL DEFAULT 0, + `reason` varchar(2048) NOT NULL, + `ckey` varchar(32) DEFAULT NULL, + `ip` int(10) unsigned DEFAULT NULL, + `computerid` varchar(32) DEFAULT NULL, + `a_ckey` varchar(32) NOT NULL, + `a_ip` int(10) unsigned NOT NULL, + `a_computerid` varchar(32) NOT NULL, + `who` varchar(2048) NOT NULL, + `adminwho` varchar(2048) NOT NULL, + `edits` text DEFAULT NULL, + `unbanned_datetime` datetime DEFAULT NULL, + `unbanned_ckey` varchar(32) DEFAULT NULL, + `unbanned_ip` int(10) unsigned DEFAULT NULL, + `unbanned_computerid` varchar(32) DEFAULT NULL, + `unbanned_round_id` int(11) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `idx_ban_isbanned` (`ckey`,`role`,`unbanned_datetime`,`expiration_time`), + KEY `idx_ban_isbanned_details` (`ckey`,`ip`,`computerid`,`role`,`unbanned_datetime`,`expiration_time`), + KEY `idx_ban_count` (`bantime`,`a_ckey`,`applies_to_admins`,`unbanned_datetime`,`expiration_time`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `connection_log` +-- + +DROP TABLE IF EXISTS `connection_log`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `connection_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `datetime` datetime DEFAULT NULL, + `server_ip` int(10) unsigned NOT NULL, + `server_port` smallint(5) unsigned NOT NULL, + `round_id` int(11) unsigned NOT NULL, + `ckey` varchar(45) DEFAULT NULL, + `ip` int(10) unsigned NOT NULL, + `computerid` varchar(45) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `death` +-- + +DROP TABLE IF EXISTS `death`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `death` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `pod` varchar(50) NOT NULL, + `x_coord` smallint(5) unsigned NOT NULL, + `y_coord` smallint(5) unsigned NOT NULL, + `z_coord` smallint(5) unsigned NOT NULL, + `mapname` varchar(32) NOT NULL, + `server_ip` int(10) unsigned NOT NULL, + `server_port` smallint(5) unsigned NOT NULL, + `round_id` int(11) NOT NULL, + `tod` datetime NOT NULL COMMENT 'Time of death', + `job` varchar(32) NOT NULL, + `special` varchar(32) DEFAULT NULL, + `name` varchar(96) NOT NULL, + `byondkey` varchar(32) NOT NULL, + `laname` varchar(96) DEFAULT NULL, + `lakey` varchar(32) DEFAULT NULL, + `bruteloss` smallint(5) unsigned NOT NULL, + `brainloss` smallint(5) unsigned NOT NULL, + `fireloss` smallint(5) unsigned NOT NULL, + `oxyloss` smallint(5) unsigned NOT NULL, + `toxloss` smallint(5) unsigned NOT NULL, + `cloneloss` smallint(5) unsigned NOT NULL, + `staminaloss` smallint(5) unsigned NOT NULL, + `last_words` varchar(255) DEFAULT NULL, + `suicide` tinyint(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `discord_links` +-- + +DROP TABLE IF EXISTS `discord_links`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `discord_links` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `ckey` varchar(32) NOT NULL, + `discord_id` bigint(20) DEFAULT NULL, + `timestamp` timestamp NOT NULL DEFAULT current_timestamp(), + `one_time_token` varchar(100) NOT NULL, + `valid` tinyint(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `feedback` +-- + +DROP TABLE IF EXISTS `feedback`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `feedback` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `datetime` datetime NOT NULL, + `round_id` int(11) unsigned NOT NULL, + `key_name` varchar(32) NOT NULL, + `key_type` enum('text','amount','tally','nested tally','associative') NOT NULL, + `version` tinyint(3) unsigned NOT NULL, + `json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`json`)), + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `ipintel` +-- + +DROP TABLE IF EXISTS `ipintel`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `ipintel` ( + `ip` int(10) unsigned NOT NULL, + `date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `intel` double NOT NULL DEFAULT 0, + PRIMARY KEY (`ip`), + KEY `idx_ipintel` (`ip`,`intel`,`date`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `legacy_population` +-- + +DROP TABLE IF EXISTS `legacy_population`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `legacy_population` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `playercount` int(11) DEFAULT NULL, + `admincount` int(11) DEFAULT NULL, + `time` datetime NOT NULL, + `server_ip` int(10) unsigned NOT NULL, + `server_port` smallint(5) unsigned NOT NULL, + `round_id` int(11) unsigned NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `library` +-- + +DROP TABLE IF EXISTS `library`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `library` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `author` varchar(45) NOT NULL, + `title` varchar(45) NOT NULL, + `content` text NOT NULL, + `category` enum('Any','Fiction','Non-Fiction','Adult','Reference','Religion') NOT NULL, + `ckey` varchar(32) NOT NULL DEFAULT 'LEGACY', + `datetime` datetime NOT NULL, + `deleted` tinyint(1) unsigned DEFAULT NULL, + `round_id_created` int(11) unsigned NOT NULL, + PRIMARY KEY (`id`), + KEY `deleted_idx` (`deleted`), + KEY `idx_lib_id_del` (`id`,`deleted`), + KEY `idx_lib_del_title` (`deleted`,`title`), + KEY `idx_lib_search` (`deleted`,`author`,`title`,`category`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `messages` +-- + +DROP TABLE IF EXISTS `messages`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `messages` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `type` enum('memo','message','message sent','note','watchlist entry') NOT NULL, + `targetckey` varchar(32) NOT NULL, + `adminckey` varchar(32) NOT NULL, + `text` varchar(2048) NOT NULL, + `timestamp` datetime NOT NULL, + `server` varchar(32) DEFAULT NULL, + `server_ip` int(10) unsigned NOT NULL, + `server_port` smallint(5) unsigned NOT NULL, + `round_id` int(11) unsigned NOT NULL, + `secret` tinyint(1) unsigned NOT NULL, + `expire_timestamp` datetime DEFAULT NULL, + `severity` enum('high','medium','minor','none') DEFAULT NULL, + `playtime` int(11) unsigned DEFAULT NULL, + `lasteditor` varchar(32) DEFAULT NULL, + `edits` text DEFAULT NULL, + `deleted` tinyint(1) unsigned NOT NULL DEFAULT 0, + `deleted_ckey` varchar(32) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `idx_msg_ckey_time` (`targetckey`,`timestamp`,`deleted`), + KEY `idx_msg_type_ckeys_time` (`type`,`targetckey`,`adminckey`,`timestamp`,`deleted`), + KEY `idx_msg_type_ckey_time_odr` (`type`,`targetckey`,`timestamp`,`deleted`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `patreon_ranks` +-- + +DROP TABLE IF EXISTS `patreon_ranks`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `patreon_ranks` ( + `ckey` varchar(100) NOT NULL, + `patreon_key` varchar(100) DEFAULT NULL, + `patreon_rank` varchar(100) DEFAULT NULL, + PRIMARY KEY (`ckey`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `player` +-- + +DROP TABLE IF EXISTS `player`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `player` ( + `ckey` varchar(32) NOT NULL, + `byond_key` varchar(32) DEFAULT NULL, + `firstseen` datetime NOT NULL, + `firstseen_round_id` int(11) unsigned NOT NULL, + `lastseen` datetime NOT NULL, + `lastseen_round_id` int(11) unsigned NOT NULL, + `ip` int(10) unsigned NOT NULL, + `computerid` varchar(32) NOT NULL, + `lastadminrank` varchar(32) NOT NULL DEFAULT 'Player', + `accountjoindate` date DEFAULT NULL, + `flags` smallint(5) unsigned NOT NULL DEFAULT 0, + PRIMARY KEY (`ckey`), + KEY `idx_player_cid_ckey` (`computerid`,`ckey`), + KEY `idx_player_ip_ckey` (`ip`,`ckey`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `poll_option` +-- + +DROP TABLE IF EXISTS `poll_option`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `poll_option` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `pollid` int(11) NOT NULL, + `text` varchar(255) NOT NULL, + `minval` int(3) DEFAULT NULL, + `maxval` int(3) DEFAULT NULL, + `descmin` varchar(32) DEFAULT NULL, + `descmid` varchar(32) DEFAULT NULL, + `descmax` varchar(32) DEFAULT NULL, + `default_percentage_calc` tinyint(1) unsigned NOT NULL DEFAULT 1, + `deleted` tinyint(1) unsigned NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_pop_pollid` (`pollid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `poll_question` +-- + +DROP TABLE IF EXISTS `poll_question`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `poll_question` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `polltype` enum('OPTION','TEXT','NUMVAL','MULTICHOICE','IRV') NOT NULL, + `created_datetime` datetime NOT NULL, + `starttime` datetime NOT NULL, + `endtime` datetime NOT NULL, + `question` varchar(255) NOT NULL, + `subtitle` varchar(255) DEFAULT NULL, + `adminonly` tinyint(1) unsigned NOT NULL, + `multiplechoiceoptions` int(2) DEFAULT NULL, + `createdby_ckey` varchar(32) NOT NULL, + `createdby_ip` int(10) unsigned NOT NULL, + `dontshow` tinyint(1) unsigned NOT NULL, + `allow_revoting` tinyint(1) unsigned NOT NULL, + `deleted` tinyint(1) unsigned NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_pquest_question_time_ckey` (`question`,`starttime`,`endtime`,`createdby_ckey`,`createdby_ip`), + KEY `idx_pquest_time_deleted_id` (`starttime`,`endtime`,`deleted`,`id`), + KEY `idx_pquest_id_time_type_admin` (`id`,`starttime`,`endtime`,`polltype`,`adminonly`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `poll_textreply` +-- + +DROP TABLE IF EXISTS `poll_textreply`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `poll_textreply` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `datetime` datetime NOT NULL, + `pollid` int(11) NOT NULL, + `ckey` varchar(32) NOT NULL, + `ip` int(10) unsigned NOT NULL, + `replytext` varchar(2048) NOT NULL, + `adminrank` varchar(32) NOT NULL, + `deleted` tinyint(1) unsigned NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_ptext_pollid_ckey` (`pollid`,`ckey`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `poll_vote` +-- + +DROP TABLE IF EXISTS `poll_vote`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `poll_vote` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `datetime` datetime NOT NULL, + `pollid` int(11) NOT NULL, + `optionid` int(11) NOT NULL, + `ckey` varchar(32) NOT NULL, + `ip` int(10) unsigned NOT NULL, + `adminrank` varchar(32) NOT NULL, + `rating` int(2) DEFAULT NULL, + `deleted` tinyint(1) unsigned NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_pvote_pollid_ckey` (`pollid`,`ckey`), + KEY `idx_pvote_optionid_ckey` (`optionid`,`ckey`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `role_time` +-- + +DROP TABLE IF EXISTS `role_time`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `role_time` ( + `ckey` varchar(32) NOT NULL, + `job` varchar(32) NOT NULL, + `minutes` int(10) unsigned NOT NULL, + PRIMARY KEY (`ckey`,`job`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `role_timeTloginsert` AFTER INSERT ON `role_time` FOR EACH ROW BEGIN INSERT into role_time_log (ckey, job, delta) VALUES (NEW.ckey, NEW.job, NEW.minutes); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `role_timeTlogupdate` AFTER UPDATE ON `role_time` FOR EACH ROW BEGIN INSERT into role_time_log (ckey, job, delta) VALUES (NEW.CKEY, NEW.job, NEW.minutes-OLD.minutes); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `role_timeTlogdelete` AFTER DELETE ON `role_time` FOR EACH ROW BEGIN INSERT into role_time_log (ckey, job, delta) VALUES (OLD.ckey, OLD.job, 0-OLD.minutes); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; + +-- +-- Table structure for table `role_time_log` +-- + +DROP TABLE IF EXISTS `role_time_log`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `role_time_log` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `ckey` varchar(32) NOT NULL, + `job` varchar(128) NOT NULL, + `delta` int(11) NOT NULL, + `datetime` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + PRIMARY KEY (`id`), + KEY `ckey` (`ckey`), + KEY `job` (`job`), + KEY `datetime` (`datetime`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `round` +-- + +DROP TABLE IF EXISTS `round`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `round` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `initialize_datetime` datetime NOT NULL, + `start_datetime` datetime DEFAULT NULL, + `shutdown_datetime` datetime DEFAULT NULL, + `end_datetime` datetime DEFAULT NULL, + `server_ip` int(10) unsigned NOT NULL, + `server_port` smallint(5) unsigned NOT NULL, + `commit_hash` char(40) DEFAULT NULL, + `game_mode` varchar(32) DEFAULT NULL, + `game_mode_result` varchar(64) DEFAULT NULL, + `end_state` varchar(64) DEFAULT NULL, + `shuttle_name` varchar(64) DEFAULT NULL, + `map_name` varchar(32) DEFAULT NULL, + `station_name` varchar(80) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `schema_revision` +-- + +DROP TABLE IF EXISTS `schema_revision`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `schema_revision` ( + `major` tinyint(3) unsigned NOT NULL, + `minor` tinyint(3) unsigned NOT NULL, + `date` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + PRIMARY KEY (`major`,`minor`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `stickyban` +-- + +DROP TABLE IF EXISTS `stickyban`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `stickyban` ( + `ckey` varchar(32) NOT NULL, + `reason` varchar(2048) NOT NULL, + `banning_admin` varchar(32) NOT NULL, + `datetime` datetime NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`ckey`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `stickyban_matched_cid` +-- + +DROP TABLE IF EXISTS `stickyban_matched_cid`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `stickyban_matched_cid` ( + `stickyban` varchar(32) NOT NULL, + `matched_cid` varchar(32) NOT NULL, + `first_matched` datetime NOT NULL DEFAULT current_timestamp(), + `last_matched` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + PRIMARY KEY (`stickyban`,`matched_cid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `stickyban_matched_ckey` +-- + +DROP TABLE IF EXISTS `stickyban_matched_ckey`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `stickyban_matched_ckey` ( + `stickyban` varchar(32) NOT NULL, + `matched_ckey` varchar(32) NOT NULL, + `first_matched` datetime NOT NULL DEFAULT current_timestamp(), + `last_matched` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `exempt` tinyint(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`stickyban`,`matched_ckey`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `stickyban_matched_ip` +-- + +DROP TABLE IF EXISTS `stickyban_matched_ip`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `stickyban_matched_ip` ( + `stickyban` varchar(32) NOT NULL, + `matched_ip` int(10) unsigned NOT NULL, + `first_matched` datetime NOT NULL DEFAULT current_timestamp(), + `last_matched` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + PRIMARY KEY (`stickyban`,`matched_ip`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `ticket` +-- + +DROP TABLE IF EXISTS `ticket`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `ticket` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `server_ip` int(10) unsigned NOT NULL, + `server_port` smallint(5) unsigned NOT NULL, + `round_id` int(11) unsigned NOT NULL, + `ticket` smallint(11) unsigned NOT NULL, + `action` varchar(20) NOT NULL DEFAULT 'Message', + `message` text NOT NULL, + `timestamp` datetime NOT NULL, + `recipient` varchar(32) DEFAULT NULL, + `sender` varchar(32) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `idx_ticket_act_recip` (`action`,`recipient`), + KEY `idx_ticket_act_send` (`action`,`sender`), + KEY `idx_ticket_tic_rid` (`ticket`,`round_id`), + KEY `idx_ticket_act_time_rid` (`action`,`timestamp`,`round_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping routines for database 'lc13_dev' +-- +/*!50003 DROP PROCEDURE IF EXISTS `set_poll_deleted` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `set_poll_deleted`( + IN `poll_id` INT +) + SQL SECURITY INVOKER +BEGIN +UPDATE `poll_question` SET deleted = 1 WHERE id = poll_id; +UPDATE `poll_option` SET deleted = 1 WHERE pollid = poll_id; +UPDATE `poll_vote` SET deleted = 1 WHERE pollid = poll_id; +UPDATE `poll_textreply` SET deleted = 1 WHERE pollid = poll_id; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2024-12-05 6:42:50 diff --git a/code/__DEFINES/subsystems.dm b/code/__DEFINES/subsystems.dm index 6ab7326a629e..44ab88f71ee2 100644 --- a/code/__DEFINES/subsystems.dm +++ b/code/__DEFINES/subsystems.dm @@ -11,7 +11,7 @@ * * make sure you add an update to the schema_version stable in the db changelog */ -#define DB_MAJOR_VERSION 5 +#define DB_MAJOR_VERSION 6 /** * DB minor schema version @@ -20,7 +20,7 @@ * * make sure you add an update to the schema_version stable in the db changelog */ -#define DB_MINOR_VERSION 12 +#define DB_MINOR_VERSION 1 //! ## Timing subsystem diff --git a/code/__DEFINES/~lobotomy_defines/_patreon.dm b/code/__DEFINES/~lobotomy_defines/_patreon.dm new file mode 100644 index 000000000000..965d07b7d155 --- /dev/null +++ b/code/__DEFINES/~lobotomy_defines/_patreon.dm @@ -0,0 +1,17 @@ +#define NO_RANK "None" +#define UNSUBBED "UNSUBBED" +#define AGENT_RANK "AGENT" +#define SENIOR_AGENT_RANK "SENIORAGENT" +#define CAPTAIN_RANK "CAPTAIN" + +// im lazy -Cupa +GLOBAL_LIST_INIT(patreon_ranks, list( + "None", + "UNSUBBED", + "AGENT", + "SENIORAGENT", + "CAPTAIN")) + +#define ACCESS_AGENT_RANK 1 +#define ACCESS_SENIOR_AGENT_RANK 2 +#define ACCESS_CAPTAIN_RANK 3 diff --git a/code/datums/patreon_data.dm b/code/datums/patreon_data.dm new file mode 100644 index 000000000000..5155fef5d507 --- /dev/null +++ b/code/datums/patreon_data.dm @@ -0,0 +1,72 @@ +/client + var/datum/patreon_data/patreon + +/datum/patreon_data + ///the client that owns this data + var/client/owner + ///the stored patreon client key for the information + var/client_key + ///the stored patreon rank collected from the server + var/owned_rank = NO_RANK + ///access rank in numbers + var/access_rank = 0 + +/datum/patreon_data/New(client/created_client) + . = ..() + if(!created_client) + return + + if(!SSdbcore.IsConnected()) + owned_rank = NO_RANK ///this is a testing variable + return + + owner = created_client + + fetch_key(owner.ckey) + fetch_rank(owner.ckey) + + assign_access_rank() + + +/datum/patreon_data/proc/fetch_key(ckey) + var/datum/db_query/query_get_key = SSdbcore.NewQuery("SELECT patreon_key FROM [format_table_name("patreon_ranks")] WHERE ckey = :ckey", + list("ckey" = ckey)) + if(query_get_key.warn_execute()) + if(query_get_key.NextRow()) + client_key = query_get_key.item[1] + qdel(query_get_key) + +/datum/patreon_data/proc/fetch_rank(ckey) + var/datum/db_query/query_get_rank = SSdbcore.NewQuery("SELECT patreon_rank FROM [format_table_name("patreon_ranks")] WHERE ckey = :ckey", + list("ckey" = ckey)) + if(query_get_rank.warn_execute()) + if(query_get_rank.NextRow()) + if(query_get_rank.item[1]) + owned_rank = query_get_rank.item[1] + if(owned_rank == "UNSUBBED2") + owned_rank = NO_RANK + else + owned_rank = NO_RANK + qdel(query_get_rank) + + +/datum/patreon_data/proc/assign_access_rank() + switch(owned_rank) + if(AGENT_RANK) + access_rank = ACCESS_AGENT_RANK + if(SENIOR_AGENT_RANK) + access_rank = ACCESS_SENIOR_AGENT_RANK + if(CAPTAIN_RANK) + access_rank = ACCESS_CAPTAIN_RANK + +/datum/patreon_data/proc/has_access(rank) + if(!access_rank) + assign_access_rank() + if(rank <= access_rank) + return TRUE + return FALSE + +/datum/patreon_data/proc/is_donator() + if((owned_rank == NO_RANK) || !owned_rank || (owned_rank == UNSUBBED)) + return FALSE + return TRUE diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 93c2e4d1eb11..32f90a7961d6 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -79,6 +79,7 @@ GLOBAL_PROTECT(admin_verbs_admin) /client/proc/toggleadminhelpsound, /client/proc/respawn_character, /datum/admins/proc/open_borgopanel, + /client/proc/change_patreon_rank, //LC13 Testing /client/proc/SpawnAbno, /client/proc/ClearAbno, diff --git a/code/modules/admin/verbs/patreon_ranks.dm b/code/modules/admin/verbs/patreon_ranks.dm new file mode 100644 index 000000000000..772390c072bc --- /dev/null +++ b/code/modules/admin/verbs/patreon_ranks.dm @@ -0,0 +1,55 @@ +/client/proc/change_patreon_rank() + set category = "Admin" + set name = "Change Patreon Rank" + set desc = "Change the Patreon Rank of a ckey" + + if(!check_rights(R_ADMIN)) + return + + if(!SSdbcore.IsConnected()) + return + + var/change_ckey = input(usr, "Which CKEY to change", "CKEY?", null) as null|text + + if(isnull(change_ckey) || length(change_ckey) <= 0) + return + + var/change_rank = input(usr, "Please select the rank to change to", "Rank?", null) as null|anything in GLOB.patreon_ranks + + if(isnull(change_rank)) + return + + var/datum/db_query/query_has_patreon_rank = SSdbcore.NewQuery( + "SELECT 1 FROM [format_table_name("patreon_ranks")] WHERE ckey = :change_ckey", + list("change_ckey" = change_ckey) + ) + + if(!query_has_patreon_rank.warn_execute()) + qdel(query_has_patreon_rank) + return + if(!query_has_patreon_rank.NextRow()) + // No entry found, inserting + QDEL_NULL(query_has_patreon_rank) + var/datum/db_query/query_add_rank = SSdbcore.NewQuery({" + INSERT INTO [format_table_name("patreon_ranks")] (ckey, patreon_key, patreon_rank) + VALUES (:change_ckey, 'DUMMYKEY', :change_rank) + "}, list("change_ckey" = change_ckey, "change_rank" = change_rank)) + + if(!query_add_rank.warn_execute()) + qdel(query_add_rank) + return + qdel(query_add_rank) + else + qdel(query_has_patreon_rank) + // Entry found, updating + var/datum/db_query/query_change_rank = SSdbcore.NewQuery( + "UPDATE [format_table_name("patreon_ranks")] SET patreon_rank = :change_rank WHERE ckey = :change_ckey", + list("change_rank" = change_rank, "change_ckey" = change_ckey) + ) + + if(!query_change_rank.warn_execute()) + qdel(query_change_rank) + return + qdel(query_change_rank) + + message_admins("Patreon rank of ckey [change_ckey] changed to [change_rank]") diff --git a/code/modules/mob/login.dm b/code/modules/mob/login.dm index 3bb706730f8c..d34519e17b52 100644 --- a/code/modules/mob/login.dm +++ b/code/modules/mob/login.dm @@ -93,6 +93,8 @@ SEND_SIGNAL(src, COMSIG_MOB_CLIENT_LOGIN, client) client.init_verbs() + client.patreon = new(client) + return TRUE diff --git a/lobotomy-corp13.dme b/lobotomy-corp13.dme index 1119929c9877..e7a3212597d8 100644 --- a/lobotomy-corp13.dme +++ b/lobotomy-corp13.dme @@ -157,6 +157,7 @@ #include "code\__DEFINES\dcs\signals.dm" #include "code\__DEFINES\dcs\signals_fish.dm" #include "code\__DEFINES\research\anomalies.dm" +#include "code\__DEFINES\~lobotomy_defines\_patreon.dm" #include "code\__DEFINES\~lobotomy_defines\adventure.dm" #include "code\__DEFINES\~lobotomy_defines\is_helpers.dm" #include "code\__DEFINES\~lobotomy_defines\weapon.dm" @@ -416,6 +417,7 @@ #include "code\datums\mutable_appearance.dm" #include "code\datums\numbered_display.dm" #include "code\datums\outfit.dm" +#include "code\datums\patreon_data.dm" #include "code\datums\position_point_vector.dm" #include "code\datums\profiling.dm" #include "code\datums\progressbar.dm" @@ -1626,6 +1628,7 @@ #include "code\modules\admin\verbs\one_click_antag.dm" #include "code\modules\admin\verbs\onlyone.dm" #include "code\modules\admin\verbs\panicbunker.dm" +#include "code\modules\admin\verbs\patreon_ranks.dm" #include "code\modules\admin\verbs\playsound.dm" #include "code\modules\admin\verbs\possess.dm" #include "code\modules\admin\verbs\pray.dm"