From 98ca6824e7ccfe566d26dca4fc49084d1be4ed55 Mon Sep 17 00:00:00 2001 From: Furior <68264134+Furrior@users.noreply.github.com> Date: Tue, 26 Sep 2023 21:18:32 +0700 Subject: [PATCH] Feat: parashiz don (#175) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit :cl: add: Поддержка нашей системы донатов через бусти /:cl: --- SQL/updates220/51.220.4-51.220.5.sql | 12 ++++++++ code/__DEFINES/misc_defines.dm | 4 +-- config/example/config.toml | 2 +- modular_ss220/donor/_donor.dm | 4 +++ modular_ss220/donor/_donor.dme | 3 ++ modular_ss220/donor/code/client_procs.dm | 35 ++++++++++++++++++++++++ modular_ss220/modular_ss220.dme | 1 + 7 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 SQL/updates220/51.220.4-51.220.5.sql create mode 100644 modular_ss220/donor/_donor.dm create mode 100644 modular_ss220/donor/_donor.dme create mode 100644 modular_ss220/donor/code/client_procs.dm diff --git a/SQL/updates220/51.220.4-51.220.5.sql b/SQL/updates220/51.220.4-51.220.5.sql new file mode 100644 index 000000000000..4e974512f0e2 --- /dev/null +++ b/SQL/updates220/51.220.4-51.220.5.sql @@ -0,0 +1,12 @@ +CREATE TABLE `budget` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `date` DATETIME NOT NULL DEFAULT current_timestamp(), + `ckey` VARCHAR(32) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci', + `amount` INT(10) UNSIGNED NOT NULL, + `source` VARCHAR(32) NOT NULL COLLATE 'utf8mb4_general_ci', + `date_start` DATETIME NOT NULL DEFAULT current_timestamp(), + `date_end` DATETIME NULL DEFAULT (current_timestamp() + interval 1 month), + `is_valid` TINYINT(1) NOT NULL DEFAULT '1', + `discord_id` bigint(20) DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) COLLATE='utf8mb4_general_ci' ENGINE=InnoDB; diff --git a/code/__DEFINES/misc_defines.dm b/code/__DEFINES/misc_defines.dm index a0e896f47301..c991fa87d252 100644 --- a/code/__DEFINES/misc_defines.dm +++ b/code/__DEFINES/misc_defines.dm @@ -336,7 +336,7 @@ #define TRANSIT_TUBE_CLOSED 3 // Maximum donation level -#define DONATOR_LEVEL_MAX 4 +#define DONATOR_LEVEL_MAX 5 // SS220 EDIT // The cooldown on OOC messages such as OOC, LOOC, praying and adminhelps #define OOC_COOLDOWN 5 @@ -375,7 +375,7 @@ #define INVESTIGATE_BOMB "bombs" // The SQL version required by this version of the code -#define SQL_VERSION 522204 // SS220 EDIT +#define SQL_VERSION 522205 // SS220 EDIT // Vending machine stuff #define CAT_NORMAL 1 diff --git a/config/example/config.toml b/config/example/config.toml index bb7cb3c88a16..e4c49fdaf4e1 100644 --- a/config/example/config.toml +++ b/config/example/config.toml @@ -147,7 +147,7 @@ ipc_screens = [ # Enable/disable the database on a whole sql_enabled = false # SQL version. If this is a mismatch, round start will be delayed -sql_version = 522204 +sql_version = 522205 # SQL server address. Can be an IP or DNS name sql_address = "127.0.0.1" # SQL server port diff --git a/modular_ss220/donor/_donor.dm b/modular_ss220/donor/_donor.dm new file mode 100644 index 000000000000..23cc7f5304a5 --- /dev/null +++ b/modular_ss220/donor/_donor.dm @@ -0,0 +1,4 @@ +/datum/modpack/donor + name = "Донат" + desc = "Поддержка старой системы донатов" + author = "furior" diff --git a/modular_ss220/donor/_donor.dme b/modular_ss220/donor/_donor.dme new file mode 100644 index 000000000000..be8999452cd0 --- /dev/null +++ b/modular_ss220/donor/_donor.dme @@ -0,0 +1,3 @@ +#include "_donor.dm" + +#include "code/client_procs.dm" diff --git a/modular_ss220/donor/code/client_procs.dm b/modular_ss220/donor/code/client_procs.dm new file mode 100644 index 000000000000..152c34c916f7 --- /dev/null +++ b/modular_ss220/donor/code/client_procs.dm @@ -0,0 +1,35 @@ +/datum/client_login_processor/donator_check/process_result(datum/db_query/Q, client/C) + if(IsGuestKey(C.ckey)) + return + + if(check_rights_client(R_ADMIN, FALSE, C)) + C.donator_level = DONATOR_LEVEL_MAX + C.donor_loadout_points() + return + + while(Q.NextRow()) + var/total = Q.item[1] + switch(total) + if(220 to 439) + C.donator_level = 1 + if(440 to 999) + C.donator_level = 2 + if(1000 to 2219) + C.donator_level = 3 + if(2220 to 9999) + C.donator_level = 4 + if(1000 to INFINITY) + C.donator_level = DONATOR_LEVEL_MAX + C.donor_loadout_points() + +/datum/client_login_processor/donator_check/get_query(client/C) + var/datum/db_query/query = SSdbcore.NewQuery({" + SELECT CAST(SUM(amount) as UNSIGNED INTEGER) FROM budget + WHERE ckey=:ckey + AND is_valid=true + AND date_start <= NOW() + AND (NOW() < date_end OR date_end IS NULL) + GROUP BY ckey + "}, list("ckey" = C.ckey)) + + return query diff --git a/modular_ss220/modular_ss220.dme b/modular_ss220/modular_ss220.dme index c0e1b14a3209..ccc1c89effd6 100644 --- a/modular_ss220/modular_ss220.dme +++ b/modular_ss220/modular_ss220.dme @@ -38,6 +38,7 @@ #include "crawl_speed/_crawl_speed.dme" #include "debug/_debug.dme" #include "discord_link/_discord_link.dme" +#include "donor/_donor.dme" #include "emotes/_emotes.dme" #include "events/_events.dme" #include "fullscreen/_fullscreen.dme"