-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain2.cpp
65 lines (55 loc) · 1.14 KB
/
main2.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
59
60
61
62
63
64
65
#include <cstdlib>
#include <iostream>
#include <string>
#include <unistd.h>
#include "m_exceptions.h"
#include "log.h"
extern void parse_args(int argc, char* argv[]);
extern void on_exit();
extern void run_init(const char*);
extern void run_main();
int global_EC = 0;
int global_Done = 0;
int global_Restart = 0;
#ifndef DONT_CATCH
bool catch_exceptions = true;
#else
bool catch_exceptions = false;
#endif
using namespace std;
int main(int argc, char* argv[]) {
if (argc > 1)
parse_args(argc, argv);
atexit(on_exit);
if (!catch_exceptions)
INFO << "ignoring exceptions" << std::endl;
if (!catch_exceptions)
run_init(argv[0]);
else {
try {
run_init(argv[0]);
}
catch (Exception & e) {
ERROR << "Exception during startup: " << e.what() << endl;
global_EC = 1;
exit(1);
}
}
if (!catch_exceptions)
run_main();
else {
try {
run_main();
}
catch (const Exception & e) {
ERROR << "Exception during game: " << e.what() << endl;
global_EC = 1;
exit(1);
}
}
if (global_Restart) {
on_exit();
execvp(argv[0], argv);
}
std::exit(0);
}