2023-09-03 02:01:32 -04:00
|
|
|
|
|
|
|
|
#include "LockedWrapper.h"
|
2023-09-04 03:27:31 -04:00
|
|
|
#include "DebugPrint.h"
|
2023-09-05 03:20:11 -04:00
|
|
|
#include "drvutil.hpp"
|
2023-09-03 02:01:32 -04:00
|
|
|
|
|
|
|
|
void FLockedWrapper::InitWrapper() {
|
|
|
|
|
if (Lockable.Wrapper.play_initialize != nullptr) {
|
|
|
|
|
// Already initialized.
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
void* DLL = FPlatformProcess::GetDllHandle(TEXT("c:\\Luprex\\build\\visual\\luprexlib.dll"));
|
|
|
|
|
if (DLL != nullptr) {
|
|
|
|
|
using InitFn = void (*)(EngineWrapper*);
|
|
|
|
|
InitFn init = (InitFn)FPlatformProcess::GetDllExport(DLL, TEXT("init_engine_wrapper"));
|
|
|
|
|
if (init != nullptr) {
|
|
|
|
|
init(&Lockable.Wrapper);
|
2023-09-04 03:21:23 -04:00
|
|
|
Lockable.Wrapper.hook_dprint(DebugPrint::DPrint);
|
2023-09-03 02:01:32 -04:00
|
|
|
}
|
|
|
|
|
}
|
2023-09-05 03:20:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FString FLockedWrapper::FetchStdout() {
|
|
|
|
|
uint32_t ndata; const char* data;
|
|
|
|
|
Lockable.Wrapper.get_outgoing(Get(), 0, &ndata, &data);
|
|
|
|
|
|
|
|
|
|
if (ndata == 0) {
|
|
|
|
|
return FString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string_view src(data, ndata);
|
|
|
|
|
int consumed;
|
|
|
|
|
std::u16string cps = drvutil::utf8_to_ucs2(src, &consumed);
|
|
|
|
|
Lockable.Wrapper.play_sent_outgoing(Get(), 0, consumed);
|
|
|
|
|
return FString(cps.size(), (const UCS2CHAR*)(&cps[0]));
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-06 23:25:37 -04:00
|
|
|
int64 FLockedWrapper::GetActor() {
|
|
|
|
|
return Lockable.Wrapper.get_actor_id(Get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FLockedWrapper::IdList FLockedWrapper::GetNear(int64 id, double rx, double ry, double rz) {
|
|
|
|
|
uint32 size;
|
|
|
|
|
int64* data;
|
|
|
|
|
Lockable.Wrapper.get_tangibles_near(Get(), id, rx, ry, rz, &size, &data);
|
|
|
|
|
return IdList(data, size);
|
|
|
|
|
}
|