Skip to content
This repository was archived by the owner on Jan 1, 2025. It is now read-only.

Commit fdf5e1b

Browse files
committed
Add proper console logging for py commands
1 parent b97dce6 commit fdf5e1b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

bl2-sdk/CPythonInterface.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ bool PythonGCTick(UObject* caller, UFunction* function, void* parms, void* resul
9595
return true;
9696
}
9797

98+
void AddToConsoleLog(UConsole *console, FString input) {
99+
for (int x = 0; x < 16; x++)
100+
if (!strcmp(console->History[x].AsString(), input.AsString()))
101+
return;
102+
console->History[console->HistoryTop] = input;
103+
console->HistoryTop = (console->HistoryTop + 1) % 16;
104+
console->HistoryBot = (console->HistoryBot + 1) % 16;
105+
console->HistoryCur = console->HistoryTop;
106+
}
107+
98108
bool CheckPythonCommand(UObject* caller, FFrame& stack, void* const result, UFunction* function)
99109
{
100110
FString *command = &FString();
@@ -104,12 +114,14 @@ bool CheckPythonCommand(UObject* caller, FFrame& stack, void* const result, UFun
104114
if (strncmp("py ", input, 3) == 0) {
105115
Logging::LogF("\n>>> %s <<<\n", input);
106116
BL2SDK::Python->DoString(input + 3);
117+
AddToConsoleLog((UConsole *)caller, *command);
107118
stack.SkipFunction();
108119
return false;
109120
}
110121
else if (strncmp("pyexec ", input, 7) == 0) {
111122
Logging::LogF("\n>>> %s <<<\n", input);
112123
BL2SDK::Python->DoFile(input + 7);
124+
AddToConsoleLog((UConsole *)caller, *command);
113125
stack.SkipFunction();
114126
return false;
115127
}

0 commit comments

Comments
 (0)