| 748 | s_console.scrollback.begin() + (s_console.scrollback.size() - 200)); |
| 749 | } |
| 750 | |
| 751 | void ConsoleRun(std::string_view line) |
| 752 | { |
| 753 | while (!line.empty() && (line.front() == ' ' || line.front() == '\t')) |
| 754 | line.remove_prefix(1); |
| 755 | if (line.empty()) |
| 756 | return; |
| 757 | ConsoleAppend(std::string("> ") + std::string(line)); |
| 758 | |
| 759 | const bool forceSqf = !line.empty() && line.front() == ':'; |
| 760 | if (forceSqf) |
| 761 | line.remove_prefix(1); |
| 762 | |
| 763 | if (!forceSqf) |
| 764 | { |
| 765 | std::string out; |
| 766 | if (DebugCommands::Run(line, out)) |
| 767 | { |
| 768 | if (!out.empty()) |
| 769 | ConsoleAppend(out); |
| 770 | return; |
| 771 | } |
| 772 | } |
| 773 | |
| 774 | // SQF path. Mirrors the Evaluator/express.hpp idiom — runs in the |
| 775 | // current game state's evaluation context. No-op + error log when |
| 776 | // no world is up (e.g. main-menu, before mission load). |
| 777 | if (!GWorld || !GWorld->GetGameState()) |
| 778 | { |
| 779 | ConsoleAppend("(no game state — SQF unavailable here)"); |
| 780 | return; |
| 781 | } |
| 782 | GameValue result = GWorld->GetGameState()->EvaluateMultiple(std::string(line).c_str()); |
| 783 | if (result.GetType() != GameNothing) |
| 784 | ConsoleAppend(std::string("= ") + (const char*)result.GetText()); |
| 785 | } |
| 786 | } // namespace |
| 787 |
no test coverage detected