This repository was archived by the owner on Dec 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
76 lines (64 loc) · 1.31 KB
/
Copy pathmain.cpp
File metadata and controls
76 lines (64 loc) · 1.31 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <misc/glad.h>
#include <GLFW/glfw3.h>
#include <core/Engine.h>
#include <graphics/Shader.h>
#include <csignal>
#include <cstdlib>
#include <iostream>
#ifdef MULTIPLAYER
#include <core/SharedGlobals.h>
#include <multiplayer/AWS.h>
#include <multiplayer/MM.h>
#endif
void signal_handler(int signal)
{
std::cerr << "Caught signal " << signal << ", executing cleanup.\n";
#ifdef MULTIPLAYER
AWS::signout();
#endif
std::exit(EXIT_FAILURE);
}
void setup_signal_handlers()
{
const int signals[] = { SIGINT, SIGTERM, SIGILL,
SIGABRT, SIGFPE, SIGPIPE };
for (int sig : signals) {
std::signal(sig, signal_handler);
}
}
int main(int argc, char const *argv[])
{
setup_signal_handlers();
#ifdef MULTIPLAYER
MatchMaking &MM = MatchMaking::get_instance();
if (MM.init(argc, argv)) {
return EXIT_FAILURE;
}
MM.match_making();
while (MM.is_handshaking() && MM.is_success())
std::this_thread::sleep_for(std::chrono::milliseconds(5));
if (MM.is_success()) {
#endif
glfwInit();
Engine engine;
engine.start();
glfwTerminate();
#ifdef MULTIPLAYER
}
switch (MM.get_match_outcome()) {
case -1:
std::cout << "Match cancelled\n";
break;
case 1:
std::cout << "Player 1 won\n";
break;
case 2:
std::cout << "Player 2 won\n";
break;
default:
break;
}
AWS::signout();
#endif
return EXIT_SUCCESS;
}