Skip to content

Commit 74459d3

Browse files
committed
refactor: clean some code
1 parent a2f8298 commit 74459d3

File tree

4 files changed

+3
-65
lines changed

4 files changed

+3
-65
lines changed

src/legacy/api/RemoteCallAPI.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#include "RemoteCallAPI.h"
2-
1+
#include "api/APIHelp.h"
32
#include "api/BaseAPI.h"
43
#include "api/BlockAPI.h"
54
#include "api/BlockEntityAPI.h"
@@ -17,10 +16,9 @@
1716
#include <RemoteCallAPI.h>
1817
#include <map>
1918
#include <process.h>
20-
#include <sstream>
2119
#include <string>
2220

23-
#define DEFAULT_REMOTE_CALL_NAME_SPACE "LLSEGlobal"
21+
const std::string DEFAULT_REMOTE_CALL_NAME_SPACE = "LLSEGlobal";
2422

2523
//////////////////// Remote Call ////////////////////
2624

src/legacy/api/RemoteCallAPI.h

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/legacy/engine/MessageSystem.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ using namespace script;
2929
//////////////////// 消息处理注册 ////////////////////
3030

3131
#include "engine/RemoteCall.h"
32-
#include "engine/TimeTaskSystem.h"
3332

3433
void ModuleMessage::handle(utils::Message& engineMsg) // Warning: Execute in another thread
3534
{

src/legacy/main/PythonHelper.cpp

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44

55
#include "Global.h"
66
#include "engine/EngineManager.h"
7-
#include "engine/EngineOwnData.h"
87
#include "engine/RemoteCall.h"
98
#include "legacy/api/CommandAPI.h"
10-
#include "legacy/api/CommandCompatibleAPI.h"
11-
#include "legacy/api/EventAPI.h"
129
#include "ll/api/utils/StringUtils.h"
1310
#include "lse/Entry.h"
1411
#include "utils/Utils.h"
@@ -18,7 +15,7 @@
1815
#include <filesystem>
1916
#include <toml.h>
2017

21-
#define PIP_EXECUTE_TIMEOUT 1800 * 1000
18+
const unsigned long PIP_EXECUTE_TIMEOUT = 1800 * 1000;
2219

2320
// pre-declare
2421
extern void BindAPIs(ScriptEngine* engine);
@@ -259,60 +256,6 @@ int executePipCommand(std::string cmd) {
259256
return exitCode;
260257
}
261258

262-
// This fix is used for Python3.10's bug:
263-
// The thread will freeze when creating a new engine while another thread is
264-
// blocking to read stdin Side effects: sys.stdin cannot be used after this
265-
// patch. More info to see: https://github.com/python/cpython/issues/83526
266-
//
267-
// Attention! When CPython is upgraded, this fix must be re-adapted or removed!!
268-
//
269-
// namespace FixPython310Stdin {
270-
// // Hard coded function address
271-
// const uintptr_t create_stdio_func_base_offset = 0xCE0F4;
272-
273-
// create_stdio_func_type create_stdio_original = nullptr;
274-
275-
// PyObject* create_stdio_hooked(
276-
// const PyConfig* config,
277-
// PyObject* io,
278-
// int fd,
279-
// int write_mode,
280-
// const char* name,
281-
// const wchar_t* encoding,
282-
// const wchar_t* errors
283-
// ) {
284-
// if (fd == 0) {
285-
// Py_RETURN_NONE;
286-
// }
287-
// return create_stdio_original(config, io, fd, write_mode, name, encoding, errors);
288-
// }
289-
290-
// bool patchPython310CreateStdio() {
291-
// if (create_stdio_original == nullptr) {
292-
// HMODULE hModule = GetModuleHandleW(L"python310.dll");
293-
// if (hModule == NULL) return false;
294-
// create_stdio_original = (create_stdio_func_type)(void*)(((uintptr_t)hModule) +
295-
// create_stdio_func_base_offset);
296-
// }
297-
298-
// DetourRestoreAfterWith();
299-
// if (DetourTransactionBegin() != NO_ERROR) return false;
300-
// else if (DetourUpdateThread(GetCurrentThread()) != NO_ERROR) return false;
301-
// else if (DetourAttach((PVOID*)&create_stdio_original, create_stdio_hooked) != NO_ERROR) return false;
302-
// else if (DetourTransactionCommit() != NO_ERROR) return false;
303-
// return true;
304-
// }
305-
306-
// bool unpatchPython310CreateStdio() {
307-
// if (DetourTransactionBegin() != NO_ERROR) return false;
308-
// else if (DetourUpdateThread(GetCurrentThread()) != NO_ERROR) return false;
309-
// else if (DetourDetach((PVOID*)&create_stdio_original, create_stdio_hooked) != NO_ERROR) return false;
310-
// else if (DetourTransactionCommit() != NO_ERROR) return false;
311-
// return true;
312-
// }
313-
314-
// } // namespace FixPython310Stdin
315-
316259
} // namespace PythonHelper
317260

318261
#endif

0 commit comments

Comments
 (0)