From 6c5f04de768958ef739c5e4a628f79e2f2b367b9 Mon Sep 17 00:00:00 2001 From: Kashargul <144968721+Kashargul@users.noreply.github.com> Date: Tue, 17 Feb 2026 15:36:18 +0100 Subject: [PATCH] use gauss elimination for color matrix (#19190) * use gauss elimination for color matrix * . * Update functions.ts * Update functions.ts * some more improvements * . * . * . * ugh --------- Co-authored-by: Cameron Lennox --- code/modules/admin/verbs/randomverbs.dm | 14 +- .../hydroponics/spreading/spreading_growth.dm | 2 + .../player_tips_controller_vr.dm | 2 +- .../MatrixTabs/ColorMatrixSolver.tsx | 69 ++++--- .../tgui/interfaces/ColorMate/functions.ts | 176 +++++++++--------- .../tgui/interfaces/ColorMate/index.tsx | 6 +- 6 files changed, 142 insertions(+), 127 deletions(-) diff --git a/code/modules/admin/verbs/randomverbs.dm b/code/modules/admin/verbs/randomverbs.dm index 88f639c736..819e520479 100644 --- a/code/modules/admin/verbs/randomverbs.dm +++ b/code/modules/admin/verbs/randomverbs.dm @@ -626,19 +626,19 @@ ADMIN_VERB(cmd_admin_add_freeform_ai_law, R_FUN, "Add Custom AI law", "Adds a cu command_announcement.Announce("Ion storm detected near the [station_name()]. Please check all AI-controlled equipment for errors.", "Anomaly Alert", new_sound = 'sound/AI/ionstorm.ogg') feedback_add_details("admin_verb","IONC") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! -ADMIN_VERB_AND_CONTEXT_MENU(cmd_admin_rejuvenate, R_ADMIN|R_FUN|R_MOD, "Rejuvenate", "Fully restores the target mob.", ADMIN_CATEGORY_GAME, mob/living/traget_mob as mob in GLOB.mob_list) - if(!traget_mob) +ADMIN_VERB_AND_CONTEXT_MENU(cmd_admin_rejuvenate, R_ADMIN|R_FUN|R_MOD, "Rejuvenate", "Fully restores the target mob.", ADMIN_CATEGORY_GAME, mob/living/target_mob as mob in GLOB.mob_list) + if(!target_mob) return - if(!istype(traget_mob)) + if(!istype(target_mob)) tgui_alert_async(user, "Cannot revive a ghost") return if(CONFIG_GET(flag/allow_admin_rev)) - traget_mob.revive() + target_mob.revive() - log_admin("[key_name(user)] healed / revived [key_name(traget_mob)]") - var/msg = span_danger("Admin [key_name_admin(user)] healed / revived [ADMIN_LOOKUPFLW(traget_mob)]!") + log_admin("[key_name(user)] healed / revived [key_name(target_mob)]") + var/msg = span_danger("Admin [key_name_admin(user)] healed / revived [ADMIN_LOOKUPFLW(target_mob)]!") message_admins(msg) - admin_ticket_log(traget_mob, msg) + admin_ticket_log(target_mob, msg) else tgui_alert_async(user, "Admin revive disabled") feedback_add_details("admin_verb","REJU") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! diff --git a/code/modules/hydroponics/spreading/spreading_growth.dm b/code/modules/hydroponics/spreading/spreading_growth.dm index 36d5717be7..69efc33395 100644 --- a/code/modules/hydroponics/spreading/spreading_growth.dm +++ b/code/modules/hydroponics/spreading/spreading_growth.dm @@ -111,6 +111,8 @@ sleep(rand(3,5)) if(!length(neighbors)) break + if(QDELETED(src)) // we sleep, might get deleted! + return spread_to(pick(neighbors)) // We shouldn't have spawned if the controller doesn't exist. diff --git a/code/modules/player_tips_vr/player_tips_controller_vr.dm b/code/modules/player_tips_vr/player_tips_controller_vr.dm index a20efefe9f..b3b8991a26 100644 --- a/code/modules/player_tips_vr/player_tips_controller_vr.dm +++ b/code/modules/player_tips_vr/player_tips_controller_vr.dm @@ -36,7 +36,7 @@ Controlled by the player_tips subsystem under code/controllers/subsystems/player if(!(target_mob.client?.prefs?.read_preference(/datum/preference/toggle/player_tips))) return if(target_mob.key && !(target_mob.key in HasReceived)) - to_chat(target_mob, span_warning("You have periodic player tips enabled. You may turn them off at any time with the Toggle Receiving Player Tips verb in Preferences, or in character set up under the OOC tab!\n Player tips appear every 45-75 minutes.")) + to_chat(target_mob, span_warning("You have periodic player tips enabled. You may turn them off at any time with the Toggle Receiving Player Tips verb in Preferences, or in character set up under the OOC tab!\nPlayer tips appear every 45-75 minutes.")) HasReceived.Add(target_mob.key) to_chat(target_mob, span_notice("[GLOB.is_valid_url.Replace(last_tip, span_linkify("$1"))]")) diff --git a/tgui/packages/tgui/interfaces/ColorMate/MatrixTabs/ColorMatrixSolver.tsx b/tgui/packages/tgui/interfaces/ColorMate/MatrixTabs/ColorMatrixSolver.tsx index abf9f83284..9732515323 100644 --- a/tgui/packages/tgui/interfaces/ColorMate/MatrixTabs/ColorMatrixSolver.tsx +++ b/tgui/packages/tgui/interfaces/ColorMate/MatrixTabs/ColorMatrixSolver.tsx @@ -2,13 +2,7 @@ import { useBackend } from 'tgui/backend'; import { Box, Button, Input, Section, Stack } from 'tgui-core/components'; import { computeMatrixFromPairs, isValidHex } from '../functions'; import { ColorMatrixColorBox } from '../Helpers/MatrixColorBox'; -import type { - ColorPair, - ColorUpdate, - Data, - MatrixColors, - SelectedId, -} from '../types'; +import type { ColorPair, ColorUpdate, Data, SelectedId } from '../types'; export const ColorMateMatrixSolver = (props: { activeID: SelectedId; @@ -51,28 +45,19 @@ export const ColorMateMatrixSolver = (props: { try { const matrix = computeMatrixFromPairs(colorPairs); - const newMatrixcolors: MatrixColors = { - rr: matrix[0][0], - rg: matrix[0][1], - rb: matrix[0][2], + const parts: number[] = []; - gr: matrix[1][0], - gg: matrix[1][1], - gb: matrix[1][2], + for (let col = 0; col < 3; col++) { + for (let row = 0; row < 3; row++) { + parts.push(Math.round(matrix[row][col] * 100) / 100); + } + } - br: matrix[2][0], - bg: matrix[2][1], - bb: matrix[2][2], - - cr: matrix[0][3], - cg: matrix[1][3], - cb: matrix[2][3], - }; - - const ourMatrix = Object.values(newMatrixcolors) - .map((v) => v.toFixed(2)) - .toString(); + for (let row = 0; row < 3; row++) { + parts.push(Math.round(matrix[row][3] * 100) / 100); + } + const ourMatrix = parts.toString(); act('set_matrix_string', { value: ourMatrix }); } catch (err) { console.log(`Matrix computation failed: ${err.message}`); @@ -122,7 +107,35 @@ export const ColorMateMatrixSolver = (props: { /> - {`==>`} +