From 5e5c75bf488430f7bb319ca52475bc6beefa5b64 Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Sun, 24 Nov 2024 14:23:27 +0000 Subject: [PATCH] Adds toggles3 (#27397) --- SQL/paradise_schema.sql | 1 + SQL/updates/61-62.sql | 4 ++++ code/__DEFINES/misc_defines.dm | 2 +- code/__DEFINES/preferences_defines.dm | 15 ++++++++++++++- .../login_processing/10-load_preferences.dm | 3 ++- code/modules/client/preference/preferences.dm | 1 + .../client/preference/preferences_mysql.dm | 4 ++++ config/example/config.toml | 2 +- 8 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 SQL/updates/61-62.sql diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql index fe3b9b15d85..cba1286a306 100644 --- a/SQL/paradise_schema.sql +++ b/SQL/paradise_schema.sql @@ -280,6 +280,7 @@ CREATE TABLE `player` ( `default_slot` smallint(4) DEFAULT '1', `toggles` int(11) DEFAULT NULL, `toggles_2` int(11) DEFAULT NULL, + `toggles_3` int(11) DEFAULT NULL, `sound` mediumint(8) DEFAULT '31', `light` MEDIUMINT(3) NOT NULL DEFAULT '7', `glowlevel` TINYINT(1) NOT NULL DEFAULT '1', diff --git a/SQL/updates/61-62.sql b/SQL/updates/61-62.sql new file mode 100644 index 00000000000..b298a807c18 --- /dev/null +++ b/SQL/updates/61-62.sql @@ -0,0 +1,4 @@ +# Updating the SQL from version 61 to version 12. -AffectedArc07 +# Adds a new bitflag column for toggles + +ALTER TABLE `player` ADD COLUMN `toggles_3` INT NULL DEFAULT NULL AFTER `toggles_2`; diff --git a/code/__DEFINES/misc_defines.dm b/code/__DEFINES/misc_defines.dm index a5995f17c6f..ccc3f766950 100644 --- a/code/__DEFINES/misc_defines.dm +++ b/code/__DEFINES/misc_defines.dm @@ -423,7 +423,7 @@ #define INVESTIGATE_HOTMIC "hotmic" // The SQL version required by this version of the code -#define SQL_VERSION 61 +#define SQL_VERSION 62 // Vending machine stuff #define CAT_NORMAL (1<<0) diff --git a/code/__DEFINES/preferences_defines.dm b/code/__DEFINES/preferences_defines.dm index fd0a1d7d7bf..8aaf307cdc4 100644 --- a/code/__DEFINES/preferences_defines.dm +++ b/code/__DEFINES/preferences_defines.dm @@ -80,13 +80,26 @@ #define TOGGLES_2_DEFAULT (PREFTOGGLE_2_FANCYUI|PREFTOGGLE_2_ITEMATTACK|PREFTOGGLE_2_WINDOWFLASHING|PREFTOGGLE_2_RUNECHAT|PREFTOGGLE_2_DEATHMESSAGE|PREFTOGGLE_2_SEE_ITEM_OUTLINES|PREFTOGGLE_2_THOUGHT_BUBBLE|PREFTOGGLE_2_DANCE_DISCO|PREFTOGGLE_2_MOD_ACTIVATION_METHOD|PREFTOGGLE_2_SWAP_INPUT_BUTTONS|PREFTOGGLE_2_LARGE_INPUT_BUTTONS) + +// toggles_3 variables. These MUST be prefixed with PREFTOGGLE_3 +#define TOGGLES_3_TOTAL 1023 // If you add or remove a preference toggle above, make sure you update this define with the total value of the toggles combined. + +// When you add a toggle here, inform AA on merge so the column can be zeroed out. This needs to exist to avoid the compiler freaking out +// Also update the above value to the actual total +#define TOGGLES_3_DEFAULT (1) + // Sanity checks +// I should really convert these to a JSON list at some point hnnnnnng #if TOGGLES_TOTAL > 16777215 #error toggles bitflag over 16777215. Please use toggles_2. #endif #if TOGGLES_2_TOTAL > 16777215 -#error toggles_2 bitflag over 16777215. Please make an issue report and postpone the feature you are working on. +#error toggles_2 bitflag over 16777215. Please use toggles_3. +#endif + +#if TOGGLES_3_TOTAL > 16777215 +#error toggles_3 bitflag over 16777215. Please make an issue report and postpone the feature you are working on. #endif // This is a list index. Required to start at 1 instead of 0 so it's properly placed in the list diff --git a/code/modules/client/login_processing/10-load_preferences.dm b/code/modules/client/login_processing/10-load_preferences.dm index 0b2c2dc4afd..b16174dfd60 100644 --- a/code/modules/client/login_processing/10-load_preferences.dm +++ b/code/modules/client/login_processing/10-load_preferences.dm @@ -32,7 +32,8 @@ server_region, muted_adminsounds_ckeys, viewrange, - map_vote_pref_json + map_vote_pref_json, + toggles_3 FROM player WHERE ckey=:ckey"}, list( "ckey" = C.ckey diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm index 42fed59b863..0ac3432dd24 100644 --- a/code/modules/client/preference/preferences.dm +++ b/code/modules/client/preference/preferences.dm @@ -63,6 +63,7 @@ GLOBAL_LIST_INIT(special_role_times, list( var/UI_style = "Midnight" var/toggles = TOGGLES_DEFAULT var/toggles2 = TOGGLES_2_DEFAULT // Created because 1 column has a bitflag limit of 24 (BYOND limitation not MySQL) + var/toggles3 = TOGGLES_3_DEFAULT // Created for see above. I need to JSONify this at some point -aa07 var/sound = SOUND_DEFAULT var/light = LIGHT_DEFAULT /// Glow level for the lighting. Takes values from GLOW_HIGH to GLOW_DISABLE. diff --git a/code/modules/client/preference/preferences_mysql.dm b/code/modules/client/preference/preferences_mysql.dm index 20252f8b58d..1ff1a56fc3a 100644 --- a/code/modules/client/preference/preferences_mysql.dm +++ b/code/modules/client/preference/preferences_mysql.dm @@ -34,6 +34,7 @@ raw_muted_admins = query.item[26] viewrange = query.item[27] raw_fptp = query.item[28] + toggles3 = text2num(query.item[29]) lastchangelog_2 = lastchangelog // Clone please @@ -43,6 +44,7 @@ default_slot = sanitize_integer(default_slot, 1, max_save_slots, initial(default_slot)) toggles = sanitize_integer(toggles, 0, TOGGLES_TOTAL, initial(toggles)) toggles2 = sanitize_integer(toggles2, 0, TOGGLES_2_TOTAL, initial(toggles2)) + toggles3 = sanitize_integer(toggles3, 0, TOGGLES_3_TOTAL, initial(toggles3)) sound = sanitize_integer(sound, 0, 65535, initial(sound)) UI_style_color = sanitize_hexcolor(UI_style_color, initial(UI_style_color)) UI_style_alpha = sanitize_integer(UI_style_alpha, 0, 255, initial(UI_style_alpha)) @@ -94,6 +96,7 @@ default_slot=:defaultslot, toggles=:toggles, toggles_2=:toggles2, + toggles_3=:toggles3, atklog=:atklog, sound=:sound, light=:light, @@ -123,6 +126,7 @@ // Even though its a number in the DB, you have to use num2text here, otherwise byond adds scientific notation to the number "toggles" = num2text(toggles, CEILING(log(10, (TOGGLES_TOTAL)), 1)), "toggles2" = num2text(toggles2, CEILING(log(10, (TOGGLES_2_TOTAL)), 1)), + "toggles3" = num2text(toggles3, CEILING(log(10, (TOGGLES_3_TOTAL)), 1)), "atklog" = atklog, "sound" = sound, "light" = light, diff --git a/config/example/config.toml b/config/example/config.toml index ad50949872c..52c60b28f8c 100644 --- a/config/example/config.toml +++ b/config/example/config.toml @@ -181,7 +181,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 = 61 +sql_version = 62 # SQL server address. Can be an IP or DNS name sql_address = "127.0.0.1" # SQL server port