Files
Joshua KidderandGitHub 7a3ad79506 All camelCase (Brute|Burn|Fire|Tox|Oxy|Organ|Stamina)(Loss) procs now use snake_case. UNDERSCORES RULE! (#94111)
## About The Pull Request
It's just a partial cleanup of
anti-[STYLE](https://github.com/tgstation/tgstation/blob/master/.github/guides/STYLE.md)
code from /tg/'s ancient history. I compiled & tested with my helpful
assistant and damage is still working.

<img width="1920" height="1040" alt="image"
src="https://github.com/user-attachments/assets/26dabc17-088f-4008-b299-3ff4c27142c3"
/>


I'll upload the .cs script I used to do it shortly.

## Why It's Good For The Game
Just minor code cleanup.

Script used is located at https://metek.tech/camelTo-Snake.7z

EDIT 11/23/25: Updated the script to use multithreading and sequential
scan so it works a hell of a lot faster
```
/*
//
Copyright 2025 Joshua 'Joan Metekillot' Kidder

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
//
*/
using System.Text.RegularExpressions;
class Program
{
    static async Task Main(string[] args)
    {
        var readFile = new FileStreamOptions
        {
            Access = FileAccess.Read,
            Share = FileShare.ReadWrite,
            Options = FileOptions.Asynchronous | FileOptions.SequentialScan
        };
        FileStreamOptions writeFile = new FileStreamOptions
        {
            Share = FileShare.ReadWrite,
            Access = FileAccess.ReadWrite,
            Mode = FileMode.Truncate,
            Options = FileOptions.Asynchronous
        };
        RegexOptions regexOptions = RegexOptions.Multiline | RegexOptions.Compiled;
        Dictionary<string, int> changedProcs = new();
        string regexPattern = @"(?<=\P{L})([a-z]+)([A-Z]{1,2}[a-z]+)*(Brute|Burn|Fire|Tox|Oxy|Organ|Stamina)(Loss)([A-Z]{1,2}[a-z]+)*";
        Regex camelCaseProcRegex = new(regexPattern, regexOptions);

        string snakeify(Match matchingRegex)
        {
            var vals =
            matchingRegex.Groups.Cast<Group>().SelectMany(_ => _.Captures).Select(_ => _.Value).ToArray();
            var newVal = string.Join("_", vals.Skip(1).ToArray()).ToLower();
            string logString = $"{vals[0]} => {newVal}";
            if (changedProcs.TryGetValue(logString, out int value))
            {
                changedProcs[logString] = value + 1;
            }
            else
            {
                changedProcs.Add(logString, 1);
            }
            return newVal;
        }
        var dmFiles = Directory.EnumerateFiles(".", "*.dm", SearchOption.AllDirectories).ToAsyncEnumerable<string>();

        // uses default ParallelOptions
        // https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.paralleloptions?view=net-10.0#main
        await Parallel.ForEachAsync(dmFiles, async (filePath, UnusedCancellationToken) =>
        {
            var reader = new StreamReader(filePath, readFile);
            string oldContent = await reader.ReadToEndAsync();
            string newContent = camelCaseProcRegex.Replace(oldContent, new MatchEvaluator((Func<Match, string>)snakeify));
            if (oldContent != newContent)
            {
                var writer = new StreamWriter(filePath, writeFile);
                await writer.WriteAsync(newContent);
                await writer.DisposeAsync();
            }
            reader.Dispose();
        });
        var logToList = changedProcs.Cast<KeyValuePair<string, int>>().ToList();
        foreach (var pair in logToList)
        {
            Console.WriteLine($"{pair.Key}: {pair.Value} locations");
        }
    }
}

```

## Changelog
🆑 Bisar
code: All (Brute|Burn|Fire|Tox|Oxy|Organ|Stamina)(Loss) procs now use
snake_case, in-line with the STYLE guide. Underscores rule!
/🆑
2025-11-27 15:50:23 -05:00

146 lines
4.8 KiB
Plaintext

/obj/machinery/computer/aifixer
name = "\improper AI system integrity restorer"
desc = "Used with intelliCards containing nonfunctional AIs to restore them to working order."
req_access = list(ACCESS_CAPTAIN, ACCESS_ROBOTICS, ACCESS_COMMAND)
circuit = /obj/item/circuitboard/computer/aifixer
icon_keyboard = "tech_key"
icon_screen = "ai-fixer"
light_color = LIGHT_COLOR_PINK
/// Variable containing transferred AI
var/mob/living/silicon/ai/occupier
/// Variable dictating if we are in the process of restoring the occupier AI
var/restoring = FALSE
/obj/machinery/computer/aifixer/screwdriver_act(mob/living/user, obj/item/I)
if(occupier)
if(machine_stat & (NOPOWER|BROKEN))
to_chat(user, span_warning("The screws on [name]'s screen won't budge."))
else
to_chat(user, span_warning("The screws on [name]'s screen won't budge and it emits a warning beep."))
else
return ..()
/obj/machinery/computer/aifixer/ui_interact(mob/user, datum/tgui/ui)
. = ..()
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "AiRestorer", name)
ui.open()
/obj/machinery/computer/aifixer/ui_data(mob/user)
var/list/data = list()
data["ejectable"] = FALSE
data["AI_present"] = FALSE
data["error"] = null
if(!occupier)
data["error"] = "Please transfer an AI unit."
else
data["AI_present"] = TRUE
data["name"] = occupier.name
data["restoring"] = restoring
data["health"] = (occupier.health + 100) / 2
data["isDead"] = occupier.stat == DEAD
data["laws"] = occupier.laws.get_law_list(include_zeroth = TRUE, render_html = FALSE)
return data
/obj/machinery/computer/aifixer/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(.)
return
if(!occupier)
restoring = FALSE
switch(action)
if("PRG_beginReconstruction")
if(occupier?.health < 100)
to_chat(usr, span_notice("Reconstruction in progress. This will take several minutes."))
playsound(src, 'sound/machines/terminal/terminal_prompt_confirm.ogg', 25, FALSE)
restoring = TRUE
occupier.notify_revival("Your core files are being restored!", source = src)
. = TRUE
/obj/machinery/computer/aifixer/proc/Fix()
if(!use_energy(active_power_usage, force = TRUE))
say("Not enough energy. Restoration cancelled.")
return FALSE
var/need_mob_update = FALSE
need_mob_update += occupier.adjust_oxy_loss(-5, updating_health = FALSE)
need_mob_update += occupier.adjust_fire_loss(-5, updating_health = FALSE)
need_mob_update += occupier.adjust_brute_loss(-5, updating_health = FALSE)
if(need_mob_update)
occupier.updatehealth()
if(occupier.health >= 0 && occupier.stat == DEAD)
occupier.revive()
if(!occupier.radio_enabled)
occupier.radio_enabled = TRUE
to_chat(occupier, span_warning("Your Subspace Transceiver has been enabled!"))
return occupier.health < 100
/obj/machinery/computer/aifixer/process()
if(..())
if(restoring)
var/oldstat = occupier.stat
restoring = Fix()
if(oldstat != occupier.stat)
update_appearance()
/obj/machinery/computer/aifixer/update_overlays()
. = ..()
if(machine_stat & (NOPOWER|BROKEN))
return
if(restoring)
. += "ai-fixer-on"
if(!occupier)
. += "ai-fixer-empty"
return
switch(occupier.stat)
if(CONSCIOUS)
. += "ai-fixer-full"
if(UNCONSCIOUS, HARD_CRIT)
. += "ai-fixer-404"
/obj/machinery/computer/aifixer/transfer_ai(interaction, mob/user, mob/living/silicon/ai/AI, obj/item/aicard/card)
if(!..())
return
//Downloading AI from card to terminal.
if(interaction == AI_TRANS_FROM_CARD)
if(machine_stat & (NOPOWER|BROKEN))
to_chat(user, span_alert("[src] is offline and cannot take an AI at this time."))
return
AI.forceMove(src)
occupier = AI
AI.set_control_disabled(TRUE)
AI.radio_enabled = FALSE
to_chat(AI, span_alert("You have been uploaded to a stationary terminal. Sadly, there is no remote access from here."))
to_chat(user, "[span_notice("Transfer successful")]: [AI.name] ([rand(1000,9999)].exe) installed and executed successfully. Local copy has been removed.")
card.AI = null
update_appearance()
else //Uploading AI from terminal to card
if(occupier && !restoring)
to_chat(occupier, span_notice("You have been downloaded to a mobile storage device. Still no remote access."))
to_chat(user, "[span_notice("Transfer successful")]: [occupier.name] ([rand(1000,9999)].exe) removed from host terminal and stored within local memory.")
occupier.forceMove(card)
card.AI = occupier
occupier = null
update_appearance()
else if (restoring)
to_chat(user, span_alert("ERROR: Reconstruction in progress."))
else if (!occupier)
to_chat(user, span_alert("ERROR: Unable to locate artificial intelligence."))
/obj/machinery/computer/aifixer/Destroy()
if(occupier)
QDEL_NULL(occupier)
return ..()
/obj/machinery/computer/aifixer/on_deconstruction(disassembled)
if(occupier)
QDEL_NULL(occupier)