mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-14 02:27:21 -07:00
Support an init script for SoH console commands
This commit is contained in:
parent
f02032aed4
commit
81e134340a
1 changed files with 23 additions and 0 deletions
23
soh/soh/Enhancements/shiprc.cpp
Normal file
23
soh/soh/Enhancements/shiprc.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <Context.h>
|
||||
#include "soh/ShipInit.hpp"
|
||||
#include <libultraship/libultraship.h>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
void Shiprc() {
|
||||
std::shared_ptr<Ship::Context> 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, {});
|
Loading…
Add table
Add a link
Reference in a new issue