From d697a1958d294a7ef7a6cb071ff7af84a22b61bd Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:37:33 +0300 Subject: [PATCH 01/24] initial commit --- modular_bandastation/loadout/_loadout.dm | 4 ++++ modular_bandastation/loadout/_loadout.dme | 5 +++++ modular_bandastation/loadout/code/categories/accessories.dm | 2 ++ modular_bandastation/loadout/code/loadout_categories.dm | 5 +++++ modular_bandastation/loadout/code/loadout_items.dm | 2 ++ modular_bandastation/modular_bandastation.dme | 1 + 6 files changed, 19 insertions(+) create mode 100644 modular_bandastation/loadout/_loadout.dm create mode 100644 modular_bandastation/loadout/_loadout.dme create mode 100644 modular_bandastation/loadout/code/categories/accessories.dm create mode 100644 modular_bandastation/loadout/code/loadout_categories.dm create mode 100644 modular_bandastation/loadout/code/loadout_items.dm diff --git a/modular_bandastation/loadout/_loadout.dm b/modular_bandastation/loadout/_loadout.dm new file mode 100644 index 0000000000000..505d15063cd70 --- /dev/null +++ b/modular_bandastation/loadout/_loadout.dm @@ -0,0 +1,4 @@ +/datum/modpack/loadout + name = "Loadout" + desc = "Изменения в loadout." + author = "larentoun" diff --git a/modular_bandastation/loadout/_loadout.dme b/modular_bandastation/loadout/_loadout.dme new file mode 100644 index 0000000000000..065cd69d7ee47 --- /dev/null +++ b/modular_bandastation/loadout/_loadout.dme @@ -0,0 +1,5 @@ +#include "_loadout.dm" + +#include "code/loadout_categories.dm" +#include "code/loadout_items.dm" +#include "code/categories/accessories.dm" diff --git a/modular_bandastation/loadout/code/categories/accessories.dm b/modular_bandastation/loadout/code/categories/accessories.dm new file mode 100644 index 0000000000000..3f395f6e7e6b9 --- /dev/null +++ b/modular_bandastation/loadout/code/categories/accessories.dm @@ -0,0 +1,2 @@ +/datum/loadout_item/accessory/pride/is_available() + return FALSE diff --git a/modular_bandastation/loadout/code/loadout_categories.dm b/modular_bandastation/loadout/code/loadout_categories.dm new file mode 100644 index 0000000000000..a3a172d8a5754 --- /dev/null +++ b/modular_bandastation/loadout/code/loadout_categories.dm @@ -0,0 +1,5 @@ +/datum/loadout_category/get_items() + . = ..() + for(var/datum/loadout_item/item as anything in .) + if(!item.is_available()) + . -= item diff --git a/modular_bandastation/loadout/code/loadout_items.dm b/modular_bandastation/loadout/code/loadout_items.dm new file mode 100644 index 0000000000000..a7b4b78b86a8b --- /dev/null +++ b/modular_bandastation/loadout/code/loadout_items.dm @@ -0,0 +1,2 @@ +/datum/loadout_item/proc/is_available() + return TRUE diff --git a/modular_bandastation/modular_bandastation.dme b/modular_bandastation/modular_bandastation.dme index f805bb52659d5..b3bf225735f62 100644 --- a/modular_bandastation/modular_bandastation.dme +++ b/modular_bandastation/modular_bandastation.dme @@ -20,6 +20,7 @@ #include "examine_panel/_examine_panel.dme" #include "gunhud/_gunhud.dme" #include "keybinding/_keybinding.dme" +#include "loadout/_loadout.dme" #include "pixel_shift/_pixel_shift.dme" #include "ru_jobs/_ru_jobs.dme" #include "translations/_translations.dme" From 9a95c72c35968eeb85fc820e01fdbf26370e5e64 Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:59:33 +0300 Subject: [PATCH 02/24] donation tiers --- .../loadout/code/categories/accessories.dm | 3 +++ .../loadout/code/loadout_items.dm | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/modular_bandastation/loadout/code/categories/accessories.dm b/modular_bandastation/loadout/code/categories/accessories.dm index 3f395f6e7e6b9..a0678194dd698 100644 --- a/modular_bandastation/loadout/code/categories/accessories.dm +++ b/modular_bandastation/loadout/code/categories/accessories.dm @@ -1,2 +1,5 @@ /datum/loadout_item/accessory/pride/is_available() return FALSE + +/datum/loadout_item/accessory/maid_apron + donator_level = 1 diff --git a/modular_bandastation/loadout/code/loadout_items.dm b/modular_bandastation/loadout/code/loadout_items.dm index a7b4b78b86a8b..e3a6e61ec8da4 100644 --- a/modular_bandastation/loadout/code/loadout_items.dm +++ b/modular_bandastation/loadout/code/loadout_items.dm @@ -1,2 +1,28 @@ +/client + var/donator_level = 0 + +/datum/loadout_item + var/donator_level = 0 + +/datum/loadout_item/get_item_information() + . = ..() + if(donator_level) + . += "Tier [donator_level]" + +// Handles giving an item to the mob +/datum/loadout_item/insert_path_into_outfit(datum/outfit/outfit, mob/living/carbon/human/equipper, visuals_only) + if(!is_available() || (donator_level && (equipper.client.donator_level < donator_level))) + to_chat(equipper, span_warning("У вас недостаточный уровень доната, чтобы взять [name]!")) + return + . = ..() + +// Removes item from the preferences menu, period. Use it only to remove stuff for ALL players. /datum/loadout_item/proc/is_available() return TRUE + +// Handles selecting from the preferences UI +/datum/preference_middleware/loadout/select_item(datum/loadout_item/selected_item) + if(selected_item.donator_level && (preferences.parent.donator_level < selected_item.donator_level)) + to_chat(preferences.parent.mob, span_warning("У вас недостаточный уровень доната, чтобы взять этот предмет!")) + return + . = ..() From 3ee28567cb4004395d07d4a76e193c5d00b9ac6e Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:15:34 +0300 Subject: [PATCH 03/24] fix giving donator items without donator --- modular_bandastation/loadout/code/loadout_items.dm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modular_bandastation/loadout/code/loadout_items.dm b/modular_bandastation/loadout/code/loadout_items.dm index e3a6e61ec8da4..2028b0f592272 100644 --- a/modular_bandastation/loadout/code/loadout_items.dm +++ b/modular_bandastation/loadout/code/loadout_items.dm @@ -9,12 +9,14 @@ if(donator_level) . += "Tier [donator_level]" -// Handles giving an item to the mob -/datum/loadout_item/insert_path_into_outfit(datum/outfit/outfit, mob/living/carbon/human/equipper, visuals_only) - if(!is_available() || (donator_level && (equipper.client.donator_level < donator_level))) - to_chat(equipper, span_warning("У вас недостаточный уровень доната, чтобы взять [name]!")) - return +// Removes donator_level items from the user if their donator_level is insufficient +/datum/preference/loadout/sanitize_loadout_list(list/passed_list, mob/optional_loadout_owner) . = ..() + for(var/path in .) + var/datum/loadout_item/item = GLOB.all_loadout_datums[path] + if(optional_loadout_owner?.client.donator_level < item.donator_level) + to_chat(optional_loadout_owner, span_warning("У вас недостаточный уровень доната, чтобы взять [item.name]!")) + . -= path // Removes item from the preferences menu, period. Use it only to remove stuff for ALL players. /datum/loadout_item/proc/is_available() @@ -22,7 +24,7 @@ // Handles selecting from the preferences UI /datum/preference_middleware/loadout/select_item(datum/loadout_item/selected_item) - if(selected_item.donator_level && (preferences.parent.donator_level < selected_item.donator_level)) + if(preferences.parent.donator_level < selected_item.donator_level) to_chat(preferences.parent.mob, span_warning("У вас недостаточный уровень доната, чтобы взять этот предмет!")) return . = ..() From 1e8d9a2e2f179dc3d036533fe7308c03b96f48b7 Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Wed, 17 Jul 2024 14:43:03 +0300 Subject: [PATCH 04/24] categorize dm files --- modular_bandastation/loadout/_loadout.dme | 2 ++ .../loadout/code/loadout_items.dm | 19 ------------------- .../loadout/code/loadout_menu.dm | 6 ++++++ .../loadout/code/loadout_preference.dm | 11 +++++++++++ 4 files changed, 19 insertions(+), 19 deletions(-) create mode 100644 modular_bandastation/loadout/code/loadout_menu.dm create mode 100644 modular_bandastation/loadout/code/loadout_preference.dm diff --git a/modular_bandastation/loadout/_loadout.dme b/modular_bandastation/loadout/_loadout.dme index 065cd69d7ee47..d68ea846c3bbd 100644 --- a/modular_bandastation/loadout/_loadout.dme +++ b/modular_bandastation/loadout/_loadout.dme @@ -2,4 +2,6 @@ #include "code/loadout_categories.dm" #include "code/loadout_items.dm" +#include "code/loadout_menu.dm" +#include "code/loadout_preference.dm" #include "code/categories/accessories.dm" diff --git a/modular_bandastation/loadout/code/loadout_items.dm b/modular_bandastation/loadout/code/loadout_items.dm index 2028b0f592272..aefed0dd25bc3 100644 --- a/modular_bandastation/loadout/code/loadout_items.dm +++ b/modular_bandastation/loadout/code/loadout_items.dm @@ -1,6 +1,3 @@ -/client - var/donator_level = 0 - /datum/loadout_item var/donator_level = 0 @@ -9,22 +6,6 @@ if(donator_level) . += "Tier [donator_level]" -// Removes donator_level items from the user if their donator_level is insufficient -/datum/preference/loadout/sanitize_loadout_list(list/passed_list, mob/optional_loadout_owner) - . = ..() - for(var/path in .) - var/datum/loadout_item/item = GLOB.all_loadout_datums[path] - if(optional_loadout_owner?.client.donator_level < item.donator_level) - to_chat(optional_loadout_owner, span_warning("У вас недостаточный уровень доната, чтобы взять [item.name]!")) - . -= path - // Removes item from the preferences menu, period. Use it only to remove stuff for ALL players. /datum/loadout_item/proc/is_available() return TRUE - -// Handles selecting from the preferences UI -/datum/preference_middleware/loadout/select_item(datum/loadout_item/selected_item) - if(preferences.parent.donator_level < selected_item.donator_level) - to_chat(preferences.parent.mob, span_warning("У вас недостаточный уровень доната, чтобы взять этот предмет!")) - return - . = ..() diff --git a/modular_bandastation/loadout/code/loadout_menu.dm b/modular_bandastation/loadout/code/loadout_menu.dm new file mode 100644 index 0000000000000..538aa35a04b7a --- /dev/null +++ b/modular_bandastation/loadout/code/loadout_menu.dm @@ -0,0 +1,6 @@ +// Handles selecting from the preferences UI +/datum/preference_middleware/loadout/select_item(datum/loadout_item/selected_item) + if(preferences.parent.donator_level < selected_item.donator_level) + to_chat(preferences.parent.mob, span_warning("У вас недостаточный уровень доната, чтобы взять [selected_item.name]!")) + return + . = ..() diff --git a/modular_bandastation/loadout/code/loadout_preference.dm b/modular_bandastation/loadout/code/loadout_preference.dm new file mode 100644 index 0000000000000..cee9000cdb14d --- /dev/null +++ b/modular_bandastation/loadout/code/loadout_preference.dm @@ -0,0 +1,11 @@ +/client + var/donator_level = 0 + +// Removes donator_level items from the user if their donator_level is insufficient +/datum/preference/loadout/sanitize_loadout_list(list/passed_list, mob/optional_loadout_owner) + . = ..() + for(var/path in .) + var/datum/loadout_item/item = GLOB.all_loadout_datums[path] + if(optional_loadout_owner?.client.donator_level < item.donator_level) + to_chat(optional_loadout_owner, span_warning("У вас недостаточный уровень доната, чтобы взять [item.name]!")) + . -= path From d819ce3c9a784262870659ddea806ed6276df983 Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Fri, 19 Jul 2024 13:10:21 +0300 Subject: [PATCH 05/24] update database --- SQL/bandastation/bandastation_update.sql | 10 ++++++++++ SQL/bandastation/database_changelog.md | 20 ++++++++++++++++--- .../_defines220/code/defines/subsystems.dm | 2 +- modular_bandastation/loadout/_loadout.dme | 1 + modular_bandastation/loadout/code/client.dm | 13 ++++++++++++ .../loadout/code/loadout_preference.dm | 3 --- 6 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 modular_bandastation/loadout/code/client.dm diff --git a/SQL/bandastation/bandastation_update.sql b/SQL/bandastation/bandastation_update.sql index d3883dc403d45..f811b32689cf9 100644 --- a/SQL/bandastation/bandastation_update.sql +++ b/SQL/bandastation/bandastation_update.sql @@ -38,3 +38,13 @@ CREATE TABLE `admin_wl` ( PRIMARY KEY (`id`), KEY `ckey` (`ckey`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +DROP TABLE IF EXISTS `player220`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `player220` ( + `ckey` varchar(32) NOT NULL, + `tier` int(2), + PRIMARY KEY (`ckey`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; diff --git a/SQL/bandastation/database_changelog.md b/SQL/bandastation/database_changelog.md index 74e7053c6a622..61b41d9468b9c 100644 --- a/SQL/bandastation/database_changelog.md +++ b/SQL/bandastation/database_changelog.md @@ -2,17 +2,31 @@ Any time you make a change to the schema files, remember to increment the databa Make sure to also update `DB_MAJOR_VERSION_220` and `DB_MINOR_VERSION_220`, which can be found in `code/modular_bandastation/_defines220/code/defines/subsystems.dm`. -The latest database version is 1.1; The query to update the schema revision table is: +The latest database version is 1.2; The query to update the schema revision table is: ```sql -INSERT INTO `schema_revision_220` (`major`, `minor`) VALUES (1, 1); +INSERT INTO `schema_revision_220` (`major`, `minor`) VALUES (1, 2); ``` or ```sql -INSERT INTO `SS13_schema_revision_220` (`major`, `minor`) VALUES (1, 1); +INSERT INTO `SS13_schema_revision_220` (`major`, `minor`) VALUES (1, 2); ``` +----------------------------------------------------- +Version 1.2, 17 July 2024, by larentoun +Created the tables: player220 + +```sql +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `player220` ( + `ckey` varchar(32) NOT NULL, + `tier` int(2), + PRIMARY KEY (`ckey`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; +``` ----------------------------------------------------- Version 1.1, 17 April 2024, by larentoun Created the tables: schema_revision220, ckey_whitelist, admin_wl diff --git a/modular_bandastation/_defines220/code/defines/subsystems.dm b/modular_bandastation/_defines220/code/defines/subsystems.dm index 90e9cdf733c47..780d90603ab14 100644 --- a/modular_bandastation/_defines220/code/defines/subsystems.dm +++ b/modular_bandastation/_defines220/code/defines/subsystems.dm @@ -15,4 +15,4 @@ * * make sure you add an update to the schema_version stable in the db changelog */ -#define DB_MINOR_VERSION_220 1 +#define DB_MINOR_VERSION_220 2 diff --git a/modular_bandastation/loadout/_loadout.dme b/modular_bandastation/loadout/_loadout.dme index d68ea846c3bbd..949af17ec4a25 100644 --- a/modular_bandastation/loadout/_loadout.dme +++ b/modular_bandastation/loadout/_loadout.dme @@ -1,5 +1,6 @@ #include "_loadout.dm" +#include "code/client.dm" #include "code/loadout_categories.dm" #include "code/loadout_items.dm" #include "code/loadout_menu.dm" diff --git a/modular_bandastation/loadout/code/client.dm b/modular_bandastation/loadout/code/client.dm new file mode 100644 index 0000000000000..51da6974c0315 --- /dev/null +++ b/modular_bandastation/loadout/code/client.dm @@ -0,0 +1,13 @@ +/client + var/donator_level = 0 + +/datum/preferences/load_savefile() + . = ..() + var/datum/db_query/query_get_donator_level = SSdbcore.NewQuery( + "SELECT tier FROM [format_table_name("player220")] WHERE ckey = :ckey", + list("ckey" = parent.ckey) + ) + if(query_get_donator_level.warn_execute() && length(query_get_donator_level.rows)) + query_get_donator_level.NextRow() + parent.donator_level = query_get_donator_level.item[1] + qdel(query_get_donator_level) diff --git a/modular_bandastation/loadout/code/loadout_preference.dm b/modular_bandastation/loadout/code/loadout_preference.dm index cee9000cdb14d..68d05f3a5dc84 100644 --- a/modular_bandastation/loadout/code/loadout_preference.dm +++ b/modular_bandastation/loadout/code/loadout_preference.dm @@ -1,6 +1,3 @@ -/client - var/donator_level = 0 - // Removes donator_level items from the user if their donator_level is insufficient /datum/preference/loadout/sanitize_loadout_list(list/passed_list, mob/optional_loadout_owner) . = ..() From ab3171302e60fc3c1dcff99520f5f9882858c51f Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Sat, 20 Jul 2024 14:58:40 +0300 Subject: [PATCH 06/24] rename table --- SQL/bandastation/bandastation_update.sql | 4 ++-- SQL/bandastation/database_changelog.md | 4 ++-- modular_bandastation/loadout/code/client.dm | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/SQL/bandastation/bandastation_update.sql b/SQL/bandastation/bandastation_update.sql index f811b32689cf9..d75870fe22bfe 100644 --- a/SQL/bandastation/bandastation_update.sql +++ b/SQL/bandastation/bandastation_update.sql @@ -39,10 +39,10 @@ CREATE TABLE `admin_wl` ( KEY `ckey` (`ckey`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -DROP TABLE IF EXISTS `player220`; +DROP TABLE IF EXISTS `player_donation220`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `player220` ( +CREATE TABLE `player_donation220` ( `ckey` varchar(32) NOT NULL, `tier` int(2), PRIMARY KEY (`ckey`) diff --git a/SQL/bandastation/database_changelog.md b/SQL/bandastation/database_changelog.md index 61b41d9468b9c..3ba30d8cc7647 100644 --- a/SQL/bandastation/database_changelog.md +++ b/SQL/bandastation/database_changelog.md @@ -15,12 +15,12 @@ INSERT INTO `SS13_schema_revision_220` (`major`, `minor`) VALUES (1, 2); ----------------------------------------------------- Version 1.2, 17 July 2024, by larentoun -Created the tables: player220 +Created the table: player_donation220 ```sql /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `player220` ( +CREATE TABLE `player_donation220` ( `ckey` varchar(32) NOT NULL, `tier` int(2), PRIMARY KEY (`ckey`) diff --git a/modular_bandastation/loadout/code/client.dm b/modular_bandastation/loadout/code/client.dm index 51da6974c0315..a5097a385621d 100644 --- a/modular_bandastation/loadout/code/client.dm +++ b/modular_bandastation/loadout/code/client.dm @@ -4,7 +4,7 @@ /datum/preferences/load_savefile() . = ..() var/datum/db_query/query_get_donator_level = SSdbcore.NewQuery( - "SELECT tier FROM [format_table_name("player220")] WHERE ckey = :ckey", + "SELECT tier FROM [format_table_name("player_donation220")] WHERE ckey = :ckey", list("ckey" = parent.ckey) ) if(query_get_donator_level.warn_execute() && length(query_get_donator_level.rows)) From 29a0e1fc54f80affa0dafca80b343950f3885b51 Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Sat, 20 Jul 2024 16:47:21 +0300 Subject: [PATCH 07/24] 220 removal --- SQL/bandastation/bandastation_update.sql | 4 ++-- SQL/bandastation/database_changelog.md | 4 ++-- modular_bandastation/loadout/code/client.dm | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/SQL/bandastation/bandastation_update.sql b/SQL/bandastation/bandastation_update.sql index d75870fe22bfe..ce24314943050 100644 --- a/SQL/bandastation/bandastation_update.sql +++ b/SQL/bandastation/bandastation_update.sql @@ -39,10 +39,10 @@ CREATE TABLE `admin_wl` ( KEY `ckey` (`ckey`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -DROP TABLE IF EXISTS `player_donation220`; +DROP TABLE IF EXISTS `player_donation`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `player_donation220` ( +CREATE TABLE `player_donation` ( `ckey` varchar(32) NOT NULL, `tier` int(2), PRIMARY KEY (`ckey`) diff --git a/SQL/bandastation/database_changelog.md b/SQL/bandastation/database_changelog.md index 3ba30d8cc7647..5cc23d0040da6 100644 --- a/SQL/bandastation/database_changelog.md +++ b/SQL/bandastation/database_changelog.md @@ -15,12 +15,12 @@ INSERT INTO `SS13_schema_revision_220` (`major`, `minor`) VALUES (1, 2); ----------------------------------------------------- Version 1.2, 17 July 2024, by larentoun -Created the table: player_donation220 +Created the table: player_donation ```sql /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `player_donation220` ( +CREATE TABLE `player_donation` ( `ckey` varchar(32) NOT NULL, `tier` int(2), PRIMARY KEY (`ckey`) diff --git a/modular_bandastation/loadout/code/client.dm b/modular_bandastation/loadout/code/client.dm index a5097a385621d..ed0348085c122 100644 --- a/modular_bandastation/loadout/code/client.dm +++ b/modular_bandastation/loadout/code/client.dm @@ -4,7 +4,7 @@ /datum/preferences/load_savefile() . = ..() var/datum/db_query/query_get_donator_level = SSdbcore.NewQuery( - "SELECT tier FROM [format_table_name("player_donation220")] WHERE ckey = :ckey", + "SELECT tier FROM [format_table_name("player_donation")] WHERE ckey = :ckey", list("ckey" = parent.ckey) ) if(query_get_donator_level.warn_execute() && length(query_get_donator_level.rows)) From 2d1118b1bb84b2e08bbfedd4b6b7291e88a42491 Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Mon, 22 Jul 2024 20:30:41 +0300 Subject: [PATCH 08/24] Update SQL/bandastation/bandastation_update.sql Co-authored-by: Gaxeer <44334376+Gaxeer@users.noreply.github.com> --- SQL/bandastation/bandastation_update.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/SQL/bandastation/bandastation_update.sql b/SQL/bandastation/bandastation_update.sql index ce24314943050..b98f48ab0628d 100644 --- a/SQL/bandastation/bandastation_update.sql +++ b/SQL/bandastation/bandastation_update.sql @@ -40,8 +40,6 @@ CREATE TABLE `admin_wl` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; DROP TABLE IF EXISTS `player_donation`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; CREATE TABLE `player_donation` ( `ckey` varchar(32) NOT NULL, `tier` int(2), From 50d3e00f8105a6d76c91c5f98bdf0c01d1065b84 Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Mon, 22 Jul 2024 20:30:46 +0300 Subject: [PATCH 09/24] Update SQL/bandastation/bandastation_update.sql Co-authored-by: Gaxeer <44334376+Gaxeer@users.noreply.github.com> --- SQL/bandastation/bandastation_update.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/SQL/bandastation/bandastation_update.sql b/SQL/bandastation/bandastation_update.sql index b98f48ab0628d..838e3703aa946 100644 --- a/SQL/bandastation/bandastation_update.sql +++ b/SQL/bandastation/bandastation_update.sql @@ -45,4 +45,3 @@ CREATE TABLE `player_donation` ( `tier` int(2), PRIMARY KEY (`ckey`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -/*!40101 SET character_set_client = @saved_cs_client */; From 376575a41e7f563ca21dced43fd5ef6bf738e7a2 Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Mon, 22 Jul 2024 20:55:23 +0300 Subject: [PATCH 10/24] tochat once --- modular_bandastation/loadout/code/loadout_preference.dm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modular_bandastation/loadout/code/loadout_preference.dm b/modular_bandastation/loadout/code/loadout_preference.dm index 68d05f3a5dc84..976ae1546977d 100644 --- a/modular_bandastation/loadout/code/loadout_preference.dm +++ b/modular_bandastation/loadout/code/loadout_preference.dm @@ -1,8 +1,11 @@ // Removes donator_level items from the user if their donator_level is insufficient /datum/preference/loadout/sanitize_loadout_list(list/passed_list, mob/optional_loadout_owner) . = ..() + var/removed_items = list() for(var/path in .) var/datum/loadout_item/item = GLOB.all_loadout_datums[path] if(optional_loadout_owner?.client.donator_level < item.donator_level) - to_chat(optional_loadout_owner, span_warning("У вас недостаточный уровень доната, чтобы взять [item.name]!")) . -= path + removed_items += item.name + if(length(removed_items) && optional_loadout_owner) + to_chat(optional_loadout_owner, span_warning("У вас недостаточный уровень доната, чтобы взять: [english_list(removed_items, and_text = " и ")]!")) From 1dfba509af61ff1e31ce4cbb2bcb9bbcb79bc0ef Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Mon, 22 Jul 2024 21:28:38 +0300 Subject: [PATCH 11/24] evade police --- modular_bandastation/loadout/code/loadout_categories.dm | 5 +++-- modular_bandastation/loadout/code/loadout_menu.dm | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modular_bandastation/loadout/code/loadout_categories.dm b/modular_bandastation/loadout/code/loadout_categories.dm index a3a172d8a5754..7e6278bb86e6f 100644 --- a/modular_bandastation/loadout/code/loadout_categories.dm +++ b/modular_bandastation/loadout/code/loadout_categories.dm @@ -1,5 +1,6 @@ /datum/loadout_category/get_items() . = ..() for(var/datum/loadout_item/item as anything in .) - if(!item.is_available()) - . -= item + if(item.is_available()) + continue + . -= item diff --git a/modular_bandastation/loadout/code/loadout_menu.dm b/modular_bandastation/loadout/code/loadout_menu.dm index 538aa35a04b7a..df3ce4dcfc910 100644 --- a/modular_bandastation/loadout/code/loadout_menu.dm +++ b/modular_bandastation/loadout/code/loadout_menu.dm @@ -1,6 +1,5 @@ // Handles selecting from the preferences UI /datum/preference_middleware/loadout/select_item(datum/loadout_item/selected_item) - if(preferences.parent.donator_level < selected_item.donator_level) - to_chat(preferences.parent.mob, span_warning("У вас недостаточный уровень доната, чтобы взять [selected_item.name]!")) - return - . = ..() + if(preferences.parent.donator_level >= selected_item.donator_level) + return ..() + to_chat(preferences.parent.mob, span_warning("У вас недостаточный уровень доната, чтобы взять [selected_item.name]!")) From 5479ab38f8335d33f302e09b1c75e8a41f714af6 Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Mon, 22 Jul 2024 23:26:58 +0300 Subject: [PATCH 12/24] change table to a new one --- SQL/bandastation/bandastation_update.sql | 22 +++++++--- SQL/bandastation/database_changelog.md | 24 ++++++----- modular_bandastation/loadout/code/client.dm | 48 ++++++++++++++++++--- 3 files changed, 72 insertions(+), 22 deletions(-) diff --git a/SQL/bandastation/bandastation_update.sql b/SQL/bandastation/bandastation_update.sql index 838e3703aa946..20cccf09541a5 100644 --- a/SQL/bandastation/bandastation_update.sql +++ b/SQL/bandastation/bandastation_update.sql @@ -39,9 +39,19 @@ CREATE TABLE `admin_wl` ( KEY `ckey` (`ckey`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -DROP TABLE IF EXISTS `player_donation`; -CREATE TABLE `player_donation` ( - `ckey` varchar(32) NOT NULL, - `tier` int(2), - PRIMARY KEY (`ckey`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +-- +-- Table structure for table `budget` +-- +DROP TABLE IF EXISTS `budget`; +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/SQL/bandastation/database_changelog.md b/SQL/bandastation/database_changelog.md index 5cc23d0040da6..b4e6f76b2b51d 100644 --- a/SQL/bandastation/database_changelog.md +++ b/SQL/bandastation/database_changelog.md @@ -14,18 +14,22 @@ INSERT INTO `SS13_schema_revision_220` (`major`, `minor`) VALUES (1, 2); ``` ----------------------------------------------------- -Version 1.2, 17 July 2024, by larentoun -Created the table: player_donation +Version 1.2, 22 July 2024, by larentoun +Created the table: budget ```sql -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `player_donation` ( - `ckey` varchar(32) NOT NULL, - `tier` int(2), - PRIMARY KEY (`ckey`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -/*!40101 SET character_set_client = @saved_cs_client */; +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; ``` ----------------------------------------------------- Version 1.1, 17 April 2024, by larentoun diff --git a/modular_bandastation/loadout/code/client.dm b/modular_bandastation/loadout/code/client.dm index ed0348085c122..6c19001120476 100644 --- a/modular_bandastation/loadout/code/client.dm +++ b/modular_bandastation/loadout/code/client.dm @@ -1,13 +1,49 @@ +#define TIER1 220 +#define TIER2 440 +#define TIER3 1000 +#define TIER4 2220 +#define TIER5 10000 + /client var/donator_level = 0 /datum/preferences/load_savefile() . = ..() - var/datum/db_query/query_get_donator_level = SSdbcore.NewQuery( - "SELECT tier FROM [format_table_name("player_donation")] WHERE ckey = :ckey", - list("ckey" = parent.ckey) - ) + var/donator_level = get_donator_level_db() + parent.donator_level = donator_level + +/datum/preferences/proc/get_donator_level_db() + var/datum/db_query/query_get_donator_level = 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" = parent.ckey)) + + var/best_value = 0 if(query_get_donator_level.warn_execute() && length(query_get_donator_level.rows)) - query_get_donator_level.NextRow() - parent.donator_level = query_get_donator_level.item[1] + while(query_get_donator_level.NextRow()) + var/amount = query_get_donator_level.item[1] + best_value = max(best_value, amount) qdel(query_get_donator_level) + + switch(best_value) + if(TIER1 to (TIER2 - 1)) + return 1 + if(TIER2 to (TIER3 - 1)) + return 2 + if(TIER3 to (TIER4 - 1)) + return 3 + if(TIER4 to (TIER5 - 1)) + return 4 + if(TIER5 to INFINITY) + return 5 + return 0 + +#undef TIER1 +#undef TIER2 +#undef TIER3 +#undef TIER4 +#undef TIER5 From 43afbd03d501a3f384f449151029ab3e1944b0da Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Mon, 22 Jul 2024 23:57:17 +0300 Subject: [PATCH 13/24] give admins tier 3 for now --- modular_bandastation/loadout/code/client.dm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modular_bandastation/loadout/code/client.dm b/modular_bandastation/loadout/code/client.dm index 6c19001120476..acb7acd20c35e 100644 --- a/modular_bandastation/loadout/code/client.dm +++ b/modular_bandastation/loadout/code/client.dm @@ -7,10 +7,20 @@ /client var/donator_level = 0 +/client/add_admin_verbs() + . = ..() + donator_level = max(donator_level, holder?.get_donator_level_admin()) + /datum/preferences/load_savefile() . = ..() - var/donator_level = get_donator_level_db() - parent.donator_level = donator_level + parent.donator_level = max(parent.donator_level, get_donator_level_db()) + +/datum/admins/proc/get_donator_level_admin() + var/best_level = 0 + for(var/datum/admin_rank/rank as anything in ranks) + if(rank.rights & R_ADMIN) + best_level = max(best_level, 3) + return best_level /datum/preferences/proc/get_donator_level_db() var/datum/db_query/query_get_donator_level = SSdbcore.NewQuery({" From 01a4c05973aa7835cd0547488340775ee614741f Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Tue, 23 Jul 2024 00:03:44 +0300 Subject: [PATCH 14/24] it is already summed --- modular_bandastation/loadout/code/client.dm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modular_bandastation/loadout/code/client.dm b/modular_bandastation/loadout/code/client.dm index acb7acd20c35e..cc373a7cae3b1 100644 --- a/modular_bandastation/loadout/code/client.dm +++ b/modular_bandastation/loadout/code/client.dm @@ -32,14 +32,13 @@ GROUP BY ckey "}, list("ckey" = parent.ckey)) - var/best_value = 0 + var/amount = 0 if(query_get_donator_level.warn_execute() && length(query_get_donator_level.rows)) - while(query_get_donator_level.NextRow()) - var/amount = query_get_donator_level.item[1] - best_value = max(best_value, amount) + query_get_donator_level.NextRow() + amount = query_get_donator_level.item[1] qdel(query_get_donator_level) - switch(best_value) + switch(amount) if(TIER1 to (TIER2 - 1)) return 1 if(TIER2 to (TIER3 - 1)) From d5639848aece2cea7130ec256f8908e57b3114f6 Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Tue, 23 Jul 2024 00:08:25 +0300 Subject: [PATCH 15/24] ladder police --- modular_bandastation/loadout/code/loadout_preference.dm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modular_bandastation/loadout/code/loadout_preference.dm b/modular_bandastation/loadout/code/loadout_preference.dm index 976ae1546977d..9c95f383bb8dd 100644 --- a/modular_bandastation/loadout/code/loadout_preference.dm +++ b/modular_bandastation/loadout/code/loadout_preference.dm @@ -4,8 +4,9 @@ var/removed_items = list() for(var/path in .) var/datum/loadout_item/item = GLOB.all_loadout_datums[path] - if(optional_loadout_owner?.client.donator_level < item.donator_level) - . -= path - removed_items += item.name + if(optional_loadout_owner?.client.donator_level >= item.donator_level) + continue + . -= path + removed_items += item.name if(length(removed_items) && optional_loadout_owner) to_chat(optional_loadout_owner, span_warning("У вас недостаточный уровень доната, чтобы взять: [english_list(removed_items, and_text = " и ")]!")) From 56e5fe918eddafc5761afe274ede3b16ff8b0d56 Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Tue, 23 Jul 2024 00:35:52 +0300 Subject: [PATCH 16/24] use proc to get donator levels --- modular_bandastation/loadout/code/client.dm | 28 +++++++++++-------- .../loadout/code/loadout_menu.dm | 3 +- .../loadout/code/loadout_preference.dm | 3 +- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/modular_bandastation/loadout/code/client.dm b/modular_bandastation/loadout/code/client.dm index cc373a7cae3b1..bb02362a7e6aa 100644 --- a/modular_bandastation/loadout/code/client.dm +++ b/modular_bandastation/loadout/code/client.dm @@ -5,24 +5,28 @@ #define TIER5 10000 /client - var/donator_level = 0 + VAR_PRIVATE/donator_level = 0 + COOLDOWN_DECLARE(db_check_cooldown) -/client/add_admin_verbs() - . = ..() - donator_level = max(donator_level, holder?.get_donator_level_admin()) +/client/proc/get_donator_level() + donator_level = max(donator_level, get_donator_level_db(), get_donator_level_admin()) + return donator_level -/datum/preferences/load_savefile() - . = ..() - parent.donator_level = max(parent.donator_level, get_donator_level_db()) - -/datum/admins/proc/get_donator_level_admin() +/client/proc/get_donator_level_admin() + if(!holder) + return 0 var/best_level = 0 - for(var/datum/admin_rank/rank as anything in ranks) + for(var/datum/admin_rank/rank as anything in holder.ranks) if(rank.rights & R_ADMIN) best_level = max(best_level, 3) + if(rank.rights & R_EVERYTHING) + return 5 return best_level -/datum/preferences/proc/get_donator_level_db() +/client/proc/get_donator_level_db() + if(!COOLDOWN_FINISHED(src, db_check_cooldown)) + return 0 + COOLDOWN_START(src, db_check_cooldown, 15 SECONDS) var/datum/db_query/query_get_donator_level = SSdbcore.NewQuery({" SELECT CAST(SUM(amount) as UNSIGNED INTEGER) FROM budget WHERE ckey=:ckey @@ -30,7 +34,7 @@ AND date_start <= NOW() AND (NOW() < date_end OR date_end IS NULL) GROUP BY ckey - "}, list("ckey" = parent.ckey)) + "}, list("ckey" = ckey)) var/amount = 0 if(query_get_donator_level.warn_execute() && length(query_get_donator_level.rows)) diff --git a/modular_bandastation/loadout/code/loadout_menu.dm b/modular_bandastation/loadout/code/loadout_menu.dm index df3ce4dcfc910..132bc8fe57eca 100644 --- a/modular_bandastation/loadout/code/loadout_menu.dm +++ b/modular_bandastation/loadout/code/loadout_menu.dm @@ -1,5 +1,6 @@ // Handles selecting from the preferences UI /datum/preference_middleware/loadout/select_item(datum/loadout_item/selected_item) - if(preferences.parent.donator_level >= selected_item.donator_level) + var/donator_level = preferences.parent.get_donator_level() + if(donator_level >= selected_item.donator_level) return ..() to_chat(preferences.parent.mob, span_warning("У вас недостаточный уровень доната, чтобы взять [selected_item.name]!")) diff --git a/modular_bandastation/loadout/code/loadout_preference.dm b/modular_bandastation/loadout/code/loadout_preference.dm index 9c95f383bb8dd..8065ebdf25edc 100644 --- a/modular_bandastation/loadout/code/loadout_preference.dm +++ b/modular_bandastation/loadout/code/loadout_preference.dm @@ -1,10 +1,11 @@ // Removes donator_level items from the user if their donator_level is insufficient /datum/preference/loadout/sanitize_loadout_list(list/passed_list, mob/optional_loadout_owner) . = ..() + var/donator_level = optional_loadout_owner?.client?.get_donator_level() || 0 var/removed_items = list() for(var/path in .) var/datum/loadout_item/item = GLOB.all_loadout_datums[path] - if(optional_loadout_owner?.client.donator_level >= item.donator_level) + if(donator_level >= item.donator_level) continue . -= path removed_items += item.name From 6c83ab4e729b85de3df092f00afb8370a8b62336 Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Tue, 23 Jul 2024 00:42:44 +0300 Subject: [PATCH 17/24] admins get 3 level --- modular_bandastation/loadout/code/client.dm | 2 -- 1 file changed, 2 deletions(-) diff --git a/modular_bandastation/loadout/code/client.dm b/modular_bandastation/loadout/code/client.dm index bb02362a7e6aa..4e48f5741d6c9 100644 --- a/modular_bandastation/loadout/code/client.dm +++ b/modular_bandastation/loadout/code/client.dm @@ -19,8 +19,6 @@ for(var/datum/admin_rank/rank as anything in holder.ranks) if(rank.rights & R_ADMIN) best_level = max(best_level, 3) - if(rank.rights & R_EVERYTHING) - return 5 return best_level /client/proc/get_donator_level_db() From b97bfe91abc616b6ae01311860ac4863b244c34f Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Tue, 23 Jul 2024 00:58:10 +0300 Subject: [PATCH 18/24] i hate deserialize --- modular_bandastation/loadout/code/client.dm | 4 ++-- modular_bandastation/loadout/code/loadout_menu.dm | 2 +- .../loadout/code/loadout_preference.dm | 12 ++++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/modular_bandastation/loadout/code/client.dm b/modular_bandastation/loadout/code/client.dm index 4e48f5741d6c9..aaa06095b318e 100644 --- a/modular_bandastation/loadout/code/client.dm +++ b/modular_bandastation/loadout/code/client.dm @@ -5,10 +5,10 @@ #define TIER5 10000 /client - VAR_PRIVATE/donator_level = 0 + var/donator_level = 0 COOLDOWN_DECLARE(db_check_cooldown) -/client/proc/get_donator_level() +/client/proc/update_donator_level() donator_level = max(donator_level, get_donator_level_db(), get_donator_level_admin()) return donator_level diff --git a/modular_bandastation/loadout/code/loadout_menu.dm b/modular_bandastation/loadout/code/loadout_menu.dm index 132bc8fe57eca..e9181e91227ee 100644 --- a/modular_bandastation/loadout/code/loadout_menu.dm +++ b/modular_bandastation/loadout/code/loadout_menu.dm @@ -1,6 +1,6 @@ // Handles selecting from the preferences UI /datum/preference_middleware/loadout/select_item(datum/loadout_item/selected_item) - var/donator_level = preferences.parent.get_donator_level() + var/donator_level = preferences.parent.update_donator_level() if(donator_level >= selected_item.donator_level) return ..() to_chat(preferences.parent.mob, span_warning("У вас недостаточный уровень доната, чтобы взять [selected_item.name]!")) diff --git a/modular_bandastation/loadout/code/loadout_preference.dm b/modular_bandastation/loadout/code/loadout_preference.dm index 8065ebdf25edc..09930c2854a48 100644 --- a/modular_bandastation/loadout/code/loadout_preference.dm +++ b/modular_bandastation/loadout/code/loadout_preference.dm @@ -1,7 +1,11 @@ +/datum/preferences/load_preferences() + . = ..() + parent.update_donator_level() + // Removes donator_level items from the user if their donator_level is insufficient -/datum/preference/loadout/sanitize_loadout_list(list/passed_list, mob/optional_loadout_owner) +/datum/preference/loadout/deserialize(input, datum/preferences/preferences) . = ..() - var/donator_level = optional_loadout_owner?.client?.get_donator_level() || 0 + var/donator_level = preferences.parent.donator_level var/removed_items = list() for(var/path in .) var/datum/loadout_item/item = GLOB.all_loadout_datums[path] @@ -9,5 +13,5 @@ continue . -= path removed_items += item.name - if(length(removed_items) && optional_loadout_owner) - to_chat(optional_loadout_owner, span_warning("У вас недостаточный уровень доната, чтобы взять: [english_list(removed_items, and_text = " и ")]!")) + if(length(removed_items) && preferences.parent.mob) + to_chat(preferences.parent.mob, span_warning("У вас недостаточный уровень доната, чтобы взять: [english_list(removed_items, and_text = " и ")]!")) From 6b7146bf90bc49b25d058caca51f6f6f8a631581 Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Tue, 23 Jul 2024 01:24:28 +0300 Subject: [PATCH 19/24] it's the best I can do --- modular_bandastation/loadout/_loadout.dme | 1 - modular_bandastation/loadout/code/client.dm | 1 + modular_bandastation/loadout/code/loadout_menu.dm | 6 ------ modular_bandastation/loadout/code/loadout_preference.dm | 8 ++++++++ 4 files changed, 9 insertions(+), 7 deletions(-) delete mode 100644 modular_bandastation/loadout/code/loadout_menu.dm diff --git a/modular_bandastation/loadout/_loadout.dme b/modular_bandastation/loadout/_loadout.dme index 949af17ec4a25..c1ba4df8b8a99 100644 --- a/modular_bandastation/loadout/_loadout.dme +++ b/modular_bandastation/loadout/_loadout.dme @@ -3,6 +3,5 @@ #include "code/client.dm" #include "code/loadout_categories.dm" #include "code/loadout_items.dm" -#include "code/loadout_menu.dm" #include "code/loadout_preference.dm" #include "code/categories/accessories.dm" diff --git a/modular_bandastation/loadout/code/client.dm b/modular_bandastation/loadout/code/client.dm index aaa06095b318e..f6f30d27055dc 100644 --- a/modular_bandastation/loadout/code/client.dm +++ b/modular_bandastation/loadout/code/client.dm @@ -5,6 +5,7 @@ #define TIER5 10000 /client + /// Call `proc/update_donator_level()` instead to get a value when possible. var/donator_level = 0 COOLDOWN_DECLARE(db_check_cooldown) diff --git a/modular_bandastation/loadout/code/loadout_menu.dm b/modular_bandastation/loadout/code/loadout_menu.dm deleted file mode 100644 index e9181e91227ee..0000000000000 --- a/modular_bandastation/loadout/code/loadout_menu.dm +++ /dev/null @@ -1,6 +0,0 @@ -// Handles selecting from the preferences UI -/datum/preference_middleware/loadout/select_item(datum/loadout_item/selected_item) - var/donator_level = preferences.parent.update_donator_level() - if(donator_level >= selected_item.donator_level) - return ..() - to_chat(preferences.parent.mob, span_warning("У вас недостаточный уровень доната, чтобы взять [selected_item.name]!")) diff --git a/modular_bandastation/loadout/code/loadout_preference.dm b/modular_bandastation/loadout/code/loadout_preference.dm index 09930c2854a48..16613185edbaf 100644 --- a/modular_bandastation/loadout/code/loadout_preference.dm +++ b/modular_bandastation/loadout/code/loadout_preference.dm @@ -2,9 +2,17 @@ . = ..() parent.update_donator_level() +// Handles selecting from the preferences UI +/datum/preference_middleware/loadout/select_item(datum/loadout_item/selected_item) + var/donator_level = preferences.parent.update_donator_level() + if(donator_level >= selected_item.donator_level) + return ..() + to_chat(preferences.parent.mob, span_warning("У вас недостаточный уровень доната, чтобы взять [selected_item.name]!")) + // Removes donator_level items from the user if their donator_level is insufficient /datum/preference/loadout/deserialize(input, datum/preferences/preferences) . = ..() + // For loadout purposes, donator_level is updated in middleware on select var/donator_level = preferences.parent.donator_level var/removed_items = list() for(var/path in .) From 5f5f449642cf7d8085b175f5999b52090d8396de Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:37:47 +0300 Subject: [PATCH 20/24] review --- modular_bandastation/loadout/code/client.dm | 40 +++++++++---------- .../loadout/code/loadout_preference.dm | 4 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/modular_bandastation/loadout/code/client.dm b/modular_bandastation/loadout/code/client.dm index f6f30d27055dc..7ef94dfd23705 100644 --- a/modular_bandastation/loadout/code/client.dm +++ b/modular_bandastation/loadout/code/client.dm @@ -1,19 +1,19 @@ -#define TIER1 220 -#define TIER2 440 -#define TIER3 1000 -#define TIER4 2220 -#define TIER5 10000 +#define DONATION_TIER_1 220 +#define DONATION_TIER_2 440 +#define DONATION_TIER_3 1000 +#define DONATION_TIER_4 2220 +#define DONATION_TIER_5 10000 /client - /// Call `proc/update_donator_level()` instead to get a value when possible. + /// Call `proc/get_donator_level()` instead to get a value when possible. var/donator_level = 0 COOLDOWN_DECLARE(db_check_cooldown) -/client/proc/update_donator_level() - donator_level = max(donator_level, get_donator_level_db(), get_donator_level_admin()) +/client/proc/get_donator_level() + donator_level = max(donator_level, get_donator_level_from_db(), get_donator_level_from_admin()) return donator_level -/client/proc/get_donator_level_admin() +/client/proc/get_donator_level_from_admin() if(!holder) return 0 var/best_level = 0 @@ -22,7 +22,7 @@ best_level = max(best_level, 3) return best_level -/client/proc/get_donator_level_db() +/client/proc/get_donator_level_from_db() if(!COOLDOWN_FINISHED(src, db_check_cooldown)) return 0 COOLDOWN_START(src, db_check_cooldown, 15 SECONDS) @@ -42,20 +42,20 @@ qdel(query_get_donator_level) switch(amount) - if(TIER1 to (TIER2 - 1)) + if(DONATION_TIER_1 to (DONATION_TIER_2 - 1)) return 1 - if(TIER2 to (TIER3 - 1)) + if(DONATION_TIER_2 to (DONATION_TIER_3 - 1)) return 2 - if(TIER3 to (TIER4 - 1)) + if(DONATION_TIER_3 to (DONATION_TIER_4 - 1)) return 3 - if(TIER4 to (TIER5 - 1)) + if(DONATION_TIER_4 to (DONATION_TIER_5 - 1)) return 4 - if(TIER5 to INFINITY) + if(DONATION_TIER_5 to INFINITY) return 5 return 0 -#undef TIER1 -#undef TIER2 -#undef TIER3 -#undef TIER4 -#undef TIER5 +#undef DONATION_TIER_1 +#undef DONATION_TIER_2 +#undef DONATION_TIER_3 +#undef DONATION_TIER_4 +#undef DONATION_TIER_5 diff --git a/modular_bandastation/loadout/code/loadout_preference.dm b/modular_bandastation/loadout/code/loadout_preference.dm index 16613185edbaf..534c42e7ad686 100644 --- a/modular_bandastation/loadout/code/loadout_preference.dm +++ b/modular_bandastation/loadout/code/loadout_preference.dm @@ -1,10 +1,10 @@ /datum/preferences/load_preferences() . = ..() - parent.update_donator_level() + parent.get_donator_level() // Handles selecting from the preferences UI /datum/preference_middleware/loadout/select_item(datum/loadout_item/selected_item) - var/donator_level = preferences.parent.update_donator_level() + var/donator_level = preferences.parent.get_donator_level() if(donator_level >= selected_item.donator_level) return ..() to_chat(preferences.parent.mob, span_warning("У вас недостаточный уровень доната, чтобы взять [selected_item.name]!")) From 84da6f4894ff2feb990a76318f1165c4ee57fdad Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Wed, 24 Jul 2024 13:36:03 +0300 Subject: [PATCH 21/24] will it fix tests? --- modular_bandastation/loadout/code/client.dm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modular_bandastation/loadout/code/client.dm b/modular_bandastation/loadout/code/client.dm index 7ef94dfd23705..3409e92d0f4c8 100644 --- a/modular_bandastation/loadout/code/client.dm +++ b/modular_bandastation/loadout/code/client.dm @@ -9,6 +9,9 @@ var/donator_level = 0 COOLDOWN_DECLARE(db_check_cooldown) +/datum/client_interface + var/donator_level = 0 + /client/proc/get_donator_level() donator_level = max(donator_level, get_donator_level_from_db(), get_donator_level_from_admin()) return donator_level From ac7c953d49b4d1cf2599b91c12828a08c40044c2 Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Wed, 24 Jul 2024 13:36:20 +0300 Subject: [PATCH 22/24] comment --- modular_bandastation/loadout/code/client.dm | 1 + 1 file changed, 1 insertion(+) diff --git a/modular_bandastation/loadout/code/client.dm b/modular_bandastation/loadout/code/client.dm index 3409e92d0f4c8..2c6b25b1be48f 100644 --- a/modular_bandastation/loadout/code/client.dm +++ b/modular_bandastation/loadout/code/client.dm @@ -9,6 +9,7 @@ var/donator_level = 0 COOLDOWN_DECLARE(db_check_cooldown) +// For unit-tests /datum/client_interface var/donator_level = 0 From e3ce445c0f4a6fd3363c518ce1d818f0a47b8bf6 Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Wed, 24 Jul 2024 13:47:49 +0300 Subject: [PATCH 23/24] it also needs procs, alright... --- modular_bandastation/loadout/code/client.dm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modular_bandastation/loadout/code/client.dm b/modular_bandastation/loadout/code/client.dm index 2c6b25b1be48f..e0cdb8575810d 100644 --- a/modular_bandastation/loadout/code/client.dm +++ b/modular_bandastation/loadout/code/client.dm @@ -13,6 +13,9 @@ /datum/client_interface var/donator_level = 0 +/datum/client_interface/proc/get_donator_level() + return donator_level + /client/proc/get_donator_level() donator_level = max(donator_level, get_donator_level_from_db(), get_donator_level_from_admin()) return donator_level From 590f587ce9cd9d1a6aeb81f6f6fb0393c02a421d Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Wed, 24 Jul 2024 14:09:25 +0300 Subject: [PATCH 24/24] review --- modular_bandastation/loadout/code/client.dm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modular_bandastation/loadout/code/client.dm b/modular_bandastation/loadout/code/client.dm index e0cdb8575810d..03ad62dfba7c8 100644 --- a/modular_bandastation/loadout/code/client.dm +++ b/modular_bandastation/loadout/code/client.dm @@ -23,11 +23,12 @@ /client/proc/get_donator_level_from_admin() if(!holder) return 0 - var/best_level = 0 - for(var/datum/admin_rank/rank as anything in holder.ranks) - if(rank.rights & R_ADMIN) - best_level = max(best_level, 3) - return best_level + var/rank_flags = holder.rank_flags() + if(rank_flags & R_EVERYTHING) + return 5 + if(rank_flags & R_ADMIN) + return 3 + return 0 /client/proc/get_donator_level_from_db() if(!COOLDOWN_FINISHED(src, db_check_cooldown))