Skip to content

Commit f093d13

Browse files
committedMar 27, 2020
fix: amend shv declarations
1 parent 71eb22d commit f093d13

File tree

5 files changed

+33
-25
lines changed

5 files changed

+33
-25
lines changed
 

‎include/nob/dx.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ namespace nob {
6363
}
6464
}
6565

66+
static void WINAPI _shv_handle(void *sc) {
67+
_handle(reinterpret_cast<IDXGISwapChain *>(sc));
68+
}
69+
6670
public:
6771
static void _init();
6872
static void _uninit();

‎src/dx.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace nob {
7676

7777
void on_render::_init() RUA_ONCE_CODE({
7878
if (shv::_init()) {
79-
shv::presentCallbackRegister(reinterpret_cast<void (*)(void *)>(&dx::on_render::_handle));
79+
shv::presentCallbackRegister(&dx::on_render::_shv_handle);
8080
return;
8181
}
8282

@@ -98,7 +98,7 @@ namespace nob {
9898
if (!shv::_init()) {
9999
return;
100100
}
101-
shv::presentCallbackUnregister(reinterpret_cast<void (*)(void *)>(&dx::on_render::_handle));
101+
shv::presentCallbackUnregister(&dx::on_render::_shv_handle);
102102
}
103103
}
104104
}

‎src/main.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace nob {
2121
}
2222

2323
namespace this_script {
24-
void _shv_main();
24+
void WINAPI _shv_main();
2525
bool _create_from_td();
2626
extern std::atomic<bool> _is_exited;
2727
}
@@ -42,7 +42,11 @@ namespace nob {
4242
#define _NOB_CALL_INIT_FN(_f) _f()
4343
#endif
4444

45-
#define _NOB_NEW_TD(_f) CreateThread(nullptr, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(static_cast<void(*)()>( _f )), nullptr, 0, nullptr);
45+
void CALLBACK _td_proc(void *f) {
46+
reinterpret_cast<void(*)()>(f)();
47+
}
48+
49+
#define _NOB_NEW_TD(_f) CreateThread(nullptr, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(&_td_proc), reinterpret_cast<LPVOID>(static_cast<void(*)()>(_f)), 0, nullptr);
4650

4751
void _init() {
4852
ntv::_pre_init();

‎src/script.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ namespace nob {
9898
return true;
9999
}
100100

101-
void _shv_main() {
101+
void WINAPI _shv_main() {
102102
while (_run()) {
103103
shv::WAIT(0);
104104
}

‎src/shv.cpp

+20-20
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,40 @@
66

77
namespace nob {
88
namespace shv {
9-
int (*createTexture)(const char *texFileName);
9+
int (WINAPI *createTexture)(const char *texFileName);
1010

11-
void (*drawTexture)(
11+
void (WINAPI *drawTexture)(
1212
int id, int index, int level, int time,
1313
float sizeX, float sizeY, float centerX, float centerY,
1414
float posX, float posY, float rotation, float screenHeightScaleFactor,
1515
float r, float g, float b, float a
1616
);
1717

18-
void (*presentCallbackRegister)(PresentCallback cb);
19-
void (*presentCallbackUnregister)(PresentCallback cb);
18+
void (WINAPI *presentCallbackRegister)(PresentCallback cb);
19+
void (WINAPI *presentCallbackUnregister)(PresentCallback cb);
2020

21-
void (*keyboardHandlerRegister)(KeyboardHandler handler);
22-
void (*keyboardHandlerUnregister)(KeyboardHandler handler);
21+
void (WINAPI *keyboardHandlerRegister)(KeyboardHandler handler);
22+
void (WINAPI *keyboardHandlerUnregister)(KeyboardHandler handler);
2323

24-
void (*scriptWait)(DWORD time);
25-
void (*scriptRegister)(HMODULE module, void(*LP_SCRIPT_MAIN)());
26-
void (*scriptRegisterAdditionalThread)(HMODULE module, void(*LP_SCRIPT_MAIN)());
27-
void (*scriptUnregister)(HMODULE module);
24+
void (WINAPI *scriptWait)(DWORD time);
25+
void (WINAPI *scriptRegister)(HMODULE module, void(WINAPI *LP_SCRIPT_MAIN)());
26+
void (WINAPI *scriptRegisterAdditionalThread)(HMODULE module, void(WINAPI *LP_SCRIPT_MAIN)());
27+
void (WINAPI *scriptUnregister)(HMODULE module);
2828

29-
void (*nativeInit)(UINT64 hash);
30-
void (*nativePush64)(UINT64 val);
31-
PUINT64 (*nativeCall)();
29+
void (WINAPI *nativeInit)(UINT64 hash);
30+
void (WINAPI *nativePush64)(UINT64 val);
31+
PUINT64 (WINAPI *nativeCall)();
3232

33-
UINT64 *(*getGlobalPtr)(int globalId);
33+
UINT64 *(WINAPI *getGlobalPtr)(int globalId);
3434

35-
int (*worldGetAllVehicles)(int *arr, int arrSize);
36-
int (*worldGetAllPeds)(int *arr, int arrSize);
37-
int (*worldGetAllObjects)(int *arr, int arrSize);
38-
int (*worldGetAllPickups)(int *arr, int arrSize);
35+
int (WINAPI *worldGetAllVehicles)(int *arr, int arrSize);
36+
int (WINAPI *worldGetAllPeds)(int *arr, int arrSize);
37+
int (WINAPI *worldGetAllObjects)(int *arr, int arrSize);
38+
int (WINAPI *worldGetAllPickups)(int *arr, int arrSize);
3939

40-
BYTE *(*getScriptHandleBaseAddress)(int handle);
40+
BYTE *(WINAPI *getScriptHandleBaseAddress)(int handle);
4141

42-
eGameVersion (*getGameVersion)();
42+
eGameVersion (WINAPI *getGameVersion)();
4343

4444
constexpr const std::array<LPCWSTR, 2> _module_names {{
4545
L"ScriptHookV.dll",

0 commit comments

Comments
 (0)
Please sign in to comment.