forked from sashavol/Frozlunky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
58 lines (49 loc) · 1.26 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#define WINVER 0x05010000
#define _WIN32_WINNT 0x05010000
#include "winheaders.h"
#include "netplay_connection.h"
#include <string>
#include <memory>
#include <iostream>
#include <iomanip>
#include "gui.h"
#include "spelunky.h"
#include "debug.h"
#include <memory>
#include <curl/curl.h>
#ifndef DEBUG_MODE
int CALLBACK WinMain(
_In_ HINSTANCE hInstance,
_In_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow
)
#else
int main()
#endif
{
curl_global_init(CURL_GLOBAL_ALL);
atexit([]() {
NetplayConnection::Deinitialize();
undo_patches();
});
NetplayConnection::Initialize();
_set_abort_behavior(0, _WRITE_ABORT_MSG);
_set_abort_behavior(0, _CALL_REPORTFAULT);
std::shared_ptr<Spelunky> spelunky = Spelunky::GetDefaultSpelunky();
if(spelunky != nullptr) {
#ifdef DEBUG_MODE
int val = gui_operate(spelunky, nullptr);
#else
int val = gui_operate(spelunky, (char*)LoadIcon(hInstance, MAKEINTRESOURCE(101)));
#endif
undo_patches();
curl_global_cleanup();
return val;
}
else {
MessageBox(NULL, "Spelunky is not running, please start it and then launch Frozlunky. (Did you start Frozlunky as an Administrator?)", "Frozlunky", MB_OK);
curl_global_cleanup();
return 0;
}
}