From 81e134340af4b1cd06f2cacc76334fceeca5de4b Mon Sep 17 00:00:00 2001 From: lilacLunatic <8488221+lilacLunatic@users.noreply.github.com> Date: Thu, 20 Mar 2025 12:15:02 -0300 Subject: [PATCH] Support an init script for SoH console commands --- soh/soh/Enhancements/shiprc.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 soh/soh/Enhancements/shiprc.cpp diff --git a/soh/soh/Enhancements/shiprc.cpp b/soh/soh/Enhancements/shiprc.cpp new file mode 100644 index 000000000..d0fbe8c50 --- /dev/null +++ b/soh/soh/Enhancements/shiprc.cpp @@ -0,0 +1,23 @@ +#include +#include "soh/ShipInit.hpp" +#include +#include +#include + +void Shiprc() { + std::shared_ptr context = Ship::Context::GetInstance(); + auto console = context->GetConsole(); + std::string path = context->GetPathRelativeToAppDirectory(".shiprc"); + std::string line; + std::string output; + + std::fstream fileShiprc(path); + if (fileShiprc.is_open()) { + while (std::getline(fileShiprc, line)) { + int32_t commandResult = console->Run(line, &output); + } + } + fileShiprc.close(); +} + +static RegisterShipInitFunc initFunc(Shiprc, {});